mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bastian Krause <bst@pengutronix.de>
To: meenakshi.aggarwal@nxp.com, horia.geanta@nxp.com,
	V.sethi@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com,
	herbert@gondor.apana.org.au, davem@davemloft.net,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Victoria Milhoan <vicki.milhoan@freescale.com>,
	Dan Douglass <dan.douglass@nxp.com>,
	Vipul Kumar <vipul_kumar@mentor.com>,
	kernel@pengutronix.de
Subject: Re: [PATCH] crypto: caam - adjust RNG timing to support more devices
Date: Tue, 18 Jul 2023 11:43:02 +0200	[thread overview]
Message-ID: <f673a09e-e212-ee7b-15c3-78afe8c70916@pengutronix.de> (raw)
In-Reply-To: <e1f3f073-9d5e-1bae-f4f8-08dc48adad62@pengutronix.de>

On 7/17/23 14:43, Bastian Krause wrote:
> On 6/12/23 10:26, meenakshi.aggarwal@nxp.com wrote:
>> From: Victoria Milhoan <vicki.milhoan@freescale.com>
>>
>> Adjust RNG timing parameters to support more i.MX6 devices.
>>
>> Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
>> Signed-off-by: Dan Douglass <dan.douglass@nxp.com>
>> Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
>> Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
>> ---
>>   drivers/crypto/caam/ctrl.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> This patch seems to breaks CAAM RNG instantiation on an i.MX8MM at my end:
> 
> caam 30900000.crypto: Entropy delay = 3200
> caam 30900000.crypto: Entropy delay = 3600
> [...]
> caam 30900000.crypto: Entropy delay = 12400
> caam 30900000.crypto: failed to instantiate RNG
> caam: probe of 30900000.crypto failed with error -11
> 
> If I revert this patch or increase RTSDCTL_ENT_DLY_MAX to a value > 
> 66800, it works again:
> 
> caam 30900000.crypto: Entropy delay = 32800
> caam 30900000.crypto: Entropy delay = 33200
> [...]
> caam 30900000.crypto: Entropy delay = 66800
> caam 30900000.crypto: Instantiated RNG4 SH0
> caam 30900000.crypto: Instantiated RNG4 SH1
> caam 30900000.crypto: device ID = 0x0a16040100000000 (Era 9)
> caam 30900000.crypto: job rings = 2, qi = 0
> caam algorithms registered in /proc/crypto
> caam 30900000.crypto: caam pkc algorithms registered in /proc/crypto
> caam 30900000.crypto: registering rng-caam
> Executing RNG SELF-TEST with wait
> random: crng init done
> caam 30900000.crypto: rng crypto API alg registered prng-caam

This ^ was the kernel log for..


--- a/drivers/crypto/caam/regs.h
+++ b/drivers/crypto/caam/regs.h
@@@ -522,7 -522,7 +522,7 @@@ struct rng4tst
   #define RTSDCTL_ENT_DLY_SHIFT 16
   #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
   #define RTSDCTL_ENT_DLY_MIN 3200
--#define RTSDCTL_ENT_DLY_MAX 12800
++#define RTSDCTL_ENT_DLY_MAX 70000
   #define RTSDCTL_SAMP_SIZE_MASK 0xffff
   #define RTSDCTL_SAMP_SIZE_VAL 512
         u32 rtsdctl;            /* seed control register */


For completion's sake: Reverting this patch..


--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -383,7 +383,7 @@ static void kick_trng(struct device *dev, int ent_delay)
                 /* min. freq. count, equal to 1/4 of the entropy sample length */
                 wr_reg32(&r4tst->rtfrqmin, val >> 2);
                 /* max. freq. count, equal to 16 times the entropy sample length */
-               wr_reg32(&r4tst->rtfrqmax, val << 4);
+               wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
         }
  
         wr_reg32(&r4tst->rtsdctl, (val << RTSDCTL_ENT_DLY_SHIFT) |


..produces this kernel log (without RNG SELF-TEST):

caam 30900000.crypto: Entropy delay = 3200
caam 30900000.crypto: Entropy delay = 3600
caam 30900000.crypto: Instantiated RNG4 SH0
caam 30900000.crypto: Instantiated RNG4 SH1
caam 30900000.crypto: device ID = 0x0a16040100000000 (Era 9)
caam 30900000.crypto: job rings = 2, qi = 0
caam algorithms registered in /proc/crypto
caam 30900000.crypto: caam pkc algorithms registered in /proc/crypto
caam 30900000.crypto: registering rng-caam
caam 30900000.crypto: rng crypto API alg registered prng-caam
random: crng init done

Regards,
Bastian

>>
>> diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
>> index 5fed3cf354c0..62dd069942e4 100644
>> --- a/drivers/crypto/caam/ctrl.c
>> +++ b/drivers/crypto/caam/ctrl.c
>> @@ -383,8 +383,8 @@ static void kick_trng(struct device *dev, int 
>> ent_delay)
>>       wr_reg32(&r4tst->rtsdctl, val);
>>       /* min. freq. count, equal to 1/4 of the entropy sample length */
>>       wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
>> -    /* disable maximum frequency count */
>> -    wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
>> +    /* max. freq. count, equal to 16 times the entropy sample length */
>> +    wr_reg32(&r4tst->rtfrqmax, ent_delay << 4);
>>       /* read the control register */
>>       val = rd_reg32(&r4tst->rtmctl);
>>   start_rng:
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


  reply	other threads:[~2023-07-18  9:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12  8:26 meenakshi.aggarwal
2023-06-15 11:45 ` Gaurav Jain
2023-06-23  8:20 ` Herbert Xu
2023-07-17 12:43 ` Bastian Krause
2023-07-18  9:43   ` Bastian Krause [this message]
2023-07-19  7:00     ` Meenakshi Aggarwal
2023-07-24  5:13       ` Meenakshi Aggarwal
2023-08-04  9:14         ` Herbert Xu
2023-08-04 12:02           ` [EXT] " Gaurav Jain
2023-08-11  8:47             ` Linux regression tracking (Thorsten Leemhuis)
2023-08-11 11:55               ` Meenakshi Aggarwal
2023-08-11 12:58                 ` Meenakshi Aggarwal
2023-08-13 14:04                   ` Linux regression tracking (Thorsten Leemhuis)
2023-07-24 17:21       ` Bastian Krause
2023-08-05 13:04   ` Linux regression tracking #adding (Thorsten Leemhuis)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f673a09e-e212-ee7b-15c3-78afe8c70916@pengutronix.de \
    --to=bst@pengutronix.de \
    --cc=V.sethi@nxp.com \
    --cc=dan.douglass@nxp.com \
    --cc=davem@davemloft.net \
    --cc=gaurav.jain@nxp.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meenakshi.aggarwal@nxp.com \
    --cc=pankaj.gupta@nxp.com \
    --cc=vicki.milhoan@freescale.com \
    --cc=vipul_kumar@mentor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®