All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] fall back to reserved minor numbers
@ 2010-05-14  3:28 Wu Fengguang
  2010-05-14  8:17 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Wu Fengguang @ 2010-05-14  3:28 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel@alsa-project.org, Clemens Ladisch

When the static minor numbers collide because of too many devices,
fall back to the reserved minor numbers 2 and 3.

This for example will allow Intel HDMI audio driver to create three PCM
devices (index 3, 7, 8; the minor number of the last index will
otherwise collide with the first record device).

The other option is to force enable CONFIG_SND_DYNAMIC_MINORS.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
 include/sound/minors.h |    4 +++-
 sound/core/sound.c     |   10 ++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

--- drm-intel.orig/include/sound/minors.h	2010-05-13 10:06:52.000000000 +0800
+++ drm-intel/include/sound/minors.h	2010-05-13 10:10:06.000000000 +0800
@@ -35,7 +35,9 @@
 #define SNDRV_MINOR_TIMER		(SNDRV_MINOR_GLOBAL + 1 * 32)
 
 #ifndef CONFIG_SND_DYNAMIC_MINORS
-						/* 2 - 3 (reserved) */
+
+#define SNDRV_MINOR_BACKUP1		2
+#define SNDRV_MINOR_BACKUP2		3
 #define SNDRV_MINOR_HWDEP		4	/* 4 - 7 */
 #define SNDRV_MINOR_RAWMIDI		8	/* 8 - 15 */
 #define SNDRV_MINOR_PCM_PLAYBACK	16	/* 16 - 23 */
