Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Liao, Bard" <bard.liao@intel.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"Girdwood, Liam R" <liam.r.girdwood@intel.com>,
	"Bossart, Pierre-louis" <pierre-louis.bossart@intel.com>
Subject: Re: snd_hdac_device_unregister is called twice on ASoC driver
Date: Sun, 28 Apr 2019 08:18:19 +0200	[thread overview]
Message-ID: <s5hmukamz4k.wl-tiwai@suse.de> (raw)
In-Reply-To: <567A313375B6F043A9BE3A1D9B8C6E7F0B425509@SHSMSX101.ccr.corp.intel.com>

On Sun, 28 Apr 2019 03:46:56 +0200,
Liao, Bard wrote:
> 
> Hi Takashi and all,
> 
> We meet a problem that snd_hdac_device_unregister will be called twice
> 
> on ASoC driver. We will call snd_hdac_ext_bus_device_init ->
> 
> snd_hdac_device_register and snd_hdac_ext_bus_device_remove ->
> 
> snd_hdac_device_unregister on ASoC driver. It looks even to me.
> 
> However, hdac_hda_codec_probe will call snd_hda_codec_device_new
> 
> to create a hda codec device. And it will assign snd_hda_codec_dev_free
> 
> to the .dev_free ops where snd_hdac_device_unregister will be called.
> 
> That’s why snd_hdac_device_unregister will be call twice on ASoC driver.
> 
> Below patch can “fix” this issue, but I don’t know if it is the right way
> 
> to fix it. Could you take a look and give me some advice?

The change looks OK to me.
Care to cook up a proper patch?


thanks,

Takashi


> 
> --- a/sound/pci/hda/hda_codec.c
> 
> +++ b/sound/pci/hda/hda_codec.c
> 
> @@ -841,7 +841,13 @@ static int snd_hda_codec_dev_free(struct snd_device
> *device)
> 
>         struct hda_codec *codec = device->device_data;
> 
>         codec->in_freeing = 1;
> 
> -       snd_hdac_device_unregister(&codec->core);
> 
> +       /*
> 
> +        * snd_hda_codec_device_new() is used by legacy HDA and ASoC driver.
> 
> +        * We can't unregister ASoC device since it will be unregistered in
> 
> +        * snd_hdac_ext_bus_device_remove().
> 
> +        */
> 
> +       if (codec->core.type == HDA_DEV_LEGACY)
> 
> +               snd_hdac_device_unregister(&codec->core);
> 
>         codec_display_power(codec, false);
> 
>         put_device(hda_codec_dev(codec));
> 
>         return 0;
> 
> --- a/sound/soc/codecs/hdac_hda.c
> 
> +++ b/sound/soc/codecs/hdac_hda.c
> 
> @@ -328,6 +328,12 @@ static int hdac_hda_codec_probe(struct snd_soc_component
> *component)
> 
>                 dev_err(&hdev->dev, "failed to create hda codec %d\n", ret);
> 
>                 goto error_no_pm;
> 
>         }
> 
> +       /*
> 
> +        * Overwrite type to HDA_DEV_ASOC since it is a ASoC driver
> 
> +        * hda_codec.c will check this flag to determine if unregister
> 
> +        * device is needed.
> 
> +        */
> 
> +       hdev->type = HDA_DEV_ASOC;
> 
>         /*
> 
>          * snd_hda_codec_device_new decrements the usage count so call get pm
> 
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

      reply	other threads:[~2019-04-28  6:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-28  1:46 snd_hdac_device_unregister is called twice on ASoC driver Liao, Bard
2019-04-28  6:18 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hmukamz4k.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=bard.liao@intel.com \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@intel.com \
    --cc=pierre-louis.bossart@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox