Skip to content

Commit 374dab2

Browse files
committed
Merge branch 'fixes' of git://git.infradead.org/users/vkoul/slave-dma
Pull slave-dmaengine fixes from Vinod Koul: "This contains small fixes spread across the drivers" * 'fixes' of git://git.infradead.org/users/vkoul/slave-dma: dmaengine: mmp_pdma: fix warning about slave caps dmaengine: qcom_bam_dma: fix wrong register offsets dmaengine: bam-dma: fix a warning about missing capabilities dmaengine: ioatdma: workaround for incorrect DMACAP register dmaengine: at_xdmac: fix for chan conf simplification dmaengine: dw: don't handle interrupt when dmaengine is not used dma: mmp-tdma: refine dma disable and dma-pos update dmaengine: shdma: Move DMA stop to (runtime) suspend callbacks dmaenegine: mmp-pdma: fix irq handler overwrite physical chan issue
2 parents 9aae0df + ecb9b42 commit 374dab2

File tree

7 files changed

+57
-22
lines changed

7 files changed

+57
-22
lines changed

drivers/dma/at_xdmac.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@ at_xdmac_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr,
664664
struct at_xdmac_desc *first = NULL, *prev = NULL;
665665
unsigned int periods = buf_len / period_len;
666666
int i;
667-
u32 cfg;
668667

669668
dev_dbg(chan2dev(chan), "%s: buf_addr=%pad, buf_len=%zd, period_len=%zd, dir=%s, flags=0x%lx\n",
670669
__func__, &buf_addr, buf_len, period_len,
@@ -700,17 +699,17 @@ at_xdmac_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr,
700699
if (direction == DMA_DEV_TO_MEM) {
701700
desc->lld.mbr_sa = atchan->per_src_addr;
702701
desc->lld.mbr_da = buf_addr + i * period_len;
703-
cfg = atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG];
702+
desc->lld.mbr_cfg = atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG];
704703
} else {
705704
desc->lld.mbr_sa = buf_addr + i * period_len;
706705
desc->lld.mbr_da = atchan->per_dst_addr;
707-
cfg = atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG];
706+
desc->lld.mbr_cfg = atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG];
708707
}
709708
desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV1
710709
| AT_XDMAC_MBR_UBC_NDEN
711710
| AT_XDMAC_MBR_UBC_NSEN
712711
| AT_XDMAC_MBR_UBC_NDE
713-
| period_len >> at_xdmac_get_dwidth(cfg);
712+
| period_len >> at_xdmac_get_dwidth(desc->lld.mbr_cfg);
714713

