Linux kernel -stable discussions
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] clocksource/i8253: Use raw_spinlock_irqsave() in" failed to apply to 5.10-stable tree
@ 2025-05-12 10:31 gregkh
  2025-05-13  7:02 ` [PATCH 5.10.y] clocksource/i8253: Use raw_spinlock_irqsave() in clockevent_i8253_disable() Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2025-05-12 10:31 UTC (permalink / raw)
  To: bigeasy, tglx; +Cc: stable


The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 94cff94634e506a4a44684bee1875d2dbf782722
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025051257-skater-skeleton-9a3d@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 94cff94634e506a4a44684bee1875d2dbf782722 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 4 Apr 2025 15:31:16 +0200
Subject: [PATCH] clocksource/i8253: Use raw_spinlock_irqsave() in
 clockevent_i8253_disable()

On x86 during boot, clockevent_i8253_disable() can be invoked via
x86_late_time_init -> hpet_time_init() -> pit_timer_init() which happens
with enabled interrupts.

If some of the old i8253 hardware is actually used then lockdep will notice
that i8253_lock is used in hard interrupt context. This causes lockdep to
complain because it observed the lock being acquired with interrupts
enabled and in hard interrupt context.

Make clockevent_i8253_disable() acquire the lock with
raw_spinlock_irqsave() to cure this.

[ tglx: Massage change log and use guard() ]

Fixes: c8c4076723dac ("x86/timer: Skip PIT initialization on modern chipsets")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20250404133116.p-XRWJXf@linutronix.de

diff --git a/drivers/clocksource/i8253.c b/drivers/clocksource/i8253.c
index 39f7c2d736d1..b603c25f3dfa 100644
--- a/drivers/clocksource/i8253.c
+++ b/drivers/clocksource/i8253.c
@@ -103,7 +103,7 @@ int __init clocksource_i8253_init(void)
 #ifdef CONFIG_CLKEVT_I8253
 void clockevent_i8253_disable(void)
 {
-	raw_spin_lock(&i8253_lock);
+	guard(raw_spinlock_irqsave)(&i8253_lock);
 
 	/*
 	 * Writing the MODE register should stop the counter, according to
@@ -132,8 +132,6 @@ void clockevent_i8253_disable(void)
 	outb_p(0, PIT_CH0);
 
 	outb_p(0x30, PIT_MODE);
-
-	raw_spin_unlock(&i8253_lock);
 }
 
 static int pit_shutdown(struct clock_event_device *evt)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 5.10.y] clocksource/i8253: Use raw_spinlock_irqsave() in clockevent_i8253_disable()
  2025-05-12 10:31 FAILED: patch "[PATCH] clocksource/i8253: Use raw_spinlock_irqsave() in" failed to apply to 5.10-stable tree gregkh
@ 2025-05-13  7:02 ` Sebastian Andrzej Siewior
  2025-05-13 18:50   ` Sasha Levin
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-05-13  7:02 UTC (permalink / raw)
  To: stable; +Cc: Sebastian Andrzej Siewior, Thomas Gleixner

On x86 during boot, clockevent_i8253_disable() can be invoked via
x86_late_time_init -> hpet_time_init() -> pit_timer_init() which happens
with enabled interrupts.

If some of the old i8253 hardware is actually used then lockdep will notice
that i8253_lock is used in hard interrupt context. This causes lockdep to
complain because it observed the lock being acquired with interrupts
enabled and in hard interrupt context.

Make clockevent_i8253_disable() acquire the lock with
raw_spinlock_irqsave() to cure this.

[ tglx: Massage change log and use guard() ]
[ bigeasy: Dropped guard() for stable ]

Fixes: c8c4076723dac ("x86/timer: Skip PIT initialization on modern chipsets")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20250404133116.p-XRWJXf@linutronix.de
(cherry picked from commit 94cff94634e506a4a44684bee1875d2dbf782722)
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/clocksource/i8253.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/i8253.c b/drivers/clocksource/i8253.c
index 39f7c2d736d16..9a91ce66e16eb 100644
--- a/drivers/clocksource/i8253.c
+++ b/drivers/clocksource/i8253.c
@@ -103,7 +103,9 @@ int __init clocksource_i8253_init(void)
 #ifdef CONFIG_CLKEVT_I8253
 void clockevent_i8253_disable(void)
 {
-	raw_spin_lock(&i8253_lock);
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&i8253_lock, flags);
 
 	/*
 	 * Writing the MODE register should stop the counter, according to
@@ -133,7 +135,7 @@ void clockevent_i8253_disable(void)
 
 	outb_p(0x30, PIT_MODE);
 
-	raw_spin_unlock(&i8253_lock);
+	raw_spin_unlock_irqrestore(&i8253_lock, flags);
 }
 
 static int pit_shutdown(struct clock_event_device *evt)
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 5.10.y] clocksource/i8253: Use raw_spinlock_irqsave() in clockevent_i8253_disable()
  2025-05-13  7:02 ` [PATCH 5.10.y] clocksource/i8253: Use raw_spinlock_irqsave() in clockevent_i8253_disable() Sebastian Andrzej Siewior
@ 2025-05-13 18:50   ` Sasha Levin
  0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-05-13 18:50 UTC (permalink / raw)
  To: stable, bigeasy; +Cc: Sasha Levin

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it

Found matching upstream commit: 94cff94634e506a4a44684bee1875d2dbf782722

Status in newer kernel trees:
6.14.y | Present (different SHA1: 6fdc7368341b)
6.12.y | Present (different SHA1: e0e66bb1af60)
6.6.y | Present (different SHA1: 5dd520b92acb)
6.1.y | Present (different SHA1: d2f5f71707cf)
5.15.y | Present (different SHA1: f29f5341f350)

Note: The patch differs from the upstream commit:
---
1:  94cff94634e50 ! 1:  2a4e575499d58 clocksource/i8253: Use raw_spinlock_irqsave() in clockevent_i8253_disable()
    @@ Commit message
         raw_spinlock_irqsave() to cure this.
     
         [ tglx: Massage change log and use guard() ]
    +    [ bigeasy: Dropped guard() for stable ]
     
         Fixes: c8c4076723dac ("x86/timer: Skip PIT initialization on modern chipsets")
         Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
         Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
         Cc: stable@vger.kernel.org
         Link: https://lore.kernel.org/all/20250404133116.p-XRWJXf@linutronix.de
    +    (cherry picked from commit 94cff94634e506a4a44684bee1875d2dbf782722)
    +    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
     
      ## drivers/clocksource/i8253.c ##
     @@ drivers/clocksource/i8253.c: int __init clocksource_i8253_init(void)
    @@ drivers/clocksource/i8253.c: int __init clocksource_i8253_init(void)
      void clockevent_i8253_disable(void)
      {
     -	raw_spin_lock(&i8253_lock);
    -+	guard(raw_spinlock_irqsave)(&i8253_lock);
    ++	unsigned long flags;
    ++
    ++	raw_spin_lock_irqsave(&i8253_lock, flags);
      
      	/*
      	 * Writing the MODE register should stop the counter, according to
     @@ drivers/clocksource/i8253.c: void clockevent_i8253_disable(void)
    - 	outb_p(0, PIT_CH0);
      
      	outb_p(0x30, PIT_MODE);
    --
    + 
     -	raw_spin_unlock(&i8253_lock);
    ++	raw_spin_unlock_irqrestore(&i8253_lock, flags);
      }
      
      static int pit_shutdown(struct clock_event_device *evt)
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-5.10.y       |  Success    |  Success   |

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-13 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12 10:31 FAILED: patch "[PATCH] clocksource/i8253: Use raw_spinlock_irqsave() in" failed to apply to 5.10-stable tree gregkh
2025-05-13  7:02 ` [PATCH 5.10.y] clocksource/i8253: Use raw_spinlock_irqsave() in clockevent_i8253_disable() Sebastian Andrzej Siewior
2025-05-13 18:50   ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox