Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/stm32mp-exti: fix the unit of the hwspinlock timeout
@ 2026-08-05  3:21 Ju Nan
  2026-08-15 14:08 ` Radu Rendec
  2026-08-16 14:20 ` [PATCH v2] " Ju Nan
  0 siblings, 2 replies; 4+ messages in thread
From: Ju Nan @ 2026-08-05  3:21 UTC (permalink / raw)
  To: tglx, mcoquelin.stm32, alexandre.torgue, junan76
  Cc: linux-kernel, linux-stm32, linux-arm-kernel

HWSPNLCK_TIMEOUT is passed to hwspin_lock_timeout_in_atomic(), whose
timeout argument is in milliseconds, not microseconds:

  atomic_delay += HWSPINLOCK_RETRY_DELAY_US;
  if (atomic_delay > to * 1000)
          return -ETIMEDOUT;

So stm32mp_exti_set_type() asks for a 1 second timeout where the comment
next to the macro says it wants 1 millisecond. The semaphore is polled
with udelay() from a section that holds chip_data->rlock, a
raw_spinlock_t, so preemption stays disabled for the whole wait on every
configuration, PREEMPT_RT included.

The hwspinlock core documents this explicitly:

  If the mode is HWLOCK_IN_ATOMIC (called from an atomic context) the
  timeout is handled with busy-waiting delays, hence shall not exceed
  few msecs.

Pass the value the comment always described. The core retries every
HWSPINLOCK_RETRY_DELAY_US (100 us), so the semaphore is still polled ten
times before giving up, which is far longer than any plausible hold time
on the coprocessor side. A timeout is reported with pr_err() and fails
the trigger type configuration, so shortening it degrades gracefully.

Signed-off-by: Ju Nan <junan76@163.com>
---
 drivers/irqchip/irq-stm32mp-exti.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-stm32mp-exti.c b/drivers/irqchip/irq-stm32mp-exti.c
index a24f4f1a4..f5f0109bf 100644
--- a/drivers/irqchip/irq-stm32mp-exti.c
+++ b/drivers/irqchip/irq-stm32mp-exti.c
@@ -23,7 +23,7 @@
 
 #define IRQS_PER_BANK			32
 
-#define HWSPNLCK_TIMEOUT		1000 /* usec */
+#define HWSPNLCK_TIMEOUT		1 /* msec */
 
 #define EXTI_EnCIDCFGR(n)		(0x180 + (n) * 4)
 #define EXTI_HWCFGR1			0x3f0
-- 
2.55.0



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

* Re: [PATCH] irqchip/stm32mp-exti: fix the unit of the hwspinlock timeout
  2026-08-05  3:21 [PATCH] irqchip/stm32mp-exti: fix the unit of the hwspinlock timeout Ju Nan
@ 2026-08-15 14:08 ` Radu Rendec
  2026-08-15 14:19   ` Radu Rendec
  2026-08-16 14:20 ` [PATCH v2] " Ju Nan
  1 sibling, 1 reply; 4+ messages in thread
From: Radu Rendec @ 2026-08-15 14:08 UTC (permalink / raw)
  To: Ju Nan, tglx, mcoquelin.stm32, alexandre.torgue
  Cc: linux-kernel, linux-stm32, linux-arm-kernel

On Wed, 2026-08-05 at 11:21 +0800, Ju Nan wrote:
> HWSPNLCK_TIMEOUT is passed to hwspin_lock_timeout_in_atomic(), whose
> timeout argument is in milliseconds, not microseconds:
> 
>   atomic_delay += HWSPINLOCK_RETRY_DELAY_US;
>   if (atomic_delay > to * 1000)
>           return -ETIMEDOUT;
> 
> So stm32mp_exti_set_type() asks for a 1 second timeout where the comment
> next to the macro says it wants 1 millisecond. The semaphore is polled
> with udelay() from a section that holds chip_data->rlock, a
> raw_spinlock_t, so preemption stays disabled for the whole wait on every
> configuration, PREEMPT_RT included.
> 
> The hwspinlock core documents this explicitly:
> 
>   If the mode is HWLOCK_IN_ATOMIC (called from an atomic context) the
>   timeout is handled with busy-waiting delays, hence shall not exceed
>   few msecs.
> 
> Pass the value the comment always described. The core retries every
> HWSPINLOCK_RETRY_DELAY_US (100 us), so the semaphore is still polled ten
> times before giving up, which is far longer than any plausible hold time
> on the coprocessor side. A timeout is reported with pr_err() and fails
> the trigger type configuration, so shortening it degrades gracefully.
> 
> Signed-off-by: Ju Nan <junan76@163.com>
> ---
>  drivers/irqchip/irq-stm32mp-exti.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-stm32mp-exti.c b/drivers/irqchip/irq-stm32mp-exti.c
> index a24f4f1a4..f5f0109bf 100644
> --- a/drivers/irqchip/irq-stm32mp-exti.c
> +++ b/drivers/irqchip/irq-stm32mp-exti.c
> @@ -23,7 +23,7 @@
>  
>  #define IRQS_PER_BANK			32
>  
> -#define HWSPNLCK_TIMEOUT		1000 /* usec */
> +#define HWSPNLCK_TIMEOUT		1 /* msec */
>  
>  #define EXTI_EnCIDCFGR(n)		(0x180 + (n) * 4)
>  #define EXTI_HWCFGR1			0x3f0

Reviewed-by: Radu Rendec <radu@rendec.net>


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

* Re: [PATCH] irqchip/stm32mp-exti: fix the unit of the hwspinlock timeout
  2026-08-15 14:08 ` Radu Rendec
@ 2026-08-15 14:19   ` Radu Rendec
  0 siblings, 0 replies; 4+ messages in thread
From: Radu Rendec @ 2026-08-15 14:19 UTC (permalink / raw)
  To: Ju Nan, tglx, mcoquelin.stm32, alexandre.torgue
  Cc: linux-kernel, linux-stm32, linux-arm-kernel

On Sat, 2026-08-15 at 10:08 -0400, Radu Rendec wrote:
> On Wed, 2026-08-05 at 11:21 +0800, Ju Nan wrote:
> > HWSPNLCK_TIMEOUT is passed to hwspin_lock_timeout_in_atomic(), whose
> > timeout argument is in milliseconds, not microseconds:
> > 
> >   atomic_delay += HWSPINLOCK_RETRY_DELAY_US;
> >   if (atomic_delay > to * 1000)
> >           return -ETIMEDOUT;
> > 
> > So stm32mp_exti_set_type() asks for a 1 second timeout where the comment
> > next to the macro says it wants 1 millisecond. The semaphore is polled
> > with udelay() from a section that holds chip_data->rlock, a
> > raw_spinlock_t, so preemption stays disabled for the whole wait on every
> > configuration, PREEMPT_RT included.
> > 
> > The hwspinlock core documents this explicitly:
> > 
> >   If the mode is HWLOCK_IN_ATOMIC (called from an atomic context) the
> >   timeout is handled with busy-waiting delays, hence shall not exceed
> >   few msecs.
> > 
> > Pass the value the comment always described. The core retries every
> > HWSPINLOCK_RETRY_DELAY_US (100 us), so the semaphore is still polled ten
> > times before giving up, which is far longer than any plausible hold time
> > on the coprocessor side. A timeout is reported with pr_err() and fails
> > the trigger type configuration, so shortening it degrades gracefully.
> > 
> > Signed-off-by: Ju Nan <junan76@163.com>
> > ---
> >  drivers/irqchip/irq-stm32mp-exti.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/irqchip/irq-stm32mp-exti.c b/drivers/irqchip/irq-stm32mp-exti.c
> > index a24f4f1a4..f5f0109bf 100644
> > --- a/drivers/irqchip/irq-stm32mp-exti.c
> > +++ b/drivers/irqchip/irq-stm32mp-exti.c
> > @@ -23,7 +23,7 @@
> >  
> >  #define IRQS_PER_BANK			32
> >  
> > -#define HWSPNLCK_TIMEOUT		1000 /* usec */
> > +#define HWSPNLCK_TIMEOUT		1 /* msec */
> >  
> >  #define EXTI_EnCIDCFGR(n)		(0x180 + (n) * 4)
> >  #define EXTI_HWCFGR1			0x3f0
> 
> Reviewed-by: Radu Rendec <radu@rendec.net>

Oops! Hit the "send" button too soon. The patch is OK, so the r-b tag
stays. But it also needs this:

Fixes: 5257169ade8c ("irqchip/stm32-exti: Use the hwspin_lock_timeout_in_atomic() API")



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

* [PATCH v2] irqchip/stm32mp-exti: fix the unit of the hwspinlock timeout
  2026-08-05  3:21 [PATCH] irqchip/stm32mp-exti: fix the unit of the hwspinlock timeout Ju Nan
  2026-08-15 14:08 ` Radu Rendec
