[alsa-devel] [RFC PATCH 1/2] ASoC: core: don't increase component module refcount unconditionally

Vinod Koul vkoul at kernel.org
Tue Feb 5 05:25:09 CET 2019


On 01-02-19, 12:07, Ranjani Sridharan wrote:
> On Fri, 2019-02-01 at 23:42 +0530, Vinod Koul wrote:
> > On 01-02-19, 11:22, Pierre-Louis Bossart wrote:
> > > The ASoC core has for the longest time increased the module
> > > reference
> > > counts, even before the transition to the component model. This is
> > > probably fine on most platforms, but it introduces a deadlock case
> > > on
> > > Intel devices with the Skylake and SOF drivers which cannot be
> > > removed
> > > due to their reference counts being modified by the core.
> > > 
> > > In these 2 cases, the PCI or ACPI driver .probe creates a platform
> > > device to let the machine driver .probe register the audio
> > > card. Conversely the PCI or ACPI driver .remove will unregister the
> > > platform device which results in the card being removed by the
> > > machine
> > > driver .remove.
> > > 
> > > With ascii art, this can be represented as
> > > 
> > > modprobe
> > > snd_soc_skl/
> > > soc-pci-dev/sof-acpci-dev  ----------> pci/acpi probe
> > >        ^                                    |
> > >        |                     ---------------|
> > >        |                    |               |
> > >        |                    V               V
> > >     increase            register        register machine
> > >     refcount            component       platform_device
> > >        ^                                    |
> > >        |                                    |
> > >        |                                    V
> > >     component <----   register card  <---- probe
> > >     probe
> > > 
> > > The issue is that by playing with the component's module reference
> > > counts during the card registration, it's no longer possible to
> > > remove
> > > the module which controls the component. This can be shown, e.g.
> > > with
> > > the following error:
> > > 
> > > root at plb-XPS-13-9350:~# lsmod | grep snd_soc_skl
> > > snd_soc_skl           110592  1
> > > 
> > > root at plb-XPS-13-9350:~# rmmod snd_soc_skl
> > > rmmod: ERROR: Module snd_soc_skl is in use
> > 
> > Yup, that would be correct, the inuse is due to the fact the sound
> > card
> > is up and someone needs to unload the sound card to remove the
> > reference.
> > 
> > That can be done by doing the rmmod of machine driver first and IIRC
> > that would remove the sound card and drop the reference and then
> > snd_soc_skl can be unloaded.
> 
> This doesnt seem to be the case though. The machine driver module
> cannot be removed either because its refcnt is also > 0.

At least this used to be the case when I used to try removal of modules
on skl, doing the reverse of load order seemed to work for me back then.

-- 
~Vinod


More information about the Alsa-devel mailing list