All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND] serial: 8250_bcm7271: move spin_lock_irqsave to spin_lock in interrupt handler
@ 2022-08-22 14:11 Tuo Cao
  2022-08-22 14:25 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Tuo Cao @ 2022-08-22 14:11 UTC (permalink / raw)
  To: alcooperx, bcm-kernel-feedback-list, gregkh, jirislaby
  Cc: linux-serial, linux-kernel, 91tuocao

it is unnecessary to call spin_lock_irqsave in a interrupt handler.

Signed-off-by: Tuo Cao <91tuocao@gmail.com>
---
 drivers/tty/serial/8250/8250_bcm7271.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c
index 8efdc271eb75..fb525c435723 100644
--- a/drivers/tty/serial/8250/8250_bcm7271.c
+++ b/drivers/tty/serial/8250/8250_bcm7271.c
@@ -560,7 +560,6 @@ static irqreturn_t brcmuart_isr(int irq, void *dev_id)
 	struct uart_port *up = dev_id;
 	struct device *dev = up->dev;
 	struct brcmuart_priv *priv = up->private_data;
-	unsigned long flags;
 	u32 interrupts;
 	u32 rval;
 	u32 tval;
@@ -569,7 +568,7 @@ static irqreturn_t brcmuart_isr(int irq, void *dev_id)
 	if (interrupts == 0)
 		return IRQ_NONE;
 
-	spin_lock_irqsave(&up->lock, flags);
+	spin_lock(&up->lock);
 
 	/* Clear all interrupts */
 	udma_writel(priv, REGS_DMA_ISR, UDMA_INTR_CLEAR, interrupts);
@@ -583,7 +582,7 @@ static irqreturn_t brcmuart_isr(int irq, void *dev_id)
 	if ((rval | tval) == 0)
 		dev_warn(dev, "Spurious interrupt: 0x%x\n", interrupts);
 
-	spin_unlock_irqrestore(&up->lock, flags);
+	spin_unlock(&up->lock);
 	return IRQ_HANDLED;
 }
 
-- 
2.17.1


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

* Re: [RESEND] serial: 8250_bcm7271: move spin_lock_irqsave to spin_lock in interrupt handler
  2022-08-22 14:11 [RESEND] serial: 8250_bcm7271: move spin_lock_irqsave to spin_lock in interrupt handler Tuo Cao
@ 2022-08-22 14:25 ` Greg KH
  2022-08-27  9:42   ` tuo cao
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2022-08-22 14:25 UTC (permalink / raw)
  To: Tuo Cao
  Cc: alcooperx, bcm-kernel-feedback-list, jirislaby, linux-serial,
	linux-kernel

On Mon, Aug 22, 2022 at 10:11:10PM +0800, Tuo Cao wrote:
> it is unnecessary to call spin_lock_irqsave in a interrupt handler.

Yes, but it is safer to do so, right?

Why is this change needed?

Did you test it on real hardware to verify it works?

We need a lot more information in the changelog text before being able
to accept this.

thanks,

greg k-h

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

* Re: [RESEND] serial: 8250_bcm7271: move spin_lock_irqsave to spin_lock in interrupt handler
  2022-08-22 14:25 ` Greg KH
@ 2022-08-27  9:42   ` tuo cao
  2022-08-30 11:35     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: tuo cao @ 2022-08-27  9:42 UTC (permalink / raw)
  To: Greg KH
  Cc: alcooperx, bcm-kernel-feedback-list, jirislaby, linux-serial,
	linux-kernel

No, whether it's spin_lock_irqsave() or spin_lock(), the security is
the same. Since this commit:e58aa3d2d0cc01ad8d6f7f640a0670433f794922,
interrupt nesting is disabled, which means interrupts has disabled in
the interrupt handlers. So, it is unnecessary to call
spin_lock_irqsave in a interrupt handler. And it takes less time
obviously to use spin_lock(),so I think this change is needed.

Finally, I'm sorry I lacked real hardware to verify it and can't
provide changelog text.

Thanks.

Greg KH <gregkh@linuxfoundation.org> 于2022年8月22日周一 22:25写道:
>
> On Mon, Aug 22, 2022 at 10:11:10PM +0800, Tuo Cao wrote:
> > it is unnecessary to call spin_lock_irqsave in a interrupt handler.
>
> Yes, but it is safer to do so, right?
>
> Why is this change needed?
>
> Did you test it on real hardware to verify it works?
>
> We need a lot more information in the changelog text before being able
> to accept this.
>
> thanks,
>
> greg k-h

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

* Re: [RESEND] serial: 8250_bcm7271: move spin_lock_irqsave to spin_lock in interrupt handler
  2022-08-27  9:42   ` tuo cao
@ 2022-08-30 11:35     ` Greg KH
  2022-09-04  8:48       ` tuo cao
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2022-08-30 11:35 UTC (permalink / raw)
  To: tuo cao
  Cc: alcooperx, bcm-kernel-feedback-list, jirislaby, linux-serial,
	linux-kernel

On Sat, Aug 27, 2022 at 05:42:19PM +0800, tuo cao wrote:
> No, whether it's spin_lock_irqsave() or spin_lock(), the security is
> the same. Since this commit:e58aa3d2d0cc01ad8d6f7f640a0670433f794922,
> interrupt nesting is disabled, which means interrupts has disabled in
> the interrupt handlers. So, it is unnecessary to call
> spin_lock_irqsave in a interrupt handler. And it takes less time
> obviously to use spin_lock(),so I think this change is needed.

I have no context at all here, please never top-post :(

And have you measured the time difference?  Is it a real thing?

> Finally, I'm sorry I lacked real hardware to verify it and can't
> provide changelog text.

Try to never do changes for drivers for functionality like this where
you do not have the hardware to test for, until you get a lot more
experience.

good luck!

greg k-h

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

* Re: [RESEND] serial: 8250_bcm7271: move spin_lock_irqsave to spin_lock in interrupt handler
  2022-08-30 11:35     ` Greg KH
@ 2022-09-04  8:48       ` tuo cao
  2022-09-04 13:10         ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: tuo cao @ 2022-09-04  8:48 UTC (permalink / raw)
  To: Greg KH
  Cc: alcooperx, bcm-kernel-feedback-list, jirislaby, linux-serial,
	linux-kernel

Greg KH <gregkh@linuxfoundation.org> 于2022年8月30日周二 19:35写道:
>
> On Sat, Aug 27, 2022 at 05:42:19PM +0800, tuo cao wrote:
> > No, whether it's spin_lock_irqsave() or spin_lock(), the security is
> > the same. Since this commit:e58aa3d2d0cc01ad8d6f7f640a0670433f794922,
> > interrupt nesting is disabled, which means interrupts has disabled in
> > the interrupt handlers. So, it is unnecessary to call
> > spin_lock_irqsave in a interrupt handler. And it takes less time
> > obviously to use spin_lock(),so I think this change is needed.
>
> I have no context at all here, please never top-post :(
>
Sorry for causing you trouble. It should be OK this time.

> And have you measured the time difference?  Is it a real thing?
>
Yes, sir. I have measured it, it is a read thing. The test code and
log have been put on Github, please check:
https://github.com/tuocao1991/api_test

> > Finally, I'm sorry I lacked real hardware to verify it and can't
> > provide changelog text.
>
> Try to never do changes for drivers for functionality like this where
> you do not have the hardware to test for, until you get a lot more
> experience.
>
I got it, thanks

> good luck!
>
> greg k-h

Best Regards!

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

* Re: [RESEND] serial: 8250_bcm7271: move spin_lock_irqsave to spin_lock in interrupt handler
  2022-09-04  8:48       ` tuo cao
@ 2022-09-04 13:10         ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2022-09-04 13:10 UTC (permalink / raw)
  To: tuo cao
  Cc: alcooperx, bcm-kernel-feedback-list, jirislaby, linux-serial,
	linux-kernel

On Sun, Sep 04, 2022 at 04:48:13PM +0800, tuo cao wrote:
> Greg KH <gregkh@linuxfoundation.org> 于2022年8月30日周二 19:35写道:
> >
> > On Sat, Aug 27, 2022 at 05:42:19PM +0800, tuo cao wrote:
> > > No, whether it's spin_lock_irqsave() or spin_lock(), the security is
> > > the same. Since this commit:e58aa3d2d0cc01ad8d6f7f640a0670433f794922,
> > > interrupt nesting is disabled, which means interrupts has disabled in
> > > the interrupt handlers. So, it is unnecessary to call
> > > spin_lock_irqsave in a interrupt handler. And it takes less time
> > > obviously to use spin_lock(),so I think this change is needed.
> >
> > I have no context at all here, please never top-post :(
> >
> Sorry for causing you trouble. It should be OK this time.
> 
> > And have you measured the time difference?  Is it a real thing?
> >
> Yes, sir. I have measured it, it is a read thing. The test code and
> log have been put on Github, please check:
> https://github.com/tuocao1991/api_test

Did you test it for this code change?

And remember, those calls are being made inside of an IRQ handler, did
you measure that time difference?

And that link does not show much, sorry, you are doing no real work at
all, and again, not operating in an irq handler.

Can you see a measurable difference with your patch applied and without
it?  If so, great, provide that informatin in the changelog text.  If
not, be very careful about changing code in stuff like this.

thanks,

greg k-h

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

end of thread, other threads:[~2022-09-04 13:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-22 14:11 [RESEND] serial: 8250_bcm7271: move spin_lock_irqsave to spin_lock in interrupt handler Tuo Cao
2022-08-22 14:25 ` Greg KH
2022-08-27  9:42   ` tuo cao
2022-08-30 11:35     ` Greg KH
2022-09-04  8:48       ` tuo cao
2022-09-04 13:10         ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.