Skip to contentSkip to conversation

revert yenta free_irq on suspend

PATCH Hugh Dickins 7 participants 23 messages Jul 30, 2005 – Aug 1, 2005

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Please revert the yenta free_irq on suspend patch (below) which went into 2.6.13-rc4 after 2.6.13-rc3-git9.

Sorry Daniel, you may have a box on which resume doesn't work without it, but on my laptop APM resume from RAM now fails to work because of it - locks up solid. The patch sounded rather fishy when it went in, but I've done an unprejudiced bisection and this turns out to be the culprit. Perhaps it needs something more (I can try further patches), but as it stands it's unsuitable for 2.6.13.

Do I recall a worry about shared interrupts? I indeed have
PCI: Found IRQ 11 for device 0000:00:1f.1
PCI: Sharing IRQ 11 with 0000:02:00.0
PCI: Found IRQ 11 for device 0000:02:00.0
PCI: Sharing IRQ 11 with 0000:00:1f.1
PCI: Found IRQ 11 for device 0000:02:01.0
PCI: Sharing IRQ 11 with 0000:02:01.1
PCI: Found IRQ 11 for device 0000:02:01.1
PCI: Sharing IRQ 11 with 0000:02:01.0
on resume before that patch, and again now I've backed it out.

Thanks,
Hugh

From: Daniel Ritz <[email protected]>

Resume doesn't seem to work without.

---

 drivers/pcmcia/yenta_socket.c |    9 +++++++++
 1 files changed, 9 insertions(+)
drivers/pcmcia/yenta_socket.c renamed from drivers/pcmcia/yenta_socket.c~yenta-free_irq-on-suspend +9 -0
diff -puN drivers/pcmcia/yenta_socket.c~yenta-free_irq-on-suspend drivers/pcmcia/yenta_socket.c
@@ -1107,6 +1107,8 @@ static int yenta_dev_suspend (struct pci
 		pci_read_config_dword(dev, 17*4, &socket->saved_state[1]);
 		pci_disable_device(dev);
 
+		free_irq(dev->irq, socket);
+
 		/*
 		 * Some laptops (IBM T22) do not like us putting the Cardbus
 		 * bridge into D3.  At a guess, some other laptop will
@@ -1132,6 +1134,13 @@ static int yenta_dev_resume (struct pci_
 		pci_enable_device(dev);
 		pci_set_master(dev);
 
+		if (socket->cb_irq)
+			if (request_irq(socket->cb_irq, yenta_interrupt,
+			                SA_SHIRQ, "yenta", socket)) {
+				printk(KERN_WARNING "Yenta: request_irq() failed on resume!\n");
+				socket->cb_irq = 0;
+			}
+
 		if (socket->type && socket->type->restore_state)
 			socket->type->restore_state(socket);
 	}
#1 lore raw
Quoted 9 lines · Hugh Dickins

Please revert the yenta free_irq on suspend patch (below) which went into 2.6.13-rc4 after 2.6.13-rc3-git9.

Sorry Daniel, you may have a box on which resume doesn't work without it, but on my laptop APM resume from RAM now fails to work because of it - locks up solid. The patch sounded rather fishy when it went in, but I've done an unprejudiced bisection and this turns out to be the culprit. Perhaps it needs something more (I can try further patches), but as it stands it's unsuitable for 2.6.13.

What this probably means is that we need some way to turn off interrupts from devices on suspend, and on resume, keep them off until drivers have had a chance to quiesce all devices, turn them back on, and then do full resume.

The "quiesce" stage needs to take account of whether devices are accessible (eg, USB mice and keyboards won't be because the USB host controller isn't resumed.)

(and no I don't have a patch for this - I think this requires another rework of the PM subsystem and drivers.) ;(

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#10 lore raw
In reply to Hugh Dickins
Quoted 3 lines · Hugh Dickins

Please revert the yenta free_irq on suspend patch (below) which went into 2.6.13-rc4 after 2.6.13-rc3-git9.

Ok. Will do.

And the ACPI people had better stop doing this crazy thing in the first place. There's really no point at all to freeing and re-requesting the interrupts, and the IRQ controller should just re-initialize itself instead.

The excuse for not doing so was totally ludicrous in the first place, if I recall correctly. Use GFP_ATOMIC in ACPI if you do things with interrupts disabled, don't break a million drivers.

Linus

#2 lore raw
In reply to Russell King
Quoted 5 lines · Russell King

What this probably means is that we need some way to turn off interrupts from devices on suspend, and on resume, keep them off until drivers have had a chance to quiesce all devices, turn them back on, and then do full resume.

No, we just need to suspend and resume the interrupt controller properly. Which we had the technology for, and we actually used to do, but for some (incorrect) reason ACPI people thought it should be up to individual drivers.

Linus

#14 lore raw
In reply to Hugh Dickins
Quoted 6 lines · Hugh Dickins

Please revert the yenta free_irq on suspend patch (below) which went into 2.6.13-rc4 after 2.6.13-rc3-git9.

Sorry Daniel, you may have a box on which resume doesn't work without it, but on my laptop APM resume from RAM now fails to work because of it - locks up solid.

Well, the patch is needed on other boxes too (eg. mine :-)) due to the recent changes in ACPI.

Could you please send the /proc/interrupts from your box?

Rafael

Signature · 3 lines
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
		-- Lewis Carroll "Alice's Adventures in Wonderland"
#3 lore raw
In reply to Linus Torvalds
Quoted 11 lines · Linus Torvalds
Quoted 5 lines · Russell King

What this probably means is that we need some way to turn off interrupts from devices on suspend, and on resume, keep them off until drivers have had a chance to quiesce all devices, turn them back on, and then do full resume.

No, we just need to suspend and resume the interrupt controller properly. Which we had the technology for, and we actually used to do, but for some (incorrect) reason ACPI people thought it should be up to individual drivers.

I don't think so - I believe one of the problem cases is where you have a screaming interrupt caused by an improperly setup device.

Consider the case where you have a shared interrupt line and you're partially through resuming devices, when one unresumed device (setup by the BIOS) suddenly starts asserting its interrupt.

The kernel then disables the source. Unfortunately, that was the IRQ for your USB host, which has your USB keyboard and mouse attached.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#15 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 6 lines · Hugh Dickins

Please revert the yenta free_irq on suspend patch (below) which went into 2.6.13-rc4 after 2.6.13-rc3-git9.

Sorry Daniel, you may have a box on which resume doesn't work without it, but on my laptop APM resume from RAM now fails to work because of it - locks up solid.

Well, the patch is needed on other boxes too (eg. mine :-)) due to the recent changes in ACPI.

well, i have been told so. but when i asked 'why?' nobody answered something else than because of a ACPI change.

the patch already died in the git tree which is good.

rgds
-daniel

#4 lore raw
In reply to Russell King
Quoted 3 lines · Russell King

I don't think so - I believe one of the problem cases is where you have a screaming interrupt caused by an improperly setup device.

Not a problem.

The thing is, this is trivially solved by
- disable irq controller last on shutdown
- re-enable irq controller last on resume

Think about it. Even if you have screaming irq's (and thus we'll shut things down somewhere during the resume), when we then get to re-enable the irq controller thing, we'll have them all back again at that point. Problem solved.

You can have variations on this, of course - you can enable the irq controller early _and_ late in the resume process. Ie do a minimal "get the basics working" early - you might want to make sure that timers etc work early on, for example, and then a "fix up the details" thing late.

An interrupt controller is clearly a special case, so it's worth spending some effort on handling it.

In contrast, what is _not_ worth doing is screweing over every single driver we have.

Linus

#9 lore raw
In reply to Russell King
Quoted 8 lines · Russell King
Quoted 7 lines · Linus Torvalds
Quoted 5 lines · Russell King

What this probably means is that we need some way to turn off interrupts from devices on suspend, and on resume, keep them off until drivers have had a chance to quiesce all devices, turn them back on, and then do full resume.

Quoted 7 lines
Quoted 4 lines

No, we just need to suspend and resume the interrupt controller properly. Which we had the technology for, and we actually used to do, but for some (incorrect) reason ACPI people thought it should be up to individual drivers.

I don't think so - I believe one of the problem cases is where you have a screaming interrupt caused by an improperly setup device.

This is happening in the real life, it seems (eg please see
http://bugzilla.kernel.org/show_bug.cgi?id=4416#c36).

Quoted 6 lines

Consider the case where you have a shared interrupt line and you're partially through resuming devices, when one unresumed device (setup by the BIOS) suddenly starts asserting its interrupt.

The kernel then disables the source. Unfortunately, that was the IRQ for your USB host, which has your USB keyboard and mouse attached.

Also, this has been discussed in this thread on the linux-pm list:
http://lists.osdl.org/pipermail/linux-pm/2005-May/000955.html

Greets,
Rafael

Signature · 3 lines
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
		-- Lewis Carroll "Alice's Adventures in Wonderland"
#5 lore raw
In reply to Linus Torvalds
Quoted 9 lines · Linus Torvalds
Quoted 2 lines · Russell King

I don't think so - I believe one of the problem cases is where you have a screaming interrupt caused by an improperly setup device.

Not a problem.

The thing is, this is trivially solved by
- disable irq controller last on shutdown
- re-enable irq controller last on resume

I reserve further judgement on this idea until it's had some field testing. 8)

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#16 lore raw
In reply to Rafael J. Wysocki
Quoted 5 lines · Rafael J. Wysocki

Well, the patch is needed on other boxes too (eg. mine :-)) due to the recent changes in ACPI.

Could you please send the /proc/interrupts from your box?

CPU0

  0:    2818513          XT-PIC  timer
  1:      56790          XT-PIC  i8042
  2:          0          XT-PIC  cascade
  8:          2          XT-PIC  rtc
 11:      57443          XT-PIC  yenta, yenta, eth0
 12:     110579          XT-PIC  i8042
 14:      31332          XT-PIC  ide0
 15:     100988          XT-PIC  ide1
NMI:          0 
LOC:          0 
ERR:          0
MIS:          0
#17 lore raw
Quoted 8 lines · Hugh Dickins
Quoted 5 lines · Rafael J. Wysocki

Well, the patch is needed on other boxes too (eg. mine :-)) due to the recent changes in ACPI.

Could you please send the /proc/interrupts from your box?

CPU0

Quoted 12 lines
  0:    2818513          XT-PIC  timer
  1:      56790          XT-PIC  i8042
  2:          0          XT-PIC  cascade
  8:          2          XT-PIC  rtc
 11:      57443          XT-PIC  yenta, yenta, eth0
 12:     110579          XT-PIC  i8042
 14:      31332          XT-PIC  ide0
 15:     100988          XT-PIC  ide1
NMI:          0 
LOC:          0 
ERR:          0
MIS:          0

Thanks. It looks like eth0 gets a yenta's interrupt and goes awry. Could you please tell me what driver the eth0 is?

Rafael

Signature · 3 lines
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
		-- Lewis Carroll "Alice's Adventures in Wonderland"
#18 lore raw
Quoted 9 lines · Rafael J. Wysocki
Quoted 5 lines · Hugh Dickins
Quoted 2 lines · Rafael J. Wysocki

Could you please send the /proc/interrupts from your box?

11: 57443 XT-PIC yenta, yenta, eth0

Thanks. It looks like eth0 gets a yenta's interrupt and goes awry. Could you please tell me what driver the eth0 is?

CONFIG_VORTEX drivers/net/3c59x.c:
0000:02:00.0: 3Com PCI 3c905C Tornado at 0xec80. Vers LK1.1.19

#6 lore raw
In reply to Linus Torvalds
Quoted 22 lines · Linus Torvalds
Quoted 3 lines · Russell King

I don't think so - I believe one of the problem cases is where you have a screaming interrupt caused by an improperly setup device.

Not a problem.

The thing is, this is trivially solved by
- disable irq controller last on shutdown
- re-enable irq controller last on resume

Think about it. Even if you have screaming irq's (and thus we'll shut things down somewhere during the resume), when we then get to re-enable the irq controller thing, we'll have them all back again at that point. Problem solved.

You can have variations on this, of course - you can enable the irq controller early _and_ late in the resume process. Ie do a minimal "get the basics working" early - you might want to make sure that timers etc work early on, for example, and then a "fix up the details" thing late.

Quoted 5 lines

An interrupt controller is clearly a special case, so it's worth spending some effort on handling it.

In contrast, what is _not_ worth doing is screweing over every single driver we have.

Well, they have _already_ been screwed by the following patch that went to your tree with the ACPI update. If you drop it, all problems related to freeing/requesting IRQs on suspend/resume will be gone.

Please note, however, that what it does is to get rid of unconditional setting ACPI PCI links on resume in hope that someone will take care of them later, which is not quite right, so to speak.

In my opinion the time for introducing this change is not the best, to put it
lightly, but it looks like it will have to be made at some point. Still I'm not
an ACPI expert, so Len could you please advise?

Greets,
Rafael

drivers/acpi/pci_link.c +14 -22
diff -Naru a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
@@ -72,10 +72,12 @@
 	u8			active;			/* Current IRQ */
 	u8			edge_level;		/* All IRQs */
 	u8			active_high_low;	/* All IRQs */
-	u8			initialized;
 	u8			resource_type;
 	u8			possible_count;
 	u8			possible[ACPI_PCI_LINK_MAX_POSSIBLE];
+	u8			initialized:1;
+	u8			suspend_resume:1;
+	u8			reserved:6;
 };
 
 struct acpi_pci_link {
@@ -530,6 +532,10 @@
 
 	ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
 
+	if (link->irq.suspend_resume) {
+		acpi_pci_link_set(link, link->irq.active);
+		link->irq.suspend_resume = 0;
+	}
 	if (link->irq.initialized)
 		return_VALUE(0);
 
@@ -713,38 +719,24 @@
 	return_VALUE(result);
 }
 
