Re: [PATCHv2 1/2] dmaengine: idma64: use kzalloc_flex

From: Andy Shevchenko

Date: Mon Jul 13 2026 - 08:04:12 EST


On Sun, Jul 12, 2026 at 03:00:38PM -0700, Rosen Penev wrote:
> Simplifies allocations by using a flexible array member in this struct.
>
> Remove idma64_alloc_desc. It now offers no readability advantages in
> this single usage.
>
> Add __counted_by to get extra runtime analysis.
>
> Apply the exact same treatment to struct idma64_dma and devm_kzalloc.


...

> static struct dma_async_tx_descriptor *idma64_prep_slave_sg(

> struct scatterlist *sg;
> unsigned int i;
>
> - desc = idma64_alloc_desc(sg_len);
> + desc = kzalloc_flex(*desc, hw, sg_len, GFP_NOWAIT);
> if (!desc)
> return NULL;
>
> + desc->ndesc = sg_len;

There are two places where this is updated. Are you sure the code become
correct after this change? Perhaps idma64_desc_free() needs additional care?

> for_each_sg(sgl, sg, sg_len, i) {
> struct idma64_hw_desc *hw = &desc->hw[i];

> hw->len = sg_dma_len(sg);
> }
>
> - desc->ndesc = sg_len;
> desc->direction = direction;
> desc->status = DMA_IN_PROGRESS;

In case the above is okay to do, move all three up to keep this block of
assignments together.

--
With Best Regards,
Andy Shevchenko