Re: [PATCH 06/11] drm/tinydrm: Remove tinydrm_shutdown()

2019-01-20 Thread Sam Ravnborg
On Sun, Jan 20, 2019 at 12:43:13PM +0100, Noralf Trønnes wrote:
> It's just a wrapper around drm_atomic_helper_shutdown() now.
> Also store drm_device in the drvdata field, since that's what's used.
> 
> Signed-off-by: Noralf Trønnes 
Reviewed-by: Sam Ravnborg 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 05/11] drm/tinydrm/mipi-dbi: Add drm_to_mipi_dbi()

2019-01-20 Thread Sam Ravnborg
On Sun, Jan 20, 2019 at 12:43:12PM +0100, Noralf Trønnes wrote:
> Add a function to derive mipi_dbi from drm_device now that tinydrm_device
> is going away.
> 
> Signed-off-by: Noralf Trønnes 
Reviewed-by: Sam Ravnborg 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 04/11] drm/tinydrm: Remove tinydrm_display_pipe_init()

2019-01-20 Thread Sam Ravnborg
Hi Noralf.

On Sun, Jan 20, 2019 at 12:43:11PM +0100, Noralf Trønnes wrote:
> Further strip down tinydrm.ko and switch to drm_simple_connector_create().

It is nice how the tinydrm drivers goes from special drivers to small
drivers with a little added to the core.

Two minor comments below. With that addressed/processed it has:
Reviewed-by: Sam Ravnborg 

> 
> Signed-off-by: Noralf Trønnes 
> ---
>  Documentation/gpu/tinydrm.rst   |   3 -
>  drivers/gpu/drm/tinydrm/core/Makefile   |   2 +-
>  drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 183 
>  drivers/gpu/drm/tinydrm/mipi-dbi.c  |  24 ++-
>  drivers/gpu/drm/tinydrm/repaper.c   |  16 +-
>  drivers/gpu/drm/tinydrm/st7586.c|  19 +-
>  include/drm/tinydrm/tinydrm.h   |   9 -
>  7 files changed, 43 insertions(+), 213 deletions(-)
>  delete mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
> 
> diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c 
> b/drivers/gpu/drm/tinydrm/mipi-dbi.c
> index 918f77c7de34..d1d546f3a664 100644
> --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
> +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
> @@ -391,7 +391,13 @@ int mipi_dbi_init(struct device *dev, struct mipi_dbi 
> *mipi,
>  {
>   size_t bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16);
>   struct tinydrm_device *tdev = >tinydrm;
> + struct drm_connector *connector;
> + struct drm_device *drm;
>   int ret;
> + static const uint64_t modifiers[] = {
> + DRM_FORMAT_MOD_LINEAR,
> + DRM_FORMAT_MOD_INVALID
> + };
>  
>   if (!mipi->command)
>   return -EINVAL;
> @@ -406,18 +412,22 @@ int mipi_dbi_init(struct device *dev, struct mipi_dbi 
> *mipi,
>   if (ret)
>   return ret;
>  
> - /* TODO: Maybe add DRM_MODE_CONNECTOR_SPI */
> - ret = tinydrm_display_pipe_init(tdev, pipe_funcs,
> - DRM_MODE_CONNECTOR_VIRTUAL,
> - mipi_dbi_formats,
> - ARRAY_SIZE(mipi_dbi_formats), mode,
> - rotation);
> + drm = tdev->drm;
> +
> + connector = drm_simple_connector_create(drm, 
> DRM_MODE_CONNECTOR_VIRTUAL, mode, rotation);
Line length too long.
This goes for all calls to drm_simple_connector_create() in this patch.

We are loosing the comment:
"TODO: Maybe add DRM_MODE_CONNECTOR_SPI"
On purpose?

> + if (IS_ERR(connector))
> + return PTR_ERR(connector);
> +
> + ret = drm_simple_display_pipe_init(drm, >pipe, pipe_funcs,
> +mipi_dbi_formats, 
> ARRAY_SIZE(mipi_dbi_formats),
> +modifiers, connector);
>   if (ret)
>   return ret;
>  
>   drm_plane_enable_fb_damage_clips(>pipe.plane);
>  
> - tdev->drm->mode_config.preferred_depth = 16;
> + drm_simple_connector_set_mode_config(connector);
> + drm->mode_config.preferred_depth = 16;
>   mipi->rotation = rotation;
>  
>   drm_mode_config_reset(tdev->drm);
> diff --git a/drivers/gpu/drm/tinydrm/repaper.c 
> b/drivers/gpu/drm/tinydrm/repaper.c
> index 72d30151ecd8..1d551744cc9b 100644
> --- a/drivers/gpu/drm/tinydrm/repaper.c
> +++ b/drivers/gpu/drm/tinydrm/repaper.c
> @@ -924,12 +924,14 @@ static int repaper_probe(struct spi_device *spi)
>   const struct drm_display_mode *mode;
>   const struct spi_device_id *spi_id;
>   const struct of_device_id *match;
> + struct drm_connector *connector;
>   struct device *dev = >dev;
>   struct tinydrm_device *tdev;
>   enum repaper_model model;
>   const char *thermal_zone;
>   struct repaper_epd *epd;
>   size_t line_buffer_size;
> + struct drm_device *drm;
>   int ret;
>  
>   match = of_match_device(repaper_of_match, dev);
> @@ -1069,13 +1071,19 @@ static int repaper_probe(struct spi_device *spi)
>   if (ret)
>   return ret;
>  
> - ret = tinydrm_display_pipe_init(tdev, _pipe_funcs,
> - DRM_MODE_CONNECTOR_VIRTUAL,
> - repaper_formats,
> - ARRAY_SIZE(repaper_formats), mode, 0);
> + drm = tdev->drm;
> +
> + connector = drm_simple_connector_create(drm, 
> DRM_MODE_CONNECTOR_VIRTUAL, mode, 0);
> + if (IS_ERR(connector))
> + return PTR_ERR(connector);
> +
> + ret = drm_simple_display_pipe_init(drm, >pipe, 
> _pipe_funcs,
> +repaper_formats, 
> ARRAY_SIZE(repaper_formats),
> +NULL, connector);
In mipi-dbi modifiers are specified, like done in tiny-core.
But this, and the other drivers, do not specify any modifiers.

Any specific reason why it is needed in one place but not the others?
Note: I do not really know the purpose, and the comment is alone triggered
because there was a difference 

Re: [PATCH 01/11] drm: Add devm_drm_dev_init/register

2019-01-20 Thread Sam Ravnborg
Hi Noralf.

On Sun, Jan 20, 2019 at 12:43:08PM +0100, Noralf Trønnes wrote:
> This adds resource managed (devres) versions of drm_dev_init() and
> drm_dev_register().
> 
> Also added is devm_drm_dev_register_with_fbdev() which sets up generic
> fbdev emulation as well.
> 
> devm_drm_dev_register() isn't exported since there are no users.
Is it relevant to use it outside this patchset - then it should be
documented/exported now to enable use.

> 
> Signed-off-by: Noralf Trønnes 
> ---
>  Documentation/driver-model/devres.txt |   4 +
>  drivers/gpu/drm/drm_drv.c | 106 ++
>  include/drm/drm_drv.h |   6 ++
>  3 files changed, 116 insertions(+)
> 
> diff --git a/Documentation/driver-model/devres.txt 
> b/Documentation/driver-model/devres.txt
> index b277cafce71e..6eebc28d4c21 100644
> --- a/Documentation/driver-model/devres.txt
> +++ b/Documentation/driver-model/devres.txt
> @@ -254,6 +254,10 @@ DMA
>dmam_pool_create()
>dmam_pool_destroy()
>  
> +DRM
> +  devm_drm_dev_init()
> +  devm_drm_dev_register_with_fbdev()
> +
>  GPIO
>devm_gpiod_get()
>devm_gpiod_get_index()
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 381581b01d48..12129772be45 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -36,6 +36,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include "drm_crtc_internal.h"
> @@ -871,6 +872,111 @@ void drm_dev_unregister(struct drm_device *dev)
>  }
>  EXPORT_SYMBOL(drm_dev_unregister);
>  
> +static void devm_drm_dev_init_release(void *data)
> +{
> + drm_dev_put(data);
> +}
> +
> +/**
> + * devm_drm_dev_init - Resource managed drm_dev_init()
> + * @parent: Parent device object
> + * @dev: DRM device
> + * @driver: DRM driver
> + *
> + * Managed drm_dev_init(). The DRM device initialized with this function is
> + * automatically released on driver detach. You must supply a
> + * _driver.release callback to control the finalization explicitly.
> + *
> + * Note: This function must be used together with
> + * devm_drm_dev_register_with_fbdev().
*must* be used, or can be used?
Reading the code this looks like something drivers that do not offer
fbdev emulation could also benefit from.

With the two comments processed this has:
Reviewed-by: Sam Ravnborg 

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 97055] Black screens on A10-8780P (Carrizo) + R7 M260/M265 (Topaz) Combo

2019-01-20 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97055

--- Comment #22 from Jack Ponting  ---
Read carefully entire description of this bug in which you followed another bug
solutions and end up with few observation related to your issues in operating
HP Pavilion 17-g133cl with A10 Carrizo+Topaz.

Jack,
http://www.qualitydissertation.co.uk/

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] vgacon: unconfuse vc_origin when using soft scrollback

2019-01-20 Thread Nicolas Pitre
When CONFIG_VGACON_SOFT_SCROLLBACK is selected, the VGA display memory
index and vc_visible_origin don't change when scrollback is activated.
The actual screen content is saved away and the scrollbackdata is copied
over it. However the vt code, and /dev/vcs devices in particular, still
expect vc_origin to always point at the actual screen content not the
displayed scrollback content.

So adjust vc_origin to point at the saved screen content when scrollback
is active and set it back to vc_visible_origin when restoring the screen.

This fixes /dev/vcsa that return scrollback content when they
shouldn't (onli /dev/vcsa without a number should), and also fixes
/dev/vcsu that should return scrollback content when scrollback is
active but currently doesn't.

An unnecessary call to vga_set_mem_top() is also removed.

Signed-off-by: Nicolas Pitre 
Cc: sta...@vger.kernel.org # v4.19+

---

I tagged it for stable starting with v4.19 as this is the kernel that
introduced /dev/vcsu* which is directly affected. Users of earlier kernels
most likely won't care.

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 09731b2f68..c6b3bdbbdb 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -271,6 +271,7 @@ static void vgacon_scrollback_update(struct vc_data *c, int 
t, int count)
 
 static void vgacon_restore_screen(struct vc_data *c)
 {
+   c->vc_origin = c->vc_visible_origin;
vgacon_scrollback_cur->save = 0;
 
if (!vga_is_gfx && !vgacon_scrollback_cur->restore) {
@@ -287,8 +288,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
int start, end, count, soff;
 
if (!lines) {
-   c->vc_visible_origin = c->vc_origin;
-   vga_set_mem_top(c);
+   vgacon_restore_screen(c);
return;
}
 
@@ -298,6 +298,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
if (!vgacon_scrollback_cur->save) {
vgacon_cursor(c, CM_ERASE);
vgacon_save_screen(c);
+   c->vc_origin = (unsigned long)c->vc_screenbuf;
vgacon_scrollback_cur->save = 1;
}
 
@@ -335,7 +336,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
int copysize;
 
int diff = c->vc_rows - count;
-   void *d = (void *) c->vc_origin;
+   void *d = (void *) c->vc_visible_origin;
void *s = (void *) c->vc_screenbuf;
 
count *= c->vc_size_row;
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v8] arm64: dts: sdm845: Add gpu and gmu device nodes

2019-01-20 Thread kbuild test robot
Hi Jordan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v5.0-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jordan-Crouse/arm64-dts-sdm845-Add-gpu-and-gmu-device-nodes/20190118-051651
config: arm64-allyesconfig
compiler: aarch64-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
GCC_VERSION=8.2.0 make.cross ARCH=arm64  allyesconfig
GCC_VERSION=8.2.0 make.cross ARCH=arm64 

All errors (new ones prefixed by >>):

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 07/11] drm/tinydrm/repaper: Use devm_drm_dev_*()

2019-01-20 Thread Sam Ravnborg
On Sun, Jan 20, 2019 at 11:22:36PM +0100, Sam Ravnborg wrote:
> Hi Noralf.
> 
> On Sun, Jan 20, 2019 at 12:43:14PM +0100, Noralf Trønnes wrote:
> > Use devm_drm_dev_init(), devm_drm_dev_register_with_fbdev() and drop
> > using tinydrm_device.
> > 
> > Signed-off-by: Noralf Trønnes 
> > ---
> >  drivers/gpu/drm/tinydrm/repaper.c | 63 ---
> >  1 file changed, 40 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/tinydrm/repaper.c 
> > b/drivers/gpu/drm/tinydrm/repaper.c
> > index 3141241ca8f0..4c8205565668 100644
> > --- a/drivers/gpu/drm/tinydrm/repaper.c
> > +++ b/drivers/gpu/drm/tinydrm/repaper.c
> > @@ -34,7 +34,7 @@
> >  #include 
> >  #include 
> >  #include 
> > -#include 
> > +#include 
> >  #include 
> >  
> >  #define REPAPER_RID_G2_COG_ID  0x12
> > @@ -60,7 +60,8 @@ enum repaper_epd_border_byte {
> >  };
> >  
> >  struct repaper_epd {
> > -   struct tinydrm_device tinydrm;
> > +   struct drm_device base;
> > +   struct drm_simple_display_pipe pipe;
> > struct spi_device *spi;
> >  
> > struct gpio_desc *panel_on;
> > @@ -89,10 +90,9 @@ struct repaper_epd {
> > bool partial;
> >  };
> >  
> > -static inline struct repaper_epd *
> > -epd_from_tinydrm(struct tinydrm_device *tdev)
> > +static inline struct repaper_epd *drm_to_epd(struct drm_device *drm)
> >  {
> > -   return container_of(tdev, struct repaper_epd, tinydrm);
> > +   return container_of(drm, struct repaper_epd, base);
> >  }
> >  
> >  static int repaper_spi_transfer(struct spi_device *spi, u8 header,
> > @@ -530,8 +530,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb)
> >  {
> > struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
> > struct dma_buf_attachment *import_attach = cma_obj->base.import_attach;
> > -   struct tinydrm_device *tdev = fb->dev->dev_private;
> > -   struct repaper_epd *epd = epd_from_tinydrm(tdev);
> > +   struct repaper_epd *epd = drm_to_epd(fb->dev);
> > struct drm_rect clip;
> > u8 *buf = NULL;
> > int ret = 0;
> > @@ -646,8 +645,7 @@ static void repaper_pipe_enable(struct 
> > drm_simple_display_pipe *pipe,
> > struct drm_crtc_state *crtc_state,
> > struct drm_plane_state *plane_state)
> >  {
> > -   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
> > -   struct repaper_epd *epd = epd_from_tinydrm(tdev);
> > +   struct repaper_epd *epd = drm_to_epd(pipe->crtc.dev);
> > struct spi_device *spi = epd->spi;
> > struct device *dev = >dev;
> > bool dc_ok = false;
> > @@ -781,8 +779,7 @@ static void repaper_pipe_enable(struct 
> > drm_simple_display_pipe *pipe,
> >  
> >  static void repaper_pipe_disable(struct drm_simple_display_pipe *pipe)
> >  {
> > -   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
> > -   struct repaper_epd *epd = epd_from_tinydrm(tdev);
> > +   struct repaper_epd *epd = drm_to_epd(pipe->crtc.dev);
> > struct spi_device *spi = epd->spi;
> > unsigned int line;
> >  
> > @@ -856,6 +853,23 @@ static const struct drm_simple_display_pipe_funcs 
> > repaper_pipe_funcs = {
> > .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
> >  };
> >  
> > +static const struct drm_mode_config_funcs repaper_mode_config_funcs = {
> > +   .fb_create = drm_gem_fb_create_with_dirty,
> > +   .atomic_check = drm_atomic_helper_check,
> > +   .atomic_commit = drm_atomic_helper_commit,
> > +};
> > +
> > +static void repaper_release(struct drm_device *drm)
> > +{
> > +   struct repaper_epd *epd = drm_to_epd(drm);
> > +
> > +   DRM_DEBUG_DRIVER("\n");
> > +
> > +   drm_mode_config_cleanup(drm);
> > +   drm_dev_fini(drm);
> > +   kfree(epd);
> > +}
> > +
> >  static const uint32_t repaper_formats[] = {
> > DRM_FORMAT_XRGB,
> >  };
> > @@ -894,6 +908,7 @@ static struct drm_driver repaper_driver = {
> > .driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
> >   DRIVER_ATOMIC,
> > .fops   = _fops,
> > +   .release= repaper_release,
> > DRM_GEM_CMA_VMAP_DRIVER_OPS,
> > .name   = "repaper",
> > .desc   = "Pervasive Displays RePaper e-ink panels",
> > @@ -927,7 +942,6 @@ static int repaper_probe(struct spi_device *spi)
> > const struct of_device_id *match;
> > struct drm_connector *connector;
> > struct device *dev = >dev;
> > -   struct tinydrm_device *tdev;
> > enum repaper_model model;
> > const char *thermal_zone;
> > struct repaper_epd *epd;
> > @@ -952,10 +966,20 @@ static int repaper_probe(struct spi_device *spi)
> > }
> > }
> >  
> > -   epd = devm_kzalloc(dev, sizeof(*epd), GFP_KERNEL);
> > +   epd = kzalloc(sizeof(*epd), GFP_KERNEL);
> > if (!epd)
> > return -ENOMEM;
> >  
> > +   drm = >base;
> > +   ret = devm_drm_dev_init(dev, drm, _driver);
> > +   if (ret) {
> > +   kfree(epd);
> > +   return ret;
> > +   }
> 

Re: [PATCH 07/11] drm/tinydrm/repaper: Use devm_drm_dev_*()

2019-01-20 Thread Sam Ravnborg
Hi Noralf.

On Sun, Jan 20, 2019 at 12:43:14PM +0100, Noralf Trønnes wrote:
> Use devm_drm_dev_init(), devm_drm_dev_register_with_fbdev() and drop
> using tinydrm_device.
> 
> Signed-off-by: Noralf Trønnes 
> ---
>  drivers/gpu/drm/tinydrm/repaper.c | 63 ---
>  1 file changed, 40 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tinydrm/repaper.c 
> b/drivers/gpu/drm/tinydrm/repaper.c
> index 3141241ca8f0..4c8205565668 100644
> --- a/drivers/gpu/drm/tinydrm/repaper.c
> +++ b/drivers/gpu/drm/tinydrm/repaper.c
> @@ -34,7 +34,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  
>  #define REPAPER_RID_G2_COG_ID0x12
> @@ -60,7 +60,8 @@ enum repaper_epd_border_byte {
>  };
>  
>  struct repaper_epd {
> - struct tinydrm_device tinydrm;
> + struct drm_device base;
> + struct drm_simple_display_pipe pipe;
>   struct spi_device *spi;
>  
>   struct gpio_desc *panel_on;
> @@ -89,10 +90,9 @@ struct repaper_epd {
>   bool partial;
>  };
>  
> -static inline struct repaper_epd *
> -epd_from_tinydrm(struct tinydrm_device *tdev)
> +static inline struct repaper_epd *drm_to_epd(struct drm_device *drm)
>  {
> - return container_of(tdev, struct repaper_epd, tinydrm);
> + return container_of(drm, struct repaper_epd, base);
>  }
>  
>  static int repaper_spi_transfer(struct spi_device *spi, u8 header,
> @@ -530,8 +530,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb)
>  {
>   struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
>   struct dma_buf_attachment *import_attach = cma_obj->base.import_attach;
> - struct tinydrm_device *tdev = fb->dev->dev_private;
> - struct repaper_epd *epd = epd_from_tinydrm(tdev);
> + struct repaper_epd *epd = drm_to_epd(fb->dev);
>   struct drm_rect clip;
>   u8 *buf = NULL;
>   int ret = 0;
> @@ -646,8 +645,7 @@ static void repaper_pipe_enable(struct 
> drm_simple_display_pipe *pipe,
>   struct drm_crtc_state *crtc_state,
>   struct drm_plane_state *plane_state)
>  {
> - struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
> - struct repaper_epd *epd = epd_from_tinydrm(tdev);
> + struct repaper_epd *epd = drm_to_epd(pipe->crtc.dev);
>   struct spi_device *spi = epd->spi;
>   struct device *dev = >dev;
>   bool dc_ok = false;
> @@ -781,8 +779,7 @@ static void repaper_pipe_enable(struct 
> drm_simple_display_pipe *pipe,
>  
>  static void repaper_pipe_disable(struct drm_simple_display_pipe *pipe)
>  {
> - struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
> - struct repaper_epd *epd = epd_from_tinydrm(tdev);
> + struct repaper_epd *epd = drm_to_epd(pipe->crtc.dev);
>   struct spi_device *spi = epd->spi;
>   unsigned int line;
>  
> @@ -856,6 +853,23 @@ static const struct drm_simple_display_pipe_funcs 
> repaper_pipe_funcs = {
>   .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
>  };
>  
> +static const struct drm_mode_config_funcs repaper_mode_config_funcs = {
> + .fb_create = drm_gem_fb_create_with_dirty,
> + .atomic_check = drm_atomic_helper_check,
> + .atomic_commit = drm_atomic_helper_commit,
> +};
> +
> +static void repaper_release(struct drm_device *drm)
> +{
> + struct repaper_epd *epd = drm_to_epd(drm);
> +
> + DRM_DEBUG_DRIVER("\n");
> +
> + drm_mode_config_cleanup(drm);
> + drm_dev_fini(drm);
> + kfree(epd);
> +}
> +
>  static const uint32_t repaper_formats[] = {
>   DRM_FORMAT_XRGB,
>  };
> @@ -894,6 +908,7 @@ static struct drm_driver repaper_driver = {
>   .driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
> DRIVER_ATOMIC,
>   .fops   = _fops,
> + .release= repaper_release,
>   DRM_GEM_CMA_VMAP_DRIVER_OPS,
>   .name   = "repaper",
>   .desc   = "Pervasive Displays RePaper e-ink panels",
> @@ -927,7 +942,6 @@ static int repaper_probe(struct spi_device *spi)
>   const struct of_device_id *match;
>   struct drm_connector *connector;
>   struct device *dev = >dev;
> - struct tinydrm_device *tdev;
>   enum repaper_model model;
>   const char *thermal_zone;
>   struct repaper_epd *epd;
> @@ -952,10 +966,20 @@ static int repaper_probe(struct spi_device *spi)
>   }
>   }
>  
> - epd = devm_kzalloc(dev, sizeof(*epd), GFP_KERNEL);
> + epd = kzalloc(sizeof(*epd), GFP_KERNEL);
>   if (!epd)
>   return -ENOMEM;
>  
> + drm = >base;
> + ret = devm_drm_dev_init(dev, drm, _driver);
> + if (ret) {
> + kfree(epd);
> + return ret;
> + }
Here you go to the trouble and free epd on error.

> +
> + drm_mode_config_init(drm);
> + drm->mode_config.funcs = _mode_config_funcs;
> +
>   epd->spi = spi;
>  
>   epd->panel_on = 

Re: [PATCH 03/11] drm/simple-kms-helper: Add drm_simple_connector_create()

2019-01-20 Thread Sam Ravnborg
Hi Noralf.

On Sun, Jan 20, 2019 at 12:43:10PM +0100, Noralf Trønnes wrote:
> This adds a function that creates a simple connector that has only one
> static mode. Additionally add a helper to set _mode_config width
> and height from the static mode.
> 
> Signed-off-by: Noralf Trønnes 
> ---
>  drivers/gpu/drm/drm_simple_kms_helper.c | 122 
>  include/drm/drm_simple_kms_helper.h |   6 ++
>  2 files changed, 128 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c 
> b/drivers/gpu/drm/drm_simple_kms_helper.c
> index 917812448d1b..ca29975afefe 100644
> --- a/drivers/gpu/drm/drm_simple_kms_helper.c
> +++ b/drivers/gpu/drm/drm_simple_kms_helper.c
> @@ -11,6 +11,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -299,4 +301,124 @@ int drm_simple_display_pipe_init(struct drm_device *dev,
>  }
>  EXPORT_SYMBOL(drm_simple_display_pipe_init);
>  
> +static const struct drm_connector_helper_funcs drm_simple_connector_hfuncs = 
> {
> + /* dummy for the atomic helper */
> +};
> +
> +static int drm_simple_connector_fill_modes(struct drm_connector *connector,
> +uint32_t maxX, uint32_t maxY)
> +{
> + return 1;
> +}
> +
> +static void drm_simple_connector_destroy(struct drm_connector *connector)
> +{
> + drm_connector_cleanup(connector);
> + kfree(connector);
> +}
> +
> +static const struct drm_connector_funcs drm_simple_connector_funcs = {
> + .reset = drm_atomic_helper_connector_reset,
> + .fill_modes = drm_simple_connector_fill_modes,
> + .destroy = drm_simple_connector_destroy,
> + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> +};
> +
> +/**
> + * drm_simple_connector_create - Create a connector with one static mode
> + * @dev: DRM device
> + * @connector_type: Connector type
> + * @mode: Supported display mode
> + * @rotation: Initial @mode rotation in degrees
Maybe extend the documentation to list valid values?
Have you considered to use the DRM_MODE_ROTATE_XXX constants here?
Current tinydrm do not use these and they may not be applicable...

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 201815] Mouse Pointer Disappears when touching top of the screen

2019-01-20 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=201815

--- Comment #13 from siyia (eutychio...@gmail.com) ---
regression is still present at linux 4.20.3

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 109162] Bugs Bunny: Lost in Time

2019-01-20 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=109162

smoki  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WORKSFORME

--- Comment #12 from smoki  ---

 OK, self variabled only in Mesa... closing then as worksforme.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 02/11] drm/modes: Add DRM_SIMPLE_MODE()

2019-01-20 Thread Noralf Trønnes


Den 20.01.2019 17.37, skrev Ilia Mirkin:
> You don't appear to set the mm in the new macro. Not sure if it's on
> purpose.
> 

Not intentional, that was a slip. I copied the DRM_MODE macro and forgot
about setting the size.

Thanks,
Noralf.

> On Sun, Jan 20, 2019, 06:43 Noralf Trønnes   wrote:
> 
> This adds a helper macro to specify modes that only contain info about
> resolution.
> 
> Signed-off-by: Noralf Trønnes  >
> ---
>  drivers/gpu/drm/tinydrm/hx8357d.c  |  2 +-
>  drivers/gpu/drm/tinydrm/ili9225.c  |  2 +-
>  drivers/gpu/drm/tinydrm/ili9341.c  |  2 +-
>  drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
>  drivers/gpu/drm/tinydrm/repaper.c  |  8 
>  drivers/gpu/drm/tinydrm/st7586.c   |  2 +-
>  drivers/gpu/drm/tinydrm/st7735r.c  |  2 +-
>  include/drm/drm_modes.h            | 16 
>  include/drm/tinydrm/tinydrm.h      | 23 ---
>  9 files changed, 26 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c
> b/drivers/gpu/drm/tinydrm/hx8357d.c
> index 8bbd0beafc6a..5a1ec0451c19 100644
> --- a/drivers/gpu/drm/tinydrm/hx8357d.c
> +++ b/drivers/gpu/drm/tinydrm/hx8357d.c
> @@ -181,7 +181,7 @@ static const struct
> drm_simple_display_pipe_funcs hx8357d_pipe_funcs = {
>  };
> 
>  static const struct drm_display_mode yx350hv15_mode = {
> -       TINYDRM_MODE(320, 480, 60, 75),
> +       DRM_SIMPLE_MODE(320, 480, 60, 75),
>  };
> 
>  DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
> diff --git a/drivers/gpu/drm/tinydrm/ili9225.c
> b/drivers/gpu/drm/tinydrm/ili9225.c
> index 43a3b68d90a2..d40814d370e2 100644
> --- a/drivers/gpu/drm/tinydrm/ili9225.c
> +++ b/drivers/gpu/drm/tinydrm/ili9225.c
> @@ -332,7 +332,7 @@ static const struct
> drm_simple_display_pipe_funcs ili9225_pipe_funcs = {
>  };
> 
>  static const struct drm_display_mode ili9225_mode = {
> -       TINYDRM_MODE(176, 220, 35, 44),
> +       DRM_SIMPLE_MODE(176, 220, 35, 44),
>  };
> 
>  DEFINE_DRM_GEM_CMA_FOPS(ili9225_fops);
> diff --git a/drivers/gpu/drm/tinydrm/ili9341.c
> b/drivers/gpu/drm/tinydrm/ili9341.c
> index 713bb2dd7e04..063f4f07f811 100644
> --- a/drivers/gpu/drm/tinydrm/ili9341.c
> +++ b/drivers/gpu/drm/tinydrm/ili9341.c
> @@ -137,7 +137,7 @@ static const struct
> drm_simple_display_pipe_funcs ili9341_pipe_funcs = {
>  };
> 
>  static const struct drm_display_mode yx240qv29_mode = {
> -       TINYDRM_MODE(240, 320, 37, 49),
> +       DRM_SIMPLE_MODE(240, 320, 37, 49),
>  };
> 
>  DEFINE_DRM_GEM_CMA_FOPS(ili9341_fops);
> diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c
> b/drivers/gpu/drm/tinydrm/mi0283qt.c
> index 82a92ec9ae3c..3d067c2ba1bc 100644
> --- a/drivers/gpu/drm/tinydrm/mi0283qt.c
> +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
> @@ -145,7 +145,7 @@ static const struct
> drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = {
>  };
> 
>  static const struct drm_display_mode mi0283qt_mode = {
> -       TINYDRM_MODE(320, 240, 58, 43),
> +       DRM_SIMPLE_MODE(320, 240, 58, 43),
>  };
> 
>  DEFINE_DRM_GEM_CMA_FOPS(mi0283qt_fops);
> diff --git a/drivers/gpu/drm/tinydrm/repaper.c
> b/drivers/gpu/drm/tinydrm/repaper.c
> index b037c6540cf3..72d30151ecd8 100644
> --- a/drivers/gpu/drm/tinydrm/repaper.c
> +++ b/drivers/gpu/drm/tinydrm/repaper.c
> @@ -860,28 +860,28 @@ static const uint32_t repaper_formats[] = {
>  };
> 
>  static const struct drm_display_mode repaper_e1144cs021_mode = {
> -       TINYDRM_MODE(128, 96, 29, 22),
> +       DRM_SIMPLE_MODE(128, 96, 29, 22),
>  };
> 
>  static const u8 repaper_e1144cs021_cs[] = { 0x00, 0x00, 0x00, 0x00,
>                                             0x00, 0x0f, 0xff, 0x00 };
> 
>  static const struct drm_display_mode repaper_e1190cs021_mode = {
> -       TINYDRM_MODE(144, 128, 36, 32),
> +       DRM_SIMPLE_MODE(144, 128, 36, 32),
>  };
> 
>  static const u8 repaper_e1190cs021_cs[] = { 0x00, 0x00, 0x00, 0x03,
>                                             0xfc, 0x00, 0x00, 0xff };
> 
>  static const struct drm_display_mode repaper_e2200cs021_mode = {
> -       TINYDRM_MODE(200, 96, 46, 22),
> +       DRM_SIMPLE_MODE(200, 96, 46, 22),
>  };
> 
>  static const u8 repaper_e2200cs021_cs[] = { 0x00, 0x00, 0x00, 0x00,
>                                             0x01, 0xff, 0xe0, 0x00 };
> 
>  static const struct drm_display_mode repaper_e2271cs021_mode = {
> -       TINYDRM_MODE(264, 176, 57, 38),
> +       DRM_SIMPLE_MODE(264, 176, 57, 38),
>  };
> 
>  static const u8 repaper_e2271cs021_cs[] = { 0x00, 0x00, 0x00, 0x7f,
> diff --git a/drivers/gpu/drm/tinydrm/st7586.c
> b/drivers/gpu/drm/tinydrm/st7586.c
> 

[PATCH v1 1/1] drm: fix drm_can_sleep() comment

2019-01-20 Thread Sam Ravnborg
Reversed logic when writing the original comment, now fixed.

Fixes: e9eafcb58921 ("drm: move drm_can_sleep() to drm_util.h")
Reported-by: Laurent Pinchart 
Signed-off-by: Sam Ravnborg 
Cc: Laurent Pinchart 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: Sean Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
---
 include/drm/drm_util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/drm/drm_util.h b/include/drm/drm_util.h
index 8163d35f8327..07b8e9f04599 100644
--- a/include/drm/drm_util.h
+++ b/include/drm/drm_util.h
@@ -71,7 +71,7 @@
  * FIXME: All users of drm_can_sleep should be removed (see todo.rst)
  *
  * Returns:
- * True if kgdb is active or we are in an atomic context or irqs are disabled
+ * False if kgdb is active, we are in atomic context or irqs are disabled.
  */
 static inline bool drm_can_sleep(void)
 {
-- 
2.12.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] video/hdmi: Change strncpy() into memcpy() in hdmi_spd_infoframe_init