-
-static int
-acpi_pci_link_resume (
-	struct acpi_pci_link	*link)
-{
-	ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
-	
-	if (link->irq.active && link->irq.initialized)
-		return_VALUE(acpi_pci_link_set(link, link->irq.active));
-	else
-		return_VALUE(0);
-}
-
-
 static int
-irqrouter_resume(
-	struct sys_device *dev)
+irqrouter_suspend(
+	struct sys_device *dev,
+	u32	state)
 {
 	struct list_head        *node = NULL;
 	struct acpi_pci_link    *link = NULL;
 
-	ACPI_FUNCTION_TRACE("irqrouter_resume");
+	ACPI_FUNCTION_TRACE("irqrouter_suspend");
 
 	list_for_each(node, &acpi_link.entries) {
-
 		link = list_entry(node, struct acpi_pci_link, node);
 		if (!link) {
 			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
 			continue;
 		}
-
-		acpi_pci_link_resume(link);
+		if (link->irq.active && link->irq.initialized)
+			link->irq.suspend_resume = 1;
 	}
 	return_VALUE(0);
 }
@@ -856,7 +848,7 @@
 
 static struct sysdev_class irqrouter_sysdev_class = {
         set_kset_name("irqrouter"),
-        .resume = irqrouter_resume,
+        .suspend = irqrouter_suspend,
 };
 
 
