From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.48 as permitted sender) client-ip=209.85.128.48; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f48.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362605; cv=none; d=zohomail.com; s=zohoarc; b=BRtfEZy0hbydYIpsc/Yy8HaKHkKZpLoiR0UWGHqDazJR/WfxKTLDjjncVKY3rZjjuau04qv6ePLm9WN/1QKojNHfNkcV8p8NikyagtAgC49Onu4TT3XgF2gEh349PxY80I7iUyd0cB8He0sz6trZnvZHwIvtQmvnda64FyInuZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362605; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gETh5/Gck0bTQVP31ZR4AiV0ecmQtPxoBf6GwvczWOs=; b=TdBYKk+AAo8LLXVB7/aTwebWB77C1ZOn7tBzWSs2LpGFOpYMhvi7ThDpIqgGVVXIcu3/4MgQGlDK4ek2TbWs403Uy4JI6+FJp55UusuWZWQmZDQUfF7ygLzRBk0evbBEDStd+x2snQFZ4Ai9BgkLWBXQuoDRPi00C3OIMR7AMkE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mx.zohomail.com with SMTPS id 1602362605169646.8275351354647; Sat, 10 Oct 2020 13:43:25 -0700 (PDT) Received: by mail-wm1-f48.google.com with SMTP id b127so449922wmb.3 for ; Sat, 10 Oct 2020 13:43:24 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gETh5/Gck0bTQVP31ZR4AiV0ecmQtPxoBf6GwvczWOs=; b=dn3QruZ0BeBNyJD7SOaGy2t1UJ/cXhGnwfkMltxP/mVqV4wNuHAYc8lIPlK+euxoHD 4BBfJ8IxFIk+f+7IKZyQccNDqb5U7NLfznVhWtZ8svJ8tXfYcK77cLa3ma9aK6HCCh72 t0UU7hv016N8lEO1Ls9JKvX7D5oZLJW58wLiawd3aWufvLOe9/mp+0BhW+Hd3MqQmQmi hC4BHdNdkzVTtL3ynCuMjNuIjWDI/cH9nOKfHRoj2VWif8/P+I0PvdR8t8xc6lyGq5Ii vFvJ5VxvyWakt3pP/y+0TLPsAA+Ik7kzVgGtXulO7EbUIlO87ERa/4yOa6qfBW0+dwWa 2yBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=gETh5/Gck0bTQVP31ZR4AiV0ecmQtPxoBf6GwvczWOs=; b=Gwofn8vma1w0HA1I7W5NmmnykSiDp6+fQichG1CwhVf3DLMhqjJfR5cTWzcJmD1Btv REu3BNTt5PhBNHkpQHCHQagXsAoF2eyDEoG3nRvox2BMiVr28zVYV10suV8/26ZWQb+l dH4wuPzF8LVR8JwVmjD5XISlWXCH/YSH3shylDrc3LlJypqfzZdMZSRuJwzAyyQMNTW4 8No5N62HEqFw96tRYjpHAfb2WGzZsQhfeFeAralxQ79x8NSlAi3XZZWi/JrCiJ4mYCVJ F1qECkD4Q4c4sFnjMrWDgj9iq5ewYICPAWEhTD/uyjWA0YQolmK/H+xpctRx9nZEITfq FAIQ== X-Gm-Message-State: AOAM533N6xCtICEnMw5SJbsWWPqj5qdHLjZ1B4s9ZWm0o40lNNxEhR44 FWWYIC+SoqjflnW7WLxeNeg= X-Google-Smtp-Source: ABdhPJwONZG/wcNaPy7XJYsbn0kuTCN4JQ/K/BQXQZ3Vj9543IOt8b8KF6DXV2VDfNXS1N5zdqQhZw== X-Received: by 2002:a1c:b388:: with SMTP id c130mr3963908wmf.175.1602362603126; Sat, 10 Oct 2020 13:43:23 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang , Alistair Francis Subject: [PATCH v3 01/20] util/cutils: Introduce freq_to_str() to display Hertz units Date: Sat, 10 Oct 2020 22:43:00 +0200 Message-Id: <20201010204319.3119239-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Introduce freq_to_str() to convert frequency values in human friendly units using the SI units for Hertz. Suggested-by: Luc Michel Reviewed-by: Alistair Francis Reviewed-by: Luc Michel Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/cutils.h | 12 ++++++++++++ util/cutils.c | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 3a86ec0321e..4bbf4834ea5 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -158,6 +158,18 @@ int qemu_strtosz_metric(const char *nptr, const char *= *end, uint64_t *result); =20 char *size_to_str(uint64_t val); =20 +/** + * freq_to_str: + * @freq_hz: frequency to stringify + * + * Return human readable string for frequency @freq_hz. + * Use SI units like KHz, MHz, and so forth. + * + * The caller is responsible for releasing the value returned + * with g_free() after use. + */ +char *freq_to_str(uint64_t freq_hz); + /* used to print char* safely */ #define STR_OR_NULL(str) ((str) ? (str) : "null") =20 diff --git a/util/cutils.c b/util/cutils.c index 8da34e04b0b..be4e43a9eff 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -885,6 +885,20 @@ char *size_to_str(uint64_t val) return g_strdup_printf("%0.3g %sB", (double)val / div, suffixes[i]); } =20 +char *freq_to_str(uint64_t freq_hz) +{ + static const char *const suffixes[] =3D { "", "K", "M", "G", "T", "P",= "E" }; + double freq =3D freq_hz; + size_t idx =3D 0; + + while (freq >=3D 1000.0 && idx < ARRAY_SIZE(suffixes)) { + freq /=3D 1000.0; + idx++; + } + + return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]); +} + int qemu_pstrcmp0(const char **str1, const char **str2) { return g_strcmp0(*str1, *str2); --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) client-ip=209.85.221.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602362606; cv=none; d=zohomail.com; s=zohoarc; b=Dkj3W4OhS9Pq5qefCMbPiv3+8wWjq7AgH41NRGOiYfTHWv54Onez2/4Pf1bopH34LyOdH/HqnGVbTFyiBjTiwNf8hT34vqOGW4fxEiMhKtSJNUjKtfAFNVgaphld+yWb9H7k3OeJLQtx01RbYVVU07tEFyYEyBVb6UvceF2aL+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362606; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PwcUcNfmDXAXz3ZdCfHv1ZWyP4lS5DeJuKN8TDRFEM0=; b=Kgoa0SSPJnvl1vibEOm+XEZpn6TG8994aO7W1EgB/eN3T3ooGbvdFloPsLNiOhk3qlaH5Z8ctmpI3Ru0BRyEzxnm0QXCWh0LKbhAAV7xGduWGCt4OcA7btCD9FUA4eh87WCrRJMA43ov/n3OlWXj5GF3hMtK9/VTMhpj3kkHsvE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.zohomail.com with SMTPS id 1602362606392714.3236611542219; Sat, 10 Oct 2020 13:43:26 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id h5so4087732wrv.7 for ; Sat, 10 Oct 2020 13:43:25 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PwcUcNfmDXAXz3ZdCfHv1ZWyP4lS5DeJuKN8TDRFEM0=; b=pkYTz2evODSTCIVzNSYqNs/Wu3LRBzHO564YrznUuNnUViWUOgDW9/UTfksKF1Ro6d QGLDUmSxIgT0+1F3FnSV7kbMysQ797Yx0fCwKRwIFCDO6/OKXTS5CY6YPnOUAiZeQjy0 stZvtnoBUqgkBvcbCQHvdNMPu6+avkYfIiN1fO0pNrcEYt2FUxn4FHxqHjbeqtxm9575 ond3xSW1yt0pWiDofywzP71AUR57LPHRdbN7ue19nWqvuSejI6dWZn+a+IdDWYSwJ1Dn gVTJEODm1506TOq0O+gnxg9g6FCgogT05HM47/CSfRMrkX1FGOuhv+/iK3A9K4Mr1OCl HJ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=PwcUcNfmDXAXz3ZdCfHv1ZWyP4lS5DeJuKN8TDRFEM0=; b=Rj7xPhQKMZ/TSD6iOn7EBoflzD/fUzguZQesjXQ8+fjrTGPkr+bovVCjYjdWLlBG/n 8ZrtNrIhSlOFobVVvtuoesstwEUXk07X3E8zW5ItvVmXAWe9dJW8R+eF3ogHOZ+Qkvnb 0wT3LpzoJSa3rL5R03CgDHjdBP8knI5jBa8W0SmUJKULCLZ2rBJpRCkgTkkOZG4ww/c/ sBbFMzodoNxs1ecgu8BJZ6hyYmGoLP9HzokZ9GQzfHGPDJLHPNe0M+BjelSA8j4yezpJ 6+rcUH0QDBKwPT+3C6/FmNlQyeXF2/O4mliU1D0QqfFWOZH2DDMI92IDc9lmGzVTsRSV FknA== X-Gm-Message-State: AOAM531cpCG3xyth8q2K7v2bb3lRTqGL/+L4DbWSv24SwbMrFGux34aX l409QgW3uOrRBN5mVemv300= X-Google-Smtp-Source: ABdhPJyKG18SUJWicNOEnW25JkO1pg40q1XYZSxXkR6vQR9z0ERwE9NcxMfyoKWY5wfiPjaa3w9lWw== X-Received: by 2002:adf:e289:: with SMTP id v9mr21472977wri.14.1602362604458; Sat, 10 Oct 2020 13:43:24 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang , Alistair Francis Subject: [PATCH v3 02/20] qdev-monitor: Display frequencies scaled to SI unit Date: Sat, 10 Oct 2020 22:43:01 +0200 Message-Id: <20201010204319.3119239-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Since commit 9f2ff99c7f2 ("qdev-monitor: print the device's clock with info qtree") we can display the clock frequencies in the monitor. Use the recently introduced freq_to_str() to display the frequencies using the closest SI unit (human friendlier). Before: (qemu) info qtree [...] dev: xilinx,zynq_slcr, id "" clock-in "ps_clk" freq_hz=3D3.333333e+07 mmio 00000000f8000000/0000000000001000 After: dev: xilinx,zynq_slcr, id "" clock-in "ps_clk" freq_hz=3D33.3 MHz mmio 00000000f8000000/0000000000001000 Reviewed-by: Luc Michel Reviewed-by: Damien Hedde Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- qdev-monitor.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index e9b7228480d..a0301cfca81 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -747,11 +747,13 @@ static void qdev_print(Monitor *mon, DeviceState *dev= , int indent) } } QLIST_FOREACH(ncl, &dev->clocks, node) { - qdev_printf("clock-%s%s \"%s\" freq_hz=3D%e\n", + g_autofree char *freq =3D NULL; + + freq =3D freq_to_str(clock_get_hz(ncl->clock)); + qdev_printf("clock-%s%s \"%s\" freq_hz=3D%s\n", ncl->output ? "out" : "in", ncl->alias ? " (alias)" : "", - ncl->name, - CLOCK_PERIOD_TO_HZ(1.0 * clock_get(ncl->clock))); + ncl->name, freq); } class =3D object_get_class(OBJECT(dev)); do { --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) client-ip=209.85.221.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362608; cv=none; d=zohomail.com; s=zohoarc; b=iiRb/62P3xQU08a0goLMddAi6g89tvYx+pYa6EqpKB4zXcudurD3vgjDTz49Erz9CaUbNYo5Mi7RNrX3XF8n36AWfWlMrX5oiBAIoCyvsLUTYGmi5YKHyaHRC8nQiWQEy8j6M4dQARNRYCRiTa+sNTc7TNGR2uOBoB9JWeixjA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362608; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TJh7BI4acX0SbBZ5nZKwJOsX7BWS7AOVMyaKy5mLNnQ=; b=kTvpQ3tEJgZMmfFWb8cTzAVZGfoGTLuK88zH9UQ5UtROh58YgvaOTLz0JecIEuOUS25K5ASmR6AtMPdc5gfhXrYHBVjuGZhIqUumStPWWljeyLNPcacnC9lcLBetFgNEHLya897HebV3J2YXXeSz/yDf5vQQXWLE6UY8BFMkAmM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.zohomail.com with SMTPS id 1602362607823906.0392104201736; Sat, 10 Oct 2020 13:43:27 -0700 (PDT) Received: by mail-wr1-f65.google.com with SMTP id g12so14147894wrp.10 for ; Sat, 10 Oct 2020 13:43:27 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TJh7BI4acX0SbBZ5nZKwJOsX7BWS7AOVMyaKy5mLNnQ=; b=FMfW6z1188lRehRgoD7J5kOTHv4sgzjppDVAeBuxMdzGtD4wyTrIumM0jpUNen61Z0 48LJnR2ulM1RfkHRWKjFCMyFI9A4OA8gV0jXt35azTp0oaTHp8F3WVBrZkBqFnMKj2u0 u1MI+oO+0pOPZ6MsaHu8elE99rx4Swnxti2ftHsbUqLO0M7rdnO9jVr59PM1KS11wC1m kho+2lTQsGVUp9Z6b3Cz+m/+bJFNudU312daWSrQSzhnVEpha8BrHV7UaO9I7PFiq65w GkCPO4VwIGV9D7760F4xVC3vdX5s00gCnJtojsavJdvy8+mnX912g1p4RSnQrTE5aWit QRkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=TJh7BI4acX0SbBZ5nZKwJOsX7BWS7AOVMyaKy5mLNnQ=; b=cT4QWlZnpw5zs0dSvBFHXkBQUNCuNXYCd+RxeTMrBhNS+PsBI0fe2oyU+d2okWj/Bc 2oC4RX/EIBbMM4oYPBLORHR6NU402pUvSBeI3OFbAaFrAdYRqKmgC9TKWGaidJZnHgvT sgY4zN3CCGfTpysOqe9oZKIRwzuY4jnsRyZGqAo3NTv7FfuTIcxo5fvul55wPBqTKD/h ov1pwPoyYFKhjk9YsHbByBziy5gtwkD6XfmfHNSqydGT7QeaZLWYEGrnNoUi5o0InuUL WDU+RLs2I+kj0iPNSGFyFus4RR3YzdX+OGdIwnKnZo/+Y5Y0Y+jz5ylVVw8sVG9eeEBM /5ow== X-Gm-Message-State: AOAM533DXKBx4yaF5OMX9NDA/ckqvA2yWOZis+RxKqSNH/eEFtbkAem5 CGX9Q6OQBJ6j3fslusd3l2Q= X-Google-Smtp-Source: ABdhPJzG5RfvOrjAj977eltUm1J+wtBCSu3E/HxEX9DZtzLk0gnvDEjBvq9AtqEc/z1pjMMSb3qPLA== X-Received: by 2002:adf:f709:: with SMTP id r9mr21973258wrp.266.1602362605953; Sat, 10 Oct 2020 13:43:25 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang , "Edgar E . Iglesias" Subject: [PATCH v3 03/20] hw/qdev-clock: Display error hint when clock is missing from device Date: Sat, 10 Oct 2020 22:43:02 +0200 Message-Id: <20201010204319.3119239-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Instead of directly aborting, display a hint to help the developer figure out the problem (likely trying to connect a clock to a device pre-dating the Clock API, thus not expecting clocks). Reviewed-by: Luc Michel Reviewed-by: Damien Hedde Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/qdev-clock.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c index 47ecb5b4fae..6a9a340d0fb 100644 --- a/hw/core/qdev-clock.c +++ b/hw/core/qdev-clock.c @@ -12,6 +12,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "hw/qdev-clock.h" #include "hw/qdev-core.h" #include "qapi/error.h" @@ -153,6 +154,11 @@ Clock *qdev_get_clock_in(DeviceState *dev, const char = *name) assert(name); =20 ncl =3D qdev_get_clocklist(dev, name); + if (!ncl) { + error_report("Can not find clock-in '%s' for device type '%s'", + name, object_get_typename(OBJECT(dev))); + abort(); + } assert(!ncl->output); =20 return ncl->clock; @@ -165,6 +171,11 @@ Clock *qdev_get_clock_out(DeviceState *dev, const char= *name) assert(name); =20 ncl =3D qdev_get_clocklist(dev, name); + if (!ncl) { + error_report("Can not find clock-out '%s' for device type '%s'", + name, object_get_typename(OBJECT(dev))); + abort(); + } assert(ncl->output); =20 return ncl->clock; --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) client-ip=209.85.128.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362609; cv=none; d=zohomail.com; s=zohoarc; b=N3y3CSpNu7ePkAabBHJbVQqH/xKI3jJi80GOKYhignb8UZQ1MSaUuGXIYU4G0Jix7Uy2lzMKjbj9EDLP9DM5udJ20c8pPmtdOSexU5CmdoplezZLWmC7oJqNPYYqGRcQC/HGL040NAxX8gfACz28Uer9OfPGTcLarvNAZp9qKrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362609; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=Y2kqlvWXtcM60ARLN2lXw3FS87SDycgHLekZC0TvjVAbO52TbNzBLMlaaY9IPj+Gh5H6D7sjyivVGywWxDLBMTZASPvXA2rbgP+eOqsoAW6yLkgYP+WmMmE4MTAAML6PMP+XN+fDW1nPE4jvWR3u4BZPm21qnax8TATfdT6Hh+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.zohomail.com with SMTPS id 1602362609260805.52319490911; Sat, 10 Oct 2020 13:43:29 -0700 (PDT) Received: by mail-wm1-f68.google.com with SMTP id p15so13281214wmi.4 for ; Sat, 10 Oct 2020 13:43:28 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=ZuqtjKpT5MXbZVwy+FCYabCWRL6j3TgGf5uHfwWaDOUujD/i3aHxKCH9SdbSTmCRE7 Ldrjq3hdIkTevQpyVltIu4Ik78DmwkNiJmvYyUSmf6qUNz/sNbdPcoVfc1HqrwtlQUi+ S5K2387QYUddiFSrOYNZabGxI8eEpmRm8067t6B7LQVe88FIvIWV4s+G9MFbB9+RzsGc vUh52T2qn3xdsmoTxet8kBKxF0QFYOozKtlXeFWFguFyL3pHdnNx2TCUmtXYlzxr8jJW gxJDTb9rBFmRGNYghxQ02OcOoX+jHHGizV0rg0pT2l+dvV7J5UdY4G7emSMi/elejCmy YE9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=i/MbO+fT9xp/+NLFB/4BSp6DjtjnPAuAtKhcJx8hB6Al9wQ/NXBDUfE2W4llPiAa2h o1xDhBZW9OIrCnupRPKU2g0vtJXlerm//Ttokm97z4dHfh0KHQ4GkT1RAKXLO4WJnOC5 pJmwSdd86huYiFK5VQZCCd5FN79yY3djntp6yS020Bs/yMztNwSnXcTjeuHquJbUj+TI gdOw8mot/Nkf+a7RvcP2ADM43iqkoIRMBdqHX3qP++0gjXzia46GtrOh09DbPkSYwS6r jEYq+4koBYV3r5U7DGCFlKFOLYcj+zbSxN5IH6x4VOKD9U8pgJwBRsP5DmoyXHwg+A38 Z8ZA== X-Gm-Message-State: AOAM530/hGNDEbeIquh5BpoGrC32gA8EwNFurUgZHPDdkW1LERMGmEo8 Shj/ZAziEuMMaXofTFPseTOF7YSUdcM= X-Google-Smtp-Source: ABdhPJwwKkazENrdC7jgR5WP9EMaZvakRFVl6PX+zsV16ZunlWBU1LR8Hi7WFFbadpmjmkfe72dMGA== X-Received: by 2002:a1c:2cc4:: with SMTP id s187mr3910567wms.36.1602362607246; Sat, 10 Oct 2020 13:43:27 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 04/20] hw/core/clock: add the clock_new helper function Date: Sat, 10 Oct 2020 22:43:03 +0200 Message-Id: <20201010204319.3119239-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) From: Luc Michel This function creates a clock and parents it to another object with a given name. It calls clock_setup_canonical_path before returning the new clock. This function is useful to create clocks in devices when one doesn't want to expose it at the qdev level (as an input or an output). Suggested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Luc Michel Message-Id: <20201010135759.437903-4-luc@lmichel.fr> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/clock.h | 13 +++++++++++++ hw/core/clock.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/hw/clock.h b/include/hw/clock.h index d357594df99..cbc5e6ced1e 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -90,6 +90,19 @@ extern const VMStateDescription vmstate_clock; */ void clock_setup_canonical_path(Clock *clk); =20 +/** + * clock_new: + * @parent: the clock parent + * @name: the clock object name + * + * Helper function to create a new clock and parent it to @parent. There i= s no + * need to call clock_setup_canonical_path on the returned clock as it is = done + * by this function. + * + * @return the newly created clock + */ +Clock *clock_new(Object *parent, const char *name); + /** * clock_set_callback: * @clk: the clock to register the callback into diff --git a/hw/core/clock.c b/hw/core/clock.c index 7066282f7b9..f866717a835 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -23,6 +23,21 @@ void clock_setup_canonical_path(Clock *clk) clk->canonical_path =3D object_get_canonical_path(OBJECT(clk)); } =20 +Clock *clock_new(Object *parent, const char *name) +{ + Object *obj; + Clock *clk; + + obj =3D object_new(TYPE_CLOCK); + object_property_add_child(parent, name, obj); + object_unref(obj); + + clk =3D CLOCK(obj); + clock_setup_canonical_path(clk); + + return clk; +} + void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque) { clk->callback =3D cb; --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) client-ip=209.85.221.66; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f66.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362610; cv=none; d=zohomail.com; s=zohoarc; b=S2/yXVefvF4LfHh7UbOZiGuAqApT2yrhkH17GvDIbF9rumK5aWDS0dhUT8xtV51GRZIBbvxNnqiB+3ZIAr0y4997FW2FcfqQJTnp3QCgbKS+HznPwHriT4vwyGAon/iqQ18fV0lhwVijhK4XFfuVpKgOU3E2+eXiy2Hsw3kreVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362610; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w+Ww+Tb9ux5DYpk7DL28NdlwI2XqYxB/b3zmX73nSUY=; b=VBswgGaXmhAFVlv9/apP5ydJjxC4rCoVV9P+zhFdwGxEt1YVn2ZA5PqCcPu6/at5t/mV+8T3lSAn6uscnhvkuHdezWFwGFyiI+ydI3vXJXZFzPMQxd53iNSbI2dSgxhnvpoxAW5sQQezmWXetDRiXhh34KQdSVVHqgpD7iiijc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.zohomail.com with SMTPS id 1602362610985581.359911460134; Sat, 10 Oct 2020 13:43:30 -0700 (PDT) Received: by mail-wr1-f66.google.com with SMTP id h7so14195223wre.4 for ; Sat, 10 Oct 2020 13:43:30 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w+Ww+Tb9ux5DYpk7DL28NdlwI2XqYxB/b3zmX73nSUY=; b=FlVRXuizJUUcngPgMygPqNNIiMkDBJpEpBQUHUeDjynyhxd4hHIDqkCb+iQVpjclpH r4hCRKu+yNCoRfZOzoBw27jqvquM7g/rjzq8IV4iQ4HiKIgTnUkdlNXAMRL8cYkEFvqK u1WpcFKFitjva5l0KVxj8zUvSzQNimk/gdZbV8ejQNBDWZ26KnpLPdVD9Af+NNGFYLlx 2bjbNa49Djy5qPHpsg4xLY/HtrL4GngrQVYqLQecJRsbvEpSHX3IyAONnDXL1qElKSqo SnAZJULWxYgJMsiznnmVj0rPfOY9nJp4z6KaTgleZLSbuSX9OV/hyGXv31qpC7DTylv5 wt9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=w+Ww+Tb9ux5DYpk7DL28NdlwI2XqYxB/b3zmX73nSUY=; b=pyKLXIkYsq3/hQ77aD6Rn7ARsklE+b4eBylBsJ/8sVOoTtGX9L3aTzLfAcrhiqRPKr yAHeju8mA2W/j14Nk2atOFOfHnxFOtltZFo2HkRedDKYOrBbPfpoZ0MDkQ6IiHsOtjE+ nwcIKwvjTm2gWa3Da6EqMJGoTdAtmBDS8tJH/OKEJreD60OEk3QEMczbjd8g53rrvExX XcEBGtxu9e1b7hvBnKolanrImCBH3a24SDXTx7UldHpRF0hciSBis6Ln+0i65C43lp2e tPZVIWnLTvqIUhGJpzG0Zkzb/opVyGTvFUPu9Gt6+PbHQxrKd8yV50nwKX8KrFQu1oYm BLEQ== X-Gm-Message-State: AOAM532qi9EQJXBpARvKsNxlBWGWsSyjWZxp87KSEkiRPNJcF9/m33wH QbWj1HsE6stCea+VmR+AeU8= X-Google-Smtp-Source: ABdhPJw8RcEG6mhL7apDRzkuwHDkHPjLk4pcpAAQA/cfcKZf7yFAQ6zKwvLreIHrZXbS20Nmb+bsqg== X-Received: by 2002:adf:f50e:: with SMTP id q14mr15085634wro.56.1602362609037; Sat, 10 Oct 2020 13:43:29 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang , Aleksandar Markovic Subject: [PATCH v3 05/20] target/mips: Move cpu_mips_get_random() with CP0 helpers Date: Sat, 10 Oct 2020 22:43:04 +0200 Message-Id: <20201010204319.3119239-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The get_random() helper uses the CP0_Wired register, which is unrelated to the CP0_Count register use as timer. Commit e16fe40c872 ("Move the MIPS CPU timer in a separate file") incorrectly moved this get_random() helper with timer specific code. Move it back to generic CP0 helpers. Reviewed-by: Aleksandar Markovic Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Luc Michel --- target/mips/internal.h | 2 +- target/mips/cp0_helper.c | 25 +++++++++++++++++++++++++ target/mips/cp0_timer.c | 25 ------------------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/target/mips/internal.h b/target/mips/internal.h index 7f159a9230c..087cabaa6d4 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -144,6 +144,7 @@ void r4k_helper_tlbr(CPUMIPSState *env); void r4k_helper_tlbinv(CPUMIPSState *env); void r4k_helper_tlbinvf(CPUMIPSState *env); void r4k_invalidate_tlb(CPUMIPSState *env, int idx, int use_extra); +uint32_t cpu_mips_get_random(CPUMIPSState *env); =20 void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, @@ -209,7 +210,6 @@ void cpu_state_reset(CPUMIPSState *s); void cpu_mips_realize_env(CPUMIPSState *env); =20 /* cp0_timer.c */ -uint32_t cpu_mips_get_random(CPUMIPSState *env); uint32_t cpu_mips_get_count(CPUMIPSState *env); void cpu_mips_store_count(CPUMIPSState *env, uint32_t value); void cpu_mips_store_compare(CPUMIPSState *env, uint32_t value); diff --git a/target/mips/cp0_helper.c b/target/mips/cp0_helper.c index de64add038b..12143ac55b9 100644 --- a/target/mips/cp0_helper.c +++ b/target/mips/cp0_helper.c @@ -203,6 +203,31 @@ static void sync_c0_entryhi(CPUMIPSState *cpu, int tc) *tcst |=3D asid; } =20 +/* XXX: do not use a global */ +uint32_t cpu_mips_get_random(CPUMIPSState *env) +{ + static uint32_t seed =3D 1; + static uint32_t prev_idx; + uint32_t idx; + uint32_t nb_rand_tlb =3D env->tlb->nb_tlb - env->CP0_Wired; + + if (nb_rand_tlb =3D=3D 1) { + return env->tlb->nb_tlb - 1; + } + + /* Don't return same value twice, so get another value */ + do { + /* + * Use a simple algorithm of Linear Congruential Generator + * from ISO/IEC 9899 standard. + */ + seed =3D 1103515245 * seed + 12345; + idx =3D (seed >> 16) % nb_rand_tlb + env->CP0_Wired; + } while (idx =3D=3D prev_idx); + prev_idx =3D idx; + return idx; +} + /* CP0 helpers */ target_ulong helper_mfc0_mvpcontrol(CPUMIPSState *env) { diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c index bd7efb152dd..9c38e9da1c8 100644 --- a/target/mips/cp0_timer.c +++ b/target/mips/cp0_timer.c @@ -29,31 +29,6 @@ =20 #define TIMER_PERIOD 10 /* 10 ns period for 100 Mhz frequency */ =20 -/* XXX: do not use a global */ -uint32_t cpu_mips_get_random(CPUMIPSState *env) -{ - static uint32_t seed =3D 1; - static uint32_t prev_idx =3D 0; - uint32_t idx; - uint32_t nb_rand_tlb =3D env->tlb->nb_tlb - env->CP0_Wired; - - if (nb_rand_tlb =3D=3D 1) { - return env->tlb->nb_tlb - 1; - } - - /* Don't return same value twice, so get another value */ - do { - /* - * Use a simple algorithm of Linear Congruential Generator - * from ISO/IEC 9899 standard. - */ - seed =3D 1103515245 * seed + 12345; - idx =3D (seed >> 16) % nb_rand_tlb + env->CP0_Wired; - } while (idx =3D=3D prev_idx); - prev_idx =3D idx; - return idx; -} - /* MIPS R4K timer */ static void cpu_mips_timer_update(CPUMIPSState *env) { --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) client-ip=209.85.221.67; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f67.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602362612; cv=none; d=zohomail.com; s=zohoarc; b=RXsj+QfgbuTeG50ttZL6DQTFiUDYCao0f7svRcFF4oig0SL7xVQZ4Kjq8HKRtonFDrItN7tLzBSKGHt1Qq/Gj4UngsIF8y/+U1qXspny5quvxt1ItrgrTu3DTPINxWrvZC9J6Yh9kYJhPozyWzQInPZXbdGzx1NnsecP6eCv9TI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362612; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W69f1MWd6lsJIyf72MtAUNNqNrrt140PbQJ0VWAk4GE=; b=Lm/Aj8REJ50rYMUk53LcuTgDAtsfzbs2eUnOrjA1FvcCTY+W4Ssck9I7Y4DHnbVOu8TC9i1NJwa2H3sXiC+OT7rN9obVmtMkde+JTQUzldUQtOgum+8Jxt6GRVVW48Z/9F5GvGu7GO4daHDte35AyAsFlDSkBiNb/EVwJmziVzI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.zohomail.com with SMTPS id 1602362612441228.15450394344896; Sat, 10 Oct 2020 13:43:32 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id g12so14148003wrp.10 for ; Sat, 10 Oct 2020 13:43:31 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W69f1MWd6lsJIyf72MtAUNNqNrrt140PbQJ0VWAk4GE=; b=iHBJeVcDCWDQV126qWVyhVrgqskHR++O2Q09MPlCx+N64wBaRI7PCNqRycHV7g3gss 8rOdtir21RCEsANy8dYJnxz3qx0r6y8/jiNFhOq6cBRHFieeI8nxgXlVDvODR16UR2gh 9B/OkNd43RtuhqwAfAkTCFKqtZwkw9cktKXkMlmSju+THK/w1Yi0NiRR905Z3u+Kq1Zm xswjpdpwqgJOlt5dZwWy/gAtOhl01NZtDiM3LOR0pk8tGas5ViqyIo5pHYEsKgjprM83 FDbaHc9L7+F+rCaZlVpno2aLVuGFGmHogNQ7o9WBdYrM0/sqCRQWFVvH9WJQY1syvPqC fHQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=W69f1MWd6lsJIyf72MtAUNNqNrrt140PbQJ0VWAk4GE=; b=JYpz2Uc9uywOU2G3N49Fz5VuGaKQUzWnmJR7ZLUMqvLZdsWC8zvc9kQD4fS0N4zyM4 HZw/68k6eNjRM3mUysyKRxtP1ZURN+maKMkjKCwHX+QMqu2LnW69ahYB2ptLG7q+MhwY 5xS9YTlPdVNMZCXoY4wWLS684ADDl2GI8w9E2uyR884P3R8xWUMGAlbQWy4q2vZiAny3 tv3FE8Qe2m3ltyllDVWWbDFNaOR/Gq7tey7XcOxrfdr+c2mWZaCTJcXUGsmuIighoo4f 2m/jOSsOTF4Cz57TpwjshzsZaymKqRluTselHcU4W7DDPIZvJzUVsXkrxeeW/rUc11ae yA+g== X-Gm-Message-State: AOAM533BJmXmlo6YH6APjnhSCb79ZPKQJwdaqTRqkBysS0wxvuUJWpzQ Qf6ZawuomQSyi93D/n7ZQKs= X-Google-Smtp-Source: ABdhPJzNquRkH/sSqLDL5dfLi3BzUXlkwpTvLvA34LUNoet/wjBt03BtZyS0LMnvdSqSxT/exzaBhA== X-Received: by 2002:adf:9461:: with SMTP id 88mr21677769wrq.307.1602362610458; Sat, 10 Oct 2020 13:43:30 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang , Aleksandar Markovic Subject: [PATCH v3 06/20] target/mips/cp0_timer: Explicit unit in variable name Date: Sat, 10 Oct 2020 22:43:05 +0200 Message-Id: <20201010204319.3119239-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Name variables holding nanoseconds with the '_ns' suffix. Reviewed-by: Aleksandar Markovic Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cp0_timer.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c index 9c38e9da1c8..5194c967ae3 100644 --- a/target/mips/cp0_timer.c +++ b/target/mips/cp0_timer.c @@ -32,13 +32,14 @@ /* MIPS R4K timer */ static void cpu_mips_timer_update(CPUMIPSState *env) { - uint64_t now, next; + uint64_t now_ns, next_ns; uint32_t wait; =20 - now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - wait =3D env->CP0_Compare - env->CP0_Count - (uint32_t)(now / TIMER_PE= RIOD); - next =3D now + (uint64_t)wait * TIMER_PERIOD; - timer_mod(env->timer, next); + now_ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + wait =3D env->CP0_Compare - env->CP0_Count - + (uint32_t)(now_ns / TIMER_PERIOD); + next_ns =3D now_ns + (uint64_t)wait * TIMER_PERIOD; + timer_mod(env->timer, next_ns); } =20 /* Expire the timer. */ @@ -56,16 +57,16 @@ uint32_t cpu_mips_get_count(CPUMIPSState *env) if (env->CP0_Cause & (1 << CP0Ca_DC)) { return env->CP0_Count; } else { - uint64_t now; + uint64_t now_ns; =20 - now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + now_ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); if (timer_pending(env->timer) - && timer_expired(env->timer, now)) { + && timer_expired(env->timer, now_ns)) { /* The timer has already expired. */ cpu_mips_timer_expire(env); } =20 - return env->CP0_Count + (uint32_t)(now / TIMER_PERIOD); + return env->CP0_Count + (uint32_t)(now_ns / TIMER_PERIOD); } } =20 --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) client-ip=209.85.221.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362613; cv=none; d=zohomail.com; s=zohoarc; b=K31DI6L8SfqH8FMCatFU9tHS8uNuwbl0VBDaUfU5fdMmBC2QTKjpGwjkyYV+x4TPM8v7/+mQY2xQEc060yF9jkLfYU0XBWU+ez3TRyiPPxFRxOh+jPxTz6/v+0HWEBnPX1fqSdjsj8J0le3IDVGYXdFIAFsKgNNtHntwpuxGuI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362613; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BslzpywZz3mbJWKAE8qW6xsdeqX9i4THsloWKfBnQUU=; b=PTutnd6zDnNn6I4ilN6JiuAAkg5luQcM6DBKIS5nTdcPFiO31nDl6RhEFe8E5NFcdtAhVBJjOy2v+1zGYFwU/lJ07U1Lf1/kYeE9YpozcmtgQhsELT/kg9nH+Rvggyb0Sll0Wc2UZYYL3qWX/38GnvKB8NaHU81o6ub9Uja9S6s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.zohomail.com with SMTPS id 16023626135557.337396758098407; Sat, 10 Oct 2020 13:43:33 -0700 (PDT) Received: by mail-wr1-f65.google.com with SMTP id y12so8788675wrp.6 for ; Sat, 10 Oct 2020 13:43:32 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BslzpywZz3mbJWKAE8qW6xsdeqX9i4THsloWKfBnQUU=; b=EmbwK9TZknnui4PQOgQRnw5vZMBRygMvlsFVsqpCk1KVMxkXBOJYLRE/UA9YqiHwkw E18r+J7lGucOVtL9uT8fUvHNd1M9U/7QAHSfsMBQ/Z2wcUaS9yHEazHEDBh3i/9aS9Nq pz+nGobjsQWDzwKx64m9OhPiwPK+WOyFuyYakVlYKLm1C/7atYj3pqdIQxLW0CQD+CD1 BiVSSFzrYen0FLzhmozgDQBjGNtSLS7uug78jPwMU+9yNdfe7DmIyloBKErJEdrv30wD wF3I6sAtMKhjjUJpfEoywFXGp6xWPSNYWQaR9dMd4WTpEddDzTtR5TgwdrA4LGu6Nd0R HoXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=BslzpywZz3mbJWKAE8qW6xsdeqX9i4THsloWKfBnQUU=; b=Wrsx0hdNbEaaZF7nEy0U3wU5Dn8m58bfKjPXHafSTgNiSq9K2DnYABPOHavYJIime+ FOKjyIfZ2QJTBpO2SBT+cdiQCZC0HRxedH3vUaLeE1FzSHy4tTiyf/RGQTnJxOPZzvMn l7uYWzENFBuHftEtzE6PguRrqr5hGeTg+4wNMZbTNR679jAa8yBeeI+50SbOTSHOKAvT ue17LTbZiCe2lgccD8lXUIRjm6J34M57FihHNBac5cdfM8Rx95vlB/wXf6wIkCGw0NKf 3DD2VMQeRdEi8VZ8W3sO6a6RmQ3RXV87s6fQMVIN+1/DZsMhLk8fz1P+5jQHokZ0I6P0 DfFQ== X-Gm-Message-State: AOAM533u9UF+BYVDiXKSxcdf8NODYLaFwM+bzmdzuHz6+HfBW6Ef+Bok CV/dg//v8ztbdOgbC1ZGwjE= X-Google-Smtp-Source: ABdhPJzxcI4inkXz91djExO+yIevY0gkOJ1BWFgYfjPAUqtmvqSef6nnp3lj6HJccHSQ2RAmVy5Puw== X-Received: by 2002:adf:e6c4:: with SMTP id y4mr21979890wrm.423.1602362611760; Sat, 10 Oct 2020 13:43:31 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 07/20] target/mips/cp0_timer: Document TIMER_PERIOD origin Date: Sat, 10 Oct 2020 22:43:06 +0200 Message-Id: <20201010204319.3119239-8-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) TIMER_PERIOD value of '10 ns' can be explained looking at commit 6af0bf9c7c3doc, where the CPU frequency is 200 MHz and CP0 default count rate is half the frequency of the CPU. Document that. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cp0_timer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c index 5194c967ae3..6fec5fe0ff7 100644 --- a/target/mips/cp0_timer.c +++ b/target/mips/cp0_timer.c @@ -27,7 +27,17 @@ #include "sysemu/kvm.h" #include "internal.h" =20 -#define TIMER_PERIOD 10 /* 10 ns period for 100 Mhz frequency */ +/* + * Since commit 6af0bf9c7c3 this model assumes a CPU clocked at 200MHz + * and a CP0 timer running at half the clock of the CPU (cp0_count_rate = =3D 2). + * + * TIMER_FREQ_HZ =3D CPU_FREQ_HZ / CP0_COUNT_RATE =3D 200 MHz / 2 =3D 100 = MHz + * + * TIMER_PERIOD_NS =3D 1 / TIMER_FREQ_HZ =3D 10 ns + */ +#define CPU_FREQ_HZ_DEFAULT 200000000 +#define CP0_COUNT_RATE_DEFAULT 2 +#define TIMER_PERIOD 10 /* 1 / (CPU_FREQ_HZ / CP0_COUNT_RATE) = */ =20 /* MIPS R4K timer */ static void cpu_mips_timer_update(CPUMIPSState *env) --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) client-ip=209.85.221.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362615; cv=none; d=zohomail.com; s=zohoarc; b=fTRaliHal1YU3nDCo8e9A5PXAE2N7h1MaicMdAI8c16F7HyuFbCsDortG0QgUGA7Yn/xB9szlA3SvkZ2h4iXwQfb8IkXl6TJ2wFOiYDPZcWGsrsdpdOqIu8Y6RTKhuvOlGMjBCV2OeLqjp2/ur+XI7r3vr3tSdpTUkdAcWDeJ9g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362615; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nQ7QIUrlrUzF/fqOFrq02YrsK4QXRUJjYFAte9Cpzpg=; b=j8v+9SOntYKLhCqlgZupXnC0r14sgEP4epgVkdh37XcWm0Pp4DvRe7tkA5WIbrr1JkFZYjx8PMJBQpAfnY5QPQPF3867aGyAMIb7UUsl4hxM+Uh/edUzbX0AeeiJD3MVviNZDsDU+BQHburk/b9/uhosyul1XULTI9kI8+q9WrE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.zohomail.com with SMTPS id 1602362615124600.130466534541; Sat, 10 Oct 2020 13:43:35 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id i1so8040781wro.1 for ; Sat, 10 Oct 2020 13:43:34 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nQ7QIUrlrUzF/fqOFrq02YrsK4QXRUJjYFAte9Cpzpg=; b=cAJNcsMz3zuDjPLgFP4IwCfGiy09/y84E8BjvVr/dqvGvy1YRE3I7DxK1hRKsGdoEA CSfbxZEbwwnYoyv7ZcvgVqIvFVtsBeYx3SbjhvDNX3OI7jv8rUetBLnwyCwi9eLTlo7Y rjpkMKuCotmBkqWrZOWoZj3823ulzXmYejZ1XN/nf3oF/OZ0n3oyeR9UoUSXBJbJBOmx /fYKhtF6vmyFnPPu/pzfdOsRmmoegbxHxkX1Myd97hxsjZ1Fqfr/VC3mkN2kg89az8br qGm+VOzB6pd8Zwdg9VVP0/SyDcUt1k6/pzJywiRYiLCQH7/C10Gd4ATxzhx59UZ/8MDF Vh1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nQ7QIUrlrUzF/fqOFrq02YrsK4QXRUJjYFAte9Cpzpg=; b=XJUgR4ad/Uu8myDZ9y4tvqr8tsO57Td0Knw+L+5seYtyLbuXDWch1ikDScaUJp5NqR yFrs2zgzC9LsZxtobHLS5g6dgn+ej2x38ak8ZJR563L9giRaQMYR71hU6X94Dzca744r 1Iz7GHTwSTmf+LZumREiZrwOiEafJzVeP0JdIW+8zm3OY73h3BccKYIQPwm4s6NhrtYE oTyFhLJY9fOOJr8fm7ELoKBEAiQv/FOmpZF30tMj3N+Sz2DNBFK8LrayanMpZwdjCiwa pbHAf4JSXR5fOuYZ/g0jThuNN6Rq/6zklM65T2tS0rkueBDqA64tm/cyPTj9RahS8jy3 yQ+A== X-Gm-Message-State: AOAM532PWDapgT0YcfM6umlsCvC/15k9YgfIVYrgzZRkve2MZp68q8HI b5CenFq9/nXoGLR/VWX/+Dg= X-Google-Smtp-Source: ABdhPJyxBNKdPYslU6d6J8oxgaxM8n37D55G0fc5LZetF+vONOAvi8KG9QD7bpy+otJPYyh+6vnUvg== X-Received: by 2002:a5d:680a:: with SMTP id w10mr22174651wru.5.1602362613138; Sat, 10 Oct 2020 13:43:33 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 08/20] target/mips: Move cp0_count_ns to CPUMIPSState Date: Sat, 10 Oct 2020 22:43:07 +0200 Message-Id: <20201010204319.3119239-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Currently the CP0 timer period is fixed at 10 ns, corresponding to a fixed CPU frequency of 200 MHz (using half the speed of the CPU). In few commits we will be able to use a different CPU frequency. In preparation, move the cp0_count_ns variable to CPUMIPSState so we can modify it. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Jiaxun Yang --- target/mips/cpu.h | 1 + target/mips/cp0_timer.c | 23 ++++++----------------- target/mips/cpu.c | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 7cf7f5239f7..085a88e9550 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1145,6 +1145,7 @@ struct CPUMIPSState { struct MIPSITUState *itu; MemoryRegion *itc_tag; /* ITC Configuration Tags */ target_ulong exception_base; /* ExceptionBase input to the core */ + uint64_t cp0_count_ns; /* CP0_Count clock period (in nanoseconds) */ }; =20 /** diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c index 6fec5fe0ff7..5ec0d6249e9 100644 --- a/target/mips/cp0_timer.c +++ b/target/mips/cp0_timer.c @@ -27,18 +27,6 @@ #include "sysemu/kvm.h" #include "internal.h" =20 -/* - * Since commit 6af0bf9c7c3 this model assumes a CPU clocked at 200MHz - * and a CP0 timer running at half the clock of the CPU (cp0_count_rate = =3D 2). - * - * TIMER_FREQ_HZ =3D CPU_FREQ_HZ / CP0_COUNT_RATE =3D 200 MHz / 2 =3D 100 = MHz - * - * TIMER_PERIOD_NS =3D 1 / TIMER_FREQ_HZ =3D 10 ns - */ -#define CPU_FREQ_HZ_DEFAULT 200000000 -#define CP0_COUNT_RATE_DEFAULT 2 -#define TIMER_PERIOD 10 /* 1 / (CPU_FREQ_HZ / CP0_COUNT_RATE) = */ - /* MIPS R4K timer */ static void cpu_mips_timer_update(CPUMIPSState *env) { @@ -47,8 +35,8 @@ static void cpu_mips_timer_update(CPUMIPSState *env) =20 now_ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); wait =3D env->CP0_Compare - env->CP0_Count - - (uint32_t)(now_ns / TIMER_PERIOD); - next_ns =3D now_ns + (uint64_t)wait * TIMER_PERIOD; + (uint32_t)(now_ns / env->cp0_count_ns); + next_ns =3D now_ns + (uint64_t)wait * env->cp0_count_ns; timer_mod(env->timer, next_ns); } =20 @@ -76,7 +64,7 @@ uint32_t cpu_mips_get_count(CPUMIPSState *env) cpu_mips_timer_expire(env); } =20 - return env->CP0_Count + (uint32_t)(now_ns / TIMER_PERIOD); + return env->CP0_Count + (uint32_t)(now_ns / env->cp0_count_ns); } } =20 @@ -92,7 +80,8 @@ void cpu_mips_store_count(CPUMIPSState *env, uint32_t cou= nt) } else { /* Store new count register */ env->CP0_Count =3D count - - (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / TIMER_PE= RIOD); + (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / + env->cp0_count_ns); /* Update timer timer */ cpu_mips_timer_update(env); } @@ -119,7 +108,7 @@ void cpu_mips_stop_count(CPUMIPSState *env) { /* Store the current value */ env->CP0_Count +=3D (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / - TIMER_PERIOD); + env->cp0_count_ns); } =20 static void mips_timer_cb(void *opaque) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index e86cd065483..84b727fefa8 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -134,6 +134,25 @@ static void mips_cpu_disas_set_info(CPUState *s, disas= semble_info *info) } } =20 +/* + * Since commit 6af0bf9c7c3 this model assumes a CPU clocked at 200MHz + * and a CP0 timer running at half the clock of the CPU (cp0_count_rate = =3D 2). + * + * TIMER_FREQ_HZ =3D CPU_FREQ_HZ / CP0_COUNT_RATE =3D 200 MHz / 2 =3D 100 = MHz + * + * TIMER_PERIOD_NS =3D 1 / TIMER_FREQ_HZ =3D 10 ns + */ +#define CPU_FREQ_HZ_DEFAULT 200000000 +#define CP0_COUNT_RATE_DEFAULT 2 +#define TIMER_PERIOD_DEFAULT 10 /* 1 / (CPU_FREQ_HZ / CP0_COUNT_RATE) = */ + +static void mips_cp0_period_set(MIPSCPU *cpu) +{ + CPUMIPSState *env =3D &cpu->env; + + env->cp0_count_ns =3D TIMER_PERIOD_DEFAULT; +} + static void mips_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); @@ -141,6 +160,8 @@ static void mips_cpu_realizefn(DeviceState *dev, Error = **errp) MIPSCPUClass *mcc =3D MIPS_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 + mips_cp0_period_set(cpu); + cpu_exec_realizefn(cs, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) client-ip=209.85.221.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362616; cv=none; d=zohomail.com; s=zohoarc; b=URTMcpJ56L1sFp1CqIGvXNTiH2yOaWsJBzK9UoNBiZH4oc/CsKzTXcNmPkHggVVtuZqIpNRWIoUVZ3o7BkChnH5hZX9Cb701ktp+ilKXat5AfeBA4LQ9WktMA0vu88mTfdlRXB1+kPxM1ohzW+sat7EMfS5F8JUJKUbx3YMMCC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362616; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yECX+EErgKEGGyu+fq5dcK6AG/+Tqf8z/yJst+0jRiM=; b=b+l9xa86ajOXyFgxd6vGd2pXD8JNHIJsiOiMtYrZWHnxXS8sn1QCBGXE7EvjB/5vfIn+Qq3uutFvAGP5Wh1QqpowBJrNJ1vKHAxURch3aFaY6VOcnp6JG12i4QWwxU4DOxHGQn8iiDVeTbl0tur46WhGSfmqQ9+11fzesbCtA7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.zohomail.com with SMTPS id 1602362616231826.9763572335688; Sat, 10 Oct 2020 13:43:36 -0700 (PDT) Received: by mail-wr1-f65.google.com with SMTP id e18so14153843wrw.9 for ; Sat, 10 Oct 2020 13:43:35 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yECX+EErgKEGGyu+fq5dcK6AG/+Tqf8z/yJst+0jRiM=; b=GfwaJNExsizLquxriFCRHQzFaXkv6y2H5zsZT9gMWghchXib8taVWRuoAeHHsPZgTc EviPdKt7X8d8G0eLDSm83avfxKsEi/TQ3liJDtPKjj47dwyAHVV4MYGJGfeETeyfJp5c 5Sd3lB2bdJHkjM7DL3vERUNVK8/uNXzCY/QNNktYwrih4bGEnJe6zBumWHM91xxyKvwK uT3fbE3fu5p9SsBT0WE/nuB2SuDXY3FbsHcuf18TDA+5Gkuar98kXWkBPtEKwwmJmqGL 18iboMIhECZMXURaYAnGC87DwmCuQ83q7Q9s3BcmYjMeLVeWScNpAtAKmJrL5T1TBmAI lVPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yECX+EErgKEGGyu+fq5dcK6AG/+Tqf8z/yJst+0jRiM=; b=M6e8zbBA7yjQ/BuyANuiUbI4o7+oDmRaNxGRr/gomTwoRdEn9WWuVesg9lLgKsNJzd JW6LlYWNZFxRXmXm3rcHISdwxu82aEalNFnAEw0ZjuZ+MrZr3ruIaWLoeqnMOfoBW3YB J2YT67HNgAJcT7J2aG7mFG47so3WxiOQYg2pHV1wYAgCcCsRLlVGAubFvVRHUb2nhT5J VuNyfWVdk2XYl2sitK1qjbAjPgWcSVMw1Tt+w0+B1nCkZHjzX0pTUIhNXSKBH3oiPic1 DL4OLfdFYbG9RXSbl4JlSX6Ke+ZDWwk7aFpYIhkkT6IAd5ilzhP+6751w5AbtNoNVjFA JiqA== X-Gm-Message-State: AOAM5322SEc1MxqMxWWn2oPdy4+Sx2ebt1yP9aCM4bKD7Av2M6dabsJs BITRri36bLUs6qTWLdPGb4I= X-Google-Smtp-Source: ABdhPJzp6nhn+H1cCwDPQChnlEly5vTzmsjcfP/Mn9BoBGu2b50MvAgQJjvERPKU0sn857NTmunMxQ== X-Received: by 2002:adf:cf04:: with SMTP id o4mr9818042wrj.244.1602362614429; Sat, 10 Oct 2020 13:43:34 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 09/20] target/mips/cpu: Calculate the CP0 timer period using the CPU frequency Date: Sat, 10 Oct 2020 22:43:08 +0200 Message-Id: <20201010204319.3119239-10-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The CP0 timer period is a function of the CPU frequency. Start using the default values, which will be replaced by properties in the next commits. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Jiaxun Yang --- target/mips/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 84b727fefa8..46188139b7b 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -144,13 +144,13 @@ static void mips_cpu_disas_set_info(CPUState *s, disa= ssemble_info *info) */ #define CPU_FREQ_HZ_DEFAULT 200000000 #define CP0_COUNT_RATE_DEFAULT 2 -#define TIMER_PERIOD_DEFAULT 10 /* 1 / (CPU_FREQ_HZ / CP0_COUNT_RATE) = */ =20 static void mips_cp0_period_set(MIPSCPU *cpu) { CPUMIPSState *env =3D &cpu->env; =20 - env->cp0_count_ns =3D TIMER_PERIOD_DEFAULT; + env->cp0_count_ns =3D muldiv64(NANOSECONDS_PER_SECOND, CP0_COUNT_RATE_= DEFAULT, + CPU_FREQ_HZ_DEFAULT); } =20 static void mips_cpu_realizefn(DeviceState *dev, Error **errp) --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) client-ip=209.85.221.66; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f66.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602362617; cv=none; d=zohomail.com; s=zohoarc; b=h8a93WZQHL1jhHiNxOQw/Jogfc0X+zB3dWSlCCvSAezLsO00XzBB29tZ5zO4i8xh/kf20LDAzB4kmSLP80s7o8i6POIixiwCYM+H34Z/S7UYR0sjBuy8VeGPbrE06WOcggRhnMvdwy7iMluuA+vgjJiFQLtTY8FBNRQvJFf+xTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362617; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i1cGbjc5Cl94JMQEfZlvF0v5MlNUEPZb+r7dtqjcBUs=; b=aVNtnE2uIOJJ/owfbsHC5pbhCvkExuJxpK6ML7e9/jtExL5XfA6J+DKqm6jmO/QqiSgl0+AVw6dR9zh3GXbL68CmVqI+SnoAmvlk/ThGx6e+UVGRoSiRvOGqIIw4rJzz0eYJVSaZkE7StzAfDuMBAIDqZEUsWORqmh01YRQibI8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.zohomail.com with SMTPS id 1602362617634351.3073509882098; Sat, 10 Oct 2020 13:43:37 -0700 (PDT) Received: by mail-wr1-f66.google.com with SMTP id n18so14171145wrs.5 for ; Sat, 10 Oct 2020 13:43:37 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i1cGbjc5Cl94JMQEfZlvF0v5MlNUEPZb+r7dtqjcBUs=; b=OAHSViclCH/bbCqb7RZmhzeDW4aZl0yYqSiS6s4ksBZAQvZzx31vqpnDq3QUjawWv8 Nga9uGXmLo+LrT1jHyNgB8jVWqdRXfsKA5R1nvEKj2ZiPgIWS201U1LgKxjSWxl2jYU+ kRLA3hd8gbnDyDZaqMf7lwAMahZViJMCgERDbKliOtDadCN3iVUWWBgqIZPoH8sM72c6 l6JI5pRI9qJuRQoFRFWxVDlcwovvVV318CaMMijSmZ5+32AvS7Oh1c1UYp32oUtt+ov4 s9EX7c7+pvxK4xSH0p3LxImDkKPT6u4GhD64/46AAQju7iwvyzNrvpH3LbPbcYiHVprG LFzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=i1cGbjc5Cl94JMQEfZlvF0v5MlNUEPZb+r7dtqjcBUs=; b=nAQkEaQcBTHyJbJmzBy8GG37zOD28tur1Ts/oGsK91zeugi6JTWaj2FmAVXIHHG699 UnSZ7C8a3aXFdAqgrf78Erna6/gnRQ7rmSS/vznXZ50JGLwu7VRN3hl5Ayk67RHmB9Vd r6lO0snmF8TPxI+2xnXZVxh6WJHEADPh6RfRKosdf6CPRxhDeA2x6/Zr40TGu6mH159G Ozqut0XaqaxvHXmBMofavMs1qCM+Sr9T+9Te9BeiH/h3aAV1I1NSb/coIE/8Mq8QAPZB n/utCD7S6s0mj8i4RDQwQ97o5s8M6gELLb/qXI1uxlM051ghOlrnWIXaST4UnP0hK4jX 38Ug== X-Gm-Message-State: AOAM532wtmv31OGXvO+ypfl2DqSEImcwXNaaLSvLr2DyhAQBpq+dX6Q6 2rQ6LO6obPbAl5MI9YdLwLw= X-Google-Smtp-Source: ABdhPJyPltsDh4l7z9svck+1Znqoj9dwZUxxi9Jxc6vzjIl6MJDosdL1OsFUK2DkGllGcrSvcaKGeg== X-Received: by 2002:a5d:4f09:: with SMTP id c9mr20627407wru.427.1602362615706; Sat, 10 Oct 2020 13:43:35 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 10/20] target/mips/cpu: Make cp0_count_rate a property Date: Sat, 10 Oct 2020 22:43:09 +0200 Message-Id: <20201010204319.3119239-11-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Since not all CPU implementations use a cores use a CP0 timer at half the frequency of the CPU, make this variable a property. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cpu.h | 9 +++++++++ target/mips/cpu.c | 19 +++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 085a88e9550..baeceb892ef 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1151,6 +1151,7 @@ struct CPUMIPSState { /** * MIPSCPU: * @env: #CPUMIPSState + * @cp0_count_rate: rate at which the coprocessor 0 counter increments * * A MIPS CPU. */ @@ -1161,6 +1162,14 @@ struct MIPSCPU { =20 CPUNegativeOffsetState neg; CPUMIPSState env; + /* + * The Count register acts as a timer, incrementing at a constant rate, + * whether or not an instruction is executed, retired, or any forward + * progress is made through the pipeline. The rate at which the counter + * increments is implementation dependent, and is a function of the + * pipeline clock of the processor, not the issue width of the process= or. + */ + unsigned cp0_count_rate; }; =20 =20 diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 46188139b7b..461edfe22b7 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -26,7 +26,7 @@ #include "qemu/module.h" #include "sysemu/kvm.h" #include "exec/exec-all.h" - +#include "hw/qdev-properties.h" =20 static void mips_cpu_set_pc(CPUState *cs, vaddr value) { @@ -135,12 +135,7 @@ static void mips_cpu_disas_set_info(CPUState *s, disas= semble_info *info) } =20 /* - * Since commit 6af0bf9c7c3 this model assumes a CPU clocked at 200MHz - * and a CP0 timer running at half the clock of the CPU (cp0_count_rate = =3D 2). - * - * TIMER_FREQ_HZ =3D CPU_FREQ_HZ / CP0_COUNT_RATE =3D 200 MHz / 2 =3D 100 = MHz - * - * TIMER_PERIOD_NS =3D 1 / TIMER_FREQ_HZ =3D 10 ns + * Since commit 6af0bf9c7c3 this model assumes a CPU clocked at 200MHz. */ #define CPU_FREQ_HZ_DEFAULT 200000000 #define CP0_COUNT_RATE_DEFAULT 2 @@ -149,7 +144,7 @@ static void mips_cp0_period_set(MIPSCPU *cpu) { CPUMIPSState *env =3D &cpu->env; =20 - env->cp0_count_ns =3D muldiv64(NANOSECONDS_PER_SECOND, CP0_COUNT_RATE_= DEFAULT, + env->cp0_count_ns =3D muldiv64(NANOSECONDS_PER_SECOND, cpu->cp0_count_= rate, CPU_FREQ_HZ_DEFAULT); } =20 @@ -202,6 +197,13 @@ static ObjectClass *mips_cpu_class_by_name(const char = *cpu_model) return oc; } =20 +static Property mips_cpu_properties[] =3D { + /* CP0 timer running at half the clock of the CPU */ + DEFINE_PROP_UINT32("cp0-count-rate", MIPSCPU, cp0_count_rate, + CP0_COUNT_RATE_DEFAULT), + DEFINE_PROP_END_OF_LIST() +}; + static void mips_cpu_class_init(ObjectClass *c, void *data) { MIPSCPUClass *mcc =3D MIPS_CPU_CLASS(c); @@ -211,6 +213,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) device_class_set_parent_realize(dc, mips_cpu_realizefn, &mcc->parent_realize); device_class_set_parent_reset(dc, mips_cpu_reset, &mcc->parent_reset); + device_class_set_props(dc, mips_cpu_properties); =20 cc->class_by_name =3D mips_cpu_class_by_name; cc->has_work =3D mips_cpu_has_work; --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) client-ip=209.85.221.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362619; cv=none; d=zohomail.com; s=zohoarc; b=YmznnKs0JODKj7JXNuile3HLlFJMUSImDAc2ZBNglbkp37wSJZwxxiHYAZD9CqAm0iAY88UPWsItaPaQvWG0sYGkf4Wy1ZAEwf/RwWsN4WoXLHPkYtPstf/5wl6cLxawzHRmvSL14KA2OhvQHcifg0twEkeKySoppf1Zi4YJxrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362619; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GJs+vUPbnbBqVHsKvcVatNykiV7Rg7UUaqvKVc5FZic=; b=d0wiUxFHy97HYRj0WRzkQ1oVNuJkt10BTrAUjJvPs3y7juR+WWLdTPuTKODHBZfGFssluN15BlGojxgr8uSgORK6qvzf28Cf2qE3oIa+3nRHHApfjRzAtR5M7g7S0Xmw7kaTOvyY1+88G3OudP93XIVJ2Y02bF7z1P011DkbkLE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.zohomail.com with SMTPS id 1602362619044352.02603107362665; Sat, 10 Oct 2020 13:43:39 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id e18so14153907wrw.9 for ; Sat, 10 Oct 2020 13:43:38 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GJs+vUPbnbBqVHsKvcVatNykiV7Rg7UUaqvKVc5FZic=; b=s2LL2ZXSOX6F4bXPGexisBmZPJ3k8Sr3e2Gqakl2QDk6oLoCWFs0Lyz8HkaXWJKf2j Mqbj4hU78NgTTfNsqWu077fQ0q5Wp7ckx/mT3xZ9pwrJGvbuuQfbC/SNkSa7PtnMZqFW mi+8LktY6V8Po1h0Pfv/mr32NpayXt3PPNSW5QV23lA+guszeatWXfb0mi6QgYqUOCr6 Otgjcn7qGKGIYftbcbTGX7d4utKgGpRH92gliwKPEeM0QBKbI94fTvUnGm/BOvHlC3Ge iqYLNX4YtxNSNlYd09NbI6mgLiBiWz2QiqNZ6CKxyjaXZoqVVsyU0pTLqljudyI2x6ku 8iBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=GJs+vUPbnbBqVHsKvcVatNykiV7Rg7UUaqvKVc5FZic=; b=GtB116Vm5Chl+CXt4+vvdMuvCMKOhcAtaopsU196igUertqdkIQIjMNbUJU/2Jm4m7 StsjNK/FtqaUUDNP1Ne4ppSPuQZ4T9xCBcKjew//N6vtfRn4/QZ9pAbKeg7GIZBUjwQz 4N4RiI+ituHTlyGfR2Mg+R9wbklY3QlYqE9fGXtnme+3+lZAtoGnrK0mrTgLIXBoJHyK lNfo1YZSN6iwQURjph68/XpithajmIPQIBjiY3ATm2AmxLCNBl0pHv87XiKT3q2tv3YB lBM5zR94qWrirqYl6VtAbcKYb+5zsVVSSEyasFGeBKPQHcmxOt8LUJjaj0f67N2IXZUw +rww== X-Gm-Message-State: AOAM531pdwQEYifNmipY3yBC6DgLCjYgKKjmys5gHEuIRLZ7jVJEMev1 0T1KX8kzLlJRR9DJmsab8Ts= X-Google-Smtp-Source: ABdhPJxbbwiuB788sbpn/3sl2yf2mLvv4GbL7Y9t1aXNvPwMB/Q6/twkA0Icla0EvRHL1yuptkiWkQ== X-Received: by 2002:adf:94c6:: with SMTP id 64mr133352wrr.8.1602362617070; Sat, 10 Oct 2020 13:43:37 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 11/20] target/mips/cpu: Allow the CPU to use dynamic frequencies Date: Sat, 10 Oct 2020 22:43:10 +0200 Message-Id: <20201010204319.3119239-12-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Use the Clock API and let the CPU object have an input clock. If no clock is connected, keep using the default frequency of 200 MHz used since the introduction of the 'r4k' machine in commit 6af0bf9c7c3. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cpu.h | 4 ++++ target/mips/cpu.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index baeceb892ef..062a4ba6225 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -4,6 +4,7 @@ #include "cpu-qom.h" #include "exec/cpu-defs.h" #include "fpu/softfloat-types.h" +#include "hw/clock.h" #include "mips-defs.h" =20 #define TCG_GUEST_DEFAULT_MO (0) @@ -1151,6 +1152,8 @@ struct CPUMIPSState { /** * MIPSCPU: * @env: #CPUMIPSState + * @clock: this CPU input clock (may be connected + * to an output clock from another device). * @cp0_count_rate: rate at which the coprocessor 0 counter increments * * A MIPS CPU. @@ -1160,6 +1163,7 @@ struct MIPSCPU { CPUState parent_obj; /*< public >*/ =20 + Clock *clock; CPUNegativeOffsetState neg; CPUMIPSState env; /* diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 461edfe22b7..3deb0245e7c 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -27,6 +27,7 @@ #include "sysemu/kvm.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" +#include "hw/qdev-clock.h" =20 static void mips_cpu_set_pc(CPUState *cs, vaddr value) { @@ -144,8 +145,8 @@ static void mips_cp0_period_set(MIPSCPU *cpu) { CPUMIPSState *env =3D &cpu->env; =20 - env->cp0_count_ns =3D muldiv64(NANOSECONDS_PER_SECOND, cpu->cp0_count_= rate, - CPU_FREQ_HZ_DEFAULT); + env->cp0_count_ns =3D cpu->cp0_count_rate + * clock_get_ns(MIPS_CPU(cpu)->clock); } =20 static void mips_cpu_realizefn(DeviceState *dev, Error **errp) @@ -155,6 +156,10 @@ static void mips_cpu_realizefn(DeviceState *dev, Error= **errp) MIPSCPUClass *mcc =3D MIPS_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 + if (!clock_get(cpu->clock)) { + /* Initialize the frequency in case the clock remains unconnected.= */ + clock_set_hz(cpu->clock, CPU_FREQ_HZ_DEFAULT); + } mips_cp0_period_set(cpu); =20 cpu_exec_realizefn(cs, &local_err); @@ -178,6 +183,7 @@ static void mips_cpu_initfn(Object *obj) MIPSCPUClass *mcc =3D MIPS_CPU_GET_CLASS(obj); =20 cpu_set_cpustate_pointers(cpu); + cpu->clock =3D qdev_init_clock_in(DEVICE(obj), "clk-in", NULL, cpu); env->cpu_model =3D mcc->cpu_def; } =20 --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) client-ip=209.85.221.66; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f66.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362620; cv=none; d=zohomail.com; s=zohoarc; b=hWSkal3pXbFSItbd2rk8Nj45cKKjZBZoZi5G680KEM8pU/ERav7Q3cN8ao0pU90IvWarZVSt/TFIN3q4eo12chKBfk2FKui7DgszM0TZdcvojoxhV+F9fuMQNd5quLdCDvxDD+T/r8UDZGUivLFJ6tP6WSKyYiPQe+L46G0XkWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362620; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=crjYYD4P+lnaJnfeybGjxAMeoUk/QLrgHry0qh2t00w=; b=E4nGZF8JVitgdlTbXIJUkEbThkILIRqbP3GRjhvl2yZIFKoE6L2cpE4Jpv7w+/9S+35R37SEyIcYFSTPTIdOi0WYcVNn98/ngIiIYmAphlu2BoMknj1OtB/7o2m3ySYGerH9LiyQU/Z9VHs6g0YJjPYQ1k1jrxuv8NJV7wKF99c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.zohomail.com with SMTPS id 1602362620373683.3415808836394; Sat, 10 Oct 2020 13:43:40 -0700 (PDT) Received: by mail-wr1-f66.google.com with SMTP id x7so5567221wrl.3 for ; Sat, 10 Oct 2020 13:43:39 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=crjYYD4P+lnaJnfeybGjxAMeoUk/QLrgHry0qh2t00w=; b=bljb66qlEMrnI2MP9QhMcKhZYwQ7Nc/5IoncdzIis/27SIUCG/UN15GpbALx1CeUvO QJQMbvRuW0l+PlOcNzao93IHGaYBx12Mz6k5kChpkjrkpkyRB4UPXCSApQfCNGSrYoYs Z0uKyu+aEOz4sjZhtZGbMRluS5HZjo/VG7nOMRYwkTikUhkyb5wi9OZOsNg8jjhK4QSy s/Rd4tdJRv3biZlI02s8XLCY+f6caS0dgbBPyn6wdXpdM+OBE4b/gNk+tCW3RlQoShUI XCEirtBM/KJCrFYePX9+Td7kCsJWTUMQ+soXC0ShUCyGeyJh3+J8sMQwFgd6otDBtImZ dz3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=crjYYD4P+lnaJnfeybGjxAMeoUk/QLrgHry0qh2t00w=; b=aAA2NzpZy5Gvz7nQiL7rbQPWo90gx9843lvAy9aONZosvDclolxQfWF4LNBsyBYS+Q lJbAJPtIVh1UfmUFcVda6/y2R6A5Qftc4Xvhs3xXcPivUW8YAFkuVgYsaneD107m4c9f i2D7mM7kaE2lmSUUqL4Xvnp2GIMDlO8FVi2wXj4AcWaZZ3zLGQlVpOEFa35WhK2JUTXm w6pkyPYAbPJadAWnBuwvqxpyD4qAH4tzRq4uUuv34QR5SqbHTv7ffSjb50q5R+6aKKoR +fFNLcUdXYQqvteR37eZBAu9fl1fdRhkhh/scFE3LdP9nviIXzxGmp9v+FStIapfiB/9 eydg== X-Gm-Message-State: AOAM533MUO9YLNPELHFk936ksXByfg+24CSAE+j/QgSqXCTujMjqu3v+ cqhyESxHflwOU22vaf+sW6w= X-Google-Smtp-Source: ABdhPJwPl5P6fDkB+GPoCkNtkTkZ6kzz4XvqBX+c4WS/ALQGcVCHrB3NJhvWMQQ5Zo+pDhTU3iN0nA== X-Received: by 2002:adf:8b92:: with SMTP id o18mr21949487wra.54.1602362618472; Sat, 10 Oct 2020 13:43:38 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 12/20] hw/mips/r4k: Explicit CPU frequency is 200 MHz Date: Sat, 10 Oct 2020 22:43:11 +0200 Message-Id: <20201010204319.3119239-13-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Since its introduction in commit 6af0bf9c7c3, the 'r4k' machine runs at 200 MHz. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/r4k.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/mips/r4k.c b/hw/mips/r4k.c index 3487013a4a1..e64687b505a 100644 --- a/hw/mips/r4k.c +++ b/hw/mips/r4k.c @@ -37,6 +37,7 @@ #include "sysemu/reset.h" #include "sysemu/runstate.h" #include "qemu/error-report.h" +#include "hw/qdev-clock.h" =20 #define MAX_IDE_BUS 2 =20 @@ -184,6 +185,7 @@ void mips_r4k_init(MachineState *machine) int bios_size; MIPSCPU *cpu; CPUMIPSState *env; + Clock *cpuclk; ResetData *reset_info; int i; qemu_irq *i8259; @@ -193,7 +195,11 @@ void mips_r4k_init(MachineState *machine) int be; =20 /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D MIPS_CPU(object_new(machine->cpu_type)); + cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); + clock_set_hz(cpuclk, 200000000); /* 200 MHz */ + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env =3D &cpu->env; =20 reset_info =3D g_malloc0(sizeof(ResetData)); --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) client-ip=209.85.221.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602362621; cv=none; d=zohomail.com; s=zohoarc; b=UkPUwXDjzHoR0FQte3aA1vXievNIL3YQZIGI/Wrlg0Hxs+n5RlWdSYWE/dCvRej6dZzKQ2OBkPz/vQ1XvkYD30dQKDak4RF2zJ2mwTT0ktd28aFHHMMVHwn3jMTvg+il0l72F273cetWuXvk/UKwNcYKwMsCVTKitRt8p+0XlFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362621; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ek5SrDH4GE8Do53h6I6t8PT0loCihX0nSv8eh5BL3UU=; b=aq6JZHZUKEyOHKzoWrz3D4RvgnowJofEUtxBuiQUOA+9dJ/IUAM/vZEELp6fguFZ+JxNyHkjpjWaeV1l8OBPQdNO2tRC3B4Hfjm4YvwmU+MpHWY5lgSW8mP+84jkohf1QrNvhtArTfHvfloqfoGZm7lt1BCsNc11F3ISKryrQ/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.zohomail.com with SMTPS id 1602362621753634.5455006387344; Sat, 10 Oct 2020 13:43:41 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id n18so14171275wrs.5 for ; Sat, 10 Oct 2020 13:43:41 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ek5SrDH4GE8Do53h6I6t8PT0loCihX0nSv8eh5BL3UU=; b=tgzyldTZBrMZ6q4KE0b1fVBtOQB3vg3/zLST3xio/0Da/pwWDWRLGxDAOuUmlnhQWf aiAdLyVmqbg0WxzPuy8LnwJyhN+tLAISFb8Gc92Q84CQlbPB8GNkwrsxjXYag1NMkQ1v bEwTjzTz0D7cA8MzfwvyRNmtRgHpMHLj08rdnMTxzQG8K8c3NToqUvGycNDh5rQA//un ks5dB3GLIjjZOQlkjWrhkXbqL7QdO2V3tRAALckRfnoTem5LrnH4+LkQMYis8H8vBa1J A4+GwQKvZlmdAp1qfXU8eEeUrIHH5NWgoiwVumIk9eFvDEpfqToff/T/wzFPyR9iDnRp q6ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ek5SrDH4GE8Do53h6I6t8PT0loCihX0nSv8eh5BL3UU=; b=I8wGjEa39I183vF1j3Jz0thz0wZ/bX3HbfVIZ/bx7tKo2i82QIo2Qe9Mx6c8Id+UD9 bwDJioO+zj1EpJua6tSL5oTQ9oW8DNMAcWAkGzi/zLibeB5Qw7qeSgLKx+BUnuMYQLBl JRvUpjPj5HW8n3HY/tui3NBklW/J/dt/31pb0aJhnYZzVKYi176z7Gi6NEvavpeNOnq2 XIDW0h2HZ/wHz806sOrvUNdxHllmhdh/DV0lcJhNeLsyNIgPRdrvA4tQmTi0egHe6vfr z2bhMcQ72zz7fZvEuSR5fro8tYQ3YZMEIhHCUCedDUuiIqpFspOXKoG0nzyeciC+Tbdw +CSQ== X-Gm-Message-State: AOAM5315uyYQmIR/VNA4f2N5VpBceZcmAWAOa395fejzJzv2O9EePCLy bO26ptauTEqPYgJvcM0pUzk= X-Google-Smtp-Source: ABdhPJzd3Eocv9z7xJb0SLs+euBqVf8vP41aduHT+MDR5PYrLioCLVgABEwH7AYTyrcUSVcMllXc7g== X-Received: by 2002:adf:f7c1:: with SMTP id a1mr15774281wrq.399.1602362619806; Sat, 10 Oct 2020 13:43:39 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 13/20] hw/mips/fuloong2e: Set CPU frequency to 533 MHz Date: Sat, 10 Oct 2020 22:43:12 +0200 Message-Id: <20201010204319.3119239-14-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The CPU frequency is normally provided by the firmware in the "cpuclock" environment variable. The 2E board can handles up to 660MHz, but be conservative and take the same value used by the Linux kernel: 533 MHz. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Jiaxun Yang --- hw/mips/fuloong2e.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index b000ed1d7f7..b25c3df19d0 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -28,6 +28,7 @@ #include "hw/isa/superio.h" #include "net/net.h" #include "hw/boards.h" +#include "hw/qdev-clock.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/block/flash.h" #include "hw/mips/mips.h" @@ -300,10 +301,15 @@ static void mips_fuloong2e_init(MachineState *machine) I2CBus *smbus; MIPSCPU *cpu; CPUMIPSState *env; + Clock *cpuclk; DeviceState *dev; =20 /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D MIPS_CPU(object_new(machine->cpu_type)); + cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); + clock_set_hz(cpuclk, 533080000); /* ~533 MHz */ + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env =3D &cpu->env; =20 qemu_register_reset(main_cpu_reset, cpu); --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) client-ip=209.85.221.66; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f66.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362622; cv=none; d=zohomail.com; s=zohoarc; b=KIBLy0tl7y3Q86r77VQjwIYihZ0CxoAubJ7DjOJ2EQGlH6fSn7OiFUgWdqgndHfZLKRmiOW93ORWzrvDmqDR9N7iZG+fFk8cRnoIaxy7xl6wEXPN128fT1IqeN/Hp1WpuursZOlQhQcEDxG3TDvDqijWigk3RkgVuGvVkGcIVVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362622; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yAfqPnpV3TT1ZjFMpcjYdcDBoe16Hc9PmfHSSw7OU4Q=; b=RuGVdiBYiGAXR60a+Oj4RPpyo06Ti+vwFM7XKbkKRTVIWtJHKsazjUZpyUmNZJU7glAj0lF1HStcDop/Ae5GL6Y0JNEC7X7ka6IaRQa2UqAhkptOcP/B/4gp+um3d83QUecKcJGC1iw8FwLXoOa/X7JjiSDJQEZVHMNXP/yvyQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.zohomail.com with SMTPS id 1602362622993521.2022644170697; Sat, 10 Oct 2020 13:43:42 -0700 (PDT) Received: by mail-wr1-f66.google.com with SMTP id e17so14138879wru.12 for ; Sat, 10 Oct 2020 13:43:42 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yAfqPnpV3TT1ZjFMpcjYdcDBoe16Hc9PmfHSSw7OU4Q=; b=XZnT9cyxuuui3lkootoFDJtjugZ2pCHj1OgA9aiHhyqWzdur7GC5v3bta9OO2dEwXd aZLYF0YJzEe0EiJ2/hMrVx4xyddqiFN3UKwKUpKRGVmkRWBrJDe3/QNRZvNBkVp9gkFE VPNuRup3BzQPTQ4fWoM74pzp9Wd3kz956krqzaw798S4Nmav9pvVigPj/g4ClqDFjKCN 44cFJxLDEQ3ntoAW1956xAFhnG+SPeOro8cfSDJKq5p2CV3rkLubefeNBI0Ayd93Ql8s J6IDlmQVivgwf3fXRjIdY/YtczTp8P3TcJwai2os/vx83gmM2ykD3nYeLKxHnTbGbYGx 25tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yAfqPnpV3TT1ZjFMpcjYdcDBoe16Hc9PmfHSSw7OU4Q=; b=mh0c5VGDDLJCAhUU+U3GH4JP0x58o5pYSprFfqgcpCxLRegEBlHU+ac4BhQQf5vmP8 xs3dVAjlML3SB4shwobP8Kmzpah5Rva7OPW3ouge9ibojBoF+PgJz+suWrG1x+yoSXxf PruVuNQtHPqXGY6L+UW07GPgDK4P9wGj0rzKlwo+vh5KE7SKSvrRuT2VLa02dRQRMnyY AwDoaaJKdCI7bosSxuTBa9GGzgEOpTfmG7IwfVctVFEzBv6qv5cAbgDw1uEXpbzAmB02 aslaBSQufYMKe/7d2UC1xUh99EcpaB8UqkIGoLtDUJS8wPkSPrYK/axFqzKYEVmiL2IY FSHQ== X-Gm-Message-State: AOAM531kws9LISCRY/qaozx1m4qvwE/p5Z+x3BMJchlvtAT/kbN3sUNc oYaUW+6y8HlIKvHLGBXkwLk= X-Google-Smtp-Source: ABdhPJwl1SZ4wjgk0tokL5AEiucFzDhv+Ks6xfq2wV/sgq3BO2IMeD1oQg3JvvBHbx4vLniw6XKUgw== X-Received: by 2002:adf:f4ca:: with SMTP id h10mr330854wrp.89.1602362621082; Sat, 10 Oct 2020 13:43:41 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 14/20] hw/mips/mipssim: Correct CPU frequency Date: Sat, 10 Oct 2020 22:43:13 +0200 Message-Id: <20201010204319.3119239-15-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The MIPSsim machine CPU frequency is too fast running at 200 MHz, while it should be 12 MHz for the 24K and 6 MHz for the 5K core. Ref: Linux commit c78cbf49c4ed ("Support for MIPSsim, the cycle accurate MIPS simulator.") Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/mipssim.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index 5d4ad74828d..b4b3c2851da 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -40,6 +40,7 @@ #include "hw/loader.h" #include "elf.h" #include "hw/sysbus.h" +#include "hw/qdev-clock.h" #include "hw/qdev-properties.h" #include "exec/address-spaces.h" #include "qemu/error-report.h" @@ -152,11 +153,20 @@ mips_mipssim_init(MachineState *machine) MemoryRegion *bios =3D g_new(MemoryRegion, 1); MIPSCPU *cpu; CPUMIPSState *env; + Clock *cpuclk; ResetData *reset_info; int bios_size; =20 /* Init CPUs. */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D MIPS_CPU(object_new(machine->cpu_type)); + cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); +#ifdef TARGET_MIPS64 + clock_set_hz(cpuclk, 6000000); /* 6 MHz */ +#else + clock_set_hz(cpuclk, 12000000); /* 12 MHz */ +#endif + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env =3D &cpu->env; =20 reset_info =3D g_malloc0(sizeof(ResetData)); --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.66 as permitted sender) client-ip=209.85.128.66; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f66.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362624; cv=none; d=zohomail.com; s=zohoarc; b=PPt5VlEBJsca5G5SJi28+lyPqv7Zn8502qlPWid7+mvdhLRX9+YHvweSlTvt+IKof9jlOIf0Q68Fg+Q52B+y3P08bs7nMo114A6iYt6qWoCVkgqU78qK8GAfvJ/pPpXjXj1qPHyVgAriwFIPNLsDZX+4EM8f4WleGKYIqs3Mfhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362624; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0r12VoVMUTuY3t4zO68E4z3Dus4xytIOTYR5/hVgU8s=; b=f0yO481hrMEfq3VruYMJUY1yy0g+MJe4wRK4Fnf/jZ8Fln8hbuTdw3VIW5DdFXR67Dx9RPnzxQHFAEzd0yA66YUdv9ehw3vDYbwEdsemca5dFSoE9lz8sA/ol6hF/pfjTJ/ltmxZZSJuX4r3ZQeMcN/ux2lY6H2sVVuyZkLMAUc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.zohomail.com with SMTPS id 1602362624266621.4199296519263; Sat, 10 Oct 2020 13:43:44 -0700 (PDT) Received: by mail-wm1-f66.google.com with SMTP id a72so2708536wme.5 for ; Sat, 10 Oct 2020 13:43:43 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0r12VoVMUTuY3t4zO68E4z3Dus4xytIOTYR5/hVgU8s=; b=OOmNf+rCJsuY+oq6W29mMirFbIEhjXNPoadgfx2xZYsCkRPnoich8ikQFilhLEHyN3 jFdsNfI/v3EFTG/rSCKIjxQFPjKsnkrWyCjUyPIEN7jfp+Xv3iY3wdSGw+rAiQLsx3L/ 0m5uelrWaTSWq3djm6f9qLKfnytoJfKcCaXZDRYD6ubg/lDFF4rqpJ1s1eKp4EJt22Zg Zf10ZTkxDS3FgmhYEqfBVwDHou23eG+I1Jtrj6CUscx6o1Q7LFqObF8lntiosgUlcJIp TyBEmOxQKKWz3d3yL8tMv/8/P0UDun7fzJCg+bWI5uuqc+NVU6xSUzT8UI/RPAeDXgUn SseA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0r12VoVMUTuY3t4zO68E4z3Dus4xytIOTYR5/hVgU8s=; b=GaQxk67/gySBS6MxVeYoFYA96URgIXJuiRTp4IBTaA2qXF1fWb9EsUuEIWAZH27pDc +oSwIZ885/wlcYKUKGQjTU3YZenz+REjxGVAVFm9us/uyZ5upPOzf6TKZRrpHcMSmYYL WVhwcOhCon+Ippww6Wsg/DqbxSi2C3aW5Y+RJiFnQsLRNJxp7KKHVWWji2gcjEhtyNHK xTOLxHMbmU0fQOnh18dIITMRiWQiqVXv5F3cw4ENy8RhWXk1zZQQhPstoJO4iquymQwd tmrg5etJzDYt+cQtd2XtaeevJ9Ytv4Shok09GudbzB6VHB/AGZ1tvLh6M93sgQhaCDeD 0U9A== X-Gm-Message-State: AOAM533ArFYU12ttMFwl9ZVlIE0GsGVeLi/uHNlK/8Zwe9X0QPGCfbPu IvGGNYtDEdoY79YR5llNOUE= X-Google-Smtp-Source: ABdhPJxKRQc9S/7ZR4utn9z55DkplkzkYAI90A8n47/cv+NT0DAgKje7aYoYZ/BXTZkkfrFgvDzmVQ== X-Received: by 2002:a1c:ed01:: with SMTP id l1mr4238892wmh.152.1602362622384; Sat, 10 Oct 2020 13:43:42 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 15/20] hw/mips/jazz: Correct CPU frequencies Date: Sat, 10 Oct 2020 22:43:14 +0200 Message-Id: <20201010204319.3119239-16-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The Magnum 4000PC CPU runs at 100 MHz, and the Acer PICA-61 CPU at ~134 MHz. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/jazz.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 47723093b63..e56e36cf3f7 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -45,6 +45,7 @@ #include "hw/audio/pcspk.h" #include "hw/input/i8042.h" #include "hw/sysbus.h" +#include "hw/qdev-clock.h" #include "exec/address-spaces.h" #include "sysemu/qtest.h" #include "sysemu/reset.h" @@ -145,6 +146,7 @@ static void mips_jazz_init(MachineState *machine, MIPSCPU *cpu; CPUClass *cc; CPUMIPSState *env; + Clock *cpuclk; qemu_irq *i8259; rc4030_dma *dmas; IOMMUMemoryRegion *rc4030_dma_mr; @@ -163,6 +165,13 @@ static void mips_jazz_init(MachineState *machine, MemoryRegion *bios2 =3D g_new(MemoryRegion, 1); SysBusESPState *sysbus_esp; ESPState *esp; + static const struct { + unsigned freq_hz; + unsigned pll_mult; + } ext_clk[] =3D { + [JAZZ_MAGNUM] =3D {50000000, 2}, + [JAZZ_PICA61] =3D {33333333, 4}, + }; =20 if (machine->ram_size > 256 * MiB) { error_report("RAM size more than 256Mb is not supported"); @@ -170,7 +179,12 @@ static void mips_jazz_init(MachineState *machine, } =20 /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D MIPS_CPU(object_new(machine->cpu_type)); + cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); + clock_set_hz(cpuclk, + ext_clk[jazz_model].freq_hz * ext_clk[jazz_model].pll_mul= t); + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env =3D &cpu->env; qemu_register_reset(main_cpu_reset, cpu); =20 --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) client-ip=209.85.128.46; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f46.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362625; cv=none; d=zohomail.com; s=zohoarc; b=DGCiHtZPC8372QhptpKxHbIjgapvS4wZywcNSikLLIvNk6wz3+WHLUak8H+LFD2njpYMbJ4SjoFWxPHkPSOvpUKgPKaCFF9UGEdm2d9tDN2Jq8Vxl2VaH77s03K3NZC6eEP4/KSBTL4LSu0TytABg2zVJ+XRYz92hURZU2eixII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362625; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ctIQLLW1NZgbCK7+6hoccFr7568Qu3bl/1p5Xwlr1Ic=; b=eUUneE2mwuBpADBRuPejtwNcEe/T+jvXAUSLE6Pwr9q+bte4t58PV0T9OTIWJbO0aw+zq5t+CHrMpCC8308DH0GD8N+SuGAs0MleGL2rNIccrLYgo0m8CVZjTWm+MeJUBlRP/nvuzDoAqyQVdCJXTNhUwCr+BLt1YJr/DsriHsI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mx.zohomail.com with SMTPS id 1602362625707672.3190495557493; Sat, 10 Oct 2020 13:43:45 -0700 (PDT) Received: by mail-wm1-f46.google.com with SMTP id q5so13271760wmq.0 for ; Sat, 10 Oct 2020 13:43:45 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ctIQLLW1NZgbCK7+6hoccFr7568Qu3bl/1p5Xwlr1Ic=; b=tDItqzi+wPveELUj41A3mnXNitrGm8FN/ffYq/Xp0u/VH0xXLm5OKqhLlTv5jTJndj /BCnzXXBfE2kr4BCfXQDolGeYlP7Dpwre3D7j51PR4p9lNyUAHdxSBK1yz3W+buC+7zk PrTYyUubixwhvWOolhb8+y15WCW0Gkd0qpzAJ9CYvpxkfiJx3Z4gpjuBsjG7hMbiZkR8 ElkWGG1hoVpgg/lCzUR2H7Eyaaf8eo+hB350QUKW6NwCj2/s2y8VS2kfFpoqTe6bMSYR dfpFfqQdoJcKsxnVdQvCmyuKpCYQJaVs9wRlF5276pUnCI5Qp0QX5ADK7jriVUXdcOoz lBuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ctIQLLW1NZgbCK7+6hoccFr7568Qu3bl/1p5Xwlr1Ic=; b=f+nju4c0qkglH72QzStUm7yLQuGjvLuzvnmqNY/XvJEdi8fILpu67eDP+saSnT/jkT YSopPgtFHsmn45vaDCumEYaC/IfpOUUAvD+SNI4AiZ1sx64+iAPGdXezPWerbiVLXRjb YRjbCecMVan2dmYJq0+1wK+68vyQ7ltmIc2sCjM0oVndFBWpUd/6//Elpg3ftLzceu+O wt5iCovlxrvtmGrQ5/fFsBzCrj8AzYGe8EaoP5MgdUbK3Z+99fuOnUViCFU746P1y9Wk VKKiobhH0YwS24fvuIUjysEHZUrhWVAeDlgabr9JvTOJ1nIevJ1xZbVU93jvi6U/43UM hTFw== X-Gm-Message-State: AOAM530oKjELjGRTTlGZ+xv/oW2diaqXTlA3ysQvG/HAd+wok8pg9a8u bUopHTdRNqhgwWZoO2gD118= X-Google-Smtp-Source: ABdhPJzRwynQDks/MLMvw+sHPH3Vr+5IXy9IL0G8cqpFsPPn1hDmZKbhg7zJYpbVeYoY6WYAoSS/7g== X-Received: by 2002:a1c:5401:: with SMTP id i1mr3936604wmb.124.1602362623887; Sat, 10 Oct 2020 13:43:43 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 16/20] hw/mips/cps: Expose input clock and connect it to CPU cores Date: Sat, 10 Oct 2020 22:43:15 +0200 Message-Id: <20201010204319.3119239-17-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Expose a qdev input clock named 'clk-in', and connect it to each core to forward-propagate the clock. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/mips/cps.h | 2 ++ hw/mips/cps.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/hw/mips/cps.h b/include/hw/mips/cps.h index 9e35a881366..859a8d4a674 100644 --- a/include/hw/mips/cps.h +++ b/include/hw/mips/cps.h @@ -21,6 +21,7 @@ #define MIPS_CPS_H =20 #include "hw/sysbus.h" +#include "hw/clock.h" #include "hw/misc/mips_cmgcr.h" #include "hw/intc/mips_gic.h" #include "hw/misc/mips_cpc.h" @@ -43,6 +44,7 @@ struct MIPSCPSState { MIPSGICState gic; MIPSCPCState cpc; MIPSITUState itu; + Clock *clock; }; =20 qemu_irq get_cps_irq(MIPSCPSState *cps, int pin_number); diff --git a/hw/mips/cps.c b/hw/mips/cps.c index 23c0f87e41a..915655b91e0 100644 --- a/hw/mips/cps.c +++ b/hw/mips/cps.c @@ -22,6 +22,7 @@ #include "qemu/module.h" #include "hw/mips/cps.h" #include "hw/mips/mips.h" +#include "hw/qdev-clock.h" #include "hw/qdev-properties.h" #include "hw/mips/cpudevs.h" #include "sysemu/kvm.h" @@ -38,6 +39,7 @@ static void mips_cps_init(Object *obj) SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); MIPSCPSState *s =3D MIPS_CPS(obj); =20 + s->clock =3D qdev_init_clock_in(DEVICE(obj), "clk-in", NULL, NULL); /* * Cover entire address space as there do not seem to be any * constraints for the base address of CPC and GIC. @@ -80,6 +82,7 @@ static void mips_cps_realize(DeviceState *dev, Error **er= rp) errp)) { return; } + qdev_connect_clock_in(DEVICE(cpu), "clk-in", s->clock); =20 if (!qdev_realize_and_unref(DEVICE(cpu), NULL, errp)) { return; --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.67 as permitted sender) client-ip=209.85.128.67; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f67.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602362626; cv=none; d=zohomail.com; s=zohoarc; b=jjPxBMDqq55ZFcsg6gwxAeIj6uoyoqdWXoE2WVlXCRG2/3azeWn2NrbJZVtJAbbwTpzVlCeMLgmGulaFGVuSGpIv1sakyT9HHAvPoMvUfUPn337zwOJ+4/gKNEEZZT7yjwAZAdQsW8DOAY7HFp9f1Vt0/JgU8dtDAqn2tDU1bH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362626; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tuhwN9e0WSQZgRYxEuwcxUwJNzQu5uaCHtzj/pF8FV8=; b=Uy4IseZTBPhjnVDG2taTMr7u9VwqSQA1q4Arx77vc3uPezjskry/npci+64xQN8WBzUeFTycDvitaDD6Crt9VvgBqxESnari/SYYeNQsF3yd4/hn4dM5Kal2EgytgeLPz5kawvdYmCe8Z1IbfO5Hqam8OAe/Hxw6KRr74NsWcWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.zohomail.com with SMTPS id 1602362626987534.4522482892025; Sat, 10 Oct 2020 13:43:46 -0700 (PDT) Received: by mail-wm1-f67.google.com with SMTP id p15so13281588wmi.4 for ; Sat, 10 Oct 2020 13:43:46 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tuhwN9e0WSQZgRYxEuwcxUwJNzQu5uaCHtzj/pF8FV8=; b=WjJ2XBd45BHbf8V8fFK0yRD+Ovc/I5c4zgpdERaxf7X5QeTph026mFwxkVL3VrzvCw FOLCLhUdJIhoG5M4Iy5NC8dixv8CUynO3QA1ohzNN5jcU5QqcHhtQYBxmzV86m6WgRNY pjuD4OX22igKQCwt5IV9RBmuqngf2aV21b9MGxs3DVveSaELX/styCJRYc5vQ3qf9tj2 J+v168x1YwgElvpiFTYsYB/uovpNMtFlqKn86VRaphcRk9bsDGLL7WdIQLOu4CeERPWB 5bpzVW8djXwk2d2U+o4E+ZkJ04VPONP2yGYAT1nPUkqxyyWdooHj6I3061Fknq5cOBfw YxHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=tuhwN9e0WSQZgRYxEuwcxUwJNzQu5uaCHtzj/pF8FV8=; b=W5HX9+180X+wktAPR1he1ZyFb6NVRM2rvcuIfrSld9N2SEp0HdSZoYKsC7irf+V/NN ANepHjqFwhPFhvMcjY4i4eT5M2oLtkKMK32cP48zBb0zR9EHMWdL9dwYElpqYURVg5Hn /f534WTLI5G8g35Phk71NIacnt8+J92AtusUdxckC+nv3Uft2EiiEOhR8Bw7eojPphFv N/IXNr5yedKqFaUAqoLobxiKki+h7sDfr0TRrkrPuWwNeNdFG6vCCMpzV7K3KMDCVVim 5Z8GV74Vk1aB/YXo63b+uYoQulgeAGOx3BWCgPrNBeM5l0tU0amvYhzb7SgWsKz5gqs9 e87g== X-Gm-Message-State: AOAM5300TbMXTqYJ02mZBszxxUz9QHaZQ3OJM52bp5977hdlH6n7/ZwQ A1fKiQQhcYDqTWA/csHTNkU= X-Google-Smtp-Source: ABdhPJxrVq9BYmHw1gI17OCYsI8WGUc3ETd+6Y7Lwrv2+52kkadbhr22KtOjeVTZQ6Mqq4fQFTdU1g== X-Received: by 2002:a1c:dc43:: with SMTP id t64mr4116412wmg.6.1602362625098; Sat, 10 Oct 2020 13:43:45 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 17/20] hw/mips/boston: Set CPU frequency to 1 GHz Date: Sat, 10 Oct 2020 22:43:16 +0200 Message-Id: <20201010204319.3119239-18-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The I6400 can run at 1 GHz or more. Create a 'cpuclk' output clock and connect it to the CPU input clock. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/boston.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 1b3f69e949c..cf2296f4488 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -30,6 +30,7 @@ #include "hw/mips/cps.h" #include "hw/mips/cpudevs.h" #include "hw/pci-host/xilinx-pcie.h" +#include "hw/qdev-clock.h" #include "hw/qdev-properties.h" #include "qapi/error.h" #include "qemu/error-report.h" @@ -54,6 +55,7 @@ struct BostonState { MachineState *mach; MIPSCPSState cps; SerialMM *uart; + Clock *cpuclk; =20 CharBackend lcd_display; char lcd_content[8]; @@ -251,10 +253,19 @@ static const MemoryRegionOps boston_platreg_ops =3D { .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 +static void mips_boston_instance_init(Object *obj) +{ + BostonState *s =3D BOSTON(obj); + + s->cpuclk =3D qdev_init_clock_out(DEVICE(obj), "cpu-refclk"); + clock_set_hz(s->cpuclk, 1000000000); /* 1 GHz */ +} + static const TypeInfo boston_device =3D { .name =3D TYPE_MIPS_BOSTON, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(BostonState), + .instance_init =3D mips_boston_instance_init, }; =20 static void boston_register_types(void) @@ -462,6 +473,8 @@ static void boston_mach_init(MachineState *machine) &error_fatal); object_property_set_int(OBJECT(&s->cps), "num-vp", machine->smp.cpus, &error_fatal); + qdev_connect_clock_in(DEVICE(&s->cps), "clk-in", + qdev_get_clock_out(dev, "cpu-refclk")); sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal); =20 sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1); --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) client-ip=209.85.221.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362628; cv=none; d=zohomail.com; s=zohoarc; b=IvhlZpvO9iEGiqLnIC+vIaFDxemmRX2ep086gN5pz7I9XybNpvszpPdoEKIsOy1EXt4Un40Ve7LGLRlCpDWipnpKgUt69B772STvoYH5j6TVa78dIcXptxVGqtv05EFapNGPq5kehs1GJZaOqxvfQabYqW5WTY+C0pHQrr22au4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362628; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XRaXNqZj1/ZpqBQYjItAcS8COgAJ0fcoH+Bv4m/WMkU=; b=gK35dIr6NioDE/D9nV+e9nWgJNOlPeCLvI1W4cj/L6i7DFXV+nl0KGEyH461UxsS5/Diz1GlTWaZb3jhZtcbi8EGsMNV7s0U7OVWOS7LBe2QhJGiJ50O67xSqVX0sRkcPzSgPilDbC44Wz/rT6y3AYpMhIAdTXgaTvY8YktNzZQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.zohomail.com with SMTPS id 160236262846648.402808968078375; Sat, 10 Oct 2020 13:43:48 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id s9so2061542wro.8 for ; Sat, 10 Oct 2020 13:43:47 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XRaXNqZj1/ZpqBQYjItAcS8COgAJ0fcoH+Bv4m/WMkU=; b=DfSXBCwFkm7AU7OIi7r40sbkp4c8IHjKeJz3mLwgCHcEg4QkLnvmP9w3p7ojnyc0IF uSLy2EnaZqFrfPO6NdT2TW2g/V3S5yCtaWUaEBMix6Q/LY+M0DmbYfZIMeA4m0sLImW4 bkYJ0afEBKuFcvcDq6wjY4zxxHbO+/7UPpLM5IuAAMJqridqqaEsoHFal5as0mU8fMl3 KXqOIqEBsOqyqzM7CJoID2PGLZ6PeJk6zFzGmMaljuKUiECRKJMX6D+JSBdaabG01jRS s9DxeTEW9mrWpiphdkcveHQbDNyqp14GsUvHrUlFAqExDzOJOvBDn4wJAkXxgsj6d0Aj +IDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=XRaXNqZj1/ZpqBQYjItAcS8COgAJ0fcoH+Bv4m/WMkU=; b=Hwn037IFaZ4gih2UeaNdN+0NvSmars7ze+Z70zhduA/c2lK8jKZeEkfrtvXNwCgAgi RzudsynWlCm9YQPCnOJbJij+s5Cv9n9go3tF1QOACXrC3wWSHQGFt0Ek93zmpjsyZjw/ Idf0NAoMaM84TDomeS/aOLCMbVDF7sNZ202FYrWev+xjyrJnD4HV0EbUK59QnIQmMTxI vW+susRcHgfM2VMcuVJaJMgIW6f/NopErM9IOGuLTROrxmneFCSItPvTiqcprCp78LF8 BBX5Q5kBd2iOQCrxP2Lj0zdmWbD5zc0EyrN8hTDnAal6KXWtV/F7Dnhm4/TZYi4Q+lNK Ai1A== X-Gm-Message-State: AOAM533SZlkKxRdraVjzbWJC1pK9OSkrp6YBWBJa9/K4TTkg3PnbZhwO zKBQg8Hkd9pBagX0fftgerY= X-Google-Smtp-Source: ABdhPJzOPmowwrrFrF0ni31Rg4i9HMU+72MjO99S0VhBrQd1mcONSnqTS/nJgkF5mveE/g1UOcrnkA== X-Received: by 2002:adf:f709:: with SMTP id r9mr21974258wrp.266.1602362626564; Sat, 10 Oct 2020 13:43:46 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 18/20] hw/mips/malta: Set CPU frequency to 320 MHz Date: Sat, 10 Oct 2020 22:43:17 +0200 Message-Id: <20201010204319.3119239-19-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The CoreLV card with ID 0x420's CPU clocked at 320 MHz. Create a 'cpuclk' output clock and connect it to the CPU input clock. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/malta.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 4019c9dc1a8..357e269e088 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -57,6 +57,7 @@ #include "sysemu/kvm.h" #include "hw/semihosting/semihost.h" #include "hw/mips/cps.h" +#include "hw/qdev-clock.h" =20 #define ENVP_ADDR 0x80002000l #define ENVP_NB_ENTRIES 16 @@ -94,6 +95,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(MaltaState, MIPS_MALTA) struct MaltaState { SysBusDevice parent_obj; =20 + Clock *cpuclk; MIPSCPSState cps; qemu_irq i8259[ISA_NUM_IRQS]; }; @@ -1159,7 +1161,7 @@ static void main_cpu_reset(void *opaque) } } =20 -static void create_cpu_without_cps(MachineState *ms, +static void create_cpu_without_cps(MachineState *ms, MaltaState *s, qemu_irq *cbus_irq, qemu_irq *i8259_irq) { CPUMIPSState *env; @@ -1167,7 +1169,9 @@ static void create_cpu_without_cps(MachineState *ms, int i; =20 for (i =3D 0; i < ms->smp.cpus; i++) { - cpu =3D MIPS_CPU(cpu_create(ms->cpu_type)); + cpu =3D MIPS_CPU(object_new(ms->cpu_type)); + qdev_connect_clock_in(DEVICE(cpu), "clk-in", s->cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); =20 /* Init internal devices */ cpu_mips_irq_init_cpu(cpu); @@ -1189,6 +1193,7 @@ static void create_cps(MachineState *ms, MaltaState *= s, &error_fatal); object_property_set_int(OBJECT(&s->cps), "num-vp", ms->smp.cpus, &error_fatal); + qdev_connect_clock_in(DEVICE(&s->cps), "clk-in", s->cpuclk); sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal); =20 sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1); @@ -1203,7 +1208,7 @@ static void mips_create_cpu(MachineState *ms, MaltaSt= ate *s, if ((ms->smp.cpus > 1) && cpu_supports_cps_smp(ms->cpu_type)) { create_cps(ms, s, cbus_irq, i8259_irq); } else { - create_cpu_without_cps(ms, cbus_irq, i8259_irq); + create_cpu_without_cps(ms, s, cbus_irq, i8259_irq); } } =20 @@ -1421,10 +1426,19 @@ void mips_malta_init(MachineState *machine) pci_vga_init(pci_bus); } =20 +static void mips_malta_instance_init(Object *obj) +{ + MaltaState *s =3D MIPS_MALTA(obj); + + s->cpuclk =3D qdev_init_clock_out(DEVICE(obj), "cpu-refclk"); + clock_set_hz(s->cpuclk, 320000000); /* 320 MHz */ +} + static const TypeInfo mips_malta_device =3D { .name =3D TYPE_MIPS_MALTA, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(MaltaState), + .instance_init =3D mips_malta_instance_init, }; =20 static void mips_malta_machine_init(MachineClass *mc) --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) client-ip=209.85.221.67; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f67.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362630; cv=none; d=zohomail.com; s=zohoarc; b=QR4pT0W4NJYl/Z8kVMz9zE14+Rj287dNJfInnzHADWWFzaLvH0EYkh2Ok4l1BXSYAVXlLlVkgdqe2AnUFm5TWSDhouwoFszHRKD+0JnS6gE1laZJq6Y8OMoyhjCVS1Mz2zwRtoOKuCANwGEuqk0Vr2x/hEF64RlWji8Mv1ewkZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362630; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VteZSfKnRVCLsYtZHNYo1AU9nWTlWiBOrpFD9RH1hDg=; b=YIfohTJlUROVqJeNu4Cb+Oyo6t3SWwt7IzNc8VMZqR2L1YpKbfV93A/9lTGYub2rIxCRbrAX8ujhLEAB7a486UXJImqV5ZYUs2/WqVy1/VcCrFG5zjxb9bXEBgeSbzWJXS6692GaD6HOtY+A2zTKaP5lw6+gGOVRyzR6L9tAhEc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.zohomail.com with SMTPS id 1602362630150357.52908501268905; Sat, 10 Oct 2020 13:43:50 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id h7so14195739wre.4 for ; Sat, 10 Oct 2020 13:43:49 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VteZSfKnRVCLsYtZHNYo1AU9nWTlWiBOrpFD9RH1hDg=; b=RwAhmhqQzoWm28PJUhmuLlWgOD1rbb8fusxp9EwYg912hs44oYYykIWrpYMjCAravH qPjTMRx1pFLyynbibxi8f9ajm0dTXGa7fYGD80+OKSYmK2P3+MIKZIOj2p5YwPZpwDRl 6m59NFahnqC17sgM/702nbUe2+XKP1WA/Mw4whh1F7+wETE33XVPE3fb9R0DH2PFm4ca 3Mm9enyfT27ZW0k/4IjmXfvC6tKlXHV4A9A8bzHN/SqC/5+/LAPV+70AyoQohNb4lp0U 8f2+8+qRi/A8LOGX/wED4mmFROzaZ9QRX6/w7bI+bpJQZ2b4/GeWJK2yPzQnxfkNzslb Awcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VteZSfKnRVCLsYtZHNYo1AU9nWTlWiBOrpFD9RH1hDg=; b=ei5xHxpLrBwP7gBuMSQDJCm6bwLcjPQp3hNjvis7dDZkHTln4Y8Z2l4pmwBQiJIm/j 8xdN8UTuLPjclMUH9Cytxq2/Dw2ueoeVsJOCWM0ABKNoR/UCIc8c9Wd5ei9EmGTb2WH7 cg85Uz/epFgADmPAdSwINmBigGY4U0krZy8dfOClKmteUz96WsUCqQw5dR0UA1edRofV K3ZuPuEN2rVw4wxtYQ+pSULiSYkLV0+Z/iRoAZm4PJs3sFmDHnwrAVMpt7YTDkeXcdOi vANb/TsOMthDwUfA5c32VSDH8IZ7ofT0j6Y6+RCcm5enMQKsoFkC+iJqugEd3XdDMTvT DEVA== X-Gm-Message-State: AOAM531KUE77yapV2lfNxAIAYSBahq4U3nmTxSIjiTwCLrSuUcndK+cW 89nygU9qkxPtGQdd9mS9cF4= X-Google-Smtp-Source: ABdhPJzEQhIuL6nbTfdCbWSKR6JpWMpjieMQWeK38qzhrMsGfgHDgK+gXbBQxaUaXRhgmTJTBFJOFQ== X-Received: by 2002:adf:f305:: with SMTP id i5mr16051782wro.346.1602362628265; Sat, 10 Oct 2020 13:43:48 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 19/20] hw/mips/cps: Do not allow use without input clock Date: Sat, 10 Oct 2020 22:43:18 +0200 Message-Id: <20201010204319.3119239-20-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Now than all QOM users provides the input clock, do not allow using a CPS without input clock connected. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/cps.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/mips/cps.c b/hw/mips/cps.c index 915655b91e0..c624821315a 100644 --- a/hw/mips/cps.c +++ b/hw/mips/cps.c @@ -74,6 +74,11 @@ static void mips_cps_realize(DeviceState *dev, Error **e= rrp) bool itu_present =3D false; bool saar_present =3D false; =20 + if (!clock_get(s->clock)) { + error_setg(errp, "CPS input clock is not connected to an output cl= ock"); + return; + } + for (i =3D 0; i < s->num_vp; i++) { cpu =3D MIPS_CPU(object_new(s->cpu_type)); =20 @@ -82,6 +87,7 @@ static void mips_cps_realize(DeviceState *dev, Error **er= rp) errp)) { return; } + /* All cores use the same clock tree */ qdev_connect_clock_in(DEVICE(cpu), "clk-in", s->clock); =20 if (!qdev_realize_and_unref(DEVICE(cpu), NULL, errp)) { --=20 2.26.2 From nobody Thu May 9 23:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) client-ip=209.85.221.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362631; cv=none; d=zohomail.com; s=zohoarc; b=Q8g6ReCUvTVb8EBunmUlBy/H/w3dsQbEAm2S1ur22H6xh2NvP9LqrqE2yfL2CSYeN2TV89xx5YSfkuYOstZrA/OvHTeyArDZaF599oKewGGT7wBUDGHbYKcoaSul+mPoePrwYLaixQ1bWWDheQVmiKxdmE5wRXLMLgW3VWtkf6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362631; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HmgC37wCjLUJVnf61J8zdojgJc5xhuHBXkX9blUA1GM=; b=h1aYkY5Neb4cCd1F/GRIlAHuvwU6AtqZgrUjFDtqg3NyjhpoHKzmkoUl5FLdnKWEf849qJ8hmR3yDWAZ1y908D4OtTGR3KD3j42D6lwG73GgOSP6AxzUig/uc7kGLkoLesXcL2v1JzIMNi4jtXdqOT1odztTa8gkR+iZniDrU2U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.zohomail.com with SMTPS id 1602362631605731.7828791422093; Sat, 10 Oct 2020 13:43:51 -0700 (PDT) Received: by mail-wr1-f65.google.com with SMTP id h7so14195775wre.4 for ; Sat, 10 Oct 2020 13:43:51 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HmgC37wCjLUJVnf61J8zdojgJc5xhuHBXkX9blUA1GM=; b=L2cCiuW1gh4KaQIQssXFB0b86mjkC7G5lKUM6vl1IOuEa7RYxGPDx+cp4HqfjrwADi KV72V48Shrst0S1S7+kqekCHaMuxwvGq6MFh1tXKSlpY65ogy/y6vgKXESIvHM+CS8n2 L4AbE4wSmOB88hMcXlR5oy0iY7PC8zDxzN/ZHmm/Ej0sKi6CaJZhooujVnzbNN5vpytq lxk44gLaEaHj3eTKH93hLhcxv1eSXPTcun88i269GDJZkdvK1ehCXoCj60cmzggzDmxR HwkLIIMugb88KYYcAxa7JcBu07YkfcavjNfSwoQ4DSeqak2Gv3ttVPYy5/WeMrSFGM1F oVJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=HmgC37wCjLUJVnf61J8zdojgJc5xhuHBXkX9blUA1GM=; b=eKD2qgmw6tR9AO2UoOxOyNMxcO3i2s6t0S3DFVNUGAChULjkHi11J4eIN/ItgUxVjs ap82Devz9jJZe6llN7fijzF/udjX3Fv8qIYnlBfxJzcq3GyK8eCb2TZIguPEJcodoU8a NMnZbGVlwiOPtf5SUBQI+q/YzNfkoJOLvJXxGZQe79DH81spS0vrD1SYq5QXlRz9Ys/h lcp1hrbGTc5xlGJgoCkiF9RG1X3eVzQ6RjxMxPgVgXbMPpKmFJCfA8JWndsMXpw5P9y4 bMz/svlWaHkttDXUETdZBL7jPrbK9NM80o5AeYMW7Ze+MRKx+jtXKeXC1hoNjPawzz7o ESLA== X-Gm-Message-State: AOAM531xczjNsskMzaR5Vav05NEqC62TlUOf5l4QPsdf9httso9vQsSi I1vyl6S1EPVDWg8TA/DCMY0= X-Google-Smtp-Source: ABdhPJzrK6R/IBjIkkKex+DEZ6OJEqH8AmIait6xHkDT0ThvG0ifr9pZ7ThXNV+ZwiRz24lX8PHz/g== X-Received: by 2002:adf:e6c4:: with SMTP id y4mr21980726wrm.423.1602362629751; Sat, 10 Oct 2020 13:43:49 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 20/20] target/mips/cpu: Display warning when CPU is used without input clock Date: Sat, 10 Oct 2020 22:43:19 +0200 Message-Id: <20201010204319.3119239-21-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) All our QOM users provides an input clock. In order to avoid avoid future machines added without clock, display a warning. User-mode emulation use the CP0 timer with the RDHWR instruction (see commit cdfcad788394) so keep using the fixed 200 MHz clock without diplaying any warning. Only display it in system-mode emulation. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cpu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 3deb0245e7c..60011068e4d 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -19,12 +19,14 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "cpu.h" #include "internal.h" #include "kvm_mips.h" #include "qemu/module.h" #include "sysemu/kvm.h" +#include "sysemu/qtest.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" #include "hw/qdev-clock.h" @@ -157,6 +159,14 @@ static void mips_cpu_realizefn(DeviceState *dev, Error= **errp) Error *local_err =3D NULL; =20 if (!clock_get(cpu->clock)) { +#ifndef CONFIG_USER_ONLY + if (!qtest_enabled()) { + g_autofree char *cpu_freq_str =3D freq_to_str(CPU_FREQ_HZ_DEFA= ULT); + + warn_report("CPU input clock is not connected to any output cl= ock, " + "using default frequency of %s.", cpu_freq_str); + } +#endif /* Initialize the frequency in case the clock remains unconnected.= */ clock_set_hz(cpu->clock, CPU_FREQ_HZ_DEFAULT); } --=20 2.26.2