Skip to content

Commit e84aeea

Browse files
Jie Haigregkh
authored andcommittedOct 26, 2022
dmaengine: hisilicon: Disable channels when unregister hisi_dma
[ Upstream commit e3bdaa0 ] When hisi_dma is unloaded or unbinded, all of channels should be disabled. This patch disables DMA channels when driver is unloaded or unbinded. Fixes: e9f08b6 ("dmaengine: hisilicon: Add Kunpeng DMA engine support") Signed-off-by: Jie Hai <[email protected]> Acked-by: Zhou Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Sasha Levin <[email protected]>

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
 

‎drivers/dma/hisi_dma.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ static void hisi_dma_reset_qp_point(struct hisi_dma_dev *hdma_dev, u32 index)
180180
hisi_dma_chan_write(hdma_dev->base, HISI_DMA_CQ_HEAD_PTR, index, 0);
181181
}
182182

183-
static void hisi_dma_reset_hw_chan(struct hisi_dma_chan *chan)
183+
static void hisi_dma_reset_or_disable_hw_chan(struct hisi_dma_chan *chan,
184+
bool disable)
184185
{
185186
struct hisi_dma_dev *hdma_dev = chan->hdma_dev;
186187
u32 index = chan->qp_num, tmp;
@@ -201,8 +202,11 @@ static void hisi_dma_reset_hw_chan(struct hisi_dma_chan *chan)
201202
hisi_dma_do_reset(hdma_dev, index);
202203
hisi_dma_reset_qp_point(hdma_dev, index);
203204
hisi_dma_pause_dma(hdma_dev, index, false);
204-
hisi_dma_enable_dma(hdma_dev, index, true);
205-
hisi_dma_unmask_irq(hdma_dev, index);
205+
206+
if (!disable) {
207+
hisi_dma_enable_dma(hdma_dev, index, true);
208+
hisi_dma_unmask_irq(hdma_dev, index);
209+
}
206210

207211
ret = readl_relaxed_poll_timeout(hdma_dev->base +
208212
HISI_DMA_Q_FSM_STS + index * HISI_DMA_OFFSET, tmp,
@@ -218,7 +222,7 @@ static void hisi_dma_free_chan_resources(struct dma_chan *c)
218222
struct hisi_dma_chan *chan = to_hisi_dma_chan(c);
219223
struct hisi_dma_dev *hdma_dev = chan->hdma_dev;
220224

221-
hisi_dma_reset_hw_chan(chan);
225+
hisi_dma_reset_or_disable_hw_chan(chan, false);
222226
vchan_free_chan_resources(&chan->vc);
223227

224228
memset(chan->sq, 0, sizeof(struct hisi_dma_sqe) * hdma_dev->chan_depth);
@@ -394,7 +398,7 @@ static void hisi_dma_enable_qp(struct hisi_dma_dev *hdma_dev, u32 qp_index)
394398

395399
static void hisi_dma_disable_qp(struct hisi_dma_dev *hdma_dev, u32 qp_index)
396400
{
397-
hisi_dma_reset_hw_chan(&hdma_dev->chan[qp_index]);
401+
hisi_dma_reset_or_disable_hw_chan(&hdma_dev->chan[qp_index], true);
398402
}
399403

400404
static void hisi_dma_enable_qps(struct hisi_dma_dev *hdma_dev)

0 commit comments

Comments
 (0)
Please sign in to comment.