From: Takashi Iwai <tiwai@suse.de>
To: Maciej Strozek <mstrozek@opensource.cirrus.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
patches@opensource.cirrus.com, alsa-devel@alsa-project.org
Subject: Re: [PATCH v2] ALSA: control: add ioctl to retrieve full card components
Date: Fri, 23 Jan 2026 15:45:40 +0100 [thread overview]
Message-ID: <87ikcse6az.wl-tiwai@suse.de> (raw)
In-Reply-To: <cf52537811c2958dda4510b50792278d04fe9f39.camel@opensource.cirrus.com>
On Fri, 23 Jan 2026 15:42:13 +0100,
Maciej Strozek wrote:
>
> W dniu pią, 23.01.2026 o godzinie 13∶15 +0100, użytkownik Takashi Iwai
> napisał:
> > On Thu, 22 Jan 2026 14:30:04 +0100,
> > Jaroslav Kysela wrote:
> > >
> > > On 1/22/26 12:12, Maciej Strozek wrote:
> > > > The fixed-size components field in SNDRV_CTL_IOCTL_CARD_INFO can
> > > > be too
> > > > small on systems with many audio devices.
> > > >
> > > > Keep the existing struct snd_ctl_card_info ABI intact and add a
> > > > new ioctl
> > > > to retrieve the full components string.
> > > >
> > > > When the legacy components field is truncated, append '>' to
> > > > indicate
> > > > that the full string is available via the new ioctl.
> > >
> > > Thanks for the patch. Comments bellow.
> > >
> > > > @@ -88,7 +89,8 @@ struct snd_card {
> > > > char irq_descr[32]; /* Interrupt description */
> > > > char mixername[80]; /* mixer name */
> > > > char components[128]; /* card components delimited with
> > > > - space */
> > > > + space, truncated to 127 chars */
> > > > + char components_extended[SNDRV_CTL_COMPONENTS_LEN]; /* full
> > > > card components string */
> > >
> > > I would remove the original components[128] string and replace it
> > > with dynamically allocated 'char *components_ptr' with 'unsigned
> > > int
> > > components_ptr_alloc' to store allocated size. Then the
> > > snd_component_add() function may allocate (and resize) dynamically
> > > the
> > > components_ptr on demand (using e.g. 32 byte step). This will also
> > > catch all drivers using the original struct member when compiled
> > > and
> > > make the memory usage a little bit happier.
> >
> > Agreed that it'd be better to point to the dynamic allocated array.
> >
> > And, we can basically drop the limit, too.
> > For example, the ioctl can store the size of the string in return
> > while filling up to the given length. So, when user-space gives
> > snd_ctl_card_components.length = 0, it just stores the actual string
> > size to this length field. Then user-space can allocate the needed
> > buffer and get the actual string.
> >
> > Or, user-space allocates a large-enough size buffer, set to length,
> > and check the actually returned length, too.
> >
> > Of course, we may (should) have some upper-limit internally for a
> > sanity check, but it doesn't have to be exposed as a part of ABI.
> >
> >
> > thanks,
> >
> > Takashi
>
> Thank you for your reviews, will prepare a v3 with dynamically
> allocated array soon.
> Do you suggest to simply error out if the internal upper-limit is
> exceeded?
I guess yes, but note that the upper limit check would be rather for
adding component strings, not for the ioctl.
Basically we don't need a temporary kmalloc for ioctl, but we can just
copy the contents since the buffer length is given.
thanks,
Takashi
prev parent reply other threads:[~2026-01-23 14:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 11:12 [PATCH v2] ALSA: control: add ioctl to retrieve full card components Maciej Strozek
2026-01-22 13:30 ` Jaroslav Kysela
2026-01-23 12:15 ` Takashi Iwai
2026-01-23 14:42 ` Maciej Strozek
2026-01-23 14:45 ` Takashi Iwai [this message]
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=87ikcse6az.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mstrozek@opensource.cirrus.com \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.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