All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm: support feature masks in drm_core_check_feature()
@ 2020-01-21 10:53 ` Jani Nikula
  0 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2020-01-21 10:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Jani Nikula, intel-gfx

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

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 include/drm/drm_drv.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index cf13470810a5..51b486d1ee81 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -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;
 }
 
 /**
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Intel-gfx] [PATCH 1/2] drm: support feature masks in drm_core_check_feature()
@ 2020-01-21 10:53 ` Jani Nikula
  0 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2020-01-21 10:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Jani Nikula, intel-gfx

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

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 include/drm/drm_drv.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index cf13470810a5..51b486d1ee81 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -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;
 }
 
 /**
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] drm/debugfs: also take per device driver features into account
  2020-01-21 10:53 ` [Intel-gfx] " Jani Nikula
@ 2020-01-21 10:53   ` Jani Nikula
  -1 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2020-01-21 10:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Jani Nikula, intel-gfx

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.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_debugfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index eab0f2687cd6..af3531bf57d3 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -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);
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Intel-gfx] [PATCH 2/2] drm/debugfs: also take per device driver features into account
@ 2020-01-21 10:53   ` Jani Nikula
  0 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2020-01-21 10:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Jani Nikula, intel-gfx

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.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_debugfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index eab0f2687cd6..af3531bf57d3 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -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);
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] drm: support feature masks in drm_core_check_feature()
  2020-01-21 10:53 ` [Intel-gfx] " Jani Nikula
@ 2020-01-21 14:26   ` Ville Syrjälä
  -1 siblings, 0 replies; 6+ messages in thread
From: Ville Syrjälä @ 2020-01-21 14:26 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx, dri-devel

On Tue, Jan 21, 2020 at 12:53:30PM +0200, Jani Nikula wrote:
> Allow a mask of features to be passed to drm_core_check_feature(). All
> features in the mask are required.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  include/drm/drm_drv.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index cf13470810a5..51b486d1ee81 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -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'

>   *
>   * 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

> + * 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
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  }
>  
>  /**
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: support feature masks in drm_core_check_feature()
@ 2020-01-21 14:26   ` Ville Syrjälä
  0 siblings, 0 replies; 6+ messages in thread
From: Ville Syrjälä @ 2020-01-21 14:26 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx, dri-devel

On Tue, Jan 21, 2020 at 12:53:30PM +0200, Jani Nikula wrote:
> Allow a mask of features to be passed to drm_core_check_feature(). All
> features in the mask are required.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  include/drm/drm_drv.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index cf13470810a5..51b486d1ee81 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -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'

>   *
>   * 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

> + * 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
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  }
>  
>  /**
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-21 14:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-21 10:53 [PATCH 1/2] drm: support feature masks in drm_core_check_feature() Jani Nikula
2020-01-21 10:53 ` [Intel-gfx] " Jani Nikula
2020-01-21 10:53 ` [PATCH 2/2] drm/debugfs: also take per device driver features into account Jani Nikula
2020-01-21 10:53   ` [Intel-gfx] " Jani Nikula
2020-01-21 14:26 ` [PATCH 1/2] drm: support feature masks in drm_core_check_feature() Ville Syrjälä
2020-01-21 14:26   ` [Intel-gfx] " Ville Syrjälä

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.