dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel@daenzer.net>
To: dri-devel@lists.freedesktop.org
Cc: Dmitry Vyukov <dvyukov@google.com>
Subject: [PATCH 2/2] drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver
Date: Wed, 30 Nov 2016 17:30:02 +0900	[thread overview]
Message-ID: <20161130083002.1520-2-michel@daenzer.net> (raw)
In-Reply-To: <20161130083002.1520-1-michel@daenzer.net>

From: Michel Dänzer <michel.daenzer@amd.com>

This is an attempt to make the previous fix a bit more robust going
forward.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 drivers/gpu/drm/drm_ioctl.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 71c3473..32f484b 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -229,6 +229,19 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	struct drm_crtc *crtc;
 
 	req->value = 0;
+
+	/* Only allow non-KMS caps with non-KMS drivers */
+	switch (req->capability) {
+	case DRM_CAP_DUMB_BUFFER:
+	case DRM_CAP_VBLANK_HIGH_CRTC:
+	case DRM_CAP_PRIME:
+	case DRM_CAP_TIMESTAMP_MONOTONIC:
+		break;
+	default:
+		if (!drm_core_check_feature(dev, DRIVER_MODESET))
+			return -ENOTSUPP;
+	}
+
 	switch (req->capability) {
 	case DRM_CAP_DUMB_BUFFER:
 		if (dev->driver->dumb_create)
@@ -254,12 +267,10 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		req->value = dev->mode_config.async_page_flip;
 		break;
 	case DRM_CAP_PAGE_FLIP_TARGET:
-		if (drm_core_check_feature(dev, DRIVER_MODESET)) {
-			req->value = 1;
-			drm_for_each_crtc(crtc, dev) {
-				if (!crtc->funcs->page_flip_target)
-					req->value = 0;
-			}
+		req->value = 1;
+		drm_for_each_crtc(crtc, dev) {
+			if (!crtc->funcs->page_flip_target)
+				req->value = 0;
 		}
 		break;
 	case DRM_CAP_CURSOR_WIDTH:
-- 
2.10.2

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

  reply	other threads:[~2016-11-30  8:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09 11:56 drm: GPF in drm_getcap Dmitry Vyukov
2016-11-26 17:17 ` Dmitry Vyukov
2016-11-26 17:35   ` David Herrmann
2016-11-26 17:50     ` Dmitry Vyukov
2016-11-26 18:02       ` David Herrmann
2016-11-26 18:07         ` Dmitry Vyukov
2016-11-26 18:22           ` David Herrmann
2016-11-28  6:55             ` Daniel Vetter
2016-11-28  7:14               ` Michel Dänzer
2016-11-28  8:41                 ` Dmitry Vyukov
2016-11-30  8:30                   ` [PATCH 1/2] drm: Don't call drm_for_each_crtc with a non-KMS driver Michel Dänzer
2016-11-30  8:30                     ` Michel Dänzer [this message]
2016-11-30  9:07                       ` [PATCH 2/2] drm: Return -ENOTSUPP when called for KMS cap " Daniel Vetter
2016-11-30 17:21                         ` Alex Deucher
2016-12-01  7:35                         ` Michel Dänzer
2016-12-01  7:37                         ` [PATCH v2] " Michel Dänzer
2016-12-01 14:46                           ` Alex Deucher
2016-12-05  8:05                             ` Daniel Vetter
2016-12-01 15:21                           ` Sean Paul
2016-12-01 15:23                             ` Daniel Vetter
2016-11-30  9:13                     ` [PATCH 1/2] drm: Don't call drm_for_each_crtc " Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161130083002.1520-2-michel@daenzer.net \
    --to=michel@daenzer.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvyukov@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).