-
Notifications
You must be signed in to change notification settings - Fork 94
increased PCI_MAX_DEVICES constant #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Alberto Daniel Lange <adlange09@gmail.com>
midnightveil
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine.
I'll approve; for other reviewers the reason for there being a hardcoded constant is because there is a hardcoded list of all PCI devices up to this number:
Line 16 in 486afd6
| libpci_device_t libpci_device_list[PCI_MAX_DEVICES]; |
Lines 80 to 109 in 486afd6
| static int libpci_add_fun(uint8_t bus, uint8_t dev, uint8_t fun) | |
| { | |
| uint16_t vendor_id = libpci_read_reg16(bus, dev, fun, PCI_VENDOR_ID); | |
| if (vendor_id == PCI_VENDOR_ID_INVALID) { | |
| /* No device here. */ | |
| return 0; | |
| } | |
| ZF_LOGD("PCI :: Device found at BUS %d DEV %d FUN %d:\n", (int)bus, (int)dev, (int)fun); | |
| ZF_LOGD(" vendorID = %s [0x%x]\n", libpci_vendorID_str(vendor_id), vendor_id); | |
| uint16_t device_id = libpci_read_reg16(bus, dev, fun, PCI_DEVICE_ID); | |
| ZF_LOGD(" deviceID = %s [0x%x]\n", libpci_deviceID_str(vendor_id, device_id), device_id); | |
| if (libpci_num_devices + 1 > PCI_MAX_DEVICES) { | |
| return 0; | |
| } | |
| libpci_device_list[libpci_num_devices].bus = bus; | |
| libpci_device_list[libpci_num_devices].dev = dev; | |
| libpci_device_list[libpci_num_devices].fun = fun; | |
| libpci_device_list[libpci_num_devices].vendor_id = vendor_id; | |
| libpci_device_list[libpci_num_devices].device_id = device_id; | |
| libpci_device_list[libpci_num_devices].vendor_name = libpci_vendorID_str(vendor_id); | |
| libpci_device_list[libpci_num_devices].device_name = libpci_deviceID_str(vendor_id, device_id); | |
| libpci_device_list[libpci_num_devices].interrupt_line = libpci_read_reg8(bus, dev, fun, PCI_INTERRUPT_LINE); | |
| libpci_device_list[libpci_num_devices].interrupt_pin = libpci_read_reg8(bus, dev, fun, PCI_INTERRUPT_PIN); | |
| libpci_device_list[libpci_num_devices].subsystem_id = libpci_read_reg16(bus, dev, fun, PCI_SUBSYSTEM_ID); | |
| libpci_read_ioconfig(&libpci_device_list[libpci_num_devices].cfg, bus, dev, fun); |
The other use is
util_libs/libpci/src/virtual_pci.c
Lines 37 to 44 in 486afd6
| libpci_device_t* matched_devices[PCI_MAX_DEVICES]; | |
| int nfound = libpci_find_device_all(vendor_id, device_id, matched_devices); | |
| for (int i = 0; i < nfound; i++) { | |
| bool ret = libpci_virtual_pci_device_allow(self, matched_devices[i]); | |
| if (!ret) return ret; | |
| } | |
| return true; | |
| } |
where it allocates a large array on the stack. That is probably the most questionable part of this.
This change increases the constant value to ensure proper PCI device enumeration on Supermicro E300-9D hardware.
With the previous value, both 10 GbE NICs (Intel X557-AT2) fail to be detected during initialization, causing PCI passthrough to break.