* BKL removal from ALSA core
@ 2010-04-14 8:14 Takashi Iwai
2010-04-14 8:14 ` [PATCH 1/3] ALSA: pcm - Remove BKL from async callback Takashi Iwai
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Takashi Iwai @ 2010-04-14 8:14 UTC (permalink / raw)
To: alsa-devel
Hi,
I recently cleaned up ALSA core code a bit. The first attemp is the
removal of BKL, at least, in ALSA side. There are still in sound_core.c
and OSS drivers, but who cares ;)
The patches below are in sound git tree topic/bkl branch.
[PATCH 1/3] ALSA: pcm - Remove BKL from async callback
[PATCH 2/3] ALSA: info - Remove BKL
[PATCH 3/3] ALSA: Remove BKL from open multiplexer
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] ALSA: pcm - Remove BKL from async callback
2010-04-14 8:14 BKL removal from ALSA core Takashi Iwai
@ 2010-04-14 8:14 ` Takashi Iwai
2010-04-14 8:14 ` [PATCH 2/3] ALSA: info - Remove BKL Takashi Iwai
2010-04-14 8:14 ` [PATCH 3/3] ALSA: Remove BKL from open multiplexer Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2010-04-14 8:14 UTC (permalink / raw)
To: alsa-devel; +Cc: Takashi Iwai
It's simply calling fasync_helper().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/pcm_native.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 8728876..cadba30 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3303,18 +3303,13 @@ static int snd_pcm_fasync(int fd, struct file * file, int on)
struct snd_pcm_file * pcm_file;
struct snd_pcm_substream *substream;
struct snd_pcm_runtime *runtime;
- int err = -ENXIO;
- lock_kernel();
pcm_file = file->private_data;
substream = pcm_file->substream;
if (PCM_RUNTIME_CHECK(substream))
- goto out;
+ return -ENXIO;
runtime = substream->runtime;
- err = fasync_helper(fd, file, on, &runtime->fasync);
-out:
- unlock_kernel();
- return err;
+ return fasync_helper(fd, file, on, &runtime->fasync);
}
/*
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] ALSA: info - Remove BKL
2010-04-14 8:14 BKL removal from ALSA core Takashi Iwai
2010-04-14 8:14 ` [PATCH 1/3] ALSA: pcm - Remove BKL from async callback Takashi Iwai
@ 2010-04-14 8:14 ` Takashi Iwai
2010-04-14 8:14 ` [PATCH 3/3] ALSA: Remove BKL from open multiplexer Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2010-04-14 8:14 UTC (permalink / raw)
To: alsa-devel; +Cc: Takashi Iwai
Use the fine-grained mutex for the assigned info object, instead.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/info.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/core/info.c b/sound/core/info.c
index d749a0d..fe83661 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -167,7 +167,7 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
data = file->private_data;
entry = data->entry;
- lock_kernel();
+ mutex_lock(&entry->access);
switch (entry->content) {
case SNDRV_INFO_CONTENT_TEXT:
switch (orig) {
@@ -196,7 +196,7 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
}
ret = -ENXIO;
out:
- unlock_kernel();
+ mutex_unlock(&entry->access);
return ret;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] ALSA: Remove BKL from open multiplexer
2010-04-14 8:14 BKL removal from ALSA core Takashi Iwai
2010-04-14 8:14 ` [PATCH 1/3] ALSA: pcm - Remove BKL from async callback Takashi Iwai
2010-04-14 8:14 ` [PATCH 2/3] ALSA: info - Remove BKL Takashi Iwai
@ 2010-04-14 8:14 ` Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2010-04-14 8:14 UTC (permalink / raw)
To: alsa-devel; +Cc: Takashi Iwai
Use a local mutex instead of BKL. This should suffice since each device
type has also its open_mutex.
Also, a bit of clean-up of the legacy device auto-loading code.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/sound.c | 73 +++++++++++++++++++++++++++-------------------------
1 files changed, 38 insertions(+), 35 deletions(-)
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 563d196..ac42af4 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -120,7 +120,29 @@ void *snd_lookup_minor_data(unsigned int minor, int type)
EXPORT_SYMBOL(snd_lookup_minor_data);
-static int __snd_open(struct inode *inode, struct file *file)
+#ifdef CONFIG_MODULES
+static struct snd_minor *autoload_device(unsigned int minor)
+{
+ int dev;
+ mutex_unlock(&sound_mutex); /* release lock temporarily */
+ dev = SNDRV_MINOR_DEVICE(minor);
+ if (dev == SNDRV_MINOR_CONTROL) {
+ /* /dev/aloadC? */
+ int card = SNDRV_MINOR_CARD(minor);
+ if (snd_cards[card] == NULL)
+ snd_request_card(card);
+ } else if (dev == SNDRV_MINOR_GLOBAL) {
+ /* /dev/aloadSEQ */
+ snd_request_other(minor);
+ }
+ mutex_lock(&sound_mutex); /* reacuire lock */
+ return snd_minors[minor];
+}
+#else /* !CONFIG_MODULES */
+#define autoload_device(minor) NULL
+#endif /* CONFIG_MODULES */
+
+static int snd_open(struct inode *inode, struct file *file)
{
unsigned int minor = iminor(inode);
struct snd_minor *mptr = NULL;
@@ -129,55 +151,36 @@ static int __snd_open(struct inode *inode, struct file *file)
if (minor >= ARRAY_SIZE(snd_minors))
return -ENODEV;
+ mutex_lock(&sound_mutex);
mptr = snd_minors[minor];
if (mptr == NULL) {
-#ifdef CONFIG_MODULES
- int dev = SNDRV_MINOR_DEVICE(minor);
- if (dev == SNDRV_MINOR_CONTROL) {
- /* /dev/aloadC? */
- int card = SNDRV_MINOR_CARD(minor);
- if (snd_cards[card] == NULL)
- snd_request_card(card);
- } else if (dev == SNDRV_MINOR_GLOBAL) {
- /* /dev/aloadSEQ */
- snd_request_other(minor);
- }
-#ifndef CONFIG_SND_DYNAMIC_MINORS
- /* /dev/snd/{controlC?,seq} */
- mptr = snd_minors[minor];
- if (mptr == NULL)
-#endif
-#endif
+ mptr = autoload_device(minor);
+ if (!mptr) {
+ mutex_unlock(&sound_mutex);
return -ENODEV;
+ }
}
old_fops = file->f_op;
file->f_op = fops_get(mptr->f_ops);
if (file->f_op == NULL) {
file->f_op = old_fops;
- return -ENODEV;
+ err = -ENODEV;
}
- if (file->f_op->open)
+ mutex_unlock(&sound_mutex);
+ if (err < 0)
+ return err;
+
+ if (file->f_op->open) {
err = file->f_op->open(inode, file);
- if (err) {
- fops_put(file->f_op);
- file->f_op = fops_get(old_fops);
+ if (err) {
+ fops_put(file->f_op);
+ file->f_op = fops_get(old_fops);
+ }
}
fops_put(old_fops);
return err;
}
-
-/* BKL pushdown: nasty #ifdef avoidance wrapper */
-static int snd_open(struct inode *inode, struct file *file)
-{
- int ret;
-
- lock_kernel();
- ret = __snd_open(inode, file);
- unlock_kernel();
- return ret;
-}
-
static const struct file_operations snd_fops =
{
.owner = THIS_MODULE,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-04-14 8:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-14 8:14 BKL removal from ALSA core Takashi Iwai
2010-04-14 8:14 ` [PATCH 1/3] ALSA: pcm - Remove BKL from async callback Takashi Iwai
2010-04-14 8:14 ` [PATCH 2/3] ALSA: info - Remove BKL Takashi Iwai
2010-04-14 8:14 ` [PATCH 3/3] ALSA: Remove BKL from open multiplexer Takashi Iwai
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).