From 462bff5aefc7f76361098ae17a98fe727c378d88 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Fri, 16 Apr 2021 10:14:16 +0200 Subject: [PATCH] dde_linux: test subdevice id for device matching As linux drivers may distinguish device configuration by pci subdevice id in addition to the pci device id, the former must also be used for finding the matching entry. Otherwise, e.g., the iwlwifi driver might load the wrong firmware. Side note: Add break statement to save superfluous iterations after match was identified. Fixes genodelabs#4076 --- repos/dde_linux/src/include/lx_emul/impl/pci.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/repos/dde_linux/src/include/lx_emul/impl/pci.h b/repos/dde_linux/src/include/lx_emul/impl/pci.h index 9ed58c7cd9..a4c9d67881 100644 --- a/repos/dde_linux/src/include/lx_emul/impl/pci.h +++ b/repos/dde_linux/src/include/lx_emul/impl/pci.h @@ -37,12 +37,17 @@ extern "C" int pci_register_driver(struct pci_driver *driver) /* request device ID from platform driver */ unsigned const device_id = client.device_id(); + unsigned const subdevice_id = client.config_read(0x2e, + Platform::Device::ACCESS_16BIT); /* look if we find the device ID in the driver's 'id_table' */ pci_device_id const *matching_id = nullptr; for (pci_device_id const *id = id_table; id->device; id++) { - if (id->device == device_id) + if ((id->device == device_id) && + (id->subdevice == PCI_ANY_ID || id->subdevice == subdevice_id)) { matching_id = id; + break; + } } /* skip device that is not handled by driver */