From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Kniss Subject: Re: [PATCH] Add drm ioctl DRM_IOCTL_MODE_GETFB2 & associated helpers. Date: Tue, 1 Aug 2017 10:24:25 -0700 Message-ID: References: <20170731182913.136758-1-djmk@google.com> <1585370.MpXFX8O0mo@avalon> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1887489858==" Return-path: In-Reply-To: <1585370.MpXFX8O0mo@avalon> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Laurent Pinchart Cc: amd-gfx@lists.freedesktop.org, heiko@sntech.de, Sean Paul , michel.daenzer@amd.com, dri-devel@lists.freedesktop.org, thierry.reding@gmail.com, krzk@kernel.org, gnurou@gmail.com, linux-samsung-soc@vger.kernel.org, jy0922.shim@samsung.com, linux-rockchip@lists.infradead.org, kyungmin.park@samsung.com, javier@osg.samsung.com, tomi.valkeinen@ti.com, bskeggs@redhat.com, nouveau@lists.freedesktop.org, ck.hu@mediatek.com, Andrey.Grodzovsky@amd.com, Joe Kniss , swarren@wwwdotorg.org, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, lin , linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com, =?UTF-8?Q?St=C3=A9phane_Marchesin?= , nils.wallmenius@gmail.com, freedreno@lists.freedesktop.org, sw0312.kim@samsung.com List-Id: linux-arm-msm@vger.kernel.org --===============1887489858== Content-Type: multipart/alternative; boundary="94eb2c1ba8cc4527630555b46b08" --94eb2c1ba8cc4527630555b46b08 Content-Type: text/plain; charset="UTF-8" Thanks for the quick review! On Tue, Aug 1, 2017 at 5:09 AM, Laurent Pinchart wrote: > Hi Joe, > > Thank you for the patch. > > On Monday 31 Jul 2017 11:29:13 Joe Kniss wrote: > > New getfb2 functionality uses drm_mode_fb_cmd2 struct to be symmetric > > with addfb2. > > What's the use case for this ? We haven't needed such an ioctl for so long > that it seemed to me that userspace doesn't really need it, but I could be > wrong. > > Sorry, I failed to reference the original email. Here it is: I am a recent addition to Google's ChromeOS gfx team. I am currently working on display testing and reporting. An important part of this is our screen capture tool, which works by querying drm for crtcs, planes, and fbs. Unfortunately, there is only limited information available via drmModeGetFB(), which often wrong information when drmModeAddFB2() was used to create the fbs. For example, if the pixel format is NV12 or YUV420, the fb returned knows nothing about the additional buffer planes required by these formats. Ideally, we would like a function (e.g. drmModeGetFB2) to return information symmetric with drmModeAddFB2 including the pixel format id, buffer plane information etc. ChromeOS has needed this functionality from the start, for both testing and error reporting. We got away with guessing the buffer's format (32bit xrgb) until now. We are now enabling overlays and more formats including multi-planar (e.g. NV12). Current getfb() reports neither the pixel format nor planar information. Without this information, going forward, our gfx testing is going to break. It would be great if we had access to higher level buffer structs (like gbm), but we generally don't since they would be created by other apps (chrome browser, android apps, etc...). > > Also modifies *_fb_create_handle() calls to accept a > > format_plane_index so that handles for each plane can be generated. > > Previously, many *_fb_create_handle() calls simply defaulted to plane 0 > > only. > > And with this patch the amd/amdgpu, armada, gma500, i915, mediatek, msm, > nouveau and radeon drivers still do. Do none of them support multi-planar > formats ? > > I would imagine that some of these do support multi-planar formats, but they don't appear to have them implemented yet (except perhaps as offsets into a single buffer). I will certainly be looking into this soon, but any changes will come in future patches. > > Signed-off-by: Joe Kniss > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 5 +- > > drivers/gpu/drm/armada/armada_fb.c | 1 + > > drivers/gpu/drm/drm_crtc_internal.h | 2 + > > drivers/gpu/drm/drm_fb_cma_helper.c | 11 ++-- > > drivers/gpu/drm/drm_framebuffer.c | 79 > +++++++++++++++++++++++++- > > drivers/gpu/drm/drm_ioctl.c | 1 + > > drivers/gpu/drm/exynos/exynos_drm_fb.c | 7 ++- > > drivers/gpu/drm/gma500/framebuffer.c | 2 + > > drivers/gpu/drm/i915/intel_display.c | 1 + > > drivers/gpu/drm/mediatek/mtk_drm_fb.c | 1 + > > drivers/gpu/drm/msm/msm_fb.c | 5 +- > > drivers/gpu/drm/nouveau/nouveau_display.c | 1 + > > drivers/gpu/drm/omapdrm/omap_fb.c | 5 +- > > drivers/gpu/drm/radeon/radeon_display.c | 5 +- > > drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 6 ++- > > drivers/gpu/drm/tegra/fb.c | 9 +++- > > include/drm/drm_framebuffer.h | 1 + > > include/uapi/drm/drm.h | 2 + > > 18 files changed, 127 insertions(+), 17 deletions(-) > > [snip] > > > diff --git a/drivers/gpu/drm/drm_framebuffer.c > > b/drivers/gpu/drm/drm_framebuffer.c index 28a0108a1ab8..67b3be1bedbc > 100644 > > --- a/drivers/gpu/drm/drm_framebuffer.c > > +++ b/drivers/gpu/drm/drm_framebuffer.c > > @@ -24,6 +24,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "drm_crtc_internal.h" > > [snip] > > > +/** > > + * drm_mode_getfb2 - get FB info > > + * @dev: drm device for the ioctl > > + * @data: data pointer for the ioctl > > + * @file_priv: drm file for the ioctl call > > + * > > + * Lookup the FB given its ID and return info about it. > > + * > > + * Called by the user via ioctl. > > + * > > + * Returns: > > + * Zero on success, negative errno on failure. > > + */ > > +int drm_mode_getfb2(struct drm_device *dev, > > + void *data, struct drm_file *file_priv) > > +{ > > + struct drm_mode_fb_cmd2 *r = data; > > + struct drm_framebuffer *fb; > > + int ret, i; > > + > > + if (!drm_core_check_feature(dev, DRIVER_MODESET)) > > + return -EINVAL; > > + > > + fb = drm_framebuffer_lookup(dev, r->fb_id); > > + if (!fb) > > + return -ENOENT; > > + > > + r->height = fb->height; > > + r->width = fb->width; > > + r->pixel_format = fb->format->format; > > + for (i = 0; i < 4; ++i) { > > + r->pitches[i] = fb->pitches[i]; > > + r->offsets[i] = fb->offsets[i]; > > + r->modifier[i] = fb->modifier; > > + r->handles[i] = 0; > > + } > > + > > + for (i = 0; i < fb->format->num_planes; ++i) { > > + if (fb->funcs->create_handle) { > > + if (drm_is_current_master(file_priv) || > > + capable(CAP_SYS_ADMIN) || > > + drm_is_control_client(file_priv)) { > > + ret = fb->funcs->create_handle(fb, i, > > file_priv, > > + > > &r->handles[i]); > > + if (ret) > > + break; > > + } else { > > + /* GET_FB() is an unprivileged ioctl so we > > must > > + * not return a buffer-handle to non-master > > + * processes! For backwards-compatibility > > + * reasons, we cannot make GET_FB() > > privileged, > > + * so just return an invalid handle for > > + * non-masters. */ > > There's no backward compatibility to handle here, just make it privileged > if > it has to be. > > Sure thing, sounds good. > > + r->handles[i] = 0; > > + ret = 0; > > + } > > + } else { > > + ret = -ENODEV; > > + break; > > + } > > + } > > + > > + /* If handle creation failed, delete/dereference any that were > made. > */ > > + if (ret) { > > + for (i = 0; i < 4; ++i) { > > + if (r->handles[i]) > > + drm_gem_handle_delete(file_priv, r- > >handles[i]); > > My initial reaction to this was to reply that not all drivers use GEM, but > after some investigation it seems they actually do. If that's really the > case, > we could get rid of the .create_handle() operation completely, which should > simplify the implementation of both DRM_IOCTL_MODE_GETFB and > DRM_IOCTL_MODE_GETFB2. > > Deleting the handle is the same in all cases, but creating the handle isn't consistent across the drivers. I didn't see a clean way to simplify this. > > + r->handles[i] = 0; > > + } > > + } > > + > > + drm_framebuffer_unreference(fb); > > + > > + return ret; > > +} > > [snip] > > > diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c > > b/drivers/gpu/drm/omapdrm/omap_fb.c index 29dc677dd4d3..a982c72a773e > 100644 > > --- a/drivers/gpu/drm/omapdrm/omap_fb.c > > +++ b/drivers/gpu/drm/omapdrm/omap_fb.c > > @@ -90,12 +90,15 @@ struct omap_framebuffer { > > }; > > > > static int omap_framebuffer_create_handle(struct drm_framebuffer *fb, > > + unsigned int format_plane_index, > > struct drm_file *file_priv, > > unsigned int *handle) > > { > > struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb); > > + if (format_plane_index >= 4 || !omap_fb->planes[format_plane_ > index]) > > The first check shouldn't be needed, the core should never call this > operation > with an index >= 4. > > I'll remove the check then. > > + return -ENOENT; > > return drm_gem_handle_create(file_priv, > > - omap_fb->planes[0].bo, handle); > > + omap_fb->planes[format_plane_index].bo, handle); > > } > > [snip] > > > diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h > > index b2c52843bc70..c81c75335cca 100644 > > --- a/include/uapi/drm/drm.h > > +++ b/include/uapi/drm/drm.h > > @@ -814,6 +814,8 @@ extern "C" { > > #define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct > > drm_mode_create_blob) > > #define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct > > drm_mode_destroy_blob) > > > > +#define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xC4, struct drm_mode_fb_cmd2) > > + > > Which tree is this based on ? The last defined ioctl > (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE) is 0xC2 in drm-next and drm-misc-next. > > I just did a quick search for "DRM_IOWR 0xC*" and picked the first unused one, there was a patch in-flight from last month that used 0xC3 ( https://lists.freedesktop.org/archives/amd-gfx/2017-June/010153.html). Naturally, I'll set this to whatever is appropriate. > > /** > > * Device specific ioctls should only be in their respective headers > > * The device specific ioctl range is from 0x40 to 0x9f. > > -- > Regards, > > Laurent Pinchart > > Thanks! -j -- Dr. Joe Michael Kniss | Google ChromeOS | djmk@google.com | 1-801-898-7977 <(801)%20898-7977> --94eb2c1ba8cc4527630555b46b08 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for the quick review!=C2=A0

On Tue, Aug 1, 2017 at 5:09 AM, Laure= nt Pinchart <laurent.pinchart@ideasonboard.com>= ; wrote:
Hi Joe= ,

Thank you for the patch.

On Monday 31 Jul 2017 11:29:13 Joe Kniss wrote:
> New getfb2 functionality uses drm_mode_fb_cmd2 struct to be symmetric<= br> > with addfb2.

What's the use case for this ? We haven't needed such an ioc= tl for so long
that it seemed to me that userspace doesn't really need it, but I could= be
wrong.

Sorry, I failed to reference the origina= l email.=C2=A0 Here it is:=C2=A0
<snip>
=C2=A0I am a recent addition to Google's Chrome= OS gfx team. =C2=A0 I am currently working on display testing and reporting= . =C2=A0 An important part of this is our screen capture tool, which works = by querying drm for crtcs, planes, and fbs.=C2=A0 Unfortunately, there is o= nly limited information available via drmModeGetFB(), which often wrong inf= ormation when drmModeAddFB2() was used to create the fbs. =C2=A0 For exampl= e, if the pixel format is NV12 or YUV420, the fb returned knows nothing abo= ut the additional buffer planes required by these formats. =C2=A0 Ideally, = we would like a function (e.g. drmModeGetFB2) to return information symmetr= ic with drmModeAddFB2 including the pixel format id, buffer plane informati= on etc. =C2=A0=C2=A0
<= /snip>
ChromeOS has needed this functionality from the = start, for both testing and error reporting.=C2=A0 We got away with guessin= g the buffer's format (32bit xrgb) until now.=C2=A0 We are now enabling= overlays and more formats including multi-planar (e.g. NV12).=C2=A0 Curren= t getfb() reports neither the pixel format nor =C2=A0planar information.=C2= =A0 Without this information, going forward, our gfx testing is going to br= eak.=C2=A0 It would be great if we had access to higher level buffer struct= s (like gbm), but we generally don't since they would be created by oth= er apps (chrome browser, android apps, etc...).
=C2=A0
> Also modifies *_fb_create_handle() calls to accept a
> format_plane_index so that handles for each plane can be generated. > Previously, many *_fb_create_handle() calls simply defaulted to plane = 0
> only.

And with this patch the amd/amdgpu, armada, gma500, i915, mediatek, = msm,
nouveau and radeon drivers still do. Do none of them support multi-planar formats ?

I would imagine that some of these do su= pport multi-planar formats, but they don't appear to have them implemen= ted yet (except perhaps as offsets into a single buffer).=C2=A0 I will cert= ainly be looking into this soon, but any changes will come in future patche= s. =C2=A0
=C2=A0
> Signed-off-by: Joe Kniss <djmk@google.com>
> ---
>=C2=A0 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |=C2=A0 5 +- >=C2=A0 drivers/gpu/drm/armada/armada_fb.c=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 |=C2=A0 1 +
>=C2=A0 drivers/gpu/drm/drm_crtc_internal.h=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0|=C2=A0 2 +
>=C2=A0 drivers/gpu/drm/drm_fb_cma_helper.c=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0| 11 ++--
>=C2=A0 drivers/gpu/drm/drm_framebuffer.c=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0| 79 +++++++++++++++++++++++++-
>=C2=A0 drivers/gpu/drm/drm_ioctl.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 1 +
>=C2=A0 drivers/gpu/drm/exynos/exynos_drm_fb.c=C2=A0 =C2=A0 =C2=A0 = |=C2=A0 7 ++-
>=C2=A0 drivers/gpu/drm/gma500/framebuffer.c=C2=A0 =C2=A0 =C2=A0 = =C2=A0 |=C2=A0 2 +
>=C2=A0 drivers/gpu/drm/i915/intel_display.c=C2=A0 =C2=A0 =C2=A0 = =C2=A0 |=C2=A0 1 +
>=C2=A0 drivers/gpu/drm/mediatek/mtk_drm_fb.c=C2=A0 =C2=A0 =C2=A0 = =C2=A0|=C2=A0 1 +
>=C2=A0 drivers/gpu/drm/msm/msm_fb.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 |=C2=A0 5 +-
>=C2=A0 drivers/gpu/drm/nouveau/nouveau_display.c=C2=A0 =C2=A0|=C2= =A0 1 +
>=C2=A0 drivers/gpu/drm/omapdrm/omap_fb.c=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0|=C2=A0 5 +-
>=C2=A0 drivers/gpu/drm/radeon/radeon_display.c=C2=A0 =C2=A0 =C2=A0= |=C2=A0 5 +-
>=C2=A0 drivers/gpu/drm/rockchip/rockchip_drm_fb.c=C2=A0 |=C2=A0 6 = ++-
>=C2=A0 drivers/gpu/drm/tegra/fb.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 9 +++-
>=C2=A0 include/drm/drm_framebuffer.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0|=C2=A0 1 +
>=C2=A0 include/uapi/drm/drm.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 +
>=C2=A0 18 files changed, 127 insertions(+), 17 deletions(-)

[snip]

> diff --git a/drivers/gpu/drm/drm_framebuffer.c
> b/drivers/gpu/drm/drm_framebuffer.c index 28a0108a1ab8..67b3be1be= dbc 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -24,6 +24,7 @@
>=C2=A0 #include <drm/drmP.h>
>=C2=A0 #include <drm/drm_auth.h>
>=C2=A0 #include <drm/drm_framebuffer.h>
> +#include <drm/drm_gem.h>
>
>=C2=A0 #include "drm_crtc_internal.h"

[snip]

> +/**
> + * drm_mode_getfb2 - get FB info
> + * @dev: drm device for the ioctl
> + * @data: data pointer for the ioctl
> + * @file_priv: drm file for the ioctl call
> + *
> + * Lookup the FB given its ID and return info about it.
> + *
> + * Called by the user via ioctl.
> + *
> + * Returns:
> + * Zero on success, negative errno on failure.
> + */
> +int drm_mode_getfb2(struct drm_device *dev,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 void *data, s= truct drm_file *file_priv)
> +{
> +=C2=A0 =C2=A0 =C2=A0struct drm_mode_fb_cmd2 *r =3D data;
> +=C2=A0 =C2=A0 =C2=A0struct drm_framebuffer *fb;
> +=C2=A0 =C2=A0 =C2=A0int ret, i;
> +
> +=C2=A0 =C2=A0 =C2=A0if (!drm_core_check_feature(dev, DRIVER_MODESET))=
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EINVAL;
> +
> +=C2=A0 =C2=A0 =C2=A0fb =3D drm_framebuffer_lookup(dev, r->fb_id);<= br> > +=C2=A0 =C2=A0 =C2=A0if (!fb)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -ENOENT;
> +
> +=C2=A0 =C2=A0 =C2=A0r->height =3D fb->height;
> +=C2=A0 =C2=A0 =C2=A0r->width =3D fb->width;
> +=C2=A0 =C2=A0 =C2=A0r->pixel_format =3D fb->format->format;<= br> > +=C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < 4; ++i) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0r->pitches[i] =3D = fb->pitches[i];
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0r->offsets[i] =3D = fb->offsets[i];
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0r->modifier[i] =3D= fb->modifier;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0r->handles[i] =3D = 0;
> +=C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < fb->format->num_planes= ; ++i) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fb->funcs->= create_handle) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0if (drm_is_current_master(file_priv) ||
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0capable(CAP_SYS_ADMIN) ||
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0drm_is_control_client(file_priv)) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D fb->funcs->create_handle(f= b, i,
> file_priv,
> +
> &r->handles[i]);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (ret)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0} else {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* GET_FB() is an unprivileged ioctl so = we
> must
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * not return a buffer-handle to non-mas= ter
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * processes! For backwards-compatibilit= y
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * reasons, we cannot make GET_FB()
> privileged,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * so just return an invalid handle for<= br> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * non-masters. */

There's no backward compatibility to handle here, just make= it privileged if
it has to be.

Sure thing, sounds good.

<= /div>
=C2=A0
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0r->handles[i] =3D 0;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D 0;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0}
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} else {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0ret =3D -ENODEV;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0break;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +=C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0/* If handle creation failed, delete/dereference = any that were made.
*/
> +=C2=A0 =C2=A0 =C2=A0if (ret) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < = 4; ++i) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0if (r->handles[i])
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0drm_gem_handle_delete(file_priv, r-=
>handles[i]);

My initial reaction to this was to reply that not all drivers use GE= M, but
after some investigation it seems they actually do. If that's really th= e case,
we could get rid of the .create_handle() operation completely, which should=
simplify the implementation of both DRM_IOCTL_MODE_GETFB and
DRM_IOCTL_MODE_GETFB2.

Deleting the handle is the same in all c= ases, but creating the handle isn't consistent across the drivers.=C2= =A0 I didn't see a clean way to simplify this.
=C2=A0
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0r->handles[i] =3D 0;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +=C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0drm_framebuffer_unreference(fb);
> +
> +=C2=A0 =C2=A0 =C2=A0return ret;
> +}

[snip]

> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c
> b/drivers/gpu/drm/omapdrm/omap_fb.c index 29dc677dd4d3..a982c72a7= 73e 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
> @@ -90,12 +90,15 @@ struct omap_framebuffer {
>=C2=A0 };
>
>=C2=A0 static int omap_framebuffer_create_handle(struct drm_frameb= uffer *fb,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int format_p= lane_index,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct drm_file = *file_priv,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int *ha= ndle)
>=C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0struct omap_framebuffer *omap_fb =3D to_omap= _framebuffer(fb);
> +=C2=A0 =C2=A0 =C2=A0if (format_plane_index >=3D 4 || !omap_fb->= planes[format_plane_index])

The first check shouldn't be needed, the core should never call = this operation
with an index >=3D 4.

I'll remove the check then.
=C2=A0
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -ENOENT;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0return drm_gem_handle_create(file_priv,=
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0omap_fb->planes[0].bo, handle);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0omap_fb->planes[format_plane_index].bo, handle);
>=C2=A0 }

[snip]

> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index b2c52843bc70..c81c75335cca 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -814,6 +814,8 @@ extern "C" {
>=C2=A0 #define DRM_IOCTL_MODE_CREATEPROPBLOB=C2=A0 =C2=A0 =C2=A0 =C2=A0= DRM_IOWR(0xBD, struct
> drm_mode_create_blob)
> #define DRM_IOCTL_MODE_DESTROYPROPBLOB=C2=A0 =C2=A0 =C2=A0 =C2=A0= DRM_IOWR(0xBE, struct
> drm_mode_destroy_blob)
>
> +#define DRM_IOCTL_MODE_GETFB2=C2=A0 DRM_IOWR(0xC4, struct drm_mode_fb= _cmd2)
> +

Which tree is this based on ? The last defined ioctl
(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE) is 0xC2 in drm-next and drm-misc-next= .

I just did a quick search for "DRM_= IOWR 0xC*" and picked the first unused one, there was a patch in-fligh= t from last month that used 0xC3 (https://lists.freedesktop.org/archi= ves/amd-gfx/2017-June/010153.html). =C2=A0 Naturally, I'll set this= to whatever is appropriate.
=C2=A0
>=C2=A0 /**
>=C2=A0 =C2=A0* Device specific ioctls should only be in their respectiv= e headers
>=C2=A0 =C2=A0* The device specific ioctl range is from 0x40 to 0x9f.
--
Regards,

Laurent Pinchart


Thanks! =C2=A0
-j


--
<= div class=3D"gmail-m_-3711990965528987190gmail_signature">
=
Dr. Joe Michael Kniss |= =C2=A0Google=C2=A0Chr= omeOS=C2=A0|=C2=A0djmk@google.com=C2=A0=C2= =A0| <= /a>1-801-898-7977=
--94eb2c1ba8cc4527630555b46b08-- --===============1887489858== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============1887489858==--