On 21-07-08 16:19, Media Fan wrote:

I'm new to ALSA and Linux sound, not sure if anything I missed. Sorry for late reply, I spent 2 days to have above results :-p

Very sorry to have put you though all that but at least you came through with flying colours. This is actually very interesting.

ALSA /home/box1/alsa/alsa-driver-1.0.17/pci/ens1370.c:714: codec read timeout 
(final) at 0x9014, reg = 0x7c [0x7c8384]
ALSA /home/box1/alsa/alsa-driver-1.0.17/pci/ens1370.c:714: codec read timeout 
(final) at 0x9014, reg = 0x7e [0x7e7605]
ALSA /home/box1/alsa/alsa-driver-1.0.17/pci/ens1370.c:714: codec read timeout 
(final) at 0x9014, reg = 0x0 [0x140]
ALSA /home/box1/alsa/alsa-driver-1.0.17/pci/ens1370.c:714: codec read timeout 
(final) at 0x9014, reg = 0x7c [0x7c8384]
ALSA /home/box1/alsa/alsa-driver-1.0.17/pci/ens1370.c:714: codec read timeout 
(final) at 0x9014, reg = 0x7e [0x7e7605]
ALSA /home/box1/alsa/alsa-driver-1.0.17/pci/ens1370.c:714: codec read timeout 
(final) at 0x9014, reg = 0x7c [0x7c8384]
ALSA /home/box1/alsa/alsa-driver-1.0.17/pci/ens1370.c:714: codec read timeout 
(final) at 0x9014, reg = 0x7e [0x7e7605]
ALSA /home/box1/alsa/alsa-driver-1.0.17/pci/ac97/ac97_codec.c:2071: AC'97 0 
access is not valid [0x0], removing mixer.
ACPI: PCI interrupt for device 0000:02:02.0 disabled
ENS1371: probe of 0000:02:02.0 failed with error -5

Firstly, we note that the codec definitely identifies as a SigmaTel STAC9704 but more importantly, we note that we're too _slow_ which shouldn't really have happened (and ofcourse didn't locally).

I have attached the next attempt and given the history of this thing, I believe this actually stands a fair chance of bringing this thing back in line.

Ofcourse, take all the time you need or want. It's again against kernel 2.6.26/2.6.25.x (and/or alsa-driver-1.0.17 which I saw you use) same as the previous patch since you said you reverted that again.

No rush...

Rene.

>From 86d9e8d586df4d5065464db57506b75c999a5647 Mon Sep 17 00:00:00 2001
From: Rene Herman <[EMAIL PROTECTED]>
Date: Mon, 21 Jul 2008 21:57:13 +0200
Subject: [PATCH] ALSA: ens1371: replace src_mutex by the reg_lock spinlock

Signed-off-by: Rene Herman <[EMAIL PROTECTED]>
---
 sound/pci/ens1370.c |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index fbf1124..afed500 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -380,7 +380,6 @@ MODULE_PARM_DESC(lineio, "Line In to Rear Out (0 = auto, 1 
= force).");
 
 struct ensoniq {
        spinlock_t reg_lock;
-       struct mutex src_mutex;
 
        int irq;
 
@@ -520,7 +519,7 @@ static unsigned int snd_es1371_wait_src_ready(struct 
ensoniq * ensoniq)
                r = inl(ES_REG(ensoniq, 1371_SMPRATE));
                if ((r & ES_1371_SRC_RAM_BUSY) == 0)
                        return r;
-               cond_resched();
+               udelay(1);
        }
        snd_printk(KERN_ERR "wait source ready timeout 0x%lx [0x%x]\n",
                   ES_REG(ensoniq, 1371_SMPRATE), r);
@@ -606,10 +605,11 @@ static void snd_es1371_codec_write(struct snd_ac97 *ac97,
                                   unsigned short reg, unsigned short val)
 {
        struct ensoniq *ensoniq = ac97->private_data;
+       unsigned long flags;
        unsigned int t, x;
 
-       mutex_lock(&ensoniq->src_mutex);
        for (t = 0; t < POLL_COUNT; t++) {
+               spin_lock_irqsave(&ensoniq->reg_lock, flags);
                if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) {
                        /* save the current state for latter */
                        x = snd_es1371_wait_src_ready(ensoniq);
@@ -633,11 +633,11 @@ static void snd_es1371_codec_write(struct snd_ac97 *ac97,
                        /* restore SRC reg */
                        snd_es1371_wait_src_ready(ensoniq);
                        outl(x, ES_REG(ensoniq, 1371_SMPRATE));
-                       mutex_unlock(&ensoniq->src_mutex);
+                       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
                        return;
                }
+               spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
        }
-       mutex_unlock(&ensoniq->src_mutex);
        snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n",
                   ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 
1371_CODEC)));
 }
@@ -646,11 +646,12 @@ static unsigned short snd_es1371_codec_read(struct 
snd_ac97 *ac97,
                                            unsigned short reg)
 {
        struct ensoniq *ensoniq = ac97->private_data;
+       unsigned long flags;
        unsigned int t, x, fail = 0;
 
       __again:
-       mutex_lock(&ensoniq->src_mutex);
        for (t = 0; t < POLL_COUNT; t++) {
+               spin_lock_irqsave(&ensoniq->reg_lock, flags);
                if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) {
                        /* save the current state for latter */
                        x = snd_es1371_wait_src_ready(ensoniq);
@@ -682,11 +683,11 @@ static unsigned short snd_es1371_codec_read(struct 
snd_ac97 *ac97,
                        /* now wait for the stinkin' data (RDY) */
                        for (t = 0; t < POLL_COUNT; t++) {
                                if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & 
ES_1371_CODEC_RDY) {
-                                       mutex_unlock(&ensoniq->src_mutex);
+                                       
spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
                                        return ES_1371_CODEC_READ(x);
                                }
                        }
-                       mutex_unlock(&ensoniq->src_mutex);
+                       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
                        if (++fail > 10) {
                                snd_printk(KERN_ERR "codec read timeout (final) 
"
                                           "at 0x%lx, reg = 0x%x [0x%x]\n",
@@ -696,8 +697,8 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 
*ac97,
                        }
                        goto __again;
                }
+               spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
        }
-       mutex_unlock(&ensoniq->src_mutex);
        snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n",
                   ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 
1371_CODEC)));
        return 0;
@@ -715,8 +716,9 @@ static void snd_es1371_codec_wait(struct snd_ac97 *ac97)
 static void snd_es1371_adc_rate(struct ensoniq * ensoniq, unsigned int rate)
 {
        unsigned int n, truncm, freq, result;
+       unsigned long flags;
 
-       mutex_lock(&ensoniq->src_mutex);
+       spin_lock_irqsave(&ensoniq->reg_lock, flags);
        n = rate / 3000;
        if ((1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9)))
                n--;
@@ -741,14 +743,15 @@ static void snd_es1371_adc_rate(struct ensoniq * ensoniq, 
unsigned int rate)
        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);
-       mutex_unlock(&ensoniq->src_mutex);
+       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
 }
 
 static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate)
 {
        unsigned int freq, r;
+       unsigned long flags;
 
-       mutex_lock(&ensoniq->src_mutex);
+       spin_lock_irqsave(&ensoniq->reg_lock, flags);
        freq = ((rate << 15) + 1500) / 3000;
        r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE |
                                                   ES_1371_DIS_P2 | 
ES_1371_DIS_R1)) |
@@ -762,14 +765,15 @@ static void snd_es1371_dac1_rate(struct ensoniq * 
ensoniq, unsigned int rate)
        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));
-       mutex_unlock(&ensoniq->src_mutex);
+       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
 }
 
 static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate)
 {
        unsigned int freq, r;
+       unsigned long flags;
 
-       mutex_lock(&ensoniq->src_mutex);
+       spin_lock_irqsave(&ensoniq->reg_lock, flags);
        freq = ((rate << 15) + 1500) / 3000;
        r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE |
                                                   ES_1371_DIS_P1 | 
ES_1371_DIS_R1)) |
@@ -784,7 +788,7 @@ static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, 
unsigned int rate)
        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));
-       mutex_unlock(&ensoniq->src_mutex);
+       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
 }
 
 #endif /* CHIP1371 */
@@ -2092,7 +2096,6 @@ static int __devinit snd_ensoniq_create(struct snd_card 
*card,
                return -ENOMEM;
        }
        spin_lock_init(&ensoniq->reg_lock);
-       mutex_init(&ensoniq->src_mutex);
        ensoniq->card = card;
        ensoniq->pci = pci;
        ensoniq->irq = -1;
-- 
1.5.5

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user

Reply via email to