dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: "Michel Dänzer" <michel@daenzer.net>,
	"Maling list - DRI developers" <dri-devel@lists.freedesktop.org>,
	"Dmitry Vyukov" <dvyukov@google.com>
Subject: Re: [PATCH 2/2] drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver
Date: Wed, 30 Nov 2016 12:21:02 -0500	[thread overview]
Message-ID: <CADnq5_N28ar5oiC3fJkGrJj5F5FMGfS7_RemLSPvPO_kya9PSQ@mail.gmail.com> (raw)
In-Reply-To: <20161130090758.kzrvr2c6tt55vnpw@phenom.ffwll.local>

On Wed, Nov 30, 2016 at 4:07 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Wed, Nov 30, 2016 at 05:30:02PM +0900, Michel Dänzer wrote:
>> 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:
>
> Dumb buffers are only meant to be used for kms drivers, should be
> disallowed too.
>
>> +     case DRM_CAP_VBLANK_HIGH_CRTC:
>
> Might be good to have a comment here that we need to allow this for old
> ums?
>

I don't think we need this for UMS.  It was added for evergreen and we
only supported this feature on KMS.

Alex

>> +     case DRM_CAP_PRIME:
>> +     case DRM_CAP_TIMESTAMP_MONOTONIC:
>
> This is pretty new, I don't think any of the old ums drivers was ever
> updated to use it. Should probably disallow it too.
>> +             break;
>> +     default:
>> +             if (!drm_core_check_feature(dev, DRIVER_MODESET))
>> +                     return -ENOTSUPP;
>> +     }
>
> And one code org bikeshed: I don't like the duplicated switch, could we
> instead split it it into two disjoint sets like this?
>
>         switch (req->capability) {
>         case DRM_CAP_PRIME:
>                 req->value |= dev->driver->prime_fd_to_handle ? DRM_PRIME_CAP_IMPORT : 0;
>                 req->value |= dev->driver->prime_handle_to_fd ? DRM_PRIME_CAP_EXPORT : 0;
>                 break;
>         ... all other non-modeset caps ...
>         }
>
>         if (!drm_core_check_feature(dev, DRIVER_MODESET))
>                 return -ENOTSUPP;
>
>         switch (req->capability) {
>         ... handle remaining caps needed for DRIVER_MODSET ...
>         default:
>                 return -EINVAL;
>         }
>
> That way it would be a bit more obvious that people who add a new cap need
> to make a decision where to put it (and by default put it in the bottom
> pile).
> -Daniel
>
>>       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
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-11-30 17:21 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                     ` [PATCH 2/2] drm: Return -ENOTSUPP when called for KMS cap " Michel Dänzer
2016-11-30  9:07                       ` Daniel Vetter
2016-11-30 17:21                         ` Alex Deucher [this message]
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=CADnq5_N28ar5oiC3fJkGrJj5F5FMGfS7_RemLSPvPO_kya9PSQ@mail.gmail.com \
    --to=alexdeucher@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvyukov@google.com \
    --cc=michel@daenzer.net \
    /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).