Skip to contentSkip to conversation

drm: support feature masks in drm_core_check_feature()

PATCH Superseded Jani Nikula 2 participants 3 messages Jan 21, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm: support feature masks in drm_core_check_feature()

Allow a mask of features to be passed to drm_core_check_feature(). All features in the mask are required.

---
 include/drm/drm_drv.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
include/drm/drm_drv.h +6 -4
index cf13470810a5..51b486d1ee81 100644
@@ -826,16 +826,18 @@ static inline bool drm_dev_is_unplugged(struct drm_device *dev)
 /**
  * drm_core_check_feature - check driver feature flags
  * @dev: DRM device to check
- * @feature: feature flag
+ * @feature: feature flag(s)
  *
  * This checks @dev for driver features, see &drm_driver.driver_features,
  * &drm_device.driver_features, and the various &enum drm_driver_feature flags.
  *
- * Returns true if the @feature is supported, false otherwise.
+ * Returns true if all features in the @feature mask are supported, false
+ * otherwise.
  */
-static inline bool drm_core_check_feature(const struct drm_device *dev, u32 feature)
+static inline bool drm_core_check_feature(const struct drm_device *dev, u32 features)
 {
-	return dev->driver->driver_features & dev->driver_features & feature;
+	return features && (dev->driver->driver_features & dev->driver_features &
+			    features) == features;
 }
 
 /**
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/2 drm/debugfs: also take per device driver features into account

Use drm_core_check_feature() to ensure both the driver features and the per-device driver features are taken into account when registering debugfs files.

---
 drivers/gpu/drm/drm_debugfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/drm_debugfs.c +1 -4
index eab0f2687cd6..af3531bf57d3 100644
@@ -180,10 +180,7 @@ int drm_debugfs_create_files(const struct drm_info_list *files, int count,
 	int i;
 
 	for (i = 0; i < count; i++) {
-		u32 features = files[i].driver_features;
-
-		if (features != 0 &&
-		    (dev->driver->driver_features & features) != features)
+		if (!drm_core_check_feature(dev, files[i].driver_features))
 			continue;
 
 		tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/2
#2 lore raw
In reply to Jani Nikula
Quoted 13 lines · Jani Nikula

Allow a mask of features to be passed to drm_core_check_feature(). All features in the mask are required.

---
 include/drm/drm_drv.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
include/drm/drm_drv.h +0 -0
index cf13470810a5..51b486d1ee81 100644

include/drm/drm_drv.h static inline bool drm_dev_is_unplugged(struct drm_device *dev) · line 829

Quoted 5 lines
include/drm/drm_drv.h +1 -1
@@ -826,16 +826,18 @@ static inline bool drm_dev_is_unplugged(struct drm_device *dev)
 /**
  * drm_core_check_feature - check driver feature flags
  * @dev: DRM device to check
- * @feature: feature flag
+ * @feature: feature flag(s)
              ^

missing 's'

include/drm/drm_drv.h static inline bool drm_dev_is_unplugged(struct drm_device *dev) · line 834

Quoted 6 lines
include/drm/drm_drv.h +1 -1
  *
  * This checks @dev for driver features, see &drm_driver.driver_features,
  * &drm_device.driver_features, and the various &enum drm_driver_feature flags.
  *
- * Returns true if the @feature is supported, false otherwise.
+ * Returns true if all features in the @feature mask are supported, false

same here

include/drm/drm_drv.h static inline bool drm_dev_is_unplugged(struct drm_device *dev) · line 840

Quoted 8 lines
include/drm/drm_drv.h +4 -2
+ * otherwise.
  */
-static inline bool drm_core_check_feature(const struct drm_device *dev, u32 feature)
+static inline bool drm_core_check_feature(const struct drm_device *dev, u32 features)
 {
-	return dev->driver->driver_features & dev->driver_features & feature;
+	return features && (dev->driver->driver_features & dev->driver_features &
+			    features) == features;

Could maybe do with an extra variable?

u32 supported = driver->driver_features & dev->driver_features; return features && (features & supported) == features;

Series is

Quoted 10 lines
include/drm/drm_drv.h +0 -0
 }
 
 /**
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel