* [PATCH v2 1/3] crypto: atmel-aes - Retire dma_request_slave_channel_compat()
2019-11-21 10:15 [PATCH v2 0/3] crypto: atmel - Retire dma_request_slave_channel_compat() Peter Ujfalusi
@ 2019-11-21 10:16 ` Peter Ujfalusi
2019-11-21 10:16 ` [PATCH v2 2/3] crypto: atmel-sha " Peter Ujfalusi
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2019-11-21 10:16 UTC (permalink / raw)
To: herbert, davem, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: vkoul, linux-crypto, linux-arm-kernel, linux-kernel
The driver no longer boots in legacy mode, only via DT. This makes the
dma_request_slave_channel_compat() redundant.
If ever the filter function would be executed it will return false as the
dma_slave is not really initialized.
Switch to use dma_request_chan() which would allow legacy boot if ever
needed again by configuring dma_slave_map for the DMA driver.
At the same time skip allocating memory for dma_slave as it is not used
anymore.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/crypto/atmel-aes.c | 50 ++++++++------------------------------
1 file changed, 10 insertions(+), 40 deletions(-)
diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c
index 3c88c164c3dc..30c41598fa2a 100644
--- a/drivers/crypto/atmel-aes.c
+++ b/drivers/crypto/atmel-aes.c
@@ -38,7 +38,6 @@
#include <crypto/internal/aead.h>
#include <crypto/internal/skcipher.h>
#include <linux/platform_data/crypto-atmel.h>
-#include <dt-bindings/dma/at91.h>
#include "atmel-aes-regs.h"
#include "atmel-authenc.h"
@@ -2364,39 +2363,23 @@ static void atmel_aes_buff_cleanup(struct atmel_aes_dev *dd)
free_page((unsigned long)dd->buf);
}
-static bool atmel_aes_filter(struct dma_chan *chan, void *slave)
-{
- struct at_dma_slave *sl = slave;
-
- if (sl && sl->dma_dev == chan->device->dev) {
- chan->private = sl;
- return true;
- } else {
- return false;
- }
-}
-
static int atmel_aes_dma_init(struct atmel_aes_dev *dd,
struct crypto_platform_data *pdata)
{
- struct at_dma_slave *slave;
- dma_cap_mask_t mask;
-
- dma_cap_zero(mask);
- dma_cap_set(DMA_SLAVE, mask);
+ int ret;
/* Try to grab 2 DMA channels */
- slave = &pdata->dma_slave->rxdata;
- dd->src.chan = dma_request_slave_channel_compat(mask, atmel_aes_filter,
- slave, dd->dev, "tx");
- if (!dd->src.chan)
+ dd->src.chan = dma_request_chan(dd->dev, "tx");
+ if (IS_ERR(dd->src.chan)) {
+ ret = PTR_ERR(dd->src.chan);
goto err_dma_in;
+ }
- slave = &pdata->dma_slave->txdata;
- dd->dst.chan = dma_request_slave_channel_compat(mask, atmel_aes_filter,
- slave, dd->dev, "rx");
- if (!dd->dst.chan)
+ dd->dst.chan = dma_request_chan(dd->dev, "rx");
+ if (IS_ERR(dd->dst.chan)) {
+ ret = PTR_ERR(dd->dst.chan);
goto err_dma_out;
+ }
return 0;
@@ -2404,7 +2387,7 @@ static int atmel_aes_dma_init(struct atmel_aes_dev *dd,
dma_release_channel(dd->src.chan);
err_dma_in:
dev_warn(dd->dev, "no DMA channel available\n");
- return -ENODEV;
+ return ret;
}
static void atmel_aes_dma_cleanup(struct atmel_aes_dev *dd)
@@ -2592,14 +2575,6 @@ static struct crypto_platform_data *atmel_aes_of_init(struct platform_device *pd
if (!pdata)
return ERR_PTR(-ENOMEM);
- pdata->dma_slave = devm_kzalloc(&pdev->dev,
- sizeof(*(pdata->dma_slave)),
- GFP_KERNEL);
- if (!pdata->dma_slave) {
- devm_kfree(&pdev->dev, pdata);
- return ERR_PTR(-ENOMEM);
- }
-
return pdata;
}
#else
@@ -2626,11 +2601,6 @@ static int atmel_aes_probe(struct platform_device *pdev)
}
}
- if (!pdata->dma_slave) {
- err = -ENXIO;
- goto aes_dd_err;
- }
-
aes_dd = devm_kzalloc(&pdev->dev, sizeof(*aes_dd), GFP_KERNEL);
if (aes_dd == NULL) {
err = -ENOMEM;
--
Peter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] crypto: atmel-sha - Retire dma_request_slave_channel_compat()
2019-11-21 10:15 [PATCH v2 0/3] crypto: atmel - Retire dma_request_slave_channel_compat() Peter Ujfalusi
2019-11-21 10:16 ` [PATCH v2 1/3] crypto: atmel-aes " Peter Ujfalusi
@ 2019-11-21 10:16 ` Peter Ujfalusi
2019-11-21 10:16 ` [PATCH v2 3/3] crypto: atmel-tdes " Peter Ujfalusi
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2019-11-21 10:16 UTC (permalink / raw)
To: herbert, davem, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: vkoul, linux-crypto, linux-arm-kernel, linux-kernel
The driver no longer boots in legacy mode, only via DT. This makes the
dma_request_slave_channel_compat() redundant.
If ever the filter function would be executed it will return false as the
dma_slave is not really initialized.
Switch to use dma_request_chan() which would allow legacy boot if ever
needed again by configuring dma_slave_map for the DMA driver.
At the same time skip allocating memory for dma_slave as it is not used
anymore.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/crypto/atmel-sha.c | 39 +++++++-------------------------------
1 file changed, 7 insertions(+), 32 deletions(-)
diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c
index 8ea0e4bcde0d..9d392c5ff06b 100644
--- a/drivers/crypto/atmel-sha.c
+++ b/drivers/crypto/atmel-sha.c
@@ -2608,32 +2608,16 @@ static int atmel_sha_register_algs(struct atmel_sha_dev *dd)
return err;
}
-static bool atmel_sha_filter(struct dma_chan *chan, void *slave)
-{
- struct at_dma_slave *sl = slave;
-
- if (sl && sl->dma_dev == chan->device->dev) {
- chan->private = sl;
- return true;
- } else {
- return false;
- }
-}
-
static int atmel_sha_dma_init(struct atmel_sha_dev *dd,
struct crypto_platform_data *pdata)
{
- dma_cap_mask_t mask_in;
+ dd->dma_lch_in.chan = dma_request_chan(dd->dev, "tx");
+ if (IS_ERR(dd->dma_lch_in.chan)) {
+ int ret = PTR_ERR(dd->dma_lch_in.chan);
- /* Try to grab DMA channel */
- dma_cap_zero(mask_in);
- dma_cap_set(DMA_SLAVE, mask_in);
-
- dd->dma_lch_in.chan = dma_request_slave_channel_compat(mask_in,
- atmel_sha_filter, &pdata->dma_slave->rxdata, dd->dev, "tx");
- if (!dd->dma_lch_in.chan) {
- dev_warn(dd->dev, "no DMA channel available\n");
- return -ENODEV;
+ if (ret != -EPROBE_DEFER)
+ dev_warn(dd->dev, "no DMA channel available\n");
+ return ret;
}
dd->dma_lch_in.dma_conf.direction = DMA_MEM_TO_DEV;
@@ -2724,12 +2708,6 @@ static struct crypto_platform_data *atmel_sha_of_init(struct platform_device *pd
if (!pdata)
return ERR_PTR(-ENOMEM);
- pdata->dma_slave = devm_kzalloc(&pdev->dev,
- sizeof(*(pdata->dma_slave)),
- GFP_KERNEL);
- if (!pdata->dma_slave)
- return ERR_PTR(-ENOMEM);
-
return pdata;
}
#else /* CONFIG_OF */
@@ -2823,10 +2801,7 @@ static int atmel_sha_probe(struct platform_device *pdev)
goto iclk_unprepare;
}
}
- if (!pdata->dma_slave) {
- err = -ENXIO;
- goto iclk_unprepare;
- }
+
err = atmel_sha_dma_init(sha_dd, pdata);
if (err)
goto err_sha_dma;
--
Peter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] crypto: atmel-tdes - Retire dma_request_slave_channel_compat()
2019-11-21 10:15 [PATCH v2 0/3] crypto: atmel - Retire dma_request_slave_channel_compat() Peter Ujfalusi
2019-11-21 10:16 ` [PATCH v2 1/3] crypto: atmel-aes " Peter Ujfalusi
2019-11-21 10:16 ` [PATCH v2 2/3] crypto: atmel-sha " Peter Ujfalusi
@ 2019-11-21 10:16 ` Peter Ujfalusi
2019-11-22 4:37 ` [PATCH v2 0/3] crypto: atmel " Vinod Koul
2019-12-11 9:36 ` Herbert Xu
4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2019-11-21 10:16 UTC (permalink / raw)
To: herbert, davem, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: vkoul, linux-crypto, linux-arm-kernel, linux-kernel
The driver no longer boots in legacy mode, only via DT. This makes the
dma_request_slave_channel_compat() redundant.
If ever the filter function would be executed it will return false as the
dma_slave is not really initialized.
Switch to use dma_request_chan() which would allow legacy boot if ever
needed again by configuring dma_slave_map for the DMA driver.
At the same time skip allocating memory for dma_slave as it is not used
anymore.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/crypto/atmel-tdes.c | 47 ++++++++++---------------------------
1 file changed, 13 insertions(+), 34 deletions(-)
diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c
index bb7c0a387c04..fbc76edaef3e 100644
--- a/drivers/crypto/atmel-tdes.c
+++ b/drivers/crypto/atmel-tdes.c
@@ -703,31 +703,17 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode)
return atmel_tdes_handle_queue(ctx->dd, req);
}
-static bool atmel_tdes_filter(struct dma_chan *chan, void *slave)
-{
- struct at_dma_slave *sl = slave;
-
- if (sl && sl->dma_dev == chan->device->dev) {
- chan->private = sl;
- return true;
- } else {
- return false;
- }
-}
-
static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd,
struct crypto_platform_data *pdata)
{
- dma_cap_mask_t mask;
-
- dma_cap_zero(mask);
- dma_cap_set(DMA_SLAVE, mask);
+ int ret;
/* Try to grab 2 DMA channels */
- dd->dma_lch_in.chan = dma_request_slave_channel_compat(mask,
- atmel_tdes_filter, &pdata->dma_slave->rxdata, dd->dev, "tx");
- if (!dd->dma_lch_in.chan)
+ dd->dma_lch_in.chan = dma_request_chan(dd->dev, "tx");
+ if (IS_ERR(dd->dma_lch_in.chan)) {
+ ret = PTR_ERR(dd->dma_lch_in.chan);
goto err_dma_in;
+ }
dd->dma_lch_in.dma_conf.direction = DMA_MEM_TO_DEV;
dd->dma_lch_in.dma_conf.dst_addr = dd->phys_base +
@@ -740,10 +726,11 @@ static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd,
DMA_SLAVE_BUSWIDTH_4_BYTES;
dd->dma_lch_in.dma_conf.device_fc = false;
- dd->dma_lch_out.chan = dma_request_slave_channel_compat(mask,
- atmel_tdes_filter, &pdata->dma_slave->txdata, dd->dev, "rx");
- if (!dd->dma_lch_out.chan)
+ dd->dma_lch_out.chan = dma_request_chan(dd->dev, "rx");
+ if (IS_ERR(dd->dma_lch_out.chan)) {
+ ret = PTR_ERR(dd->dma_lch_out.chan);
goto err_dma_out;
+ }
dd->dma_lch_out.dma_conf.direction = DMA_DEV_TO_MEM;
dd->dma_lch_out.dma_conf.src_addr = dd->phys_base +
@@ -761,8 +748,9 @@ static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd,
err_dma_out:
dma_release_channel(dd->dma_lch_in.chan);
err_dma_in:
- dev_warn(dd->dev, "no DMA channel available\n");
- return -ENODEV;
+ if (ret != -EPROBE_DEFER)
+ dev_warn(dd->dev, "no DMA channel available\n");
+ return ret;
}
static void atmel_tdes_dma_cleanup(struct atmel_tdes_dev *dd)
@@ -1193,12 +1181,6 @@ static struct crypto_platform_data *atmel_tdes_of_init(struct platform_device *p
if (!pdata)
return ERR_PTR(-ENOMEM);
- pdata->dma_slave = devm_kzalloc(&pdev->dev,
- sizeof(*(pdata->dma_slave)),
- GFP_KERNEL);
- if (!pdata->dma_slave)
- return ERR_PTR(-ENOMEM);
-
return pdata;
}
#else /* CONFIG_OF */
@@ -1292,10 +1274,7 @@ static int atmel_tdes_probe(struct platform_device *pdev)
goto err_pdata;
}
}
- if (!pdata->dma_slave) {
- err = -ENXIO;
- goto err_pdata;
- }
+
err = atmel_tdes_dma_init(tdes_dd, pdata);
if (err)
goto err_tdes_dma;
--
Peter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/3] crypto: atmel - Retire dma_request_slave_channel_compat()
2019-11-21 10:15 [PATCH v2 0/3] crypto: atmel - Retire dma_request_slave_channel_compat() Peter Ujfalusi
` (2 preceding siblings ...)
2019-11-21 10:16 ` [PATCH v2 3/3] crypto: atmel-tdes " Peter Ujfalusi
@ 2019-11-22 4:37 ` Vinod Koul
2019-12-11 9:36 ` Herbert Xu
4 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2019-11-22 4:37 UTC (permalink / raw)
To: Peter Ujfalusi
Cc: herbert, davem, nicolas.ferre, alexandre.belloni,
ludovic.desroches, linux-crypto, linux-arm-kernel, linux-kernel
On 21-11-19, 12:15, Peter Ujfalusi wrote:
> Hi,
>
> Changes since v1:
> - Rebased on next-20191121 to avoid conflict for atmel-aes
>
> I'm going through the kernel to crack down on dma_request_slave_channel_compat()
> users.
>
> These drivers no longer needs it as they are only probed via DT and even if they
> would probe in legacy mode, the dma_request_chan() + dma_slave_map must be used
> for supporting non DT boots.
Reviewed-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/3] crypto: atmel - Retire dma_request_slave_channel_compat()
2019-11-21 10:15 [PATCH v2 0/3] crypto: atmel - Retire dma_request_slave_channel_compat() Peter Ujfalusi
` (3 preceding siblings ...)
2019-11-22 4:37 ` [PATCH v2 0/3] crypto: atmel " Vinod Koul
@ 2019-12-11 9:36 ` Herbert Xu
4 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2019-12-11 9:36 UTC (permalink / raw)
To: Peter Ujfalusi
Cc: davem, nicolas.ferre, alexandre.belloni, ludovic.desroches,
vkoul, linux-crypto, linux-arm-kernel, linux-kernel
On Thu, Nov 21, 2019 at 12:15:59PM +0200, Peter Ujfalusi wrote:
> Hi,
>
> Changes since v1:
> - Rebased on next-20191121 to avoid conflict for atmel-aes
>
> I'm going through the kernel to crack down on dma_request_slave_channel_compat()
> users.
>
> These drivers no longer needs it as they are only probed via DT and even if they
> would probe in legacy mode, the dma_request_chan() + dma_slave_map must be used
> for supporting non DT boots.
>
> I have only compile tested the drivers!
>
> Regards,
> Peter
> ---
> Peter Ujfalusi (3):
> crypto: atmel-aes - Retire dma_request_slave_channel_compat()
> crypto: atmel-sha - Retire dma_request_slave_channel_compat()
> crypto: atmel-tdes - Retire dma_request_slave_channel_compat()
>
> drivers/crypto/atmel-aes.c | 50 ++++++++-----------------------------
> drivers/crypto/atmel-sha.c | 39 ++++++-----------------------
> drivers/crypto/atmel-tdes.c | 47 ++++++++++------------------------
> 3 files changed, 30 insertions(+), 106 deletions(-)
All applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread