All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
@ 2019-04-12  2:40 libin.yang
  2019-04-12  3:00 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 9+ messages in thread
From: libin.yang @ 2019-04-12  2:40 UTC (permalink / raw)
  To: alsa-devel, tiwai, broonie; +Cc: libin.yang, pierre-louis.bossart

From: Libin Yang <libin.yang@intel.com>

In resume from S3, HDAC HDMI codec driver dapm event callback may be
operated before HDMI codec driver turns on the display audio power
domain because of the contest between display driver and hdmi codec driver.

This patch adds the device_link between soc card device (consumer) and
hdmi codec device (supplier) to make sure the sequence is always correct.

Signed-off-by: Libin Yang <libin.yang@intel.com>
---
 sound/soc/codecs/hdac_hdmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 5eeb0fe..8bb883e 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1855,6 +1855,15 @@ static int hdmi_codec_probe(struct snd_soc_component *component)
 	hdmi->card = dapm->card->snd_card;
 
 	/*
+	 * Setup a device_link between card device and HDMI codec device.
+	 * The card device is the consumer and the HDMI codec device is
+	 * the supplier. With this setting, we can make sure that the audio
+	 * domain in display power will be always turned on before operating
+	 * on the HDMI audio codec registers.
+	 */
+	device_link_add(component->card->dev, &hdev->dev, DL_FLAG_RPM_ACTIVE |
+			DL_FLAG_AUTOREMOVE_CONSUMER);
+	/*
 	 * hdac_device core already sets the state to active and calls
 	 * get_noresume. So enable runtime and set the device to suspend.
 	 */
-- 
2.7.4

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