2019-01-20 Thread Mathieu Malaterre
On Fri, Jan 18, 2019 at 8:51 PM Joe Perches  wrote:
>
> On Fri, 2019-01-18 at 20:32 +0100, Mathieu Malaterre wrote:
> > Using strncpy() is less than perfect since the destination buffers do not
> > need to be NUL terminated. Replace strncpy() with memcpy() to address a
> > warning triggered by gcc using W=1 and optimize the code a bit.
> >
> > This commit removes the following warnings:
> >
> >   drivers/video/hdmi.c:234:2: warning: 'strncpy' specified bound 8 equals 
> > destination size [-Wstringop-truncation]
> >   drivers/video/hdmi.c:235:2: warning: 'strncpy' specified bound 16 equals 
> > destination size [-Wstringop-truncation]
> []
> > diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
> []
> > @@ -231,8 +231,8 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe 
> > *frame,
> >   frame->version = 1;
> >   frame->length = HDMI_SPD_INFOFRAME_SIZE;
> >
> > - strncpy(frame->vendor, vendor, sizeof(frame->vendor));
> > - strncpy(frame->product, product, sizeof(frame->product));
> > + memcpy(frame->vendor, vendor, sizeof(frame->vendor));
> > + memcpy(frame->product, product, sizeof(frame->product));
>
> This is not good.
>
> vendor can be any location and shorter than sizeof(frame->vendor)
> so this can copy from invalid memory locations.

Ah right. I did not realize that and know I see the call with "Intel",
will re-spin.

> You probably want strscpy.

Right.

> This is called with at least "mediatek" and "broadcom", so perhaps
> it's better still to change the struct vendor size to something a
> bit larger.  Maybe change vendor[8] to vendor[16];

Looks like 8 bytes is required for call like hdmi_spd_infoframe_unpack()

> include/linux/hdmi.h:struct hdmi_spd_infoframe {
> include/linux/hdmi.h-   enum hdmi_infoframe_type type;
> include/linux/hdmi.h-   unsigned char version;
> include/linux/hdmi.h-   unsigned char length;
> include/linux/hdmi.h-   char vendor[8];
> include/linux/hdmi.h-   char product[16];
> include/linux/hdmi.h-   enum hdmi_spd_sdi sdi;
> include/linux/hdmi.h-};
>
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-20 Thread Liam Mark
On Fri, 18 Jan 2019, Laura Abbott wrote:

> On 1/18/19 10:37 AM, Liam Mark wrote:
> > Add support for configuring dma mapping attributes when mapping
> > and unmapping memory through dma_buf_map_attachment and
> > dma_buf_unmap_attachment.
> > 
> > Signed-off-by: Liam Mark 
> > ---
> >   include/linux/dma-buf.h | 3 +++
> >   1 file changed, 3 insertions(+)
> > 
> > diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> > index 58725f890b5b..59bf33e09e2d 100644
> > --- a/include/linux/dma-buf.h
> > +++ b/include/linux/dma-buf.h
> > @@ -308,6 +308,8 @@ struct dma_buf {
> >* @dev: device attached to the buffer.
> >* @node: list of dma_buf_attachment.
> >* @priv: exporter specific attachment data.
> > + * @dma_map_attrs: DMA mapping attributes to be used in
> > + *dma_buf_map_attachment() and dma_buf_unmap_attachment().
> >*
> >* This structure holds the attachment information between the dma_buf
> > buffer
> >* and its user device(s). The list contains one attachment struct per
> > device
> > @@ -323,6 +325,7 @@ struct dma_buf_attachment {
> > struct device *dev;
> > struct list_head node;
> > void *priv;
> > +   unsigned long dma_map_attrs;
> >   };
> > /**
> > 
> 
> Did you miss part of this patch? This only adds it to the structure but
> doesn't
> add it to any API. The same commment applies to the follow up patch,
> I don't quite see how it's being used.
> 

Were you asking for a cleaner DMA-buf API to set this field or were you 
asking for a change to an upstream client to make use of this field?

I have clients set the dma_map_attrs field directly on their
dma_buf_attachment struct before calling dma_buf_map_attachment (if they
need this functionality).
Of course this is all being used in Android for out of tree drivers, but
I assume it is just as useful to everyone else who has cached ION buffers
which aren't always accessed by the CPU.

My understanding is that AOSP Android on Hikey 960 also is currently
suffering from too many CMOs due to dma_map_attachemnt always applying
CMOs, so this support should help them avoid it.

> Thanks,
> Laura
> 

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v6] drm/msm/a6xx: Add support for an interconnect path

2019-01-20 Thread Evan Green
On Fri, Jan 18, 2019 at 12:24 PM Jordan Crouse  wrote:
>
> Try to get the interconnect path for the GPU and vote for the maximum
> bandwidth to support all frequencies. This is needed for performance.
> Later we will want to scale the bandwidth based on the frequency to
> also optimize for power but that will require some device tree
> infrastructure that does not yet exist.
>
> v6: use icc_set_bw() instead of icc_set()
> v5: Remove hardcoded interconnect name and just use the default
> v4: Don't use a port string at all to skip the need for names in the DT
> v3: Use macros and change port string per Georgi Djakov
>
> Signed-off-by: Jordan Crouse 
> ---
>
>  drivers/gpu/drm/msm/Kconfig |  1 +
>  drivers/gpu/drm/msm/adreno/a6xx_gmu.c   | 20 
>  drivers/gpu/drm/msm/adreno/adreno_gpu.c |  9 +
>  drivers/gpu/drm/msm/msm_gpu.h   |  3 +++
>  4 files changed, 33 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
> index cf549f1..78c9e5a5 100644
> --- a/drivers/gpu/drm/msm/Kconfig
> +++ b/drivers/gpu/drm/msm/Kconfig
> @@ -5,6 +5,7 @@ config DRM_MSM
> depends on ARCH_QCOM || SOC_IMX5 || (ARM && COMPILE_TEST)
> depends on OF && COMMON_CLK
> depends on MMU
> +   depends on INTERCONNECT || !INTERCONNECT
> select QCOM_MDT_LOADER if ARCH_QCOM
> select REGULATOR
> select DRM_KMS_HELPER
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
> b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 5beb83d..c48fe46 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -2,6 +2,7 @@
>  /* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. */
>
>  #include 
> +#include 
>  #include 
>  #include 
>
> @@ -84,6 +85,9 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu)
>
>  static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
>  {
> +   struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
> +   struct adreno_gpu *adreno_gpu = _gpu->base;
> +   struct msm_gpu *gpu = _gpu->base;
> int ret;
>
> gmu_write(gmu, REG_A6XX_GMU_DCVS_ACK_OPTION, 0);
> @@ -106,6 +110,12 @@ static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, 
> int index)
> dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
>
> gmu->freq = gmu->gpu_freqs[index];
> +
> +   /*
> +* Eventually we will want to scale the path vote with the frequency 
> but
> +* for now leave it at max so that the performance is nominal.
> +*/
> +   icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
>  }
>
>  void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq)
> @@ -705,6 +715,8 @@ int a6xx_gmu_reset(struct a6xx_gpu *a6xx_gpu)
>
>  int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
>  {
> +   struct adreno_gpu *adreno_gpu = _gpu->base;
> +   struct msm_gpu *gpu = _gpu->base;
> struct a6xx_gmu *gmu = _gpu->gmu;
> int status, ret;
>
> @@ -720,6 +732,9 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
> if (ret)
> goto out;
>
> +   /* Set the bus quota to a reasonable value for boot */
> +   icc_set_bw(gpu->icc_path, 0, MBps_to_icc(3072));

Does the comment mention boot because this resume call happens during
init? How come this number is different from the one in
__a6xx_gmu_set_freq? Also, you're setting an average bandwidth of 0, I
guess you don't know really what your average is, and the hardware is
fine with that setting. Is that true?
-Evan
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Aw: [PATCH 2/2] drm/mediatek: Add Mediatek framebuffer device

2019-01-20 Thread Matthias Brugger


On 18/01/2019 02:46, CK Hu wrote:
> Hi, Frank:
> 
> On Thu, 2019-01-17 at 15:14 +0100, Frank Wunderlich wrote:
>> Hi,
>>
>> this Patchset does not hang on Bananapi R2, but does not show anything on 
>> FB-Console...seems anything is missing
>>
>> https://github.com/frank-w/BPI-R2-4.14/tree/4.20-fbdev
>>
>> dmesg | grep 'fb\|framebuffer'
>> [0.00] Linux version 4.20.0-rc7-bpi-r2-fbdev (frank@frank-N56VZ) 
>> (gcc version 7.3.0 (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04)) 9
>> [0.00] cma: Reserved 64 MiB at 0xfb80
>> [0.00] Kernel command line: board=bpi-r2 console=earlyprintk 
>> console=tty1 fbcon=map:0 console=ttyS0,115200 root=/dev/mmcblk7
>> [5.733185] [drm:drm_fb_helper_generic_probe] surface width(1280), 
>> height(1024) and bpp(32)
>> [5.754452] [drm:drm_mode_addfb2] [FB:44]
>> [5.792878] mediatek-drm 1400.dispsys: fb0: DRM emulated frame buffer 
>> device
>> [5.814067] [drm:drm_fb_helper_hotplug_event.part.11] 
>> [6.203083] mediatek-drm 1400.dispsys: [drm:drm_client_dev_hotplug] 
>> fbdev: ret=0
>> [   24.930347] mediatek-drm 1400.dispsys: [drm:drm_client_dev_restore] 
>> fbdev: ret=0
>> [   25.196872] mediatek-drm 1400.dispsys: [drm:drm_client_dev_restore] 
>> fbdev: ret=0
>> [   25.281184] [drm:drm_mode_addfb2] [FB:49]
>> [   27.947962] [drm:drm_mode_addfb2] [FB:49]
> 
> The log does not show any information of error, but it close fbdev at
> the time 24.930347.
> 
> I just test vmap() by writing white color into framebuffer after vmap()
> and use user space program to control fbdev to show this framebuffer and
> the panel shows white screen. So I believe that vmap() and fbdev works
> fine, but I'm not sure what happen to fbcon. I would try to setup fbcon
> to find out the bug. If you could try to debug parallelly, it would be
> much help.
> 

may it be the not yet fixed mmsys compatible problem?
Frank, did you test with my last series [1]?

Regards,
Matthias

[1] https://patchwork.kernel.org/cover/10686345/

> Regards,
> CK
> 
>>
>> regards Frank
>>
>>
>>> Gesendet: Mittwoch, 16. Januar 2019 um 02:39 Uhr
>>> Von: "CK Hu" 
>>> An: "Philipp Zabel" , "David Airlie" 
>>> , "Daniel Vetter" , "Matthias Brugger" 
>>> , "Noralf Tr�nnes" , "Frank 
>>> Wunderlich" 
>>> Cc: dri-devel@lists.freedesktop.org, linux-arm-ker...@lists.infradead.org, 
>>> linux-media...@lists.infradead.org, linux-ker...@vger.kernel.org, 
>>> srv_heupstr...@mediatek.com, "CK Hu" 
>>> Betreff: [PATCH 2/2] drm/mediatek: Add Mediatek framebuffer device
>>>
>>> For Mediatek drm driver, use fbdev emulation to create a framebuffer
>>> device.
>>>
>>> Signed-off-by: CK Hu 
>>> ---
>>>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 +
>>>  1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
>>> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>>> index 6ec4ca070382..5fcc0e294696 100644
>>> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>>> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>>> @@ -16,6 +16,7 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>>  #include 
>>>  #include 
>>>  #include 
>>> @@ -378,6 +379,10 @@ static int mtk_drm_bind(struct device *dev)
>>> if (ret < 0)
>>> goto err_deinit;
>>>  
>>> +   ret = drm_fbdev_generic_setup(drm, 32);
>>> +   if (ret)
>>> +   DRM_ERROR("Failed to initialize fbdev: %d\n", ret);
>>> +
>>> return 0;
>>>  
>>>  err_deinit:
>>> -- 
>>> 2.18.1
>>>
>>>
>>
>> ___
>> Linux-mediatek mailing list
>> linux-media...@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-mediatek
> 
> 
> 
> ___
> Linux-mediatek mailing list
> linux-media...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/bridge: lvds-encoder: remove surplus NULL checks

2019-01-20 Thread Peter Rosin
The gpio API explicitly allows skipping the NULL check, precisely to
allow for neat support for optional gpios. Which is exactly what is at
play here.

Reported-by: Andrzej Hajda 
Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/bridge/lvds-encoder.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bridge/lvds-encoder.c 
b/drivers/gpu/drm/bridge/lvds-encoder.c
index 36d8557bc097..584007eaf6e1 100644
--- a/drivers/gpu/drm/bridge/lvds-encoder.c
+++ b/drivers/gpu/drm/bridge/lvds-encoder.c
@@ -36,8 +36,7 @@ static void lvds_encoder_enable(struct drm_bridge *bridge)
 struct lvds_encoder,
 bridge);
 
-   if (lvds_encoder->powerdown_gpio)
-   gpiod_set_value_cansleep(lvds_encoder->powerdown_gpio, 0);
+   gpiod_set_value_cansleep(lvds_encoder->powerdown_gpio, 0);
 }
 
 static void lvds_encoder_disable(struct drm_bridge *bridge)
@@ -46,8 +45,7 @@ static void lvds_encoder_disable(struct drm_bridge *bridge)
 struct lvds_encoder,
 bridge);
 
-   if (lvds_encoder->powerdown_gpio)
-   gpiod_set_value_cansleep(lvds_encoder->powerdown_gpio, 1);
+   gpiod_set_value_cansleep(lvds_encoder->powerdown_gpio, 1);
 }
 
 static struct drm_bridge_funcs funcs = {
-- 
2.11.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-20 Thread Liam Mark
Add support for configuring dma mapping attributes when mapping
and unmapping memory through dma_buf_map_attachment and
dma_buf_unmap_attachment.

Signed-off-by: Liam Mark 
---
 include/linux/dma-buf.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 58725f890b5b..59bf33e09e2d 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -308,6 +308,8 @@ struct dma_buf {
  * @dev: device attached to the buffer.
  * @node: list of dma_buf_attachment.
  * @priv: exporter specific attachment data.
+ * @dma_map_attrs: DMA mapping attributes to be used in
+ *dma_buf_map_attachment() and dma_buf_unmap_attachment().
  *
  * This structure holds the attachment information between the dma_buf buffer
  * and its user device(s). The list contains one attachment struct per device
@@ -323,6 +325,7 @@ struct dma_buf_attachment {
struct device *dev;
struct list_head node;
void *priv;
+   unsigned long dma_map_attrs;
 };
 
 /**
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/2] drm/omap: panel-tpo-td028ttec1: add backlight support

2019-01-20 Thread Andreas Kemnade
This panel has a backlight, so fetch it from devicetree using the
as documented in panel-common.txt. It is implemented the same way as in
panel-dpi.c
This ensures the backlight is also disabled when the display is
turned off like when doing xset dpms force off.

Signed-off-by: Andreas Kemnade 
---
 .../gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c| 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c 
b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
index 7ddc8c574a61..f326ba9dcf62 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
@@ -35,6 +35,8 @@ struct panel_drv_data {
 
struct videomode vm;
 
+   struct backlight_device *backlight;
+
struct spi_device *spi_dev;
 };
 
@@ -268,6 +270,8 @@ static int td028ttec1_panel_enable(struct omap_dss_device 
*dssdev)
 
r |= jbt_ret_write_0(ddata, JBT_REG_DISPLAY_ON);
 
+   backlight_enable(ddata->backlight);
+
dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
 
 transfer_err:
@@ -283,6 +287,8 @@ static void td028ttec1_panel_disable(struct omap_dss_device 
*dssdev)
if (!omapdss_device_is_enabled(dssdev))
return;
 
+   backlight_disable(ddata->backlight);
+
dev_dbg(dssdev->dev, "td028ttec1_panel_disable()\n");
 
jbt_ret_write_0(ddata, JBT_REG_DISPLAY_OFF);
@@ -321,6 +327,15 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
 
dev_dbg(>dev, "%s\n", __func__);
 
+   ddata = devm_kzalloc(>dev, sizeof(*ddata), GFP_KERNEL);
+   if (ddata == NULL)
+   return -ENOMEM;
+
+   ddata->backlight = devm_of_find_backlight(>dev);
+
+   if (IS_ERR(ddata->backlight))
+   return PTR_ERR(ddata->backlight);
+
spi->bits_per_word = 9;
spi->mode = SPI_MODE_3;
 
@@ -330,9 +345,6 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
return r;
}
 
-   ddata = devm_kzalloc(>dev, sizeof(*ddata), GFP_KERNEL);
-   if (ddata == NULL)
-   return -ENOMEM;
 
dev_set_drvdata(>dev, ddata);
 
-- 
2.11.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [linux-sunxi] Re: HDMI/DVI spurious failure

2019-01-20 Thread Priit Laes
On Thu, Jan 17, 2019 at 12:33:40PM +0100, Maxime Ripard wrote:
> On Wed, Jan 16, 2019 at 08:35:16PM +, Priit Laes wrote:
> > On Wed, Jan 16, 2019 at 08:24:42PM +0100, Maxime Ripard wrote:
> > > Hi Priit,
> > > 
> > > On Wed, Jan 16, 2019 at 07:58:54AM +, Priit Laes wrote:
> > > > > On Mon, Jan 14, 2019 at 01:29:34PM +, Priit Laes wrote:
> > > > > > I have a somewhat curious case with one HDMI/DVI screen that fails
> > > > > > to initialize properly every 6-7 boots. The display itself is also
> > > > > > somewhat flawed (missing HPD pin and the VSYNC/HSYNC pulse width
> > > > > > is set to 0 in EDID), but I suspect there could be some issues
> > > > > > regarding timing in A20 HDMI driver in Linux.
> > > > > > 
> > > > ...
> > > > 
> > > > > It doesn't look related to the clock rate itself, since it doesn't
> > > > > change between the two cases. However, in one case the DDC clock is
> > > > > enabled and in the other it's disabled.
> > > > > 
> > > > > Was it taken at the same time? Maybe you can try with that patch?
> > > > > http://code.bulix.org/z7jmkm-555344?raw
> > > > 
> > > > Thanks, after doing ~50+ boots I haven't seen a single failure.
> > > > 
> > > > Previously I had following failure cases which are now both fixed:
> > > > 
> > > > a) Linux without u-boot HDMI, where one in every 6-7 boots failed.
> > > > b) u--boot with hdmi enabled switching to simplefb and then switching
> > > > to kms, where previously all boots ended up with garbled screen.
> > > 
> > > So it's not really a fix, but it really looks like the clock is not
> > > enabled when it should.
> > > 
> > > Can you describe your test scenario a bit more? What are you doing
> > > exactly, just booting? When do you start using the display? When did
> > > you capture the debugfs output that you pasted?
> > 
> > Display is already connected via HDMI to the board. I don't really
> > remove it, I just boot the device and let it start Xorg.
> > Meanwhile I just ssh into the device and capture debugfs output.
> > See my 3 testing scenarios below.
> > 
> > Kernel also includes one extra patch to fall back to DDC, in case HPD
> > fails. Mostly the same I already submitted last November [1].
> 
> Do you have the same issue without that patch?

Can't really test this display without this patch and I do not have other
HDMI/DVI screens. And this issue does not happen with other HDMI displays
that I have here.

> > For u-boot I have also some extra patches, to detect HPD-less HDMI
> > displays [2] + relax some EDID timing checks [3] so u-boot can actually
> > initialize my screen.
> 
> Do you have the same issues without those patches?

Yes. Without those patches display is not detected by u-boot (issues with
missing hpd pin and stricter edid checks), so kernel initializes display.

Disabling those patches is mostly the same as disabling the HDMI support
in u-boot the kernel side.

> > So first configuration with 100% failures:
> > 1) u-boot initializes HDMI ( A20-OLinuXino-Lime2-eMMC_defconfig )
> > 2) Linux switches to simplefb
> > ... somewhere around here blinking cursor is replaced with garbage
> > on screen 
> > 3) Linux switches to kms
> > 4) Xorg starts
> > 
> > Second scenario with failure every 6-7 boots:
> > 1) Disabled HDMI in u-boot for my board
> > 2) Linux sets up kms (sometimes fails here)
> > 3) Xorg starts
> > 4) ssh to machine and take the clock dump
> 
> Do you have the DRM fbdev emulation enabled in that case or is Xorg
> the first to setup the kms driver? Do you have some logs and a
> configuration?

Xorg logs for scenario 1 and 2 are basically the same whether or not
HDMI is enabled in u-boot. Now, differences arise when DDC clock is
marked as critical. Attached files:
* Xorg.0.ddc-critical.log
* Xorg.0.ddc-default.log

Also attached drm.debug outputs.

> Maxime
> 
> -- 
> Maxime Ripard, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com


Linux with (edid fallback + clk_critical patch)



[12.552] 
X.Org X Server 1.19.2
Release Date: 2017-03-02
[12.553] X Protocol Version 11, Revision 0
[12.553] Build Operating System: Linux 4.9.0-8-armmp-lpae armv7l Debian
[12.553] Current Operating System: Linux xxx-screen 
5.0.0-rc1-00021-g9b31f15d4c57 #76 SMP Fri Jan 18 11:12:40 EET 2019 armv7l
[12.553] Kernel command line: console=ttyS0,115200n8 root=/dev/mmcblk0p1 
rootwait debug
[12.553] Build Date: 03 November 2018  05:53:43AM
[12.553] xorg-server 2:1.19.2-1+deb9u5 (https://www.debian.org/support) 
[12.554] Current version of pixman: 0.34.0
[12.554]Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
[12.554] Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[12.554] (==) Log file: "/var/log/Xorg.0.log", Time: Fri Jan 18 09:13:19 
2019
[12.573] 

Aw: Re: [PATCH 2/2] drm/mediatek: Add Mediatek framebuffer device

2019-01-20 Thread Frank Wunderlich
I have tested same codebase where my FBDev-Patch works (4.20-hdmiv5), only 
without it and CK Hu's 2 Patches

does generic fbdev depend on the mmsys-Patch?

regards Frank


> Gesendet: Freitag, 18. Januar 2019 um 09:39 Uhr
> Von: "Matthias Brugger" 
> may it be the not yet fixed mmsys compatible problem?
> Frank, did you test with my last series [1]?
> 
> Regards,
> Matthias
> 
> [1] https://patchwork.kernel.org/cover/10686345/
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/komeda: Remove unused variable

2019-01-20 Thread Gustavo A. R. Silva
Remove unused variable *pdev* in komeda_parse_dt():

drivers/gpu/drm/arm/display/komeda//komeda_dev.c: In function ‘komeda_parse_dt’:
drivers/gpu/drm/arm/display/komeda//komeda_dev.c:52:26: warning: unused 
variable ‘pdev’ [-Wunused-variable]
  struct platform_device *pdev = to_platform_device(dev);
  ^~~~

Fixes: 7e8d4fcf8daf ("drm: arm/komeda: Remove IRQ parsing from initial series")
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
index 16f4e72abc1a..0fe6954fbbf4 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
@@ -49,7 +49,6 @@ static int komeda_parse_pipe_dt(struct komeda_dev *mdev, 
struct device_node *np)
 
 static int komeda_parse_dt(struct device *dev, struct komeda_dev *mdev)
 {
-   struct platform_device *pdev = to_platform_device(dev);
struct device_node *child, *np = dev->of_node;
struct clk *clk;
int ret;
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm/xen-front: Make shmem backed display buffer coherent

2019-01-20 Thread Oleksandr Andrushchenko
On 1/17/19 11:18 AM, Christoph Hellwig wrote:
> On Wed, Jan 16, 2019 at 06:43:29AM +, Oleksandr Andrushchenko wrote:
>>> This whole issue keeps getting more and more confusing.
>> Well, I don't really do DMA here, but instead the buffers in
>> question are shared with other Xen domain, so effectively it
>> could be thought of some sort of DMA here, where the "device" is
>> that remote domain. If the buffers are not flushed then the
>> remote part sees some inconsistency which in my case results
>> in artifacts on screen while displaying the buffers.
>> When buffers are allocated via DMA API then there are no artifacts;
>> if buffers are allocated with shmem + DMA mapping then there are no
>> artifacts as well.
>> The only offending use-case is when I use shmem backed buffers,
>> but do not flush them
> The right answer would be to implement cache maintainance hooks for
> this case in the Xen arch code.  These would basically look the same
> as the low-level cache maintainance used by the DMA ops, but without
> going through the DMA mapping layer, in fact they should probably
> reuse the same low-level assembly routines.
>
> I don't think this is the first usage of such Xen buffer sharing, so
> what do the other users do?
I'll have to get even deeper into it. Initially I
looked at the code, but didn't find anything useful.
Or maybe I have just overlooked obvious things there

Thank you,
Oleksandr
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] video/hdmi: Change strncpy() into memcpy() in hdmi_spd_infoframe_init

2019-01-20 Thread Mathieu Malaterre
Using strncpy() is less than perfect since the destination buffers do not
need to be NUL terminated. Replace strncpy() with memcpy() to address a
warning triggered by gcc using W=1 and optimize the code a bit.

This commit removes the following warnings:

  drivers/video/hdmi.c:234:2: warning: 'strncpy' specified bound 8 equals 
destination size [-Wstringop-truncation]
  drivers/video/hdmi.c:235:2: warning: 'strncpy' specified bound 16 equals 
destination size [-Wstringop-truncation]

Signed-off-by: Mathieu Malaterre 
---
 drivers/video/hdmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 799ae49774f5..553c39ac8f9e 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -231,8 +231,8 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe 
*frame,
frame->version = 1;
frame->length = HDMI_SPD_INFOFRAME_SIZE;
 
-   strncpy(frame->vendor, vendor, sizeof(frame->vendor));
-   strncpy(frame->product, product, sizeof(frame->product));
+   memcpy(frame->vendor, vendor, sizeof(frame->vendor));
+   memcpy(frame->product, product, sizeof(frame->product));
 
return 0;
 }
-- 
2.19.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/2] drm/omap: panel-tpo-td028ttec1: add backlight support

2019-01-20 Thread Andreas Kemnade
This panel has a backlight, so add a property describing that and
add the code to use that.
This makes things like xset dpms force off
also turn off the backlight, so we do not need to rely on additional
userspace programs to do that.

Andreas Kemnade (2):
  drm/omap: panel-tpo-td028ttec1: add backlight support
  dt-bindings: panel: td028ttec1: add backlight property

 .../bindings/display/panel/tpo,td028ttec1.txt  |  2 ++
 .../gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c| 18 +++---
 2 files changed, 17 insertions(+), 3 deletions(-)

-- 
2.11.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v6] drm/msm/a6xx: Add support for an interconnect path

2019-01-20 Thread Evan Green
On Fri, Jan 18, 2019 at 3:27 PM Jordan Crouse  wrote:
>
> On Fri, Jan 18, 2019 at 03:04:34PM -0800, Evan Green wrote:
> > On Fri, Jan 18, 2019 at 12:24 PM Jordan Crouse  
> > wrote:
> > >
> > > Try to get the interconnect path for the GPU and vote for the maximum
> > > bandwidth to support all frequencies. This is needed for performance.
> > > Later we will want to scale the bandwidth based on the frequency to
> > > also optimize for power but that will require some device tree
> > > infrastructure that does not yet exist.
> > >
> > > v6: use icc_set_bw() instead of icc_set()
> > > v5: Remove hardcoded interconnect name and just use the default
> > > v4: Don't use a port string at all to skip the need for names in the DT
> > > v3: Use macros and change port string per Georgi Djakov
> > >
> > > Signed-off-by: Jordan Crouse 
> > > ---
> > >
> > >  drivers/gpu/drm/msm/Kconfig |  1 +
> > >  drivers/gpu/drm/msm/adreno/a6xx_gmu.c   | 20 
> > >  drivers/gpu/drm/msm/adreno/adreno_gpu.c |  9 +
> > >  drivers/gpu/drm/msm/msm_gpu.h   |  3 +++
> > >  4 files changed, 33 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
> > > index cf549f1..78c9e5a5 100644
> > > --- a/drivers/gpu/drm/msm/Kconfig
> > > +++ b/drivers/gpu/drm/msm/Kconfig
> > > @@ -5,6 +5,7 @@ config DRM_MSM
> > > depends on ARCH_QCOM || SOC_IMX5 || (ARM && COMPILE_TEST)
> > > depends on OF && COMMON_CLK
> > > depends on MMU
> > > +   depends on INTERCONNECT || !INTERCONNECT
> > > select QCOM_MDT_LOADER if ARCH_QCOM
> > > select REGULATOR
> > > select DRM_KMS_HELPER
> > > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
> > > b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > > index 5beb83d..c48fe46 100644
> > > --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > > @@ -2,6 +2,7 @@
> > >  /* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. */
> > >
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >
> > > @@ -84,6 +85,9 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu)
> > >
> > >  static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
> > >  {
> > > +   struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, 
> > > gmu);
> > > +   struct adreno_gpu *adreno_gpu = _gpu->base;
> > > +   struct msm_gpu *gpu = _gpu->base;
> > > int ret;
> > >
> > > gmu_write(gmu, REG_A6XX_GMU_DCVS_ACK_OPTION, 0);
> > > @@ -106,6 +110,12 @@ static void __a6xx_gmu_set_freq(struct a6xx_gmu 
> > > *gmu, int index)
> > > dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", 
> > > ret);
> > >
> > > gmu->freq = gmu->gpu_freqs[index];
> > > +
> > > +   /*
> > > +* Eventually we will want to scale the path vote with the 
> > > frequency but
> > > +* for now leave it at max so that the performance is nominal.
> > > +*/
> > > +   icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
> > >  }
> > >
> > >  void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq)
> > > @@ -705,6 +715,8 @@ int a6xx_gmu_reset(struct a6xx_gpu *a6xx_gpu)
> > >
> > >  int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
> > >  {
> > > +   struct adreno_gpu *adreno_gpu = _gpu->base;
> > > +   struct msm_gpu *gpu = _gpu->base;
> > > struct a6xx_gmu *gmu = _gpu->gmu;
> > > int status, ret;
> > >
> > > @@ -720,6 +732,9 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
> > > if (ret)
> > > goto out;
> > >
> > > +   /* Set the bus quota to a reasonable value for boot */
> > > +   icc_set_bw(gpu->icc_path, 0, MBps_to_icc(3072));
> >
> > Does the comment mention boot because this resume call happens during
> > init?
>
> Correct. Boot refers to the GMU in this context.
>
> > How come this number is different from the one in __a6xx_gmu_set_freq?
>
> If you never request a bus quota from the kernel the sucker is horribly
> painfully slow. I'm not sure if that is just the default reset value of
> the registers or if the bootloader is doing something. In any event
> the GMU doesn't always initialize if you try to bring it up with the
> default bus settings so we set it to a "reasonable" quota for the
> init sequence. I admit I didn't come up with these numbers on my own;
> some poor anonymous soul debugged this on the downstream kernel and
> I just stole the same parameters.
>
> As for _a6xx_gmu_set_freq() eventually we'll agree on a way to communicate
> the bus bandwidth in the opp settings and we'll be able to adjust the quota
> based on the frequency to save power so that's why the code is organized the 
> way
> it is so that a6xx_gmu_set_freq() won't have to be massively changed later.

Oh I see, so it's just a placeholder to max for now until the OPP part
gets figured out. That makes sense.

Reviewed-by: Evan Green 

Re: [PATCH 2/4] staging: android: ion: Restrict cache maintenance to dma mapped memory

2019-01-20 Thread Liam Mark
On Fri, 18 Jan 2019, Andrew F. Davis wrote:

> On 1/18/19 12:37 PM, Liam Mark wrote:
> > The ION begin_cpu_access and end_cpu_access functions use the
> > dma_sync_sg_for_cpu and dma_sync_sg_for_device APIs to perform cache
> > maintenance.
> > 
> > Currently it is possible to apply cache maintenance, via the
> > begin_cpu_access and end_cpu_access APIs, to ION buffers which are not
> > dma mapped.
> > 
> > The dma sync sg APIs should not be called on sg lists which have not been
> > dma mapped as this can result in cache maintenance being applied to the
> > wrong address. If an sg list has not been dma mapped then its dma_address
> > field has not been populated, some dma ops such as the swiotlb_dma_ops ops
> > use the dma_address field to calculate the address onto which to apply
> > cache maintenance.
> > 
> > Also I don’t think we want CMOs to be applied to a buffer which is not
> > dma mapped as the memory should already be coherent for access from the
> > CPU. Any CMOs required for device access taken care of in the
> > dma_buf_map_attachment and dma_buf_unmap_attachment calls.
> > So really it only makes sense for begin_cpu_access and end_cpu_access to
> > apply CMOs if the buffer is dma mapped.
> > 
> > Fix the ION begin_cpu_access and end_cpu_access functions to only apply
> > cache maintenance to buffers which are dma mapped.
> > 
> > Fixes: 2a55e7b5e544 ("staging: android: ion: Call dma_map_sg for syncing 
> > and mapping")
> > Signed-off-by: Liam Mark 
> > ---
> >  drivers/staging/android/ion/ion.c | 26 +-
> >  1 file changed, 21 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/staging/android/ion/ion.c 
> > b/drivers/staging/android/ion/ion.c
> > index 6f5afab7c1a1..1fe633a7fdba 100644
> > --- a/drivers/staging/android/ion/ion.c
> > +++ b/drivers/staging/android/ion/ion.c
> > @@ -210,6 +210,7 @@ struct ion_dma_buf_attachment {
> > struct device *dev;
> > struct sg_table *table;
> > struct list_head list;
> > +   bool dma_mapped;
> >  };
> >  
> >  static int ion_dma_buf_attach(struct dma_buf *dmabuf,
> > @@ -231,6 +232,7 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf,
> >  
> > a->table = table;
> > a->dev = attachment->dev;
> > +   a->dma_mapped = false;
> > INIT_LIST_HEAD(>list);
> >  
> > attachment->priv = a;
> > @@ -261,12 +263,18 @@ static struct sg_table *ion_map_dma_buf(struct 
> > dma_buf_attachment *attachment,
> >  {
> > struct ion_dma_buf_attachment *a = attachment->priv;
> > struct sg_table *table;
> > +   struct ion_buffer *buffer = attachment->dmabuf->priv;
> >  
> > table = a->table;
> >  
> > +   mutex_lock(>lock);
> > if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
> > -   direction))
> > +   direction)) {
> > +   mutex_unlock(>lock);
> > return ERR_PTR(-ENOMEM);
> > +   }
> > +   a->dma_mapped = true;
> > +   mutex_unlock(>lock);
> >  
> > return table;
> >  }
> > @@ -275,7 +283,13 @@ static void ion_unmap_dma_buf(struct 
> > dma_buf_attachment *attachment,
> >   struct sg_table *table,
> >   enum dma_data_direction direction)
> >  {
> > +   struct ion_dma_buf_attachment *a = attachment->priv;
> > +   struct ion_buffer *buffer = attachment->dmabuf->priv;
> > +
> > +   mutex_lock(>lock);
> > dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
> > +   a->dma_mapped = false;
> > +   mutex_unlock(>lock);
> >  }
> >  
> >  static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
> > @@ -346,8 +360,9 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf 
> > *dmabuf,
> >  
> > mutex_lock(>lock);
> > list_for_each_entry(a, >attachments, list) {
> 
> When no devices are attached then buffer->attachments is empty and the
> below does not run, so if I understand this patch correctly then what
> you are protecting against is CPU access in the window after
> dma_buf_attach but before dma_buf_map.
> 

Yes

> This is the kind of thing that again makes me think a couple more
> ordering requirements on DMA-BUF ops are needed. DMA-BUFs do not require
> the backing memory to be allocated until map time, this is why the
> dma_address field would still be null as you note in the commit message.
> So why should the CPU be performing accesses on a buffer that is not
> actually backed yet?
> 
> I can think of two solutions:
> 
> 1) Only allow CPU access (mmap, kmap, {begin,end}_cpu_access) while at
> least one device is mapped.
> 

Would be quite limiting to clients.

> 2) Treat the CPU access request like the a device map request and
> trigger the allocation of backing memory just like if a device map had
> come in.
> 

Which is, as you mention pretty much what we have now (though the buffer 
is allocated even earlier).

> I know the current Ion heaps (and most other DMA-BUF exporters) all do
> the allocation up front so the memory is already there, 

[PATCH 2/4] staging: android: ion: Restrict cache maintenance to dma mapped memory

2019-01-20 Thread Liam Mark
The ION begin_cpu_access and end_cpu_access functions use the
dma_sync_sg_for_cpu and dma_sync_sg_for_device APIs to perform cache
maintenance.

Currently it is possible to apply cache maintenance, via the
begin_cpu_access and end_cpu_access APIs, to ION buffers which are not
dma mapped.

The dma sync sg APIs should not be called on sg lists which have not been
dma mapped as this can result in cache maintenance being applied to the
wrong address. If an sg list has not been dma mapped then its dma_address
field has not been populated, some dma ops such as the swiotlb_dma_ops ops
use the dma_address field to calculate the address onto which to apply
cache maintenance.

Also I don’t think we want CMOs to be applied to a buffer which is not
dma mapped as the memory should already be coherent for access from the
CPU. Any CMOs required for device access taken care of in the
dma_buf_map_attachment and dma_buf_unmap_attachment calls.
So really it only makes sense for begin_cpu_access and end_cpu_access to
apply CMOs if the buffer is dma mapped.

Fix the ION begin_cpu_access and end_cpu_access functions to only apply
cache maintenance to buffers which are dma mapped.

Fixes: 2a55e7b5e544 ("staging: android: ion: Call dma_map_sg for syncing and 
mapping")
Signed-off-by: Liam Mark 
---
 drivers/staging/android/ion/ion.c | 26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index 6f5afab7c1a1..1fe633a7fdba 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -210,6 +210,7 @@ struct ion_dma_buf_attachment {
struct device *dev;
struct sg_table *table;
struct list_head list;
+   bool dma_mapped;
 };
 
 static int ion_dma_buf_attach(struct dma_buf *dmabuf,
@@ -231,6 +232,7 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf,
 
a->table = table;
a->dev = attachment->dev;
+   a->dma_mapped = false;
INIT_LIST_HEAD(>list);
 
attachment->priv = a;
@@ -261,12 +263,18 @@ static struct sg_table *ion_map_dma_buf(struct 
dma_buf_attachment *attachment,
 {
struct ion_dma_buf_attachment *a = attachment->priv;
struct sg_table *table;
+   struct ion_buffer *buffer = attachment->dmabuf->priv;
 
table = a->table;
 
+   mutex_lock(>lock);
if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
-   direction))
+   direction)) {
+   mutex_unlock(>lock);
return ERR_PTR(-ENOMEM);
+   }
+   a->dma_mapped = true;
+   mutex_unlock(>lock);
 
return table;
 }
@@ -275,7 +283,13 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment 
*attachment,
  struct sg_table *table,
  enum dma_data_direction direction)
 {
+   struct ion_dma_buf_attachment *a = attachment->priv;
+   struct ion_buffer *buffer = attachment->dmabuf->priv;
+
+   mutex_lock(>lock);
dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
+   a->dma_mapped = false;
+   mutex_unlock(>lock);
 }
 
 static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
@@ -346,8 +360,9 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf 
*dmabuf,
 
mutex_lock(>lock);
list_for_each_entry(a, >attachments, list) {
-   dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents,
-   direction);
+   if (a->dma_mapped)
+   dma_sync_sg_for_cpu(a->dev, a->table->sgl,
+   a->table->nents, direction);
}
 
 unlock:
@@ -369,8 +384,9 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf 
*dmabuf,
 
mutex_lock(>lock);
list_for_each_entry(a, >attachments, list) {
-   dma_sync_sg_for_device(a->dev, a->table->sgl, a->table->nents,
-  direction);
+   if (a->dma_mapped)
+   dma_sync_sg_for_device(a->dev, a->table->sgl,
+  a->table->nents, direction);
}
mutex_unlock(>lock);
 
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC] drm: Remove unused Renesas SH Mobile DRM driver

2019-01-20 Thread Geert Uytterhoeven
Since its incarnation in v3.7 almost 7 years ago, no users of the SH
Mobile DRM driver have appeared.

Hence remove the driver.  It can be resurrected from git history,
if/when needed.

Signed-off-by: Geert Uytterhoeven 
---
Against drm/drm-next

 MAINTAINERS   |   2 -
 drivers/gpu/drm/Kconfig   |   2 -
 drivers/gpu/drm/Makefile  |   1 -
 drivers/gpu/drm/shmobile/Kconfig  |  14 -
 drivers/gpu/drm/shmobile/Makefile |   8 -
 .../gpu/drm/shmobile/shmob_drm_backlight.c|  86 ---
 .../gpu/drm/shmobile/shmob_drm_backlight.h|  19 -
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 689 --
 drivers/gpu/drm/shmobile/shmob_drm_crtc.h |  53 --
 drivers/gpu/drm/shmobile/shmob_drm_drv.c  | 311 
 drivers/gpu/drm/shmobile/shmob_drm_drv.h  |  41 --
 drivers/gpu/drm/shmobile/shmob_drm_kms.c  | 146 
 drivers/gpu/drm/shmobile/shmob_drm_kms.h  |  29 -
 drivers/gpu/drm/shmobile/shmob_drm_plane.c| 259 ---
 drivers/gpu/drm/shmobile/shmob_drm_plane.h|  18 -
 drivers/gpu/drm/shmobile/shmob_drm_regs.h | 307 
 include/linux/platform_data/shmob_drm.h   |  91 ---
 17 files changed, 2076 deletions(-)
 delete mode 100644 drivers/gpu/drm/shmobile/Kconfig
 delete mode 100644 drivers/gpu/drm/shmobile/Makefile
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_backlight.c
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_backlight.h
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_crtc.c
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_crtc.h
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_drv.c
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_drv.h
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_kms.c
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_kms.h
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_plane.c
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_plane.h
 delete mode 100644 drivers/gpu/drm/shmobile/shmob_drm_regs.h
 delete mode 100644 include/linux/platform_data/shmob_drm.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 4c0879650caf3c10..61009a7be8862d68 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5098,8 +5098,6 @@ L:linux-renesas-...@vger.kernel.org
 T: git git://linuxtv.org/pinchartl/media drm/du/next
 S: Supported
 F: drivers/gpu/drm/rcar-du/
-F: drivers/gpu/drm/shmobile/
-F: include/linux/platform_data/shmob_drm.h
 F: Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
 F: Documentation/devicetree/bindings/display/bridge/renesas,lvds.txt
 F: Documentation/devicetree/bindings/display/renesas,du.txt
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index bd943a71756ca81b..3df7b8905ca8b736 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -273,8 +273,6 @@ source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
 
 source "drivers/gpu/drm/rcar-du/Kconfig"
 
-source "drivers/gpu/drm/shmobile/Kconfig"
-
 source "drivers/gpu/drm/sun4i/Kconfig"
 
 source "drivers/gpu/drm/omapdrm/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index f0c1f8731a2761ed..9b5bee490a899468 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -82,7 +82,6 @@ obj-$(CONFIG_DRM_AST) += ast/
 obj-$(CONFIG_DRM_ARMADA) += armada/
 obj-$(CONFIG_DRM_ATMEL_HLCDC)  += atmel-hlcdc/
 obj-$(CONFIG_DRM_RCAR_DU) += rcar-du/
-obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/
 obj-y  += omapdrm/
 obj-$(CONFIG_DRM_SUN4I) += sun4i/
 obj-y  += tilcdc/
diff --git a/drivers/gpu/drm/shmobile/Kconfig b/drivers/gpu/drm/shmobile/Kconfig
deleted file mode 100644
index 61bbe8e8bcc51db9..
--- a/drivers/gpu/drm/shmobile/Kconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config DRM_SHMOBILE
-   tristate "DRM Support for SH Mobile"
-   depends on DRM && ARM
-   depends on ARCH_SHMOBILE || COMPILE_TEST
-   select BACKLIGHT_CLASS_DEVICE
-   select BACKLIGHT_LCD_SUPPORT
-   select DRM_KMS_HELPER
-   select DRM_KMS_CMA_HELPER
-   select DRM_GEM_CMA_HELPER
-   help
- Choose this option if you have an SH Mobile chipset.
- If M is selected the module will be called shmob-drm.
-
diff --git a/drivers/gpu/drm/shmobile/Makefile 
b/drivers/gpu/drm/shmobile/Makefile
deleted file mode 100644
index 861edafed8562c87..
--- a/drivers/gpu/drm/shmobile/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-shmob-drm-y := shmob_drm_backlight.o \
-  shmob_drm_crtc.o \
-  shmob_drm_drv.o \
-  shmob_drm_kms.o \
-  shmob_drm_plane.o
-
-obj-$(CONFIG_DRM_SHMOBILE) += shmob-drm.o
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_backlight.c 
b/drivers/gpu/drm/shmobile/shmob_drm_backlight.c
deleted file mode 100644
index f6628a5ee95f3e9a..
--- 

[PATCH] drm/vkms: Fix flush_work() without INIT_WORK().

2019-01-20 Thread Tetsuo Handa
syzbot is hitting a lockdep warning [1] because flush_work() is called
without INIT_WORK() after kzalloc() at vkms_atomic_crtc_reset().

Commit 6c234fe37c57627a ("drm/vkms: Implement CRC debugfs API") added
INIT_WORK() to only vkms_atomic_crtc_duplicate_state() side. Assuming
that lifecycle of crc_work is appropriately managed, fix this problem
by adding INIT_WORK() to vkms_atomic_crtc_reset() side.

[1] 
https://syzkaller.appspot.com/bug?id=a5954455fcfa51c29ca2ab55b203076337e1c770

Reported-and-tested-by: syzbot 

Signed-off-by: Tetsuo Handa 
---
 drivers/gpu/drm/vkms/vkms_crtc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 177bbcb..3c37d8c 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -104,6 +104,7 @@ static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
if (!vkms_state)
return;
+   INIT_WORK(_state->crc_work, vkms_crc_work_handle);
 
crtc->state = _state->base;
crtc->state->crtc = crtc;
-- 
1.8.3.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/2] dt-bindings: panel: td028ttec1: add backlight property

2019-01-20 Thread Andreas Kemnade
This add an additional backlight property as described
in panel-common.txt

Signed-off-by: Andreas Kemnade 
---
 Documentation/devicetree/bindings/display/panel/tpo,td028ttec1.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/panel/tpo,td028ttec1.txt 
b/Documentation/devicetree/bindings/display/panel/tpo,td028ttec1.txt
index ed34253d9fb1..898e06ecf4ef 100644
--- a/Documentation/devicetree/bindings/display/panel/tpo,td028ttec1.txt
+++ b/Documentation/devicetree/bindings/display/panel/tpo,td028ttec1.txt
@@ -6,6 +6,7 @@ Required properties:
 
 Optional properties:
 - label: a symbolic name for the panel
+- backlight: phandle of the backlight device
 
 Required nodes:
 - Video port for DPI input
@@ -21,6 +22,7 @@ lcd-panel: td028ttec1@0 {
spi-cpha;
 
label = "lcd";
+   backlight = <>;
port {
lcd_in: endpoint {
remote-endpoint = <_out>;
-- 
2.11.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/4] staging: android: ion: Support for mapping with dma mapping attributes

2019-01-20 Thread Liam Mark
Add support for configuring dma mapping attributes when mapping
and unmapping memory through dma_buf_map_attachment and
dma_buf_unmap_attachment.

For example this will allow ION clients to skip cache maintenance, by
using DMA_ATTR_SKIP_CPU_SYNC, for buffers which are clean and haven't been
accessed by the CPU.

Signed-off-by: Liam Mark 
---
 drivers/staging/android/ion/ion.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index 1fe633a7fdba..0aae845b20ba 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -268,8 +268,8 @@ static struct sg_table *ion_map_dma_buf(struct 
dma_buf_attachment *attachment,
table = a->table;
 
mutex_lock(>lock);
-   if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
-   direction)) {
+   if (!dma_map_sg_attrs(attachment->dev, table->sgl, table->nents,
+ direction, attachment->dma_map_attrs)) {
mutex_unlock(>lock);
return ERR_PTR(-ENOMEM);
}
@@ -287,7 +287,8 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment 
*attachment,
struct ion_buffer *buffer = attachment->dmabuf->priv;
 
mutex_lock(>lock);
-   dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
+   dma_unmap_sg_attrs(attachment->dev, table->sgl, table->nents, direction,
+  attachment->dma_map_attrs);
a->dma_mapped = false;
mutex_unlock(>lock);
 }
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-20 Thread Liam Mark
On Fri, 18 Jan 2019, Andrew F. Davis wrote:

> On 1/17/19 7:04 PM, Liam Mark wrote:
> > On Thu, 17 Jan 2019, Andrew F. Davis wrote:
> > 
> >> On 1/16/19 4:48 PM, Liam Mark wrote:
> >>> On Wed, 16 Jan 2019, Andrew F. Davis wrote:
> >>>
>  On 1/15/19 1:05 PM, Laura Abbott wrote:
> > On 1/15/19 10:38 AM, Andrew F. Davis wrote:
> >> On 1/15/19 11:45 AM, Liam Mark wrote:
> >>> On Tue, 15 Jan 2019, Andrew F. Davis wrote:
> >>>
>  On 1/14/19 11:13 AM, Liam Mark wrote:
> > On Fri, 11 Jan 2019, Andrew F. Davis wrote:
> >
> >> Buffers may not be mapped from the CPU so skip cache maintenance
> >> here.
> >> Accesses from the CPU to a cached heap should be bracketed with
> >> {begin,end}_cpu_access calls so maintenance should not be needed
> >> anyway.
> >>
> >> Signed-off-by: Andrew F. Davis 
> >> ---
> >>   drivers/staging/android/ion/ion.c | 7 ---
> >>   1 file changed, 4 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/staging/android/ion/ion.c
> >> b/drivers/staging/android/ion/ion.c
> >> index 14e48f6eb734..09cb5a8e2b09 100644
> >> --- a/drivers/staging/android/ion/ion.c
> >> +++ b/drivers/staging/android/ion/ion.c
> >> @@ -261,8 +261,8 @@ static struct sg_table *ion_map_dma_buf(struct
> >> dma_buf_attachment *attachment,
> >>     table = a->table;
> >>   -    if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
> >> -    direction))
> >> +    if (!dma_map_sg_attrs(attachment->dev, table->sgl, 
> >> table->nents,
> >> +  direction, DMA_ATTR_SKIP_CPU_SYNC))
> >
> > Unfortunately I don't think you can do this for a couple reasons.
> > You can't rely on {begin,end}_cpu_access calls to do cache
> > maintenance.
> > If the calls to {begin,end}_cpu_access were made before the call to
> > dma_buf_attach then there won't have been a device attached so the
> > calls
> > to {begin,end}_cpu_access won't have done any cache maintenance.
> >
> 
>  That should be okay though, if you have no attachments (or all
>  attachments are IO-coherent) then there is no need for cache
>  maintenance. Unless you mean a sequence where a non-io-coherent 
>  device
>  is attached later after data has already been written. Does that
>  sequence need supporting?
> >>>
> >>> Yes, but also I think there are cases where CPU access can happen 
> >>> before
> >>> in Android, but I will focus on later for now.
> >>>
>  DMA-BUF doesn't have to allocate the backing
>  memory until map_dma_buf() time, and that should only happen after 
>  all
>  the devices have attached so it can know where to put the buffer. So 
>  we
>  shouldn't expect any CPU access to buffers before all the devices are
>  attached and mapped, right?
> 
> >>>
> >>> Here is an example where CPU access can happen later in Android.
> >>>
> >>> Camera device records video -> software post processing -> video 
> >>> device
> >>> (who does compression of raw data) and writes to a file
> >>>
> >>> In this example assume the buffer is cached and the devices are not
> >>> IO-coherent (quite common).
> >>>
> >>
> >> This is the start of the problem, having cached mappings of memory that
> >> is also being accessed non-coherently is going to cause issues one way
> >> or another. On top of the speculative cache fills that have to be
> >> constantly fought back against with CMOs like below; some coherent
> >> interconnects behave badly when you mix coherent and non-coherent 
> >> access
> >> (snoop filters get messed up).
> >>
> >> The solution is to either always have the addresses marked non-coherent
> >> (like device memory, no-map carveouts), or if you really want to use
> >> regular system memory allocated at runtime, then all cached mappings of
> >> it need to be dropped, even the kernel logical address (area as painful
> >> as that would be).
> >>
> >
> > I agree it's broken, hence my desire to remove it :)
> >
> > The other problem is that uncached buffers are being used for
> > performance reason so anything that would involve getting
> > rid of the logical address would probably negate any performance
> > benefit.
> >
> 
>  I wouldn't go as far as to remove them just yet.. Liam seems pretty
>  adamant that they have valid uses. I'm just not sure performance is one
>  of them, maybe in the case of software locks between devices or
>  something where there needs to be a lot of back and forth interleaved
>  access on small amounts of data?
> 

Re: [linux-sunxi] Re: HDMI/DVI spurious failure

2019-01-20 Thread Priit Laes
On Fri, Jan 18, 2019 at 03:04:18PM +0100, Maxime Ripard wrote:
> On Fri, Jan 18, 2019 at 10:10:53AM +, Priit Laes wrote:
> > > > > > > It doesn't look related to the clock rate itself, since it doesn't
> > > > > > > change between the two cases. However, in one case the DDC clock 
> > > > > > > is
> > > > > > > enabled and in the other it's disabled.
> > > > > > > 
> > > > > > > Was it taken at the same time? Maybe you can try with that patch?
> > > > > > > http://code.bulix.org/z7jmkm-555344?raw
> > > > > > 
> > > > > > Thanks, after doing ~50+ boots I haven't seen a single failure.
> > > > > > 
> > > > > > Previously I had following failure cases which are now both fixed:
> > > > > > 
> > > > > > a) Linux without u-boot HDMI, where one in every 6-7 boots failed.
> > > > > > b) u--boot with hdmi enabled switching to simplefb and then 
> > > > > > switching
> > > > > > to kms, where previously all boots ended up with garbled screen.
> > > > > 
> > > > > So it's not really a fix, but it really looks like the clock is not
> > > > > enabled when it should.
> > > > > 
> > > > > Can you describe your test scenario a bit more? What are you doing
> > > > > exactly, just booting? When do you start using the display? When did
> > > > > you capture the debugfs output that you pasted?
> > > > 
> > > > Display is already connected via HDMI to the board. I don't really
> > > > remove it, I just boot the device and let it start Xorg.
> > > > Meanwhile I just ssh into the device and capture debugfs output.
> > > > See my 3 testing scenarios below.
> > > > 
> > > > Kernel also includes one extra patch to fall back to DDC, in case HPD
> > > > fails. Mostly the same I already submitted last November [1].
> > > 
> > > Do you have the same issue without that patch?
> > 
> > Can't really test this display without this patch and I do not have other
> > HDMI/DVI screens. And this issue does not happen with other HDMI displays
> > that I have here.
> 
> Can't you just force the monitor to be reported as present? It's not
> great and we don't want to merge it, but that would allow you to test
> that setup without too many interferences.

Baseline is clean u-boot / linux. U-boot does not detect/enable display.

1) Booting Linux with drm.debug=0xe

* Linux does not detect/enable display

2) Booting with drm.debug=0xe video=HDMI-A-1:640x480@60e

* Linux detects display, but display is garbled, and proper edid data is 
detected:

[snip]
pll-video1 000   32700  0 0 
 5
   pll-video1-2x   000   65400  0 0 
 5
  hdmi-tmds00025153846  0 0 
 5
 hdmi-ddc  000   89835  0 0 
 5
[/snip]

3) Booting with drm.debug=0xe video=HDMI-A-1:640x480@60e
And also one extra patch for Linux where HDMI DDC clock marked as critical

Linux detects and initializes display properly:
[snip]
pll-video1 110   32700  0 0 
 5
   pll-video1-2x   110   65400  0 0 
 5
  hdmi-tmds11025153846  0 0 
 5
 hdmi-ddc  110   89835  0 0 
 5
[/snip]


> Maxime
> 
> -- 
> Maxime Ripard, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to linux-sunxi+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/4] staging: android: ion: Support cpu access during dma_buf_detach

2019-01-20 Thread Liam Mark
Often userspace doesn't know when the kernel will be calling dma_buf_detach
on the buffer.
If userpace starts its CPU access at the same time as the sg list is being
freed it could end up accessing the sg list after it has been freed.

Thread AThread B
- DMA_BUF_IOCTL_SYNC IOCT
 - ion_dma_buf_begin_cpu_access
  - list_for_each_entry
- ion_dma_buf_detatch
 - free_duped_table
   - dma_sync_sg_for_cpu

Fix this by getting the ion_buffer lock before freeing the sg table memory.

Fixes: 2a55e7b5e544 ("staging: android: ion: Call dma_map_sg for syncing and 
mapping")
Signed-off-by: Liam Mark 
---
 drivers/staging/android/ion/ion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index a0802de8c3a1..6f5afab7c1a1 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -248,10 +248,10 @@ static void ion_dma_buf_detatch(struct dma_buf *dmabuf,
struct ion_dma_buf_attachment *a = attachment->priv;
struct ion_buffer *buffer = dmabuf->priv;
 
-   free_duped_table(a->table);
mutex_lock(>lock);
list_del(>list);
mutex_unlock(>lock);
+   free_duped_table(a->table);
 
kfree(a);
 }
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm: rcar-du: Fix build error

2019-01-20 Thread Nathan Chancellor
On arm{32,64} allyesconfig builds:

drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c:40:1: error: incomplete result type 
'enum drm_mode_status' in function definition
drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c:47:10: error: incomplete definition of 
type 'struct drm_display_mode'
drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c:48:10: error: use of undeclared 
identifier 'MODE_CLOCK_HIGH'
drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c:50:9: error: use of undeclared 
identifier 'MODE_OK'

After the removal of drmP.h from this file and its removal from
bridge/dw_hdmi.h, these types are not defined anymore, as they
were implicitly coming into that file through drm_crtc.h.

Fixes: 428747ae5cca ("drm: remove include of drmP.h from bridge/dw_hdmi.h")
Fixes: 9a47db8e7a9d ("drm: rcar-du: Remove inclusion of drmP.h")
Signed-off-by: Nathan Chancellor 
---
 drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c 
b/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
index 0fb25113f19c..452461dc96f2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
+++ b/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #define RCAR_HDMI_PHY_OPMODE_PLLCFG0x06/* Mode of operation and PLL 
dividers */
 #define RCAR_HDMI_PHY_PLLCURRGMPCTRL   0x10/* PLL current and Gmp 
(conductance) */
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/4] ION stability and perf changes

2019-01-20 Thread Liam Mark
Some stability changes to improve ION robustness and a perf related
change to make it easier for clients to avoid unnecessary cache
maintenance, such as when buffers are clean and haven't had any CPU
access.

Liam Mark (4):
  staging: android: ion: Support cpu access during dma_buf_detach
  staging: android: ion: Restrict cache maintenance to dma mapped memory
  dma-buf: add support for mapping with dma mapping attributes
  staging: android: ion: Support for mapping with dma mapping attributes

 drivers/staging/android/ion/ion.c | 33 +
 include/linux/dma-buf.h   |  3 +++
 2 files changed, 28 insertions(+), 8 deletions(-)

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Aw: Re: [PATCH 2/2] drm/mediatek: Add Mediatek framebuffer device

2019-01-20 Thread Frank Wunderlich
Tested with mmsys-Patch, but same result, no fbcon, tft is switched on but i 
see no kernel-log

after boot is finished, i see X-server, until this point i see only black screen

regards Frank


> Gesendet: Freitag, 18. Januar 2019 um 09:39 Uhr
> Von: "Matthias Brugger" 
> may it be the not yet fixed mmsys compatible problem?
> Frank, did you test with my last series [1]?
> [1] https://patchwork.kernel.org/cover/10686345/
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [linux-sunxi] [PATCH v3 02/28] clk: sunxi-ng: Adjust MP clock parent rate when allowed

2019-01-20 Thread Jernej Škrabec
Dne četrtek, 17. januar 2019 ob 08:24:02 CET je Priit Laes napisal(a):
> On Wed, Jan 16, 2019 at 06:00:32PM +0100, Jernej Škrabec wrote:
> > Dne sreda, 16. januar 2019 ob 13:09:58 CET je Priit Laes napisal(a):
> > > On Thu, Jan 10, 2019 at 06:10:59PM +0100, Jernej Škrabec wrote:
> > > > Dne četrtek, 10. januar 2019 ob 10:15:48 CET je Priit Laes napisal(a):
> > > > > On Sun, Nov 04, 2018 at 07:26:39PM +0100, Jernej Skrabec wrote:
> > > > > > Currently MP clocks don't consider adjusting parent rate even if
> > > > > > they
> > > > > > are allowed to do so. Such behaviour considerably lowers amount of
> > > > > > possible rates, which is very inconvenient when such clock is used
> > > > > > for
> > > > > > pixel clock, for example.
> > > > > > 
> > > > > > In order to improve the situation, adjusting parent rate is
> > > > > > considered
> > > > > > when allowed.
> > > > > > 
> > > > > > This code is inspired by clk_divider_bestdiv() function, which
> > > > > > does
> > > > > > basically the same thing for different clock type.
> > > > > 
> > > > > This patch seems to break the eMMC support on Olinuxino-Lime2-eMMC
> > > > > boards:
> > > > > 
> > > > > EXT4-fs (mmcblk1p4): INFO: recovery required on readonly filesystem
> > > > > EXT4-fs (mmcblk1p4): write access will be enabled during recovery
> > > > > sunxi-mmc 1c11000.mmc: data error, sending stop command
> > > > > sunxi-mmc 1c11000.mmc: send stop command failed
> > > > 
> > > > I'm not familiar with A20. What is interesting is that emmc clocks
> > > > don't
> > > > have CLK_SET_RATE_PARENT flag set, so you shouldn't see any
> > > > difference.
> > > > 
> > > > Can you post content of clk_summary with and without this patch?
> > > 
> > > In both cases I booted from FEL with rootfs on sdcard and tried to mount
> > > partition from eMMC to /mnt. With your patch, last step it fails.
> > > 
> > > pre-patch working:
> > > pll-ddr-other[768MHz] -> mmc2[512MHz]. (For some reason ahb-mmc2 is
> > > off?)
> > > 
> > > post-patch not working:
> > > pll-periph[600MHz] ->  mmc2[500Mhz], (ahb-mmc2 is enabled)
> > > 
> > > Also, attached the logs.
> > 
> > Thanks. Just one more request. Can you enable debug messages in mmc
> > driver?
> > I'm interested in output of this line:
> > 
> > dev_dbg(mmc_dev(mmc), "setting clk to %d, rounded %ld\n",
> > 
> > clock, rate);
> 
> 1c11000 is eMMC:
> [snip]
> [1.961644] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.004091] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.020296] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.039917] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.047847] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.055053] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.065256] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.092351] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.168725] sunxi-mmc 1c11000.mmc: setting clk to 40, rounded 40
> [2.189403] sunxi-mmc 1c11000.mmc: setting clk to 5200, rounded
> 5200 [2.203340] sunxi-mmc 1c11000.mmc: setting clk to 5200,
> rounded 5200 [2.211412] sunxi-mmc 1c11000.mmc: setting clk to
> 5200, rounded 5200 [4.967865] sunxi-mmc 1c11000.mmc: setting
> clk to 5200, rounded 5200 [8.755345] sunxi-mmc 1c11000.mmc:
> setting clk to 5200, rounded 5200 [9.082510] sunxi-mmc
> 1c11000.mmc: setting clk to 5200, rounded 5200
> 
> Here I tried to mount partition from eMMC...
> 
> [   72.167311] sunxi-mmc 1c11000.mmc: setting clk to 5200, rounded
> 5200 [   72.269629] sunxi-mmc 1c11000.mmc: data error, sending stop
> command [   73.268999] sunxi-mmc 1c11000.mmc: send stop command failed
> [/snip]
> 
> And clock tree:
> [snip]
> pll-periph-base330  12  0   
>  0  5 pll-periph  660   6  
>0 0  5 mmc2 3305000 
> 0 0  5 mmc2_sample   110   
> 5000  0   120  5 mmc2_output   110 
>   5000  060  5 ahb 18   18 
>   0   3  0 0  5 ahb-mmc2  11   
> 0   3  0 0  5 [/snip]
> 
> 
> And without patch:
> [snip]
> [2.003341] sunxi-mmc 1c11000.mmc: XXX: setting clk to 40, rounded
> 40 [2.019479] sunxi-mmc 1c11000.mmc: XXX: setting clk to 40,
> rounded 40 [2.039144] sunxi-mmc 1c11000.mmc: XXX: setting clk to
> 40, rounded 40 [2.047129] sunxi-mmc 1c11000.mmc: XXX: setting
> clk to 40, rounded 40 [2.054324] sunxi-mmc 1c11000.mmc: XXX:
> setting clk to 40, rounded 40 [2.064481] sunxi-mmc 1c11000.mmc:
> XXX: setting clk to 

[PATCH] iommu/intel: quirk to disable DMAR for QM57 igfx

2019-01-20 Thread Eric Wong
Joonas Lahtinen  wrote:
> Quoting Eric Wong (2019-01-04 03:06:26)
> > Yeah, so the Debian bpo 4.17(.17) kernel did not set
> > CONFIG_INTEL_IOMMU_DEFAULT_ON, so I didn't encounter problems.
> > My self-built kernels all set CONFIG_INTEL_IOMMU_DEFAULT_ON.
> 
> So it's the case that IOMMU never worked on your machine.
> 
> My recommendation would be to simply use intel_iommu=igfx_off if you
> need IOMMU.
> 
> Old hardware is known to have issues with IOMMU, and retroactively
> enabling IOMMU on those machines just brings them up :/

How about we use a quirk in case distros make IOMMU the default
one day?

8<
Subject: [PATCH] iommu/intel: quirk to disable DMAR for QM57 igfx

Like the GM45, it seems the integrated graphics on QM57 seems
broken and hanging graphics with "intel_iommu=on".  So allow
future users to unconditionally enable DMAR support and not have
to remember or know to specify "intel_iommu=igfx_off"

cf. https://lore.kernel.org/lkml/20181227114948.ev4b3jte3ubsc5us@dcvr/
cf. 
https://lore.kernel.org/lkml/154659116310.4596.13613897418163029...@jlahtine-desk.ger.corp.intel.com/

Signed-off-by: Eric Wong 
---
 drivers/iommu/intel-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 048b5ab36a02..dc2507a01580 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5399,7 +5399,7 @@ const struct iommu_ops intel_iommu_ops = {
 
 static void quirk_iommu_g4x_gfx(struct pci_dev *dev)
 {
-   /* G4x/GM45 integrated gfx dmar support is totally busted. */
+   /* G4x/GM45/QM57 integrated gfx dmar support is totally busted. */
pr_info("Disabling IOMMU for graphics on this chipset\n");
dmar_map_gfx = 0;
 }
@@ -5411,6 +5411,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e20, 
quirk_iommu_g4x_gfx);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e30, quirk_iommu_g4x_gfx);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e40, quirk_iommu_g4x_gfx);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e90, quirk_iommu_g4x_gfx);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0044, quirk_iommu_g4x_gfx);
 
 static void quirk_iommu_rwbf(struct pci_dev *dev)
 {
@@ -5457,7 +5458,6 @@ static void quirk_calpella_no_shadow_gtt(struct pci_dev 
*dev)
}
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0040, 
quirk_calpella_no_shadow_gtt);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0044, 
quirk_calpella_no_shadow_gtt);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0062, 
quirk_calpella_no_shadow_gtt);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x006a, 
quirk_calpella_no_shadow_gtt);
 
-- 
EW
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Xen-devel] [PATCH v2] drm/xen-front: Make shmem backed display buffer coherent

2019-01-20 Thread Julien Grall

(+ Stefano)

Hi,

Sorry for jumping late in the conversation.

On 18/01/2019 09:40, Oleksandr Andrushchenko wrote:

On 1/17/19 11:18 AM, Christoph Hellwig wrote:

On Wed, Jan 16, 2019 at 06:43:29AM +, Oleksandr Andrushchenko wrote:

This whole issue keeps getting more and more confusing.

Well, I don't really do DMA here, but instead the buffers in
question are shared with other Xen domain, so effectively it
could be thought of some sort of DMA here, where the "device" is
that remote domain. If the buffers are not flushed then the
remote part sees some inconsistency which in my case results
in artifacts on screen while displaying the buffers.
When buffers are allocated via DMA API then there are no artifacts;
if buffers are allocated with shmem + DMA mapping then there are no
artifacts as well.
The only offending use-case is when I use shmem backed buffers,
but do not flush them

The right answer would be to implement cache maintainance hooks for
this case in the Xen arch code.  These would basically look the same
as the low-level cache maintainance used by the DMA ops, but without
going through the DMA mapping layer, in fact they should probably
reuse the same low-level assembly routines.

I don't think this is the first usage of such Xen buffer sharing, so
what do the other users do?

I'll have to get even deeper into it. Initially I
looked at the code, but didn't find anything useful.
Or maybe I have just overlooked obvious things there

From Xen on Arm ABI:

"All memory which is shared with other entities in the system
(including the hypervisor and other guests) must reside in memory
which is mapped as Normal Inner Write-Back Outer Write-Back Inner-Shareable.
This applies to:
  - hypercall arguments passed via a pointer to guest memory.
  - memory shared via the grant table mechanism (including PV I/O
rings etc).
  - memory shared with the hypervisor (struct shared_info, struct
vcpu_info, the grant table, etc).
"

So you should not need any cache maintenance here. Can you provide more details 
on the memory attribute you use for memory shared in both the backend and frontend?


Cheers,



Thank you,
Oleksandr
___
Xen-devel mailing list
xen-de...@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel



--
Julien Grall
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 02/11] drm/modes: Add DRM_SIMPLE_MODE()

2019-01-20 Thread Ilia Mirkin
You don't appear to set the mm in the new macro. Not sure if it's on
purpose.

On Sun, Jan 20, 2019, 06:43 Noralf Trønnes  This adds a helper macro to specify modes that only contain info about
> resolution.
>
> Signed-off-by: Noralf Trønnes 
> ---
>  drivers/gpu/drm/tinydrm/hx8357d.c  |  2 +-
>  drivers/gpu/drm/tinydrm/ili9225.c  |  2 +-
>  drivers/gpu/drm/tinydrm/ili9341.c  |  2 +-
>  drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
>  drivers/gpu/drm/tinydrm/repaper.c  |  8 
>  drivers/gpu/drm/tinydrm/st7586.c   |  2 +-
>  drivers/gpu/drm/tinydrm/st7735r.c  |  2 +-
>  include/drm/drm_modes.h| 16 
>  include/drm/tinydrm/tinydrm.h  | 23 ---
>  9 files changed, 26 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c
> b/drivers/gpu/drm/tinydrm/hx8357d.c
> index 8bbd0beafc6a..5a1ec0451c19 100644
> --- a/drivers/gpu/drm/tinydrm/hx8357d.c
> +++ b/drivers/gpu/drm/tinydrm/hx8357d.c
> @@ -181,7 +181,7 @@ static const struct drm_simple_display_pipe_funcs
> hx8357d_pipe_funcs = {
>  };
>
>  static const struct drm_display_mode yx350hv15_mode = {
> -   TINYDRM_MODE(320, 480, 60, 75),
> +   DRM_SIMPLE_MODE(320, 480, 60, 75),
>  };
>
>  DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
> diff --git a/drivers/gpu/drm/tinydrm/ili9225.c
> b/drivers/gpu/drm/tinydrm/ili9225.c
> index 43a3b68d90a2..d40814d370e2 100644
> --- a/drivers/gpu/drm/tinydrm/ili9225.c
> +++ b/drivers/gpu/drm/tinydrm/ili9225.c
> @@ -332,7 +332,7 @@ static const struct drm_simple_display_pipe_funcs
> ili9225_pipe_funcs = {
>  };
>
>  static const struct drm_display_mode ili9225_mode = {
> -   TINYDRM_MODE(176, 220, 35, 44),
> +   DRM_SIMPLE_MODE(176, 220, 35, 44),
>  };
>
>  DEFINE_DRM_GEM_CMA_FOPS(ili9225_fops);
> diff --git a/drivers/gpu/drm/tinydrm/ili9341.c
> b/drivers/gpu/drm/tinydrm/ili9341.c
> index 713bb2dd7e04..063f4f07f811 100644
> --- a/drivers/gpu/drm/tinydrm/ili9341.c
> +++ b/drivers/gpu/drm/tinydrm/ili9341.c
> @@ -137,7 +137,7 @@ static const struct drm_simple_display_pipe_funcs
> ili9341_pipe_funcs = {
>  };
>
>  static const struct drm_display_mode yx240qv29_mode = {
> -   TINYDRM_MODE(240, 320, 37, 49),
> +   DRM_SIMPLE_MODE(240, 320, 37, 49),
>  };
>
>  DEFINE_DRM_GEM_CMA_FOPS(ili9341_fops);
> diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c
> b/drivers/gpu/drm/tinydrm/mi0283qt.c
> index 82a92ec9ae3c..3d067c2ba1bc 100644
> --- a/drivers/gpu/drm/tinydrm/mi0283qt.c
> +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
> @@ -145,7 +145,7 @@ static const struct drm_simple_display_pipe_funcs
> mi0283qt_pipe_funcs = {
>  };
>
>  static const struct drm_display_mode mi0283qt_mode = {
> -   TINYDRM_MODE(320, 240, 58, 43),
> +   DRM_SIMPLE_MODE(320, 240, 58, 43),
>  };
>
>  DEFINE_DRM_GEM_CMA_FOPS(mi0283qt_fops);
> diff --git a/drivers/gpu/drm/tinydrm/repaper.c
> b/drivers/gpu/drm/tinydrm/repaper.c
> index b037c6540cf3..72d30151ecd8 100644
> --- a/drivers/gpu/drm/tinydrm/repaper.c
> +++ b/drivers/gpu/drm/tinydrm/repaper.c
> @@ -860,28 +860,28 @@ static const uint32_t repaper_formats[] = {
>  };
>
>  static const struct drm_display_mode repaper_e1144cs021_mode = {
> -   TINYDRM_MODE(128, 96, 29, 22),
> +   DRM_SIMPLE_MODE(128, 96, 29, 22),
>  };
>
>  static const u8 repaper_e1144cs021_cs[] = { 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x0f, 0xff, 0x00 };
>
>  static const struct drm_display_mode repaper_e1190cs021_mode = {
> -   TINYDRM_MODE(144, 128, 36, 32),
> +   DRM_SIMPLE_MODE(144, 128, 36, 32),
>  };
>
>  static const u8 repaper_e1190cs021_cs[] = { 0x00, 0x00, 0x00, 0x03,
> 0xfc, 0x00, 0x00, 0xff };
>
>  static const struct drm_display_mode repaper_e2200cs021_mode = {
> -   TINYDRM_MODE(200, 96, 46, 22),
> +   DRM_SIMPLE_MODE(200, 96, 46, 22),
>  };
>
>  static const u8 repaper_e2200cs021_cs[] = { 0x00, 0x00, 0x00, 0x00,
> 0x01, 0xff, 0xe0, 0x00 };
>
>  static const struct drm_display_mode repaper_e2271cs021_mode = {
> -   TINYDRM_MODE(264, 176, 57, 38),
> +   DRM_SIMPLE_MODE(264, 176, 57, 38),
>  };
>
>  static const u8 repaper_e2271cs021_cs[] = { 0x00, 0x00, 0x00, 0x7f,
> diff --git a/drivers/gpu/drm/tinydrm/st7586.c
> b/drivers/gpu/drm/tinydrm/st7586.c
> index 01a8077954b3..5ee7db561349 100644
> --- a/drivers/gpu/drm/tinydrm/st7586.c
> +++ b/drivers/gpu/drm/tinydrm/st7586.c
> @@ -312,7 +312,7 @@ static const struct drm_simple_display_pipe_funcs
> st7586_pipe_funcs = {
>  };
>
>  static const struct drm_display_mode st7586_mode = {
> -   TINYDRM_MODE(178, 128, 37, 27),
> +   DRM_SIMPLE_MODE(178, 128, 37, 27),
>  };
>
>  DEFINE_DRM_GEM_CMA_FOPS(st7586_fops);
> diff --git a/drivers/gpu/drm/tinydrm/st7735r.c
> b/drivers/gpu/drm/tinydrm/st7735r.c
> index 3bab9a9569a6..6c7904c205f0 100644
> --- a/drivers/gpu/drm/tinydrm/st7735r.c
> +++ b/drivers/gpu/drm/tinydrm/st7735r.c
> @@ -111,7 +111,7 

[PATCH 10/11] drm/tinydrm: Use drm_dev_enter/exit()

2019-01-20 Thread Noralf Trønnes
This protects device resources from use after device removal.

There are 3 ways for driver-device unbinding to happen:
- The driver module is unloaded causing the driver to be unregistered.
  This can't happen as long as there are open file handles because a
  reference is taken on the module.
- The device is removed (Device Tree overlay unloading).
  This can happen at any time.
- The driver sysfs unbind file can be used to unbind the driver from the
  device. This can happen any time.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/hx8357d.c  |  9 +--
 drivers/gpu/drm/tinydrm/ili9225.c  | 24 ++---
 drivers/gpu/drm/tinydrm/ili9341.c  |  9 +--
 drivers/gpu/drm/tinydrm/mi0283qt.c |  9 +--
 drivers/gpu/drm/tinydrm/mipi-dbi.c | 39 +++
 drivers/gpu/drm/tinydrm/repaper.c  | 42 +-
 drivers/gpu/drm/tinydrm/st7586.c   | 23 +---
 drivers/gpu/drm/tinydrm/st7735r.c  |  9 +--
 8 files changed, 131 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c 
b/drivers/gpu/drm/tinydrm/hx8357d.c
index 4648bd6d6282..aac2c4bda779 100644
--- a/drivers/gpu/drm/tinydrm/hx8357d.c
+++ b/drivers/gpu/drm/tinydrm/hx8357d.c
@@ -49,13 +49,16 @@ static void yx240qv29_enable(struct drm_simple_display_pipe 
*pipe,
 {
struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev);
u8 addr_mode;
-   int ret;
+   int ret, idx;
+
+   if (!drm_dev_enter(pipe->crtc.dev, ))
+   return;
 
DRM_DEBUG_KMS("\n");
 
ret = mipi_dbi_poweron_conditional_reset(mipi);
if (ret < 0)
-   return;
+   goto out_exit;
if (ret == 1)
goto out_enable;
 
@@ -171,6 +174,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe 
*pipe,
}
mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode);
mipi_dbi_enable_flush(mipi, crtc_state, plane_state);
+out_exit:
+   drm_dev_exit(idx);
 }
 
 static const struct drm_simple_display_pipe_funcs hx8357d_pipe_funcs = {
diff --git a/drivers/gpu/drm/tinydrm/ili9225.c 
b/drivers/gpu/drm/tinydrm/ili9225.c
index 20a44a43a64a..9dfc472032ae 100644
--- a/drivers/gpu/drm/tinydrm/ili9225.c
+++ b/drivers/gpu/drm/tinydrm/ili9225.c
@@ -88,13 +88,16 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, 
struct drm_rect *rect)
bool swap = mipi->swap_bytes;
u16 x_start, y_start;
u16 x1, x2, y1, y2;
-   int ret = 0;
+   int idx, ret = 0;
bool full;
void *tr;
 
if (!mipi->enabled)
return;
 
+   if (!drm_dev_enter(fb->dev, ))
+   return;
+
full = width == fb->width && height == fb->height;
 
DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, 
DRM_RECT_ARG(rect));
@@ -157,6 +160,8 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, 
struct drm_rect *rect)
 err_msg:
if (ret)
dev_err_once(fb->dev->dev, "Failed to update display %d\n", 
ret);
+
+   drm_dev_exit(idx);
 }
 
 static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -190,9 +195,12 @@ static void ili9225_pipe_enable(struct 
drm_simple_display_pipe *pipe,
.y1 = 0,
.y2 = fb->height,
};
-   int ret;
+   int ret, idx;
u8 am_id;
 
+   if (!drm_dev_enter(pipe->crtc.dev, ))
+   return;
+
DRM_DEBUG_KMS("\n");
 
mipi_dbi_hw_reset(mipi);
@@ -206,7 +214,7 @@ static void ili9225_pipe_enable(struct 
drm_simple_display_pipe *pipe,
ret = ili9225_command(mipi, ILI9225_POWER_CONTROL_1, 0x);
if (ret) {
DRM_DEV_ERROR(dev, "Error sending command %d\n", ret);
-   return;
+   goto out_exit;
}
ili9225_command(mipi, ILI9225_POWER_CONTROL_2, 0x);
ili9225_command(mipi, ILI9225_POWER_CONTROL_3, 0x);
@@ -279,16 +287,22 @@ static void ili9225_pipe_enable(struct 
drm_simple_display_pipe *pipe,
 
mipi->enabled = true;
ili9225_fb_dirty(fb, );
+out_exit:
+   drm_dev_exit(idx);
 }
 
 static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)
 {
struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev);
+   int idx;
+
+   if (!drm_dev_enter(pipe->crtc.dev, ))
+   return;
 
DRM_DEBUG_KMS("\n");
 
if (!mipi->enabled)
-   return;
+   goto out_exit;
 
ili9225_command(mipi, ILI9225_DISPLAY_CONTROL_1, 0x);
msleep(50);
@@ -297,6 +311,8 @@ static void ili9225_pipe_disable(struct 
drm_simple_display_pipe *pipe)
ili9225_command(mipi, ILI9225_POWER_CONTROL_1, 0x0a02);
 
mipi->enabled = false;
+out_exit:
+   drm_dev_exit(idx);
 }
 
 static int ili9225_dbi_command(struct mipi_dbi *mipi, u8 cmd, u8 *par,
diff --git a/drivers/gpu/drm/tinydrm/ili9341.c 
b/drivers/gpu/drm/tinydrm/ili9341.c

[PATCH 05/11] drm/tinydrm/mipi-dbi: Add drm_to_mipi_dbi()

2019-01-20 Thread Noralf Trønnes
Add a function to derive mipi_dbi from drm_device now that tinydrm_device
is going away.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/hx8357d.c  |  3 +--
 drivers/gpu/drm/tinydrm/ili9225.c  | 11 ---
 drivers/gpu/drm/tinydrm/ili9341.c  |  3 +--
 drivers/gpu/drm/tinydrm/mi0283qt.c |  3 +--
 drivers/gpu/drm/tinydrm/mipi-dbi.c |  9 +++--
 drivers/gpu/drm/tinydrm/st7586.c   |  9 +++--
 drivers/gpu/drm/tinydrm/st7735r.c  |  3 +--
 include/drm/tinydrm/mipi-dbi.h |  5 +++--
 8 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c 
b/drivers/gpu/drm/tinydrm/hx8357d.c
index 5a1ec0451c19..ab604513b865 100644
--- a/drivers/gpu/drm/tinydrm/hx8357d.c
+++ b/drivers/gpu/drm/tinydrm/hx8357d.c
@@ -46,8 +46,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe 
*pipe,
 struct drm_crtc_state *crtc_state,
 struct drm_plane_state *plane_state)
 {
-   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
-   struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
+   struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev);
u8 addr_mode;
int ret;
 
diff --git a/drivers/gpu/drm/tinydrm/ili9225.c 
b/drivers/gpu/drm/tinydrm/ili9225.c
index d40814d370e2..40e1f98ca393 100644
--- a/drivers/gpu/drm/tinydrm/ili9225.c
+++ b/drivers/gpu/drm/tinydrm/ili9225.c
@@ -81,8 +81,7 @@ static inline int ili9225_command(struct mipi_dbi *mipi, u8 
cmd, u16 data)
 static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
 {
struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
-   struct tinydrm_device *tdev = fb->dev->dev_private;
-   struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
+   struct mipi_dbi *mipi = drm_to_mipi_dbi(fb->dev);
unsigned int height = rect->y2 - rect->y1;
unsigned int width = rect->x2 - rect->x1;
bool swap = mipi->swap_bytes;
@@ -181,10 +180,9 @@ static void ili9225_pipe_enable(struct 
drm_simple_display_pipe *pipe,
struct drm_crtc_state *crtc_state,
struct drm_plane_state *plane_state)
 {
-   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
-   struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
+   struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev);
struct drm_framebuffer *fb = plane_state->fb;
-   struct device *dev = tdev->drm->dev;
+   struct device *dev = pipe->crtc.dev->dev;
struct drm_rect rect = {
.x1 = 0,
.x2 = fb->width,
@@ -284,8 +282,7 @@ static void ili9225_pipe_enable(struct 
drm_simple_display_pipe *pipe,
 
 static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)
 {
-   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
-   struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
+   struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev);
 
DRM_DEBUG_KMS("\n");
 
diff --git a/drivers/gpu/drm/tinydrm/ili9341.c 
b/drivers/gpu/drm/tinydrm/ili9341.c
index 063f4f07f811..86f8884036b2 100644
--- a/drivers/gpu/drm/tinydrm/ili9341.c
+++ b/drivers/gpu/drm/tinydrm/ili9341.c
@@ -52,8 +52,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe 
*pipe,
 struct drm_crtc_state *crtc_state,
 struct drm_plane_state *plane_state)
 {
-   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
-   struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
+   struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev);
u8 addr_mode;
int ret;
 
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 3d067c2ba1bc..ea14f89cf9af 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -54,8 +54,7 @@ static void mi0283qt_enable(struct drm_simple_display_pipe 
*pipe,
struct drm_crtc_state *crtc_state,
struct drm_plane_state *plane_state)
 {
-   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
-   struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
+   struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev);
u8 addr_mode;
int ret;
 
diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c 
b/drivers/gpu/drm/tinydrm/mipi-dbi.c
index d1d546f3a664..3c66a844fe56 100644
--- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
+++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
@@ -216,8 +216,7 @@ EXPORT_SYMBOL(mipi_dbi_buf_copy);
 static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect 
*rect)
 {
struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
-   struct tinydrm_device *tdev = fb->dev->dev_private;
-   struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
+   struct mipi_dbi *mipi = drm_to_mipi_dbi(fb->dev);
unsigned int height = rect->y2 - rect->y1;

[PATCH 11/11] drm/fb-helper: generic: Don't take module ref for fbcon

2019-01-20 Thread Noralf Trønnes
It's now safe to let fbcon unbind automatically on fbdev unregister.
The crash problem was fixed in commit 2122b40580dd
("fbdev: fbcon: Fix unregister crash when more than one framebuffer")

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 31fcf94bf825..5d0327f603bb 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2999,7 +2999,8 @@ static int drm_fbdev_fb_open(struct fb_info *info, int 
user)
 {
struct drm_fb_helper *fb_helper = info->par;
 
-   if (!try_module_get(fb_helper->dev->driver->fops->owner))
+   /* No need to take a ref for fbcon because it unbinds on unregister */
+   if (user && !try_module_get(fb_helper->dev->driver->fops->owner))
return -ENODEV;
 
return 0;
@@ -3009,7 +3010,8 @@ static int drm_fbdev_fb_release(struct fb_info *info, int 
user)
 {
struct drm_fb_helper *fb_helper = info->par;
 
-   module_put(fb_helper->dev->driver->fops->owner);
+   if (user)
+   module_put(fb_helper->dev->driver->fops->owner);
 
return 0;
 }
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 06/11] drm/tinydrm: Remove tinydrm_shutdown()

2019-01-20 Thread Noralf Trønnes
It's just a wrapper around drm_atomic_helper_shutdown() now.
Also store drm_device in the drvdata field, since that's what's used.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 14 --
 drivers/gpu/drm/tinydrm/hx8357d.c   |  7 +++
 drivers/gpu/drm/tinydrm/ili9225.c   |  7 +++
 drivers/gpu/drm/tinydrm/ili9341.c   |  7 +++
 drivers/gpu/drm/tinydrm/mi0283qt.c  | 15 +--
 drivers/gpu/drm/tinydrm/repaper.c   |  8 
 drivers/gpu/drm/tinydrm/st7586.c|  7 +++
 drivers/gpu/drm/tinydrm/st7735r.c   |  7 +++
 include/drm/tinydrm/tinydrm.h   |  1 -
 9 files changed, 24 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
index 614f532ea89f..e4a77feaacd6 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
@@ -166,18 +166,4 @@ int devm_tinydrm_register(struct tinydrm_device *tdev)
 }
 EXPORT_SYMBOL(devm_tinydrm_register);
 
-/**
- * tinydrm_shutdown - Shutdown tinydrm
- * @tdev: tinydrm device
- *
- * This function makes sure that the display pipeline is disabled.
- * Used by drivers in their shutdown callback to turn off the display
- * on machine shutdown and reboot.
- */
-void tinydrm_shutdown(struct tinydrm_device *tdev)
-{
-   drm_atomic_helper_shutdown(tdev->drm);
-}
-EXPORT_SYMBOL(tinydrm_shutdown);
-
 MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c 
b/drivers/gpu/drm/tinydrm/hx8357d.c
index ab604513b865..84dda622df85 100644
--- a/drivers/gpu/drm/tinydrm/hx8357d.c
+++ b/drivers/gpu/drm/tinydrm/hx8357d.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -242,16 +243,14 @@ static int hx8357d_probe(struct spi_device *spi)
if (ret)
return ret;
 
-   spi_set_drvdata(spi, mipi);
+   spi_set_drvdata(spi, mipi->tinydrm.drm);
 
