From patchwork Sat Oct 10 17:25:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 571C1C433E7 for ; Sat, 10 Oct 2020 17:28:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8A4C2245C for ; Sat, 10 Oct 2020 17:28:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iI1HoX+Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8A4C2245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIfZ-0001v8-PG for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:28:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdV-0000Ki-62 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:25 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:32919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdT-0003q3-N3 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:24 -0400 Received: by mail-wr1-x430.google.com with SMTP id b8so460572wrn.0 for ; Sat, 10 Oct 2020 10:26:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=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=MBf0cSeyKLhjyctMptOLY8u301juLnYVHIk29swsr7b2eOMatX8NW+sH++4QBZP1Ld 2kXoYqG4Ce3CMbU9FBiBrs97BNqdGNWiHKnQimlpRpjZqHjKQSFXsRCscTJjxpgkxPv4 27C+owTu5vq8uQBBtZ0SapwD1CRVFPAms1+d90hdBQ4NVApRdgUHL9jB2k2QzQxFv+ae XlyCWNMp62SkwO/qfRdnIDc60zvpwvyOtF6Br5gKPyltkbLdhOS80ypiiHc9nmxrLoS+ NY3N0n3NY48//IQ6LafUEPfRS11HWPY04t/naFEfZ//wuU7QxsUlt0hrmWGNN/32Xupd 7Dzw== X-Gm-Message-State: AOAM533MjJIfWhqfogdKP7pPdEG51e5JGo6UvJehsNTJtk24Km9F8k/F fJOTwPdr7JN5TlJH+jnfIVK/4Hej/EE= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x430.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , Alistair Francis , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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); char *size_to_str(uint64_t val); +/** + * 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") 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]); } +char *freq_to_str(uint64_t freq_hz) +{ + static const char *const suffixes[] = { "", "K", "M", "G", "T", "P", "E" }; + double freq = freq_hz; + size_t idx = 0; + + while (freq >= 1000.0 && idx < ARRAY_SIZE(suffixes)) { + freq /= 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); From patchwork Sat Oct 10 17:25:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 303198 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 664A7C433DF for ; Sat, 10 Oct 2020 17:32:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A2E52227E for ; Sat, 10 Oct 2020 17:32:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YxY18DeN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A2E52227E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIjS-0005TR-Og for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:32:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdW-0000L3-OS for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:26 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:52512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdV-0003qD-3e for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:26 -0400 Received: by mail-wm1-x341.google.com with SMTP id e23so5862594wme.2 for ; 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=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=CilSFx1+oaQPaierZzwK/pQlEmiz1ZKIMFpD2+1/BYMi8nLyr8fJ6N3dccVkD5uD3W /fvyTgHe7pb5bHe9lBeN50rfeSiW0cBzVaCPVUyi7vC1HerwRfN410DyOjPqgnO+cv6+ NS+x0S3jd9bcTEwRCfsSGKIiQ/1YCpBHhyn1hPS8kvwYqSO87WfweOiwN7jyWSm8g5Y3 skv44kfgiV+H/FPkDSBmlPMAlpdm02/U0ijVhlmsIh6UOs7MiPZ8+S8pk8zGfpQjWvo/ nTfXr/zrFb0SNyxyhubjPWbIPO1iLHgDGtjoDFiDuE8LVmlNgCEgIVANRWZiDfXlwFiM qlMA== X-Gm-Message-State: AOAM533Bp1RDExu3SUCku37oxJIRCK7oVZtnNjKMld+xZPvjH6bPfcO0 lN84VfCI61ZeEBT0tiDr0m9OtaMkR7M= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , Alistair Francis , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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=3.333333e+07 mmio 00000000f8000000/0000000000001000 After: dev: xilinx,zynq_slcr, id "" clock-in "ps_clk" freq_hz=33.3 MHz mmio 00000000f8000000/0000000000001000 Reviewed-by: Luc Michel Reviewed-by: Damien Hedde Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé --- 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=%e\n", + g_autofree char *freq = NULL; + + freq = freq_to_str(clock_get_hz(ncl->clock)); + qdev_printf("clock-%s%s \"%s\" freq_hz=%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 = object_get_class(OBJECT(dev)); do { From patchwork Sat Oct 10 17:26:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DB49C433DF for ; Sat, 10 Oct 2020 17:34:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B5422245F for ; Sat, 10 Oct 2020 17:34:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tj5rWkyr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B5422245F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIlQ-0000V6-Bq for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:34:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdX-0000N0-Q7 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:27 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:41766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdW-0003qU-AR for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:27 -0400 Received: by mail-wr1-x443.google.com with SMTP id s9so1576787wro.8 for ; 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=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=oZI/SDttd55iWWtnumRq/Xx/OLMrvWVs/lIKm0OLRlCto6awqREwLptPb8dB7Rolsg FfYhQ9QnZyk3SfMq6/MgsQIxhDPgH7xT4xxOIX/5i3KxwmzKwsARk6dVenSCgA+aJh8l LPuOz0crXCtlRJlXoACt+iDgdDmRPC5TS6JuqQG0PBqxIjynQOcWpzh5jN713BP+W+Du 293WVeq1pQgmfmwZ240fyjBh7uwL/lJRz7DsEK2w2JwHoY5URx8o99N3npo2fjUMz7RG tGj2yYiexlL4aJ3RDEy/1iFD5+OWxT130xB+HMkCOO+/ZAM79LDfDFRFouusIe3swUTC f7yw== X-Gm-Message-State: AOAM532mPUlEzcrCuSOkL1XfB0G4KwdfNKrGx8U7+hQ9D+FfiDskymz+ 4SYeG3Sbbs5xTJDgQjS/QOktxMZpvjs= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , "Edgar E . Iglesias" , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 @@ */ #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); ncl = 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); return ncl->clock; @@ -165,6 +171,11 @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name) assert(name); ncl = 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); return ncl->clock; From patchwork Sat Oct 10 17:26:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 404A0C433E7 for ; Sat, 10 Oct 2020 17:32:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C2B2C2227E for ; Sat, 10 Oct 2020 17:32:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VNZIODbJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2B2C2227E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIjR-0005SL-U5 for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:32:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdZ-0000Qs-Ga for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:29 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdX-0003qj-WD for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:29 -0400 Received: by mail-wr1-x444.google.com with SMTP id e18so13666902wrw.9 for ; 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=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=BpAmybVLDcqfwZkzdviBhda+2ZnzNrTqLn0TInZe//j18XXgROeXnm6WM/aFnLeS6y 8rxKZETYV45HNkeZ2+3YLQDZpPtnuDd5IS60xVAbjzxt4JRCBooT2RE63pPuILUJT0ZD HpJVcmNVXHwDmY0SVmvDhv/ybN3hwU68muhFkEdY/2F7XPbtwzBWAjWSnJYnUby7E7cQ NWWk1E1vldBRUMnKMPM7m5miNgf6CK7LZQujbBj8G/LAzzhD8ptiEunGnhnIJJik+F4k /AYc7yKxMxr/ewN03gmq+jNpltmhuIqlhuyiX3W7H/052EEoiGElhooFXf4vp1KY0O4B 81Ow== X-Gm-Message-State: AOAM532bXnlR5i/VVHpSBVaUIT6/YwOSpSwKUvNJ9o2bzsILXMCPI8M1 WUr8WEcouwv6beH9C4Gu/FE2aPH6W0s= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é Signed-off-by: Luc Michel Message-Id: <20201010135759.437903-4-luc@lmichel.fr> Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé --- 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); +/** + * clock_new: + * @parent: the clock parent + * @name: the clock object name + * + * Helper function to create a new clock and parent it to @parent. There is 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 = object_get_canonical_path(OBJECT(clk)); } +Clock *clock_new(Object *parent, const char *name) +{ + Object *obj; + Clock *clk; + + obj = object_new(TYPE_CLOCK); + object_property_add_child(parent, name, obj); + object_unref(obj); + + clk = CLOCK(obj); + clock_setup_canonical_path(clk); + + return clk; +} + void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque) { clk->callback = cb; From patchwork Sat Oct 10 17:26:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D79AC433DF for ; Sat, 10 Oct 2020 17:28:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 940ED2245C for ; Sat, 10 Oct 2020 17:28:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aziUhqsk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 940ED2245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIfo-0002Dc-Hi for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:28:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIda-0000T3-T2 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:30 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:34185) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdZ-0003qy-Ai for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:30 -0400 Received: by mail-wr1-x441.google.com with SMTP id i1so7554568wro.1 for ; 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=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=PZLLGd9Xt6ToEHrdsUCafhuR229FVzXGFLOo4+5IesDef1wIkmCoMk1Hxp67jT7096 hzGF74hNZQtmjVHYfYizZBf4P8Vr1hZrX8aNF4M86d9cbWodys0hIphU/KtU8qyPHHd8 ios5j2eYyFUIGqRBHk4hwnAxZvN/gHWOMyGrxd7rNLocp27loj046AHhiG6luJDXwzSZ f9LqD9wsut6dbbbgO1KGSyBNPEZVGTtxJcEo5dXHy463yXMY5Ck4rnr7W5zCn2UtDtPQ VHDtfBDQFuTOoKhmuNwjBx5AjRWSPNCSZTIKFinn2akGzdaFnFEpsIF4XtCsnHC2LYaX ZchQ== X-Gm-Message-State: AOAM5321HUuFtsvoXj8OvHwERsxaSswMNd+gnT+c4NY/ugD+3QfmXBgv ciOW5xE1NTDeLlMM02Lo3Z85NmA0X7U= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aleksandar Markovic , =?utf-8?q?Herv?= =?utf-8?q?=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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); 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); /* 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 |= asid; } +/* XXX: do not use a global */ +uint32_t cpu_mips_get_random(CPUMIPSState *env) +{ + static uint32_t seed = 1; + static uint32_t prev_idx; + uint32_t idx; + uint32_t nb_rand_tlb = env->tlb->nb_tlb - env->CP0_Wired; + + if (nb_rand_tlb == 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 = 1103515245 * seed + 12345; + idx = (seed >> 16) % nb_rand_tlb + env->CP0_Wired; + } while (idx == prev_idx); + prev_idx = 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 @@ #define TIMER_PERIOD 10 /* 10 ns period for 100 Mhz frequency */ -/* XXX: do not use a global */ -uint32_t cpu_mips_get_random(CPUMIPSState *env) -{ - static uint32_t seed = 1; - static uint32_t prev_idx = 0; - uint32_t idx; - uint32_t nb_rand_tlb = env->tlb->nb_tlb - env->CP0_Wired; - - if (nb_rand_tlb == 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 = 1103515245 * seed + 12345; - idx = (seed >> 16) % nb_rand_tlb + env->CP0_Wired; - } while (idx == prev_idx); - prev_idx = idx; - return idx; -} - /* MIPS R4K timer */ static void cpu_mips_timer_update(CPUMIPSState *env) { From patchwork Sat Oct 10 17:26:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 303196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9C28C433E7 for ; Sat, 10 Oct 2020 17:34:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5090622460 for ; Sat, 10 Oct 2020 17:34:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K6kQ3SpG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5090622460 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIlQ-0000UN-Ey for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:34:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdc-0000Vj-9S for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:32 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:39437) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIda-0003r6-Qj for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:31 -0400 Received: by mail-wr1-x444.google.com with SMTP id y12so8301301wrp.6 for ; 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=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=CSpnRtSdvqeh2TIVVxZFjd11S0yhkrqAwEOCtwMj8UyZXkXOJrTm3bITUiDQJbBDIY Did0YYBdheAZAy7ZaFmzFyVdeFlBS8ZuHFRGG8C21HK8YkcwVBKnkge6Xz201ZRTzcAX BRbmvng0NSXeyjNHJhGcAnekroq8zwaXoaE96AKPohjKKzEAIYCSk+R3vXY3n+1mRopm Hi5eFcjdkgJyNwMt31EGeYPvdSaDfHGGqPyh452VaoeTpWvrsLEBbBruT8nXHqY1AmO1 1JL6HetQo6m5UdyTeyPmHcWGey/Y1qdnvThziYuKsyioe/Uc4tpDUSc2xKJuOcKr6APP ancA== X-Gm-Message-State: AOAM531PUKVF+WhYvk/WIOGsya86c+ASQ/O8qiP9+W3BCK2VzbAichy9 3I/xR9EklfqhRJfSUUam1yl3EjYsBg8= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aleksandar Markovic , =?utf-8?q?Herv?= =?utf-8?q?=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Name variables holding nanoseconds with the '_ns' suffix. Reviewed-by: Aleksandar Markovic Signed-off-by: Philippe Mathieu-Daudé --- 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; - now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - wait = env->CP0_Compare - env->CP0_Count - (uint32_t)(now / TIMER_PERIOD); - next = now + (uint64_t)wait * TIMER_PERIOD; - timer_mod(env->timer, next); + now_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + wait = env->CP0_Compare - env->CP0_Count - + (uint32_t)(now_ns / TIMER_PERIOD); + next_ns = now_ns + (uint64_t)wait * TIMER_PERIOD; + timer_mod(env->timer, next_ns); } /* 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; - now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + now_ns = 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); } - return env->CP0_Count + (uint32_t)(now / TIMER_PERIOD); + return env->CP0_Count + (uint32_t)(now_ns / TIMER_PERIOD); } } From patchwork Sat Oct 10 17:26:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 705A4C433E7 for ; Sat, 10 Oct 2020 17:36:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0DC5F2245F for ; Sat, 10 Oct 2020 17:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pjr7GAEc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DC5F2245F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRInU-0003xS-5o for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:36:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdd-0000Yc-TG for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:34 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:42068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdc-0003rG-Ct for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:33 -0400 Received: by mail-wr1-x442.google.com with SMTP id e18so13667036wrw.9 for ; 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=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=Z+4uzXiTomroQ1nlNB9N95hAJBEetx8mNOgZsmlKOFit+5GU0Xmmh7jbEfwN09AQBd 6wsX9zogOJ7k4QCJTfiTno43SFvccp/5E8Y5jOvj960CiQ78wOaeI4W6/p11vWeeQX3L WCOKikzysn3q1pBGdFVGniHHjg+ZcNLBfmffImimL0KdwJ8DC4ELM6FPurzbSNZ9oxTa HpJ8lxXDNPq7Az1jjShgirdgkJy1LcymsptUgFxuuO2Jt928kMBuKiwPmolI4dk2G/3D lhts804hpWbmQjN+wJdYMLohD5joF+rT+G6rlINUrl35JkFu/cXN8qNdBpluRAaodok0 Dtqg== X-Gm-Message-State: AOAM532kHgOMzV116K9zNN1bsKDoTK8TRrgZtrGOS0juDuHT69QLJF/+ gpIFqQlwBV6kNxQozlpzKet86TLTfoo= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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" -#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 = 2). + * + * TIMER_FREQ_HZ = CPU_FREQ_HZ / CP0_COUNT_RATE = 200 MHz / 2 = 100 MHz + * + * TIMER_PERIOD_NS = 1 / TIMER_FREQ_HZ = 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) From patchwork Sat Oct 10 17:26:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F0A9C433E7 for ; Sat, 10 Oct 2020 17:39:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D952D22461 for ; Sat, 10 Oct 2020 17:39:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LxveMPg8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D952D22461 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIqG-0007KU-Rs for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:39:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdf-0000at-8t for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:35 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdd-0003rQ-I9 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:34 -0400 Received: by mail-wr1-x441.google.com with SMTP id g12so13662249wrp.10 for ; 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=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=Jxoaqgy9gwRQY6X/7NgDToDMZ7nsoqxehB5lINv29Qgd6Vhb5pc8CgosTk8oNK59ok ZrSpTmyNCwiSPxX8KUftabxWmqP0OCbOWMDn2nNJWl+CBplRIbZJjbHQrRz8ZVkcd/fF xgn+8gQvB48C7ycFh+uE1iSdaDaQp/peHVYDeXaaufbFL3aorhDDAnNd+rF+zjqJKk1Q t2VZopKiYOpkXATH0bdPlSw/ftQg2zkhGF97FlaKr/mDNs5fUf87vqGujMdrWaE1u6yK GITv35E9jAIOBOU8GQ/Gmysy7t80vqok2zkvstujAUoTYwuus8upyvjgCIiPnN3wNjm4 lhmA== X-Gm-Message-State: AOAM530jvElsuyPT1yetEnr7wjFLLpIEk5obCa7VELqbcjdoze7yDPF9 8D7qxnuRUoFKPfwcAWR2zjnuXTW1i+8= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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) */ }; /** 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" -/* - * 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 = 2). - * - * TIMER_FREQ_HZ = CPU_FREQ_HZ / CP0_COUNT_RATE = 200 MHz / 2 = 100 MHz - * - * TIMER_PERIOD_NS = 1 / TIMER_FREQ_HZ = 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) now_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); wait = env->CP0_Compare - env->CP0_Count - - (uint32_t)(now_ns / TIMER_PERIOD); - next_ns = now_ns + (uint64_t)wait * TIMER_PERIOD; + (uint32_t)(now_ns / env->cp0_count_ns); + next_ns = now_ns + (uint64_t)wait * env->cp0_count_ns; timer_mod(env->timer, next_ns); } @@ -76,7 +64,7 @@ uint32_t cpu_mips_get_count(CPUMIPSState *env) cpu_mips_timer_expire(env); } - return env->CP0_Count + (uint32_t)(now_ns / TIMER_PERIOD); + return env->CP0_Count + (uint32_t)(now_ns / env->cp0_count_ns); } } @@ -92,7 +80,8 @@ void cpu_mips_store_count(CPUMIPSState *env, uint32_t count) } else { /* Store new count register */ env->CP0_Count = count - - (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / TIMER_PERIOD); + (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 += (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / - TIMER_PERIOD); + env->cp0_count_ns); } 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, disassemble_info *info) } } +/* + * 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 = 2). + * + * TIMER_FREQ_HZ = CPU_FREQ_HZ / CP0_COUNT_RATE = 200 MHz / 2 = 100 MHz + * + * TIMER_PERIOD_NS = 1 / TIMER_FREQ_HZ = 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 = &cpu->env; + + env->cp0_count_ns = TIMER_PERIOD_DEFAULT; +} + static void mips_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); @@ -141,6 +160,8 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp) MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(dev); Error *local_err = NULL; + mips_cp0_period_set(cpu); + cpu_exec_realizefn(cs, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); From patchwork Sat Oct 10 17:26:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 303199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAFC5C433DF for ; Sat, 10 Oct 2020 17:29:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C5592245C for ; Sat, 10 Oct 2020 17:29:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XVcaN6s1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C5592245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIg7-0002Kf-U1 for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:29:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdg-0000cK-A3 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:36 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIde-0003rX-P1 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:35 -0400 Received: by mail-wr1-x443.google.com with SMTP id t9so13659164wrq.11 for ; 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=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=My4PdVjYjgD/2xyWZ23/Vv/BR6b0bkuHEsyJ1H2gOUj8DjGxwSKeNWgyU80pXtO5rV 87YGtE76hRz/iPOuEbwmpqesMF/ntII73Yk3ojWCUjEHtZjtzw2k2sPofF7iOfjffY6z hfp0LHIHVJFvx4GW3xAGTxQfqiiGkvWdJquPJZGMyFjzoyLVKriybsC4HUyxfn8mjhSh xLnbk/dSEfoO/g9aWZHgOJXhHM0T/bv+WGBYagGOxgm0fRN2a6oCPDMjUNmTeI5+gpdt nqiSOvPYUg4Ismz2OPGui9k41nBFmlCQuQomzwm9nX46dEQrIgq6G0QarBgq1/QSV0it U5JA== X-Gm-Message-State: AOAM533iluqaUqVV3TscbgGt74VmhtWlQOk89FK9SaX3yMqs0sxbzbXA /mPyAebIjriQGXK1C9vtxXvczC5UTGY= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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, disassemble_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) */ static void mips_cp0_period_set(MIPSCPU *cpu) { CPUMIPSState *env = &cpu->env; - env->cp0_count_ns = TIMER_PERIOD_DEFAULT; + env->cp0_count_ns = muldiv64(NANOSECONDS_PER_SECOND, CP0_COUNT_RATE_DEFAULT, + CPU_FREQ_HZ_DEFAULT); } static void mips_cpu_realizefn(DeviceState *dev, Error **errp) From patchwork Sat Oct 10 17:26:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 303194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF450C433DF for ; Sat, 10 Oct 2020 17:36:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 50DCC22460 for ; Sat, 10 Oct 2020 17:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SKKtqH7M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50DCC22460 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRInU-0003yU-DU for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:36:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdi-0000dg-P5 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:40 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdf-0003rd-QQ for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:37 -0400 Received: by mail-wr1-x444.google.com with SMTP id i1so7554807wro.1 for ; Sat, 10 Oct 2020 10:26:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i1cGbjc5Cl94JMQEfZlvF0v5MlNUEPZb+r7dtqjcBUs=; b=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=TmCED+fHDue9M0rjpuHSPQPuUTLokB2zirK1hb0GHBsNW9VPcX5xE68q+EkgqWHB64 6iQLgTuUJbsc0WP4hacqTpk3+Rxad4f8TxUR45cOyD9TVvx8cPHHjr40Wg9wJs0retht dYYz0wJIVXo0WeKJ9needprv11NhXCgV/5ZRBbJV+1DEXsUMTnrk+TfhOXEq/C1iAvLr JOa95Mbnfysqqpkrx9o8JfsKTpuloBEvowZubaLJYUZDQq+8QdZxv+Q1UumCzAswgwYw q4HRl+ZgQblI5+yRPJkRpZDeQiYJH2L7dZCwF0JmcXKXopS0dD+taeEpmdw1ncpVD/1d IjEg== X-Gm-Message-State: AOAM533SZrZiWkuIoT1eHavjCIcxlWQTATLGK8HZLQA0nIVEZ/HSQzE5 xajr9NHCHvqEtoC19wAyyNtlxXSV9NU= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 { 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 processor. + */ + unsigned cp0_count_rate; }; 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" static void mips_cpu_set_pc(CPUState *cs, vaddr value) { @@ -135,12 +135,7 @@ static void mips_cpu_disas_set_info(CPUState *s, disassemble_info *info) } /* - * 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 = 2). - * - * TIMER_FREQ_HZ = CPU_FREQ_HZ / CP0_COUNT_RATE = 200 MHz / 2 = 100 MHz - * - * TIMER_PERIOD_NS = 1 / TIMER_FREQ_HZ = 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 = &cpu->env; - env->cp0_count_ns = muldiv64(NANOSECONDS_PER_SECOND, CP0_COUNT_RATE_DEFAULT, + env->cp0_count_ns = muldiv64(NANOSECONDS_PER_SECOND, cpu->cp0_count_rate, CPU_FREQ_HZ_DEFAULT); } @@ -202,6 +197,13 @@ static ObjectClass *mips_cpu_class_by_name(const char *cpu_model) return oc; } +static Property mips_cpu_properties[] = { + /* 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 = MIPS_CPU_CLASS(c); @@ -211,6 +213,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) 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); cc->class_by_name = mips_cpu_class_by_name; cc->has_work = mips_cpu_has_work; From patchwork Sat Oct 10 17:26:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 303192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EBBDC43457 for ; Sat, 10 Oct 2020 17:39:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E1A0F22461 for ; Sat, 10 Oct 2020 17:39:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eYaWz2r4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1A0F22461 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIqH-0007NI-TA for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:39:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdm-0000eK-6V for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:43 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdi-0003ro-HY for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:41 -0400 Received: by mail-wm1-x344.google.com with SMTP id d81so12886841wmc.1 for ; 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=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=H/BPpTJ5ZwrqmfxTiyKK210P+GYO6p7JlCQAcc26BJXhtsaqTqEr747ilKAAdAjl/K hNgnS3uUsplorcvsLGdg4t1YBFr3WLzhMk/fYrWJ2zlb3Vy/ey6mu74UDYv2AY75efk0 /r291Fx6cpvw2oF69adfj2PgjP8u5l99+bM/cZUoRbZgUOHaWS452jFc5+6T/oAM17a1 qXv6bFdj9N78o/Dhh+tKNNF65R0NUg2dkpPfVt8ZhgaOaoe1khxaK//CMp8bcSjlP/KH bMeB0wJDADHcq9uXi7WS3ptiZ57Ww0SnNIpX+IjGELVzQUDrCxyzCY9fzdmhwdjvK8yp Vaew== X-Gm-Message-State: AOAM532OvviJzKK53XYhnMxm8Yk1Lo6e1fFmea2sEAwYXrgoq57bN/rh FFCEZNuB5FbBWH6JEgt0bkZi/eHv/WM= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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" #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 >*/ + 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" static void mips_cpu_set_pc(CPUState *cs, vaddr value) { @@ -144,8 +145,8 @@ static void mips_cp0_period_set(MIPSCPU *cpu) { CPUMIPSState *env = &cpu->env; - env->cp0_count_ns = muldiv64(NANOSECONDS_PER_SECOND, cpu->cp0_count_rate, - CPU_FREQ_HZ_DEFAULT); + env->cp0_count_ns = cpu->cp0_count_rate + * clock_get_ns(MIPS_CPU(cpu)->clock); } static void mips_cpu_realizefn(DeviceState *dev, Error **errp) @@ -155,6 +156,10 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp) MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(dev); Error *local_err = NULL; + 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); cpu_exec_realizefn(cs, &local_err); @@ -178,6 +183,7 @@ static void mips_cpu_initfn(Object *obj) MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(obj); cpu_set_cpustate_pointers(cpu); + cpu->clock = qdev_init_clock_in(DEVICE(obj), "clk-in", NULL, cpu); env->cpu_model = mcc->cpu_def; } From patchwork Sat Oct 10 17:26:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 303197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8C90C433DF for ; Sat, 10 Oct 2020 17:32:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D1462245F for ; Sat, 10 Oct 2020 17:32:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AA7Rs5Vs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D1462245F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIjm-0005z0-Eb for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:32:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdt-0000fe-53 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:51 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:50895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdk-0003ru-Bv for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:43 -0400 Received: by mail-wm1-x344.google.com with SMTP id 13so12892024wmf.0 for ; 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=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=Lf3lvU7hm3NR3tyDzA3kax/IE/L0m18JFQPrtpsBkLg2LfVZSukkbkofRHNOpmJO0o rE+4AQtn7nwFsOapr2D4aEDo6LyPeTUdIU2+tsmUBv7K+Qo+QGlmUX6lWA6tQ+7Ug4Ak 804gcPcgd5vWu8CL5wad23+um54YIcEO2U093hpVV+XNDwD+pPrFpykB5NnexTzKH5W4 RGR6waP2sSRziFjBQ1MqGamLoed+THemhk8ufx0JURVH+m2y/J51tIu4W4FBRpRJP52n cBnTakIGL4KjIxbXyBItUsrucfGShO2RATec9G4qb0Bi5kSw0Lus9uthJAaulBQWn3tg dTSA== X-Gm-Message-State: AOAM5320JJxb0mXwTpnliezbZPR2YOnrjWma+yI+7f0dm35AHuynDh9H RCCZsnXQasgO66E96+Q/2cdoMNCP3gQ= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Since its introduction in commit 6af0bf9c7c3, the 'r4k' machine runs at 200 MHz. Signed-off-by: Philippe Mathieu-Daudé --- 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" #define MAX_IDE_BUS 2 @@ -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; /* init CPUs */ - cpu = MIPS_CPU(cpu_create(machine->cpu_type)); + cpu = MIPS_CPU(object_new(machine->cpu_type)); + cpuclk = 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 = &cpu->env; reset_info = g_malloc0(sizeof(ResetData)); From patchwork Sat Oct 10 17:26:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60297C433DF for ; Sat, 10 Oct 2020 17:34:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C44A2245F for ; Sat, 10 Oct 2020 17:34:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Gst39v3O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C44A2245F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIlb-0000kR-5w for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:34:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdt-0000fd-4y for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:51 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43421) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdk-0003s3-32 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:42 -0400 Received: by mail-wr1-x441.google.com with SMTP id g12so13662477wrp.10 for ; Sat, 10 Oct 2020 10:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=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=CZlbeedBRFcxtl3UewaI8iDS2dhVjp5DHf+m+Z6fFYCtffoTb5D0DrYkumgeasBtUd aXZb8wnYZRbXdCWAuWHrbVlwmZUgcZWhgy3e+vWYyXT0AwTIVBv7Vl0+fJNusEZW/fJ3 hbYlF1QciL/Ik2CJMpVIYTWaGqHawhXqnrptOUTB52jtCDU4eyhdF8QRl5tg5HbEXsql hUALGHC084lu+0e+DvdprezGXQmjlXbgOTqbO2FxC6nEXfaqZKNmr5Y5Mvg9fYT+h7eW 00B+eUlIyXeuoTTXQFhGtcLVmgHN0MXLPi/kSruUlFtVInaEemfS+q6kdU7PfSMKxpLu fAPw== X-Gm-Message-State: AOAM532uMlm6LEvMjAyU2enjUOxU4RL/WUFV0eDyZzWIBJnoe5s67c8I Gby6eALLmh/TSdwCw1zclt1PG0fDXeE= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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; /* init CPUs */ - cpu = MIPS_CPU(cpu_create(machine->cpu_type)); + cpu = MIPS_CPU(object_new(machine->cpu_type)); + cpuclk = 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 = &cpu->env; qemu_register_reset(main_cpu_reset, cpu); From patchwork Sat Oct 10 17:26:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F537C433E7 for ; Sat, 10 Oct 2020 17:32:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C88652245C for ; Sat, 10 Oct 2020 17:32:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E7W5A0+v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C88652245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIjb-0005ka-JV for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:32:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdu-0000fh-0P for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:51 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:47075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdl-0003sA-VO for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:43 -0400 Received: by mail-wr1-x443.google.com with SMTP id n6so13370272wrm.13 for ; 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=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=aRWu644D5aooja3qXGcnvSjuMeVK1V0YNN0ygfuSSXDkxPrwTwZsIVzul67i5W/Lvy M19cJ0clAtkoC/+nUUPNA9DMS0Z5afPOCPoFO/JU5U5iRoYO1ewwD+7+5JxTCvRVTJhu Ar9nLYKQtAKmILDCDP3jKs26e1VFsOYg6yZd3OUZcewCL3cze2OxNtFhNt7JEgDRXbKo mxTcmZcvKFEVVQHUYW0X36lPZL2b0nqcpbisM5hXLi6SOeYoiz42ZXyIRtRYEJkmzYWT GY73ZZGCNmBMxtKt7rYigKomA3Y1ybN281tD0q7zDgXBTOQDvxiqaVXhmS53mbQWCXZW unJg== X-Gm-Message-State: AOAM531r8/45zeDOOkCZDkk5saON+JPmKg8ThHDU8JYTNPDrmBP+zBt/ CHxMG4faCwQ2Bcz8BHY3YFvX44oelws= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 = g_new(MemoryRegion, 1); MIPSCPU *cpu; CPUMIPSState *env; + Clock *cpuclk; ResetData *reset_info; int bios_size; /* Init CPUs. */ - cpu = MIPS_CPU(cpu_create(machine->cpu_type)); + cpu = MIPS_CPU(object_new(machine->cpu_type)); + cpuclk = 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 = &cpu->env; reset_info = g_malloc0(sizeof(ResetData)); From patchwork Sat Oct 10 17:26:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 303195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 951D4C433DF for ; Sat, 10 Oct 2020 17:34:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 312F02245F for ; Sat, 10 Oct 2020 17:34:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D6UP6D8r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 312F02245F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIlf-0000wA-AJ for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:34:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdu-0000fi-PZ for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:51 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:37524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdl-0003sI-Ve for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:45 -0400 Received: by mail-wr1-x443.google.com with SMTP id h7so13707948wre.4 for ; 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=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=WNfB2TZF4p21EbZtC46F7HMw7CfmyKN29PK72VQWqRb2M6KYuvleGbJ/SkqIxDBIWb SRxNbukN30estleVJ4Ze4h9a0kVTbZvgBMkKaVak+0sxW0VKAbge39FxEXWzmxHmqLCo DQS0KM22CkarACLp9pKvOl+GK2Q/LPpF1/NgdjQnq7DsgJCjEHMI3/eKjVsSpnjxGBL1 qLbri5TE3TZTb6kQWuIKq2YKNJRxFnlJlOhse83AAZTG6jhkdacOUEJtzlNjykfsSpCD bOZAikhnpXM9FTVaUa6HRVA4g3ZhvPFn26PUyUQ4KW6uGXvcFv5okR20nQ15Ih/lDSHg 3OBA== X-Gm-Message-State: AOAM532tDkoL7/MEBzE8PW5/F2RHzIJQoF+RjzUL/nQaX3R96t01YlVz QLI0qZO9aZ90qriaK0V+uz7mLW0YlEU= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The Magnum 4000PC CPU runs at 100 MHz, and the Acer PICA-61 CPU at ~134 MHz. Signed-off-by: Philippe Mathieu-Daudé --- 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 = g_new(MemoryRegion, 1); SysBusESPState *sysbus_esp; ESPState *esp; + static const struct { + unsigned freq_hz; + unsigned pll_mult; + } ext_clk[] = { + [JAZZ_MAGNUM] = {50000000, 2}, + [JAZZ_PICA61] = {33333333, 4}, + }; 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, } /* init CPUs */ - cpu = MIPS_CPU(cpu_create(machine->cpu_type)); + cpu = MIPS_CPU(object_new(machine->cpu_type)); + cpuclk = clock_new(OBJECT(machine), "cpuclk-out"); + clock_set_hz(cpuclk, + ext_clk[jazz_model].freq_hz * ext_clk[jazz_model].pll_mult); + qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); env = &cpu->env; qemu_register_reset(main_cpu_reset, cpu); From patchwork Sat Oct 10 17:26:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 046D0C433E7 for ; Sat, 10 Oct 2020 17:36:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A46D22461 for ; Sat, 10 Oct 2020 17:36:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RBGnDAlY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A46D22461 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRInb-0004H4-Mz for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:36:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdz-0000iU-N3 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:55 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:47075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdu-0003sU-HS for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:52 -0400 Received: by mail-wr1-x442.google.com with SMTP id n6so13370382wrm.13 for ; 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=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=IUUA1CVzPOeBwR7BCUBgCIOpwK6csJ01eaX8PhCKlEaEdV7X9I19wwHMA2tOx++YMY DkxnlwVODQlMEPWeMeirzzmguYHWX0aJvgkJDa82zEGrof2+2Nb5V4nd2/fZVyL0EbVf ZZo8AkUTFdVSsS4ZthLNsQqJzMXQRZVIg0TgIiQicreFeNBXTnYrBbCz98rg8O4SwgGv /jneUlEpTtNcBtnu/vVJvikQJ9sD10tFbg+/ATAKHLocuc3mShWsElxVhAs9oTwJ5eUB ghxfRVic5wnU7ZVG1XifggyiAs+ftlzlFl4i8gOqxJr6GFoDtQR6gWRraKqugq5+MWcM bTwA== X-Gm-Message-State: AOAM531btIXAIqorWHeLkBE8fxtinlQr1QZ439RUY6+CiGpmRXvULV5F h09S8kLMSatCusBbn4u+gPI8eUYOYUQ= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Expose a qdev input clock named 'clk', and connect it to each core. Signed-off-by: Philippe Mathieu-Daudé --- 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 #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; }; 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 = SYS_BUS_DEVICE(obj); MIPSCPSState *s = MIPS_CPS(obj); + s->clock = 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 **errp) errp)) { return; } + qdev_connect_clock_in(DEVICE(cpu), "clk", s->clock); if (!qdev_realize_and_unref(DEVICE(cpu), NULL, errp)) { return; From patchwork Sat Oct 10 17:26:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 441ADC433DF for ; Sat, 10 Oct 2020 17:43:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 887E52246B for ; Sat, 10 Oct 2020 17:43:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fVKyDzTQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 887E52246B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRItd-0002K6-H4 for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:43:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIe1-0000lQ-B9 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:57 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:47076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdz-0003sb-D1 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:56 -0400 Received: by mail-wr1-x443.google.com with SMTP id n6so13370430wrm.13 for ; 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=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=I+WCPy/n1fR4GErHzduUI6HPvOvq4kLj/ayyGRTlUCmY7QAOv9iQaD/fT39DGGYMk6 qkYr9UrLJHivm2LUaseIJpgAQ7qpQ/jsPjqGhSg2k+YfTs55gQUWie770C/jkf23YzN+ FNFXdFjWUkMplrhg7ofW3RkD5bXYYjWgphj8iMW5/OTPh/fRGTmEb3kKya8fpksg8E2M odPfaarKW5twOey27YqFuLVxyVdbhz6PfviVoODcVaDLc2cR4580QF8coWDVTEIr7kUg KdFo23mX6QH60VK1IBPdRv8vgmUHw6+FtYIkLbYQ5/wh5wZgLJubSJYnz1NjaxfFIYPM yNSw== X-Gm-Message-State: AOAM530SZ0D5/J7txmC5WKH+3tRYx350x5ha6X/zSfgpwV/F7GwfknXI 8uTH0r6zdHSgqfRCAyJLH0olmX5uguc= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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; CharBackend lcd_display; char lcd_content[8]; @@ -251,10 +253,19 @@ static const MemoryRegionOps boston_platreg_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static void mips_boston_instance_init(Object *obj) +{ + BostonState *s = BOSTON(obj); + + s->cpuclk = qdev_init_clock_out(DEVICE(obj), "cpuclk-out"); + clock_set_hz(s->cpuclk, 1000000000); /* 1 GHz */ +} + static const TypeInfo boston_device = { .name = TYPE_MIPS_BOSTON, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(BostonState), + .instance_init = mips_boston_instance_init, }; 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); sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1); From patchwork Sat Oct 10 17:26:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B32CCC433E7 for ; Sat, 10 Oct 2020 17:44:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3595B22470 for ; Sat, 10 Oct 2020 17:44:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bRNurP37" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3595B22470 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIuV-0003D6-8y for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:43:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdz-0000iT-OJ for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:55 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdw-0003sf-TJ for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:54 -0400 Received: by mail-wr1-x444.google.com with SMTP id x7so5082488wrl.3 for ; 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=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=pts5kQl0rEe1hNgq8KeHrjUe4tWVX4B3OMFC9JSezwoL8zsYPBfUEYBm2K17npFO0y 8Ybs0R2+oIKk8x2j31F/5wnKX4aog92dWsElUlc+vs6lAIPaysGfqXGzDCYaEqfaBEAU 8eTk7aH6QpzshEx7aU1Po+daKUcjIXOjZXqm6//LPSYGxAgWJjxHTm4hMl4mMYX/B2ok 54KRVCX+8W772+Q8ZNHlRjxpjAoIht9Y+rqtcm7og+PH8wtJn98tBMefQwTtUL74MZQQ Fl7Y9vv/bKSgYAfb4T3Sg9jH8KwgUtiefPPwLisgk/QHI+hHLFpPBd+u0NV/WGiwIAe7 wOtw== X-Gm-Message-State: AOAM530tY8wwyZt+klP3zJLmoDLTZ3SyKaFWdhx2eItZT5peBBwJxZnS pZNB9dINBtMwiXKPgQjk/jsjZPssZAQ= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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" #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; + Clock *cpuclk; MIPSCPSState cps; qemu_irq i8259[ISA_NUM_IRQS]; }; @@ -1159,7 +1161,7 @@ static void main_cpu_reset(void *opaque) } } -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; for (i = 0; i < ms->smp.cpus; i++) { - cpu = MIPS_CPU(cpu_create(ms->cpu_type)); + cpu = MIPS_CPU(object_new(ms->cpu_type)); + qdev_connect_clock_in(DEVICE(cpu), "clk", s->cpuclk); + qdev_realize(DEVICE(cpu), NULL, &error_abort); /* 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); sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1); @@ -1203,7 +1208,7 @@ static void mips_create_cpu(MachineState *ms, MaltaState *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); } } @@ -1421,10 +1426,19 @@ void mips_malta_init(MachineState *machine) pci_vga_init(pci_bus); } +static void mips_malta_instance_init(Object *obj) +{ + MaltaState *s = MIPS_MALTA(obj); + + s->cpuclk = qdev_init_clock_out(DEVICE(obj), "cpuclk-out"); + clock_set_hz(s->cpuclk, 320000000); /* 320 MHz */ +} + static const TypeInfo mips_malta_device = { .name = TYPE_MIPS_MALTA, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(MaltaState), + .instance_init = mips_malta_instance_init, }; static void mips_malta_machine_init(MachineClass *mc) From patchwork Sat Oct 10 17:26:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 303193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D430EC433DF for ; Sat, 10 Oct 2020 17:36:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7FF6222461 for ; Sat, 10 Oct 2020 17:36:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EGd4lNF/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FF6222461 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIng-0004TY-KN for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:36:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIdz-0000ib-Oi for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:55 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdu-0003sn-Hl for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:53 -0400 Received: by mail-wm1-x341.google.com with SMTP id d81so12887208wmc.1 for ; Sat, 10 Oct 2020 10:26:46 -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=MOmvsAG+VL77pcXHRd+wKkbpkr9m/Vnq2doxUzqSm8xF6IpbNPQXsk2JjSqxz3jq/Q 6eb+YT1lv0NFOz6ROIwPdRaeumUeMokVHesa72UJy91b8exTbnSOxmBKvYNrz7fUpG7t lTzjMerQtSdJt7mrkN3tNRNd6x3fcpRGgU31Z9UYN6zVwxTe1m+222Osu1IuKFMedCTa 65wKBG7iwO9r2xdK13uuAspLdOPfIzQFIpHtfllr8+X6ramVDA7bAmQpBsFSp8oOWP5v bzX3JRe5GjyfEV8qk8zejDzEp/W/T26Ips9WgKB1CIXvoCJx/Coe3hbAsdg6nToMNmuP cCHQ== X-Gm-Message-State: AOAM533jD+W31vV3GIMI9rFwF3Y4ixPQmRIiElPB7oFpKZfVgx+ML9CM TEHoHYFkvr/m2k4fAjHX8QU682ThUrs= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 **errp) bool itu_present = false; bool saar_present = false; + if (!clock_get(s->clock)) { + error_setg(errp, "CPS input clock is not connected to an output clock"); + return; + } + for (i = 0; i < s->num_vp; i++) { cpu = MIPS_CPU(object_new(s->cpu_type)); From patchwork Sat Oct 10 17:26:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08897C433E7 for ; Sat, 10 Oct 2020 17:39:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93BCA22461 for ; Sat, 10 Oct 2020 17:39:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OspX0yPr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93BCA22461 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRIqP-0007fg-Ms for qemu-devel@archiver.kernel.org; Sat, 10 Oct 2020 13:39:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRIe1-0000lP-B3 for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:57 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRIdz-0003st-Dl for qemu-devel@nongnu.org; Sat, 10 Oct 2020 13:26:56 -0400 Received: by mail-wm1-x343.google.com with SMTP id f21so12874559wml.3 for ; Sat, 10 Oct 2020 10:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=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=XsXqkfAC9yOzl5ZGs/aKVh0tcS3ikuSqNDLfTbC8g/oFRjR98M/c/S5IFk+UzkIrdf a44GLPvfr5nXsVbV27FYI+CltU7nUZ+JaLZwlip0LInWgTCTmLSpajxzv5TXMt9xPrS7 Pp10PBFtOxguhnC3SStMz48nRZE8yucrnRXmKD/GKhGVfiUnJJjlalHHZdedNb76PPAW CwjGgYb6TDW4OenF0ZwkXw1tPVosLqwWgF86A0QpRZUC2UrhqcOysjnDXEP4TiLN3UnX sEiiHzKr9wlvQ1felrBXMNf10L+XBgQGY8r2jyFUH0/IXWi+cOlCjkGkcN+c9h9PyQth 8nBA== X-Gm-Message-State: AOAM533buEfcfaoDs7cllKSt7FHKnxBvPBgIZg9/0xG/JNGAPHO37cuZ Su3cT0A2Nq2fFzi7U7W60lDWHB056TU= 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Huacai Chen , Aleksandar Rikalo , Luc Michel , Paul Burton , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Huacai Chen , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 @@ */ #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 = NULL; if (!clock_get(cpu->clock)) { +#ifndef CONFIG_USER_ONLY + g_autofree char *cpu_freq_str = 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); }