Re: [PATCH v3 2/4] ASoC: SDCA: Populate IRQ data earlier

From: Charles Keepax

Date: Mon Jul 20 2026 - 11:07:24 EST


On Sun, Jul 19, 2026 at 02:24:26PM +0100, Mark Brown wrote:
> On Thu, Jul 16, 2026 at 03:26:37PM +0100, Charles Keepax wrote:
> > Currently, the IRQ data (attached Entity/Control/etc) is populated
> > as the IRQ is requested. However, this can cause issues as
> > occasionally the setup process wants to access specifics of
> > an IRQ before the IRQ is actually enabled. To facilitate this
> > cache all the IRQ data during sdca_irq_populate_early() and make
> > sdca_irq_populate() simply request the outstanding IRQs. This
> > also has the advantage that sdca_irq_populate() can now just
> > iterate through the IRQ array which is much smaller/faster than
> > going through every Entity in the Function for Controls.
>
> > --- a/sound/soc/sdca/sdca_interrupts.c
> > +++ b/sound/soc/sdca/sdca_interrupts.c
> > @@ -375,7 +375,7 @@ int sdca_irq_data_populate(struct device *dev, struct regmap *regmap,
> > if (!dev)
> > return -ENODEV;
> >
> > - name = kasprintf(GFP_KERNEL, "%s %s", entity->label, control->label);
> > + name = devm_kasprintf(dev, GFP_KERNEL, "%s %s", entity->label, control->label);
> > if (!name)
> > return -ENOMEM;
> >
>
> Moving to devm_ makes me a bit nervous.

Moving to devm should be good here. The expectation is that
sdca_irq_populate_early() is called from device probe and this
moves all the allocations into there. Even before this series
we had devm_ allocations being done by sdca_fdl_alloc_state(),
so the requirement to call sdca_irq_populate_early() from device
probe already existed.

With the split of the cleanup into two steps though, we could
move everything onto manually allocations and clean them up there
if we felt this was a little too hidden behind the API? Or
document it more in the kernel doc I guess?

> > @@ -448,21 +448,34 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap,
>
> > + case SDCA_CTL_TYPE_S(GE, DETECTED_MODE):
> > + ret = sdca_jack_alloc_state(interrupt);
> > if (ret)
> > return ret;
> >
> > + interrupt->handler = detected_mode_handler;
> > + break;
>
> > struct sdca_interrupt_info *info)
> >
>
> I'm a bit surprised there's no corresponding change in the cleanup path,
> we're moving the allocation to the device driver not the card but the
> card may be bound and unbound from the device. Perhaps I'm missing
> something?

There is a sneaky:

- kfree(interrupt->name);

At the bottom of the patch.

Thanks,
Charles