Skip to content

Commit 9aa4880

Browse files
smaeulvinodkoul
authored andcommitted
dmaengine: sun6i: Do not use virt_to_phys
This breaks on RISC-V, because dma_pool_alloc returns addresses which are not in the linear map. Instead, plumb through the physical address which is already known anyway. Acked-by: Maxime Ripard <maxime@cerno.tech> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20220424172759.33383-3-samuel@sholland.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 59e4777 commit 9aa4880

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

drivers/dma/sun6i-dma.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@ static inline void sun6i_dma_dump_com_regs(struct sun6i_dma_dev *sdev)
241241
static inline void sun6i_dma_dump_chan_regs(struct sun6i_dma_dev *sdev,
242242
struct sun6i_pchan *pchan)
243243
{
244-
phys_addr_t reg = virt_to_phys(pchan->base);
245-
246-
dev_dbg(sdev->slave.dev, "Chan %d reg: %pa\n"
244+
dev_dbg(sdev->slave.dev, "Chan %d reg:\n"
247245
"\t___en(%04x): \t0x%08x\n"
248246
"\tpause(%04x): \t0x%08x\n"
249247
"\tstart(%04x): \t0x%08x\n"
@@ -252,7 +250,7 @@ static inline void sun6i_dma_dump_chan_regs(struct sun6i_dma_dev *sdev,
252250
"\t__dst(%04x): \t0x%08x\n"
253251
"\tcount(%04x): \t0x%08x\n"
254252
"\t_para(%04x): \t0x%08x\n\n",
255-
pchan->idx, &reg,
253+
pchan->idx,
256254
DMA_CHAN_ENABLE,
257255
readl(pchan->base + DMA_CHAN_ENABLE),
258256
DMA_CHAN_PAUSE,
@@ -385,17 +383,16 @@ static void *sun6i_dma_lli_add(struct sun6i_dma_lli *prev,
385383
}
386384

387385
static inline void sun6i_dma_dump_lli(struct sun6i_vchan *vchan,
388-
struct sun6i_dma_lli *lli)
386+
struct sun6i_dma_lli *v_lli,
387+
dma_addr_t p_lli)
389388
{
390-
phys_addr_t p_lli = virt_to_phys(lli);
391-
392389
dev_dbg(chan2dev(&vchan->vc.chan),
393-
"\n\tdesc: p - %pa v - 0x%p\n"
390+
"\n\tdesc:\tp - %pad v - 0x%p\n"
394391
"\t\tc - 0x%08x s - 0x%08x d - 0x%08x\n"
395392
"\t\tl - 0x%08x p - 0x%08x n - 0x%08x\n",
396-
&p_lli, lli,
397-
lli->cfg, lli->src, lli->dst,
398-
lli->len, lli->para, lli->p_lli_next);
393+
&p_lli, v_lli,
394+
v_lli->cfg, v_lli->src, v_lli->dst,
395+
v_lli->len, v_lli->para, v_lli->p_lli_next);
399396
}
400397

401398
static void sun6i_dma_free_desc(struct virt_dma_desc *vd)
@@ -445,7 +442,7 @@ static int sun6i_dma_start_desc(struct sun6i_vchan *vchan)
445442
pchan->desc = to_sun6i_desc(&desc->tx);
446443
pchan->done = NULL;
447444

448-
sun6i_dma_dump_lli(vchan, pchan->desc->v_lli);
445+
sun6i_dma_dump_lli(vchan, pchan->desc->v_lli, pchan->desc->p_lli);
449446

450447
irq_reg = pchan->idx / DMA_IRQ_CHAN_NR;
451448
irq_offset = pchan->idx % DMA_IRQ_CHAN_NR;
@@ -670,7 +667,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
670667

671668
sun6i_dma_lli_add(NULL, v_lli, p_lli, txd);
672669

673-
sun6i_dma_dump_lli(vchan, v_lli);
670+
sun6i_dma_dump_lli(vchan, v_lli, p_lli);
674671

675672
return vchan_tx_prep(&vchan->vc, &txd->vd, flags);
676673

@@ -746,14 +743,16 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_slave_sg(
746743
}
747744

748745
dev_dbg(chan2dev(chan), "First: %pad\n", &txd->p_lli);
749-
for (prev = txd->v_lli; prev; prev = prev->v_lli_next)
750-
sun6i_dma_dump_lli(vchan, prev);
746+
for (p_lli = txd->p_lli, v_lli = txd->v_lli; v_lli;
747+
p_lli = v_lli->p_lli_next, v_lli = v_lli->v_lli_next)
748+
sun6i_dma_dump_lli(vchan, v_lli, p_lli);
751749

752750
return vchan_tx_prep(&vchan->vc, &txd->vd, flags);
753751

754752
err_lli_free:
755-
for (prev = txd->v_lli; prev; prev = prev->v_lli_next)
756-
dma_pool_free(sdev->pool, prev, virt_to_phys(prev));
753+
for (p_lli = txd->p_lli, v_lli = txd->v_lli; v_lli;
754+
p_lli = v_lli->p_lli_next, v_lli = v_lli->v_lli_next)
755+
dma_pool_free(sdev->pool, v_lli, p_lli);
757756
kfree(txd);
758757
return NULL;
759758
}
@@ -820,8 +819,9 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic(
820819
return vchan_tx_prep(&vchan->vc, &txd->vd, flags);
821820

822821
err_lli_free:
823-
for (prev = txd->v_lli; prev; prev = prev->v_lli_next)
824-
dma_pool_free(sdev->pool, prev, virt_to_phys(prev));
822+
for (p_lli = txd->p_lli, v_lli = txd->v_lli; v_lli;
823+
p_lli = v_lli->p_lli_next, v_lli = v_lli->v_lli_next)
824+
dma_pool_free(sdev->pool, v_lli, p_lli);
825825
kfree(txd);
826826
return NULL;
827827
}

0 commit comments

Comments
 (0)