715714
dev_dbg(chan2dev(chan),
716715
"%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n",

drivers/dma/dw/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ static irqreturn_t dw_dma_interrupt(int irq, void *dev_id)
626626
dev_vdbg(dw->dma.dev, "%s: status=0x%x\n", __func__, status);
627627

628628
/* Check if we have any interrupt from the DMAC */
629-
if (!status)
629+
if (!status || !dw->in_use)
630630
return IRQ_NONE;
631631

632632
/*

drivers/dma/ioat/dma_v3.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ static bool is_bwd_noraid(struct pci_dev *pdev)
230230
switch (pdev->device) {
231231
case PCI_DEVICE_ID_INTEL_IOAT_BWD2:
232232
case PCI_DEVICE_ID_INTEL_IOAT_BWD3:
233+
case PCI_DEVICE_ID_INTEL_IOAT_BDXDE0:
234+
case PCI_DEVICE_ID_INTEL_IOAT_BDXDE1:
235+
case PCI_DEVICE_ID_INTEL_IOAT_BDXDE2:
236+
case PCI_DEVICE_ID_INTEL_IOAT_BDXDE3:
233237
return true;
234238
default:
235239
return false;

drivers/dma/mmp_pdma.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ static irqreturn_t mmp_pdma_int_handler(int irq, void *dev_id)
219219

220220
while (dint) {
221221
i = __ffs(dint);
222+
/* only handle interrupts belonging to pdma driver*/
223+
if (i >= pdev->dma_channels)
224+
break;
222225
dint &= (dint - 1);
223226
phy = &pdev->phy[i];
224227
ret = mmp_pdma_chan_handler(irq, phy);
@@ -999,6 +1002,9 @@ static int mmp_pdma_probe(struct platform_device *op)
9991002
struct resource *iores;
10001003
int i, ret, irq = 0;
10011004
int dma_channels = 0, irq_num = 0;
1005+
const enum dma_slave_buswidth widths =
1006+
DMA_SLAVE_BUSWIDTH_1_BYTE | DMA_SLAVE_BUSWIDTH_2_BYTES |
1007+
DMA_SLAVE_BUSWIDTH_4_BYTES;
10021008

10031009
pdev = devm_kzalloc(&op->dev, sizeof(*pdev), GFP_KERNEL);
10041010
if (!pdev)
@@ -1066,6 +1072,10 @@ static int mmp_pdma_probe(struct platform_device *op)
10661072
pdev->device.device_config = mmp_pdma_config;
10671073
pdev->device.device_terminate_all = mmp_pdma_terminate_all;
10681074
pdev->device.copy_align = PDMA_ALIGNMENT;
1075+
pdev->device.src_addr_widths = widths;
1076+
pdev->device.dst_addr_widths = widths;
1077+
pdev->device.directions = BIT(DMA_MEM_TO_DEV) | BIT(DMA_DEV_TO_MEM);
1078+
pdev->device.residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
10691079

10701080
if (pdev->dev->coherent_dma_mask)
10711081
dma_set_mask(pdev->dev, pdev->dev->coherent_dma_mask);

drivers/dma/mmp_tdma.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct mmp_tdma_chan {
110110
struct tasklet_struct tasklet;
111111

112112
struct mmp_tdma_desc *desc_arr;
113-
phys_addr_t desc_arr_phys;
113+
dma_addr_t desc_arr_phys;
114114
int desc_num;
115115
enum dma_transfer_direction dir;
116116
dma_addr_t dev_addr;
@@ -166,9 +166,12 @@ static void mmp_tdma_enable_chan(struct mmp_tdma_chan *tdmac)
166166
static int mmp_tdma_disable_chan(struct dma_chan *chan)
167167
{
168168
struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
169+
u32 tdcr;
169170

170-
writel(readl(tdmac->reg_base + TDCR) & ~TDCR_CHANEN,
171-
tdmac->reg_base + TDCR);
171+
tdcr = readl(tdmac->reg_base + TDCR);
172+
tdcr |= TDCR_ABR;
173+
tdcr &= ~TDCR_CHANEN;
174+
writel(tdcr, tdmac->reg_base + TDCR);
172175

173176
tdmac->status = DMA_COMPLETE;
174177

@@ -296,12 +299,27 @@ static int mmp_tdma_clear_chan_irq(struct mmp_tdma_chan *tdmac)
296299
return -EAGAIN;
297300
}
298301

302+
static size_t mmp_tdma_get_pos(struct mmp_tdma_chan *tdmac)
303+
{
304+
size_t reg;
305+
306+
if (tdmac->idx == 0) {
307+
reg = __raw_readl(tdmac->reg_base + TDSAR);
308+
reg -= tdmac->desc_arr[0].src_addr;
309+
} else if (tdmac->idx == 1) {
310+
reg = __raw_readl(tdmac->reg_base + TDDAR);
311+
reg -= tdmac->desc_arr[0].dst_addr;
312+
} else
313+
return -EINVAL;
314+
315+
return reg;
316+
}
317+
299318
static irqreturn_t mmp_tdma_chan_handler(int irq, void *dev_id)
300319
{
301320
struct mmp_tdma_chan *tdmac = dev_id;
302321

303322
if (mmp_tdma_clear_chan_irq(tdmac) == 0) {
304-
tdmac->pos = (tdmac->pos + tdmac->period_len) % tdmac->buf_len;
305323
tasklet_schedule(&tdmac->tasklet);
306324
return IRQ_HANDLED;
307325
} else
@@ -343,7 +361,7 @@ static void mmp_tdma_free_descriptor(struct mmp_tdma_chan *tdmac)
343361
int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc);
344362

345363
gpool = tdmac->pool;
346-
if (tdmac->desc_arr)
364+
if (gpool && tdmac->desc_arr)
347365
gen_pool_free(gpool, (unsigned long)tdmac->desc_arr,
348366
size);
349367
tdmac->desc_arr = NULL;
@@ -499,6 +517,7 @@ static enum dma_status mmp_tdma_tx_status(struct dma_chan *chan,
499517
{
500518
struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
501519

520+
tdmac->pos = mmp_tdma_get_pos(tdmac);
502521
dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie,
503522
tdmac->buf_len - tdmac->pos);
504523

@@ -610,7 +629,7 @@ static int mmp_tdma_probe(struct platform_device *pdev)
610629
int i, ret;
611630
int irq = 0, irq_num = 0;
612631
int chan_num = TDMA_CHANNEL_NUM;
613-
struct gen_pool *pool;
632+
struct gen_pool *pool = NULL;
614633

615634
of_id = of_match_device(mmp_tdma_dt_ids, &pdev->dev);
616635
if (of_id)

drivers/dma/qcom_bam_dma.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ static const struct reg_offset_data bam_v1_4_reg_info[] = {
162162
[BAM_P_IRQ_STTS] = { 0x1010, 0x1000, 0x00, 0x00 },
163163
[BAM_P_IRQ_CLR] = { 0x1014, 0x1000, 0x00, 0x00 },
164164
[BAM_P_IRQ_EN] = { 0x1018, 0x1000, 0x00, 0x00 },
165-
[BAM_P_EVNT_DEST_ADDR] = { 0x102C, 0x00, 0x1000, 0x00 },
166-
[BAM_P_EVNT_REG] = { 0x1018, 0x00, 0x1000, 0x00 },
167-
[BAM_P_SW_OFSTS] = { 0x1000, 0x00, 0x1000, 0x00 },
165+
[BAM_P_EVNT_DEST_ADDR] = { 0x182C, 0x00, 0x1000, 0x00 },
166+
[BAM_P_EVNT_REG] = { 0x1818, 0x00, 0x1000, 0x00 },
167+
[BAM_P_SW_OFSTS] = { 0x1800, 0x00, 0x1000, 0x00 },
168168
[BAM_P_DATA_FIFO_ADDR] = { 0x1824, 0x00, 0x1000, 0x00 },
169169
[BAM_P_DESC_FIFO_ADDR] = { 0x181C, 0x00, 0x1000, 0x00 },
170170
[BAM_P_EVNT_GEN_TRSHLD] = { 0x1828, 0x00, 0x1000, 0x00 },
@@ -1143,6 +1143,10 @@ static int bam_dma_probe(struct platform_device *pdev)
11431143
dma_cap_set(DMA_SLAVE, bdev->common.cap_mask);
11441144

11451145
/* initialize dmaengine apis */
1146+
bdev->common.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
1147+
bdev->common.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
1148+
bdev->common.src_addr_widths = DMA_SLAVE_BUSWIDTH_4_BYTES;
1149+
bdev->common.dst_addr_widths = DMA_SLAVE_BUSWIDTH_4_BYTES;
11461150
bdev->common.device_alloc_chan_resources = bam_alloc_chan;
11471151
bdev->common.device_free_chan_resources = bam_free_chan;
11481152
bdev->common.device_prep_slave_sg = bam_prep_slave_sg;

drivers/dma/sh/shdmac.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,12 @@ static void sh_dmae_chan_remove(struct sh_dmae_device *shdev)
582582
}
583583
}
584584

585-
static void sh_dmae_shutdown(struct platform_device *pdev)
586-
{
587-
struct sh_dmae_device *shdev = platform_get_drvdata(pdev);
588-
sh_dmae_ctl_stop(shdev);
589-
}
590-
591585
#ifdef CONFIG_PM
592586
static int sh_dmae_runtime_suspend(struct device *dev)
593587
{
588+
struct sh_dmae_device *shdev = dev_get_drvdata(dev);
589+
590+
sh_dmae_ctl_stop(shdev);
594591
return 0;
595592
}
596593

@@ -605,6 +602,9 @@ static int sh_dmae_runtime_resume(struct device *dev)
605602
#ifdef CONFIG_PM_SLEEP
606603
static int sh_dmae_suspend(struct device *dev)
607604
{
605+
struct sh_dmae_device *shdev = dev_get_drvdata(dev);
606+
607+
sh_dmae_ctl_stop(shdev);
608608
return 0;
609609
}
610610

@@ -929,13 +929,12 @@ static int sh_dmae_remove(struct platform_device *pdev)
929929
}
930930

931931
static struct platform_driver sh_dmae_driver = {
932-
.driver = {
932+
.driver = {
933933
.pm = &sh_dmae_pm,
934934
.name = SH_DMAE_DRV_NAME,
935935
.of_match_table = sh_dmae_of_match,
936936
},
937937
.remove = sh_dmae_remove,
938-
.shutdown = sh_dmae_shutdown,
939938
};
940939

941940
static int __init sh_dmae_init(void)

0 commit comments

Comments
 (0)