return devm_tinydrm_register(>tinydrm);
 }
 
 static void hx8357d_shutdown(struct spi_device *spi)
 {
-   struct mipi_dbi *mipi = spi_get_drvdata(spi);
-
-   tinydrm_shutdown(>tinydrm);
+   drm_atomic_helper_shutdown(spi_get_drvdata(spi));
 }
 
 static struct spi_driver hx8357d_spi_driver = {
diff --git a/drivers/gpu/drm/tinydrm/ili9225.c 
b/drivers/gpu/drm/tinydrm/ili9225.c
index 40e1f98ca393..3f59cfbd31ba 100644
--- a/drivers/gpu/drm/tinydrm/ili9225.c
+++ b/drivers/gpu/drm/tinydrm/ili9225.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -396,16 +397,14 @@ static int ili9225_probe(struct spi_device *spi)
if (ret)
return ret;
 
-   spi_set_drvdata(spi, mipi);
+   spi_set_drvdata(spi, mipi->tinydrm.drm);
 
return devm_tinydrm_register(>tinydrm);
 }
 
 static void ili9225_shutdown(struct spi_device *spi)
 {
-   struct mipi_dbi *mipi = spi_get_drvdata(spi);
-
-   tinydrm_shutdown(>tinydrm);
+   drm_atomic_helper_shutdown(spi_get_drvdata(spi));
 }
 
 static struct spi_driver ili9225_spi_driver = {
diff --git a/drivers/gpu/drm/tinydrm/ili9341.c 
b/drivers/gpu/drm/tinydrm/ili9341.c
index 86f8884036b2..3b7565a6311e 100644
--- a/drivers/gpu/drm/tinydrm/ili9341.c
+++ b/drivers/gpu/drm/tinydrm/ili9341.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -204,16 +205,14 @@ static int ili9341_probe(struct spi_device *spi)
if (ret)
return ret;
 
-   spi_set_drvdata(spi, mipi);
+   spi_set_drvdata(spi, mipi->tinydrm.drm);
 
return devm_tinydrm_register(>tinydrm);
 }
 
 static void ili9341_shutdown(struct spi_device *spi)
 {
-   struct mipi_dbi *mipi = spi_get_drvdata(spi);
-
-   tinydrm_shutdown(>tinydrm);
+   drm_atomic_helper_shutdown(spi_get_drvdata(spi));
 }
 
 static struct spi_driver ili9341_spi_driver = {
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index ea14f89cf9af..da326fd1450d 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -217,30 +218,24 @@ static int mi0283qt_probe(struct spi_device *spi)
if (ret)
return ret;
 
-   spi_set_drvdata(spi, mipi);
+   spi_set_drvdata(spi, mipi->tinydrm.drm);
 
return devm_tinydrm_register(>tinydrm);
 }
 
 static void mi0283qt_shutdown(struct spi_device *spi)
 {
-   struct mipi_dbi *mipi = spi_get_drvdata(spi);
-
-   tinydrm_shutdown(>tinydrm);
+   drm_atomic_helper_shutdown(spi_get_drvdata(spi));
 }
 
 static int __maybe_unused mi0283qt_pm_suspend(struct device *dev)
 {
-   struct mipi_dbi *mipi = dev_get_drvdata(dev);
-
-   return drm_mode_config_helper_suspend(mipi->tinydrm.drm);
+   return drm_mode_config_helper_suspend(dev_get_drvdata(dev));
 }
 
 

[PATCH 07/11] drm/tinydrm/repaper: Use devm_drm_dev_*()

2019-01-20 Thread Noralf Trønnes
Use devm_drm_dev_init(), devm_drm_dev_register_with_fbdev() and drop
using tinydrm_device.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/repaper.c | 63 ---
 1 file changed, 40 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/repaper.c 