* Re: [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
  2019-04-12  2:40 [PATCH] ASoC: codec: hdac_hdmi add device_link to card device libin.yang
@ 2019-04-12  3:00 ` Pierre-Louis Bossart
  2019-04-12  3:04   ` Yang, Libin
  0 siblings, 1 reply; 9+ messages in thread
From: Pierre-Louis Bossart @ 2019-04-12  3:00 UTC (permalink / raw)
  To: libin.yang, alsa-devel, tiwai, broonie

On 4/11/19 9:40 PM, libin.yang@intel.com wrote:
> From: Libin Yang <libin.yang@intel.com>
> 
> In resume from S3, HDAC HDMI codec driver dapm event callback may be
> operated before HDMI codec driver turns on the display audio power
> domain because of the contest between display driver and hdmi codec driver.
> 
> This patch adds the device_link between soc card device (consumer) and
> hdmi codec device (supplier) to make sure the sequence is always correct.
> 
> Signed-off-by: Libin Yang <libin.yang@intel.com>
> ---
>   sound/soc/codecs/hdac_hdmi.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
> index 5eeb0fe..8bb883e 100644
> --- a/sound/soc/codecs/hdac_hdmi.c
> +++ b/sound/soc/codecs/hdac_hdmi.c
> @@ -1855,6 +1855,15 @@ static int hdmi_codec_probe(struct snd_soc_component *component)
>   	hdmi->card = dapm->card->snd_card;
>   
>   	/*
> +	 * Setup a device_link between card device and HDMI codec device.
> +	 * The card device is the consumer and the HDMI codec device is
> +	 * the supplier. With this setting, we can make sure that the audio
> +	 * domain in display power will be always turned on before operating
> +	 * on the HDMI audio codec registers.
> +	 */
> +	device_link_add(component->card->dev, &hdev->dev, DL_FLAG_RPM_ACTIVE |
> +			DL_FLAG_AUTOREMOVE_CONSUMER);

Should device_link_free() be added to hdmi_codec_remove then?
Thanks!

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

* Re: [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
  2019-04-12  3:00 ` Pierre-Louis Bossart
@ 2019-04-12  3:04   ` Yang, Libin
  2019-04-12 13:51     ` Pierre-Louis Bossart
  0 siblings, 1 reply; 9+ messages in thread
From: Yang, Libin @ 2019-04-12  3:04 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel, tiwai, broonie

Hi Pierre,

>-----Original Message-----
>From: Pierre-Louis Bossart [mailto:pierre-louis.bossart@linux.intel.com]
>Sent: Friday, April 12, 2019 11:00 AM
>To: Yang, Libin <libin.yang@intel.com>; alsa-devel@alsa-project.org;
>tiwai@suse.de; broonie@kernel.org
>Subject: Re: [alsa-devel] [PATCH] ASoC: codec: hdac_hdmi add device_link to
>card device
>
>On 4/11/19 9:40 PM, libin.yang@intel.com wrote:
>> From: Libin Yang <libin.yang@intel.com>
>>
>> In resume from S3, HDAC HDMI codec driver dapm event callback may be
>> operated before HDMI codec driver turns on the display audio power
>> domain because of the contest between display driver and hdmi codec
>driver.
>>
>> This patch adds the device_link between soc card device (consumer) and
>> hdmi codec device (supplier) to make sure the sequence is always correct.
>>
>> Signed-off-by: Libin Yang <libin.yang@intel.com>
>> ---
>>   sound/soc/codecs/hdac_hdmi.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/sound/soc/codecs/hdac_hdmi.c
>> b/sound/soc/codecs/hdac_hdmi.c index 5eeb0fe..8bb883e 100644
>> --- a/sound/soc/codecs/hdac_hdmi.c
>> +++ b/sound/soc/codecs/hdac_hdmi.c
>> @@ -1855,6 +1855,15 @@ static int hdmi_codec_probe(struct
>snd_soc_component *component)
>>   	hdmi->card = dapm->card->snd_card;
>>
>>   	/*
>> +	 * Setup a device_link between card device and HDMI codec device.
>> +	 * The card device is the consumer and the HDMI codec device is
>> +	 * the supplier. With this setting, we can make sure that the audio
>> +	 * domain in display power will be always turned on before operating
>> +	 * on the HDMI audio codec registers.
>> +	 */
>> +	device_link_add(component->card->dev, &hdev->dev,
>DL_FLAG_RPM_ACTIVE |
>> +			DL_FLAG_AUTOREMOVE_CONSUMER);
>
>Should device_link_free() be added to hdmi_codec_remove then?

As Takashi suggested, I add the DL_FLAG_AUTOREMOVE_CONSUMER flag.
This will make sure the link will be freed when machine driver are removed.
And as machine driver depends on the hdac_hdmi module, when
hdmi_codec_remove() is called, the link is freed already.

Regards,
Libin

>Thanks!

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

* Re: [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
  2019-04-12  3:04   ` Yang, Libin
@ 2019-04-12 13:51     ` Pierre-Louis Bossart
  2019-04-12 13:54       ` Yang, Libin
  2019-04-12 14:33       ` Yang, Libin
  0 siblings, 2 replies; 9+ messages in thread
From: Pierre-Louis Bossart @ 2019-04-12 13:51 UTC (permalink / raw)
  To: Yang, Libin, alsa-devel, tiwai, broonie


>>> +	device_link_add(component->card->dev, &hdev->dev,
>> DL_FLAG_RPM_ACTIVE |
>>> +			DL_FLAG_AUTOREMOVE_CONSUMER);
>>
>> Should device_link_free() be added to hdmi_codec_remove then?
> 
> As Takashi suggested, I add the DL_FLAG_AUTOREMOVE_CONSUMER flag.
> This will make sure the link will be freed when machine driver are removed.
> And as machine driver depends on the hdac_hdmi module, when
> hdmi_codec_remove() is called, the link is freed already.

ok, maybe adding a comment would help dummies like me who didn't know 
about this flag? Thanks!

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

* Re: [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
  2019-04-12 13:51     ` Pierre-Louis Bossart
@ 2019-04-12 13:54       ` Yang, Libin
  2019-04-12 14:33       ` Yang, Libin
  1 sibling, 0 replies; 9+ messages in thread
From: Yang, Libin @ 2019-04-12 13:54 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel, tiwai, broonie

Hi Pierre,

>-----Original Message-----
>From: Pierre-Louis Bossart [mailto:pierre-louis.bossart@linux.intel.com]
>Sent: Friday, April 12, 2019 9:52 PM
>To: Yang, Libin <libin.yang@intel.com>; alsa-devel@alsa-project.org;
>tiwai@suse.de; broonie@kernel.org
>Subject: Re: [alsa-devel] [PATCH] ASoC: codec: hdac_hdmi add device_link to
>card device
>
>
>>>> +	device_link_add(component->card->dev, &hdev->dev,
>>> DL_FLAG_RPM_ACTIVE |
>>>> +			DL_FLAG_AUTOREMOVE_CONSUMER);
>>>
>>> Should device_link_free() be added to hdmi_codec_remove then?
>>
>> As Takashi suggested, I add the DL_FLAG_AUTOREMOVE_CONSUMER flag.
>> This will make sure the link will be freed when machine driver are removed.
>> And as machine driver depends on the hdac_hdmi module, when
>> hdmi_codec_remove() is called, the link is freed already.
>
>ok, maybe adding a comment would help dummies like me who didn't know
>about this flag? Thanks!

Thanks for suggestion. I will add the comment.

Regards,
Libin

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

* Re: [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
  2019-04-12 13:51     ` Pierre-Louis Bossart
  2019-04-12 13:54       ` Yang, Libin
@ 2019-04-12 14:33       ` Yang, Libin
  2019-04-12 15:02         ` Pierre-Louis Bossart
  1 sibling, 1 reply; 9+ messages in thread
From: Yang, Libin @ 2019-04-12 14:33 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel, tiwai, broonie

>>
>>>>> +	device_link_add(component->card->dev, &hdev->dev,
>>>> DL_FLAG_RPM_ACTIVE |
>>>>> +			DL_FLAG_AUTOREMOVE_CONSUMER);
>>>>
>>>> Should device_link_free() be added to hdmi_codec_remove then?
>>>
>>> As Takashi suggested, I add the DL_FLAG_AUTOREMOVE_CONSUMER flag.
>>> This will make sure the link will be freed when machine driver are removed.
>>> And as machine driver depends on the hdac_hdmi module, when
>>> hdmi_codec_remove() is called, the link is freed already.
>>
>>ok, maybe adding a comment would help dummies like me who didn't know
>>about this flag? Thanks!
>
>Thanks for suggestion. I will add the comment.

After a second thought, is there any possibility that the machine driver does
not depend on the hdac_hdmi module? I checked our current driver,
there is the dependency between machine driver and hdac_hdmi module.

Regards,
Libin

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

* Re: [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
  2019-04-12 14:33       ` Yang, Libin
@ 2019-04-12 15:02         ` Pierre-Louis Bossart
  2019-04-12 23:00           ` Yang, Libin
  0 siblings, 1 reply; 9+ messages in thread
From: Pierre-Louis Bossart @ 2019-04-12 15:02 UTC (permalink / raw)
  To: Yang, Libin, alsa-devel, tiwai, broonie



On 4/12/19 9:33 AM, Yang, Libin wrote:
>>>
>>>>>> +	device_link_add(component->card->dev, &hdev->dev,
>>>>> DL_FLAG_RPM_ACTIVE |
>>>>>> +			DL_FLAG_AUTOREMOVE_CONSUMER);
>>>>>
>>>>> Should device_link_free() be added to hdmi_codec_remove then?
>>>>
>>>> As Takashi suggested, I add the DL_FLAG_AUTOREMOVE_CONSUMER flag.
>>>> This will make sure the link will be freed when machine driver are removed.
>>>> And as machine driver depends on the hdac_hdmi module, when
>>>> hdmi_codec_remove() is called, the link is freed already.
>>>
>>> ok, maybe adding a comment would help dummies like me who didn't know
>>> about this flag? Thanks!
>>
>> Thanks for suggestion. I will add the comment.
> 
> After a second thought, is there any possibility that the machine driver does
> not depend on the hdac_hdmi module? I checked our current driver,
> there is the dependency between machine driver and hdac_hdmi module.

I don't get your question.
All machine drivers supporting the iDISP link explicitly use a select 
HDAC_HDMI in the Kconfig and refer to DAIs created/exposed by the 
hdac_hdmi module.
It's possible that the hdac_hdmi codec is probed as a result of the 
platform driver configuration but the machine driver does not support 
HDMI. In that case, is there any issue with your solution?

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

* Re: [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
  2019-04-12 15:02         ` Pierre-Louis Bossart
@ 2019-04-12 23:00           ` Yang, Libin
  2019-04-13  6:06             ` Takashi Iwai
  0 siblings, 1 reply; 9+ messages in thread
From: Yang, Libin @ 2019-04-12 23:00 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel, tiwai, broonie

Hi Pierre,

>-----Original Message-----
>From: Pierre-Louis Bossart [mailto:pierre-louis.bossart@linux.intel.com]
>Sent: Friday, April 12, 2019 11:03 PM
>To: Yang, Libin <libin.yang@intel.com>; alsa-devel@alsa-project.org;
>tiwai@suse.de; broonie@kernel.org
>Subject: Re: [alsa-devel] [PATCH] ASoC: codec: hdac_hdmi add device_link to
>card device
>
>
>
>On 4/12/19 9:33 AM, Yang, Libin wrote:
>>>>
>>>>>>> +	device_link_add(component->card->dev, &hdev->dev,
>>>>>> DL_FLAG_RPM_ACTIVE |
>>>>>>> +			DL_FLAG_AUTOREMOVE_CONSUMER);
>>>>>>
>>>>>> Should device_link_free() be added to hdmi_codec_remove then?
>>>>>
>>>>> As Takashi suggested, I add the DL_FLAG_AUTOREMOVE_CONSUMER
>flag.
>>>>> This will make sure the link will be freed when machine driver are
>removed.
>>>>> And as machine driver depends on the hdac_hdmi module, when
>>>>> hdmi_codec_remove() is called, the link is freed already.
>>>>
>>>> ok, maybe adding a comment would help dummies like me who didn't
>>>> know about this flag? Thanks!
>>>
>>> Thanks for suggestion. I will add the comment.
>>
>> After a second thought, is there any possibility that the machine
>> driver does not depend on the hdac_hdmi module? I checked our current
>> driver, there is the dependency between machine driver and hdac_hdmi
>module.
>
>I don't get your question.
>All machine drivers supporting the iDISP link explicitly use a select
>HDAC_HDMI in the Kconfig and refer to DAIs created/exposed by the
>hdac_hdmi module.

So the dependency should always exists. I have checked all the machine
drivers and they all depends on the hdac_hdmi if they are using it.

>It's possible that the hdac_hdmi codec is probed as a result of the platform
>driver configuration but the machine driver does not support HDMI. In that
>case, is there any issue with your solution?

If machine driver doesn't support HDMI, component will never be called.
It is safe.

Hi Takashi,

My patch doesn't use component->init() as you suggested. But they should
be similar. Are you OK with this patch?

Regards,
Libin

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

* Re: [PATCH] ASoC: codec: hdac_hdmi add device_link to card device
  2019-04-12 23:00           ` Yang, Libin
@ 2019-04-13  6:06             ` Takashi Iwai
  0 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2019-04-13  6:06 UTC (permalink / raw)
  To: Yang, Libin; +Cc: alsa-devel, broonie, Pierre-Louis Bossart

On Sat, 13 Apr 2019 01:00:38 +0200,
Yang, Libin wrote:
> 
> Hi Pierre,
> 
> >-----Original Message-----
> >From: Pierre-Louis Bossart [mailto:pierre-louis.bossart@linux.intel.com]
> >Sent: Friday, April 12, 2019 11:03 PM
> >To: Yang, Libin <libin.yang@intel.com>; alsa-devel@alsa-project.org;
> >tiwai@suse.de; broonie@kernel.org
> >Subject: Re: [alsa-devel] [PATCH] ASoC: codec: hdac_hdmi add device_link to
> >card device
> >
> >
> >
> >On 4/12/19 9:33 AM, Yang, Libin wrote:
> >>>>
> >>>>>>> +	device_link_add(component->card->dev, &hdev->dev,
> >>>>>> DL_FLAG_RPM_ACTIVE |
> >>>>>>> +			DL_FLAG_AUTOREMOVE_CONSUMER);
> >>>>>>
> >>>>>> Should device_link_free() be added to hdmi_codec_remove then?
> >>>>>
> >>>>> As Takashi suggested, I add the DL_FLAG_AUTOREMOVE_CONSUMER
> >flag.
> >>>>> This will make sure the link will be freed when machine driver are
> >removed.
> >>>>> And as machine driver depends on the hdac_hdmi module, when
> >>>>> hdmi_codec_remove() is called, the link is freed already.
> >>>>
> >>>> ok, maybe adding a comment would help dummies like me who didn't
> >>>> know about this flag? Thanks!
> >>>
> >>> Thanks for suggestion. I will add the comment.
> >>
> >> After a second thought, is there any possibility that the machine
> >> driver does not depend on the hdac_hdmi module? I checked our current
> >> driver, there is the dependency between machine driver and hdac_hdmi
> >module.
> >
> >I don't get your question.
> >All machine drivers supporting the iDISP link explicitly use a select
> >HDAC_HDMI in the Kconfig and refer to DAIs created/exposed by the
> >hdac_hdmi module.
> 
> So the dependency should always exists. I have checked all the machine
> drivers and they all depends on the hdac_hdmi if they are using it.
> 
> >It's possible that the hdac_hdmi codec is probed as a result of the platform
> >driver configuration but the machine driver does not support HDMI. In that
> >case, is there any issue with your solution?
> 
> If machine driver doesn't support HDMI, component will never be called.
> It is safe.
> 
> Hi Takashi,
> 
> My patch doesn't use component->init() as you suggested. But they should
> be similar. Are you OK with this patch?

Yes.


Takashi

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

end of thread, other threads:[~2019-04-13  6:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12  2:40 [PATCH] ASoC: codec: hdac_hdmi add device_link to card device libin.yang
2019-04-12  3:00 ` Pierre-Louis Bossart
2019-04-12  3:04   ` Yang, Libin
2019-04-12 13:51     ` Pierre-Louis Bossart
2019-04-12 13:54       ` Yang, Libin
2019-04-12 14:33       ` Yang, Libin
2019-04-12 15:02         ` Pierre-Louis Bossart
2019-04-12 23:00           ` Yang, Libin
2019-04-13  6:06             ` 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.