From patchwork Sat Apr 6 11:17:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13619780 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 8F383C67861 for ; Sat, 6 Apr 2024 11:31:35 +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=pysXt8nt8eE16c T7jAYaSf3r2xietnfMyHXd9c9ANL463JktReIrriGc+k9L9pKZlskUkQACwyTn8HLsdmGkc2beIP+ j6ddZDpZPsgFjE8i9AwGS3882cCv6WwqaZ8W6k01L3z7nZz5PDsJ4tadA4kYo9Vo+Kbrw1p8ApHyG 0WqkxnN4bZIfXcltgX5tNipdxrUCkpVllWOMm8cnI3hyYzBXnw1hL4kahNw4XFCAxHClYhUtCU5FD T1TF8CO00y++jobL1blabDf2P05ZRehHEFDbcWDXIm/bP27NTneexThVgkbuGssDWeh1Iv/CP2D1x 8bhUqNBZGBUawPK0W1Cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rt4Gc-0000000ACy7-3O66; Sat, 06 Apr 2024 11:31:26 +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 1rt4GZ-0000000ACw3-1V3I for linux-riscv@lists.infradead.org; Sat, 06 Apr 2024 11:31:24 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 358D8CE19BE; Sat, 6 Apr 2024 11:31:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D00C9C43390; Sat, 6 Apr 2024 11:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712403080; bh=kxw8lEOeXnx/duF9z7ST9TT/zC6EoGrvtJe8oJFI1B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kD+KtTXj/GBjQUtr6D1v/myTGzsq973TWGwuzcxWDl6/CjFmbP50gM/JVNX58qrgd EUcASu06PHK5jfQ3QNBfcSNrsLpU7hjW9xVTzsUQ8BCdx59mBulPvueYfkwwhZh1D3 Ro4Cs/FOBTRN2zGolCo9LGk43zQhmZC/ZB4Rs4/PXyJS0X35Gg8HyttKhBQHaT3erO PhwZfs16AI77tZ+6Py0jXcj9ZcBwMwW/U+hAbUGaslrA9P4Owjs/jFxLQmXH62SGvh DOVmIxFb0qf+tnmLIuXObaJkPONg1btiKj9dDq/7L+WYYej7XRoQ4vdH8MUDWbgsXP +8m3vR/9SczOQ== From: Jisheng Zhang To: Daniel Lezcano , Thomas Gleixner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Samuel Holland Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v2 1/3] clocksource/drivers/timer-riscv: Add set_state_oneshot_stopped Date: Sat, 6 Apr 2024 19:17:55 +0800 Message-ID: <20240406111757.1597-2-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240406111757.1597-1-jszhang@kernel.org> References: <20240406111757.1597-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240406_043123_608702_BC4B7F49 X-CRM114-Status: GOOD ( 10.54 ) 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 Sat Apr 6 11:17:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13619782 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 B077DCD1284 for ; Sat, 6 Apr 2024 11:31:40 +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=2Z1uDTRhnR5edoJw9dGdykEDKRtyiBcap7IJL4WAqNo=; b=btDeGm/3HWzxur Jv5w+Kg0tbkALqUwpX3mPVHVQQY/IKV7zmfpj8Rlx5U2GvGzoUsi5LMOjh0hD7BxTyPugzdMKU3Z7 pI8IxxOjZTYCtVg5j00eKK5T5gDs373UtCYQkIGWhus4NtierapFFS7b52ZakRgupF57fNSgdlHCn ZrhAKrmbtQC5qhr2GSxOX0L5aacK5NPKMsmY872T9KGk4iq+sAIX5RONtvOjf65uH1vW2acMZbsKC dhni9bfiyWXJ91MF2hB3TAd9a4uUM2su9pzDttuNxoVolCcYCx8gMJvhTKSw4au78eqC7OpiI0mm1 EXCz83LCIzgQNmHqDxIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rt4Ge-0000000ACzD-3Fxv; Sat, 06 Apr 2024 11:31:28 +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 1rt4GZ-0000000ACw9-2f5I for linux-riscv@lists.infradead.org; Sat, 06 Apr 2024 11:31:25 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AAA3360B2B; Sat, 6 Apr 2024 11:31:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D956BC43141; Sat, 6 Apr 2024 11:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712403082; bh=66gmc8NYeVWAyoDrDcv4Y+x0uF90S93OHXhD2YCJ+6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ORp0hN7UO4eAFVjTVf+j76i3KDprQYwqJpkNxvDrt+iPdVVS6f0JuqH2XGji5lexO VMgDm9Bm7R1z1XzoynU/F8vM/ab82da/na0x9fdYRATW5wtdBxEgqs2ueta2Wn1r6Y kenWH0Xtfzq4OppuuLViU5DSllzVe1rMeN332aV+AcqgyZ/tyNr0UyN222Nz8VlgGi xCVAAraEpdqZc/56/nku3IRctwH2c9uid1h4GtwLQ+5tSFSsD0/HrGGssaMTeb6LL4 hCqSEkaNErssRXqLItMqPpvkhkj/w7jRvglqDVMz818h7r4fNWOH4zZ3RZrUQqmjV1 skUKAikVI+gVg== From: Jisheng Zhang To: Daniel Lezcano , Thomas Gleixner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Samuel Holland Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v2 2/3] clocksource/drivers/timer-clint: Add set_state_shutdown Date: Sat, 6 Apr 2024 19:17:56 +0800 Message-ID: <20240406111757.1597-3-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240406111757.1597-1-jszhang@kernel.org> References: <20240406111757.1597-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240406_043123_765871_49238A57 X-CRM114-Status: UNSURE ( 9.59 ) 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..1c17eff9861e 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(U64_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 Sat Apr 6 11:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13619781 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 08E61CD1284 for ; Sat, 6 Apr 2024 11:31:37 +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=TYsMbVAfvcHzdp9IMQJPETr5DhkaHM26Hx2g83nLVZ4=; b=bKen9y3Nsg3O3g xDkyis4B4jZXnNj/Q/cKw9yEpJZ2d3Tn1KdcxwhWTGHrxaYt3q+Xc+kkAgR07bAzmJfAjsgUsZhF8 SwwyYfaYgEh5PnZ5fCxUMRzNA6uXLDNtYxYK3Oy21gNlJHno9unM3uPuBPZPnFWnqgqkNO4JZRb6Q XbvaEyXd3gE+lbKKAyfd98NkyFjA4jv6NxS4GFO/rNS3onY5d0Ci9X6RviP/gSrA8FaUTP/4pUIG3 xm8XxMV+g7AA33bPkB/np7uXp7vmbFc1Ak6Quzv0byXMNd6jtBQe8Ln3EEUpcl7PAUyTWTshHUNaA LfOoStmWJmyPQvSZczvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rt4Gi-0000000AD1A-0Mni; Sat, 06 Apr 2024 11:31:32 +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 1rt4Gd-0000000ACxv-0KFl for linux-riscv@lists.infradead.org; Sat, 06 Apr 2024 11:31:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 76982CE19BE; Sat, 6 Apr 2024 11:31:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4331C433F1; Sat, 6 Apr 2024 11:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712403084; bh=QNz4CJCFePste/7DhKkLbFCEPMnrk6GSUJBGB1Aj74U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8XjQBe/E5HTHforMou7F0rT2W0G3OjrHdYJ6K+oat6W4FF6vVUP9NIUAIqT9EJUR uqenOb2f/JATM2VxEjKOCIq8oMSyy1DPKELKFX5K1256zGXVDsS7f6K/qDevPWKkSl 7WivOFgVG7kANEROaGzXdC7LTSYVQ6TqzqyHHwsSr1Kirr/Vs5s0ObmhnhS+EKwuVR bd2GGlIvffrXvgNc33owMD0XRJ6F6Y1lohtulMHUIG0PRuAq5pbKNCeDJHiDO+XY4+ xPgDLTi21AlyVDJbdJw3XmX4cYBBD/Qndb5zMUqu+n3H1GYqblgHIG97b0S4QaQdGP N3cZKEBv//cLA== From: Jisheng Zhang To: Daniel Lezcano , Thomas Gleixner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Samuel Holland Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v2 3/3] clocksource/drivers/timer-clint: Add set_state_oneshot_stopped Date: Sat, 6 Apr 2024 19:17:57 +0800 Message-ID: <20240406111757.1597-4-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240406111757.1597-1-jszhang@kernel.org> References: <20240406111757.1597-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240406_043127_441462_00EADAD0 X-CRM114-Status: UNSURE ( 9.28 ) 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 1c17eff9861e..f468fa8bf5f0 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)