* [PATCH] sound/pci/via82xx.c "sleeping function called..."
@ 2002-10-30 4:23 Josh Myer
2002-10-30 14:09 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Josh Myer @ 2002-10-30 4:23 UTC (permalink / raw)
To: tiwai, linux-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1484 bytes --]
Attached is a patch which seems to cure these, but no promises that it's
Correct (!):
(To: l-k so the Gurus can tell me i'm wrong more efficiently =)
Debug: sleeping function called from illegal context at mm/slab.c:1374
Call Trace:
[<c0114d41>] __might_sleep+0x55/0x64
[<c012f44a>] kmalloc+0x56/0x1e4
[<c4049098>] build_via_table+0x38/0x184 [snd-via82xx]
[<c40490bb>] build_via_table+0x5b/0x184 [snd-via82xx]
[<c01b8567>] __delay+0x13/0x28
[<c404955a>] snd_via82xx_setup_periods+0x2e/0x128 [snd-via82xx]
[<c4049864>] snd_via82xx_playback_prepare+0x80/0x8c [snd-via82xx]
[<c4037e80>] snd_pcm_prepare+0xac/0x18c [snd-pcm]
[<c40397e6>] snd_pcm_common_ioctl1+0x1d6/0x2a8 [snd-pcm]
[<c4039c1e>] snd_pcm_playback_ioctl1+0x366/0x374 [snd-pcm]
[<c4039fbf>] snd_pcm_kernel_playback_ioctl_R7d246e95+0x27/0x30 [snd-pcm]
[<c403a01b>] snd_pcm_kernel_ioctl_Ra45ade40+0x23/0x40 [snd-pcm]
[<c4052c81>] snd_pcm_oss_prepare+0x15/0x34 [snd-pcm-oss]
[<c4052cd2>] snd_pcm_oss_make_ready+0x32/0x40 [snd-pcm-oss]
[<c4053060>] snd_pcm_oss_write1+0x3c/0x148 [snd-pcm-oss]
[<c4054f6a>] snd_pcm_oss_write+0x32/0x68 [snd-pcm-oss]
[<c013d351>] vfs_write+0xc1/0x160
[<c013d456>] sys_write+0x2a/0x3c
[<c0108b07>] syscall_call+0x7/0xb
It's creepy to look over at the TV and see what looks like an Oops trace
but the music is still going... =)
--
/jbm, but you can call me Josh. Really, you can!
"What's a metaphor?" "For sheep to graze in"
7958 1C1C 306A CDF8 4468 3EDE 1F93 F49D 5FA1 49C4
[-- Attachment #2: Type: TEXT/plain, Size: 446 bytes --]
--- linux-2.5.44/sound/pci/via82xx.c 2002-10-19 00:01:19.000000000 -0400
+++ linux-2.5.44-jbm/sound/pci/via82xx.c 2002-10-29 23:12:26.000000000 -0500
@@ -217,7 +217,7 @@
return -ENOMEM;
}
if (! dev->idx_table) {
- dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL);
+ dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_ATOMIC);
if (! dev->idx_table)
return -ENOMEM;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] sound/pci/via82xx.c "sleeping function called..."
2002-10-30 4:23 [PATCH] sound/pci/via82xx.c "sleeping function called..." Josh Myer
@ 2002-10-30 14:09 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2002-10-30 14:09 UTC (permalink / raw)
To: Josh Myer; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
Hi,
At Tue, 29 Oct 2002 22:23:15 -0600 (CST),
Josh Myer wrote:
>
> Attached is a patch which seems to cure these, but no promises that it's
> Correct (!):
thanks for spotting this bug.
yes, the patch cures, but it may fail the allocation because of
ATOMIC. could you try the attached patch?
Takashi
[-- Attachment #2: via82xx-fix.dif --]
[-- Type: application/octet-stream, Size: 4309 bytes --]
--- linux/sound/pci/via82xx.c 22 Oct 2002 09:37:30 -0000 1.12
+++ linux/sound/pci/via82xx.c 30 Oct 2002 14:06:18 -0000
@@ -201,11 +201,16 @@
} viadev_t;
+/*
+ * allocate and initialize the descriptor buffers
+ * periods = number of periods
+ * fragsize = period size in bytes
+ */
static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
- struct pci_dev *pci)
+ struct pci_dev *pci,
+ int periods, int fragsize)
{
- int i, idx, ofs, rest, fragsize;
- snd_pcm_runtime_t *runtime = substream->runtime;
+ int i, idx, ofs, rest;
struct snd_sg_buf *sgbuf = snd_magic_cast(snd_pcm_sgbuf_t, substream->dma_private, return -EINVAL);
if (! dev->table) {
@@ -223,10 +228,9 @@
}
/* fill the entries */
- fragsize = snd_pcm_lib_period_bytes(substream);
idx = 0;
ofs = 0;
- for (i = 0; i < runtime->periods; i++) {
+ for (i = 0; i < periods; i++) {
rest = fragsize;
/* fill descriptors for a period.
* a period can be split to several descriptors if it's
@@ -241,7 +245,7 @@
r = rest;
rest -= r;
if (! rest) {
- if (i == runtime->periods - 1)
+ if (i == periods - 1)
flag = VIA_TBL_BIT_EOL; /* buffer boundary */
else
flag = VIA_TBL_BIT_FLAG; /* period boundary */
@@ -472,19 +476,14 @@
}
-static int snd_via82xx_setup_periods(via82xx_t *chip, viadev_t *viadev,
- snd_pcm_substream_t *substream)
+static int snd_via82xx_set_format(via82xx_t *chip, viadev_t *viadev,
+ snd_pcm_substream_t *substream)
{
snd_pcm_runtime_t *runtime = substream->runtime;
unsigned long port = chip->port + viadev->reg_offset;
- int err;
snd_via82xx_channel_reset(chip, viadev);
- err = build_via_table(viadev, substream, chip->pci);
- if (err < 0)
- return err;
-
outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR);
switch (chip->chip_type) {
case TYPE_VIA686:
@@ -583,11 +582,28 @@
static int snd_via82xx_hw_params(snd_pcm_substream_t * substream,
snd_pcm_hw_params_t * hw_params)
{
- return snd_pcm_sgbuf_alloc(substream, params_buffer_bytes(hw_params));
+ via82xx_t *chip = snd_pcm_substream_chip(substream);
+ viadev_t *viadev = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? &chip->playback : &chip->capture;
+ int err;
+
+ err = snd_pcm_sgbuf_alloc(substream, params_buffer_bytes(hw_params));
+ if (err < 0)
+ return err;
+ err = build_via_table(viadev, substream, chip->pci,
+ params_periods(hw_params),
+ params_period_bytes(hw_params));
+ if (err < 0)
+ return err;
+ return err;
}
static int snd_via82xx_hw_free(snd_pcm_substream_t * substream)
{
+ via82xx_t *chip = snd_pcm_substream_chip(substream);
+ viadev_t *viadev = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? &chip->playback : &chip->capture;
+
+ clean_via_table(viadev, substream, chip->pci);
+ snd_pcm_sgbuf_free(substream);
return 0;
}
@@ -606,7 +622,7 @@
tmp = inl(VIAREG(chip, PLAYBACK_STOP_IDX)) & ~0xfffff;
outl(tmp | (0xffff * runtime->rate)/(48000/16), VIAREG(chip, PLAYBACK_STOP_IDX));
}
- return snd_via82xx_setup_periods(chip, &chip->playback, substream);
+ return snd_via82xx_set_format(chip, &chip->playback, substream);
}
static int snd_via82xx_capture_prepare(snd_pcm_substream_t * substream)
@@ -617,7 +633,7 @@
snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate);
if (chip->chip_type == TYPE_VIA8233)
outb(VIA_REG_CAPTURE_FIFO_ENABLE, VIAREG(chip, CAPTURE_FIFO));
- return snd_via82xx_setup_periods(chip, &chip->capture, substream);
+ return snd_via82xx_set_format(chip, &chip->capture, substream);
}
static inline unsigned int snd_via82xx_cur_ptr(via82xx_t *chip, viadev_t *viadev)
@@ -761,20 +777,16 @@
static int snd_via82xx_playback_close(snd_pcm_substream_t * substream)
{
via82xx_t *chip = snd_pcm_substream_chip(substream);
-
- clean_via_table(&chip->playback, substream, chip->pci);
- snd_pcm_sgbuf_delete(substream);
chip->playback.substream = NULL;
+ snd_pcm_sgbuf_delete(substream);
return 0;
}
static int snd_via82xx_capture_close(snd_pcm_substream_t * substream)
{
via82xx_t *chip = snd_pcm_substream_chip(substream);
-
- clean_via_table(&chip->capture, substream, chip->pci);
- snd_pcm_sgbuf_delete(substream);
chip->capture.substream = NULL;
+ snd_pcm_sgbuf_delete(substream);
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-10-30 14:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-30 4:23 [PATCH] sound/pci/via82xx.c "sleeping function called..." Josh Myer
2002-10-30 14:09 ` 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.