All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-11-28 15:25 Emil Velikov
  2015-11-30  7:46   ` Daniel Vetter
  2015-12-01 10:18   ` Xinliang Liu
  0 siblings, 2 replies; 19+ messages in thread
From: Emil Velikov @ 2015-11-28 15:25 UTC (permalink / raw)
  To: Xinliang Liu
  Cc: linux-doc, Catalin Marinas, Will Deacon, linuxarm, ML dri-devel,
	xuwei5, Benjamin Gaignard, zourongrong, xuyiping, corbet, w.f,
	lijianhua, devicetree, bintian.wang, puck.chen, LAKML,
	andy.green, liguozhu, haojian.zhuang

Hi Xinliang,

On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> Add DRM master driver for hi6220 SoC which used in HiKey board.
> Add dumb buffer feature.
> Add prime dmabuf feature.
>
> Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> Signed-off-by: Andy Green <andy.green@linaro.org>
Your s-o-b should be the bottom of the list. There was a presentation
(ages ago) from Greg KH, who nicely described the order as a "chain of
command" or "guilt path". Looks like the rest of the series could use
this tweak.

> ---
>  drivers/gpu/drm/Kconfig                  |   2 +
>  drivers/gpu/drm/Makefile                 |   1 +
>  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
>  drivers/gpu/drm/hisilicon/Makefile       |   3 +
>  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
>  5 files changed, 229 insertions(+)
>  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
>  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
>  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 8773fad..038aae8 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
>  source "drivers/gpu/drm/imx/Kconfig"
>
>  source "drivers/gpu/drm/vc4/Kconfig"
> +
> +source "drivers/gpu/drm/hisilicon/Kconfig"
I could swear that we can a patch that sorts these alphabetically,
although it doesn't seem to have made it upstream yet :-(

> --- /dev/null
> +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c

> +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
> +{
The use of .load (and .unload?) callbacks is not recommended. Take a
look at Laurent Pinchart's patch [1] about the whys and hows on the
topic

> +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
> +                                            struct drm_gem_object *obj,
> +                                            int flags)
> +{
> +       /* we want to be able to write in mmapped buffer */
> +       flags |= O_RDWR;
Erm... something feels fishy here. Out of the existing 15 drivers
setting up the prime callbacks only one (sti) does a similar thing. So
either everyone else is missing something obvious or hisilicon and sti
can rework their inner working to remove this (dare I say it) hack.

> +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> +                                   struct drm_device *dev,
> +                                   struct drm_mode_create_dumb *args)
> +{
> +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> +
> +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> +       args->pitch = roundup(min_pitch, 8);
> +
I'm not sure you want this kind of dependency of an out of tree driver
upstream. If this is some limitation on the display engine so be it,
but tailoring things for an external module seems like a very bad
idea.

> +       return drm_gem_cma_dumb_create_internal(file, dev, args);
> +}

