From mboxrd@z Thu Jan 1 00:00:00 1970 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 3F67CC2BB9A for ; Tue, 15 Dec 2020 15:10: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 DDACC2073C for ; Tue, 15 Dec 2020 15:10:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDACC2073C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpByH-0006AC-PM for qemu-devel@archiver.kernel.org; Tue, 15 Dec 2020 10:10:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpBxJ-0005J2-L4 for qemu-devel@nongnu.org; Tue, 15 Dec 2020 10:09:37 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpBxH-0000kk-Va for qemu-devel@nongnu.org; Tue, 15 Dec 2020 10:09:37 -0500 Received: by mail-wr1-x443.google.com with SMTP id d13so1930724wrc.13 for ; Tue, 15 Dec 2020 07:09:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a+b1GhhvLrJkl2Vn8twSVpP5pnoCxjLycXJoM3JnXDI=; b=vXod0hlRtxicw20rtXnuoOemidOlUPRkiR/tvzmwg/ezxSLvMCOld985Rb6jDK+WcU iuat5mh2r68+5zf887w/lY5ypFUeSYni2fIwDyNniK3LPoSVO86/vkI0Qpf5+iUdHYrf Fp5dnS/2WEVWuWWiR5uq0INpMcyiKMChYaauAvnA/2GLp0CMMgO6O+awD3IcfgPO0doW Z1eWaotURoPyn8zshWiZEEfa1/FVSg9bQqPbdq8Bl8y93R2Y68MO5bg7sj+QxcViAEj2 QLaXlQIOCDa6vn1jiDdmz486lF8rZFW7BhUnojkaDvUyI3JBpwRnrlaTFdsAmHi0crlP 6M7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a+b1GhhvLrJkl2Vn8twSVpP5pnoCxjLycXJoM3JnXDI=; b=XrhskQESeBIgU5clX/W+xT/bjolsw3R4LWsXum329SZaoktYVrz7d6NdyhX0blaCSh 2zaKOMTPRNMebxQtAwXaz05nJ2efs6A4Xg2+68Ls/h//k4OJZMdd/zoTQk/wYAq6fWS/ DdeQtWCC/VKaCapMOp17cjE+hspO78Vd6w7MyovpnOvW8h+B7TZXRVKNz6McumgNNB39 akfQ+XhmHETCoqo0KrezH3nbK1nnVDA5sJconptcCO8fqgsYv170xNwxXmWNLC/vm/94 tFWQ+Cz0bzKbVPBLyZbjyUOdEoxlthqlY3suaLVrc9tuIQTQJ/RiMTzZ/mEOISrfgu5i UReQ== X-Gm-Message-State: AOAM5316GgtD2r9ZhvlfnGRuErClEWz+lKXu0SU1O/DxRSCOZxoDcm9B lQwuJt8UG38vKJ+bGmN92sPUw+IXqgXfjw== X-Google-Smtp-Source: ABdhPJyPLZQEW38E3wxggCl/nNZzX+hiM7eD872pQkgvOCbC4dRBMNPXGBpZSl/WUyxkXKKdCr5Uww== X-Received: by 2002:a5d:4cca:: with SMTP id c10mr33881136wrt.176.1608044974039; Tue, 15 Dec 2020 07:09:34 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id l1sm36930593wmi.15.2020.12.15.07.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 07:09:33 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 2/4] target/mips: Don't use clock_get_ns() in clock period calculation Date: Tue, 15 Dec 2020 15:09:27 +0000 Message-Id: <20201215150929.30311-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201215150929.30311-1-peter.maydell@linaro.org> References: <20201215150929.30311-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x443.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Aleksandar Rikalo , Richard Henderson , Luc Michel , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Currently the MIPS code uses the old clock_get_ns() API to calculate a time length in nanoseconds: cpu->cp0_count_rate * clock_get_ns(MIPS_CPU(cpu)->clock) This relies on the clock having a period which is an exact number of nanoseconds. Switch to the new clock_ticks_to_ns() function, which does the multiplication internally at a higher precision. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Luc Michel --- 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 aadc6f8e74d..eea14f3b52f 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -380,8 +380,8 @@ static void mips_cp0_period_set(MIPSCPU *cpu) { CPUMIPSState *env = &cpu->env; - env->cp0_count_ns = cpu->cp0_count_rate - * clock_get_ns(MIPS_CPU(cpu)->clock); + env->cp0_count_ns = clock_ticks_to_ns(MIPS_CPU(cpu)->clock, + cpu->cp0_count_rate); assert(env->cp0_count_ns); } -- 2.20.1