Commit d3464ccd authored by Linus Torvalds's avatar Linus Torvalds

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
parents 1e3778cb cf24aac3
...@@ -192,6 +192,7 @@ struct rcar_dmac_chan { ...@@ -192,6 +192,7 @@ struct rcar_dmac_chan {
* @iomem: remapped I/O memory base * @iomem: remapped I/O memory base
* @n_channels: number of available channels * @n_channels: number of available channels
* @channels: array of DMAC channels * @channels: array of DMAC channels
* @channels_mask: bitfield of which DMA channels are managed by this driver
* @modules: bitmask of client modules in use * @modules: bitmask of client modules in use
*/ */
struct rcar_dmac { struct rcar_dmac {
...@@ -202,6 +203,7 @@ struct rcar_dmac { ...@@ -202,6 +203,7 @@ struct rcar_dmac {
unsigned int n_channels; unsigned int n_channels;
struct rcar_dmac_chan *channels; struct rcar_dmac_chan *channels;
unsigned int channels_mask;
DECLARE_BITMAP(modules, 256); DECLARE_BITMAP(modules, 256);
}; };
...@@ -438,7 +440,7 @@ static int rcar_dmac_init(struct rcar_dmac *dmac) ...@@ -438,7 +440,7 @@ static int rcar_dmac_init(struct rcar_dmac *dmac)
u16 dmaor; u16 dmaor;
/* Clear all channels and enable the DMAC globally. */ /* Clear all channels and enable the DMAC globally. */
rcar_dmac_write(dmac, RCAR_DMACHCLR, GENMASK(dmac->n_channels - 1, 0)); rcar_dmac_write(dmac, RCAR_DMACHCLR, dmac->channels_mask);
rcar_dmac_write(dmac, RCAR_DMAOR, rcar_dmac_write(dmac, RCAR_DMAOR,
RCAR_DMAOR_PRI_FIXED | RCAR_DMAOR_DME); RCAR_DMAOR_PRI_FIXED | RCAR_DMAOR_DME);
...@@ -814,6 +816,9 @@ static void rcar_dmac_stop_all_chan(struct rcar_dmac *dmac) ...@@ -814,6 +816,9 @@ static void rcar_dmac_stop_all_chan(struct rcar_dmac *dmac)
for (i = 0; i < dmac->n_channels; ++i) { for (i = 0; i < dmac->n_channels; ++i) {
struct rcar_dmac_chan *chan = &dmac->channels[i]; struct rcar_dmac_chan *chan = &dmac->channels[i];
if (!(dmac->channels_mask & BIT(i)))
continue;
/* Stop and reinitialize the channel. */ /* Stop and reinitialize the channel. */
spin_lock_irq(&chan->lock); spin_lock_irq(&chan->lock);
rcar_dmac_chan_halt(chan); rcar_dmac_chan_halt(chan);
...@@ -1776,6 +1781,8 @@ static int rcar_dmac_chan_probe(struct rcar_dmac *dmac, ...@@ -1776,6 +1781,8 @@ static int rcar_dmac_chan_probe(struct rcar_dmac *dmac,
return 0; return 0;
} }
#define RCAR_DMAC_MAX_CHANNELS 32
static int rcar_dmac_parse_of(struct device *dev, struct rcar_dmac *dmac) static int rcar_dmac_parse_of(struct device *dev, struct rcar_dmac *dmac)
{ {
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
...@@ -1787,12 +1794,16 @@ static int rcar_dmac_parse_of(struct device *dev, struct rcar_dmac *dmac) ...@@ -1787,12 +1794,16 @@ static int rcar_dmac_parse_of(struct device *dev, struct rcar_dmac *dmac)
return ret; return ret;
} }
if (dmac->n_channels <= 0 || dmac->n_channels >= 100) { /* The hardware and driver don't support more than 32 bits in CHCLR */
if (dmac->n_channels <= 0 ||
dmac->n_channels >= RCAR_DMAC_MAX_CHANNELS) {
dev_err(dev, "invalid number of channels %u\n", dev_err(dev, "invalid number of channels %u\n",
dmac->n_channels); dmac->n_channels);
return -EINVAL; return -EINVAL;
} }
dmac->channels_mask = GENMASK(dmac->n_channels - 1, 0);
return 0; return 0;
} }
...@@ -1802,7 +1813,6 @@ static int rcar_dmac_probe(struct platform_device *pdev) ...@@ -1802,7 +1813,6 @@ static int rcar_dmac_probe(struct platform_device *pdev)
DMA_SLAVE_BUSWIDTH_2_BYTES | DMA_SLAVE_BUSWIDTH_4_BYTES | DMA_SLAVE_BUSWIDTH_2_BYTES | DMA_SLAVE_BUSWIDTH_4_BYTES |
DMA_SLAVE_BUSWIDTH_8_BYTES | DMA_SLAVE_BUSWIDTH_16_BYTES | DMA_SLAVE_BUSWIDTH_8_BYTES | DMA_SLAVE_BUSWIDTH_16_BYTES |
DMA_SLAVE_BUSWIDTH_32_BYTES | DMA_SLAVE_BUSWIDTH_64_BYTES; DMA_SLAVE_BUSWIDTH_32_BYTES | DMA_SLAVE_BUSWIDTH_64_BYTES;
unsigned int channels_offset = 0;
struct dma_device *engine; struct dma_device *engine;
struct rcar_dmac *dmac; struct rcar_dmac *dmac;
struct resource *mem; struct resource *mem;
...@@ -1831,10 +1841,8 @@ static int rcar_dmac_probe(struct platform_device *pdev) ...@@ -1831,10 +1841,8 @@ static int rcar_dmac_probe(struct platform_device *pdev)
* level we can't disable it selectively, so ignore channel 0 for now if * level we can't disable it selectively, so ignore channel 0 for now if
* the device is part of an IOMMU group. * the device is part of an IOMMU group.
*/ */
if (device_iommu_mapped(&pdev->dev)) { if (device_iommu_mapped(&pdev->dev))
dmac->n_channels--; dmac->channels_mask &= ~BIT(0);
channels_offset = 1;
}
dmac->channels = devm_kcalloc(&pdev->dev, dmac->n_channels, dmac->channels = devm_kcalloc(&pdev->dev, dmac->n_channels,
sizeof(*dmac->channels), GFP_KERNEL); sizeof(*dmac->channels), GFP_KERNEL);
...@@ -1892,8 +1900,10 @@ static int rcar_dmac_probe(struct platform_device *pdev) ...@@ -1892,8 +1900,10 @@ static int rcar_dmac_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&engine->channels); INIT_LIST_HEAD(&engine->channels);
for (i = 0; i < dmac->n_channels; ++i) { for (i = 0; i < dmac->n_channels; ++i) {
ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i], if (!(dmac->channels_mask & BIT(i)))
i + channels_offset); continue;
ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i], i);
if (ret < 0) if (ret < 0)
goto error; goto error;
} }
......
...@@ -908,6 +908,7 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, ...@@ -908,6 +908,7 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); struct sprd_dma_chn *schan = to_sprd_dma_chan(chan);
struct dma_slave_config *slave_cfg = &schan->slave_cfg; struct dma_slave_config *slave_cfg = &schan->slave_cfg;
dma_addr_t src = 0, dst = 0; dma_addr_t src = 0, dst = 0;
dma_addr_t start_src = 0, start_dst = 0;
struct sprd_dma_desc *sdesc; struct sprd_dma_desc *sdesc;
struct scatterlist *sg; struct scatterlist *sg;
u32 len = 0; u32 len = 0;
...@@ -954,6 +955,11 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, ...@@ -954,6 +955,11 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
dst = sg_dma_address(sg); dst = sg_dma_address(sg);
} }
if (!i) {
start_src = src;
start_dst = dst;
}
/* /*
* The link-list mode needs at least 2 link-list * The link-list mode needs at least 2 link-list
* configurations. If there is only one sg, it doesn't * 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, ...@@ -970,8 +976,8 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
} }
} }
ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, src, dst, len, ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, start_src,
dir, flags, slave_cfg); start_dst, len, dir, flags, slave_cfg);
if (ret) { if (ret) {
kfree(sdesc); kfree(sdesc);
return NULL; return NULL;
......
...@@ -391,8 +391,10 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev) ...@@ -391,8 +391,10 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)
ret = of_property_read_u32_array(node, pname, (u32 *)rsv_events, ret = of_property_read_u32_array(node, pname, (u32 *)rsv_events,
nelm * 2); nelm * 2);
if (ret) if (ret) {
kfree(rsv_events);
return ret; return ret;
}
for (i = 0; i < nelm; i++) { for (i = 0; i < nelm; i++) {
ti_dra7_xbar_reserve(rsv_events[i][0], rsv_events[i][1], ti_dra7_xbar_reserve(rsv_events[i][0], rsv_events[i][1],
......
...@@ -1540,8 +1540,10 @@ static int omap_dma_probe(struct platform_device *pdev) ...@@ -1540,8 +1540,10 @@ static int omap_dma_probe(struct platform_device *pdev)
rc = devm_request_irq(&pdev->dev, irq, omap_dma_irq, rc = devm_request_irq(&pdev->dev, irq, omap_dma_irq,
IRQF_SHARED, "omap-dma-engine", od); IRQF_SHARED, "omap-dma-engine", od);
if (rc) if (rc) {
omap_dma_free(od);
return rc; return rc;
}
} }
if (omap_dma_glbl_read(od, CAPS_0) & CAPS_0_SUPPORT_LL123) if (omap_dma_glbl_read(od, CAPS_0) & CAPS_0_SUPPORT_LL123)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment