什么是 PCI 怪癖?

Dev*_*son 15 pci linux-kernel

在阅读 Linux 内核时,我听到了很多关于 PCI 怪癖的信息,但没有网站解释或定义 PCI 怪癖。什么是 PCI 怪癖?

Chr*_*own 17

“怪癖”是被认为不符合预期操作的设备属性。

下面是一个例子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 */
}
Run Code Online (Sandbox Code Playgroud)

这是一个“怪癖”,因为设备会报告虚假错误。当此设备运行时,怪癖会设置某些属性,使内核的其他部分以不同的方式运行(可能通过忽略虚假错误,或通过解决已知问题)。

不过,并非 Linux 内核中的所有怪癖都是这样。有些人不是简单地禁用受影响的功能,而是尝试解决它,例如:

/*
 * 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");
        }
}
Run Code Online (Sandbox Code Playgroud)