From nobody Sun Nov 24 08:28:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1724920859; cv=none; d=zohomail.com; s=zohoarc; b=bMYshV8SaD3jev73lOnHRYXY/iEgvIJw3JqMQbrrcaG1xjhJ8HsvVS+JYXkW8mGtV9D9v5eG+PtahHnyv5hNRiENe8f7j/1GRBnpN/HuYSCouD9wOw8g+6F7ZgeDIhEnWmaNwKD8Cwpdo0+0MA8u1hIeIC52gIvhs2f2q8Kw+1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724920859; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mbWbqYoyluppncMW0T7AjEVIwxQPlFi/vO8bJwXgZ6c=; b=NODG7ONKmXDQkJT9j/oKoH+RfMt9fizNmjl+kQ2OAQjtUsf5qcH0k8fQKEiduuYO2bUTQBEJOyGnq6dFZPlVSK5zJ3EU6+3Dv9rI2ftC0QLdH6QVbr+3XHIcXu3CBvLywSottXJ6Ouj4frE67pIOUMX1x4P7wBxDTAHGvBlFHJE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724920859028263.187114200938; Thu, 29 Aug 2024 01:40:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjahN-0000M7-IN; Thu, 29 Aug 2024 04:40:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sjahM-0000KW-99 for qemu-devel@nongnu.org; Thu, 29 Aug 2024 04:40:08 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjahK-0008Vt-HS for qemu-devel@nongnu.org; Thu, 29 Aug 2024 04:40:08 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5bed68129a7so446321a12.2 for ; Thu, 29 Aug 2024 01:40:05 -0700 (PDT) Received: from localhost (cst2-173-13.cust.vodafone.cz. [31.30.173.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8988feb580sm48789866b.37.2024.08.29.01.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 01:40:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1724920804; x=1725525604; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mbWbqYoyluppncMW0T7AjEVIwxQPlFi/vO8bJwXgZ6c=; b=fjZJ+RIFMe1XbnO+EUD+VCwg3d2XLjxxAbbbbbG3W8JL20YlihCvFsxJpwVTReueHz VybLMzST4ccQuuaCWFMr0BLn6Hh09z2bv9ELcIsgovl4oT/fniQNo16CedlDVblGdx0V oy9wDlKK6Ko2Q+lXJscK8gd0uT0yQfJIHvJt3a2kX2Oeau60KclWslrMb/2P3iHYxo/o TAgm2sk086HcVOM2ruJ89vRA96KBagVGdHSp5AXph5PYiOAw8FLmoMVhM+TJJmYUWAp+ R6ZGGfU7m1kvUFEjxsJTtV3akr8GXpDb6YG6W4XHnMw00YNuScTQx3vXv+PfJ3iGyIfG VrQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724920804; x=1725525604; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mbWbqYoyluppncMW0T7AjEVIwxQPlFi/vO8bJwXgZ6c=; b=rtMrO25w9z+ezTo2rIe3Mxx6rHp+VtUqb3mDYObEGTBTU+A4k/rne05G27DABTRsAO EQF42tw6KWZhPIJdvPIhQ5y8spmviVZh8xVDElqj31NWvtN2+KeiBKPsBzXkpYQ6UHp3 SBE48NA67MXF/pRpdqLbNsHnC4KMsGKxXcDoIvLz8ht3rxGIEjGRJ2Xve9x9LyPmlhwR 7lHzDOqA6fa27bHCNeRTsmxAdv8hK3YfhDen+8+wcBQ8M7RACubu0VKIvOcvX9FWU3aG IFfg20JwlMbAS8rFP6P8vFpAnv28KS0gXIKDcLKVTkhtEbfe1pNwtMJw5sUNetSgAdGb kQDg== X-Gm-Message-State: AOJu0YySd5vGIlyXLDu+BtLmYR7u7mwD/jTKrpLhm1bTQFfd1cCSklJM gsTQJTelN3CH0q8VBvWyWwZZYPHZHIUUp/29FY5ltGHbSI/j5nZeUs+52pq8dzHjYTMY4QrxHQj OjpQ= X-Google-Smtp-Source: AGHT+IFnKVvj42PDH+02HJVgSs1VoNY05sXS7V13QqM9xpi37TZ3/5lYeh8H+bOXJM0eMyi2QdW0Dw== X-Received: by 2002:a17:907:2ce5:b0:a7a:9f0f:ab26 with SMTP id a640c23a62f3a-a897f83b149mr134684666b.23.1724920803893; Thu, 29 Aug 2024 01:40:03 -0700 (PDT) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Anup Patel , palmer@dabbelt.com, alistair.francis@wdc.com, bmeng.cn@gmail.com, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , atishp@rivosinc.com Subject: [PATCH] target/riscv: Stop timer with infinite timecmp Date: Thu, 29 Aug 2024 10:40:03 +0200 Message-ID: <20240829084002.1805006-2-ajones@ventanamicro.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=ajones@ventanamicro.com; helo=mail-ed1-x52c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1724920860415116600 Content-Type: text/plain; charset="utf-8" While the spec doesn't state it, setting timecmp to UINT64_MAX is another way to stop a timer, as it's considered setting the next timer event to occur at infinity. And, even if the time CSR does eventually reach UINT64_MAX, the very next tick will bring it back to zero, once again less than timecmp. For this reason riscv_timer_write_timecmp() special cases UINT64_MAX. However, if a previously set timecmp has not yet expired, then setting timecmp to UINT64_MAX to disable / stop it would not work, as the special case left the previous QEMU timer active, which would then still deliver an interrupt at that previous timecmp time. Ensure the stopped timer will not still deliver an interrupt by also deleting the QEMU timer in the UINT64_MAX special case. Fixes: ae0edf2188b3 ("target/riscv: No need to re-start QEMU timer when tim= ecmp =3D=3D UINT64_MAX") Signed-off-by: Andrew Jones Reviewed-by: Alistair Francis --- target/riscv/time_helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/time_helper.c b/target/riscv/time_helper.c index 8d245bed3ae3..bc0d9a0c4c35 100644 --- a/target/riscv/time_helper.c +++ b/target/riscv/time_helper.c @@ -92,6 +92,7 @@ void riscv_timer_write_timecmp(CPURISCVState *env, QEMUTi= mer *timer, * equals UINT64_MAX. */ if (timecmp =3D=3D UINT64_MAX) { + timer_del(timer); return; } =20 --=20 2.45.2