diff mbox

[v2] dma: dw: Add suspend and resume handling for PCI mode DW_DMAC.

Message ID 1394820159-562-1-git-send-email-chiau.ee.chew@intel.com (mailing list archive)
State Accepted
Commit 4501fe61b286
Delegated to: Vinod Koul
Headers show

Commit Message

Chew Chiau Ee March 14, 2014, 6:02 p.m. UTC
From: Chew, Chiau Ee <chiau.ee.chew@intel.com>

This is to disable/enable DW_DMAC hw during late suspend/early resume.
Since DMA is providing service to other clients (eg: SPI, HSUART),
we need to ensure DMA suspends after the clients and resume
before the clients are active.

Signed-off-by: Chew, Chiau Ee <chiau.ee.chew@intel.com>
---
 v2 changelog:
 * Change suspend_noirq and resume_noirq callback to suspend_late
   and resume_early.

 drivers/dma/dw/pci.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

Comments

Andy Shevchenko March 14, 2014, 11:28 a.m. UTC | #1
On Sat, 2014-03-15 at 02:02 +0800, Chew Chiau Ee wrote:
> From: Chew, Chiau Ee <chiau.ee.chew@intel.com>
> 
> This is to disable/enable DW_DMAC hw during late suspend/early resume.
> Since DMA is providing service to other clients (eg: SPI, HSUART),
> we need to ensure DMA suspends after the clients and resume
> before the clients are active.

Thanks for an update!

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

P.S. It seems a material is for v3.16?

> 
> Signed-off-by: Chew, Chiau Ee <chiau.ee.chew@intel.com>
> ---
>  v2 changelog:
>  * Change suspend_noirq and resume_noirq callback to suspend_late
>    and resume_early.
> 
>  drivers/dma/dw/pci.c |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/dma/dw/pci.c b/drivers/dma/dw/pci.c
> index 755cc6b..fec59f1 100644
> --- a/drivers/dma/dw/pci.c
> +++ b/drivers/dma/dw/pci.c
> @@ -75,6 +75,36 @@ static void dw_pci_remove(struct pci_dev *pdev)
>  		dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +
> +static int dw_pci_suspend_late(struct device *dev)
> +{
> +	struct pci_dev *pci = to_pci_dev(dev);
> +	struct dw_dma_chip *chip = pci_get_drvdata(pci);
> +
> +	return dw_dma_suspend(chip);
> +};
> +
> +static int dw_pci_resume_early(struct device *dev)
> +{
> +	struct pci_dev *pci = to_pci_dev(dev);
> +	struct dw_dma_chip *chip = pci_get_drvdata(pci);
> +
> +	return dw_dma_resume(chip);
> +};
> +
> +#else /* !CONFIG_PM_SLEEP */
> +
> +#define dw_pci_suspend_late	NULL
> +#define dw_pci_resume_early	NULL
> +
> +#endif /* !CONFIG_PM_SLEEP */
> +
> +static const struct dev_pm_ops dw_pci_dev_pm_ops = {
> +	.suspend_late = dw_pci_suspend_late,
> +	.resume_early = dw_pci_resume_early,
> +};
> +
>  static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
>  	/* Medfield */
>  	{ PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata },
> @@ -95,6 +125,9 @@ static struct pci_driver dw_pci_driver = {
>  	.id_table	= dw_pci_id_table,
>  	.probe		= dw_pci_probe,
>  	.remove		= dw_pci_remove,
> +	.driver	= {
> +		.pm	= &dw_pci_dev_pm_ops,
> +	},
>  };
>  
>  module_pci_driver(dw_pci_driver);
Viresh Kumar March 14, 2014, 5:21 p.m. UTC | #2
On Fri, Mar 14, 2014 at 4:58 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Sat, 2014-03-15 at 02:02 +0800, Chew Chiau Ee wrote:
>> From: Chew, Chiau Ee <chiau.ee.chew@intel.com>
>>
>> This is to disable/enable DW_DMAC hw during late suspend/early resume.
>> Since DMA is providing service to other clients (eg: SPI, HSUART),
>> we need to ensure DMA suspends after the clients and resume
>> before the clients are active.
>
> Thanks for an update!
>
> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

> P.S. It seems a material is for v3.16?

I think it can go in 3.15 as well.. we aren't that late yet.
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vinod Koul March 26, 2014, 6:23 a.m. UTC | #3
On Sat, Mar 15, 2014 at 02:02:39AM +0800, Chew Chiau Ee wrote:
> From: Chew, Chiau Ee <chiau.ee.chew@intel.com>
> 
> This is to disable/enable DW_DMAC hw during late suspend/early resume.
> Since DMA is providing service to other clients (eg: SPI, HSUART),
> we need to ensure DMA suspends after the clients and resume
> before the clients are active.
> 
> Signed-off-by: Chew, Chiau Ee <chiau.ee.chew@intel.com>

Rather than bunch of ifdef, would make sense to provde a mcros in dmaengine core
to do so as we expect all dmaengine drivers to be late probe

Applied thanks
diff mbox

Patch

diff --git a/drivers/dma/dw/pci.c b/drivers/dma/dw/pci.c
index 755cc6b..fec59f1 100644
--- a/drivers/dma/dw/pci.c
+++ b/drivers/dma/dw/pci.c
@@ -75,6 +75,36 @@  static void dw_pci_remove(struct pci_dev *pdev)
 		dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
 }
 
+#ifdef CONFIG_PM_SLEEP
+
+static int dw_pci_suspend_late(struct device *dev)
+{
+	struct pci_dev *pci = to_pci_dev(dev);
+	struct dw_dma_chip *chip = pci_get_drvdata(pci);
+
+	return dw_dma_suspend(chip);
+};
+
+static int dw_pci_resume_early(struct device *dev)
+{
+	struct pci_dev *pci = to_pci_dev(dev);
+	struct dw_dma_chip *chip = pci_get_drvdata(pci);
+
+	return dw_dma_resume(chip);
+};
+
+#else /* !CONFIG_PM_SLEEP */
+
+#define dw_pci_suspend_late	NULL
+#define dw_pci_resume_early	NULL
+
+#endif /* !CONFIG_PM_SLEEP */
+
+static const struct dev_pm_ops dw_pci_dev_pm_ops = {
+	.suspend_late = dw_pci_suspend_late,
+	.resume_early = dw_pci_resume_early,
+};
+
 static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
 	/* Medfield */
 	{ PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata },
@@ -95,6 +125,9 @@  static struct pci_driver dw_pci_driver = {
 	.id_table	= dw_pci_id_table,
 	.probe		= dw_pci_probe,
 	.remove		= dw_pci_remove,
+	.driver	= {
+		.pm	= &dw_pci_dev_pm_ops,
+	},
 };
 
 module_pci_driver(dw_pci_driver);