Skip to content

Commit 23db0ed

Browse files
committed
Merge tag 'dmaengine-fix-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine fixes from Vinod Koul: "Bunch of minor driver fixes for drivers in this cycle: - Kernel doc warning documentation fixes - apple driver fix for register access - amd driver dropping private dma_ops - freescale cleanup path fix - refcount fix for mv_xor driver - null pointer deref fix for at_xdmac driver - GENMASK to GENMASK_ULL fix for loongson2 apb driver - Tegra driver fix for correcting dma status" * tag 'dmaengine-fix-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: dmaengine: tegra: Return correct DMA status when paused dmaengine: mv_xor: fix child node refcount handling in early exit dmaengine: fsl-edma: implement the cleanup path of fsl_edma3_attach_pd() dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs dmaengine: apple-admac: Avoid accessing registers in probe linux/dmaengine.h: fix a few kernel-doc warnings dmaengine: loongson2-apb: Change GENMASK to GENMASK_ULL dmaengine: dw: Select only supported masters for ACPI devices dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset
2 parents 6fcb22e + ebc0086 commit 23db0ed

File tree

13 files changed

+92
-34
lines changed

13 files changed

+92
-34
lines changed

drivers/dma/amd/qdma/qdma.c

+12-16
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include <linux/bitfield.h>
88
#include <linux/bitops.h>
99
#include <linux/dmaengine.h>
10+
#include <linux/dma-mapping.h>
1011
#include <linux/module.h>
1112
#include <linux/mod_devicetable.h>
12-
#include <linux/dma-map-ops.h>
1313
#include <linux/platform_device.h>
1414
#include <linux/platform_data/amd_qdma.h>
1515
#include <linux/regmap.h>
@@ -492,18 +492,9 @@ static int qdma_device_verify(struct qdma_device *qdev)
492492

