Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+92 -34
+12 -16
drivers/dma/amd/qdma/qdma.c
··· 7 7 #include <linux/bitfield.h> 8 8 #include <linux/bitops.h> 9 9 #include <linux/dmaengine.h> 10 + #include <linux/dma-mapping.h> 10 11 #include <linux/module.h> 11 12 #include <linux/mod_devicetable.h> 12 - #include <linux/dma-map-ops.h> 13 13 #include <linux/platform_device.h> 14 14 #include <linux/platform_data/amd_qdma.h> 15 15 #include <linux/regmap.h> ··· 492 492 493 493 static int qdma_device_setup(struct qdma_device *qdev) 494 494 { 495 - struct device *dev = &qdev->pdev->dev; 496 495 u32 ring_sz = QDMA_DEFAULT_RING_SIZE; 497 496 int ret = 0; 498 - 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 497 507 498 ret = qdma_setup_fmap_context(qdev); 508 499 if (ret) { ··· 539 548 { 540 549 struct qdma_queue *queue = to_qdma_queue(chan); 541 550 struct qdma_device *qdev = queue->qdev; 542 - struct device *dev = qdev->dma_dev.dev; 551 + struct qdma_platdata *pdata; 543 552 544 553 qdma_clear_queue_context(queue); 545 554 vchan_free_chan_resources(&queue->vchan); 546 - dma_free_coherent(dev, queue->ring_size * QDMA_MM_DESC_SIZE, 555 + pdata = dev_get_platdata(&qdev->pdev->dev); 556 + dma_free_coherent(pdata->dma_dev, queue->ring_size * QDMA_MM_DESC_SIZE, 547 557 queue->desc_base, queue->dma_desc_base); 548 558 } 549 559 ··· 557 565 struct qdma_queue *queue = to_qdma_queue(chan); 558 566 struct qdma_device *qdev = queue->qdev; 559 567 struct qdma_ctxt_sw_desc desc; 568 + struct qdma_platdata *pdata; 560 569 size_t size; 561 570 int ret; 562 571 ··· 565 572 if (ret) 566 573 return ret; 567 574 575 + pdata = dev_get_platdata(&qdev->pdev->dev); 568 576 size = queue->ring_size * QDMA_MM_DESC_SIZE; 569 - queue->desc_base = dma_alloc_coherent(qdev->dma_dev.dev, size, 577 + queue->desc_base = dma_alloc_coherent(pdata->dma_dev, size, 570 578 &queue->dma_desc_base, 571 579 GFP_KERNEL); 572 580 if (!queue->desc_base) { ··· 582 588 if (ret) { 583 589 qdma_err(qdev, "Failed to setup SW desc ctxt for %s", 584 590 chan->name); 585 - dma_free_coherent(qdev->dma_dev.dev, size, queue->desc_base, 591 + dma_free_coherent(pdata->dma_dev, size, queue->desc_base, 586 592 queue->dma_desc_base); 587 593 return ret; 588 594 } ··· 942 948 943 949 static int qdmam_alloc_qintr_rings(struct qdma_device *qdev) 944 950 { 945 - u32 ctxt[QDMA_CTXT_REGMAP_LEN]; 951 + struct qdma_platdata *pdata = dev_get_platdata(&qdev->pdev->dev); 946 952 struct device *dev = &qdev->pdev->dev; 953 + u32 ctxt[QDMA_CTXT_REGMAP_LEN]; 947 954 struct qdma_intr_ring *ring; 948 955 struct qdma_ctxt_intr intr_ctxt; 949 956 u32 vector; ··· 964 969 ring->msix_id = qdev->err_irq_idx + i + 1; 965 970 ring->ridx = i; 966 971 ring->color = 1; 967 - ring->base = dmam_alloc_coherent(dev, QDMA_INTR_RING_SIZE, 972 + ring->base = dmam_alloc_coherent(pdata->dma_dev, 973 + QDMA_INTR_RING_SIZE, 968 974 &ring->dev_base, GFP_KERNEL); 969 975 if (!ring->base) { 970 976 qdma_err(qdev, "Failed to alloc intr ring %d", i);
+2 -5
drivers/dma/apple-admac.c
··· 153 153 { 154 154 struct admac_sram *sram; 155 155 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); 156 158 157 159 if (dir == DMA_MEM_TO_DEV) 158 160 sram = &ad->txcache; ··· 914 912 goto free_irq; 915 913 } 916 914 917 - ad->txcache.size = readl_relaxed(ad->base + REG_TX_SRAM_SIZE); 918 - ad->rxcache.size = readl_relaxed(ad->base + REG_RX_SRAM_SIZE); 919 - 920 915 dev_info(&pdev->dev, "Audio DMA Controller\n"); 921 - dev_info(&pdev->dev, "imprint %x TX cache %u RX cache %u\n", 922 - readl_relaxed(ad->base + REG_IMPRINT), ad->txcache.size, ad->rxcache.size); 923 916 924 917 return 0; 925 918
+2
drivers/dma/at_xdmac.c
··· 1363 1363 return NULL; 1364 1364 1365 1365 desc = at_xdmac_memset_create_desc(chan, atchan, dest, len, value); 1366 + if (!desc) 1367 + return NULL; 1366 1368 list_add_tail(&desc->desc_node, &desc->descs_list); 1367 1369 1368 1370 desc->tx_dma_desc.cookie = -EBUSY;
+4 -2
drivers/dma/dw/acpi.c
··· 8 8 9 9 static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param) 10 10 { 11 + struct dw_dma *dw = to_dw_dma(chan->device); 12 + struct dw_dma_chip_pdata *data = dev_get_drvdata(dw->dma.dev); 11 13 struct acpi_dma_spec *dma_spec = param; 12 14 struct dw_dma_slave slave = { 13 15 .dma_dev = dma_spec->dev, 14 16 .src_id = dma_spec->slave_id, 15 17 .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, 18 20 }; 19 21 20 22 return dw_dma_filter(chan, &slave);
+8
drivers/dma/dw/internal.h
··· 51 51 int (*probe)(struct dw_dma_chip *chip); 52 52 int (*remove)(struct dw_dma_chip *chip); 53 53 struct dw_dma_chip *chip; 54 + u8 m_master; 55 + u8 p_master; 54 56 }; 55 57 56 58 static __maybe_unused const struct dw_dma_chip_pdata dw_dma_chip_pdata = { 57 59 .probe = dw_dma_probe, 58 60 .remove = dw_dma_remove, 61 + .m_master = 0, 62 + .p_master = 1, 59 63 }; 60 64 61 65 static const struct dw_dma_platform_data idma32_pdata = { ··· 76 72 .pdata = &idma32_pdata, 77 73 .probe = idma32_dma_probe, 78 74 .remove = idma32_dma_remove, 75 + .m_master = 0, 76 + .p_master = 0, 79 77 }; 80 78 81 79 static const struct dw_dma_platform_data xbar_pdata = { ··· 94 88 .pdata = &xbar_pdata, 95 89 .probe = idma32_dma_probe, 96 90 .remove = idma32_dma_remove, 91 + .m_master = 0, 92 + .p_master = 0, 97 93 }; 98 94 99 95 #endif /* _DMA_DW_INTERNAL_H */
+2 -2
drivers/dma/dw/pci.c
··· 56 56 if (ret) 57 57 return ret; 58 58 59 - dw_dma_acpi_controller_register(chip->dw); 60 - 61 59 pci_set_drvdata(pdev, data); 60 + 61 + dw_dma_acpi_controller_register(chip->dw); 62 62 63 63 return 0; 64 64 }
+1
drivers/dma/fsl-edma-common.h
··· 166 166 struct work_struct issue_worker; 167 167 struct platform_device *pdev; 168 168 struct device *pd_dev; 169 + struct device_link *pd_dev_link; 169 170 u32 srcid; 170 171 struct clk *clk; 171 172 int priority;
+36 -5
drivers/dma/fsl-edma-main.c
··· 417 417 }; 418 418 MODULE_DEVICE_TABLE(of, fsl_edma_dt_ids); 419 419 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 + 420 444 static int fsl_edma3_attach_pd(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) 421 445 { 422 446 struct fsl_edma_chan *fsl_chan; 423 - struct device_link *link; 424 447 struct device *pd_chan; 425 448 struct device *dev; 426 449 int i; ··· 459 436 pd_chan = dev_pm_domain_attach_by_id(dev, i); 460 437 if (IS_ERR_OR_NULL(pd_chan)) { 461 438 dev_err(dev, "Failed attach pd %d\n", i); 462 - return -EINVAL; 439 + goto detach; 463 440 } 464 441 465 - link = device_link_add(dev, pd_chan, DL_FLAG_STATELESS | 442 + fsl_chan->pd_dev_link = device_link_add(dev, pd_chan, DL_FLAG_STATELESS | 466 443 DL_FLAG_PM_RUNTIME | 467 444 DL_FLAG_RPM_ACTIVE); 468 - if (!link) { 445 + if (!fsl_chan->pd_dev_link) { 469 446 dev_err(dev, "Failed to add device_link to %d\n", i); 470 - return -EINVAL; 447 + dev_pm_domain_detach(pd_chan, false); 448 + goto detach; 471 449 } 472 450 473 451 fsl_chan->pd_dev = pd_chan; ··· 479 455 } 480 456 481 457 return 0; 458 + 459 + detach: 460 + fsl_edma3_detach_pd(fsl_edma); 461 + return -EINVAL; 482 462 } 483 463 484 464 static int fsl_edma_probe(struct platform_device *pdev) ··· 570 542 571 543 if (drvdata->flags & FSL_EDMA_DRV_HAS_PD) { 572 544 ret = fsl_edma3_attach_pd(pdev, fsl_edma); 545 + if (ret) 546 + return ret; 547 + ret = devm_add_action_or_reset(&pdev->dev, devm_fsl_edma3_detach_pd, fsl_edma); 573 548 if (ret) 574 549 return ret; 575 550 }
+1 -1
drivers/dma/loongson2-apb-dma.c
··· 31 31 #define LDMA_ASK_VALID BIT(2) 32 32 #define LDMA_START BIT(3) /* DMA start operation */ 33 33 #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 */ 35 35 36 36 /* Bitfields in ndesc_addr field of HW descriptor */ 37 37 #define LDMA_DESC_EN BIT(0) /*1: The next descriptor is valid */
+2
drivers/dma/mv_xor.c
··· 1388 1388 irq = irq_of_parse_and_map(np, 0); 1389 1389 if (!irq) { 1390 1390 ret = -ENODEV; 1391 + of_node_put(np); 1391 1392 goto err_channel_add; 1392 1393 } 1393 1394 ··· 1397 1396 if (IS_ERR(chan)) { 1398 1397 ret = PTR_ERR(chan); 1399 1398 irq_dispose_mapping(irq); 1399 + of_node_put(np); 1400 1400 goto err_channel_add; 1401 1401 } 1402 1402
+10
drivers/dma/tegra186-gpc-dma.c
··· 231 231 bool config_init; 232 232 char name[30]; 233 233 enum dma_transfer_direction sid_dir; 234 + enum dma_status status; 234 235 int id; 235 236 int irq; 236 237 int slave_id; ··· 394 393 tegra_dma_dump_chan_regs(tdc); 395 394 } 396 395 396 + tdc->status = DMA_PAUSED; 397 + 397 398 return ret; 398 399 } 399 400 ··· 422 419 val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); 423 420 val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE; 424 421 tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); 422 + 423 + tdc->status = DMA_IN_PROGRESS; 425 424 } 426 425 427 426 static int tegra_dma_device_resume(struct dma_chan *dc) ··· 549 544 550 545 tegra_dma_sid_free(tdc); 551 546 tdc->dma_desc = NULL; 547 + tdc->status = DMA_COMPLETE; 552 548 } 553 549 554 550 static void tegra_dma_chan_decode_error(struct tegra_dma_channel *tdc, ··· 722 716 tdc->dma_desc = NULL; 723 717 } 724 718 719 + tdc->status = DMA_COMPLETE; 725 720 tegra_dma_sid_free(tdc); 726 721 vchan_get_all_descriptors(&tdc->vc, &head); 727 722 spin_unlock_irqrestore(&tdc->vc.lock, flags); ··· 775 768 ret = dma_cookie_status(dc, cookie, txstate); 776 769 if (ret == DMA_COMPLETE) 777 770 return ret; 771 + 772 + if (tdc->status == DMA_PAUSED) 773 + ret = DMA_PAUSED; 778 774 779 775 spin_lock_irqsave(&tdc->vc.lock, flags); 780 776 vd = vchan_find_desc(&tdc->vc, cookie);
+10 -3
include/linux/dmaengine.h
··· 84 84 DMA_TRANS_NONE, 85 85 }; 86 86 87 - /** 87 + /* 88 88 * Interleaved Transfer Request 89 89 * ---------------------------- 90 90 * A chunk is collection of contiguous bytes to be transferred. ··· 223 223 }; 224 224 225 225 /** 226 - * enum pq_check_flags - result of async_{xor,pq}_zero_sum operations 226 + * enum sum_check_flags - result of async_{xor,pq}_zero_sum operations 227 227 * @SUM_CHECK_P_RESULT - 1 if xor zero sum error, 0 otherwise 228 228 * @SUM_CHECK_Q_RESULT - 1 if reed-solomon zero sum error, 0 otherwise 229 229 */ ··· 286 286 * pointer to the engine's metadata area 287 287 * 4. Read out the metadata from the pointer 288 288 * 289 - * Note: the two mode is not compatible and clients must use one mode for a 289 + * Warning: the two modes are not compatible and clients must use one mode for a 290 290 * descriptor. 291 291 */ 292 292 enum dma_desc_metadata_mode { ··· 594 594 * @phys: physical address of the descriptor 595 595 * @chan: target channel for this operation 596 596 * @tx_submit: accept the descriptor, assign ordered cookie and mark the 597 + * @desc_free: driver's callback function to free a resusable descriptor 598 + * after completion 597 599 * descriptor pending. To be pushed on .issue_pending() call 598 600 * @callback: routine to call after this operation is complete 601 + * @callback_result: error result from a DMA transaction 599 602 * @callback_param: general parameter to pass to the callback routine 603 + * @unmap: hook for generic DMA unmap data 600 604 * @desc_metadata_mode: core managed metadata mode to protect mixed use of 601 605 * DESC_METADATA_CLIENT or DESC_METADATA_ENGINE. Otherwise 602 606 * DESC_METADATA_NONE ··· 831 827 * @device_prep_dma_memset: prepares a memset operation 832 828 * @device_prep_dma_memset_sg: prepares a memset operation over a scatter list 833 829 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation 830 + * @device_prep_peripheral_dma_vec: prepares a scatter-gather DMA transfer, 831 + * where the address and size of each segment is located in one entry of 832 + * the dma_vec array. 834 833 * @device_prep_slave_sg: prepares a slave dma operation 835 834 * @device_prep_dma_cyclic: prepare a cyclic dma operation suitable for audio. 836 835 * The function takes a buffer of size buf_len. The callback function will
+2
include/linux/platform_data/amd_qdma.h
··· 26 26 * @max_mm_channels: Maximum number of MM DMA channels in each direction 27 27 * @device_map: DMA slave map 28 28 * @irq_index: The index of first IRQ 29 + * @dma_dev: The device pointer for dma operations 29 30 */ 30 31 struct qdma_platdata { 31 32 u32 max_mm_channels; 32 33 u32 irq_index; 33 34 struct dma_slave_map *device_map; 35 + struct device *dma_dev; 34 36 }; 35 37 36 38 #endif /* _PLATDATA_AMD_QDMA_H */