Re: [PATCH] Add SATA device to VIA IRQ quirk fixup list

From: Daniel Drake
Date: Sun Jul 16 2006 - 10:01:19 EST


Andrew Morton wrote:
Guys, this is a really serious failure but afaict nobody is working on it
and generally nothing at all is happening.

How do we fix all this? (Who owns it?)

I'd like to push the attached patch for inclusion. I have tested it on my VIA Apollo system, and I hope it is an acceptable compromise while nobody has a complete understanding of the issues around this quirk.

I think this belongs to Greg as its a PCI thing, but we should probably look for a yay or nay from Jeff as well.

Daniel [PATCH] PCI quirk_via_irq behaviour change

The most recent VIA IRQ quirk changes have broken various VIA devices for
some users. We are not able to add these devices to the blacklist as they
are also available in PCI-card form, and running the quirk on these devices
brings us back to square one (running the VIA quirk on non-VIA boards where
the quirk is not needed).

This patch, based on suggestions from Sergey Vlasov, implements a scheme
similar to but more restrictive than the scheme we had in 2.6.16 and earlier.
It runs the quirk on all VIA hardware, but only if a VIA southbridge was
detected on the system.

There is still a downside to this patch: if the user inserts a VIA PCI card
into a VIA-based motherboard, the quirk will also run on the VIA PCI card.
This corner case is hard to avoid.

However, I think this patch should be applied because:
- The quirk won't run on Chris's non-VIA system, which was the cause of
change in the first place.
- Affected sata_via users will be able to boot again
- Nobody really has a full understanding of the problem and the issues,
so I think this "compromise solution" should be acceptable for now.

Signed-off-by: Daniel Drake <dsd@xxxxxxxxxx>

Index: linux/drivers/pci/quirks.c
--- linux.orig/drivers/pci/quirks.c
+++ linux/drivers/pci/quirks.c
* Some of the on-chip devices are actually '586 devices' so they are
* listed here.
+static int via_irq_fixup_needed = -1;
+ * As some VIA hardware is available in PCI-card form, we need to restrict
+ * this quirk to VIA PCI hardware built onto VIA-based motherboards only.
+ * We try to locate a VIA southbridge before deciding whether the quirk
+ * should be applied.
+ */
+static const struct pci_device_id via_irq_fixup_tbl[] = {
+ {
+ .vendor = PCI_VENDOR_ID_VIA,
+ .device = PCI_ANY_ID,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .class = PCI_CLASS_BRIDGE_ISA << 8,
+ .class_mask = 0xffff00,
+ },
+ { 0, },
static void quirk_via_irq(struct pci_dev *dev)
u8 irq, new_irq;

+ if (via_irq_fixup_needed == -1)
+ via_irq_fixup_needed = pci_dev_present(via_irq_fixup_tbl);
+ if (!via_irq_fixup_needed)
+ return;
new_irq = dev->irq & 0xf;
pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
if (new_irq != irq) {
@@ -661,13 +688,7 @@ static void quirk_via_irq(struct pci_dev
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq);

* VIA VT82C598 has its device ID settable and many BIOSes