From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>,
Seung-Woo Kim <sw0312.kim@samsung.com>,
Liviu Dudau <liviu.dudau@arm.com>,
ML dri-devel <dri-devel@lists.freedesktop.org>,
Thierry Reding <thierry.reding@gmail.com>,
Gerd Hoffmann <kraxel@redhat.com>,
"Vetter, Daniel" <daniel.vetter@intel.com>,
marex@denx.de,
Boris BREZILLON <boris.brezillon@free-electrons.com>,
Alexey Brodkin <abrodkin@synopsys.com>,
Russell King - ARM Linux <linux@armlinux.org.uk>,
Xinliang Liu <z.liuxinliang@hisilicon.com>,
Xinwei Kong <kong.kongxinwei@hisilicon.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
Ben Skeggs <bskeggs@redhat.com>, Dave Airlie <airlied@redhat.com>,
Chen Feng <puck.chen@hisilicon.com>, Jyri Sarha <jsarha@ti.com>,
Alex Deucher <alexander.deucher@amd.com>,
Vincent Abriou <vincent.abriou@st.com>,
Huan Wang <alison.wang@freescale.com>,
Emil Velikov <emil.l.velikov@gmail.com>,
Philippe
Subject: Re: [PATCH 01/41] drm/gem: Add drm_gem_dumb_map_offset()
Date: Thu, 27 Jul 2017 13:01:09 +0300 [thread overview]
Message-ID: <2667744.Zmh4XzqVxs@avalon> (raw)
In-Reply-To: <9230d751-ea2a-b946-459e-24b27e9f5b2a@tronnes.org>
Hi Noralf,
On Wednesday 26 Jul 2017 20:41:53 Noralf Trønnes wrote:
> Den 26.07.2017 14.05, skrev Emil Velikov:
> > On 23 July 2017 at 20:16, Noralf Trønnes <noralf@tronnes.org> wrote:
> >> Add a common drm_driver.dumb_map_offset function for GEM backed drivers.
> >>
> >> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> >> ---
> >>
> >> drivers/gpu/drm/drm_gem.c | 35 +++++++++++++++++++++++++++++++++++
> >> include/drm/drm_gem.h | 2 ++
> >> 2 files changed, 37 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> >> index 5df028a..a8d396b 100644
> >> --- a/drivers/gpu/drm/drm_gem.c
> >> +++ b/drivers/gpu/drm/drm_gem.c
> >> @@ -311,6 +311,41 @@ drm_gem_handle_delete(struct drm_file *filp, u32
> >> handle)>>
> >> EXPORT_SYMBOL(drm_gem_handle_delete);
> >>
> >> /**
> >> + * drm_gem_dumb_map_offset - return the fake mmap offset for a gem
> >> object
> >> + * @file: drm file-private structure containing the gem object
> >> + * @dev: corresponding drm_device
> >> + * @handle: gem object handle
> >> + * @offset: return location for the fake mmap offset
> >> + *
> >> + * This implements the &drm_driver.dumb_map_offset kms driver callback
> >> for
> >> + * drivers which use gem to manage their backing storage.
> >> + *
> >> + * Returns:
> >> + * 0 on success or a negative error code on failure.
> >> + */
> >> +int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device
> >> *dev,
> >> + u32 handle, u64 *offset)
> >> +{
> >> + struct drm_gem_object *obj;
> >> + int ret;
> >> +
> >> + obj = drm_gem_object_lookup(file, handle);
> >> + if (!obj)
> >> + return -ENOENT;
> >> +
> >> + ret = drm_gem_create_mmap_offset(obj);
> >
> > With later patches one goes to reuse this helper instead of
> > drm_gem_cma_dumb_map_offset().
> > At the same time, the latter does not have the
> > drm_gem_create_mmap_offset() call we see here.
>
> You're rigth, the cma library and a couple of other drivers if I recall
> correctly, call drm_gem_create_mmap_offset() during object creation.
> Daniel was of the opinion that this should happen when mmap is called.
> drm_gem_create_mmap_offset() is idempotent as the docs call it. Calling
> it a second time is ok, since it does nothing (needs to take a lock
> though).
I came to the exact same conclusion. It might be a slightly more efficient if
we coudl call drm_gem_create_mmap_offset() at the GEM object creation time,
but as that's not possible for all drivers, and as the .dumb_map_offset()
operation is not in any hot path anyway, I stopped investigating how we could
optimize the implementation.
> I haven't removed drm_gem_create_mmap_offset() from the drivers that do
> it during object creation, trying to keep this from doing to much.
> The cma library will be changed though when I add the generic fb/gem
> helper.
>
> > Meanwhile some drivers have their own offset function which is
> > virtually identical to the original drm_gem_cma_dumb_map_offset.
> > Yet those are left unchanged.
> >
> > For example in cirrus [1]:
> > There the only code difference seems to be an "upcast" followed
> > immediately by a "downcast". Which should effectively be a noop.
>
> The main reason for that is to try and keep this simple so I'm able to
> add my shmem/gem library in reasonable time :-) I didn't want to do
> changes that wasn't straight forward. But yes, the cirrus drivers looks
> quite straight forward and the functions isn't used by other parts of
> the driver. I looked at a driver (omap?) that had similar functions,
> and those where called from other parts of the driver, so I expected
> the same here I guess.
For omapdrm I believe we could drop the custom .dumb_map_offset() operation,
as the only use for customs offsets in the driver is for tiled buffers, which
are created by an omapdrm-specific IOCTL. However, I can't tell at the moment
whether userspace code that create tiled buffers with the OMAP_GEM_NEW ioctl
get the mmap offset with OMAP_GEM_INFO as they should, or if
DRM_IOCTL_MODE_MAP_DUMB gets sometimes abused for non-dumb buffers.
> You say "some drivers", can you name them?
> Some drivers takes locks or do other stuff that made me skip them.
>
> Noralf.
>
> > That said, I could be loosing my marbles.
> >
> > HTH
> > Emil
> >
> > [1]
> > https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/cirrus/cir
> > rus_main.c#n292
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-07-27 10:01 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-23 19:16 [PATCH 00/41] drm/dumb-buffers: Add defaults for .dumb_map_offset and .dumb_destroy Noralf Trønnes
2017-07-23 19:16 ` [PATCH 01/41] drm/gem: Add drm_gem_dumb_map_offset() Noralf Trønnes
2017-07-24 7:46 ` Philipp Zabel
2017-07-24 22:50 ` Laurent Pinchart
2017-07-26 12:05 ` Emil Velikov
2017-07-26 18:41 ` Noralf Trønnes
2017-07-27 0:13 ` Emil Velikov
2017-07-27 15:57 ` Noralf Trønnes
2017-07-27 10:01 ` Laurent Pinchart [this message]
2017-07-26 14:19 ` Sean Paul
2017-07-23 19:16 ` [PATCH 02/41] drm/dumb-buffers: Add defaults for .dumb_map_offset and .dumb_destroy Noralf Trønnes
2017-07-24 16:33 ` Eric Anholt
2017-07-26 14:24 ` Sean Paul
2017-07-23 19:16 ` [PATCH 03/41] drm/arc: Use .dumb_map_offset and .dumb_destroy defaults Noralf Trønnes
2017-07-24 6:51 ` Alexey Brodkin
2017-07-23 19:16 ` [PATCH 04/41] drm/arm: hdlcd: " Noralf Trønnes
2017-07-24 12:10 ` Brian Starkey
2017-07-23 19:16 ` [PATCH 05/41] drm/arm: mali-dp: " Noralf Trønnes
2017-07-24 12:11 ` Brian Starkey
2017-07-23 19:16 ` [PATCH 06/41] drm/atmel-hlcdc: " Noralf Trønnes
2017-07-27 19:21 ` Boris Brezillon
2017-07-23 19:16 ` [PATCH 07/41] drm/fsl-dcu: " Noralf Trønnes
2017-07-29 17:24 ` Stefan Agner
2017-08-04 13:15 ` Noralf Trønnes
2017-07-23 19:16 ` [PATCH 08/41] drm/kirin: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 09/41] drm/imx: " Noralf Trønnes
2017-07-24 7:46 ` Philipp Zabel
2017-07-24 19:37 ` Noralf Trønnes
2017-07-23 19:16 ` [PATCH 10/41] drm/meson: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 11/41] drm/mxsfb: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 12/41] drm/pl111: " Noralf Trønnes
2017-07-24 16:34 ` Eric Anholt
2017-07-23 19:16 ` [PATCH 13/41] drm/rcar-du: " Noralf Trønnes
2017-07-24 22:51 ` Laurent Pinchart
2017-07-23 19:16 ` [PATCH 14/41] drm/shmobile: " Noralf Trønnes
2017-07-24 22:51 ` Laurent Pinchart
2017-07-23 19:16 ` [PATCH 15/41] drm/sti: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 16/41] drm/stm: " Noralf Trønnes
2017-07-25 8:43 ` Philippe CORNU
2017-07-23 19:16 ` [PATCH 17/41] drm/sun4i: " Noralf Trønnes
2017-07-27 6:34 ` Maxime Ripard
2017-07-23 19:16 ` [PATCH 18/41] drm/tilcdc: " Noralf Trønnes
2017-07-27 12:18 ` Jyri Sarha
2017-07-23 19:16 ` [PATCH 19/41] drm/vc4: " Noralf Trønnes
2017-07-24 16:33 ` Eric Anholt
2017-07-23 19:16 ` [PATCH 20/41] drm/zte: " Noralf Trønnes
2017-07-25 14:15 ` Shawn Guo
2017-07-23 19:16 ` [PATCH 21/41] drm/tinydrm: " Noralf Trønnes
2017-07-26 14:25 ` Sean Paul
2017-07-23 19:16 ` [PATCH 22/41] drm/mediatek: " Noralf Trønnes
2017-07-24 7:38 ` Philipp Zabel
2017-07-23 19:16 ` [PATCH 23/41] drm/gma500: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 24/41] drm/rockchip: " Noralf Trønnes
2017-07-26 14:19 ` Sean Paul
2017-07-23 19:16 ` [PATCH 25/41] drm/tegra: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 26/41] drm/cirrus: Use the drm_driver.dumb_destroy default Noralf Trønnes
2017-07-23 19:16 ` [PATCH 27/41] drm/udl: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 28/41] drm/qxl: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 29/41] drm/amdgpu: " Noralf Trønnes
2017-07-24 15:18 ` Deucher, Alexander
2017-07-23 19:16 ` [PATCH 30/41] drm/omapdrm: " Noralf Trønnes
2017-07-24 22:51 ` Laurent Pinchart
2017-07-23 19:16 ` [PATCH 31/41] drm/ast: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 32/41] drm/nouveau: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 33/41] drm/i915: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 34/41] drm/msm: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 35/41] drm/exynos: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 36/41] drm/hisilicon: hibmc: " Noralf Trønnes
2017-07-26 14:25 ` Sean Paul
2017-07-23 19:16 ` [PATCH 37/41] drm/mgag200: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 38/41] drm/radeon: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 39/41] drm/bochs: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 40/41] drm/armada: " Noralf Trønnes
2017-07-23 19:16 ` [PATCH 41/41] drm/virtio: " Noralf Trønnes
2017-07-24 19:39 ` [PATCH 00/41] drm/dumb-buffers: Add defaults for .dumb_map_offset and .dumb_destroy Noralf Trønnes
2017-07-25 6:57 ` Daniel Vetter
2017-07-25 8:44 ` Philippe CORNU
2017-07-29 12:09 ` Noralf Trønnes
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=2667744.Zmh4XzqVxs@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=abrodkin@synopsys.com \
--cc=airlied@redhat.com \
--cc=alexander.deucher@amd.com \
--cc=alison.wang@freescale.com \
--cc=boris.brezillon@free-electrons.com \
--cc=bskeggs@redhat.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=jsarha@ti.com \
--cc=kong.kongxinwei@hisilicon.com \
--cc=kraxel@redhat.com \
--cc=linux@armlinux.org.uk \
--cc=liviu.dudau@arm.com \
--cc=marex@denx.de \
--cc=narmstrong@baylibre.com \
--cc=noralf@tronnes.org \
--cc=puck.chen@hisilicon.com \
--cc=sw0312.kim@samsung.com \
--cc=thierry.reding@gmail.com \
--cc=tomi.valkeinen@ti.com \
--cc=vincent.abriou@st.com \
--cc=z.liuxinliang@hisilicon.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