public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check
@ 2026-01-28 14:27 Andy Shevchenko
  2026-01-28 15:09 ` Ilpo Järvinen
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-01-28 14:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby (SUSE), linux-kernel, linux-serial
  Cc: Ilpo Järvinen, Andy Shevchenko

serial8250_release_dma() is NULL-aware, no need to check this in the caller.
While at it, make sure DMA won't be used again, by NULLifying the pointer.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_port.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 21fdf84f118f..c40d750d5a4b 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2366,8 +2366,8 @@ void serial8250_do_shutdown(struct uart_port *port)
 
 	synchronize_irq(port->irq);
 
-	if (up->dma)
-		serial8250_release_dma(up);
+	serial8250_release_dma(up);
+	up->dma = NULL;
 
 	scoped_guard(uart_port_lock_irqsave, port) {
 		if (port->flags & UPF_FOURPORT) {
-- 
2.50.1


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

* Re: [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check
  2026-01-28 14:27 [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check Andy Shevchenko
@ 2026-01-28 15:09 ` Ilpo Järvinen
  2026-01-28 15:44   ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Ilpo Järvinen @ 2026-01-28 15:09 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Greg Kroah-Hartman, Jiri Slaby (SUSE), LKML, linux-serial

[-- Attachment #1: Type: text/plain, Size: 1046 bytes --]

On Wed, 28 Jan 2026, Andy Shevchenko wrote:

> serial8250_release_dma() is NULL-aware, no need to check this in the caller.
> While at it, make sure DMA won't be used again, by NULLifying the pointer.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/tty/serial/8250/8250_port.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index 21fdf84f118f..c40d750d5a4b 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -2366,8 +2366,8 @@ void serial8250_do_shutdown(struct uart_port *port)
>  
>  	synchronize_irq(port->irq);
>  
> -	if (up->dma)
> -		serial8250_release_dma(up);
> +	serial8250_release_dma(up);
> +	up->dma = NULL;
>  
>  	scoped_guard(uart_port_lock_irqsave, port) {
>  		if (port->flags & UPF_FOURPORT) {
> 

Seems reasonable safeguard,

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>


-- 
 i.

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

* Re: [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check
  2026-01-28 15:09 ` Ilpo Järvinen
@ 2026-01-28 15:44   ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-01-28 15:44 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Greg Kroah-Hartman, Jiri Slaby (SUSE), LKML, linux-serial

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 422 bytes --]

On Wed, Jan 28, 2026 at 05:09:31PM +0200, Ilpo Järvinen wrote:
> On Wed, 28 Jan 2026, Andy Shevchenko wrote:

...

> > -	if (up->dma)
> > -		serial8250_release_dma(up);
> > +	serial8250_release_dma(up);
> > +	up->dma = NULL;
> 
> Seems reasonable safeguard,

Note, 8250_omap does the same for last 3 years.

> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Thanks!


-- 
With Best Regards,
Andy Shevchenko



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

* [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check
@ 2026-03-02 15:27 Andy Shevchenko
  2026-03-03  5:25 ` Jiri Slaby
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-03-02 15:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby (SUSE), linux-kernel, linux-serial
  Cc: Andy Shevchenko

serial8250_release_dma() is NULL-aware, no need to check this in the caller.
While at it, make sure DMA won't be used again, by NULLifying the pointer.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_port.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index d99c5ad7e47c..2a830969d22b 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2366,8 +2366,8 @@ void serial8250_do_shutdown(struct uart_port *port)
 
 	synchronize_irq(port->irq);
 
-	if (up->dma)
-		serial8250_release_dma(up);
+	serial8250_release_dma(up);
+	up->dma = NULL;
 
 	scoped_guard(uart_port_lock_irqsave, port) {
 		if (port->flags & UPF_FOURPORT) {
-- 
2.50.1


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

* Re: [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check
  2026-03-02 15:27 Andy Shevchenko
@ 2026-03-03  5:25 ` Jiri Slaby
  2026-03-03  7:55   ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2026-03-03  5:25 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial

On 02. 03. 26, 16:27, Andy Shevchenko wrote:
> serial8250_release_dma() is NULL-aware, no need to check this in the caller.
> While at it, make sure DMA won't be used again, by NULLifying the pointer.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/tty/serial/8250/8250_port.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index d99c5ad7e47c..2a830969d22b 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -2366,8 +2366,8 @@ void serial8250_do_shutdown(struct uart_port *port)
>   
>   	synchronize_irq(port->irq);
>   
> -	if (up->dma)
> -		serial8250_release_dma(up);
> +	serial8250_release_dma(up);
> +	up->dma = NULL;

Shouldn't serial8250_release_dma() NULL it instead, so the callers need 
not to bother?

thanks,
-- 
js
suse labs

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

* Re: [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check
  2026-03-03  5:25 ` Jiri Slaby
@ 2026-03-03  7:55   ` Andy Shevchenko
  2026-03-03  8:26     ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-03-03  7:55 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Greg Kroah-Hartman, linux-kernel, linux-serial

On Tue, Mar 03, 2026 at 06:25:29AM +0100, Jiri Slaby wrote:
> On 02. 03. 26, 16:27, Andy Shevchenko wrote:
> > serial8250_release_dma() is NULL-aware, no need to check this in the caller.
> > While at it, make sure DMA won't be used again, by NULLifying the pointer.

> >   	synchronize_irq(port->irq);
> > -	if (up->dma)
> > -		serial8250_release_dma(up);
> > +	serial8250_release_dma(up);
> > +	up->dma = NULL;
> 
> Shouldn't serial8250_release_dma() NULL it instead, so the callers need not
> to bother?

I copied what 8250_omap is doing. But we can do what you suggested I think.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check
  2026-03-03  7:55   ` Andy Shevchenko
@ 2026-03-03  8:26     ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-03-03  8:26 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Greg Kroah-Hartman, linux-kernel, linux-serial

On Tue, Mar 03, 2026 at 09:55:45AM +0200, Andy Shevchenko wrote:
> On Tue, Mar 03, 2026 at 06:25:29AM +0100, Jiri Slaby wrote:
> > On 02. 03. 26, 16:27, Andy Shevchenko wrote:
> > > serial8250_release_dma() is NULL-aware, no need to check this in the caller.
> > > While at it, make sure DMA won't be used again, by NULLifying the pointer.

...

> > > -	if (up->dma)
> > > -		serial8250_release_dma(up);
> > > +	serial8250_release_dma(up);
> > > +	up->dma = NULL;
> > 
> > Shouldn't serial8250_release_dma() NULL it instead, so the callers need not
> > to bother?
> 
> I copied what 8250_omap is doing. But we can do what you suggested I think.

I looked at the 8250_dma code and serial8250_release_dma() in particular,
and I think I am not going to change the approach. The 'dma' pointer is
assigned outside of serial8250_request_dma() and NULLifying it in
serial8250_release_dma() will be a layering violation.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-03-03  8:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28 14:27 [PATCH v1 1/1] serial: 8250_port: Drop duplicate NULL check Andy Shevchenko
2026-01-28 15:09 ` Ilpo Järvinen
2026-01-28 15:44   ` Andy Shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2026-03-02 15:27 Andy Shevchenko
2026-03-03  5:25 ` Jiri Slaby
2026-03-03  7:55   ` Andy Shevchenko
2026-03-03  8:26     ` Andy Shevchenko

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