All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Introduce userspace-driven ALSA timers
@ 2024-07-26  7:47 Ivan Orlov
  2024-07-26  7:47 ` [PATCH 1/4] ALSA: aloop: Allow using global timers Ivan Orlov
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Ivan Orlov @ 2024-07-26  7:47 UTC (permalink / raw)
  To: perex, tiwai, corbet, broonie, shuah
  Cc: Ivan Orlov, linux-kselftest, linux-doc, linux-sound, linux-kernel,
	aholzinger

There are multiple possible timer sources which could be useful for
the sound stream synchronization: hrtimers, hardware clocks (e.g. PTP),
timer wheels (jiffies). Currently, using one of them to synchronize
the audio stream of snd-aloop module would require writing a
kernel-space driver which exports an ALSA timer through the
snd_timer interface.

However, it is not really convenient for application developers, who may
want to define their custom timer sources for audio synchronization.

For instance, we could have a network application which receives frames
and sends them to snd-aloop pcm device, and another application
listening on the other end of snd-aloop. It makes sense to transfer a
new period of data only when certain amount of frames is received
through the network, but definitely not when a certain amount of jiffies
on a local system elapses. Since all of the devices are purely virtual
it won't introduce any glitches and will help the application developers
to avoid using sample-rate conversion.

This patch series introduces userspace-driven ALSA timers: virtual
timers which are created and controlled from userspace. The timer can
be created from the userspace using the new ioctl SNDRV_TIMER_IOCTL_CREATE.
After creating a timer, it becomes available for use system-wide, so it
can be passed to snd-aloop as a timer source (timer_source parameter
would be "-1.SNDRV_TIMER_GLOBAL_UDRIVEN.{timer_id}"). When the userspace
app decides to trigger a timer, it calls another ioctl
SNDRV_TIMER_IOCTL_TRIGGER on the file descriptor of a timer. It
initiates a transfer of a new period of data.

Userspace-driven timers are associated with file descriptors. If the
application wishes to destroy the timer, it can simply release the file
descriptor of a virtual timer.

I believe introducing new ioctl calls is quite inconvenient (as we have
a limited amount of them), but other possible ways of app <-> kernel
communication (like virtual FS) seem completely inappropriate for this
task (but I'd love to discuss alternative solutions).

This patch series also updates the snd-aloop module so the global timers
can be used as a timer_source for it (it allows using userspace-driven
timers as timer source).

Ivan Orlov (4):
  ALSA: aloop: Allow using global timers
  Docs/sound: Add documentation for userspace-driven ALSA timers
  ALSA: timer: Introduce virtual userspace-driven timers
  selftests: ALSA: Cover userspace-driven timers with test

 Documentation/sound/index.rst               |   1 +
 Documentation/sound/utimers.rst             | 120 +++++++++++
 include/uapi/sound/asound.h                 |  17 ++
 sound/core/Kconfig                          |  11 +
 sound/core/timer.c                          | 226 ++++++++++++++++++++
 sound/drivers/aloop.c                       |   2 +
 tools/testing/selftests/alsa/Makefile       |   2 +-
 tools/testing/selftests/alsa/global-timer.c |  87 ++++++++
 tools/testing/selftests/alsa/utimer-test.c  | 133 ++++++++++++
 9 files changed, 598 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/sound/utimers.rst
 create mode 100644 tools/testing/selftests/alsa/global-timer.c
 create mode 100644 tools/testing/selftests/alsa/utimer-test.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: [PATCH 4/4] selftests: ALSA: Cover userspace-driven timers with test
@ 2024-07-28  5:40 kernel test robot
  0 siblings, 0 replies; 15+ messages in thread
From: kernel test robot @ 2024-07-28  5:40 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240726074750.626671-5-ivan.orlov0322@gmail.com>
References: <20240726074750.626671-5-ivan.orlov0322@gmail.com>
TO: Ivan Orlov <ivan.orlov0322@gmail.com>
TO: perex@perex.cz
TO: tiwai@suse.com
TO: corbet@lwn.net
TO: broonie@kernel.org
TO: shuah@kernel.org
CC: Ivan Orlov <ivan.orlov0322@gmail.com>
CC: linux-kselftest@vger.kernel.org
CC: linux-doc@vger.kernel.org
CC: linux-sound@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: aholzinger@gmx.de

Hi Ivan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus linus/master v6.10 next-20240726]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ivan-Orlov/ALSA-aloop-Allow-using-global-timers/20240726-155158
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20240726074750.626671-5-ivan.orlov0322%40gmail.com
patch subject: [PATCH 4/4] selftests: ALSA: Cover userspace-driven timers with test
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240728/202407281359.vMYdESrT-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202407281359.vMYdESrT-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> utimer-test.c:73:1: warning: non-void function does not return a value [-Wreturn-type]
      73 | }
         | ^
>> utimer-test.c:117:11: warning: enumeration value 'TIMER_NO_EVENT' not handled in switch [-Wswitch]
     117 |                 switch (parse_timer_output(buf)) {
         |                         ^~~~~~~~~~~~~~~~~~~~~~~
   2 warnings generated.


vim +73 tools/testing/selftests/alsa/utimer-test.c

5cf58530fa628b Ivan Orlov 2024-07-26  62  
5cf58530fa628b Ivan Orlov 2024-07-26  63  static void *ticking_func(void *data)
5cf58530fa628b Ivan Orlov 2024-07-26  64  {
5cf58530fa628b Ivan Orlov 2024-07-26  65  	int i;
5cf58530fa628b Ivan Orlov 2024-07-26  66  	int *fd = (int *)data;
5cf58530fa628b Ivan Orlov 2024-07-26  67  
5cf58530fa628b Ivan Orlov 2024-07-26  68  	for (i = 0; i < TICKS_COUNT; i++) {
5cf58530fa628b Ivan Orlov 2024-07-26  69  		/* Well, trigger the timer! */
5cf58530fa628b Ivan Orlov 2024-07-26  70  		ioctl(*fd, SNDRV_TIMER_IOCTL_TRIGGER, NULL);
5cf58530fa628b Ivan Orlov 2024-07-26  71  		sleep(TIMER_FREQ_SEC);
5cf58530fa628b Ivan Orlov 2024-07-26  72  	}
5cf58530fa628b Ivan Orlov 2024-07-26 @73  }
5cf58530fa628b Ivan Orlov 2024-07-26  74  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2024-07-28 11:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26  7:47 [PATCH 0/4] Introduce userspace-driven ALSA timers Ivan Orlov
2024-07-26  7:47 ` [PATCH 1/4] ALSA: aloop: Allow using global timers Ivan Orlov
2024-07-26  7:47 ` [PATCH 2/4] Docs/sound: Add documentation for userspace-driven ALSA timers Ivan Orlov
2024-07-26  7:47 ` [PATCH 3/4] ALSA: timer: Introduce virtual userspace-driven timers Ivan Orlov
2024-07-28  6:52   ` Christophe JAILLET
2024-07-28  8:49     ` Ivan Orlov
2024-07-28  6:59   ` Christophe JAILLET
2024-07-28  8:51     ` Ivan Orlov
2024-07-28  9:30       ` Christophe JAILLET
2024-07-28  9:42         ` Ivan Orlov
2024-07-28 10:29           ` Christophe JAILLET
2024-07-28 11:54             ` Ivan Orlov
2024-07-26  7:47 ` [PATCH 4/4] selftests: ALSA: Cover userspace-driven timers with test Ivan Orlov
2024-07-28  6:10   ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2024-07-28  5:40 kernel test robot

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.