Signature · 3 lines
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
		-- Lewis Carroll "Alice's Adventures in Wonderland"
#19 lore raw
In reply to Hugh Dickins
Quoted 6 lines · Hugh Dickins
Quoted 5 lines · Rafael J. Wysocki
Quoted 4 lines · Hugh Dickins
Quoted 2 lines · Rafael J. Wysocki

Could you please send the /proc/interrupts from your box?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

11: 57443 XT-PIC yenta, yenta, eth0

Thanks. It looks like eth0 gets a yenta's interrupt and goes awry. Could you please tell me what driver the eth0 is?

CONFIG_VORTEX drivers/net/3c59x.c:
0000:02:00.0: 3Com PCI 3c905C Tornado at 0xec80. Vers LK1.1.19

Thanks again. From the first look the suspend/resume routines of the driver are missing some calls. In particular, with the IRQ-freeing patch for yenta it is likely to get an out-of-order interrupt as I suspected.

Linus has apparently dropped that patch for yenta, but in case it is reintroduced in the future you will probably need a patch to make the network driver cooperate. I'll try to prepare one tomorrow, if I can, but I have no hardware to test it.

Greets,
Rafael

Signature · 3 lines
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
		-- Lewis Carroll "Alice's Adventures in Wonderland"
#7 lore raw
In reply to Rafael J. Wysocki
Quoted 4 lines · Rafael J. Wysocki

Well, they have _already_ been screwed by the following patch that went to your tree with the ACPI update. If you drop it, all problems related to freeing/requesting IRQs on suspend/resume will be gone.

Yes. I really think we need to revert that patch, we just can't fix this any other way in the short run - the "request_irq/free_irq()" thing has broken too many setups. And we _need_ an answer for the short run, since I want to be able to release 2.6.13 without having lots of peoples laptop suspends be broken.

Yes, I realize that it fixed suspend for some people, but the thing is, anything that expects lots of drivers to change just is fundamentally broken. In a perfect world we might be able to get all drivers to do the right thing, but dammit, in a perfect world we wouldn't have ACPI in the first place.

So I guess I'll just have to revert the ACPI change that caused drivers to do request_irq/free_irq. I'd prefer it if the ACPI people did that revert themselves, though.

Linus

#11 lore raw
In reply to Linus Torvalds

Hi!

Quoted 9 lines
Quoted 2 lines

Please revert the yenta free_irq on suspend patch (below) which went into 2.6.13-rc4 after 2.6.13-rc3-git9.

Ok. Will do.

And the ACPI people had better stop doing this crazy thing in the first place. There's really no point at all to freeing and re-requesting the interrupts, and the IRQ controller should just re-initialize itself instead.

Well, on some machines interrupts can change during suspend (or so I was told). I did not like the ACPI change at one point, but it is very wrong to revert PCMCIA fix without also fixing ACPI interpretter.

And it indeed seems that ACPI interpretter is hard to fix in the right way.

Pavel

Signature · 1 line
if you have sharp zaurus hardware you don't need... you know my address
#12 lore raw
Quoted 4 lines · Pavel Machek

Well, on some machines interrupts can change during suspend (or so I was told). I did not like the ACPI change at one point, but it is very wrong to revert PCMCIA fix without also fixing ACPI interpretter.

We _are_ going to fix the ACPI interpreter.

As to irq's changing during suspend - I'll believe that when I see it, not when some chicken little runs around worrying about it. I doubt anybody has ever seen it, and I'm 100% sure that we have serious breakage right now on machines where it definitely doesn't happen.

Quoted 2 lines

And it indeed seems that ACPI interpretter is hard to fix in the right way.

We'll revert to the behaviour that it has traditionally had, and start working forwards in a more careful manner. Where we don't break working setups.

Linus

#13 lore raw
Quoted 4 lines · Linus Torvalds

We'll revert to the behaviour that it has traditionally had, and start working forwards in a more careful manner. Where we don't break working setups.

Here's a suggested revert (a pure "patch -R" won't work, since there's been other differences since). It works for me, and suspends/resumes from RAM on my EVO with all the irq links getting re-programmed (dmesg is very clear about that ;).

It's pretty much the old 2.6.12 code, updated for the refcounting etc.

Linus

----

drivers/acpi/pci_link.c +18 -21
@@ -776,15 +776,25 @@ end:
 }
 
 static int
-irqrouter_suspend(
-	struct sys_device *dev,
-	u32	state)
+acpi_pci_link_resume(
+	struct acpi_pci_link *link)
+{
+	ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
+
+	if (link->refcnt && link->irq.active && link->irq.initialized)
+		return_VALUE(acpi_pci_link_set(link, link->irq.active));
+	else
+		return_VALUE(0);
+}
+
+static int
+irqrouter_resume(
+	struct sys_device *dev)
 {
 	struct list_head        *node = NULL;
 	struct acpi_pci_link    *link = NULL;
-	int			ret = 0;
 
-	ACPI_FUNCTION_TRACE("irqrouter_suspend");
+	ACPI_FUNCTION_TRACE("irqrouter_resume");
 
 	list_for_each(node, &acpi_link.entries) {
 		link = list_entry(node, struct acpi_pci_link, node);
@@ -793,24 +803,11 @@ irqrouter_suspend(
 				"Invalid link context\n"));
 			continue;
 		}
-		if (link->irq.initialized && link->refcnt != 0
-			/* We ignore legacy IDE device irq */
-			&& link->irq.active != 14 && link->irq.active !=15) {
-			printk(KERN_WARNING PREFIX
-				"%d drivers with interrupt %d neglected to call"
-				" pci_disable_device at .suspend\n",
-				link->refcnt,
-				link->irq.active);
-			printk(KERN_WARNING PREFIX
-				"Fix the driver, or rmmod before suspend\n");
-			link->refcnt = 0;
-			ret = -EINVAL;
-		}
+		acpi_pci_link_resume(link);
 	}
-	return_VALUE(ret);
+	return_VALUE(0);
 }
 
-
 static int
 acpi_pci_link_remove (
 	struct acpi_device	*device,
@@ -922,7 +919,7 @@ __setup("acpi_irq_balance", acpi_irq_bal
 /* FIXME: we will remove this interface after all drivers call pci_disable_device */
 static struct sysdev_class irqrouter_sysdev_class = {
         set_kset_name("irqrouter"),
-        .suspend = irqrouter_suspend,
+        .resume = irqrouter_resume,
 };
 
 
#20 lore raw
In reply to Rafael J. Wysocki
Quoted 15 lines · Rafael J. Wysocki
Quoted 6 lines · Hugh Dickins
Quoted 5 lines · Rafael J. Wysocki
Quoted 4 lines · Hugh Dickins
Quoted 2 lines · Rafael J. Wysocki

Could you please send the /proc/interrupts from your box?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

11: 57443 XT-PIC yenta, yenta, eth0

Thanks. It looks like eth0 gets a yenta's interrupt and goes awry. Could you please tell me what driver the eth0 is?

CONFIG_VORTEX drivers/net/3c59x.c:
0000:02:00.0: 3Com PCI 3c905C Tornado at 0xec80. Vers LK1.1.19

Quoted 8 lines

Thanks again. From the first look the suspend/resume routines of the driver are missing some calls. In particular, with the IRQ-freeing patch for yenta it is likely to get an out-of-order interrupt as I suspected.

Linus has apparently dropped that patch for yenta, but in case it is reintroduced in the future you will probably need a patch to make the network driver cooperate. I'll try to prepare one tomorrow, if I can, but I have no hardware to test it.

The patch follows. It compiles and should work, though I haven't tested it.

Greets,
Rafael

drivers/net/3c59x.c +17 -1
Index: linux-2.6.13-rc4-git3/drivers/net/3c59x.c
===================================================================
@@ -973,6 +973,11 @@ static int vortex_suspend (struct pci_de
 			netif_device_detach(dev);
 			vortex_down(dev, 1);
 		}
+		pci_save_state(pdev);
+		pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
+		free_irq(dev->irq, dev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, pci_choose_state(pdev, state));
 	}
 	return 0;
 }
@@ -980,8 +985,19 @@ static int vortex_suspend (struct pci_de
 static int vortex_resume (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
+	struct vortex_private *vp = netdev_priv(dev);
 
-	if (dev && dev->priv) {
+	if (dev && vp) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		pci_enable_device(pdev);
+		pci_set_master(pdev);
+		if (request_irq(dev->irq, vp->full_bus_master_rx ?
+				&boomerang_interrupt : &vortex_interrupt, SA_SHIRQ, dev->name, dev)) {
+			printk(KERN_WARNING "%s: Could not reserve IRQ %d\n", dev->name, dev->irq);
+			pci_disable_device(pdev);
+			return -EBUSY;
+		}
 		if (netif_running(dev)) {
 			vortex_up(dev);
 			netif_device_attach(dev);
Signature · 3 lines
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
		-- Lewis Carroll "Alice's Adventures in Wonderland"
#8 lore raw
In reply to Linus Torvalds
Quoted 8 lines · Linus Torvalds
Quoted 3 lines · Russell King

I don't think so - I believe one of the problem cases is where you have a screaming interrupt caused by an improperly setup device.

Not a problem.

Quoted 8 lines

The thing is, this is trivially solved by
- disable irq controller last on shutdown
- re-enable irq controller last on resume

Think about it. Even if you have screaming irq's (and thus we'll shut things down somewhere during the resume), when we then get to re-enable the irq controller thing, we'll have them all back again at that point. Problem solved.

That is nasty. That means every single driver must be careful not to ever "wait" for the device interrupt to happen at resume. I'm not talking about adding a timeout or such (that should be done anyway to deal with hot unplug) but having something like IDE -> queues wakeup request and blocks til it's dealt with. That sort of thing. It's annoying, it means no driver can rely on IRQs actually working in their resume callback. Not nice.

Also, once a driver has woken up, it doesn't really have an idea that the rest of the system is not yet fully up (or that it actually is), and thus doesn't really know if interrupts are still globally off or not if we implement your scheme. That may cause nasty effects too I suppose...

Quoted 10 lines

You can have variations on this, of course - you can enable the irq controller early _and_ late in the resume process. Ie do a minimal "get the basics working" early - you might want to make sure that timers etc work early on, for example, and then a "fix up the details" thing late.

An interrupt controller is clearly a special case, so it's worth spending some effort on handling it.

In contrast, what is _not_ worth doing is screweing over every single driver we have.

I'm not fan of the free/request irq on suspend & resume for various reasons, and I don't think it actually fixes the problem discussed anyway because of shared interrupts, but heh, the problem is real on x86 it seems (BIOS crap !). Not sure what the best fix is.

Ben.

#21 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · Rafael J. Wysocki
Quoted 5 lines · Rafael J. Wysocki

Linus has apparently dropped that patch for yenta, but in case it is reintroduced in the future you will probably need a patch to make the network driver cooperate. I'll try to prepare one tomorrow, if I can, but I have no hardware to test it.

The patch follows. It compiles and should work, though I haven't tested it.

Thanks for making the effort, Rafael,
but I'm afraid your patch does not solve it.

Prior to -rc4, or in current -git which has the yenta patch reverted, my laptop manages APM resume from RAM with the following 8 messages (I won't complain that it could list even more permutations!)

PCI: Found IRQ 11 for device 0000:00:1f.1
PCI: Sharing IRQ 11 with 0000:02:00.0
PCI: Found IRQ 11 for device 0000:02:00.0
PCI: Sharing IRQ 11 with 0000:00:1f.1
PCI: Found IRQ 11 for device 0000:02:01.0
PCI: Sharing IRQ 11 with 0000:02:01.1
PCI: Found IRQ 11 for device 0000:02:01.1
PCI: Sharing IRQ 11 with 0000:02:01.0

Unpatched -rc4 locks up on resume, showing none of those messages. -rc4 with your drivers/net/3c59x.c patch locks up on resume, after showing just the first four of those messages.

Whatever, I very much share the position Linus has expressed so
forcefully: it's foolish suddenly to demand changes in an indeterminate number of drivers (surely yenta and 3c59x aren't the end of it?), especially in the final days leading up to a release.

I surely would not have asked him to revert the yenta patch, nor would he have done so (thank you, Linus), if my machine were the only problem. It's very easy for me to carry my own patches to get working, but we fear the trouble seen here gives a foretaste of others' trouble if the changes were to remain in the release.

As to whether the changes should be retained in -mm, I simply don't have an appreciation of the scope of the problems either way, to have a worthwhile opinion.

Hugh

#22 lore raw
Quoted 26 lines · Hugh Dickins
Quoted 8 lines · Rafael J. Wysocki
Quoted 5 lines · Rafael J. Wysocki

Linus has apparently dropped that patch for yenta, but in case it is reintroduced in the future you will probably need a patch to make the network driver cooperate. I'll try to prepare one tomorrow, if I can, but I have no hardware to test it.

The patch follows. It compiles and should work, though I haven't tested it.

Thanks for making the effort, Rafael,
but I'm afraid your patch does not solve it.

Prior to -rc4, or in current -git which has the yenta patch reverted, my laptop manages APM resume from RAM with the following 8 messages (I won't complain that it could list even more permutations!)

PCI: Found IRQ 11 for device 0000:00:1f.1
PCI: Sharing IRQ 11 with 0000:02:00.0
PCI: Found IRQ 11 for device 0000:02:00.0
PCI: Sharing IRQ 11 with 0000:00:1f.1
PCI: Found IRQ 11 for device 0000:02:01.0
PCI: Sharing IRQ 11 with 0000:02:01.1
PCI: Found IRQ 11 for device 0000:02:01.1
PCI: Sharing IRQ 11 with 0000:02:01.0

Quoted 3 lines

Unpatched -rc4 locks up on resume, showing none of those messages. -rc4 with your drivers/net/3c59x.c patch locks up on resume, after showing just the first four of those messages.

Thanks for testing. The results you observe mean that the problem is in fact more complicated than I thought. It seems to make up a good test case but I wouldn't like to bother you any more. :-)

Quoted 4 lines

Whatever, I very much share the position Linus has expressed so
forcefully: it's foolish suddenly to demand changes in an indeterminate number of drivers (surely yenta and 3c59x aren't the end of it?), especially in the final days leading up to a release.

Fully agreed.

Quoted 5 lines

I surely would not have asked him to revert the yenta patch, nor would he have done so (thank you, Linus), if my machine were the only problem. It's very easy for me to carry my own patches to get working, but we fear the trouble seen here gives a foretaste of others' trouble if the changes were to remain in the release.

Indeed.

Greets,
Rafael

Signature · 3 lines
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
		-- Lewis Carroll "Alice's Adventures in Wonderland"