--- drm-intel.orig/sound/core/sound.c	2010-05-13 10:06:04.000000000 +0800
+++ drm-intel/sound/core/sound.c	2010-05-13 10:11:19.000000000 +0800
@@ -269,8 +269,14 @@ int snd_register_device_for_dev(int type
 	minor = snd_find_free_minor();
 #else
 	minor = snd_kernel_minor(type, card, dev);
-	if (minor >= 0 && snd_minors[minor])
-		minor = -EBUSY;
+	if (minor >= 0) {
+		if (snd_minors[minor])
+			minor = SNDRV_MINOR_BACKUP1;
+		if (snd_minors[minor])
+			minor = SNDRV_MINOR_BACKUP2;
+		if (snd_minors[minor])
+			minor = -EBUSY;
+	}
 #endif
 	if (minor < 0) {
 		mutex_unlock(&sound_mutex);

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

* Re: [RFC][PATCH] fall back to reserved minor numbers
  2010-05-14  3:28 [RFC][PATCH] fall back to reserved minor numbers Wu Fengguang
@ 2010-05-14  8:17 ` Takashi Iwai
  2010-05-14  8:55   ` Wu Fengguang
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2010-05-14  8:17 UTC (permalink / raw)
  To: Wu Fengguang; +Cc: alsa-devel@alsa-project.org, Clemens Ladisch

At Fri, 14 May 2010 11:28:28 +0800,
Wu Fengguang wrote:
> 
> When the static minor numbers collide because of too many devices,
> fall back to the reserved minor numbers 2 and 3.
> 
> This for example will allow Intel HDMI audio driver to create three PCM
> devices (index 3, 7, 8; the minor number of the last index will
> otherwise collide with the first record device).
> 
> The other option is to force enable CONFIG_SND_DYNAMIC_MINORS.
> 
> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>

Well, frankly, I don't see a big merit of doing this.

Most (all?) 2.6-based distros are using udev, thus
CONFIG_SND_DYNAMIC_MINORS should be used there.  The rest is for old
distros or for some limited systems like embedded devices, and they
won't need so much PCM devices.

Even if we do this, it doesn't make sense unless the user-space side
creates the corresponding device node.


thanks,

Takashi

> ---
>  include/sound/minors.h |    4 +++-
>  sound/core/sound.c     |   10 ++++++++--
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> --- drm-intel.orig/include/sound/minors.h	2010-05-13 10:06:52.000000000 +0800
> +++ drm-intel/include/sound/minors.h	2010-05-13 10:10:06.000000000 +0800
> @@ -35,7 +35,9 @@
>  #define SNDRV_MINOR_TIMER		(SNDRV_MINOR_GLOBAL + 1 * 32)
>  
>  #ifndef CONFIG_SND_DYNAMIC_MINORS
> -						/* 2 - 3 (reserved) */
> +
> +#define SNDRV_MINOR_BACKUP1		2
> +#define SNDRV_MINOR_BACKUP2		3
>  #define SNDRV_MINOR_HWDEP		4	/* 4 - 7 */
>  #define SNDRV_MINOR_RAWMIDI		8	/* 8 - 15 */
>  #define SNDRV_MINOR_PCM_PLAYBACK	16	/* 16 - 23 */
> --- drm-intel.orig/sound/core/sound.c	2010-05-13 10:06:04.000000000 +0800
> +++ drm-intel/sound/core/sound.c	2010-05-13 10:11:19.000000000 +0800
> @@ -269,8 +269,14 @@ int snd_register_device_for_dev(int type
>  	minor = snd_find_free_minor();
>  #else
>  	minor = snd_kernel_minor(type, card, dev);
> -	if (minor >= 0 && snd_minors[minor])
> -		minor = -EBUSY;
> +	if (minor >= 0) {
> +		if (snd_minors[minor])
> +			minor = SNDRV_MINOR_BACKUP1;
> +		if (snd_minors[minor])
> +			minor = SNDRV_MINOR_BACKUP2;
> +		if (snd_minors[minor])
> +			minor = -EBUSY;
> +	}
>  #endif
>  	if (minor < 0) {
>  		mutex_unlock(&sound_mutex);
> 

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

* Re: [RFC][PATCH] fall back to reserved minor numbers
  2010-05-14  8:17 ` Takashi Iwai
@ 2010-05-14  8:55   ` Wu Fengguang
  2010-05-14  8:59     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Wu Fengguang @ 2010-05-14  8:55 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel@alsa-project.org, Clemens Ladisch

On Fri, May 14, 2010 at 04:17:27PM +0800, Takashi Iwai wrote:
> At Fri, 14 May 2010 11:28:28 +0800,
> Wu Fengguang wrote:
> > 
> > When the static minor numbers collide because of too many devices,
> > fall back to the reserved minor numbers 2 and 3.
> > 
> > This for example will allow Intel HDMI audio driver to create three PCM
> > devices (index 3, 7, 8; the minor number of the last index will
> > otherwise collide with the first record device).
> > 
> > The other option is to force enable CONFIG_SND_DYNAMIC_MINORS.
> > 
> > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
> 
> Well, frankly, I don't see a big merit of doing this.
> 
> Most (all?) 2.6-based distros are using udev, thus
> CONFIG_SND_DYNAMIC_MINORS should be used there.  The rest is for old
> distros or for some limited systems like embedded devices, and they
> won't need so much PCM devices.
> 
> Even if we do this, it doesn't make sense unless the user-space side
> creates the corresponding device node.

I was afraid of this case: an embedded system with G45 HDMI codec.
This codec only has 1 PCM playback device, however the driver still
requires enabling CONFIG_SND_DYNAMIC_MINORS in order to support more
capable HDMI codecs.

Thanks,
Fengguang

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

* Re: [RFC][PATCH] fall back to reserved minor numbers
  2010-05-14  8:55   ` Wu Fengguang
@ 2010-05-14  8:59     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2010-05-14  8:59 UTC (permalink / raw)
  To: Wu Fengguang; +Cc: alsa-devel@alsa-project.org, Clemens Ladisch

At Fri, 14 May 2010 16:55:26 +0800,
Wu Fengguang wrote:
> 
> On Fri, May 14, 2010 at 04:17:27PM +0800, Takashi Iwai wrote:
> > At Fri, 14 May 2010 11:28:28 +0800,
> > Wu Fengguang wrote:
> > > 
> > > When the static minor numbers collide because of too many devices,
> > > fall back to the reserved minor numbers 2 and 3.
> > > 
> > > This for example will allow Intel HDMI audio driver to create three PCM
> > > devices (index 3, 7, 8; the minor number of the last index will
> > > otherwise collide with the first record device).
> > > 
> > > The other option is to force enable CONFIG_SND_DYNAMIC_MINORS.
> > > 
> > > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
> > 
> > Well, frankly, I don't see a big merit of doing this.
> > 
> > Most (all?) 2.6-based distros are using udev, thus
> > CONFIG_SND_DYNAMIC_MINORS should be used there.  The rest is for old
> > distros or for some limited systems like embedded devices, and they
> > won't need so much PCM devices.
> > 
> > Even if we do this, it doesn't make sense unless the user-space side
> > creates the corresponding device node.
> 
> I was afraid of this case: an embedded system with G45 HDMI codec.
> This codec only has 1 PCM playback device, however the driver still
> requires enabling CONFIG_SND_DYNAMIC_MINORS in order to support more
> capable HDMI codecs.

It's 2.6 kernel and no udev?  It must be a rare case.
In such a case, they can patch it out by themselves.


Takashi

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

end of thread, other threads:[~2010-05-14  8:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-14  3:28 [RFC][PATCH] fall back to reserved minor numbers Wu Fengguang
2010-05-14  8:17 ` Takashi Iwai
2010-05-14  8:55   ` Wu Fengguang
2010-05-14  8:59     ` Takashi Iwai

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.