bhyve: scan PCI device functions to find host LPC

At least on some AMD devices the host LPC bridge could be located as
seperate function of another PCI device.

Fixes:			f4ceaff56d
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39310
This commit is contained in:
Corvin Köhne 2023-03-29 09:45:11 +02:00
parent 134ced89c4
commit d3e03d235e
No known key found for this signature in database
GPG Key ID: D854DA56315E026A

View File

@ -461,10 +461,22 @@ pci_lpc_get_sel(struct pcisel *const sel)
memset(sel, 0, sizeof(*sel));
for (uint8_t slot = 0; slot <= PCI_SLOTMAX; ++slot) {
uint8_t max_func = 0;
sel->pc_dev = slot;
if ((read_config(sel, PCIR_CLASS, 1) == PCIC_BRIDGE) &&
(read_config(sel, PCIR_SUBCLASS, 1) == PCIS_BRIDGE_ISA)) {
return (0);
sel->pc_func = 0;
if (read_config(sel, PCIR_HDRTYPE, 1) & PCIM_MFDEV)
max_func = PCI_FUNCMAX;
for (uint8_t func = 0; func <= max_func; ++func) {
sel->pc_func = func;
if ((read_config(sel, PCIR_CLASS, 1) == PCIC_BRIDGE) &&
(read_config(sel, PCIR_SUBCLASS, 1) ==
PCIS_BRIDGE_ISA)) {
return (0);
}
}
}