linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: caam - enable crypto-engine retry mechanism
@ 2020-10-21 20:06 Iuliana Prodan
  2020-10-26 15:36 ` Horia Geantă
  0 siblings, 1 reply; 4+ messages in thread
From: Iuliana Prodan @ 2020-10-21 20:06 UTC (permalink / raw)
  To: Herbert Xu, Horia Geanta, Aymen Sghaier
  Cc: David S. Miller, Silvano Di Ninno, Franck Lenormand,
	linux-crypto, linux-kernel, linux-imx, Andrei Botila,
	Dragos Rosioru, Iuliana Prodan

Use the new crypto_engine_alloc_init_and_set() function to
initialize crypto-engine and enable retry mechanism.

Set the maximum size for crypto-engine software queue based on
Job Ring size (JOBR_DEPTH) and a threshold (reserved for the
non-crypto-API requests that are not pass through crypto-engine).

The callback for do_batch_requests is NULL, since CAAM
doesn't support linked requests.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
---
 drivers/crypto/caam/intern.h | 3 +++
 drivers/crypto/caam/jr.c     | 6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h
index 9112279..44fe6ee 100644
--- a/drivers/crypto/caam/intern.h
+++ b/drivers/crypto/caam/intern.h
@@ -16,6 +16,9 @@
 /* Currently comes from Kconfig param as a ^2 (driver-required) */
 #define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE)
 
+#define THRESHOLD 15
+#define CRYPTO_ENGINE_MAX_QLEN (2 * (JOBR_DEPTH - THRESHOLD))
+
 /* Kconfig params for interrupt coalescing if selected (else zero) */
 #ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_INTC
 #define JOBR_INTC JRCFG_ICEN
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 6f66996..88540c9 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -550,7 +550,11 @@ static int caam_jr_probe(struct platform_device *pdev)
 	}
 
 	/* Initialize crypto engine */
-	jrpriv->engine = crypto_engine_alloc_init(jrdev, false);
+	jrpriv->engine = crypto_engine_alloc_init_and_set(jrdev,
+							  true,
+							  NULL,
+							  false,
+							  CRYPTO_ENGINE_MAX_QLEN);
 	if (!jrpriv->engine) {
 		dev_err(jrdev, "Could not init crypto-engine\n");
 		return -ENOMEM;
-- 
2.1.0


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

* Re: [PATCH] crypto: caam - enable crypto-engine retry mechanism
  2020-10-21 20:06 [PATCH] crypto: caam - enable crypto-engine retry mechanism Iuliana Prodan
@ 2020-10-26 15:36 ` Horia Geantă
  2020-10-26 17:11   ` Iuliana Prodan
  0 siblings, 1 reply; 4+ messages in thread
From: Horia Geantă @ 2020-10-26 15:36 UTC (permalink / raw)
  To: Iuliana Prodan, Herbert Xu, Aymen Sghaier
  Cc: David S. Miller, Silvano Di Ninno, Franck Lenormand,
	linux-crypto, linux-kernel, dl-linux-imx, Andrei Botila,
	Dragos Rosioru

On 10/21/2020 11:07 PM, Iuliana Prodan wrote:
> Use the new crypto_engine_alloc_init_and_set() function to
> initialize crypto-engine and enable retry mechanism.
> 
> Set the maximum size for crypto-engine software queue based on
> Job Ring size (JOBR_DEPTH) and a threshold (reserved for the
> non-crypto-API requests that are not pass through crypto-engine).
				       ^ passed

> 
> The callback for do_batch_requests is NULL, since CAAM
> doesn't support linked requests.
> 
> Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
> ---
>  drivers/crypto/caam/intern.h | 3 +++
>  drivers/crypto/caam/jr.c     | 6 +++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h
> index 9112279..44fe6ee 100644
> --- a/drivers/crypto/caam/intern.h
> +++ b/drivers/crypto/caam/intern.h
> @@ -16,6 +16,9 @@
>  /* Currently comes from Kconfig param as a ^2 (driver-required) */
>  #define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE)
>  
> +#define THRESHOLD 15
Unless there's a comment added for THRESHOLD (e.g. what's in the
commit message), I don't think the define is helpful.

> +#define CRYPTO_ENGINE_MAX_QLEN (2 * (JOBR_DEPTH - THRESHOLD))
> +
What's the logic behind multiplying by 2?

>  /* Kconfig params for interrupt coalescing if selected (else zero) */
>  #ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_INTC
>  #define JOBR_INTC JRCFG_ICEN
> diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
> index 6f66996..88540c9 100644
> --- a/drivers/crypto/caam/jr.c
> +++ b/drivers/crypto/caam/jr.c
> @@ -550,7 +550,11 @@ static int caam_jr_probe(struct platform_device *pdev)
>  	}
>  
>  	/* Initialize crypto engine */
> -	jrpriv->engine = crypto_engine_alloc_init(jrdev, false);
> +	jrpriv->engine = crypto_engine_alloc_init_and_set(jrdev,
> +							  true,
> +							  NULL,
> +							  false,
> +							  CRYPTO_ENGINE_MAX_QLEN);
Let's make the argument list more compact.

Horia

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

* Re: [PATCH] crypto: caam - enable crypto-engine retry mechanism
  2020-10-26 15:36 ` Horia Geantă
@ 2020-10-26 17:11   ` Iuliana Prodan
  2020-10-26 17:57     ` Horia Geantă
  0 siblings, 1 reply; 4+ messages in thread
From: Iuliana Prodan @ 2020-10-26 17:11 UTC (permalink / raw)
  To: Horia Geantă, Herbert Xu, Aymen Sghaier
  Cc: David S. Miller, Silvano Di Ninno, Franck Lenormand,
	linux-crypto, linux-kernel, dl-linux-imx, Andrei Botila,
	Dragos Rosioru

On 10/26/2020 5:36 PM, Horia Geantă wrote:
> On 10/21/2020 11:07 PM, Iuliana Prodan wrote:
>> Use the new crypto_engine_alloc_init_and_set() function to
>> initialize crypto-engine and enable retry mechanism.
>>
>> Set the maximum size for crypto-engine software queue based on
>> Job Ring size (JOBR_DEPTH) and a threshold (reserved for the
>> non-crypto-API requests that are not pass through crypto-engine).
> 				       ^ passed
> 
>>
>> The callback for do_batch_requests is NULL, since CAAM
>> doesn't support linked requests.
>>
>> Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
>> ---
>>   drivers/crypto/caam/intern.h | 3 +++
>>   drivers/crypto/caam/jr.c     | 6 +++++-
>>   2 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h
>> index 9112279..44fe6ee 100644
>> --- a/drivers/crypto/caam/intern.h
>> +++ b/drivers/crypto/caam/intern.h
>> @@ -16,6 +16,9 @@
>>   /* Currently comes from Kconfig param as a ^2 (driver-required) */
>>   #define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE)
>>   
>> +#define THRESHOLD 15
> Unless there's a comment added for THRESHOLD (e.g. what's in the
> commit message), I don't think the define is helpful.
> 
>> +#define CRYPTO_ENGINE_MAX_QLEN (2 * (JOBR_DEPTH - THRESHOLD))
>> +
> What's the logic behind multiplying by 2?

I added the 2 as the number of Job Rings.
My logic was that crypto-engine is one per CAAM (x no of JRs), while 
JOB_DEPTH is per JR.
I know there are targets with other than 2 JRs. Therefore, is there a 
way to get this number automatically?


Thanks,
Iulia

>>   /* Kconfig params for interrupt coalescing if selected (else zero) */
>>   #ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_INTC
>>   #define JOBR_INTC JRCFG_ICEN
>> diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
>> index 6f66996..88540c9 100644
>> --- a/drivers/crypto/caam/jr.c
>> +++ b/drivers/crypto/caam/jr.c
>> @@ -550,7 +550,11 @@ static int caam_jr_probe(struct platform_device *pdev)
>>   	}
>>   
>>   	/* Initialize crypto engine */
>> -	jrpriv->engine = crypto_engine_alloc_init(jrdev, false);
>> +	jrpriv->engine = crypto_engine_alloc_init_and_set(jrdev,
>> +							  true,
>> +							  NULL,
>> +							  false,
>> +							  CRYPTO_ENGINE_MAX_QLEN);
> Let's make the argument list more compact.
> 
> Horia
> 

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

* Re: [PATCH] crypto: caam - enable crypto-engine retry mechanism
  2020-10-26 17:11   ` Iuliana Prodan
@ 2020-10-26 17:57     ` Horia Geantă
  0 siblings, 0 replies; 4+ messages in thread
From: Horia Geantă @ 2020-10-26 17:57 UTC (permalink / raw)
  To: Iuliana Prodan, Herbert Xu, Aymen Sghaier
  Cc: David S. Miller, Silvano Di Ninno, Franck Lenormand,
	linux-crypto, linux-kernel, dl-linux-imx, Andrei Botila,
	Dragos Rosioru

On 10/26/2020 7:11 PM, Iuliana Prodan wrote:
> On 10/26/2020 5:36 PM, Horia Geantă wrote:
>> On 10/21/2020 11:07 PM, Iuliana Prodan wrote:
[...]
>>> +#define CRYPTO_ENGINE_MAX_QLEN (2 * (JOBR_DEPTH - THRESHOLD))
>>> +
>> What's the logic behind multiplying by 2?
> 
> I added the 2 as the number of Job Rings.
> My logic was that crypto-engine is one per CAAM (x no of JRs), while 
> JOB_DEPTH is per JR.
Currently there is one crypto-engine per JR.
crypto_engine_alloc_init() is called when caam/jr driver is probing.

> I know there are targets with other than 2 JRs. Therefore, is there a 
> way to get this number automatically?
> 
Most SoCs have CAAM configured with 4 JRs.
Of course what's visible to the kernel might be different.

Given there's one crypto-engine / JR, determining the number of JRs
shouldn't be required.

Horia

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

end of thread, other threads:[~2020-10-26 17:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 20:06 [PATCH] crypto: caam - enable crypto-engine retry mechanism Iuliana Prodan
2020-10-26 15:36 ` Horia Geantă
2020-10-26 17:11   ` Iuliana Prodan
2020-10-26 17:57     ` Horia Geantă

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).