All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: ucc_uart: Use platform IRQ helper
@ 2026-09-25 18:25 Rosen Penev
  2026-09-25 18:33 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Rosen Penev @ 2026-09-25 18:25 UTC (permalink / raw)
  To: linux-serial
  Cc: Timur Tabi, Greg Kroah-Hartman, Jiri Slaby,
	open list:FREESCALE QUICC ENGINE UCC UART DRIVER,
	open list:TTY LAYER AND SERIAL DRIVERS

Avoid calling irq_dispose_mapping() by letting the platform_device
machinery handle it. Also enable possibility of handling -EPROBE_DEFER
and other errors. Handle before any allocation or anything to avoid
dealing with gotos.

Assisted-by: LLM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/tty/serial/ucc_uart.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 6b7dcbbacd13..c3c83a59dcce 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -1238,6 +1238,7 @@ static int ucc_uart_probe(struct platform_device *ofdev)
 	struct uart_qe_port *qe_port = NULL;
 	struct resource res;
 	u32 val;
+	int irq;
 	int ret;
 
 	/*
@@ -1247,6 +1248,10 @@ static int ucc_uart_probe(struct platform_device *ofdev)
 	if (ret)
 		return ret;
 
+	irq = platform_get_irq(ofdev, 0);
+	if (irq < 0)
+		return irq;
+
 	qe_port = kzalloc_obj(struct uart_qe_port);
 	if (!qe_port) {
 		dev_err(&ofdev->dev, "can't allocate QE port structure\n");
@@ -1338,13 +1343,7 @@ static int ucc_uart_probe(struct platform_device *ofdev)
 		goto out_free;
 	}
 
-	qe_port->port.irq = irq_of_parse_and_map(np, 0);
-	if (qe_port->port.irq == 0) {
-		dev_err(&ofdev->dev, "could not map IRQ for UCC%u\n",
-		       qe_port->ucc_num + 1);
-		ret = -EINVAL;
-		goto out_free;
-	}
+	qe_port->port.irq = irq;
 
 	/*
 	 * Newer device trees have an "fsl,qe" compatible property for the QE
-- 
2.55.0


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

* Re: [PATCH] serial: ucc_uart: Use platform IRQ helper
  2026-09-25 18:25 [PATCH] serial: ucc_uart: Use platform IRQ helper Rosen Penev
@ 2026-09-25 18:33 ` sashiko-bot
  2026-09-25 18:50   ` Rosen Penev
  0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-09-25 18:33 UTC (permalink / raw)
  To: Rosen Penev; +Cc: linux-serial

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] probe deferral: leak of async firmware load due to platform_get_irq() ordering
--

commit 887c64b890c9273da1e7e1715e89bca754adbfb0
Author: Rosen Penev <rosenp@gmail.com>

serial: ucc_uart: Use platform IRQ helper

This commit updates the driver to use platform_get_irq() instead of
irq_of_parse_and_map() to obtain the IRQ. The IRQ lookup is moved earlier
in the probe function to simplify error handling and explicitly handle
probe deferral.

> diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
> index 6b7dcbbacd13d..c3c83a59dcce7 100644
> --- a/drivers/tty/serial/ucc_uart.c
> +++ b/drivers/tty/serial/ucc_uart.c
> @@ -1238,6 +1238,7 @@ static int ucc_uart_probe(struct platform_device *ofdev)
>  	struct uart_qe_port *qe_port = NULL;
>  	struct resource res;
>  	u32 val;
> +	int irq;
>  	int ret;
>  
>  	/*
> @@ -1247,6 +1248,10 @@ static int ucc_uart_probe(struct platform_device *ofdev)
>  	if (ret)
>  		return ret;
>  
> +	irq = platform_get_irq(ofdev, 0);
> +	if (irq < 0)
> +		return irq;
> +

[Severity: High]
If platform_get_irq() returns -EPROBE_DEFER here, does this leak the
asynchronous firmware load initiated by the preceding call to
soft_uart_init()?

Looking at soft_uart_init(), an async load is triggered like this:

    ret = request_firmware_nowait(THIS_MODULE,
                                  FW_ACTION_UEVENT, filename, &ofdev->dev,
                                  GFP_KERNEL, &ofdev->dev, uart_firmware_cont);

Since the async firmware load is not cancelled on probe deferral, the probe 
will eventually be retried and will call soft_uart_init() a second time. 

Could this lead to duplicated asynchronous firmware loads and concurrent
execution of qe_upload_firmware() upon probe retry, potentially causing
data races or hardware state corruption?

Would it make sense to move platform_get_irq() even earlier in the
probe function, before soft_uart_init(), to prevent this probe deferral
side effect?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260925182504.54976-1-rosenp@gmail.com?part=1

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

* Re: [PATCH] serial: ucc_uart: Use platform IRQ helper
  2026-09-25 18:33 ` sashiko-bot
@ 2026-09-25 18:50   ` Rosen Penev
  0 siblings, 0 replies; 3+ messages in thread
From: Rosen Penev @ 2026-09-25 18:50 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-serial

On Fri, Sep 25, 2026 at 11:33 AM <sashiko-bot@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] probe deferral: leak of async firmware load due to platform_get_irq() ordering
> --
>
> commit 887c64b890c9273da1e7e1715e89bca754adbfb0
> Author: Rosen Penev <rosenp@gmail.com>
>
> serial: ucc_uart: Use platform IRQ helper
>
> This commit updates the driver to use platform_get_irq() instead of
> irq_of_parse_and_map() to obtain the IRQ. The IRQ lookup is moved earlier
> in the probe function to simplify error handling and explicitly handle
> probe deferral.
>
> > diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
> > index 6b7dcbbacd13d..c3c83a59dcce7 100644
> > --- a/drivers/tty/serial/ucc_uart.c
> > +++ b/drivers/tty/serial/ucc_uart.c
> > @@ -1238,6 +1238,7 @@ static int ucc_uart_probe(struct platform_device *ofdev)
> >       struct uart_qe_port *qe_port = NULL;
> >       struct resource res;
> >       u32 val;
> > +     int irq;
> >       int ret;
> >
> >       /*
> > @@ -1247,6 +1248,10 @@ static int ucc_uart_probe(struct platform_device *ofdev)
> >       if (ret)
> >               return ret;
> >
> > +     irq = platform_get_irq(ofdev, 0);
> > +     if (irq < 0)
> > +             return irq;
> > +
>
> [Severity: High]
> If platform_get_irq() returns -EPROBE_DEFER here, does this leak the
> asynchronous firmware load initiated by the preceding call to
> soft_uart_init()?
That's pre-existing.
>
> Looking at soft_uart_init(), an async load is triggered like this:
>
>     ret = request_firmware_nowait(THIS_MODULE,
>                                   FW_ACTION_UEVENT, filename, &ofdev->dev,
>                                   GFP_KERNEL, &ofdev->dev, uart_firmware_cont);
>
> Since the async firmware load is not cancelled on probe deferral, the probe
> will eventually be retried and will call soft_uart_init() a second time.
>
> Could this lead to duplicated asynchronous firmware loads and concurrent
> execution of qe_upload_firmware() upon probe retry, potentially causing
> data races or hardware state corruption?
>
> Would it make sense to move platform_get_irq() even earlier in the
> probe function, before soft_uart_init(), to prevent this probe deferral
> side effect?
Yes
>
> [ ... ]
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260925182504.54976-1-rosenp@gmail.com?part=1

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

end of thread, other threads:[~2026-09-25 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-25 18:25 [PATCH] serial: ucc_uart: Use platform IRQ helper Rosen Penev
2026-09-25 18:33 ` sashiko-bot
2026-09-25 18:50   ` Rosen Penev

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.