All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Henningsson <david.henningsson@canonical.com>
To: "Lin, Mengdong" <mengdong.lin@intel.com>
Cc: Takashi Iwai <tiwai@suse.de>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: Re: [PATCH] ALSA: hda - delay resume haswell hdmi codec in system resume
Date: Mon, 08 Apr 2013 11:49:09 +0200	[thread overview]
Message-ID: <51629295.1000701@canonical.com> (raw)
In-Reply-To: <F46914AEC2663F4A9BB62374E5EEF8F83752F5@SHSMSX101.ccr.corp.intel.com>

On 04/07/2013 02:10 AM, Lin, Mengdong wrote:
>> -----Original Message-----
>> From: Takashi Iwai [mailto:tiwai@suse.de]
>> Sent: Saturday, April 06, 2013 1:05 AM
>
>
>>>>> Immediate playback:
>>>>>    1. System skips hda_call_codec_resume and sets
>> codec->resume_delayed.
>>>>>    2. Process context wants to start playback, which powers up the
>>>>> codec and calls intel_haswell_set_power_state.
>>>>>    3. intel_haswell_wait_ready_to_resume enables unsol events and
>>>>> starts to wait on ready_to_resume
>>>>>    4. Gfx init finishes, and workq context fires the unsol event,
>>>>> which calls hdmi_intrinsic_event, which triggers the resume_wq.
>>>>>    5. Process context and workq context now continues in parallel,
>>>>> potentially (but hopefully not) leading to race conditions?
>>>>
>>>> The current patch has a small race, but it can be avoided by
>>>> clearing
>>>> spec->ready_to_resume early enough, e.g. in suspend callback or in
>>>> init callback, like the patch below.
>>>>
>>>
>>> I think there is no race for Haswell. In my test I observed that the
>>> unsol evnet will not be received until intel_haswell_wait_ready_to_resume()
>> enables the unsol event on the pins.
>>> So I put "spec->ready_to_resume = 0" before enabling the unsol event.
>>
>> Practically your patch would work well, but theoretically the unsol event might
>> be issued and handled by hdmi_intrinsic_event() before you go into
>> intel_haswell_wait_ready_to_resume().  That is, you _clear_
>> spec->ready_to_resume again and wait for the unsol event that had been
>> already processed.  That's the race David pointed.
>>
>> The fix is simply not to clear spec->ready_to_resume in
>> intel_haswell_wait_ready_to_resume() but clear it much earlier already before
>> the resume path as my patch does.  Then wait_event() passes immediately
>> (and the unsol enablement of is anyway harmless).
>>
>
> Hi Takashi,
>
> I see. Thanks for clarifying!
>
> I'll revise the patch and test it again when I'm in office on Monday.
> Also I'll rebase the patch to for-next branch of sound git tree and fix the indentations and spaces errors.

I'm still not understanding this patch.

We of course cannot have a situation where HDMI jack detection is not 
correctly working after S3, which looks like would be the case here?

Second, I just saw on a machine we're working on, the symptoms: one of 
the pins in D3 and the right channel muted. And this was on a clean 
boot, not after S3 suspend/resume cycle.

To look at the problem again: If the problem is that something must be 
done on the graphics driver side first and then on the audio side, 
wouldn't the solution be for the video driver and audio driver to 
communicate somehow? And resume (and possibly init?) would not complete 
until first the graphics driver has done its resume, and after that, the 
audio driver. I e, userspace will remain frozen until both drivers have 
completed a correct resume.


-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic

  reply	other threads:[~2013-04-08  9:49 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-26 18:12 [PATCH] ALSA: hda - delay resume haswell hdmi codec in system resume mengdong.lin
2013-03-26  7:02 ` Lin, Mengdong
2013-04-02  9:53   ` Takashi Iwai
2013-04-05 16:58     ` Lin, Mengdong
2013-04-07  7:28       ` Takashi Iwai
2013-03-26 10:58 ` David Henningsson
2013-03-27  2:03   ` Lin, Mengdong
2013-03-27  8:19     ` David Henningsson
2013-03-27 10:01       ` Lin, Mengdong
2013-04-02 11:53         ` David Henningsson
2013-04-02 12:18           ` Takashi Iwai
2013-04-02 12:49             ` David Henningsson
2013-04-05 13:01               ` Takashi Iwai
2013-04-05 13:08                 ` Takashi Iwai
2013-04-05 16:42                 ` Lin, Mengdong
2013-04-05 17:04                   ` Takashi Iwai
2013-04-07  0:10                     ` Lin, Mengdong
2013-04-08  9:49                       ` David Henningsson [this message]
2013-04-08 10:24                         ` Takashi Iwai
2013-04-08 11:06                           ` Lin, Mengdong
2013-04-08 11:35                             ` David Henningsson
2013-04-08 11:59                               ` Takashi Iwai
2013-04-08 12:20                                 ` David Henningsson
2013-04-08 12:23                                   ` Takashi Iwai
2013-04-08 13:30                                     ` David Henningsson
2013-04-08 13:49                                       ` Takashi Iwai
2013-04-08 15:47                                         ` Lin, Mengdong
2013-04-09  6:45                                           ` David Henningsson
2013-04-09  6:53                                             ` Takashi Iwai
2013-04-09  7:10                                               ` David Henningsson
2013-04-09  7:42                                                 ` Takashi Iwai
2013-04-09  8:18                                                   ` Lin, Mengdong
2013-04-09  9:15                                                     ` David Henningsson
2013-04-09  9:26                                                       ` Takashi Iwai
2013-04-10  5:29                                                         ` David Henningsson
2013-04-10  5:47                                                           ` Takashi Iwai
2013-04-10  6:02                                                             ` David Henningsson
2013-04-10  6:52                                                               ` Takashi Iwai
2013-04-10 10:38                                                                 ` David Henningsson
2013-04-14 13:48                                                                   ` Lin, Mengdong
2013-04-15  7:02                                                                     ` David Henningsson
2013-04-15  7:48                                                                       ` Lin, Mengdong
2013-04-17  5:51                                                                         ` David Henningsson
2013-04-17  6:12                                                                           ` Takashi Iwai
2013-05-03  6:56                                                                             ` Lin, Mengdong
2013-05-03  7:20                                                                               ` David Henningsson
2013-05-03  7:30                                                                                 ` Lin, Mengdong
2013-05-06  6:27                                                                                   ` Lin, Mengdong
2013-05-06  7:08                                                                                     ` David Henningsson
2013-05-06  9:48                                                                                       ` Lin, Mengdong
2013-04-05 13:06 ` Takashi Iwai
2013-04-05 13:12 ` Takashi Iwai

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=51629295.1000701@canonical.com \
    --to=david.henningsson@canonical.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=mengdong.lin@intel.com \
    --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.