[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aC0J8g6UYxSw_7zZ@gondor.apana.org.au>
Date: Wed, 21 May 2025 07:02:10 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Bharat Bhushan <bbhushan2@...vell.com>
Cc: bbrezillon@...nel.org, schalla@...vell.com, davem@...emloft.net,
giovanni.cabiddu@...el.com, linux@...blig.org,
bharatb.linux@...il.com, linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH 2/4 v2] crypto: octeontx2: Fix address alignment issue on
ucode loading
On Tue, May 20, 2025 at 06:37:35PM +0530, Bharat Bhushan wrote:
>
> @@ -1519,22 +1520,27 @@ int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf)
> if (ret)
> goto delete_grps;
>
> - compl_rlen = ALIGN(sizeof(union otx2_cpt_res_s), OTX2_CPT_DMA_MINALIGN);
> - len = compl_rlen + LOADFVC_RLEN;
> + len = LOADFVC_RLEN + sizeof(union otx2_cpt_res_s) +
> + OTX2_CPT_RES_ADDR_ALIGN;
>
> - result = kzalloc(len, GFP_KERNEL);
> - if (!result) {
> + rptr = kzalloc(len, GFP_KERNEL);
> + if (!rptr) {
> ret = -ENOMEM;
> goto lf_cleanup;
> }
> - rptr_baddr = dma_map_single(&pdev->dev, (void *)result, len,
> +
> + rptr_baddr = dma_map_single(&pdev->dev, rptr, len,
> DMA_BIDIRECTIONAL);
After this change rptr is still unaligned. However, you appear
to be doing bidirectional DMA to rptr, so it should be aligned
to ARCH_DMA_MINALIGN or you risk corrupting the surrounding
memory.
Only TO_DEVICE DMA addresses can be unaligned.
Cheers,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists