linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <david.woodhouse@intel.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Adrian Bunk <bunk@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Natalie Protasevich <protasnb@gmail.com>
Subject: Re: 2.6.32-rc4: Reported regressions from 2.6.31
Date: Mon, 12 Oct 2009 11:18:58 +0100	[thread overview]
Message-ID: <1255342738.24732.265.camel@macbook.infradead.org> (raw)
In-Reply-To: <alpine.LFD.2.01.0910111554400.3438@localhost.localdomain>

On Mon, 2009-10-12 at 00:07 +0100, Linus Torvalds wrote:
> The IOMMU should not be reprogrammed until _after_ we have handled and 
> re-initialized all the devices, so I really think the problem is the IOMMU 
> code, not the USB code.

The IOMMU init is happening in the right place, I think. It has to be
before device_initcall(), because it has to be set up before we actually
start initialising devices -- we have to have the IOMMU in place before
any real drivers try to set up DMA mappings.

It's currently fs_initcall(), with an explicit comment saying that it
has to be after PCI initialisation. The only way it could be later is if
we move it to rootfs_initcall().

> (Of course, the underlying problem is that USB legacy mode handling by 
> BIOS with SMM is some seriously insane crap, no question about that. At 
> the same time, the IOMMU code is just clearly wrong in removing the legacy 
> mappings before we have initialized all devices, so the revert is simply 
> the right thing to do)

Well, according to the design, the IOMMU code is doing the right thing¹.

The theory is that the BIOS _tells_ us about the legacy mappings it
needs by putting them in an ACPI table (the RMRR table). Of course, the
reality is that BIOSes are universally shit and often fail to do this.

If the BIOSes were only _slightly_ shit, there'd be a few harmless DMA
faults and the legacy USB would stop of its own accord. But no, a bunch
of them also manage to lock up in SMM mode when their DMA goes AWOL.

The only viable solution (short of an open source BIOS written by sober
people) was to quiesce the USB controllers before enabling the IOMMU.

The final PCI quirks are currently run from pci_init() which is a
device_initcall(), which is too late -- in fact, it could actually be
_after_ some of the real device drivers have taken control of the same
hardware.

So the better fix is probably just to fix that problem -- move the final
PCI quirks so they happen a little earlier. If we move them to
fs_initcall_sync() and then move the IOMMU init to rootfs_initcall(),
then everything ought to work, I think...

(Let's rename 'pci_init()' and move it to quirks.c while we're at it,
since it only actually does that one thing. If/when I submit this
properly, I'll do that in a separate commit.)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 64b838e..e0d9199 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -311,7 +311,7 @@ void pci_iommu_shutdown(void)
 	amd_iommu_shutdown();
 }
 /* Must execute after PCI subsystem */
-fs_initcall(pci_iommu_init);
+rootfs_initcall(pci_iommu_init);
 
 #ifdef CONFIG_PCI
 /* Many VIA bridges seem to corrupt data for DAC. Disable it here */
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6edecff..2b575cf 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2719,17 +2719,6 @@ int __attribute__ ((weak)) pci_ext_cfg_avail(struct pci_dev *dev)
 	return 1;
 }
 
-static int __devinit pci_init(void)
-{
-	struct pci_dev *dev = NULL;
-
-	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
-		pci_fixup_device(pci_fixup_final, dev);
-	}
-
-	return 0;
-}
-
 static int __init pci_setup(char *str)
 {
 	while (str) {
@@ -2767,8 +2756,6 @@ static int __init pci_setup(char *str)
 }
 early_param("pci", pci_setup);
 
-device_initcall(pci_init);
-
 EXPORT_SYMBOL(pci_reenable_device);
 EXPORT_SYMBOL(pci_enable_device_io);
 EXPORT_SYMBOL(pci_enable_device_mem);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 6099fac..d99c9b4 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2572,6 +2572,19 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
 	}
 	pci_do_fixups(dev, start, end);
 }
+
+static int __devinit pci_apply_final_quirks(void)
+{
+	struct pci_dev *dev = NULL;
+
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+		pci_fixup_device(pci_fixup_final, dev);
+	}
+
+	return 0;
+}
+
+fs_initcall_sync(pci_apply_final_quirks);
 #else
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) {}
 #endif


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation

¹ Yes, the design is completely broken. Anyone with any real-world
  experience would have known that the BIOS would never get this right.
  Personally, I find that it's useful to assume malice on the part of
  BIOS authors. I'm not suggesting that it's actually _true_, but it
  does tend to give a useful predictor of _just_ how badly they're going
  to screw things up.




  reply	other threads:[~2009-10-12 10:19 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-11 22:07 2.6.32-rc4: Reported regressions from 2.6.31 Rafael J. Wysocki
2009-10-11 22:15 ` [Bug #14277] Caught 8-bit read from freed memory in b43 driver at association Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14296] spitz boots but suspend/resume is broken Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14278] New message "NOHZ: local_softirq_pending 08" at each ping request Rafael J. Wysocki
2009-10-12 13:15   ` Michael Buesch
2009-10-12 21:49     ` Rafael J. Wysocki
2009-10-13 14:27       ` John W. Linville
2009-10-13 20:50         ` Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14279] Suspend to RAM freeze totally since 2.6.32-rc1 - Acer Aspire 1511Lmi laptop Rafael J. Wysocki
2009-10-12  8:09   ` Jan Beulich
2009-10-12 21:50     ` Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14302] Kernel panic on i386 machine when booting with profile=2 Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14298] warning at manage.c:361 (set_irq_wake), matrix-keypad related? Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14297] console resume broken since ba15ab0e8d Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14352] WARNING: at net/mac80211/scan.c:267 Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14299] oops in wireless, iwl3945 related? Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14334] pcmcia suspend regression from 2.6.31.1 to 2.6.31.2 - Dell Inspiron 600m Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14370] ext4 corruptions Rafael J. Wysocki
2009-10-12  6:50   ` Alexey Fisher
2009-10-12 21:53     ` Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14354] Bad corruption with 2.6.32-rc1 and upwards Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14353] BUG: sleeping function called from invalid context at kernel/mutex.c:280 Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14355] USB serial regression after 2.6.31.1 with Huawei E169 GSM modem Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14372] Wireless not working after suspend-resume Rafael J. Wysocki
2009-10-12 18:48   ` Fabio Comolli
2009-10-12 21:55     ` Rafael J. Wysocki
2009-10-13  7:07     ` Maciej Rutecki
2009-10-11 22:22 ` [Bug #14373] Task blocked for more than 120 seconds Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14374] MCEs caused by commit db8be50c4307dac2b37305fc59c8dc0f978d09ea Rafael J. Wysocki
2009-10-12 13:35   ` Mikael Pettersson
2009-10-12 21:56     ` Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14375] Intel(R) I/OAT DMA Engine init failed Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14378] Problems with net/core/skbuff.c Rafael J. Wysocki
2009-10-12 10:42   ` David Miller
2009-10-12 15:07     ` Massimo "CtRiX" Cetra
2009-10-13  9:11     ` Massimo Cetra
2009-10-13  9:23       ` Massimo Cetra
2009-10-13 10:19       ` Eric Dumazet
2009-10-13 10:25         ` David Miller
2009-10-13 10:26         ` Massimo Cetra
2009-10-14 19:27           ` Massimo Cetra
2009-10-15  0:36             ` [PATCH] virtio_net: use dev_kfree_skb_any() in free_old_xmit_skbs() Eric Dumazet
2009-10-15  6:30               ` David Miller
2009-10-13 10:22       ` [Bug #14378] Problems with net/core/skbuff.c David Miller
2009-10-13 10:27         ` Massimo Cetra
2009-10-11 22:22 ` [Bug #14376] Kernel NULL pointer dereference/ kvm subsystem Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14379] ACPI Warning for _SB_.BAT0._BIF: Converted Buffer to expected String Rafael J. Wysocki
2009-10-12  3:14   ` Justin Mattock
2009-10-12  3:35     ` Lin Ming
2009-10-12  3:58       ` Justin P. Mattock
2009-10-12 21:58         ` Rafael J. Wysocki
2009-10-13  3:12           ` Justin P. Mattock
2009-10-11 22:22 ` [Bug #14381] iwlagn lost connection after s2ram (with warnings) Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14382] Transmit failure in et131x Rafael J. Wysocki
2009-10-11 22:30   ` Alan Cox
2009-10-11 22:22 ` [Bug #14380] Video tearing/glitching with T400 laptops Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14384] tbench regression with 2.6.32-rc1 Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14386] GPF in snd_hda_intel Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14383] hackbench regression with kernel 2.6.32-rc1 Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14387] deadlock with fallocate Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14390] "bind" a device to a driver doesn't not work anymore Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14392] Touchpad "paste" stops working after suspend to RAM Rafael J. Wysocki
2009-10-11 22:22 ` [Bug #14389] Build system issue Rafael J. Wysocki
2009-10-13 18:53   ` Sam Ravnborg
2009-10-13 20:52     ` Rafael J. Wysocki
2009-10-11 23:07 ` 2.6.32-rc4: Reported regressions from 2.6.31 Linus Torvalds
2009-10-12 10:18   ` David Woodhouse [this message]
2009-10-12 12:06     ` [PATCH 1/4] Rename pci_init() to pci_apply_final_quirks(), move it to quirks.c David Woodhouse
2009-10-12 12:06     ` [PATCH 2/4] Mark pci_apply_final_quirks() __init rather than __devinit David Woodhouse
2009-10-12 12:06     ` [PATCH 3/4] Run pci_apply_final_quirks() sooner David Woodhouse
2009-10-12 12:06     ` [PATCH 4/4] x86: Move pci_iommu_init to rootfs_initcall() David Woodhouse
2009-10-12 14:26     ` 2.6.32-rc4: Reported regressions from 2.6.31 David Woodhouse
2009-10-12 15:24     ` Linus Torvalds
2009-10-12 15:56       ` David Woodhouse
2009-10-12 16:13         ` Alan Cox
2009-10-12 17:35         ` Linus Torvalds
2009-10-12 20:29           ` David Woodhouse
2009-10-11 23:11 ` Linus Torvalds
2009-10-12  0:02   ` Theodore Tso

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=1255342738.24732.265.camel@macbook.infradead.org \
    --to=david.woodhouse@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bunk@kernel.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=protasnb@gmail.com \
    --cc=rjw@sisk.pl \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).