linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Rob Herring <robh@kernel.org>
Cc: "Heiko Stübner" <heiko@sntech.de>,
	"Neil Armstrong" <narmstrong@baylibre.com>,
	"David Airlie" <airlied@linux.ie>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	"Sandy Huang" <hjc@rock-chips.com>,
	"Benjamin Gaignard" <benjamin.gaignard@linaro.org>,
	linux-amlogic@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	"Yannick Fertre" <yannick.fertre@st.com>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Xinwei Kong" <kong.kongxinwei@hisilicon.com>,
	"Xinliang Liu" <z.liuxinliang@hisilicon.com>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	"Chen-Yu Tsai" <wens@csie.org>,
	"Noralf Trønnes" <noralf@tronnes.org>,
	"James (Qian) Wang" <james.qian.wang@arm.com>,
	"CK Hu" <ck.hu@mediatek.com>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Alexandre Torgue" <alexandre.torgue@st.com>,
	"Chen Feng" <puck.chen@hisilicon.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"open list:MEDIA DRIVERS FOR RENESAS - FCP"
	<linux-renesas-soc@vger.kernel.org>,
	"Maxime Ripard" <mripard@kernel.org>,
	"moderated list:ARM/Mediatek SoC support"
	<linux-mediatek@lists.infradead.org>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>, "Sean Paul" <sean@poorly.run>,
	"moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
	<linux-arm-kernel@lists.infradead.org>,
	"Philippe Cornu" <philippe.cornu@st.com>,
	"Vincent Abriou" <vincent.abriou@st.com>,
	"Kieran Bingham" <kieran.bingham+renesas@ideasonboard.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Rongrong Zou" <zourongrong@gmail.com>,
	"Brian Starkey" <brian.starkey@arm.com>
Subject: Re: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
Date: Wed, 23 Oct 2019 17:27:11 +0300	[thread overview]
Message-ID: <20191023142711.GB1904@pendragon.ideasonboard.com> (raw)
In-Reply-To: <CAL_JsqJk4xeFCHPqpXUSW4XJ=eQ+EYPUpjX_4UL9Pw_OAcqLdA@mail.gmail.com>

Hi Rob,

