diff mbox

drm: Allow CAP_DUMB_BUFFERS on !MODESET

Message ID 20180504142547.12930-1-ezequiel@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ezequiel Garcia May 4, 2018, 2:25 p.m. UTC
It's perfectly possible to get dumb buffers out of drivers
that don't support modeset. This is the case of vgem,
which can be used to export dmabuf to run various tests.
Therefore, move the dumb buffer capability check before
the mode set check.

Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").

Fixes: d5264ed3823a ("drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver")
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
---
 drivers/gpu/drm/drm_ioctl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Maarten Lankhorst May 7, 2018, 9:36 a.m. UTC | #1
Op 04-05-18 om 16:25 schreef Ezequiel Garcia:
> It's perfectly possible to get dumb buffers out of drivers
> that don't support modeset. This is the case of vgem,
> which can be used to export dmabuf to run various tests.
> Therefore, move the dumb buffer capability check before
> the mode set check.
>
> Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").
>
> Fixes: d5264ed3823a ("drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver")
> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> ---
>  drivers/gpu/drm/drm_ioctl.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index af782911c505..deac011a0c25 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_DUMB_BUFFER:
> +		req->value |= dev->driver->dumb_create ? 1 : 0;
Why the |= ?
> +		return 0;
>  	}
>  
>  	/* Other caps only work with KMS drivers */
> @@ -251,10 +254,6 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
>  		return -ENOTSUPP;
>  
>  	switch (req->capability) {
> -	case DRM_CAP_DUMB_BUFFER:
> -		if (dev->driver->dumb_create)
> -			req->value = 1;
> -		break;
>  	case DRM_CAP_VBLANK_HIGH_CRTC:
>  		req->value = 1;
>  		break;
Ezequiel Garcia May 8, 2018, 4:47 a.m. UTC | #2
On Mon, 2018-05-07 at 11:36 +0200, Maarten Lankhorst wrote:
> Op 04-05-18 om 16:25 schreef Ezequiel Garcia:
> > It's perfectly possible to get dumb buffers out of drivers
> > that don't support modeset. This is the case of vgem,
> > which can be used to export dmabuf to run various tests.
> > Therefore, move the dumb buffer capability check before
> > the mode set check.
> > 
> > Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").
> > 
> > Fixes: d5264ed3823a ("drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver")
> > Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> > ---
> >  drivers/gpu/drm/drm_ioctl.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> > index af782911c505..deac011a0c25 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_DUMB_BUFFER:
> > +		req->value |= dev->driver->dumb_create ? 1 : 0;
> 
> Why the |= ?

I'd say that's a silly copy-paste glitch. Will send a v2.

> > +		return 0;
> >  	}
> >  
> >  	/* Other caps only work with KMS drivers */
> > @@ -251,10 +254,6 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
> >  		return -ENOTSUPP;
> >  
> >  	switch (req->capability) {
> > -	case DRM_CAP_DUMB_BUFFER:
> > -		if (dev->driver->dumb_create)
> > -			req->value = 1;
> > -		break;
> >  	case DRM_CAP_VBLANK_HIGH_CRTC:
> >  		req->value = 1;
> >  		break;
> 
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index af782911c505..deac011a0c25 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_DUMB_BUFFER:
+		req->value |= dev->driver->dumb_create ? 1 : 0;
+		return 0;
 	}
 
 	/* Other caps only work with KMS drivers */
@@ -251,10 +254,6 @@  static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		return -ENOTSUPP;
 
 	switch (req->capability) {
-	case DRM_CAP_DUMB_BUFFER:
-		if (dev->driver->dumb_create)
-			req->value = 1;
-		break;
 	case DRM_CAP_VBLANK_HIGH_CRTC:
 		req->value = 1;
 		break;