From nobody Sat May 11 09:18:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.51 as permitted sender) client-ip=209.85.221.51; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f51.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602496694; cv=none; d=zohomail.com; s=zohoarc; b=nAyfZ0Ej+B53bUm7hVGreqvLH/LEh1aZRxSTR+zZrFbjqeLBDej4w7iaINZnCXoGW8bo2HQJ0yJivoIYmQQBS0h5EFU+g//zqUmKX/fU7uGBaXNyt63aK7TEoUSxQBUL45nZHMSdYPxn8u6pml5ploL1WpThC+N7lUx8XufBd0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496694; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gETh5/Gck0bTQVP31ZR4AiV0ecmQtPxoBf6GwvczWOs=; b=ISKt6Qnu2h+ezGHI5mXaG/A4S1bdx9bK1BSDJsBq1Toimbu0yEOQENHMxFJIjZsQuJ7iGDXtriKAl3tvlkhs3LEZ6JOxEABtuzG2dBtmkynZE8BVGJrDuLbc2LcN07d1PBqBpFGgrPVRtHSx/W/SrrlLU9tYdDuiEdnhw2RJ+KQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mx.zohomail.com with SMTPS id 1602496694790857.0820559837787; Mon, 12 Oct 2020 02:58:14 -0700 (PDT) Received: by mail-wr1-f51.google.com with SMTP id e17so18416385wru.12 for ; Mon, 12 Oct 2020 02:58:14 -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 i10sm5789911wrq.27.2020.10.12.02.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58:12 -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=BnD9EkWuN4fVfGBKrKaKf/D3lY4cja0EcrNxlxJ0XTwXGhHCDfFbBx/N0A+00P4fGr GfqeMxSdOxKESoblvQiCcp4Kq5L02M1e8EHhmPcaTdpTJz6RQ3dSkkBQidY4IlcedmnO 0vzlA3/wDZ14gqdX1CKo2gzg5dNQ1hTVEPYOklNnIUVbY01wv2xTYg7HvForn6jEJG17 6L8UmcVyoxLA02aU4hG2VatJ/X1PVYhKTCrQ7d7GeaO3VQKhaQKKHwOOopJ4uuCgTTtm MjwY1zjSr9Ke4hplJ7a00qZVlmILk8jEVdqKkk5eQ+8KX1UI9g1dU/Nn9rXancsGmcJ+ cKdA== 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=F7TgLtZ8k0Nocq6fGXTMNEOPUTBG8FmtNCR+p2OK1XdOLWmkp7wbxcxphDg18CIg0x CMQeanefuMVjGBctcG5sJrVehcf7o4agbDSPYzhFSmyVqzvURl99RxMuJjhFW61dZDez TT8yWmpoc8AWrhqdsiy9MPqMTwY+6FdDqoUU31TRChhhNr+Qn5JeK6xDiX5KyvoZseKL DLtgigJZTvqHhJicx7fTG/kRxI2xDFebarl17XS1PYah8xCBcsNm7/cln0mwmtE15BKK 3RFiUGXNyQ1ZFgOw9yNTH6y2+oBfimZCTNH9Ha6mL8Y4tRt8WZ+6NyS8OPI20mNbgT0G rR0A== X-Gm-Message-State: AOAM532hfFXNUaAxgOuCZi4GAG4Ta2kNV0CjdaTQcdQYhtFlzalQ2djz PI5QKEKwyq0I9sIKcQamGNs= X-Google-Smtp-Source: ABdhPJyzp3Oz7lCryfa0fnJoTqdlUd1COKkw1hzCjLMsXWfyyPMCOg5Gb01EipYiH2nnffSxKJaDMw== X-Received: by 2002:adf:bbcb:: with SMTP id z11mr28737435wrg.130.1602496692860; Mon, 12 Oct 2020 02:58:12 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Alistair Francis Subject: [PATCH v4 01/21] util/cutils: Introduce freq_to_str() to display Hertz units Date: Mon, 12 Oct 2020 11:57:44 +0200 Message-Id: <20201012095804.3335117-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 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=1602496699; cv=none; d=zohomail.com; s=zohoarc; b=DrDYhfH2aOpIBUc16n+sENhrVSum5bPV09JBP32F+ljDXCBlOK1S/ykHTbgqTmXni8rrJeudY+8aLYcr9uak6CzLZRRzKqY7B9daS9a/jK8dQt/CmpSeTgsOHnPc4DjbkatnECEITrzy22V00xpnGLaAmwMpLyycM4pZVmsJ4Zc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496699; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PwcUcNfmDXAXz3ZdCfHv1ZWyP4lS5DeJuKN8TDRFEM0=; b=OwwWtvMFOub5GK1ftf7PbWLKkPfX/nW+tU5YaOzDSFHp7NIPA3RQwrMRkn+VCZuwvadjuNTAitBBrXmyL6FULrOsbhoPlGIVgmyDWeAyk/4VQnqFzenriYDhXsp3pF4okna0+89EQeoiuwF7sHdS1TW8ycqn4GUbQq/qWA1LLms= 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 1602496699897905.8952574055639; Mon, 12 Oct 2020 02:58:19 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id e17so18416682wru.12 for ; Mon, 12 Oct 2020 02:58:19 -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 f63sm22951584wme.38.2020.10.12.02.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58:17 -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=Afke2oLk84c/91f8ro6BCV6WqmOKymh5A9C9pxGLZVplAHfTK+uHHYHxsFtcu7sxiN WNhgCsMGi1YdT1B7XD/HuShdNkLokctrEJubWgsgBOvSPk4ckjMktiDCLg/ha/Yw/3Tl B77N0+Ppsdlu7T5e64PXdlEKow7zGC7Bu+UesustIbT+1h+lU2CPEczlBrPNNJ7ZaAYh /mvtsMcgEZbXZAEpaFdbjoxC6osOM8Hk2I2OZ4/c4AazCrBhKIrThylw6+4lMiTYrbOa qnbwKpq8vpjiJSlRSFfotYs0Vtc4XvO5+hCLt6A4pPoYO6mVOf8xll7FaIeOHL4+003Z 9caA== 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=r+nqxGguPSILdyoHoKSbdtWo5CWKV1qvS+o5t7n/lgTRpQZmtTfgJbw5etgoqdFPr9 12P6uR82PWWDrPfcWUjRZs1OVtlEca1AUAuzrjx2wbxjPNgicDwk+dxQi43yaE31QBB0 RpsGl1I/O2xB1RXmhinQYpvGpS1QCPk3rDOB2wStKYyCeACezWPeoOPbE8NbMFcKZdIr v2zf1ATgEYbcY+EkMB1teAtWjR/MlKfWqOtAFP2AWdOFV+moyQk0RS15HwTQtQuYW3g/ g8Tylr0odtXMsAK+7rWbi1fpWd+DFhnPzM+m8mgn/oXod9YJ+DB9Q9tRaXR5LnCnu15v V6vA== X-Gm-Message-State: AOAM533+XcB9vjkUeVPBrIfEJUPAWfcyQmXbsY9CZSruYcghd0ihUnAP b9KmQDinF8yj8LtfxXV8ejg= X-Google-Smtp-Source: ABdhPJy13cIQCD/UZGSJtlwqhG7e9HriF9Jph7dReRID8RnEZqd/dyxWDAgPo5aQLYvqMjip1biS7w== X-Received: by 2002:adf:f247:: with SMTP id b7mr2966826wrp.56.1602496697864; Mon, 12 Oct 2020 02:58:17 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Alistair Francis Subject: [PATCH v4 02/21] qdev-monitor: Display frequencies scaled to SI unit Date: Mon, 12 Oct 2020 11:57:45 +0200 Message-Id: <20201012095804.3335117-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 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=1602496704; cv=none; d=zohomail.com; s=zohoarc; b=HU3PpaXoDuaLNvyvNvMlG0b+SsRnvYbi2g7PRbnVBblPu0f2cYPb90SoGYKA7VkWI2Bw7YTotMUxwJskihQqySfngNwmm5XxAgVGqEsZ5Xu9dmUP61zSrIYqyczYRZdivH/dSK+LFUF5IJrep+7zVyHkVr4hrjqOlkdFPABpXq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496704; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TJh7BI4acX0SbBZ5nZKwJOsX7BWS7AOVMyaKy5mLNnQ=; b=SfmaF66uptyU7B0YTKjtFBXp77SRkKPI1LT5DAQml0tx1WBYFjfSeG6AJ0KC6vOIJnyNcnYozw0QCX5qBFGZuOUccoJxKA+BJCRb1ZLuypLdAghBYgkxe68WBdYYjFnPUSMQt2gZSPMHTjzTjMzfawtxgrunWQ7rN2Nbd3m7+nk= 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 1602496704908423.69096578152914; Mon, 12 Oct 2020 02:58:24 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id n18so18449885wrs.5 for ; Mon, 12 Oct 2020 02:58: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 b63sm24768438wme.9.2020.10.12.02.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58: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=TJh7BI4acX0SbBZ5nZKwJOsX7BWS7AOVMyaKy5mLNnQ=; b=Lv/TS8qXfKMzJ/M5MTqQnDSBHyFa/kR9hoBDRvrMI2cQvbPYn31Edq06Bm3EWtv48+ 0M76UiLbhag+d076czV/DZ+ayKJibzozlXLouFgVCjHovGIKYEK9Ah2ilqtxP2yuPcRG HlceeovwbvKH/DGLaxOt9ohL9u5fIwfG3PtUfBssQ/SaT4jRhk9OaDU7jpdm6w3F5KzL KAIrDn30q2crj2zOgPHOiQ60MK/3UPBSasWrU6XN8c4EH9oFmrbhNSnN6t55YEk81obk gFmztb6lcEhAcxGqIoZA+sE7Y0N/fKygjrIg4yktezJJsGc5vAcH4v8jGmSkCx5SYHho lGTA== 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=hMKtd77lwZ8e0tvHmHmpyYeBxgx4BOE+caA9wl+vqg6fraQYlv4qaLMoci8CjvGn9D UJQEmsNnZGEdbhn9frxcfatlCOCKcOGXegs/+t8Hb3sBGIsKc3SiinbSbzmuIU7AsMVs PEVlmlNrLdgjKrj0CGh1MiXwweodPku+Onmw8spGEWGr9mjuxP+O8TtwesSi7g9VK5Z6 qdSEUqZgs7hMSVjfWXrknLhC/u8s9/n8HQrkKZiWqAng6Rbw/g9wSRKPz+eGXtHgdoDk Wdv2RswlZ/QSIazrJUMIUC6APbu/upqlfat6rCV6A2a+5QWBWd68mPc30hl5l2FtZynH KuqQ== X-Gm-Message-State: AOAM532yWkt2qnrIGJkRHwmo/kPb/5BER1Sqg8ZnQafhNHR4HiBASsaQ 1jTKNDPfjKlBqbcs77874O4= X-Google-Smtp-Source: ABdhPJyoip+VpcdQ3F2bsI/C2YIXIjphJ0CcPY4vT2U2ISF0ShBapLCJdr2xL6wMl/FH6EK9dmUavQ== X-Received: by 2002:adf:9d81:: with SMTP id p1mr28048520wre.13.1602496702949; Mon, 12 Oct 2020 02:58:22 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Edgar E . Iglesias" Subject: [PATCH v4 03/21] hw/qdev-clock: Display error hint when clock is missing from device Date: Mon, 12 Oct 2020 11:57:46 +0200 Message-Id: <20201012095804.3335117-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 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=1602496709; cv=none; d=zohomail.com; s=zohoarc; b=kWHcE0L5jTk/BjSQ5mC5Yyc7TO+0EYee7L0c6U4ept9PZALk6HLVqbf7zNSDl02rQxTCMOsnsZsdEXp7TvWY5Fkxqr2pZKNU+1Aq3tgrZxWsjN+27CuNuLF3Cc8tVbIpNOoxUn0Veb0UCjmhn7+hemd5HPSjWBOuB97fF2OAPP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496709; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=TeRKKLJ/2VN3HwPdiK2eCgEgQwhsGT6OxQqYagcl1+LeZmbmReyVM8AaIxL2Q8r/kUtvUJKR83Fm4LnZvM8tZ95U0gNWuD+jEpTamqI0QUIn6Rm1hIbQPDGLi/9HJTJEaq3/DrtRYT/sGD/YgqT2s5XH+WJEFM20s17yZcpSxz8= 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 1602496709757820.365148600446; Mon, 12 Oct 2020 02:58:29 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id e17so18417299wru.12 for ; Mon, 12 Oct 2020 02:58:29 -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 o4sm5818180wrv.8.2020.10.12.02.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58:27 -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=dFmegpwxb8euMMRQQEGMouVsG2+0bmiCmTc0ht6OmWPSLFoSoSMjMpADS5CUOatHvg DQr5Wm7vAKUd7yPABbRsudghPUAhLKC7yT3RfcwGdno1nmgLNpiDOM1f3ZgzrFGhHoaQ T8UlI23l9kcsPTzqhyAM2N/YS1OKnHQgQMymlhZrQ7bo6qHorS2YJ7Kp7LbYkzo6BhYz 872jVlV0QZuOblFYoZNfBdK/1YsUjsODx29mYRBO2GfVK0fMFq14q9+jVWcYuIR8ZUeu U5Q+Oe7Q5gel/TsmRi7ks2TIm7K25tZJeZk7DyTt4mybBZ6eq1IVTYQy/RELLevpmV1E IfIg== 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=Dzy535/IGThVqzI3M6FUCsmQ+dik2/AmQ9DjqsNyfjVPjgJQSMnq4oZsq61Q4zfb/c EPzLiD5wHBKTwVzk+RV6z0T3o8kEKL2FacSMdFLV1bVV3vZ+GqQokIFGHd0pRUW4pTzm qPLhGioDAlRG6IAVNOoOgiv9YbsJ8G5l4sAMeW/yd6qzsDYQ5a2nv6tHIzkogb42Wcay c5RxsqEB2kzNz4mmCbbeCoBiwR/117/asYy/FOUR1jFV8cvI7B7UHXmq6b29e/JOk8yD /6QAT1CZsZAlzpQPYXKDDSVbjRFavxoAw2NZgPzbtFEOIbVv9qOPtKXqdoSCgjUgJvic nQ7A== X-Gm-Message-State: AOAM532PA/euZNLNhRXOEr4HlkwhYOm85BgofSGBfVGXB4INRTtjGDxe 4m/as24VCHtmf4/dcrLxm9I= X-Google-Smtp-Source: ABdhPJwFbeoXx9XHDBEuZvQYFu1qwSYmmyjHufFRObDw6JwXbGePhOXWueLuA/0O56yomKzXYNqYwg== X-Received: by 2002:adf:de89:: with SMTP id w9mr6094617wrl.212.1602496707924; Mon, 12 Oct 2020 02:58: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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 04/21] hw/core/clock: add the clock_new helper function Date: Mon, 12 Oct 2020 11:57:47 +0200 Message-Id: <20201012095804.3335117-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) client-ip=209.85.128.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 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=1602496714; cv=none; d=zohomail.com; s=zohoarc; b=NR/0LJ3Ii1ZnfsjQM/S5EZBcRV/0hNcjHJPdEnBiR++lUqnTzo7C3qkUsjX9ad84sdkyhypkO1S2m9ou8btPfjU+63OGMiwX0aJgP2HuvX02z72Zips7IzXYAhX2nE1zoWHWSD1MCSwimC7CPrkT8CMZkSPm8HJeiLaMF3HckE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496714; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WmL2Cw01Ae/xf1QUpqX/8MWanyHWKt0nSifDF6+l7KE=; b=ASlGLEZW3JlFqZW4xbvzxZwbvMq+xc8vTUvQL7ddMv/y2md+yHfHK1PdGSxH9bh4gh/XYYzHORPi53yS4NlA65w1qTFnmNbJB6ga6FginUJZiQfuMeuPpuEGTL1y9GLCX7SglRn/0e9MMn2vAUP+V0n/gq6mooxw0N1Bpupgj4A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.zohomail.com with SMTPS id 1602496714712451.56911360351614; Mon, 12 Oct 2020 02:58:34 -0700 (PDT) Received: by mail-wm1-f65.google.com with SMTP id p15so16627773wmi.4 for ; Mon, 12 Oct 2020 02:58: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 u5sm27303231wru.63.2020.10.12.02.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58: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=WmL2Cw01Ae/xf1QUpqX/8MWanyHWKt0nSifDF6+l7KE=; b=iNJl9tRdmv+9EF3MsRTpb6oPo+NeLKCJzJPbztj+WW5fBn/6wFhXHBjIPF0FvYyNfS l2fZXTvDh04tlzoH3GjTYkhvyLgXwk5VcnWT2gjwVtOMpibrPErGXO4YfjHoblaVK/1u fYB5OhFk9qQxivcMKhv3mc1heNRJ4sCYLNl4StkdmOseaFEdsxfWIeSRBGFpXc5aqC1o TyTtsE5BWISR4aMOy/7FM328ERm+9HxZZS6WVIXV5GMG8yQ15HEuUhCVSmGdTi0tr/c2 PqtdYezUMqaTfCjO06SpZvMBjOETJur3Stj4RaVH9VhBzm5K3pTM6KGCtwy6ifyXDS9D /Glg== 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=WmL2Cw01Ae/xf1QUpqX/8MWanyHWKt0nSifDF6+l7KE=; b=k1bWjjQls/DHkkdsxdt/OAClPaV3XrvD86t6qOPzYHAtXXLzW3/XoJFc/vfCIQkxIG 8d0S/8i9KuQcgbXj5jWUOA62RL1ur42piCj7vEU0qyNjRyRQeOTowZJgSPP6li5bKV9i 8aVkuKrp/fh3N6zaFe3NBjmQmkC/x8uYqMbL/UNk8BEMAfx8AmQss/uO38KmsYzxR4py yXHj9rKDUqvleBCQ7BQN1ysbKiTLNhVh6ftGAhFLdeaHULn2o27Zo7tqMkltVB+iEWrm Gr0DCs5UCTpvAeHszZw8ugfZT3U9zmGENeJGicmdpcrSbpFg3npmXX51QuE6xuym4UYZ EDSw== X-Gm-Message-State: AOAM531GlzXh6ki67k0/ZVpjKzKv7J8CVT+BD+tTTr+hxSMMtw/ba+9K Ka8NkucOg2/17cHH1w5rrbE= X-Google-Smtp-Source: ABdhPJwfzuZ+p2dAx9X/sTi2r3XqdBPt6ai9ziGh9PRoBzeaKo0OJ1V00H85UfBKSbP8q6acbCPJOQ== X-Received: by 2002:a7b:c20d:: with SMTP id x13mr10682546wmi.83.1602496712904; Mon, 12 Oct 2020 02:58:32 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aleksandar Markovic Subject: [PATCH v4 05/21] target/mips: Move cpu_mips_get_random() with CP0 helpers Date: Mon, 12 Oct 2020 11:57:48 +0200 Message-Id: <20201012095804.3335117-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 used 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 Reviewed-by: Luc Michel Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Sat May 11 09:18:26 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=1602496719; cv=none; d=zohomail.com; s=zohoarc; b=j1/SlhH8KhBphsjgIB3pziGfJ/ipLaR1rm/ZFUGK0G+n8pdbMGG5lfC2FbphuwINpI8N2FvsLv1jJkyKQAh3IgInC3QQTuT+5b0t7JKfdsTcAzouKStZYbTZ77hrdHbclGWbgH02mLp9M86oY+MPM5aIQiBSh4e1gvfBMcTFFLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496719; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W69f1MWd6lsJIyf72MtAUNNqNrrt140PbQJ0VWAk4GE=; b=hUgsg6fIXPOBUdr1NkKlPDHHlMSpZKfkLo6GXYGVjzrt44kpMBhcCyTjIo9u/7woKIOLii2WlgF2sHXoMsqsxF7SBxxSrXSoyDbo52Y+OBT5HmKI0A4BRdrJ/rMA/ue1+3QLoKHyr6STsZPUi9Egw2dNWMb3KzbOCTXsHacF/Nc= 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 1602496719658548.4584997242285; Mon, 12 Oct 2020 02:58:39 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id g12so18426025wrp.10 for ; Mon, 12 Oct 2020 02:58: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 y66sm6111467wmd.14.2020.10.12.02.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58: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=W69f1MWd6lsJIyf72MtAUNNqNrrt140PbQJ0VWAk4GE=; b=q2o77w4PonIUwOsZD1vKUPejn1owgAcjw6ECoTE/8+QbGSDdeda9Zxgpq0Ou00Nrgo 9nPcELq+JiDLc5vPW7F051blAXDFGZimhEUCts2VYtVYji32vLtejqhyam1h9VPZ8XHP K1dMA7bWBxqNaGnRIwp27CAtOFGhZYbiqc89UdREvQbmyVo3otKIKLdjEhkkxQ2eeNUx lod7FU9H8z1hI/OSaiJ3VTlhVYaL3V0L2VfKAM93iLSafqgv064VS40SulQDs0a+LJND MtM1S4r2xcGDIEpyMFDcY7NniaXJchiH+1qEwx/k/gRrsQXoDAdPMJGl9jQUjFXYqyp3 1eXw== 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=iDl4sLm8lmy+w2tY/BpAT0NNj4hhcgv4rGPSUuKfyXQye+YBemYVAtEIf5Af+a2Iya R8MjiovpTzQzqFCCxmJScP0g7oo6yVIq7CYi+F6WroUufoyPfIv3Cj5iRb7sfCFlAQ4C huilzlqAcfUSisT3L2BeBhSaX25SVQYvdxxErY/hyqVWw0oHlFuMcRbzXMlK3WYGMXEV J/sez7E4Ppov/ryr9uSAuSDzYSLek8Vh73l5b2xLUw4hxuJXlq0iMATnF6XeZZQpf3pv QXlzxXSuJMIWCu7Sbp5CMnMo0bOdDgpMN4ysMrrHkO4WxVHKCV8eas4ynd13iDZaoAf/ pFhQ== X-Gm-Message-State: AOAM5306E8AOfcKntQVTqyPWc3IQW+A6z7FatKYw354kMCfoCAAQ6iB9 /jW4Dwonkq4HbAJY+I9wtyg= X-Google-Smtp-Source: ABdhPJy1J0fwTHvZzL2PvVZuHpIQ6+1hkzG7l1VDGW1QGRwcjZUV+CVKWb45g4h7P/CUgS8BOEu3gg== X-Received: by 2002:adf:912e:: with SMTP id j43mr28760542wrj.325.1602496717819; Mon, 12 Oct 2020 02:58: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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aleksandar Markovic Subject: [PATCH v4 06/21] target/mips/cp0_timer: Explicit unit in variable name Date: Mon, 12 Oct 2020 11:57:49 +0200 Message-Id: <20201012095804.3335117-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 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=1602496724; cv=none; d=zohomail.com; s=zohoarc; b=lKCGv1z0Z0LvyxNvpfsBHqnUnfZDa/rZ1cI/FmF05ZZCP2U+1PvJZPijSNwwA9I6SAIOsNTyNHl3XDF7nBYYSM+ZbNJS2eES/6BpLe05/oMzTavpJr29oDXZwi+68+5mxJZ4nLHaCGbZ78vXaKwhKHOMzuCJ8d5iDky+nqncV9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496724; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BslzpywZz3mbJWKAE8qW6xsdeqX9i4THsloWKfBnQUU=; b=miragI1x7UwXaGRX1jxNioWysWGHEk0hRE8cesF3SNNMK4F80jO+/jf9XfirUSGZpywMsWmqP+E+KsrBYc9PKLZd2ONd7Eq7GgHpKTsvj9+/9+2t2G75IkAEG3VOMeUmEh+ft0YfYM6lqyvdTKoqImiXiOXdN8iPXqfMuxuRF5k= 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 160249672458550.29479038941918; Mon, 12 Oct 2020 02:58:44 -0700 (PDT) Received: by mail-wm1-f66.google.com with SMTP id b127so4116647wmb.3 for ; Mon, 12 Oct 2020 02:58: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 p4sm18509023wrf.67.2020.10.12.02.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58:42 -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=Nwh+UZHUYlKehslP0zzY6SNy42Av82JyPRBoOIZ0yLgo5GQPp5xUzDX709PVfKEwK6 EGovsbu83i+W0cATt5nzH0CKV6ao4F2Bj964FzM6HM9QBNHhWabDjzJwjh8LM9TSzBfT E3QjUVrr0X8qrPI/tdVSPJjoivo416sMQ3W9uLkbhsB4GuKeeaCpg93pFGkte/z8YtEe RDYBovhhg0OvXZ7hrSAEpC+qNCwyimlbGuWWOo/cE0olyZ8rE46HYKZbcDjQNo5MfcES 9t7yFAzi1gGCws3r9hh4+tzrU73WuNh8FzLh1g9V8rAhP0Mywxfz8PrHURDO8+TyM96d Fr3g== 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=CWHZVj5UYNAa7eFjq36vVK66D9vqTHQstdqHzLA3BBhEXTleKA9I8aH+WDY1yOG0kO IdJk83fOi+AWsIjuahgaqV9DKAuw4ZsL2ZdllnVApCsB9+hnoUBk/FwXAsejUZlzeC1Q +Uhe5H7dudQyGXhTcA87pTh7isj5bA44koxhYe7YeU86bfoHPXeEgIXrWGImapQTzj3Q 3vLPinqvQ1mgxn8ltqSOJO+jfngocr1c07wWe4dg/zV0Uw7iYEjt+6+jTt8pIcgebAsQ zYoyIa/5BZ7jRamALhy7ZNylCHJdSG9560H4WVZHaNAmpHFCsXkACoKV6D60Z+VBFrkV 5XVw== X-Gm-Message-State: AOAM531E61nNXfPpX+ayczZScS/T66cphqFQ3osQKJ5RepdT/oaVQsAs FTR9Fk8hRW1a0F0G+R03HG0= X-Google-Smtp-Source: ABdhPJzalZ2YSu0yCWKEpr4Z4BQCOopIXMQhbN81ghwst7hkVLMevO6SnVLpOKsb5SBQvPkxGU1HEA== X-Received: by 2002:a1c:a515:: with SMTP id o21mr9941774wme.75.1602496722782; Mon, 12 Oct 2020 02:58: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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 07/21] target/mips/cp0_timer: Document TIMER_PERIOD origin Date: Mon, 12 Oct 2020 11:57:50 +0200 Message-Id: <20201012095804.3335117-8-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 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=1602496729; cv=none; d=zohomail.com; s=zohoarc; b=lZSvLx1v0EBRVE/omi1PSyY7frSrtfW88HzfNF1i9wJz2V1ZITrh/PAbcf/+sNnTFFItkrT0SaoaVdf/u+9CfNsJlC/NYnMse2h/q8a9BesSG4GMHZhg1+4gyMukOXWX1PI1Jl7YQt7xs0Is0gGn8jVLX2etBstvbLy/BYs1Oz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496729; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YpZ3Uuep0cLzPYC8Zcjvarbsi7fcC1N6ZWQum3BDP3g=; b=LSec4e5xPmjyEsdKjFnOnqtJ/fJf4GggmolRogByIvx24ziExwoCufA87jz0KqPjCnGjw6+ygl4O3tsYYNTunz8BV77pEq9kANh6715bNFRCwAZc1T+Qgxzdhnc7mymDt8/vwtgm4SyEx3Fo2BBTDNnshnt6foVayYK3mUmvhiw= 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 1602496729805331.44813628329746; Mon, 12 Oct 2020 02:58:49 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id y12so13071505wrp.6 for ; Mon, 12 Oct 2020 02:58: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 i33sm25610419wri.79.2020.10.12.02.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58: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=YpZ3Uuep0cLzPYC8Zcjvarbsi7fcC1N6ZWQum3BDP3g=; b=qoTQSRc0XvTkGOum7nfOOBQKeszs2Q2cgR1bdWenKp4oAHTVvJ2NmfwtTTHKtVX/h7 gvVY8+v/hTQ9gx0rGT2cN/m3si4rqmABKFSuln9J2PqlP4oH7VmhDszRQ9JOoEh/uJkT 4EVUWPsqsyK1snWe3BwAtOefgBgcIGD6HnVSxM4oDX9cfHGnadGr8Btgm23J/jyxzhNF /+dYCxYJGNSqYjaVZGPEEn/uV+1PhxhHkPE9WywPzkgJgHvXNV6IAPK1v/fMnR7ra58R b+NL7wALdLd/InJdXVNUO6h8T6Aa8MuPxKSQ6SbMsQVK9ZV+XZo+HuB0sfQosv09IJv2 CkGg== 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=YpZ3Uuep0cLzPYC8Zcjvarbsi7fcC1N6ZWQum3BDP3g=; b=Up4U/kmT/82Dj9Qmh+UmflNSeS1sWljJJMwv4Hn6skUeoMjOtz6BzGQw/nFHSkhLB1 4bXdE2D5hrAVhpnvbUrOT1CwgU0CY5nQs3xHdBhrfBxM3Hpj3mZMsdf7BJVIhQcwRzB1 ad0Lann1JToG5WqJk7S3FzbeqbmrtEunGAAt+FoC/j8YRyBKQdAqTaVOK4NHdrMll2qv u46O0jZCFKO0bf3k45emLuPxAm+0K88+gECfoVSmV84Ksz4TTZuLonJ9GeyY2F16zSsa L3uhqLG06E9d8bpJOH9H+0otITHMsRiSkIedJtvaw/o/28xLsw/HST9s54YAadKbjFat +bkw== X-Gm-Message-State: AOAM532vVjI5UDpHww8h4i+HfOVszo7f0Psu42/PyWGxa8oB+Fit6cyj Yv8jqx+dfoiklWDTJBbOGq0= X-Google-Smtp-Source: ABdhPJxxg8ss+ogjg3IDSS7sM5Q/4+IvIH3u8NxT/KChe+7wjT0cxTLetdlWexF3E7PKMIC6dILEpg== X-Received: by 2002:a5d:5344:: with SMTP id t4mr9499676wrv.267.1602496727859; Mon, 12 Oct 2020 02:58:47 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 08/21] target/mips: Move cp0_count_ns to CPUMIPSState Date: Mon, 12 Oct 2020 11:57:51 +0200 Message-Id: <20201012095804.3335117-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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. Reviewed-by: Jiaxun Yang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Sat May 11 09:18:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) client-ip=209.85.128.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602496734; cv=none; d=zohomail.com; s=zohoarc; b=ZX/kwPgsAXqOXTCTgwQnQa2AN8N+t6RuLZr9uKiiEB3X/xnbP1eNsbqkpD/j2K/X05+jtNbDlmHKRd2ERa5vB7EAPbBXJcYpb/brfN90maJGIrL8/U/014v+dLeY5MOL0xvWm3WyIcDlVbcJlbUR+hUzFYHaN2suQuEE4YKZsuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496734; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5dM1prX3X04GapBDfDTo/Yh6oDCmLyBdhUwYpLbSa6w=; b=NHYRYaH8CLRxV+LiNTsXvvZNe4d2zt7Qa59MLA4K9Q/v2vFGBjyz+RgNozXeaNASrtxGQDrdLkPmGFlZ0y61u1qzL5bCKdtf9xCkPI4GhVfC0NzcCDzkfTIoD5e9bvl0EbRUDCi4oWaLY9+/pHvKCdkdCr+zksDCssnJWR4/SiQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.zohomail.com with SMTPS id 160249673481246.49248821355445; Mon, 12 Oct 2020 02:58:54 -0700 (PDT) Received: by mail-wm1-f65.google.com with SMTP id 13so16655591wmf.0 for ; Mon, 12 Oct 2020 02:58:54 -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 y66sm6112296wmd.14.2020.10.12.02.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58:52 -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=5dM1prX3X04GapBDfDTo/Yh6oDCmLyBdhUwYpLbSa6w=; b=oWG18BDpdc04Bx/JDKi6avBzZAJMrSZDk7qquAXpLo+hStIui+sdSaDJhd3OJZaefK SJogdUUyF52NApSt2PLDtdMfes7jY39VFVnlfwohEO39wOc67dDnuCrMY4/80I658uav W7cQKmRmy3VkiV/S7Ql33vIO09j2sSwo97tlwbySMmR1fpaOD9N0RPuDLhF6YtykgHpe n7jQDZ0cfsRE7aqJuyFaWApyZtUnbLeBQdLtSCjO/YinZ3f9rGBkjGczJ8b9zF75oFc5 jmXk0oVls/peqal2WnpoIHy7ID8A2fwmu9DPpO6y2U7JCpwvoITKM/PFVNZZza2W0RGP RzBw== 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=5dM1prX3X04GapBDfDTo/Yh6oDCmLyBdhUwYpLbSa6w=; b=f5sw0dyRytaxLHbbkhH8QVjkkmMyUR3X/UutIu4dR31EqMkpGtBCYiy7ih8h/hmQ6u v/YtYoTuhBWVtirQHYlWBbuGisLqTEoE6jMag2QXoGqOonI/jMyXb7qtOVfn+EaIcPIt LWiXSNzGnxN1FfXJ3ncFfCCUnSHkBbUYNnQ5JNL7ba+zIrV+XhwII0cdjBgaOA0tu9Az jPULHh0I5OJCoZLGpVUjnU4VK2XxkAydODVJvZjp8Q6y2QHwfVrrDfSfDN3ZKZk5Iqpq QS/8tt3tTV4m36w2hsHH41R2Qcy/F2CpXWhdAmBWsKSvEekGR38983Qzw8zsFMC+UpRp qJOA== X-Gm-Message-State: AOAM533NzdKA1Wdv6IhfT0NRReR/QllO+dnAc1I7Pt1Pat/kWBppbVsq E+lLxZp7GohrpO5PHHj1iTY= X-Google-Smtp-Source: ABdhPJyBM5GPazNhKDCAInhdt12GfOgErmbGcZmW/Ev96kd/1MTPVrSBH/Vc5VuVrgNh6HpuucEakQ== X-Received: by 2002:a1c:e089:: with SMTP id x131mr10479209wmg.78.1602496732821; Mon, 12 Oct 2020 02:58:52 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 09/21] target/mips/cpu: Calculate the CP0 timer period using the CPU frequency Date: Mon, 12 Oct 2020 11:57:52 +0200 Message-Id: <20201012095804.3335117-10-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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. Reviewed-by: Jiaxun Yang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Sat May 11 09:18:26 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=1602496739; cv=none; d=zohomail.com; s=zohoarc; b=IesNYzeHVvPEWWs70wvptsa+8FsRS2oeEUPwyHMhiohN4t0z2R9ArcdfxEyywNIK96NV93L5QZppBXsIskhtr666jCgivT1rKxwqKXZ+pHVr34BnAINpSqgZeeVRboG1I4cHjy89jGVBoUF0DPTT1h9J8nkjtqW+ee0Kawbhu8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496739; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i1cGbjc5Cl94JMQEfZlvF0v5MlNUEPZb+r7dtqjcBUs=; b=NP/c44qrJcZX73nDLUQwYY1mpzYh/HKmq//UlDnIGQlEkrH4BwwDgY9S+r8/t836PritP8K59lmoXet+g+HtWJ27cyycFyxn15RiKhYXWlVvT+T/xvzOq9d0g86NK0aNGzPxGj/rPchYhbiROAPCtqlmGqeLfDQWVHU86mTptRc= 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 1602496739770262.50867257749394; Mon, 12 Oct 2020 02:58:59 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id e17so18418990wru.12 for ; Mon, 12 Oct 2020 02:58:59 -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 c16sm25182785wrx.31.2020.10.12.02.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58:57 -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=mySgucuT+mIienoSK6h9h6BhwOCkdQESWURoe6cGQrndcSemCzwjGKbyVdbm/KoWk6 xpAJUkWycjMVf3qebDnFF+eiUc+6GT6ryxNh25iaxDpR8aaNf58/lIItfahi6qM9nVFa YF3jigf/MVgj8vuC18QRcUHEwJkgKdc6+jAOtixGWyEIooYlVVx78h4dHeK2pw0KaDe5 QaIUuFu38qCGC8Ll2t4FwppVyitlAJwvAbonSg1zfVzsSDqe5eyrcHsfPZ2opg4IMqG2 7EPgSqkDcUEkcBEVfKV/ocYRNRJic/clt4kbTVfEg4oPU79YtSaAW80aFv2elqEuJ+Cq HBbg== 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=OQLCPmduTillQc5HCY8O7q2njFJGOMzNEV0iR3/R8k9hR1ZefaUcHHGQbDZhT6wZoY tiw0v9M6Ga5/G8XRkEqGTcEMHrouR22THzkUuLefC5IxDOtWEmKglgf4XjcXr/YoE6lZ MKH7eQaXCH5BkJaJYix4b5iX+qmduirnrKISq6xPf7kJ94qKkwkb6+J/1Af6IArd9zn7 DOhqaS3dxgDZootmuEO8jLJAfZ6mt+6qh3vEaV8x7ihOkI5kG66wIuhKWxtqG/WKa3v8 2wyzw0WXmf8ZtM6QSSuB+pal4A8eJS003GozPMeDE3+ddc4xHIQnA7DvvCvq+MMlAKGU V3qg== X-Gm-Message-State: AOAM532bC1qEOWJEaEkMSBxC0WnoMrLDrNxgPK+kXsjaF4ZhvCbI6Hx3 Mw27WHu6tq0cmmoyrQKXBdo= X-Google-Smtp-Source: ABdhPJyWzxBwslLmWAk7f7s7LLJ4eM2dKIiWpY/UMEBltVrLsrGiuPSfmurlXoZnMuYeLGkGRA8LfQ== X-Received: by 2002:adf:e78b:: with SMTP id n11mr30170491wrm.280.1602496737732; Mon, 12 Oct 2020 02:58:57 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 10/21] target/mips/cpu: Make cp0_count_rate a property Date: Mon, 12 Oct 2020 11:57:53 +0200 Message-Id: <20201012095804.3335117-11-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 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=1602496744; cv=none; d=zohomail.com; s=zohoarc; b=LB39jhsBqmTW0uOgzw3zF7UdeJ61S8660DG9emuEUocs5cYbbfu9SkGDSe8FbWvK8+qNEwrCpAmVxDA0zbAxlLfbkWJuFUIFJS8Lzd8fCbff0gRKT6GahhDpYaXc6nXydywIRYM7KSWORGiiBn1Zg2UvGHWCQok+eoL9oGjEJ4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496744; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GJs+vUPbnbBqVHsKvcVatNykiV7Rg7UUaqvKVc5FZic=; b=g2od7kbFpbq7rVdmo4t2ItyD/UWmkO70/awY7QESTzDLUFAbLsKoPHuop/x5vjKsPnaPD14nk5l2/Z5VA+hj8fZUFtEkExatxRSt0gqURxs3PghOCPIYrNe/sa34q4GWpdOyaBRfnqt+lA8EBxPk8rgoHD+7wm01auKNNJGvtV0= 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 1602496744342325.7870247918221; Mon, 12 Oct 2020 02:59:04 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id i1so12325324wro.1 for ; Mon, 12 Oct 2020 02:59:03 -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 a3sm15030602wrh.94.2020.10.12.02.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59:02 -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=t1dvB4k9VMEVu7wJ6I7VAc6UFFOJ5IHZwkGF7O1RSQZv3fh71j6SyPYpclObdy9Gkk fngs2vbhXYWMPMiCzouskHzscFYrhKFIMNTHnKrAhJgNJ2qYPPzvd6nVSluOtPrhL1eO LqzXF0tt/kv316n/VTs8f3zVdZlIOnZtostDjLdfv2Hw/dIqaxuxcH8GLGzuDLZRH+Ny McZuwJfDt6RWNiA+fWROhBP7gOXSsz0sTaB31UW3Or/B255uHmPkeVSU8NLYGZuRxkoG XVJSjejYPyZ/cVpIPtMn03ag/RB7me0A0UnYdMV8GPboKtLyZb7zGW23Hk+BULQ/ixVY bF7w== 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=ZIGIarbtizKFtepdytBD3a9/8GK0gBM9twPIgL/4lldwjlgUBIxfJxcEgthAGSkeBx HjRdi4CCHreH0djb6P2T1SsZVqYu/jdTmzbfsChHRjHcYh1VcyRkOYIk8Hl7y8LIB0m0 V8L8Hyw7d0fwmI+5zdyUXQFxdXR7/yu4u9disR5BVsAT/pJWtqt6uSlAAto7f5qMJax9 2NC6nh3uQDIzK/HB8tdEzJkpd4/m2CY6jG6sljYg+LIsvrJXkGhTOZHb6gyDay6hmWqG Ie+CCfK5cpbM1Gt4GRl2Mgiv3qestjyvPO5HAJmHt7f6SZDd4aVQJ5WbeF/9TvxIkquG hbuQ== X-Gm-Message-State: AOAM5322q9OW+7NXakaehXgUQ4y5dbejK7Q85KYH5kNBARLS07ggqHJp YCNZMF73+WpCiduLGLuf05o= X-Google-Smtp-Source: ABdhPJznEGodWB8oZ36rsRRridGRchL8LIgW3YvZCRZArtWFVGaLpcm/84aHwDNJWfvR7l3DqJ5U+A== X-Received: by 2002:adf:fe48:: with SMTP id m8mr28456025wrs.127.1602496742549; Mon, 12 Oct 2020 02:59:02 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 11/21] target/mips/cpu: Allow the CPU to use dynamic frequencies Date: Mon, 12 Oct 2020 11:57:54 +0200 Message-Id: <20201012095804.3335117-12-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 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; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602496749; cv=none; d=zohomail.com; s=zohoarc; b=OHGie85h0h/xaSTFGpBAqnKj/r8lrknlFKTCeUXm1zpkA868K/tkIfz/r/5o+Wah2eohxRw6w17HGg8bM4XsW1dTt/bva8dE+GEMCjNkoRYsJqsu+ye6NFTIDiQbhzAf3VYF+0OOm4wD2RYZ1El7m8JQdSKPSfa+4dmm8U5iHD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496749; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WMmrjqbhyA78SVq9CMHVcgoa6LhwqY9bNf3V4TYAoRc=; b=ZC4UGT/YrdKljtoZ79yO3kj8XxZzaN8P9ba8z31uathM+lADUYp70Ca/yXoyn1ztbZdAmScRLuXZOUTmKfoqnOwPXwjlS8H9ca36g5JPaaSJzpEMNfsaft6fjPYKnGHEsOZbKkTCv0cHTkwY2K6FYnu6613xgvqQAep6PqVG1jM= 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; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.zohomail.com with SMTPS id 1602496749239716.099022714513; Mon, 12 Oct 2020 02:59:09 -0700 (PDT) Received: by mail-wr1-f65.google.com with SMTP id h5so8372231wrv.7 for ; Mon, 12 Oct 2020 02:59:08 -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 x3sm14141947wmi.45.2020.10.12.02.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59:06 -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=WMmrjqbhyA78SVq9CMHVcgoa6LhwqY9bNf3V4TYAoRc=; b=s7uTrGsEDEcyfML7sJMr2MaJmwphstoP+G/q03Wf+oq5cLpicDpmN8Ni4GGWs7g98J 5CmtF0cDdFaoG4aLfRcAl5vP75USAhjKqTU1xPFOQzM1b/f7VX8wR+9LQC6FUVpNMpzN Ey9niCOGTReosyIEwbXkKXO36wj8mdgjZ0JTYuJX1xoUHJ9c7Hes0K2+piJtby8O8FaJ GMZ4MDZXMy+hQyywBJOdSXdh8XyDTyZmso5YJcO0/O/oFlg/EITRXeyeFwBe4zuH2alF MdWjBbIGGI9OuQHfv4FiZ1fFzUa/c5vkmObeQmQsR0Tj+P/n+mH1Mf/mEYYVqNUcc4RI bLYQ== 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=WMmrjqbhyA78SVq9CMHVcgoa6LhwqY9bNf3V4TYAoRc=; b=i06bZ52gsDa4x6LBd5FgXJEmAf10jKJU0ejijnVissCAMIx/mGE79ELkjFmRI7km0Z XaxVy+qIAztT/jJrhjTXmu4J1cQqaPGjkSgzO1sKozGzbnytlJdw9Z74plCiQBcFpEZK UJRXxUbDe99qeris0FxyZH4O6vpdRQq9sqPIVNfbFVNOKKFinCDLDUO2qGl1fIegwBQB q8tNrJelVX4HBBIkgTrlF5WhxBaGuxU2lOuZVBcK1b6cnZiXnn35W+ooHfhsM+iN39aT Rg+9yYDC6kyO6PhyeSgakTvSubbmWvd1m3xVIzS3TIoSdwMWguRBKzxFLITLzoaqmv2k 6QBg== X-Gm-Message-State: AOAM532AHiHARSOXcRt37YHGMoo2r2xX6Y3VY+0usL9Bodf+CruCK3Ez t9NHD7U8AE1/rgraHDOeg/w= X-Google-Smtp-Source: ABdhPJxNW73H0oOuOXL6LlO+tYIMk/Z9NE32Le9285U+9eofddRNeK4NSNWPqmr15r1TXaAeUuyRIw== X-Received: by 2002:adf:dd8f:: with SMTP id x15mr27126074wrl.124.1602496747289; Mon, 12 Oct 2020 02:59:07 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 12/21] target/mips/cpu: Introduce mips_cpu_create_with_clock() helper Date: Mon, 12 Oct 2020 11:57:55 +0200 Message-Id: <20201012095804.3335117-13-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 an helper to create a MIPS CPU and connect it to a reference clock. This helper is not MIPS specific, but so far only MIPS CPUs need it. Suggested-by: Huacai Chen Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cpu.h | 12 ++++++++++++ target/mips/cpu.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 062a4ba6225..d41579d44ae 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1307,4 +1307,16 @@ static inline void cpu_get_tb_cpu_state(CPUMIPSState= *env, target_ulong *pc, MIPS_HFLAG_HWRENA_ULR); } =20 +/** + * mips_cpu_create_with_clock: + * @typename: a MIPS CPU type. + * @cpu_refclk: this cpu input clock (an output clock of another device) + * + * Instantiates a MIPS CPU, set the input clock of the CPU to @cpu_refclk, + * then realizes the CPU. + * + * Returns: A #CPUState or %NULL if an error occurred. + */ +MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refcl= k); + #endif /* MIPS_CPU_H */ diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 3deb0245e7c..23f7b4508a4 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -287,3 +287,15 @@ static void mips_cpu_register_types(void) } =20 type_init(mips_cpu_register_types) + +/* Could be used by generic CPU object */ +MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refcl= k) +{ + DeviceState *cpu; + + cpu =3D DEVICE(object_new(cpu_type)); + qdev_connect_clock_in(cpu, "clk-in", cpu_refclk); + qdev_realize(cpu, NULL, &error_abort); + + return MIPS_CPU(cpu); +} --=20 2.26.2 From nobody Sat May 11 09:18:26 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=1602496754; cv=none; d=zohomail.com; s=zohoarc; b=k8n40VBRqXVT6VXDb2QMIJp1IdyiS8ex1HR5F7y/I6YhDZeMdWoHQw5H+yDrCaCPgxb19VgFEalgAeVk91WX3eNF5ax31/HU3YwIiOnqklxONgeEqLd0A/r+74L308mveEShOpVOzXtNlngpAlXkqxpRsezbnDSScwK3fWsCke4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496754; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=byk2/oSFMnCdpjKrO2EAT/wj1qG+dKg35aVK/7AqGxI=; b=ijX7sf3GQSFHfaeM2GpkSKQ41uXNI6Do6I6++AZqA0JlWldN6HpyX6IyJXYk5dmyfOhVutIpWRU0kq7MMLHGKGeNM0gINAjiP5oqOmLl/kqS+xjT+CtTu6dzfuTl4AG1fgCbsQZkQtLgJxRqHplHl7OmwKSXdhpgOF8sDDh0rX4= 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 1602496753992859.3269213464944; Mon, 12 Oct 2020 02:59:13 -0700 (PDT) Received: by mail-wm1-f68.google.com with SMTP id 13so16656280wmf.0 for ; Mon, 12 Oct 2020 02:59:13 -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 v8sm23093229wmb.20.2020.10.12.02.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59:11 -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=byk2/oSFMnCdpjKrO2EAT/wj1qG+dKg35aVK/7AqGxI=; b=b2bX4goUCEc7lJZzyaNl7H3q17UBM1cF9nXYftCPlkgDyhQk7w+imMA1ITEU7HDZXt LDavM8k2GjqFFSBcnGlMge+mga1iMYJDZaWoohCf4rfNLLgFnEjQ47UqLv4Fx/pBlbjY CQQUb7IW5y+s5s4sjt972xBzikfTlyVtBYBfrlHHRWKBAVfyk2cNr0q/RhtDpY8pR5Fk zXS+QgThMa+ZeNSWgGN1x0TwXtTC+0B+Vb+rGRss+aS1KvZevmL1Eee/i02+LtFrfI4o k8iKwbKkZm5Askfk/f/w9nnWXazL5u2w6HKr+8713cyAmdOdmEfc3gn/uN+FW8Fbgq/i TbFA== 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=byk2/oSFMnCdpjKrO2EAT/wj1qG+dKg35aVK/7AqGxI=; b=XlSsCi4aWB7OSjwp5YaE2Itx3q0fSlek18JVrgFcfUNzIp81JkfPZxS8DKpHRSd1QB yJa12HlH6Cbmt3EtHN+sjHSgqC6MR5oteduFXhR0uKKSYnwvNoqXNY7HNramBj6f1Smw YO5uoDraUi4Rf97ZlnawXJPaSxrtZF2iU8N406/8bbqLVCo8tx4hJvbutX5NnLogvGXj 9ZIkmmPrQfKCx19/8xfbueX1nXg3Ep/bplmaSO4wlQPSZoOuXbLaFcK6em0UbQsLn54F Vr6kMJbEsfy0MocaFPu0Xpx/aloszVMRcH7aSTPKKFnuPAfmpXANGmZQrqpTHLbq1qFh hpIw== X-Gm-Message-State: AOAM533m+H1ikQoxgf6LMbV9RR1R/DxYdGNl5L7vpW8otr6EPLuTjPLQ GCeCS7GyHfmZaY5S9FyatuA= X-Google-Smtp-Source: ABdhPJyC9QNaif9pdTfDJ0nrkHBf+ccTR1+Cn2fPCzL3/9JAUHKrEA0Q0GeUFeWBXTWzzLk/4jBTGg== X-Received: by 2002:a1c:5583:: with SMTP id j125mr9864324wmb.75.1602496752032; Mon, 12 Oct 2020 02:59:12 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 13/21] hw/mips/r4k: Explicit CPU frequency is 200 MHz Date: Mon, 12 Oct 2020 11:57:56 +0200 Message-Id: <20201012095804.3335117-14-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/mips/r4k.c b/hw/mips/r4k.c index 3487013a4a1..39bc626e7c5 100644 --- a/hw/mips/r4k.c +++ b/hw/mips/r4k.c @@ -13,6 +13,7 @@ #include "qapi/error.h" #include "qemu-common.h" #include "cpu.h" +#include "hw/clock.h" #include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" #include "hw/intc/i8259.h" @@ -182,6 +183,7 @@ void mips_r4k_init(MachineState *machine) MemoryRegion *isa_io =3D g_new(MemoryRegion, 1); MemoryRegion *isa_mem =3D g_new(MemoryRegion, 1); int bios_size; + Clock *cpuclk; MIPSCPU *cpu; CPUMIPSState *env; ResetData *reset_info; @@ -192,8 +194,11 @@ void mips_r4k_init(MachineState *machine) DriveInfo *dinfo; int be; =20 + cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); + clock_set_hz(cpuclk, 200000000); /* 200 MHz */ + /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D mips_cpu_create_with_clock(machine->cpu_type, cpuclk); env =3D &cpu->env; =20 reset_info =3D g_malloc0(sizeof(ResetData)); --=20 2.26.2 From nobody Sat May 11 09:18:26 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; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602496758; cv=none; d=zohomail.com; s=zohoarc; b=gK5xX19JKGOACVOfB09mYoU5WZV6fM00HCfkva1Xy6Y9zYkayMhTjsgSu0RUvZn22+4TsULPPuNefBSr4J5ScIFc1eKvwzRMaU4300D6grwlNKgBtwQl/51lhlnaKylOfH1loMsoIwhcDZ8rZw2rThFRp6/LhlJAeXDqBWKuSCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496758; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=apVjxDybnUJ2U2TEJYATAtdpZBtLB//EdpC/ZilWuQE=; b=SWEoP21n0uSDjNAdieMR8cA5KwldpItdOaSyQLYb/SPwSEt4gkDxrYT5Gi+30WcD0P9r7zffU/6vKrgtepp8wQtoMmrQz3OuitNOZ/917bNM7lFF2b1oVhM+5j1c9+zef42MJUz+Gm0FhB8FYa9BFIMM5w9Cupho0K63rXzDm/A= 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; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.zohomail.com with SMTPS id 1602496758984933.9893890797033; Mon, 12 Oct 2020 02:59:18 -0700 (PDT) Received: by mail-wm1-f66.google.com with SMTP id f21so16631817wml.3 for ; Mon, 12 Oct 2020 02:59:18 -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 a199sm23646142wmd.8.2020.10.12.02.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59:16 -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=apVjxDybnUJ2U2TEJYATAtdpZBtLB//EdpC/ZilWuQE=; b=nSzzEjhPctxe9QsUSyqylr7c3tpctrzNtfBHM9Pl8ydyfDKJ7yqCQgLnG24ISj/M9f 9NtU4O9rbbUJkGBSkmchUcaGv5MPWSkh/eIxAyvueoRE+5UafBAIiCiuydWk5cpRXR1g XZjKMtLjppFinH7IhTfoCAPN67fKeq2XkPGye6IFHhC9cUAjaj/HgarABM34r3eWbF2+ haOPKgv+cJaizCQdHM0eeJQkPjKWlMG0eNat1+kj2kkC+eRZcXOdpjZQw4Kpy386HF0p 0QfbVkZi0Pek6KHC7tlMIYU+1OtHVKj3DAOmWxYZe0m6I3vhk990OaaEb/nunv5jLbn9 PQ9w== 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=apVjxDybnUJ2U2TEJYATAtdpZBtLB//EdpC/ZilWuQE=; b=AOn8PTveuW6qMEHRbd/9GYxDt1JB0Bak4GbRO2oJYTdtVaiuMh21rOuaOygp765rkd TuNF2v6vcv/WqowI2tx7vE3l7zyoICw4V3u+/9IL+juwZdyIm/20RYNoUX8UgEREdfzu MDJVrxTctf2+BaS8OUSPLoKBS0iINPiMOuanmof8jFnnVzga5LmN/mv8yV5NITRoQNUx mLE8HXD5LUkDU9TpMcr+FEe/HGFZ7ixIox+e7phyrgaiuROqyr6hQMcm5SXWbAlhV9dw w7rFW0zjVb5RzIFQpRj4IpkhdoLWiZPmFnSMBhlVOz21kWjLtNtUvD71N0LT6EQeTinY ZLZQ== X-Gm-Message-State: AOAM533F0wC8edw4Fry8Wi/ToOxUj//tnB3AtiO4ItJM5IxE+iCwweQ3 lGx0hKRCqD1xR4PLD4EJUEA= X-Google-Smtp-Source: ABdhPJxOaL+rCn+r5vVaBXVGmBBsLcYnWRpV8tN0xohvr7XSTDNWMyuI9Xkz3/7IRZIvqnndZAi03w== X-Received: by 2002:a1c:9c4b:: with SMTP id f72mr10020738wme.188.1602496757016; Mon, 12 Oct 2020 02:59:17 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 14/21] hw/mips/fuloong2e: Set CPU frequency to 533 MHz Date: Mon, 12 Oct 2020 11:57:57 +0200 Message-Id: <20201012095804.3335117-15-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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. Reviewed-by: Jiaxun Yang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/fuloong2e.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index b000ed1d7f7..b8234f61083 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -23,6 +23,7 @@ #include "qemu/units.h" #include "qapi/error.h" #include "cpu.h" +#include "hw/clock.h" #include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/isa/superio.h" @@ -298,12 +299,16 @@ static void mips_fuloong2e_init(MachineState *machine) PCIBus *pci_bus; ISABus *isa_bus; I2CBus *smbus; + Clock *cpuclk; MIPSCPU *cpu; CPUMIPSState *env; DeviceState *dev; =20 + cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); + clock_set_hz(cpuclk, 533080000); /* ~533 MHz */ + /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D mips_cpu_create_with_clock(machine->cpu_type, cpuclk); env =3D &cpu->env; =20 qemu_register_reset(main_cpu_reset, cpu); --=20 2.26.2 From nobody Sat May 11 09:18:26 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=1602496764; cv=none; d=zohomail.com; s=zohoarc; b=HsQ7xvcZOvFgn5o5MiGXl3+Az6ZL1yZawOlSWqSI4K1QqnWCV9wRjWjvf6DO+vLHy68123Hi69Aj4eNCgfriD1fihy41ajp+8LyZzD9N+GUiErTd+zHVNiTaW1a3/6HRUFBqPz9Z52Otj+HJAljIVmD+pkrUtTzDrC1JJUoHOiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496764; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MXkPVd2aO8qnDLNyGp6W47ZEx+VHl+jUfpvG7Jg6mWc=; b=jS7K/15quj6JYBhAHnTUiZHMrUwvgpeHSXLVUB8lTh4Rq5a48VgG4oPzcsmkHj6sP9Jo1QcoDyYPFXJQoDnV+l1jc/2TS6iMMri3OIZ3MZpjejaZHsMnjTcMiFlrNxrF/2uVGT5ZZNGOaiAe5/7WCJEJSX9w04SaAq65k5iejos= 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 1602496764055535.9278450401382; Mon, 12 Oct 2020 02:59:24 -0700 (PDT) Received: by mail-wr1-f65.google.com with SMTP id e17so18420470wru.12 for ; Mon, 12 Oct 2020 02:59:23 -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 d9sm21817241wmb.30.2020.10.12.02.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59:21 -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=MXkPVd2aO8qnDLNyGp6W47ZEx+VHl+jUfpvG7Jg6mWc=; b=kWG8uj5CVJq0UUdFxBkQSCdGju9p13Sxx19mrHzoOQJNS/GooO239Br20eNNf1CPPW ERlFPx/nW0p4HnfvpGOLybQyxVF6K7+K6t75rH+MbB/50a7BoxZxt8YTbSKuhLli+fFz DTl8/hTb3NfcXb3mr/pTncOZ+sX5t3rvuj+RunfEFRm3AU7Jam7y9Kb0klhx7VTrXcVn bGMi3ghQYaLpewUr1+e8AXJJvq559xJ+b0hNSQMmLYU362pqsAYPJcouWkoJ2J03R8kO Wu7zyXvKVK5vnU09YSoT253TERCuJlwpFX6Jn3umDWB5W5QBl4dWkwjWpLGjlthzT+X/ xgfg== 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=MXkPVd2aO8qnDLNyGp6W47ZEx+VHl+jUfpvG7Jg6mWc=; b=bkLzEqY4YJ+c/ITHarn8vY5AjJd9M9LkAirgBLT8vjJ6jNN1avyRVojw62T9j0LWr7 mkPmnrVr4eo5Qkdqw2U8v1wUGMXJPG4JdhXw+GSQZzJ9jexMZ/G+ZDQKxK1CgrK3lgG1 9MK054UAVczAwfwAicwIEhPQYgQtpeTCbozYUVqoTE9M4A5ynqfUPKkJFBYlPfpwpfuO xSQCaj0gmszGIfxo2On00eptkbohOPmI+FC5W/0bUHBsYZOeMCAdEVxLQJVHih0+iAva LS4b6EDEb2vwxz6+hBSVwoSIMu07OIjLje6KReojS45WG4O/ARZxl/HfwGcGCkt47jRI ZAfQ== X-Gm-Message-State: AOAM5319xmnYSiT93Prdl79hL4TozLYwl9TUy3tPdayaYxO3ttS7ibT+ OkUpKud6TbWbAWdI7n4gjSk= X-Google-Smtp-Source: ABdhPJzXbfmfiiXt1SFn+K4dFVRj8kz2coFcKsyvelzPQV1ftK+7oHw9TdfMlEUAFZgr1CPcoRgBrg== X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr27933386wrx.133.1602496761825; Mon, 12 Oct 2020 02:59:21 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 15/21] hw/mips/mipssim: Correct CPU frequency Date: Mon, 12 Oct 2020 11:57:58 +0200 Message-Id: <20201012095804.3335117-16-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index 5d4ad74828d..f0042f7f436 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -29,6 +29,7 @@ #include "qapi/error.h" #include "qemu-common.h" #include "cpu.h" +#include "hw/clock.h" #include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" #include "hw/char/serial.h" @@ -150,13 +151,21 @@ mips_mipssim_init(MachineState *machine) MemoryRegion *address_space_mem =3D get_system_memory(); MemoryRegion *isa =3D g_new(MemoryRegion, 1); MemoryRegion *bios =3D g_new(MemoryRegion, 1); + Clock *cpuclk; MIPSCPU *cpu; CPUMIPSState *env; ResetData *reset_info; int bios_size; =20 + 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 + /* Init CPUs. */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D mips_cpu_create_with_clock(machine->cpu_type, cpuclk); env =3D &cpu->env; =20 reset_info =3D g_malloc0(sizeof(ResetData)); --=20 2.26.2 From nobody Sat May 11 09:18:26 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=1602496770; cv=none; d=zohomail.com; s=zohoarc; b=lhF98GhGIjLFoQyXdVac3y5Wlr5uvmzHJwnBFu2abul8pg1zxIex7p2WDPpKuIb2Er7bBvX8E5a00Q/fureAOi09T+kbcIgx8zlSt6xdXjGUr+45CansVGxPbk7g4K522uhboxQGifdWE8+XHBIjbEKIwNgsiqnFM1/w9LOcog8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496770; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ytszplYWdJCurTZ0nZEtSvETXq8R68amu9kSJHCX8FE=; b=d+JJLSba84vRgelqqqAgRpEFNT9nYxqc2OWgfyGEhNqjxK5WpGhjmBUV+ntsyZqzPvq95563ns/eJprlQlAs79TNyOJXSg5dw2OSwqTw4wlyLTfXFzE2ZkjIkPEcxPDgXbLv4CYR4PGW+jTgICVXnTKGRxaPirDgZJfyvMq8ze4= 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 1602496770188309.87489775000427; Mon, 12 Oct 2020 02:59:30 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id e17so18420837wru.12 for ; Mon, 12 Oct 2020 02:59:29 -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 u195sm638354wmu.18.2020.10.12.02.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59:27 -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=ytszplYWdJCurTZ0nZEtSvETXq8R68amu9kSJHCX8FE=; b=paGx5Wc2/seBuyRGUrNK5HrQu8loNxQ9ND8y3aL2M4GJxy84c1lR1HJwrhh+7Wmbgc 17mqCiSIocR/KlZsM1cdC48oH4UzLWKI5YYLEluO/lRTmnt/oQhcP2fSoOIf38kOt7JH h3DiNr77C5tU/0jZmoKPLT87/gNErTiKP1uWqziVnY74+BaBinz6WS0EQgm+LPFPMb27 Rde/IK6VP17MJMBChRw6qVHEqU0K03wVwXE3jrrJE3mbhoqPJdzQBTTAEdR5Falu8/3d Su9qOBvvItpukzMPkMWiHh1QhiEZTdDJdB2+G4/SZnDP7O0Frrqfv2nK8y0DAM7G/xik XFKQ== 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=ytszplYWdJCurTZ0nZEtSvETXq8R68amu9kSJHCX8FE=; b=Uz/+K8Sx5LfG8vOCRbDpaX1H1Tm/+I3Muwhl1mjtZSS/BgE2ETRlOIfjhYpCJvSccc l1uDvm6xIs4b7Z2u6I6/FspGsGNDUaF8fWjcs49k1D6QTX6vEVMN0I06CK/+A/vhvUZ4 V/ZA2OJBLeRO1Ri3Zb0IdfgqAzCB0wUy8J0o45dnvhDF2Ft1jgw+47xZzXRihZKGF2tl Wf5rroF1KbStSSbhDQMDZLn9zQARmJFxvrCtwwcZuAigQewEMJLyXbnMdYr75hM7pMKb lGcP/frvAxIHxgrX9qFKs+19rNt1EV8E3m7SSMxl+Idy0oRbjJpjc1sfsPc3avWYFZb+ YfJw== X-Gm-Message-State: AOAM53146THCdMssw1bJFWIU/e+DAi5hDMLpFIKjCXJ896OX+hQjY7qV GAz5mohnZHjbw0TXdvDo/co= X-Google-Smtp-Source: ABdhPJzGiUsE7pndCQl3jM+RcxaMRu5BR5mc29hTNJrP+yBUiT/JEMr4O7aNFi0yGes3+u41yYkY3w== X-Received: by 2002:a5d:4802:: with SMTP id l2mr28098268wrq.282.1602496768207; Mon, 12 Oct 2020 02:59:28 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 16/21] hw/mips/jazz: Correct CPU frequencies Date: Mon, 12 Oct 2020 11:57:59 +0200 Message-Id: <20201012095804.3335117-17-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 47723093b63..8f1ad55ba34 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "hw/clock.h" #include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" #include "hw/intc/i8259.h" @@ -142,6 +143,7 @@ static void mips_jazz_init(MachineState *machine, MemoryRegion *address_space =3D get_system_memory(); char *filename; int bios_size, n; + Clock *cpuclk; MIPSCPU *cpu; CPUClass *cc; CPUMIPSState *env; @@ -163,14 +165,25 @@ 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"); exit(EXIT_FAILURE); } =20 + cpuclk =3D clock_new(OBJECT(machine), "cpu-refclk"); + clock_set_hz(cpuclk, ext_clk[jazz_model].freq_hz + * ext_clk[jazz_model].pll_mult); + /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D mips_cpu_create_with_clock(machine->cpu_type, cpuclk); env =3D &cpu->env; qemu_register_reset(main_cpu_reset, cpu); =20 --=20 2.26.2 From nobody Sat May 11 09:18:26 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=1602496775; cv=none; d=zohomail.com; s=zohoarc; b=Fc4lGLA0FX7bkYxOuDCfZdu5TqhqHDyvO6ffFWs2D/9CVd31x8+nz02QCU4LtNuZrwuD/lzIgdhZQbrYDibN6eWR8pUfbLJSTIBGjWxDvlEJi3hBhPDg8oLdAuRXj8x9yE47Mz4FrCFGkvS3cMMa2Bk4Rcuf+J2KcYDs3Kor3UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496775; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aGuMhEybmPvVnTdSYOtH7MX85+5QscNdHJrgVgiAwF4=; b=YIdRSca9TzPb2kNcLTfJs72gK9OKtF390PKJUtmUEwe1b0WgSq+SMFNf9We3POcmPgoyMojX+Nb89uyJ1LaCYrxciWm0p0rmTrD00SOaRIpsStn4URMQkexeeN76EiAA+tYFS4yNlQZOEvx5ua0n4ujzKDcRrCCI4CT3bnDrUZA= 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 1602496775115907.9100771979371; Mon, 12 Oct 2020 02:59:35 -0700 (PDT) Received: by mail-wm1-f66.google.com with SMTP id j136so16946959wmj.2 for ; Mon, 12 Oct 2020 02:59: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 y14sm21695105wma.48.2020.10.12.02.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59: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=aGuMhEybmPvVnTdSYOtH7MX85+5QscNdHJrgVgiAwF4=; b=rDtx6M+NBWpWawh/Tru88CRfgfT9rdLKSyT+mr6cioarHtaZwcLGY3pvl1lF219/2d AvksOE5LOOVifLfHiO5blAIYwvIFS3tTh8DLfBXHmLxTNc5ZuGSVruLdVjypdjDWqSWT MdDJsQCeEGqcPhTw6SMoSfKG0R7FTYhjlkd+nFlp9u6XCRi7hpZFzRtYlhU2RuIzhwLp e+vABOu0SQonzlitjVzLxSZw7RajB9BgNZKm92QDwJojLSE41jup1pAaZhD8A/puXWch 9bd1OIY6t0+jgB4UCbL/DLNt6SAJ34enc3x3xcLCX6CVGGG2mEFPnezDKdHCzc0fC8rX 2BlQ== 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=aGuMhEybmPvVnTdSYOtH7MX85+5QscNdHJrgVgiAwF4=; b=dI1i8JkNrN2uEDVu46IRM8zrBW3vzncXXJyACCLfctx1FIiaew8UYuRW3YUBPXGf6a AkSTe8/ouZp4uuQ4SGZawnRzGpQviphpF1Om7+9GEmtIosJauaawATWUu6iHOm/tmPEB v9zKcI5/ahdxl5YROf+nnSk4mnC1vFfNl7gS+sIEm/IV1ZmdV3E1WNVHy7BtevxbLZAf L7dhIt243cbdS/jXqfhbQVzNCfR/2JcLyMiKKCAVQ703fFGbTTBsjUSfKavpPu1kDxTJ C37M5dc4a1IxxWQHcJ0EusXJM5bI+UBPm4kQzjR/Mw2upzJ7csxqdOaB+ds7AGruZ8k7 Zzfw== X-Gm-Message-State: AOAM532jg3KdhuxQs87OPTutfQvFw2xqUOl8f6swLz0S3a1U2/PObUM0 Pf5CIf+ICpZGUo6yxmxre/E= X-Google-Smtp-Source: ABdhPJw6Wjlk+bACzI5Qve0koO9tViV/K80SgFNZXBfrlQlDLUFB3KNzbwjfMKn8ftIipajKJ+UJow== X-Received: by 2002:a1c:2108:: with SMTP id h8mr10048664wmh.63.1602496773274; Mon, 12 Oct 2020 02:59: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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 17/21] hw/mips/cps: Expose input clock and connect it to CPU cores Date: Mon, 12 Oct 2020 11:58:00 +0200 Message-Id: <20201012095804.3335117-18-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 | 4 ++++ 2 files changed, 6 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..af7b58c4bdd 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,8 @@ 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)) { return; --=20 2.26.2 From nobody Sat May 11 09:18:26 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 ARC-Seal: i=1; a=rsa-sha256; t=1602496780; cv=none; d=zohomail.com; s=zohoarc; b=YL7J2+9zAoaoLfBJ6X02SezjzLucBfDJCb9cyIegr+w6L5dCBgxpIukXnLitdqFTpcsi3fHVEhjYH1NRTDVfiDRrlYL5OGYTkvqycAnux0aKAvdXz1kAzMpfkiffRMviXupXOJ1vdeCxd/9gTX/+OveMQZ5dhcrMf+0CCCyURMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496780; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tuhwN9e0WSQZgRYxEuwcxUwJNzQu5uaCHtzj/pF8FV8=; b=TtpDTyiSTx8ayVZWU0kXqaNBItHJlwN+rw3Pj8kJYt1EzvrchW/wl/XB+Zog3qcxtYcw+8D7qLyPQMS7Vp9xwq63MHA6OI8TIfLmxDu+a/zysBy5XM12dzZWBvovGUGJ3Z1V3jBfrcUUf4G9i8h5BLcGmC8tw9kqwh83Il5ZmI0= 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 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.zohomail.com with SMTPS id 1602496780260328.6979757987682; Mon, 12 Oct 2020 02:59:40 -0700 (PDT) Received: by mail-wm1-f67.google.com with SMTP id q5so16937804wmq.0 for ; Mon, 12 Oct 2020 02:59: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 h7sm1388024wrt.45.2020.10.12.02.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59: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=tuhwN9e0WSQZgRYxEuwcxUwJNzQu5uaCHtzj/pF8FV8=; b=K00OKLsVEh7JKNf/vxVOR7F0IHOUw92ZkCnel3He04y3LY6OsB/tU3zfZUGT1VvWM2 jRZAbk7RJ6WFSsIjkYprq7gsNZnxUlqCBs5MWVoZwRdwxULTfwKD/ykqdSTMxzSawQXH SZrA5AIyRTBF8GjR5yCmRf9bhyy74dbvr/+C3khr9H59j3T+rjPN9IhiPSfFL47eEjeL XupeMF1/CfDBQ/NV6FOb9Ip/30/Y7xXBqJdkioYC3YTEDY+6I/9Eaiov/ElzUoSn1al5 RZ/7/bBWM0cqCnILw0a79mKfMmPK+bHSZzfbc3+zFdRZJBmxxipRWiHeB1/MCwVf2G0r JM7w== 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=oTeqOQRO+37mbTp4qS0YtNN3uDTKxwyYjqT6sBSD3nV3FSWvg212H1/eQ2etfZ9R+U 5OG3RQ/gXkETztdlVET2qKgH8PjSPHe4vnyY6AP0cs8mGmywg1YoZkGpRZtbuJbiWCjm cyJcaeqe9Rq2SL4ZrmbUR6UPL8ZozeIie8Ng20IBNPApMWlLvyy5nitkoexnnQOWGTem 6cs9PQxVI7rZHYDBNx+YStkzaCV92ohaxb/wrYry/rwRUNoNsJfqoQlqYgXcHy3M0w85 4UnvvAHhKYBV8ZVmsUUuAjmTjcGVfQvumN/vysi3UK3HX9epYcZlFuN62bK32GGP1/OJ i9PA== X-Gm-Message-State: AOAM531CxNqYGInMQNOwvSiR+C2FduNa+cMzxPYYpG+pnSyWjXKiMO8w na9YF/1D6JQ1tEdpSdWK58I= X-Google-Smtp-Source: ABdhPJwkXJccCPa7quihKjGssh3yroMqDtdoV9/fNdCEdEAPs+oEWz+mYf5If/PXn1UkZY+PuclWbA== X-Received: by 2002:a1c:e045:: with SMTP id x66mr10146371wmg.104.1602496778424; Mon, 12 Oct 2020 02:59: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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 18/21] hw/mips/boston: Set CPU frequency to 1 GHz Date: Mon, 12 Oct 2020 11:58:01 +0200 Message-Id: <20201012095804.3335117-19-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 Sat May 11 09:18:26 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=1602496785; cv=none; d=zohomail.com; s=zohoarc; b=JnnMr5w7OZs5gyh0QLL6UhDOSoVG30O/r6kYMRbgOrMZMCS/+7oeZGLGtGqP5D/r/imGRORsdWifCU9j6IDl9U5qd9VEttnOifkV9LdtjNnrYCUK9LB2VHfuAxhULXPS/wE7ilQ2L4Q9frqC3AYyEl2IQI6BRXep8+pK3/DccgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496785; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OtZ8xecNb90sNX6MOb7lEpaLU7iDzMbfu7tSNksXSOc=; b=WNIkzOC3RIFv7U2j3tCdtUIEbuABsFIOuvnQSWQ+nZf8YDNmSlL5toxdkWwnTsCJkSvdHnW15mFZO8KHjNbZ/2PagWfUEaibb/XWuT/jnJaoEwMnpHqC8s2ouD3aqvo1QVCYQlL3U3CGaDeoYdwHm0czn1jehpkbbHkv8op04aI= 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 160249678533516.32326673079706; Mon, 12 Oct 2020 02:59:45 -0700 (PDT) Received: by mail-wr1-f66.google.com with SMTP id b8so5229616wrn.0 for ; Mon, 12 Oct 2020 02:59:44 -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 l5sm23785997wrq.14.2020.10.12.02.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59:42 -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=OtZ8xecNb90sNX6MOb7lEpaLU7iDzMbfu7tSNksXSOc=; b=k2jJHQOFoTksM4/FYYSptEbhuneEnscar6rjcHzsLabHBHq6kBda16lWg6bb09BqcT Mc/XRqktdSg9ZIUxtGNG6bIayWI8F8Qwr69bRXEvKxbsu2qZxttS3cL0WbFaK435wXP/ jgitAX0jSpwPG7iXsKejvX7W2tuUYoeK8t2yxGo+MmglmDa4mZP4MOUuIabrW790f4o8 jSzqf74+Skx01OHl5Gk1B7vTqU5sA5YOgXdfRk6Ua55DYHXaw9XJ0WFrzZE6rgWBMuh5 uQcmaQ4pjZslytsBxDgGTwTeghk9i43fF/P4RJhvPuBZ6/4XBVMxMDTekUBuh6R/Yh4W kOFA== 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=OtZ8xecNb90sNX6MOb7lEpaLU7iDzMbfu7tSNksXSOc=; b=EMkOV5goM55bPZlMB8rzR43H7UvSnZphqH/pKPHAAKYYXcHnoJ2SbLiZl3pI1jSl8M c/FKrbI9q4yqzgn4sfWL1ZjRm8XZ6SC4TAp0qZF0hAb2AR/qGqarqgDzU98cR4hbIRPP FvjWiNW/rxQiQ17dq4H13STV/4ACCmDZcJmnlj/2IOsi6SeJ0PhW+jqA+4HSiljZJlBK n9s00vtMq9m2Zy1ge/rzkJUcf+FevzEkQkuhEVa8uYkmNvbzyw7nuhDmYY59g8uIwomD b5NE0jqHeIidEobKsCnNLOzDuiEomVN87qU6CStFTdLY40TmsnzELeAzBKG/MrL0X1tg dQFw== X-Gm-Message-State: AOAM531GqYMBZePswXgOQHvcGgS7+Vh2Rh7QhJyjhIkXcRTaqBrpwNzO vAQT3bk1HW6v4JenbSXmim8= X-Google-Smtp-Source: ABdhPJwbQE6G0hhqj10cmVQAYs17b+B9aMuhJgVik7SQOLeah03ww1csdTUJR9n0Egni/iQghUln3g== X-Received: by 2002:adf:f207:: with SMTP id p7mr31113174wro.152.1602496783499; Mon, 12 Oct 2020 02:59: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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 19/21] hw/mips/malta: Set CPU frequency to 320 MHz Date: Mon, 12 Oct 2020 11:58:02 +0200 Message-Id: <20201012095804.3335117-20-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 4019c9dc1a8..1e2b750719e 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -26,6 +26,7 @@ #include "qemu/units.h" #include "qemu-common.h" #include "cpu.h" +#include "hw/clock.h" #include "hw/southbridge/piix.h" #include "hw/isa/superio.h" #include "hw/char/serial.h" @@ -57,6 +58,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 +96,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 +1162,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 +1170,7 @@ 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_create_with_clock(ms->cpu_type, s->cpuclk); =20 /* Init internal devices */ cpu_mips_irq_init_cpu(cpu); @@ -1189,6 +1192,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 +1207,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 +1425,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 Sat May 11 09:18:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) client-ip=209.85.128.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602496790; cv=none; d=zohomail.com; s=zohoarc; b=HusaTIPez3mh5tYzBDh5rilZwr9KGOhstYJgSXtYelaVRydgTlxnujWfmInZVxDL+Wuytqmw8tzVOLKtlNpOKubqIx4rjOfwo6lUL7i5FuLdd0saYLex7xgy0Yk0iYicRoij7//DE9pTQPwYqO2HZoeAtRztTSt44drDAH1hLFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496790; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SeH+Hehlck8m/GFTKOCzWoLDNRcm+8wSSlkI3BiVy4c=; b=Qlaitnmyc8LJrfJPMisowjoY1fX+jb2ny5/5pYRHsl3l7BXI0BA5SdQ9OODYwFIbMXaYlSMnQxrXCDk50QxO3uQ67wUPPn/y/Y3b6QGjqiBg5+Vg7pyOOqFJiZaHvw/g2Z5sWwPcgHQXoI3JKNV6vLr0QVi9qdie1jQ9Jnt1D3o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.zohomail.com with SMTPS id 1602496790348252.16008927341227; Mon, 12 Oct 2020 02:59:50 -0700 (PDT) Received: by mail-wm1-f65.google.com with SMTP id a72so6053881wme.5 for ; Mon, 12 Oct 2020 02:59: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 u15sm23953845wrm.77.2020.10.12.02.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59: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=SeH+Hehlck8m/GFTKOCzWoLDNRcm+8wSSlkI3BiVy4c=; b=A6YxX7ESw+gclZM/z8xR/asoA5OhwTWI7qG9sHW82+U+zrn+80rr9Ojqi1KyutO/wV DKMzOMOe4mk/zKsDWZTqTGNnJpDuTklMCndJsehdG5T3fO7pEix9b+N82xVZonxtQ9xC /8rUraUjzMuxamC+aVEnN+eP+8SX5sDvkcZ5eRFJfZ5SqN+c75VB1LHteR+bujaN2eND THnYakbZKi7AjQHMxR1Xypuj+fPe966DpwKkl8RLlKzVCy57lNijj7DWTawzvkemddJs TtXtfCoFbzXXbtqvXf+XapljUz77IbvQEsFTypGTXcYCI8gE8ru/BHnh0DsrYgVkK/Lu 7Zjg== 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=SeH+Hehlck8m/GFTKOCzWoLDNRcm+8wSSlkI3BiVy4c=; b=q2q612g8JUKeSYTn0G0l6sJB1C7t4rr1rp6iz50sa6CE1vgtzZI2P2py6FJPv/0uk+ UNUOJ/ZGvmMjqIA11Uy4scVTMuveXLihB5EiPQeFWTIkix2Kw5PVLqvEVPwg8Ts51z/l EdOXYAHxOKwlbmDY+UPlP6QrFErgjNHTYDCl5LlKcNwoWo/wYJyuHfg3618M9rrMzMTt nkQy4f3AkSu58fGNmu7/s4mhT1QnrlIXcX9HsaQ1Lr23P9OdZqvU/10MHBOuPormt16B asst4C0adu49V8lDXHJpqlgzSS8pptSdxPwWnk4PDKXEefC8reVxshb6I4NKhHwZEi9h ymuw== X-Gm-Message-State: AOAM533gUZJtYJfc/uP37lJZeVtyD4ldXQtpMTCMormnB7pCUoZbPJ9+ +wmtthhT2BcOWCvilYf/JTo= X-Google-Smtp-Source: ABdhPJyowOAjINWJ2GAVaThUvGccTMgBtWglz0jRIzrT8RnVW4rhSmEwB5shZxmTfQ+NnX3FFnEerg== X-Received: by 2002:a7b:ca42:: with SMTP id m2mr10430939wml.145.1602496788576; Mon, 12 Oct 2020 02:59: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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 20/21] hw/mips/cps: Do not allow use without input clock Date: Mon, 12 Oct 2020 11:58:03 +0200 Message-Id: <20201012095804.3335117-21-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/mips/cps.c b/hw/mips/cps.c index af7b58c4bdd..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 --=20 2.26.2 From nobody Sat May 11 09:18:26 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=1602496797; cv=none; d=zohomail.com; s=zohoarc; b=Xq7Mih8ByjsRAXaV+luQ8DTdlVyE26gk0XYHyXB5GLGJZnD86M3GSLH7wM0VUUmHbs4Oijwdf1hwXhne6LQ+jcGKU2jhTVqbbH3mvjKHQjkPyecr8OyBVltFcSPtkxUpOMYJ3Fy3e4ajE6LuOlLVi6hVDg+l4jW5m9cZSZ0rw5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496797; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cW/gfj34pmesiBnES6l2ixnKu1WwVqBwo9OSQ9eCA9g=; b=gHPcgIkRu2eNtfDXwLnrmRkrM9ybtO+9SLIS6fPwiBZ+uJXCKA+GvrjNHW9tZr7BK4h5g1r0d+RpWSDKUU8uzAxinKTGRZpW0U6Ww8951rxK+Lj1Q76PrtdBI6bimvy9I7cOpBm7d4DpCtcA21r57L0jsj0qjfFdQ12FVIQkyws= 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 16024967972513.6770757727482533; Mon, 12 Oct 2020 02:59:57 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id g12so18430851wrp.10 for ; Mon, 12 Oct 2020 02:59:54 -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 t13sm22300006wmj.15.2020.10.12.02.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:59:52 -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=cW/gfj34pmesiBnES6l2ixnKu1WwVqBwo9OSQ9eCA9g=; b=SHhabzs3z9clXgqH70u2QvqTe3YqImGe3v/XAx7mS9Psb0LZV06AxubP9l4xl+SpLM XJ/rHsDPkb0lzk15Y8sN0vtVBuJpcX5WtIVmoUnv7xjb28zxaMUQjaaJ1LbQFYrJZMws gCaf5KywD1XWaLj/FPhG5jPkYF3ZsUs3bRq5gFezN/Z+RaOVURROZrdnILpCewoyDkpX /rznTZ6PbQxlxsZIQilKZJuux/n+oXJsl1NEHEWEGHaFVQrXlIGQiG5ACy7A3zgUlwkE Bsu5H+PcxIzVkx9x7B94cw+5b9h6oDfrMsuyfDtmWSXIiBq90E/g1dsP1vMVUxHf3ocb Cn/Q== 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=cW/gfj34pmesiBnES6l2ixnKu1WwVqBwo9OSQ9eCA9g=; b=g9gRC7EvJCIk/rG/o5Ry50iGlG5RCxi+xpfLcrMf+oIpfGzn/gaxXNIoTEV4eRa40w z2/ucD5J4Zp0xpQpC9mB6n5cGwd+/sZQ/aTMbacXZ5nCcQSFUTLDPpOlveD3YtrupfRo Q6Ocd0yj/EFRswBaIL3cV5C4hG2O7BcY41yNcMsnslKxhqIO5QqaZqE1xVY3jUSlsdNq vTyLlyqdA3EIq2WJbGzk7b1Etd47y1AMO8s7eDE1VILn/096QyroWzn1PnaaBnL8FptK PBQCQzuGVwyYgHiuNlnheP9WOoY85UxW7c9TAKdhsfzHNdKAQh7OYOlSFAYaguzhk1w/ uzbQ== X-Gm-Message-State: AOAM532dsF6oRjv4U/V4m77TLugBVud5g/ZY2fPh383yVZ3nIhGM8o9b KnDIVu70w2rR/dDnu1qgdWo= X-Google-Smtp-Source: ABdhPJzfTBpmqmq3JBZjngs0H2XF8XmirkPAKJsDKGcQxwRG+5K3evn/EssB+wFoAdJ6YoxAxxks8Q== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr20009304wrn.91.1602496793428; Mon, 12 Oct 2020 02:59:53 -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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 21/21] target/mips/cpu: Display warning when CPU is used without input clock Date: Mon, 12 Oct 2020 11:58:04 +0200 Message-Id: <20201012095804.3335117-22-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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 23f7b4508a4..8daa5878ba1 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