On Wed, May 21, 2025 at 4:32 AM Herbert Xu herbert@gondor.apana.org.au wrote:
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.
Yes, rptr was not aligned as ARCH_KMALLOC_MINALIGN and rptr alignment are same. But as per the second part of the comment, rptr must be aligned to ARCH_DMA_MINALIGN. So will change total memory allocation and rptr and result_address alignment accordingly.
Thanks -Bharat
Only TO_DEVICE DMA addresses can be unaligned.
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