mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] spi: balance remove-path teardown in three drivers
@ 2026-09-24 11:23 Guangshuo Li
  2026-09-24 11:23 ` [PATCH 1/3] spi: fsl: unmap immr_spi_cs on remove Guangshuo Li
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-09-24 11:23 UTC (permalink / raw)
  To: broonie, heiko, william.zhang, kursad.oney, jonas.gorski
  Cc: linux-spi, linux-kernel, linusw, linux-arm-kernel,
	linux-rockchip, jon.lin, bcm-kernel-feedback-list, noltari,
	lgs201920130244

Several SPI drivers establish resources or runtime-PM state during probe
but do not perform the matching teardown after successful removal.

Add the missing unmap or runtime-PM cleanup in each driver's remove path,
following the cleanup already used by its probe error paths.

Guangshuo Li (3):
  spi: fsl: unmap immr_spi_cs on remove
  spi: rockchip-sfc: Clean up runtime PM on remove
  spi: bcm63xx-hsspi: Disable runtime PM on remove

 drivers/spi/spi-bcm63xx-hsspi.c | 1 +
 drivers/spi/spi-fsl-spi.c       | 8 ++++++++
 drivers/spi/spi-rockchip-sfc.c  | 6 ++++++
 3 files changed, 15 insertions(+)


base-commit: f03c39de3a1307371a4032757cd1732e91087c7d
-- 
2.43.0


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

* [PATCH 1/3] spi: fsl: unmap immr_spi_cs on remove
  2026-09-24 11:23 [PATCH 0/3] spi: balance remove-path teardown in three drivers Guangshuo Li
@ 2026-09-24 11:23 ` Guangshuo Li
  2026-09-24 11:23 ` [PATCH 2/3] spi: rockchip-sfc: Clean up runtime PM " Guangshuo Li
  2026-09-24 11:23 ` [PATCH 3/3] spi: bcm63xx-hsspi: Disable " Guangshuo Li
  2 siblings, 0 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-09-24 11:23 UTC (permalink / raw)
  To: broonie, heiko, william.zhang, kursad.oney, jonas.gorski
  Cc: linux-spi, linux-kernel, linusw, linux-arm-kernel,
	linux-rockchip, jon.lin, bcm-kernel-feedback-list, noltari,
	lgs201920130244

of_fsl_spi_remove() does not unmap pinfo->immr_spi_cs after a
successful probe when CONFIG_FSL_SOC is enabled and fsl,spisel_boot
causes of_fsl_spi_probe() to map it with ioremap(). The probe error
path already performs the matching iounmap().

Retrieve pinfo from the platform data and call iounmap() when
pinfo->immr_spi_cs is present, pairing normal removal with the mapping
established by of_fsl_spi_probe().

Fixes: 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/spi/spi-fsl-spi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index e45816ef7b65..665902703973 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -702,10 +702,18 @@ static void of_fsl_spi_remove(struct platform_device *ofdev)
 {
 	struct spi_controller *host = platform_get_drvdata(ofdev);
 	struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(host);
+#if IS_ENABLED(CONFIG_FSL_SOC)
+	struct fsl_spi_platform_data *pdata = dev_get_platdata(&ofdev->dev);
+	struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
+#endif
 
 	spi_unregister_controller(host);
 
 	fsl_spi_cpm_free(mpc8xxx_spi);
+#if IS_ENABLED(CONFIG_FSL_SOC)
+	if (pinfo->immr_spi_cs)
+		iounmap(pinfo->immr_spi_cs);
+#endif
 }
 
 static struct platform_driver of_fsl_spi_driver = {
-- 
2.43.0


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

* [PATCH 2/3] spi: rockchip-sfc: Clean up runtime PM on remove
  2026-09-24 11:23 [PATCH 0/3] spi: balance remove-path teardown in three drivers Guangshuo Li
  2026-09-24 11:23 ` [PATCH 1/3] spi: fsl: unmap immr_spi_cs on remove Guangshuo Li
@ 2026-09-24 11:23 ` Guangshuo Li
  2026-09-29  2:21   ` Shawn Lin
  2026-09-24 11:23 ` [PATCH 3/3] spi: bcm63xx-hsspi: Disable " Guangshuo Li
  2 siblings, 1 reply; 5+ messages in thread
From: Guangshuo Li @ 2026-09-24 11:23 UTC (permalink / raw)
  To: broonie, heiko, william.zhang, kursad.oney, jonas.gorski
  Cc: linux-spi, linux-kernel, linusw, linux-arm-kernel,
	linux-rockchip, jon.lin, bcm-kernel-feedback-list, noltari,
	lgs201920130244

rockchip_sfc_probe() enables runtime PM and autosuspend before registering
the controller. After a successful probe, rockchip_sfc_remove() tears down
the controller and clocks without undoing that runtime PM setup.

The probe error path resumes the device, drops the temporary usage count,
disables runtime PM, marks the device suspended, and stops using
autosuspend before disabling the clocks. The remove path lacks this
matching cleanup.

Mirror the existing error-path sequence in rockchip_sfc_remove() before
disabling the clocks.

Fixes: 8011709906d0 ("spi: rockchip-sfc: Support pm ops")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/spi/spi-rockchip-sfc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/spi/spi-rockchip-sfc.c b/drivers/spi/spi-rockchip-sfc.c
index 662a994da60b..6e1c7d6318bb 100644
--- a/drivers/spi/spi-rockchip-sfc.c
+++ b/drivers/spi/spi-rockchip-sfc.c
@@ -747,6 +747,12 @@ static void rockchip_sfc_remove(struct platform_device *pdev)
 			 DMA_BIDIRECTIONAL);
 	free_pages((unsigned long)sfc->buffer, get_order(sfc->max_iosize));
 
