public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: revert yenta free_irq on suspend
@ 2005-07-31 20:34 ambx1
  2005-07-31 21:20 ` Pavel Machek
                   ` (2 more replies)
  0 siblings, 3 replies; 58+ messages in thread
From: ambx1 @ 2005-07-31 20:34 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Pavel Machek, Hugh Dickins, Andrew Morton, Dominik Brodowski,
	Daniel Ritz, Linux Kernel Mailing List, Len Brown

----- Original Message ----- 
From: Linus Torvalds <torvalds@osdl.org> 
Date: Sunday, July 31, 2005 11:53 am 
Subject: Re: revert yenta free_irq on suspend 

> 
> 
> On Sun, 31 Jul 2005, Pavel Machek wrote: 
> > 
> > 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. 
> 
> > 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 

Hi Linus,

In general, I think that calling free_irq is the right behavior.
Although irqs changing after suspend is rare, there are also some
more serious issues.  This has been discussed in the past, and a
summary is as follows:

1.) race conditions:
Consider the case where several PCI devices are sharing a single PCI
interrupt.  One device is suspended, but doesn't call free_irq.  Now
another properly behaving device on the same interrupt line generates
an interrupt.  Let's say the suspended device had its handler
registered first, and therefore is called first.  The handler will
attempt to access registers on the physically-off device to determine
if it generated the interrupt.  The PCI bus will issue a master abort.
The driver's interrupt handler will likely interpret the read
incorrectly.

Every interrupt handler could be modified to check if the device is
available, but it would be cleaner and more efficient to unregister
the interrupt.  Either way, every driver has to be changed to support
PM correctly.

2.) runtime power management:
We don't want to leave stale interrupt handlers registered when only
suspending a specific device.  As we move toward supporting runtime
power management it will be important to ensure every driver calls
free_irq() in its suspend() (or whatever we're using at that point)
routine.  This avoids interrupt handler bugs and extra interrupt
overhead.


Also I'd like to point out that this patch broke APM suspend-to-ram,
not ACPI S3.  IMO, it may not be possible to support both APM and ACPI
on every system, as their specs are not intended to be compatible.
Progress toward proper suspend-to-ram support will, in many cases, be
a small setback for APM.  This really can't be avoided.

There are, however, some things we can do to mitigate the breakage
toward APM.  Specifically, we should indicate the type of suspend state,
including if it's an ACPI or APM state, for each driver's ->suspend()
routine.  This will give drivers the opportunity to act differently
for APM when necessary.  I'm currenlty working on this issue.

APM is useful for legacy hardware and systems with blacklisted ACPI
support.  I don't think we should attempt to support APM on any system
with working ACPI suspend/resume.

Thanks,
Adam


^ permalink raw reply	[flat|nested] 58+ messages in thread
* Re: revert yenta free_irq on suspend
@ 2005-08-01  3:03 ambx1
  2005-08-01  4:53 ` Linus Torvalds
  2005-08-01  8:49 ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 58+ messages in thread
From: ambx1 @ 2005-08-01  3:03 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Dave Airlie, Pavel Machek, Hugh Dickins, Andrew Morton,
	Dominik Brodowski, Daniel Ritz, Linux Kernel Mailing List,
	Len Brown

----- Original Message -----
From: Linus Torvalds <torvalds@osdl.org>
Date: Sunday, July 31, 2005 9:07 pm
Subject: Re: revert yenta free_irq on suspend

> 
> 
> On Mon, 1 Aug 2005, Dave Airlie wrote:
> > 
> > You said earlier we only should fix drivers that need fixing, but 
> they> all need fixing
> 
> I think you're still talking from a theoretical standpoing, while 
> all my 
> arguments are practical.
> 
> In _practice_, I hope that
> 
> (a) we don't see that very much (ie the people for whom things 
> work 
>     already are a strong argument that this is less of a problem in
>     practice than people try to make it appear)

They may not always be triggered, but they are real bugs.  We can't
ensure stable PM until they are fixed.  If they weren't a real issue,
then calling free_irq() in pcmcia probably wouldn't have broken the
sound driver we saw in this case.

> 
> (b) drivers, _especially_ on notebooks, are already able to handle 
> an 
>     incoming interrupt with the device in D3 state and returning 0xff
>     for all reads.
> 
>     In particular, this is exactly the same thing that you get on 
> a 
>     surprise device removal too.
> 
> iow it really _really_ shouldn't matter that a shared interrupt 
> comes in
> after (or before) a device has gone to sleep. Because a driver that 
> can'thandle that schenario is buggy for totally unrelated reasons, 
> and doing a 
> "free_irq()/request_irq()" pair at suspend time is _not_ the solution!

I understand this.  But calling free_irq()/request_irq() still seems
to make sense.  It's the cleanest and most straightforward approach.
It's the easiest way we can ensure there will not be race conditions.
An interrupt could be triggered during the device's power transition
when it's in between on and off.  More importantly, we need this change
for runtime power management anyway.

> 
> > This has nothing to do with the issues with highlevel PM interfaces
> > for shutting down hardware, this is do with fixing the drivers in 
> the> kernel currently and what the correct way to do it is without 
> breaking> someone elses hardware....
> 
> ... and I don't think this has _anything_ to do with 
> free_irq/request_irq, 
> and everything to do with the fact that we can try to make at least 
> the 
> common drivers "hardened" for unexpected interrupts coming in when 
> the hw 
> might not be ready for them.

We either need to change every driver to free irqs or "harden" each
of them.  Freeing irqs obviously seems easier.  I propose we make
this change in -mm in one pass to avoid bugs like this.

Also, as I said earlier, the better we support OSPM initiated power
management, the more likely APM will break.  This may be technically
unavoidable on some isolated boxes without quirks.  I agree with
Pavel that "do nothing" may make sense, but it seems some devices
may still need to be disabled by the OS.  As a real world example,
we currently can't turn off cardbus bridges because it breaks APM
on a couple of older laptops.

Thanks,
Adam


^ permalink raw reply	[flat|nested] 58+ messages in thread
* RE: revert yenta free_irq on suspend
@ 2005-07-31  5:03 Brown, Len
  2005-07-31  5:31 ` Linus Torvalds
                   ` (3 more replies)
  0 siblings, 4 replies; 58+ messages in thread
From: Brown, Len @ 2005-07-31  5:03 UTC (permalink / raw)
  To: Linus Torvalds, Rafael J. Wysocki
  Cc: linux-kernel, Russell King, Hugh Dickins, Andrew Morton,
	Dominik Brodowski, Daniel Ritz

>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.

If that is what you want, I'll be happy to do it.

If one believes that suspend/resume is working on a large number of
systems -- working to a level that a distro can acutally support it,
then restoring our temporary resume IRQ router hack to make many systems
work
is clearly the right thing to do.

But that believe would be total fantasy -- supsend/resume is not
working on a large number of machines, and no distro is currently
able to support it.  (I'm talking about S3 suspend to RAM primarily,
suspend to disk is less interesting -- though Red Hat doesn't
even support _that_)

We can got back to the old hack, but it will probably just delay
the day that suspend/resume is working broadly, and actually
can be deployed and supported by distros.

-Len

^ permalink raw reply	[flat|nested] 58+ messages in thread
* revert yenta free_irq on suspend
@ 2005-07-30 19:10 Hugh Dickins
  2005-07-30 20:03 ` Russell King
                   ` (2 more replies)
  0 siblings, 3 replies; 58+ messages in thread
From: Hugh Dickins @ 2005-07-30 19:10 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Dominik Brodowski, Daniel Ritz, linux-kernel

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 <daniel.ritz@gmx.ch>

Resume doesn't seem to work without.

Signed-off-by: Daniel Ritz <daniel.ritz@gmx.ch>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/pcmcia/yenta_socket.c |    9 +++++++++
 1 files changed, 9 insertions(+)

diff -puN drivers/pcmcia/yenta_socket.c~yenta-free_irq-on-suspend drivers/pcmcia/yenta_socket.c
--- devel/drivers/pcmcia/yenta_socket.c~yenta-free_irq-on-suspend	2005-07-28 01:05:52.000000000 -0700
+++ devel-akpm/drivers/pcmcia/yenta_socket.c	2005-07-28 01:05:52.000000000 -0700
@@ -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);
 	}

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2005-08-03 11:49 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-31 20:34 revert yenta free_irq on suspend ambx1
2005-07-31 21:20 ` Pavel Machek
2005-08-01  8:56   ` Benjamin Herrenschmidt
2005-07-31 22:55 ` Linus Torvalds
2005-07-31 23:05   ` Pavel Machek
2005-07-31 23:24     ` Linus Torvalds
2005-07-31 23:27       ` Pavel Machek
2005-07-31 23:44         ` Linus Torvalds
2005-07-31 23:59           ` Dave Airlie
2005-08-01  0:19             ` Linus Torvalds
2005-08-01  0:44               ` Dave Airlie
2005-08-01  1:07                 ` Linus Torvalds
2005-08-01  7:15                   ` Pavel Machek
2005-08-01  7:01               ` Sanjoy Mahajan
2005-08-01  7:25           ` Pavel Machek
2005-07-31 23:10   ` Dave Airlie
2005-08-01  1:59 ` Shaohua Li
2005-08-01  2:06   ` Andrew Morton
2005-08-01  2:22     ` Shaohua Li
2005-08-01  7:19     ` Pavel Machek
2005-08-01 21:38     ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2005-08-01  3:03 ambx1
2005-08-01  4:53 ` Linus Torvalds
2005-08-01  8:49 ` Benjamin Herrenschmidt
2005-08-02 10:56   ` Pavel Machek
2005-08-03 11:42     ` Benjamin Herrenschmidt
2005-07-31  5:03 Brown, Len
2005-07-31  5:31 ` Linus Torvalds
2005-07-31  9:49 ` Rafael J. Wysocki
2005-07-31 22:27 ` Dave Jones
2005-08-01  0:00   ` Andreas Steinmetz
2005-08-01  0:06     ` Dave Jones
2005-08-01  0:09       ` Andreas Steinmetz
2005-08-03  9:23   ` Pavel Machek
2005-08-01  8:51 ` Matthew Garrett
2005-07-30 19:10 Hugh Dickins
2005-07-30 20:03 ` Russell King
2005-07-30 20:36   ` Linus Torvalds
2005-07-30 20:54     ` Russell King
2005-07-30 21:10       ` Linus Torvalds
2005-07-30 21:30         ` Russell King
2005-07-30 22:28         ` Rafael J. Wysocki
2005-07-31  4:49           ` Linus Torvalds
2005-08-01  9:06         ` Benjamin Herrenschmidt
2005-07-30 21:20       ` Rafael J. Wysocki
2005-07-30 20:34 ` Linus Torvalds
2005-07-31 13:29   ` Pavel Machek
2005-07-31 15:53     ` Linus Torvalds
2005-07-31 17:09       ` Linus Torvalds
2005-07-30 20:49 ` Rafael J. Wysocki
2005-07-30 21:08   ` Daniel Ritz
2005-07-30 21:32   ` Hugh Dickins
2005-07-30 22:00     ` Rafael J. Wysocki
2005-07-30 22:24       ` Hugh Dickins
2005-07-30 23:09         ` Rafael J. Wysocki
2005-07-31 20:15           ` Rafael J. Wysocki
2005-08-01 20:34             ` Hugh Dickins
2005-08-01 21:54               ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox