diff mbox series

dmaengine: dw-edma: Remove runtime PM support

Message ID 20220512083612.122824-1-manivannan.sadhasivam@linaro.org (mailing list archive)
State Not Applicable
Headers show
Series dmaengine: dw-edma: Remove runtime PM support | expand

Commit Message

Manivannan Sadhasivam May 12, 2022, 8:36 a.m. UTC
Currently, the dw-edma driver enables the runtime_pm for parent device
(chip->dev) and increments/decrements the refcount during alloc/free
chan resources callbacks.

This leads to a problem when the eDMA driver has been probed, but the
channels were not used. This scenario can happen when the DW PCIe driver
probes eDMA driver successfully, but the PCI EPF driver decides not to
use eDMA channels and use iATU instead for PCI transfers.

In this case, the underlying device would be runtime suspended due to
pm_runtime_enable() in dw_edma_probe() and the PCI EPF driver would have
no knowledge of it.

Ideally, the eDMA driver should not be the one doing the runtime PM of
the parent device. The responsibility should instead belong to the client
drivers like PCI EPF.

So let's remove the runtime PM support from eDMA driver.

Cc: Serge Semin <fancer.lancer@gmail.com>
Cc: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---

Note: This patch is made on top of Frank and Serge's edma work, but should
be applicable independently also.

[PATCH v10 0/9] Enable designware PCI EP EDMA locally
[PATCH v2 00/26] dmaengine: dw-edma: Add RP/EP local DMA controllers support

 drivers/dma/dw-edma/dw-edma-core.c | 12 ------------
 1 file changed, 12 deletions(-)

Comments

Serge Semin May 12, 2022, 11:13 a.m. UTC | #1
On Thu, May 12, 2022 at 02:06:12PM +0530, Manivannan Sadhasivam wrote:
> Currently, the dw-edma driver enables the runtime_pm for parent device
> (chip->dev) and increments/decrements the refcount during alloc/free
> chan resources callbacks.
> 
> This leads to a problem when the eDMA driver has been probed, but the
> channels were not used. This scenario can happen when the DW PCIe driver
> probes eDMA driver successfully, but the PCI EPF driver decides not to
> use eDMA channels and use iATU instead for PCI transfers.
> 
> In this case, the underlying device would be runtime suspended due to
> pm_runtime_enable() in dw_edma_probe() and the PCI EPF driver would have
> no knowledge of it.
> 
> Ideally, the eDMA driver should not be the one doing the runtime PM of
> the parent device. The responsibility should instead belong to the client
> drivers like PCI EPF.
> 
> So let's remove the runtime PM support from eDMA driver.

Right. Especially seeing the runtime PM has already been configured
for the PCIe peripheral devices in pci_pm_init(). It is relevant for the remote
eDMA setup. Meanwhile the local eDMA-enabled platforms (DW PCIe hosts
and CPU-side of the DW PCIe End-points) need to manually handle
the PM policy in the platform drivers the way it is done for instance in
drivers/pci/controller/dwc/{pci-dra7xx.c, pci-keystone.c, pcie-qcom.c,
pcie-tegra194.c}. So feel free to add:

Reviewed-by: Serge Semin <fancer.lancer@gmail.com>

> 
> Cc: Serge Semin <fancer.lancer@gmail.com>
> Cc: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
> 

> Note: This patch is made on top of Frank and Serge's edma work, but should
> be applicable independently also.
> 

To be clearer regarding what patchsets Manivannan is talking about:

> [PATCH v10 0/9] Enable designware PCI EP EDMA locally

Link: https://lore.kernel.org/linux-pci/20220503005801.1714345-1-Frank.Li@nxp.com/

> [PATCH v2 00/26] dmaengine: dw-edma: Add RP/EP local DMA controllers support

Link: https://lore.kernel.org/linux-pci/20220503225104.12108-1-Sergey.Semin@baikalelectronics.ru/

Anyway I would suggest to merge this patch on top of or before ahead
the Frank's work since my series enables the eDMA support for the
currently available platforms, which unlikely (the eDMA driver must be
explicitly enabled and the DT-part needs to be fixed) but may get some
runtime-PM conflicts denoted in the patch log.

-Sergey

> 
>  drivers/dma/dw-edma/dw-edma-core.c | 12 ------------
>  1 file changed, 12 deletions(-)
> 
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index 561686b51915..b2b5077d380b 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -9,7 +9,6 @@
>  #include <linux/module.h>
>  #include <linux/device.h>
>  #include <linux/kernel.h>
> -#include <linux/pm_runtime.h>
>  #include <linux/dmaengine.h>
>  #include <linux/err.h>
>  #include <linux/interrupt.h>
> @@ -731,15 +730,12 @@ static int dw_edma_alloc_chan_resources(struct dma_chan *dchan)
>  		dchan->dev->chan_dma_dev = false;
>  	}
>  
> -	pm_runtime_get(chan->dw->chip->dev);
> -
>  	return 0;
>  }
>  
>  static void dw_edma_free_chan_resources(struct dma_chan *dchan)
>  {
>  	unsigned long timeout = jiffies + msecs_to_jiffies(5000);
> -	struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan);
>  	int ret;
>  
>  	while (time_before(jiffies, timeout)) {
> @@ -752,8 +748,6 @@ static void dw_edma_free_chan_resources(struct dma_chan *dchan)
>  
>  		cpu_relax();
>  	}
> -
> -	pm_runtime_put(chan->dw->chip->dev);
>  }
>  
>  static int dw_edma_channel_setup(struct dw_edma *dw, u32 wr_alloc, u32 rd_alloc)
> @@ -1010,9 +1004,6 @@ int dw_edma_probe(struct dw_edma_chip *chip)
>  	if (err)
>  		goto err_irq_free;
>  
> -	/* Power management */
> -	pm_runtime_enable(dev);
> -
>  	/* Turn debugfs on */
>  	dw_edma_v0_core_debugfs_on(dw);
>  
> @@ -1046,9 +1037,6 @@ int dw_edma_remove(struct dw_edma_chip *chip)
>  	for (i = (dw->nr_irqs - 1); i >= 0; i--)
>  		free_irq(chip->ops->irq_vector(dev, i), &dw->irq[i]);
>  
> -	/* Power management */
> -	pm_runtime_disable(dev);
> -
>  	/* Deregister eDMA device */
>  	dma_async_device_unregister(&dw->dma);
>  	list_for_each_entry_safe(chan, _chan, &dw->dma.channels,
> -- 
> 2.25.1
>
Manivannan Sadhasivam Aug. 19, 2022, 8:40 a.m. UTC | #2
On Thu, May 12, 2022 at 02:06:12PM +0530, Manivannan Sadhasivam wrote:
> Currently, the dw-edma driver enables the runtime_pm for parent device
> (chip->dev) and increments/decrements the refcount during alloc/free
> chan resources callbacks.
> 
> This leads to a problem when the eDMA driver has been probed, but the
> channels were not used. This scenario can happen when the DW PCIe driver
> probes eDMA driver successfully, but the PCI EPF driver decides not to
> use eDMA channels and use iATU instead for PCI transfers.
> 
> In this case, the underlying device would be runtime suspended due to
> pm_runtime_enable() in dw_edma_probe() and the PCI EPF driver would have
> no knowledge of it.
> 
> Ideally, the eDMA driver should not be the one doing the runtime PM of
> the parent device. The responsibility should instead belong to the client
> drivers like PCI EPF.
> 
> So let's remove the runtime PM support from eDMA driver.
> 
> Cc: Serge Semin <fancer.lancer@gmail.com>
> Cc: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Looks like this one missed 6.0. Vinod, can you please merge this now?

Thanks,
Mani

> ---
> 
> Note: This patch is made on top of Frank and Serge's edma work, but should
> be applicable independently also.
> 
> [PATCH v10 0/9] Enable designware PCI EP EDMA locally
> [PATCH v2 00/26] dmaengine: dw-edma: Add RP/EP local DMA controllers support
> 
>  drivers/dma/dw-edma/dw-edma-core.c | 12 ------------
>  1 file changed, 12 deletions(-)
> 
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index 561686b51915..b2b5077d380b 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -9,7 +9,6 @@
>  #include <linux/module.h>
>  #include <linux/device.h>
>  #include <linux/kernel.h>
> -#include <linux/pm_runtime.h>
>  #include <linux/dmaengine.h>
>  #include <linux/err.h>
>  #include <linux/interrupt.h>
> @@ -731,15 +730,12 @@ static int dw_edma_alloc_chan_resources(struct dma_chan *dchan)
>  		dchan->dev->chan_dma_dev = false;
>  	}
>  
> -	pm_runtime_get(chan->dw->chip->dev);
> -
>  	return 0;
>  }
>  
>  static void dw_edma_free_chan_resources(struct dma_chan *dchan)
>  {
>  	unsigned long timeout = jiffies + msecs_to_jiffies(5000);
> -	struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan);
>  	int ret;
>  
>  	while (time_before(jiffies, timeout)) {
> @@ -752,8 +748,6 @@ static void dw_edma_free_chan_resources(struct dma_chan *dchan)
>  
>  		cpu_relax();
>  	}
> -
> -	pm_runtime_put(chan->dw->chip->dev);
>  }
>  
>  static int dw_edma_channel_setup(struct dw_edma *dw, u32 wr_alloc, u32 rd_alloc)
> @@ -1010,9 +1004,6 @@ int dw_edma_probe(struct dw_edma_chip *chip)
>  	if (err)
>  		goto err_irq_free;
>  
> -	/* Power management */
> -	pm_runtime_enable(dev);
> -
>  	/* Turn debugfs on */
>  	dw_edma_v0_core_debugfs_on(dw);
>  
> @@ -1046,9 +1037,6 @@ int dw_edma_remove(struct dw_edma_chip *chip)
>  	for (i = (dw->nr_irqs - 1); i >= 0; i--)
>  		free_irq(chip->ops->irq_vector(dev, i), &dw->irq[i]);
>  
> -	/* Power management */
> -	pm_runtime_disable(dev);
> -
>  	/* Deregister eDMA device */
>  	dma_async_device_unregister(&dw->dma);
>  	list_for_each_entry_safe(chan, _chan, &dw->dma.channels,
> -- 
> 2.25.1
>
Vinod Koul Sept. 4, 2022, 5:21 p.m. UTC | #3
On 19-08-22, 14:10, Manivannan Sadhasivam wrote:
> On Thu, May 12, 2022 at 02:06:12PM +0530, Manivannan Sadhasivam wrote:
> > Currently, the dw-edma driver enables the runtime_pm for parent device
> > (chip->dev) and increments/decrements the refcount during alloc/free
> > chan resources callbacks.
> > 
> > This leads to a problem when the eDMA driver has been probed, but the
> > channels were not used. This scenario can happen when the DW PCIe driver
> > probes eDMA driver successfully, but the PCI EPF driver decides not to
> > use eDMA channels and use iATU instead for PCI transfers.
> > 
> > In this case, the underlying device would be runtime suspended due to
> > pm_runtime_enable() in dw_edma_probe() and the PCI EPF driver would have
> > no knowledge of it.
> > 
> > Ideally, the eDMA driver should not be the one doing the runtime PM of
> > the parent device. The responsibility should instead belong to the client
> > drivers like PCI EPF.
> > 
> > So let's remove the runtime PM support from eDMA driver.
> > 
> > Cc: Serge Semin <fancer.lancer@gmail.com>
> > Cc: Frank Li <Frank.Li@nxp.com>
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> 
> Looks like this one missed 6.0. Vinod, can you please merge this now?

This fails for me, can you pls rebase and resend
diff mbox series

Patch

diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
index 561686b51915..b2b5077d380b 100644
--- a/drivers/dma/dw-edma/dw-edma-core.c
+++ b/drivers/dma/dw-edma/dw-edma-core.c
@@ -9,7 +9,6 @@ 
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
-#include <linux/pm_runtime.h>
 #include <linux/dmaengine.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
@@ -731,15 +730,12 @@  static int dw_edma_alloc_chan_resources(struct dma_chan *dchan)
 		dchan->dev->chan_dma_dev = false;
 	}
 
-	pm_runtime_get(chan->dw->chip->dev);
-
 	return 0;
 }
 
 static void dw_edma_free_chan_resources(struct dma_chan *dchan)
 {
 	unsigned long timeout = jiffies + msecs_to_jiffies(5000);
-	struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan);
 	int ret;
 
 	while (time_before(jiffies, timeout)) {
@@ -752,8 +748,6 @@  static void dw_edma_free_chan_resources(struct dma_chan *dchan)
 
 		cpu_relax();
 	}
-
-	pm_runtime_put(chan->dw->chip->dev);
 }
 
 static int dw_edma_channel_setup(struct dw_edma *dw, u32 wr_alloc, u32 rd_alloc)
@@ -1010,9 +1004,6 @@  int dw_edma_probe(struct dw_edma_chip *chip)
 	if (err)
 		goto err_irq_free;
 
-	/* Power management */
-	pm_runtime_enable(dev);
-
 	/* Turn debugfs on */
 	dw_edma_v0_core_debugfs_on(dw);
 
@@ -1046,9 +1037,6 @@  int dw_edma_remove(struct dw_edma_chip *chip)
 	for (i = (dw->nr_irqs - 1); i >= 0; i--)
 		free_irq(chip->ops->irq_vector(dev, i), &dw->irq[i]);
 
-	/* Power management */
-	pm_runtime_disable(dev);
-
 	/* Deregister eDMA device */
 	dma_async_device_unregister(&dw->dma);
 	list_for_each_entry_safe(chan, _chan, &dw->dma.channels,