Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, Jaroslav Kysela <perex@perex.cz>
Subject: Re: [PATCH 6/8] ALSA: emu10k1: add support for 2x/4x word clocks in E-MU D.A.S. mode
Date: Tue, 13 Jun 2023 12:52:43 +0200	[thread overview]
Message-ID: <ZIhKe99WGpLFN1ld@ugly> (raw)
In-Reply-To: <87v8fren1k.wl-tiwai@suse.de>

On Tue, Jun 13, 2023 at 11:20:23AM +0200, Takashi Iwai wrote:
>On Tue, 13 Jun 2023 09:38:20 +0200,
>Oswald Buddenhagen wrote:
>> 
>> Notably, add_ctls() now uses snd_ctl_add_locked(), so it doesn't
>> deadlock when called from snd_emu1010_clock_shift_put(). This also
>> affects the initial creation of the controls, which is OK, as that is
>> done before the card is registered, so no concurrent access can occur.
>
>Creating and removing the controls from kctl put callback is no good
>idea.  In general, dynamic control creation/deletion already confuses
>user-space.
>
i kind of expected that, but what i've tried so far worked remarkably 
well (ok, it was mostly alsamixer).

> On top of that, if it's done by a control element, it can
>be even triggered endlessly by user.
>
it shouldn't, because there is no circularity between the controls. 
even if the app sets all controls as a response to new ones appearing, 
the second round will be a no-op for the multiplier control, and 
therefore causes no new creattion/deletion notifications, and thus 
terminates the recursion.

but suppose a sufficiently broken application exists. then causing it to 
fail still seems quite acceptable: this is effectively new hardware (the 
new mode needs to be enabled manually), so it would be simply 
unsupported by the application until that gets fixed.

>A safer approach would be to create controls statically, and set
>active flag dynamically, I suppose.
>
i wanted to do that, but the problem is that not only the number of 
controls changes, but also the number of enum values in each control, as 
there is no way to make particular enum values inactive.
and i didn't want to keep three whole sets of controls around at all 
times, as that seems a bit wasteful.

also, i don't think that disabling would be fundamentally different from 
deleting: the particular code paths taken are somewhat different, but 
the high-level view is essentially the same. so we can't really make 
predictions which one would work better.

>And, if we really have to create / delete a kctl element from some
>kctl action, don't do it in the callback but process in another work.
>
would that really improve anything? for the notification to be received 
before the ioctl returns, it would have to be watched by a different 
thread. but if the app thought that there is a race, it would have to 
take the lock before issuing the ioctl anyway. so i think for user space 
it doesn't matter when exactly the notifications are emitted.

otoh, making the mixer reorganization async would introduce rather 
significant complexity to the driver due to having to deal with ioctls 
that come in while the inconsistent state persists (which seems likely 
during a state restoration).

so i would _really_ prefer to keep things as they are, and think about 
changing them only once we have hard evidence that the approach is too 
problematic.

regards,
ossi

  reply	other threads:[~2023-06-13 10:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13  7:38 [PATCH 0/8] ALSA: emu10k1: add support for high-bitrate modes of E-MU cards Oswald Buddenhagen
2023-06-13  7:38 ` [PATCH 1/8] ALSA: emu10k1: introduce alternative E-MU D.A.S. mode Oswald Buddenhagen
2023-06-13  7:38 ` [PATCH 2/8] ALSA: emu10k1: improve mixer control naming in " Oswald Buddenhagen
2023-06-13  7:38 ` [PATCH 3/8] ALSA: emu10k1: set the "no filtering" bits on PCM voices Oswald Buddenhagen
2023-06-13  7:38 ` [PATCH 4/8] ALSA: emu10k1: make playback in E-MU D.A.S. mode 32-bit Oswald Buddenhagen
2023-06-13  7:38 ` [PATCH 5/8] ALSA: add snd_ctl_add_locked() Oswald Buddenhagen
2023-06-13  7:38 ` [PATCH 6/8] ALSA: emu10k1: add support for 2x/4x word clocks in E-MU D.A.S. mode Oswald Buddenhagen
2023-06-13  9:20   ` Takashi Iwai
2023-06-13 10:52     ` Oswald Buddenhagen [this message]
2023-06-13 11:08       ` Takashi Iwai
2023-06-13 14:00         ` Oswald Buddenhagen
2023-06-13 14:13           ` Takashi Iwai
2023-06-13 15:23             ` Oswald Buddenhagen
2023-06-13 15:43               ` Takashi Iwai
2023-06-13 17:14                 ` Oswald Buddenhagen
2023-06-14  6:36                   ` Takashi Iwai
2023-06-14  8:52                     ` Oswald Buddenhagen
2023-06-14  9:16                       ` Takashi Iwai
2023-06-14 10:53                         ` Oswald Buddenhagen
2023-06-13  7:38 ` [PATCH 7/8] ALSA: emu10k1: add high-rate capture " Oswald Buddenhagen
2023-06-13  7:38 ` [PATCH 8/8] ALSA: emu10k1: add high-rate playback " Oswald Buddenhagen
2023-06-22  7:05   ` kernel test robot

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=ZIhKe99WGpLFN1ld@ugly \
    --to=oswald.buddenhagen@gmx.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox