[1/3] spi: dw: Move runtime PM enable/disable from common to platform driver part
diff mbox series

Message ID 20191018132131.31608-1-jarkko.nikula@linux.intel.com
State Accepted
Headers show
Series
  • [1/3] spi: dw: Move runtime PM enable/disable from common to platform driver part
Related show

Commit Message

Jarkko Nikula Oct. 18, 2019, 1:21 p.m. UTC
After commit 1e6959832510 ("spi: dw: Add basic runtime PM support")
there is following warning from PCI enumerated DesignWare SPI controller
during probe:

	dw_spi_pci 0000:00:13.0: Unbalanced pm_runtime_enable!

Runtime PM is already enabled for PCI devices by the PCI core and doing
it again in common DW SPI code leads to unbalanced enable calls.

Fix this by moving the runtime PM enable/disable calls to the platform
driver part of the driver.

Cc: Phil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
 drivers/spi/spi-dw-mmio.c | 5 +++++
 drivers/spi/spi-dw.c      | 7 -------
 2 files changed, 5 insertions(+), 7 deletions(-)

Comments

Andy Shevchenko Oct. 22, 2019, 8:32 a.m. UTC | #1
On Sat, Oct 19, 2019 at 11:26 AM Jarkko Nikula
<jarkko.nikula@linux.intel.com> wrote:
>
> After commit 1e6959832510 ("spi: dw: Add basic runtime PM support")
> there is following warning from PCI enumerated DesignWare SPI controller
> during probe:
>
>         dw_spi_pci 0000:00:13.0: Unbalanced pm_runtime_enable!
>
> Runtime PM is already enabled for PCI devices by the PCI core and doing
> it again in common DW SPI code leads to unbalanced enable calls.
>
> Fix this by moving the runtime PM enable/disable calls to the platform
> driver part of the driver.
>

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> ---
>  drivers/spi/spi-dw-mmio.c | 5 +++++
>  drivers/spi/spi-dw.c      | 7 -------
>  2 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
> index b5ce8bd58d9e..384a3ab6dc2d 100644
> --- a/drivers/spi/spi-dw-mmio.c
> +++ b/drivers/spi/spi-dw-mmio.c
> @@ -9,6 +9,7 @@
>  #include <linux/err.h>
>  #include <linux/interrupt.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>  #include <linux/slab.h>
>  #include <linux/spi/spi.h>
>  #include <linux/scatterlist.h>
> @@ -193,6 +194,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
>                         goto out;
>         }
>
> +       pm_runtime_enable(&pdev->dev);
> +
>         ret = dw_spi_add_host(&pdev->dev, dws);
>         if (ret)
>                 goto out;
> @@ -201,6 +204,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
>         return 0;
>
>  out:
> +       pm_runtime_disable(&pdev->dev);
>         clk_disable_unprepare(dwsmmio->pclk);
>  out_clk:
>         clk_disable_unprepare(dwsmmio->clk);
> @@ -212,6 +216,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
>         struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
>
>         dw_spi_remove_host(&dwsmmio->dws);
> +       pm_runtime_disable(&pdev->dev);
>         clk_disable_unprepare(dwsmmio->pclk);
>         clk_disable_unprepare(dwsmmio->clk);
>
> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> index 54ed6eb3e252..466f5c67843b 100644
> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -10,7 +10,6 @@
>  #include <linux/module.h>
>  #include <linux/highmem.h>
>  #include <linux/delay.h>
> -#include <linux/pm_runtime.h>
>  #include <linux/slab.h>
>  #include <linux/spi/spi.h>
>
> @@ -499,8 +498,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
>         if (dws->set_cs)
>                 master->set_cs = dws->set_cs;
>
> -       pm_runtime_enable(dev);
> -
>         /* Basic HW init */
>         spi_hw_init(dev, dws);
>
> @@ -529,7 +526,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
>         spi_enable_chip(dws, 0);
>         free_irq(dws->irq, master);
>  err_free_master:
> -       pm_runtime_disable(dev);
>         spi_controller_put(master);
>         return ret;
>  }
> @@ -544,9 +540,6 @@ void dw_spi_remove_host(struct dw_spi *dws)
>
>         spi_shutdown_chip(dws);
>
> -       if (dws->master)
> -               pm_runtime_disable(&dws->master->dev);
> -
>         free_irq(dws->irq, dws->master);
>  }
>  EXPORT_SYMBOL_GPL(dw_spi_remove_host);
> --
> 2.23.0
>

Patch
diff mbox series

diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index b5ce8bd58d9e..384a3ab6dc2d 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -9,6 +9,7 @@ 
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/spi/spi.h>
 #include <linux/scatterlist.h>
@@ -193,6 +194,8 @@  static int dw_spi_mmio_probe(struct platform_device *pdev)
 			goto out;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+
 	ret = dw_spi_add_host(&pdev->dev, dws);
 	if (ret)
 		goto out;
@@ -201,6 +204,7 @@  static int dw_spi_mmio_probe(struct platform_device *pdev)
 	return 0;
 
 out:
+	pm_runtime_disable(&pdev->dev);
 	clk_disable_unprepare(dwsmmio->pclk);
 out_clk:
 	clk_disable_unprepare(dwsmmio->clk);
@@ -212,6 +216,7 @@  static int dw_spi_mmio_remove(struct platform_device *pdev)
 	struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
 
 	dw_spi_remove_host(&dwsmmio->dws);
+	pm_runtime_disable(&pdev->dev);
 	clk_disable_unprepare(dwsmmio->pclk);
 	clk_disable_unprepare(dwsmmio->clk);
 
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 54ed6eb3e252..466f5c67843b 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -10,7 +10,6 @@ 
 #include <linux/module.h>
 #include <linux/highmem.h>
 #include <linux/delay.h>
-#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/spi/spi.h>
 
@@ -499,8 +498,6 @@  int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 	if (dws->set_cs)
 		master->set_cs = dws->set_cs;
 
-	pm_runtime_enable(dev);
-
 	/* Basic HW init */
 	spi_hw_init(dev, dws);
 
@@ -529,7 +526,6 @@  int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 	spi_enable_chip(dws, 0);
 	free_irq(dws->irq, master);
 err_free_master:
-	pm_runtime_disable(dev);
 	spi_controller_put(master);
 	return ret;
 }
@@ -544,9 +540,6 @@  void dw_spi_remove_host(struct dw_spi *dws)
 
 	spi_shutdown_chip(dws);
 
-	if (dws->master)
-		pm_runtime_disable(&dws->master->dev);
-
 	free_irq(dws->irq, dws->master);
 }
 EXPORT_SYMBOL_GPL(dw_spi_remove_host);