All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, clemens@ladisch.de
Subject: Re: [PATCH v2 1/3] ALSA: pcm: add snd_pcm_period_elapsed() variant without acquiring lock of PCM substream
Date: Thu, 10 Jun 2021 17:05:21 +0900	[thread overview]
Message-ID: <20210610080521.GA84899@workstation> (raw)
In-Reply-To: <s5h1r9ab22u.wl-tiwai@suse.de>

On Thu, Jun 10, 2021 at 09:39:37AM +0200, Takashi Iwai wrote:
> On Thu, 10 Jun 2021 01:16:23 +0200,
> Takashi Sakamoto wrote:
> > 
> > On Wed, Jun 09, 2021 at 05:27:29PM +0200, Takashi Iwai wrote:
> > > On Wed, 09 Jun 2021 16:31:43 +0200,
> > > Takashi Sakamoto wrote:
> > > > diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
> > > > index b7e3d8f44511..3488ec1e3674 100644
> > > > --- a/sound/core/pcm_lib.c
> > > > +++ b/sound/core/pcm_lib.c
> > > > @@ -1778,27 +1778,41 @@ int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream,
> > > >  EXPORT_SYMBOL(snd_pcm_lib_ioctl);
> > > >  
> > > >  /**
> > > > - * snd_pcm_period_elapsed - update the pcm status for the next period
> > > > - * @substream: the pcm substream instance
> > > > + * snd_pcm_period_elapsed_under_stream_lock() - update the status of runtime for the next period
> > > > + *						under acquired lock of PCM substream.
> > > > + * @substream: the instance of pcm substream.
> > > > + *
> > > > + * This function is called when the batch of audio data frames as the same size as the period of
> > > > + * buffer is already processed in audio data transmission.
> > > > + *
> > > > + * The call of function updates the status of runtime with the latest position of audio data
> > > > + * transmission, checks overrun and underrun over buffer, awaken user processes from waiting for
> > > > + * available audio data frames, sampling audio timestamp, and performs stop or drain the PCM
> > > > + * substream according to configured threshold.
> > > > + *
> > > > + * The function is intended to use for the case that PCM driver operates audio data frames under
> > > > + * acquired lock of PCM substream; e.g. in callback of any operation of &snd_pcm_ops in process
> > > > + * context. In any interrupt context, it's preferrable to use ``snd_pcm_period_elapsed()`` instead
> > > > + * since lock of PCM substream should be acquired in advance.
> > > >   *
> > > > - * This function is called from the interrupt handler when the
> > > > - * PCM has processed the period size.  It will update the current
> > > > - * pointer, wake up sleepers, etc.
> > > > + * Developer should pay enough attention that some callbacks in &snd_pcm_ops are done by the call of
> > > > + * function:
> > > >   *
> > > > - * Even if more than one periods have elapsed since the last call, you
> > > > - * have to call this only once.
> > > > + * - .pointer - to retrieve current position of audio data transmission by frame count or XRUN state.
> > > > + * - .trigger - with SNDRV_PCM_TRIGGER_STOP at XRUN or DRAINING state.
> > > > + * - .get_time_info - to retrieve audio time stamp if needed.
> > > > + *
> > > > + * Even if more than one periods have elapsed since the last call, you have to call this only once.
> > > > + *
> > > > + * Context: Any context in which lock of PCM substream is already acquired. This function may not
> > > > + * sleep.
> > > 
> > > Hm, this text still remains here.  Overlooked?
> > 
> > It's my intension for documentation of
> > snd_pcm_period_elapsed_under_stream_lock() since it's expected to call
> > it under acquired lock. Its implementation doesn't yield processor
> > voluntarily by itself. If it yielded, it would depend on implementation
> > of each driver for struct snd_pcm_ops.{pointer, trigger, get_time_info},
> > but it's not preferable implementation of driver, in my opinion.
> 
> My point is again about the sleep.  This function may sleep in the
> nonatomic mode.  The type of the PCM stream lock depends on it.

Would I simply request you to show how the added function yields except
for the driver implementation? The lock of stream is expected to be
acquired already.


Regards

Takashi Sakamoto

  reply	other threads:[~2021-06-10  8:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 14:31 [PATCH v2 0/3] ALSA: pcm:firewire: allow to operate for period elapse event in process context Takashi Sakamoto
2021-06-09 14:31 ` [PATCH v2 1/3] ALSA: pcm: add snd_pcm_period_elapsed() variant without acquiring lock of PCM substream Takashi Sakamoto
2021-06-09 15:27   ` Takashi Iwai
2021-06-09 23:16     ` Takashi Sakamoto
2021-06-10  7:39       ` Takashi Iwai
2021-06-10  8:05         ` Takashi Sakamoto [this message]
2021-06-10  8:08           ` Takashi Iwai
2021-06-10  8:26             ` Takashi Sakamoto
2021-06-10  8:36               ` Takashi Iwai
2021-06-10 10:12                 ` Takashi Sakamoto
2021-06-10 11:03                   ` Takashi Iwai
2021-06-11  3:38                     ` Takashi Sakamoto
2021-06-11  6:47                       ` Takashi Iwai
2021-06-11  7:07                         ` Takashi Sakamoto
2021-06-11  7:31                           ` Takashi Iwai
2021-06-09 14:31 ` [PATCH v2 2/3] ALSA: firewire-lib: operate for period elapse event in process context Takashi Sakamoto
2021-06-09 14:31 ` [PATCH v2 3/3] ALSA: firewire-lib: obsolete workqueue for period update Takashi Sakamoto

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=20210610080521.GA84899@workstation \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --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.