From nobody Fri May 10 15:21:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 as permitted sender) client-ip=209.85.221.52; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f52.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 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=1602350784; cv=none; d=zohomail.com; s=zohoarc; b=K1iCj02r+25Sz7mMB3UJyqDXUDCsUjQFzOSRXWWWPYjaEY0ntyo1Lc33s6w2qGpheGl1Tw/L4GRvtH3cD5dQH4tatOM+1166LuVGkthrbUXO8c8ZHGP4bF2iIFM8v4c+MToftIKxvS4jloG+7IKoCIZcMwDO9gYXdgq1JJD9gqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350784; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gETh5/Gck0bTQVP31ZR4AiV0ecmQtPxoBf6GwvczWOs=; b=IxZQ+99BA8D0sChEPzaCQZHv9oa8OJ3m2MIJHIJlpYfyD9WIOKlDvGEidJGftpCatx4XCVymM23hJ8OINFZ/4/0gUXzwFtqxb9f2tLPh+UT7uSr5xIqsk/djI2UlPLbcHBOLt27IbEkC41+qtgsA1SIPszSng5WrbKueeIRFg8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mx.zohomail.com with SMTPS id 1602350784107606.6422453797338; Sat, 10 Oct 2020 10:26:24 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id i1so7554352wro.1 for ; Sat, 10 Oct 2020 10:26: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 i11sm16786068wre.32.2020.10.10.10.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26: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=gETh5/Gck0bTQVP31ZR4AiV0ecmQtPxoBf6GwvczWOs=; b=iI1HoX+YZZdHeu9yNUFeeX/+y0NDPSiOXplkKT3YYlRqP8BM/oJ7Nupak3enQioODa aOFVPw0RR1lKe4G50Qj44zIJnAVYzRqc4SkTcI8QL65BP5qzwxV3tuKK4fLUa8+10+ph VpbrM9e19vHtJFoUu6eGZIE16CWrlcQuJocJ+Gg245B7HhZzH6W46X7ky5B1JZsQ/h1m /ngTjCVFtQb7Le4ZGtn4RMyaLaNeb95Do0sVg0MfMeHcvZi0i/9I+j68k9eJVB+ThEfQ 5DEPq0w+zZt1VMNQjnwgPv2UxEgX1cc3Y8WWEBZdob3xGSrdh0Q8EW0xJ8m5jGHZDush Ttlg== 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=G4rp7BMMPob3mW6QUn9Xz6eZ4TwLEVm8no/w27m17jQcCMTFrAKwZ58jlfUj39E9Y6 naMCYySbg54el5GXyfZdtJkNKYAZUVunj4gF81/6rUOIK55FgTB+BnoiuMPZgmYifVkK fFIac3Ti5MmOMdoY2pRboPiAUPDZ4bvTX3BBj362Uc+6Vtl8oKJNjXcC53XhJg9IZJbb HoMlz8tnigeZ0LPOogJ8QRzqKCD1uUE8nTDJ0WUKGEX/c0nLpVNItnyQS6V7R6jm0vvf DML+lHBhMtYDYye1v+Z1Q42Y2QhFnbOBEyol9V5gxaip2w0/EB/tIk1gX2J5+9Hr+Mz4 GRXQ== X-Gm-Message-State: AOAM531TSVfYsuTDgG/yY8whJ/UH8RAf/z0RSLwpm1riJbrJRwnIEo3C NoNzWrzKYokbnhOcSGIJFrs= X-Google-Smtp-Source: ABdhPJwKhmFKDk4ukX2yk58h4kOzGiduNDVAXZx1ib6Re0lZQFj3f/YfHiM5o8cKnVhFgLvyrpAa6Q== X-Received: by 2002:adf:bacc:: with SMTP id w12mr11547986wrg.66.1602350782061; Sat, 10 Oct 2020 10:26: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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel , Alistair Francis Subject: [PATCH v2 01/20] util/cutils: Introduce freq_to_str() to display Hertz units Date: Sat, 10 Oct 2020 19:25:58 +0200 Message-Id: <20201010172617.3079633-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 Fri May 10 15:21:45 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=1602350785; cv=none; d=zohomail.com; s=zohoarc; b=WXvx2R5XDNcnEv/xAswlUJc0AGXX1vL5cd0YTiTTwd0+kzpBsR3NgY5CK8hVl6klaJkYoWU+isZs7EDbdmT+DU+xgLvv/IurpoGgZhOJC2xbGSkwd+RDbmwz9q2Dd9z6AdTZwtL4XnBcTiptf8TpjzgV4Hp0q9+NtgZkONq+oRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350785; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PwcUcNfmDXAXz3ZdCfHv1ZWyP4lS5DeJuKN8TDRFEM0=; b=QwD3xur9Uu0dNCf11haIaWHNc53kGOBR4g0iedfUDrFhtxBaeXu80c+7I6mhwjEMvDf6IXq76hiVvG+gN2sTvmqW1sPOj6OTtO1FCHYrvXgvPCdJSF6S/EugqCqbSDu0iDK78frJBXXQIesc/nNcJFKLQ8+cXHK/nij3u4IWxs4= 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 1602350785269996.4190440312773; Sat, 10 Oct 2020 10:26:25 -0700 (PDT) Received: by mail-wm1-f65.google.com with SMTP id e2so12857285wme.1 for ; Sat, 10 Oct 2020 10:26: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 i11sm16786068wre.32.2020.10.10.10.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26: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=PwcUcNfmDXAXz3ZdCfHv1ZWyP4lS5DeJuKN8TDRFEM0=; b=YxY18DeNnYphjJN08LdP4vD11Hqv0wBT99crsSbj7pox1gHolSw5StCK+5um6v72fM 0o5JFxmSlxOGMXTbHgi3bFOhF/K6tmoqlVGU94/hYuKlin+kE4as/7PIRoyyH5YvpDCA tq76hBnpyRUfTbtcY3j16zrMRB/W34zrD29mrR6mKvaqaDQDWJ1BDwBNMlvh043fLPA2 Q+6oc8k8HuFi5JwJEc8av9clvKJv/6o+wgjqFWdrNxghP5qH0eK/EIIohwzplfBHHuDq 8GyZbdMK5r5Ry3bSEkT7jjPSs1Rr5Zt7E6v+1mOMIh9sXfrysuokVPrPfiieVLuvw1aj KfTg== 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=tPu4ICkWZ0h9zyeIpHuAQ5QON7nopGo4N7dLAvirLTq9reHYzpUB4UTPAe9mvs86wM deRniAIWBizO3TL28OQMauo9JBOXCBbv41MAhgyoiWAzBmTs9KpHaqkioyZmFKAG9ZBi O1juWZipre6ckxhqUaQ1DtMSagOookKzp9RYJ+zFP0FfL3m4w7wK4u4mrgYBheFU6SwN AoxsVHhhwXP+Q/WfsTrFiA4ItVLC5hAvrqXz/1232wHbd2Q5uqV7bTO1DtchGYlMd+4U Nf2DNaez6uEKCKarF/hLCrlDZFDkx75JcKD5BhwAz+4fu/SjW5CTk8jrgv+pWuLz7z5P 6jwg== X-Gm-Message-State: AOAM533f9xNKFTxWPOp3eJINibv+Y1tnXusMTuUyICmBPoQUD7Fcc7i+ /ui+DQFaNgu2T9T5HrtUxjk= X-Google-Smtp-Source: ABdhPJyGcuOeHJiyPmmICuteYtWQrWGzYsWTWQ36xcxa0ucu+AQnw2sm+dRw0AjQv5MhLsOe2CqS6g== X-Received: by 2002:a1c:c28a:: with SMTP id s132mr3435280wmf.67.1602350783424; Sat, 10 Oct 2020 10:26:23 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel , Alistair Francis Subject: [PATCH v2 02/20] qdev-monitor: Display frequencies scaled to SI unit Date: Sat, 10 Oct 2020 19:25:59 +0200 Message-Id: <20201010172617.3079633-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 Fri May 10 15:21:45 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=1602350787; cv=none; d=zohomail.com; s=zohoarc; b=XuAkHxXdnivbaIUwY61vEGVmY05gHTdOYYI2ylLagM5dUUp4q5Q1nP7pPHs+yEFxZYBhmryPAdfi0xF1UpoADgeVXCXzSPxPU/CERFiE4WuMBZW2GztE23zH52Vh31pb1iaZoaECmsIM5sV1gSnKFXE7460cEX+kD0YZVl89KFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350787; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TJh7BI4acX0SbBZ5nZKwJOsX7BWS7AOVMyaKy5mLNnQ=; b=h9y8ZJDYHexGe8fCja5c16FGEZoNf21Xs008dCeQKRa+XkJedSKZKBZQpXs7rWmWy1YK4ooktfPdoYRlMf3XnBdtIZYJwyjZBgLr4PrpAXWKM1rrIEY4aquHW+g28Gq6x0CL+2H0/H7oxt+v8PMnp5CfVG5916WYwpLuvrLEWag= 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 1602350786644470.55220063731065; Sat, 10 Oct 2020 10:26:26 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id i1so7554450wro.1 for ; Sat, 10 Oct 2020 10:26:26 -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 i11sm16786068wre.32.2020.10.10.10.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:24 -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=tj5rWkyrRBcdTGvn95AhoF0ecbN+HyDx5Mg+HCpwqyDncJ+kB2+0aT1wHPfq2g7pM4 4PjNu1iMSvvGUTkf0jq5Pbb5gN1r7U5cStOTvXutryDhf8DCJJb35PxO5XwtTf6QQSqQ B1NW7Q2EoDvqJ9GrlqWVT97YQNLr+F1oPr5wp7IW0d2h4AcrJCpntqWtIGP4OkG4wLrx QeE6P+pUJsHksF6Naw/CRTT4EYmvOjOOctsQLdLSshzY0Bx9WDOO99GeBWEEMh1gP6Ko jVPaXapFWmsflAFw2nYE29B3+3tqxGakph2O63jcE0h2UvDuFoeoEnTz2gpLlYSAsaGd ySVA== 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=ZAitaBq4QVSvVZklGUzWZguw9hZsG4YJJ6FZoNQo8aC8PvakNsJiF6MquMLLLAmE4d XEPrtLWDe4xIRENKgw2rEbZMya04UppKuXxw7roE7Bkp0oAA2rHsxADKQxCAI/TKFvJG I/tING+EM8y54/HnLezgiSDzQ7+Y1sA3kPG3lnp8fM4Z8pBSedWVBMKK3G8pJ1nl33Vr AQmBYGi4KCtYfj5eE4CT6fgN9B5TSpMYIMJ2e/uo8RRz7uFjoXHZ5+fJXej3x7PrrwzS iDb0WRjZKJHMvN7jyLeHyOYGv3LZidL9hEOec8dq5ESmH9M5YWJ+Z0js76jtYXBFXlto aZZQ== X-Gm-Message-State: AOAM531PmLrm3bUMv/PpMjciINd+ULc9eUgJ0p3FK8CLpgvLEgL+pZgD V4I6OgTPnA4jFXISyPmTdJ8= X-Google-Smtp-Source: ABdhPJwWpk8CB057JNTUPUOS4iPv4XY5zRlzctbyrJQMQOIm9+wq8eUDstnrt22T5nJEizeQlSUfNA== X-Received: by 2002:a5d:6a85:: with SMTP id s5mr21819857wru.90.1602350784688; Sat, 10 Oct 2020 10:26:24 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel , "Edgar E . Iglesias" Subject: [PATCH v2 03/20] hw/qdev-clock: Display error hint when clock is missing from device Date: Sat, 10 Oct 2020 19:26:00 +0200 Message-Id: <20201010172617.3079633-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 Fri May 10 15:21:45 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=1602350788; cv=none; d=zohomail.com; s=zohoarc; b=UZSikNtI7fbnLbGzsMLdp3LuWUuiEayLF1Y4EwIFhIB1w+UOnhd7cR6RmCtI0QvoCHzaWV1F1D+JyA+7whabI53hiM1uWGhuS4iC7cjhIThnpe93tO/yiYcr6H3GUj+FDgQm+Bwq2HC80N5AVXK4fcPTr6GQiqujhcfDYa53rB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350788; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=Y+fIPlRb0YXqAQN9xiftbYrDoNpSb/RLcO1SH9Kb11AfRQiEq0lan/wfjpwh1KeztX0l2POnmHx/9Xr/d8e6Zwj/WQITH4+qfGp5PH11E0P2wZXoRjRYtt/LocW8zmggGFsy8bhlc50+Lvl8log74JjDhmYH/Xf/PWa1ltzPJBk= 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 160235078841234.62591161800492; Sat, 10 Oct 2020 10:26:28 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id t9so13658937wrq.11 for ; Sat, 10 Oct 2020 10:26:27 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=VNZIODbJL37JdFqCpr8kQ4CBc8EulYHr0VJqZx/+Orbb5nKbOzCXCSSo5SB0+FF8kZ DnMXv1pEC1DNxu3foBY+noVBDKvyYSdJUOLYqddyKwRkeU/NDFF3nCdbh8uuJY6lK/6J dJx6VTVZ/N7qtjHogWgQ6psBGWpq81OHQ67UVR3iHo0BzhsNqzezDmqFm/7V/HtYmrsq SLmtS/nTXTbWl9jdXDeB3hLY+gKiUHKf2DpZfj1jPMSh5sH9IpIklriETN0+Q9a//ubL viJpNFEgJDbo7sWmjTafCQssG3sIGs5npE3smZJRztLKTv3qS8ZYEC7TAtgD/3ItfCh/ oigQ== 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=M0r1+25uLZFMB0YKrmIRRXfq19INTAkgN3cZDEhk0k8uphgubybML1IAC1ZabzSoNV qVvXVVgzmmRVPm3zo+6J1OyUWoUj3lC6P8N5I2WdxoT9w5bFtRlogkzY7OyqAxso/x7j LHXjUICOXs5arEkyVS4N6W8HvRnT2+A6NPlU7Nz+JIve+LUDluHUYjvOOnsFcbVF6sxV oJWhlXjx7sSPtrRq2xkDMaWOBZsSmhujWkONc6Oo0EG6Xd+5dfDDtUj+EPY/fWnwVJ3c 1I8H0MU1STUBW1zKmdE/ZACOcafu9vo2JUR6tP0tMfvR6GSOTXo+VDb4f/ngx6DwlPsf GGzQ== X-Gm-Message-State: AOAM532Jf6RqEV8hnISWd/TjyUvMmTFjpjSDXpuVP0/tb3YVMJ/PBEUg jjG5kAlUYgfJ7EQB2Aaknng= X-Google-Smtp-Source: ABdhPJz4lAvTPNnGvkCrGFLKN7Vg2JsNstR2Yc01E+EHwOft1i1t+TkkN39/E911C82DJ7yNtbgn8w== X-Received: by 2002:a5d:4d10:: with SMTP id z16mr1004043wrt.360.1602350786429; Sat, 10 Oct 2020 10:26:26 -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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 04/20] hw/core/clock: add the clock_new helper function Date: Sat, 10 Oct 2020 19:26:01 +0200 Message-Id: <20201010172617.3079633-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 Fri May 10 15:21:45 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=1602350789; cv=none; d=zohomail.com; s=zohoarc; b=K6Hx5vjE9F77Ui6mhHEeTskQoKJMQ0CLEkXxkouBeAuVnFTKt+63J2EwX/WKU8fdkKRPHs1BoDhGlvybG+dU3hEb9QaHGU1CSznpd0WXtztpuKfXDgGlFMgCDSXYYq7Q9LZkryQm0U8OCeqEe69F9QFlm55j/hGroZklVPEu8Lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350789; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w+Ww+Tb9ux5DYpk7DL28NdlwI2XqYxB/b3zmX73nSUY=; b=g21L4CrLIFw0PtNpEA/smD02P6qQV9uoj2nSoK55XZdxo/2u+5z+gCaffzj33mmZYXsXRvWSg54W2nTKloHMqOJmOmvcoMGwxGZc7TJar2Tkzi1C5PWFUW8k89ZJM8oS67retvEVMKuncV7i6CYNBNk0HujfVY9fTDgRTXqKe3c= 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 160235078971594.59310074837924; Sat, 10 Oct 2020 10:26:29 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id b8so460772wrn.0 for ; Sat, 10 Oct 2020 10:26: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 i11sm16786068wre.32.2020.10.10.10.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26: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=w+Ww+Tb9ux5DYpk7DL28NdlwI2XqYxB/b3zmX73nSUY=; b=aziUhqskN66qLugiFjiaKanCNVYoV2uzyECr7mXWx5V1tVLiPHlGvrp9t1X0EipdJ3 fXoyJibEoQCTDW6wT4aGJZPzHa31VyGWBZBU4LSQg5bpuKJQs/625F6W1JBC91+UzDQh wUQJ8payE5095KDHcZxaFtdt2b9t98IuuL+OhsjL2pmzh4D9KPkEzHmWpeHXNiZHIj3l AyDHhtl0DvQSW53e5sMmeZs/pOxV/sKQHkdU8DwI/wvuzzthZSIiZaeipiZKH447tCJZ 5aR/eGGkkNxm9OBeyjIQLFJKuJf7rgBxdJCMUivsozRZctJht+MQl28IK+BuxBakoc7A gyQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=w+Ww+Tb9ux5DYpk7DL28NdlwI2XqYxB/b3zmX73nSUY=; b=F9yNLQpyhUWWjsr/WYdUAMDSq40/N8rXmr4g+vJQgDJ+DGPz9FgEC1oz5S3Bbil+0I hZGmOXmPfOv0w+9TvaGPEAqKGGOUsL9C5KuIq/IVJWHknuFWARnuwp9Xn4JOZhI10vGa b9KJoS1PT2zgTXjMc1jA5M9wRI0mqeCtYZovM2ZoxtGdoeaL4cA68QRUdys3T3j5X1Ls PJyo3S6oTbGRdvcT3aUGwa8ac8GSzjoinJx4RR+6WlIw9Q2YKbQ2aXavhb3J4M/xBuBV 2SqzMid8zJRsq1zfH0RGbGqb1f16pyVY920tBsL6xIcLAOcXnUC87AufNMGQFAGERGur JCPQ== X-Gm-Message-State: AOAM531qDYjcLFtrkjYr0Z1qyfXpuby3zlDXJGDQCuLds29T5uHvkm69 50m+tqYZxj3U9/YRok0/SiU= X-Google-Smtp-Source: ABdhPJyg2MouUJ6BCn3Bt72zmWKeJ1PRFBTmNYJCz2QtbzzYwRLGojyUNDAx89Muhoo4KzG2Gi5ayw== X-Received: by 2002:adf:8030:: with SMTP id 45mr21406726wrk.177.1602350787800; Sat, 10 Oct 2020 10:26: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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel , Aleksandar Markovic Subject: [PATCH v2 05/20] target/mips: Move cpu_mips_get_random() with CP0 helpers Date: Sat, 10 Oct 2020 19:26:02 +0200 Message-Id: <20201010172617.3079633-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The get_random() helper uses the CP0_Wired register, which is unrelated to the CP0_Count register use as timer. Commit e16fe40c872 ("Move the MIPS CPU timer in a separate file") incorrectly moved this get_random() helper with timer specific code. Move it back to generic CP0 helpers. Reviewed-by: Aleksandar Markovic Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Fri May 10 15:21:45 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=1602350791; cv=none; d=zohomail.com; s=zohoarc; b=QmMnjk3qtuJX2AYGMhXD/+dRQbOoeM7+qXFDoFsPZDn37wp/zdjBiJjBaKM5OZzPLEZrONiYt1buOC9IAJnFn9qGGYyQHnjE5Ore2oLWpgmLU+5rFyeANZ3yU9cnyCwspBWv0jJq3oJvm2IvTu2mmAIQH4i6sVCHTdNxDGF4JfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350791; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W69f1MWd6lsJIyf72MtAUNNqNrrt140PbQJ0VWAk4GE=; b=IJrV+K8XcIPCXQRy/AlDj1/om4RFR1gC4lHfTPXybk8GVx2A1QwFEYAwGnvBNuTRiU7+YDd/9eeIZF6IhWvQaAthaPvJOXcG/5tdLFoIGQqfPnmfGpgT2nqiiK8+JEDOomPGytfBdKCuwY/bTXJVhhftI2KMHCfTe+gq3BFe6Ak= 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 1602350791304617.9322593954113; Sat, 10 Oct 2020 10:26:31 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id x7so5081902wrl.3 for ; Sat, 10 Oct 2020 10:26:30 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W69f1MWd6lsJIyf72MtAUNNqNrrt140PbQJ0VWAk4GE=; b=K6kQ3SpGhXuvYjxxyXmiZt19sPdLD+kf217TxOBdkBsSqqI3JkCrHylkFjWmtaBqRM IsAC7qrHAhfzwjDgj9Hkls6IG5FBp56Voi1Rz0SffAENLkSqGCQFxu1DNwlQ8UCDxGyJ VgeJ4mg3Vb4LSRrF9XVM+FkK0LoL/EB79Fo8pRCtWU+cJjCfHsJQ3Coaicp4e0qzS1/v vS4rpp61UCf6EbTCfqWmYk4AgrQfxoUHrEzbV2EQN7Hsxc4PXh6UG7aWAZcz5SN6LPkT HDnCTwo3Yji2q9aYoWAX8TwP/HhUepXY0ugNmT2NpFtlG8rN5FFlKiXuxAwd5nUodtLg j4lg== 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=CE7oaAePiISv6NX8l5F9n+iK0YNaepyVYY9RB81XvghvK/kn/vCoXgR0lefNhUvFGX bx957H87ArVqWmkZYQc+qmIXHiwE2qlZHxQ0U+cBXz2Xvj53R6ONu/0li7+eg6XdrWpS 1fkDG016qahZsKALmNpl1bIsK/Ol42gmo1vLjn41DY73L3joTXVyU/fNfwMrwyxnHUUj A/e2469SfY1q26DPvAcVJquCyIZBcewiqlTNOkXomERcn1VAnRcmkJn3YfbxwGovPROE JKF7pFXTxkUAaK5ucSxdkvzHvf5ZX5OIFTLCbBN7pMUIuoYy8+S9iLa3EFzIz2GXWXDN YzoQ== X-Gm-Message-State: AOAM533+YQcFo810sJQxSu3NPuzz/FsBErajZubfqo3+7vQp0AL3peHr BUMZKrdD3Ybh4O0YaSkiAcg= X-Google-Smtp-Source: ABdhPJyUZmPFR0Imb/SyRQCSUOmkhDCmHMCzoSdFTZOnLWLndChB2aEdWHUCb4rT/+ECaZuWIa6bVA== X-Received: by 2002:a5d:6a4f:: with SMTP id t15mr15143577wrw.126.1602350789387; Sat, 10 Oct 2020 10:26:29 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel , Aleksandar Markovic Subject: [PATCH v2 06/20] target/mips/cp0_timer: Explicit unit in variable name Date: Sat, 10 Oct 2020 19:26:03 +0200 Message-Id: <20201010172617.3079633-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 Fri May 10 15:21:45 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=1602350792; cv=none; d=zohomail.com; s=zohoarc; b=NBdaf1H3PKgvxwz8D/zS1ysGLGgL8yauIvCt+sdtyw09RioOdD+TqCAwiJEQVgsjp3OhoHRfK9q4yM7VAuo/ba5eTC/HxGiePwWRZcv096igAu/YyT0yXlvJ5rSicH+l36Ib1YVmojSZwg+ePfxdt8MxuAqsRTUF8qXvvK7fTBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350792; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BslzpywZz3mbJWKAE8qW6xsdeqX9i4THsloWKfBnQUU=; b=jMpU9T/9m8uzivsqjT99OGKgGavJC5htxzhKiegiWhNl2RKZlt4L6TKvIr/UA2xSIpDPZDLIzNaAUxHM5BSj8rxz7D82nL+g5y7O4FPWjGYU2yDjU9+3Vgr/9XdVsLcHBScl5zxiMOEAqXSuH0fzPu/iToyzbgCMjXNRi7M9FHU= 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 1602350792864574.4532651394356; Sat, 10 Oct 2020 10:26:32 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id i1so7554659wro.1 for ; Sat, 10 Oct 2020 10:26:32 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:30 -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=pjr7GAEcqfMXNrpLVvYJztm3aj5lg5IkUT4H1AWhOE71gxrsuvT0XdjlE/UtjtqOej U3xiCAccbHb/3Fd8SJQjM3BjTv1b5VLyqxuuVUCukL2Q6Xb6SKrDmRrZJXPuUeS/UfmA H+ElfgsWLaGL8YO2DwCBaCzCdgFUtCV5tjLrthqJFpeaECI3AUqtDFU2cV6iPBjn7mLo PMaERISkWlqZaJOVBXAG1Yyx8lW8gpfayYhHsqRCekmiiDZa8CGlNZ/TWYgGZk5riJ2J QeiZBPDFClDEIoMARdnS2xasX6tT+jzWLSX7/+4/nD2SrnjBLvhiTI3lRqKvwk7HCOKK XRkA== 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=ZH6R0LWbrMzy346/lSDkb32pPsGRV33lFFgHfnvXYGvPFClYxKEwIyEKvkm21REM+1 V+TksmzwWu0wdEcIqNbeQ7pT7Xm2i7wMobLjMEA+7xHKXv4bmRKRQluZagNStrkGcEgS CY8y4LB7TQvzTJt2y2wcruzX1zH1LqrCH549oV7YeiX77WB5QaqTG03ItCt8JSs2nI0t 5e/pt5AOLF9soSmCbrzEwvzUfuC3uLcx4ulObiDOVkLf/Smr7dgh/xc1GqX1Q1nI+Ilp 8vhriSx+31ZchHJV19ynvmT09gqbAaM/int8EdCJ3DrsriuyTu9ptAjif06WG8TZGuAm rzDg== X-Gm-Message-State: AOAM532tggaQQdr+H3JUAj1+TY4XRof2svlThMXBw4S857mt42Ba0jnO 01Nbcz+g8G/MrGguFz3kd9E= X-Google-Smtp-Source: ABdhPJzIl5ahmAun9fpg+HMrCrCevt30Ama0z0hsCUbg9EHKqUHFMXeBFijpC987BUsAyzst9CwNLg== X-Received: by 2002:adf:a3d8:: with SMTP id m24mr20690743wrb.418.1602350790833; Sat, 10 Oct 2020 10:26:30 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 07/20] target/mips/cp0_timer: Document TIMER_PERIOD origin Date: Sat, 10 Oct 2020 19:26:04 +0200 Message-Id: <20201010172617.3079633-8-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 Fri May 10 15:21:45 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=1602350794; cv=none; d=zohomail.com; s=zohoarc; b=R7YTBj5uh/EbpktHLXUCGkz9nbDXikRUhpIFDUSFshIAuE8wbDtrveFSCC4833Krh1S/SngiKgrTYsQJKjt7/4U5MvnGPz35N5+BPIjSeGyKfQ5YFS+/bHNcaK60MSwMZsec7LbwIKsSRVFezsIB+gulqWQOrBxi7eOENxjI9hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350794; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nQ7QIUrlrUzF/fqOFrq02YrsK4QXRUJjYFAte9Cpzpg=; b=CQryYLcIkNT6hs1mLEcsrYqpN0167hy2iNvEBaTr+wfA4pNcbybocnMZpFXwbxequAgAOGmjCy1w8hDB5GRSqd/ADCinA4i2fn7xlSKkS4VB4LtJqDBqX5zfTnNZLkfYaHW2oIIY48F2vChIB73dY/pLsoT/aPScyyL1YAF90uo= 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 1602350794040792.7500580948584; Sat, 10 Oct 2020 10:26:34 -0700 (PDT) Received: by mail-wr1-f66.google.com with SMTP id n15so13682241wrq.2 for ; Sat, 10 Oct 2020 10:26:33 -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 i11sm16786068wre.32.2020.10.10.10.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nQ7QIUrlrUzF/fqOFrq02YrsK4QXRUJjYFAte9Cpzpg=; b=LxveMPg8blq9EWnsKXlJRPTfo3T88aHQ6vT4jq7USHOwkM75FAdD4EUZRLouvD7Pjp LdI4LrNMyzfHiOUFDWA+fJJfNd3yDi5EQFbeXKHkZL07kq3rkJh4j5wHBQhAzqZSY4t7 l9sz955SN2kcopL9Zf1kXPZNY9N3/U6TPJHw2a0coYI/j8ofiZx4ocH4qRugcL64tNM/ yoSXnTBSMsUqPSVpz7Z2G+ZoIrLxVKIckdIJdkDx7Pjm/qvpVy2ZrBlgug0lDWvdpnkX 4uP+f/RAPvmVB6Xd1stR7vj5D4fQBu+qorh4UKYQIYJsJEqWJVZ6V/BPiZz5fQAvzJN0 A6dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nQ7QIUrlrUzF/fqOFrq02YrsK4QXRUJjYFAte9Cpzpg=; b=m+38Het1P52JTjfkCPVn4wHimEk0W6hJG7/fWSMguV/EADUwqnYW7zO0ma3TsNa0nW NJ5ojzOQpbChJLKP7+9vdcJTmhX+mYpSWBixwDPYKaDMXh1YMud0uUH0dhVQ9juXAyOL hDyHV1fFTStA0TQ+8ZSsuVyuim4Z3Aq/zra914MFQOl0IAu5WqLOajfK8aEZwniXSTN+ YVZ9keh8t9FnXB6+XCGEkkN/qbyclXFFR4gbh0M70Ur6psOicca5GB+vgd6jCwIdfIuS cCjh2FaJrH0oQT8NvciiWs68adyx818IRT8eg5ZyF9AWUGLDcnGylPTIkeB+zVGezvVW 1smw== X-Gm-Message-State: AOAM53352TxjCwFy6hMsFi5dK5KZ4DKOlEoj2sPJc4tharzb02Q2Sh35 J4RoPZRlLdx3mMhEeONzHwA= X-Google-Smtp-Source: ABdhPJy4pZv5Xpp/pNoGZEdELqRUc6YqHNWm63kbWgr/D3YC+EopgZZDJqDLAgN/A8Ml7af+wHe4Vg== X-Received: by 2002:adf:cd0c:: with SMTP id w12mr20573269wrm.305.1602350792032; Sat, 10 Oct 2020 10:26: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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 08/20] target/mips: Move cp0_count_ns to CPUMIPSState Date: Sat, 10 Oct 2020 19:26:05 +0200 Message-Id: <20201010172617.3079633-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Currently the CP0 timer period is fixed at 10 ns, corresponding to a fixed CPU frequency of 200 MHz (using half the speed of the CPU). In few commits we will be able to use a different CPU frequency. In preparation, move the cp0_count_ns variable to CPUMIPSState so we can modify it. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Fri May 10 15:21:45 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=1602350795; cv=none; d=zohomail.com; s=zohoarc; b=WFc+MoWnsTBsKDikpioc3e9yxJow+U6JnQ79Wg051qCGDl7OdOtbfzFPI6Y3blS18UZ+oe8KK8Vki79+yJziRBPS4L8TNImpYEmWRBWktaI6lo5ZwiXwAZ4FxSFE/roBOgfS9AKK//qgfNUg89aal79C0+fB/vhiQQin2WG+JHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350795; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yECX+EErgKEGGyu+fq5dcK6AG/+Tqf8z/yJst+0jRiM=; b=ZDdCjvuylneNMvIABcWQfwaaFgnx4zbcIkdi3nu4vRCWqq5KmFm5BrJ6OlS3LYJCwDbJAbsDypp5m+4/bFOVYvb4YcHxNkPNgO1PD0CGhZjRkQYmb49If5lwonygGqUqNSeO32i+P3XHoYq2HWDbpRXgXXhpECCQGAq5oh4gwhE= 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 1602350795132528.8627665747346; Sat, 10 Oct 2020 10:26:35 -0700 (PDT) Received: by mail-wr1-f66.google.com with SMTP id n6so13370012wrm.13 for ; Sat, 10 Oct 2020 10:26: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 i11sm16786068wre.32.2020.10.10.10.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26: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=yECX+EErgKEGGyu+fq5dcK6AG/+Tqf8z/yJst+0jRiM=; b=XVcaN6s1ekbIoxMOzRyexjdBVNgQqUDmrZGilTjRJ9csuAZ9xZW/97j4xjaS0fPc7y U4XDyEsosyQ/GFp/M8GPu0JUh7xSHtCuQm1gmTYw51RLV3QIhxAx7eYdqxCu4p02i7Kl UujcpIyQojYPoMqwt9y1vrsx2sWd5avmXhhKVXr5K9b1ASRPRY87SgU4HykMkgAFP8CT r+PTgBZiDDJ27BWeQRA33+NBYhGpDvwTG1gTLczgXZZBTc07g3Ia3oTsC3tbCX0ZoFN9 AQaOmXDMB148gWobRg/qOUZEz0hEorN/EihdKz7Dy/DElz6uVw5Ww/0Eq4xvfb6fYR6c Hvtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yECX+EErgKEGGyu+fq5dcK6AG/+Tqf8z/yJst+0jRiM=; b=kaAu52vjcV9ee2//g9E5tNAByR7P97VaQ+3cRaxyZE+mmDQ2SNOwNpVzNEJLbggz4k nT8liwsSNQXMlg3PtW4D6QVTZk3AbmE7Ob6ee2Q6XSlrahJylI3zuWzbWUIgT6pj8ImT ayDRyT8JDOAZIrZ2RRSFSGVeo63wkj0pOyxiquHvsUpT2ccUEFMpH7wqIrVjzNK8d9mM fD9qVeJ6KTIypVGBJ3YA8yToUvDtxnFDnaC+5B5WVlq2GN8Obo1BSls3KrGuLboDKLJf 9DVcpx+qtrvLCGAnkbKLW5KLq3j9Bitznw4tpz1xZNkBFU62aX1owD9wD5tUj79smu5b bCXA== X-Gm-Message-State: AOAM531b4k5/kvjxn0aW9OMcPiAzHDP8toRYsqv96gwdP1eRwb0m6Vmw vJw2zcO2uPrgHI1u5cU/OC8= X-Google-Smtp-Source: ABdhPJzoT0ZoFIh4H6Sd9ODIjjxJZT/88YaHsrSpwIwGmsy/ytZJMmpUw7RDUumapV0As97c9Qf9LQ== X-Received: by 2002:a5d:558e:: with SMTP id i14mr22144049wrv.40.1602350793216; Sat, 10 Oct 2020 10:26: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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 09/20] target/mips/cpu: Calculate the CP0 timer period using the CPU frequency Date: Sat, 10 Oct 2020 19:26:06 +0200 Message-Id: <20201010172617.3079633-10-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The CP0 timer period is a function of the CPU frequency. Start using the default values, which will be replaced by properties in the next commits. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Fri May 10 15:21:45 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=1602350796; cv=none; d=zohomail.com; s=zohoarc; b=BziMOZ6pqnxk64Cb2gTj65/3LzGeFroGdZ3dwCsq7DtYG5MhEwNCV3Yjx9SQFHMDRUsPuyAEjbTJ/WhumaFRyroGD8h0fJ+4lZDYTQCq37eOkryIVtg39Jt2BQ2gec31Bc8AmWDlHN53nHc2FhEdiY4RY2MDYCq+z/OKs3n1ZaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350796; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i1cGbjc5Cl94JMQEfZlvF0v5MlNUEPZb+r7dtqjcBUs=; b=aHaTEtuFQ1DQ+kA1tHFT66XFvpc/D0fsmuGCjeMN7aowrViMZK1e7NK+z136/NSzAcwxBd8l+6CFO02M/RWt8vVIlvArdXhWpQtLg6tREm5ChzFGcGLNK5YH2y+54tQfAJar3/3BLg1uERTgPAB1YYEQEymmKWGzPeGrcnbJiEA= 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 1602350796348204.62690614631958; Sat, 10 Oct 2020 10:26:36 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id b8so461029wrn.0 for ; Sat, 10 Oct 2020 10:26:35 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i1cGbjc5Cl94JMQEfZlvF0v5MlNUEPZb+r7dtqjcBUs=; b=SKKtqH7MaIjmjoZzCPXDhMH+IUc5IO5PRCMeH50ranrtbo6BJnubq9H2E2oyTpPaNT hOajyPLpYYN/WZhtEkNIKPwVmsFbiooWU76zV1b1l31SoSNsCi1ALQhfGn3LUaX6+LIC zoXr388r31tGNsdoLot1pv96jY7XoPWLqFO0E6yqKC8M3+W/GYPXLTpru3RwifLuQ/X+ om3FkmjeGzQ+k+0zQAR7Lg1ZOCugMM38x/XMQhjgHeOkifPY0gg5e6XfuDkfLFIjvset a+mIiun4Abr/RhP+hD6HekM+YjpdUS5ojhih4QYhtWdiP6pmqaEyhITTQ74IlPhPouUN ZMyg== 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=n1lXMPYcjArhFvsjD0KXZQta60Sr7d50oZMfSkW7RnOlSsUdGMyTPjJfgS13S2cr4d 7rn16PTDJYWw8NCX6UklocJgd7P+HPA7wVn5RprVXiefdfMX7WIz0j+Ybx+U1Vg2vtrl 08MTtqlXH4MDCrJPKj1EmGUwoRUlNyZJ9LFgJXd0wIswSiWWpfBN+sU08tAKEJe1HIK/ WqXui2PG/hAJuAiPylDK7yGBf4hlmu3YkHqclbioy3d8+QR61yZFtU7lhsJZzDSSOjrp OMXH4/7hx7cq3AXnYaXKJ5RYL2JXKilamoMNwDLShGi0ncR0+sGYWP6FTP7i75riNdG8 k6cA== X-Gm-Message-State: AOAM533j8adMst2+0ij4pzJpbPpAERMt7tsHhvnnKFTFTySnx72yrL1U oFGgR//HmWD5sXiqpela+v0= X-Google-Smtp-Source: ABdhPJzAbaZ6zR9VIiJSLmay4Mk9SWsp+Y/6KB/Vzfw+vEooVmyzOYESI8DDN0ySMYrtB2zV3H3ulA== X-Received: by 2002:a5d:63c3:: with SMTP id c3mr20630624wrw.315.1602350794356; Sat, 10 Oct 2020 10:26:34 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 10/20] target/mips/cpu: Make cp0_count_rate a property Date: Sat, 10 Oct 2020 19:26:07 +0200 Message-Id: <20201010172617.3079633-11-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 Fri May 10 15:21:45 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=1602350797; cv=none; d=zohomail.com; s=zohoarc; b=MislKFpf5M4ZGor2EGMR42nTs+xJI4R+pjO6EtZWrRfvVNFwVny36XoHePmvAhj+kt9EgW2jxz2rmgyvydiOlq6RT3sgfKFE3TPpj2HZJmMY/MrmaspQkS4N6cbszHBAaI7pZpei57lkcOteYfKUzioEmsDZSjI0zBKP4u2Kd3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350797; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GJs+vUPbnbBqVHsKvcVatNykiV7Rg7UUaqvKVc5FZic=; b=VfeYiLooTvFWjVq9L54l612Gh3K7D65s1EFP7EYvfSSoW5CGB20s7S7KjAfdlXkEr1ZAgc1xaGFVS+AR51miIdYC611OCScsKzqUADS7Y7vyKAb5183NW80j/J/Yp1aH0b1ybyl7RipYNSOPWq3m9o4gOfuRoKVSjKlF/l0Cn/0= 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 1602350797473683.8066032029026; Sat, 10 Oct 2020 10:26:37 -0700 (PDT) Received: by mail-wm1-f68.google.com with SMTP id e2so12857641wme.1 for ; Sat, 10 Oct 2020 10:26:36 -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 i11sm16786068wre.32.2020.10.10.10.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:34 -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=eYaWz2r4mRDquzy6uPEASAgNB9lW5MXM+p33nvjo4eNH4/HLgmqjrrU3eA1UNEGiG5 KYi/9fzBjRD6ZTrcB2wzxiLIfiPOQTb3/A8ljKXrgxvsbxMaEt6xW0lmj6+bvjnZohr7 fmYwmA6GRa96eVLv0Yv4ymyZhJInfjJRXiVehjc7hOiU6rkZI5xtHuUlHOa+Cb0w9CJ9 UOo1mB2z5V82SfMp4/9RmfIeOoXpawAswsdeQNKtU1cAx9OExam5QoJPuD4O+26kFpKV K3DjsboCL/H0ZDMVHa/H93p05RPi1Tqnjy+MyV8rlzaVUBTTu10HIXDU4C37MJNdftqN 0O5Q== 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=pfwVkTi33aIQKQhFx7D5FiYNmtDXO04HWRmHelPE5EDriqLK8PcNSxsUwYhfqicErM KrQ6lvMZFUy5iL8HLsFvkf1/ZU525GEsPaR2xHY/6BbiZdVc8iTQHDzYrf22GxE/wORG Z1zu3SODrtUciPp4617KqLEyPSOq+E1PvJ6DggeapOj2LDhwIHH4yS91Ar4lN7+LOqck Tm3Jp3XyFahjRm7lnT95EzSI+vvS8YxkoaLmAbX0fujcC0Vv9pk3sHNDGw23SZlbDja8 ALEaihSzQovcRgsmXXTru+vGyzv5BRWqw4ifzcsfrCQIcLXaB9TkdUe72QS7e3uXjKZj mSAQ== X-Gm-Message-State: AOAM530oV/ckAk0Q0Y6ShjUU4gvSYkMEa+Qv6mQz5pFdkItRF/eif4Ee LqFFvwEcs5PhO1XCEpvCM8o= X-Google-Smtp-Source: ABdhPJxempHW8LfOowFAaxwgAsUhj6DQ5ykFG16WIUxFlaJuzZFMZyRjPbUSCsyVE5txDc4nM/8e9A== X-Received: by 2002:a1c:a9d1:: with SMTP id s200mr3458266wme.107.1602350795548; Sat, 10 Oct 2020 10:26:35 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 11/20] target/mips/cpu: Allow the CPU to use dynamic frequencies Date: Sat, 10 Oct 2020 19:26:08 +0200 Message-Id: <20201010172617.3079633-12-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 Fri May 10 15:21:45 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=1602350798; cv=none; d=zohomail.com; s=zohoarc; b=foYlg0lEBlFNFMhEEPrIrKqA5qDYyzGFVxJFrd2aHm3MgkRAB/wDfKln/W0E0h/hXP40qrARrLcVKn5xS9SR3spDi+I14eZN7lpnpCITm/KPON3PQdj0JipQcROM9lbCYluNUeJVO/ZJ3Yrv4BM8RDZoCBbbvHp9pTNGJiXrbQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350798; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KF4jlo0OyNqwMyy2jqY6Lx0uD1/IYTY4WjoEWyppwjE=; b=KqXls7uX9ydV5EjNegMisbobneG0APrFWjLy+Gcbv6F1Y3Q+obENkZMyQhu5Hxd/Z6IoQ3QfmFRGgovAp1FNoB0Bm90Mwxwrtw0y/gSaFiVHvAnquJe2YAAw+edbaSmK8qbVlAwER0snflMv7qg9/q0+9bklGRjk9udN4H/Pf6Y= 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 1602350798818359.26295162493864; Sat, 10 Oct 2020 10:26:38 -0700 (PDT) Received: by mail-wm1-f67.google.com with SMTP id 13so12892005wmf.0 for ; Sat, 10 Oct 2020 10:26:38 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KF4jlo0OyNqwMyy2jqY6Lx0uD1/IYTY4WjoEWyppwjE=; b=AA7Rs5VszEbANgkzAn984Y7CYBeIXauxkDnhEkkBTVfBr/+9tTV5pQ0RL+5lbtUzLv d6CnsGIVTPXRTnAloPfEVgGuQ4ct6tiuRAdYOTjDaEEsRromObO4mANlAh+BUFx/4tS2 vEWpsxEB00pwttKsTeXCG5uy+A5GxaeDU0KI07UjBSoqHONF56ETHXzjRzKNDNscGqqx K9YOMv/H7Ov6mc3tfsUTFE5nf6qJhsYPK4tc0BMzRU+ReSKvNVmzSqHO+4o5RoWD8v9p Cwude9S6poYz23MrcCPz9bBCtQNSIZJHZDdsUImSCrL/kkfeVMj32ktgdhKrpzZJ7EgN +6GQ== 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=KF4jlo0OyNqwMyy2jqY6Lx0uD1/IYTY4WjoEWyppwjE=; b=T+wxSEpv4vl5aCFPXB+bqqn/KOHsm6C+uS9SSPA0o0mj8FVydmHmaURIhA5JMBHSUU M9y7MTi+I5sUiNbQ9TQCOgjauN+7S9jYe+JwJv9mPFI4DljY0ri/emcUz5yC8WBN89sz Kvagnt2Ui1zAtRm/J+XyAfS7oVa0DLYdDqOvHtpvVKIYOjK3wJmjyf5APyIJbbnNyByi +zR5aQWprMBAALs2veB79SoTzphmL6e0QqREDeoMRG96YRLOjUVE3PN2/AoPbHDQ+Y6f sXhPUiJqCH2Y+qIqPirvaA9lzQpO0HUDMTi7YH0bTFKYi7OTRg7cwrsY0rucnN3MiWJW M9vg== X-Gm-Message-State: AOAM530M9ImoLoXbj53C9mn4VWCpKqadYhEb8yOcZjT+IJkcNjlPMpyt XQyuLP3lPomwZvZtF1t5pIA= X-Google-Smtp-Source: ABdhPJwc/hpVyPeuspmmFd3J81GwX9JNKjOu0RSWP2/ZmBq4tbGH4ag07vLFSpHww+f4DIMlafRZRg== X-Received: by 2002:a1c:f214:: with SMTP id s20mr3448063wmc.84.1602350796893; Sat, 10 Oct 2020 10:26:36 -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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 12/20] hw/mips/r4k: Explicit CPU frequency is 200 MHz Date: Sat, 10 Oct 2020 19:26:09 +0200 Message-Id: <20201010172617.3079633-13-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Since its introduction in commit 6af0bf9c7c3, the 'r4k' machine runs at 200 MHz. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/r4k.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/mips/r4k.c b/hw/mips/r4k.c index 3487013a4a1..6d550c637c6 100644 --- a/hw/mips/r4k.c +++ b/hw/mips/r4k.c @@ -37,6 +37,7 @@ #include "sysemu/reset.h" #include "sysemu/runstate.h" #include "qemu/error-report.h" +#include "hw/qdev-clock.h" =20 #define MAX_IDE_BUS 2 =20 @@ -184,6 +185,7 @@ void mips_r4k_init(MachineState *machine) int bios_size; MIPSCPU *cpu; CPUMIPSState *env; + Clock *cpuclk; ResetData *reset_info; int i; qemu_irq *i8259; @@ -193,7 +195,11 @@ void mips_r4k_init(MachineState *machine) int be; =20 /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D MIPS_CPU(object_new(machine->cpu_type)); + cpuclk =3D clock_new(OBJECT(machine), "cpuclk-out"); + clock_set_hz(cpuclk, 200000000); /* 200 MHz */ + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env =3D &cpu->env; =20 reset_info =3D g_malloc0(sizeof(ResetData)); --=20 2.26.2 From nobody Fri May 10 15:21:45 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=1602350800; cv=none; d=zohomail.com; s=zohoarc; b=gpOD72HpfI7f72HrLoqVFPlRL8mfh02nbv5BMtqZYX2q+a5tXAAVJHG2Hx+Edh1sRwN9w0uetyKRf5ssv2ZyAbxw2TEkvSQAWDzLZOeZG35K/A0lLuq38d7QQpEtbMHmjM/sPq/+uI3Mzl6VueJcspGXNr1tvyxvCNrGYqvxBio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350800; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PjooBS/HuXPashnAGPYOFYqNvHqJcPHFc0Sj+LpxwB4=; b=TwORK8qgTiNx2IjC4doKvPNX8cAcfX4Rt4dIEgsbqtiO69mx55oMSxU1u4tFzPhXPzhj02/1Rr0UdmpIZTALNG2Bav7qvvRMssh1IPuktHMHSvo/JqlWkuM15I2PxHIoaZbVeTf/OG8hBN2UmR4i3UrMPjqwgfo+aKc8enNTDHM= 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 1602350800049408.95364062097576; Sat, 10 Oct 2020 10:26:40 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id b8so461161wrn.0 for ; Sat, 10 Oct 2020 10:26: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 i11sm16786068wre.32.2020.10.10.10.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26: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=PjooBS/HuXPashnAGPYOFYqNvHqJcPHFc0Sj+LpxwB4=; b=Gst39v3Ot1Rb2ZaHr5o0uK9XSH0V125G+UzeEIG7dakaIkAQ8VMaJ93HGxgPEhQ30q vnxBQZamFb7eUEco6t/XfDv9/pZemp1qVYxzZPyaw418kiHpMSkv2AFsfUNBoZwM/O2o ADOWQaEyjvbMFnh72lH5JQY0jk+25l+aktiNaARtB5YPyOj4pbAGM29+uCCSVcSXWRiQ a6OoR7yH2BZx8OPyRCxkxMj7GDQXes0XdtsgIecBbP9hlB+6BR1nGzGOD70ndQc8fSfq mMgMQZwRZCygWlcDxh6wwQSu6HqBymA5CgtBjs4VrZy4TECLJVAMqY4YA07RKFJkPcmb M14g== 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=PjooBS/HuXPashnAGPYOFYqNvHqJcPHFc0Sj+LpxwB4=; b=HQ/cbZHjkcCLt9CswBZUtQuqiDUBpr8MGMPi7B6RJIDcNQuIB7nB1nQRdyrVVWMNFY QSQz0j3ikc+xaQqXKrnx1Mz5k/PSbS7PRO+Jjo5WwW2Xr+RxjddheSxfpcOXmYHJE0gh pDOOuPAZyhisxoxlyUJu7TUBZnmTAA/gYDO+I2QfK8DF7rFurs5QYBVrR/k341+qbngO 429qzmkHa1erX3r27qnahUNQEjsH/GyInxAfOONff0N3TcYv3FGgynftGdlpAJ+GtQDK rTHG0reDeO7iIsCI+5qBpVlzfEmapgwmyQiLqob5dMWl6lWYiXkntOUjtkv82fJb55xG L3gQ== X-Gm-Message-State: AOAM532hWXPcoes70gU9SHY4MONSUaslBrZyN3uWRRGuKObjzbwVPrXM pGeF3/ZzSKVbq0eGFFTjXnQ= X-Google-Smtp-Source: ABdhPJxMbBS8f+ekOjlw2KmSHwCdCAGRyxO+jRnLmOMA4B8D7dVmpijY9eprinanUfRL2+XW7HXPfw== X-Received: by 2002:adf:e312:: with SMTP id b18mr22100566wrj.372.1602350798061; Sat, 10 Oct 2020 10:26: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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 13/20] hw/mips/fuloong2e: Set CPU frequency to 533 MHz Date: Sat, 10 Oct 2020 19:26:10 +0200 Message-Id: <20201010172617.3079633-14-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The CPU frequency is normally provided by the firmware in the "cpuclock" environment variable. The 2E board can handles up to 660MHz, but be conservative and take the same value used by the Linux kernel: 533 MHz. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/fuloong2e.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index b000ed1d7f7..553f1638396 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -28,6 +28,7 @@ #include "hw/isa/superio.h" #include "net/net.h" #include "hw/boards.h" +#include "hw/qdev-clock.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/block/flash.h" #include "hw/mips/mips.h" @@ -300,10 +301,15 @@ static void mips_fuloong2e_init(MachineState *machine) I2CBus *smbus; MIPSCPU *cpu; CPUMIPSState *env; + Clock *cpuclk; DeviceState *dev; =20 /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D MIPS_CPU(object_new(machine->cpu_type)); + cpuclk =3D clock_new(OBJECT(machine), "cpuclk-out"); + clock_set_hz(cpuclk, 533080000); /* ~533 MHz */ + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env =3D &cpu->env; =20 qemu_register_reset(main_cpu_reset, cpu); --=20 2.26.2 From nobody Fri May 10 15:21:45 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=1602350801; cv=none; d=zohomail.com; s=zohoarc; b=MahGlVlcYXMHNP/aHPNww7DnnB7cv4Paa7OBxEv4CbmL0YBmih5MQ3nU0aI7I7fqIxhJBqXVbBV8OLlR2JATjHuLWUhZ0yYZJfN0ORyvJBn7dSscoA/DR4pGsIdxudmKIKtXS6hqGN8/ZKShsoAUiWZT5lw6rDrNBTErlLurChY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350801; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hdRhjIayqSG6GvTVj0uTOvZjLJ71MQG8ccDZSx/sEYE=; b=G6W0Pzbu+h1wZJAnELwx1lVqBDHVLz4Aoa4Hgtmo5ExoucmPPSSr7QscmH3qVFyrQdELEVXfR+ADLoDSPBCLTCMwh/4FfSmRtJuaEgp4orBUIIkvOnOnZqwxtApNg8tZ5QyL+ZllPKGpal+tVGbKUyi6tsNjPc3uwYGJB3LFltc= 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 1602350801270149.45782294333026; Sat, 10 Oct 2020 10:26:41 -0700 (PDT) Received: by mail-wr1-f65.google.com with SMTP id n18so13685472wrs.5 for ; Sat, 10 Oct 2020 10:26:40 -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 i11sm16786068wre.32.2020.10.10.10.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:38 -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=hdRhjIayqSG6GvTVj0uTOvZjLJ71MQG8ccDZSx/sEYE=; b=E7W5A0+vN4b5dNUXbFoPH01zRB2oloLAteRqSP620JSSdj/8AEfRB6obLGc+tDkjDz 0p3fhEnFFp7/4Ja+b9ZS4sC8y3eTvJnwpDlduODWZOHhxG6c1h3a9xbQgltGsA6485Fr 8XMi5u82gf/QL0NOMgjqpWEwO4P3xDp7qHGucO5VTHZV44duaIAsnwSNglawkgGLpg7a lVhIio3khjUreETVkW4KDFhAma8OxS281G11xaRmbl5b4MPnU0AIP1VIqD7hmapKDtEa aIAQo1tR1rKFISY6gHwU4N58YW++QF/qXwES0LcJPROIdm8ulhuD7GbWxfJXC5/ouOmf w+2Q== 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=hdRhjIayqSG6GvTVj0uTOvZjLJ71MQG8ccDZSx/sEYE=; b=lf466M+SrjOYEM6ceClF8WYiO9+bMW00HupWlbw+sb2k/AMavif7cMY/QMQhB1vXCZ c/NH7PJTTW4pLkwx6PJAMdXa55D9MGNm2YnfBvivVJgRyfW1yVabi27JdQHWW8DRbVLN rVgP8HvdpkIucvi6FgZzqcnoJe0a+qfo2uusdHtaCCsqk1sKyE2N4y5kdfaYcgKGNoZN dK5eLi0PvRUb3V5NBz6yedpc0XbTbWqT66+AIauczsBsSIWYT6AAvMpq41k2Xr8kEOlk H/i30roLzn+n2v5C+4seorAkDp3e9vZOnIFbK8ZYeF2irK2ksfi7CtA9bVVl5FX4w2Mt 8G1A== X-Gm-Message-State: AOAM5333JPF5axCMvdnoZPys/KCGyVtxT7bF78tTWcZRuFG/DP8v51PB bW8JfPoCX6ToqwgSIbgDoZc= X-Google-Smtp-Source: ABdhPJwR+hr544T154ZceUdAVG8hfgVOrrTVrIqCJwJdKvc6Xl1XCu5vvNnq623zJnM44KyzksIxaQ== X-Received: by 2002:adf:8b85:: with SMTP id o5mr7239211wra.104.1602350799399; Sat, 10 Oct 2020 10:26:39 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 14/20] hw/mips/mipssim: Correct CPU frequency Date: Sat, 10 Oct 2020 19:26:11 +0200 Message-Id: <20201010172617.3079633-15-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The MIPSsim machine CPU frequency is too fast running at 200 MHz, while it should be 12 MHz for the 24K and 6 MHz for the 5K core. Ref: Linux commit c78cbf49c4ed ("Support for MIPSsim, the cycle accurate MIPS simulator.") Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/mipssim.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index 5d4ad74828d..ded96a7868c 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -40,6 +40,7 @@ #include "hw/loader.h" #include "elf.h" #include "hw/sysbus.h" +#include "hw/qdev-clock.h" #include "hw/qdev-properties.h" #include "exec/address-spaces.h" #include "qemu/error-report.h" @@ -152,11 +153,20 @@ mips_mipssim_init(MachineState *machine) MemoryRegion *bios =3D g_new(MemoryRegion, 1); MIPSCPU *cpu; CPUMIPSState *env; + Clock *cpuclk; ResetData *reset_info; int bios_size; =20 /* Init CPUs. */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D MIPS_CPU(object_new(machine->cpu_type)); + cpuclk =3D clock_new(OBJECT(machine), "cpuclk-out"); +#ifdef TARGET_MIPS64 + clock_set_hz(cpuclk, 6000000); /* 6 MHz */ +#else + clock_set_hz(cpuclk, 12000000); /* 12 MHz */ +#endif + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env =3D &cpu->env; =20 reset_info =3D g_malloc0(sizeof(ResetData)); --=20 2.26.2 From nobody Fri May 10 15:21:45 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=1602350802; cv=none; d=zohomail.com; s=zohoarc; b=gUfCHZ0YjKvF9PelLnwNVyO9Ra+pHKHghNbCiEF3oDs3byFq4TdcrCjzAfGEb2nDUxLgAwdoDzAd1grNb3oblbJIHdXtbfznnbYS6lhc/BbbVMWaECIxCtiZ0KqGGwaRWciajYULsXW0Pkq9DHCLLOBeHI495HVFZl1MC8699QQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350802; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mo8sozT8Ds0POWKsTkBJwfxWCnr4o7uZvZTyjWCRQog=; b=MHAkQTHnI6mBNsjB8rTD2sWSH9CsKU5SKX7M7iQWbOdm8Hr8VAbpAyP83+AAAGRMdCUCLDVNCOaKegy/zZQpZPCaPlI2ir7GasK4Uop64MY2zMLNF5RMT4akKsn9x4ExJoNVCCSz+L20sC3b/JWX7zp57MrOPK9dJ202ahpiLqo= 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 1602350802507244.92275738780177; Sat, 10 Oct 2020 10:26:42 -0700 (PDT) Received: by mail-wr1-f65.google.com with SMTP id g12so13662562wrp.10 for ; Sat, 10 Oct 2020 10:26:41 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mo8sozT8Ds0POWKsTkBJwfxWCnr4o7uZvZTyjWCRQog=; b=D6UP6D8r6vRazkg7klsfufRkeM+Vep60YGqMMbJzfN8xXqq3iMdERCUbUOq7uWg90X gTldD0WM4YWdXqdzlXdX8IFKfizEIMZyn7nMYd4Sp7CxlvoGLtKhtmuqa5pkzzDFw56v 4TChsldDL/4QEU0qendgau6cYKgjJ/gXF35YbFjI1dZezhyzefG6ADJy5TgQQ0KA2jAP qVfCO7DIBTITNMCKG2m84NnRbtByQosxgYZkFi7sEFpk+MUVnwr2OZasNKLn8bjNqJR1 BV8XU9VJWKUDfkP4qcHXcMzNtHc6aqblWOsKsTwEJZZAU3uODhfiiM5Q55PsPk5IFSut 10yw== 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=Mo8sozT8Ds0POWKsTkBJwfxWCnr4o7uZvZTyjWCRQog=; b=iXTMga3zlAUT3rKXPejTu3Xci8lZM0U1QwGMZjm7xjsWgEu4k0UcXAaW+d4/h0LVF1 VvjXPNlsEJzULe2RHMqzgtaw+QFeUbV8Uk9jufLvGFejaZwbJpn3FTJPNKFGpouFQNai cQBQCKVX398xziuqVKWgXQXIFF3RCK+yvIV0lekFzuK5j25U4f76OMb8E1YD2oGN8/Ia sXfWo7VKiHtcume/Z4o+f8lvfWjZnLXNRBSpdYunwnCg5bWVOof6yhTRolvZmoynpnIH AaWeQWFEn/A9Nji6H1ktDcLs5dOp1C0AWaVhwcccDtwLbNKuXA0eT73MUTzLUbVbtfmG 9orw== X-Gm-Message-State: AOAM533kdvYXQ2wDOFDMxNASTEmuhZfr/MMFffCjh0mzqQ6HEm6yHuQM V0NyD1LaNZM/Sh41RLVuu2Q= X-Google-Smtp-Source: ABdhPJw//C9ZEgL09JdhvBjlMYTCXXIcq+twNW00ByTKaN/V5tdaamNFbv2tahDokYLhWsOUPSK+lg== X-Received: by 2002:adf:bacc:: with SMTP id w12mr11548881wrg.66.1602350800614; Sat, 10 Oct 2020 10:26:40 -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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 15/20] hw/mips/jazz: Correct CPU frequencies Date: Sat, 10 Oct 2020 19:26:12 +0200 Message-Id: <20201010172617.3079633-16-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The Magnum 4000PC CPU runs at 100 MHz, and the Acer PICA-61 CPU at ~134 MHz. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/jazz.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 47723093b63..a506cacd5a7 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -45,6 +45,7 @@ #include "hw/audio/pcspk.h" #include "hw/input/i8042.h" #include "hw/sysbus.h" +#include "hw/qdev-clock.h" #include "exec/address-spaces.h" #include "sysemu/qtest.h" #include "sysemu/reset.h" @@ -145,6 +146,7 @@ static void mips_jazz_init(MachineState *machine, MIPSCPU *cpu; CPUClass *cc; CPUMIPSState *env; + Clock *cpuclk; qemu_irq *i8259; rc4030_dma *dmas; IOMMUMemoryRegion *rc4030_dma_mr; @@ -163,6 +165,13 @@ static void mips_jazz_init(MachineState *machine, MemoryRegion *bios2 =3D g_new(MemoryRegion, 1); SysBusESPState *sysbus_esp; ESPState *esp; + static const struct { + unsigned freq_hz; + unsigned pll_mult; + } ext_clk[] =3D { + [JAZZ_MAGNUM] =3D {50000000, 2}, + [JAZZ_PICA61] =3D {33333333, 4}, + }; =20 if (machine->ram_size > 256 * MiB) { error_report("RAM size more than 256Mb is not supported"); @@ -170,7 +179,12 @@ static void mips_jazz_init(MachineState *machine, } =20 /* init CPUs */ - cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); + cpu =3D MIPS_CPU(object_new(machine->cpu_type)); + cpuclk =3D clock_new(OBJECT(machine), "cpuclk-out"); + clock_set_hz(cpuclk, + ext_clk[jazz_model].freq_hz * ext_clk[jazz_model].pll_mul= t); + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env =3D &cpu->env; qemu_register_reset(main_cpu_reset, cpu); =20 --=20 2.26.2 From nobody Fri May 10 15:21:45 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=1602350803; cv=none; d=zohomail.com; s=zohoarc; b=Awfjw7xoSxZCknUyH9rUtAVmEbjuQTwzdX/Ibtxy41rAU+Bnxs01NNVNuB4FEMASjHCowvfAra6EXHiVwJZMPoyfNB17r84qI2WSdsaGoPHyJ9j91AO8flGPAljWd/eI6BaAIHfq8m+BLctapXE9FLUd4gqaYOh0CIofVii+TeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350803; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tcSJN3WRYnSDrhVA+aXirUwwuRtaV2HQ16b4T6e3VA4=; b=ZpVlqUSv19xKvABnjiC7SNH7MnYQM7NRLNTZSuUxnnLG62CMGrrmjLKN3ycakH3/TkyqgvjqTlDm9FhGn8aj8XGLkREIpeIej/Fp/ZcxM+/IxEpMhUCt01epyNmpJ6q50m0ZiknPVa60qpGg28hJtcgz42D1hBdVpCNNIse7zxo= 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 1602350803658138.94517611376057; Sat, 10 Oct 2020 10:26:43 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id n15so13682613wrq.2 for ; Sat, 10 Oct 2020 10:26: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 i11sm16786068wre.32.2020.10.10.10.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tcSJN3WRYnSDrhVA+aXirUwwuRtaV2HQ16b4T6e3VA4=; b=RBGnDAlYMQWKKSWxw10Rs4ujxuZ9nfuKKS5hsDlQk+ZDWhCXTnqS+ZTlfTRd0x71yr 51sQvX6Yro7KZkldlYA6hYGboTSWFQBUl1MVC68yHnwgj6eixEAYUlY8bNmuS3qWVZA4 p0l6L//QDBnCfznY0O+u4BEjzi/B1tzlYvYe1pwS3N0NyU7l53pFKBhtxVIcL2zwSvgB eWG9l08RPoZ+gdn1KRPp71oht0GM2w7OHw/zLkUx6kxG2OqmESjV7EVMMASLQjUgHIWT yutpjWnCI/EbJlR1CR4VBz8y/rWquL3jlP3hb/VfXolE6VjvifU4Ojw91v4mhtTKPe+D Zx6Q== 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=tcSJN3WRYnSDrhVA+aXirUwwuRtaV2HQ16b4T6e3VA4=; b=Uc1qVXz84QjStADWc+263YAKKPzbeGQkAlIODvqkbJRG+Gr+/L6GaAIvHvCJwmpNut 8Hm9tcxIAhPuSMCA1u64GOlo5AIxX0HI848brBtn0fK9UeAWtNh38NTnPyZX2X07/JzI gaoOloXZpyxRTAcW4oLgPdT8HsggTRRoEC3dY/CnX/GJX8IyTnvHM7niIt+ofNqckRu4 3n5q8gu5APl2+h7WHDK5DTvGWtk3Z2GFZF6FN7/bs+2fZCa7sXt9o8BvxbTSZur0bGg0 7c9xiQNahYdui5d5GBoblB0DIzF0D4wPN2IkBV+tJ38Ed8UJanDSMeds5KHbh5TSfS+E X+WA== X-Gm-Message-State: AOAM531ZXOOIbpCwn8lhubRPGEjsa/gwtehAFHZB0wuEUSXzJXzLQRoK BmfPLjlm8dQHDA4XgUK5FEg= X-Google-Smtp-Source: ABdhPJzj+dRgzxxSVZnpEvSCsQnsx7f4noyXJeWW2BnXbTjyVHF5MHlH2Ph3Wo3CyzsNwAvwHYvaTg== X-Received: by 2002:adf:a50e:: with SMTP id i14mr17758194wrb.121.1602350801741; Sat, 10 Oct 2020 10:26:41 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 16/20] hw/mips/cps: Expose input clock and connect it to CPU cores Date: Sat, 10 Oct 2020 19:26:13 +0200 Message-Id: <20201010172617.3079633-17-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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', and connect it to each core. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/mips/cps.h | 2 ++ hw/mips/cps.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/hw/mips/cps.h b/include/hw/mips/cps.h index 9e35a881366..859a8d4a674 100644 --- a/include/hw/mips/cps.h +++ b/include/hw/mips/cps.h @@ -21,6 +21,7 @@ #define MIPS_CPS_H =20 #include "hw/sysbus.h" +#include "hw/clock.h" #include "hw/misc/mips_cmgcr.h" #include "hw/intc/mips_gic.h" #include "hw/misc/mips_cpc.h" @@ -43,6 +44,7 @@ struct MIPSCPSState { MIPSGICState gic; MIPSCPCState cpc; MIPSITUState itu; + Clock *clock; }; =20 qemu_irq get_cps_irq(MIPSCPSState *cps, int pin_number); diff --git a/hw/mips/cps.c b/hw/mips/cps.c index 23c0f87e41a..c332609f7b3 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", NULL, NULL); /* * Cover entire address space as there do not seem to be any * constraints for the base address of CPC and GIC. @@ -80,6 +82,7 @@ static void mips_cps_realize(DeviceState *dev, Error **er= rp) errp)) { return; } + qdev_connect_clock_in(DEVICE(cpu), "clk", s->clock); =20 if (!qdev_realize_and_unref(DEVICE(cpu), NULL, errp)) { return; --=20 2.26.2 From nobody Fri May 10 15:21:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) client-ip=209.85.221.66; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f66.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602350804; cv=none; d=zohomail.com; s=zohoarc; b=GogF/EIkxwL9QoF71OaDI0Cc39pKke5le/kqhCG+bwMeoFTKAXAwamkj4tYYcLuhGNIbK02kxj4OQmo00BW6P8nHuEpuqRODP3GuJ+PQxSQKiSxghr1dIP/DV/ItpllORMX/Df7JewxUFrG0/QQooB9IeYKsZOgsun2LY1C9jYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350804; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5FmtWrPGtRrGLQ2kaslyRtSRGaDuo1hSoL/f+YzkQ9M=; b=UQPSp9UnJ1tnKLjvGuy3uvyFnxBnRajpuAxSUtczNfTzRW2T+a/c19quX+lazsPQYScdG+6nhaTpS+rySbeyztlZmXqp+wgv2ynCv6pZ5y9GhvHVQ8jVOwm2SkGt6+2CkEPW9BV1BfOkeAk4SuL+ut1HDC4praAlGP11zQex0gk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.zohomail.com with SMTPS id 1602350804862651.7502807651804; Sat, 10 Oct 2020 10:26:44 -0700 (PDT) Received: by mail-wr1-f66.google.com with SMTP id x7so5082429wrl.3 for ; Sat, 10 Oct 2020 10:26: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 i11sm16786068wre.32.2020.10.10.10.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26: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=5FmtWrPGtRrGLQ2kaslyRtSRGaDuo1hSoL/f+YzkQ9M=; b=fVKyDzTQal6dpYYSR2lcKtlVlrfWjTZ4AGwFz10B8Go9YJXuhfCRkiGtSJVArfznXr Y4IEIoJMk0/VijhvqT8Pc1kIITrw8JN20WEZPGslC4yPEAoEnfSIRqDMfURuOK0iRNsY Sc0O3f5kJAn4hl4rsJu3Euu8grmcuXNXNVMnFxgczkPrXcyIDHXExKEwQWWjh94ShW/j sSZYi/bGDgRhWqNngq+j58ou/NKjTKk29G9Ofc1bNVTHUrC/5lWpt4VwRmwi+wzRcoeu 3Wwwg/HxP8qZp8ngBDi2Mj3VGhp7ZLqY5AkHw8B6ZachNPIHQbAQadQSZJj0SrvdYpuB vfSA== 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=5FmtWrPGtRrGLQ2kaslyRtSRGaDuo1hSoL/f+YzkQ9M=; b=sn9wQkQbJIcu1scw+rxUrVaOPZqPK/V8GMV+7u6pICuGFh0EZkrrbYtwuUZI90/j1w pNbIowLYwJAeppMsm6EGUZ0ylEQDUhf4xmfdv5u0CloZKzZKSkZO9Q4wcPjkHuYz0EyI FAcmpk+mmwGk8jmimFBxAIrc31QuU0/hs/jGr+T9G/oe8ZHo7E4K4I4LQrkc4JNJkWCt yb2lhrZcgSIVTAQxDVuCBOl9hBoqFN0NjCGSTI2D7e94HH4rs5xOwmPHV1RmBmYFfvfm Yg0Tz7/vu7tnBqkXlACLDyOHQBdndxlTJH4NyaSX2pC2S8PK41jS286NtwYWXCgqI07h +sWQ== X-Gm-Message-State: AOAM532LPGL4Sg16eGHS+f2b0vP7HZ2WFXdHA+XrDMuEqKpfNcqo1qBq dGK7EzeUWAJ0xI1haMcJYio= X-Google-Smtp-Source: ABdhPJyyEPnyPXsxpllYWbrE6qazQJxTUvqTYG0c0yhUamfbqD1XtHAGIQIDRd2LbSU+jmFWqWzWYg== X-Received: by 2002:adf:d841:: with SMTP id k1mr20957030wrl.227.1602350802958; Sat, 10 Oct 2020 10:26: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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 17/20] hw/mips/boston: Set CPU frequency to 1 GHz Date: Sat, 10 Oct 2020 19:26:14 +0200 Message-Id: <20201010172617.3079633-18-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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..c998140d7bb 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), "cpuclk-out"); + 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", + qdev_get_clock_out(dev, "cpuclk")); 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 Fri May 10 15:21:45 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=1602350806; cv=none; d=zohomail.com; s=zohoarc; b=lDi4B5U+eXSib3b3Yiaa7aYKjtaAc7jzchLScxi9upKyE68zQCFFRVm8DJ0H9jAZJk0TQpPJ8XBpb+67VEVQf9/n/8p2Ndhl44W/yELNKijNbQ0hZIiWqCNeEzarbeXroAmGb/afQNjHN7yt68LYEKNOdp+3hLNPO+D63MNQcVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350806; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dmH1PdHA/1En+SEzSBgyyb1Sf53UufFVZ9n5a0/mMSE=; b=KEPrVOJiBFFF8UOH0OuSJ/WwF2nMY86qPM2czZmIseCtgrUHQefDaGzzfcIsEbyukOy3ylkRnYpDnEVuiwq2+cCdq+1jF24aKFOc/oun3nGSdDjnxU7Kqi6eUoA3/tjsP6N4D307QnYTXlRkis11pW32HoLyQkbk6/4Z1Tz6Yqw= 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 1602350806065407.5959708701896; Sat, 10 Oct 2020 10:26:46 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id n15so13682721wrq.2 for ; Sat, 10 Oct 2020 10:26:45 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dmH1PdHA/1En+SEzSBgyyb1Sf53UufFVZ9n5a0/mMSE=; b=bRNurP37e66I9P1bx2It5L7GPBYBltasOd3VaM3lnpNyk5Aao6DCTyZ2FYq9PCMkYc kZVzBBZrEFFcYEAL/tv/f8gQlvDIRmiPJxbX1c7sMyh2wZkk4gln46xaZ0GU8x9Q7Ifo 2Gy2ZGIi5Whxaw/Agdw65P5hBfP67QZmamp2W8/8AX7EDSaYxcar9Rwpm6sPnrwGa17i a881mE6L+9Fy5fUm8eQD4Z/DVIzvqtIO5oKkoy+x7/hMOIAH1h4ysPxq69wUM7v1VM1U GqFQU9wCV5HzhstQkvTsnZ/DkaEb3hSDbxqEFW9UTb6HMw8RGPZl7xoEu2OsRtY3/Dyj WkOw== 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=dmH1PdHA/1En+SEzSBgyyb1Sf53UufFVZ9n5a0/mMSE=; b=mtRmQyAYwL1SJexfUEIeuU/p7pMUZMk8rAGRAVgbndLtaMROGLNtuIa2mlL3EJhPaQ c+97rg2KpFcA93Rg4Rygt26KrIrZgbnQ9Er4W31V7FtX/mX5EVBfXx7Q7gChFN4HYMje yQxJelWsSbpbdEqPrHmfGN/chB6LVEa6FIGizBrvCj1qaqjxfIwzFZL+uNBQPN5pIT0X odWo21lthuPagG8ggMoDSW1ZZJZUqqU2wU50bt18AZeZ2UKqpbcF7xE553uZ8nJuQ1Jz Y5qlXuOQYM9nZnUu4L5HudnO++f7rs6dPESeNSU8FXNkW/t853Cc2IbfbBmglGgtLRPs FOYQ== X-Gm-Message-State: AOAM531jCjiGDEygXUdfpz2q+VFIG9UHTSrGEInBIJccUrHUwZxXANls O038SBxjdoYzW+UKPzL84x0= X-Google-Smtp-Source: ABdhPJxgDQLD8niyH1xw5l/wjfdv7zr3eFiwLwQgIJqfJ663DXZ8GN8Eo2GQRxxWoIno9DOw5VkFSw== X-Received: by 2002:adf:dd46:: with SMTP id u6mr20915934wrm.295.1602350804126; Sat, 10 Oct 2020 10:26:44 -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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 18/20] hw/mips/malta: Set CPU frequency to 320 MHz Date: Sat, 10 Oct 2020 19:26:15 +0200 Message-Id: <20201010172617.3079633-19-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The CoreLV card with ID 0x420's CPU clocked at 320 MHz. Create a 'cpuclk' output clock and connect it to the CPU input clock. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/malta.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 4019c9dc1a8..c1e8fceeea7 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -57,6 +57,7 @@ #include "sysemu/kvm.h" #include "hw/semihosting/semihost.h" #include "hw/mips/cps.h" +#include "hw/qdev-clock.h" =20 #define ENVP_ADDR 0x80002000l #define ENVP_NB_ENTRIES 16 @@ -94,6 +95,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(MaltaState, MIPS_MALTA) struct MaltaState { SysBusDevice parent_obj; =20 + Clock *cpuclk; MIPSCPSState cps; qemu_irq i8259[ISA_NUM_IRQS]; }; @@ -1159,7 +1161,7 @@ static void main_cpu_reset(void *opaque) } } =20 -static void create_cpu_without_cps(MachineState *ms, +static void create_cpu_without_cps(MachineState *ms, MaltaState *s, qemu_irq *cbus_irq, qemu_irq *i8259_irq) { CPUMIPSState *env; @@ -1167,7 +1169,9 @@ static void create_cpu_without_cps(MachineState *ms, int i; =20 for (i =3D 0; i < ms->smp.cpus; i++) { - cpu =3D MIPS_CPU(cpu_create(ms->cpu_type)); + cpu =3D MIPS_CPU(object_new(ms->cpu_type)); + qdev_connect_clock_in(DEVICE(cpu), "clk", s->cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); =20 /* Init internal devices */ cpu_mips_irq_init_cpu(cpu); @@ -1189,6 +1193,7 @@ static void create_cps(MachineState *ms, MaltaState *= s, &error_fatal); object_property_set_int(OBJECT(&s->cps), "num-vp", ms->smp.cpus, &error_fatal); + qdev_connect_clock_in(DEVICE(&s->cps), "clk", s->cpuclk); sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal); =20 sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1); @@ -1203,7 +1208,7 @@ static void mips_create_cpu(MachineState *ms, MaltaSt= ate *s, if ((ms->smp.cpus > 1) && cpu_supports_cps_smp(ms->cpu_type)) { create_cps(ms, s, cbus_irq, i8259_irq); } else { - create_cpu_without_cps(ms, cbus_irq, i8259_irq); + create_cpu_without_cps(ms, s, cbus_irq, i8259_irq); } } =20 @@ -1421,10 +1426,19 @@ void mips_malta_init(MachineState *machine) pci_vga_init(pci_bus); } =20 +static void mips_malta_instance_init(Object *obj) +{ + MaltaState *s =3D MIPS_MALTA(obj); + + s->cpuclk =3D qdev_init_clock_out(DEVICE(obj), "cpuclk-out"); + 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 Fri May 10 15:21:45 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; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602350807; cv=none; d=zohomail.com; s=zohoarc; b=PucL0rce6SRaCnTBzarir3Vf7ffevKavW2NSD2I3WLOekqgs/gpUoEHO7FXpFa4sl0PpwPoqaJkr2txR0MC0m+H4Pmx1IsD/j9w7OlkSEGgBdTev3GPs/U3Los2E9gMd99KUd1UWKMg6IxxqWaz+9cd9oVc1zgzRzNK8FUFkRIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350807; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fgZXf1AO3a8DivRJPhe6TxsSwXBBGYh+JMLoIUTG0d4=; b=k7YXhQ6dljSvcEYMtK2nQa6qCrEiGMsIRSjK2BN17DPsGsFeFXrKgXtxhc8JVNg7WyboPvIJSrt+C2Q+H82AmGh5miqu6R1p+6mcEIVNjvDnk/8CzF3zo23gGtIYuay1FdKpD/HgMSWHziYtIg1LUbyrcctbC4KTxS/UoRY3W+o= 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; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.zohomail.com with SMTPS id 1602350807242925.7049182252599; Sat, 10 Oct 2020 10:26:47 -0700 (PDT) Received: by mail-wm1-f68.google.com with SMTP id e23so5863269wme.2 for ; Sat, 10 Oct 2020 10:26:46 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fgZXf1AO3a8DivRJPhe6TxsSwXBBGYh+JMLoIUTG0d4=; b=EGd4lNF/KpmfPrGyVCHMr+mpveFNL1Yt22slAVadkyjHRo1G0Aa4bc8H8QRbnhdgpU 6B3JDC80Ci1SiGRsNghB24VJ+0aU5K8zoN1vF5LTn7Npb6LWGKtxgU/7QvbEPPIQBf4O ZQI2f0yfPn6AYfw/qjCELOXrJwB3hI4ciXghMS1iaC/rKhTFSspAdYCKYvv/1lRb3RU8 99wE7nUWzME18k2UDQuI54pLwfocVtkZ/U+/ue/lHzhDlLFf/CPCw+hSLgUOFhH0Z8Pi XdIoYh/cAgatSrH5yre5m6y/ed4f8vVOjaRI20pvzkPyWzMlVwOsqJQGN4Jvxx4V7vmn 5UMA== 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=fgZXf1AO3a8DivRJPhe6TxsSwXBBGYh+JMLoIUTG0d4=; b=GROU1QMFvtnUjnt08GoJKXEPq15caUR4Rh1t7k6eagzT7g+k1o9NbCa6AJ5bmeed88 nebTU+b09m2Apo/Tax7CQCnd0tBc4oO8gSxme2Q0iEK3JKtqCnA+3DxtO54qthkdvOl4 Rh+As+rX0Anr3iAbIvAA4f5XloOS7AybDw5KYgc86gN/nwpISt8r1xLwBTpmjqqYU/8J zp+f/AOyDu/Bix/oqJ2LAQfeq2hjJEaZbzK2En0JYocspt5v2dZ34YaGaTF6R3Hsd4Qr ut5T6z3Zp/y9E0w7vHaxMpR2qYrySkZZ4X2NL9E/h2lXPqOsuoOI2YFxlnAQQAE4EWiK YcKA== X-Gm-Message-State: AOAM532pu9RA9mqlTJCQ7p6cU6f43fGbesqmCbC8dX6C4VGpwe2grblw 6ix6ZO712dcMwvtzL9VLSrk= X-Google-Smtp-Source: ABdhPJzzNiQ/s6w5qvGsEb3o6kbK74SPUB/U1duMhWbJLmyvI5wZw8wca8CtPLSG5Eia1rkjCpeFoA== X-Received: by 2002:a7b:cb4a:: with SMTP id v10mr3380280wmj.87.1602350805273; Sat, 10 Oct 2020 10:26:45 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 19/20] hw/mips/cps: Do not allow use without input clock Date: Sat, 10 Oct 2020 19:26:16 +0200 Message-Id: <20201010172617.3079633-20-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 c332609f7b3..f044e500b8c 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 Fri May 10 15:21:45 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=1602350808; cv=none; d=zohomail.com; s=zohoarc; b=KWNpFhAcvytJt9MoCb9H4ZyLhcnQ36SGDVZzFuoqCEZZnkGlzX41Tm2Om6WWkv3RpnvXuRLemr8lkS/GmzBhZhZe6TZzcehpwlKyRMqlX6lwEQx6bQcxGJ+KEjFgk+cDZ7cIjiKxqKsbn41QGHXxtOP9nIlh927L/2mcjN4UUZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350808; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AzmFEGnohCvn1W440dVAMj47SxdqWOdTt0i8s2oVyM8=; b=HsdRt0kBRaWGiYmf+b2oxY8hR6lxOJB76AQkeoXdJmNG/1ri1+5jucFHqXS/Cx2JYUk63n3ep8CRa8FEEw9OzSsxvCEbaB9LBR/cfih9N+m9Kh4z0PLjFkgzRuaf+nX1mA4PjA176d2z4mOWgFsEKk4sOWBbozOi7B8CmdtZbxY= 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 16023508083101009.0253844053525; Sat, 10 Oct 2020 10:26:48 -0700 (PDT) Received: by mail-wm1-f65.google.com with SMTP id q5so12849090wmq.0 for ; Sat, 10 Oct 2020 10:26:47 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id i11sm16786068wre.32.2020.10.10.10.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AzmFEGnohCvn1W440dVAMj47SxdqWOdTt0i8s2oVyM8=; b=OspX0yPr7Xj5RvIU/nGUysSoWyPtK1GUzJz4KC82XCDc2iJD5UIUk1FPJBAb5Rv8sT LI0kbu1/foPAmnlp+yb0Kn+ifFzoMdX5h/pVB7eIr/E64AsVSo578Yc6RT1fAkkvk1BU 2uPKRmP8mxtjMiWuCWlDc8gpkfWuuSjHWhIs24scFJsDPMN851j5wC+ji6HPvuM7KxNA dDCpRA+JFk4UQdJe5MSbanfQ7VyDhGNxT+KTaWcu5Jo33k9+CwLkKW8UYM/ha2EDSZGz GJaHJlYgbpWuSmLeV8FCZMQW7/p3rT+o1y2ntxqq9cgIr+Kk0FZ1ze/3YeE4QNRIErHQ SoNw== 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=AzmFEGnohCvn1W440dVAMj47SxdqWOdTt0i8s2oVyM8=; b=iVyrMRCyPnCMAb43F4jm+mmPWTpc3EtlmDsi4012bytTudkKUSYagBfLFTfgHrfbhq rLfcinJRBlkp87cI9T9tx7pQDbqqWvnwazIAI1ZJAhm/7fcHMIqrKLVINUao/xJkRNxr sDUSifKljvelbNVCARQECaR/GRmO1bTSIPh7R3TPe1YnQ7+TGqxvWBpBz++yVYebJ7M8 DWmOIyYj899FvyxjZrjLBQ30E4mIw8hgniXstTFtVSIdU3UdiuHC0Jg2YVZd/WfaLxuB VI47TmokkIaT1ZqSYE8rbsNWSJtaXMHvN8fsYnlUfeg9kcT3/uigN1uos2AZuc099jET 2YAQ== X-Gm-Message-State: AOAM533FLUo6fAaPIcOq6EaYwybxr4aNw0XQSiyDfwfcFZSRYsmHrJXX 7v8YStlkTAAEaiuwMdJuGKg= X-Google-Smtp-Source: ABdhPJyXHdUBLGljPFHqIC/kRszrJeCdF+H9u3tgZs/XSnnZUlLzDSuDyB5WB1l/Q+h/lnyDuNVONA== X-Received: by 2002:a1c:63c3:: with SMTP id x186mr3652008wmb.66.1602350806437; Sat, 10 Oct 2020 10:26:46 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 20/20] target/mips/cpu: Display warning when CPU is used without input clock Date: Sat, 10 Oct 2020 19:26:17 +0200 Message-Id: <20201010172617.3079633-21-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 3deb0245e7c..0c801a3a075 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,12 @@ static void mips_cpu_realizefn(DeviceState *dev, Error= **errp) Error *local_err =3D NULL; =20 if (!clock_get(cpu->clock)) { +#ifndef CONFIG_USER_ONLY + g_autofree char *cpu_freq_str =3D freq_to_str(CPU_FREQ_HZ_DEFAULT); + + warn_report("CPU input clock is not connected to any output clock,= " + "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