From: Takashi Iwai <tiwai@suse.de>
To: Ingo Molnar <mingo@elte.hu>
Cc: Lee Revell <rlrevell@joe-job.com>,
Mark_H_Johnson@raytheon.com, "K.R. Foley" <kr@cybsft.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Felipe Alfaro Solana <lkml@felipe-alfaro.com>,
Daniel Schmitt <pnambic@unu.nu>,
alsa-devel <alsa-devel@lists.sourceforge.net>
Subject: Re: [patch] voluntary-preempt-2.6.9-rc1-bk4-Q5
Date: Tue, 31 Aug 2004 21:02:46 +0200 [thread overview]
Message-ID: <s5hisazyvu1.wl@alsa2.suse.de> (raw)
In-Reply-To: <20040831184846.GB25485@elte.hu>
At Tue, 31 Aug 2004 20:48:46 +0200,
Ingo Molnar wrote:
>
>
> * Takashi Iwai <tiwai@suse.de> wrote:
>
> > Does the attached patch fix this problem?
> >
> >
> > Takashi
> >
> > --- linux/sound/pci/ens1370.c 25 Aug 2004 09:57:03 -0000 1.64
> > +++ linux/sound/pci/ens1370.c 31 Aug 2004 18:17:45 -0000
> > @@ -513,6 +513,7 @@
> > r = inl(ES_REG(ensoniq, 1371_SMPRATE));
> > if ((r & ES_1371_SRC_RAM_BUSY) == 0)
> > return r;
> > + cond_resched();
>
> but ... snd_es1371_wait_src_ready() is being called with
> ensoniq->reg_lock held and you must not reschedule with a spinlock held.
Oh yes, you're right. I overlooked that.
> cond_resched_lock(&ensoniq->req_lock) might not crash immediately, but
> is it really safe to release the driver lock at this point?
The lock can be released, but then *_rate() functions may become racy
with each other.
Ok, the second try.
Takashi
--- linux/sound/pci/ens1370.c 25 Aug 2004 09:57:03 -0000 1.64
+++ linux/sound/pci/ens1370.c 31 Aug 2004 19:00:33 -0000
@@ -372,6 +372,7 @@
struct _snd_ensoniq {
spinlock_t reg_lock;
+ struct semaphore src_mutex;
int irq;
@@ -513,6 +514,7 @@
r = inl(ES_REG(ensoniq, 1371_SMPRATE));
if ((r & ES_1371_SRC_RAM_BUSY) == 0)
return r;
+ cond_resched();
}
snd_printk("wait source ready timeout 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_SMPRATE), r);
return 0;
@@ -696,6 +698,7 @@
{
unsigned int n, truncm, freq, result;
+ down(&ensoniq->src_mutex);
n = rate / 3000;
if ((1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9)))
n--;
@@ -719,12 +722,14 @@
snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff);
snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, n << 8);
snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, n << 8);
+ up(&ensoniq->src_mutex);
}
static void snd_es1371_dac1_rate(ensoniq_t * ensoniq, unsigned int rate)
{
unsigned int freq, r;
+ down(&ensoniq->src_mutex);
freq = ((rate << 15) + 1500) / 3000;
r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1)) | ES_1371_DIS_P1;
outl(r, ES_REG(ensoniq, 1371_SMPRATE));
@@ -734,12 +739,14 @@
snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff);
r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1));
outl(r, ES_REG(ensoniq, 1371_SMPRATE));
+ up(&ensoniq->src_mutex);
}
static void snd_es1371_dac2_rate(ensoniq_t * ensoniq, unsigned int rate)
{
unsigned int freq, r;
+ down(&ensoniq->src_mutex);
freq = ((rate << 15) + 1500) / 3000;
r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1)) | ES_1371_DIS_P2;
outl(r, ES_REG(ensoniq, 1371_SMPRATE));
@@ -749,6 +756,7 @@
snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff);
r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1));
outl(r, ES_REG(ensoniq, 1371_SMPRATE));
+ up(&ensoniq->src_mutex);
}
#endif /* CHIP1371 */
@@ -870,11 +878,12 @@
case 44100: ensoniq->ctrl |= ES_1370_WTSRSEL(3); break;
default: snd_BUG();
}
-#else
- snd_es1371_dac1_rate(ensoniq, runtime->rate);
#endif
outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
spin_unlock_irq(&ensoniq->reg_lock);
+#ifndef CHIP1370
+ snd_es1371_dac1_rate(ensoniq, runtime->rate);
+#endif
return 0;
}
@@ -908,11 +917,12 @@
ensoniq->ctrl |= ES_1370_PCLKDIVO(ES_1370_SRTODIV(runtime->rate));
ensoniq->u.es1370.pclkdiv_lock |= ES_MODE_PLAY2;
}
-#else
- snd_es1371_dac2_rate(ensoniq, runtime->rate);
#endif
outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
spin_unlock_irq(&ensoniq->reg_lock);
+#ifndef CHIP1370
+ snd_es1371_dac2_rate(ensoniq, runtime->rate);
+#endif
return 0;
}
@@ -944,11 +954,12 @@
ensoniq->ctrl |= ES_1370_PCLKDIVO(ES_1370_SRTODIV(runtime->rate));
ensoniq->u.es1370.pclkdiv_lock |= ES_MODE_CAPTURE;
}
-#else
- snd_es1371_adc_rate(ensoniq, runtime->rate);
#endif
outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
spin_unlock_irq(&ensoniq->reg_lock);
+#ifndef CHIP1370
+ snd_es1371_adc_rate(ensoniq, runtime->rate);
+#endif
return 0;
}
@@ -1886,6 +1897,7 @@
if (ensoniq == NULL)
return -ENOMEM;
spin_lock_init(&ensoniq->reg_lock);
+ init_MUTEX(&ensoniq->src_mutex);
ensoniq->card = card;
ensoniq->pci = pci;
ensoniq->irq = -1;
next prev parent reply other threads:[~2004-08-31 19:06 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-31 15:17 [patch] voluntary-preempt-2.6.9-rc1-bk4-Q5 Mark_H_Johnson
2004-08-31 17:20 ` Lee Revell
2004-08-31 18:09 ` Lee Revell
2004-08-31 18:53 ` Takashi Iwai
2004-08-31 18:56 ` Ingo Molnar
2004-09-02 16:59 ` Jaroslav Kysela
2004-09-02 17:50 ` Lee Revell
2004-08-31 18:19 ` Takashi Iwai
2004-08-31 18:48 ` Ingo Molnar
2004-08-31 19:02 ` Takashi Iwai [this message]
2004-08-31 18:50 ` Ingo Molnar
[not found] <OFD220F58F.002C5901-ON86256F02.005C2FB1-86256F02.005C2FD5@raytheon.com>
2004-09-01 17:09 ` Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2004-09-01 15:21 Mark_H_Johnson
2004-09-02 22:24 ` Ingo Molnar
2004-09-01 14:37 Mark_H_Johnson
2004-09-01 19:31 ` Takashi Iwai
[not found] <2yiVZ-IZ-15@gated-at.bofh.it>
[not found] ` <2ylhi-2hg-3@gated-at.bofh.it>
[not found] ` <2ynLU-42D-7@gated-at.bofh.it>
[not found] ` <2yqJJ-5ZL-1@gated-at.bofh.it>
[not found] ` <2yQkS-6Zh-13@gated-at.bofh.it>
[not found] ` <2zaCV-4FE-3@gated-at.bofh.it>
[not found] ` <2zaWk-4Yj-9@gated-at.bofh.it>
[not found] ` <2zmE8-4Zz-11@gated-at.bofh.it>
[not found] ` <2zngP-5wD-9@gated-at.bofh.it>
[not found] ` <2zngP-5wD-7@gated-at.bofh.it>
[not found] ` <2znJS-5Pm-25@gated-at.bofh.it>
2004-08-31 23:06 ` Andi Kleen
[not found] ` <2znJS-5Pm-27@gated-at.bofh.it>
[not found] ` <2znJS-5Pm-29@gated-at.bofh.it>
[not found] ` <2znJS-5Pm-31@gated-at.bofh.it>
[not found] ` <2znJS-5Pm-33@gated-at.bofh.it>
2004-08-31 23:10 ` Andi Kleen
2004-09-01 7:05 ` Ingo Molnar
2004-08-31 20:10 Mark_H_Johnson
2004-08-31 20:37 ` Ingo Molnar
2004-08-31 12:46 Mark_H_Johnson
2004-08-30 22:04 Mark_H_Johnson
2004-08-31 6:31 ` Ingo Molnar
2004-09-01 7:30 ` Ingo Molnar
2004-08-30 19:13 Mark_H_Johnson
2004-08-30 19:21 ` Ingo Molnar
2004-08-31 8:49 ` Ingo Molnar
2004-09-02 6:33 ` Ingo Molnar
2004-08-28 17:52 [patch] voluntary-preempt-2.6.9-rc1-bk4-Q0 Lee Revell
2004-08-28 19:44 ` [patch] voluntary-preempt-2.6.9-rc1-bk4-Q2 Ingo Molnar
2004-08-28 20:10 ` Daniel Schmitt
2004-08-28 20:31 ` [patch] voluntary-preempt-2.6.9-rc1-bk4-Q3 Ingo Molnar
2004-08-28 21:10 ` Lee Revell
2004-08-28 21:13 ` Ingo Molnar
2004-08-28 21:16 ` Lee Revell
2004-08-28 23:51 ` Lee Revell
2004-08-29 2:35 ` Lee Revell
2004-08-29 5:43 ` [patch] voluntary-preempt-2.6.9-rc1-bk4-Q4 Ingo Molnar
2004-08-30 9:06 ` [patch] voluntary-preempt-2.6.9-rc1-bk4-Q5 Ingo Molnar
2004-08-30 14:25 ` Thomas Charbonnel
2004-08-30 18:00 ` Ingo Molnar
2004-08-31 19:23 ` Thomas Charbonnel
2004-08-31 19:30 ` Ingo Molnar
2004-08-31 19:45 ` Thomas Charbonnel
2004-08-31 6:40 ` Lee Revell
2004-08-31 6:53 ` Ingo Molnar
2004-08-31 23:03 ` Lee Revell
2004-09-01 15:52 ` Martin Josefsson
2004-09-01 21:15 ` Lee Revell
2004-09-01 21:30 ` Lee Revell
2004-08-31 7:06 ` Ingo Molnar
2004-08-31 19:21 ` Lee Revell
2004-08-31 19:37 ` Ingo Molnar
2004-08-31 19:47 ` Lee Revell
2004-08-31 19:51 ` Ingo Molnar
2004-08-31 20:09 ` Ingo Molnar
2004-08-31 20:10 ` Lee Revell
2004-08-31 20:14 ` Ingo Molnar
2004-08-31 20:20 ` Ingo Molnar
2004-08-31 20:34 ` Lee Revell
2004-08-31 20:39 ` Ingo Molnar
2004-08-31 20:41 ` Lee Revell
2004-08-31 17:40 ` Peter Zijlstra
2004-09-01 1:43 ` Lee Revell
2004-09-01 2:30 ` Lee Revell
2004-09-01 7:27 ` Lee Revell
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=s5hisazyvu1.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=Mark_H_Johnson@raytheon.com \
--cc=alsa-devel@lists.sourceforge.net \
--cc=kr@cybsft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@felipe-alfaro.com \
--cc=mingo@elte.hu \
--cc=pnambic@unu.nu \
--cc=rlrevell@joe-job.com \
/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