All of lore.kernel.org
 help / color / mirror / Atom feed
* Timeout issues in wait_for_avail function
@ 2018-05-07 10:49 Zengtao (B)
  2018-05-13 10:40   ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Zengtao (B) @ 2018-05-07 10:49 UTC (permalink / raw)
  To: perex, tiwai; +Cc: alsa-devel, linux-kernel

Hi perex and tiwai:

I have met a timeout case when capture audio from snd-usb-audio device, 
when the host call the pcm_read and get into the wait_for_avail function.
The following happends
1.  No available data for capture(maybe because of the late response audio data by the uac device)
2.  The current thread falls into sleep state and no one wakes up it.
3.  The current thread will sleep 10s(schedule_timeout(1000)) and then wakeup.

I have two question about the wait_for_avail:
1. The timeout value too long, is it a reasonable value? 
2. Is there any mechanism to wake up the thread if there is data from the hw.

Regards
Zengtao

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

* Re: [alsa-devel] Timeout issues in wait_for_avail function
  2018-05-07 10:49 Timeout issues in wait_for_avail function Zengtao (B)
@ 2018-05-13 10:40   ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2018-05-13 10:40 UTC (permalink / raw)
  To: Zengtao (B); +Cc: perex, tiwai, alsa-devel, linux-kernel

On Mon, 07 May 2018 12:49:34 +0200,
Zengtao (B) wrote:
> 
> Hi perex and tiwai:
> 
> I have met a timeout case when capture audio from snd-usb-audio device, 
> when the host call the pcm_read and get into the wait_for_avail function.
> The following happends
> 1.  No available data for capture(maybe because of the late response audio data by the uac device)

Hrm, in the case of capture, the data must be available.
If it's not the case, something is wrong.

> 2.  The current thread falls into sleep state and no one wakes up it.
> 3.  The current thread will sleep 10s(schedule_timeout(1000)) and then wakeup.
> 
> I have two question about the wait_for_avail:
> 1. The timeout value too long, is it a reasonable value? 
> 2. Is there any mechanism to wake up the thread if there is data from the hw.

The scenario above shouldn't happen, so no need for discussion.
Rather we should check why it's woken up even though no data is
available.

You can check the tracepoints to see the action of PCM stream, and
confirm whether it's really no data, or it's just lost by some
reason (or looks as if so).


Takashi

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

* Re: Timeout issues in wait_for_avail function
@ 2018-05-13 10:40   ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2018-05-13 10:40 UTC (permalink / raw)
  To: Zengtao (B); +Cc: linux-kernel, alsa-devel, tiwai

On Mon, 07 May 2018 12:49:34 +0200,
Zengtao (B) wrote:
> 
> Hi perex and tiwai:
> 
> I have met a timeout case when capture audio from snd-usb-audio device, 
> when the host call the pcm_read and get into the wait_for_avail function.
> The following happends
> 1.  No available data for capture(maybe because of the late response audio data by the uac device)

Hrm, in the case of capture, the data must be available.
If it's not the case, something is wrong.

> 2.  The current thread falls into sleep state and no one wakes up it.
> 3.  The current thread will sleep 10s(schedule_timeout(1000)) and then wakeup.
> 
> I have two question about the wait_for_avail:
> 1. The timeout value too long, is it a reasonable value? 
> 2. Is there any mechanism to wake up the thread if there is data from the hw.

The scenario above shouldn't happen, so no need for discussion.
Rather we should check why it's woken up even though no data is
available.

You can check the tracepoints to see the action of PCM stream, and
confirm whether it's really no data, or it's just lost by some
reason (or looks as if so).


Takashi

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

* RE: [alsa-devel] Timeout issues in wait_for_avail function
  2018-05-13 10:40   ` Takashi Iwai
  (?)
@ 2018-05-31  7:43   ` Zengtao (B)
  2018-05-31  8:06       ` Takashi Iwai
  -1 siblings, 1 reply; 6+ messages in thread
From: Zengtao (B) @ 2018-05-31  7:43 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: perex, tiwai, alsa-devel, linux-kernel

Hi Takashi:

Thank you for your reply.

>-----Original Message-----
>From: Takashi Iwai [mailto:tiwai@suse.de]
>Sent: Sunday, May 13, 2018 6:40 PM
>To: Zengtao (B) <prime.zeng@hisilicon.com>
>Cc: perex@perex.cz; tiwai@suse.com; alsa-devel@alsa-project.org;
>linux-kernel@vger.kernel.org
>Subject: Re: [alsa-devel] Timeout issues in wait_for_avail function
>
>On Mon, 07 May 2018 12:49:34 +0200,
>Zengtao (B) wrote:
>>
>> Hi perex and tiwai:
>>
>> I have met a timeout case when capture audio from snd-usb-audio
>> device, when the host call the pcm_read and get into the wait_for_avail
>function.
>> The following happends
>> 1.  No available data for capture(maybe because of the late response
>> audio data by the uac device)
>
>Hrm, in the case of capture, the data must be available.
>If it's not the case, something is wrong.
>
>> 2.  The current thread falls into sleep state and no one wakes up it.
>> 3.  The current thread will sleep 10s(schedule_timeout(1000)) and then
>wakeup.
>>
>> I have two question about the wait_for_avail:
>> 1. The timeout value too long, is it a reasonable value?
>> 2. Is there any mechanism to wake up the thread if there is data from the
>hw.
>
>The scenario above shouldn't happen, so no need for discussion.
>Rather we should check why it's woken up even though no data is available.
>

It really happens on my platform, and anyway 10 seconds timeout seems
not a reasonable value. And I don't there is any guarantee that there must be avail
data when we reach wait_for_avail, in fact, inside the wait_for_avail, there is branch
when no data is available.

>You can check the tracepoints to see the action of PCM stream, and confirm
>whether it's really no data, or it's just lost by some reason (or looks as if so).
>
I trace the data flow, we reach the wait_for_avail function before the usb snd data arrives, 
so we wait until 10 seconds timeout. 

>
>Takashi


Regards
Zengtao 

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

* Re: [alsa-devel] Timeout issues in wait_for_avail function
  2018-05-31  7:43   ` [alsa-devel] " Zengtao (B)
@ 2018-05-31  8:06       ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2018-05-31  8:06 UTC (permalink / raw)
  To: Zengtao (B); +Cc: perex, alsa-devel, linux-kernel

On Thu, 31 May 2018 09:43:10 +0200,
Zengtao (B) wrote:
> 
> Hi Takashi:
> 
> Thank you for your reply.
> 
> >-----Original Message-----
> >From: Takashi Iwai [mailto:tiwai@suse.de]
> >Sent: Sunday, May 13, 2018 6:40 PM
> >To: Zengtao (B) <prime.zeng@hisilicon.com>
> >Cc: perex@perex.cz; tiwai@suse.com; alsa-devel@alsa-project.org;
> >linux-kernel@vger.kernel.org
> >Subject: Re: [alsa-devel] Timeout issues in wait_for_avail function
> >
> >On Mon, 07 May 2018 12:49:34 +0200,
> >Zengtao (B) wrote:
> >>
> >> Hi perex and tiwai:
> >>
> >> I have met a timeout case when capture audio from snd-usb-audio
> >> device, when the host call the pcm_read and get into the wait_for_avail
> >function.
> >> The following happends
> >> 1.  No available data for capture(maybe because of the late response
> >> audio data by the uac device)
> >
> >Hrm, in the case of capture, the data must be available.
> >If it's not the case, something is wrong.
> >
> >> 2.  The current thread falls into sleep state and no one wakes up it.
> >> 3.  The current thread will sleep 10s(schedule_timeout(1000)) and then
> >wakeup.
> >>
> >> I have two question about the wait_for_avail:
> >> 1. The timeout value too long, is it a reasonable value?
> >> 2. Is there any mechanism to wake up the thread if there is data from the
> >hw.
> >
> >The scenario above shouldn't happen, so no need for discussion.
> >Rather we should check why it's woken up even though no data is available.
> >
> 
> It really happens on my platform, and anyway 10 seconds timeout seems
> not a reasonable value.

The timeout isn't about guaranteeing anything.  It's merely a
last-resort safeguard.  So it *has to* be long, per definition.

That is, if you hit this timeout, it means that something is already
wrong.  In that case, fix the real cause instead of tweaking the
timeout.


Takashi

> And I don't there is any guarantee that there must be avail
> data when we reach wait_for_avail, in fact, inside the wait_for_avail, there is branch
> when no data is available.
> 
> >You can check the tracepoints to see the action of PCM stream, and confirm
> >whether it's really no data, or it's just lost by some reason (or looks as if so).
> >
> I trace the data flow, we reach the wait_for_avail function before the usb snd data arrives, 
> so we wait until 10 seconds timeout. 
> 
> >
> >Takashi
> 
> 
> Regards
> Zengtao 

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

* Re: Timeout issues in wait_for_avail function
@ 2018-05-31  8:06       ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2018-05-31  8:06 UTC (permalink / raw)
  To: Zengtao (B); +Cc: alsa-devel, linux-kernel

On Thu, 31 May 2018 09:43:10 +0200,
Zengtao (B) wrote:
> 
> Hi Takashi:
> 
> Thank you for your reply.
> 
> >-----Original Message-----
> >From: Takashi Iwai [mailto:tiwai@suse.de]
> >Sent: Sunday, May 13, 2018 6:40 PM
> >To: Zengtao (B) <prime.zeng@hisilicon.com>
> >Cc: perex@perex.cz; tiwai@suse.com; alsa-devel@alsa-project.org;
> >linux-kernel@vger.kernel.org
> >Subject: Re: [alsa-devel] Timeout issues in wait_for_avail function
> >
> >On Mon, 07 May 2018 12:49:34 +0200,
> >Zengtao (B) wrote:
> >>
> >> Hi perex and tiwai:
> >>
> >> I have met a timeout case when capture audio from snd-usb-audio
> >> device, when the host call the pcm_read and get into the wait_for_avail
> >function.
> >> The following happends
> >> 1.  No available data for capture(maybe because of the late response
> >> audio data by the uac device)
> >
> >Hrm, in the case of capture, the data must be available.
> >If it's not the case, something is wrong.
> >
> >> 2.  The current thread falls into sleep state and no one wakes up it.
> >> 3.  The current thread will sleep 10s(schedule_timeout(1000)) and then
> >wakeup.
> >>
> >> I have two question about the wait_for_avail:
> >> 1. The timeout value too long, is it a reasonable value?
> >> 2. Is there any mechanism to wake up the thread if there is data from the
> >hw.
> >
> >The scenario above shouldn't happen, so no need for discussion.
> >Rather we should check why it's woken up even though no data is available.
> >
> 
> It really happens on my platform, and anyway 10 seconds timeout seems
> not a reasonable value.

The timeout isn't about guaranteeing anything.  It's merely a
last-resort safeguard.  So it *has to* be long, per definition.

That is, if you hit this timeout, it means that something is already
wrong.  In that case, fix the real cause instead of tweaking the
timeout.


Takashi

> And I don't there is any guarantee that there must be avail
> data when we reach wait_for_avail, in fact, inside the wait_for_avail, there is branch
> when no data is available.
> 
> >You can check the tracepoints to see the action of PCM stream, and confirm
> >whether it's really no data, or it's just lost by some reason (or looks as if so).
> >
> I trace the data flow, we reach the wait_for_avail function before the usb snd data arrives, 
> so we wait until 10 seconds timeout. 
> 
> >
> >Takashi
> 
> 
> Regards
> Zengtao 

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

end of thread, other threads:[~2018-05-31  8:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-07 10:49 Timeout issues in wait_for_avail function Zengtao (B)
2018-05-13 10:40 ` [alsa-devel] " Takashi Iwai
2018-05-13 10:40   ` Takashi Iwai
2018-05-31  7:43   ` [alsa-devel] " Zengtao (B)
2018-05-31  8:06     ` Takashi Iwai
2018-05-31  8: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.