15

I hear a lot about PCI quirks when reading about the Linux kernel, but no website explains or defines PCI quirks. What are PCI quirks?

2
  • 1
    A quirk is just a non-intuitive inconsistency. It's not a technical term. We would probably need to see the text you're referring to in order to elaborate on what they're saying. Though there is a file that provides routines drivers can use to work around various quirks they've ran into over the years. But ultimately, it's just an informal term used in the same sense as the regular English language term.
    – Bratchley
    Jul 17, 2013 at 16:11
  • 1
    If you're really curious, that file is pretty well commented explaining what each routine does.
    – Bratchley
    Jul 17, 2013 at 16:12

1 Answer 1

16

"Quirks" are attributes of a device that are considered to be noncompliant with expected operation.

Here's an example from quirks.c:

/* The Mellanox Tavor device gives false positive parity errors
 * Mark this device with a broken_parity_status, to allow
 * PCI scanning code to "skip" this now blacklisted device.
 */
static void quirk_mellanox_tavor(struct pci_dev *dev)
{
        dev->broken_parity_status = 1;  /* This device gives false positives */
}

This is a "quirk" as the device reports spurious errors. When this device is operative, the quirk sets certain attributes that make other parts of the kernel act differently (perhaps by ignoring spurious errors, or by working around a known issue).

Not all quirks in the Linux kernel are like this, though. Instead of simply disabling the affected feature, some try to work around it, for example:

/*
 * Some CS5536 BIOSes (for example, the Soekris NET5501 board w/ comBIOS
 * ver. 1.33  20070103) don't set the correct ISA PCI region header info.
 * BAR0 should be 8 bytes; instead, it may be set to something like 8k
 * (which conflicts w/ BAR1's memory range).
 */
static void quirk_cs5536_vsa(struct pci_dev *dev)
{
        if (pci_resource_len(dev, 0) != 8) {
                struct resource *res = &dev->resource[0];
                res->end = res->start + 8 - 1;
                dev_info(&dev->dev, "CS5536 ISA bridge bug detected "
                                "(incorrect header); workaround applied.\n");
        }
}
4
  • 1
    @Chris Down - how would I notice that my device has PCI quirks? And what would happen, if I disable PCI quirk workarounds in the kernel? Sep 28, 2014 at 12:45
  • 1
    That depends entirely on what device you have. Depending on the device, there may be a message in the kernel log mentioning a quirk workaround has been applied (as in the second example above), or there may not be. The only surefire way is to look at quirks.c for the vendor and/or device. Disabling quirks could have a varied effect depending on how serious the workaround is; it could have no noticeable side effects or it could cause the device to not work properly.
    – ruscur
    Jun 20, 2017 at 4:21
  • 1
    One example of "what would happen" could be, for example, videocard driver being unable to read videocard BIOS and in the end unable to properly configure it. Having CONFIG_PCI_QUIRKS back in kernel fixes the issue.
    – PF4Public
    Dec 11, 2018 at 22:10
  • 1
    What would happen is specific to the quirk. It could be anywhere from nothing happens to it hangs/crashes the machine. Technically some smoke could be let out of some components too which is worse than a hang. Each entry is its own specific issue not to be assumed to be related in any way to other brands or models issues.
    – old_timer
    Jan 8, 2020 at 21:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .