diff mbox series

[1/4] serial: 8250: omap: Fix freeing of resources on failed register

Message ID 20230508082014.23083-2-tony@atomide.com (mailing list archive)
State New, archived
Headers show
Series More console rebind changes for 8250_omap serial driver | expand

Commit Message

Tony Lindgren May 8, 2023, 8:20 a.m. UTC
If serial8250_register_8250_port() fails, the SoC can hang as the
deferred PMQoS work will still run as is not flushed and removed.

Fixes: 61929cf0169d ("tty: serial: Add 8250-core based omap driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/tty/serial/8250/8250_omap.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ilpo Järvinen May 8, 2023, 9:55 a.m. UTC | #1
On Mon, 8 May 2023, Tony Lindgren wrote:

> If serial8250_register_8250_port() fails, the SoC can hang as the
> deferred PMQoS work will still run as is not flushed and removed.
> 
> Fixes: 61929cf0169d ("tty: serial: Add 8250-core based omap driver")
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/tty/serial/8250/8250_omap.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
> @@ -1532,7 +1532,9 @@ static int omap8250_probe(struct platform_device *pdev)
>  err:
>  	pm_runtime_dont_use_autosuspend(&pdev->dev);
>  	pm_runtime_put_sync(&pdev->dev);
> +	flush_work(&priv->qos_work);
>  	pm_runtime_disable(&pdev->dev);
> +	cpu_latency_qos_remove_request(&priv->pm_qos_request);
>  	return ret;

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

An unrelated comment to the patch itself, there seems to be somewhat 
handwavy and possibly wrong calculation for the pm qos latency. First of 
all, I think it would want something based on port->frame_time, and I'm 
far from convinced that 64 is right as it matches FIFO size which doesn't 
feel correct for a wakeup related time.
Tony Lindgren May 8, 2023, 11:08 a.m. UTC | #2
* Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [230508 09:55]:
> An unrelated comment to the patch itself, there seems to be somewhat 
> handwavy and possibly wrong calculation for the pm qos latency. First of 
> all, I think it would want something based on port->frame_time, and I'm 
> far from convinced that 64 is right as it matches FIFO size which doesn't 
> feel correct for a wakeup related time.

Thanks for spotting it, good point. I'll take a look at that in a separate
patch.

Regards,

Tony
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -1532,7 +1532,9 @@  static int omap8250_probe(struct platform_device *pdev)
 err:
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_put_sync(&pdev->dev);
+	flush_work(&priv->qos_work);
 	pm_runtime_disable(&pdev->dev);
+	cpu_latency_qos_remove_request(&priv->pm_qos_request);
 	return ret;
 }