Skip to content

Commit 256ca9c

Browse files
committed
ALSA: seq-oss: Initialize MIDI clients asynchronously
We've got bug reports that the module loading stuck on Debian system with 3.10 kernel. The debugging session revealed that the initial registration of OSS sequencer clients stuck at module loading time, which involves again with request_module() at the init phase. This is triggered only by special --install stuff Debian is using, but it's still not good to have such loops. As a workaround, call the registration part asynchronously. This is a better approach irrespective of the hang fix, in anyway. Reported-and-tested-by: Philipp Matthias Hahn <pmhahn@pmhahn.de> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent d52392b commit 256ca9c

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎sound/core/seq/oss/seq_oss_init.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/export.h>
3232
#include <linux/moduleparam.h>
3333
#include <linux/slab.h>
34+
#include <linux/workqueue.h>
3435

3536
/*
3637
* common variables
@@ -60,6 +61,14 @@ static void free_devinfo(void *private);
6061
#define call_ctl(type,rec) snd_seq_kernel_client_ctl(system_client, type, rec)
6162

6263

64+
/* call snd_seq_oss_midi_lookup_ports() asynchronously */
65+
static void async_call_lookup_ports(struct work_struct *work)
66+
{
67+
snd_seq_oss_midi_lookup_ports(system_client);
68+
}
69+
70+
static DECLARE_WORK(async_lookup_work, async_call_lookup_ports);
71+
6372
/*
6473
* create sequencer client for OSS sequencer
6574
*/
@@ -85,9 +94,6 @@ snd_seq_oss_create_client(void)
8594
system_client = rc;
8695
debug_printk(("new client = %d\n", rc));
8796

88-
/* look up midi devices */
89-
snd_seq_oss_midi_lookup_ports(system_client);
90-
9197
/* create annoucement receiver port */
9298
memset(port, 0, sizeof(*port));
9399
strcpy(port->name, "Receiver");
@@ -115,6 +121,9 @@ snd_seq_oss_create_client(void)
115121
}
116122
rc = 0;
117123

124+
/* look up midi devices */
125+
schedule_work(&async_lookup_work);
126+
118127
__error:
119128
kfree(port);
120129
return rc;
@@ -160,6 +169,7 @@ receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic
160169
int
161170
snd_seq_oss_delete_client(void)
162171
{
172+
cancel_work_sync(&async_lookup_work);
163173
if (system_client >= 0)
164174
snd_seq_delete_kernel_client(system_client);
165175

‎sound/core/seq/oss/seq_oss_midi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static int send_midi_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
7272
* look up the existing ports
7373
* this looks a very exhausting job.
7474
*/
75-
int __init
75+
int
7676
snd_seq_oss_midi_lookup_ports(int client)
7777
{
7878
struct snd_seq_client_info *clinfo;

0 commit comments

Comments
 (0)