Skip to content

Commit f270535

Browse files
Akhil Rgregkh
authored andcommitted
dmaengine: tegra: Return correct DMA status when paused
commit ebc0086 upstream. Currently, the driver does not return the correct DMA status when a DMA pause is issued by the client drivers. This causes GPCDMA users to assume that DMA is still running, while in reality, the DMA is paused. Return DMA_PAUSED for tx_status() if the channel is paused in the middle of a transfer. Fixes: ee17028 ("dmaengine: tegra: Add tegra gpcdma driver") Cc: [email protected] Signed-off-by: Akhil R <[email protected]> Signed-off-by: Kartik Rajput <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8cf5aa0 commit f270535

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/dma/tegra186-gpc-dma.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ struct tegra_dma_channel {
231231
bool config_init;
232232
char name[30];
233233
enum dma_transfer_direction sid_dir;
234+
enum dma_status status;
234235
int id;
235236
int irq;
236237
int slave_id;
@@ -393,6 +394,8 @@ static int tegra_dma_pause(struct tegra_dma_channel *tdc)
393394
tegra_dma_dump_chan_regs(tdc);
394395
}
395396

397+
tdc->status = DMA_PAUSED;
398+
396399
return ret;
397400
}
398401

@@ -419,6 +422,8 @@ static void tegra_dma_resume(struct tegra_dma_channel *tdc)
419422
val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
420423
val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
421424
tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
425+
426+
tdc->status = DMA_IN_PROGRESS;
422427
}
423428

424429
static int tegra_dma_device_resume(struct dma_chan *dc)
@@ -544,6 +549,7 @@ static void tegra_dma_xfer_complete(struct tegra_dma_channel *tdc)
544549

545550
tegra_dma_sid_free(tdc);
546551
tdc->dma_desc = NULL;
552+
tdc->status = DMA_COMPLETE;
547553
}
548554

549555
static void tegra_dma_chan_decode_error(struct tegra_dma_channel *tdc,
@@ -716,6 +722,7 @@ static int tegra_dma_terminate_all(struct dma_chan *dc)
716722
tdc->dma_desc = NULL;
717723
}
718724

725+
tdc->status = DMA_COMPLETE;
719726
tegra_dma_sid_free(tdc);
720727
vchan_get_all_descriptors(&tdc->vc, &head);
721728
spin_unlock_irqrestore(&tdc->vc.lock, flags);
@@ -769,6 +776,9 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
769776
if (ret == DMA_COMPLETE)
770777
return ret;
771778

779+
if (tdc->status == DMA_PAUSED)
780+
ret = DMA_PAUSED;
781+
772782
spin_lock_irqsave(&tdc->vc.lock, flags);
773783
vd = vchan_find_desc(&tdc->vc, cookie);
774784
if (vd) {

0 commit comments

Comments
 (0)