dma: dw: Add suspend and resume handling for PCI mode DW_DMAC.
Subsystems (2)
PATCH 1/1 dma: dw: Add suspend and resume handling for PCI mode DW_DMAC.
From: Chew, Chiau Ee <[email protected]>
This is to disable/enable DW_DMAC hw during suspend/resume.
--- drivers/dma/dw/pci.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)
drivers/dma/dw/pci.c +33 -0
@@ -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_noirq (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_noirq (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_noirq NULL +#define dw_pci_resume_noirq NULL + +#endif /* !CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops dw_pci_dev_pm_ops = { + .suspend_noirq = dw_pci_suspend_noirq, + .resume_noirq = dw_pci_resume_noirq, +}; +static DEFINE_PCI_DEVICE_TABLE (dw_pci_id_table) = {/* Medfield */ {PCI_VDEVICE (INTEL ,0x0827 ), (kernel_ulong_t)&dw_pci_pdata },
@@ -92,6 +122,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);
Signature · 1 line
1.7.4.4
Quoted 32 lines · Chew Chiau Ee
From: Chew, Chiau Ee <[email protected]>
This is to disable/enable
DW_DMAChw during suspend/resume.Signed-off-by Chew, Chiau Ee <[email protected]>Acked-by Andy Shevchenko <[email protected]>--- drivers/dma/dw/pci.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)drivers/dma/dw/pci.c +14
-0@@ -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_noirq (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_noirq (struct device *dev) +{ +struct pci_dev *pci =to_pci_dev (dev); +struct dw_dma_chip *chip =pci_get_drvdata (pci);
drivers/dma/dw/pci.c static void dw_pci_remove(struct pci_dev *pdev) · line 101
Quoted 10 lines
drivers/dma/dw/pci.c +10
-0+ + return dw_dma_resume(chip); +}; + +#else /* !CONFIG_PM_SLEEP */ + +#define dw_pci_suspend_noirq NULL +#define dw_pci_resume_noirq NULL + +#endif /* !CONFIG_PM_SLEEP */
How about SET_SYSTEM_SLEEP_PM_OPS instead?
--
~Vinod
Quoted 22 lines
drivers/dma/dw/pci.c +9
-0+ +static const struct dev_pm_ops dw_pci_dev_pm_ops = { + .suspend_noirq = dw_pci_suspend_noirq, + .resume_noirq = dw_pci_resume_noirq, +}; +static DEFINE_PCI_DEVICE_TABLE (dw_pci_id_table) = {/* Medfield */ {PCI_VDEVICE (INTEL ,0x0827 ), (kernel_ulong_t)&dw_pci_pdata },@@ -92,6 +122,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);Signature · 1 line
1.7.4.4
Quoted 36 lines · Vinod Koul
Quoted 35 lines · Chew Chiau Ee
From: Chew, Chiau Ee <[email protected]>
This is to disable/enable
DW_DMAChw during suspend/resume.Signed-off-by Chew, Chiau Ee <[email protected]>Acked-by Andy Shevchenko <[email protected]>--- drivers/dma/dw/pci.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)drivers/dma/dw/pci.c +17
-0@@ -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_noirq (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_noirq (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); +};
Quoted 8 lines
drivers/dma/dw/pci.c static void dw_pci_remove(struct pci_dev *pdev) · line 101
Quoted 7 lines
drivers/dma/dw/pci.c +7
-0+ +#else /* !CONFIG_PM_SLEEP */ + +#define dw_pci_suspend_noirq NULL +#define dw_pci_resume_noirq NULL + +#endif /* !CONFIG_PM_SLEEP */ How about
SET_SYSTEM_SLEEP_PM_OPSinstead?
So, we are using *_noirq versions of the functions here. What happened when we switch to normal ones? Any side effects?
Quoted 26 lines
--
~VinodQuoted 22 lines
drivers/dma/dw/pci.c +9
-0+ +static const struct dev_pm_ops dw_pci_dev_pm_ops = { + .suspend_noirq = dw_pci_suspend_noirq, + .resume_noirq = dw_pci_resume_noirq, +}; +static DEFINE_PCI_DEVICE_TABLE (dw_pci_id_table) = {/* Medfield */ {PCI_VDEVICE (INTEL ,0x0827 ), (kernel_ulong_t)&dw_pci_pdata },@@ -92,6 +122,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);Signature · 1 line
1.7.4.4
Signature · 13 lines
Andy Shevchenko <[email protected]> Intel Finland Oy --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Vinod,
As mentioned by Andy, we are using *_noirq verion of suspend/resume PM callback whereby the callbacks would be executed after IRQ handlers have been disabled. If using SET_SYSTEM_SLEEP_PM_OPS, it would be the normal suspend/resume PM callback. Looking at the Desginware DMAC platform code (drivers/dma/dw/platform.c), it is using the *_noirq suspend/resume PM callback. Is it advisable to use the normal suspend/resume PM callback instead of *_noirq suspend/PM callback?
Thanks,
Chiau Ee
-----Original Message-----
From: Shevchenko, Andriy
Sent: Tuesday, December 10, 2013 7:57 PM
To: Koul, Vinod
Cc: Chew, Chiau Ee; Viresh Kumar; Andy Shevchenko; Williams, Dan J; [email protected]; [email protected]
Subject: Re: [PATCH] dma: dw: Add suspend and resume handling for PCI mode DW_DMAC.
Quoted 34 lines · Vinod Koul
Quoted 33 lines · Chew Chiau Ee
From: Chew, Chiau Ee <[email protected]>
This is to disable/enable
DW_DMAChw during suspend/resume.Signed-off-by Chew, Chiau Ee <[email protected]>Acked-by Andy Shevchenko <[email protected]>--- drivers/dma/dw/pci.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)drivers/dma/dw/pci.c index renamed from drivers/dma/dw/pci.c +0
-0e89fc24..97bc3a2 100644
drivers/dma/dw/pci.c +15
-0@@ -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_noirq (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_noirq (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); +};
Quoted 8 lines
drivers/dma/dw/pci.c static void dw_pci_remove(struct pci_dev *pdev) · line 101
Quoted 7 lines
drivers/dma/dw/pci.c +7
-0+ +#else /* !CONFIG_PM_SLEEP */ + +#define dw_pci_suspend_noirq NULL +#define dw_pci_resume_noirq NULL + +#endif /* !CONFIG_PM_SLEEP */ How about
SET_SYSTEM_SLEEP_PM_OPSinstead?
So, we are using *_noirq versions of the functions here. What happened when we switch to normal ones? Any side effects?
Quoted 20 lines
--
~VinodQuoted 17 lines
drivers/dma/dw/pci.c +8
-1+ +static const struct dev_pm_ops dw_pci_dev_pm_ops = { + .suspend_noirq = dw_pci_suspend_noirq, + .resume_noirq = dw_pci_resume_noirq, }; +static DEFINE_PCI_DEVICE_TABLE (dw_pci_id_table) = {/* Medfield */ { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata }, @@ -92,6 +122,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, + }, };
Quoted 5 lines
Quoted 4 lines
module_pci_driver(dw_pci_driver);
--
1.7.4.4
--
Andy Shevchenko <[email protected]> Intel Finland Oy ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 1 line · Chiau Ee
Vinod,
Please do *NOT* top post
Please fix your MUA to wrap lines with 80chars. I have fix below to make it readble...
Quoted 7 lines
As mentioned by Andy, we are using
*_noirqverion of suspend/resume PM callback whereby the callbacks would be executed after IRQ handlers have been disabled. If usingSET_SYSTEM_SLEEP_PM_OPS, it would be the normal suspend/resume PM callback. Looking at the Desginware DMAC platform code (drivers/dma/dw/platform.c), it is using the*_noirqsuspend/resume PM callback. Is it advisable to use the normal suspend/resume PM callback instead of*_noirqsuspend/PM callback?
i dont see a reason why we need the noirq versions
--
~Vinod
Quoted 85 lines
Thanks,
Chiau Ee-----Original Message-----
From: Shevchenko, Andriy
Sent: Tuesday, December 10, 2013 7:57 PM
To: Koul, Vinod
Cc: Chew, Chiau Ee; Viresh Kumar; Andy Shevchenko; Williams, Dan J; [email protected]; [email protected]
Subject: Re: [PATCH] dma: dw: Add suspend and resume handling for PCI modeDW_DMAC.Quoted 34 lines · Vinod Koul
Quoted 33 lines · Chew Chiau Ee
From: Chew, Chiau Ee <[email protected]>
This is to disable/enable
DW_DMAChw during suspend/resume.Signed-off-by Chew, Chiau Ee <[email protected]>Acked-by Andy Shevchenko <[email protected]>--- drivers/dma/dw/pci.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)drivers/dma/dw/pci.c index renamed from drivers/dma/dw/pci.c +0
-0e89fc24..97bc3a2 100644
drivers/dma/dw/pci.c +15
-0@@ -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_noirq (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_noirq (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); +};Quoted 8 lines
drivers/dma/dw/pci.c static void dw_pci_remove(struct pci_dev *pdev) · line 101
Quoted 7 lines
drivers/dma/dw/pci.c +7
-0+ +#else /* !CONFIG_PM_SLEEP */ + +#define dw_pci_suspend_noirq NULL +#define dw_pci_resume_noirq NULL + +#endif /* !CONFIG_PM_SLEEP */ How about
SET_SYSTEM_SLEEP_PM_OPSinstead?So, we are using
*_noirqversions of the functions here. What happened when we switch to normal ones? Any side effects?Quoted 20 lines
--
~VinodQuoted 17 lines
drivers/dma/dw/pci.c +8
-1+ +static const struct dev_pm_ops dw_pci_dev_pm_ops = { + .suspend_noirq = dw_pci_suspend_noirq, + .resume_noirq = dw_pci_resume_noirq, }; +static DEFINE_PCI_DEVICE_TABLE (dw_pci_id_table) = {/* Medfield */ { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata }, @@ -92,6 +122,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, + }, };Quoted 5 lines
Quoted 4 lines
module_pci_driver(dw_pci_driver);
--
1.7.4.4--
Andy Shevchenko <[email protected]> Intel Finland Oy
Andy Shevchenko
reviewerQuoted 11 lines · Vinod Koul
Quoted 7 lines · Chiau Ee
As mentioned by Andy, we are using
*_noirqverion of suspend/resume PM callback whereby the callbacks would be executed after IRQ handlers have been disabled. If usingSET_SYSTEM_SLEEP_PM_OPS, it would be the normal suspend/resume PM callback. Looking at the Desginware DMAC platform code (drivers/dma/dw/platform.c), it is using the*_noirqsuspend/resume PM callback. Is it advisable to use the normal suspend/resume PM callback instead of*_noirqsuspend/PM callback?i dont see a reason why we need the noirq versions
Okay. I imagine the following use case.
For example we have compiled in DMA driver (dw_dmac) along with, for example, SPI driver.
System was scheduled to go sleep.
An order of calling IIUC might be DMA first, then SPI (since they are not in parent / child relations).
What was happened when SPI would like to do a DMA transfer and DMA is going to sleep? I'm trying to understand if this is a case.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
How about
SET_SYSTEM_SLEEP_PM_OPSinstead?So, we are using
*_noirqversions of the functions here. What happened when we switch to normal ones? Any side effects?
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 18 lines · Andy Shevchenko
Quoted 11 lines · Vinod Koul
Quoted 7 lines · Chiau Ee
As mentioned by Andy, we are using
*_noirqverion of suspend/resume PM callback whereby the callbacks would be executed after IRQ handlers have been disabled. If usingSET_SYSTEM_SLEEP_PM_OPS, it would be the normal suspend/resume PM callback. Looking at the Desginware DMAC platform code (drivers/dma/dw/platform.c), it is using the*_noirqsuspend/resume PM callback. Is it advisable to use the normal suspend/resume PM callback instead of*_noirqsuspend/PM callback?i dont see a reason why we need the noirq versions
Okay. I imagine the following use case.
For example we have compiled in DMA driver (
dw_dmac) along with, for example, SPI driver.
Quoted 7 lines
System was scheduled to go sleep.
An order of calling IIUC might be DMA first, then SPI (since they are not in parent / child relations).
What was happened when SPI would like to do a DMA transfer and DMA is going to sleep? I'm trying to understand if this is a case.
In that case how does no irq version help us?
For these cases, I have been using suspend_late. Since the dmaengine driver is providing service to other clients (SPI), it needs to esnure that it suspends after SPI using suspend_late and resume using resume_early. That way dma is availble whenever the client is active
--
~Vinod
Quoted 11 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
How about
SET_SYSTEM_SLEEP_PM_OPSinstead?So, we are using
*_noirqversions of the functions here. What happened when we switch to normal ones? Any side effects?Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 19 lines · Vinod Koul
Quoted 18 lines · Andy Shevchenko
Quoted 11 lines · Vinod Koul
Quoted 7 lines · Chiau Ee
As mentioned by Andy, we are using
*_noirqverion of suspend/resume PM callback whereby the callbacks would be executed after IRQ handlers have been disabled. If usingSET_SYSTEM_SLEEP_PM_OPS, it would be the normal suspend/resume PM callback. Looking at the Desginware DMAC platform code (drivers/dma/dw/platform.c), it is using the*_noirqsuspend/resume PM callback. Is it advisable to use the normal suspend/resume PM callback instead of*_noirqsuspend/PM callback?i dont see a reason why we need the noirq versions
Okay. I imagine the following use case.
For example we have compiled in DMA driver (
dw_dmac) along with, for example, SPI driver.
Quoted 8 lines
Quoted 7 lines
System was scheduled to go sleep.
An order of calling IIUC might be DMA first, then SPI (since they are not in parent / child relations).
What was happened when SPI would like to do a DMA transfer and DMA is going to sleep? I'm trying to understand if this is a case.
In that case how does no irq version help us?
It guarantees that we have no user of DMA anymore, since there is no interrupt going on.
Quoted 4 lines
For these cases, I have been using
suspend_late. Since the dmaengine driver is providing service to other clients (SPI), it needs to esnure that it suspends after SPI usingsuspend_lateand resume usingresume_early. That way dma is availble whenever the client is active
suspend_late is working in context that interrupt handler may be invoked. Thus, to have DMA driver be properly shut down we have to wait / terminate possible ongoing transfer.
It seems for me all DMA drivers that are using system .suspend()/.resume() are potentially buggy.
Quoted 16 lines
--
~VinodQuoted 11 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
How about
SET_SYSTEM_SLEEP_PM_OPSinstead?So, we are using
*_noirqversions of the functions here. What happened when we switch to normal ones? Any side effects?Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Signature · 13 lines
Andy Shevchenko <[email protected]> Intel Finland Oy --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 25 lines · Andriy
Quoted 24 lines · Vinod Koul
Quoted 23 lines · Andy Shevchenko
Quoted 11 lines · Vinod Koul
Quoted 7 lines · Chiau Ee
As mentioned by Andy, we are using
*_noirqverion of suspend/resume PM callback whereby the callbacks would be executed after IRQ handlers have been disabled. If usingSET_SYSTEM_SLEEP_PM_OPS, it would be the normal suspend/resume PM callback. Looking at the Desginware DMAC platform code (drivers/dma/dw/platform.c), it is using the*_noirqsuspend/resume PM callback. Is it advisable to use the normal suspend/resume PM callback instead of*_noirqsuspend/PM callback?i dont see a reason why we need the noirq versions
Okay. I imagine the following use case.
For example we have compiled in DMA driver (
dw_dmac) along with, for example, SPI driver.System was scheduled to go sleep.
An order of calling IIUC might be DMA first, then SPI (since they are not in parent / child relations).
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
What was happened when SPI would like to do a DMA transfer and DMA is going to sleep? I'm trying to understand if this is a case.
In that case how does no irq version help us?
It guarantees that we have no user of DMA anymore, since there is no interrupt going on.
well how is that. It will gaurantee that there wont be interrupt. User can still submit a transaction or another transaction will be in progress...
Quoted 8 lines
Quoted 4 lines
For these cases, I have been using
suspend_late. Since the dmaengine driver is providing service to other clients (SPI), it needs to esnure that it suspends after SPI usingsuspend_lateand resume usingresume_early. That way dma is availble whenever the client is active
suspend_lateis working in context that interrupt handler may be invoked. Thus, to have DMA driver be properly shut down we have to wait / terminate possible ongoing transfer.
Well client is already suspended via .suspend. So where is the transaction :)
Quoted 3 lines
It seems for me all DMA drivers that are using system .suspend()/.resume() are potentially buggy.
Yup!
Signature · 1 line
~Vinod
Quoted 26 lines · Vinod Koul
Quoted 25 lines · Andriy
Quoted 24 lines · Vinod Koul
Quoted 23 lines · Andy Shevchenko
Quoted 11 lines · Vinod Koul
Quoted 7 lines · Chiau Ee
As mentioned by Andy, we are using
*_noirqverion of suspend/resume PM callback whereby the callbacks would be executed after IRQ handlers have been disabled. If usingSET_SYSTEM_SLEEP_PM_OPS, it would be the normal suspend/resume PM callback. Looking at the Desginware DMAC platform code (drivers/dma/dw/platform.c), it is using the*_noirqsuspend/resume PM callback. Is it advisable to use the normal suspend/resume PM callback instead of*_noirqsuspend/PM callback?i dont see a reason why we need the noirq versions
Okay. I imagine the following use case.
For example we have compiled in DMA driver (
dw_dmac) along with, for example, SPI driver.System was scheduled to go sleep.
An order of calling IIUC might be DMA first, then SPI (since they are not in parent / child relations).
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
What was happened when SPI would like to do a DMA transfer and DMA is going to sleep? I'm trying to understand if this is a case.
In that case how does no irq version help us?
It guarantees that we have no user of DMA anymore, since there is no interrupt going on.
well how is that. It will gaurantee that there wont be interrupt. User can still submit a transaction or another transaction will be in progress...
This is how system suspend callback tree is called.
First it calls .suspend() for all devices, then .suspend_late(), then .suspend_noirq().
There is set of assumptions per each callback round. After .suspend() the device must be quiescent.
But...
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
For these cases, I have been using
suspend_late. Since the dmaengine driver is providing service to other clients (SPI), it needs to esnure that it suspends after SPI usingsuspend_lateand resume usingresume_early. That way dma is availble whenever the client is active
suspend_lateis working in context that interrupt handler may be invoked. Thus, to have DMA driver be properly shut down we have to wait / terminate possible ongoing transfer.Well client is already suspended via .suspend. So where is the transaction :)
...as I already wrote before we have no parent-child relationship between DMA and, for example, SPI. That means we may possible have the case when SPI's .suspend() will be called later than DMA's one.
Quoted 3 lines
Quoted 2 lines
It seems for me all DMA drivers that are using system .suspend()/.resume() are potentially buggy.
Yup!
So, we have to decide what to do with them. .suspend_late() still seems for me not the best approach. *Or* we have to check for ongoing transaction and do something with it. *Or* just shut down the device and rely on DMA transaction initiator that it handles the terminated transaction properly.
What is you opinion?
Signature · 13 lines
Andy Shevchenko <[email protected]> Intel Finland Oy --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 55 lines · Andriy
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 9 lines
Quoted 7 lines
As mentioned by Andy, we are using
*_noirqverion of suspend/resume PM callback whereby the callbacks would be executed after IRQ handlers have been disabled. If usingSET_SYSTEM_SLEEP_PM_OPS, it would be the normal suspend/resume PM callback. Looking at the Desginware DMAC platform code (drivers/dma/dw/platform.c), it is using the*_noirqsuspend/resume PM callback. Is it advisable to use the normal suspend/resume PM callback instead of*_noirqsuspend/PM callback?i dont see a reason why we need the noirq versions
Okay. I imagine the following use case.
For example we have compiled in DMA driver (
dw_dmac) along with, for example, SPI driver.System was scheduled to go sleep.
An order of calling IIUC might be DMA first, then SPI (since they are not in parent / child relations).
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
What was happened when SPI would like to do a DMA transfer and DMA is going to sleep? I'm trying to understand if this is a case.
In that case how does no irq version help us?
It guarantees that we have no user of DMA anymore, since there is no interrupt going on.
well how is that. It will gaurantee that there wont be interrupt. User can still submit a transaction or another transaction will be in progress...
This is how system suspend callback tree is called.
First it calls .suspend() for all devices, then .suspend_late(), then .suspend_noirq().
There is set of assumptions per each callback round. After .suspend() the device must be quiescent.
But...
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
For these cases, I have been using
suspend_late. Since the dmaengine driver is providing service to other clients (SPI), it needs to esnure that it suspends after SPI usingsuspend_lateand resume usingresume_early. That way dma is availble whenever the client is active
suspend_lateis working in context that interrupt handler may be invoked. Thus, to have DMA driver be properly shut down we have to wait / terminate possible ongoing transfer.Well client is already suspended via .suspend. So where is the transaction :)
...as I already wrote before we have no parent-child relationship between DMA and, for example, SPI. That means we may possible have the case when SPI's .suspend() will be called later than DMA's one.
Quoted 2 lines
Quoted 2 lines
It seems for me all DMA drivers that are using system .suspend()/.resume() are potentially buggy.
Quoted 7 lines
Quoted 1 line
Yup!
So, we have to decide what to do with them. .suspend_late() still seems for me not the best approach. *Or* we have to check for ongoing transaction and do something with it. *Or* just shut down the device and rely on DMA transaction initiator that it handles the terminated transaction properly.
As you clearly said, we dont have a parent-child relatation though we have big dependency. I think this is true for DMA clients, i ran into similar situation with i2c few days back!
So only think which can give us a good system behaviour would be clients getting suspended first and then then service providing subsystems. (same reason why we do dma driver loading and init much before others drivers)
So yes in the .suspend callback of the client, it needs to
1) abort any transactions it has
2) make the client quiscent
then the .late_suspend kicks in and suspend the core drivers like dma.
This is how it has worked reliably for me in production systems. I am all ears if we have a better and cleaner apprach to this problem :)
Signature · 1 line
~Vinod
Andy Shevchenko
reviewerQuoted 24 lines · Vinod Koul
Quoted 16 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
For these cases, I have been using
suspend_late. Since the dmaengine driver is providing service to other clients (SPI), it needs to esnure that it suspends after SPI usingsuspend_lateand resume usingresume_early. That way dma is availble whenever the client is active
suspend_lateis working in context that interrupt handler may be invoked. Thus, to have DMA driver be properly shut down we have to wait / terminate possible ongoing transfer.Well client is already suspended via .suspend. So where is the transaction :)
...as I already wrote before we have no parent-child relationship between DMA and, for example, SPI. That means we may possible have the case when SPI's .suspend() will be called later than DMA's one.
Quoted 2 lines
Quoted 2 lines
It seems for me all DMA drivers that are using system .suspend()/.resume() are potentially buggy.
Quoted 7 lines
Quoted 1 line
Yup!
So, we have to decide what to do with them. .suspend_late() still seems for me not the best approach. *Or* we have to check for ongoing transaction and do something with it. *Or* just shut down the device and rely on DMA transaction initiator that it handles the terminated transaction properly.
Quoted 6 lines
As you clearly said, we dont have a parent-child relatation though we have big dependency. I think this is true for DMA clients, i ran into similar situation with i2c few days back!
So only think which can give us a good system behaviour would be clients getting suspended first and then then service providing subsystems.
Agree.
Quoted 2 lines
(same reason why we
do dma driver loading and init much before others drivers)
Yes, it would be done via deferred probe.
Quoted 8 lines
So yes in the .suspend callback of the client, it needs to
1) abort any transactions it has
2) make the client quiscentthen the .late_suspend kicks in and suspend the core drivers like dma.
This is how it has worked reliably for me in production systems. I am all ears if we have a better and cleaner apprach to this problem :)
Yes, summarize everything we discussed we have to:
- provide suspend_late, resume_early callbacks in the DMA driver
instead of *_noirq versions
- ensure that all clients on our platforms follow the described
scenario
Chiau Ee, I think you may to change your patch accordingly.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 62 lines
-----Original Message-----
From: Andy Shevchenko [mailto:[email protected]]
Sent: Monday, January 27, 2014 6:17 PM
To: Koul, Vinod
Cc: Andy Shevchenko; Chew, Chiau Ee; Viresh Kumar; Williams, Dan J; [email protected]; [email protected]
Subject: Re: [PATCH] dma: dw: Add suspend and resume handling for PCI modeDW_DMAC.Quoted 26 lines · Vinod Koul
Quoted 18 lines
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
For these cases, I have been using
suspend_late. Since the dmaengine driver is providing service to other clients (SPI), it needs to esnure that it suspends after SPI usingsuspend_lateand resume usingresume_early. That way dma is availble whenever the client is active
suspend_lateis working in context that interrupt handler may be invoked. Thus, to have DMA driver be properly shut down we have to wait / terminate possible ongoing transfer.Well client is already suspended via .suspend. So where is the transaction :)
...as I already wrote before we have no parent-child relationship between DMA and, for example, SPI. That means we may possible have the case when SPI's .suspend() will be called later than DMA's one.
Quoted 2 lines
Quoted 2 lines
It seems for me all DMA drivers that are using system .suspend()/.resume() are potentially buggy.
Quoted 7 lines
Quoted 1 line
Yup!
So, we have to decide what to do with them. .suspend_late() still seems for me not the best approach. *Or* we have to check for ongoing transaction and do something with it. *Or* just shut down the device and rely on DMA transaction initiator that it handles the terminated transaction properly.
Quoted 6 lines
As you clearly said, we dont have a parent-child relatation though we have big dependency. I think this is true for DMA clients, i ran into similar situation with i2c few days back!
So only think which can give us a good system behaviour would be clients getting suspended first and then then service providing subsystems.
Agree.
Quoted 2 lines
(same reason why we
do dma driver loading and init much before others drivers)Yes, it would be done via deferred probe.
Quoted 8 lines
So yes in the .suspend callback of the client, it needs to
1) abort any transactions it has
2) make the client quiscentthen the .late_suspend kicks in and suspend the core drivers like dma.
This is how it has worked reliably for me in production systems. I am all ears if we have a better and cleaner apprach to this problem :)
Quoted 6 lines
Yes, summarize everything we discussed we have to:
- providesuspend_late,resume_earlycallbacks in the DMA driver instead of*_noirqversions
- ensure that all clients on our platforms follow the described scenarioChiau Ee, I think you may to change your patch accordingly.
Ok. Noted
Quoted 5 lines
--
Andy Shevchenko <[email protected]> Intel Finland Oy
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