2007-08-03 22:21:35

by Gert Robben

[permalink] [raw]
Subject: PROBLEM: snd-au8830: dead after software suspend

After a suspend-resume cycle (using Suspend2), my sound card doesn't
work anymore. It works again after reloading the module.

dmesg, initial boot:
> Linux version 2.6.22-ck1
----8<----
> PCI driver au8830 lacks driver specific resume support.

dmesg, after resume, trying to use the card:
> vortex: ac97 codec stuck busy

Thanks for any help!

Gert Robben


2007-08-03 22:44:09

by Robert Hancock

[permalink] [raw]
Subject: Re: PROBLEM: snd-au8830: dead after software suspend

Gert Robben wrote:
> After a suspend-resume cycle (using Suspend2), my sound card doesn't
> work anymore. It works again after reloading the module.
>
> dmesg, initial boot:
>> Linux version 2.6.22-ck1
> ----8<----
>> PCI driver au8830 lacks driver specific resume support.
>
> dmesg, after resume, trying to use the card:
>> vortex: ac97 codec stuck busy
>
> Thanks for any help!

That driver will have to be updated to reinitialize the card properly
after resume.. Have you reported this to the ALSA people?

--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/

2007-08-04 00:12:15

by Gert Robben

[permalink] [raw]
Subject: Re: PROBLEM: snd-au8830: dead after software suspend

Robert Hancock wrote:
> Have you reported this to the ALSA people?
No, I thought this might as well be something for PCI or PM people, and
I expected some ALSA people are also reading this list.
If not, where else should I report this exactly?

Gert Robben

2007-08-04 00:18:31

by Jesper Juhl

[permalink] [raw]
Subject: Re: PROBLEM: snd-au8830: dead after software suspend

On 04/08/07, Gert Robben <[email protected]> wrote:
> Robert Hancock wrote:
> > Have you reported this to the ALSA people?
> No, I thought this might as well be something for PCI or PM people, and
> I expected some ALSA people are also reading this list.
> If not, where else should I report this exactly?
>

alsa-devel would seem to be a good starting point - see
http://www.alsa-project.org/mailing-lists.php
Also, the author of the driver, Manuel Jander <[email protected]>,
would probably be a good person to add to Cc.
And keeping LKML on Cc while sending to above people usually never hurts :-)

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

2007-08-04 00:51:52

by Gert Robben

[permalink] [raw]
Subject: Re: PROBLEM: snd-au8830: dead after software suspend

>>> Have you reported this to the ALSA people?
>> No, I thought this might as well be something for PCI or PM people, and
>> I expected some ALSA people are also reading this list.
>> If not, where else should I report this exactly?
> alsa-devel [...] the author of the driver
Done (original message below). Thanks again :)

Gert Robben wrote:
> After a suspend-resume cycle (using Suspend2), my sound card doesn't
> work anymore. It works again after reloading the module.
>
> dmesg, initial boot:
>> Linux version 2.6.22-ck1
> ----8<----
>> PCI driver au8830 lacks driver specific resume support.
>
> dmesg, after resume, trying to use the card:
>> vortex: ac97 codec stuck busy
>
> Thanks for any help!
>
> Gert Robben

2007-08-04 09:37:26

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: PROBLEM: snd-au8830: dead after software suspend

On Saturday, 4 August 2007 02:51, Gert Robben wrote:
> >>> Have you reported this to the ALSA people?
> >> No, I thought this might as well be something for PCI or PM people, and
> >> I expected some ALSA people are also reading this list.
> >> If not, where else should I report this exactly?
> > alsa-devel [...] the author of the driver
> Done (original message below). Thanks again :)

You also may want to file a bug at http://bugzilla.kernel.org .

If you decide to do that, please file it as
"Power Management"->Hibernation/Suspend bug, I'll redirect it to the ALSA
people.

Greetings,
Rafael


--
"Premature optimization is the root of all evil." - Donald Knuth

2007-08-06 13:30:59

by Takashi Iwai

[permalink] [raw]
Subject: Re: [alsa-devel] PROBLEM: snd-au8830: dead after software suspend

At Sat, 04 Aug 2007 02:51:44 +0200,
Gert Robben wrote:
>
> >>> Have you reported this to the ALSA people?
> >> No, I thought this might as well be something for PCI or PM people, and
> >> I expected some ALSA people are also reading this list.
> >> If not, where else should I report this exactly?
> > alsa-devel [...] the author of the driver
> Done (original message below). Thanks again :)
>
> Gert Robben wrote:
> > After a suspend-resume cycle (using Suspend2), my sound card doesn't
> > work anymore. It works again after reloading the module.
> >
> > dmesg, initial boot:
> >> Linux version 2.6.22-ck1
> > ----8<----
> >> PCI driver au8830 lacks driver specific resume support.
> >
> > dmesg, after resume, trying to use the card:
> >> vortex: ac97 codec stuck busy
> >
> > Thanks for any help!
> >
> > Gert Robben

The below is an untested fix. Give it a try.


Takashi

diff -r 23fc708178e1 pci/au88x0/au88x0.c
--- a/pci/au88x0/au88x0.c Mon Aug 06 14:05:27 2007 +0200
+++ b/pci/au88x0/au88x0.c Mon Aug 06 15:19:16 2007 +0200
@@ -78,7 +78,7 @@ static void vortex_fix_agp_bridge(struct
}
}

-static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix)
+static void snd_vortex_workaround(struct pci_dev *vortex, int fix)
{
struct pci_dev *via = NULL;

@@ -117,6 +117,50 @@ static void __devinit snd_vortex_workaro
pci_dev_put(via);
}

+/*
+ * Power management code
+ */
+#ifdef CONFIG_PM
+static int snd_vortex_suspend(struct pci_dev *pci, pm_message_t state)
+{
+ struct snd_card *card = pci_get_drvdata(pci);
+ struct snd_vortex *chip = card->private_data;
+ int i;
+
+ snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+ for (i = 0; i < VORTEX_PCM_LAST; i++)
+ snd_pcm_suspend_all(chip->pcm[i]);
+ snd_ac97_suspend(chip->codec);
+ vortex_core_shutdown(chip);
+ pci_disable_device(pci);
+ pci_save_state(pci);
+ return 0;
+}
+
+static int snd_vortex_resume(struct pci_dev *pci)
+{
+ struct snd_card *card = pci_get_drvdata(pci);
+ struct snd_vortex *chip = card->private_data;
+
+ pci_set_power_state(pci, PCI_D0);
+ pci_restore_state(pci);
+ if (pci_enable_device(pci) < 0) {
+ printk(KERN_ERR "au88x0: pci_enable_device failed, "
+ "disabling device\n");
+ snd_card_disconnect(card);
+ return -EIO;
+ }
+ pci_set_master(pci);
+ vortex_core_init(chip, 1);
+ snd_vortex_workaround(pci, chip->pcifix);
+ snd_ac97_resume(chip->codec);
+ vortex_connect_default(chip, 1);
+ vortex_enable_int(chip);
+ snd_power_change_state(card, SNDRV_CTL_POWER_D0);
+ return 0;
+}
+#endif /* CONFIG_PM */
+
// component-destructor
// (see "Management of Cards and Components")
static int snd_vortex_dev_free(struct snd_device *device)
@@ -192,7 +236,7 @@ snd_vortex_create(struct snd_card *card,
/* Init audio core.
* This must be done before we do request_irq otherwise we can get spurious
* interupts that we do not handle properly and make a mess of things */
- if ((err = vortex_core_init(chip)) != 0) {
+ if ((err = vortex_core_init(chip, 0)) != 0) {
printk(KERN_ERR "hw core init failed\n");
goto core_out;
}
@@ -262,7 +306,9 @@ snd_vortex_probe(struct pci_dev *pci, co
snd_card_free(card);
return err;
}
- snd_vortex_workaround(pci, pcifix[dev]);
+ card->private_data = chip;
+ chip->pcifix = pcifix[dev];
+ snd_vortex_workaround(pci, chip->pcifix);

// Card details needed in snd_vortex_midi
strcpy(card->driver, CARD_NAME_SHORT);
@@ -382,6 +428,10 @@ static struct pci_driver driver = {
.id_table = snd_vortex_ids,
.probe = snd_vortex_probe,
.remove = __devexit_p(snd_vortex_remove),
+#ifdef CONFIG_PM
+ .suspend = snd_vortex_suspend,
+ .resume = snd_vortex_resume,
+#endif
};

// initialization of the module
diff -r 23fc708178e1 pci/au88x0/au88x0.h
--- a/pci/au88x0/au88x0.h Mon Aug 06 14:05:27 2007 +0200
+++ b/pci/au88x0/au88x0.h Mon Aug 06 15:19:16 2007 +0200
@@ -178,7 +178,7 @@ struct snd_vortex {
/* PCI hardware resources */
unsigned long io;
void __iomem *mmio;
- unsigned int irq;
+ int irq;
spinlock_t lock;

/* PCI device */
@@ -186,6 +186,7 @@ struct snd_vortex {
u16 vendor;
u16 device;
u8 rev;
+ int pcifix;
};

/* Functions. */
@@ -233,7 +234,7 @@ static unsigned short vortex_codec_read(
static unsigned short vortex_codec_read(struct snd_ac97 * codec, unsigned short addr);
static void vortex_spdif_init(vortex_t * vortex, int spdif_sr, int spdif_mode);

-static int vortex_core_init(vortex_t * card);
+static int vortex_core_init(vortex_t * card, int do_resume);
static int vortex_core_shutdown(vortex_t * card);
static void vortex_enable_int(vortex_t * card);
static irqreturn_t vortex_interrupt(int irq, void *dev_id);
diff -r 23fc708178e1 pci/au88x0/au88x0_a3d.c
--- a/pci/au88x0/au88x0_a3d.c Mon Aug 06 14:05:27 2007 +0200
+++ b/pci/au88x0/au88x0_a3d.c Mon Aug 06 15:19:16 2007 +0200
@@ -593,7 +593,7 @@ static int vortex_a3d_register_controls(
static int vortex_a3d_register_controls(vortex_t * vortex);
static void vortex_a3d_unregister_controls(vortex_t * vortex);
/* A3D base support init/shudown */
-static void __devinit vortex_Vort3D_enable(vortex_t * v)
+static void vortex_Vort3D_enable(vortex_t * v)
{
int i;

diff -r 23fc708178e1 pci/au88x0/au88x0_core.c
--- a/pci/au88x0/au88x0_core.c Mon Aug 06 14:05:27 2007 +0200
+++ b/pci/au88x0/au88x0_core.c Mon Aug 06 15:19:16 2007 +0200
@@ -2658,7 +2658,7 @@ static void vortex_spdif_init(vortex_t *

/* Initialization */

-static int __devinit vortex_core_init(vortex_t * vortex)
+static int vortex_core_init(vortex_t * vortex, int do_resume)
{

printk(KERN_INFO "Vortex: init.... ");
@@ -2688,7 +2688,8 @@ static int __devinit vortex_core_init(vo
vortex_mixer_init(vortex);
vortex_srcblock_init(vortex);
#ifndef CHIP_AU8820
- vortex_eq_init(vortex);
+ if (!do_resume)
+ vortex_eq_init(vortex);
vortex_spdif_init(vortex, 48000, 1);
vortex_Vort3D_enable(vortex);
#endif

2007-08-06 16:15:39

by Gert Robben

[permalink] [raw]
Subject: Re: [alsa-devel] PROBLEM: snd-au8830: dead after software suspend

Takashi Iwai wrote:
> The below is an untested fix. Give it a try.
With the patch, things seem to be much better (but I'm no expert).

The things remaining seem to be:
- sound can't be heard
- MPlayer gives an error, instead of doing nothing.

I've enabled debugging, and did the following, without and with the patch:
boot, mplayer start+pause, suspend, resume, mplayer unpause+exit+start+exit,
rmmod.

Below is an edited diff of the dmesges (printk's begin with a "k"),
without and with the patch, with my comments added. I hope this is
enough info. If you need the full dmesges, let me know.

Anyway, thanks for you work :)

Gert Robben

--- without patch
+++ with patch
initial boot:
k ACPI: PCI Interrupt 0000:00:11.0[A] -> GSI 19 (level, low) -> IRQ 19
k Vortex: init.... <3>ALSA sound/core/control.c:331: control 3:0:0:Play
k back PCM advanced processing:0 is already present
k done.
-k PCI driver au8830 lacks driver specific resume support.
during suspend:
+k Vortex: shutdown...<6>done.
+k ACPI: PCI interrupt for device 0000:00:11.0 disabled
during resume:
+k PM: Writing back config space on device 0000:00:11.0 at offset 1 (was
k 2900007, writing 2900003)
k ACPI: PCI Interrupt 0000:00:11.0[A] -> GSI 19 (level, low) -> IRQ 19
+k Vortex: init.... <6>ata1.00: configured for UDMA/33
+k ALSA sound/core/control.c:331: control 3:0:0:Playback PCM advanced pr
k ocessing:0 is already present
+k done.
mplayer unpause:
+- gives mplayer error: alsa-lib: pcm_hw.c:612(snd_pcm_hw_pause) SNDRV_P
CM_IOCTL_PAUSE failed: File descriptor in bad state
- nothing else happens
mplayer exit:
+k vortex_adb_delroutes: route not found! 0x40
+k vortex_adb_delroutes: route not found! 0x2060
k src alarm
+k vortex_adb_delroutes: route not found! 0x41
+k vortex_adb_delroutes: route not found! 0x2161
k src alarm
mplayer start:
-- nothing happens
+- mplayer seems to play fine, but no sound can be heard
rmmod:
-k vortex: ac97 codec stuck busy
-k vortex: ac97 codec stuck busy
-k vortex: ac97 codec stuck busy
-k vortex: ac97 codec stuck busy
k analog.c: 0 out of 0 reads (0%) on pci0000:00:11.0/gameport0 failed
-k Vortex: shutdown...<3>mix ALARM 0
-k mix ALARM 0
-k mix ALARM 0
-k mix ALARM 0
-k mix ALARM 0
-k mix ALARM 0
-k done.
+k Vortex: shutdown...<6>done.
k ACPI: PCI interrupt for device 0000:00:11.0 disabled

2007-08-06 16:57:44

by Takashi Iwai

[permalink] [raw]
Subject: Re: [alsa-devel] PROBLEM: snd-au8830: dead after software suspend

At Mon, 06 Aug 2007 18:15:27 +0200,
Gert Robben wrote:
>
> Takashi Iwai wrote:
> > The below is an untested fix. Give it a try.
> With the patch, things seem to be much better (but I'm no expert).
>
> The things remaining seem to be:
> - sound can't be heard
> - MPlayer gives an error, instead of doing nothing.
>
> I've enabled debugging, and did the following, without and with the patch:
> boot, mplayer start+pause, suspend, resume, mplayer unpause+exit+start+exit,
> rmmod.
>
> Below is an edited diff of the dmesges (printk's begin with a "k"),
> without and with the patch, with my comments added. I hope this is
> enough info. If you need the full dmesges, let me know.
>

Hm, the routing inside the driver seems more (too) complicated than I
first took a glance. Sorry, I have no time for further digging right
now. Hopefully Manuel or any other guy will take over...


Takashi