All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ALSA: hda: fix unregister device twice on ASoC driver
@ 2019-04-27 20:53 Bard liao
  2019-04-27 20:53 ` [PATCH 2/2] ASoC: hdac_hda: overwrite hdev type to HDA_DEV_ASOC Bard liao
  2019-04-29  7:12 ` [PATCH 1/2] ALSA: hda: fix unregister device twice on ASoC driver Takashi Iwai
  0 siblings, 2 replies; 4+ messages in thread
From: Bard liao @ 2019-04-27 20:53 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: liam.r.girdwood, alsa-devel, pierre-louis.bossart, bard.liao

snd_hda_codec_device_new() is used by both legacy HDA and ASoC
driver. However, we will call snd_hdac_device_unregister() in
snd_hdac_ext_bus_device_remove() for ASoC device. This patch uses
the type flag in hdac_device struct to determine is it a ASoC device
or legacy HDA device and call snd_hdac_device_unregister() in
snd_hda_codec_dev_free() only if it is a legacy HDA device.

Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
---
 sound/pci/hda/hda_codec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 701a69d856f5..b20eb7fc83eb 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -832,7 +832,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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ASoC: hdac_hda: overwrite hdev type to HDA_DEV_ASOC
  2019-04-27 20:53 [PATCH 1/2] ALSA: hda: fix unregister device twice on ASoC driver Bard liao
@ 2019-04-27 20:53 ` Bard liao
  2019-04-29  7:12   ` Takashi Iwai
  2019-04-29  7:12 ` [PATCH 1/2] ALSA: hda: fix unregister device twice on ASoC driver Takashi Iwai
  1 sibling, 1 reply; 4+ messages in thread
From: Bard liao @ 2019-04-27 20:53 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: liam.r.girdwood, alsa-devel, pierre-louis.bossart, bard.liao

In ASoC driver, snd_hdac_device_register() will be called by
snd_hdac_ext_bus_device_init() and snd_hdac_device_unregister()
will called by snd_hdac_ext_bus_device_remove(). However when
ASoC codec driver call snd_hda_codec_device_new() to create a
new hda codec, it will assign snd_hda_codec_dev_free() to the
dev_free ops and snd_hda_codec_dev_free() will call
snd_hdac_device_unregister(). As a result, snd_hdac_device_unregister()
will be called twice in ASoC driver. To prevent it, we use hdev
type to determine if the hda codec is registered by legacy HDA
driver or ASoC driver and unregister device in  snd_hda_codec_dev_free()
only if it is a legacy HDA device.
This patch will overwrite the hdev type so that we can know it is
a ASoC device.

Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
---
 sound/soc/codecs/hdac_hda.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c
index f889d94c8e3c..7d4940256914 100644
--- 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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ALSA: hda: fix unregister device twice on ASoC driver
  2019-04-27 20:53 [PATCH 1/2] ALSA: hda: fix unregister device twice on ASoC driver Bard liao
  2019-04-27 20:53 ` [PATCH 2/2] ASoC: hdac_hda: overwrite hdev type to HDA_DEV_ASOC Bard liao
@ 2019-04-29  7:12 ` Takashi Iwai
  1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2019-04-29  7:12 UTC (permalink / raw)
  To: Bard liao
  Cc: liam.r.girdwood, alsa-devel, broonie, pierre-louis.bossart, bard.liao

On Sat, 27 Apr 2019 22:53:39 +0200,
Bard liao wrote:
> 
> snd_hda_codec_device_new() is used by both legacy HDA and ASoC
> driver. However, we will call snd_hdac_device_unregister() in
> snd_hdac_ext_bus_device_remove() for ASoC device. This patch uses
> the type flag in hdac_device struct to determine is it a ASoC device
> or legacy HDA device and call snd_hdac_device_unregister() in
> snd_hda_codec_dev_free() only if it is a legacy HDA device.
> 
> Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>

Applied, thanks.


Takashi


> ---
>  sound/pci/hda/hda_codec.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> index 701a69d856f5..b20eb7fc83eb 100644
> --- a/sound/pci/hda/hda_codec.c
> +++ b/sound/pci/hda/hda_codec.c
> @@ -832,7 +832,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;
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] ASoC: hdac_hda: overwrite hdev type to HDA_DEV_ASOC
  2019-04-27 20:53 ` [PATCH 2/2] ASoC: hdac_hda: overwrite hdev type to HDA_DEV_ASOC Bard liao
@ 2019-04-29  7:12   ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2019-04-29  7:12 UTC (permalink / raw)
  To: Bard liao
  Cc: liam.r.girdwood, alsa-devel, broonie, pierre-louis.bossart, bard.liao

On Sat, 27 Apr 2019 22:53:40 +0200,
Bard liao wrote:
> 
> In ASoC driver, snd_hdac_device_register() will be called by
> snd_hdac_ext_bus_device_init() and snd_hdac_device_unregister()
> will called by snd_hdac_ext_bus_device_remove(). However when
> ASoC codec driver call snd_hda_codec_device_new() to create a
> new hda codec, it will assign snd_hda_codec_dev_free() to the
> dev_free ops and snd_hda_codec_dev_free() will call
> snd_hdac_device_unregister(). As a result, snd_hdac_device_unregister()
> will be called twice in ASoC driver. To prevent it, we use hdev
> type to determine if the hda codec is registered by legacy HDA
> driver or ASoC driver and unregister device in  snd_hda_codec_dev_free()
> only if it is a legacy HDA device.
> This patch will overwrite the hdev type so that we can know it is
> a ASoC device.
> 
> Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>

Applied, thanks.


Takashi


> ---
>  sound/soc/codecs/hdac_hda.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c
> index f889d94c8e3c..7d4940256914 100644
> --- 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
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-29  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-27 20:53 [PATCH 1/2] ALSA: hda: fix unregister device twice on ASoC driver Bard liao
2019-04-27 20:53 ` [PATCH 2/2] ASoC: hdac_hda: overwrite hdev type to HDA_DEV_ASOC Bard liao
2019-04-29  7:12   ` Takashi Iwai
2019-04-29  7:12 ` [PATCH 1/2] ALSA: hda: fix unregister device twice on ASoC driver Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.