493493
static int qdma_device_setup(struct qdma_device *qdev)
494494
{
495-
struct device *dev = &qdev->pdev->dev;
496495
u32 ring_sz = QDMA_DEFAULT_RING_SIZE;
497496
int ret = 0;
498497

499-
while (dev && get_dma_ops(dev))
500-
dev = dev->parent;
501-
if (!dev) {
502-
qdma_err(qdev, "dma device not found");
503-
return -EINVAL;
504-
}
505-
set_dma_ops(&qdev->pdev->dev, get_dma_ops(dev));
506-
507498
ret = qdma_setup_fmap_context(qdev);
508499
if (ret) {
509500
qdma_err(qdev, "Failed setup fmap context");
@@ -548,11 +539,12 @@ static void qdma_free_queue_resources(struct dma_chan *chan)
548539
{
549540
struct qdma_queue *queue = to_qdma_queue(chan);
550541
struct qdma_device *qdev = queue->qdev;
551-
struct device *dev = qdev->dma_dev.dev;
542+
struct qdma_platdata *pdata;
552543

553544
qdma_clear_queue_context(queue);
554545
vchan_free_chan_resources(&queue->vchan);
555-
dma_free_coherent(dev, queue->ring_size * QDMA_MM_DESC_SIZE,
546+
pdata = dev_get_platdata(&qdev->pdev->dev);
547+
dma_free_coherent(pdata->dma_dev, queue->ring_size * QDMA_MM_DESC_SIZE,
556548
queue->desc_base, queue->dma_desc_base);
557549
}
558550

@@ -565,15 +557,17 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
565557
struct qdma_queue *queue = to_qdma_queue(chan);
566558
struct qdma_device *qdev = queue->qdev;
567559
struct qdma_ctxt_sw_desc desc;
560+
struct qdma_platdata *pdata;
568561
size_t size;
569562
int ret;
570563

571564
ret = qdma_clear_queue_context(queue);
572565
if (ret)
573566
return ret;
574567

568+
pdata = dev_get_platdata(&qdev->pdev->dev);
575569
size = queue->ring_size * QDMA_MM_DESC_SIZE;
576-
queue->desc_base = dma_alloc_coherent(qdev->dma_dev.dev, size,
570+
queue->desc_base = dma_alloc_coherent(pdata->dma_dev, size,
577571
&queue->dma_desc_base,
578572
GFP_KERNEL);
579573
if (!queue->desc_base) {
@@ -588,7 +582,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
588582
if (ret) {
589583
qdma_err(qdev, "Failed to setup SW desc ctxt for %s",
590584
chan->name);
591-
dma_free_coherent(qdev->dma_dev.dev, size, queue->desc_base,
585+
dma_free_coherent(pdata->dma_dev, size, queue->desc_base,
592586
queue->dma_desc_base);
593587
return ret;
594588
}
@@ -948,8 +942,9 @@ static int qdma_init_error_irq(struct qdma_device *qdev)
948942

949943
static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)
950944
{
951-
u32 ctxt[QDMA_CTXT_REGMAP_LEN];
945+
struct qdma_platdata *pdata = dev_get_platdata(&qdev->pdev->dev);
952946
struct device *dev = &qdev->pdev->dev;
947+
u32 ctxt[QDMA_CTXT_REGMAP_LEN];
953948
struct qdma_intr_ring *ring;
954949
struct qdma_ctxt_intr intr_ctxt;
955950
u32 vector;
@@ -969,7 +964,8 @@ static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)
969964
ring->msix_id = qdev->err_irq_idx + i + 1;
970965
ring->ridx = i;
971966
ring->color = 1;
972-
ring->base = dmam_alloc_coherent(dev, QDMA_INTR_RING_SIZE,
967+
ring->base = dmam_alloc_coherent(pdata->dma_dev,
968+
QDMA_INTR_RING_SIZE,
973969
&ring->dev_base, GFP_KERNEL);
974970
if (!ring->base) {
975971
qdma_err(qdev, "Failed to alloc intr ring %d", i);

drivers/dma/apple-admac.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ static int admac_alloc_sram_carveout(struct admac_data *ad,
153153
{
154154
struct admac_sram *sram;
155155
int i, ret = 0, nblocks;
156+
ad->txcache.size = readl_relaxed(ad->base + REG_TX_SRAM_SIZE);
157+
ad->rxcache.size = readl_relaxed(ad->base + REG_RX_SRAM_SIZE);
156158

157159
if (dir == DMA_MEM_TO_DEV)
158160
sram = &ad->txcache;
@@ -912,12 +914,7 @@ static int admac_probe(struct platform_device *pdev)
912914
goto free_irq;
913915
}
914916

915-
ad->txcache.size = readl_relaxed(ad->base + REG_TX_SRAM_SIZE);
916-
ad->rxcache.size = readl_relaxed(ad->base + REG_RX_SRAM_SIZE);
917-
918917
dev_info(&pdev->dev, "Audio DMA Controller\n");
919-
dev_info(&pdev->dev, "imprint %x TX cache %u RX cache %u\n",
920-
readl_relaxed(ad->base + REG_IMPRINT), ad->txcache.size, ad->rxcache.size);
921918

922919
return 0;
923920

drivers/dma/at_xdmac.c

+2
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,8 @@ at_xdmac_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value,
13631363
return NULL;
13641364

13651365
desc = at_xdmac_memset_create_desc(chan, atchan, dest, len, value);
1366+
if (!desc)
1367+
return NULL;
13661368
list_add_tail(&desc->desc_node, &desc->descs_list);
13671369

13681370
desc->tx_dma_desc.cookie = -EBUSY;

drivers/dma/dw/acpi.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
1010
{
11+
struct dw_dma *dw = to_dw_dma(chan->device);
12+
struct dw_dma_chip_pdata *data = dev_get_drvdata(dw->dma.dev);
1113
struct acpi_dma_spec *dma_spec = param;
1214
struct dw_dma_slave slave = {
1315
.dma_dev = dma_spec->dev,
1416
.src_id = dma_spec->slave_id,
1517
.dst_id = dma_spec->slave_id,
16-
.m_master = 0,
17-
.p_master = 1,
18+
.m_master = data->m_master,
19+
.p_master = data->p_master,
1820
};
1921

2022
return dw_dma_filter(chan, &slave);

drivers/dma/dw/internal.h

+8
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ struct dw_dma_chip_pdata {
5151
int (*probe)(struct dw_dma_chip *chip);
5252
int (*remove)(struct dw_dma_chip *chip);
5353
struct dw_dma_chip *chip;
54+
u8 m_master;
55+
u8 p_master;
5456
};
5557

5658
static __maybe_unused const struct dw_dma_chip_pdata dw_dma_chip_pdata = {
5759
.probe = dw_dma_probe,
5860
.remove = dw_dma_remove,
61+
.m_master = 0,
62+
.p_master = 1,
5963
};
6064

6165
static const struct dw_dma_platform_data idma32_pdata = {
@@ -72,6 +76,8 @@ static __maybe_unused const struct dw_dma_chip_pdata idma32_chip_pdata = {
7276
.pdata = &idma32_pdata,
7377
.probe = idma32_dma_probe,
7478
.remove = idma32_dma_remove,
79+
.m_master = 0,
80+
.p_master = 0,
7581
};
7682

7783
static const struct dw_dma_platform_data xbar_pdata = {
@@ -88,6 +94,8 @@ static __maybe_unused const struct dw_dma_chip_pdata xbar_chip_pdata = {
8894
.pdata = &xbar_pdata,
8995
.probe = idma32_dma_probe,
9096
.remove = idma32_dma_remove,
97+
.m_master = 0,
98+
.p_master = 0,
9199
};
92100

93101
#endif /* _DMA_DW_INTERNAL_H */

drivers/dma/dw/pci.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
5656
if (ret)
5757
return ret;
5858

59-
dw_dma_acpi_controller_register(chip->dw);
60-
6159
pci_set_drvdata(pdev, data);
6260

61+
dw_dma_acpi_controller_register(chip->dw);
62+
6363
return 0;
6464
}
6565

drivers/dma/fsl-edma-common.h

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ struct fsl_edma_chan {
166166
struct work_struct issue_worker;
167167
struct platform_device *pdev;
168168
struct device *pd_dev;
169+
struct device_link *pd_dev_link;
169170
u32 srcid;
170171
struct clk *clk;
171172
int priority;

drivers/dma/fsl-edma-main.c

+36-5
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,33 @@ static const struct of_device_id fsl_edma_dt_ids[] = {
417417
};
418418
MODULE_DEVICE_TABLE(of, fsl_edma_dt_ids);
419419

420+
static void fsl_edma3_detach_pd(struct fsl_edma_engine *fsl_edma)
421+
{
422+
struct fsl_edma_chan *fsl_chan;
423+
int i;
424+
425+
for (i = 0; i < fsl_edma->n_chans; i++) {
426+
if (fsl_edma->chan_masked & BIT(i))
427+
continue;
428+
fsl_chan = &fsl_edma->chans[i];
429+
if (fsl_chan->pd_dev_link)
430+
device_link_del(fsl_chan->pd_dev_link);
431+
if (fsl_chan->pd_dev) {
432+
dev_pm_domain_detach(fsl_chan->pd_dev, false);
433+
pm_runtime_dont_use_autosuspend(fsl_chan->pd_dev);
434+
pm_runtime_set_suspended(fsl_chan->pd_dev);
435+
}
436+
}
437+
}
438+
439+
static void devm_fsl_edma3_detach_pd(void *data)
440+
{
441+
fsl_edma3_detach_pd(data);
442+
}
443+
420444
static int fsl_edma3_attach_pd(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma)
421445
{
422446
struct fsl_edma_chan *fsl_chan;
423-
struct device_link *link;
424447
struct device *pd_chan;
425448
struct device *dev;
426449
int i;
@@ -436,15 +459,16 @@ static int fsl_edma3_attach_pd(struct platform_device *pdev, struct fsl_edma_eng
436459
pd_chan = dev_pm_domain_attach_by_id(dev, i);
437460
if (IS_ERR_OR_NULL(pd_chan)) {
438461
dev_err(dev, "Failed attach pd %d\n", i);
439-
return -EINVAL;
462+
goto detach;
440463
}
441464

442-
link = device_link_add(dev, pd_chan, DL_FLAG_STATELESS |
465+
fsl_chan->pd_dev_link = device_link_add(dev, pd_chan, DL_FLAG_STATELESS |
443466
DL_FLAG_PM_RUNTIME |
444467
DL_FLAG_RPM_ACTIVE);
445-
if (!link) {
468+
if (!fsl_chan->pd_dev_link) {
446469
dev_err(dev, "Failed to add device_link to %d\n", i);
447-
return -EINVAL;
470+
dev_pm_domain_detach(pd_chan, false);
471+
goto detach;
448472
}
449473

450474
fsl_chan->pd_dev = pd_chan;
@@ -455,6 +479,10 @@ static int fsl_edma3_attach_pd(struct platform_device *pdev, struct fsl_edma_eng
455479
}
456480

457481
return 0;
482+
483+
detach:
484+
fsl_edma3_detach_pd(fsl_edma);
485+
return -EINVAL;
458486
}
459487

460488
static int fsl_edma_probe(struct platform_device *pdev)
@@ -544,6 +572,9 @@ static int fsl_edma_probe(struct platform_device *pdev)
544572
ret = fsl_edma3_attach_pd(pdev, fsl_edma);
545573
if (ret)
546574
return ret;
575+
ret = devm_add_action_or_reset(&pdev->dev, devm_fsl_edma3_detach_pd, fsl_edma);
576+
if (ret)
577+
return ret;
547578
}
548579

549580
if (drvdata->flags & FSL_EDMA_DRV_TCD64)

drivers/dma/loongson2-apb-dma.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define LDMA_ASK_VALID BIT(2)
3232
#define LDMA_START BIT(3) /* DMA start operation */
3333
#define LDMA_STOP BIT(4) /* DMA stop operation */
34-
#define LDMA_CONFIG_MASK GENMASK(4, 0) /* DMA controller config bits mask */
34+
#define LDMA_CONFIG_MASK GENMASK_ULL(4, 0) /* DMA controller config bits mask */
3535

3636
/* Bitfields in ndesc_addr field of HW descriptor */
3737
#define LDMA_DESC_EN BIT(0) /*1: The next descriptor is valid */

drivers/dma/mv_xor.c

+2
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,7 @@ static int mv_xor_probe(struct platform_device *pdev)
13881388
irq = irq_of_parse_and_map(np, 0);
13891389
if (!irq) {
13901390
ret = -ENODEV;
1391+
of_node_put(np);
13911392
goto err_channel_add;
13921393
}
13931394

@@ -1396,6 +1397,7 @@ static int mv_xor_probe(struct platform_device *pdev)
13961397
if (IS_ERR(chan)) {
13971398
ret = PTR_ERR(chan);
13981399
irq_dispose_mapping(irq);
1400+
of_node_put(np);
13991401
goto err_channel_add;
14001402
}
14011403

drivers/dma/tegra186-gpc-dma.c

+10
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)