b/drivers/gpu/drm/tinydrm/repaper.c
index 3141241ca8f0..4c8205565668 100644
--- a/drivers/gpu/drm/tinydrm/repaper.c
+++ b/drivers/gpu/drm/tinydrm/repaper.c
@@ -34,7 +34,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #define REPAPER_RID_G2_COG_ID  0x12
@@ -60,7 +60,8 @@ enum repaper_epd_border_byte {
 };
 
 struct repaper_epd {
-   struct tinydrm_device tinydrm;
+   struct drm_device base;
+   struct drm_simple_display_pipe pipe;
struct spi_device *spi;
 
struct gpio_desc *panel_on;
@@ -89,10 +90,9 @@ struct repaper_epd {
bool partial;
 };
 
-static inline struct repaper_epd *
-epd_from_tinydrm(struct tinydrm_device *tdev)
+static inline struct repaper_epd *drm_to_epd(struct drm_device *drm)
 {
-   return container_of(tdev, struct repaper_epd, tinydrm);
+   return container_of(drm, struct repaper_epd, base);
 }
 
 static int repaper_spi_transfer(struct spi_device *spi, u8 header,
@@ -530,8 +530,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb)
 {
struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
struct dma_buf_attachment *import_attach = cma_obj->base.import_attach;
-   struct tinydrm_device *tdev = fb->dev->dev_private;
-   struct repaper_epd *epd = epd_from_tinydrm(tdev);
+   struct repaper_epd *epd = drm_to_epd(fb->dev);
struct drm_rect clip;
u8 *buf = NULL;
int ret = 0;
@@ -646,8 +645,7 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
struct drm_crtc_state *crtc_state,
struct drm_plane_state *plane_state)
 {
-   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
-   struct repaper_epd *epd = epd_from_tinydrm(tdev);
+   struct repaper_epd *epd = drm_to_epd(pipe->crtc.dev);
struct spi_device *spi = epd->spi;
struct device *dev = >dev;
bool dc_ok = false;
@@ -781,8 +779,7 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
 
 static void repaper_pipe_disable(struct drm_simple_display_pipe *pipe)
 {
-   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
-   struct repaper_epd *epd = epd_from_tinydrm(tdev);
+   struct repaper_epd *epd = drm_to_epd(pipe->crtc.dev);
struct spi_device *spi = epd->spi;
unsigned int line;
 
@@ -856,6 +853,23 @@ static const struct drm_simple_display_pipe_funcs 
repaper_pipe_funcs = {
.prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
 };
 
+static const struct drm_mode_config_funcs repaper_mode_config_funcs = {
+   .fb_create = drm_gem_fb_create_with_dirty,
+   .atomic_check = drm_atomic_helper_check,
+   .atomic_commit = drm_atomic_helper_commit,
+};
+
+static void repaper_release(struct drm_device *drm)
+{
+   struct repaper_epd *epd = drm_to_epd(drm);
+
+   DRM_DEBUG_DRIVER("\n");
+
+   drm_mode_config_cleanup(drm);
+   drm_dev_fini(drm);
+   kfree(epd);
+}
+
 static const uint32_t repaper_formats[] = {
DRM_FORMAT_XRGB,
 };
@@ -894,6 +908,7 @@ static struct drm_driver repaper_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
  DRIVER_ATOMIC,
.fops   = _fops,
+   .release= repaper_release,
DRM_GEM_CMA_VMAP_DRIVER_OPS,
.name   = "repaper",
.desc   = "Pervasive Displays RePaper e-ink panels",
@@ -927,7 +942,6 @@ static int repaper_probe(struct spi_device *spi)
const struct of_device_id *match;
struct drm_connector *connector;
struct device *dev = >dev;
-   struct tinydrm_device *tdev;
enum repaper_model model;
const char *thermal_zone;
struct repaper_epd *epd;
@@ -952,10 +966,20 @@ static int repaper_probe(struct spi_device *spi)
}
}
 
-   epd = devm_kzalloc(dev, sizeof(*epd), GFP_KERNEL);
+   epd = kzalloc(sizeof(*epd), GFP_KERNEL);
if (!epd)
return -ENOMEM;
 
+   drm = >base;
+   ret = devm_drm_dev_init(dev, drm, _driver);
+   if (ret) {
+   kfree(epd);
+   return ret;
+   }
+
+   drm_mode_config_init(drm);
+   drm->mode_config.funcs = _mode_config_funcs;
+
epd->spi = spi;
 
epd->panel_on = devm_gpiod_get(dev, "panel-on", GPIOD_OUT_LOW);
@@ -1066,32 +1090,25 @@ static int repaper_probe(struct spi_device *spi)
if (!epd->current_frame)
return -ENOMEM;
 
-   tdev = >tinydrm;
-
-   ret = devm_tinydrm_init(dev, tdev, _driver);
-   if 

[PATCH 04/11] drm/tinydrm: Remove tinydrm_display_pipe_init()

2019-01-20 Thread Noralf Trønnes
Further strip down tinydrm.ko and switch to drm_simple_connector_create().

Signed-off-by: Noralf Trønnes 
---
 Documentation/gpu/tinydrm.rst   |   3 -
 drivers/gpu/drm/tinydrm/core/Makefile   |   2 +-
 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 183 
 drivers/gpu/drm/tinydrm/mipi-dbi.c  |  24 ++-
 drivers/gpu/drm/tinydrm/repaper.c   |  16 +-
 drivers/gpu/drm/tinydrm/st7586.c|  19 +-
 include/drm/tinydrm/tinydrm.h   |   9 -
 7 files changed, 43 insertions(+), 213 deletions(-)
 delete mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c

diff --git a/Documentation/gpu/tinydrm.rst b/Documentation/gpu/tinydrm.rst
index a913644bfc19..1ca726474af4 100644
--- a/Documentation/gpu/tinydrm.rst
+++ b/Documentation/gpu/tinydrm.rst
@@ -17,9 +17,6 @@ Core functionality
 .. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c
:export:
 
-.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
-   :export:
-
 Additional helpers
 ==
 
diff --git a/drivers/gpu/drm/tinydrm/core/Makefile 
b/drivers/gpu/drm/tinydrm/core/Makefile
index fb221e6f8885..bf2df7326df7 100644
--- a/drivers/gpu/drm/tinydrm/core/Makefile
+++ b/drivers/gpu/drm/tinydrm/core/Makefile
@@ -1,3 +1,3 @@
-tinydrm-y := tinydrm-core.o tinydrm-pipe.o tinydrm-helpers.o
+tinydrm-y := tinydrm-core.o tinydrm-helpers.o
 
 obj-$(CONFIG_DRM_TINYDRM) += tinydrm.o
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
deleted file mode 100644
index 323564329535..
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2016 Noralf Trønnes
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-struct tinydrm_connector {
-   struct drm_connector base;
-   struct drm_display_mode mode;
-};
-
-static inline struct tinydrm_connector *
-to_tinydrm_connector(struct drm_connector *connector)
-{
-   return container_of(connector, struct tinydrm_connector, base);
-}
-
-static int tinydrm_connector_get_modes(struct drm_connector *connector)
-{
-   struct tinydrm_connector *tconn = to_tinydrm_connector(connector);
-   struct drm_display_mode *mode;
-
-   mode = drm_mode_duplicate(connector->dev, >mode);
-   if (!mode) {
-   DRM_ERROR("Failed to duplicate mode\n");
-   return 0;
-   }
-
-   if (mode->name[0] == '\0')
-   drm_mode_set_name(mode);
-
-   mode->type |= DRM_MODE_TYPE_PREFERRED;
-   drm_mode_probed_add(connector, mode);
-
-   if (mode->width_mm) {
-   connector->display_info.width_mm = mode->width_mm;
-   connector->display_info.height_mm = mode->height_mm;
-   }
-
-   return 1;
-}
-
-static const struct drm_connector_helper_funcs tinydrm_connector_hfuncs = {
-   .get_modes = tinydrm_connector_get_modes,
-};
-
-static enum drm_connector_status
-tinydrm_connector_detect(struct drm_connector *connector, bool force)
-{
-   if (drm_dev_is_unplugged(connector->dev))
-   return connector_status_disconnected;
-
-   return connector->status;
-}
-
-static void tinydrm_connector_destroy(struct drm_connector *connector)
-{
-   struct tinydrm_connector *tconn = to_tinydrm_connector(connector);
-
-   drm_connector_cleanup(connector);
-   kfree(tconn);
-}
-
-static const struct drm_connector_funcs tinydrm_connector_funcs = {
-   .reset = drm_atomic_helper_connector_reset,
-   .detect = tinydrm_connector_detect,
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = tinydrm_connector_destroy,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-struct drm_connector *
-tinydrm_connector_create(struct drm_device *drm,
-const struct drm_display_mode *mode,
-int connector_type)
-{
-   struct tinydrm_connector *tconn;
-   struct drm_connector *connector;
-   int ret;
-
-   tconn = kzalloc(sizeof(*tconn), GFP_KERNEL);
-   if (!tconn)
-   return ERR_PTR(-ENOMEM);
-
-   drm_mode_copy(>mode, mode);
-   connector = >base;
-
-   drm_connector_helper_add(connector, _connector_hfuncs);
-   ret = drm_connector_init(drm, connector, _connector_funcs,
-connector_type);
-   if (ret) {
-   kfree(tconn);
-   return ERR_PTR(ret);
-   }
-
-   connector->status = connector_status_connected;
-
-   return connector;
-}
-
-static int tinydrm_rotate_mode(struct 

[PATCH 08/11] drm/tinydrm: Use devm_drm_dev_*()

2019-01-20 Thread Noralf Trønnes
Use devm_drm_dev_init(), devm_drm_dev_register_with_fbdev() and drop
using tinydrm_device.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/hx8357d.c  |  25 +--
 drivers/gpu/drm/tinydrm/ili9225.c  |  25 +--
 drivers/gpu/drm/tinydrm/ili9341.c  |  25 +--
 drivers/gpu/drm/tinydrm/mi0283qt.c |  25 +--
 drivers/gpu/drm/tinydrm/mipi-dbi.c |  69 +++-
 drivers/gpu/drm/tinydrm/st7586.c   | 101 ++---
 drivers/gpu/drm/tinydrm/st7735r.c  |  25 +--
 include/drm/tinydrm/mipi-dbi.h |  26 +---
 8 files changed, 206 insertions(+), 115 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c 
b/drivers/gpu/drm/tinydrm/hx8357d.c
index 84dda622df85..4648bd6d6282 100644
--- a/drivers/gpu/drm/tinydrm/hx8357d.c
+++ b/drivers/gpu/drm/tinydrm/hx8357d.c
@@ -189,6 +189,7 @@ DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
 static struct drm_driver hx8357d_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | 
DRIVER_ATOMIC,
.fops   = _fops,
+   .release= mipi_dbi_release,
DRM_GEM_CMA_VMAP_DRIVER_OPS,
.debugfs_init   = mipi_dbi_debugfs_init,
.name   = "hx8357d",
@@ -213,15 +214,25 @@ MODULE_DEVICE_TABLE(spi, hx8357d_id);
 static int hx8357d_probe(struct spi_device *spi)
 {
struct device *dev = >dev;
+   struct drm_device *drm;
struct mipi_dbi *mipi;
struct gpio_desc *dc;
u32 rotation = 0;
int ret;
 
-   mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
+   mipi = kzalloc(sizeof(*mipi), GFP_KERNEL);
if (!mipi)
return -ENOMEM;
 
+   drm = >base;
+   ret = devm_drm_dev_init(dev, drm, _driver);
+   if (ret) {
+   kfree(mipi);
+   return ret;
+   }
+
+   drm_mode_config_init(drm);
+
dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW);
if (IS_ERR(dc)) {
DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n");
@@ -238,14 +249,18 @@ static int hx8357d_probe(struct spi_device *spi)
if (ret)
return ret;
 
-   ret = mipi_dbi_init(>dev, mipi, _pipe_funcs,
-   _driver, _mode, rotation);
+   ret = mipi_dbi_init(mipi, _pipe_funcs, _mode, 
rotation);
if (ret)
return ret;
 
-   spi_set_drvdata(spi, mipi->tinydrm.drm);
+   drm_mode_config_reset(drm);
 
-   return devm_tinydrm_register(>tinydrm);
+   spi_set_drvdata(spi, drm);
+
+   DRM_DEBUG_DRIVER("SPI speed: %uMHz, rotation = %u\n",
+spi->max_speed_hz / 100, rotation);
+
+   return devm_drm_dev_register_with_fbdev(drm, 0);
 }
 
 static void hx8357d_shutdown(struct spi_device *spi)
diff --git a/drivers/gpu/drm/tinydrm/ili9225.c 
b/drivers/gpu/drm/tinydrm/ili9225.c
index 3f59cfbd31ba..20a44a43a64a 100644
--- a/drivers/gpu/drm/tinydrm/ili9225.c
+++ b/drivers/gpu/drm/tinydrm/ili9225.c
@@ -339,6 +339,7 @@ static struct drm_driver ili9225_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
  DRIVER_ATOMIC,
.fops   = _fops,
+   .release= mipi_dbi_release,
DRM_GEM_CMA_VMAP_DRIVER_OPS,
.name   = "ili9225",
.desc   = "Ilitek ILI9225",
@@ -362,15 +363,25 @@ MODULE_DEVICE_TABLE(spi, ili9225_id);
 static int ili9225_probe(struct spi_device *spi)
 {
struct device *dev = >dev;
+   struct drm_device *drm;
struct mipi_dbi *mipi;
struct gpio_desc *rs;
u32 rotation = 0;
int ret;
 
-   mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
+   mipi = kzalloc(sizeof(*mipi), GFP_KERNEL);
if (!mipi)
return -ENOMEM;
 
+   drm = >base;
+   ret = devm_drm_dev_init(dev, drm, _driver);
+   if (ret) {
+   kfree(mipi);
+   return ret;
+   }
+
+   drm_mode_config_init(drm);
+
mipi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(mipi->reset)) {
DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n");
@@ -392,14 +403,18 @@ static int ili9225_probe(struct spi_device *spi)
/* override the command function set in  mipi_dbi_spi_init() */
mipi->command = ili9225_dbi_command;
 
-   ret = mipi_dbi_init(>dev, mipi, _pipe_funcs,
-   _driver, _mode, rotation);
+   ret = mipi_dbi_init(mipi, _pipe_funcs, _mode, rotation);
if (ret)
return ret;
 
-   spi_set_drvdata(spi, mipi->tinydrm.drm);
+   drm_mode_config_reset(drm);
 
-   return devm_tinydrm_register(>tinydrm);
+   spi_set_drvdata(spi, drm);
+
+   DRM_DEBUG_DRIVER("SPI speed: %uMHz, rotation = %u\n",
+spi->max_speed_hz / 100, rotation);
+
+   return 

[PATCH 02/11] drm/modes: Add DRM_SIMPLE_MODE()

2019-01-20 Thread Noralf Trønnes
This adds a helper macro to specify modes that only contain info about
resolution.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/hx8357d.c  |  2 +-
 drivers/gpu/drm/tinydrm/ili9225.c  |  2 +-
 drivers/gpu/drm/tinydrm/ili9341.c  |  2 +-
 drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
 drivers/gpu/drm/tinydrm/repaper.c  |  8 
 drivers/gpu/drm/tinydrm/st7586.c   |  2 +-
 drivers/gpu/drm/tinydrm/st7735r.c  |  2 +-
 include/drm/drm_modes.h| 16 
 include/drm/tinydrm/tinydrm.h  | 23 ---
 9 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c 
b/drivers/gpu/drm/tinydrm/hx8357d.c
index 8bbd0beafc6a..5a1ec0451c19 100644
--- a/drivers/gpu/drm/tinydrm/hx8357d.c
+++ b/drivers/gpu/drm/tinydrm/hx8357d.c
@@ -181,7 +181,7 @@ static const struct drm_simple_display_pipe_funcs 
hx8357d_pipe_funcs = {
 };
 
 static const struct drm_display_mode yx350hv15_mode = {
-   TINYDRM_MODE(320, 480, 60, 75),
+   DRM_SIMPLE_MODE(320, 480, 60, 75),
 };
 
 DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
diff --git a/drivers/gpu/drm/tinydrm/ili9225.c 
b/drivers/gpu/drm/tinydrm/ili9225.c
index 43a3b68d90a2..d40814d370e2 100644
--- a/drivers/gpu/drm/tinydrm/ili9225.c
+++ b/drivers/gpu/drm/tinydrm/ili9225.c
@@ -332,7 +332,7 @@ static const struct drm_simple_display_pipe_funcs 
ili9225_pipe_funcs = {
 };
 
 static const struct drm_display_mode ili9225_mode = {
-   TINYDRM_MODE(176, 220, 35, 44),
+   DRM_SIMPLE_MODE(176, 220, 35, 44),
 };
 
 DEFINE_DRM_GEM_CMA_FOPS(ili9225_fops);
diff --git a/drivers/gpu/drm/tinydrm/ili9341.c 
b/drivers/gpu/drm/tinydrm/ili9341.c
index 713bb2dd7e04..063f4f07f811 100644
--- a/drivers/gpu/drm/tinydrm/ili9341.c
+++ b/drivers/gpu/drm/tinydrm/ili9341.c
@@ -137,7 +137,7 @@ static const struct drm_simple_display_pipe_funcs 
ili9341_pipe_funcs = {
 };
 
 static const struct drm_display_mode yx240qv29_mode = {
-   TINYDRM_MODE(240, 320, 37, 49),
+   DRM_SIMPLE_MODE(240, 320, 37, 49),
 };
 
 DEFINE_DRM_GEM_CMA_FOPS(ili9341_fops);
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 82a92ec9ae3c..3d067c2ba1bc 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -145,7 +145,7 @@ static const struct drm_simple_display_pipe_funcs 
mi0283qt_pipe_funcs = {
 };
 
 static const struct drm_display_mode mi0283qt_mode = {
-   TINYDRM_MODE(320, 240, 58, 43),
+   DRM_SIMPLE_MODE(320, 240, 58, 43),
 };
 
 DEFINE_DRM_GEM_CMA_FOPS(mi0283qt_fops);
diff --git a/drivers/gpu/drm/tinydrm/repaper.c 
b/drivers/gpu/drm/tinydrm/repaper.c
index b037c6540cf3..72d30151ecd8 100644
--- a/drivers/gpu/drm/tinydrm/repaper.c
+++ b/drivers/gpu/drm/tinydrm/repaper.c
@@ -860,28 +860,28 @@ static const uint32_t repaper_formats[] = {
 };
 
 static const struct drm_display_mode repaper_e1144cs021_mode = {
-   TINYDRM_MODE(128, 96, 29, 22),
+   DRM_SIMPLE_MODE(128, 96, 29, 22),
 };
 
 static const u8 repaper_e1144cs021_cs[] = { 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0xff, 0x00 };
 
 static const struct drm_display_mode repaper_e1190cs021_mode = {
-   TINYDRM_MODE(144, 128, 36, 32),
+   DRM_SIMPLE_MODE(144, 128, 36, 32),
 };
 
 static const u8 repaper_e1190cs021_cs[] = { 0x00, 0x00, 0x00, 0x03,
0xfc, 0x00, 0x00, 0xff };
 
 static const struct drm_display_mode repaper_e2200cs021_mode = {
-   TINYDRM_MODE(200, 96, 46, 22),
+   DRM_SIMPLE_MODE(200, 96, 46, 22),
 };
 
 static const u8 repaper_e2200cs021_cs[] = { 0x00, 0x00, 0x00, 0x00,
0x01, 0xff, 0xe0, 0x00 };
 
 static const struct drm_display_mode repaper_e2271cs021_mode = {
-   TINYDRM_MODE(264, 176, 57, 38),
+   DRM_SIMPLE_MODE(264, 176, 57, 38),
 };
 
 static const u8 repaper_e2271cs021_cs[] = { 0x00, 0x00, 0x00, 0x7f,
diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c
index 01a8077954b3..5ee7db561349 100644
--- a/drivers/gpu/drm/tinydrm/st7586.c
+++ b/drivers/gpu/drm/tinydrm/st7586.c
@@ -312,7 +312,7 @@ static const struct drm_simple_display_pipe_funcs 
st7586_pipe_funcs = {
 };
 
 static const struct drm_display_mode st7586_mode = {
-   TINYDRM_MODE(178, 128, 37, 27),
+   DRM_SIMPLE_MODE(178, 128, 37, 27),
 };
 
 DEFINE_DRM_GEM_CMA_FOPS(st7586_fops);
diff --git a/drivers/gpu/drm/tinydrm/st7735r.c 
b/drivers/gpu/drm/tinydrm/st7735r.c
index 3bab9a9569a6..6c7904c205f0 100644
--- a/drivers/gpu/drm/tinydrm/st7735r.c
+++ b/drivers/gpu/drm/tinydrm/st7735r.c
@@ -111,7 +111,7 @@ static const struct drm_simple_display_pipe_funcs 
jd_t18003_t01_pipe_funcs = {
 };
 
 static const struct drm_display_mode jd_t18003_t01_mode = {
-   TINYDRM_MODE(128, 160, 28, 35),
+   DRM_SIMPLE_MODE(128, 160, 28, 35),
 };
 
 DEFINE_DRM_GEM_CMA_FOPS(st7735r_fops);
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h

[PATCH 01/11] drm: Add devm_drm_dev_init/register

2019-01-20 Thread Noralf Trønnes
This adds resource managed (devres) versions of drm_dev_init() and
drm_dev_register().

Also added is devm_drm_dev_register_with_fbdev() which sets up generic
fbdev emulation as well.

devm_drm_dev_register() isn't exported since there are no users.

Signed-off-by: Noralf Trønnes 
---
 Documentation/driver-model/devres.txt |   4 +
 drivers/gpu/drm/drm_drv.c | 106 ++
 include/drm/drm_drv.h |   6 ++
 3 files changed, 116 insertions(+)

diff --git a/Documentation/driver-model/devres.txt 
b/Documentation/driver-model/devres.txt
index b277cafce71e..6eebc28d4c21 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -254,6 +254,10 @@ DMA
   dmam_pool_create()
   dmam_pool_destroy()
 
+DRM
+  devm_drm_dev_init()
+  devm_drm_dev_register_with_fbdev()
+
 GPIO
   devm_gpiod_get()
   devm_gpiod_get_index()
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 381581b01d48..12129772be45 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -36,6 +36,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "drm_crtc_internal.h"
@@ -871,6 +872,111 @@ void drm_dev_unregister(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_dev_unregister);
 
+static void devm_drm_dev_init_release(void *data)
+{
+   drm_dev_put(data);
+}
+
+/**
+ * devm_drm_dev_init - Resource managed drm_dev_init()
+ * @parent: Parent device object
+ * @dev: DRM device
+ * @driver: DRM driver
+ *
+ * Managed drm_dev_init(). The DRM device initialized with this function is
+ * automatically released on driver detach. You must supply a
+ * _driver.release callback to control the finalization explicitly.
+ *
+ * Note: This function must be used together with
+ * devm_drm_dev_register_with_fbdev().
+ *
+ * RETURNS:
+ * 0 on success, or error code on failure.
+ */
+int devm_drm_dev_init(struct device *parent,
+ struct drm_device *dev,
+ struct drm_driver *driver)
+{
+   int ret;
+
+   if (WARN_ON(!parent || !driver->release))
+   return -EINVAL;
+
+   ret = drm_dev_init(dev, driver, parent);
+   if (ret)
+   return ret;
+
+   /*
+* This is a temporary release action that is used if probing fails
+* before devm_drm_dev_register() is called.
+*/
+   ret = devm_add_action(parent, devm_drm_dev_init_release, dev);
+   if (ret)
+   devm_drm_dev_init_release(dev);
+
+   return ret;
+}
+EXPORT_SYMBOL(devm_drm_dev_init);
+
+static void devm_drm_dev_register_release(void *data)
+{
+   drm_dev_unplug(data);
+}
+
+static int devm_drm_dev_register(struct drm_device *dev)
+{
+   int ret;
+
+   ret = drm_dev_register(dev, 0);
+   if (ret)
+   return ret;
+
+   /*
+* This has now served it's purpose, remove it to not mess up ref
+* counting.
+*/
+   devm_remove_action(dev->dev, devm_drm_dev_init_release, dev);
+
+   ret = devm_add_action(dev->dev, devm_drm_dev_register_release, dev);
+   if (ret)
+   devm_drm_dev_register_release(dev);
+
+   return ret;
+}
+
+/**
+ * devm_drm_dev_register_with_fbdev - Resource managed drm_dev_register()
+ *including generic fbdev emulation
+ * @dev: DRM device to register
+ * @fbdev_bpp: Preferred bits per pixel for fbdev (optional)
+ *
+ * Managed drm_dev_register() that also calls drm_fbdev_generic_setup().
+ * The DRM device registered with this function is automatically unregistered 
on
+ * driver detach using drm_dev_unplug().
+ *
+ * Note: This function must be used together with devm_drm_dev_init().
+ *
+ * For testing driver detach can be triggered manually by writing to the driver
+ * 'unbind' file.
+ *
+ * RETURNS:
+ * 0 on success, negative error code on failure.
+ */
+int devm_drm_dev_register_with_fbdev(struct drm_device *dev,
+unsigned int fbdev_bpp)
+{
+   int ret;
+
+   ret = devm_drm_dev_register(dev);
+   if (ret)
+   return ret;
+
+   drm_fbdev_generic_setup(dev, fbdev_bpp);
+
+   return 0;
+}
+EXPORT_SYMBOL(devm_drm_dev_register_with_fbdev);
+
 /**
  * drm_dev_set_unique - Set the unique name of a DRM device
  * @dev: device of which to set the unique name
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 35af23f5fa0d..c3f0477f2e7f 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -628,6 +628,12 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
 int drm_dev_register(struct drm_device *dev, unsigned long flags);
 void drm_dev_unregister(struct drm_device *dev);
 
+int devm_drm_dev_init(struct device *parent,
+ struct drm_device *dev,
+ struct drm_driver *driver);
+int devm_drm_dev_register_with_fbdev(struct drm_device *dev,
+unsigned int fbdev_bpp);
+
 

[PATCH 09/11] drm/tinydrm: Remove tinydrm_device

2019-01-20 Thread Noralf Trønnes
No more users left so it can go alongside its helpers.
Update the tinydrm docs description and remove todo entry.

Signed-off-by: Noralf Trønnes 
---
 Documentation/gpu/tinydrm.rst |  26 +--
 Documentation/gpu/todo.rst|   4 -
 drivers/gpu/drm/tinydrm/core/Makefile |   2 +-
 drivers/gpu/drm/tinydrm/core/tinydrm-core.c   | 169 --
 .../gpu/drm/tinydrm/core/tinydrm-helpers.c|   2 +
 include/drm/tinydrm/tinydrm.h |  42 -
 6 files changed, 10 insertions(+), 235 deletions(-)
 delete mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-core.c
 delete mode 100644 include/drm/tinydrm/tinydrm.h

diff --git a/Documentation/gpu/tinydrm.rst b/Documentation/gpu/tinydrm.rst
index 1ca726474af4..19969b989efb 100644
--- a/Documentation/gpu/tinydrm.rst
+++ b/Documentation/gpu/tinydrm.rst
@@ -1,24 +1,12 @@
-==
-drm/tinydrm Driver library
-==
+
+drm/tinydrm Tiny DRM drivers
+
 
-.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c
-   :doc: overview
+tinydrm is a collection of DRM drivers that are so small they can fit in a
+single source file.
 
-Core functionality
-==
-
-.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c
-   :doc: core
-
-.. kernel-doc:: include/drm/tinydrm/tinydrm.h
-   :internal:
-
-.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c
-   :export:
-
-Additional helpers
-==
+Helpers
+===
 
 .. kernel-doc:: include/drm/tinydrm/tinydrm-helpers.h
:internal:
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 38360ede1221..3495aec7a8d4 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -435,10 +435,6 @@ those drivers as simple as possible, so lots of room for 
refactoring:
   one of the ideas for having a shared dsi/dbi helper, abstracting away the
   transport details more.
 
-- Quick aside: The unregister devm stuff is kinda getting the lifetimes of
-  a drm_device wrong. Doesn't matter, since everyone else gets it wrong
-  too :-)
-
 Contact: Noralf Trønnes, Daniel Vetter
 
 AMD DC Display Driver
diff --git a/drivers/gpu/drm/tinydrm/core/Makefile 
b/drivers/gpu/drm/tinydrm/core/Makefile
index bf2df7326df7..f88ea7ad302f 100644
--- a/drivers/gpu/drm/tinydrm/core/Makefile
+++ b/drivers/gpu/drm/tinydrm/core/Makefile
@@ -1,3 +1,3 @@
-tinydrm-y := tinydrm-core.o tinydrm-helpers.o
+tinydrm-y := tinydrm-helpers.o
 
 obj-$(CONFIG_DRM_TINYDRM) += tinydrm.o
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
deleted file mode 100644
index e4a77feaacd6..
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2016 Noralf Trønnes
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/**
- * DOC: overview
- *
- * This library provides driver helpers for very simple display hardware.
- *
- * It is based on _simple_display_pipe coupled with a _connector which
- * has only one fixed _display_mode. The framebuffers are backed by the
- * cma helper and have support for framebuffer flushing (dirty).
- * fbdev support is also included.
- *
- */
-
-/**
- * DOC: core
- *
- * The driver allocates _device, initializes it using
- * devm_tinydrm_init(), sets up the pipeline using tinydrm_display_pipe_init()
- * and registers the DRM device using devm_tinydrm_register().
- */
-
-static const struct drm_mode_config_funcs tinydrm_mode_config_funcs = {
-   .fb_create = drm_gem_fb_create_with_dirty,
-   .atomic_check = drm_atomic_helper_check,
-   .atomic_commit = drm_atomic_helper_commit,
-};
-
-static int tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
-   struct drm_driver *driver)
-{
-   struct drm_device *drm;
-
-   /*
-* We don't embed drm_device, because that prevent us from using
-* devm_kzalloc() to allocate tinydrm_device in the driver since
-* drm_dev_put() frees the structure. The devm_ functions provide
-* for easy error handling.
-*/
-   drm = drm_dev_alloc(driver, parent);
-   if (IS_ERR(drm))
-   return PTR_ERR(drm);
-
-   tdev->drm = drm;
-   drm->dev_private = tdev;
-   drm_mode_config_init(drm);
-   drm->mode_config.funcs = _mode_config_funcs;
-   drm->mode_config.allow_fb_modifiers = true;
-
-   return 0;
-}
-
-static void tinydrm_fini(struct tinydrm_device *tdev)
-{
-   drm_mode_config_cleanup(tdev->drm);
-   tdev->drm->dev_private = NULL;
-   

[PATCH 00/11] drm/tinydrm: Remove tinydrm_device

2019-01-20 Thread Noralf Trønnes
This patchset is part of the effort to remove tinydrm.ko. It removes
struct tinydrm_device and tinydrm.h.

While doing this refactoring I have ensured that device unplug is
working.

The generic fbdev emulation has now been verified that it properly
handles device unplug with open file handles and bound fbcon.

Noralf.

Noralf Trønnes (11):
  drm: Add devm_drm_dev_init/register
  drm/modes: Add DRM_SIMPLE_MODE()
  drm/simple-kms-helper: Add drm_simple_connector_create()
  drm/tinydrm: Remove tinydrm_display_pipe_init()
  drm/tinydrm/mipi-dbi: Add drm_to_mipi_dbi()
  drm/tinydrm: Remove tinydrm_shutdown()
  drm/tinydrm/repaper: Use devm_drm_dev_*()
  drm/tinydrm: Use devm_drm_dev_*()
  drm/tinydrm: Remove tinydrm_device
  drm/tinydrm: Use drm_dev_enter/exit()
  drm/fb-helper: generic: Don't take module ref for fbcon

 Documentation/driver-model/devres.txt |   4 +
 Documentation/gpu/tinydrm.rst |  29 +--
 Documentation/gpu/todo.rst|   4 -
 drivers/gpu/drm/drm_drv.c | 106 ++
 drivers/gpu/drm/drm_fb_helper.c   |   6 +-
 drivers/gpu/drm/drm_simple_kms_helper.c   | 122 
 drivers/gpu/drm/tinydrm/core/Makefile |   2 +-
 drivers/gpu/drm/tinydrm/core/tinydrm-core.c   | 183 --
 .../gpu/drm/tinydrm/core/tinydrm-helpers.c|   2 +
 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c   | 183 --
 drivers/gpu/drm/tinydrm/hx8357d.c |  44 +++--
 drivers/gpu/drm/tinydrm/ili9225.c |  67 +--
 drivers/gpu/drm/tinydrm/ili9341.c |  44 +++--
 drivers/gpu/drm/tinydrm/mi0283qt.c|  52 +++--
 drivers/gpu/drm/tinydrm/mipi-dbi.c| 133 +
 drivers/gpu/drm/tinydrm/repaper.c | 129 
 drivers/gpu/drm/tinydrm/st7586.c  | 133 +++--
 drivers/gpu/drm/tinydrm/st7735r.c |  44 +++--
 include/drm/drm_drv.h |   6 +
 include/drm/drm_modes.h   |  16 ++
 include/drm/drm_simple_kms_helper.h   |   6 +
 include/drm/tinydrm/mipi-dbi.h|  27 ++-
 include/drm/tinydrm/tinydrm.h |  75 ---
 23 files changed, 715 insertions(+), 702 deletions(-)
 delete mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-core.c
 delete mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
 delete mode 100644 include/drm/tinydrm/tinydrm.h

-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 03/11] drm/simple-kms-helper: Add drm_simple_connector_create()

2019-01-20 Thread Noralf Trønnes
This adds a function that creates a simple connector that has only one
static mode. Additionally add a helper to set _mode_config width
and height from the static mode.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_simple_kms_helper.c | 122 
 include/drm/drm_simple_kms_helper.h |   6 ++
 2 files changed, 128 insertions(+)

diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c 
b/drivers/gpu/drm/drm_simple_kms_helper.c
index 917812448d1b..ca29975afefe 100644
--- a/drivers/gpu/drm/drm_simple_kms_helper.c
+++ b/drivers/gpu/drm/drm_simple_kms_helper.c
@@ -11,6 +11,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -299,4 +301,124 @@ int drm_simple_display_pipe_init(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_simple_display_pipe_init);
 
+static const struct drm_connector_helper_funcs drm_simple_connector_hfuncs = {
+   /* dummy for the atomic helper */
+};
+
+static int drm_simple_connector_fill_modes(struct drm_connector *connector,
+  uint32_t maxX, uint32_t maxY)
+{
+   return 1;
+}
+
+static void drm_simple_connector_destroy(struct drm_connector *connector)
+{
+   drm_connector_cleanup(connector);
+   kfree(connector);
+}
+
+static const struct drm_connector_funcs drm_simple_connector_funcs = {
+   .reset = drm_atomic_helper_connector_reset,
+   .fill_modes = drm_simple_connector_fill_modes,
+   .destroy = drm_simple_connector_destroy,
+   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+};
+
+/**
+ * drm_simple_connector_create - Create a connector with one static mode
+ * @dev: DRM device
+ * @connector_type: Connector type
+ * @mode: Supported display mode
+ * @rotation: Initial @mode rotation in degrees
+ *
+ * This function creates a _connector that has one fixed _display_mode
+ * which will be rotated according to @rotation.
+ *
+ * Returns:
+ * Pointer to connector on success, or ERR_PTR on failure.
+ */
+struct drm_connector *
+drm_simple_connector_create(struct drm_device *dev, int connector_type,
+   const struct drm_display_mode *mode,
+   unsigned int rotation)
+{
+   struct drm_display_mode *mode_dup = NULL;
+   struct drm_connector *connector;
+   int ret;
+
+   connector = kzalloc(sizeof(*connector), GFP_KERNEL);
+   if (!connector)
+   return ERR_PTR(-ENOMEM);
+
+   drm_connector_helper_add(connector, _simple_connector_hfuncs);
+   ret = drm_connector_init(dev, connector, _simple_connector_funcs,
+connector_type);
+   if (ret)
+   goto err_free;
+
+   connector->status = connector_status_connected;
+
+   mode_dup = drm_mode_duplicate(dev, mode);
+   if (!mode_dup) {
+   ret = -ENOMEM;
+   goto err_cleanup;
+   }
+
+   if (rotation == 90 || rotation == 270) {
+   swap(mode_dup->hdisplay, mode_dup->vdisplay);
+   swap(mode_dup->hsync_start, mode_dup->vsync_start);
+   swap(mode_dup->hsync_end, mode_dup->vsync_end);
+   swap(mode_dup->htotal, mode_dup->vtotal);
+   swap(mode_dup->width_mm, mode_dup->height_mm);
+   } else if (rotation != 0 && rotation != 180) {
+   DRM_ERROR("Illegal rotation value %u\n", rotation);
+   ret = -EINVAL;
+   goto err_cleanup;
+   }
+
+   mode_dup->type |= DRM_MODE_TYPE_PREFERRED;
+   if (mode_dup->name[0] == '\0')
+   drm_mode_set_name(mode_dup);
+
+   list_add(_dup->head, >modes);
+
+   connector->display_info.width_mm = mode_dup->width_mm;
+   connector->display_info.height_mm = mode_dup->height_mm;
+
+   return connector;
+
+err_cleanup:
+   drm_connector_cleanup(connector);
+   drm_mode_destroy(dev, mode_dup);
+err_free:
+   kfree(connector);
+
+   return ERR_PTR(ret);
+}
+EXPORT_SYMBOL(drm_simple_connector_create);
+
+/**
+ * drm_simple_connector_set_mode_config - Set _mode_config width and height
+ * @connector: Connector
+ *
+ * This function sets the _mode_config min/max width and height based on 
the
+ * connector fixed display mode.
+ */
+void drm_simple_connector_set_mode_config(struct drm_connector *connector)
+{
+   struct drm_mode_config *mode_config = >dev->mode_config;
+   struct drm_display_mode *mode;
+
+   mode = list_first_entry(>modes, struct drm_display_mode, 
head);
+   if (WARN_ON(!mode))
+   return;
+
+   mode_config->min_width = mode->hdisplay;
+   mode_config->max_width = mode->hdisplay;
+   mode_config->min_height = mode->vdisplay;
+   mode_config->max_height = mode->vdisplay;
+}
+EXPORT_SYMBOL(drm_simple_connector_set_mode_config);
+
 MODULE_LICENSE("GPL");
diff --git a/include/drm/drm_simple_kms_helper.h