+	pm_runtime_get_sync(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
+	pm_runtime_set_suspended(&pdev->dev);
+	pm_runtime_dont_use_autosuspend(&pdev->dev);
+
 	clk_disable_unprepare(sfc->clk);
 	clk_disable_unprepare(sfc->hclk);
 }
-- 
2.43.0


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

* [PATCH 3/3] spi: bcm63xx-hsspi: Disable runtime PM on remove
  2026-09-24 11:23 [PATCH 0/3] spi: balance remove-path teardown in three drivers Guangshuo Li
  2026-09-24 11:23 ` [PATCH 1/3] spi: fsl: unmap immr_spi_cs on remove Guangshuo Li
  2026-09-24 11:23 ` [PATCH 2/3] spi: rockchip-sfc: Clean up runtime PM " Guangshuo Li
@ 2026-09-24 11:23 ` Guangshuo Li
  2 siblings, 0 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-09-24 11:23 UTC (permalink / raw)
  To: broonie, heiko, william.zhang, kursad.oney, jonas.gorski
  Cc: linux-spi, linux-kernel, linusw, linux-arm-kernel,
	linux-rockchip, jon.lin, bcm-kernel-feedback-list, noltari,
	lgs201920130244

bcm63xx_hsspi_probe() enables runtime PM before creating the sysfs
 group, but bcm63xx_hsspi_remove() does not perform the matching
pm_runtime_disable() after a successful probe.

The probe error paths already disable runtime PM when sysfs group
creation or controller registration fails.

Add pm_runtime_disable() to the remove path after removing the sysfs
group to balance pm_runtime_enable() from bcm63xx_hsspi_probe().

Fixes: fb8695e3749e ("spi: bcm63xx-hsspi: fix pm_runtime")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/spi/spi-bcm63xx-hsspi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c
index 25f169a2a81d..80bf02bc324a 100644
--- a/drivers/spi/spi-bcm63xx-hsspi.c
+++ b/drivers/spi/spi-bcm63xx-hsspi.c
@@ -882,6 +882,7 @@ static void bcm63xx_hsspi_remove(struct platform_device *pdev)
 	/* reset the hardware and block queue progress */
 	__raw_writel(0, bs->regs + HSSPI_INT_MASK_REG);
 	sysfs_remove_group(&pdev->dev.kobj, &bcm63xx_hsspi_group);
+	pm_runtime_disable(&pdev->dev);
 }
 
 static int bcm63xx_hsspi_suspend(struct device *dev)
-- 
2.43.0


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

* Re: [PATCH 2/3] spi: rockchip-sfc: Clean up runtime PM on remove
  2026-09-24 11:23 ` [PATCH 2/3] spi: rockchip-sfc: Clean up runtime PM " Guangshuo Li
@ 2026-09-29  2:21   ` Shawn Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Shawn Lin @ 2026-09-29  2:21 UTC (permalink / raw)
  To: Guangshuo Li, broonie, heiko, william.zhang, kursad.oney, jonas.gorski
  Cc: shawn.lin, linux-spi, linux-kernel, linusw, linux-arm-kernel,
	linux-rockchip, jon.lin, bcm-kernel-feedback-list, noltari

Hi Guangshuo

在 2026/09/24 星期四 19:23, Guangshuo Li 写道:
> rockchip_sfc_probe() enables runtime PM and autosuspend before registering
> the controller. After a successful probe, rockchip_sfc_remove() tears down
> the controller and clocks without undoing that runtime PM setup.
> 
> The probe error path resumes the device, drops the temporary usage count,
> disables runtime PM, marks the device suspended, and stops using
> autosuspend before disabling the clocks. The remove path lacks this
> matching cleanup.
> 
> Mirror the existing error-path sequence in rockchip_sfc_remove() before
> disabling the clocks.
> 

Thanks for this patch. However, it was fixed, see:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=34e32e9ade58e32daf933974c9b697d066fc5aaa

> Fixes: 8011709906d0 ("spi: rockchip-sfc: Support pm ops")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>   drivers/spi/spi-rockchip-sfc.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/spi/spi-rockchip-sfc.c b/drivers/spi/spi-rockchip-sfc.c
> index 662a994da60b..6e1c7d6318bb 100644
> --- a/drivers/spi/spi-rockchip-sfc.c
> +++ b/drivers/spi/spi-rockchip-sfc.c
> @@ -747,6 +747,12 @@ static void rockchip_sfc_remove(struct platform_device *pdev)
>   			 DMA_BIDIRECTIONAL);
>   	free_pages((unsigned long)sfc->buffer, get_order(sfc->max_iosize));
>   
> +	pm_runtime_get_sync(&pdev->dev);
> +	pm_runtime_put_noidle(&pdev->dev);
> +	pm_runtime_disable(&pdev->dev);
> +	pm_runtime_set_suspended(&pdev->dev);
> +	pm_runtime_dont_use_autosuspend(&pdev->dev);
> +
>   	clk_disable_unprepare(sfc->clk);
>   	clk_disable_unprepare(sfc->hclk);
>   }


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

end of thread, other threads:[~2026-09-29  2:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 11:23 [PATCH 0/3] spi: balance remove-path teardown in three drivers Guangshuo Li
2026-09-24 11:23 ` [PATCH 1/3] spi: fsl: unmap immr_spi_cs on remove Guangshuo Li
2026-09-24 11:23 ` [PATCH 2/3] spi: rockchip-sfc: Clean up runtime PM " Guangshuo Li
2026-09-29  2:21   ` Shawn Lin
2026-09-24 11:23 ` [PATCH 3/3] spi: bcm63xx-hsspi: Disable " Guangshuo Li

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

all inboxes | Powered by JetHome®