]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe/configfs: Prepare to filter-out configfs attributes
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 2 Sep 2025 13:17:43 +0000 (15:17 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 4 Sep 2025 20:32:46 +0000 (22:32 +0200)
Implement empty ops.is_visible hook to allow filtering-out any not
supported attributes, as not all of them are applicable on all xe
platforms.

Since during creation of each new configfs directory we are looking
for xe device descriptor to validate that xe driver supports given
PCI device, store reference to that descriptor to allow later use
while doing attribute filtering.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Stuart Summers <stuart.summers@intel.com>
Link: https://lore.kernel.org/r/20250902131744.5076-3-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_configfs.c

index 1025d3979b066f7bfc29cc2ff9afe784b22360b2..43f000260752429b4ccee9b58bd7216b99458215 100644 (file)
@@ -134,6 +134,8 @@ struct xe_config_group_device {
 
        /* protects attributes */
        struct mutex lock;
+       /* matching descriptor */
+       const struct xe_device_desc *desc;
 };
 
 static const struct xe_config_device device_defaults = {
@@ -362,8 +364,21 @@ static struct configfs_item_operations xe_config_device_ops = {
        .release        = xe_config_device_release,
 };
 
+static bool xe_config_device_is_visible(struct config_item *item,
+                                       struct configfs_attribute *attr, int n)
+{
+       struct xe_config_group_device *dev = to_xe_config_group_device(item);
+
+       return dev->desc; /* shall be always true */
+}
+
+static struct configfs_group_operations xe_config_device_group_ops = {
+       .is_visible     = xe_config_device_is_visible,
+};
+
 static const struct config_item_type xe_config_device_type = {
        .ct_item_ops    = &xe_config_device_ops,
+       .ct_group_ops   = &xe_config_device_group_ops,
        .ct_attrs       = xe_config_device_attrs,
        .ct_owner       = THIS_MODULE,
 };
@@ -442,6 +457,7 @@ static struct config_group *xe_config_make_device_group(struct config_group *gro
        if (!dev)
                return ERR_PTR(-ENOMEM);
 
+       dev->desc = match;
        set_device_defaults(&dev->config);
 
        config_group_init_type_name(&dev->group, name, &xe_config_device_type);
@@ -451,12 +467,12 @@ static struct config_group *xe_config_make_device_group(struct config_group *gro
        return &dev->group;
 }
 
-static struct configfs_group_operations xe_config_device_group_ops = {
+static struct configfs_group_operations xe_config_group_ops = {
        .make_group     = xe_config_make_device_group,
 };
 
 static const struct config_item_type xe_configfs_type = {
-       .ct_group_ops   = &xe_config_device_group_ops,
+       .ct_group_ops   = &xe_config_group_ops,
        .ct_owner       = THIS_MODULE,
 };