From patchwork Wed Mar 27 15:35:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13606865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AADE9CD1280 for ; Wed, 27 Mar 2024 15:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q30epaVw63ETitJ8gVP7p+huaxV7XiKtrP45smsoFg0=; b=dPNSIj9hLb1RK5 /2lJg9A/upgRgmRpYbl2nklBPykMx1zZpsSDj3LWQ76HUzCdHQTRB3yUyzhrsCnspcGvtOZSSRGUw ZFdpU/XqM6R1IW7GINy3wkdyrPTa8D1KUrx90Xd1VtxNZx4/8l3CRb8Vlo1ZQxL0T/RRWFuN87tQR azttJUtpUq9EeuCVpXi992Qf9xSIsrPztLvQtXNvWAZQTs+yJ43svNuzO59WkRcOnOpMN3a5WRMnc mYmPH8u8EFsj136RLpyVLROx2fsTfIc/gf+lUZqEWDO3yoVIYXJ+LzlLEpSTFU0X1jh61FOelnRmD r7+EMOu/OshEAVoZLWYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVVp-00000009uCy-2O9x; Wed, 27 Mar 2024 15:48:25 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVVm-00000009uAu-0VCV for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 15:48:23 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 81377615F6; Wed, 27 Mar 2024 15:48:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A95BC433C7; Wed, 27 Mar 2024 15:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711554501; bh=kxw8lEOeXnx/duF9z7ST9TT/zC6EoGrvtJe8oJFI1B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sr1y1Cuu9f/Se064mDUn1HaCUkTnbO9IBcwOnhO4s3a/Mlvj19hhrxttE8kNOJA1i zW0nSCuYqRkkblNx79/0IToZ+uYKPrVtK/RsRTGET65JvBUlbnBr+xnURpFy6E9uEO Jsc+HyY1Qqo4OpmJ5FHxS0LBgybRWxjAhhIC2DbLn+PzW/Mry+jN1z3i0/FuRNrs0A T0BNpgtrWjidXAsNZVrDC5m0wr0xCw1IWoUuwrYkFCsnQe19gwecezPAQgkZcYdkCK Jl7Orhrx+qfMJ4Tv93a6bLdHSbX/8kFx+KwKZCKZ40GSm5YwG8T0gWZ6tGf2kVX46Y V+Yf/i5ucujfA== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Daniel Lezcano , Thomas Gleixner Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] clocksource/drivers/timer-riscv: Add set_state_oneshot_stopped Date: Wed, 27 Mar 2024 23:35:00 +0800 Message-ID: <20240327153502.2133-2-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327153502.2133-1-jszhang@kernel.org> References: <20240327153502.2133-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_084822_235787_85BD20FA X-CRM114-Status: GOOD ( 10.88 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org To avoid spurious timer interrupts when KTIME_MAX is used, we need to configure set_state_oneshot_stopped(). Although implementing this is optional, it still affects things like power management for the extra timer interrupt. Check commit 8fff52fd5093 ("clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state") for more information. Signed-off-by: Jisheng Zhang --- drivers/clocksource/timer-riscv.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c index 48ce50c5f5e6..e661fc037337 100644 --- a/drivers/clocksource/timer-riscv.c +++ b/drivers/clocksource/timer-riscv.c @@ -69,11 +69,12 @@ static int riscv_clock_shutdown(struct clock_event_device *evt) static unsigned int riscv_clock_event_irq; static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { - .name = "riscv_timer_clockevent", - .features = CLOCK_EVT_FEAT_ONESHOT, - .rating = 100, - .set_next_event = riscv_clock_next_event, - .set_state_shutdown = riscv_clock_shutdown, + .name = "riscv_timer_clockevent", + .features = CLOCK_EVT_FEAT_ONESHOT, + .rating = 100, + .set_next_event = riscv_clock_next_event, + .set_state_shutdown = riscv_clock_shutdown, + .set_state_oneshot_stopped = riscv_clock_shutdown, }; /* From patchwork Wed Mar 27 15:35:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13606867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF0A2C54E67 for ; Wed, 27 Mar 2024 15:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ESLS74USpg5ki9APeTcOUUffx/nBpwwM1FiarCYvnnw=; b=RnyPw2va8CUUPX 8U+UQzVyTvT9ychUDV3Y32YQN+znLtJ0G1mHqosVcOE//dWhSoy4O1FfYyRaNLtR8DXTObuLXmvzw 6rnIslWSHRzGQ8vy7+vImufALWJAjbrssKcHRvnItS/coG/qHoR27g+aLGe5DQf8HzOnq1cYqAhjH 7X3SPyAgVrmIMmA3LHwBGUockkqG+QRbiUsr9FcptCN2rH5x+WWUYRvDMw7gZdJQwv1Ci2yjGsAvQ m8y2WXGu6WtUssUlWMYyzIlYZQM1Qp2UAFfz3CWnwyuLFCaWxtqmkLsF4xdr79mjpsu3/O+42ZYZG CmcLV14aNyQNfnbHZFWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVVt-00000009uFM-48jb; Wed, 27 Mar 2024 15:48:30 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVVq-00000009uCZ-1mca for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 15:48:27 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 50111CE272B; Wed, 27 Mar 2024 15:48:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1735C433B1; Wed, 27 Mar 2024 15:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711554503; bh=Nw3gMFJ/F/poxLbQzgT93Y2Pv42axzvi9HneGeq24nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3vctCY4JRAjYtkAQ9qoJRjfijrTnXvrV+n2Bi6grrTy1C/hCrBQNQG75kqU5pou4 7HdzjXIGxIkOXUPUHLVfmemuWs0TkX99r1f1H1fj0v4Uw1DEX5qdpI0vkB0B24c4K4 Wi4eRQG1SFM+SfTggRlSwzW35E9NbQ/cmsn5JRCyFBavzMNy7Wmbv3EVj8+re/UTf9 P5FaRh5UZ5/zqd3g9RdGF7P8DNji083zB77mImuMUIuYHmg9bVzS3QN4FPvoHPMYiw e8hxkUty/1x8LVKowUWEyj73DMCRqsZXOrWL/MRc0NYyDMqS9vv5N49fliBRdZg4wu 74mtVZw54zisg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Daniel Lezcano , Thomas Gleixner Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] clocksource/drivers/timer-clint: Add set_state_shutdown Date: Wed, 27 Mar 2024 23:35:01 +0800 Message-ID: <20240327153502.2133-3-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327153502.2133-1-jszhang@kernel.org> References: <20240327153502.2133-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_084826_685103_A330A5F4 X-CRM114-Status: UNSURE ( 9.83 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add clocksource detach/shutdown callback to disable RISC-V timer interrupt when switching out clockevent from clint timer to another timer. Signed-off-by: Jisheng Zhang --- drivers/clocksource/timer-clint.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/clocksource/timer-clint.c b/drivers/clocksource/timer-clint.c index 09fd292eb83d..56cf6c672e6d 100644 --- a/drivers/clocksource/timer-clint.c +++ b/drivers/clocksource/timer-clint.c @@ -119,11 +119,21 @@ static int clint_clock_next_event(unsigned long delta, return 0; } +static int clint_clock_shutdown(struct clock_event_device *evt) +{ + void __iomem *r = clint_timer_cmp + + cpuid_to_hartid_map(smp_processor_id()); + + writeq_relaxed(ULONG_MAX, r); + return 0; +} + static DEFINE_PER_CPU(struct clock_event_device, clint_clock_event) = { - .name = "clint_clockevent", - .features = CLOCK_EVT_FEAT_ONESHOT, - .rating = 100, - .set_next_event = clint_clock_next_event, + .name = "clint_clockevent", + .features = CLOCK_EVT_FEAT_ONESHOT, + .rating = 100, + .set_next_event = clint_clock_next_event, + .set_state_shutdown = clint_clock_shutdown, }; static int clint_timer_starting_cpu(unsigned int cpu) From patchwork Wed Mar 27 15:35:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13606868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7353C54E67 for ; Wed, 27 Mar 2024 15:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VjLekSL2wjYLYewCweEUI0vM/LLTX1MuDYk1nFef1uo=; b=mZ37ZsV56VM4Xg 4i6syB2XqcfLkqryDxId42uVu2d9xBc8GVLjMPfa7iPCxoIAet6eU06keXNjHL/x8HgSyX8Y2ocRh 4WrD1SQq9fTfWzEIHgB3IbueLw6rmtbtqpPHDxR5l9K7aCRWqFz6L9nd77DZxmpLT4BvlKTwfJj4F CuLAfGgLDZuh/BB3xIPXUJae/pzu+mmAnPkI9Hl1M2g3/i/pgn6h29IHIaT37nRyr6f5d/PlfmoK0 3FROYk0+j80Xs1zfWtvrv49aQ4GWOc3OyNDdt2y1epSvNPB/e0Jj6kZy/hEBrbYcqkEmeMYAI3DJC YEshvugHF17LLtW8Tc+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVVw-00000009uGa-0rM3; Wed, 27 Mar 2024 15:48:32 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVVq-00000009uDd-3dKX for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 15:48:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3DB35615D8; Wed, 27 Mar 2024 15:48:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16D24C433F1; Wed, 27 Mar 2024 15:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711554505; bh=G8Du/nKE3EQGqBI4paXDN1AIdNVl4glAliWu+H6P45c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rJaykR9+OUNmZr8FxTeTlU3uWMWDqdwYbp3icdv9jf2Q6hJMBgQDEBGpikt5hRtAf 6La3dI3Nq+RMa6s+5yvwewnzw/JWkIbLhukmqq88cKYBgWA56MFnJxYJhIzMCCsrT2 tdnL14om1dRM4/C9RQxh1xS4SJzqci0pX/fYmssovPrdEpAZMqbn7/lp2XLV1/dygo EysNPjAnNgZK+erhl7WXhr0hfGBWQCY+0wU14BCX9wAa3Y4YXsYbJ/pLBU+c6/WDy1 /xyzq1sIy9qXQAFVpd4QGDCQC3F/7gyOAzQzskObCZ25XfFaGsPFxoSm6YPYymed7k Blh/EcdKYg7og== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Daniel Lezcano , Thomas Gleixner Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] clocksource/drivers/timer-clint: Add set_state_oneshot_stopped Date: Wed, 27 Mar 2024 23:35:02 +0800 Message-ID: <20240327153502.2133-4-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327153502.2133-1-jszhang@kernel.org> References: <20240327153502.2133-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_084827_165055_FF43B382 X-CRM114-Status: UNSURE ( 9.32 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org To avoid spurious timer interrupts when KTIME_MAX is used, we need to configure set_state_oneshot_stopped(). Although implementing this is optional, it still affects things like power management for the extra timer interrupt. Check commit 8fff52fd5093 ("clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state") for more information. Signed-off-by: Jisheng Zhang --- drivers/clocksource/timer-clint.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clocksource/timer-clint.c b/drivers/clocksource/timer-clint.c index 56cf6c672e6d..f5c04520d6b1 100644 --- a/drivers/clocksource/timer-clint.c +++ b/drivers/clocksource/timer-clint.c @@ -134,6 +134,7 @@ static DEFINE_PER_CPU(struct clock_event_device, clint_clock_event) = { .rating = 100, .set_next_event = clint_clock_next_event, .set_state_shutdown = clint_clock_shutdown, + .set_state_oneshot_stopped = clint_clock_shutdown, }; static int clint_timer_starting_cpu(unsigned int cpu)