> +static int hisi_drm_bind(struct device *dev)
> +{
> +       dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
> +       return drm_platform_init(&hisi_drm_driver, to_platform_device(dev));
As pointed out by the the kernel doc - drm_platform_init is deprecated.


Regards,
Emil

[1] http://lists.freedesktop.org/archives/dri-devel/2015-November/095466.html
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-11-28 15:25 [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver Emil Velikov
@ 2015-11-30  7:46   ` Daniel Vetter
  2015-12-01 10:18   ` Xinliang Liu
  1 sibling, 0 replies; 19+ messages in thread
From: Daniel Vetter @ 2015-11-30  7:46 UTC (permalink / raw)
  To: Emil Velikov
  Cc: linux-doc, Catalin Marinas, Will Deacon, linuxarm, ML dri-devel,
	xuwei5, Benjamin Gaignard, zourongrong, xuyiping, corbet, w.f,
	lijianhua, devicetree, bintian.wang, puck.chen, LAKML,
	andy.green, liguozhu, haojian.zhuang

On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
> Hi Xinliang,
> 
> On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> > Add DRM master driver for hi6220 SoC which used in HiKey board.
> > Add dumb buffer feature.
> > Add prime dmabuf feature.
> >
> > Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> > Signed-off-by: Andy Green <andy.green@linaro.org>
> Your s-o-b should be the bottom of the list. There was a presentation
> (ages ago) from Greg KH, who nicely described the order as a "chain of
> command" or "guilt path". Looks like the rest of the series could use
> this tweak.
> 
> > ---
> >  drivers/gpu/drm/Kconfig                  |   2 +
> >  drivers/gpu/drm/Makefile                 |   1 +
> >  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
> >  drivers/gpu/drm/hisilicon/Makefile       |   3 +
> >  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
> >  5 files changed, 229 insertions(+)
> >  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
> >  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
> >  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
> >
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index 8773fad..038aae8 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
> >  source "drivers/gpu/drm/imx/Kconfig"
> >
> >  source "drivers/gpu/drm/vc4/Kconfig"
> > +
> > +source "drivers/gpu/drm/hisilicon/Kconfig"
> I could swear that we can a patch that sorts these alphabetically,
> although it doesn't seem to have made it upstream yet :-(
> 
> > --- /dev/null
> > +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
> 
> > +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
> > +{
> The use of .load (and .unload?) callbacks is not recommended. Take a
> look at Laurent Pinchart's patch [1] about the whys and hows on the
> topic
> 
> > +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
> > +                                            struct drm_gem_object *obj,
> > +                                            int flags)
> > +{
> > +       /* we want to be able to write in mmapped buffer */
> > +       flags |= O_RDWR;
> Erm... something feels fishy here. Out of the existing 15 drivers
> setting up the prime callbacks only one (sti) does a similar thing. So
> either everyone else is missing something obvious or hisilicon and sti
> can rework their inner working to remove this (dare I say it) hack.

Mmap on drm dma-bufs doesn't work, and fairly intentionally. There's been
some rfc patch series to address this:

http://lists.freedesktop.org/archives/dri-devel/2015-August/089263.html

Unfortunately it seems stuck with getting the userspace piece in shape.
Might be best to ping Tiago for an update.

Meanwhile please don't do this in drivers ;-)

> > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> > +                                   struct drm_device *dev,
> > +                                   struct drm_mode_create_dumb *args)
> > +{
> > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> > +
> > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> > +       args->pitch = roundup(min_pitch, 8);
> > +
> I'm not sure you want this kind of dependency of an out of tree driver
> upstream. If this is some limitation on the display engine so be it,
> but tailoring things for an external module seems like a very bad
> idea.

Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
go upstream to fix this ...
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-11-30  7:46   ` Daniel Vetter
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Vetter @ 2015-11-30  7:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
> Hi Xinliang,
> 
> On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> > Add DRM master driver for hi6220 SoC which used in HiKey board.
> > Add dumb buffer feature.
> > Add prime dmabuf feature.
> >
> > Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> > Signed-off-by: Andy Green <andy.green@linaro.org>
> Your s-o-b should be the bottom of the list. There was a presentation
> (ages ago) from Greg KH, who nicely described the order as a "chain of
> command" or "guilt path". Looks like the rest of the series could use
> this tweak.
> 
> > ---
> >  drivers/gpu/drm/Kconfig                  |   2 +
> >  drivers/gpu/drm/Makefile                 |   1 +
> >  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
> >  drivers/gpu/drm/hisilicon/Makefile       |   3 +
> >  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
> >  5 files changed, 229 insertions(+)
> >  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
> >  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
> >  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
> >
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index 8773fad..038aae8 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
> >  source "drivers/gpu/drm/imx/Kconfig"
> >
> >  source "drivers/gpu/drm/vc4/Kconfig"
> > +
> > +source "drivers/gpu/drm/hisilicon/Kconfig"
> I could swear that we can a patch that sorts these alphabetically,
> although it doesn't seem to have made it upstream yet :-(
> 
> > --- /dev/null
> > +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
> 
> > +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
> > +{
> The use of .load (and .unload?) callbacks is not recommended. Take a
> look at Laurent Pinchart's patch [1] about the whys and hows on the
> topic
> 
> > +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
> > +                                            struct drm_gem_object *obj,
> > +                                            int flags)
> > +{
> > +       /* we want to be able to write in mmapped buffer */
> > +       flags |= O_RDWR;
> Erm... something feels fishy here. Out of the existing 15 drivers
> setting up the prime callbacks only one (sti) does a similar thing. So
> either everyone else is missing something obvious or hisilicon and sti
> can rework their inner working to remove this (dare I say it) hack.

Mmap on drm dma-bufs doesn't work, and fairly intentionally. There's been
some rfc patch series to address this:

http://lists.freedesktop.org/archives/dri-devel/2015-August/089263.html

Unfortunately it seems stuck with getting the userspace piece in shape.
Might be best to ping Tiago for an update.

Meanwhile please don't do this in drivers ;-)

> > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> > +                                   struct drm_device *dev,
> > +                                   struct drm_mode_create_dumb *args)
> > +{
> > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> > +
> > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> > +       args->pitch = roundup(min_pitch, 8);
> > +
> I'm not sure you want this kind of dependency of an out of tree driver
> upstream. If this is some limitation on the display engine so be it,
> but tailoring things for an external module seems like a very bad
> idea.

Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
go upstream to fix this ...
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-11-30  7:46   ` Daniel Vetter
@ 2015-11-30 17:25     ` Rob Herring
  -1 siblings, 0 replies; 19+ messages in thread
From: Rob Herring @ 2015-11-30 17:25 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-doc, Catalin Marinas, Will Deacon, linuxarm, ML dri-devel,
	xuwei5, Benjamin Gaignard, zourongrong, xuyiping, corbet, w.f,
	lijianhua, devicetree, bintian.wang, puck.chen, LAKML,
	andy.green, Emil Velikov, liguozhu, haojian.zhuang

On Mon, Nov 30, 2015 at 08:46:03AM +0100, Daniel Vetter wrote:
> On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
> > Hi Xinliang,
> > 
> > On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> > > Add DRM master driver for hi6220 SoC which used in HiKey board.
> > > Add dumb buffer feature.
> > > Add prime dmabuf feature.
> > >

> > > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> > > +                                   struct drm_device *dev,
> > > +                                   struct drm_mode_create_dumb *args)
> > > +{
> > > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> > > +
> > > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> > > +       args->pitch = roundup(min_pitch, 8);
> > > +
> > I'm not sure you want this kind of dependency of an out of tree driver
> > upstream. If this is some limitation on the display engine so be it,
> > but tailoring things for an external module seems like a very bad
> > idea.
> 
> Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
> go upstream to fix this ...

I believe this is copy-n-paste from Rockchip driver.

I'm curious why there is not a common interface for rendering buffers at 
least for systems without graphics memory like most ARM systems. Are the 
requirements of GPU so diverse that things like pitch alignment can't be 
parameterized?

Rob
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-11-30 17:25     ` Rob Herring
  0 siblings, 0 replies; 19+ messages in thread
From: Rob Herring @ 2015-11-30 17:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 30, 2015 at 08:46:03AM +0100, Daniel Vetter wrote:
> On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
> > Hi Xinliang,
> > 
> > On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> > > Add DRM master driver for hi6220 SoC which used in HiKey board.
> > > Add dumb buffer feature.
> > > Add prime dmabuf feature.
> > >

> > > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> > > +                                   struct drm_device *dev,
> > > +                                   struct drm_mode_create_dumb *args)
> > > +{
> > > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> > > +
> > > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> > > +       args->pitch = roundup(min_pitch, 8);
> > > +
> > I'm not sure you want this kind of dependency of an out of tree driver
> > upstream. If this is some limitation on the display engine so be it,
> > but tailoring things for an external module seems like a very bad
> > idea.
> 
> Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
> go upstream to fix this ...

I believe this is copy-n-paste from Rockchip driver.

I'm curious why there is not a common interface for rendering buffers at 
least for systems without graphics memory like most ARM systems. Are the 
requirements of GPU so diverse that things like pitch alignment can't be 
parameterized?

Rob

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-11-30 17:25     ` Rob Herring
@ 2015-12-01  7:12       ` Daniel Vetter
  -1 siblings, 0 replies; 19+ messages in thread
From: Daniel Vetter @ 2015-12-01  7:12 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-doc, Catalin Marinas, Will Deacon, linuxarm, ML dri-devel,
	xuwei5, Benjamin Gaignard, zourongrong, xuyiping, corbet, w.f,
	lijianhua, devicetree, bintian.wang, puck.chen, LAKML,
	andy.green, Emil Velikov, liguozhu, haojian.zhuang

On Mon, Nov 30, 2015 at 11:25:28AM -0600, Rob Herring wrote:
> On Mon, Nov 30, 2015 at 08:46:03AM +0100, Daniel Vetter wrote:
> > On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
> > > Hi Xinliang,
> > > 
> > > On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> > > > Add DRM master driver for hi6220 SoC which used in HiKey board.
> > > > Add dumb buffer feature.
> > > > Add prime dmabuf feature.
> > > >
> 
> > > > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> > > > +                                   struct drm_device *dev,
> > > > +                                   struct drm_mode_create_dumb *args)
> > > > +{
> > > > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> > > > +
> > > > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> > > > +       args->pitch = roundup(min_pitch, 8);
> > > > +
> > > I'm not sure you want this kind of dependency of an out of tree driver
> > > upstream. If this is some limitation on the display engine so be it,
> > > but tailoring things for an external module seems like a very bad
> > > idea.
> > 
> > Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
> > go upstream to fix this ...
> 
> I believe this is copy-n-paste from Rockchip driver.
> 
> I'm curious why there is not a common interface for rendering buffers at 
> least for systems without graphics memory like most ARM systems. Are the 
> requirements of GPU so diverse that things like pitch alignment can't be 
> parameterized?

pitch requirements is generally the least worry. The real fun starts with
tiling modes and how all that stuff interacts. Atm the only solution we
have is "userspace needs to know" in form of either gralloc (android) or
gbm (cros, desktop linux). There have been ideas to for describing buffer
limits, but nothing concrete yet.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-12-01  7:12       ` Daniel Vetter
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Vetter @ 2015-12-01  7:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 30, 2015 at 11:25:28AM -0600, Rob Herring wrote:
> On Mon, Nov 30, 2015 at 08:46:03AM +0100, Daniel Vetter wrote:
> > On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
> > > Hi Xinliang,
> > > 
> > > On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> > > > Add DRM master driver for hi6220 SoC which used in HiKey board.
> > > > Add dumb buffer feature.
> > > > Add prime dmabuf feature.
> > > >
> 
> > > > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> > > > +                                   struct drm_device *dev,
> > > > +                                   struct drm_mode_create_dumb *args)
> > > > +{
> > > > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> > > > +
> > > > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> > > > +       args->pitch = roundup(min_pitch, 8);
> > > > +
> > > I'm not sure you want this kind of dependency of an out of tree driver
> > > upstream. If this is some limitation on the display engine so be it,
> > > but tailoring things for an external module seems like a very bad
> > > idea.
> > 
> > Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
> > go upstream to fix this ...
> 
> I believe this is copy-n-paste from Rockchip driver.
> 
> I'm curious why there is not a common interface for rendering buffers at 
> least for systems without graphics memory like most ARM systems. Are the 
> requirements of GPU so diverse that things like pitch alignment can't be 
> parameterized?

pitch requirements is generally the least worry. The real fun starts with
tiling modes and how all that stuff interacts. Atm the only solution we
have is "userspace needs to know" in form of either gralloc (android) or
gbm (cros, desktop linux). There have been ideas to for describing buffer
limits, but nothing concrete yet.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-11-28 15:25 [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver Emil Velikov
@ 2015-12-01 10:18   ` Xinliang Liu
  2015-12-01 10:18   ` Xinliang Liu
  1 sibling, 0 replies; 19+ messages in thread
From: Xinliang Liu @ 2015-12-01 10:18 UTC (permalink / raw)
  To: Emil Velikov
  Cc: ML dri-devel, devicetree, Daniel Vetter, Rob Herring,
	Daniel Stone, architt, David Airlie, Jon Corbet, Catalin Marinas,
	Will Deacon, Andy Green, Yiping Xu, linux-doc, Wang Fei,
	zourongrong, linuxarm, Xu Wei, Bintian Wang, Haojian Zhuang,
	Benjamin Gaignard, Feng Chen, lijianhua, Liguozhu (Kenneth),
	LAKML

On 28 November 2015 at 23:25, Emil Velikov <emil.l.velikov@gmail.com> wrote:

Hi Emil, thanks again for review.

> Hi Xinliang,
>
> On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
>> Add DRM master driver for hi6220 SoC which used in HiKey board.
>> Add dumb buffer feature.
>> Add prime dmabuf feature.
>>
>> Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
>> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
>> Signed-off-by: Andy Green <andy.green@linaro.org>
> Your s-o-b should be the bottom of the list. There was a presentation
> (ages ago) from Greg KH, who nicely described the order as a "chain of
> command" or "guilt path". Looks like the rest of the series could use
> this tweak.

will fixed in v3.

>
>> ---
>>  drivers/gpu/drm/Kconfig                  |   2 +
>>  drivers/gpu/drm/Makefile                 |   1 +
>>  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
>>  drivers/gpu/drm/hisilicon/Makefile       |   3 +
>>  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
>>  5 files changed, 229 insertions(+)
>>  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
>>  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
>>  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>>
>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> index 8773fad..038aae8 100644
>> --- a/drivers/gpu/drm/Kconfig
>> +++ b/drivers/gpu/drm/Kconfig
>> @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
>>  source "drivers/gpu/drm/imx/Kconfig"
>>
>>  source "drivers/gpu/drm/vc4/Kconfig"
>> +
>> +source "drivers/gpu/drm/hisilicon/Kconfig"
> I could swear that we can a patch that sorts these alphabetically,
> although it doesn't seem to have made it upstream yet :-(

Yes, as there are so many drm drivers now, it's time to do this work I think.
I'll try to send a separate patch for this soon.

>
>> --- /dev/null
>> +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>
>> +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
>> +{
> The use of .load (and .unload?) callbacks is not recommended. Take a
> look at Laurent Pinchart's patch [1] about the whys and hows on the
> topic

will removed .load/unload in v3.

>
>> +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
>> +                                            struct drm_gem_object *obj,
>> +                                            int flags)
>> +{
>> +       /* we want to be able to write in mmapped buffer */
>> +       flags |= O_RDWR;
> Erm... something feels fishy here. Out of the existing 15 drivers
> setting up the prime callbacks only one (sti) does a similar thing. So
> either everyone else is missing something obvious or hisilicon and sti
> can rework their inner working to remove this (dare I say it) hack.

I would talk to sti guys about this. Not sure how to handle this now.

>
>> +static int hisi_gem_cma_dumb_create(struct drm_file *file,
>> +                                   struct drm_device *dev,
>> +                                   struct drm_mode_create_dumb *args)
>> +{
>> +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
>> +
>> +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
>> +       args->pitch = roundup(min_pitch, 8);
>> +
> I'm not sure you want this kind of dependency of an out of tree driver
> upstream. If this is some limitation on the display engine so be it,
> but tailoring things for an external module seems like a very bad
> idea.

I can move this mali dependency to user drivers (such as gralloc and
xf86-video-armsoc).
Do you think it is reasonable?

>
>> +       return drm_gem_cma_dumb_create_internal(file, dev, args);
>> +}
>
>> +static int hisi_drm_bind(struct device *dev)
>> +{
>> +       dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
>> +       return drm_platform_init(&hisi_drm_driver, to_platform_device(dev));
> As pointed out by the the kernel doc - drm_platform_init is deprecated.
>

will remove drm_platform_init in v3.

Thanks,
-xinliang

>
> Regards,
> Emil
>
> [1] http://lists.freedesktop.org/archives/dri-devel/2015-November/095466.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-12-01 10:18   ` Xinliang Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Xinliang Liu @ 2015-12-01 10:18 UTC (permalink / raw)
  To: linux-arm-kernel

On 28 November 2015 at 23:25, Emil Velikov <emil.l.velikov@gmail.com> wrote:

Hi Emil, thanks again for review.

> Hi Xinliang,
>
> On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
>> Add DRM master driver for hi6220 SoC which used in HiKey board.
>> Add dumb buffer feature.
>> Add prime dmabuf feature.
>>
>> Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
>> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
>> Signed-off-by: Andy Green <andy.green@linaro.org>
> Your s-o-b should be the bottom of the list. There was a presentation
> (ages ago) from Greg KH, who nicely described the order as a "chain of
> command" or "guilt path". Looks like the rest of the series could use
> this tweak.

will fixed in v3.

>
>> ---
>>  drivers/gpu/drm/Kconfig                  |   2 +
>>  drivers/gpu/drm/Makefile                 |   1 +
>>  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
>>  drivers/gpu/drm/hisilicon/Makefile       |   3 +
>>  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
>>  5 files changed, 229 insertions(+)
>>  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
>>  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
>>  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>>
>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> index 8773fad..038aae8 100644
>> --- a/drivers/gpu/drm/Kconfig
>> +++ b/drivers/gpu/drm/Kconfig
>> @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
>>  source "drivers/gpu/drm/imx/Kconfig"
>>
>>  source "drivers/gpu/drm/vc4/Kconfig"
>> +
>> +source "drivers/gpu/drm/hisilicon/Kconfig"
> I could swear that we can a patch that sorts these alphabetically,
> although it doesn't seem to have made it upstream yet :-(

Yes, as there are so many drm drivers now, it's time to do this work I think.
I'll try to send a separate patch for this soon.

>
>> --- /dev/null
>> +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>
>> +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
>> +{
> The use of .load (and .unload?) callbacks is not recommended. Take a
> look at Laurent Pinchart's patch [1] about the whys and hows on the
> topic

will removed .load/unload in v3.

>
>> +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
>> +                                            struct drm_gem_object *obj,
>> +                                            int flags)
>> +{
>> +       /* we want to be able to write in mmapped buffer */
>> +       flags |= O_RDWR;
> Erm... something feels fishy here. Out of the existing 15 drivers
> setting up the prime callbacks only one (sti) does a similar thing. So
> either everyone else is missing something obvious or hisilicon and sti
> can rework their inner working to remove this (dare I say it) hack.

I would talk to sti guys about this. Not sure how to handle this now.

>
>> +static int hisi_gem_cma_dumb_create(struct drm_file *file,
>> +                                   struct drm_device *dev,
>> +                                   struct drm_mode_create_dumb *args)
>> +{
>> +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
>> +
>> +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
>> +       args->pitch = roundup(min_pitch, 8);
>> +
> I'm not sure you want this kind of dependency of an out of tree driver
> upstream. If this is some limitation on the display engine so be it,
> but tailoring things for an external module seems like a very bad
> idea.

I can move this mali dependency to user drivers (such as gralloc and
xf86-video-armsoc).
Do you think it is reasonable?

>
>> +       return drm_gem_cma_dumb_create_internal(file, dev, args);
>> +}
>
>> +static int hisi_drm_bind(struct device *dev)
>> +{
>> +       dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
>> +       return drm_platform_init(&hisi_drm_driver, to_platform_device(dev));
> As pointed out by the the kernel doc - drm_platform_init is deprecated.
>

will remove drm_platform_init in v3.

Thanks,
-xinliang

>
> Regards,
> Emil
>
> [1] http://lists.freedesktop.org/archives/dri-devel/2015-November/095466.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-11-30  7:46   ` Daniel Vetter
@ 2015-12-01 10:52     ` Xinliang Liu
  -1 siblings, 0 replies; 19+ messages in thread
From: Xinliang Liu @ 2015-12-01 10:52 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Emil Velikov, ML dri-devel, devicetree, Rob Herring,
	Daniel Stone, architt, David Airlie, Jon Corbet, Catalin Marinas,
	Will Deacon, Andy Green, Yiping Xu, linux-doc, Wang Fei,
	zourongrong, linuxarm, Xu Wei, Bintian Wang, Haojian Zhuang,
	Benjamin Gaignard, Feng Chen, lijianhua, Liguozhu (Kenneth),
	LAKML

On 30 November 2015 at 15:46, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
>> Hi Xinliang,
>>
>> On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
>> > Add DRM master driver for hi6220 SoC which used in HiKey board.
>> > Add dumb buffer feature.
>> > Add prime dmabuf feature.
>> >
>> > Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
>> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
>> > Signed-off-by: Andy Green <andy.green@linaro.org>
>> Your s-o-b should be the bottom of the list. There was a presentation
>> (ages ago) from Greg KH, who nicely described the order as a "chain of
>> command" or "guilt path". Looks like the rest of the series could use
>> this tweak.
>>
>> > ---
>> >  drivers/gpu/drm/Kconfig                  |   2 +
>> >  drivers/gpu/drm/Makefile                 |   1 +
>> >  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
>> >  drivers/gpu/drm/hisilicon/Makefile       |   3 +
>> >  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
>> >  5 files changed, 229 insertions(+)
>> >  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
>> >  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
>> >  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>> >
>> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> > index 8773fad..038aae8 100644
>> > --- a/drivers/gpu/drm/Kconfig
>> > +++ b/drivers/gpu/drm/Kconfig
>> > @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
>> >  source "drivers/gpu/drm/imx/Kconfig"
>> >
>> >  source "drivers/gpu/drm/vc4/Kconfig"
>> > +
>> > +source "drivers/gpu/drm/hisilicon/Kconfig"
>> I could swear that we can a patch that sorts these alphabetically,
>> although it doesn't seem to have made it upstream yet :-(
>>
>> > --- /dev/null
>> > +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>>
>> > +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
>> > +{
>> The use of .load (and .unload?) callbacks is not recommended. Take a
>> look at Laurent Pinchart's patch [1] about the whys and hows on the
>> topic
>>
>> > +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
>> > +                                            struct drm_gem_object *obj,
>> > +                                            int flags)
>> > +{
>> > +       /* we want to be able to write in mmapped buffer */
>> > +       flags |= O_RDWR;
>> Erm... something feels fishy here. Out of the existing 15 drivers
>> setting up the prime callbacks only one (sti) does a similar thing. So
>> either everyone else is missing something obvious or hisilicon and sti
>> can rework their inner working to remove this (dare I say it) hack.
>
> Mmap on drm dma-bufs doesn't work, and fairly intentionally. There's been
> some rfc patch series to address this:
>
> http://lists.freedesktop.org/archives/dri-devel/2015-August/089263.html
>
> Unfortunately it seems stuck with getting the userspace piece in shape.
> Might be best to ping Tiago for an update.
>
> Meanwhile please don't do this in drivers ;-)

It seems Tiago's patch is the best way to fix mmap issue.
I'll ping him, hope he will repsonse.

>
>> > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
>> > +                                   struct drm_device *dev,
>> > +                                   struct drm_mode_create_dumb *args)
>> > +{
>> > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
>> > +
>> > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
>> > +       args->pitch = roundup(min_pitch, 8);
>> > +
>> I'm not sure you want this kind of dependency of an out of tree driver
>> upstream. If this is some limitation on the display engine so be it,
>> but tailoring things for an external module seems like a very bad
>> idea.
>
> Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
> go upstream to fix this ...

Oh! I have use dumb buffers for rendering now. What does dumb buffer
mean and what's dumb buffers  for?
For rendering buffer requirements how should I do then?

Thanks,
-xinliang

> -Daniel
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-12-01 10:52     ` Xinliang Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Xinliang Liu @ 2015-12-01 10:52 UTC (permalink / raw)
  To: linux-arm-kernel

On 30 November 2015 at 15:46, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
>> Hi Xinliang,
>>
>> On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
>> > Add DRM master driver for hi6220 SoC which used in HiKey board.
>> > Add dumb buffer feature.
>> > Add prime dmabuf feature.
>> >
>> > Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
>> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
>> > Signed-off-by: Andy Green <andy.green@linaro.org>
>> Your s-o-b should be the bottom of the list. There was a presentation
>> (ages ago) from Greg KH, who nicely described the order as a "chain of
>> command" or "guilt path". Looks like the rest of the series could use
>> this tweak.
>>
>> > ---
>> >  drivers/gpu/drm/Kconfig                  |   2 +
>> >  drivers/gpu/drm/Makefile                 |   1 +
>> >  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
>> >  drivers/gpu/drm/hisilicon/Makefile       |   3 +
>> >  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
>> >  5 files changed, 229 insertions(+)
>> >  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
>> >  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
>> >  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>> >
>> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> > index 8773fad..038aae8 100644
>> > --- a/drivers/gpu/drm/Kconfig
>> > +++ b/drivers/gpu/drm/Kconfig
>> > @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
>> >  source "drivers/gpu/drm/imx/Kconfig"
>> >
>> >  source "drivers/gpu/drm/vc4/Kconfig"
>> > +
>> > +source "drivers/gpu/drm/hisilicon/Kconfig"
>> I could swear that we can a patch that sorts these alphabetically,
>> although it doesn't seem to have made it upstream yet :-(
>>
>> > --- /dev/null
>> > +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
>>
>> > +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
>> > +{
>> The use of .load (and .unload?) callbacks is not recommended. Take a
>> look at Laurent Pinchart's patch [1] about the whys and hows on the
>> topic
>>
>> > +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
>> > +                                            struct drm_gem_object *obj,
>> > +                                            int flags)
>> > +{
>> > +       /* we want to be able to write in mmapped buffer */
>> > +       flags |= O_RDWR;
>> Erm... something feels fishy here. Out of the existing 15 drivers
>> setting up the prime callbacks only one (sti) does a similar thing. So
>> either everyone else is missing something obvious or hisilicon and sti
>> can rework their inner working to remove this (dare I say it) hack.
>
> Mmap on drm dma-bufs doesn't work, and fairly intentionally. There's been
> some rfc patch series to address this:
>
> http://lists.freedesktop.org/archives/dri-devel/2015-August/089263.html
>
> Unfortunately it seems stuck with getting the userspace piece in shape.
> Might be best to ping Tiago for an update.
>
> Meanwhile please don't do this in drivers ;-)

It seems Tiago's patch is the best way to fix mmap issue.
I'll ping him, hope he will repsonse.

>
>> > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
>> > +                                   struct drm_device *dev,
>> > +                                   struct drm_mode_create_dumb *args)
>> > +{
>> > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
>> > +
>> > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
>> > +       args->pitch = roundup(min_pitch, 8);
>> > +
>> I'm not sure you want this kind of dependency of an out of tree driver
>> upstream. If this is some limitation on the display engine so be it,
>> but tailoring things for an external module seems like a very bad
>> idea.
>
> Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
> go upstream to fix this ...

Oh! I have use dumb buffers for rendering now. What does dumb buffer
mean and what's dumb buffers  for?
For rendering buffer requirements how should I do then?

Thanks,
-xinliang

> -Daniel
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-12-01 10:52     ` Xinliang Liu
@ 2015-12-01 12:54       ` Daniel Vetter
  -1 siblings, 0 replies; 19+ messages in thread
From: Daniel Vetter @ 2015-12-01 12:54 UTC (permalink / raw)
  To: Xinliang Liu
  Cc: Daniel Vetter, Emil Velikov, ML dri-devel, devicetree,
	Rob Herring, Daniel Stone, architt, David Airlie, Jon Corbet,
	Catalin Marinas, Will Deacon, Andy Green, Yiping Xu, linux-doc,
	Wang Fei, zourongrong, linuxarm, Xu Wei, Bintian Wang,
	Haojian Zhuang, Benjamin Gaignard, Feng Chen, lijianhua,
	Liguozhu (Kenneth),
	LAKML

On Tue, Dec 01, 2015 at 06:52:20PM +0800, Xinliang Liu wrote:
> On 30 November 2015 at 15:46, Daniel Vetter <daniel@ffwll.ch> wrote:
> > On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
> >> Hi Xinliang,
> >>
> >> On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> >> > Add DRM master driver for hi6220 SoC which used in HiKey board.
> >> > Add dumb buffer feature.
> >> > Add prime dmabuf feature.
> >> >
> >> > Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
> >> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> >> > Signed-off-by: Andy Green <andy.green@linaro.org>
> >> Your s-o-b should be the bottom of the list. There was a presentation
> >> (ages ago) from Greg KH, who nicely described the order as a "chain of
> >> command" or "guilt path". Looks like the rest of the series could use
> >> this tweak.
> >>
> >> > ---
> >> >  drivers/gpu/drm/Kconfig                  |   2 +
> >> >  drivers/gpu/drm/Makefile                 |   1 +
> >> >  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
> >> >  drivers/gpu/drm/hisilicon/Makefile       |   3 +
> >> >  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
> >> >  5 files changed, 229 insertions(+)
> >> >  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
> >> >  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
> >> >  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
> >> >
> >> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> >> > index 8773fad..038aae8 100644
> >> > --- a/drivers/gpu/drm/Kconfig
> >> > +++ b/drivers/gpu/drm/Kconfig
> >> > @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
> >> >  source "drivers/gpu/drm/imx/Kconfig"
> >> >
> >> >  source "drivers/gpu/drm/vc4/Kconfig"
> >> > +
> >> > +source "drivers/gpu/drm/hisilicon/Kconfig"
> >> I could swear that we can a patch that sorts these alphabetically,
> >> although it doesn't seem to have made it upstream yet :-(
> >>
> >> > --- /dev/null
> >> > +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
> >>
> >> > +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
> >> > +{
> >> The use of .load (and .unload?) callbacks is not recommended. Take a
> >> look at Laurent Pinchart's patch [1] about the whys and hows on the
> >> topic
> >>
> >> > +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
> >> > +                                            struct drm_gem_object *obj,
> >> > +                                            int flags)
> >> > +{
> >> > +       /* we want to be able to write in mmapped buffer */
> >> > +       flags |= O_RDWR;
> >> Erm... something feels fishy here. Out of the existing 15 drivers
> >> setting up the prime callbacks only one (sti) does a similar thing. So
> >> either everyone else is missing something obvious or hisilicon and sti
> >> can rework their inner working to remove this (dare I say it) hack.
> >
> > Mmap on drm dma-bufs doesn't work, and fairly intentionally. There's been
> > some rfc patch series to address this:
> >
> > http://lists.freedesktop.org/archives/dri-devel/2015-August/089263.html
> >
> > Unfortunately it seems stuck with getting the userspace piece in shape.
> > Might be best to ping Tiago for an update.
> >
> > Meanwhile please don't do this in drivers ;-)
> 
> It seems Tiago's patch is the best way to fix mmap issue.
> I'll ping him, hope he will repsonse.
> 
> >
> >> > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> >> > +                                   struct drm_device *dev,
> >> > +                                   struct drm_mode_create_dumb *args)
> >> > +{
> >> > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> >> > +
> >> > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> >> > +       args->pitch = roundup(min_pitch, 8);
> >> > +
> >> I'm not sure you want this kind of dependency of an out of tree driver
> >> upstream. If this is some limitation on the display engine so be it,
> >> but tailoring things for an external module seems like a very bad
> >> idea.
> >
> > Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
> > go upstream to fix this ...
> 
> Oh! I have use dumb buffers for rendering now. What does dumb buffer
> mean and what's dumb buffers  for?
> For rendering buffer requirements how should I do then?

Dumb buffers are really just a very thin in-kernel abstraction for boot
splash screens. As soon as you have real userspace (surfaceflinger, gl es,
whatever) the idea is that an allocator in userspace (like gralloc, gbm or
similar) figures out the allocation constraints and where to allocate
things exactly. Maybe that includes allocating from dumb buffers with
special knowledge (by increasing x/y perhaps), but most likely that means
you either allocate from your proprietary/out-of-tree gpu render driver or
some other central allocator like ion.

Anyway, adding hacks to the dumb buffer which are meant to facilite
sharing with other devices, or using it for anything else than a boot
splash is a no-go. DRM has made the design decision that gpu rendering is
too vendor-specific at the kernel level to make such generic interfaces
possible, and that allocation problems can only be solved properly in
userspace.

For your case specifically first step is to get an open-source mali driver
released, since that the basic requirement for upstream drm to design new
solutions in any area. Hence why I mentioned that ;-)

Kernel modesetting drivers don't need that since for those we have a
well-defined ABI and already existing userspace like X or Wayland which
can use it.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-12-01 12:54       ` Daniel Vetter
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Vetter @ 2015-12-01 12:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Dec 01, 2015 at 06:52:20PM +0800, Xinliang Liu wrote:
> On 30 November 2015 at 15:46, Daniel Vetter <daniel@ffwll.ch> wrote:
> > On Sat, Nov 28, 2015 at 03:25:35PM +0000, Emil Velikov wrote:
> >> Hi Xinliang,
> >>
> >> On 28 November 2015 at 10:38, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> >> > Add DRM master driver for hi6220 SoC which used in HiKey board.
> >> > Add dumb buffer feature.
> >> > Add prime dmabuf feature.
> >> >
> >> > Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
> >> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> >> > Signed-off-by: Andy Green <andy.green@linaro.org>
> >> Your s-o-b should be the bottom of the list. There was a presentation
> >> (ages ago) from Greg KH, who nicely described the order as a "chain of
> >> command" or "guilt path". Looks like the rest of the series could use
> >> this tweak.
> >>
> >> > ---
> >> >  drivers/gpu/drm/Kconfig                  |   2 +
> >> >  drivers/gpu/drm/Makefile                 |   1 +
> >> >  drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
> >> >  drivers/gpu/drm/hisilicon/Makefile       |   3 +
> >> >  drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
> >> >  5 files changed, 229 insertions(+)
> >> >  create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
> >> >  create mode 100644 drivers/gpu/drm/hisilicon/Makefile
> >> >  create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c
> >> >
> >> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> >> > index 8773fad..038aae8 100644
> >> > --- a/drivers/gpu/drm/Kconfig
> >> > +++ b/drivers/gpu/drm/Kconfig
> >> > @@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
> >> >  source "drivers/gpu/drm/imx/Kconfig"
> >> >
> >> >  source "drivers/gpu/drm/vc4/Kconfig"
> >> > +
> >> > +source "drivers/gpu/drm/hisilicon/Kconfig"
> >> I could swear that we can a patch that sorts these alphabetically,
> >> although it doesn't seem to have made it upstream yet :-(
> >>
> >> > --- /dev/null
> >> > +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
> >>
> >> > +static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
> >> > +{
> >> The use of .load (and .unload?) callbacks is not recommended. Take a
> >> look at Laurent Pinchart's patch [1] about the whys and hows on the
> >> topic
> >>
> >> > +static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
> >> > +                                            struct drm_gem_object *obj,
> >> > +                                            int flags)
> >> > +{
> >> > +       /* we want to be able to write in mmapped buffer */
> >> > +       flags |= O_RDWR;
> >> Erm... something feels fishy here. Out of the existing 15 drivers
> >> setting up the prime callbacks only one (sti) does a similar thing. So
> >> either everyone else is missing something obvious or hisilicon and sti
> >> can rework their inner working to remove this (dare I say it) hack.
> >
> > Mmap on drm dma-bufs doesn't work, and fairly intentionally. There's been
> > some rfc patch series to address this:
> >
> > http://lists.freedesktop.org/archives/dri-devel/2015-August/089263.html
> >
> > Unfortunately it seems stuck with getting the userspace piece in shape.
> > Might be best to ping Tiago for an update.
> >
> > Meanwhile please don't do this in drivers ;-)
> 
> It seems Tiago's patch is the best way to fix mmap issue.
> I'll ping him, hope he will repsonse.
> 
> >
> >> > +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> >> > +                                   struct drm_device *dev,
> >> > +                                   struct drm_mode_create_dumb *args)
> >> > +{
> >> > +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> >> > +
> >> > +       /* mali gpu need pitch 8 bytes alignment for 32bpp */
> >> > +       args->pitch = roundup(min_pitch, 8);
> >> > +
> >> I'm not sure you want this kind of dependency of an out of tree driver
> >> upstream. If this is some limitation on the display engine so be it,
> >> but tailoring things for an external module seems like a very bad
> >> idea.
> >
> > Yup, nacked. dumb_create is for dumb buffers, not rendering. Mali needs to
> > go upstream to fix this ...
> 
> Oh! I have use dumb buffers for rendering now. What does dumb buffer
> mean and what's dumb buffers  for?
> For rendering buffer requirements how should I do then?

Dumb buffers are really just a very thin in-kernel abstraction for boot
splash screens. As soon as you have real userspace (surfaceflinger, gl es,
whatever) the idea is that an allocator in userspace (like gralloc, gbm or
similar) figures out the allocation constraints and where to allocate
things exactly. Maybe that includes allocating from dumb buffers with
special knowledge (by increasing x/y perhaps), but most likely that means
you either allocate from your proprietary/out-of-tree gpu render driver or
some other central allocator like ion.

Anyway, adding hacks to the dumb buffer which are meant to facilite
sharing with other devices, or using it for anything else than a boot
splash is a no-go. DRM has made the design decision that gpu rendering is
too vendor-specific at the kernel level to make such generic interfaces
possible, and that allocation problems can only be solved properly in
userspace.

For your case specifically first step is to get an open-source mali driver
released, since that the basic requirement for upstream drm to design new
solutions in any area. Hence why I mentioned that ;-)

Kernel modesetting drivers don't need that since for those we have a
well-defined ABI and already existing userspace like X or Wayland which
can use it.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-12-03 16:21     ` Rob Herring
@ 2015-12-05  1:25       ` Xinliang Liu
  -1 siblings, 0 replies; 19+ messages in thread
From: Xinliang Liu @ 2015-12-05  1:25 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-doc, Catalin Marinas, Will Deacon, Linuxarm, dri-devel,
	Wei Xu, Benjamin Gaignard, zourongrong, Yiping Xu,
	Jonathan Corbet, Wang Fei, lijianhua, devicetree, Bintian Wang,
	Chen Feng, linux-arm-kernel, Andy Green, Liguozhu (Kenneth),
	Haojian Zhuang

On 4 December 2015 at 00:21, Rob Herring <robh@kernel.org> wrote:
> On Sat, Nov 28, 2015 at 4:38 AM, Xinliang Liu <xinliang.liu@linaro.org> wrote:
>> Add DRM master driver for hi6220 SoC which used in HiKey board.
>> Add dumb buffer feature.
>> Add prime dmabuf feature.
>>
>> Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
>> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
>> Signed-off-by: Andy Green <andy.green@linaro.org>
>> ---
>
>> +static int hisi_gem_cma_dumb_create(struct drm_file *file,
>> +                                   struct drm_device *dev,
>> +                                   struct drm_mode_create_dumb *args)
>> +{
>> +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
>
> BTW, is args->bpp supposed to be bits or bytes? I'm using your dumb bo
> support in drm_gralloc which does bytes as that is what
> gralloc_drm_get_bpp returns. The virtio-gpu driver does bits. I'm
> guessing bits is correct.

yes, it is bits. And pitch is bytes.

>
> Rob
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-12-05  1:25       ` Xinliang Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Xinliang Liu @ 2015-12-05  1:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 4 December 2015 at 00:21, Rob Herring <robh@kernel.org> wrote:
> On Sat, Nov 28, 2015 at 4:38 AM, Xinliang Liu <xinliang.liu@linaro.org> wrote:
>> Add DRM master driver for hi6220 SoC which used in HiKey board.
>> Add dumb buffer feature.
>> Add prime dmabuf feature.
>>
>> Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
>> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
>> Signed-off-by: Andy Green <andy.green@linaro.org>
>> ---
>
>> +static int hisi_gem_cma_dumb_create(struct drm_file *file,
>> +                                   struct drm_device *dev,
>> +                                   struct drm_mode_create_dumb *args)
>> +{
>> +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
>
> BTW, is args->bpp supposed to be bits or bytes? I'm using your dumb bo
> support in drm_gralloc which does bytes as that is what
> gralloc_drm_get_bpp returns. The virtio-gpu driver does bits. I'm
> guessing bits is correct.

yes, it is bits. And pitch is bytes.

>
> Rob

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-11-28 10:38   ` Xinliang Liu
@ 2015-12-03 16:21     ` Rob Herring
  -1 siblings, 0 replies; 19+ messages in thread
From: Rob Herring @ 2015-12-03 16:21 UTC (permalink / raw)
  To: Xinliang Liu
  Cc: dri-devel, devicetree, Daniel Vetter, Daniel Stone,
	Archit Taneja, David Airlie, Jonathan Corbet, Catalin Marinas,
	Will Deacon, linux-doc, linux-arm-kernel, Linuxarm, Andy Green,
	Haojian Zhuang, Liguozhu (Kenneth),
	Wei Xu, w.f, Chen Feng, Bintian Wang, Benjamin Gaignard,
	Yiping Xu, Xinwei

On Sat, Nov 28, 2015 at 4:38 AM, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> Add DRM master driver for hi6220 SoC which used in HiKey board.
> Add dumb buffer feature.
> Add prime dmabuf feature.
>
> Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> Signed-off-by: Andy Green <andy.green@linaro.org>
> ---

> +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> +                                   struct drm_device *dev,
> +                                   struct drm_mode_create_dumb *args)
> +{
> +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);

BTW, is args->bpp supposed to be bits or bytes? I'm using your dumb bo
support in drm_gralloc which does bytes as that is what
gralloc_drm_get_bpp returns. The virtio-gpu driver does bits. I'm
guessing bits is correct.

Rob

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-12-03 16:21     ` Rob Herring
  0 siblings, 0 replies; 19+ messages in thread
From: Rob Herring @ 2015-12-03 16:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Nov 28, 2015 at 4:38 AM, Xinliang Liu <xinliang.liu@linaro.org> wrote:
> Add DRM master driver for hi6220 SoC which used in HiKey board.
> Add dumb buffer feature.
> Add prime dmabuf feature.
>
> Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> Signed-off-by: Andy Green <andy.green@linaro.org>
> ---

> +static int hisi_gem_cma_dumb_create(struct drm_file *file,
> +                                   struct drm_device *dev,
> +                                   struct drm_mode_create_dumb *args)
> +{
> +       int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);

BTW, is args->bpp supposed to be bits or bytes? I'm using your dumb bo
support in drm_gralloc which does bytes as that is what
gralloc_drm_get_bpp returns. The virtio-gpu driver does bits. I'm
guessing bits is correct.

Rob

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
  2015-11-28 10:38 [PATCH v2 00/10] Add New DRM Driver for HiSilicon hi6220 SoC Xinliang Liu
@ 2015-11-28 10:38   ` Xinliang Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Xinliang Liu @ 2015-11-28 10:38 UTC (permalink / raw)
  To: dri-devel, devicetree, daniel, robh, daniel, architt, airlied,
	corbet, catalin.marinas, will.deacon
  Cc: linux-doc, linux-arm-kernel, linuxarm, andy.green,
	haojian.zhuang, liguozhu, xuwei5, w.f, puck.chen, bintian.wang,
	benjamin.gaignard, xuyiping, kong.kongxinwei, zourongrong,
	lijianhua, sumit.semwal, Xinliang Liu

Add DRM master driver for hi6220 SoC which used in HiKey board.
Add dumb buffer feature.
Add prime dmabuf feature.

Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
---
 drivers/gpu/drm/Kconfig                  |   2 +
 drivers/gpu/drm/Makefile                 |   1 +
 drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
 drivers/gpu/drm/hisilicon/Makefile       |   3 +
 drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
 5 files changed, 229 insertions(+)
 create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
 create mode 100644 drivers/gpu/drm/hisilicon/Makefile
 create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 8773fad..038aae8 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
 source "drivers/gpu/drm/imx/Kconfig"
 
 source "drivers/gpu/drm/vc4/Kconfig"
+
+source "drivers/gpu/drm/hisilicon/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 1e9ff4c..e7efcb7 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -75,3 +75,4 @@ obj-y			+= i2c/
 obj-y			+= panel/
 obj-y			+= bridge/
 obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
+obj-$(CONFIG_DRM_HISI) += hisilicon/
diff --git a/drivers/gpu/drm/hisilicon/Kconfig b/drivers/gpu/drm/hisilicon/Kconfig
new file mode 100644
index 0000000..70aa8d1
--- /dev/null
+++ b/drivers/gpu/drm/hisilicon/Kconfig
@@ -0,0 +1,9 @@
+config DRM_HISI
+	tristate "DRM Support for Hisilicon SoCs Platform"
+	depends on DRM
+	select DRM_KMS_HELPER
+	select DRM_GEM_CMA_HELPER
+	select DRM_KMS_CMA_HELPER
+	help
+	  Choose this option if you have a hisilicon chipsets(hi6220).
+	  If M is selected the module will be called hisi-drm.
diff --git a/drivers/gpu/drm/hisilicon/Makefile b/drivers/gpu/drm/hisilicon/Makefile
new file mode 100644
index 0000000..7375456
--- /dev/null
+++ b/drivers/gpu/drm/hisilicon/Makefile
@@ -0,0 +1,3 @@
+hisi-drm-y := hisi_drm_drv.o 
+
+obj-$(CONFIG_DRM_HISI)	+= hisi-drm.o
diff --git a/drivers/gpu/drm/hisilicon/hisi_drm_drv.c b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
new file mode 100644
index 0000000..445e2ec
--- /dev/null
+++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
@@ -0,0 +1,214 @@
+/*
+ * Hisilicon SoCs drm master driver
+ *
+ * Copyright (c) 2014-2015 Hisilicon Limited.
+ * Author:
+ *	Xinliang Liu <xinliang.liu@linaro.org>
+ *	Xinliang Liu <z.liuxinliang@hisilicon.com>
+ *	Xinwei Kong <kong.kongxinwei@hisilicon.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/of_platform.h>
+#include <linux/component.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_atomic_helper.h>
+
+#define DRIVER_NAME	"hisi-drm"
+
+static int hisi_drm_unload(struct drm_device *dev)
+{
+	drm_mode_config_cleanup(dev);
+	return 0;
+}
+
+static const struct drm_mode_config_funcs hisi_drm_mode_config_funcs = {
+	.fb_create = drm_fb_cma_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
+
+static void hisi_drm_mode_config_init(struct drm_device *dev)
+{
+	dev->mode_config.min_width = 0;
+	dev->mode_config.min_height = 0;
+
+	dev->mode_config.max_width = 2048;
+	dev->mode_config.max_height = 2048;
+
+	dev->mode_config.funcs = &hisi_drm_mode_config_funcs;
+}
+
+static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
+{
+	int ret;
+
+	dev_set_drvdata(dev->dev, dev);
+
+	/* dev->mode_config initialization */
+	drm_mode_config_init(dev);
+	hisi_drm_mode_config_init(dev);
+
+	/* bind and init sub drivers */
+	ret = component_bind_all(dev->dev, dev);
+	if (ret) {
+		DRM_ERROR("failed to bind all component.\n");
+		goto err_mode_config_cleanup;
+	}
+
+	/* reset all the states of crtc/plane/encoder/connector */
+	drm_mode_config_reset(dev);
+
+	return 0;
+
+err_mode_config_cleanup:
+	drm_mode_config_cleanup(dev);
+
+	return ret;
+}
+
+static const struct file_operations hisi_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
+					     struct drm_gem_object *obj,
+					     int flags)
+{
+	/* we want to be able to write in mmapped buffer */
+	flags |= O_RDWR;
+	return drm_gem_prime_export(dev, obj, flags);
+}
+
+static int hisi_gem_cma_dumb_create(struct drm_file *file,
+				    struct drm_device *dev,
+				    struct drm_mode_create_dumb *args)
+{
+	int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+	/* mali gpu need pitch 8 bytes alignment for 32bpp */
+	args->pitch = roundup(min_pitch, 8);
+
+	return drm_gem_cma_dumb_create_internal(file, dev, args);
+}
+
+static struct drm_driver hisi_drm_driver = {
+	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
+				  DRIVER_ATOMIC,
+	.load			= hisi_drm_load,
+	.unload                 = hisi_drm_unload,
+	.fops			= &hisi_drm_fops,
+	.set_busid		= drm_platform_set_busid,
+
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.dumb_create		= hisi_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_export	= hisi_gem_prime_export,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+
+	.name			= "hisi",
+	.desc			= "Hisilicon SoCs' DRM Driver",
+	.date			= "20150718",
+	.major			= 1,
+	.minor			= 0,
+};
+
+static int compare_of(struct device *dev, void *data)
+{
+	return dev->of_node == data;
+}
+
+static int hisi_drm_bind(struct device *dev)
+{
+	dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
+	return drm_platform_init(&hisi_drm_driver, to_platform_device(dev));
+}
+
+static void hisi_drm_unbind(struct device *dev)
+{
+	drm_put_dev(dev_get_drvdata(dev));
+}
+
+static const struct component_master_ops hisi_drm_ops = {
+	.bind = hisi_drm_bind,
+	.unbind = hisi_drm_unbind,
+};
+
+static int hisi_drm_platform_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->of_node;
+	struct device_node *child_np;
+	struct component_match *match = NULL;
+
+	of_platform_populate(node, NULL, NULL, dev);
+
+	child_np = of_get_next_available_child(node, NULL);
+	while (child_np) {
+		component_match_add(dev, &match, compare_of, child_np);
+		of_node_put(child_np);
+		child_np = of_get_next_available_child(node, child_np);
+	}
+
+	return component_master_add_with_match(dev, &hisi_drm_ops, match);
+
+	return 0;
+}
+
+static int hisi_drm_platform_remove(struct platform_device *pdev)
+{
+	component_master_del(&pdev->dev, &hisi_drm_ops);
+	of_platform_depopulate(&pdev->dev);
+	return 0;
+}
+
+static const struct of_device_id hisi_drm_dt_ids[] = {
+	{ .compatible = "hisilicon,hi6220-dss", },
+	{ /* end node */ },
+};
+MODULE_DEVICE_TABLE(of, hisi_drm_dt_ids);
+
+static struct platform_driver hisi_drm_platform_driver = {
+	.probe = hisi_drm_platform_probe,
+	.remove = hisi_drm_platform_remove,
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = DRIVER_NAME,
+		.of_match_table = hisi_drm_dt_ids,
+	},
+};
+
+module_platform_driver(hisi_drm_platform_driver);
+
+MODULE_AUTHOR("Xinliang Liu <xinliang.liu@linaro.org>");
+MODULE_AUTHOR("Xinliang Liu <z.liuxinliang@hisilicon.com>");
+MODULE_AUTHOR("Xinwei Kong <kong.kongxinwei@hisilicon.com>");
+MODULE_DESCRIPTION("hisilicon SoCs' DRM master driver");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver
@ 2015-11-28 10:38   ` Xinliang Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Xinliang Liu @ 2015-11-28 10:38 UTC (permalink / raw)
  To: linux-arm-kernel

Add DRM master driver for hi6220 SoC which used in HiKey board.
Add dumb buffer feature.
Add prime dmabuf feature.

Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
---
 drivers/gpu/drm/Kconfig                  |   2 +
 drivers/gpu/drm/Makefile                 |   1 +
 drivers/gpu/drm/hisilicon/Kconfig        |   9 ++
 drivers/gpu/drm/hisilicon/Makefile       |   3 +
 drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 214 +++++++++++++++++++++++++++++++
 5 files changed, 229 insertions(+)
 create mode 100644 drivers/gpu/drm/hisilicon/Kconfig
 create mode 100644 drivers/gpu/drm/hisilicon/Makefile
 create mode 100644 drivers/gpu/drm/hisilicon/hisi_drm_drv.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 8773fad..038aae8 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -274,3 +274,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
 source "drivers/gpu/drm/imx/Kconfig"
 
 source "drivers/gpu/drm/vc4/Kconfig"
+
+source "drivers/gpu/drm/hisilicon/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 1e9ff4c..e7efcb7 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -75,3 +75,4 @@ obj-y			+= i2c/
 obj-y			+= panel/
 obj-y			+= bridge/
 obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
+obj-$(CONFIG_DRM_HISI) += hisilicon/
diff --git a/drivers/gpu/drm/hisilicon/Kconfig b/drivers/gpu/drm/hisilicon/Kconfig
new file mode 100644
index 0000000..70aa8d1
--- /dev/null
+++ b/drivers/gpu/drm/hisilicon/Kconfig
@@ -0,0 +1,9 @@
+config DRM_HISI
+	tristate "DRM Support for Hisilicon SoCs Platform"
+	depends on DRM
+	select DRM_KMS_HELPER
+	select DRM_GEM_CMA_HELPER
+	select DRM_KMS_CMA_HELPER
+	help
+	  Choose this option if you have a hisilicon chipsets(hi6220).
+	  If M is selected the module will be called hisi-drm.
diff --git a/drivers/gpu/drm/hisilicon/Makefile b/drivers/gpu/drm/hisilicon/Makefile
new file mode 100644
index 0000000..7375456
--- /dev/null
+++ b/drivers/gpu/drm/hisilicon/Makefile
@@ -0,0 +1,3 @@
+hisi-drm-y := hisi_drm_drv.o 
+
+obj-$(CONFIG_DRM_HISI)	+= hisi-drm.o
diff --git a/drivers/gpu/drm/hisilicon/hisi_drm_drv.c b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
new file mode 100644
index 0000000..445e2ec
--- /dev/null
+++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c
@@ -0,0 +1,214 @@
+/*
+ * Hisilicon SoCs drm master driver
+ *
+ * Copyright (c) 2014-2015 Hisilicon Limited.
+ * Author:
+ *	Xinliang Liu <xinliang.liu@linaro.org>
+ *	Xinliang Liu <z.liuxinliang@hisilicon.com>
+ *	Xinwei Kong <kong.kongxinwei@hisilicon.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/of_platform.h>
+#include <linux/component.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_atomic_helper.h>
+
+#define DRIVER_NAME	"hisi-drm"
+
+static int hisi_drm_unload(struct drm_device *dev)
+{
+	drm_mode_config_cleanup(dev);
+	return 0;
+}
+
+static const struct drm_mode_config_funcs hisi_drm_mode_config_funcs = {
+	.fb_create = drm_fb_cma_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
+
+static void hisi_drm_mode_config_init(struct drm_device *dev)
+{
+	dev->mode_config.min_width = 0;
+	dev->mode_config.min_height = 0;
+
+	dev->mode_config.max_width = 2048;
+	dev->mode_config.max_height = 2048;
+
+	dev->mode_config.funcs = &hisi_drm_mode_config_funcs;
+}
+
+static int hisi_drm_load(struct drm_device *dev, unsigned long flags)
+{
+	int ret;
+
+	dev_set_drvdata(dev->dev, dev);
+
+	/* dev->mode_config initialization */
+	drm_mode_config_init(dev);
+	hisi_drm_mode_config_init(dev);
+
+	/* bind and init sub drivers */
+	ret = component_bind_all(dev->dev, dev);
+	if (ret) {
+		DRM_ERROR("failed to bind all component.\n");
+		goto err_mode_config_cleanup;
+	}
+
+	/* reset all the states of crtc/plane/encoder/connector */
+	drm_mode_config_reset(dev);
+
+	return 0;
+
+err_mode_config_cleanup:
+	drm_mode_config_cleanup(dev);
+
+	return ret;
+}
+
+static const struct file_operations hisi_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct dma_buf *hisi_gem_prime_export(struct drm_device *dev,
+					     struct drm_gem_object *obj,
+					     int flags)
+{
+	/* we want to be able to write in mmapped buffer */
+	flags |= O_RDWR;
+	return drm_gem_prime_export(dev, obj, flags);
+}
+
+static int hisi_gem_cma_dumb_create(struct drm_file *file,
+				    struct drm_device *dev,
+				    struct drm_mode_create_dumb *args)
+{
+	int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+	/* mali gpu need pitch 8 bytes alignment for 32bpp */
+	args->pitch = roundup(min_pitch, 8);
+
+	return drm_gem_cma_dumb_create_internal(file, dev, args);
+}
+
+static struct drm_driver hisi_drm_driver = {
+	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
+				  DRIVER_ATOMIC,
+	.load			= hisi_drm_load,
+	.unload                 = hisi_drm_unload,
+	.fops			= &hisi_drm_fops,
+	.set_busid		= drm_platform_set_busid,
+
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.dumb_create		= hisi_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_export	= hisi_gem_prime_export,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+
+	.name			= "hisi",
+	.desc			= "Hisilicon SoCs' DRM Driver",
+	.date			= "20150718",
+	.major			= 1,
+	.minor			= 0,
+};
+
+static int compare_of(struct device *dev, void *data)
+{
+	return dev->of_node == data;
+}
+
+static int hisi_drm_bind(struct device *dev)
+{
+	dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
+	return drm_platform_init(&hisi_drm_driver, to_platform_device(dev));
+}
+
+static void hisi_drm_unbind(struct device *dev)
+{
+	drm_put_dev(dev_get_drvdata(dev));
+}
+
+static const struct component_master_ops hisi_drm_ops = {
+	.bind = hisi_drm_bind,
+	.unbind = hisi_drm_unbind,
+};
+
+static int hisi_drm_platform_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->of_node;
+	struct device_node *child_np;
+	struct component_match *match = NULL;
+
+	of_platform_populate(node, NULL, NULL, dev);
+
+	child_np = of_get_next_available_child(node, NULL);
+	while (child_np) {
+		component_match_add(dev, &match, compare_of, child_np);
+		of_node_put(child_np);
+		child_np = of_get_next_available_child(node, child_np);
+	}
+
+	return component_master_add_with_match(dev, &hisi_drm_ops, match);
+
+	return 0;
+}
+
+static int hisi_drm_platform_remove(struct platform_device *pdev)
+{
+	component_master_del(&pdev->dev, &hisi_drm_ops);
+	of_platform_depopulate(&pdev->dev);
+	return 0;
+}
+
+static const struct of_device_id hisi_drm_dt_ids[] = {
+	{ .compatible = "hisilicon,hi6220-dss", },
+	{ /* end node */ },
+};
+MODULE_DEVICE_TABLE(of, hisi_drm_dt_ids);
+
+static struct platform_driver hisi_drm_platform_driver = {
+	.probe = hisi_drm_platform_probe,
+	.remove = hisi_drm_platform_remove,
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = DRIVER_NAME,
+		.of_match_table = hisi_drm_dt_ids,
+	},
+};
+
+module_platform_driver(hisi_drm_platform_driver);
+
+MODULE_AUTHOR("Xinliang Liu <xinliang.liu@linaro.org>");
+MODULE_AUTHOR("Xinliang Liu <z.liuxinliang@hisilicon.com>");
+MODULE_AUTHOR("Xinwei Kong <kong.kongxinwei@hisilicon.com>");
+MODULE_DESCRIPTION("hisilicon SoCs' DRM master driver");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-12-05  1:25 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-28 15:25 [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver Emil Velikov
2015-11-30  7:46 ` Daniel Vetter
2015-11-30  7:46   ` Daniel Vetter
2015-11-30 17:25   ` Rob Herring
2015-11-30 17:25     ` Rob Herring
2015-12-01  7:12     ` Daniel Vetter
2015-12-01  7:12       ` Daniel Vetter
2015-12-01 10:52   ` Xinliang Liu
2015-12-01 10:52     ` Xinliang Liu
2015-12-01 12:54     ` Daniel Vetter
2015-12-01 12:54       ` Daniel Vetter
2015-12-01 10:18 ` Xinliang Liu
2015-12-01 10:18   ` Xinliang Liu
  -- strict thread matches above, loose matches on Subject: below --
2015-11-28 10:38 [PATCH v2 00/10] Add New DRM Driver for HiSilicon hi6220 SoC Xinliang Liu
2015-11-28 10:38 ` [PATCH v2 03/10] drm/hisilicon: Add hisilicon DRM master driver Xinliang Liu
2015-11-28 10:38   ` Xinliang Liu
2015-12-03 16:21   ` Rob Herring
2015-12-03 16:21     ` Rob Herring
2015-12-05  1:25     ` Xinliang Liu
2015-12-05  1:25       ` Xinliang Liu

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.