diff mbox

crypto: ixp4xxx: Use dma_pool_zalloc()

Message ID 20180217101113.GA13514@jordon-HP-15-Notebook-PC (mailing list archive)
State Changes Requested
Headers show

Commit Message

Souptick Joarder Feb. 17, 2018, 10:11 a.m. UTC
Use dma_pool_zalloc() instead of dma_pool_alloc + memset

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
 drivers/crypto/ixp4xx_crypto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--
1.9.1

Comments

Herbert Xu Feb. 22, 2018, 2:10 p.m. UTC | #1
On Sat, Feb 17, 2018 at 03:41:13PM +0530, Souptick Joarder wrote:
> Use dma_pool_zalloc() instead of dma_pool_alloc + memset
> 
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>

Hmm, the memset doesn't just happen at allocation time.  You haven't
explained why it is OK to remove the memset at these other points.

Cheers,
Souptick Joarder Feb. 22, 2018, 3:02 p.m. UTC | #2
On Thu, Feb 22, 2018 at 7:40 PM, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Sat, Feb 17, 2018 at 03:41:13PM +0530, Souptick Joarder wrote:
>> Use dma_pool_zalloc() instead of dma_pool_alloc + memset
>>
>> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
>
> Hmm, the memset doesn't just happen at allocation time.  You haven't
> explained why it is OK to remove the memset at these other points.

Inside init_sa_dir(), reset_sa_dir() is called immediately after
dma_pool_alloc()
where memset was done for  pointer "dir->npe_ctx". Hence removing the memset
is fine inside reset_sa_dir() as dma_pool_zalloc() is already doing it.

>
> Cheers,
> --
> 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
Herbert Xu Feb. 22, 2018, 3:14 p.m. UTC | #3
On Thu, Feb 22, 2018 at 08:32:36PM +0530, Souptick Joarder wrote:
> On Thu, Feb 22, 2018 at 7:40 PM, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> > On Sat, Feb 17, 2018 at 03:41:13PM +0530, Souptick Joarder wrote:
> >> Use dma_pool_zalloc() instead of dma_pool_alloc + memset
> >>
> >> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> >
> > Hmm, the memset doesn't just happen at allocation time.  You haven't
> > explained why it is OK to remove the memset at these other points.
> 
> Inside init_sa_dir(), reset_sa_dir() is called immediately after
> dma_pool_alloc()
> where memset was done for  pointer "dir->npe_ctx". Hence removing the memset
> is fine inside reset_sa_dir() as dma_pool_zalloc() is already doing it.

Yes but reset_sa_dir is also called from other places.

Cheers,
Souptick Joarder Feb. 22, 2018, 3:24 p.m. UTC | #4
On Thu, Feb 22, 2018 at 8:44 PM, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Thu, Feb 22, 2018 at 08:32:36PM +0530, Souptick Joarder wrote:
>> On Thu, Feb 22, 2018 at 7:40 PM, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>> > On Sat, Feb 17, 2018 at 03:41:13PM +0530, Souptick Joarder wrote:
>> >> Use dma_pool_zalloc() instead of dma_pool_alloc + memset
>> >>
>> >> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
>> >
>> > Hmm, the memset doesn't just happen at allocation time.  You haven't
>> > explained why it is OK to remove the memset at these other points.
>>
>> Inside init_sa_dir(), reset_sa_dir() is called immediately after
>> dma_pool_alloc()
>> where memset was done for  pointer "dir->npe_ctx". Hence removing the memset
>> is fine inside reset_sa_dir() as dma_pool_zalloc() is already doing it.
>
> Yes but reset_sa_dir is also called from other places.

Apology, Missed it. Then adding dma_pool_zalloc() not making much difference.
Shall I drop this patch or send v2 ?

>
> Cheers,
> --
> 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
Herbert Xu Feb. 22, 2018, 3:42 p.m. UTC | #5
On Thu, Feb 22, 2018 at 08:54:27PM +0530, Souptick Joarder wrote:
>
> Apology, Missed it. Then adding dma_pool_zalloc() not making much difference.
> Shall I drop this patch or send v2 ?

I think we should probably leave it alone.

Thanks,
Souptick Joarder Feb. 22, 2018, 3:50 p.m. UTC | #6
On Thu, Feb 22, 2018 at 9:12 PM, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Thu, Feb 22, 2018 at 08:54:27PM +0530, Souptick Joarder wrote:
>>
>> Apology, Missed it. Then adding dma_pool_zalloc() not making much difference.
>> Shall I drop this patch or send v2 ?
>
> I think we should probably leave it alone.
>
> Thanks,

Sure :)

> --
> 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
diff mbox

Patch

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 717a266..42e1403 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -537,14 +537,13 @@  static void release_ixp_crypto(struct device *dev)

 static void reset_sa_dir(struct ix_sa_dir *dir)
 {
-	memset(dir->npe_ctx, 0, NPE_CTX_LEN);
 	dir->npe_ctx_idx = 0;
 	dir->npe_mode = 0;
 }

 static int init_sa_dir(struct ix_sa_dir *dir)
 {
-	dir->npe_ctx = dma_pool_alloc(ctx_pool, GFP_KERNEL, &dir->npe_ctx_phys);
+	dir->npe_ctx = dma_pool_zalloc(ctx_pool, GFP_KERNEL, &dir->npe_ctx_phys);
 	if (!dir->npe_ctx) {
 		return -ENOMEM;
 	}