Commit 23889c6352ab4a842a30221bb412ff49954b2fb3

Authored by Sascha Hauer
1 parent 7214a8b14f

dmaengine i.MX SDMA: reserve channel 0 by not registering it

We need channel 0 of the sdma engine for internal purposes. We
accomplished this by calling dma_request_channel() in the probe
function. This does not work when multiple dma engines are
present which is the case when IPU support for i.MX31/35 is
compiled in. So instead of registering channel 0 and reserving
it afterwards simply do not register it in the first place.
With this the dmaengine channel counting does not match sdma
channel counting anymore, so we have to use sdma channel counting
in the driver.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Showing 1 changed file with 12 additions and 18 deletions Side-by-side Diff

drivers/dma/imx-sdma.c
... ... @@ -230,7 +230,7 @@
230 230 * struct sdma_channel - housekeeping for a SDMA channel
231 231 *
232 232 * @sdma pointer to the SDMA engine for this channel
233   - * @channel the channel number, matches dmaengine chan_id
  233 + * @channel the channel number, matches dmaengine chan_id + 1
234 234 * @direction transfer type. Needed for setting SDMA script
235 235 * @peripheral_type Peripheral type. Needed for setting SDMA script
236 236 * @event_id0 aka dma request line
... ... @@ -799,7 +799,7 @@
799 799  
800 800 cookie = sdma_assign_cookie(sdmac);
801 801  
802   - sdma_enable_channel(sdma, tx->chan->chan_id);
  802 + sdma_enable_channel(sdma, sdmac->channel);
803 803  
804 804 spin_unlock_irq(&sdmac->lock);
805 805  
... ... @@ -812,10 +812,6 @@
812 812 struct imx_dma_data *data = chan->private;
813 813 int prio, ret;
814 814  
815   - /* No need to execute this for internal channel 0 */
816   - if (chan->chan_id == 0)
817   - return 0;
818   -
819 815 if (!data)
820 816 return -EINVAL;
821 817  
... ... @@ -880,7 +876,7 @@
880 876 struct sdma_channel *sdmac = to_sdma_chan(chan);
881 877 struct sdma_engine *sdma = sdmac->sdma;
882 878 int ret, i, count;
883   - int channel = chan->chan_id;
  879 + int channel = sdmac->channel;
884 880 struct scatterlist *sg;
885 881  
886 882 if (sdmac->status == DMA_IN_PROGRESS)
... ... @@ -978,7 +974,7 @@
978 974 struct sdma_channel *sdmac = to_sdma_chan(chan);
979 975 struct sdma_engine *sdma = sdmac->sdma;
980 976 int num_periods = buf_len / period_len;
981   - int channel = chan->chan_id;
  977 + int channel = sdmac->channel;
982 978 int ret, i = 0, buf = 0;
983 979  
984 980 dev_dbg(sdma->dev, "%s channel: %d\n", __func__, channel);
... ... @@ -1252,7 +1248,6 @@
1252 1248 struct resource *iores;
1253 1249 struct sdma_platform_data *pdata = pdev->dev.platform_data;
1254 1250 int i;
1255   - dma_cap_mask_t mask;
1256 1251 struct sdma_engine *sdma;
1257 1252  
1258 1253 sdma = kzalloc(sizeof(*sdma), GFP_KERNEL);
... ... @@ -1309,8 +1304,14 @@
1309 1304 sdmac->chan.device = &sdma->dma_device;
1310 1305 sdmac->channel = i;
1311 1306  
1312   - /* Add the channel to the DMAC list */
1313   - list_add_tail(&sdmac->chan.device_node, &sdma->dma_device.channels);
  1307 + /*
  1308 + * Add the channel to the DMAC list. Do not add channel 0 though
  1309 + * because we need it internally in the SDMA driver. This also means
  1310 + * that channel 0 in dmaengine counting matches sdma channel 1.
  1311 + */
  1312 + if (i)
  1313 + list_add_tail(&sdmac->chan.device_node,
  1314 + &sdma->dma_device.channels);
1314 1315 }
1315 1316  
1316 1317 ret = sdma_init(sdma);
... ... @@ -1339,13 +1340,6 @@
1339 1340 dev_err(&pdev->dev, "unable to register\n");
1340 1341 goto err_init;
1341 1342 }
1342   -
1343   - /* request channel 0. This is an internal control channel
1344   - * to the SDMA engine and not available to clients.
1345   - */
1346   - dma_cap_zero(mask);
1347   - dma_cap_set(DMA_SLAVE, mask);
1348   - dma_request_channel(mask, NULL, NULL);
1349 1343  
1350 1344 dev_info(sdma->dev, "initialized\n");
1351 1345