Skip to content

Commit 676f9c2

Browse files
mitaVinod Koul
authored andcommitted
dmaengine: xilinx: fix device_terminate_all() callback for AXI CDMA
The device_terminate_all() callback for this driver stops current DMA operations by clearing RUNSTOP bit in the control register and waiting HALTED bit set in the status register. But AXI CDMA which is one of the supported DMA engine by this driver does not provide the run / stop controls and those bits in the control and status registers are reserved. So when device_terminate_all() is called, the error message is printed and the channel is marked as having errors in xilinx_dma_halt(). This change adds stop_transfer() callback which differentiates CDMA and other DMA engine. The CDMA's one avoids the unsupported operations and instead polls the status register to check if the DMA operations are in progress for AXI CDMA. Cc: Vinod Koul <vinod.koul@intel.com> Cc: Kedareswara rao Appana <appana.durga.rao@xilinx.com> Cc: Michal Simek <monstr@monstr.eu> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
1 parent c1ae3cf commit 676f9c2

1 file changed

Lines changed: 33 additions & 16 deletions

File tree

‎drivers/dma/xilinx/xilinx_dma.c‎

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ struct xilinx_dma_tx_descriptor {
331331
* @seg_v: Statically allocated segments base
332332
* @cyclic_seg_v: Statically allocated segment base for cyclic transfers
333333
* @start_transfer: Differentiate b/w DMA IP's transfer
334+
* @stop_transfer: Differentiate b/w DMA IP's quiesce
334335
*/
335336
struct xilinx_dma_chan {
336337
struct xilinx_dma_device *xdev;
@@ -361,6 +362,7 @@ struct xilinx_dma_chan {
361362
struct xilinx_axidma_tx_segment *seg_v;
362363
struct xilinx_axidma_tx_segment *cyclic_seg_v;
363364
void (*start_transfer)(struct xilinx_dma_chan *chan);
365+
int (*stop_transfer)(struct xilinx_dma_chan *chan);
364366
u16 tdest;
365367
};
366368

@@ -946,26 +948,32 @@ static bool xilinx_dma_is_idle(struct xilinx_dma_chan *chan)
946948
}
947949

948950
/**
949-
* xilinx_dma_halt - Halt DMA channel
951+
* xilinx_dma_stop_transfer - Halt DMA channel
950952
* @chan: Driver specific DMA channel
951953
*/
952-
static void xilinx_dma_halt(struct xilinx_dma_chan *chan)
954+
static int xilinx_dma_stop_transfer(struct xilinx_dma_chan *chan)
953955
{
954-
int err;
955956
u32 val;
956957

957958
dma_ctrl_clr(chan, XILINX_DMA_REG_DMACR, XILINX_DMA_DMACR_RUNSTOP);
958959

959960
/* Wait for the hardware to halt */
960-
err = xilinx_dma_poll_timeout(chan, XILINX_DMA_REG_DMASR, val,
961-
(val & XILINX_DMA_DMASR_HALTED), 0,
962-
XILINX_DMA_LOOP_COUNT);
961+
return xilinx_dma_poll_timeout(chan, XILINX_DMA_REG_DMASR, val,
962+
val & XILINX_DMA_DMASR_HALTED, 0,
963+
XILINX_DMA_LOOP_COUNT);
964+
}
963965

964-
if (err) {
965-
dev_err(chan->dev, "Cannot stop channel %p: %x\n",
966-
chan, dma_ctrl_read(chan, XILINX_DMA_REG_DMASR));
967-
chan->err = true;
968-
}
966+
/**
967+
* xilinx_cdma_stop_transfer - Wait for the current transfer to complete
968+
* @chan: Driver specific DMA channel
969+
*/
970+
static int xilinx_cdma_stop_transfer(struct xilinx_dma_chan *chan)
971+
{
972+
u32 val;
973+
974+
return xilinx_dma_poll_timeout(chan, XILINX_DMA_REG_DMASR, val,
975+
val & XILINX_DMA_DMASR_IDLE, 0,
976+
XILINX_DMA_LOOP_COUNT);
969977
}
970978

971979
/**
@@ -2003,12 +2011,17 @@ static int xilinx_dma_terminate_all(struct dma_chan *dchan)
20032011
{
20042012
struct xilinx_dma_chan *chan = to_xilinx_chan(dchan);
20052013
u32 reg;
2014+
int err;
20062015

20072016
if (chan->cyclic)
20082017
xilinx_dma_chan_reset(chan);
20092018

2010-
/* Halt the DMA engine */
2011-
xilinx_dma_halt(chan);
2019+
err = chan->stop_transfer(chan);
2020+
if (err) {
2021+
dev_err(chan->dev, "Cannot stop channel %p: %x\n",
2022+
chan, dma_ctrl_read(chan, XILINX_DMA_REG_DMASR));
2023+
chan->err = true;
2024+
}
20122025

20132026
/* Remove and free all of the descriptors in the lists */
20142027
xilinx_dma_free_descriptors(chan);
@@ -2397,12 +2410,16 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev,
23972410
return err;
23982411
}
23992412

2400-
if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA)
2413+
if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {
24012414
chan->start_transfer = xilinx_dma_start_transfer;
2402-
else if (xdev->dma_config->dmatype == XDMA_TYPE_CDMA)
2415+
chan->stop_transfer = xilinx_dma_stop_transfer;
2416+
} else if (xdev->dma_config->dmatype == XDMA_TYPE_CDMA) {
24032417
chan->start_transfer = xilinx_cdma_start_transfer;
2404-
else
2418+
chan->stop_transfer = xilinx_cdma_stop_transfer;
2419+
} else {
24052420
chan->start_transfer = xilinx_vdma_start_transfer;
2421+
chan->stop_transfer = xilinx_dma_stop_transfer;
2422+
}
24062423

24072424
/* Initialize the tasklet */
24082425
tasklet_init(&chan->tasklet, xilinx_dma_do_tasklet,

0 commit comments

Comments
 (0)