From 45ad7c0c7b86f7abbc5ce0d13fb947dca1645316 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 11 Jul 2024 11:04:16 -0400 Subject: kernel: pci: Fix cap offset handling Signed-off-by: Ian Moffett --- sys/dev/pci/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sys') diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 65f315d..a7b8bac 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -110,6 +110,7 @@ static void pci_set_device_info(struct pci_device *dev) { uint32_t classrev; + int capoff; dev->vendor_id = pci_readl(dev, PCIREG_VENDOR_ID) & 0xFFFF; dev->device_id = pci_readl(dev, PCIREG_DEVICE_ID) & 0xFFFF; @@ -127,7 +128,8 @@ pci_set_device_info(struct pci_device *dev) dev->bar[5] = pci_readl(dev, PCIREG_BAR5); dev->irq_line = pci_readl(dev, PCIREG_IRQLINE) & 0xFF; - dev->msix_capoff = pci_get_cap(dev, PCI_CAP_MSIX); + capoff = pci_get_cap(dev, PCI_CAP_MSIX); + dev->msix_capoff = (capoff < 0) ? 0 : capoff; } /* -- cgit v1.2.3