Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arina Kharlamova" <arina.kharlamova@mbzuai.ac.ae>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: uartlite: Resume the device before disabling the clock on remove
Date: Tue, 01 Dec 2026 19:33:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-244083@kernel.org> (raw)
In-Reply-To: <20261201-uartlite-remove-clk-v1-1-bdffc49566f6@mbzuai.ac.ae>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] serial: uartlite: clk_disable_unprepare() called before
  ulite_release()
--

commit 61b30e88d1673ed11a94dda9b0b4e0f2531305d8
Author: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>

serial: uartlite: Resume the device before disabling the clock on remove

This commit takes a runtime PM reference at the start of ulite_remove() so
that the device is resumed before clk_disable_unprepare() is called, and
drops the reference after disabling runtime PM.

> diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
> index b9a14dc2f2fdf..993569d3432df 100644
> --- a/drivers/tty/serial/uartlite.c
> +++ b/drivers/tty/serial/uartlite.c
> @@ -893,10 +893,12 @@ static void ulite_remove(struct platform_device *pdev)
>  	struct uart_port *port = dev_get_drvdata(&pdev->dev);
>  	struct uartlite_data *pdata = port->private_data;
>  
> +	pm_runtime_get_sync(&pdev->dev);
>  	clk_disable_unprepare(pdata->clk);
>  	ulite_release(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  	pm_runtime_set_suspended(&pdev->dev);
> +	pm_runtime_put_noidle(&pdev->dev);
>  	pm_runtime_dont_use_autosuspend(&pdev->dev);
>  }

[Severity: High]
Does calling clk_disable_unprepare(pdata->clk) before ulite_release() and
pm_runtime_disable() disable and unprepare the clock while the UART port is
still active?

When an open port is removed, ulite_startup() holds a second clk_enable()
reference, so clk_disable_unprepare() unprepares a still-enabled clock and
triggers a clk_core_unprepare() warning before ulite_release() ->
uart_remove_one_port() -> ulite_shutdown() accesses ULITE_CONTROL and calls
clk_disable() on the unprepared clock:

drivers/tty/serial/uartlite.c:ulite_shutdown() {
	...
	uart_out32(0, ULITE_CONTROL, port);
	uart_in32(ULITE_CONTROL, port); /* dummy */
	free_irq(port->irq, port);
	clk_disable(pdata->clk);
}

When a closed or console port is removed, clk_disable_unprepare() gates off
the AXI clock before uart_remove_one_port() unregisters the console and
port, so console output during unregistration accesses ULITE registers with
the clock disabled.  Moving clk_disable_unprepare(pdata->clk) after
ulite_release() and pm_runtime_disable() keeps the clock prepared and
enabled until port teardown finishes.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-uartlite-remove-clk-v1-1-bdffc49566f6@mbzuai.ac.ae?part=1

      reply	other threads:[~2026-12-01 19:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 19:19 [PATCH] serial: uartlite: Resume the device before disabling the clock on remove Arina Kharlamova via B4 Relay
2026-12-01 19:33 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-244083@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arina.kharlamova@mbzuai.ac.ae \
    --cc=linux-serial@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox