Skip to content

Commit f065199

Browse files
committed
Merge tag 'dmaengine-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine updates from Vinod Koul: "Core: - Mark dma_request_slave_channel() deprecated in favour of dma_request_chan() - subsystem conversion for tasklet_setup() API - subsystem removal of local dma_parms for arm drivers Also updates to bunch of driver notably TI, DW and AXI-DMAC" * tag 'dmaengine-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: (104 commits) dmaengine: owl-dma: fix kernel-doc style for enum dmaengine: zynqmp_dma: fix kernel-doc style for tasklet dmaengine: xilinx_dma: fix kernel-doc style for tasklet dmaengine: qcom: bam_dma: fix kernel-doc style for tasklet dmaengine: altera-msgdma: fix kernel-doc style for tasklet dmaengine: xilinx: dpdma: convert tasklets to use new tasklet_setup() API dmaengine: sf-pdma: convert tasklets to use new tasklet_setup() API dt-bindings: Fix 'reg' size issues in zynqmp examples dmaengine: rcar-dmac: drop double zeroing dmaengine: sh: drop double zeroing dmaengine: ioat: Allocate correct size for descriptor chunk dmaengine: ti: k3-udma: use devm_platform_ioremap_resource_byname dmaengine: fsl: remove bad channel update dmaengine: dma-jz4780: Fix race in jz4780_dma_tx_status dmaengine: pl330: fix argument for tasklet dmaengine: dmatest: Return boolean result directly in filter() dmaengine: dmatest: Check list for emptiness before access its last entry dmaengine: ti: k3-udma-glue: fix channel enable functions dmaengine: iop-adma: Fix pointer cast warnings dmaengine: dw-edma: Fix Using plain integer as NULL pointer in dw-edma-v0-debugfs.c ...
2 parents c48b75b + fc143e3 commit f065199

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+930
-437
lines changed

Documentation/ABI/stable/sysfs-driver-dma-idxd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ Description: The maximum number of bandwidth tokens that may be in use at
116116
one time by operations that access low bandwidth memory in the
117117
device.
118118

119+
What: /sys/bus/dsa/devices/dsa<m>/cmd_status
120+
Date: Aug 28, 2020
121+
KernelVersion: 5.10.0
122+
123+
Description: The last executed device administrative command's status/error.
124+
119125
What: /sys/bus/dsa/devices/wq<m>.<n>/group_id
120126
Date: Oct 25, 2019
121127
KernelVersion: 5.6.0
@@ -170,6 +176,20 @@ Contact: [email protected]
170176
Description: The number of entries in this work queue that may be filled
171177
via a limited portal.
172178

179+
What: /sys/bus/dsa/devices/wq<m>.<n>/max_transfer_size
180+
Date: Aug 28, 2020
181+
KernelVersion: 5.10.0
182+
183+
Description: The max transfer sized for this workqueue. Cannot exceed device
184+
max transfer size. Configurable parameter.
185+
186+
What: /sys/bus/dsa/devices/wq<m>.<n>/max_batch_size
187+
Date: Aug 28, 2020
188+
KernelVersion: 5.10.0
189+
190+
Description: The max batch size for this workqueue. Cannot exceed device
191+
max batch size. Configurable parameter.
192+
173193
What: /sys/bus/dsa/devices/engine<m>.<n>/group_id
174194
Date: Oct 25, 2019
175195
KernelVersion: 5.6.0

Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ properties:
1616
compatible:
1717
items:
1818
- enum:
19+
- renesas,dmac-r8a7742 # RZ/G1H
1920
- renesas,dmac-r8a7743 # RZ/G1M
2021
- renesas,dmac-r8a7744 # RZ/G1N
2122
- renesas,dmac-r8a7745 # RZ/G1E

Documentation/devicetree/bindings/dma/snps,dma-spear1340.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ properties:
1818
const: snps,dma-spear1340
1919

2020
"#dma-cells":
21-
const: 3
21+
minimum: 3
22+
maximum: 4
2223
description: |
2324
First cell is a phandle pointing to the DMA controller. Second one is
2425
the DMA request line number. Third cell is the memory master identifier
2526
for transfers on dynamically allocated channel. Fourth cell is the
26-
peripheral master identifier for transfers on an allocated channel.
27+
peripheral master identifier for transfers on an allocated channel. Fifth
28+
cell is an optional mask of the DMA channels permitted to be allocated
29+
for the corresponding client device.
2730
2831
reg:
2932
maxItems: 1

drivers/dma/altera-msgdma.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,11 @@ static int msgdma_alloc_chan_resources(struct dma_chan *dchan)
678678

679679
/**
680680
* msgdma_tasklet - Schedule completion tasklet
681-
* @data: Pointer to the Altera sSGDMA channel structure
681+
* @t: Pointer to the Altera sSGDMA channel structure
682682
*/
683-
static void msgdma_tasklet(unsigned long data)
683+
static void msgdma_tasklet(struct tasklet_struct *t)
684684
{
685-
struct msgdma_device *mdev = (struct msgdma_device *)data;
685+
struct msgdma_device *mdev = from_tasklet(mdev, t, irq_tasklet);
686686
u32 count;
687687
u32 __maybe_unused size;
688688
u32 __maybe_unused status;
@@ -830,7 +830,7 @@ static int msgdma_probe(struct platform_device *pdev)
830830
if (ret)
831831
return ret;
832832

833-
tasklet_init(&mdev->irq_tasklet, msgdma_tasklet, (unsigned long)mdev);
833+
tasklet_setup(&mdev->irq_tasklet, msgdma_tasklet);
834834

835835
dma_cookie_init(&mdev->dmachan);
836836

drivers/dma/at_hdmac.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ static void atc_handle_cyclic(struct at_dma_chan *atchan)
598598

599599
/*-- IRQ & Tasklet ---------------------------------------------------*/
600600

601-
static void atc_tasklet(unsigned long data)
601+
static void atc_tasklet(struct tasklet_struct *t)
602602
{
603-
struct at_dma_chan *atchan = (struct at_dma_chan *)data;
603+
struct at_dma_chan *atchan = from_tasklet(atchan, t, tasklet);
604604

605605
if (test_and_clear_bit(ATC_IS_ERROR, &atchan->status))
606606
return atc_handle_error(atchan);
@@ -1892,8 +1892,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
18921892
INIT_LIST_HEAD(&atchan->queue);
18931893
INIT_LIST_HEAD(&atchan->free_list);
18941894

1895-
tasklet_init(&atchan->tasklet, atc_tasklet,
1896-
(unsigned long)atchan);
1895+
tasklet_setup(&atchan->tasklet, atc_tasklet);
18971896
atc_enable_chan_irq(atdma, i);
18981897
}
18991898

drivers/dma/at_xdmac.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,9 +1613,9 @@ static void at_xdmac_handle_error(struct at_xdmac_chan *atchan)
16131613
/* Then continue with usual descriptor management */
16141614
}
16151615

1616-
static void at_xdmac_tasklet(unsigned long data)
1616+
static void at_xdmac_tasklet(struct tasklet_struct *t)
16171617
{
1618-
struct at_xdmac_chan *atchan = (struct at_xdmac_chan *)data;
1618+
struct at_xdmac_chan *atchan = from_tasklet(atchan, t, tasklet);
16191619
struct at_xdmac_desc *desc;
16201620
u32 error_mask;
16211621

@@ -2063,8 +2063,7 @@ static int at_xdmac_probe(struct platform_device *pdev)
20632063
spin_lock_init(&atchan->lock);
20642064
INIT_LIST_HEAD(&atchan->xfers_list);
20652065
INIT_LIST_HEAD(&atchan->free_descs_list);
2066-
tasklet_init(&atchan->tasklet, at_xdmac_tasklet,
2067-
(unsigned long)atchan);
2066+
tasklet_setup(&atchan->tasklet, at_xdmac_tasklet);
20682067

20692068
/* Clear pending interrupts. */
20702069
while (at_xdmac_chan_read(atchan, AT_XDMAC_CIS))

drivers/dma/bcm2835-dma.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@
4141
* struct bcm2835_dmadev - BCM2835 DMA controller
4242
* @ddev: DMA device
4343
* @base: base address of register map
44-
* @dma_parms: DMA parameters (to convey 1 GByte max segment size to clients)
4544
* @zero_page: bus address of zero page (to detect transactions copying from
4645
* zero page and avoid accessing memory if so)
4746
*/
4847
struct bcm2835_dmadev {
4948
struct dma_device ddev;
5049
void __iomem *base;
51-
struct device_dma_parameters dma_parms;
5250
dma_addr_t zero_page;
5351
};
5452

@@ -902,7 +900,6 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
902900
if (!od)
903901
return -ENOMEM;
904902

905-
pdev->dev.dma_parms = &od->dma_parms;
906903
dma_set_max_seg_size(&pdev->dev, 0x3FFFFFFF);
907904

908905
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

drivers/dma/coh901318.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,9 +1868,9 @@ static struct coh901318_desc *coh901318_queue_start(struct coh901318_chan *cohc)
18681868
* This tasklet is called from the interrupt handler to
18691869
* handle each descriptor (DMA job) that is sent to a channel.
18701870
*/
1871-
static void dma_tasklet(unsigned long data)
1871+
static void dma_tasklet(struct tasklet_struct *t)
18721872
{
1873-
struct coh901318_chan *cohc = (struct coh901318_chan *) data;
1873+
struct coh901318_chan *cohc = from_tasklet(cohc, t, tasklet);
18741874
struct coh901318_desc *cohd_fin;
18751875
unsigned long flags;
18761876
struct dmaengine_desc_callback cb;
@@ -2615,8 +2615,7 @@ static void coh901318_base_init(struct dma_device *dma, const int *pick_chans,
26152615
INIT_LIST_HEAD(&cohc->active);
26162616
INIT_LIST_HEAD(&cohc->queue);
26172617

2618-
tasklet_init(&cohc->tasklet, dma_tasklet,
2619-
(unsigned long) cohc);
2618+
tasklet_setup(&cohc->tasklet, dma_tasklet);
26202619

26212620
list_add_tail(&cohc->chan.device_node,
26222621
&dma->channels);

drivers/dma/dma-axi-dmac.c

Lines changed: 107 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Author: Lars-Peter Clausen <[email protected]>
77
*/
88

9+
#include <linux/bitfield.h>
910
#include <linux/clk.h>
1011
#include <linux/device.h>
1112
#include <linux/dma-mapping.h>
@@ -45,6 +46,16 @@
4546
* there is no address than can or needs to be configured for the device side.
4647
*/
4748

49+
#define AXI_DMAC_REG_INTERFACE_DESC 0x10
50+
#define AXI_DMAC_DMA_SRC_TYPE_MSK GENMASK(13, 12)
51+
#define AXI_DMAC_DMA_SRC_TYPE_GET(x) FIELD_GET(AXI_DMAC_DMA_SRC_TYPE_MSK, x)
52+
#define AXI_DMAC_DMA_SRC_WIDTH_MSK GENMASK(11, 8)
53+
#define AXI_DMAC_DMA_SRC_WIDTH_GET(x) FIELD_GET(AXI_DMAC_DMA_SRC_WIDTH_MSK, x)
54+
#define AXI_DMAC_DMA_DST_TYPE_MSK GENMASK(5, 4)
55+
#define AXI_DMAC_DMA_DST_TYPE_GET(x) FIELD_GET(AXI_DMAC_DMA_DST_TYPE_MSK, x)
56+
#define AXI_DMAC_DMA_DST_WIDTH_MSK GENMASK(3, 0)
57+
#define AXI_DMAC_DMA_DST_WIDTH_GET(x) FIELD_GET(AXI_DMAC_DMA_DST_WIDTH_MSK, x)
58+
4859
#define AXI_DMAC_REG_IRQ_MASK 0x80
4960
#define AXI_DMAC_REG_IRQ_PENDING 0x84
5061
#define AXI_DMAC_REG_IRQ_SOURCE 0x88
@@ -134,8 +145,6 @@ struct axi_dmac {
134145

135146
struct dma_device dma_dev;
136147
struct axi_dmac_chan chan;
137-
138-
struct device_dma_parameters dma_parms;
139148
};
140149

141150
static struct axi_dmac *chan_to_axi_dmac(struct axi_dmac_chan *chan)
@@ -717,6 +726,20 @@ static const struct regmap_config axi_dmac_regmap_config = {
717726
.writeable_reg = axi_dmac_regmap_rdwr,
718727
};
719728

729+
static void axi_dmac_adjust_chan_params(struct axi_dmac_chan *chan)
730+
{
731+
chan->address_align_mask = max(chan->dest_width, chan->src_width) - 1;
732+
733+
if (axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan))
734+
chan->direction = DMA_MEM_TO_MEM;
735+
else if (!axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan))
736+
chan->direction = DMA_MEM_TO_DEV;
737+
else if (axi_dmac_dest_is_mem(chan) && !axi_dmac_src_is_mem(chan))
738+
chan->direction = DMA_DEV_TO_MEM;
739+
else
740+
chan->direction = DMA_DEV_TO_DEV;
741+
}
742+
720743
/*
721744
* The configuration stored in the devicetree matches the configuration
722745
* parameters of the peripheral instance and allows the driver to know which
@@ -760,26 +783,81 @@ static int axi_dmac_parse_chan_dt(struct device_node *of_chan,
760783
return ret;
761784
chan->dest_width = val / 8;
762785

763-
chan->address_align_mask = max(chan->dest_width, chan->src_width) - 1;
786+
axi_dmac_adjust_chan_params(chan);
764787

765-
if (axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan))
766-
chan->direction = DMA_MEM_TO_MEM;
767-
else if (!axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan))
768-
chan->direction = DMA_MEM_TO_DEV;
769-
else if (axi_dmac_dest_is_mem(chan) && !axi_dmac_src_is_mem(chan))
770-
chan->direction = DMA_DEV_TO_MEM;
771-
else
772-
chan->direction = DMA_DEV_TO_DEV;
788+
return 0;
789+
}
790+
791+
static int axi_dmac_parse_dt(struct device *dev, struct axi_dmac *dmac)
792+
{
793+
struct device_node *of_channels, *of_chan;
794+
int ret;
795+
796+
of_channels = of_get_child_by_name(dev->of_node, "adi,channels");
797+
if (of_channels == NULL)
798+
return -ENODEV;
799+
800+
for_each_child_of_node(of_channels, of_chan) {
801+
ret = axi_dmac_parse_chan_dt(of_chan, &dmac->chan);
802+
if (ret) {
803+
of_node_put(of_chan);
804+
of_node_put(of_channels);
805+
return -EINVAL;
806+
}
807+
}
808+
of_node_put(of_channels);
773809

774810
return 0;
775811
}
776812

777-
static int axi_dmac_detect_caps(struct axi_dmac *dmac)
813+
static int axi_dmac_read_chan_config(struct device *dev, struct axi_dmac *dmac)
778814
{
779815
struct axi_dmac_chan *chan = &dmac->chan;
780-
unsigned int version;
816+
unsigned int val, desc;
781817

782-
version = axi_dmac_read(dmac, ADI_AXI_REG_VERSION);
818+
desc = axi_dmac_read(dmac, AXI_DMAC_REG_INTERFACE_DESC);
819+
if (desc == 0) {
820+
dev_err(dev, "DMA interface register reads zero\n");
821+
return -EFAULT;
822+
}
823+
824+
val = AXI_DMAC_DMA_SRC_TYPE_GET(desc);
825+
if (val > AXI_DMAC_BUS_TYPE_FIFO) {
826+
dev_err(dev, "Invalid source bus type read: %d\n", val);
827+
return -EINVAL;
828+
}
829+
chan->src_type = val;
830+
831+
val = AXI_DMAC_DMA_DST_TYPE_GET(desc);
832+
if (val > AXI_DMAC_BUS_TYPE_FIFO) {
833+
dev_err(dev, "Invalid destination bus type read: %d\n", val);
834+
return -EINVAL;
835+
}
836+
chan->dest_type = val;
837+
838+
val = AXI_DMAC_DMA_SRC_WIDTH_GET(desc);
839+
if (val == 0) {
840+
dev_err(dev, "Source bus width is zero\n");
841+
return -EINVAL;
842+
}
843+
/* widths are stored in log2 */
844+
chan->src_width = 1 << val;
845+
846+
val = AXI_DMAC_DMA_DST_WIDTH_GET(desc);
847+
if (val == 0) {
848+
dev_err(dev, "Destination bus width is zero\n");
849+
return -EINVAL;
850+
}
851+
chan->dest_width = 1 << val;
852+
853+
axi_dmac_adjust_chan_params(chan);
854+
855+
return 0;
856+
}
857+
858+
static int axi_dmac_detect_caps(struct axi_dmac *dmac, unsigned int version)
859+
{
860+
struct axi_dmac_chan *chan = &dmac->chan;
783861

784862
axi_dmac_write(dmac, AXI_DMAC_REG_FLAGS, AXI_DMAC_FLAG_CYCLIC);
785863
if (axi_dmac_read(dmac, AXI_DMAC_REG_FLAGS) == AXI_DMAC_FLAG_CYCLIC)
@@ -826,11 +904,11 @@ static int axi_dmac_detect_caps(struct axi_dmac *dmac)
826904

827905
static int axi_dmac_probe(struct platform_device *pdev)
828906
{
829-
struct device_node *of_channels, *of_chan;
830907
struct dma_device *dma_dev;
831908
struct axi_dmac *dmac;
832909
struct resource *res;
833910
struct regmap *regmap;
911+
unsigned int version;
834912
int ret;
835913

836914
dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL);
@@ -852,23 +930,22 @@ static int axi_dmac_probe(struct platform_device *pdev)
852930
if (IS_ERR(dmac->clk))
853931
return PTR_ERR(dmac->clk);
854932

855-
INIT_LIST_HEAD(&dmac->chan.active_descs);
933+
ret = clk_prepare_enable(dmac->clk);
934+
if (ret < 0)
935+
return ret;
856936

857-
of_channels = of_get_child_by_name(pdev->dev.of_node, "adi,channels");
858-
if (of_channels == NULL)
859-
return -ENODEV;
937+
version = axi_dmac_read(dmac, ADI_AXI_REG_VERSION);
860938

861-
for_each_child_of_node(of_channels, of_chan) {
862-
ret = axi_dmac_parse_chan_dt(of_chan, &dmac->chan);
863-
if (ret) {
864-
of_node_put(of_chan);
865-
of_node_put(of_channels);
866-
return -EINVAL;
867-
}
868-
}
869-
of_node_put(of_channels);
939+
if (version >= ADI_AXI_PCORE_VER(4, 3, 'a'))
940+
ret = axi_dmac_read_chan_config(&pdev->dev, dmac);
941+
else
942+
ret = axi_dmac_parse_dt(&pdev->dev, dmac);
943+
944+
if (ret < 0)
945+
goto err_clk_disable;
946+
947+
INIT_LIST_HEAD(&dmac->chan.active_descs);
870948

871-
pdev->dev.dma_parms = &dmac->dma_parms;
872949
dma_set_max_seg_size(&pdev->dev, UINT_MAX);
873950

874951
dma_dev = &dmac->dma_dev;
@@ -894,11 +971,7 @@ static int axi_dmac_probe(struct platform_device *pdev)
894971
dmac->chan.vchan.desc_free = axi_dmac_desc_free;
895972
vchan_init(&dmac->chan.vchan, dma_dev);
896973

897-
ret = clk_prepare_enable(dmac->clk);
898-
if (ret < 0)
899-
return ret;
900-
901-
ret = axi_dmac_detect_caps(dmac);
974+
ret = axi_dmac_detect_caps(dmac, version);
902975
if (ret)
903976
goto err_clk_disable;
904977

0 commit comments

Comments
 (0)