diff mbox series

[01/20] drm: Let userspace check if driver supports modeset

Message ID 20180809001606.26876-1-jose.souza@intel.com (mailing list archive)
State New, archived
Headers show
Series [01/20] drm: Let userspace check if driver supports modeset | expand

Commit Message

Souza, Jose Aug. 9, 2018, 12:15 a.m. UTC
GPU accelerators usually don't have display block or the display
driver part can be disabled when building driver(for servers it saves
some resources) so it is important let userspace check this
capability too.

Right now we are checking
drmModeGetResources()/drm_mode_getresources() for a error to detect
if display is enabled but it is a hackish way as it can fail for
other reasons too.

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 drivers/gpu/drm/drm_ioctl.c | 3 +++
 include/uapi/drm/drm.h      | 1 +
 2 files changed, 4 insertions(+)

Comments

Chris Wilson Aug. 9, 2018, 8:34 a.m. UTC | #1
Quoting José Roberto de Souza (2018-08-09 01:15:47)
> GPU accelerators usually don't have display block or the display
> driver part can be disabled when building driver(for servers it saves
> some resources) so it is important let userspace check this
> capability too.
> 
> Right now we are checking
> drmModeGetResources()/drm_mode_getresources() for a error to detect
> if display is enabled but it is a hackish way as it can fail for
> other reasons too.

Literally there are no other ways to fail. It reports -EINVAL if
!MODESET and the counts otherwise. No allocations, no pointer chasing.
-Chris
Souza, Jose Aug. 15, 2018, 8:34 p.m. UTC | #2
Ping series review

On Wed, 2018-08-08 at 17:15 -0700, José Roberto de Souza wrote:
> GPU accelerators usually don't have display block or the display
> driver part can be disabled when building driver(for servers it saves
> some resources) so it is important let userspace check this
> capability too.
> 
> Right now we are checking
> drmModeGetResources()/drm_mode_getresources() for a error to detect
> if display is enabled but it is a hackish way as it can fail for
> other reasons too.
> 
> Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> ---
>  drivers/gpu/drm/drm_ioctl.c | 3 +++
>  include/uapi/drm/drm.h      | 1 +
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_ioctl.c
> b/drivers/gpu/drm/drm_ioctl.c
> index ea10e9a26aad..3a8438ae9b51 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -244,6 +244,9 @@ static int drm_getcap(struct drm_device *dev,
> void *data, struct drm_file *file_
>  	case DRM_CAP_SYNCOBJ:
>  		req->value = drm_core_check_feature(dev,
> DRIVER_SYNCOBJ);
>  		return 0;
> +	case DRM_CAP_MODESET:
> +		req->value = drm_core_check_feature(dev,
> DRIVER_MODESET);
> +		return 0;
>  	}
>  
>  	/* Other caps only work with KMS drivers */
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index 300f336633f2..85fae6ddbf48 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -649,6 +649,7 @@ struct drm_gem_open {
>  #define DRM_CAP_PAGE_FLIP_TARGET	0x11
>  #define DRM_CAP_CRTC_IN_VBLANK_EVENT	0x12
>  #define DRM_CAP_SYNCOBJ		0x13
> +#define DRM_CAP_MODESET		0x14
>  
>  /** DRM_IOCTL_GET_CAP ioctl argument type */
>  struct drm_get_cap {
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index ea10e9a26aad..3a8438ae9b51 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -244,6 +244,9 @@  static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_SYNCOBJ:
 		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
 		return 0;
+	case DRM_CAP_MODESET:
+		req->value = drm_core_check_feature(dev, DRIVER_MODESET);
+		return 0;
 	}
 
 	/* Other caps only work with KMS drivers */
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 300f336633f2..85fae6ddbf48 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -649,6 +649,7 @@  struct drm_gem_open {
 #define DRM_CAP_PAGE_FLIP_TARGET	0x11
 #define DRM_CAP_CRTC_IN_VBLANK_EVENT	0x12
 #define DRM_CAP_SYNCOBJ		0x13
+#define DRM_CAP_MODESET		0x14
 
 /** DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {