[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f67acb13-a48e-763b-dce6-d3867b0e4965@nxp.com>
Date: Wed, 27 Apr 2022 14:48:39 +0300
From: Horia Geantă <horia.geanta@....com>
To: Meenakshi Aggarwal <meenakshi.aggarwal@....com>,
Pankaj Gupta <pankaj.gupta@....com>,
Gaurav Jain <gaurav.jain@....com>,
Varun Sethi <V.Sethi@....com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S . Miller" <davem@...emloft.net>
Cc: "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
dl-linux-imx <linux-imx@....com>
Subject: Re: [PATCH v3 1/1] crypto: caam/rng: Add support for PRNG
On 4/20/2022 9:38 AM, Meenakshi Aggarwal wrote:
> +static void caam_prng_done(struct device *jrdev, u32 *desc, u32 err,
> + void *context)
> +{
> + struct caam_prng_ctx *jctx = context;
> +
> + if (err >> JRSTA_SSRC_SHIFT)
> + jctx->err = caam_jr_strstatus(jrdev, err);
The details of error handling are in error.c, let's keep this abstraction.
> + else
> + jctx->err = 0;
> +
> + complete(&jctx->done);
> +}
> +
[...]
> +static int caam_prng_seed(struct crypto_rng *tfm,
> + const u8 *seed, unsigned int slen)
> +{
> + struct caam_prng_ctx ctx;
> + struct device *jrdev;
> + dma_addr_t seed_dma;
> + u32 *desc;
> + u8 *buf;
> + int ret = 0;
> +
> + if (seed == NULL) {
> + pr_err("Seed not provided\n");
> + return ret;
> + }
> +
> + buf = kzalloc(slen, GFP_KERNEL);
> + if (!buf)
> + return -ENOMEM;
> +
> + jrdev = caam_jr_alloc();
> + ret = PTR_ERR_OR_ZERO(jrdev);
> + if (ret) {
> + pr_err("Job Ring Device allocation failed\n");
> + kfree(buf);
> + return ret;
> + }
> +
> + desc = kzalloc(CAAM_PRNG_DESC_LEN, GFP_KERNEL | GFP_DMA);
> + if (!desc) {
> + ret = -ENOMEM;
> + goto out1;
> + }
> +
> + memcpy(buf, seed, slen);
> +
> + seed_dma = dma_map_single(jrdev, buf, slen, DMA_FROM_DEVICE);
Now that seedsize is 0, the .seed callback is called with slen = 0.
Reseed descriptor should be updated too.
Horia
Powered by blists - more mailing lists