From: Rohan Garg <rohan.garg@collabora.com>
To: dri-devel@lists.freedesktop.org, Emil Velikov <emil.l.velikov@gmail.com>
Cc: kernel@collabora.com
Subject: Re: [PATCH v5 1/2] drm/ioctl: Add a ioctl to set and get a label on GEM objects
Date: Thu, 21 May 2020 02:07:09 +0200 [thread overview]
Message-ID: <7761830.T7Z3S40VBb@solembum> (raw)
In-Reply-To: <CACvgo52mso5kEWtjBQKM9RF51P=KnERRoWGai-emo2ofzJWLXA@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 3527 bytes --]
Hey Emil
I've applied all the suggestions except the ones I discuss below.
>
> As a high-level question: how does this compare to VC4_LABEL_BO?
> Is it possible to implement to replace or partially implement the vc4
> one with this infra?
>
> IMHO this is something to aim for.
>
Yep, the intention is to replace the VC4 specific labeling with a more generic
framework that all drivers can use.
> A handful of ideas and suggestions below:
>
> On Thu, 14 May 2020 at 16:05, Rohan Garg <rohan.garg@collabora.com> wrote:
> > Signed-off-by: Rohan Garg <rohan.garg@collabora.com>
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> New functionality usually has suggested-by tags. Reported-by tags are
> used when the feature isn't behaving as expected.
>
This was suggested as part of the previous review process [1].
> > +
> > + kfree(gem_obj->label);
> > +
> > + gem_obj->label = adopted_label;
>
> Do we have any protection of ->label wrt concurrent access? Say two
> writers, attempting to both set the label.
>
Great catch. I'll protect this from concurrent access.
>
> > +
> > + if (!dev->driver->set_label || args->len > PAGE_SIZE)
>
> AFAICT the PAGE_SIZE check should be a EINVAL.
>
> Additionally, It would be better, to use the default implementation
> when the function pointer is not explicitly set.
> That should allow for more consistent and easier use.
>
> Think about the time gap (esp. for some distributions) between the
> kernel feature landing and being generally accessible to userspace.
>
This is intentional since vmgfx uses TTM and the DRM helpers would not work.
Sure, we could simply add a patch to the series that hooks up the relevant
code to vmgfx and then calls the DRM label helper for all other drivers, but
I'd rather have driver developers explicitly opt into this functionality.
> > + return -EOPNOTSUPP;
> > +
> > + if (!args->len)
> > + label = NULL;
> > + else if (args->len && args->label)
> > + label = strndup_user(u64_to_user_ptr(args->label),
> > args->len); + else
>
> Might be worth throwing EINVAL for !len && label... or perhaps not. In
> either case please document it.
>
Hm, I'm not entirely sure what documentation I should add here since we
already document the drm_handle_label struct in the relevant header.
>
> > +
> > + if (args->label)
> > + ret = copy_to_user(u64_to_user_ptr(args->label),
> > + label,
> > + args->len);
> > +
>
> Consider the following - userspace allocates less memory than needed
> for the whole string.
> Be that size concerns or simply because it's interested only in the
> first X bytes.
>
> If we're interested in supporting that, a simple min(args->len, len)
> could be used.
>
I wouldn't be opposed to this if such a need arises in the future.
> s/int/__u32/ + comment, currently no flags are defined.
> > +#define DRM_IOCTL_HANDLE_SET_LABEL DRM_IOWR(0xCF, struct
> > drm_handle_label)
> Pretty sure that WR is wrong here, although I don't recall we should
> be using read or write only.
> Unfortunately many drivers/ioctls get this wrong :-\
>
From a quick read of the IO{W,R} documentation, I suppose we should be marking
SET_LABEL as DRM_IOW and GET_LABEL as DRM_IOR.
Thanks!
Rohan Garg
[1] https://patchwork.freedesktop.org/patch/335508/?
series=66752&rev=4#comment_621167
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-05-21 0:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-14 15:05 [PATCH v5 0/2] Introducing IOCTL's to set/get label's for a buffer object Rohan Garg
2020-05-14 15:05 ` [PATCH v5 1/2] drm/ioctl: Add a ioctl to set and get a label on GEM objects Rohan Garg
2020-05-19 23:48 ` Emil Velikov
2020-05-21 0:07 ` Rohan Garg [this message]
2020-05-21 1:19 ` Emil Velikov
2020-05-14 15:05 ` [PATCH v5 2/2] panfrost: Set default labeling helpers Rohan Garg
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=7761830.T7Z3S40VBb@solembum \
--to=rohan.garg@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=kernel@collabora.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 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.