On Tue, Oct 22, 2019 at 03:02:06PM -0500, Rob Herring wrote:
> On Tue, Oct 22, 2019 at 6:30 AM Laurent Pinchart wrote:
> > On Mon, Oct 21, 2019 at 04:45:48PM -0500, Rob Herring wrote:
> >> Add support in CMA helpers to handle callers specifying
> >> DRM_MODE_DUMB_KERNEL_MAP flag. Existing behavior is maintained with this
> >> change. drm_gem_cma_dumb_create() always creates a kernel mapping as
> >> before. drm_gem_cma_dumb_create_internal() lets the caller set the flags
> >> as desired. Therefore, update all the existing callers of
> >> drm_gem_cma_dumb_create_internal() to also set the
> >> DRM_MODE_DUMB_KERNEL_MAP flag.
> >>
> >> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >> Cc: Maxime Ripard <mripard@kernel.org>
> >> Cc: Sean Paul <sean@poorly.run>
> >> Cc: David Airlie <airlied@linux.ie>
> >> Cc: Daniel Vetter <daniel@ffwll.ch>
> >> Cc: "James (Qian) Wang" <james.qian.wang@arm.com>
> >> Cc: Liviu Dudau <liviu.dudau@arm.com>
> >> Cc: Brian Starkey <brian.starkey@arm.com>
> >> Cc: Neil Armstrong <narmstrong@baylibre.com>
> >> Cc: Kevin Hilman <khilman@baylibre.com>
> >> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> >> Cc: Sandy Huang <hjc@rock-chips.com>
> >> Cc: "Heiko Stübner" <heiko@sntech.de>
> >> Cc: Yannick Fertre <yannick.fertre@st.com>
> >> Cc: Philippe Cornu <philippe.cornu@st.com>
> >> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> >> Cc: Vincent Abriou <vincent.abriou@st.com>
> >> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> >> Cc: Alexandre Torgue <alexandre.torgue@st.com>
> >> Cc: Chen-Yu Tsai <wens@csie.org>
> >> Cc: linux-amlogic@lists.infradead.org
> >> Cc: linux-arm-kernel@lists.infradead.org
> >> Cc: linux-renesas-soc@vger.kernel.org
> >> Cc: linux-rockchip@lists.infradead.org
> >> Cc: linux-stm32@st-md-mailman.stormreply.com
> >> Signed-off-by: Rob Herring <robh@kernel.org>
> >> ---
> >>  .../gpu/drm/arm/display/komeda/komeda_kms.c   |  1 +
> >>  drivers/gpu/drm/arm/malidp_drv.c              |  1 +
> >>  drivers/gpu/drm/drm_gem_cma_helper.c          | 48 +++++++++++--------
> >>  drivers/gpu/drm/meson/meson_drv.c             |  1 +
> >>  drivers/gpu/drm/rcar-du/rcar_du_kms.c         |  1 +
> >>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  1 +
> >>  drivers/gpu/drm/stm/drv.c                     |  1 +
> >>  drivers/gpu/drm/sun4i/sun4i_drv.c             |  1 +
> >>  8 files changed, 36 insertions(+), 19 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> >> index d49772de93e0..7cf0dc4cbfc1 100644
> >> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> >> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> >> @@ -31,6 +31,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file,
> >>       u32 pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> >>
> >>       args->pitch = ALIGN(pitch, mdev->chip.bus_width);
> >> +     args->flags = DRM_MODE_DUMB_KERNEL_MAP;
> >>
> >>       return drm_gem_cma_dumb_create_internal(file, dev, args);
> >>  }
> >> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> >> index 8a76315aaa0f..aeb1a779ecc1 100644
> >> --- a/drivers/gpu/drm/arm/malidp_drv.c
> >> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> >> @@ -465,6 +465,7 @@ static int malidp_dumb_create(struct drm_file *file_priv,
> >>       u8 alignment = malidp_hw_get_pitch_align(malidp->dev, 1);
> >>
> >>       args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), alignment);
> >> +     args->flags = DRM_MODE_DUMB_KERNEL_MAP;
> >>
> >>       return drm_gem_cma_dumb_create_internal(file_priv, drm, args);
> >>  }
> >> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
> >> index 4cebfe01e6ea..f91e9e8adeaf 100644
> >> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> >> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> >> @@ -78,21 +78,8 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)
> >>       return ERR_PTR(ret);
> >>  }
> >>
> >> -/**
> >> - * drm_gem_cma_create - allocate an object with the given size
> >> - * @drm: DRM device
> >> - * @size: size of the object to allocate
> >> - *
> >> - * This function creates a CMA GEM object and allocates a contiguous chunk of
> >> - * memory as backing store. The backing memory has the writecombine attribute
> >> - * set.
> >> - *
> >> - * Returns:
> >> - * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative
> >> - * error code on failure.
> >> - */
> >> -struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
> >> -                                           size_t size)
> >> +static struct drm_gem_cma_object *
> >> +drm_gem_cma_create_flags(struct drm_device *drm, size_t size, u32 flags)
> >>  {
> >>       struct drm_gem_cma_object *cma_obj;
> >>       int ret;
> >> @@ -103,6 +90,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
> >>       if (IS_ERR(cma_obj))
> >>               return cma_obj;
> >>
> >> +     if (!(flags & DRM_MODE_DUMB_KERNEL_MAP))
> >> +             cma_obj->dma_attrs |= DMA_ATTR_NO_KERNEL_MAPPING;
> >> +
> >>       cma_obj->vaddr = dma_alloc_attrs(drm->dev, size, &cma_obj->paddr,
> >>                                        GFP_KERNEL | __GFP_NOWARN,
> >>                                        cma_obj->dma_attrs);
> >> @@ -119,6 +109,25 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
> >>       drm_gem_object_put_unlocked(&cma_obj->base);
> >>       return ERR_PTR(ret);
> >>  }
> >> +
> >> +/**
> >> + * drm_gem_cma_create - allocate an object with the given size
> >> + * @drm: DRM device
> >> + * @size: size of the object to allocate
> >> + *
> >> + * This function creates a CMA GEM object and allocates a contiguous chunk of
> >> + * memory as backing store. The backing memory has the writecombine attribute
> >> + * set.
> >> + *
> >
> > Shouldn't you mention here that the function always creates a kernel
> > mapping, and that callers that don't need the mapping should use
> > drm_gem_cma_dumb_create_internal() instead ?
> 
> Are you confusing drm_gem_cma_create with drm_gem_cma_dumb_create?
> drm_gem_cma_dumb_create() uses defaults and
> drm_gem_cma_dumb_create_internal() allows the caller to tweak
> parameters. Nothing new there other than an additional param to tweak.
> 
> > drm_gem_cma_dumb_create_internal() operates at a different level though,
> > and drm_gem_cma_create() is only exported for a single driver. There's
> > no equivalent to drm_gem_cma_create() that can skip the kernel mapping.
> 
> Because we don't yet need one. drm_gem_cma_create_flags() can be made
> public when we do. I could do that now I guess and make
> drm_gem_cma_create an inline wrapper.

I don't mind not having drm_gem_cma_create_flags() made public (but you
can do so already if you prefer) if there's no user. My point is that we
now have a mechanism to skip creation of kernel mappings, and that
drm_gem_cma_create() will always result in the creation of a kernel
mapping. I thought it was worth mentioning it, but if you think that's
not needed, feel free to ignore the comment.

-- 
Regards,

Laurent Pinchart

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

      reply	other threads:[~2019-10-23 14:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191021214550.1461-1-robh@kernel.org>
2019-10-21 21:45 ` [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag Rob Herring
2019-10-22  6:13   ` james qian wang (Arm Technology China)
2019-10-22  7:50   ` Neil Armstrong
2019-10-22 11:30   ` Laurent Pinchart
2019-10-22 11:40     ` Geert Uytterhoeven
2019-10-22 19:52       ` Rob Herring
2019-10-22 20:02     ` Rob Herring
2019-10-23 14:27       ` Laurent Pinchart [this message]

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=20191023142711.GB1904@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=alexandre.torgue@st.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=brian.starkey@arm.com \
    --cc=ck.hu@mediatek.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=james.qian.wang@arm.com \
    --cc=khilman@baylibre.com \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mripard@kernel.org \
    --cc=narmstrong@baylibre.com \
    --cc=noralf@tronnes.org \
    --cc=p.zabel@pengutronix.de \
    --cc=philippe.cornu@st.com \
    --cc=puck.chen@hisilicon.com \
    --cc=robh@kernel.org \
    --cc=sean@poorly.run \
    --cc=vincent.abriou@st.com \
    --cc=wens@csie.org \
    --cc=yannick.fertre@st.com \
    --cc=z.liuxinliang@hisilicon.com \
    --cc=zourongrong@gmail.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).