From nobody Sat Apr 27 23:20:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) client-ip=209.85.218.47; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f47.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617960992; cv=none; d=zohomail.com; s=zohoarc; b=kzjTL922S4j8LtQejVV+uT2KcICt8i64o6AKikEsNKmpWnAbrPC24t6kFXtJ1Id7uSOy4nEsoMDO6AWw50kpjdFu6TpVHASrTMrWyCI5PsrGETdFxc8aCiTJ59zEuOW8Zh4SnEligTxUCYDKKNhSicj7V3pK7Bn1PAKDd21/gt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617960992; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2jzT10IDw8GqcAMkVi0ePEkWHtJHIafM5a4hvb/idiU=; b=VWeIhclhebCWFaKRnykpwqiScGkvKhVg9rD0jYUfyQRjtxevEjsRHKcI3YnWXi53r0q43KF/PA1Wx8FjXoOmHS6xpa9pUvWU6U+BmMszu3buFRkxZny41cA9Y4O+medijXC0MJmL+NILVCEnhTRrqh4+UegAwpDYxUxHN4+40yo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by mx.zohomail.com with SMTPS id 1617960992875198.8866877408334; Fri, 9 Apr 2021 02:36:32 -0700 (PDT) Received: by mail-ej1-f47.google.com with SMTP id e14so7598861ejz.11 for ; Fri, 09 Apr 2021 02:36:32 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id r17sm1122048edx.1.2021.04.09.02.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 02:36: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=2jzT10IDw8GqcAMkVi0ePEkWHtJHIafM5a4hvb/idiU=; b=nbBdZhNU6QpWAf6JVUEAfVtUjh9YH1O45GPqVE3u4nWq3u41YDlCTmSn2KDQ82JBfE dD0AHFzUugEJYgHCMZWrSFLhotwkl8zmC4XOMFKH3V/TCLA8b1fpM7OwaKtx9XyBZXN+ CTBsWK/ce+qfvyf4H/VldUMEHbnPklvrab0roJr3A5MwN37VaBveJAJK+tyLsxPM5B0q lkd3AgF4RoPr7b4mwPvWprIU+kuEZeha/IuNXAJORH5KRS4LbC2mTmPTMC/xmFSdmNcF arIBQREzOuaoGLifQsaY/DbzD0agouvpndYZLTRQGQPNrZRgKjqcOvrMJKgUy9nBAwoc Bi3Q== 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=2jzT10IDw8GqcAMkVi0ePEkWHtJHIafM5a4hvb/idiU=; b=Y4gHNuTuGWfaJ4SsWsCdFdAyLJieQ4ginW9V8AuwiepksEK1RMRZKm6niOIGzo1a8x QRSavh0dC4BgKUlk3Lyl3+Fwlyh/T6EC7HVteB1IPNF8eeYxZBJTzhyCOPimsaEvSJuX UGgokGbh6MfzVnQN5e6tQ+YV/PB2T/DuB2rNESF5SGLOD6pamLHotlyb16oAa4poHjl7 wTSIw/ZRpPgPmI2F+afbL13yvXo2jwTcXA/PbO2hGBCxcctvVpHLYYipuszc/FnubQgS ciXFrXnLdKEvH899bwIJHEjGMt/DK7QhbxWHOxs+I4pzi+pE4r8OAP+Igw9Kfgq2fktN eIpQ== X-Gm-Message-State: AOAM533t2LDzAQVmzIdh+2d8Ii+SDRivb1xJaq9x2RD39J4HPZZGSRP2 uMRK1q/gr5NSBE8AI83Mvjc= X-Google-Smtp-Source: ABdhPJx457xqYwWe+eGM7e1lKVWCyUhiblYH+B6eeFgD8FjlJqli76ufM3QPp6xxv8MCNXE2ADXubA== X-Received: by 2002:a17:906:fcb2:: with SMTP id qw18mr14803984ejb.434.1617960991097; Fri, 09 Apr 2021 02:36:31 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Peter Maydell , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hao Wu , Aleksandar Rikalo , Huacai Chen , Aurelien Jarno Subject: [RFC PATCH-for-6.1 v2 1/6] target/mips/cpu: Use clock_has_source() instead of clock_get() Date: Fri, 9 Apr 2021 11:36:18 +0200 Message-Id: <20210409093623.2402750-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409093623.2402750-1-f4bug@amsat.org> References: <20210409093623.2402750-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) clock_get() returns the clock period. With an unconnected clock we get 0. This is not what we want here. Use the API properly by using the clock_has_source() function instead. Fixes: a0713e85bfa ("target/mips/cpu: Allow the CPU to use dynamic frequenc= ies") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/mips/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index dce1e166bde..aa0b00256e6 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -612,7 +612,7 @@ static void mips_cpu_realizefn(DeviceState *dev, Error = **errp) MIPSCPUClass *mcc =3D MIPS_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 - if (!clock_get(cpu->clock)) { + if (!clock_has_source(cpu->clock)) { #ifndef CONFIG_USER_ONLY if (!qtest_enabled()) { g_autofree char *cpu_freq_str =3D freq_to_str(CPU_FREQ_HZ_DEFA= ULT); --=20 2.26.3 From nobody Sat Apr 27 23:20:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.44 as permitted sender) client-ip=209.85.208.44; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f44.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617960998; cv=none; d=zohomail.com; s=zohoarc; b=nCMhItHTRWmNi7KV/yuHIrha4f8cfwfqwYCZg17faGUo3P7mNZjLbSSGu6XR/88zUxjC/LNaUyWbTVzakUjtHLJgU3rNyxKGkacgtdltyvj4IAl2ug4mIu2v4Rw+Z+rg4KJOEkd6+aDfSOSMFlOblNK8AMZIcoOSsbKDA3BSotA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617960998; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lxBTXyvbAaGxN3p2AS1o7HgTWI8VLAUHNHXBSFX2Z74=; b=mBkHn+RrFkjEV+mUugpxmwnnJzIK/Mdj10kFXj9o/i/u4YmJAV2YpP32i0b6MHmzc1Bh9FTEB/+osOvi0SyeYAE4Xoh4jJyIVRxKineYbntUlzwn1s5KkcwCKsJjnNOLl1bBfdH++ij+5U9RRUOKVWpPZ3/yoZXDaHVpcu3wlyE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by mx.zohomail.com with SMTPS id 1617960998203700.0312605345518; Fri, 9 Apr 2021 02:36:38 -0700 (PDT) Received: by mail-ed1-f44.google.com with SMTP id e7so5752052edu.10 for ; Fri, 09 Apr 2021 02:36:37 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id t1sm1070337eds.53.2021.04.09.02.36.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 02:36: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=lxBTXyvbAaGxN3p2AS1o7HgTWI8VLAUHNHXBSFX2Z74=; b=SsXF+UgIizRJlNFOQ2H+y4CGGoClAglnEgI3y/MrRXtsJbHBTLEZrjaWO43gBHPVNh 2+Ir3rN2K10FfnemQBcBxXRK5JeHOoJ+4pBTearUlvZwXZ9HcKDWPB/rUOAc79SWckV9 msJzmfzkRtmbT3Hm339M0gRNN489Gga2K48ygWGKDPtX+tYTqukI+L2BntqNNL3IKwUK Gsd+i0nU/GFOX/vLHOXFyJR94HFx99yOqLdzEVuR4SfP9iXghRObnyc9r3sp5oMxYeLN ZZvy7/q2L5PH/QVFTsuoG5LG2n8qxEuueEmXsIbbbE1tHv2bYzd+kdbwfahYIxPxf8mP bUng== 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=lxBTXyvbAaGxN3p2AS1o7HgTWI8VLAUHNHXBSFX2Z74=; b=OY9bbM1YFFVQjWmiT70GGnvqmp4I/pDDJMoE+JGzHpJ82ZHy/Qq8J6DUXdVWLxGgpp nIyB39Ng2Zjh9wqpdzS8zrEdcrdImU7PD301hM9XjJ90MQah98QLsjF5HUFuKc5fWuVU Iai0csIGwSwDw/u1N4DjskudYuOqbyRwN7E7g0B9055v8PKmsNg67ISTjFh0oKT1Ycdf RhtbNB7NRjuce+DgE3u3Wj5KdXcBuEC4L2d3GXGK5yyFkppmB8QeYyIoblJN9j8NRvWY 4iak6yAopLNgj70Z/M/f+Y4TKwalsz0xmIiBBhK2/1vYht9N+u9mfaubh6v2XdKjWEer urYA== X-Gm-Message-State: AOAM530QQ5QaalAXkEPnULWI4Fcwh54652QsW4ixhgK5iRj5mgME3k9t eaSFxW1Klq8aTQH9LVMmgEI= X-Google-Smtp-Source: ABdhPJwSBS3RTHQYhNdbckVP0XM2zHcgPpKtPxo7Znz1G/19SoBlSGgXKGTKiKsHUmhhmJdwNq1Y6w== X-Received: by 2002:a05:6402:51d4:: with SMTP id r20mr16676168edd.112.1617960996372; Fri, 09 Apr 2021 02:36:36 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Peter Maydell , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hao Wu , Aleksandar Rikalo , Huacai Chen , Aurelien Jarno Subject: [RFC PATCH-for-6.1 v2 2/6] target/mips/cpu: Update CP0 clock when CPU clock is propagated Date: Fri, 9 Apr 2021 11:36:19 +0200 Message-Id: <20210409093623.2402750-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409093623.2402750-1-f4bug@amsat.org> References: <20210409093623.2402750-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Setting the CP0 clock simply on CPU init is incorrect. First because the clock can not be yet propagated. Second because we aimed to support dynamic frequencies in commit a0713e85bfa, so the CPU frequency can be changed *after* init time. The correct way is to register a ClockCallback, which will update the CP0 period when the clock changes. Fixes: a0713e85bfa ("target/mips/cpu: Allow the CPU to use dynamic frequenc= ies") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/mips/cpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index aa0b00256e6..db93d19c49a 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -604,6 +604,13 @@ static void mips_cp0_period_set(MIPSCPU *cpu) assert(env->cp0_count_ns); } =20 +static void mips_cpu_clk_update(void *opaque, ClockEvent event) +{ + MIPSCPU *cpu =3D opaque; + + mips_cp0_period_set(cpu); +} + static void mips_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); @@ -624,7 +631,6 @@ static void mips_cpu_realizefn(DeviceState *dev, Error = **errp) /* Initialize the frequency in case the clock remains unconnected.= */ clock_set_hz(cpu->clock, CPU_FREQ_HZ_DEFAULT); } - mips_cp0_period_set(cpu); =20 cpu_exec_realizefn(cs, &local_err); if (local_err !=3D NULL) { @@ -653,7 +659,8 @@ static void mips_cpu_initfn(Object *obj) MIPSCPUClass *mcc =3D MIPS_CPU_GET_CLASS(obj); =20 cpu_set_cpustate_pointers(cpu); - cpu->clock =3D qdev_init_clock_in(DEVICE(obj), "clk-in", NULL, cpu, 0); + cpu->clock =3D qdev_init_clock_in(DEVICE(obj), "clk-in", + mips_cpu_clk_update, cpu, ClockUpdate); env->cpu_model =3D mcc->cpu_def; } =20 --=20 2.26.3 From nobody Sat Apr 27 23:20:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.41 as permitted sender) client-ip=209.85.218.41; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f41.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1617961003; cv=none; d=zohomail.com; s=zohoarc; b=g/KTc3lzMwI5w4Ae70JKJ6dIthR4u4iK9wFeliOql855qprvEpqMgNOWi4EGdkmdKfConVuzlcTbDkq9u8ETDqzAe3O2gxY4/BVUY+gRtTsUkgkAUMsy6hx1c60fT4UfWoXH0Q0VhLDN6r3GU33VNBsAeiJRhwkTK3cfqlN7/jU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617961003; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=T+4ADdhkVIxyjAgrjisa3QyFRFD4Jv4USEQdTNaJS5Q=; b=g26nW5fqfnj1S9b26JyMaZUAuau39u6nGELSEW5y2hP+6Z7/q9mwnlWkKV6H8nrS8/rbfz8EGMRk5+gH+fnuk1fXG2A+wCs12mMCBKQfyTf8FcEgSu6zwMJnmaD14FBbx60xnIn+ncLrwiqG5I2RmTKKTod2Cp+UR+ykAJB4mh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by mx.zohomail.com with SMTPS id 1617961003256857.045128670455; Fri, 9 Apr 2021 02:36:43 -0700 (PDT) Received: by mail-ej1-f41.google.com with SMTP id mh7so7594861ejb.12 for ; Fri, 09 Apr 2021 02:36:42 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id bh14sm940837ejb.104.2021.04.09.02.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 02:36: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=T+4ADdhkVIxyjAgrjisa3QyFRFD4Jv4USEQdTNaJS5Q=; b=W2X8XMNDESoAQWNNcDFUt1MgIH/TxfqP1Y6eOfjXtlWD5oUCyJnPgrMiHTkmKLX0lg rXRG47oWaTn4bu7Y9sActP/lBS2cXAgpzHNUK+IWj41P7xf10pQ3Keodoqfmc9MKj1M9 RUpRtdOpTQvJCzTl0Xh67/CVS74TOv5Y540nq7gqUP9L1lKuyhFQPp7vuvqj0C17a3Gq +7ESkvw/ijmSzMwMKRSZHon8gwKat9UOBAV1HiiyT7NQn9yVo0u4cxybCoM2iY41xi9E aLEWdRuDCg8SOGgTMJ10H5kXwkpQ1SeglcOoVLxrGnirgX/yWsBgtkxB7/hBIPR37CLP F+vg== 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=T+4ADdhkVIxyjAgrjisa3QyFRFD4Jv4USEQdTNaJS5Q=; b=NVIfzBCyubrs3UwBjq/2RolWLFmVKCtizmc4GbdwTJuIPkYne6UijeT1Fwdi3NRfT/ x5opdP66fpoN1lHaxDx3RZeGcIkeplPlEtLWJR+/9VMbyBA6Apszr3hTcD9lhVrRmFe6 zPQy0BZgrGRFFQM75vUmi9pZ22PzimHvVh2D2SGAf6ZDJb1cPZYLIta7nKrBedSQhH3T scJFMGxPi/g/F5SXs6f+wNI4CEPANQ1M+vMcESKPIyz/mmVWPIdji2Q5/6KMDgX7kjls bSbLibzSYBI9HREAhytzcy/olpZF9PGStYD5DQPH7Sag2ballMXIRH8oPfscTivn6Co3 Zj0g== X-Gm-Message-State: AOAM533rYJxb7c3R8lOvv8nVOE8mFHF1wLMVDw+OsZMsm3hwgT60VN0j M9m1Fpv3j2BzO4M9cNcxctQ= X-Google-Smtp-Source: ABdhPJwLF+rmA11f92HSpvmo0LOqtUCTjFF7xwH1c8BFH65iCN2HyyHYlYfeizKX9yn5QHQBqJ5FEA== X-Received: by 2002:a17:906:49c1:: with SMTP id w1mr15582105ejv.178.1617961001554; Fri, 09 Apr 2021 02:36:41 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Peter Maydell , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hao Wu , Aleksandar Rikalo , Huacai Chen , Aurelien Jarno Subject: [RFC PATCH-for-6.1 v2 3/6] target/mips/cp0_timer: Add ns_to_count() helper Date: Fri, 9 Apr 2021 11:36:20 +0200 Message-Id: <20210409093623.2402750-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409093623.2402750-1-f4bug@amsat.org> References: <20210409093623.2402750-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Factor ns_to_count() out to simplify a bit. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/mips/cp0_timer.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c index 70de95d338f..73355b44b15 100644 --- a/target/mips/cp0_timer.c +++ b/target/mips/cp0_timer.c @@ -27,6 +27,11 @@ #include "sysemu/kvm.h" #include "internal.h" =20 +static uint32_t ns_to_count(CPUMIPSState *env, uint64_t ns) +{ + return ns / env->cp0_count_ns; +} + /* MIPS R4K timer */ static void cpu_mips_timer_update(CPUMIPSState *env) { @@ -34,8 +39,7 @@ static void cpu_mips_timer_update(CPUMIPSState *env) uint32_t wait; =20 now_ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - wait =3D env->CP0_Compare - env->CP0_Count - - (uint32_t)(now_ns / env->cp0_count_ns); + wait =3D env->CP0_Compare - env->CP0_Count - ns_to_count(env, now_ns); next_ns =3D now_ns + (uint64_t)wait * env->cp0_count_ns; timer_mod(env->timer, next_ns); } @@ -64,7 +68,7 @@ uint32_t cpu_mips_get_count(CPUMIPSState *env) cpu_mips_timer_expire(env); } =20 - return env->CP0_Count + (uint32_t)(now_ns / env->cp0_count_ns); + return env->CP0_Count + ns_to_count(env, now_ns); } } =20 @@ -79,9 +83,8 @@ void cpu_mips_store_count(CPUMIPSState *env, uint32_t cou= nt) env->CP0_Count =3D count; } else { /* Store new count register */ - env->CP0_Count =3D count - - (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / - env->cp0_count_ns); + env->CP0_Count =3D count - ns_to_count(env, + qemu_clock_get_ns(QEMU_CLOCK_= VIRTUAL)); /* Update timer timer */ cpu_mips_timer_update(env); } @@ -107,8 +110,7 @@ void cpu_mips_start_count(CPUMIPSState *env) void cpu_mips_stop_count(CPUMIPSState *env) { /* Store the current value */ - env->CP0_Count +=3D (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / - env->cp0_count_ns); + env->CP0_Count +=3D ns_to_count(env, qemu_clock_get_ns(QEMU_CLOCK_VIRT= UAL)); } =20 static void mips_timer_cb(void *opaque) --=20 2.26.3 From nobody Sat Apr 27 23:20:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.46 as permitted sender) client-ip=209.85.218.46; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f46.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1617961008; cv=none; d=zohomail.com; s=zohoarc; b=mF9p5K0j1Baxp0c+k1A/YN83YSMV2D+lxlqgkqivZpLH9U2D0ufPT6cW8UmR2B6ph8KzMMiJkd2yml7UZCJM98COllNnTt9fgPeKjsGdwSBTMGx/5zaR+hh/pI64cQy9laOAH6eWnSASHJZdLNdNYT2hxEHpdXkJ9J38rIcymI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617961008; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GLOcVdq6UID+RpF1UB80wJ7L4dB9pvnLuoK+9eg5AUA=; b=nalp/fvReSd1uGqk9c9AqNDPLJCNfHm6Ie1+kG/8oFFQ9rShAatnPdvjg8z3I2Mwk8pZUt97NSn533Ich9ggkrd8WcUR0cOvC73CEI538GYHwzUktZhCNt4IEuASwSsPIen7310OzZokLmc0zFe/hXZniYs+81loe/FFBrQrEQ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by mx.zohomail.com with SMTPS id 1617961008602296.03612175556816; Fri, 9 Apr 2021 02:36:48 -0700 (PDT) Received: by mail-ej1-f46.google.com with SMTP id g5so930888ejx.0 for ; Fri, 09 Apr 2021 02:36:48 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id cy5sm1120079edb.46.2021.04.09.02.36.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 02:36: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=GLOcVdq6UID+RpF1UB80wJ7L4dB9pvnLuoK+9eg5AUA=; b=iuQRKpON7fzy/OMr8h7zhGJheYA7Ps5PEK9OajnkQmkTsT4W7HS1Wd9MyroH1wKEpa njvKXxDQC3fPB+FvVpG/w2cB2q4d+VPZjOtMV4lii/oXDoKL35q0nZHGoiFWY2NK97c4 vLsK23s1gf9PhCIuP0RuzfosGwTP/p6xRxsnZS33NKNI/11ZH/GJqDcGCAb2szFsv9vc 6qOzF8wGui3WNuXuRIne7W2GsjC4nel5+iX7xUqCdhKlpzgEs3U3GEdvGdlx48h33zCo h8LU69qFMP1x8OYnXDxjHQ5ToqdTpK4MWtBETMND6m2LVjArpsDUhw/jvUmH9nHBUJ3G b47A== 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=GLOcVdq6UID+RpF1UB80wJ7L4dB9pvnLuoK+9eg5AUA=; b=Ybxlr260xLuRqPuBZTtATafc1yUtBV+jaGmfJDI3Ku6J+kfLeDjEwbb6QCCabEQHUN kOt235xo2RpQb3a0qPMgHSF8ODe889W2jRMwrSqRhbrGgZ5dD1VH5AOHm5c7j+8/iQaO a7Rzt+qc89DHD+VfLWrBaPN/Ak4l+YXajkjaTG413C1/cTBMKGx/sB7gpKoK0VYXazCK iwMZrPzM5b4xJfqXYRxyJXC/dpmiLRW40tTkIR1AyWQJwbNAaeiYGPVsNY4wX7Pobmex +c3rsBoJ7PuarwBo9F/h7mBxE7O72IlHpKIksUBhpvyNhd3q7Hj+OAlappAG755A2e9q sTLw== X-Gm-Message-State: AOAM533PG3t52JVnihdEG0F3f1GraQLS0Us1N6V023Oh3LZjH40l6ClR YjIIfXJ5qRtSvcvIJBJJkkE= X-Google-Smtp-Source: ABdhPJyYBRdhsYdICc3OmXUlrnf+Wub7UJNZytylr5dNT/Madf+UcJhPwVEOH87Sn9kkbo5XIXv+mw== X-Received: by 2002:a17:906:7691:: with SMTP id o17mr15339108ejm.55.1617961006917; Fri, 09 Apr 2021 02:36:46 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Peter Maydell , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hao Wu , Aleksandar Rikalo , Huacai Chen , Aurelien Jarno Subject: [RFC PATCH-for-6.1 v2 4/6] target/mips/cp0_timer: Add ns_substract_to_count() helper Date: Fri, 9 Apr 2021 11:36:21 +0200 Message-Id: <20210409093623.2402750-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409093623.2402750-1-f4bug@amsat.org> References: <20210409093623.2402750-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Factor ns_substract_to_count() out to simplify a bit. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cp0_timer.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c index 73355b44b15..85f2f85838d 100644 --- a/target/mips/cp0_timer.c +++ b/target/mips/cp0_timer.c @@ -32,6 +32,12 @@ static uint32_t ns_to_count(CPUMIPSState *env, uint64_t = ns) return ns / env->cp0_count_ns; } =20 +static uint32_t ns_substract_to_count(CPUMIPSState *env, + uint32_t count, uint64_t ns) +{ + return count - ns_to_count(env, ns); +} + /* MIPS R4K timer */ static void cpu_mips_timer_update(CPUMIPSState *env) { @@ -39,7 +45,7 @@ static void cpu_mips_timer_update(CPUMIPSState *env) uint32_t wait; =20 now_ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - wait =3D env->CP0_Compare - env->CP0_Count - ns_to_count(env, now_ns); + wait =3D ns_substract_to_count(env, env->CP0_Compare - env->CP0_Count,= now_ns); next_ns =3D now_ns + (uint64_t)wait * env->cp0_count_ns; timer_mod(env->timer, next_ns); } @@ -83,8 +89,8 @@ void cpu_mips_store_count(CPUMIPSState *env, uint32_t cou= nt) env->CP0_Count =3D count; } else { /* Store new count register */ - env->CP0_Count =3D count - ns_to_count(env, - qemu_clock_get_ns(QEMU_CLOCK_= VIRTUAL)); + env->CP0_Count =3D ns_substract_to_count(env, count, + qemu_clock_get_ns(QEMU_CLOC= K_VIRTUAL)); /* Update timer timer */ cpu_mips_timer_update(env); } --=20 2.26.3 From nobody Sat Apr 27 23:20:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) client-ip=209.85.218.49; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f49.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617961013; cv=none; d=zohomail.com; s=zohoarc; b=GC9b4JQCtdvFoWycHOcuYjsuOEtSkHNCQvAyKpEl5YxgjYDnHVYkCtprV3qGsaH8FpPE668moP9OFxa/2/tfjt6pIe+F5gxhRuwwDbyzWzmt3TIKG8Kkogfztsm+e3XwhGi2FGySPVsLE1Biv3vnQCa4CgR7IFd8bPPd4RYVTog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617961013; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QrsQ6titnvPEg2qiFo1iauoMBA2a+w2LknU0pG+NZbE=; b=W3ZMtn8LUB4TyYIi021lWUHY0F0gfMqLBAUCdbVCxTEVdHL1TvhZmZ1Vmrhez8plRV/B6dl1ECz63xvJcFb52+PrtnWZ76cnAIVQ1dVLnNEgnjR0CDVX71Fljs+BfEF7MCVCPaBRTSibppkTAp2vm44E4FJ4ONwLlz2TTQW7FdM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mx.zohomail.com with SMTPS id 1617961013947198.17894017173194; Fri, 9 Apr 2021 02:36:53 -0700 (PDT) Received: by mail-ej1-f49.google.com with SMTP id g17so4849700ejp.8 for ; Fri, 09 Apr 2021 02:36:53 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id y16sm1068851edc.62.2021.04.09.02.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 02:36:51 -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=QrsQ6titnvPEg2qiFo1iauoMBA2a+w2LknU0pG+NZbE=; b=fXONjXNCPPQSyIraE886aSBPxzjUEGunSCDwO6mVQpGddCchTHGvk/0fEMVzDGxQMT gYtJ/3Faxf8JH2FoEbPGy4cxlObv4ssGgsvNr7HTbV9mdHThzW4a/Lu8yyR6t+jwdmfD KI9dHfQ8MOP3TuovkfkBmv0l/cdxGB33JBIJkkBt7hgBtO5WGnN5uJMFJUudGsEHaX21 fIvMJ8JTTK97/gukZinJO3hM7k9Ud6d1gQMB3xt2B63kHZXsNKhZjLAeC4uWke11kS3e /8lf4t5JEHywENwp4z6M/HV6ixkpUNEDJFRWQU+ROul/HCIiNrI0m1Z587c3c7q7InAd pAsQ== 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=QrsQ6titnvPEg2qiFo1iauoMBA2a+w2LknU0pG+NZbE=; b=bDi1oWvjJ7KYFGQTAPet5RnmpkaeOxLAyQF4o+mT5ZMEPKypHjOl6N8IUKokCjCCh1 ISV4ot4jrWprEoxjBP0rwwAG+8E4ADqjBWHaujbZiE7nmOb3m20hZMKOc1wp0DwhZuvU 7DyiGiW31J1lL6zth13xuY3l8x423XPY12j8zxXKbhTXWlVX3+erLKoblfFJa0baB22j tR2FENrvmHcy9tQg9MpLm8+5KULrcAR5+U2fSE5BipXNBqZ2CjQYfON0gnboH76TACH8 CSunzP2g5fEsjdVwzO6uU0aTPVWdvlWWjcAot519nlLJeCkGf9AZZ66kmLhJ/bA7RnzK LTHA== X-Gm-Message-State: AOAM531bTl7z+a0Tg6R7XEdCNnWZDsVEJxgOgzlgv6ePanlY9WSowdbr evtWkimDYmXSwtYdt1pnFdE= X-Google-Smtp-Source: ABdhPJwS4mXF5NFBA8feO1iS6BvIiEHY+0Vj252uKymUJD3TG8EaerrH6W1Ji2c+J4aasEkqFVyBSw== X-Received: by 2002:a17:906:c058:: with SMTP id bm24mr15478461ejb.335.1617961012244; Fri, 09 Apr 2021 02:36:52 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Peter Maydell , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hao Wu , Aleksandar Rikalo , Huacai Chen , Aurelien Jarno Subject: [RFC PATCH-for-6.1 v2 5/6] target/mips/cp0_timer: Use new clock_ns_to_ticks() Date: Fri, 9 Apr 2021 11:36:22 +0200 Message-Id: <20210409093623.2402750-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409093623.2402750-1-f4bug@amsat.org> References: <20210409093623.2402750-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Use the new clock_ns_to_ticks() function in cp0_timer where appropriate. This allows us to remove CPUMIPSState::cp0_count_ns and mips_cp0_period_set() and mips_cpu_clk_update(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cpu.h | 1 - target/mips/cp0_timer.c | 41 ++++++++++++++++++++++++++++++----------- target/mips/cpu.c | 18 +----------------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 075c24abdad..10f10018b95 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1160,7 +1160,6 @@ struct CPUMIPSState { struct MIPSITUState *itu; MemoryRegion *itc_tag; /* ITC Configuration Tags */ target_ulong exception_base; /* ExceptionBase input to the core */ - uint64_t cp0_count_ns; /* CP0_Count clock period (in nanoseconds) */ }; =20 /** diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c index 85f2f85838d..3b76cc97f6a 100644 --- a/target/mips/cp0_timer.c +++ b/target/mips/cp0_timer.c @@ -27,26 +27,31 @@ #include "sysemu/kvm.h" #include "internal.h" =20 -static uint32_t ns_to_count(CPUMIPSState *env, uint64_t ns) +static uint32_t tick_to_count(MIPSCPU *cpu, uint64_t ticks) { - return ns / env->cp0_count_ns; + return ticks / cpu->cp0_count_rate; } =20 -static uint32_t ns_substract_to_count(CPUMIPSState *env, - uint32_t count, uint64_t ns) +static uint32_t tick_substract_to_count(MIPSCPU *cpu, + uint32_t count, uint64_t ticks) { - return count - ns_to_count(env, ns); + return count - tick_to_count(cpu, ticks); } =20 /* MIPS R4K timer */ static void cpu_mips_timer_update(CPUMIPSState *env) { + MIPSCPU *cpu =3D env_archcpu(env); uint64_t now_ns, next_ns; uint32_t wait; + uint64_t now_ticks; =20 now_ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - wait =3D ns_substract_to_count(env, env->CP0_Compare - env->CP0_Count,= now_ns); - next_ns =3D now_ns + (uint64_t)wait * env->cp0_count_ns; + now_ticks =3D clock_ns_to_ticks(cpu->clock, now_ns); + wait =3D tick_substract_to_count(cpu, env->CP0_Compare - env->CP0_Coun= t, + now_ticks); + next_ns =3D now_ns + (uint64_t)wait * clock_ticks_to_ns(cpu->clock, + cpu->cp0_count_r= ate); timer_mod(env->timer, next_ns); } =20 @@ -65,6 +70,7 @@ uint32_t cpu_mips_get_count(CPUMIPSState *env) if (env->CP0_Cause & (1 << CP0Ca_DC)) { return env->CP0_Count; } else { + MIPSCPU *cpu =3D env_archcpu(env); uint64_t now_ns; =20 now_ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); @@ -74,12 +80,16 @@ uint32_t cpu_mips_get_count(CPUMIPSState *env) cpu_mips_timer_expire(env); } =20 - return env->CP0_Count + ns_to_count(env, now_ns); + return env->CP0_Count + tick_to_count(cpu, + clock_ns_to_ticks(cpu->clock, + now_ns)); } } =20 void cpu_mips_store_count(CPUMIPSState *env, uint32_t count) { + MIPSCPU *cpu =3D env_archcpu(env); + /* * This gets called from cpu_state_reset(), potentially before timer i= nit. * So env->timer may be NULL, which is also the case with KVM enabled = so @@ -88,9 +98,13 @@ void cpu_mips_store_count(CPUMIPSState *env, uint32_t co= unt) if (env->CP0_Cause & (1 << CP0Ca_DC) || !env->timer) { env->CP0_Count =3D count; } else { + uint64_t cp0_count_ticks; + + cp0_count_ticks =3D clock_ns_to_ticks(cpu->clock, + qemu_clock_get_ns(QEMU_CLOCK_V= IRTUAL)); /* Store new count register */ - env->CP0_Count =3D ns_substract_to_count(env, count, - qemu_clock_get_ns(QEMU_CLOC= K_VIRTUAL)); + env->CP0_Count =3D tick_substract_to_count(cpu, count, cp0_count_t= icks); + /* Update timer timer */ cpu_mips_timer_update(env); } @@ -115,8 +129,13 @@ void cpu_mips_start_count(CPUMIPSState *env) =20 void cpu_mips_stop_count(CPUMIPSState *env) { + MIPSCPU *cpu =3D env_archcpu(env); + uint64_t cp0_count_ticks; + + cp0_count_ticks =3D clock_ns_to_ticks(cpu->clock, + qemu_clock_get_ns(QEMU_CLOCK_VIRTU= AL)); /* Store the current value */ - env->CP0_Count +=3D ns_to_count(env, qemu_clock_get_ns(QEMU_CLOCK_VIRT= UAL)); + env->CP0_Count +=3D tick_to_count(cpu, cp0_count_ticks); } =20 static void mips_timer_cb(void *opaque) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index db93d19c49a..a66caa44bee 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -595,22 +595,6 @@ static void mips_cpu_disas_set_info(CPUState *s, disas= semble_info *info) #define CPU_FREQ_HZ_DEFAULT 200000000 #define CP0_COUNT_RATE_DEFAULT 2 =20 -static void mips_cp0_period_set(MIPSCPU *cpu) -{ - CPUMIPSState *env =3D &cpu->env; - - env->cp0_count_ns =3D clock_ticks_to_ns(MIPS_CPU(cpu)->clock, - cpu->cp0_count_rate); - assert(env->cp0_count_ns); -} - -static void mips_cpu_clk_update(void *opaque, ClockEvent event) -{ - MIPSCPU *cpu =3D opaque; - - mips_cp0_period_set(cpu); -} - static void mips_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); @@ -660,7 +644,7 @@ static void mips_cpu_initfn(Object *obj) =20 cpu_set_cpustate_pointers(cpu); cpu->clock =3D qdev_init_clock_in(DEVICE(obj), "clk-in", - mips_cpu_clk_update, cpu, ClockUpdate); + NULL, NULL, ClockUpdate); env->cpu_model =3D mcc->cpu_def; } =20 --=20 2.26.3 From nobody Sat Apr 27 23:20:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.48 as permitted sender) client-ip=209.85.208.48; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f48.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617961019; cv=none; d=zohomail.com; s=zohoarc; b=YQK24FXgDY2lr40vvSJKZAlr62cX3+QHFpNm4fmUMhN7XVopo2gCVK/3l1DywZD0jy7kQdEkOtYYF3lJUxXue0t77MXlw7M/7XaKCOkqggxiqU45ROckQ1IMqgNXwP89ewGmGadDO79y5iDAhTtrA5orWej7VAs+YebcHp8Tm90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617961019; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PXqnygnDNRvgHqFuhkZNL41NPY6pp82Qlb6Fn+d88n8=; b=dYmHf2/fkE4lTW/p4Q3U9gn6BYAAjuZ2NbfBmgM0wWXinyA2IoYX2a0E5NDxLszHZbqJhD1F+sFSmxuvRliskBsfcULvdXg06NdGz9O5p168v7g6pmASzjvMGgxsxtPsJW8riSMqNACZ6qITyMdmGhGekO/FVQEiuUv5qThdMjg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by mx.zohomail.com with SMTPS id 1617961019227822.9990398712365; Fri, 9 Apr 2021 02:36:59 -0700 (PDT) Received: by mail-ed1-f48.google.com with SMTP id e7so5753153edu.10 for ; Fri, 09 Apr 2021 02:36:58 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id bh14sm941191ejb.104.2021.04.09.02.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 02:36:56 -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=PXqnygnDNRvgHqFuhkZNL41NPY6pp82Qlb6Fn+d88n8=; b=nKpx5aSojz4tdZC6/pso6slZDGWhIJIGZOdizPPUjbaPCxfQFlIuVo+t2tQHLPXjTx v3ViF57x0wX3b5ENata9isOhztsm6eqhevpOsxZDlNRbSwlA9LtHp+wcrmxpzs8KlyjN DqzpKmIBrdiMCThGDeS8vN8S8mYEp32CtLt295OBSTDr8anbnPgX8hUvdGt7NE7eTi2B bNw9iFWcB9/McxhYFtdP3vfqnJOt1HYajpKx2NMFISlACa6m8rUn38c1RU60nh4myaJa s4T8P4nv0BtTshUGiHnLhZFCnfh/RSEfQaUeuTcwY8keXTK4Qa7FY2Li/ABvrVIYmzuj OhVA== 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=PXqnygnDNRvgHqFuhkZNL41NPY6pp82Qlb6Fn+d88n8=; b=qMhxw9u7MyFI8mPj0nnHLcXEcN/COY+dHRlr0QbLaCqavQnGQyXAzd2pXG6IwvVBpu ZrdBSFQvTbOKiCnPvQe6YXdp77A0ssK5hIoFQiGp91nQw4LY1tBjYqCic1mSoQjtLWyL /ZF6Yb4K1L+EsWRk/Iq9loUBeegLaIBxn9GXFu06fvRifUdUAsAeiknSvAf0JZZR9Bzg xtQ9QFYKi7ZLMKrBu9c6vjpFnVNACYaxYJWoKiM4jEcbQs1Cmf9TcKBAyZ/l+UdugmL2 NCoMQJehHZdQdl2qMfIl8YXCTWs+umHepw77VmTSaf2M8J2VVXb9YPCmBzEUd+9jeQ8g rrOQ== X-Gm-Message-State: AOAM5325eclBe8Hdsmeoo27vLhK/5pIoTJeRjloJvbr8mo47BBc+H6C3 S6uQ15qJAj6GKj+gy8KcXWg= X-Google-Smtp-Source: ABdhPJytB528ytxgXKFTaaCXEJyVT4c1+lPaEmPqtyhRgd7zEGafjTYY/ICBGrATZXkQZkgekH9pLA== X-Received: by 2002:a05:6402:344e:: with SMTP id l14mr16811382edc.184.1617961017441; Fri, 09 Apr 2021 02:36:57 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Peter Maydell , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hao Wu , Aleksandar Rikalo , Huacai Chen , Aurelien Jarno Subject: [RFC PATCH-for-6.1 v2 6/6] hw/mips/loongson3_virt: Raise CPU clock to 2 GHz Date: Fri, 9 Apr 2021 11:36:23 +0200 Message-Id: <20210409093623.2402750-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409093623.2402750-1-f4bug@amsat.org> References: <20210409093623.2402750-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Commit cd3a53b727d ("clock: Add clock_ns_to_ticks() function") removed the limitation of using clock with a frequency of 1 GHz or more. The previous commit converted the MIPS CP0 timer to use this new clock_ns_to_ticks() function. We can now use a clock of 2 GHz with the Loongson3 virt board. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/loongson3_virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index b15071defc6..0b72ef8a684 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -152,7 +152,7 @@ static const MemoryRegionOps loongson3_pm_ops =3D { } }; =20 -#define DEF_LOONGSON3_FREQ (800 * 1000 * 1000) +#define DEF_LOONGSON3_FREQ (2000 * 1000 * 1000) =20 static uint64_t get_cpu_freq_hz(void) { --=20 2.26.3