From: David Henningsson <david.henningsson@canonical.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, 1040030@bugs.launchpad.net
Subject: Re: [PATCH] ALSA: hda - fix broken HDMI jack detection after S3
Date: Wed, 22 Aug 2012 16:27:35 +0200 [thread overview]
Message-ID: <5034EC57.2090503@canonical.com> (raw)
In-Reply-To: <s5hmx1nyqxx.wl%tiwai@suse.de>
On 08/22/2012 03:52 PM, Takashi Iwai wrote:
> At Wed, 22 Aug 2012 15:46:59 +0200,
> David Henningsson wrote:
>>
>> On 08/22/2012 02:58 PM, Takashi Iwai wrote:
>>> At Wed, 22 Aug 2012 14:39:17 +0200,
>>> David Henningsson wrote:
>>>>
>>>> On 08/22/2012 02:22 PM, Takashi Iwai wrote:
>>>>> At Wed, 22 Aug 2012 14:01:41 +0200,
>>>>> David Henningsson wrote:
>>>>>>
>>>>>> The HDMI codec (an NVIDIA one in this case) forgot that its pins
>>>>>> were unsol enabled, while it was suspended. Therefore jack detection
>>>>>> was broken after S3.
>>>>>> With this patch, we reenable the unsol events on resume,
>>>>>> and also do an extra check afterwards, to see if the HDMI monitor was
>>>>>> plugged/unplugged while in S3.
>>>>>>
>>>>>> Cc: stable@kernel.org (3.3+)
>>>>>> BugLink: https://bugs.launchpad.net/bugs/1040030
>>>>>> Signed-off-by: David Henningsson <david.henningsson@canonical.com>
>>>>>> ---
>>>>>> sound/pci/hda/patch_hdmi.c | 13 +++++++++++++
>>>>>> 1 file changed, 13 insertions(+)
>>>>>>
>>>>>> diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
>>>>>> index 8f23374..6a3ac05 100644
>>>>>> --- a/sound/pci/hda/patch_hdmi.c
>>>>>> +++ b/sound/pci/hda/patch_hdmi.c
>>>>>> @@ -1315,6 +1315,16 @@ static int generic_hdmi_init(struct hda_codec *codec)
>>>>>> return 0;
>>>>>> }
>>>>>>
>>>>>> +#ifdef CONFIG_PM
>>>>>> +static int generic_hdmi_resume(struct hda_codec *codec)
>>>>>> +{
>>>>>> + snd_hda_codec_resume_cache(codec);
>>>>>> + snd_hda_jack_set_dirty_all(codec);
>>>>>> + snd_hda_jack_report_sync(codec);
>>>>>> + return 0;
>>>>>
>>>>> Hm, is this really needed?
>>>>>
>>>>> snd_hda_jack_set_dirty_all() is already called in
>>>>> hda_call_codec_resume(), and snd_hda_jack_report_sync() is called in
>>>>> the init callback.
>>>>
>>>> The tester (who has the hardware) has gone for the day, so I can't
>>>> really verify different scenarios right now, but after having looked at
>>>> hda_call_codec_resume I see what you mean...
>>>>
>>>> I do notice one difference though - the order.
>>>> snd_hda_codec_resume_cache, which is what writes the unsol_enable verbs,
>>>> should probably be before the set_dirty_all / report_sync. If not for
>>>> anything else, so for the race condition of somebody plugging/unplugging
>>>> the monitor after checking the jack but before the unsol is enabled.
>>>
>>> Calling snd_hda_jack_report_sync() in init means that all jacks are
>>> checked at first, then the caches are resumed. So this won't change
>>> ENABLE_UNSOL verb setups.
>>
>> I'm not sure I'm following. Here's the order in hda_call_codec_resume:
>>
>> snd_hda_jack_set_dirty_all()
>> generic_hdmi_init -> snd_hda_jack_report_sync() - get_pin_sense
>> snd_hda_codec_resume_cache() - set_unsol_enable
>>
>> With the (theoretical?) race condition being a change of pin sense
>> between snd_hda_jack_report_sync() and snd_hda_codec_resume_cache(),
>> which will not be picked up.
>
> In that race, yes. But this should be irrelevant with this bug :)
Yes, the bug needs further verification.
>> The patch changed the order to:
>>
>> snd_hda_codec_resume_cache() - set_unsol_enable
>> snd_hda_jack_set_dirty_all()
>> snd_hda_jack_report_sync() - get_pin_sense
>>
>> Which eliminates that race condition.
>
> Well, what I'm thinking now is rather to call
> snd_hda_jack_report_sync() generically in hda_call_codec_resume().
> The call doesn't have to be in all places.
> Ditto for the initialization case. It'll clean up many lines.
Fine with me - the more code being generic, the better.
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
next prev parent reply other threads:[~2012-08-22 14:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-22 12:01 [PATCH] ALSA: hda - fix broken HDMI jack detection after S3 David Henningsson
2012-08-22 12:22 ` Takashi Iwai
2012-08-22 12:39 ` David Henningsson
2012-08-22 12:58 ` Takashi Iwai
2012-08-22 13:46 ` David Henningsson
2012-08-22 13:52 ` Takashi Iwai
2012-08-22 14:27 ` David Henningsson [this message]
2012-08-22 14:49 ` Takashi Iwai
2012-08-22 17:00 ` David Henningsson
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=5034EC57.2090503@canonical.com \
--to=david.henningsson@canonical.com \
--cc=1040030@bugs.launchpad.net \
--cc=alsa-devel@alsa-project.org \
--cc=tiwai@suse.de \
/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 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.