From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Heiko Stuebner <heiko@sntech.de>
Cc: broonie@kernel.org, linux-spi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, quentin.schulz@cherry.de,
Lee Jones <lee@kernel.org>,
Heiko Stuebner <heiko.stuebner@cherry.de>
Subject: Re: [PATCH v3 6/7] spi: rockchip: Move to pm_runtime_resume_and_get
Date: Wed, 18 Nov 2026 02:53:32 +0100 [thread overview]
Message-ID: <av0CaMF_jOyqMYA0@venus> (raw)
In-Reply-To: <20261117235021.2013719-7-heiko@sntech.de>
[-- Attachment #1.1: Type: text/plain, Size: 2466 bytes --]
Hi,
On Wed, Nov 18, 2026 at 12:50:20AM +0100, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner@cherry.de>
>
> Currently pm_runtime_get_sync() is used, which increments the usage
> count even if the resume was not successful.
>
> Move to the more modern pm_runtime_resume_and_get() which handles the
> usage counter better.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner@cherry.de>
> ---
This only makes sense when combined with error handling. Keeping
the use count increased makes more sense for the current code:
pm_runtime_get_sync(); // keep use count increased on failure
random_code();
pm_runtime_put(); // always decrease the RPM use count
Meanwhile your new code would result in double decrease on error:
pm_runtime_resume_and_get(); // only increase use count on success
random_code();
pm_runtime_put(); // always decrease RPM use count
Realistically random_code() will SError anyways without runtime PM,
so it *should* actually be pm_runtime_resume_and_get + error handling:
ret = pm_runtime_resume_and_get();
if (ret)
return ret;
random_code();
pm_runtime_put();
For this pattern pm_runtime_resume_and_get() is better than
pm_runtime_get_sync().
Greetings,
-- Sebastian
> drivers/spi/spi-rockchip.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 8bb55d52d346..ce1629e5a513 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -255,7 +255,7 @@ static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
>
> if (cs_asserted) {
> /* Keep things powered as long as CS is asserted */
> - pm_runtime_get_sync(rs->dev);
> + pm_runtime_resume_and_get(rs->dev);
>
> if (spi_get_csgpiod(spi, 0))
> ROCKCHIP_SPI_SET_BITS(rs->regs + ROCKCHIP_SPI_SER, 1);
> @@ -734,7 +734,7 @@ static int rockchip_spi_setup(struct spi_device *spi)
> return -EINVAL;
> }
>
> - pm_runtime_get_sync(rs->dev);
> + pm_runtime_resume_and_get(rs->dev);
>
> cr0 = readl_relaxed(rs->regs + ROCKCHIP_SPI_CTRLR0);
>
> @@ -924,7 +924,7 @@ static void rockchip_spi_remove(struct platform_device *pdev)
> {
> struct spi_controller *ctlr = platform_get_drvdata(pdev);
>
> - pm_runtime_get_sync(&pdev->dev);
> + pm_runtime_resume_and_get(&pdev->dev);
>
> spi_unregister_controller(ctlr);
>
> --
> 2.53.0
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2026-11-18 1:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 23:50 [PATCH v3 0/7] spi: Implement a atomic transfer as a last resort Heiko Stuebner
2026-11-17 23:50 ` [PATCH v3 1/7] spi: Allow spi_toggle_csgpiod() to get called from atomic contexts Heiko Stuebner
2026-11-17 23:50 ` [PATCH v3 2/7] spi: Allow spi_delay_exec() to be used " Heiko Stuebner
2026-11-17 23:50 ` [PATCH v3 3/7] spi: Export spi_set_cs() function Heiko Stuebner
2026-11-17 23:50 ` [PATCH v3 4/7] spi: Add infrastructure for atomic sync transfers Heiko Stuebner
2026-11-17 23:50 ` [PATCH v3 5/7] spi: rockchip: Fix runtime resume error handling Heiko Stuebner
2026-11-17 23:50 ` [PATCH v3 6/7] spi: rockchip: Move to pm_runtime_resume_and_get Heiko Stuebner
2026-11-18 1:53 ` Sebastian Reichel [this message]
2026-11-17 23:50 ` [PATCH v3 7/7] spi: rockchip: Add an atomic transfer function Heiko Stuebner
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=av0CaMF_jOyqMYA0@venus \
--to=sebastian.reichel@collabora.com \
--cc=broonie@kernel.org \
--cc=heiko.stuebner@cherry.de \
--cc=heiko@sntech.de \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=quentin.schulz@cherry.de \
/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