From nobody Wed Nov 27 04:40:50 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1700136694; cv=none; d=zohomail.com; s=zohoarc; b=CLWZuJcUFU5kWJe4syrR9j0gn+l74G28mQtRIdusuC89DCtsuazeh1xLD3wjpMqUop5A8RJX/G8/ioM/KOE0JhoCHelUFdbjZ80Nzrc+WztXkJqsbxmXpCxglOfi9A1lMBOWQfzuxuX0QAm+7qqJ3as+nGpwqCcl4CAAeaVmQ00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700136694; 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=a+oK2BI5FX0kNdpxIq+ER+WDfFF2odsb7hqi+ZwJyoY=; b=VZDdFL1tUxOG23jh2snjwaH1baVsvdN4eQ5pMTUzvXk22WLuS5vvA50qZpAWltpa2GBUBsloBBHulX1M5zNI0+evf1nb7JBKqdY+I4bb8NRP6RpqOlookH+9AG6QNT7IxN3rTctXqm5F9R7trVSFtd+AH8B8hdp1FXEiz9TBYik= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700136694911431.9274453874591; Thu, 16 Nov 2023 04:11:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3bCv-0006rb-9f; Thu, 16 Nov 2023 07:10:56 -0500 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 1r3bCo-0006r8-Cg; Thu, 16 Nov 2023 07:10:46 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3bCa-0008ND-4d; Thu, 16 Nov 2023 07:10:43 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-32f7bd27c2aso581325f8f.2; Thu, 16 Nov 2023 04:10:30 -0800 (PST) Received: from localhost.localdomain ([213.94.54.170]) by smtp.gmail.com with ESMTPSA id w7-20020adff9c7000000b0033130644c87sm13493243wrr.54.2023.11.16.04.10.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Nov 2023 04:10:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700136629; x=1700741429; 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=a+oK2BI5FX0kNdpxIq+ER+WDfFF2odsb7hqi+ZwJyoY=; b=mgPFNwgPr+OXTwl2ruXnGt4xTApKFNkgEtXvRCC3oU8Q8YlKLnfJS4iEXOAVlxKhLr bY51ZXvDkkVFotb/Ph4WPe5KYM9tD8FQnh0dEMsZ3uHbT84K5jxFJbABvAvQyTdTgMV6 7qOG2aYoMEMWKdgNYVe/eT4rhy4HjRyL3+8KuWniTXgMgYvPAPhjwufzyFuDADZ2mcrC opoaLJXKysNEjouLP2QaBgEfcYbdfgQvqFojssc17sPF+Ol81n9JurheBfDZYM7RWoNe ufRUfsRCmjje0Ub7p0vFyODy1U/oqfQ7faxLy8YSSBXVIqNdk8+pwBl1Z3axSnAoj6cO f73g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700136629; x=1700741429; 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=a+oK2BI5FX0kNdpxIq+ER+WDfFF2odsb7hqi+ZwJyoY=; b=IDG1EaD0wXnsYgnHwHKKqq3UbidUkwba3v8i27aGma/35LdQ8wCnaRhdep2kkBTJF+ 7kYQ7PiHLAssyDVveoxjiT7pekAxWpjWKQTZXJwZwJFmRJnj7bGOskJljtrg5xA0SxLu dV34StOgZaJktqtERCXzfxhe2NSYpIC/pUhc+WUY5ssX36M2JTUSeB7e7fgGNQL9fiYp H+968b1GPLDXM4Q5gh5/H4PSyb+fThFHBvO6whDmA7RtQS/2owyYEJLiBtljSST28VBd aL/ZF7Isa9D6j5LxW5nI0rNTgsnbK8YK+IHCQ/cS8qFY9zyPO1mqynutyY8hPBCKTm+K eg9g== X-Gm-Message-State: AOJu0YymPJ9FnbnQiyNFegXd8XqHfc42bZW0P5nqoU5OGEm4ECBBPAez /vQ1gQT4Rf4TYtjJo9Vgzn9WLuJHj2Rm6FLB X-Google-Smtp-Source: AGHT+IETD+tNjc5vnK8rxazPJV12t/pL8MZ/8NjniKNIuMG8D+QbfTOVkhW+yOem1nV+KasvJWOnqw== X-Received: by 2002:a5d:64c6:0:b0:32f:8920:48ab with SMTP id f6-20020a5d64c6000000b0032f892048abmr11237215wri.65.1700136628859; Thu, 16 Nov 2023 04:10:28 -0800 (PST) From: =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas?= To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Alistair.Francis@wdc.com, bin.meng@windriver.com, palmer@dabbelt.com, liwei1518@gmail.com, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com, qemu-riscv@nongnu.org, =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas?= Subject: [PATCH] Fix SiFive E CLINT clock frequency (#1978) Date: Thu, 16 Nov 2023 13:07:03 +0100 Message-Id: <20231116120702.53170-1-rcardenas.rod@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) 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::431; envelope-from=rcardenas.rod@gmail.com; helo=mail-wr1-x431.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, FREEMAIL_FROM=0.001, 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 @gmail.com) X-ZM-MESSAGEID: 1700136696455100001 Content-Type: text/plain; charset="utf-8" If you check the manual of SiFive E310 (https://cdn.sparkfun.com/assets/7/f= /0/2/7/fe310-g002-manual-v19p05.pdf?_gl=3D1*w2ieef*_ga*MTcyNDI2MjM0Ny4xNjk2= ODcwNTM3*_ga_T369JS7J9N*MTY5Njg3MDUzNy4xLjAuMTY5Njg3MDUzNy42MC4wLjA.), you = can see in Figure 1 that the CLINT is connected to the real time clock, whi= ch also feeds the AON peripheral (they share the same clock). In page 43, the docs also say that the timer registers of the CLINT count t= icks from the rtcclk. I am currently playing with bare metal applications both in QEMU and a phys= ical SiFive E310 board and I confirm that the CLINT clock in the physical b= oard runs at 32.768 kHz. In QEMU, the same app produces a completely differ= ent outcome, as sometimes a new CLINT interrupt is triggered before finishi= ng other tasks. You can check issue #1978 on GitLab for more information. --- hw/riscv/sifive_e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 0d37adc542..87d9602383 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -225,7 +225,7 @@ static void sifive_e_soc_realize(DeviceState *dev, Erro= r **errp) RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, 0, ms->smp.cpus, RISCV_ACLINT_DEFAULT_MTIMECMP, RISCV_ACLINT_DEFAULT_MTIME, - RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, false); + SIFIVE_E_LFCLK_DEFAULT_FREQ, false); sifive_e_prci_create(memmap[SIFIVE_E_DEV_PRCI].base); =20 /* AON */ --=20 2.39.3 (Apple Git-145)