From: Takashi Iwai <tiwai@suse.de>
To: Vinod Koul <vkoul@kernel.org>
Cc: Joris Verhaegen <verhaegen@google.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Cezary Rojewski <cezary.rojewski@intel.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
Srinivas Kandagatla <srini@kernel.org>,
Daniel Baluta <daniel.baluta@nxp.com>,
Orson Zhai <orsonzhai@gmail.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Chunyan Zhang <zhang.lyra@gmail.com>,
Kunihiko Hayashi <hayashi.kunihiko@socionext.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
kernel-team@android.com, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, patches@opensource.cirrus.com,
linux-arm-msm@vger.kernel.org,
sound-open-firmware@alsa-project.org,
linux-arm-kernel@lists.infradead.org,
Miller Liang <millerliang@google.com>
Subject: Re: [PATCH v4 2/3] ALSA: compress_offload: Add SNDRV_COMPRESS_TSTAMP64 ioctl
Date: Tue, 05 Aug 2025 07:59:42 +0200 [thread overview]
Message-ID: <87h5ym1f75.wl-tiwai@suse.de> (raw)
In-Reply-To: <aJGM2zXS6hOLDFm1@vaman>
On Tue, 05 Aug 2025 06:47:59 +0200,
Vinod Koul wrote:
>
> On 01-08-25, 10:27, Joris Verhaegen wrote:
> > The previous patch introduced the internal infrastructure for handling
> > 64-bit timestamps. This patch exposes this capability to user-space.
> >
> > Define the new ioctl command SNDRV_COMPRESS_TSTAMP64, which allows
> > applications to fetch the overflow-safe struct snd_compr_tstamp64.
> >
> > The ioctl dispatch table is updated to handle the new command by
> > calling a new snd_compr_tstamp64 handler, while the legacy path is
> > renamed to snd_compr_tstamp32 for clarity.
> >
> > This patch bumps the SNDRV_COMPRESS_VERSION to 0.4.0.
> >
> > Reviewed-by: Miller Liang <millerliang@google.com>
> > Tested-by: Joris Verhaegen <verhaegen@google.com>
> > Signed-off-by: Joris Verhaegen <verhaegen@google.com>
> > ---
> > include/uapi/sound/compress_offload.h | 5 +++--
> > sound/core/compress_offload.c | 19 +++++++++++++------
> > 2 files changed, 16 insertions(+), 8 deletions(-)
> >
> > diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h
> > index abd0ea3f86ee..70b8921601f9 100644
> > --- a/include/uapi/sound/compress_offload.h
> > +++ b/include/uapi/sound/compress_offload.h
> > @@ -13,8 +13,7 @@
> > #include <sound/asound.h>
> > #include <sound/compress_params.h>
> >
> > -
> > -#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 3, 0)
> > +#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 4, 0)
> > /**
> > * struct snd_compressed_buffer - compressed buffer
> > * @fragment_size: size of buffer fragment in bytes
> > @@ -208,6 +207,7 @@ struct snd_compr_task_status {
> > * Note: only codec params can be changed runtime and stream params cant be
> > * SNDRV_COMPRESS_GET_PARAMS: Query codec params
> > * SNDRV_COMPRESS_TSTAMP: get the current timestamp value
> > + * SNDRV_COMPRESS_TSTAMP64: get the current timestamp value in 64 bit format
> > * SNDRV_COMPRESS_AVAIL: get the current buffer avail value.
> > * This also queries the tstamp properties
> > * SNDRV_COMPRESS_PAUSE: Pause the running stream
> > @@ -230,6 +230,7 @@ struct snd_compr_task_status {
> > struct snd_compr_metadata)
> > #define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp)
> > #define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail)
> > +#define SNDRV_COMPRESS_TSTAMP64 _IOR('C', 0x22, struct snd_compr_tstamp64)
> > #define SNDRV_COMPRESS_PAUSE _IO('C', 0x30)
> > #define SNDRV_COMPRESS_RESUME _IO('C', 0x31)
> > #define SNDRV_COMPRESS_START _IO('C', 0x32)
> > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> > index d3164aa07158..445220fdb6a0 100644
> > --- a/sound/core/compress_offload.c
> > +++ b/sound/core/compress_offload.c
> > @@ -736,18 +736,23 @@ snd_compr_set_metadata(struct snd_compr_stream *stream, unsigned long arg)
> > return retval;
> > }
> >
> > -static inline int
> > -snd_compr_tstamp(struct snd_compr_stream *stream, unsigned long arg)
> > +static inline int snd_compr_tstamp(struct snd_compr_stream *stream,
> > + unsigned long arg, bool is_32bit)
> > {
> > struct snd_compr_tstamp64 tstamp64 = { 0 };
> > struct snd_compr_tstamp tstamp32 = { 0 };
> > + const void *copy_from = &tstamp64;
> > + size_t copy_size = sizeof(tstamp64);
> > int ret;
> >
> > ret = snd_compr_update_tstamp(stream, &tstamp64);
> > if (ret == 0) {
> > - snd_compr_tstamp32_from_64(&tstamp32, &tstamp64);
> > - ret = copy_to_user((struct snd_compr_tstamp __user *)arg,
> > - &tstamp32, sizeof(tstamp32)) ?
> > + if (is_32bit) {
> > + snd_compr_tstamp32_from_64(&tstamp32, &tstamp64);
> > + copy_from = &tstamp32;
> > + copy_size = sizeof(tstamp32);
> > + }
>
> Most of the applications and people would be 32bit right now and we
> expect this to progressively change, but then this imposes a penalty as
> default path is 64 bit, since we expect this ioctl to be called very
> frequently, should we do this optimization for 64bit here?
Through a quick glance over the patch, I don't think you'll hit the
significant performance loss. It's merely a few bytes of extra copies
before copy_to_user(), after all. But, of course, it'd be more
convincing if anyone can test and give the actual numbers.
thanks,
Takashi
next prev parent reply other threads:[~2025-08-05 5:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 9:27 [PATCH v4 0/3] ALSA: compress_offload: Add 64-bit safe timestamp API Joris Verhaegen
2025-08-01 9:27 ` [PATCH v4 1/3] ALSA: compress_offload: Add 64-bit safe timestamp infrastructure Joris Verhaegen
2025-08-01 12:05 ` Mark Brown
2025-08-01 9:27 ` [PATCH v4 2/3] ALSA: compress_offload: Add SNDRV_COMPRESS_TSTAMP64 ioctl Joris Verhaegen
2025-08-05 4:47 ` Vinod Koul
2025-08-05 5:59 ` Takashi Iwai [this message]
2025-08-18 14:05 ` Charles Keepax
2025-08-19 5:08 ` Vinod Koul
2025-08-21 7:18 ` Takashi Iwai
2025-08-06 11:34 ` George Verhaegen
2025-08-01 9:27 ` [PATCH v4 3/3] ALSA: compress_offload: Add SNDRV_COMPRESS_AVAIL64 ioctl Joris Verhaegen
2025-08-05 4:50 ` Vinod Koul
2025-08-21 8:53 ` George Verhaegen
2025-08-01 9:59 ` [PATCH v4 0/3] ALSA: compress_offload: Add 64-bit safe timestamp API Charles Keepax
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=87h5ym1f75.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=baolin.wang@linux.alibaba.com \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=daniel.baluta@nxp.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=kernel-team@android.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=millerliang@google.com \
--cc=orsonzhai@gmail.com \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sound-open-firmware@alsa-project.org \
--cc=srini@kernel.org \
--cc=tiwai@suse.com \
--cc=verhaegen@google.com \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
--cc=zhang.lyra@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).