Skip to content

Commit d3464cc

Browse files
committed
Merge tag 'dmaengine-fix-5.3' of git://git.infradead.org/users/vkoul/slave-dma
Pull dmaengine fixes from Vinod Koul: "Some late fixes for drivers: - memory leak in ti crossbar dma driver - cleanup of omap dma probe - Fix for link list configuration in sprd dma driver - Handling fixed for DMACHCLR if iommu is mapped in rcar dma" * tag 'dmaengine-fix-5.3' of git://git.infradead.org/users/vkoul/slave-dma: dmaengine: rcar-dmac: Fix DMACHCLR handling if iommu is mapped dmaengine: sprd: Fix the DMA link-list configuration dmaengine: ti: omap-dma: Add cleanup in omap_dma_probe() dmaengine: ti: dma-crossbar: Fix a memory leak bug
2 parents 1e3778c + cf24aac commit d3464cc

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

drivers/dma/sh/rcar-dmac.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ struct rcar_dmac_chan {
192192
* @iomem: remapped I/O memory base
193193
* @n_channels: number of available channels
194194
* @channels: array of DMAC channels
195+
* @channels_mask: bitfield of which DMA channels are managed by this driver
195196
* @modules: bitmask of client modules in use
196197
*/
197198
struct rcar_dmac {
@@ -202,6 +203,7 @@ struct rcar_dmac {
202203

203204
unsigned int n_channels;
204205
struct rcar_dmac_chan *channels;
206+
unsigned int channels_mask;
205207

206208
DECLARE_BITMAP(modules, 256);
207209
};
@@ -438,7 +440,7 @@ static int rcar_dmac_init(struct rcar_dmac *dmac)
438440
u16 dmaor;
439441

440442
/* Clear all channels and enable the DMAC globally. */
441-
rcar_dmac_write(dmac, RCAR_DMACHCLR, GENMASK(dmac->n_channels - 1, 0));
443+
rcar_dmac_write(dmac, RCAR_DMACHCLR, dmac->channels_mask);
442444
rcar_dmac_write(dmac, RCAR_DMAOR,
443445
RCAR_DMAOR_PRI_FIXED | RCAR_DMAOR_DME);
444446

@@ -814,6 +816,9 @@ static void rcar_dmac_stop_all_chan(struct rcar_dmac *dmac)
814816
for (i = 0; i < dmac->n_channels; ++i) {
815817
struct rcar_dmac_chan *chan = &dmac->channels[i];
816818

819+
if (!(dmac->channels_mask & BIT(i)))
820+
continue;
821+
817822
/* Stop and reinitialize the channel. */
818823
spin_lock_irq(&chan->lock);
819824
rcar_dmac_chan_halt(chan);
@@ -1776,6 +1781,8 @@ static int rcar_dmac_chan_probe(struct rcar_dmac *dmac,
17761781
return 0;
17771782
}
17781783

1784+
#define RCAR_DMAC_MAX_CHANNELS 32
1785+
17791786
static int rcar_dmac_parse_of(struct device *dev, struct rcar_dmac *dmac)
17801787
{
17811788
struct device_node *np = dev->of_node;
@@ -1787,12 +1794,16 @@ static int rcar_dmac_parse_of(struct device *dev, struct rcar_dmac *dmac)
17871794
return ret;
17881795
}
17891796

1790-
if (dmac->n_channels <= 0 || dmac->n_channels >= 100) {
1797+
/* The hardware and driver don't support more than 32 bits in CHCLR */
1798+
if (dmac->n_channels <= 0 ||
1799+
dmac->n_channels >= RCAR_DMAC_MAX_CHANNELS) {
17911800
dev_err(dev, "invalid number of channels %u\n",
17921801
dmac->n_channels);
17931802
return -EINVAL;
17941803
}
17951804

1805+
dmac->channels_mask = GENMASK(dmac->n_channels - 1, 0);
1806+
17961807
return 0;
17971808
}
17981809

@@ -1802,7 +1813,6 @@ static int rcar_dmac_probe(struct platform_device *pdev)
18021813
DMA_SLAVE_BUSWIDTH_2_BYTES | DMA_SLAVE_BUSWIDTH_4_BYTES |
18031814
DMA_SLAVE_BUSWIDTH_8_BYTES | DMA_SLAVE_BUSWIDTH_16_BYTES |
18041815
DMA_SLAVE_BUSWIDTH_32_BYTES | DMA_SLAVE_BUSWIDTH_64_BYTES;
1805-
unsigned int channels_offset = 0;
18061816
struct dma_device *engine;
18071817
struct rcar_dmac *dmac;
18081818
struct resource *mem;
@@ -1831,10 +1841,8 @@ static int rcar_dmac_probe(struct platform_device *pdev)
18311841
* level we can't disable it selectively, so ignore channel 0 for now if
18321842
* the device is part of an IOMMU group.
18331843
*/
1834-
if (device_iommu_mapped(&pdev->dev)) {
1835-
dmac->n_channels--;
1836-
channels_offset = 1;
1837-
}
1844+
if (device_iommu_mapped(&pdev->dev))
1845+
dmac->channels_mask &= ~BIT(0);
18381846

18391847
dmac->channels = devm_kcalloc(&pdev->dev, dmac->n_channels,
18401848
sizeof(*dmac->channels), GFP_KERNEL);
@@ -1892,8 +1900,10 @@ static int rcar_dmac_probe(struct platform_device *pdev)
18921900
INIT_LIST_HEAD(&engine->channels);
18931901

18941902
for (i = 0; i < dmac->n_channels; ++i) {
1895-
ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i],
1896-
i + channels_offset);
1903+
if (!(dmac->channels_mask & BIT(i)))
1904+
continue;
1905+
1906+
ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i], i);
18971907
if (ret < 0)
18981908
goto error;
18991909
}

drivers/dma/sprd-dma.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
908908
struct sprd_dma_chn *schan = to_sprd_dma_chan(chan);
909909
struct dma_slave_config *slave_cfg = &schan->slave_cfg;
910910
dma_addr_t src = 0, dst = 0;
911+
dma_addr_t start_src = 0, start_dst = 0;
911912
struct sprd_dma_desc *sdesc;
912913
struct scatterlist *sg;
913914
u32 len = 0;
@@ -954,6 +955,11 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
954955
dst = sg_dma_address(sg);
955956
}
956957

958+
if (!i) {
959+
start_src = src;
960+
start_dst = dst;
961+
}
962+
957963
/*
958964
* The link-list mode needs at least 2 link-list
959965
* configurations. If there is only one sg, it doesn't
@@ -970,8 +976,8 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
970976
}
971977
}
972978

973-
ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, src, dst, len,
974-
dir, flags, slave_cfg);
979+
ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, start_src,
980+
start_dst, len, dir, flags, slave_cfg);
975981
if (ret) {
976982
kfree(sdesc);
977983
return NULL;

drivers/dma/ti/dma-crossbar.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,10 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)
391391

392392
ret = of_property_read_u32_array(node, pname, (u32 *)rsv_events,
393393
nelm * 2);
394-
if (ret)
394+
if (ret) {
395+
kfree(rsv_events);
395396
return ret;
397+
}
396398

397399
for (i = 0; i < nelm; i++) {
398400
ti_dra7_xbar_reserve(rsv_events[i][0], rsv_events[i][1],

drivers/dma/ti/omap-dma.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,10 @@ static int omap_dma_probe(struct platform_device *pdev)
15401540

15411541
rc = devm_request_irq(&pdev->dev, irq, omap_dma_irq,
15421542
IRQF_SHARED, "omap-dma-engine", od);
1543-
if (rc)
1543+
if (rc) {
1544+
omap_dma_free(od);
15441545
return rc;
1546+
}
15451547
}
15461548

15471549
if (omap_dma_glbl_read(od, CAPS_0) & CAPS_0_SUPPORT_LL123)

0 commit comments

Comments
 (0)