]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe/configfs: Only allow configurations for supported devices
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 31 Jul 2025 19:33:38 +0000 (21:33 +0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 5 Aug 2025 19:30:48 +0000 (12:30 -0700)
Since we already lookup for the real PCI device before we allow
to create its directory config, we might also check if the found
device matches our driver PCI ID list. This will prevent creation
of the directory configs for the unsupported devices.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20250731193339.179829-11-michal.wajdeczko@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_configfs.c

index 3fc01bef01143c297841df6d47116d94edfdc785..5c13749733af0500dde9102c4153ccc0d6f72e66 100644 (file)
@@ -270,11 +270,22 @@ static const struct config_item_type xe_config_device_type = {
        .ct_owner       = THIS_MODULE,
 };
 
+static const struct xe_device_desc *xe_match_desc(struct pci_dev *pdev)
+{
+       struct device_driver *driver = driver_find("xe", &pci_bus_type);
+       struct pci_driver *drv = to_pci_driver(driver);
+       const struct pci_device_id *ids = drv ? drv->id_table : NULL;
+       const struct pci_device_id *found = pci_match_id(ids, pdev);
+
+       return found ? (const void *)found->driver_data : NULL;
+}
+
 static struct config_group *xe_config_make_device_group(struct config_group *group,
                                                        const char *name)
 {
        unsigned int domain, bus, slot, function;
        struct xe_config_group_device *dev;
+       const struct xe_device_desc *match;
        struct pci_dev *pdev;
        char canonical[16];
        int ret;
@@ -292,8 +303,16 @@ static struct config_group *xe_config_make_device_group(struct config_group *gro
        pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(slot, function));
        if (!pdev)
                return ERR_PTR(-ENODEV);
+
+       match = xe_match_desc(pdev);
+       if (!match)
+               pci_info(pdev, "xe driver does not support configuration of this device\n");
+
        pci_dev_put(pdev);
 
+       if (!match)
+               return ERR_PTR(-ENOENT);
+
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev)
                return ERR_PTR(-ENOMEM);