Hi,
Vinod: as I promised: https://lkml.org/lkml/2015/5/8/80
With this series it is possible to put omap-dma or edma to even late_initcall
and the drivers will figure out the load order fine(ish).
We need to add dma_request_slave_channel_compat_reason() which is the equivalent
of dma_request_slave_channel_compat() but returning with error codes in case of
failure instead of NULL pointer.
The rest of the series just converts the OMAP/daVinci drivers to use this new
function to get the channel(s) and to handle the deferred probing.
I did not moved the omap-dma, edma or ti-dma-crossbar from arch_initcall. If I
do so UART will only comes up after the DMA driver is loaded since we are using,
or going to use 8250 with DAM support. This delays the kernel messages. Other
issue is the MMC/SD cards. On board with eMMC and SD card slot the mmcblk0/1
might get swapped due to different probe order for the MMC/SD drivers. For
example in omap5-uevm:
1. omap-dma in arch_initcall the SD card is mmcblk1 (4809c000.mmc) and eMMC is
mmcblk0 (480b4000.mmc)
2. omap-dma in late_initcall the SD card is mmcblk0 (4809c000.mmc) and eMMC is
mmcblk1 (480b4000.mmc)
Because in case 1 the 4809c000.mmc got deferred by missing regulator so
480b4000.mmc got registered first. In case 2 both deferring because of DMA and
at the end 4809c000.mmc get registered first. So far I have not found a way to
bind mmcblk0/1 to a specific node...
Regards,
Peter
---
Peter Ujfalusi (13):
dmaengine: of_dma: Correct return code for
of_dma_request_slave_channel in case !CONFIG_OF
dmaengine: Introduce dma_request_slave_channel_compat_reason()
serial: 8250_dma: Support for deferred probing when requesting DMA
channels
mmc: omap_hsmmc: No need to check DMA channel validity at module
remove
mmc: omap_hsmmc: Support for deferred probing when requesting DMA
channels
mmc: omap: Support for deferred probing when requesting DMA channels
mmc: davinci_mmc: Support for deferred probing when requesting DMA
channels
crypto: omap-aes - Support for deferred probing when requesting DMA
channels
crypto: omap-des - Support for deferred probing when requesting DMA
channels
crypto: omap-sham - Support for deferred probing when requesting DMA
channel
spi: omap2-mcspi: Support for deferred probing when requesting DMA
channels
[media] omap3isp: Support for deferred probing when requesting DMA
channel
ASoC: omap-pcm: Switch to use
dma_request_slave_channel_compat_reason()
drivers/crypto/omap-aes.c | 38 ++++++++++++++++---------------
drivers/crypto/omap-des.c | 38 ++++++++++++++++---------------
drivers/crypto/omap-sham.c | 15 ++++++++----
drivers/media/platform/omap3isp/isphist.c | 12 +++++++---
drivers/mmc/host/davinci_mmc.c | 26 ++++++++++++---------
drivers/mmc/host/omap.c | 20 ++++++++++++----
drivers/mmc/host/omap_hsmmc.c | 28 ++++++++++-------------
drivers/spi/spi-omap2-mcspi.c | 36 +++++++++++++++++------------
drivers/tty/serial/8250/8250_dma.c | 18 +++++++--------
include/linux/dmaengine.h | 22 ++++++++++++++++++
include/linux/of_dma.h | 2 +-
sound/soc/omap/omap-pcm.c | 16 ++++++++-----
12 files changed, 164 insertions(+), 107 deletions(-)
--
2.3.5
Switch to use ma_request_slave_channel_compat_reason() to request the DMA
channels. Only fall back to pio mode if the error code returned is not
-EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Ulf Hansson <[email protected]>
CC: Jarkko Nikula <[email protected]>
---
drivers/mmc/host/omap.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 68dd6c79c378..29238d0fbc24 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1390,20 +1390,32 @@ static int mmc_omap_probe(struct platform_device *pdev)
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
if (res)
sig = res->start;
- host->dma_tx = dma_request_slave_channel_compat(mask,
+ host->dma_tx = dma_request_slave_channel_compat_reason(mask,
omap_dma_filter_fn, &sig, &pdev->dev, "tx");
- if (!host->dma_tx)
+ if (IS_ERR(host->dma_tx)) {
+ ret = PTR_ERR(host->dma_tx);
+ if (ret == -EPROBE_DEFER)
+ goto err_free_dma;
+
+ host->dma_tx = NULL;
dev_warn(host->dev, "unable to obtain TX DMA engine channel %u\n",
sig);
+ }
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
if (res)
sig = res->start;
- host->dma_rx = dma_request_slave_channel_compat(mask,
+ host->dma_rx = dma_request_slave_channel_compat_reason(mask,
omap_dma_filter_fn, &sig, &pdev->dev, "rx");
- if (!host->dma_rx)
+ if (IS_ERR(host->dma_rx)) {
+ ret = PTR_ERR(host->dma_rx);
+ if (ret == -EPROBE_DEFER)
+ goto err_free_dma;
+
+ host->dma_rx = NULL;
dev_warn(host->dev, "unable to obtain RX DMA engine channel %u\n",
sig);
+ }
ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host);
if (ret)
--
2.3.5
of_dma_request_slave_channel should return either pointer for valid
dma_chan or ERR_PTR() error code, NULL is not expected to be returned.
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Grant Likely <[email protected]>
CC: Rob Herring <[email protected]>
---
include/linux/of_dma.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
index 98ba7525929e..0fd80be152c4 100644
--- a/include/linux/of_dma.h
+++ b/include/linux/of_dma.h
@@ -80,7 +80,7 @@ static inline int of_dma_router_register(struct device_node *np,
static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
const char *name)
{
- return NULL;
+ return ERR_PTR(-ENODEV);
}
static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
--
2.3.5
Switch to use ma_request_slave_channel_compat_reason() to request the DMA
channel. Only fall back to polling mode if the error code returned is not
-EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Herbert Xu <[email protected]>
CC: David S. Miller <[email protected]>
CC: Lokesh Vutla <[email protected]>
---
drivers/crypto/omap-sham.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index b2024c95a3cf..66bae8288741 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -1946,9 +1946,14 @@ static int omap_sham_probe(struct platform_device *pdev)
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
- dd->dma_lch = dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
- &dd->dma, dev, "rx");
- if (!dd->dma_lch) {
+ dd->dma_lch = dma_request_slave_channel_compat_reason(mask,
+ omap_dma_filter_fn,
+ &dd->dma, dev, "rx");
+ if (IS_ERR(dd->dma_lch)) {
+ err = PTR_ERR(dd->dma_lch);
+ if (err == -EPROBE_DEFER)
+ goto data_err;
+
dd->polling_mode = 1;
dev_dbg(dev, "using polling mode instead of dma\n");
}
@@ -1995,7 +2000,7 @@ err_algs:
&dd->pdata->algs_info[i].algs_list[j]);
err_pm:
pm_runtime_disable(dev);
- if (dd->dma_lch)
+ if (!dd->polling_mode)
dma_release_channel(dd->dma_lch);
data_err:
dev_err(dev, "initialization failed.\n");
@@ -2021,7 +2026,7 @@ static int omap_sham_remove(struct platform_device *pdev)
tasklet_kill(&dd->done_task);
pm_runtime_disable(&pdev->dev);
- if (dd->dma_lch)
+ if (!dd->polling_mode)
dma_release_channel(dd->dma_lch);
return 0;
--
2.3.5
Switch to use ma_request_slave_channel_compat_reason() to request the DMA
channels. Only fall back to pio mode if the error code returned is not
-EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Mark Brown <[email protected]>
---
drivers/spi/spi-omap2-mcspi.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index a7d85c5ab2fa..e6ff937688ff 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -948,6 +948,7 @@ static int omap2_mcspi_request_dma(struct spi_device *spi)
struct omap2_mcspi_dma *mcspi_dma;
dma_cap_mask_t mask;
unsigned sig;
+ int ret = 0;
mcspi = spi_master_get_devdata(master);
mcspi_dma = mcspi->dma_channels + spi->chip_select;
@@ -959,30 +960,35 @@ static int omap2_mcspi_request_dma(struct spi_device *spi)
dma_cap_set(DMA_SLAVE, mask);
sig = mcspi_dma->dma_rx_sync_dev;
- mcspi_dma->dma_rx =
- dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
- &sig, &master->dev,
- mcspi_dma->dma_rx_ch_name);
- if (!mcspi_dma->dma_rx)
+ mcspi_dma->dma_rx = dma_request_slave_channel_compat_reason(mask,
+ omap_dma_filter_fn, &sig, &master->dev,
+ mcspi_dma->dma_rx_ch_name);
+ if (IS_ERR(mcspi_dma->dma_rx)) {
+ ret = PTR_ERR(mcspi_dma->dma_rx);
+ mcspi_dma->dma_rx = NULL;
+ if (ret != -EPROBE_DEFER)
+ ret = -EAGAIN;
goto no_dma;
+ }
sig = mcspi_dma->dma_tx_sync_dev;
- mcspi_dma->dma_tx =
- dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
- &sig, &master->dev,
- mcspi_dma->dma_tx_ch_name);
+ mcspi_dma->dma_tx = dma_request_slave_channel_compat_reason(mask,
+ omap_dma_filter_fn, &sig, &master->dev,
+ mcspi_dma->dma_tx_ch_name);
- if (!mcspi_dma->dma_tx) {
+ if (IS_ERR(mcspi_dma->dma_tx)) {
+ ret = PTR_ERR(mcspi_dma->dma_tx);
+ mcspi_dma->dma_tx = NULL;
dma_release_channel(mcspi_dma->dma_rx);
mcspi_dma->dma_rx = NULL;
- goto no_dma;
+ if (ret != -EPROBE_DEFER)
+ ret = -EAGAIN;
}
- return 0;
-
no_dma:
- dev_warn(&spi->dev, "not using DMA for McSPI\n");
- return -EAGAIN;
+ if (ret && ret != -EPROBE_DEFER)
+ dev_warn(&spi->dev, "not using DMA for McSPI\n");
+ return ret;
}
static int omap2_mcspi_setup(struct spi_device *spi)
--
2.3.5
dma_request_slave_channel_compat() 'eats' up the returned error codes which
prevents drivers using the compat call to be able to do deferred probing.
The new wrapper is identical in functionality but it will return with error
code in case of failure and will pass the -EPROBE_DEFER to the caller in
case dma_request_slave_channel_reason() returned with it.
Signed-off-by: Peter Ujfalusi <[email protected]>
---
include/linux/dmaengine.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index abf63ceabef9..6c777394835c 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1120,4 +1120,26 @@ static inline struct dma_chan
return __dma_request_channel(mask, fn, fn_param);
}
+
+#define dma_request_slave_channel_compat_reason(mask, x, y, dev, name) \
+ __dma_request_slave_channel_compat_reason(&(mask), x, y, dev, name)
+
+static inline struct dma_chan
+*__dma_request_slave_channel_compat_reason(const dma_cap_mask_t *mask,
+ dma_filter_fn fn, void *fn_param,
+ struct device *dev, char *name)
+{
+ struct dma_chan *chan;
+
+ chan = dma_request_slave_channel_reason(dev, name);
+ /* Try via legacy API if not requesting for deferred probing */
+ if (IS_ERR(chan) && PTR_ERR(chan) != -EPROBE_DEFER)
+ chan = __dma_request_channel(mask, fn, fn_param);
+
+ if (!chan)
+ chan = ERR_PTR(-ENODEV);
+
+ return chan;
+}
+
#endif /* DMAENGINE_H */
--
2.3.5
Switch to use ma_request_slave_channel_compat_reason() to request the DMA
channels. Only fall back to pio mode if the error code returned is not
-EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Herbert Xu <[email protected]>
CC: David S. Miller <[email protected]>
CC: Lokesh Vutla <[email protected]>
---
drivers/crypto/omap-aes.c | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index 9a28b7e07c71..699a14509adb 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -356,7 +356,7 @@ static void omap_aes_dma_out_callback(void *data)
static int omap_aes_dma_init(struct omap_aes_dev *dd)
{
- int err = -ENOMEM;
+ int err;
dma_cap_mask_t mask;
dd->dma_lch_out = NULL;
@@ -365,21 +365,20 @@ static int omap_aes_dma_init(struct omap_aes_dev *dd)
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
- dd->dma_lch_in = dma_request_slave_channel_compat(mask,
- omap_dma_filter_fn,
- &dd->dma_in,
- dd->dev, "rx");
- if (!dd->dma_lch_in) {
+ dd->dma_lch_in = dma_request_slave_channel_compat_reason(mask,
+ omap_dma_filter_fn, &dd->dma_in,
+ dd->dev, "rx");
+ if (IS_ERR(dd->dma_lch_in)) {
dev_err(dd->dev, "Unable to request in DMA channel\n");
- goto err_dma_in;
+ return PTR_ERR(dd->dma_lch_in);
}
- dd->dma_lch_out = dma_request_slave_channel_compat(mask,
- omap_dma_filter_fn,
- &dd->dma_out,
- dd->dev, "tx");
- if (!dd->dma_lch_out) {
+ dd->dma_lch_out = dma_request_slave_channel_compat_reason(mask,
+ omap_dma_filter_fn, &dd->dma_out,
+ dd->dev, "tx");
+ if (IS_ERR(dd->dma_lch_out)) {
dev_err(dd->dev, "Unable to request out DMA channel\n");
+ err = PTR_ERR(dd->dma_lch_out);
goto err_dma_out;
}
@@ -387,14 +386,15 @@ static int omap_aes_dma_init(struct omap_aes_dev *dd)
err_dma_out:
dma_release_channel(dd->dma_lch_in);
-err_dma_in:
- if (err)
- pr_err("error: %d\n", err);
+
return err;
}
static void omap_aes_dma_cleanup(struct omap_aes_dev *dd)
{
+ if (dd->pio_only)
+ return;
+
dma_release_channel(dd->dma_lch_out);
dma_release_channel(dd->dma_lch_in);
}
@@ -1218,7 +1218,9 @@ static int omap_aes_probe(struct platform_device *pdev)
tasklet_init(&dd->queue_task, omap_aes_queue_task, (unsigned long)dd);
err = omap_aes_dma_init(dd);
- if (err && AES_REG_IRQ_STATUS(dd) && AES_REG_IRQ_ENABLE(dd)) {
+ if (err == -EPROBE_DEFER) {
+ goto err_irq;
+ } else if (err && AES_REG_IRQ_STATUS(dd) && AES_REG_IRQ_ENABLE(dd)) {
dd->pio_only = 1;
irq = platform_get_irq(pdev, 0);
@@ -1262,8 +1264,8 @@ err_algs:
for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
crypto_unregister_alg(
&dd->pdata->algs_info[i].algs_list[j]);
- if (!dd->pio_only)
- omap_aes_dma_cleanup(dd);
+
+ omap_aes_dma_cleanup(dd);
err_irq:
tasklet_kill(&dd->done_task);
tasklet_kill(&dd->queue_task);
--
2.3.5
The driver will not probe without valid DMA channels so no need to check
if they are valid when the module is removed.
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Ulf Hansson <[email protected]>
---
drivers/mmc/host/omap_hsmmc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 2cd828f42151..57bb85930f81 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -2190,10 +2190,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
if (host->use_reg)
omap_hsmmc_reg_put(host);
- if (host->tx_chan)
- dma_release_channel(host->tx_chan);
- if (host->rx_chan)
- dma_release_channel(host->rx_chan);
+ dma_release_channel(host->tx_chan);
+ dma_release_channel(host->rx_chan);
pm_runtime_put_sync(host->dev);
pm_runtime_disable(host->dev);
--
2.3.5
Switch to use ma_request_slave_channel_compat_reason() to request the DMA
channels. In case of error, return the error code we received including
-EPROBE_DEFER
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Ulf Hansson <[email protected]>
---
drivers/mmc/host/omap_hsmmc.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 57bb85930f81..d252478391ee 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -2088,23 +2088,21 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
- host->rx_chan =
- dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
- &rx_req, &pdev->dev, "rx");
+ host->rx_chan = dma_request_slave_channel_compat_reason(mask,
+ omap_dma_filter_fn, &rx_req, &pdev->dev, "rx");
- if (!host->rx_chan) {
+ if (IS_ERR(host->rx_chan)) {
dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req);
- ret = -ENXIO;
+ ret = PTR_ERR(host->rx_chan);
goto err_irq;
}
- host->tx_chan =
- dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
- &tx_req, &pdev->dev, "tx");
+ host->tx_chan = dma_request_slave_channel_compat_reason(mask,
+ omap_dma_filter_fn, &tx_req, &pdev->dev, "tx");
- if (!host->tx_chan) {
+ if (IS_ERR(host->tx_chan)) {
dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req);
- ret = -ENXIO;
+ ret = PTR_ERR(host->tx_chan);
goto err_irq;
}
@@ -2166,9 +2164,9 @@ err_slot_name:
if (host->use_reg)
omap_hsmmc_reg_put(host);
err_irq:
- if (host->tx_chan)
+ if (!IS_ERR_OR_NULL(host->tx_chan))
dma_release_channel(host->tx_chan);
- if (host->rx_chan)
+ if (!IS_ERR_OR_NULL(host->rx_chan))
dma_release_channel(host->rx_chan);
pm_runtime_put_sync(host->dev);
pm_runtime_disable(host->dev);
--
2.3.5
Switch to use ma_request_slave_channel_compat_reason() to request the DMA
channel. Only fall back to pio mode if the error code returned is not
-EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Laurent Pinchart <[email protected]>
CC: Mauro Carvalho Chehab <[email protected]>
---
drivers/media/platform/omap3isp/isphist.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/omap3isp/isphist.c b/drivers/media/platform/omap3isp/isphist.c
index 7138b043a4aa..e690ca13af0e 100644
--- a/drivers/media/platform/omap3isp/isphist.c
+++ b/drivers/media/platform/omap3isp/isphist.c
@@ -499,14 +499,20 @@ int omap3isp_hist_init(struct isp_device *isp)
if (res)
sig = res->start;
- hist->dma_ch = dma_request_slave_channel_compat(mask,
+ hist->dma_ch = dma_request_slave_channel_compat_reason(mask,
omap_dma_filter_fn, &sig, isp->dev, "hist");
- if (!hist->dma_ch)
+ if (IS_ERR(hist->dma_ch)) {
+ ret = PTR_ERR(hist->dma_ch);
+ if (ret == -EPROBE_DEFER)
+ return ret;
+
+ hist->dma_ch = NULL;
dev_warn(isp->dev,
"hist: DMA channel request failed, using PIO\n");
- else
+ } else {
dev_dbg(isp->dev, "hist: using DMA channel %s\n",
dma_chan_name(hist->dma_ch));
+ }
}
hist->ops = &hist_ops;
--
2.3.5
Switch to use ma_request_slave_channel_compat_reason() to request the DMA
channels. Only fall back to pio mode if the error code returned is not
-EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
Signed-off-by: Peter Ujfalusi <[email protected]>
CC: Ulf Hansson <[email protected]>
---
drivers/mmc/host/davinci_mmc.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index b2b3f8bbfd8c..df81e4e2f662 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -530,20 +530,20 @@ static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host)
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
- host->dma_tx =
- dma_request_slave_channel_compat(mask, edma_filter_fn,
- &host->txdma, mmc_dev(host->mmc), "tx");
- if (!host->dma_tx) {
+ host->dma_tx = dma_request_slave_channel_compat_reason(mask,
+ edma_filter_fn, &host->txdma,
+ mmc_dev(host->mmc), "tx");
+ if (IS_ERR(host->dma_tx)) {
dev_err(mmc_dev(host->mmc), "Can't get dma_tx channel\n");
- return -ENODEV;
+ return PTR_ERR(host->dma_tx);
}
- host->dma_rx =
- dma_request_slave_channel_compat(mask, edma_filter_fn,
- &host->rxdma, mmc_dev(host->mmc), "rx");
- if (!host->dma_rx) {
+ host->dma_rx = dma_request_slave_channel_compat_reason(mask,
+ edma_filter_fn, &host->rxdma,
+ mmc_dev(host->mmc), "rx");
+ if (IS_ERR(host->dma_rx)) {
dev_err(mmc_dev(host->mmc), "Can't get dma_rx channel\n");
- r = -ENODEV;
+ r = PTR_ERR(host->dma_rx);
goto free_master_write;
}
@@ -1307,8 +1307,12 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)
host->mmc_irq = irq;
host->sdio_irq = platform_get_irq(pdev, 1);
- if (host->use_dma && davinci_acquire_dma_channels(host) != 0)
+ if (host->use_dma) {
+ ret = davinci_acquire_dma_channels(host);
+ if (ret == -EPROBE_DEFER)
+ goto out;
host->use_dma = 0;
+ }
/* REVISIT: someday, support IRQ-driven card detection. */
mmc->caps |= MMC_CAP_NEEDS_POLL;
--
2.3.5
On Tue, May 26, 2015 at 04:26:06PM +0300, Peter Ujfalusi wrote:
> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
> channels. Only fall back to pio mode if the error code returned is not
> -EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
I've got two patches from a patch series here with no cover letter...
I'm guessing there's no interdependencies or anything? Please always
ensure that when sending a patch series everyone getting the patches can
tell what the series as a whole looks like (if there's no dependencies
consider posting as individual patches rather than a series).
Mark,
On 05/26/2015 06:27 PM, Mark Brown wrote:
> On Tue, May 26, 2015 at 04:26:06PM +0300, Peter Ujfalusi wrote:
>
>> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
>> channels. Only fall back to pio mode if the error code returned is not
>> -EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
>
> I've got two patches from a patch series here with no cover letter...
> I'm guessing there's no interdependencies or anything? Please always
> ensure that when sending a patch series everyone getting the patches can
> tell what the series as a whole looks like (if there's no dependencies
> consider posting as individual patches rather than a series).
I have put the maintainers of the relevant subsystems as CC in the commit
message and sent the series to all of the mailing lists. This series was
touching 7 subsystems and I thought not spamming every maintainer with all the
mails might be better.
In v2 I will keep this in mind.
The series depends on the first two patch, which adds the
dma_request_slave_channel_compat_reason() function.
--
P?ter
On Wed, May 27, 2015 at 02:15:12PM +0300, Peter Ujfalusi wrote:
> I have put the maintainers of the relevant subsystems as CC in the commit
> message and sent the series to all of the mailing lists. This series was
> touching 7 subsystems and I thought not spamming every maintainer with all the
> mails might be better.
You need to at least include people on the cover letter, otherwise
they'll have no idea what's going on.
On Tue, May 26, 2015 at 04:26:06PM +0300, Peter Ujfalusi wrote:
> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
> channels. Only fall back to pio mode if the error code returned is not
> -EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
Acked-by: Mark Brown <[email protected]>
On 26 May 2015 at 15:25, Peter Ujfalusi <[email protected]> wrote:
> The driver will not probe without valid DMA channels so no need to check
> if they are valid when the module is removed.
>
> Signed-off-by: Peter Ujfalusi <[email protected]>
> CC: Ulf Hansson <[email protected]>
Acked-by: Ulf Hansson <[email protected]>
Kind regards
Uffe
> ---
> drivers/mmc/host/omap_hsmmc.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 2cd828f42151..57bb85930f81 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -2190,10 +2190,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
> if (host->use_reg)
> omap_hsmmc_reg_put(host);
>
> - if (host->tx_chan)
> - dma_release_channel(host->tx_chan);
> - if (host->rx_chan)
> - dma_release_channel(host->rx_chan);
> + dma_release_channel(host->tx_chan);
> + dma_release_channel(host->rx_chan);
>
> pm_runtime_put_sync(host->dev);
> pm_runtime_disable(host->dev);
> --
> 2.3.5
>
On 26 May 2015 at 15:26, Peter Ujfalusi <[email protected]> wrote:
> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
I guess it should be dma_request_slave_... huh, that was a long name. :-)
> channels. In case of error, return the error code we received including
> -EPROBE_DEFER
>
> Signed-off-by: Peter Ujfalusi <[email protected]>
> CC: Ulf Hansson <[email protected]>
With the minor change above.
Acked-by: Ulf Hansson <[email protected]>
Kind regards
Uffe
> ---
> drivers/mmc/host/omap_hsmmc.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 57bb85930f81..d252478391ee 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -2088,23 +2088,21 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
> dma_cap_zero(mask);
> dma_cap_set(DMA_SLAVE, mask);
>
> - host->rx_chan =
> - dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
> - &rx_req, &pdev->dev, "rx");
> + host->rx_chan = dma_request_slave_channel_compat_reason(mask,
> + omap_dma_filter_fn, &rx_req, &pdev->dev, "rx");
>
> - if (!host->rx_chan) {
> + if (IS_ERR(host->rx_chan)) {
> dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req);
> - ret = -ENXIO;
> + ret = PTR_ERR(host->rx_chan);
> goto err_irq;
> }
>
> - host->tx_chan =
> - dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
> - &tx_req, &pdev->dev, "tx");
> + host->tx_chan = dma_request_slave_channel_compat_reason(mask,
> + omap_dma_filter_fn, &tx_req, &pdev->dev, "tx");
>
> - if (!host->tx_chan) {
> + if (IS_ERR(host->tx_chan)) {
> dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req);
> - ret = -ENXIO;
> + ret = PTR_ERR(host->tx_chan);
> goto err_irq;
> }
>
> @@ -2166,9 +2164,9 @@ err_slot_name:
> if (host->use_reg)
> omap_hsmmc_reg_put(host);
> err_irq:
> - if (host->tx_chan)
> + if (!IS_ERR_OR_NULL(host->tx_chan))
> dma_release_channel(host->tx_chan);
> - if (host->rx_chan)
> + if (!IS_ERR_OR_NULL(host->rx_chan))
> dma_release_channel(host->rx_chan);
> pm_runtime_put_sync(host->dev);
> pm_runtime_disable(host->dev);
> --
> 2.3.5
>
On 26 May 2015 at 15:26, Peter Ujfalusi <[email protected]> wrote:
> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
> channels. Only fall back to pio mode if the error code returned is not
> -EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
>
> Signed-off-by: Peter Ujfalusi <[email protected]>
> CC: Ulf Hansson <[email protected]>
Acked-by: Ulf Hansson <[email protected]>
Kind regards
Uffe
> ---
> drivers/mmc/host/davinci_mmc.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
> index b2b3f8bbfd8c..df81e4e2f662 100644
> --- a/drivers/mmc/host/davinci_mmc.c
> +++ b/drivers/mmc/host/davinci_mmc.c
> @@ -530,20 +530,20 @@ static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host)
> dma_cap_zero(mask);
> dma_cap_set(DMA_SLAVE, mask);
>
> - host->dma_tx =
> - dma_request_slave_channel_compat(mask, edma_filter_fn,
> - &host->txdma, mmc_dev(host->mmc), "tx");
> - if (!host->dma_tx) {
> + host->dma_tx = dma_request_slave_channel_compat_reason(mask,
> + edma_filter_fn, &host->txdma,
> + mmc_dev(host->mmc), "tx");
> + if (IS_ERR(host->dma_tx)) {
> dev_err(mmc_dev(host->mmc), "Can't get dma_tx channel\n");
> - return -ENODEV;
> + return PTR_ERR(host->dma_tx);
> }
>
> - host->dma_rx =
> - dma_request_slave_channel_compat(mask, edma_filter_fn,
> - &host->rxdma, mmc_dev(host->mmc), "rx");
> - if (!host->dma_rx) {
> + host->dma_rx = dma_request_slave_channel_compat_reason(mask,
> + edma_filter_fn, &host->rxdma,
> + mmc_dev(host->mmc), "rx");
> + if (IS_ERR(host->dma_rx)) {
> dev_err(mmc_dev(host->mmc), "Can't get dma_rx channel\n");
> - r = -ENODEV;
> + r = PTR_ERR(host->dma_rx);
> goto free_master_write;
> }
>
> @@ -1307,8 +1307,12 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)
> host->mmc_irq = irq;
> host->sdio_irq = platform_get_irq(pdev, 1);
>
> - if (host->use_dma && davinci_acquire_dma_channels(host) != 0)
> + if (host->use_dma) {
> + ret = davinci_acquire_dma_channels(host);
> + if (ret == -EPROBE_DEFER)
> + goto out;
> host->use_dma = 0;
> + }
>
> /* REVISIT: someday, support IRQ-driven card detection. */
> mmc->caps |= MMC_CAP_NEEDS_POLL;
> --
> 2.3.5
>
On Tue, May 26, 2015 at 04:25:57PM +0300, Peter Ujfalusi wrote:
> dma_request_slave_channel_compat() 'eats' up the returned error codes which
> prevents drivers using the compat call to be able to do deferred probing.
>
> The new wrapper is identical in functionality but it will return with error
> code in case of failure and will pass the -EPROBE_DEFER to the caller in
> case dma_request_slave_channel_reason() returned with it.
This is okay but am worried about one more warpper, how about fixing
dma_request_slave_channel_compat()
--
~Vinod
>
> Signed-off-by: Peter Ujfalusi <[email protected]>
> ---
> include/linux/dmaengine.h | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index abf63ceabef9..6c777394835c 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -1120,4 +1120,26 @@ static inline struct dma_chan
>
> return __dma_request_channel(mask, fn, fn_param);
> }
> +
> +#define dma_request_slave_channel_compat_reason(mask, x, y, dev, name) \
> + __dma_request_slave_channel_compat_reason(&(mask), x, y, dev, name)
> +
> +static inline struct dma_chan
> +*__dma_request_slave_channel_compat_reason(const dma_cap_mask_t *mask,
> + dma_filter_fn fn, void *fn_param,
> + struct device *dev, char *name)
> +{
> + struct dma_chan *chan;
> +
> + chan = dma_request_slave_channel_reason(dev, name);
> + /* Try via legacy API if not requesting for deferred probing */
> + if (IS_ERR(chan) && PTR_ERR(chan) != -EPROBE_DEFER)
> + chan = __dma_request_channel(mask, fn, fn_param);
> +
> + if (!chan)
> + chan = ERR_PTR(-ENODEV);
> +
> + return chan;
> +}
> +
> #endif /* DMAENGINE_H */
> --
> 2.3.5
>
--
On Fri, May 29, 2015 at 11:33 AM, Vinod Koul <[email protected]> wrote:
> On Tue, May 26, 2015 at 04:25:57PM +0300, Peter Ujfalusi wrote:
>> dma_request_slave_channel_compat() 'eats' up the returned error codes which
>> prevents drivers using the compat call to be able to do deferred probing.
>>
>> The new wrapper is identical in functionality but it will return with error
>> code in case of failure and will pass the -EPROBE_DEFER to the caller in
>> case dma_request_slave_channel_reason() returned with it.
> This is okay but am worried about one more warpper, how about fixing
> dma_request_slave_channel_compat()
Then all callers of dma_request_slave_channel_compat() have to be
modified to handle ERR_PTR first.
The same is true for (the existing) dma_request_slave_channel_reason()
vs. dma_request_slave_channel().
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
On Fri, May 29, 2015 at 11:42:27AM +0200, Geert Uytterhoeven wrote:
> On Fri, May 29, 2015 at 11:33 AM, Vinod Koul <[email protected]> wrote:
> > On Tue, May 26, 2015 at 04:25:57PM +0300, Peter Ujfalusi wrote:
> >> dma_request_slave_channel_compat() 'eats' up the returned error codes which
> >> prevents drivers using the compat call to be able to do deferred probing.
> >>
> >> The new wrapper is identical in functionality but it will return with error
> >> code in case of failure and will pass the -EPROBE_DEFER to the caller in
> >> case dma_request_slave_channel_reason() returned with it.
> > This is okay but am worried about one more warpper, how about fixing
> > dma_request_slave_channel_compat()
>
> Then all callers of dma_request_slave_channel_compat() have to be
> modified to handle ERR_PTR first.
>
> The same is true for (the existing) dma_request_slave_channel_reason()
> vs. dma_request_slave_channel().
Good point, looking again, I think we should rather fix
dma_request_slave_channel_reason() as it was expected to return err code and
add new users. Anyway users of this API do expect the reason...
--
~Vinod
On 05/29/2015 01:18 PM, Vinod Koul wrote:
> On Fri, May 29, 2015 at 11:42:27AM +0200, Geert Uytterhoeven wrote:
>> On Fri, May 29, 2015 at 11:33 AM, Vinod Koul <[email protected]> wrote:
>>> On Tue, May 26, 2015 at 04:25:57PM +0300, Peter Ujfalusi wrote:
>>>> dma_request_slave_channel_compat() 'eats' up the returned error codes which
>>>> prevents drivers using the compat call to be able to do deferred probing.
>>>>
>>>> The new wrapper is identical in functionality but it will return with error
>>>> code in case of failure and will pass the -EPROBE_DEFER to the caller in
>>>> case dma_request_slave_channel_reason() returned with it.
>>> This is okay but am worried about one more warpper, how about fixing
>>> dma_request_slave_channel_compat()
>>
>> Then all callers of dma_request_slave_channel_compat() have to be
>> modified to handle ERR_PTR first.
>>
>> The same is true for (the existing) dma_request_slave_channel_reason()
>> vs. dma_request_slave_channel().
> Good point, looking again, I think we should rather fix
> dma_request_slave_channel_reason() as it was expected to return err code and
> add new users. Anyway users of this API do expect the reason...
Hrm, they are for different use.dma_request_slave_channel()/_reason() is for
drivers only working via DT or ACPI while
dma_request_slave_channel_compat()/_reason() is for drivers expected to run in
DT/ACPI or legacy mode as well.
I added the dma_request_slave_channel_compat_reason() because OMAP/daVinci
drivers are using this to request channels - they need to support DT and
legacy mode.
But it is doable to do this for both the non _compat and _compat version:
1. change all users to check IS_ERR_OR_NULL(chan)
return the PTR_ERR if not NULL, or do whatever the driver was doing in case
of chan == NULL.
2. change the non _compat and _compat versions to do the same as the _reason
variants, #define the _reason ones to the non _reason names
3. Rename the _reason use to non _reason function in drivers
4. Remove the #defines for the _reason functions
5. Change the IS_ERR_OR_NULL(chan) to IS_ERR(chan) in all drivers
The result:
Both dma_request_slave_channel() and dma_request_slave_channel_compat() will
return ERR_PTR in case of failure or in success they will return the pinter to
chan.
Is this what you were asking?
It is a bit broader than what this series was doing: taking care of
OMAP/daVinci drivers for deferred probing regarding to dmaengine ;)
--
P?ter
On Fri, May 29, 2015 at 05:32:50PM +0300, Peter Ujfalusi wrote:
> On 05/29/2015 01:18 PM, Vinod Koul wrote:
> > On Fri, May 29, 2015 at 11:42:27AM +0200, Geert Uytterhoeven wrote:
> >> On Fri, May 29, 2015 at 11:33 AM, Vinod Koul <[email protected]> wrote:
> >>> On Tue, May 26, 2015 at 04:25:57PM +0300, Peter Ujfalusi wrote:
> >>>> dma_request_slave_channel_compat() 'eats' up the returned error codes which
> >>>> prevents drivers using the compat call to be able to do deferred probing.
> >>>>
> >>>> The new wrapper is identical in functionality but it will return with error
> >>>> code in case of failure and will pass the -EPROBE_DEFER to the caller in
> >>>> case dma_request_slave_channel_reason() returned with it.
> >>> This is okay but am worried about one more warpper, how about fixing
> >>> dma_request_slave_channel_compat()
> >>
> >> Then all callers of dma_request_slave_channel_compat() have to be
> >> modified to handle ERR_PTR first.
> >>
> >> The same is true for (the existing) dma_request_slave_channel_reason()
> >> vs. dma_request_slave_channel().
> > Good point, looking again, I think we should rather fix
> > dma_request_slave_channel_reason() as it was expected to return err code and
> > add new users. Anyway users of this API do expect the reason...
>
> Hrm, they are for different use.dma_request_slave_channel()/_reason() is for
> drivers only working via DT or ACPI while
> dma_request_slave_channel_compat()/_reason() is for drivers expected to run in
> DT/ACPI or legacy mode as well.
>
> I added the dma_request_slave_channel_compat_reason() because OMAP/daVinci
> drivers are using this to request channels - they need to support DT and
> legacy mode.
I think we should hide these things behind the API and do this behind the
hood for ACPI/DT systems.
Also it makes sense to use right API and mark rest as depricated
>
> But it is doable to do this for both the non _compat and _compat version:
> 1. change all users to check IS_ERR_OR_NULL(chan)
> return the PTR_ERR if not NULL, or do whatever the driver was doing in case
> of chan == NULL.
> 2. change the non _compat and _compat versions to do the same as the _reason
> variants, #define the _reason ones to the non _reason names
> 3. Rename the _reason use to non _reason function in drivers
> 4. Remove the #defines for the _reason functions
> 5. Change the IS_ERR_OR_NULL(chan) to IS_ERR(chan) in all drivers
> The result:
> Both dma_request_slave_channel() and dma_request_slave_channel_compat() will
> return ERR_PTR in case of failure or in success they will return the pinter to
> chan.
>
> Is this what you were asking?
> It is a bit broader than what this series was doing: taking care of
> OMAP/daVinci drivers for deferred probing regarding to dmaengine ;)
Yes but it would make sense right? I know it is a larger work but then we
wouldn't want another dma_request_slave_xxx API, at some point we have stop
it exapnding, perhpas now :)
Yes I am all ears to stage this work and not do transition gardually..
--
~Vinod
Vinod,
On 06/02/2015 03:55 PM, Vinod Koul wrote:
> On Fri, May 29, 2015 at 05:32:50PM +0300, Peter Ujfalusi wrote:
>> On 05/29/2015 01:18 PM, Vinod Koul wrote:
>>> On Fri, May 29, 2015 at 11:42:27AM +0200, Geert Uytterhoeven wrote:
>>>> On Fri, May 29, 2015 at 11:33 AM, Vinod Koul <[email protected]> wrote:
>>>>> On Tue, May 26, 2015 at 04:25:57PM +0300, Peter Ujfalusi wrote:
>>>>>> dma_request_slave_channel_compat() 'eats' up the returned error codes which
>>>>>> prevents drivers using the compat call to be able to do deferred probing.
>>>>>>
>>>>>> The new wrapper is identical in functionality but it will return with error
>>>>>> code in case of failure and will pass the -EPROBE_DEFER to the caller in
>>>>>> case dma_request_slave_channel_reason() returned with it.
>>>>> This is okay but am worried about one more warpper, how about fixing
>>>>> dma_request_slave_channel_compat()
>>>>
>>>> Then all callers of dma_request_slave_channel_compat() have to be
>>>> modified to handle ERR_PTR first.
>>>>
>>>> The same is true for (the existing) dma_request_slave_channel_reason()
>>>> vs. dma_request_slave_channel().
>>> Good point, looking again, I think we should rather fix
>>> dma_request_slave_channel_reason() as it was expected to return err code and
>>> add new users. Anyway users of this API do expect the reason...
>>
>> Hrm, they are for different use.dma_request_slave_channel()/_reason() is for
>> drivers only working via DT or ACPI while
>> dma_request_slave_channel_compat()/_reason() is for drivers expected to run in
>> DT/ACPI or legacy mode as well.
>>
>> I added the dma_request_slave_channel_compat_reason() because OMAP/daVinci
>> drivers are using this to request channels - they need to support DT and
>> legacy mode.
> I think we should hide these things behind the API and do this behind the
> hood for ACPI/DT systems.
>
> Also it makes sense to use right API and mark rest as depricated
So to convert the dma_request_slave_channel_compat() and not to create _reason
variant?
Or to have single API to request channel? The problem with that is that we
need different parameters for legacy and DT for example.
>>
>> But it is doable to do this for both the non _compat and _compat version:
>> 1. change all users to check IS_ERR_OR_NULL(chan)
>> return the PTR_ERR if not NULL, or do whatever the driver was doing in case
>> of chan == NULL.
>> 2. change the non _compat and _compat versions to do the same as the _reason
>> variants, #define the _reason ones to the non _reason names
>> 3. Rename the _reason use to non _reason function in drivers
>> 4. Remove the #defines for the _reason functions
>> 5. Change the IS_ERR_OR_NULL(chan) to IS_ERR(chan) in all drivers
>> The result:
>> Both dma_request_slave_channel() and dma_request_slave_channel_compat() will
>> return ERR_PTR in case of failure or in success they will return the pinter to
>> chan.
>>
>> Is this what you were asking?
>> It is a bit broader than what this series was doing: taking care of
>> OMAP/daVinci drivers for deferred probing regarding to dmaengine ;)
> Yes but it would make sense right? I know it is a larger work but then we
> wouldn't want another dma_request_slave_xxx API, at some point we have stop
> it exapnding, perhpas now :)
Yes, it make sense to get rid if the _reason() things and have the
dma_request_slave_channel() and dma_request_slave_channel_compat() return with
error code
One thing we need to do for this is to change the error codes coming back from
the _dt() and _acpi() calls when we boot in legacy mode. Right now the only
error code which comes back is -ENODEV and -EPROBE_DEFER. We need to
differentiate between 'real' errors and from the fact that we did not booted
with DT or the ACPI is not available.
IMHO if we boot with DT and the channel request fails with other than
-EPROBE_DEFER we should not go and try to get the channel via legacy API.
> Yes I am all ears to stage this work and not do transition gardually..
>
--
P?ter
On Thu, Jun 04, 2015 at 06:58:06PM +0300, Peter Ujfalusi wrote:
> Vinod,
>
> On 06/02/2015 03:55 PM, Vinod Koul wrote:
> > On Fri, May 29, 2015 at 05:32:50PM +0300, Peter Ujfalusi wrote:
> >> On 05/29/2015 01:18 PM, Vinod Koul wrote:
> >>> On Fri, May 29, 2015 at 11:42:27AM +0200, Geert Uytterhoeven wrote:
> >>>> On Fri, May 29, 2015 at 11:33 AM, Vinod Koul <[email protected]> wrote:
> >>>>> On Tue, May 26, 2015 at 04:25:57PM +0300, Peter Ujfalusi wrote:
> >>>>>> dma_request_slave_channel_compat() 'eats' up the returned error codes which
> >>>>>> prevents drivers using the compat call to be able to do deferred probing.
> >>>>>>
> >>>>>> The new wrapper is identical in functionality but it will return with error
> >>>>>> code in case of failure and will pass the -EPROBE_DEFER to the caller in
> >>>>>> case dma_request_slave_channel_reason() returned with it.
> >>>>> This is okay but am worried about one more warpper, how about fixing
> >>>>> dma_request_slave_channel_compat()
> >>>>
> >>>> Then all callers of dma_request_slave_channel_compat() have to be
> >>>> modified to handle ERR_PTR first.
> >>>>
> >>>> The same is true for (the existing) dma_request_slave_channel_reason()
> >>>> vs. dma_request_slave_channel().
> >>> Good point, looking again, I think we should rather fix
> >>> dma_request_slave_channel_reason() as it was expected to return err code and
> >>> add new users. Anyway users of this API do expect the reason...
> >>
> >> Hrm, they are for different use.dma_request_slave_channel()/_reason() is for
> >> drivers only working via DT or ACPI while
> >> dma_request_slave_channel_compat()/_reason() is for drivers expected to run in
> >> DT/ACPI or legacy mode as well.
> >>
> >> I added the dma_request_slave_channel_compat_reason() because OMAP/daVinci
> >> drivers are using this to request channels - they need to support DT and
> >> legacy mode.
> > I think we should hide these things behind the API and do this behind the
> > hood for ACPI/DT systems.
> >
> > Also it makes sense to use right API and mark rest as depricated
>
> So to convert the dma_request_slave_channel_compat() and not to create _reason
> variant?
>
> Or to have single API to request channel? The problem with that is that we
> need different parameters for legacy and DT for example.
Sorry this slipped thru
Thinking about it again, I think we should coverge to two APIs and mark the
legacy depracuated and look to convert folks and phase that out
--
~Vinod
On 06/12/2015 03:58 PM, Vinod Koul wrote:
> Sorry this slipped thru
I was away for a week anyways ;)
> Thinking about it again, I think we should coverge to two APIs and mark the
> legacy depracuated and look to convert folks and phase that out
Currently, w/o this series we have these APIs:
/* to be used with DT/ACPI */
dma_request_slave_channel(dev, name) /* NULL on failure */
dma_request_slave_channel_reason(dev, name) /* error code on failure */
/* Legacy mode only - no DT/ACPI lookup */
dma_request_channel(mask, fn, fn_param) /* NULL on failure */
/* to be used with DT/ACPI or legacy boot */
dma_request_slave_channel_compat(mask, fn, fn_param, dev, name) /* NULL on
failure */
To request _any_ channel to be used for memcpy one has to use
dma_request_channel(mask, NULL, NULL);
If I did not missed something.
As we need different types of parameters for DT/ACPI and legacy (non DT/ACPI
lookup) and the good API names are already taken, we might need to settle:
/* to be used with DT/ACPI */
dma_request_slave_channel(dev, name) /* error code on failure */
- Convert users to check IS_ERR_OR_NULL() instead against NULL
- Mark dma_request_slave_channel_reason() deprecated and convert the current users
/* to be used with DT/ACPI or legacy boot */
dma_request_slave_channel_compat(mask, fn, fn_param, dev, name) /* error code
on failure */
- Convert users to check IS_ERR_OR_NULL() instead against NULL
- Do not try legacy mode if either OF or ACPI failed because of real error
/* Legacy mode only - no DT/ACPI lookup */
dma_request_channel_legacy(mask, fn, fn_param) /* error code on failure */
- convert users of dma_request_channel()
- mark dma_request_channel() deprecated
/* to be used to get a channel for memcpy for example */
dma_request_any_channel(mask) /* error code on failure */
- Convert current dma_request_channel(mask, NULL, NULL) users
I know, any of the other function could be prepared to handle this when
parameters are missing, but it is a bit cleaner to have separate API for this.
It would be nice to find another name for the
dma_request_slave_channel_compat() so with the new name we could have chance
to rearrange the parameters: (dev, name, mask, fn, fn_param)
We would end up with the following APIs, all returning with error code on failure:
dma_request_slave_channel(dev, name);
dma_request_channel_legacy(mask, fn, fn_param);
dma_request_slave_channel_compat(mask, fn, fn_param, dev, name);
dma_request_any_channel(mask);
What do you think?
--
P?ter
On Mon, Jun 22, 2015 at 02:31:00PM +0300, Peter Ujfalusi wrote:
> On 06/12/2015 03:58 PM, Vinod Koul wrote:
> > Sorry this slipped thru
>
> I was away for a week anyways ;)
>
> > Thinking about it again, I think we should coverge to two APIs and mark the
> > legacy depracuated and look to convert folks and phase that out
>
> Currently, w/o this series we have these APIs:
> /* to be used with DT/ACPI */
> dma_request_slave_channel(dev, name) /* NULL on failure */
> dma_request_slave_channel_reason(dev, name) /* error code on failure */
>
> /* Legacy mode only - no DT/ACPI lookup */
> dma_request_channel(mask, fn, fn_param) /* NULL on failure */
>
> /* to be used with DT/ACPI or legacy boot */
> dma_request_slave_channel_compat(mask, fn, fn_param, dev, name) /* NULL on
> failure */
>
> To request _any_ channel to be used for memcpy one has to use
> dma_request_channel(mask, NULL, NULL);
>
> If I did not missed something.
I dont think so :)
> As we need different types of parameters for DT/ACPI and legacy (non DT/ACPI
> lookup) and the good API names are already taken, we might need to settle:
>
> /* to be used with DT/ACPI */
> dma_request_slave_channel(dev, name) /* error code on failure */
> - Convert users to check IS_ERR_OR_NULL() instead against NULL
> - Mark dma_request_slave_channel_reason() deprecated and convert the current users
>
> /* to be used with DT/ACPI or legacy boot */
> dma_request_slave_channel_compat(mask, fn, fn_param, dev, name) /* error code
> on failure */
> - Convert users to check IS_ERR_OR_NULL() instead against NULL
> - Do not try legacy mode if either OF or ACPI failed because of real error
Should we keep the filter fn and an API for this, I am still not too sure
about that part. Anyway users should be on DT/ACPI. if someone wants filter
then let them use dma_request_channel()
>
> /* Legacy mode only - no DT/ACPI lookup */
> dma_request_channel_legacy(mask, fn, fn_param) /* error code on failure */
> - convert users of dma_request_channel()
> - mark dma_request_channel() deprecated
Why should we create a new API, how about marking dma_request_channel() as
legacy and generic memcpy API and let other users be migrated?
>
> /* to be used to get a channel for memcpy for example */
> dma_request_any_channel(mask) /* error code on failure */
> - Convert current dma_request_channel(mask, NULL, NULL) users
> I know, any of the other function could be prepared to handle this when
> parameters are missing, but it is a bit cleaner to have separate API for this.
Though it has merits but adds another API. We cna have internal
_dma_request_xxx API where parameters are missing and clean but to users
single API might be a better idea
>
> It would be nice to find another name for the
> dma_request_slave_channel_compat() so with the new name we could have chance
> to rearrange the parameters: (dev, name, mask, fn, fn_param)
>
> We would end up with the following APIs, all returning with error code on failure:
> dma_request_slave_channel(dev, name);
> dma_request_channel_legacy(mask, fn, fn_param);
> dma_request_slave_channel_compat(mask, fn, fn_param, dev, name);
> dma_request_any_channel(mask);
This is good idea but still we end up with 4 APIs. Why not just converge to
two API, one legacy + memcpy + filer fn and one untimate API for slave?
Internally we may have 4 APIs for cleaner handling...
Thoughts... ??
--
~Vinod
On Wednesday 24 June 2015 21:54:01 Vinod Koul wrote:
> > It would be nice to find another name for the
> > dma_request_slave_channel_compat() so with the new name we could have chance
> > to rearrange the parameters: (dev, name, mask, fn, fn_param)
> >
> > We would end up with the following APIs, all returning with error code on failure:
> > dma_request_slave_channel(dev, name);
> > dma_request_channel_legacy(mask, fn, fn_param);
> > dma_request_slave_channel_compat(mask, fn, fn_param, dev, name);
> > dma_request_any_channel(mask);
> This is good idea but still we end up with 4 APIs. Why not just converge to
> two API, one legacy + memcpy + filer fn and one untimate API for slave?
>
> Internally we may have 4 APIs for cleaner handling...
>
Not sure if it's realistic, but I think it would be nice to have
a way for converting the current slave drivers that use the
mask/filter/param API to the dev/name based API. We should
be able to do this by registering a lookup table from platform
code that translates one to the other, like we do with the
clkdev lookup to find a device clock based on a local identifier.
The main downside of this is that it's a lot of work if we want
to completely remove dma_request_channel() for slave drivers,
but it could be done more gradually.
Another upside is that we could come up with a mechanism to
avoid the link-time dependency on the filter-function that
causes problems when that filter is defined in a loadable
module for the dmaengine driver.
Arnd
Hi Peter,
Thank you for the patch.
What happened to this patch series ? It looks like
dma_request_slave_channel_compat_reason() isn't in mainline, so I can't apply
this patch.
I'll mark this patch as deferred in patchwork, please resubmit it if you
resubmit the series (and by the look of it the issue you're trying to fix
still exists, so it would be nice if you could get it eventually fixed).
On Tuesday 26 May 2015 16:26:07 Peter Ujfalusi wrote:
> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
> channel. Only fall back to pio mode if the error code returned is not
> -EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
>
> Signed-off-by: Peter Ujfalusi <[email protected]>
> CC: Laurent Pinchart <[email protected]>
> CC: Mauro Carvalho Chehab <[email protected]>
> ---
> drivers/media/platform/omap3isp/isphist.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/omap3isp/isphist.c
> b/drivers/media/platform/omap3isp/isphist.c index
> 7138b043a4aa..e690ca13af0e 100644
> --- a/drivers/media/platform/omap3isp/isphist.c
> +++ b/drivers/media/platform/omap3isp/isphist.c
> @@ -499,14 +499,20 @@ int omap3isp_hist_init(struct isp_device *isp)
> if (res)
> sig = res->start;
>
> - hist->dma_ch = dma_request_slave_channel_compat(mask,
> + hist->dma_ch = dma_request_slave_channel_compat_reason(mask,
> omap_dma_filter_fn, &sig, isp->dev, "hist");
> - if (!hist->dma_ch)
> + if (IS_ERR(hist->dma_ch)) {
> + ret = PTR_ERR(hist->dma_ch);
> + if (ret == -EPROBE_DEFER)
> + return ret;
> +
> + hist->dma_ch = NULL;
> dev_warn(isp->dev,
> "hist: DMA channel request failed, using PIO\n");
> - else
> + } else {
> dev_dbg(isp->dev, "hist: using DMA channel %s\n",
> dma_chan_name(hist->dma_ch));
> + }
> }
>
> hist->ops = &hist_ops;
--
Regards,
Laurent Pinchart
Hi Laurent,
On 11/09/2015 09:50 PM, Laurent Pinchart wrote:
> Hi Peter,
>
> Thank you for the patch.
>
> What happened to this patch series ? It looks like
> dma_request_slave_channel_compat_reason() isn't in mainline, so I can't apply
> this patch.
>
> I'll mark this patch as deferred in patchwork, please resubmit it if you
> resubmit the series
The original series - containing this patch - generated a bit of discussion
and it seams that I will need to do bigger change in the dmaengine API
compared to this.
I think this patch can be dropped as the dmaengine changes will not go in as
they were.
(and by the look of it the issue you're trying to fix
> still exists, so it would be nice if you could get it eventually fixed).
Yes, the issue still valid for the OMAP/DaVinci driver the series was touching.
I will try to send a new series in the coming weeks.
Thanks,
P?ter
>
> On Tuesday 26 May 2015 16:26:07 Peter Ujfalusi wrote:
>> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
>> channel. Only fall back to pio mode if the error code returned is not
>> -EPROBE_DEFER, otherwise return from the probe with the -EPROBE_DEFER.
>>
>> Signed-off-by: Peter Ujfalusi <[email protected]>
>> CC: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]>
>> CC: Mauro Carvalho Chehab <[email protected]>
>> ---
>> drivers/media/platform/omap3isp/isphist.c | 12 +++++++++---
>> 1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/platform/omap3isp/isphist.c
>> b/drivers/media/platform/omap3isp/isphist.c index
>> 7138b043a4aa..e690ca13af0e 100644
>> --- a/drivers/media/platform/omap3isp/isphist.c
>> +++ b/drivers/media/platform/omap3isp/isphist.c
>> @@ -499,14 +499,20 @@ int omap3isp_hist_init(struct isp_device *isp)
>> if (res)
>> sig = res->start;
>>
>> - hist->dma_ch = dma_request_slave_channel_compat(mask,
>> + hist->dma_ch = dma_request_slave_channel_compat_reason(mask,
>> omap_dma_filter_fn, &sig, isp->dev, "hist");
>> - if (!hist->dma_ch)
>> + if (IS_ERR(hist->dma_ch)) {
>> + ret = PTR_ERR(hist->dma_ch);
>> + if (ret == -EPROBE_DEFER)
>> + return ret;
>> +
>> + hist->dma_ch = NULL;
>> dev_warn(isp->dev,
>> "hist: DMA channel request failed, using PIO\n");
>> - else
>> + } else {
>> dev_dbg(isp->dev, "hist: using DMA channel %s\n",
>> dma_chan_name(hist->dma_ch));
>> + }
>> }
>>
>> hist->ops = &hist_ops;
>
Hi Vinod,
bringing this old thread back to life as I just started to work on this.
On 06/24/2015 07:24 PM, Vinod Koul wrote:
>> We would end up with the following APIs, all returning with error code on failure:
>> dma_request_slave_channel(dev, name);
>> dma_request_channel_legacy(mask, fn, fn_param);
>> dma_request_slave_channel_compat(mask, fn, fn_param, dev, name);
>> dma_request_any_channel(mask);
> This is good idea but still we end up with 4 APIs. Why not just converge to
> two API, one legacy + memcpy + filer fn and one untimate API for slave?
Looked at the current API and it's use and, well, it is a bit confusing.
What I hoped that we can separate users to two category:
1. Slave channel requests, where we request a specific channel to handle HW
requests/triggers.
For this we could have:
dma_request_slave_channel(dev, name, fn, fn_param);
In DT/ACPI only drivers we can NULL out the fn and fn_param, in pure legacy
mode we null out the name, I would keep the dev so we could print dev specific
error in dmaengine core, but it could be optional, IN case of drivers used
both DT/ACPI and legacy mode all parameter can be filled and the core will
decide what to do.
For the legacy needs the dmaengine code would provide the mask dows with
DMA_SLAVE flag set.
2. non slave channel requests, where only the functionality matters, like
memcpy, interleaved, memset, etc.
We could have a simple:
dma_request_channel(mask);
But looking at the drivers using dmaengine legacy dma_request_channel() API:
Some sets DMA_INTERRUPT or DMA_PRIVATE or DMA_SG along with DMA_SLAVE:
drivers/misc/carma/carma-fpga.c DMA_INTERRUPT|DMA_SLAVE|DMA_SG
drivers/misc/carma/carma-fpga-program.c DMA_MEMCPY|DMA_SLAVE|DMA_SG
drivers/media/platform/soc_camera/mx3_camera.c DMA_SLAVE|DMA_PRIVATE
sound/soc/intel/common/sst-firmware.c DMA_SLAVE|DMA_MEMCPY
as examples.
Not sure how valid are these...
Some drivers do pass fn and fn_param when requesting channel for DMA_MEMCPY
drivers/misc/mic/host/mic_device.h
drivers/mtd/nand/fsmc_nand.c
sound/soc/intel/common/sst-firmware.c (well, this request DMA_SLAVE capability
at the same time).
Some driver sets the fn_param w/o fn, which means fn_param is ignored.
So the
dma_request_slave_channel(dev, name, fn, fn_param);
dma_request_channel(mask);
almost covers the current users and would be pretty clean ;)
If we add the mask to the slave channel API - which will become universal,
drop in replacement for dma_request_channel, and we might have only one API:
dma_request_channel(dev, name, mask, fn, fn_param);
>
> Internally we may have 4 APIs for cleaner handling...
>
> Thoughts... ??
Yes, as we need to arrange the code internally to keep things neat.
--
P?ter
On Wednesday 18 November 2015 16:21:26 Peter Ujfalusi wrote:
> 2. non slave channel requests, where only the functionality matters, like
> memcpy, interleaved, memset, etc.
> We could have a simple:
> dma_request_channel(mask);
>
> But looking at the drivers using dmaengine legacy dma_request_channel() API:
> Some sets DMA_INTERRUPT or DMA_PRIVATE or DMA_SG along with DMA_SLAVE:
> drivers/misc/carma/carma-fpga.c DMA_INTERRUPT|DMA_SLAVE|DMA_SG
> drivers/misc/carma/carma-fpga-program.c DMA_MEMCPY|DMA_SLAVE|DMA_SG
> drivers/media/platform/soc_camera/mx3_camera.c DMA_SLAVE|DMA_PRIVATE
> sound/soc/intel/common/sst-firmware.c DMA_SLAVE|DMA_MEMCPY
>
> as examples.
> Not sure how valid are these...
It's usually not much harder to separate out the legacy case from
the normal dma_request_slave_channel_reason(), so those drivers don't
really need to use the unified compat API.
Arnd
On 11/18/2015 04:29 PM, Arnd Bergmann wrote:
> On Wednesday 18 November 2015 16:21:26 Peter Ujfalusi wrote:
>> 2. non slave channel requests, where only the functionality matters, like
>> memcpy, interleaved, memset, etc.
>> We could have a simple:
>> dma_request_channel(mask);
>>
>> But looking at the drivers using dmaengine legacy dma_request_channel() API:
>> Some sets DMA_INTERRUPT or DMA_PRIVATE or DMA_SG along with DMA_SLAVE:
>> drivers/misc/carma/carma-fpga.c DMA_INTERRUPT|DMA_SLAVE|DMA_SG
>> drivers/misc/carma/carma-fpga-program.c DMA_MEMCPY|DMA_SLAVE|DMA_SG
>> drivers/media/platform/soc_camera/mx3_camera.c DMA_SLAVE|DMA_PRIVATE
>> sound/soc/intel/common/sst-firmware.c DMA_SLAVE|DMA_MEMCPY
>>
>> as examples.
>> Not sure how valid are these...
>
> It's usually not much harder to separate out the legacy case from
> the normal dma_request_slave_channel_reason(), so those drivers don't
> really need to use the unified compat API.
The current dma_request_slave_channel()/_reason() is not the 'legacy' API.
Currently there is no way to get the reason why the dma channel request fails
when using the _compat() version of the API, which is used by drivers which
can be used in DT or in legacy mode as well. Sure, they all could have local
if(){}else{} for handling this, but it is not a nice thing.
As it was discussed instead of adding the _reason() version for the _compat
call, we should simplify the dmaengine API for getting the channel and at the
same time we will have ERR_PTR returned instead of NULL.
--
P?ter
On Wednesday 18 November 2015 16:41:35 Peter Ujfalusi wrote:
> On 11/18/2015 04:29 PM, Arnd Bergmann wrote:
> > On Wednesday 18 November 2015 16:21:26 Peter Ujfalusi wrote:
> >> 2. non slave channel requests, where only the functionality matters, like
> >> memcpy, interleaved, memset, etc.
> >> We could have a simple:
> >> dma_request_channel(mask);
> >>
> >> But looking at the drivers using dmaengine legacy dma_request_channel() API:
> >> Some sets DMA_INTERRUPT or DMA_PRIVATE or DMA_SG along with DMA_SLAVE:
> >> drivers/misc/carma/carma-fpga.c DMA_INTERRUPT|DMA_SLAVE|DMA_SG
> >> drivers/misc/carma/carma-fpga-program.c DMA_MEMCPY|DMA_SLAVE|DMA_SG
> >> drivers/media/platform/soc_camera/mx3_camera.c DMA_SLAVE|DMA_PRIVATE
> >> sound/soc/intel/common/sst-firmware.c DMA_SLAVE|DMA_MEMCPY
> >>
> >> as examples.
> >> Not sure how valid are these...
I just had a look myself. carma has been removed fortunately in linux-next,
so we don't have to worry about that any more.
I assume that the sst-firmware.c case is a mistake, it should just use a
plain DMA_SLAVE and not DMA_MEMCPY.
Aside from these, everyone else uses either DMA_CYCLIC in addition to
DMA_SLAVE, which seems valid, or they use DMA_PRIVATE, which I think is
redundant in slave drivers and can be removed.
> > It's usually not much harder to separate out the legacy case from
> > the normal dma_request_slave_channel_reason(), so those drivers don't
> > really need to use the unified compat API.
>
> The current dma_request_slave_channel()/_reason() is not the 'legacy' API.
> Currently there is no way to get the reason why the dma channel request fails
> when using the _compat() version of the API, which is used by drivers which
> can be used in DT or in legacy mode as well. Sure, they all could have local
> if(){}else{} for handling this, but it is not a nice thing.
>
> As it was discussed instead of adding the _reason() version for the _compat
> call, we should simplify the dmaengine API for getting the channel and at the
> same time we will have ERR_PTR returned instead of NULL.
What I meant was that we don't need to handle them with the unified
simple interface. The users of DMA_CYCLIC can just keep using
an internal helper that only deals with the legacy case, or use
dma_request_slave() or whatever is the new API for the DT case.
Arnd
On Wed, Nov 18, 2015 at 5:07 PM, Arnd Bergmann <[email protected]> wrote:
> On Wednesday 18 November 2015 16:41:35 Peter Ujfalusi wrote:
>> On 11/18/2015 04:29 PM, Arnd Bergmann wrote:
>> > On Wednesday 18 November 2015 16:21:26 Peter Ujfalusi wrote:
>> >> 2. non slave channel requests, where only the functionality matters, like
>> >> memcpy, interleaved, memset, etc.
>> >> We could have a simple:
>> >> dma_request_channel(mask);
>> >>
>> >> But looking at the drivers using dmaengine legacy dma_request_channel() API:
>> >> Some sets DMA_INTERRUPT or DMA_PRIVATE or DMA_SG along with DMA_SLAVE:
>> >> drivers/misc/carma/carma-fpga.c DMA_INTERRUPT|DMA_SLAVE|DMA_SG
>> >> drivers/misc/carma/carma-fpga-program.c DMA_MEMCPY|DMA_SLAVE|DMA_SG
>> >> drivers/media/platform/soc_camera/mx3_camera.c DMA_SLAVE|DMA_PRIVATE
>> >> sound/soc/intel/common/sst-firmware.c DMA_SLAVE|DMA_MEMCPY
>> >>
>> >> as examples.
>> >> Not sure how valid are these...
>
> I just had a look myself. carma has been removed fortunately in linux-next,
> so we don't have to worry about that any more.
>
> I assume that the sst-firmware.c case is a mistake, it should just use a
> plain DMA_SLAVE and not DMA_MEMCPY.
Other way around.
--
With Best Regards,
Andy Shevchenko
On Wed, Nov 18, 2015 at 4:21 PM, Peter Ujfalusi <[email protected]> wrote:
> Hi Vinod,
>
> bringing this old thread back to life as I just started to work on this.
What I remember we need to convert drivers to use new API meanwhile it
is good to keep old one to avoid patch storm which does nothing useful
(IIRC Russel's opinion).
On the other hand there are a lot of drivers that are used on the set
of platforms starting from legacy and abandoned ones (like AVR32) to
relatively new and newest.
And I'm not a fan of those thousands of API calls either.
--
With Best Regards,
Andy Shevchenko
On Wednesday 18 November 2015 17:43:04 Andy Shevchenko wrote:
> >
> > I assume that the sst-firmware.c case is a mistake, it should just use a
> > plain DMA_SLAVE and not DMA_MEMCPY.
>
> Other way around.
>
Ok, I see. In that case I guess it also shouldn't call
dmaengine_slave_config(), right? I don't think that's valid
on a MEMCPY channel.
Arnd
On Wed, Nov 18, 2015 at 5:51 PM, Arnd Bergmann <[email protected]> wrote:
> On Wednesday 18 November 2015 17:43:04 Andy Shevchenko wrote:
>> >
>> > I assume that the sst-firmware.c case is a mistake, it should just use a
>> > plain DMA_SLAVE and not DMA_MEMCPY.
>>
>> Other way around.
>>
>
> Ok, I see. In that case I guess it also shouldn't call
> dmaengine_slave_config(), right? I don't think that's valid
> on a MEMCPY channel.
Hmm… That's right, though I suspect still one thing why it's done this
way. Let's ask Vinod and Liam about that.
--
With Best Regards,
Andy Shevchenko
On Wed, Nov 18, 2015 at 04:51:54PM +0100, Arnd Bergmann wrote:
> On Wednesday 18 November 2015 17:43:04 Andy Shevchenko wrote:
> > >
> > > I assume that the sst-firmware.c case is a mistake, it should just use a
> > > plain DMA_SLAVE and not DMA_MEMCPY.
> >
> > Other way around.
> >
>
> Ok, I see. In that case I guess it also shouldn't call
> dmaengine_slave_config(), right? I don't think that's valid
> on a MEMCPY channel.
Yes it is not valid. In this case the dma driver should invoke a generic memcpy
and not need slave parameters, knowing the hw and reason for this (firmware
download to DSP memory), this doesn't qualify for slave case.
In fact filter function doesn't need a channel, any channel in this
controller will be good
--
~Vinod
On 11/18/2015 05:07 PM, Arnd Bergmann wrote:
> On Wednesday 18 November 2015 16:41:35 Peter Ujfalusi wrote:
>> On 11/18/2015 04:29 PM, Arnd Bergmann wrote:
>>> On Wednesday 18 November 2015 16:21:26 Peter Ujfalusi wrote:
>>>> 2. non slave channel requests, where only the functionality matters, like
>>>> memcpy, interleaved, memset, etc.
>>>> We could have a simple:
>>>> dma_request_channel(mask);
>>>>
>>>> But looking at the drivers using dmaengine legacy dma_request_channel() API:
>>>> Some sets DMA_INTERRUPT or DMA_PRIVATE or DMA_SG along with DMA_SLAVE:
>>>> drivers/misc/carma/carma-fpga.c DMA_INTERRUPT|DMA_SLAVE|DMA_SG
>>>> drivers/misc/carma/carma-fpga-program.c DMA_MEMCPY|DMA_SLAVE|DMA_SG
>>>> drivers/media/platform/soc_camera/mx3_camera.c DMA_SLAVE|DMA_PRIVATE
>>>> sound/soc/intel/common/sst-firmware.c DMA_SLAVE|DMA_MEMCPY
>>>>
>>>> as examples.
>>>> Not sure how valid are these...
>
> I just had a look myself. carma has been removed fortunately in linux-next,
> so we don't have to worry about that any more.
>
> I assume that the sst-firmware.c case is a mistake, it should just use a
> plain DMA_SLAVE and not DMA_MEMCPY.
>
> Aside from these, everyone else uses either DMA_CYCLIC in addition to
> DMA_SLAVE, which seems valid, or they use DMA_PRIVATE, which I think is
> redundant in slave drivers and can be removed.
Yep, CYCLIC. How could I forgot that ;)
>>> It's usually not much harder to separate out the legacy case from
>>> the normal dma_request_slave_channel_reason(), so those drivers don't
>>> really need to use the unified compat API.
>>
>> The current dma_request_slave_channel()/_reason() is not the 'legacy' API.
>> Currently there is no way to get the reason why the dma channel request fails
>> when using the _compat() version of the API, which is used by drivers which
>> can be used in DT or in legacy mode as well. Sure, they all could have local
>> if(){}else{} for handling this, but it is not a nice thing.
>>
>> As it was discussed instead of adding the _reason() version for the _compat
>> call, we should simplify the dmaengine API for getting the channel and at the
>> same time we will have ERR_PTR returned instead of NULL.
>
> What I meant was that we don't need to handle them with the unified
> simple interface. The users of DMA_CYCLIC can just keep using
> an internal helper that only deals with the legacy case, or use
> dma_request_slave() or whatever is the new API for the DT case.
I think we can go with a single API, but I don't really like that:
dma_request_channel(dev, name, *mask, fn, fn_param);
This would cover all current uses being legacy, DT/ACPI, compat, etc:
dma_request_channel(NULL, NULL, &mask, fn, fn_param); /* Legacy slave */
dma_request_channel(NULL, NULL, &mask, NULL, NULL); /* memcpy. etc */
dma_request_channel(dev, name, NULL, NULL, NULL); /* DT/ACPI, current slave */
dma_request_channel(dev, name, &mask, fn, fn_param); /* current compat */
Note, that we need "const dma_cap_mask_t *mask" to be able to make the mask
optional.
If we have two main APIs, one to request slave channels and one to get any
channel with given capability
dma_request_slave_channel(NULL, NULL, &mask, fn, fn_param); /* Legacy slave */
dma_request_slave_channel(dev, name, NULL, NULL, NULL); /* DT/ACPI, current
slave */
dma_request_slave_channel(dev, name, &mask, fn, fn_param); /* current compat*/
This way we can omit the mask also in cases when the client only want to get
DMA_SLAVE, we can just build up the mask within the function. If the mask is
provided we would copy the bits from the provided mask, so for example if you
want to have DMA_SLAVE+DMA_CYCLIC, the driver only needs to pass DMA_CYCLIC,
the DMA_SLAVE is going to be set anyways.
dma_request_channel(mask); /* memcpy. etc, non slave mostly */
Not sure how to name this as reusing existing (good, descriptive) function
names would mean changes all over the kernel to start off this.
Not used and
request_dma_channel(); /* as _irq/_mem_region/_resource, etc */
request_dma();
dma_channel_request();
All in all, not sure which way would be better...
--
P?ter
On 11/18/2015 05:46 PM, Andy Shevchenko wrote:
> On Wed, Nov 18, 2015 at 4:21 PM, Peter Ujfalusi <[email protected]> wrote:
>> Hi Vinod,
>>
>> bringing this old thread back to life as I just started to work on this.
>
> What I remember we need to convert drivers to use new API meanwhile it
> is good to keep old one to avoid patch storm which does nothing useful
> (IIRC Russel's opinion).
I tend to agree. But we need to start converting the users at some point
either way.
Another issue is the fact that the current dmaengine API is using all the good
names I can think of ;)
> On the other hand there are a lot of drivers that are used on the set
> of platforms starting from legacy and abandoned ones (like AVR32) to
> relatively new and newest.
>
> And I'm not a fan of those thousands of API calls either.
>
--
Péter
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
On Thursday 19 November 2015 12:34:22 Peter Ujfalusi wrote:
>
> I think we can go with a single API, but I don't really like that:
> dma_request_channel(dev, name, *mask, fn, fn_param);
>
> This would cover all current uses being legacy, DT/ACPI, compat, etc:
> dma_request_channel(NULL, NULL, &mask, fn, fn_param); /* Legacy slave */
> dma_request_channel(NULL, NULL, &mask, NULL, NULL); /* memcpy. etc */
> dma_request_channel(dev, name, NULL, NULL, NULL); /* DT/ACPI, current slave */
> dma_request_channel(dev, name, &mask, fn, fn_param); /* current compat */
>
> Note, that we need "const dma_cap_mask_t *mask" to be able to make the mask
> optional.
Right, that would work, but I also don't really like it.
> If we have two main APIs, one to request slave channels and one to get any
> channel with given capability
> dma_request_slave_channel(NULL, NULL, &mask, fn, fn_param); /* Legacy slave */
> dma_request_slave_channel(dev, name, NULL, NULL, NULL); /* DT/ACPI, current
> slave */
> dma_request_slave_channel(dev, name, &mask, fn, fn_param); /* current compat*/
>
> This way we can omit the mask also in cases when the client only want to get
> DMA_SLAVE, we can just build up the mask within the function. If the mask is
> provided we would copy the bits from the provided mask, so for example if you
> want to have DMA_SLAVE+DMA_CYCLIC, the driver only needs to pass DMA_CYCLIC,
> the DMA_SLAVE is going to be set anyways.
I think it's more logical here to have mask=NULL mean that we want DMA_SLAVE,
but otherwise pass the full mask as DMA_SLAVE|DMA_CYCLIC etc.
> dma_request_channel(mask); /* memcpy. etc, non slave mostly */
>
> Not sure how to name this as reusing existing (good, descriptive) function
> names would mean changes all over the kernel to start off this.
>
> Not used and
> request_dma_channel(); /* as _irq/_mem_region/_resource, etc */
> request_dma();
> dma_channel_request();
dma_request_slavechan();
dma_request_slave();
dma_request_mask();
> All in all, not sure which way would be better...
I think I would prefer the simplest API to have only the dev+name
arguments, as we tend to move that way for all platforms anyway, and it
seems silly to have all drivers pass three NULL arguments all the time.
At the moment, there are 139 references to dma_request_slave_channel_*
in the kernel, and only 46 of them are dma_request_slave_channel_compat.
Out of those 46, a couple can already be converted back to use
dma_request_slave_channel() because the platform now only supports
devicetree based boots and will not go back to platform data.
How about something like
extern struct dma_chan *
__dma_request_chan(struct device *dev, const char *name,
const dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param);
static inline struct dma_chan *
dma_request_slavechan(struct device *dev, const char *name)
{
return __dma_request_chan(dev, name, NULL, NULL, NULL);
}
static inline struct dma_chan *
dma_request_chan(const dma_cap_mask_t *mask)
{
return __dma_request_chan(NULL, NULL, mask, NULL, NULL);
}
That way the vast majority of drivers can use one of the two nice interfaces
and the rest can be converted to use __dma_request_chan().
On a related topic, we had in the past considered providing a way for
platform code to register a lookup table of some sort, to associate
a device/name pair with a configuration. That would let us use the
simplified dma_request_slavechan(dev, name) pair everywhere. We could
use the same method that we have for clk_register_clkdevs() or
pinctrl_register_map().
Something like either
static struct dma_chan_map myplatform_dma_map[] = {
{ .devname = "omap-aes0", .slave = "tx", .filter = omap_dma_filter_fn, .arg = (void *)65, },
{ .devname = "omap-aes0", .slave = "rx", .filter = omap_dma_filter_fn, .arg = (void *)66, },
};
or
static struct dma_chan_map myplatform_dma_map[] = {
{ .devname = "omap-aes0", .slave = "tx", .master = "omap-dma-engine0", .req = 65, },
{ .devname = "omap-aes0", .slave = "rx", .master = "omap-dma-engine0", .req = 66, },
};
we could even allow a combination of the two, so the simple case just specifies
master and req number, which requires changes to the dmaengine driver, but we could
also do a mass-conversion to the .filter/.arg variant.
Arnd
On 11/19/2015 01:25 PM, Arnd Bergmann wrote:
>> If we have two main APIs, one to request slave channels and one to get any
>> channel with given capability
>> dma_request_slave_channel(NULL, NULL, &mask, fn, fn_param); /* Legacy slave */
>> dma_request_slave_channel(dev, name, NULL, NULL, NULL); /* DT/ACPI, current
>> slave */
>> dma_request_slave_channel(dev, name, &mask, fn, fn_param); /* current compat*/
>>
>> This way we can omit the mask also in cases when the client only want to get
>> DMA_SLAVE, we can just build up the mask within the function. If the mask is
>> provided we would copy the bits from the provided mask, so for example if you
>> want to have DMA_SLAVE+DMA_CYCLIC, the driver only needs to pass DMA_CYCLIC,
>> the DMA_SLAVE is going to be set anyways.
>
> I think it's more logical here to have mask=NULL mean that we want DMA_SLAVE,
> but otherwise pass the full mask as DMA_SLAVE|DMA_CYCLIC etc.
Yep, could be, while I would write the core part to set the DMA_SLAVE
unconditionally anyways. If the API say it is dma_request_slavechan() it is
expected to get channel which is capable of DMA_SLAVE.
>> dma_request_channel(mask); /* memcpy. etc, non slave mostly */
>>
>> Not sure how to name this as reusing existing (good, descriptive) function
>> names would mean changes all over the kernel to start off this.
>>
>> Not used and
>> request_dma_channel(); /* as _irq/_mem_region/_resource, etc */
>> request_dma();
>> dma_channel_request();
>
> dma_request_slavechan();
> dma_request_slave();
> dma_request_mask();
Let me think aloud here a bit...
1. To request slave channel which will return you the channel your device is
bind via DT/ACPI or the platform map table you propose later:
dma_request_chan(struct device *dev, const char *name);
2. To request a channel (any channel) matching with the capabilities the
driver needs, like memcpy, memset, etc:
#define dma_request_chan_by_mask(mask) __dma_request_chan_by_mask(&(mask))
__dma_request_chan_by_mask(const dma_cap_mask_t *mask);
I think the dma_request_chan() does not need mask to be passed, since via this
we request a specific channel which has been defined/set by DT/ACPI or the
lookup map. We could add a mask parameter which could be used to sanity check
the channel we got against the capabilities the driver needs from the channel.
We currently do this in the drivers where the author wanted to make sure that
the channel is capable of what it should be capable.
So two API to request channel:
struct dma_chan *dma_request_chan(struct device *dev, const char *name);
struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask);
Both will return with the valid channel pointer or in case of failure with
ERR_PTR().
We need to go through the code in regards to return codes also to have sane
mapping.
>
>> All in all, not sure which way would be better...
>
> I think I would prefer the simplest API to have only the dev+name
> arguments, as we tend to move that way for all platforms anyway, and it
> seems silly to have all drivers pass three NULL arguments all the time.
> At the moment, there are 139 references to dma_request_slave_channel_*
> in the kernel, and only 46 of them are dma_request_slave_channel_compat.
> Out of those 46, a couple can already be converted back to use
> dma_request_slave_channel() because the platform now only supports
> devicetree based boots and will not go back to platform data.
>
> How about something like
>
> extern struct dma_chan *
> __dma_request_chan(struct device *dev, const char *name,
> const dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param);
>
> static inline struct dma_chan *
> dma_request_slavechan(struct device *dev, const char *name)
> {
> return __dma_request_chan(dev, name, NULL, NULL, NULL);
> }
>
> static inline struct dma_chan *
> dma_request_chan(const dma_cap_mask_t *mask)
> {
> return __dma_request_chan(NULL, NULL, mask, NULL, NULL);
> }
>
> That way the vast majority of drivers can use one of the two nice interfaces
> and the rest can be converted to use __dma_request_chan().
>
> On a related topic, we had in the past considered providing a way for
> platform code to register a lookup table of some sort, to associate
> a device/name pair with a configuration. That would let us use the
> simplified dma_request_slavechan(dev, name) pair everywhere. We could
> use the same method that we have for clk_register_clkdevs() or
> pinctrl_register_map().
>
> Something like either
>
> static struct dma_chan_map myplatform_dma_map[] = {
> { .devname = "omap-aes0", .slave = "tx", .filter = omap_dma_filter_fn, .arg = (void *)65, },
> { .devname = "omap-aes0", .slave = "rx", .filter = omap_dma_filter_fn, .arg = (void *)66, },
> };
>
> or
>
> static struct dma_chan_map myplatform_dma_map[] = {
> { .devname = "omap-aes0", .slave = "tx", .master = "omap-dma-engine0", .req = 65, },
> { .devname = "omap-aes0", .slave = "rx", .master = "omap-dma-engine0", .req = 66, },
sa11x0-dma expects the fn_param as string :o
> };
Basically we are deprecating the use of IORESOURCE_DMA?
For legacy the filter function is pretty much needed to handle the differences
between the platforms as not all of them does the filtering in a same way. So
the first type of map would be feasible IMHO.
> we could even allow a combination of the two, so the simple case just specifies
> master and req number, which requires changes to the dmaengine driver, but we could
> also do a mass-conversion to the .filter/.arg variant.
This will get rid of the need for the fn and fn_param parameters when
requesting dma channel, but it will not get rid of the exported function from
the dma engine drivers since in arch code we need to have visibility to the
filter_fn.
--
P?ter
On Friday 20 November 2015 12:25:06 Peter Ujfalusi wrote:
> On 11/19/2015 01:25 PM, Arnd Bergmann wrote:
> >> dma_request_channel(mask); /* memcpy. etc, non slave mostly */
> >>
> >> Not sure how to name this as reusing existing (good, descriptive) function
> >> names would mean changes all over the kernel to start off this.
> >>
> >> Not used and
> >> request_dma_channel(); /* as _irq/_mem_region/_resource, etc */
> >> request_dma();
> >> dma_channel_request();
> >
> > dma_request_slavechan();
> > dma_request_slave();
> > dma_request_mask();
>
> Let me think aloud here a bit...
> 1. To request slave channel which will return you the channel your device is
> bind via DT/ACPI or the platform map table you propose later:
>
> dma_request_chan(struct device *dev, const char *name);
>
> 2. To request a channel (any channel) matching with the capabilities the
> driver needs, like memcpy, memset, etc:
>
> #define dma_request_chan_by_mask(mask) __dma_request_chan_by_mask(&(mask))
> __dma_request_chan_by_mask(const dma_cap_mask_t *mask);
>
> I think the dma_request_chan() does not need mask to be passed, since via this
> we request a specific channel which has been defined/set by DT/ACPI or the
> lookup map. We could add a mask parameter which could be used to sanity check
> the channel we got against the capabilities the driver needs from the channel.
> We currently do this in the drivers where the author wanted to make sure that
> the channel is capable of what it should be capable.
>
> So two API to request channel:
> struct dma_chan *dma_request_chan(struct device *dev, const char *name);
> struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask);
>
> Both will return with the valid channel pointer or in case of failure with
> ERR_PTR().
>
> We need to go through the code in regards to return codes also to have sane
> mapping.
Right.
> > That way the vast majority of drivers can use one of the two nice interfaces
> > and the rest can be converted to use __dma_request_chan().
> >
> > On a related topic, we had in the past considered providing a way for
> > platform code to register a lookup table of some sort, to associate
> > a device/name pair with a configuration. That would let us use the
> > simplified dma_request_slavechan(dev, name) pair everywhere. We could
> > use the same method that we have for clk_register_clkdevs() or
> > pinctrl_register_map().
> >
> > Something like either
> >
> > static struct dma_chan_map myplatform_dma_map[] = {
> > { .devname = "omap-aes0", .slave = "tx", .filter = omap_dma_filter_fn, .arg = (void *)65, },
> > { .devname = "omap-aes0", .slave = "rx", .filter = omap_dma_filter_fn, .arg = (void *)66, },
> > };
> >
> > or
> >
> > static struct dma_chan_map myplatform_dma_map[] = {
> > { .devname = "omap-aes0", .slave = "tx", .master = "omap-dma-engine0", .req = 65, },
> > { .devname = "omap-aes0", .slave = "rx", .master = "omap-dma-engine0", .req = 66, },
>
> sa11x0-dma expects the fn_param as string :o
Some of them do, but the new API requires changes in both the DMA master and
slave drivers, so that could be changed if we wanted to, or we just allow
both methods indefinitely and let sa11x0-dma pass the filterfn+data rather than
a number.
> > };
>
> Basically we are deprecating the use of IORESOURCE_DMA?
I thought we already had ;-)
> For legacy the filter function is pretty much needed to handle the differences
> between the platforms as not all of them does the filtering in a same way. So
> the first type of map would be feasible IMHO.
It certainly makes the transition to a map table much easier.
> > we could even allow a combination of the two, so the simple case just specifies
> > master and req number, which requires changes to the dmaengine driver, but we could
> > also do a mass-conversion to the .filter/.arg variant.
>
> This will get rid of the need for the fn and fn_param parameters when
> requesting dma channel, but it will not get rid of the exported function from
> the dma engine drivers since in arch code we need to have visibility to the
> filter_fn.
Correct. A lot of dmaengine drivers already need to be built-in so the platform
code can put a pointer to the filter function, so it would not be worse for them.
Another idea would be to remove the filter function from struct dma_chan_map
and pass the map through platform data to the dmaengine driver, which then
registers it to the core along with the mask. Something like:
/* platform code */
static struct dma_chan_map oma_dma_map[] = {
{ .devname = "omap-aes0", .slave = "tx", .arg = (void *)65, },
{ .devname = "omap-aes0", .slave = "rx", .arg = (void *)66, },
...
{},
};
static struct omap_system_dma_plat_info dma_plat_info __initdata = {
.dma_map = &oma_dma_map,
...
};
machine_init(void)
{
...
platform_device_register_data(NULL, "omap-dma-engine", 0, &dma_plat_info, sizeof(dma_plat_info);
...
}
/* dmaengine driver */
static int omap_dma_probe(struct platform_device *pdev)
{
struct omap_system_dma_plat_info *pdata = dev_get_platdata(&pdev->dev);
...
dmam_register_platform_map(&pdev->dev, omap_dma_filter_fn, pdata->dma_map);
}
/* dmaengine core */
struct dma_map_list {
struct list_head node;
struct device *master;
dma_filter_fn filter;
struct dma_chan_map *map;
};
static LIST_HEAD(dma_map_list);
static DEFINE_MUTEX(dma_map_mutex);
int dmam_register_platform_map(struct device *dev, dma_filter_fn filter, struct dma_chan_map *map)
{
struct dma_map_list *list = kmalloc(sizeof(*list), GFP_KERNEL);
if (!list)
return -ENOMEM;
list->dev = dev;
list->filter = filter;
list->map = map;
mutex_lock(&dma_map_mutex);
list_add(&dma_map_list, &list->node);
mutex_unlock(&dma_map_mutex);
}
Now we can completely remove the dependency on the filter function definition
from platform code and slave drivers.
Arnd
On Fri, Nov 20, 2015 at 12:58 PM, Arnd Bergmann <[email protected]> wrote:
> On Friday 20 November 2015 12:25:06 Peter Ujfalusi wrote:
>> On 11/19/2015 01:25 PM, Arnd Bergmann wrote:
> Another idea would be to remove the filter function from struct dma_chan_map
> and pass the map through platform data
Why not unified device properties?
--
With Best Regards,
Andy Shevchenko
On 11/20/2015 02:24 PM, Andy Shevchenko wrote:
> On Fri, Nov 20, 2015 at 12:58 PM, Arnd Bergmann <[email protected]> wrote:
>> On Friday 20 November 2015 12:25:06 Peter Ujfalusi wrote:
>>> On 11/19/2015 01:25 PM, Arnd Bergmann wrote:
>
>> Another idea would be to remove the filter function from struct dma_chan_map
>> and pass the map through platform data
>
> Why not unified device properties?
Is this some Windows/ACPI feature? Quick search gives mostly MSDN and
Windows10 related links.
We only need dma_chan_map for platforms which has not been converted to DT and
still using legacy boot. Or platforms which can still boot in legacy mode. In
DT/ACPI mode we do not need this map at all.
--
Péter
On 11/20/2015 12:58 PM, Arnd Bergmann wrote:
>>> That way the vast majority of drivers can use one of the two nice interfaces
>>> and the rest can be converted to use __dma_request_chan().
>>>
>>> On a related topic, we had in the past considered providing a way for
>>> platform code to register a lookup table of some sort, to associate
>>> a device/name pair with a configuration. That would let us use the
>>> simplified dma_request_slavechan(dev, name) pair everywhere. We could
>>> use the same method that we have for clk_register_clkdevs() or
>>> pinctrl_register_map().
>>>
>>> Something like either
>>>
>>> static struct dma_chan_map myplatform_dma_map[] = {
>>> { .devname = "omap-aes0", .slave = "tx", .filter = omap_dma_filter_fn, .arg = (void *)65, },
>>> { .devname = "omap-aes0", .slave = "rx", .filter = omap_dma_filter_fn, .arg = (void *)66, },
>>> };
>>>
>>> or
>>>
>>> static struct dma_chan_map myplatform_dma_map[] = {
>>> { .devname = "omap-aes0", .slave = "tx", .master = "omap-dma-engine0", .req = 65, },
>>> { .devname = "omap-aes0", .slave = "rx", .master = "omap-dma-engine0", .req = 66, },
>>
>> sa11x0-dma expects the fn_param as string :o
>
> Some of them do, but the new API requires changes in both the DMA master and
> slave drivers, so that could be changed if we wanted to, or we just allow
> both methods indefinitely and let sa11x0-dma pass the filterfn+data rather than
> a number.
Hrm, I would say that we need to push everyone to use the new API. sa11x0
should not be a big deal to fix IMHO and other users should be reasonably
simple to convert.
>>> };
>>
>> Basically we are deprecating the use of IORESOURCE_DMA?
>
> I thought we already had ;-)
For DT boot, yes. Not for the legacy boot.
>> For legacy the filter function is pretty much needed to handle the differences
>> between the platforms as not all of them does the filtering in a same way. So
>> the first type of map would be feasible IMHO.
>
> It certainly makes the transition to a map table much easier.
And the aim anyway is to convert everything to DT, right?
>>> we could even allow a combination of the two, so the simple case just specifies
>>> master and req number, which requires changes to the dmaengine driver, but we could
>>> also do a mass-conversion to the .filter/.arg variant.
>>
>> This will get rid of the need for the fn and fn_param parameters when
>> requesting dma channel, but it will not get rid of the exported function from
>> the dma engine drivers since in arch code we need to have visibility to the
>> filter_fn.
>
> Correct. A lot of dmaengine drivers already need to be built-in so the platform
> code can put a pointer to the filter function, so it would not be worse for them.
>
> Another idea would be to remove the filter function from struct dma_chan_map
> and pass the map through platform data to the dmaengine driver, which then
> registers it to the core along with the mask. Something like:
>
> /* platform code */
> static struct dma_chan_map oma_dma_map[] = {
> { .devname = "omap-aes0", .slave = "tx", .arg = (void *)65, },
> { .devname = "omap-aes0", .slave = "rx", .arg = (void *)66, },
> ...
> {},
> };
>
> static struct omap_system_dma_plat_info dma_plat_info __initdata = {
> .dma_map = &oma_dma_map,
> ...
> };
>
> machine_init(void)
> {
> ...
> platform_device_register_data(NULL, "omap-dma-engine", 0, &dma_plat_info, sizeof(dma_plat_info);
> ...
> }
>
> /* dmaengine driver */
>
> static int omap_dma_probe(struct platform_device *pdev)
> {
> struct omap_system_dma_plat_info *pdata = dev_get_platdata(&pdev->dev);
> ...
>
> dmam_register_platform_map(&pdev->dev, omap_dma_filter_fn, pdata->dma_map);
> }
>
> /* dmaengine core */
>
> struct dma_map_list {
> struct list_head node;
> struct device *master;
> dma_filter_fn filter;
> struct dma_chan_map *map;
> };
>
> static LIST_HEAD(dma_map_list);
> static DEFINE_MUTEX(dma_map_mutex);
>
> int dmam_register_platform_map(struct device *dev, dma_filter_fn filter, struct dma_chan_map *map)
> {
> struct dma_map_list *list = kmalloc(sizeof(*list), GFP_KERNEL);
>
> if (!list)
> return -ENOMEM;
>
> list->dev = dev;
> list->filter = filter;
> list->map = map;
>
> mutex_lock(&dma_map_mutex);
> list_add(&dma_map_list, &list->node);
> mutex_unlock(&dma_map_mutex);
> }
>
> Now we can completely remove the dependency on the filter function definition
> from platform code and slave drivers.
Sounds feasible for OMAP and daVinci and for others as well. I think ;)
I would go with this if someone asks my opinion :D
The core change to add the new API + the dma_map support should be pretty
straight forward. It can live alongside with the old API and we can phase out
the users of the old one.
The legacy support would need more time since we need to modify the arch codes
and the corresponding DMA drivers to get the map registered, but after that
the remaining drivers can be converted to use the new API.
--
P?ter
On Friday 20 November 2015 14:52:03 Peter Ujfalusi wrote:
>
> >> For legacy the filter function is pretty much needed to handle the differences
> >> between the platforms as not all of them does the filtering in a same way. So
> >> the first type of map would be feasible IMHO.
> >
> > It certainly makes the transition to a map table much easier.
>
> And the aim anyway is to convert everything to DT, right?
We won't be able to do that. Some architectures (avr32 and sh for instance)
use the dmaengine API but will likely never support DT. On ARM, at
least sa1100 is in the same category, probably also ep93xx and portions
of pxa, omap1 and davinci.
> > int dmam_register_platform_map(struct device *dev, dma_filter_fn filter, struct dma_chan_map *map)
> > {
> > struct dma_map_list *list = kmalloc(sizeof(*list), GFP_KERNEL);
> >
> > if (!list)
> > return -ENOMEM;
> >
> > list->dev = dev;
> > list->filter = filter;
> > list->map = map;
> >
> > mutex_lock(&dma_map_mutex);
> > list_add(&dma_map_list, &list->node);
> > mutex_unlock(&dma_map_mutex);
> > }
> >
> > Now we can completely remove the dependency on the filter function definition
> > from platform code and slave drivers.
>
> Sounds feasible for OMAP and daVinci and for others as well. I think
> I would go with this if someone asks my opinion
Ok.
> The core change to add the new API + the dma_map support should be pretty
> straight forward. It can live alongside with the old API and we can phase out
> the users of the old one.
> The legacy support would need more time since we need to modify the arch codes
> and the corresponding DMA drivers to get the map registered, but after that
> the remaining drivers can be converted to use the new API.
Right. It's not urgent and as long as we agree on the overall approach, we can
always do the platform support first and wait for the following merge window
before moving over the slave drivers.
Arnd
On Fri, Nov 20, 2015 at 2:30 PM, Peter Ujfalusi <[email protected]> wrote:
> On 11/20/2015 02:24 PM, Andy Shevchenko wrote:
>> On Fri, Nov 20, 2015 at 12:58 PM, Arnd Bergmann <[email protected]> wrote:
>>> On Friday 20 November 2015 12:25:06 Peter Ujfalusi wrote:
>>>> On 11/19/2015 01:25 PM, Arnd Bergmann wrote:
>>
>>> Another idea would be to remove the filter function from struct dma_chan_map
>>> and pass the map through platform data
>>
>> Why not unified device properties?
>
> Is this some Windows/ACPI feature?
Nope.
Check drivers/base/property.c
> Quick search gives mostly MSDN and
> Windows10 related links.
>
> We only need dma_chan_map for platforms which has not been converted to DT and
> still using legacy boot. Or platforms which can still boot in legacy mode. In
> DT/ACPI mode we do not need this map at all.
--
With Best Regards,
Andy Shevchenko