From: Jonathan Gray Subject: Re: PCI amd64: Enables MSI/MSI-X interrupts on QEMU i440fx chipset emulation To: Yuichiro NAITO Cc: kettenis@openbsd.org, tech@openbsd.org, yasuoka@openbsd.org Date: Mon, 7 Oct 2024 13:29:06 +1100 On Mon, Oct 07, 2024 at 10:54:14AM +0900, Yuichiro NAITO wrote: > Hi, this patch sets 'PCI_FLAGS_MSI_ENABLED' if the kernel runs on a QEMU > virtual machine with i440fx chipset emulation. The i440fx is the default > chipset on the QEMU so users will use it first. > And then ixv(4) and iavf(4) will fail because MSI-X interrupts are not > supported by the kernel. > > The i440fx is quite old and the ACPI table is revision 1. We cannot know > if it has MSI capability from the ACPI table. So I add the flag as a quirk. i440fx was released in 1996. Why not use the q35/ich9 machine? That hardware had MSI. If networking is configured, non-default options are already set. > > The same quirk is implemented in NetBSD. > > https://github.com/NetBSD/src/blob/affb7619d18b17a184eede63a4823f629a2893fc/sys/arch/x86/pci/pci_machdep.c#L273 > > FreeBSD seems to have the quirk but is used as the exception for blacklist > devices. Probably they see the PCI device capability header of MSI/MSI-X. > Until we see the same capability, my patch will be useful for the VF driver > users. > > OK? > > diff --git a/sys/arch/amd64/pci/pci_machdep.c b/sys/arch/amd64/pci/pci_machdep.c > index 30257ab7d82..4a49c898e96 100644 > --- a/sys/arch/amd64/pci/pci_machdep.c > +++ b/sys/arch/amd64/pci/pci_machdep.c > @@ -170,6 +170,31 @@ void > pci_attach_hook(struct device *parent, struct device *self, > struct pcibus_attach_args *pba) > { > + pci_chipset_tag_t pc = pba->pba_pc; > + pcitag_t tag; > + pcireg_t id, class; > + > + if (pba->pba_bus != 0) > + return; > + > + tag = pci_make_tag(pc, 0, 0, 0); > + id = pci_conf_read(pc, tag, PCI_ID_REG); > + class = pci_conf_read(pc, tag, PCI_CLASS_REG); > + > + if (PCI_CLASS(class) != PCI_CLASS_BRIDGE || > + PCI_SUBCLASS(class) != PCI_SUBCLASS_BRIDGE_HOST) > + return; > + > + /* > + * QEMU uses the old chipset i440fx by default, but it can use > + * MSI/MSI-X interrupt. We cannot know if MSI/MISX is available > + * from the ACPI table. Because it's quite old style (revision 1). > + */ > + if ((cpu_ecxfeature & CPUIDECX_HV) && > + PCI_VENDOR(id) == PCI_VENDOR_INTEL && > + PCI_PRODUCT(id) == PCI_PRODUCT_INTEL_82441FX) { > + pba->pba_flags |= PCI_FLAGS_MSI_ENABLED; > + } > } > > int > > -- > Yuichiro NAITO (naito.yuichiro@gmail.com) > >