History

Merge tag 'dmaengine-fix-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine

Pull dmaengine fixes from Vinod Koul: "A bunch of driver fixes for: - dma mask fix for mmp pdma driver - Xilinx regmap max register, uninitialized addr_width fix - device leak fix for bunch of drivers in the subsystem - stm32 dmamux, TI crossbar driver fixes for device & of node leak and route allocation cleanup - Tegra use afer free fix - Memory leak fix in Qualcomm gpi and omap-dma driver - compatible fix for apple driver" * tag 'dmaengine-fix-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: (25 commits) dmaengine: apple-admac: Add "apple,t8103-admac" compatible dmaengine: omap-dma: fix dma_pool resource leak in error paths dmaengine: qcom: gpi: Fix memory leak in gpi_peripheral_config() dmaengine: sh: rz-dmac: Fix rz_dmac_terminate_all() dmaengine: xilinx_dma: Fix uninitialized addr_width when "xlnx,addrwidth" property is missing dmaengine: tegra-adma: Fix use-after-free dmaengine: fsl-edma: Fix clk leak on alloc_chan_resources failure dmaengine: mmp_pdma: Fix race condition in mmp_pdma_residue() dmaengine: ti: k3-udma: fix device leak on udma lookup dmaengine: ti: dma-crossbar: clean up dra7x route allocation error paths dmaengine: ti: dma-crossbar: fix device leak on am335x route allocation dmaengine: ti: dma-crossbar: fix device leak on dra7x route allocation dmaengine: stm32: dmamux: clean up route allocation error labels dmaengine: stm32: dmamux: fix OF node leak on route allocation failure dmaengine: stm32: dmamux: fix device leak on route allocation dmaengine: sh: rz-dmac: fix device leak on probe failure dmaengine: lpc32xx-dmamux: fix device leak on route allocation dmaengine: lpc18xx-dmamux: fix device leak on route allocation dmaengine: idxd: fix device leaks on compat bind and unbind dmaengine: dw: dmamux: fix OF node leak on route allocation failure ...

Linus Torvalds committed 10 months ago

Commit e90b81e2 parents 3271b25 76cba1e20 files · +168 −73Browse files

Unified · Split

20 files
  1. drivers/dma/apple-admac.c +1 −0
  2. drivers/dma/at_hdmac.c +7 −2
  3. drivers/dma/bcm-sba-raid.c +5 −1
  4. drivers/dma/cv1800b-dmamux.c +10 −7
  5. drivers/dma/dw/rzn1-dmamux.c +3 −1
  6. drivers/dma/fsl-edma-common.c +1 −0
  7. drivers/dma/idxd/compat.c +19 −4
  8. drivers/dma/lpc18xx-dmamux.c +14 −5
  9. drivers/dma/lpc32xx-dmamux.c +14 −5
  10. drivers/dma/mmp_pdma.c +14 −12
  11. drivers/dma/qcom/gpi.c +4 −2
  12. drivers/dma/sh/rz-dmac.c +16 −2
  13. drivers/dma/stm32/stm32-dmamux.c +19 −12
  14. drivers/dma/tegra210-adma.c +9 −1
  15. drivers/dma/ti/dma-crossbar.c +20 −15
  16. drivers/dma/ti/k3-udma-private.c +1 −1
  17. drivers/dma/ti/omap-dma.c +4 −0
  18. drivers/dma/xilinx/xdma-regs.h +1 −0
  19. drivers/dma/xilinx/xdma.c +1 −1
  20. drivers/dma/xilinx/xilinx_dma.c +5 −2
drivers/dma/apple-admac.c+1−0
@@ -936,6 +936,7 @@ static void admac_remove(struct platform_device *pdev) · 935 unmodified lines
936936 }
937937
938938 static const struct of_device_id admac_of_match[] = {
939+ { .compatible = "apple,t8103-admac", },
939940 { .compatible = "apple,admac", },
940941 { }
941942 };
drivers/dma/at_hdmac.c+7−2
@@ -1765,6 +1765,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan) · 1764 unmodified lines
17651765 static void atc_free_chan_resources(struct dma_chan *chan)
17661766 {
17671767 struct at_dma_chan *atchan = to_at_dma_chan(chan);
1768+ struct at_dma_slave *atslave;
17681769
17691770 BUG_ON(atc_chan_is_enabled(atchan));
17701771
@@ -1774,8 +1775,12 @@ static void atc_free_chan_resources(struct dma_chan *chan) · 3 unmodified lines
17741775 /*
17751776 * Free atslave allocated in at_dma_xlate()
17761777 */
1777− kfree(chan->private);
1778− chan->private = NULL;
1778+ atslave = chan->private;
1779+ if (atslave) {
1780+ put_device(atslave->dma_dev);
1781+ kfree(atslave);
1782+ chan->private = NULL;
1783+ }
17791784
17801785 dev_vdbg(chan2dev(chan), "free_chan_resources: done\n");
17811786 }
drivers/dma/bcm-sba-raid.c+5−1
@@ -1699,7 +1699,7 @@ static int sba_probe(struct platform_device *pdev) · 1698 unmodified lines
16991699 /* Prealloc channel resource */
17001700 ret = sba_prealloc_channel_resources(sba);
17011701 if (ret)
1702− goto fail_free_mchan;
1702+ goto fail_put_mbox;
17031703
17041704 /* Check availability of debugfs */
17051705 if (!debugfs_initialized())
@@ -1729,6 +1729,8 @@ skip_debugfs: · 23 unmodified lines
17291729 fail_free_resources:
17301730 debugfs_remove_recursive(sba->root);
17311731 sba_freeup_channel_resources(sba);
1732+fail_put_mbox:
1733+ put_device(sba->mbox_dev);
17321734 fail_free_mchan:
17331735 mbox_free_channel(sba->mchan);
17341736 return ret;
@@ -1744,6 +1746,8 @@ static void sba_remove(struct platform_device *pdev) · 9 unmodified lines
17441746
17451747 sba_freeup_channel_resources(sba);
17461748
1749+ put_device(sba->mbox_dev);
1750+
17471751 mbox_free_channel(sba->mchan);
17481752 }
17491753
drivers/dma/cv1800b-dmamux.c+10−7
@@ -102,11 +102,11 @@ static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 101 unmodified lines
102102 struct llist_node *node;
103103 unsigned long flags;
104104 unsigned int chid, devid, cpuid;
105− int ret;
105+ int ret = -EINVAL;
106106
107107 if (dma_spec->args_count != DMAMUX_NCELLS) {
108108 dev_err(&pdev->dev, "invalid number of dma mux args\n");
109− return ERR_PTR(-EINVAL);
109+ goto err_put_pdev;
110110 }
111111
112112 devid = dma_spec->args[0];
@@ -115,18 +115,18 @@ static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 2 unmodified lines
115115
116116 if (devid > MAX_DMA_MAPPING_ID) {
117117 dev_err(&pdev->dev, "invalid device id: %u\n", devid);
118− return ERR_PTR(-EINVAL);
118+ goto err_put_pdev;
119119 }
120120
121121 if (cpuid > MAX_DMA_CPU_ID) {
122122 dev_err(&pdev->dev, "invalid cpu id: %u\n", cpuid);
123− return ERR_PTR(-EINVAL);
123+ goto err_put_pdev;
124124 }
125125
126126 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
127127 if (!dma_spec->np) {
128128 dev_err(&pdev->dev, "can't get dma master\n");
129− return ERR_PTR(-EINVAL);
129+ goto err_put_pdev;
130130 }
131131
132132 spin_lock_irqsave(&dmamux->lock, flags);
@@ -136,8 +136,6 @@ static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 3 unmodified lines
136136 if (map->peripheral == devid && map->cpu == cpuid)
137137 goto found;
138138 }
139−
140− ret = -EINVAL;
141139 goto failed;
142140 } else {
143141 node = llist_del_first(&dmamux->free_maps);
@@ -171,12 +169,17 @@ found: · 27 unmodified lines
171169 dev_dbg(&pdev->dev, "register channel %u for req %u (cpu %u)\n",
172170 chid, devid, cpuid);
173171
172+ put_device(&pdev->dev);
173+
174174 return map;
175175
176176 failed:
177177 spin_unlock_irqrestore(&dmamux->lock, flags);
178178 of_node_put(dma_spec->np);
179179 dev_err(&pdev->dev, "errno %d\n", ret);
180+err_put_pdev:
181+ put_device(&pdev->dev);
182+
180183 return ERR_PTR(ret);
181184 }
182185
drivers/dma/dw/rzn1-dmamux.c+3−1
@@ -90,7 +90,7 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 89 unmodified lines
9090
9191 if (test_and_set_bit(map->req_idx, dmamux->used_chans)) {
9292 ret = -EBUSY;
93− goto free_map;
93+ goto put_dma_spec_np;
9494 }
9595
9696 mask = BIT(map->req_idx);
@@ -103,6 +103,8 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 6 unmodified lines
103103
104104 clear_bitmap:
105105 clear_bit(map->req_idx, dmamux->used_chans);
106+put_dma_spec_np:
107+ of_node_put(dma_spec->np);
106108 free_map:
107109 kfree(map);
108110 put_device:
drivers/dma/fsl-edma-common.c+1−0
@@ -873,6 +873,7 @@ err_errirq: · 872 unmodified lines
873873 free_irq(fsl_chan->txirq, fsl_chan);
874874 err_txirq:
875875 dma_pool_destroy(fsl_chan->tcd_pool);
876+ clk_disable_unprepare(fsl_chan->clk);
876877
877878 return ret;
878879 }
drivers/dma/idxd/compat.c+19−4
@@ -20,11 +20,16 @@ static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t c · 19 unmodified lines
2020 int rc = -ENODEV;
2121
2222 dev = bus_find_device_by_name(bus, NULL, buf);
23− if (dev && dev->driver) {
23+ if (!dev)
24+ return -ENODEV;
25+
26+ if (dev->driver) {
2427 device_driver_detach(dev);
2528 rc = count;
2629 }
2730
31+ put_device(dev);
32+
2833 return rc;
2934 }
3035 static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
@@ -38,9 +43,12 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t cou · 7 unmodified lines
3843 struct idxd_dev *idxd_dev;
3944
4045 dev = bus_find_device_by_name(bus, NULL, buf);
41− if (!dev || dev->driver || drv != &dsa_drv.drv)
46+ if (!dev)
4247 return -ENODEV;
4348
49+ if (dev->driver || drv != &dsa_drv.drv)
50+ goto err_put_dev;
51+
4452 idxd_dev = confdev_to_idxd_dev(dev);
4553 if (is_idxd_dev(idxd_dev)) {
4654 alt_drv = driver_find("idxd", bus);
@@ -53,13 +61,20 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t cou · 6 unmodified lines
5361 alt_drv = driver_find("user", bus);
5462 }
5563 if (!alt_drv)
56− return -ENODEV;
64+ goto err_put_dev;
5765
5866 rc = device_driver_attach(alt_drv, dev);
5967 if (rc < 0)
60− return rc;
68+ goto err_put_dev;
69+
70+ put_device(dev);
6171
6272 return count;
73+
74+err_put_dev:
75+ put_device(dev);
76+
77+ return rc;
6378 }
6479 static DRIVER_ATTR_IGNORE_LOCKDEP(bind, 0200, NULL, bind_store);
6580
drivers/dma/lpc18xx-dmamux.c+14−5
@@ -57,30 +57,31 @@ static void *lpc18xx_dmamux_reserve(struct of_phandle_args *dma_spec, · 56 unmodified lines
5757 struct lpc18xx_dmamux_data *dmamux = platform_get_drvdata(pdev);
5858 unsigned long flags;
5959 unsigned mux;
60+ int ret = -EINVAL;
6061
6162 if (dma_spec->args_count != 3) {
6263 dev_err(&pdev->dev, "invalid number of dma mux args\n");
63− return ERR_PTR(-EINVAL);
64+ goto err_put_pdev;
6465 }
6566
6667 mux = dma_spec->args[0];
6768 if (mux >= dmamux->dma_master_requests) {
6869 dev_err(&pdev->dev, "invalid mux number: %d\n",
6970 dma_spec->args[0]);
70− return ERR_PTR(-EINVAL);
71+ goto err_put_pdev;
7172 }
7273
7374 if (dma_spec->args[1] > LPC18XX_DMAMUX_MAX_VAL) {
7475 dev_err(&pdev->dev, "invalid dma mux value: %d\n",
7576 dma_spec->args[1]);
76− return ERR_PTR(-EINVAL);
77+ goto err_put_pdev;
7778 }
7879
7980 /* The of_node_put() will be done in the core for the node */
8081 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
8182 if (!dma_spec->np) {
8283 dev_err(&pdev->dev, "can't get dma master\n");
83− return ERR_PTR(-EINVAL);
84+ goto err_put_pdev;
8485 }
8586
8687 spin_lock_irqsave(&dmamux->lock, flags);
@@ -89,7 +90,8 @@ static void *lpc18xx_dmamux_reserve(struct of_phandle_args *dma_spec, · 2 unmodified lines
8990 dev_err(&pdev->dev, "dma request %u busy with %u.%u\n",
9091 mux, mux, dmamux->muxes[mux].value);
9192 of_node_put(dma_spec->np);
92− return ERR_PTR(-EBUSY);
93+ ret = -EBUSY;
94+ goto err_put_pdev;
9395 }
9496
9597 dmamux->muxes[mux].busy = true;
@@ -106,7 +108,14 @@ static void *lpc18xx_dmamux_reserve(struct of_phandle_args *dma_spec, · 10 unmodified lines
106108 dev_dbg(&pdev->dev, "mapping dmamux %u.%u to dma request %u\n", mux,
107109 dmamux->muxes[mux].value, mux);
108110
111+ put_device(&pdev->dev);
112+
109113 return &dmamux->muxes[mux];
114+
115+err_put_pdev:
116+ put_device(&pdev->dev);
117+
118+ return ERR_PTR(ret);
110119 }
111120
112121 static int lpc18xx_dmamux_probe(struct platform_device *pdev)
drivers/dma/lpc32xx-dmamux.c+14−5
@@ -95,11 +95,12 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec, · 94 unmodified lines
9595 struct lpc32xx_dmamux_data *dmamux = platform_get_drvdata(pdev);
9696 unsigned long flags;
9797 struct lpc32xx_dmamux *mux = NULL;
98+ int ret = -EINVAL;
9899 int i;
99100
100101 if (dma_spec->args_count != 3) {
101102 dev_err(&pdev->dev, "invalid number of dma mux args\n");
102− return ERR_PTR(-EINVAL);
103+ goto err_put_pdev;
103104 }
104105
105106 for (i = 0; i < ARRAY_SIZE(lpc32xx_muxes); i++) {
@@ -111,20 +112,20 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec, · 5 unmodified lines
111112 if (!mux) {
112113 dev_err(&pdev->dev, "invalid mux request number: %d\n",
113114 dma_spec->args[0]);
114− return ERR_PTR(-EINVAL);
115+ goto err_put_pdev;
115116 }
116117
117118 if (dma_spec->args[2] > 1) {
118119 dev_err(&pdev->dev, "invalid dma mux value: %d\n",
119120 dma_spec->args[1]);
120− return ERR_PTR(-EINVAL);
121+ goto err_put_pdev;
121122 }
122123
123124 /* The of_node_put() will be done in the core for the node */
124125 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
125126 if (!dma_spec->np) {
126127 dev_err(&pdev->dev, "can't get dma master\n");
127− return ERR_PTR(-EINVAL);
128+ goto err_put_pdev;
128129 }
129130
130131 spin_lock_irqsave(&dmamux->lock, flags);
@@ -133,7 +134,8 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec, · 2 unmodified lines
133134 dev_err(dev, "dma request signal %d busy, routed to %s\n",
134135 mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1);
135136 of_node_put(dma_spec->np);
136− return ERR_PTR(-EBUSY);
137+ ret = -EBUSY;
138+ goto err_put_pdev;
137139 }
138140
139141 mux->busy = true;
@@ -148,7 +150,14 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec, · 8 unmodified lines
148150 dev_dbg(dev, "dma request signal %d routed to %s\n",
149151 mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1);
150152
153+ put_device(&pdev->dev);
154+
151155 return mux;
156+
157+err_put_pdev:
158+ put_device(&pdev->dev);
159+
160+ return ERR_PTR(ret);
152161 }
153162
154163 static int lpc32xx_dmamux_probe(struct platform_device *pdev)
drivers/dma/mmp_pdma.c+14−12
@@ -152,8 +152,8 @@ struct mmp_pdma_phy { · 151 unmodified lines
152152 *
153153 * Controller Configuration:
154154 * @run_bits: Control bits in DCSR register for channel start/stop
155− * @dma_mask: DMA addressing capability of controller. 0 to use OF/platform
156− * settings, or explicit mask like DMA_BIT_MASK(32/64)
155+ * @dma_width: DMA addressing width in bits (32 or 64). Determines the
156+ * DMA mask capability of the controller hardware.
157157 */
158158 struct mmp_pdma_ops {
159159 /* Hardware Register Operations */
@@ -173,7 +173,7 @@ struct mmp_pdma_ops { · 13 unmodified lines
173173
174174 /* Controller Configuration */
175175 u32 run_bits;
176− u64 dma_mask;
176+ u32 dma_width;
177177 };
178178
179179 struct mmp_pdma_device {
@@ -928,6 +928,7 @@ static unsigned int mmp_pdma_residue(struct mmp_pdma_chan *chan, · 748 unmodified lines
928928 {
929929 struct mmp_pdma_desc_sw *sw;
930930 struct mmp_pdma_device *pdev = to_mmp_pdma_dev(chan->chan.device);
931+ unsigned long flags;
931932 u64 curr;
932933 u32 residue = 0;
933934 bool passed = false;
@@ -945,6 +946,8 @@ static unsigned int mmp_pdma_residue(struct mmp_pdma_chan *chan, · 11 unmodified lines
945946 else
946947 curr = pdev->ops->read_src_addr(chan->phy);
947948
949+ spin_lock_irqsave(&chan->desc_lock, flags);
950+
948951 list_for_each_entry(sw, &chan->chain_running, node) {
949952 u64 start, end;
950953 u32 len;
@@ -989,6 +992,7 @@ static unsigned int mmp_pdma_residue(struct mmp_pdma_chan *chan, · 38 unmodified lines
989992 continue;
990993
991994 if (sw->async_tx.cookie == cookie) {
995+ spin_unlock_irqrestore(&chan->desc_lock, flags);
992996 return residue;
993997 } else {
994998 residue = 0;
@@ -996,6 +1000,8 @@ static unsigned int mmp_pdma_residue(struct mmp_pdma_chan *chan, · 1 unmodified line
9961000 }
9971001 }
9981002
1003+ spin_unlock_irqrestore(&chan->desc_lock, flags);
1004+
9991005 /* We should only get here in case of cyclic transactions */
10001006 return residue;
10011007 }
@@ -1172,7 +1178,7 @@ static const struct mmp_pdma_ops marvell_pdma_v1_ops = { · 170 unmodified lines
11721178 .get_desc_src_addr = get_desc_src_addr_32,
11731179 .get_desc_dst_addr = get_desc_dst_addr_32,
11741180 .run_bits = (DCSR_RUN),
1175− .dma_mask = 0, /* let OF/platform set DMA mask */
1181+ .dma_width = 32,
11761182 };
11771183
11781184 static const struct mmp_pdma_ops spacemit_k1_pdma_ops = {
@@ -1185,7 +1191,7 @@ static const struct mmp_pdma_ops spacemit_k1_pdma_ops = { · 6 unmodified lines
11851191 .get_desc_src_addr = get_desc_src_addr_64,
11861192 .get_desc_dst_addr = get_desc_dst_addr_64,
11871193 .run_bits = (DCSR_RUN | DCSR_LPAEEN),
1188− .dma_mask = DMA_BIT_MASK(64), /* force 64-bit DMA addr capability */
1194+ .dma_width = 64,
11891195 };
11901196
11911197 static const struct of_device_id mmp_pdma_dt_ids[] = {
@@ -1314,13 +1320,9 @@ static int mmp_pdma_probe(struct platform_device *op) · 122 unmodified lines
13141320 pdev->device.directions = BIT(DMA_MEM_TO_DEV) | BIT(DMA_DEV_TO_MEM);
13151321 pdev->device.residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
13161322
1317− /* Set DMA mask based on ops->dma_mask, or OF/platform */
1318− if (pdev->ops->dma_mask)
1319− dma_set_mask(pdev->dev, pdev->ops->dma_mask);
1320− else if (pdev->dev->coherent_dma_mask)
1321− dma_set_mask(pdev->dev, pdev->dev->coherent_dma_mask);
1322− else
1323− dma_set_mask(pdev->dev, DMA_BIT_MASK(64));
1323+ /* Set DMA mask based on controller hardware capabilities */
1324+ dma_set_mask_and_coherent(pdev->dev,
1325+ DMA_BIT_MASK(pdev->ops->dma_width));
13241326
13251327 ret = dma_async_device_register(&pdev->device);
13261328 if (ret) {
drivers/dma/qcom/gpi.c+4−2
@@ -1605,14 +1605,16 @@ static int · 1604 unmodified lines
16051605 gpi_peripheral_config(struct dma_chan *chan, struct dma_slave_config *config)
16061606 {
16071607 struct gchan *gchan = to_gchan(chan);
1608+ void *new_config;
16081609
16091610 if (!config->peripheral_config)
16101611 return -EINVAL;
16111612
1612− gchan->config = krealloc(gchan->config, config->peripheral_size, GFP_NOWAIT);
1613− if (!gchan->config)
1613+ new_config = krealloc(gchan->config, config->peripheral_size, GFP_NOWAIT);
1614+ if (!new_config)
16141615 return -ENOMEM;
16151616
1617+ gchan->config = new_config;
16161618 memcpy(gchan->config, config->peripheral_config, config->peripheral_size);
16171619
16181620 return 0;
drivers/dma/sh/rz-dmac.c+16−2
@@ -557,11 +557,16 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, · 556 unmodified lines
557557 static int rz_dmac_terminate_all(struct dma_chan *chan)
558558 {
559559 struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
560+ struct rz_lmdesc *lmdesc = channel->lmdesc.base;
560561 unsigned long flags;
562+ unsigned int i;
561563 LIST_HEAD(head);
562564
563565 rz_dmac_disable_hw(channel);
564566 spin_lock_irqsave(&channel->vc.lock, flags);
567+ for (i = 0; i < DMAC_NR_LMDESC; i++)
568+ lmdesc[i].header = 0;
569+
565570 list_splice_tail_init(&channel->ld_active, &channel->ld_free);
566571 list_splice_tail_init(&channel->ld_queue, &channel->ld_free);
567572 vchan_get_all_descriptors(&channel->vc, &head);
@@ -854,6 +859,13 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac, · 286 unmodified lines
854859 return 0;
855860 }
856861
862+static void rz_dmac_put_device(void *_dev)
863+{
864+ struct device *dev = _dev;
865+
866+ put_device(dev);
867+}
868+
857869 static int rz_dmac_parse_of_icu(struct device *dev, struct rz_dmac *dmac)
858870 {
859871 struct device_node *np = dev->of_node;
@@ -876,6 +888,10 @@ static int rz_dmac_parse_of_icu(struct device *dev, struct rz_dmac *dmac) · 16 unmodified lines
876888 return -ENODEV;
877889 }
878890
891+ ret = devm_add_action_or_reset(dev, rz_dmac_put_device, &dmac->icu.pdev->dev);
892+ if (ret)
893+ return ret;
894+
879895 dmac_index = args.args[0];
880896 if (dmac_index > RZV2H_MAX_DMAC_INDEX) {
881897 dev_err(dev, "DMAC index %u invalid.\n", dmac_index);
@@ -1055,8 +1071,6 @@ static void rz_dmac_remove(struct platform_device *pdev) · 173 unmodified lines
10551071 reset_control_assert(dmac->rstc);
10561072 pm_runtime_put(&pdev->dev);
10571073 pm_runtime_disable(&pdev->dev);
1058−
1059− platform_device_put(dmac->icu.pdev);
10601074 }
10611075
10621076 static const struct of_device_id of_rz_dmac_match[] = {
drivers/dma/stm32/stm32-dmamux.c+19−12
@@ -90,23 +90,25 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 89 unmodified lines
9090 struct stm32_dmamux_data *dmamux = platform_get_drvdata(pdev);
9191 struct stm32_dmamux *mux;
9292 u32 i, min, max;
93− int ret;
93+ int ret = -EINVAL;
9494 unsigned long flags;
9595
9696 if (dma_spec->args_count != 3) {
9797 dev_err(&pdev->dev, "invalid number of dma mux args\n");
98− return ERR_PTR(-EINVAL);
98+ goto err_put_pdev;
9999 }
100100
101101 if (dma_spec->args[0] > dmamux->dmamux_requests) {
102102 dev_err(&pdev->dev, "invalid mux request number: %d\n",
103103 dma_spec->args[0]);
104− return ERR_PTR(-EINVAL);
104+ goto err_put_pdev;
105105 }
106106
107107 mux = kzalloc(sizeof(*mux), GFP_KERNEL);
108− if (!mux)
109− return ERR_PTR(-ENOMEM);
108+ if (!mux) {
109+ ret = -ENOMEM;
110+ goto err_put_pdev;
111+ }
110112
111113 spin_lock_irqsave(&dmamux->lock, flags);
112114 mux->chan_id = find_first_zero_bit(dmamux->dma_inuse,
@@ -116,7 +118,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 3 unmodified lines
116118 spin_unlock_irqrestore(&dmamux->lock, flags);
117119 dev_err(&pdev->dev, "Run out of free DMA requests\n");
118120 ret = -ENOMEM;
119− goto error_chan_id;
121+ goto err_free_mux;
120122 }
121123 set_bit(mux->chan_id, dmamux->dma_inuse);
122124 spin_unlock_irqrestore(&dmamux->lock, flags);
@@ -133,8 +135,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 10 unmodified lines
133135 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", i - 1);
134136 if (!dma_spec->np) {
135137 dev_err(&pdev->dev, "can't get dma master\n");
136− ret = -EINVAL;
137− goto error;
138+ goto err_clear_inuse;
138139 }
139140
140141 /* Set dma request */
@@ -142,7 +143,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 1 unmodified line
142143 ret = pm_runtime_resume_and_get(&pdev->dev);
143144 if (ret < 0) {
144145 spin_unlock_irqrestore(&dmamux->lock, flags);
145− goto error;
146+ goto err_put_dma_spec_np;
146147 }
147148 spin_unlock_irqrestore(&dmamux->lock, flags);
148149
@@ -160,13 +161,19 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, · 11 unmodified lines
160161 dev_dbg(&pdev->dev, "Mapping DMAMUX(%u) to DMA%u(%u)\n",
161162 mux->request, mux->master, mux->chan_id);
162163
164+ put_device(&pdev->dev);
165+
163166 return mux;
164167
165−error:
168+err_put_dma_spec_np:
169+ of_node_put(dma_spec->np);
170+err_clear_inuse:
166171 clear_bit(mux->chan_id, dmamux->dma_inuse);
167−
168−error_chan_id:
172+err_free_mux:
169173 kfree(mux);
174+err_put_pdev:
175+ put_device(&pdev->dev);
176+
170177 return ERR_PTR(ret);
171178 }
172179
drivers/dma/tegra210-adma.c+9−1
@@ -429,10 +429,17 @@ static void tegra_adma_stop(struct tegra_adma_chan *tdc) · 428 unmodified lines
429429 return;
430430 }
431431
432− kfree(tdc->desc);
432+ vchan_terminate_vdesc(&tdc->desc->vd);
433433 tdc->desc = NULL;
434434 }
435435
436+static void tegra_adma_synchronize(struct dma_chan *dc)
437+{
438+ struct tegra_adma_chan *tdc = to_tegra_adma_chan(dc);
439+
440+ vchan_synchronize(&tdc->vc);
441+}
442+
436443 static void tegra_adma_start(struct tegra_adma_chan *tdc)
437444 {
438445 struct virt_dma_desc *vd = vchan_next_desc(&tdc->vc);
@@ -1155,6 +1162,7 @@ static int tegra_adma_probe(struct platform_device *pdev) · 716 unmodified lines
11551162 tdma->dma_dev.device_config = tegra_adma_slave_config;
11561163 tdma->dma_dev.device_tx_status = tegra_adma_tx_status;
11571164 tdma->dma_dev.device_terminate_all = tegra_adma_terminate_all;
1165+ tdma->dma_dev.device_synchronize = tegra_adma_synchronize;
11581166 tdma->dma_dev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
11591167 tdma->dma_dev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
11601168 tdma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
drivers/dma/ti/dma-crossbar.c+20−15
@@ -79,34 +79,35 @@ static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec, · 78 unmodified lines
7979 {
8080 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
8181 struct ti_am335x_xbar_data *xbar = platform_get_drvdata(pdev);
82− struct ti_am335x_xbar_map *map;
82+ struct ti_am335x_xbar_map *map = ERR_PTR(-EINVAL);
8383
8484 if (dma_spec->args_count != 3)
85− return ERR_PTR(-EINVAL);
85+ goto out_put_pdev;
8686
8787 if (dma_spec->args[2] >= xbar->xbar_events) {
8888 dev_err(&pdev->dev, "Invalid XBAR event number: %d\n",
8989 dma_spec->args[2]);
90− return ERR_PTR(-EINVAL);
90+ goto out_put_pdev;
9191 }
9292
9393 if (dma_spec->args[0] >= xbar->dma_requests) {
9494 dev_err(&pdev->dev, "Invalid DMA request line number: %d\n",
9595 dma_spec->args[0]);
96− return ERR_PTR(-EINVAL);
96+ goto out_put_pdev;
9797 }
9898
9999 /* The of_node_put() will be done in the core for the node */
100100 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
101101 if (!dma_spec->np) {
102102 dev_err(&pdev->dev, "Can't get DMA master\n");
103− return ERR_PTR(-EINVAL);
103+ goto out_put_pdev;
104104 }
105105
106106 map = kzalloc(sizeof(*map), GFP_KERNEL);
107107 if (!map) {
108108 of_node_put(dma_spec->np);
109− return ERR_PTR(-ENOMEM);
109+ map = ERR_PTR(-ENOMEM);
110+ goto out_put_pdev;
110111 }
111112
112113 map->dma_line = (u16)dma_spec->args[0];
@@ -120,6 +121,9 @@ static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec, · 7 unmodified lines
120121
121122 ti_am335x_xbar_write(xbar->iomem, map->dma_line, map->mux_val);
122123
124+out_put_pdev:
125+ put_device(&pdev->dev);
126+
123127 return map;
124128 }
125129
@@ -241,28 +245,26 @@ static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec, · 115 unmodified lines
241245 {
242246 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
243247 struct ti_dra7_xbar_data *xbar = platform_get_drvdata(pdev);
244− struct ti_dra7_xbar_map *map;
248+ struct ti_dra7_xbar_map *map = ERR_PTR(-EINVAL);
245249
246250 if (dma_spec->args[0] >= xbar->xbar_requests) {
247251 dev_err(&pdev->dev, "Invalid XBAR request number: %d\n",
248252 dma_spec->args[0]);
249− put_device(&pdev->dev);
250− return ERR_PTR(-EINVAL);
253+ goto out_put_pdev;
251254 }
252255
253256 /* The of_node_put() will be done in the core for the node */
254257 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
255258 if (!dma_spec->np) {
256259 dev_err(&pdev->dev, "Can't get DMA master\n");
257− put_device(&pdev->dev);
258− return ERR_PTR(-EINVAL);
260+ goto out_put_pdev;
259261 }
260262
261263 map = kzalloc(sizeof(*map), GFP_KERNEL);
262264 if (!map) {
263265 of_node_put(dma_spec->np);
264− put_device(&pdev->dev);
265− return ERR_PTR(-ENOMEM);
266+ map = ERR_PTR(-ENOMEM);
267+ goto out_put_pdev;
266268 }
267269
268270 mutex_lock(&xbar->mutex);
@@ -273,8 +275,8 @@ static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec, · 4 unmodified lines
273275 dev_err(&pdev->dev, "Run out of free DMA requests\n");
274276 kfree(map);
275277 of_node_put(dma_spec->np);
276− put_device(&pdev->dev);
277− return ERR_PTR(-ENOMEM);
278+ map = ERR_PTR(-ENOMEM);
279+ goto out_put_pdev;
278280 }
279281 set_bit(map->xbar_out, xbar->dma_inuse);
280282 mutex_unlock(&xbar->mutex);
@@ -288,6 +290,9 @@ static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec, · 7 unmodified lines
288290
289291 ti_dra7_xbar_write(xbar->iomem, map->xbar_out, map->xbar_in);
290292
293+out_put_pdev:
294+ put_device(&pdev->dev);
295+
291296 return map;
292297 }
293298
drivers/dma/ti/k3-udma-private.c+1−1
@@ -42,9 +42,9 @@ struct udma_dev *of_xudma_dev_get(struct device_node *np, const char *property) · 41 unmodified lines
4242 }
4343
4444 ud = platform_get_drvdata(pdev);
45+ put_device(&pdev->dev);
4546 if (!ud) {
4647 pr_debug("UDMA has not been probed\n");
47− put_device(&pdev->dev);
4848 return ERR_PTR(-EPROBE_DEFER);
4949 }
5050
drivers/dma/ti/omap-dma.c+4−0
@@ -1808,6 +1808,8 @@ static int omap_dma_probe(struct platform_device *pdev) · 1807 unmodified lines
18081808 if (rc) {
18091809 pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n",
18101810 rc);
1811+ if (od->ll123_supported)
1812+ dma_pool_destroy(od->desc_pool);
18111813 omap_dma_free(od);
18121814 return rc;
18131815 }
@@ -1823,6 +1825,8 @@ static int omap_dma_probe(struct platform_device *pdev) · 9 unmodified lines
18231825 if (rc) {
18241826 pr_warn("OMAP-DMA: failed to register DMA controller\n");
18251827 dma_async_device_unregister(&od->ddev);
1828+ if (od->ll123_supported)
1829+ dma_pool_destroy(od->desc_pool);
18261830 omap_dma_free(od);
18271831 }
18281832 }
drivers/dma/xilinx/xdma-regs.h+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99
1010 /* The length of register space exposed to host */
1111 #define XDMA_REG_SPACE_LEN 65536
12+#define XDMA_MAX_REG_OFFSET (XDMA_REG_SPACE_LEN - 4)
1213
1314 /*
1415 * maximum number of DMA channels for each direction:
drivers/dma/xilinx/xdma.c+1−1
@@ -38,7 +38,7 @@ static const struct regmap_config xdma_regmap_config = { · 37 unmodified lines
3838 .reg_bits = 32,
3939 .val_bits = 32,
4040 .reg_stride = 4,
41− .max_register = XDMA_REG_SPACE_LEN,
41+ .max_register = XDMA_MAX_REG_OFFSET,
4242 };
4343
4444 /**
drivers/dma/xilinx/xilinx_dma.c+5−2
@@ -131,6 +131,7 @@ · 130 unmodified lines
131131 #define XILINX_MCDMA_MAX_CHANS_PER_DEVICE 0x20
132132 #define XILINX_DMA_MAX_CHANS_PER_DEVICE 0x2
133133 #define XILINX_CDMA_MAX_CHANS_PER_DEVICE 0x1
134+#define XILINX_DMA_DFAULT_ADDRWIDTH 0x20
134135
135136 #define XILINX_DMA_DMAXR_ALL_IRQ_MASK \
136137 (XILINX_DMA_DMASR_FRM_CNT_IRQ | \
@@ -3159,7 +3160,7 @@ static int xilinx_dma_probe(struct platform_device *pdev) · 3022 unmodified lines
31593160 struct device_node *node = pdev->dev.of_node;
31603161 struct xilinx_dma_device *xdev;
31613162 struct device_node *child, *np = pdev->dev.of_node;
3162− u32 num_frames, addr_width, len_width;
3163+ u32 num_frames, addr_width = XILINX_DMA_DFAULT_ADDRWIDTH, len_width;
31633164 int i, err;
31643165
31653166 /* Allocate and initialize the DMA engine structure */
@@ -3235,7 +3236,9 @@ static int xilinx_dma_probe(struct platform_device *pdev) · 69 unmodified lines
32353236
32363237 err = of_property_read_u32(node, "xlnx,addrwidth", &addr_width);
32373238 if (err < 0)
3238− dev_warn(xdev->dev, "missing xlnx,addrwidth property\n");
3239+ dev_warn(xdev->dev,
3240+ "missing xlnx,addrwidth property, using default value %d\n",
3241+ XILINX_DMA_DFAULT_ADDRWIDTH);
32393242
32403243 if (addr_width > 32)
32413244 xdev->ext_addr = true;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t