Skip to content

Commit 91f0ff8

Browse files
andy-shevvinodkoul
authored andcommitted
dmaengine: dw: Reset DRAIN bit when resume the channel
For Intel iDMA 32-bit the channel can be drained on a suspend. We need to reset the bit on the resume to return a status quo. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 69da8be commit 91f0ff8

4 files changed

Lines changed: 25 additions & 7 deletions

File tree

‎drivers/dma/dw/core.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -846,11 +846,11 @@ static int dwc_pause(struct dma_chan *chan)
846846
return 0;
847847
}
848848

849-
static inline void dwc_chan_resume(struct dw_dma_chan *dwc)
849+
static inline void dwc_chan_resume(struct dw_dma_chan *dwc, bool drain)
850850
{
851-
u32 cfglo = channel_readl(dwc, CFG_LO);
851+
struct dw_dma *dw = to_dw_dma(dwc->chan.device);
852852

853-
channel_writel(dwc, CFG_LO, cfglo & ~DWC_CFGL_CH_SUSP);
853+
dw->resume_chan(dwc, drain);
854854

855855
clear_bit(DW_DMA_IS_PAUSED, &dwc->flags);
856856
}
@@ -863,7 +863,7 @@ static int dwc_resume(struct dma_chan *chan)
863863
spin_lock_irqsave(&dwc->lock, flags);
864864

865865
if (test_bit(DW_DMA_IS_PAUSED, &dwc->flags))
866-
dwc_chan_resume(dwc);
866+
dwc_chan_resume(dwc, false);
867867

868868
spin_unlock_irqrestore(&dwc->lock, flags);
869869

@@ -886,7 +886,7 @@ static int dwc_terminate_all(struct dma_chan *chan)
886886

887887
dwc_chan_disable(dw, dwc);
888888

889-
dwc_chan_resume(dwc);
889+
dwc_chan_resume(dwc, true);
890890

891891
/* active_list entries will end up before queued entries */
892892
list_splice_init(&dwc->queue, &list);

‎drivers/dma/dw/dw.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ static void dw_dma_suspend_chan(struct dw_dma_chan *dwc, bool drain)
3535
channel_writel(dwc, CFG_LO, cfglo | DWC_CFGL_CH_SUSP);
3636
}
3737

38+
static void dw_dma_resume_chan(struct dw_dma_chan *dwc, bool drain)
39+
{
40+
u32 cfglo = channel_readl(dwc, CFG_LO);
41+
42+
channel_writel(dwc, CFG_LO, cfglo & ~DWC_CFGL_CH_SUSP);
43+
}
44+
3845
static u32 dw_dma_bytes2block(struct dw_dma_chan *dwc,
3946
size_t bytes, unsigned int width, size_t *len)
4047
{
@@ -91,6 +98,7 @@ int dw_dma_probe(struct dw_dma_chip *chip)
9198
/* Channel operations */
9299
dw->initialize_chan = dw_dma_initialize_chan;
93100
dw->suspend_chan = dw_dma_suspend_chan;
101+
dw->resume_chan = dw_dma_resume_chan;
94102
dw->encode_maxburst = dw_dma_encode_maxburst;
95103
dw->bytes2block = dw_dma_bytes2block;
96104
dw->block2bytes = dw_dma_block2bytes;

‎drivers/dma/dw/idma32.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,20 @@ static void idma32_suspend_chan(struct dw_dma_chan *dwc, bool drain)
3434

3535
if (drain)
3636
cfglo |= IDMA32C_CFGL_CH_DRAIN;
37-
else
38-
cfglo &= ~IDMA32C_CFGL_CH_DRAIN;
3937

4038
channel_writel(dwc, CFG_LO, cfglo | DWC_CFGL_CH_SUSP);
4139
}
4240

41+
static void idma32_resume_chan(struct dw_dma_chan *dwc, bool drain)
42+
{
43+
u32 cfglo = channel_readl(dwc, CFG_LO);
44+
45+
if (drain)
46+
cfglo &= ~IDMA32C_CFGL_CH_DRAIN;
47+
48+
channel_writel(dwc, CFG_LO, cfglo & ~DWC_CFGL_CH_SUSP);
49+
}
50+
4351
static u32 idma32_bytes2block(struct dw_dma_chan *dwc,
4452
size_t bytes, unsigned int width, size_t *len)
4553
{
@@ -117,6 +125,7 @@ int idma32_dma_probe(struct dw_dma_chip *chip)
117125
/* Channel operations */
118126
dw->initialize_chan = idma32_initialize_chan;
119127
dw->suspend_chan = idma32_suspend_chan;
128+
dw->resume_chan = idma32_resume_chan;
120129
dw->encode_maxburst = idma32_encode_maxburst;
121130
dw->bytes2block = idma32_bytes2block;
122131
dw->block2bytes = idma32_block2bytes;

‎drivers/dma/dw/regs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ struct dw_dma {
315315
/* Channel operations */
316316
void (*initialize_chan)(struct dw_dma_chan *dwc);
317317
void (*suspend_chan)(struct dw_dma_chan *dwc, bool drain);
318+
void (*resume_chan)(struct dw_dma_chan *dwc, bool drain);
318319
void (*encode_maxburst)(struct dw_dma_chan *dwc, u32 *maxburst);
319320
u32 (*bytes2block)(struct dw_dma_chan *dwc, size_t bytes,
320321
unsigned int width, size_t *len);

0 commit comments

Comments
 (0)