linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] crypto: stm32/hash: Defer probe management
@ 2020-04-27  6:42 Lionel Debieve
  2020-04-27  6:42 ` [PATCH 1/3] crypto: stm32/hash - defer probe for reset controller Lionel Debieve
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lionel Debieve @ 2020-04-27  6:42 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Maxime Coquelin, Alexandre Torgue,
	linux-crypto
  Cc: linux-arm-kernel, linux-kernel, linux-stm32

These patches manage properly the defer probe for STM32 Hash driver.
It allows the driver to be probed later if clock, reset or dma return
a defer error.
It also removes the error print messages in such cases.

Etienne Carriere (2):
  crypto: stm32/hash - defer probe for reset controller
  crypto: stm32/hash - defer probe for dma device

Lionel Debieve (1):
  crypto: stm32/hash - don't print error on probe deferral

 drivers/crypto/stm32/stm32-hash.c | 38 ++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 11 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] crypto: stm32/hash - defer probe for reset controller
  2020-04-27  6:42 [PATCH 0/3] crypto: stm32/hash: Defer probe management Lionel Debieve
@ 2020-04-27  6:42 ` Lionel Debieve
  2020-04-27  6:42 ` [PATCH 2/3] crypto: stm32/hash - defer probe for dma device Lionel Debieve
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lionel Debieve @ 2020-04-27  6:42 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Maxime Coquelin, Alexandre Torgue,
	linux-crypto
  Cc: linux-arm-kernel, linux-kernel, linux-stm32

From: Etienne Carriere <etienne.carriere@st.com>

Change stm32 HASH driver to defer its probe operation when
reset controller device is registered but has not been probed yet.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Lionel DEBIEVE <lionel.debieve@st.com>
---
 drivers/crypto/stm32/stm32-hash.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index 167b80eec437..fad6190be088 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -1482,7 +1482,12 @@ static int stm32_hash_probe(struct platform_device *pdev)
 	pm_runtime_enable(dev);
 
 	hdev->rst = devm_reset_control_get(&pdev->dev, NULL);
-	if (!IS_ERR(hdev->rst)) {
+	if (IS_ERR(hdev->rst)) {
+		if (PTR_ERR(hdev->rst) == -EPROBE_DEFER) {
+			ret = -EPROBE_DEFER;
+			goto err_reset;
+		}
+	} else {
 		reset_control_assert(hdev->rst);
 		udelay(2);
 		reset_control_deassert(hdev->rst);
@@ -1535,7 +1540,7 @@ static int stm32_hash_probe(struct platform_device *pdev)
 
 	if (hdev->dma_lch)
 		dma_release_channel(hdev->dma_lch);
-
+err_reset:
 	pm_runtime_disable(dev);
 	pm_runtime_put_noidle(dev);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] crypto: stm32/hash - defer probe for dma device
  2020-04-27  6:42 [PATCH 0/3] crypto: stm32/hash: Defer probe management Lionel Debieve
  2020-04-27  6:42 ` [PATCH 1/3] crypto: stm32/hash - defer probe for reset controller Lionel Debieve
@ 2020-04-27  6:42 ` Lionel Debieve
  2020-04-27  6:42 ` [PATCH 3/3] crypto: stm32/hash - don't print error on probe deferral Lionel Debieve
  2020-05-08  6:04 ` [PATCH 0/3] crypto: stm32/hash: Defer probe management Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Lionel Debieve @ 2020-04-27  6:42 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Maxime Coquelin, Alexandre Torgue,
	linux-crypto
  Cc: linux-arm-kernel, linux-kernel, linux-stm32

From: Etienne Carriere <etienne.carriere@st.com>

Change stm32 HASH driver to defer its probe operation when
DMA channel device is registered but has not been probed yet.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Lionel DEBIEVE <lionel.debieve@st.com>
---
 drivers/crypto/stm32/stm32-hash.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index fad6190be088..0d592f55a271 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -507,6 +507,7 @@ static int stm32_hash_hmac_dma_send(struct stm32_hash_dev *hdev)
 static int stm32_hash_dma_init(struct stm32_hash_dev *hdev)
 {
 	struct dma_slave_config dma_conf;
+	struct dma_chan *chan;
 	int err;
 
 	memset(&dma_conf, 0, sizeof(dma_conf));
@@ -518,11 +519,11 @@ static int stm32_hash_dma_init(struct stm32_hash_dev *hdev)
 	dma_conf.dst_maxburst = hdev->dma_maxburst;
 	dma_conf.device_fc = false;
 
-	hdev->dma_lch = dma_request_chan(hdev->dev, "in");
-	if (IS_ERR(hdev->dma_lch)) {
-		dev_err(hdev->dev, "Couldn't acquire a slave DMA channel.\n");
-		return PTR_ERR(hdev->dma_lch);
-	}
+	chan = dma_request_chan(hdev->dev, "in");
+	if (IS_ERR(chan))
+		return PTR_ERR(chan);
+
+	hdev->dma_lch = chan;
 
 	err = dmaengine_slave_config(hdev->dma_lch, &dma_conf);
 	if (err) {
@@ -1498,8 +1499,15 @@ static int stm32_hash_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, hdev);
 
 	ret = stm32_hash_dma_init(hdev);
-	if (ret)
+	switch (ret) {
+	case 0:
+		break;
+	case -ENOENT:
 		dev_dbg(dev, "DMA mode not available\n");
+		break;
+	default:
+		goto err_dma;
+	}
 
 	spin_lock(&stm32_hash.lock);
 	list_add_tail(&hdev->list, &stm32_hash.dev_list);
@@ -1537,7 +1545,7 @@ static int stm32_hash_probe(struct platform_device *pdev)
 	spin_lock(&stm32_hash.lock);
 	list_del(&hdev->list);
 	spin_unlock(&stm32_hash.lock);
-
+err_dma:
 	if (hdev->dma_lch)
 		dma_release_channel(hdev->dma_lch);
 err_reset:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] crypto: stm32/hash - don't print error on probe deferral
  2020-04-27  6:42 [PATCH 0/3] crypto: stm32/hash: Defer probe management Lionel Debieve
  2020-04-27  6:42 ` [PATCH 1/3] crypto: stm32/hash - defer probe for reset controller Lionel Debieve
  2020-04-27  6:42 ` [PATCH 2/3] crypto: stm32/hash - defer probe for dma device Lionel Debieve
@ 2020-04-27  6:42 ` Lionel Debieve
  2020-05-08  6:04 ` [PATCH 0/3] crypto: stm32/hash: Defer probe management Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Lionel Debieve @ 2020-04-27  6:42 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Maxime Coquelin, Alexandre Torgue,
	linux-crypto
  Cc: linux-arm-kernel, linux-kernel, linux-stm32

Change driver to not print an error message when the device
probe is deferred for a clock resource.

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
---
 drivers/crypto/stm32/stm32-hash.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index 0d592f55a271..03c5e6683805 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -1464,8 +1464,11 @@ static int stm32_hash_probe(struct platform_device *pdev)
 
 	hdev->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(hdev->clk)) {
-		dev_err(dev, "failed to get clock for hash (%lu)\n",
-			PTR_ERR(hdev->clk));
+		if (PTR_ERR(hdev->clk) != -EPROBE_DEFER) {
+			dev_err(dev, "failed to get clock for hash (%lu)\n",
+				PTR_ERR(hdev->clk));
+		}
+
 		return PTR_ERR(hdev->clk);
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] crypto: stm32/hash: Defer probe management
  2020-04-27  6:42 [PATCH 0/3] crypto: stm32/hash: Defer probe management Lionel Debieve
                   ` (2 preceding siblings ...)
  2020-04-27  6:42 ` [PATCH 3/3] crypto: stm32/hash - don't print error on probe deferral Lionel Debieve
@ 2020-05-08  6:04 ` Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2020-05-08  6:04 UTC (permalink / raw)
  To: Lionel Debieve
  Cc: David S . Miller, Maxime Coquelin, Alexandre Torgue,
	linux-crypto, linux-arm-kernel, linux-kernel, linux-stm32

On Mon, Apr 27, 2020 at 08:42:23AM +0200, Lionel Debieve wrote:
> These patches manage properly the defer probe for STM32 Hash driver.
> It allows the driver to be probed later if clock, reset or dma return
> a defer error.
> It also removes the error print messages in such cases.
> 
> Etienne Carriere (2):
>   crypto: stm32/hash - defer probe for reset controller
>   crypto: stm32/hash - defer probe for dma device
> 
> Lionel Debieve (1):
>   crypto: stm32/hash - don't print error on probe deferral
> 
>  drivers/crypto/stm32/stm32-hash.c | 38 ++++++++++++++++++++++---------
>  1 file changed, 27 insertions(+), 11 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] 5+ messages in thread

end of thread, other threads:[~2020-05-08  6:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27  6:42 [PATCH 0/3] crypto: stm32/hash: Defer probe management Lionel Debieve
2020-04-27  6:42 ` [PATCH 1/3] crypto: stm32/hash - defer probe for reset controller Lionel Debieve
2020-04-27  6:42 ` [PATCH 2/3] crypto: stm32/hash - defer probe for dma device Lionel Debieve
2020-04-27  6:42 ` [PATCH 3/3] crypto: stm32/hash - don't print error on probe deferral Lionel Debieve
2020-05-08  6:04 ` [PATCH 0/3] crypto: stm32/hash: Defer probe management Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).