aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2017-01-19 11:49:07 -0500
committerVinod Koul <vinod.koul@intel.com>2017-01-25 00:59:11 -0500
commitae4a3e028bb8b59e7cfeb0cc9ef03d885182ce8b (patch)
tree139fc7e29f97d6bb6c4dca2a97be2dc3f824bd51
parent49def1853334396f948dcb4cedb9347abb318df5 (diff)
dmaengine: cppi41: Fix runtime PM timeouts with USB mass storage
Commit fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support") added runtime PM support for cppi41, but had corner case issues. Some of the issues were fixed with commit 098de42ad670 ("dmaengine: cppi41: Fix unpaired pm runtime when only a USB hub is connected"). That fix however caused a new regression where we can get error -115 messages with USB on BeagleBone when connecting a USB mass storage device to a hub. This is because when connecting a USB mass storage device to a hub, the initial DMA transfers can take over 200ms to complete and cppi41 autosuspend delay times out. To fix the issue, we want to implement refcounting for chan_busy array that contains the active dma transfers. Increasing the autosuspend delay won't help as that the delay could be potentially seconds, and it's best to let the USB subsystem to deal with the timeouts on errors. The earlier attempt for runtime PM was buggy as the pm_runtime_get/put() calls could get unpaired easily as they did not follow the state of the chan_busy array as described in commit 098de42ad670 ("dmaengine: cppi41: Fix unpaired pm runtime when only a USB hub is connected". Let's fix the issue by adding pm_runtime_get() to where a new transfer is added to the chan_busy array, and calls to pm_runtime_put() where chan_busy array entry is cleared. This prevents any autosuspend timeouts from happening while dma transfers are active. Fixes: 098de42ad670 ("dmaengine: cppi41: Fix unpaired pm runtime when only a USB hub is connected") Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support") Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Bin Liu <b-liu@ti.com> Cc: Grygorii Strashko <grygorii.strashko@ti.com> Cc: Kevin Hilman <khilman@baylibre.com> Cc: Patrick Titiano <ptitiano@baylibre.com> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/cppi41.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index d5ba43a87a68..7de4fdf86a6a 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -257,6 +257,10 @@ static struct cppi41_channel *desc_to_chan(struct cppi41_dd *cdd, u32 desc)
257 BUG_ON(desc_num >= ALLOC_DECS_NUM); 257 BUG_ON(desc_num >= ALLOC_DECS_NUM);
258 c = cdd->chan_busy[desc_num]; 258 c = cdd->chan_busy[desc_num];
259 cdd->chan_busy[desc_num] = NULL; 259 cdd->chan_busy[desc_num] = NULL;
260
261 /* Usecount for chan_busy[], paired with push_desc_queue() */
262 pm_runtime_put(cdd->ddev.dev);
263
260 return c; 264 return c;
261} 265}
262 266
@@ -447,6 +451,15 @@ static void push_desc_queue(struct cppi41_channel *c)
447 */ 451 */
448 __iowmb(); 452 __iowmb();
449 453
454 /*
455 * DMA transfers can take at least 200ms to complete with USB mass
456 * storage connected. To prevent autosuspend timeouts, we must use
457 * pm_runtime_get/put() when chan_busy[] is modified. This will get
458 * cleared in desc_to_chan() or cppi41_stop_chan() depending on the
459 * outcome of the transfer.
460 */
461 pm_runtime_get(cdd->ddev.dev);
462
450 desc_phys = lower_32_bits(c->desc_phys); 463 desc_phys = lower_32_bits(c->desc_phys);
451 desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc); 464 desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
452 WARN_ON(cdd->chan_busy[desc_num]); 465 WARN_ON(cdd->chan_busy[desc_num]);
@@ -705,6 +718,9 @@ static int cppi41_stop_chan(struct dma_chan *chan)
705 WARN_ON(!cdd->chan_busy[desc_num]); 718 WARN_ON(!cdd->chan_busy[desc_num]);
706 cdd->chan_busy[desc_num] = NULL; 719 cdd->chan_busy[desc_num] = NULL;
707 720
721 /* Usecount for chan_busy[], paired with push_desc_queue() */
722 pm_runtime_put(cdd->ddev.dev);
723
708 return 0; 724 return 0;
709} 725}
710 726