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

Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma

Pull slave-dmaengine updates from Vinod Koul:
"Nothing exciting this time, odd fixes in a bunch of drivers"

* 'next' of git://git.infradead.org/users/vkoul/slave-dma:
dmaengine: at_hdmac: take maxburst from slave configuration
dmaengine: at_hdmac: remove ATC_DEFAULT_CTRLA constant
dmaengine: at_hdmac: remove some at_dma_slave comments
dma: imx-sdma: make channel0 operations atomic
dmaengine: Fixup dmaengine_prep_slave_single() to be actually useful
dmaengine: Use dma_sg_len(sg) instead of sg->length
dmaengine: Use sg_dma_address instead of sg_phys
DMA: PL330: Remove duplicate header file inclusion
dma: imx-sdma: keep the callbacks invoked in the tasklet
dmaengine: dw_dma: add Device Tree probing capability
dmaengine: dw_dmac: Add clk_{un}prepare() support
dma/amba-pl08x: add support for the Nomadik variant
dma/amba-pl08x: check for terminal count status only

+169 -105
+17
Documentation/devicetree/bindings/dma/snps-dma.txt
··· 1 + * Synopsys Designware DMA Controller 2 + 3 + Required properties: 4 + - compatible: "snps,dma-spear1340" 5 + - reg: Address range of the DMAC registers 6 + - interrupt-parent: Should be the phandle for the interrupt controller 7 + that services interrupts for this device 8 + - interrupt: Should contain the DMAC interrupt number 9 + 10 + Example: 11 + 12 + dma@fc000000 { 13 + compatible = "snps,dma-spear1340"; 14 + reg = <0xfc000000 0x1000>; 15 + interrupt-parent = <&vic1>; 16 + interrupts = <12>; 17 + };
+2
arch/arm/include/asm/hardware/pl080.h
··· 102 102 #define PL080_WIDTH_16BIT (0x1) 103 103 #define PL080_WIDTH_32BIT (0x2) 104 104 105 + #define PL080N_CONFIG_ITPROT (1 << 20) 106 + #define PL080N_CONFIG_SECPROT (1 << 19) 105 107 #define PL080_CONFIG_HALT (1 << 18) 106 108 #define PL080_CONFIG_ACTIVE (1 << 17) /* RO */ 107 109 #define PL080_CONFIG_LOCK (1 << 16)
-1
arch/arm/mach-at91/at91sam9g45_devices.c
··· 436 436 atslave->dma_dev = &at_hdmac_device.dev; 437 437 atslave->cfg = ATC_FIFOCFG_HALFFIFO 438 438 | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW; 439 - atslave->ctrla = ATC_SCSIZE_16 | ATC_DCSIZE_16; 440 439 if (mmc_id == 0) /* MCI0 */ 441 440 atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0) 442 441 | ATC_DST_PER(AT_DMA_ID_MCI0);
-26
arch/arm/mach-at91/include/mach/at_hdmac.h
··· 26 26 /** 27 27 * struct at_dma_slave - Controller-specific information about a slave 28 28 * @dma_dev: required DMA master device 29 - * @tx_reg: physical address of data register used for 30 - * memory-to-peripheral transfers 31 - * @rx_reg: physical address of data register used for 32 - * peripheral-to-memory transfers 33 - * @reg_width: peripheral register width 34 29 * @cfg: Platform-specific initializer for the CFG register 35 - * @ctrla: Platform-specific initializer for the CTRLA register 36 30 */ 37 31 struct at_dma_slave { 38 32 struct device *dma_dev; 39 33 u32 cfg; 40 - u32 ctrla; 41 34 }; 42 35 43 36 ··· 57 64 #define ATC_FIFOCFG_HALFFIFO (0x1 << 28) 58 65 #define ATC_FIFOCFG_ENOUGHSPACE (0x2 << 28) 59 66 60 - /* Platform-configurable bits in CTRLA */ 61 - #define ATC_SCSIZE_MASK (0x7 << 16) /* Source Chunk Transfer Size */ 62 - #define ATC_SCSIZE_1 (0x0 << 16) 63 - #define ATC_SCSIZE_4 (0x1 << 16) 64 - #define ATC_SCSIZE_8 (0x2 << 16) 65 - #define ATC_SCSIZE_16 (0x3 << 16) 66 - #define ATC_SCSIZE_32 (0x4 << 16) 67 - #define ATC_SCSIZE_64 (0x5 << 16) 68 - #define ATC_SCSIZE_128 (0x6 << 16) 69 - #define ATC_SCSIZE_256 (0x7 << 16) 70 - #define ATC_DCSIZE_MASK (0x7 << 20) /* Destination Chunk Transfer Size */ 71 - #define ATC_DCSIZE_1 (0x0 << 20) 72 - #define ATC_DCSIZE_4 (0x1 << 20) 73 - #define ATC_DCSIZE_8 (0x2 << 20) 74 - #define ATC_DCSIZE_16 (0x3 << 20) 75 - #define ATC_DCSIZE_32 (0x4 << 20) 76 - #define ATC_DCSIZE_64 (0x5 << 20) 77 - #define ATC_DCSIZE_128 (0x6 << 20) 78 - #define ATC_DCSIZE_256 (0x7 << 20) 79 67 80 68 #endif /* AT_HDMAC_H */
+41 -11
drivers/dma/amba-pl08x.c
··· 95 95 * struct vendor_data - vendor-specific config parameters for PL08x derivatives 96 96 * @channels: the number of channels available in this variant 97 97 * @dualmaster: whether this version supports dual AHB masters or not. 98 + * @nomadik: whether the channels have Nomadik security extension bits 99 + * that need to be checked for permission before use and some registers are 100 + * missing 98 101 */ 99 102 struct vendor_data { 100 103 u8 channels; 101 104 bool dualmaster; 105 + bool nomadik; 102 106 }; 103 107 104 108 /* ··· 389 385 390 386 spin_lock_irqsave(&ch->lock, flags); 391 387 392 - if (!ch->serving) { 388 + if (!ch->locked && !ch->serving) { 393 389 ch->serving = virt_chan; 394 390 ch->signal = -1; 395 391 spin_unlock_irqrestore(&ch->lock, flags); ··· 1328 1324 int ret, tmp; 1329 1325 1330 1326 dev_dbg(&pl08x->adev->dev, "%s prepare transaction of %d bytes from %s\n", 1331 - __func__, sgl->length, plchan->name); 1327 + __func__, sg_dma_len(sgl), plchan->name); 1332 1328 1333 1329 txd = pl08x_get_txd(plchan, flags); 1334 1330 if (!txd) { ··· 1382 1378 1383 1379 dsg->len = sg_dma_len(sg); 1384 1380 if (direction == DMA_MEM_TO_DEV) { 1385 - dsg->src_addr = sg_phys(sg); 1381 + dsg->src_addr = sg_dma_address(sg); 1386 1382 dsg->dst_addr = slave_addr; 1387 1383 } else { 1388 1384 dsg->src_addr = slave_addr; 1389 - dsg->dst_addr = sg_phys(sg); 1385 + dsg->dst_addr = sg_dma_address(sg); 1390 1386 } 1391 1387 } 1392 1388 ··· 1488 1484 */ 1489 1485 static void pl08x_ensure_on(struct pl08x_driver_data *pl08x) 1490 1486 { 1487 + /* The Nomadik variant does not have the config register */ 1488 + if (pl08x->vd->nomadik) 1489 + return; 1491 1490 writel(PL080_CONFIG_ENABLE, pl08x->base + PL080_CONFIG); 1492 1491 } 1493 1492 ··· 1623 1616 __func__, err); 1624 1617 writel(err, pl08x->base + PL080_ERR_CLEAR); 1625 1618 } 1626 - tc = readl(pl08x->base + PL080_INT_STATUS); 1619 + tc = readl(pl08x->base + PL080_TC_STATUS); 1627 1620 if (tc) 1628 1621 writel(tc, pl08x->base + PL080_TC_CLEAR); 1629 1622 ··· 1780 1773 spin_lock_irqsave(&ch->lock, flags); 1781 1774 virt_chan = ch->serving; 1782 1775 1783 - seq_printf(s, "%d\t\t%s\n", 1784 - ch->id, virt_chan ? virt_chan->name : "(none)"); 1776 + seq_printf(s, "%d\t\t%s%s\n", 1777 + ch->id, 1778 + virt_chan ? virt_chan->name : "(none)", 1779 + ch->locked ? " LOCKED" : ""); 1785 1780 1786 1781 spin_unlock_irqrestore(&ch->lock, flags); 1787 1782 } ··· 1927 1918 } 1928 1919 1929 1920 /* Initialize physical channels */ 1930 - pl08x->phy_chans = kmalloc((vd->channels * sizeof(*pl08x->phy_chans)), 1921 + pl08x->phy_chans = kzalloc((vd->channels * sizeof(*pl08x->phy_chans)), 1931 1922 GFP_KERNEL); 1932 1923 if (!pl08x->phy_chans) { 1933 1924 dev_err(&adev->dev, "%s failed to allocate " ··· 1942 1933 ch->id = i; 1943 1934 ch->base = pl08x->base + PL080_Cx_BASE(i); 1944 1935 spin_lock_init(&ch->lock); 1945 - ch->serving = NULL; 1946 1936 ch->signal = -1; 1937 + 1938 + /* 1939 + * Nomadik variants can have channels that are locked 1940 + * down for the secure world only. Lock up these channels 1941 + * by perpetually serving a dummy virtual channel. 1942 + */ 1943 + if (vd->nomadik) { 1944 + u32 val; 1945 + 1946 + val = readl(ch->base + PL080_CH_CONFIG); 1947 + if (val & (PL080N_CONFIG_ITPROT | PL080N_CONFIG_SECPROT)) { 1948 + dev_info(&adev->dev, "physical channel %d reserved for secure access only\n", i); 1949 + ch->locked = true; 1950 + } 1951 + } 1952 + 1947 1953 dev_dbg(&adev->dev, "physical channel %d is %s\n", 1948 1954 i, pl08x_phy_channel_busy(ch) ? "BUSY" : "FREE"); 1949 1955 } ··· 2041 2017 .dualmaster = true, 2042 2018 }; 2043 2019 2020 + static struct vendor_data vendor_nomadik = { 2021 + .channels = 8, 2022 + .dualmaster = true, 2023 + .nomadik = true, 2024 + }; 2025 + 2044 2026 static struct vendor_data vendor_pl081 = { 2045 2027 .channels = 2, 2046 2028 .dualmaster = false, ··· 2067 2037 }, 2068 2038 /* Nomadik 8815 PL080 variant */ 2069 2039 { 2070 - .id = 0x00280880, 2040 + .id = 0x00280080, 2071 2041 .mask = 0x00ffffff, 2072 - .data = &vendor_pl080, 2042 + .data = &vendor_nomadik, 2073 2043 }, 2074 2044 { 0, 0 }, 2075 2045 };
+7 -8
drivers/dma/at_hdmac.c
··· 39 39 */ 40 40 41 41 #define ATC_DEFAULT_CFG (ATC_FIFOCFG_HALFFIFO) 42 - #define ATC_DEFAULT_CTRLA (0) 43 42 #define ATC_DEFAULT_CTRLB (ATC_SIF(AT_DMA_MEM_IF) \ 44 43 |ATC_DIF(AT_DMA_MEM_IF)) 45 44 ··· 573 574 return NULL; 574 575 } 575 576 576 - ctrla = ATC_DEFAULT_CTRLA; 577 577 ctrlb = ATC_DEFAULT_CTRLB | ATC_IEN 578 578 | ATC_SRC_ADDR_MODE_INCR 579 579 | ATC_DST_ADDR_MODE_INCR ··· 583 585 * of the most common optimization. 584 586 */ 585 587 if (!((src | dest | len) & 3)) { 586 - ctrla |= ATC_SRC_WIDTH_WORD | ATC_DST_WIDTH_WORD; 588 + ctrla = ATC_SRC_WIDTH_WORD | ATC_DST_WIDTH_WORD; 587 589 src_width = dst_width = 2; 588 590 } else if (!((src | dest | len) & 1)) { 589 - ctrla |= ATC_SRC_WIDTH_HALFWORD | ATC_DST_WIDTH_HALFWORD; 591 + ctrla = ATC_SRC_WIDTH_HALFWORD | ATC_DST_WIDTH_HALFWORD; 590 592 src_width = dst_width = 1; 591 593 } else { 592 - ctrla |= ATC_SRC_WIDTH_BYTE | ATC_DST_WIDTH_BYTE; 594 + ctrla = ATC_SRC_WIDTH_BYTE | ATC_DST_WIDTH_BYTE; 593 595 src_width = dst_width = 0; 594 596 } 595 597 ··· 666 668 return NULL; 667 669 } 668 670 669 - ctrla = ATC_DEFAULT_CTRLA | atslave->ctrla; 671 + ctrla = ATC_SCSIZE(sconfig->src_maxburst) 672 + | ATC_DCSIZE(sconfig->dst_maxburst); 670 673 ctrlb = ATC_IEN; 671 674 672 675 switch (direction) { ··· 795 796 enum dma_transfer_direction direction) 796 797 { 797 798 struct at_dma_chan *atchan = to_at_dma_chan(chan); 798 - struct at_dma_slave *atslave = chan->private; 799 799 struct dma_slave_config *sconfig = &atchan->dma_sconfig; 800 800 u32 ctrla; 801 801 802 802 /* prepare common CRTLA value */ 803 - ctrla = ATC_DEFAULT_CTRLA | atslave->ctrla 803 + ctrla = ATC_SCSIZE(sconfig->src_maxburst) 804 + | ATC_DCSIZE(sconfig->dst_maxburst) 804 805 | ATC_DST_WIDTH(reg_width) 805 806 | ATC_SRC_WIDTH(reg_width) 806 807 | period_len >> reg_width;
+20 -1
drivers/dma/at_hdmac_regs.h
··· 87 87 /* Bitfields in CTRLA */ 88 88 #define ATC_BTSIZE_MAX 0xFFFFUL /* Maximum Buffer Transfer Size */ 89 89 #define ATC_BTSIZE(x) (ATC_BTSIZE_MAX & (x)) /* Buffer Transfer Size */ 90 - /* Chunck Tranfer size definitions are in at_hdmac.h */ 90 + #define ATC_SCSIZE_MASK (0x7 << 16) /* Source Chunk Transfer Size */ 91 + #define ATC_SCSIZE(x) (ATC_SCSIZE_MASK & ((x) << 16)) 92 + #define ATC_SCSIZE_1 (0x0 << 16) 93 + #define ATC_SCSIZE_4 (0x1 << 16) 94 + #define ATC_SCSIZE_8 (0x2 << 16) 95 + #define ATC_SCSIZE_16 (0x3 << 16) 96 + #define ATC_SCSIZE_32 (0x4 << 16) 97 + #define ATC_SCSIZE_64 (0x5 << 16) 98 + #define ATC_SCSIZE_128 (0x6 << 16) 99 + #define ATC_SCSIZE_256 (0x7 << 16) 100 + #define ATC_DCSIZE_MASK (0x7 << 20) /* Destination Chunk Transfer Size */ 101 + #define ATC_DCSIZE(x) (ATC_DCSIZE_MASK & ((x) << 20)) 102 + #define ATC_DCSIZE_1 (0x0 << 20) 103 + #define ATC_DCSIZE_4 (0x1 << 20) 104 + #define ATC_DCSIZE_8 (0x2 << 20) 105 + #define ATC_DCSIZE_16 (0x3 << 20) 106 + #define ATC_DCSIZE_32 (0x4 << 20) 107 + #define ATC_DCSIZE_64 (0x5 << 20) 108 + #define ATC_DCSIZE_128 (0x6 << 20) 109 + #define ATC_DCSIZE_256 (0x7 << 20) 91 110 #define ATC_SRC_WIDTH_MASK (0x3 << 24) /* Source Single Transfer Size */ 92 111 #define ATC_SRC_WIDTH(x) ((x) << 24) 93 112 #define ATC_SRC_WIDTH_BYTE (0x0 << 24)
+1 -1
drivers/dma/coh901318.c
··· 1033 1033 1034 1034 if (!sgl) 1035 1035 goto out; 1036 - if (sgl->length == 0) 1036 + if (sg_dma_len(sgl) == 0) 1037 1037 goto out; 1038 1038 1039 1039 spin_lock_irqsave(&cohc->lock, flg);
+2 -2
drivers/dma/coh901318_lli.c
··· 270 270 271 271 if (dir == DMA_MEM_TO_DEV) 272 272 /* increment source address */ 273 - src = sg_phys(sg); 273 + src = sg_dma_address(sg); 274 274 else 275 275 /* increment destination address */ 276 - dst = sg_phys(sg); 276 + dst = sg_dma_address(sg); 277 277 278 278 bytes_to_transfer = sg_dma_len(sg); 279 279
+18 -8
drivers/dma/dw_dmac.c
··· 17 17 #include <linux/init.h> 18 18 #include <linux/interrupt.h> 19 19 #include <linux/io.h> 20 + #include <linux/of.h> 20 21 #include <linux/mm.h> 21 22 #include <linux/module.h> 22 23 #include <linux/platform_device.h> ··· 743 742 struct dw_desc *desc; 744 743 u32 len, dlen, mem; 745 744 746 - mem = sg_phys(sg); 745 + mem = sg_dma_address(sg); 747 746 len = sg_dma_len(sg); 748 747 749 748 if (!((mem | len) & 7)) ··· 810 809 struct dw_desc *desc; 811 810 u32 len, dlen, mem; 812 811 813 - mem = sg_phys(sg); 812 + mem = sg_dma_address(sg); 814 813 len = sg_dma_len(sg); 815 814 816 815 if (!((mem | len) & 7)) ··· 1430 1429 err = PTR_ERR(dw->clk); 1431 1430 goto err_clk; 1432 1431 } 1433 - clk_enable(dw->clk); 1432 + clk_prepare_enable(dw->clk); 1434 1433 1435 1434 /* force dma off, just in case */ 1436 1435 dw_dma_off(dw); ··· 1511 1510 return 0; 1512 1511 1513 1512 err_irq: 1514 - clk_disable(dw->clk); 1513 + clk_disable_unprepare(dw->clk); 1515 1514 clk_put(dw->clk); 1516 1515 err_clk: 1517 1516 iounmap(dw->regs); ··· 1541 1540 channel_clear_bit(dw, CH_EN, dwc->mask); 1542 1541 } 1543 1542 1544 - clk_disable(dw->clk); 1543 + clk_disable_unprepare(dw->clk); 1545 1544 clk_put(dw->clk); 1546 1545 1547 1546 iounmap(dw->regs); ··· 1560 1559 struct dw_dma *dw = platform_get_drvdata(pdev); 1561 1560 1562 1561 dw_dma_off(platform_get_drvdata(pdev)); 1563 - clk_disable(dw->clk); 1562 + clk_disable_unprepare(dw->clk); 1564 1563 } 1565 1564 1566 1565 static int dw_suspend_noirq(struct device *dev) ··· 1569 1568 struct dw_dma *dw = platform_get_drvdata(pdev); 1570 1569 1571 1570 dw_dma_off(platform_get_drvdata(pdev)); 1572 - clk_disable(dw->clk); 1571 + clk_disable_unprepare(dw->clk); 1573 1572 1574 1573 return 0; 1575 1574 } ··· 1579 1578 struct platform_device *pdev = to_platform_device(dev); 1580 1579 struct dw_dma *dw = platform_get_drvdata(pdev); 1581 1580 1582 - clk_enable(dw->clk); 1581 + clk_prepare_enable(dw->clk); 1583 1582 dma_writel(dw, CFG, DW_CFG_DMA_EN); 1584 1583 return 0; 1585 1584 } ··· 1593 1592 .poweroff_noirq = dw_suspend_noirq, 1594 1593 }; 1595 1594 1595 + #ifdef CONFIG_OF 1596 + static const struct of_device_id dw_dma_id_table[] = { 1597 + { .compatible = "snps,dma-spear1340" }, 1598 + {} 1599 + }; 1600 + MODULE_DEVICE_TABLE(of, dw_dma_id_table); 1601 + #endif 1602 + 1596 1603 static struct platform_driver dw_driver = { 1597 1604 .remove = __exit_p(dw_remove), 1598 1605 .shutdown = dw_shutdown, 1599 1606 .driver = { 1600 1607 .name = "dw_dmac", 1601 1608 .pm = &dw_dev_pm_ops, 1609 + .of_match_table = of_match_ptr(dw_dma_id_table), 1602 1610 }, 1603 1611 }; 1604 1612
+6 -6
drivers/dma/imx-dma.c
··· 227 227 struct scatterlist *sg = d->sg; 228 228 unsigned long now; 229 229 230 - now = min(d->len, sg->length); 230 + now = min(d->len, sg_dma_len(sg)); 231 231 if (d->len != IMX_DMA_LENGTH_LOOP) 232 232 d->len -= now; 233 233 ··· 763 763 desc = list_first_entry(&imxdmac->ld_free, struct imxdma_desc, node); 764 764 765 765 for_each_sg(sgl, sg, sg_len, i) { 766 - dma_length += sg->length; 766 + dma_length += sg_dma_len(sg); 767 767 } 768 768 769 769 switch (imxdmac->word_size) { 770 770 case DMA_SLAVE_BUSWIDTH_4_BYTES: 771 - if (sgl->length & 3 || sgl->dma_address & 3) 771 + if (sg_dma_len(sgl) & 3 || sgl->dma_address & 3) 772 772 return NULL; 773 773 break; 774 774 case DMA_SLAVE_BUSWIDTH_2_BYTES: 775 - if (sgl->length & 1 || sgl->dma_address & 1) 775 + if (sg_dma_len(sgl) & 1 || sgl->dma_address & 1) 776 776 return NULL; 777 777 break; 778 778 case DMA_SLAVE_BUSWIDTH_1_BYTE: ··· 831 831 imxdmac->sg_list[i].page_link = 0; 832 832 imxdmac->sg_list[i].offset = 0; 833 833 imxdmac->sg_list[i].dma_address = dma_addr; 834 - imxdmac->sg_list[i].length = period_len; 834 + sg_dma_len(&imxdmac->sg_list[i]) = period_len; 835 835 dma_addr += period_len; 836 836 } 837 837 838 838 /* close the loop */ 839 839 imxdmac->sg_list[periods].offset = 0; 840 - imxdmac->sg_list[periods].length = 0; 840 + sg_dma_len(&imxdmac->sg_list[periods]) = 0; 841 841 imxdmac->sg_list[periods].page_link = 842 842 ((unsigned long)imxdmac->sg_list | 0x01) & ~0x02; 843 843
+39 -29
drivers/dma/imx-sdma.c
··· 24 24 #include <linux/mm.h> 25 25 #include <linux/interrupt.h> 26 26 #include <linux/clk.h> 27 - #include <linux/wait.h> 27 + #include <linux/delay.h> 28 28 #include <linux/sched.h> 29 29 #include <linux/semaphore.h> 30 30 #include <linux/spinlock.h> ··· 271 271 enum dma_status status; 272 272 unsigned int chn_count; 273 273 unsigned int chn_real_count; 274 + struct tasklet_struct tasklet; 274 275 }; 275 276 276 277 #define IMX_DMA_SG_LOOP BIT(0) ··· 324 323 dma_addr_t context_phys; 325 324 struct dma_device dma_device; 326 325 struct clk *clk; 327 - struct mutex channel_0_lock; 326 + spinlock_t channel_0_lock; 328 327 struct sdma_script_start_addrs *script_addrs; 329 328 }; 330 329 ··· 402 401 } 403 402 404 403 /* 405 - * sdma_run_channel - run a channel and wait till it's done 404 + * sdma_run_channel0 - run a channel and wait till it's done 406 405 */ 407 - static int sdma_run_channel(struct sdma_channel *sdmac) 406 + static int sdma_run_channel0(struct sdma_engine *sdma) 408 407 { 409 - struct sdma_engine *sdma = sdmac->sdma; 410 - int channel = sdmac->channel; 411 408 int ret; 409 + unsigned long timeout = 500; 412 410 413 - init_completion(&sdmac->done); 411 + sdma_enable_channel(sdma, 0); 414 412 415 - sdma_enable_channel(sdma, channel); 413 + while (!(ret = readl_relaxed(sdma->regs + SDMA_H_INTR) & 1)) { 414 + if (timeout-- <= 0) 415 + break; 416 + udelay(1); 417 + } 416 418 417 - ret = wait_for_completion_timeout(&sdmac->done, HZ); 419 + if (ret) { 420 + /* Clear the interrupt status */ 421 + writel_relaxed(ret, sdma->regs + SDMA_H_INTR); 422 + } else { 423 + dev_err(sdma->dev, "Timeout waiting for CH0 ready\n"); 424 + } 418 425 419 426 return ret ? 0 : -ETIMEDOUT; 420 427 } ··· 434 425 void *buf_virt; 435 426 dma_addr_t buf_phys; 436 427 int ret; 437 - 438 - mutex_lock(&sdma->channel_0_lock); 428 + unsigned long flags; 439 429 440 430 buf_virt = dma_alloc_coherent(NULL, 441 431 size, 442 432 &buf_phys, GFP_KERNEL); 443 433 if (!buf_virt) { 444 - ret = -ENOMEM; 445 - goto err_out; 434 + return -ENOMEM; 446 435 } 436 + 437 + spin_lock_irqsave(&sdma->channel_0_lock, flags); 447 438 448 439 bd0->mode.command = C0_SETPM; 449 440 bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD; ··· 453 444 454 445 memcpy(buf_virt, buf, size); 455 446 456 - ret = sdma_run_channel(&sdma->channel[0]); 447 + ret = sdma_run_channel0(sdma); 448 + 449 + spin_unlock_irqrestore(&sdma->channel_0_lock, flags); 457 450 458 451 dma_free_coherent(NULL, size, buf_virt, buf_phys); 459 - 460 - err_out: 461 - mutex_unlock(&sdma->channel_0_lock); 462 452 463 453 return ret; 464 454 } ··· 542 534 sdmac->desc.callback(sdmac->desc.callback_param); 543 535 } 544 536 545 - static void mxc_sdma_handle_channel(struct sdma_channel *sdmac) 537 + static void sdma_tasklet(unsigned long data) 546 538 { 547 - complete(&sdmac->done); 539 + struct sdma_channel *sdmac = (struct sdma_channel *) data; 548 540 549 - /* not interested in channel 0 interrupts */ 550 - if (sdmac->channel == 0) 551 - return; 541 + complete(&sdmac->done); 552 542 553 543 if (sdmac->flags & IMX_DMA_SG_LOOP) 554 544 sdma_handle_channel_loop(sdmac); ··· 560 554 unsigned long stat; 561 555 562 556 stat = readl_relaxed(sdma->regs + SDMA_H_INTR); 557 + /* not interested in channel 0 interrupts */ 558 + stat &= ~1; 563 559 writel_relaxed(stat, sdma->regs + SDMA_H_INTR); 564 560 565 561 while (stat) { 566 562 int channel = fls(stat) - 1; 567 563 struct sdma_channel *sdmac = &sdma->channel[channel]; 568 564 569 - mxc_sdma_handle_channel(sdmac); 565 + tasklet_schedule(&sdmac->tasklet); 570 566 571 567 __clear_bit(channel, &stat); 572 568 } ··· 667 659 struct sdma_context_data *context = sdma->context; 668 660 struct sdma_buffer_descriptor *bd0 = sdma->channel[0].bd; 669 661 int ret; 662 + unsigned long flags; 670 663 671 664 if (sdmac->direction == DMA_DEV_TO_MEM) { 672 665 load_address = sdmac->pc_from_device; ··· 685 676 dev_dbg(sdma->dev, "event_mask0 = 0x%08x\n", (u32)sdmac->event_mask[0]); 686 677 dev_dbg(sdma->dev, "event_mask1 = 0x%08x\n", (u32)sdmac->event_mask[1]); 687 678 688 - mutex_lock(&sdma->channel_0_lock); 679 + spin_lock_irqsave(&sdma->channel_0_lock, flags); 689 680 690 681 memset(context, 0, sizeof(*context)); 691 682 context->channel_state.pc = load_address; ··· 704 695 bd0->mode.count = sizeof(*context) / 4; 705 696 bd0->buffer_addr = sdma->context_phys; 706 697 bd0->ext_buffer_addr = 2048 + (sizeof(*context) / 4) * channel; 698 + ret = sdma_run_channel0(sdma); 707 699 708 - ret = sdma_run_channel(&sdma->channel[0]); 709 - 710 - mutex_unlock(&sdma->channel_0_lock); 700 + spin_unlock_irqrestore(&sdma->channel_0_lock, flags); 711 701 712 702 return ret; 713 703 } ··· 946 938 947 939 bd->buffer_addr = sg->dma_address; 948 940 949 - count = sg->length; 941 + count = sg_dma_len(sg); 950 942 951 943 if (count > 0xffff) { 952 944 dev_err(sdma->dev, "SDMA channel %d: maximum bytes for sg entry exceeded: %d > %d\n", ··· 1305 1297 if (!sdma) 1306 1298 return -ENOMEM; 1307 1299 1308 - mutex_init(&sdma->channel_0_lock); 1300 + spin_lock_init(&sdma->channel_0_lock); 1309 1301 1310 1302 sdma->dev = &pdev->dev; 1311 1303 ··· 1367 1359 dma_cookie_init(&sdmac->chan); 1368 1360 sdmac->channel = i; 1369 1361 1362 + tasklet_init(&sdmac->tasklet, sdma_tasklet, 1363 + (unsigned long) sdmac); 1370 1364 /* 1371 1365 * Add the channel to the DMAC list. Do not add channel 0 though 1372 1366 * because we need it internally in the SDMA driver. This also means
+4 -4
drivers/dma/intel_mid_dma.c
··· 394 394 } 395 395 } 396 396 /*Populate CTL_HI values*/ 397 - ctl_hi.ctlx.block_ts = get_block_ts(sg->length, 397 + ctl_hi.ctlx.block_ts = get_block_ts(sg_dma_len(sg), 398 398 desc->width, 399 399 midc->dma->block_size); 400 400 /*Populate SAR and DAR values*/ 401 - sg_phy_addr = sg_phys(sg); 401 + sg_phy_addr = sg_dma_address(sg); 402 402 if (desc->dirn == DMA_MEM_TO_DEV) { 403 403 lli_bloc_desc->sar = sg_phy_addr; 404 404 lli_bloc_desc->dar = mids->dma_slave.dst_addr; ··· 747 747 txd = intel_mid_dma_prep_memcpy(chan, 748 748 mids->dma_slave.dst_addr, 749 749 mids->dma_slave.src_addr, 750 - sgl->length, 750 + sg_dma_len(sgl), 751 751 flags); 752 752 return txd; 753 753 } else { ··· 759 759 pr_debug("MDMA: SG Length = %d, direction = %d, Flags = %#lx\n", 760 760 sg_len, direction, flags); 761 761 762 - txd = intel_mid_dma_prep_memcpy(chan, 0, 0, sgl->length, flags); 762 + txd = intel_mid_dma_prep_memcpy(chan, 0, 0, sg_dma_len(sgl), flags); 763 763 if (NULL == txd) { 764 764 pr_err("MDMA: Prep memcpy failed\n"); 765 765 return NULL;
+3 -3
drivers/dma/mxs-dma.c
··· 415 415 ccw->bits |= BF_CCW(MXS_DMA_CMD_NO_XFER, COMMAND); 416 416 } else { 417 417 for_each_sg(sgl, sg, sg_len, i) { 418 - if (sg->length > MAX_XFER_BYTES) { 418 + if (sg_dma_len(sg) > MAX_XFER_BYTES) { 419 419 dev_err(mxs_dma->dma_device.dev, "maximum bytes for sg entry exceeded: %d > %d\n", 420 - sg->length, MAX_XFER_BYTES); 420 + sg_dma_len(sg), MAX_XFER_BYTES); 421 421 goto err_out; 422 422 } 423 423 ··· 425 425 426 426 ccw->next = mxs_chan->ccw_phys + sizeof(*ccw) * idx; 427 427 ccw->bufaddr = sg->dma_address; 428 - ccw->xfer_bytes = sg->length; 428 + ccw->xfer_bytes = sg_dma_len(sg); 429 429 430 430 ccw->bits = 0; 431 431 ccw->bits |= CCW_CHAIN;
+1 -1
drivers/dma/pch_dma.c
··· 621 621 goto err_desc_get; 622 622 623 623 desc->regs.dev_addr = reg; 624 - desc->regs.mem_addr = sg_phys(sg); 624 + desc->regs.mem_addr = sg_dma_address(sg); 625 625 desc->regs.size = sg_dma_len(sg); 626 626 desc->regs.next = DMA_DESC_FOLLOW_WITHOUT_IRQ; 627 627
-1
drivers/dma/pl330.c
··· 21 21 #include <linux/interrupt.h> 22 22 #include <linux/dma-mapping.h> 23 23 #include <linux/dmaengine.h> 24 - #include <linux/interrupt.h> 25 24 #include <linux/amba/bus.h> 26 25 #include <linux/amba/pl330.h> 27 26 #include <linux/pm_runtime.h>
+1 -1
drivers/dma/ste_dma40.c
··· 2362 2362 } 2363 2363 2364 2364 sg[periods].offset = 0; 2365 - sg[periods].length = 0; 2365 + sg_dma_len(&sg[periods]) = 0; 2366 2366 sg[periods].page_link = 2367 2367 ((unsigned long)sg | 0x01) & ~0x02; 2368 2368
+3
include/linux/amba/pl08x.h
··· 92 92 * right now 93 93 * @serving: the virtual channel currently being served by this physical 94 94 * channel 95 + * @locked: channel unavailable for the system, e.g. dedicated to secure 96 + * world 95 97 */ 96 98 struct pl08x_phy_chan { 97 99 unsigned int id; ··· 101 99 spinlock_t lock; 102 100 int signal; 103 101 struct pl08x_dma_chan *serving; 102 + bool locked; 104 103 }; 105 104 106 105 /**
+4 -2
include/linux/dmaengine.h
··· 615 615 } 616 616 617 617 static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single( 618 - struct dma_chan *chan, void *buf, size_t len, 618 + struct dma_chan *chan, dma_addr_t buf, size_t len, 619 619 enum dma_transfer_direction dir, unsigned long flags) 620 620 { 621 621 struct scatterlist sg; 622 - sg_init_one(&sg, buf, len); 622 + sg_init_table(&sg, 1); 623 + sg_dma_address(&sg) = buf; 624 + sg_dma_len(&sg) = len; 623 625 624 626 return chan->device->device_prep_slave_sg(chan, &sg, 1, 625 627 dir, flags, NULL);