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

Merge tag 'dmaengine-5.2-rc1' of git://git.infradead.org/users/vkoul/slave-dma

Pull dmaengine updates from Vinod Koul:

- Updates to stm32 dma residue calculations

- Interleave dma capability to axi-dmac and support for ZynqMP arch

- Rework of channel assignment for rcar dma

- Debugfs for pl330 driver

- Support for Tegra186/Tegra194, refactoring for new chips and support
for pause/resume

- Updates to axi-dmac, bcm2835, fsl-edma, idma64, imx-sdma, rcar-dmac,
stm32-dma etc

- dev_get_drvdata() updates on few drivers

* tag 'dmaengine-5.2-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (34 commits)
dmaengine: tegra210-adma: restore channel status
dmaengine: tegra210-dma: free dma controller in remove()
dmaengine: tegra210-adma: add pause/resume support
dmaengine: tegra210-adma: add support for Tegra186/Tegra194
Documentation: DT: Add compatibility binding for Tegra186
dmaengine: tegra210-adma: prepare for supporting newer Tegra chips
dmaengine: at_xdmac: remove a stray bottom half unlock
dmaengine: fsl-edma: Adjust indentation
dmaengine: fsl-edma: Fix typo in Vybrid name
dmaengine: stm32-dma: fix residue calculation in stm32-dma
dmaengine: nbpfaxi: Use dev_get_drvdata()
dmaengine: bcm-sba-raid: Use dev_get_drvdata()
dmaengine: stm32-dma: Fix unsigned variable compared with zero
dmaengine: stm32-dma: use platform_get_irq()
dmaengine: rcar-dmac: Update copyright information
dmaengine: imx-sdma: Only check ratio on parts that support 1:1
dmaengine: xgene-dma: fix spelling mistake "descripto" -> "descriptor"
dmaengine: idma64: Move driver name to the header
dmaengine: bcm2835: Drop duplicate capability setting.
dmaengine: pl330: _stop: clear interrupt status
...

+566 -169
+2 -2
Documentation/devicetree/bindings/dma/adi,axi-dmac.txt
··· 18 18 19 19 Required channel sub-node properties: 20 20 - reg: Which channel this node refers to. 21 - - adi,length-width: Width of the DMA transfer length register. 22 21 - adi,source-bus-width, 23 22 adi,destination-bus-width: Width of the source or destination bus in bits. 24 23 - adi,source-bus-type, ··· 27 28 1 (AXI_DMAC_TYPE_AXI_STREAM): Streaming AXI interface 28 29 2 (AXI_DMAC_TYPE_AXI_FIFO): FIFO interface 29 30 30 - Optional channel properties: 31 + Deprecated optional channel properties: 32 + - adi,length-width: Width of the DMA transfer length register. 31 33 - adi,cyclic: Must be set if the channel supports hardware cyclic DMA 32 34 transfers. 33 35 - adi,2d: Must be set if the channel supports hardware 2D DMA transfers.
+3 -1
Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt
··· 4 4 between system memory and the Audio Processing Engine (APE). 5 5 6 6 Required properties: 7 - - compatible: Must be "nvidia,tegra210-adma". 7 + - compatible: Should contain one of the following: 8 + - "nvidia,tegra210-adma": for Tegra210 9 + - "nvidia,tegra186-adma": for Tegra186 and Tegra194 8 10 - reg: Should contain DMA registers location and length. This should be 9 11 a single entry that includes all of the per-channel registers in one 10 12 contiguous bank.
+1 -1
drivers/dma/Kconfig
··· 99 99 100 100 config AXI_DMAC 101 101 tristate "Analog Devices AXI-DMAC DMA support" 102 - depends on MICROBLAZE || NIOS2 || ARCH_ZYNQ || ARCH_SOCFPGA || COMPILE_TEST 102 + depends on MICROBLAZE || NIOS2 || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_SOCFPGA || COMPILE_TEST 103 103 select DMA_ENGINE 104 104 select DMA_VIRTUAL_CHANNELS 105 105 help
+16 -6
drivers/dma/amba-pl08x.c
··· 254 254 * @slave: whether this channel is a device (slave) or for memcpy 255 255 * @signal: the physical DMA request signal which this channel is using 256 256 * @mux_use: count of descriptors using this DMA request signal setting 257 + * @waiting_at: time in jiffies when this channel moved to waiting state 257 258 */ 258 259 struct pl08x_dma_chan { 259 260 struct virt_dma_chan vc; ··· 268 267 bool slave; 269 268 int signal; 270 269 unsigned mux_use; 270 + unsigned long waiting_at; 271 271 }; 272 272 273 273 /** ··· 877 875 if (!ch) { 878 876 dev_dbg(&pl08x->adev->dev, "no physical channel available for xfer on %s\n", plchan->name); 879 877 plchan->state = PL08X_CHAN_WAITING; 878 + plchan->waiting_at = jiffies; 880 879 return; 881 880 } 882 881 ··· 916 913 { 917 914 struct pl08x_driver_data *pl08x = plchan->host; 918 915 struct pl08x_dma_chan *p, *next; 919 - 916 + unsigned long waiting_at; 920 917 retry: 921 918 next = NULL; 919 + waiting_at = jiffies; 922 920 923 - /* Find a waiting virtual channel for the next transfer. */ 921 + /* 922 + * Find a waiting virtual channel for the next transfer. 923 + * To be fair, time when each channel reached waiting state is compared 924 + * to select channel that is waiting for the longest time. 925 + */ 924 926 list_for_each_entry(p, &pl08x->memcpy.channels, vc.chan.device_node) 925 - if (p->state == PL08X_CHAN_WAITING) { 927 + if (p->state == PL08X_CHAN_WAITING && 928 + p->waiting_at <= waiting_at) { 926 929 next = p; 927 - break; 930 + waiting_at = p->waiting_at; 928 931 } 929 932 930 933 if (!next && pl08x->has_slave) { 931 934 list_for_each_entry(p, &pl08x->slave.channels, vc.chan.device_node) 932 - if (p->state == PL08X_CHAN_WAITING) { 935 + if (p->state == PL08X_CHAN_WAITING && 936 + p->waiting_at <= waiting_at) { 933 937 next = p; 934 - break; 938 + waiting_at = p->waiting_at; 935 939 } 936 940 } 937 941
+59 -8
drivers/dma/at_xdmac.c
··· 308 308 return csize; 309 309 }; 310 310 311 + static inline bool at_xdmac_chan_is_peripheral_xfer(u32 cfg) 312 + { 313 + return cfg & AT_XDMAC_CC_TYPE_PER_TRAN; 314 + } 315 + 311 316 static inline u8 at_xdmac_get_dwidth(u32 cfg) 312 317 { 313 318 return (cfg & AT_XDMAC_CC_DWIDTH_MASK) >> AT_XDMAC_CC_DWIDTH_OFFSET; ··· 394 389 at_xdmac_chan_read(atchan, AT_XDMAC_CUBC)); 395 390 396 391 at_xdmac_chan_write(atchan, AT_XDMAC_CID, 0xffffffff); 397 - reg = AT_XDMAC_CIE_RBEIE | AT_XDMAC_CIE_WBEIE | AT_XDMAC_CIE_ROIE; 392 + reg = AT_XDMAC_CIE_RBEIE | AT_XDMAC_CIE_WBEIE; 393 + /* 394 + * Request Overflow Error is only for peripheral synchronized transfers 395 + */ 396 + if (at_xdmac_chan_is_peripheral_xfer(first->lld.mbr_cfg)) 397 + reg |= AT_XDMAC_CIE_ROIE; 398 + 398 399 /* 399 400 * There is no end of list when doing cyclic dma, we need to get 400 401 * an interrupt after each periods. ··· 1586 1575 dmaengine_desc_get_callback_invoke(txd, NULL); 1587 1576 } 1588 1577 1578 + static void at_xdmac_handle_error(struct at_xdmac_chan *atchan) 1579 + { 1580 + struct at_xdmac *atxdmac = to_at_xdmac(atchan->chan.device); 1581 + struct at_xdmac_desc *bad_desc; 1582 + 1583 + /* 1584 + * The descriptor currently at the head of the active list is 1585 + * broken. Since we don't have any way to report errors, we'll 1586 + * just have to scream loudly and try to continue with other 1587 + * descriptors queued (if any). 1588 + */ 1589 + if (atchan->irq_status & AT_XDMAC_CIS_RBEIS) 1590 + dev_err(chan2dev(&atchan->chan), "read bus error!!!"); 1591 + if (atchan->irq_status & AT_XDMAC_CIS_WBEIS) 1592 + dev_err(chan2dev(&atchan->chan), "write bus error!!!"); 1593 + if (atchan->irq_status & AT_XDMAC_CIS_ROIS) 1594 + dev_err(chan2dev(&atchan->chan), "request overflow error!!!"); 1595 + 1596 + spin_lock_bh(&atchan->lock); 1597 + 1598 + /* Channel must be disabled first as it's not done automatically */ 1599 + at_xdmac_write(atxdmac, AT_XDMAC_GD, atchan->mask); 1600 + while (at_xdmac_read(atxdmac, AT_XDMAC_GS) & atchan->mask) 1601 + cpu_relax(); 1602 + 1603 + bad_desc = list_first_entry(&atchan->xfers_list, 1604 + struct at_xdmac_desc, 1605 + xfer_node); 1606 + 1607 + spin_unlock_bh(&atchan->lock); 1608 + 1609 + /* Print bad descriptor's details if needed */ 1610 + dev_dbg(chan2dev(&atchan->chan), 1611 + "%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n", 1612 + __func__, &bad_desc->lld.mbr_sa, &bad_desc->lld.mbr_da, 1613 + bad_desc->lld.mbr_ubc); 1614 + 1615 + /* Then continue with usual descriptor management */ 1616 + } 1617 + 1589 1618 static void at_xdmac_tasklet(unsigned long data) 1590 1619 { 1591 1620 struct at_xdmac_chan *atchan = (struct at_xdmac_chan *)data; ··· 1645 1594 || (atchan->irq_status & error_mask)) { 1646 1595 struct dma_async_tx_descriptor *txd; 1647 1596 1648 - if (atchan->irq_status & AT_XDMAC_CIS_RBEIS) 1649 - dev_err(chan2dev(&atchan->chan), "read bus error!!!"); 1650 - if (atchan->irq_status & AT_XDMAC_CIS_WBEIS) 1651 - dev_err(chan2dev(&atchan->chan), "write bus error!!!"); 1652 - if (atchan->irq_status & AT_XDMAC_CIS_ROIS) 1653 - dev_err(chan2dev(&atchan->chan), "request overflow error!!!"); 1597 + if (atchan->irq_status & error_mask) 1598 + at_xdmac_handle_error(atchan); 1654 1599 1655 1600 spin_lock(&atchan->lock); 1656 1601 desc = list_first_entry(&atchan->xfers_list, 1657 1602 struct at_xdmac_desc, 1658 1603 xfer_node); 1659 1604 dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc); 1660 - BUG_ON(!desc->active_xfer); 1605 + if (!desc->active_xfer) { 1606 + dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting"); 1607 + spin_unlock(&atchan->lock); 1608 + return; 1609 + } 1661 1610 1662 1611 txd = &desc->tx_dma_desc; 1663 1612
+1 -2
drivers/dma/bcm-sba-raid.c
··· 1459 1459 1460 1460 static int sba_debugfs_stats_show(struct seq_file *file, void *offset) 1461 1461 { 1462 - struct platform_device *pdev = to_platform_device(file->private); 1463 - struct sba_device *sba = platform_get_drvdata(pdev); 1462 + struct sba_device *sba = dev_get_drvdata(file->private); 1464 1463 1465 1464 /* Write stats in file */ 1466 1465 sba_write_stats_in_seqfile(sba, file);
-1
drivers/dma/bcm2835-dma.c
··· 891 891 dma_cap_set(DMA_SLAVE, od->ddev.cap_mask); 892 892 dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask); 893 893 dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask); 894 - dma_cap_set(DMA_SLAVE, od->ddev.cap_mask); 895 894 dma_cap_set(DMA_MEMCPY, od->ddev.cap_mask); 896 895 od->ddev.device_alloc_chan_resources = bcm2835_dma_alloc_chan_resources; 897 896 od->ddev.device_free_chan_resources = bcm2835_dma_free_chan_resources;
+83 -33
drivers/dma/dma-axi-dmac.c
··· 166 166 167 167 static bool axi_dmac_check_len(struct axi_dmac_chan *chan, unsigned int len) 168 168 { 169 - if (len == 0 || len > chan->max_length) 169 + if (len == 0) 170 170 return false; 171 171 if ((len & chan->align_mask) != 0) /* Not aligned */ 172 172 return false; ··· 379 379 return desc; 380 380 } 381 381 382 + static struct axi_dmac_sg *axi_dmac_fill_linear_sg(struct axi_dmac_chan *chan, 383 + enum dma_transfer_direction direction, dma_addr_t addr, 384 + unsigned int num_periods, unsigned int period_len, 385 + struct axi_dmac_sg *sg) 386 + { 387 + unsigned int num_segments, i; 388 + unsigned int segment_size; 389 + unsigned int len; 390 + 391 + /* Split into multiple equally sized segments if necessary */ 392 + num_segments = DIV_ROUND_UP(period_len, chan->max_length); 393 + segment_size = DIV_ROUND_UP(period_len, num_segments); 394 + /* Take care of alignment */ 395 + segment_size = ((segment_size - 1) | chan->align_mask) + 1; 396 + 397 + for (i = 0; i < num_periods; i++) { 398 + len = period_len; 399 + 400 + while (len > segment_size) { 401 + if (direction == DMA_DEV_TO_MEM) 402 + sg->dest_addr = addr; 403 + else 404 + sg->src_addr = addr; 405 + sg->x_len = segment_size; 406 + sg->y_len = 1; 407 + sg++; 408 + addr += segment_size; 409 + len -= segment_size; 410 + } 411 + 412 + if (direction == DMA_DEV_TO_MEM) 413 + sg->dest_addr = addr; 414 + else 415 + sg->src_addr = addr; 416 + sg->x_len = len; 417 + sg->y_len = 1; 418 + sg++; 419 + addr += len; 420 + } 421 + 422 + return sg; 423 + } 424 + 382 425 static struct dma_async_tx_descriptor *axi_dmac_prep_slave_sg( 383 426 struct dma_chan *c, struct scatterlist *sgl, 384 427 unsigned int sg_len, enum dma_transfer_direction direction, ··· 429 386 { 430 387 struct axi_dmac_chan *chan = to_axi_dmac_chan(c); 431 388 struct axi_dmac_desc *desc; 389 + struct axi_dmac_sg *dsg; 432 390 struct scatterlist *sg; 391 + unsigned int num_sgs; 433 392 unsigned int i; 434 393 435 394 if (direction != chan->direction) 436 395 return NULL; 437 396 438 - desc = axi_dmac_alloc_desc(sg_len); 397 + num_sgs = 0; 398 + for_each_sg(sgl, sg, sg_len, i) 399 + num_sgs += DIV_ROUND_UP(sg_dma_len(sg), chan->max_length); 400 + 401 + desc = axi_dmac_alloc_desc(num_sgs); 439 402 if (!desc) 440 403 return NULL; 404 + 405 + dsg = desc->sg; 441 406 442 407 for_each_sg(sgl, sg, sg_len, i) { 443 408 if (!axi_dmac_check_addr(chan, sg_dma_address(sg)) || ··· 454 403 return NULL; 455 404 } 456 405 457 - if (direction == DMA_DEV_TO_MEM) 458 - desc->sg[i].dest_addr = sg_dma_address(sg); 459 - else 460 - desc->sg[i].src_addr = sg_dma_address(sg); 461 - desc->sg[i].x_len = sg_dma_len(sg); 462 - desc->sg[i].y_len = 1; 406 + dsg = axi_dmac_fill_linear_sg(chan, direction, sg_dma_address(sg), 1, 407 + sg_dma_len(sg), dsg); 463 408 } 464 409 465 410 desc->cyclic = false; ··· 470 423 { 471 424 struct axi_dmac_chan *chan = to_axi_dmac_chan(c); 472 425 struct axi_dmac_desc *desc; 473 - unsigned int num_periods, i; 426 + unsigned int num_periods, num_segments; 474 427 475 428 if (direction != chan->direction) 476 429 return NULL; ··· 483 436 return NULL; 484 437 485 438 num_periods = buf_len / period_len; 439 + num_segments = DIV_ROUND_UP(period_len, chan->max_length); 486 440 487 - desc = axi_dmac_alloc_desc(num_periods); 441 + desc = axi_dmac_alloc_desc(num_periods * num_segments); 488 442 if (!desc) 489 443 return NULL; 490 444 491 - for (i = 0; i < num_periods; i++) { 492 - if (direction == DMA_DEV_TO_MEM) 493 - desc->sg[i].dest_addr = buf_addr; 494 - else 495 - desc->sg[i].src_addr = buf_addr; 496 - desc->sg[i].x_len = period_len; 497 - desc->sg[i].y_len = 1; 498 - buf_addr += period_len; 499 - } 445 + axi_dmac_fill_linear_sg(chan, direction, buf_addr, num_periods, 446 + period_len, desc->sg); 500 447 501 448 desc->cyclic = true; 502 449 ··· 526 485 527 486 if (chan->hw_2d) { 528 487 if (!axi_dmac_check_len(chan, xt->sgl[0].size) || 529 - !axi_dmac_check_len(chan, xt->numf)) 488 + xt->numf == 0) 530 489 return NULL; 531 490 if (xt->sgl[0].size + dst_icg > chan->max_length || 532 491 xt->sgl[0].size + src_icg > chan->max_length) ··· 618 577 return ret; 619 578 chan->dest_width = val / 8; 620 579 621 - ret = of_property_read_u32(of_chan, "adi,length-width", &val); 622 - if (ret) 623 - return ret; 624 - 625 - if (val >= 32) 626 - chan->max_length = UINT_MAX; 627 - else 628 - chan->max_length = (1ULL << val) - 1; 629 - 630 580 chan->align_mask = max(chan->dest_width, chan->src_width) - 1; 631 581 632 582 if (axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan)) ··· 629 597 else 630 598 chan->direction = DMA_DEV_TO_DEV; 631 599 632 - chan->hw_cyclic = of_property_read_bool(of_chan, "adi,cyclic"); 633 - chan->hw_2d = of_property_read_bool(of_chan, "adi,2d"); 634 - 635 600 return 0; 601 + } 602 + 603 + static void axi_dmac_detect_caps(struct axi_dmac *dmac) 604 + { 605 + struct axi_dmac_chan *chan = &dmac->chan; 606 + 607 + axi_dmac_write(dmac, AXI_DMAC_REG_FLAGS, AXI_DMAC_FLAG_CYCLIC); 608 + if (axi_dmac_read(dmac, AXI_DMAC_REG_FLAGS) == AXI_DMAC_FLAG_CYCLIC) 609 + chan->hw_cyclic = true; 610 + 611 + axi_dmac_write(dmac, AXI_DMAC_REG_Y_LENGTH, 1); 612 + if (axi_dmac_read(dmac, AXI_DMAC_REG_Y_LENGTH) == 1) 613 + chan->hw_2d = true; 614 + 615 + axi_dmac_write(dmac, AXI_DMAC_REG_X_LENGTH, 0xffffffff); 616 + chan->max_length = axi_dmac_read(dmac, AXI_DMAC_REG_X_LENGTH); 617 + if (chan->max_length != UINT_MAX) 618 + chan->max_length++; 636 619 } 637 620 638 621 static int axi_dmac_probe(struct platform_device *pdev) ··· 694 647 of_node_put(of_channels); 695 648 696 649 pdev->dev.dma_parms = &dmac->dma_parms; 697 - dma_set_max_seg_size(&pdev->dev, dmac->chan.max_length); 650 + dma_set_max_seg_size(&pdev->dev, UINT_MAX); 698 651 699 652 dma_dev = &dmac->dma_dev; 700 653 dma_cap_set(DMA_SLAVE, dma_dev->cap_mask); 701 654 dma_cap_set(DMA_CYCLIC, dma_dev->cap_mask); 655 + dma_cap_set(DMA_INTERLEAVE, dma_dev->cap_mask); 702 656 dma_dev->device_free_chan_resources = axi_dmac_free_chan_resources; 703 657 dma_dev->device_tx_status = dma_cookie_status; 704 658 dma_dev->device_issue_pending = axi_dmac_issue_pending; ··· 722 674 ret = clk_prepare_enable(dmac->clk); 723 675 if (ret < 0) 724 676 return ret; 677 + 678 + axi_dmac_detect_caps(dmac); 725 679 726 680 axi_dmac_write(dmac, AXI_DMAC_REG_IRQ_MASK, 0x00); 727 681
+1 -1
drivers/dma/fsl-edma-common.h
··· 136 136 }; 137 137 138 138 enum edma_version { 139 - v1, /* 32ch, Vybdir, mpc57x, etc */ 139 + v1, /* 32ch, Vybrid, mpc57x, etc */ 140 140 v2, /* 64ch Coldfire */ 141 141 }; 142 142
+3 -3
drivers/dma/fsl-edma.c
··· 144 144 fsl_edma_irq_handler, 0, "eDMA", fsl_edma); 145 145 if (ret) { 146 146 dev_err(&pdev->dev, "Can't register eDMA IRQ.\n"); 147 - return ret; 147 + return ret; 148 148 } 149 149 } else { 150 150 ret = devm_request_irq(&pdev->dev, fsl_edma->txirq, 151 151 fsl_edma_tx_handler, 0, "eDMA tx", fsl_edma); 152 152 if (ret) { 153 153 dev_err(&pdev->dev, "Can't register eDMA tx IRQ.\n"); 154 - return ret; 154 + return ret; 155 155 } 156 156 157 157 ret = devm_request_irq(&pdev->dev, fsl_edma->errirq, 158 158 fsl_edma_err_handler, 0, "eDMA err", fsl_edma); 159 159 if (ret) { 160 160 dev_err(&pdev->dev, "Can't register eDMA err IRQ.\n"); 161 - return ret; 161 + return ret; 162 162 } 163 163 } 164 164
+8 -7
drivers/dma/idma64.c
··· 19 19 #include <linux/platform_device.h> 20 20 #include <linux/slab.h> 21 21 22 - #include "idma64.h" 22 + #include <linux/dma/idma64.h> 23 23 24 - /* Platform driver name */ 25 - #define DRV_NAME "idma64" 24 + #include "idma64.h" 26 25 27 26 /* For now we support only two channels */ 28 27 #define IDMA64_NR_CHAN 2 ··· 591 592 idma64->dma.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); 592 593 idma64->dma.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; 593 594 594 - idma64->dma.dev = chip->dev; 595 + idma64->dma.dev = chip->sysdev; 595 596 596 597 dma_set_max_seg_size(idma64->dma.dev, IDMA64C_CTLH_BLOCK_TS_MASK); 597 598 ··· 631 632 { 632 633 struct idma64_chip *chip; 633 634 struct device *dev = &pdev->dev; 635 + struct device *sysdev = dev->parent; 634 636 struct resource *mem; 635 637 int ret; 636 638 ··· 648 648 if (IS_ERR(chip->regs)) 649 649 return PTR_ERR(chip->regs); 650 650 651 - ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 651 + ret = dma_coerce_mask_and_coherent(sysdev, DMA_BIT_MASK(64)); 652 652 if (ret) 653 653 return ret; 654 654 655 655 chip->dev = dev; 656 + chip->sysdev = sysdev; 656 657 657 658 ret = idma64_probe(chip); 658 659 if (ret) ··· 698 697 .probe = idma64_platform_probe, 699 698 .remove = idma64_platform_remove, 700 699 .driver = { 701 - .name = DRV_NAME, 700 + .name = LPSS_IDMA64_DRIVER_NAME, 702 701 .pm = &idma64_dev_pm_ops, 703 702 }, 704 703 }; ··· 708 707 MODULE_LICENSE("GPL v2"); 709 708 MODULE_DESCRIPTION("iDMA64 core driver"); 710 709 MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>"); 711 - MODULE_ALIAS("platform:" DRV_NAME); 710 + MODULE_ALIAS("platform:" LPSS_IDMA64_DRIVER_NAME);
+2
drivers/dma/idma64.h
··· 216 216 /** 217 217 * struct idma64_chip - representation of iDMA 64-bit controller hardware 218 218 * @dev: struct device of the DMA controller 219 + * @sysdev: struct device of the physical device that does DMA 219 220 * @irq: irq line 220 221 * @regs: memory mapped I/O space 221 222 * @idma64: struct idma64 that is filed by idma64_probe() 222 223 */ 223 224 struct idma64_chip { 224 225 struct device *dev; 226 + struct device *sysdev; 225 227 int irq; 226 228 void __iomem *regs; 227 229 struct idma64 *idma64;
+14 -1
drivers/dma/imx-sdma.c
··· 419 419 int chnenbl0; 420 420 int num_events; 421 421 struct sdma_script_start_addrs *script_addrs; 422 + bool check_ratio; 422 423 }; 423 424 424 425 struct sdma_engine { ··· 558 557 .script_addrs = &sdma_script_imx7d, 559 558 }; 560 559 560 + static struct sdma_driver_data sdma_imx8mq = { 561 + .chnenbl0 = SDMA_CHNENBL0_IMX35, 562 + .num_events = 48, 563 + .script_addrs = &sdma_script_imx7d, 564 + .check_ratio = 1, 565 + }; 566 + 561 567 static const struct platform_device_id sdma_devtypes[] = { 562 568 { 563 569 .name = "imx25-sdma", ··· 588 580 .name = "imx7d-sdma", 589 581 .driver_data = (unsigned long)&sdma_imx7d, 590 582 }, { 583 + .name = "imx8mq-sdma", 584 + .driver_data = (unsigned long)&sdma_imx8mq, 585 + }, { 591 586 /* sentinel */ 592 587 } 593 588 }; ··· 604 593 { .compatible = "fsl,imx31-sdma", .data = &sdma_imx31, }, 605 594 { .compatible = "fsl,imx25-sdma", .data = &sdma_imx25, }, 606 595 { .compatible = "fsl,imx7d-sdma", .data = &sdma_imx7d, }, 596 + { .compatible = "fsl,imx8mq-sdma", .data = &sdma_imx8mq, }, 607 597 { /* sentinel */ } 608 598 }; 609 599 MODULE_DEVICE_TABLE(of, sdma_dt_ids); ··· 1864 1852 if (ret) 1865 1853 goto disable_clk_ipg; 1866 1854 1867 - if (clk_get_rate(sdma->clk_ahb) == clk_get_rate(sdma->clk_ipg)) 1855 + if (sdma->drvdata->check_ratio && 1856 + (clk_get_rate(sdma->clk_ahb) == clk_get_rate(sdma->clk_ipg))) 1868 1857 sdma->clk_ratio = 1; 1869 1858 1870 1859 /* Be sure SDMA has not started yet */
+2 -2
drivers/dma/nbpfaxi.c
··· 1491 1491 #ifdef CONFIG_PM 1492 1492 static int nbpf_runtime_suspend(struct device *dev) 1493 1493 { 1494 - struct nbpf_device *nbpf = platform_get_drvdata(to_platform_device(dev)); 1494 + struct nbpf_device *nbpf = dev_get_drvdata(dev); 1495 1495 clk_disable_unprepare(nbpf->clk); 1496 1496 return 0; 1497 1497 } 1498 1498 1499 1499 static int nbpf_runtime_resume(struct device *dev) 1500 1500 { 1501 - struct nbpf_device *nbpf = platform_get_drvdata(to_platform_device(dev)); 1501 + struct nbpf_device *nbpf = dev_get_drvdata(dev); 1502 1502 return clk_prepare_enable(nbpf->clk); 1503 1503 } 1504 1504 #endif
+58 -3
drivers/dma/pl330.c
··· 11 11 * (at your option) any later version. 12 12 */ 13 13 14 + #include <linux/debugfs.h> 14 15 #include <linux/kernel.h> 15 16 #include <linux/io.h> 16 17 #include <linux/init.h> ··· 967 966 { 968 967 void __iomem *regs = thrd->dmac->base; 969 968 u8 insn[6] = {0, 0, 0, 0, 0, 0}; 969 + u32 inten = readl(regs + INTEN); 970 970 971 971 if (_state(thrd) == PL330_STATE_FAULT_COMPLETING) 972 972 UNTIL(thrd, PL330_STATE_FAULTING | PL330_STATE_KILLING); ··· 980 978 981 979 _emit_KILL(0, insn); 982 980 983 - /* Stop generating interrupts for SEV */ 984 - writel(readl(regs + INTEN) & ~(1 << thrd->ev), regs + INTEN); 985 - 986 981 _execute_DBGINSN(thrd, insn, is_manager(thrd)); 982 + 983 + /* clear the event */ 984 + if (inten & (1 << thrd->ev)) 985 + writel(1 << thrd->ev, regs + INTCLR); 986 + /* Stop generating interrupts for SEV */ 987 + writel(inten & ~(1 << thrd->ev), regs + INTEN); 987 988 } 988 989 989 990 /* Start doing req 'idx' of thread 'thrd' */ ··· 2901 2896 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \ 2902 2897 BIT(DMA_SLAVE_BUSWIDTH_8_BYTES) 2903 2898 2899 + #ifdef CONFIG_DEBUG_FS 2900 + static int pl330_debugfs_show(struct seq_file *s, void *data) 2901 + { 2902 + struct pl330_dmac *pl330 = s->private; 2903 + int chans, pchs, ch, pr; 2904 + 2905 + chans = pl330->pcfg.num_chan; 2906 + pchs = pl330->num_peripherals; 2907 + 2908 + seq_puts(s, "PL330 physical channels:\n"); 2909 + seq_puts(s, "THREAD:\t\tCHANNEL:\n"); 2910 + seq_puts(s, "--------\t-----\n"); 2911 + for (ch = 0; ch < chans; ch++) { 2912 + struct pl330_thread *thrd = &pl330->channels[ch]; 2913 + int found = -1; 2914 + 2915 + for (pr = 0; pr < pchs; pr++) { 2916 + struct dma_pl330_chan *pch = &pl330->peripherals[pr]; 2917 + 2918 + if (!pch->thread || thrd->id != pch->thread->id) 2919 + continue; 2920 + 2921 + found = pr; 2922 + } 2923 + 2924 + seq_printf(s, "%d\t\t", thrd->id); 2925 + if (found == -1) 2926 + seq_puts(s, "--\n"); 2927 + else 2928 + seq_printf(s, "%d\n", found); 2929 + } 2930 + 2931 + return 0; 2932 + } 2933 + 2934 + DEFINE_SHOW_ATTRIBUTE(pl330_debugfs); 2935 + 2936 + static inline void init_pl330_debugfs(struct pl330_dmac *pl330) 2937 + { 2938 + debugfs_create_file(dev_name(pl330->ddma.dev), 2939 + S_IFREG | 0444, NULL, pl330, 2940 + &pl330_debugfs_fops); 2941 + } 2942 + #else 2943 + static inline void init_pl330_debugfs(struct pl330_dmac *pl330) 2944 + { 2945 + } 2946 + #endif 2947 + 2904 2948 /* 2905 2949 * Runtime PM callbacks are provided by amba/bus.c driver. 2906 2950 * ··· 3136 3082 dev_err(&adev->dev, "unable to set the seg size\n"); 3137 3083 3138 3084 3085 + init_pl330_debugfs(pl330); 3139 3086 dev_info(&adev->dev, 3140 3087 "Loaded driver for PL330 DMAC-%x\n", adev->periphid); 3141 3088 dev_info(&adev->dev,
+2 -2
drivers/dma/sh/rcar-dmac.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Renesas R-Car Gen2 DMA Controller Driver 3 + * Renesas R-Car Gen2/Gen3 DMA Controller Driver 4 4 * 5 - * Copyright (C) 2014 Renesas Electronics Inc. 5 + * Copyright (C) 2014-2019 Renesas Electronics Inc. 6 6 * 7 7 * Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 8 8 */
+85 -18
drivers/dma/stm32-dma.c
··· 1042 1042 return ndtr << width; 1043 1043 } 1044 1044 1045 + /** 1046 + * stm32_dma_is_current_sg - check that expected sg_req is currently transferred 1047 + * @chan: dma channel 1048 + * 1049 + * This function called when IRQ are disable, checks that the hardware has not 1050 + * switched on the next transfer in double buffer mode. The test is done by 1051 + * comparing the next_sg memory address with the hardware related register 1052 + * (based on CT bit value). 1053 + * 1054 + * Returns true if expected current transfer is still running or double 1055 + * buffer mode is not activated. 1056 + */ 1057 + static bool stm32_dma_is_current_sg(struct stm32_dma_chan *chan) 1058 + { 1059 + struct stm32_dma_device *dmadev = stm32_dma_get_dev(chan); 1060 + struct stm32_dma_sg_req *sg_req; 1061 + u32 dma_scr, dma_smar, id; 1062 + 1063 + id = chan->id; 1064 + dma_scr = stm32_dma_read(dmadev, STM32_DMA_SCR(id)); 1065 + 1066 + if (!(dma_scr & STM32_DMA_SCR_DBM)) 1067 + return true; 1068 + 1069 + sg_req = &chan->desc->sg_req[chan->next_sg]; 1070 + 1071 + if (dma_scr & STM32_DMA_SCR_CT) { 1072 + dma_smar = stm32_dma_read(dmadev, STM32_DMA_SM0AR(id)); 1073 + return (dma_smar == sg_req->chan_reg.dma_sm0ar); 1074 + } 1075 + 1076 + dma_smar = stm32_dma_read(dmadev, STM32_DMA_SM1AR(id)); 1077 + 1078 + return (dma_smar == sg_req->chan_reg.dma_sm1ar); 1079 + } 1080 + 1045 1081 static size_t stm32_dma_desc_residue(struct stm32_dma_chan *chan, 1046 1082 struct stm32_dma_desc *desc, 1047 1083 u32 next_sg) 1048 1084 { 1049 1085 u32 modulo, burst_size; 1050 - u32 residue = 0; 1086 + u32 residue; 1087 + u32 n_sg = next_sg; 1088 + struct stm32_dma_sg_req *sg_req = &chan->desc->sg_req[chan->next_sg]; 1051 1089 int i; 1052 1090 1053 1091 /* 1054 - * In cyclic mode, for the last period, residue = remaining bytes from 1055 - * NDTR 1092 + * Calculate the residue means compute the descriptors 1093 + * information: 1094 + * - the sg_req currently transferred 1095 + * - the Hardware remaining position in this sg (NDTR bits field). 1096 + * 1097 + * A race condition may occur if DMA is running in cyclic or double 1098 + * buffer mode, since the DMA register are automatically reloaded at end 1099 + * of period transfer. The hardware may have switched to the next 1100 + * transfer (CT bit updated) just before the position (SxNDTR reg) is 1101 + * read. 1102 + * In this case the SxNDTR reg could (or not) correspond to the new 1103 + * transfer position, and not the expected one. 1104 + * The strategy implemented in the stm32 driver is to: 1105 + * - read the SxNDTR register 1106 + * - crosscheck that hardware is still in current transfer. 1107 + * In case of switch, we can assume that the DMA is at the beginning of 1108 + * the next transfer. So we approximate the residue in consequence, by 1109 + * pointing on the beginning of next transfer. 1110 + * 1111 + * This race condition doesn't apply for none cyclic mode, as double 1112 + * buffer is not used. In such situation registers are updated by the 1113 + * software. 1056 1114 */ 1057 - if (chan->desc->cyclic && next_sg == 0) { 1058 - residue = stm32_dma_get_remaining_bytes(chan); 1059 - goto end; 1115 + 1116 + residue = stm32_dma_get_remaining_bytes(chan); 1117 + 1118 + if (!stm32_dma_is_current_sg(chan)) { 1119 + n_sg++; 1120 + if (n_sg == chan->desc->num_sgs) 1121 + n_sg = 0; 1122 + residue = sg_req->len; 1060 1123 } 1061 1124 1062 1125 /* 1063 - * For all other periods in cyclic mode, and in sg mode, 1064 - * residue = remaining bytes from NDTR + remaining periods/sg to be 1065 - * transferred 1126 + * In cyclic mode, for the last period, residue = remaining bytes 1127 + * from NDTR, 1128 + * else for all other periods in cyclic mode, and in sg mode, 1129 + * residue = remaining bytes from NDTR + remaining 1130 + * periods/sg to be transferred 1066 1131 */ 1067 - for (i = next_sg; i < desc->num_sgs; i++) 1068 - residue += desc->sg_req[i].len; 1069 - residue += stm32_dma_get_remaining_bytes(chan); 1132 + if (!chan->desc->cyclic || n_sg != 0) 1133 + for (i = n_sg; i < desc->num_sgs; i++) 1134 + residue += desc->sg_req[i].len; 1070 1135 1071 - end: 1072 1136 if (!chan->mem_burst) 1073 1137 return residue; 1074 1138 ··· 1366 1302 1367 1303 for (i = 0; i < STM32_DMA_MAX_CHANNELS; i++) { 1368 1304 chan = &dmadev->chan[i]; 1369 - res = platform_get_resource(pdev, IORESOURCE_IRQ, i); 1370 - if (!res) { 1371 - ret = -EINVAL; 1372 - dev_err(&pdev->dev, "No irq resource for chan %d\n", i); 1305 + chan->irq = platform_get_irq(pdev, i); 1306 + ret = platform_get_irq(pdev, i); 1307 + if (ret < 0) { 1308 + if (ret != -EPROBE_DEFER) 1309 + dev_err(&pdev->dev, 1310 + "No irq resource for chan %d\n", i); 1373 1311 goto err_unregister; 1374 1312 } 1375 - chan->irq = res->start; 1313 + chan->irq = ret; 1314 + 1376 1315 ret = devm_request_irq(&pdev->dev, chan->irq, 1377 1316 stm32_dma_chan_irq, 0, 1378 1317 dev_name(chan2dev(chan)), chan);
+204 -65
drivers/dma/tegra210-adma.c
··· 22 22 #include <linux/of_device.h> 23 23 #include <linux/of_dma.h> 24 24 #include <linux/of_irq.h> 25 - #include <linux/pm_clock.h> 26 25 #include <linux/pm_runtime.h> 27 26 #include <linux/slab.h> 28 27 ··· 30 31 #define ADMA_CH_CMD 0x00 31 32 #define ADMA_CH_STATUS 0x0c 32 33 #define ADMA_CH_STATUS_XFER_EN BIT(0) 34 + #define ADMA_CH_STATUS_XFER_PAUSED BIT(1) 33 35 34 36 #define ADMA_CH_INT_STATUS 0x10 35 37 #define ADMA_CH_INT_STATUS_XFER_DONE BIT(0) 36 38 37 39 #define ADMA_CH_INT_CLEAR 0x1c 38 40 #define ADMA_CH_CTRL 0x24 39 - #define ADMA_CH_CTRL_TX_REQ(val) (((val) & 0xf) << 28) 40 - #define ADMA_CH_CTRL_TX_REQ_MAX 10 41 - #define ADMA_CH_CTRL_RX_REQ(val) (((val) & 0xf) << 24) 42 - #define ADMA_CH_CTRL_RX_REQ_MAX 10 43 41 #define ADMA_CH_CTRL_DIR(val) (((val) & 0xf) << 12) 44 42 #define ADMA_CH_CTRL_DIR_AHUB2MEM 2 45 43 #define ADMA_CH_CTRL_DIR_MEM2AHUB 4 46 44 #define ADMA_CH_CTRL_MODE_CONTINUOUS (2 << 8) 47 45 #define ADMA_CH_CTRL_FLOWCTRL_EN BIT(1) 46 + #define ADMA_CH_CTRL_XFER_PAUSE_SHIFT 0 48 47 49 48 #define ADMA_CH_CONFIG 0x28 50 49 #define ADMA_CH_CONFIG_SRC_BUF(val) (((val) & 0x7) << 28) 51 50 #define ADMA_CH_CONFIG_TRG_BUF(val) (((val) & 0x7) << 24) 52 - #define ADMA_CH_CONFIG_BURST_SIZE(val) (((val) & 0x7) << 20) 53 - #define ADMA_CH_CONFIG_BURST_16 5 51 + #define ADMA_CH_CONFIG_BURST_SIZE_SHIFT 20 52 + #define ADMA_CH_CONFIG_MAX_BURST_SIZE 16 54 53 #define ADMA_CH_CONFIG_WEIGHT_FOR_WRR(val) ((val) & 0xf) 55 54 #define ADMA_CH_CONFIG_MAX_BUFS 8 56 55 57 56 #define ADMA_CH_FIFO_CTRL 0x2c 58 57 #define ADMA_CH_FIFO_CTRL_OVRFW_THRES(val) (((val) & 0xf) << 24) 59 58 #define ADMA_CH_FIFO_CTRL_STARV_THRES(val) (((val) & 0xf) << 16) 60 - #define ADMA_CH_FIFO_CTRL_TX_SIZE(val) (((val) & 0xf) << 8) 61 - #define ADMA_CH_FIFO_CTRL_RX_SIZE(val) ((val) & 0xf) 59 + #define ADMA_CH_FIFO_CTRL_TX_FIFO_SIZE_SHIFT 8 60 + #define ADMA_CH_FIFO_CTRL_RX_FIFO_SIZE_SHIFT 0 62 61 63 62 #define ADMA_CH_LOWER_SRC_ADDR 0x34 64 63 #define ADMA_CH_LOWER_TRG_ADDR 0x3c ··· 66 69 #define ADMA_CH_XFER_STATUS 0x54 67 70 #define ADMA_CH_XFER_STATUS_COUNT_MASK 0xffff 68 71 69 - #define ADMA_GLOBAL_CMD 0xc00 70 - #define ADMA_GLOBAL_SOFT_RESET 0xc04 71 - #define ADMA_GLOBAL_INT_CLEAR 0xc20 72 - #define ADMA_GLOBAL_CTRL 0xc24 72 + #define ADMA_GLOBAL_CMD 0x00 73 + #define ADMA_GLOBAL_SOFT_RESET 0x04 73 74 74 - #define ADMA_CH_REG_OFFSET(a) (a * 0x80) 75 + #define TEGRA_ADMA_BURST_COMPLETE_TIME 20 75 76 76 77 #define ADMA_CH_FIFO_CTRL_DEFAULT (ADMA_CH_FIFO_CTRL_OVRFW_THRES(1) | \ 77 - ADMA_CH_FIFO_CTRL_STARV_THRES(1) | \ 78 - ADMA_CH_FIFO_CTRL_TX_SIZE(3) | \ 79 - ADMA_CH_FIFO_CTRL_RX_SIZE(3)) 78 + ADMA_CH_FIFO_CTRL_STARV_THRES(1)) 79 + 80 + #define ADMA_CH_REG_FIELD_VAL(val, mask, shift) (((val) & mask) << shift) 81 + 80 82 struct tegra_adma; 81 83 82 84 /* 83 85 * struct tegra_adma_chip_data - Tegra chip specific data 86 + * @global_reg_offset: Register offset of DMA global register. 87 + * @global_int_clear: Register offset of DMA global interrupt clear. 88 + * @ch_req_tx_shift: Register offset for AHUB transmit channel select. 89 + * @ch_req_rx_shift: Register offset for AHUB receive channel select. 90 + * @ch_base_offset: Reister offset of DMA channel registers. 91 + * @ch_req_mask: Mask for Tx or Rx channel select. 92 + * @ch_req_max: Maximum number of Tx or Rx channels available. 93 + * @ch_reg_size: Size of DMA channel register space. 84 94 * @nr_channels: Number of DMA channels available. 85 95 */ 86 96 struct tegra_adma_chip_data { 87 - int nr_channels; 97 + unsigned int (*adma_get_burst_config)(unsigned int burst_size); 98 + unsigned int global_reg_offset; 99 + unsigned int global_int_clear; 100 + unsigned int ch_req_tx_shift; 101 + unsigned int ch_req_rx_shift; 102 + unsigned int ch_base_offset; 103 + unsigned int ch_req_mask; 104 + unsigned int ch_req_max; 105 + unsigned int ch_reg_size; 106 + unsigned int nr_channels; 88 107 }; 89 108 90 109 /* ··· 112 99 unsigned int src_addr; 113 100 unsigned int trg_addr; 114 101 unsigned int fifo_ctrl; 102 + unsigned int cmd; 115 103 unsigned int tc; 116 104 }; 117 105 ··· 142 128 enum dma_transfer_direction sreq_dir; 143 129 unsigned int sreq_index; 144 130 bool sreq_reserved; 131 + struct tegra_adma_chan_regs ch_regs; 145 132 146 133 /* Transfer count and position info */ 147 134 unsigned int tx_buf_count; ··· 156 141 struct dma_device dma_dev; 157 142 struct device *dev; 158 143 void __iomem *base_addr; 144 + struct clk *ahub_clk; 159 145 unsigned int nr_channels; 160 146 unsigned long rx_requests_reserved; 161 147 unsigned long tx_requests_reserved; ··· 164 148 /* Used to store global command register state when suspending */ 165 149 unsigned int global_cmd; 166 150 151 + const struct tegra_adma_chip_data *cdata; 152 + 167 153 /* Last member of the structure */ 168 154 struct tegra_adma_chan channels[0]; 169 155 }; 170 156 171 157 static inline void tdma_write(struct tegra_adma *tdma, u32 reg, u32 val) 172 158 { 173 - writel(val, tdma->base_addr + reg); 159 + writel(val, tdma->base_addr + tdma->cdata->global_reg_offset + reg); 174 160 } 175 161 176 162 static inline u32 tdma_read(struct tegra_adma *tdma, u32 reg) 177 163 { 178 - return readl(tdma->base_addr + reg); 164 + return readl(tdma->base_addr + tdma->cdata->global_reg_offset + reg); 179 165 } 180 166 181 167 static inline void tdma_ch_write(struct tegra_adma_chan *tdc, u32 reg, u32 val) ··· 227 209 int ret; 228 210 229 211 /* Clear any interrupts */ 230 - tdma_write(tdma, ADMA_GLOBAL_INT_CLEAR, 0x1); 212 + tdma_write(tdma, tdma->cdata->global_int_clear, 0x1); 231 213 232 214 /* Assert soft reset */ 233 215 tdma_write(tdma, ADMA_GLOBAL_SOFT_RESET, 0x1); 234 216 235 217 /* Wait for reset to clear */ 236 218 ret = readx_poll_timeout(readl, 237 - tdma->base_addr + ADMA_GLOBAL_SOFT_RESET, 219 + tdma->base_addr + 220 + tdma->cdata->global_reg_offset + 221 + ADMA_GLOBAL_SOFT_RESET, 238 222 status, status == 0, 20, 10000); 239 223 if (ret) 240 224 return ret; ··· 256 236 if (tdc->sreq_reserved) 257 237 return tdc->sreq_dir == direction ? 0 : -EINVAL; 258 238 239 + if (sreq_index > tdma->cdata->ch_req_max) { 240 + dev_err(tdma->dev, "invalid DMA request\n"); 241 + return -EINVAL; 242 + } 243 + 259 244 switch (direction) { 260 245 case DMA_MEM_TO_DEV: 261 - if (sreq_index > ADMA_CH_CTRL_TX_REQ_MAX) { 262 - dev_err(tdma->dev, "invalid DMA request\n"); 263 - return -EINVAL; 264 - } 265 - 266 246 if (test_and_set_bit(sreq_index, &tdma->tx_requests_reserved)) { 267 247 dev_err(tdma->dev, "DMA request reserved\n"); 268 248 return -EINVAL; ··· 270 250 break; 271 251 272 252 case DMA_DEV_TO_MEM: 273 - if (sreq_index > ADMA_CH_CTRL_RX_REQ_MAX) { 274 - dev_err(tdma->dev, "invalid DMA request\n"); 275 - return -EINVAL; 276 - } 277 - 278 253 if (test_and_set_bit(sreq_index, &tdma->rx_requests_reserved)) { 279 254 dev_err(tdma->dev, "DMA request reserved\n"); 280 255 return -EINVAL; ··· 443 428 spin_unlock_irqrestore(&tdc->vc.lock, flags); 444 429 } 445 430 431 + static bool tegra_adma_is_paused(struct tegra_adma_chan *tdc) 432 + { 433 + u32 csts; 434 + 435 + csts = tdma_ch_read(tdc, ADMA_CH_STATUS); 436 + csts &= ADMA_CH_STATUS_XFER_PAUSED; 437 + 438 + return csts ? true : false; 439 + } 440 + 441 + static int tegra_adma_pause(struct dma_chan *dc) 442 + { 443 + struct tegra_adma_chan *tdc = to_tegra_adma_chan(dc); 444 + struct tegra_adma_desc *desc = tdc->desc; 445 + struct tegra_adma_chan_regs *ch_regs = &desc->ch_regs; 446 + int dcnt = 10; 447 + 448 + ch_regs->ctrl = tdma_ch_read(tdc, ADMA_CH_CTRL); 449 + ch_regs->ctrl |= (1 << ADMA_CH_CTRL_XFER_PAUSE_SHIFT); 450 + tdma_ch_write(tdc, ADMA_CH_CTRL, ch_regs->ctrl); 451 + 452 + while (dcnt-- && !tegra_adma_is_paused(tdc)) 453 + udelay(TEGRA_ADMA_BURST_COMPLETE_TIME); 454 + 455 + if (dcnt < 0) { 456 + dev_err(tdc2dev(tdc), "unable to pause DMA channel\n"); 457 + return -EBUSY; 458 + } 459 + 460 + return 0; 461 + } 462 + 463 + static int tegra_adma_resume(struct dma_chan *dc) 464 + { 465 + struct tegra_adma_chan *tdc = to_tegra_adma_chan(dc); 466 + struct tegra_adma_desc *desc = tdc->desc; 467 + struct tegra_adma_chan_regs *ch_regs = &desc->ch_regs; 468 + 469 + ch_regs->ctrl = tdma_ch_read(tdc, ADMA_CH_CTRL); 470 + ch_regs->ctrl &= ~(1 << ADMA_CH_CTRL_XFER_PAUSE_SHIFT); 471 + tdma_ch_write(tdc, ADMA_CH_CTRL, ch_regs->ctrl); 472 + 473 + return 0; 474 + } 475 + 446 476 static int tegra_adma_terminate_all(struct dma_chan *dc) 447 477 { 448 478 struct tegra_adma_chan *tdc = to_tegra_adma_chan(dc); ··· 541 481 return ret; 542 482 } 543 483 484 + static unsigned int tegra210_adma_get_burst_config(unsigned int burst_size) 485 + { 486 + if (!burst_size || burst_size > ADMA_CH_CONFIG_MAX_BURST_SIZE) 487 + burst_size = ADMA_CH_CONFIG_MAX_BURST_SIZE; 488 + 489 + return fls(burst_size) << ADMA_CH_CONFIG_BURST_SIZE_SHIFT; 490 + } 491 + 492 + static unsigned int tegra186_adma_get_burst_config(unsigned int burst_size) 493 + { 494 + if (!burst_size || burst_size > ADMA_CH_CONFIG_MAX_BURST_SIZE) 495 + burst_size = ADMA_CH_CONFIG_MAX_BURST_SIZE; 496 + 497 + return (burst_size - 1) << ADMA_CH_CONFIG_BURST_SIZE_SHIFT; 498 + } 499 + 544 500 static int tegra_adma_set_xfer_params(struct tegra_adma_chan *tdc, 545 501 struct tegra_adma_desc *desc, 546 502 dma_addr_t buf_addr, 547 503 enum dma_transfer_direction direction) 548 504 { 549 505 struct tegra_adma_chan_regs *ch_regs = &desc->ch_regs; 506 + const struct tegra_adma_chip_data *cdata = tdc->tdma->cdata; 550 507 unsigned int burst_size, adma_dir; 551 508 552 509 if (desc->num_periods > ADMA_CH_CONFIG_MAX_BUFS) ··· 572 495 switch (direction) { 573 496 case DMA_MEM_TO_DEV: 574 497 adma_dir = ADMA_CH_CTRL_DIR_MEM2AHUB; 575 - burst_size = fls(tdc->sconfig.dst_maxburst); 498 + burst_size = tdc->sconfig.dst_maxburst; 576 499 ch_regs->config = ADMA_CH_CONFIG_SRC_BUF(desc->num_periods - 1); 577 - ch_regs->ctrl = ADMA_CH_CTRL_TX_REQ(tdc->sreq_index); 500 + ch_regs->ctrl = ADMA_CH_REG_FIELD_VAL(tdc->sreq_index, 501 + cdata->ch_req_mask, 502 + cdata->ch_req_tx_shift); 578 503 ch_regs->src_addr = buf_addr; 579 504 break; 580 505 581 506 case DMA_DEV_TO_MEM: 582 507 adma_dir = ADMA_CH_CTRL_DIR_AHUB2MEM; 583 - burst_size = fls(tdc->sconfig.src_maxburst); 508 + burst_size = tdc->sconfig.src_maxburst; 584 509 ch_regs->config = ADMA_CH_CONFIG_TRG_BUF(desc->num_periods - 1); 585 - ch_regs->ctrl = ADMA_CH_CTRL_RX_REQ(tdc->sreq_index); 510 + ch_regs->ctrl = ADMA_CH_REG_FIELD_VAL(tdc->sreq_index, 511 + cdata->ch_req_mask, 512 + cdata->ch_req_rx_shift); 586 513 ch_regs->trg_addr = buf_addr; 587 514 break; 588 515 ··· 595 514 return -EINVAL; 596 515 } 597 516 598 - if (!burst_size || burst_size > ADMA_CH_CONFIG_BURST_16) 599 - burst_size = ADMA_CH_CONFIG_BURST_16; 600 - 601 517 ch_regs->ctrl |= ADMA_CH_CTRL_DIR(adma_dir) | 602 518 ADMA_CH_CTRL_MODE_CONTINUOUS | 603 519 ADMA_CH_CTRL_FLOWCTRL_EN; 604 - ch_regs->config |= ADMA_CH_CONFIG_BURST_SIZE(burst_size); 520 + ch_regs->config |= cdata->adma_get_burst_config(burst_size); 605 521 ch_regs->config |= ADMA_CH_CONFIG_WEIGHT_FOR_WRR(1); 606 522 ch_regs->fifo_ctrl = ADMA_CH_FIFO_CTRL_DEFAULT; 607 523 ch_regs->tc = desc->period_len & ADMA_CH_TC_COUNT_MASK; ··· 713 635 static int tegra_adma_runtime_suspend(struct device *dev) 714 636 { 715 637 struct tegra_adma *tdma = dev_get_drvdata(dev); 638 + struct tegra_adma_chan_regs *ch_reg; 639 + struct tegra_adma_chan *tdc; 640 + int i; 716 641 717 642 tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD); 643 + if (!tdma->global_cmd) 644 + goto clk_disable; 718 645 719 - return pm_clk_suspend(dev); 646 + for (i = 0; i < tdma->nr_channels; i++) { 647 + tdc = &tdma->channels[i]; 648 + ch_reg = &tdc->ch_regs; 649 + ch_reg->cmd = tdma_ch_read(tdc, ADMA_CH_CMD); 650 + /* skip if channel is not active */ 651 + if (!ch_reg->cmd) 652 + continue; 653 + ch_reg->tc = tdma_ch_read(tdc, ADMA_CH_TC); 654 + ch_reg->src_addr = tdma_ch_read(tdc, ADMA_CH_LOWER_SRC_ADDR); 655 + ch_reg->trg_addr = tdma_ch_read(tdc, ADMA_CH_LOWER_TRG_ADDR); 656 + ch_reg->ctrl = tdma_ch_read(tdc, ADMA_CH_CTRL); 657 + ch_reg->fifo_ctrl = tdma_ch_read(tdc, ADMA_CH_FIFO_CTRL); 658 + ch_reg->config = tdma_ch_read(tdc, ADMA_CH_CONFIG); 659 + } 660 + 661 + clk_disable: 662 + clk_disable_unprepare(tdma->ahub_clk); 663 + 664 + return 0; 720 665 } 721 666 722 667 static int tegra_adma_runtime_resume(struct device *dev) 723 668 { 724 669 struct tegra_adma *tdma = dev_get_drvdata(dev); 725 - int ret; 670 + struct tegra_adma_chan_regs *ch_reg; 671 + struct tegra_adma_chan *tdc; 672 + int ret, i; 726 673 727 - ret = pm_clk_resume(dev); 728 - if (ret) 674 + ret = clk_prepare_enable(tdma->ahub_clk); 675 + if (ret) { 676 + dev_err(dev, "ahub clk_enable failed: %d\n", ret); 729 677 return ret; 730 - 678 + } 731 679 tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd); 680 + 681 + if (!tdma->global_cmd) 682 + return 0; 683 + 684 + for (i = 0; i < tdma->nr_channels; i++) { 685 + tdc = &tdma->channels[i]; 686 + ch_reg = &tdc->ch_regs; 687 + /* skip if channel was not active earlier */ 688 + if (!ch_reg->cmd) 689 + continue; 690 + tdma_ch_write(tdc, ADMA_CH_TC, ch_reg->tc); 691 + tdma_ch_write(tdc, ADMA_CH_LOWER_SRC_ADDR, ch_reg->src_addr); 692 + tdma_ch_write(tdc, ADMA_CH_LOWER_TRG_ADDR, ch_reg->trg_addr); 693 + tdma_ch_write(tdc, ADMA_CH_CTRL, ch_reg->ctrl); 694 + tdma_ch_write(tdc, ADMA_CH_FIFO_CTRL, ch_reg->fifo_ctrl); 695 + tdma_ch_write(tdc, ADMA_CH_CONFIG, ch_reg->config); 696 + tdma_ch_write(tdc, ADMA_CH_CMD, ch_reg->cmd); 697 + } 732 698 733 699 return 0; 734 700 } 735 701 736 702 static const struct tegra_adma_chip_data tegra210_chip_data = { 737 - .nr_channels = 22, 703 + .adma_get_burst_config = tegra210_adma_get_burst_config, 704 + .global_reg_offset = 0xc00, 705 + .global_int_clear = 0x20, 706 + .ch_req_tx_shift = 28, 707 + .ch_req_rx_shift = 24, 708 + .ch_base_offset = 0, 709 + .ch_req_mask = 0xf, 710 + .ch_req_max = 10, 711 + .ch_reg_size = 0x80, 712 + .nr_channels = 22, 713 + }; 714 + 715 + static const struct tegra_adma_chip_data tegra186_chip_data = { 716 + .adma_get_burst_config = tegra186_adma_get_burst_config, 717 + .global_reg_offset = 0, 718 + .global_int_clear = 0x402c, 719 + .ch_req_tx_shift = 27, 720 + .ch_req_rx_shift = 22, 721 + .ch_base_offset = 0x10000, 722 + .ch_req_mask = 0x1f, 723 + .ch_req_max = 20, 724 + .ch_reg_size = 0x100, 725 + .nr_channels = 32, 738 726 }; 739 727 740 728 static const struct of_device_id tegra_adma_of_match[] = { 741 729 { .compatible = "nvidia,tegra210-adma", .data = &tegra210_chip_data }, 730 + { .compatible = "nvidia,tegra186-adma", .data = &tegra186_chip_data }, 742 731 { }, 743 732 }; 744 733 MODULE_DEVICE_TABLE(of, tegra_adma_of_match); ··· 830 685 return -ENOMEM; 831 686 832 687 tdma->dev = &pdev->dev; 688 + tdma->cdata = cdata; 833 689 tdma->nr_channels = cdata->nr_channels; 834 690 platform_set_drvdata(pdev, tdma); 835 691 ··· 839 693 if (IS_ERR(tdma->base_addr)) 840 694 return PTR_ERR(tdma->base_addr); 841 695 842 - ret = pm_clk_create(&pdev->dev); 843 - if (ret) 844 - return ret; 845 - 846 - ret = of_pm_clk_add_clk(&pdev->dev, "d_audio"); 847 - if (ret) 848 - goto clk_destroy; 696 + tdma->ahub_clk = devm_clk_get(&pdev->dev, "d_audio"); 697 + if (IS_ERR(tdma->ahub_clk)) { 698 + dev_err(&pdev->dev, "Error: Missing ahub controller clock\n"); 699 + return PTR_ERR(tdma->ahub_clk); 700 + } 849 701 850 702 pm_runtime_enable(&pdev->dev); 851 703 ··· 859 715 for (i = 0; i < tdma->nr_channels; i++) { 860 716 struct tegra_adma_chan *tdc = &tdma->channels[i]; 861 717 862 - tdc->chan_addr = tdma->base_addr + ADMA_CH_REG_OFFSET(i); 718 + tdc->chan_addr = tdma->base_addr + cdata->ch_base_offset 719 + + (cdata->ch_reg_size * i); 863 720 864 721 tdc->irq = of_irq_get(pdev->dev.of_node, i); 865 722 if (tdc->irq <= 0) { ··· 891 746 tdma->dma_dev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); 892 747 tdma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); 893 748 tdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; 749 + tdma->dma_dev.device_pause = tegra_adma_pause; 750 + tdma->dma_dev.device_resume = tegra_adma_resume; 894 751 895 752 ret = dma_async_device_register(&tdma->dma_dev); 896 753 if (ret < 0) { ··· 923 776 pm_runtime_put_sync(&pdev->dev); 924 777 rpm_disable: 925 778 pm_runtime_disable(&pdev->dev); 926 - clk_destroy: 927 - pm_clk_destroy(&pdev->dev); 928 779 929 780 return ret; 930 781 } ··· 932 787 struct tegra_adma *tdma = platform_get_drvdata(pdev); 933 788 int i; 934 789 790 + of_dma_controller_free(pdev->dev.of_node); 935 791 dma_async_device_unregister(&tdma->dma_dev); 936 792 937 793 for (i = 0; i < tdma->nr_channels; ++i) ··· 940 794 941 795 pm_runtime_put_sync(&pdev->dev); 942 796 pm_runtime_disable(&pdev->dev); 943 - pm_clk_destroy(&pdev->dev); 944 797 945 798 return 0; 946 799 } 947 800 948 - #ifdef CONFIG_PM_SLEEP 949 - static int tegra_adma_pm_suspend(struct device *dev) 950 - { 951 - return pm_runtime_suspended(dev) == false; 952 - } 953 - #endif 954 - 955 801 static const struct dev_pm_ops tegra_adma_dev_pm_ops = { 956 802 SET_RUNTIME_PM_OPS(tegra_adma_runtime_suspend, 957 803 tegra_adma_runtime_resume, NULL) 958 - SET_SYSTEM_SLEEP_PM_OPS(tegra_adma_pm_suspend, NULL) 804 + SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 805 + pm_runtime_force_resume) 959 806 }; 960 807 961 808 static struct platform_driver tegra_admac_driver = {
+3 -3
drivers/dma/xgene-dma.c
··· 703 703 704 704 INIT_LIST_HEAD(&ld_completed); 705 705 706 - spin_lock_bh(&chan->lock); 706 + spin_lock(&chan->lock); 707 707 708 708 /* Clean already completed and acked descriptors */ 709 709 xgene_dma_clean_completed_descriptor(chan); ··· 772 772 */ 773 773 xgene_chan_xfer_ld_pending(chan); 774 774 775 - spin_unlock_bh(&chan->lock); 775 + spin_unlock(&chan->lock); 776 776 777 777 /* Run the callback for each descriptor, in order */ 778 778 list_for_each_entry_safe(desc_sw, _desc_sw, &ld_completed, node) { ··· 797 797 return -ENOMEM; 798 798 } 799 799 800 - chan_dbg(chan, "Allocate descripto pool\n"); 800 + chan_dbg(chan, "Allocate descriptor pool\n"); 801 801 802 802 return 1; 803 803 }
+2 -2
drivers/mfd/intel-lpss.c
··· 28 28 #include <linux/seq_file.h> 29 29 #include <linux/io-64-nonatomic-lo-hi.h> 30 30 31 + #include <linux/dma/idma64.h> 32 + 31 33 #include "intel-lpss.h" 32 34 33 35 #define LPSS_DEV_OFFSET 0x000 ··· 97 95 DEFINE_RES_MEM(LPSS_IDMA64_OFFSET, LPSS_IDMA64_SIZE), 98 96 DEFINE_RES_IRQ(0), 99 97 }; 100 - 101 - #define LPSS_IDMA64_DRIVER_NAME "idma64" 102 98 103 99 /* 104 100 * Cells needs to be ordered so that the iDMA is created first. This is
+1 -6
drivers/spi/spi-pxa2xx.c
··· 1498 1498 1499 1499 static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param) 1500 1500 { 1501 - struct device *dev = param; 1502 - 1503 - if (dev != chan->device->dev->parent) 1504 - return false; 1505 - 1506 - return true; 1501 + return param == chan->device->dev; 1507 1502 } 1508 1503 1509 1504 #endif /* CONFIG_PCI */
+2 -2
drivers/tty/serial/8250/8250_dw.c
··· 365 365 366 366 static bool dw8250_idma_filter(struct dma_chan *chan, void *param) 367 367 { 368 - return param == chan->device->dev->parent; 368 + return param == chan->device->dev; 369 369 } 370 370 371 371 /* ··· 434 434 data->uart_16550_compatible = true; 435 435 } 436 436 437 - /* Platforms with iDMA */ 437 + /* Platforms with iDMA 64-bit */ 438 438 if (platform_get_resource_byname(to_platform_device(p->dev), 439 439 IORESOURCE_MEM, "lpss_priv")) { 440 440 data->dma.rx_param = p->dev->parent;
+14
include/linux/dma/idma64.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Definitions for the Intel integrated DMA 64-bit 4 + * 5 + * Copyright (C) 2019 Intel Corporation 6 + */ 7 + 8 + #ifndef __LINUX_DMA_IDMA64_H__ 9 + #define __LINUX_DMA_IDMA64_H__ 10 + 11 + /* Platform driver name */ 12 + #define LPSS_IDMA64_DRIVER_NAME "idma64" 13 + 14 + #endif /* __LINUX_DMA_IDMA64_H__ */