@ 2026-08-16 14:20 ` Ju Nan
  1 sibling, 0 replies; 4+ messages in thread
From: Ju Nan @ 2026-08-16 14:20 UTC (permalink / raw)
  To: junan76, radu
  Cc: alexandre.torgue, linux-arm-kernel, linux-kernel, linux-stm32,
	mcoquelin.stm32, tglx

HWSPNLCK_TIMEOUT is passed to hwspin_lock_timeout_in_atomic(), whose
timeout argument is in milliseconds, not microseconds:

  atomic_delay += HWSPINLOCK_RETRY_DELAY_US;
  if (atomic_delay > to * 1000)
          return -ETIMEDOUT;

So stm32mp_exti_set_type() asks for a 1 second timeout where the comment
next to the macro says it wants 1 millisecond. The semaphore is polled
with udelay() from a section that holds chip_data->rlock, a
raw_spinlock_t, so preemption stays disabled for the whole wait on every
configuration, PREEMPT_RT included.

The hwspinlock core documents this explicitly:

  If the mode is HWLOCK_IN_ATOMIC (called from an atomic context) the
  timeout is handled with busy-waiting delays, hence shall not exceed
  few msecs.

Pass the value the comment always described. The core retries every
HWSPINLOCK_RETRY_DELAY_US (100 us), so the semaphore is still polled ten
times before giving up, which is far longer than any plausible hold time
on the coprocessor side. A timeout is reported with pr_err() and fails
the trigger type configuration, so shortening it degrades gracefully.

Fixes: 5257169ade8c ("irqchip/stm32-exti: Use the hwspin_lock_timeout_in_atomic() API")
Reviewed-by: Radu Rendec <radu@rendec.net>
Signed-off-by: Ju Nan <junan76@163.com>
---
changelog:

v2: Add Fixes tag suggested by Radu Rendec
v1: https://lore.kernel.org/all/20260805032139.35420-2-junan76@163.com/
---
 drivers/irqchip/irq-stm32mp-exti.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-stm32mp-exti.c b/drivers/irqchip/irq-stm32mp-exti.c
index a24f4f1a4..f5f0109bf 100644
--- a/drivers/irqchip/irq-stm32mp-exti.c
+++ b/drivers/irqchip/irq-stm32mp-exti.c
@@ -23,7 +23,7 @@
 
 #define IRQS_PER_BANK			32
 
-#define HWSPNLCK_TIMEOUT		1000 /* usec */
+#define HWSPNLCK_TIMEOUT		1 /* msec */
 
 #define EXTI_EnCIDCFGR(n)		(0x180 + (n) * 4)
 #define EXTI_HWCFGR1			0x3f0
-- 
2.55.0



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

end of thread, other threads:[~2026-08-16 14:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05  3:21 [PATCH] irqchip/stm32mp-exti: fix the unit of the hwspinlock timeout Ju Nan
2026-08-15 14:08 ` Radu Rendec
2026-08-15 14:19   ` Radu Rendec
2026-08-16 14:20 ` [PATCH v2] " Ju Nan

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