[PATCH 4/4] drm/sun4i: dotclock: Round to closest clock rate

2016-09-19 Thread Chen-Yu Tsai
On Mon, Sep 19, 2016 at 3:16 AM, Maxime Ripard
 wrote:
> Hi,
>
> On Thu, Sep 15, 2016 at 11:14:02PM +0800, Chen-Yu Tsai wrote:
>> With display pixel clocks we want to have the closest possible clock
>> rate, to minimize timing and refresh rate skews. Whether the actual
>> clock rate is higher or lower than the requested rate is less important.
>>
>> Also check candidates against the requested rate, rather than the
>> ideal parent rate, the varying dividers also influence the difference
>> between the requested rate and the rounded rate.
>>
>> Signed-off-by: Chen-Yu Tsai 
>> ---
>>  drivers/gpu/drm/sun4i/sun4i_dotclock.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/sun4i/sun4i_dotclock.c 
>> b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
>> index 3eb99784f371..d401156490f3 100644
>> --- a/drivers/gpu/drm/sun4i/sun4i_dotclock.c
>> +++ b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
>> @@ -90,7 +90,8 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw, 
>> unsigned long rate,
>>   goto out;
>>   }
>>
>> - if ((rounded < ideal) && (rounded > best_parent)) {
>> + if (abs(rate - rounded / i) <
>> + abs(rate - best_parent / best_div)) {
>
> I'm not sure what you're trying to do here. Why is the divider involved?

Say you want the dotclock at X, so you try Y = 6 ~ 127 for the divider.
Now you're asking the CCF to round (X*Y).

In the original code, you were comparing the result of rounding (X * Y).

if ((rounded < ideal) && (rounded > best_parent)) {
best_parent = rounded;
best_div = i;
}

where ideal = X * Y (i in the code). Given the divider increases in
the loop, you are actually not closing in on the best divider, but the
highest divider that doesn't give a higher rate than the ideal rate.

Including the divider makes it compare the actual dot clock frequency
if a given divider was used.

Does this makes sense? Explaining this kind of makes my head spin...

Regards
ChenYu

>
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com


[GIT PULL] etnaviv-next for 4.9

2016-09-19 Thread Lucas Stach
Hi Dave,

just wanted to make sure that the etnaviv pull-request doesn't fall
through the cracks again, before I'm heading off to XDC.

Hopefully the hickups in our infrastructure haven't caused you any
inconvenience with this one.

Regards,
Lucas

Am Donnerstag, den 15.09.2016, 16:28 +0200 schrieb Lucas Stach:
> Hi Dave,
> 
> this is the etnaviv feature pull-request for Linux 4.9.
> 
> Notable changes:
> 
> - Cleanups from Fabio to some error paths and proper error
> propagation.
> 
> - Lots of refactoring and new code to support the new MMU version 2,
> still relatively unoptimized and doesn't yet provide better process
> isolation than MMUv1, but enough to get newer cores up and running.
> 
> - New hardware support: GC3000, as found on the NXP i.MX6 QuadPlus
> SoC.
> 
> Regards,
> Lucas
> 
> The following changes since commit
> 29b4817d4018df78086157ea3a55c1d9424a7cfc:
> 
>   Linux 4.8-rc1 (2016-08-07 18:18:00 -0700)
> 
> are available in the git repository at:
> 
>   git://git.pengutronix.de/git/lst/linux.git drm-etnaviv-next
> 
> for you to fetch changes up to
> 1b94a9b7d2dc26ddfd66b0d9c4533040a78cc394:
> 
>   drm/etnaviv: mark whole context as lost in recover worker (2016-09-
> 15 15:29:46 +0200)
> 
> 
> Fabio Estevam (3):
>       drm/etnaviv: check for errors when enabling clocks
>       drm/etnaviv: remove unneeded 'fail' label
>       drm/etnaviv: remove unneeded variable initialization
> 
> Lucas Stach (22):
>       drm/etnaviv: take GPU lock later in the submit process
>       drm/etnaviv: fold various clock enable/disable functions into
> top ones
>       drm/etnaviv: only try to use the linear window on MMUv1
>       drm/etnaviv: only check if the cmdbuf is inside the linear
> window on MMUv1
>       drm/etnaviv: rename etnaviv_iommu_domain_restore to
> etnaviv_iommuv1_restore
>       drm/etnaviv: move linear window setup into
> etnaviv_iommuv1_restore
>       drm/etnaviv: indirect IOMMU restore through etnaviv MMU
>       drm/etnaviv: move IOMMU domain allocation into etnaviv MMU
>       drm/etnaviv: remove unused iommu_v2 header
>       drm/etnaviv: move gpu_va() to etnaviv mmu
>       drm/etnaviv: split out wait for gpu idle
>       drm/etnaviv: split out FE start
>       drm/etnaviv: split out iova search and MMU reaping logic
>       drm/etnaviv: map cmdbuf through MMU on version 2
>       drm/etnaviv: add function to construct MMUv2 init buffer
>       drm/etnaviv: add flushing logic for MMUv2
>       drm/etnaviv: handle MMU exception in IRQ handler
>       drm/etnaviv: implement IOMMUv2 translation
>       drm/etnaviv: fix up model and revision for GC2000+
>       drm/etnaviv: space out IOVA layout for cmdbufs on MMUv2
>       drm/etnaviv: record correct cmdbuf IOVA in dump
>       drm/etnaviv: mark whole context as lost in recover worker
> 
>  drivers/gpu/drm/etnaviv/etnaviv_buffer.c   |  81
> +
>  drivers/gpu/drm/etnaviv/etnaviv_drv.h      |   1 +
>  drivers/gpu/drm/etnaviv/etnaviv_dump.c     |   6 ++-
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c      | 243
> ++---
> --
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.h      |   4 ++
>  drivers/gpu/drm/etnaviv/etnaviv_iommu.c    |  15 +--
>  drivers/gpu/drm/etnaviv/etnaviv_iommu.h    |  10 ++---
>  drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c | 261
> +
> --
>  drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.h |  25 ---
>  drivers/gpu/drm/etnaviv/etnaviv_mmu.c      | 149
> -
>  drivers/gpu/drm/etnaviv/etnaviv_mmu.h      |   9 +++-
>  drivers/gpu/drm/etnaviv/state_hi.xml.h     |   9 ++--
>  12 files changed, 587 insertions(+), 226 deletions(-)
>  delete mode 100644 drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.h
> 
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/4] drm/sun4i: rgb: Declare RGB encoder and connector as MIPI DPI

2016-09-19 Thread Chen-Yu Tsai
On Mon, Sep 19, 2016 at 3:12 AM, Maxime Ripard
 wrote:
> Hi,
>
> On Thu, Sep 15, 2016 at 11:13:59PM +0800, Chen-Yu Tsai wrote:
>> The 18 or 24 bit parallel RGB LCD panel interface found on Allwinner
>> SoCs matches the description of MIPI DPI. Declare the RGB encoder and
>> connector as MIPI DPI.
>
> Unfortunately, even it that patch might be true (is there a public
> spec for that standard?), this breaks the user-space, so there's no

Not that I know of. I basically googled the term and looked at other
datasheets and asked on #linux-arm-kernel.

> way we change this.

:(

ChenYu


[PATCH] drm/udl: Fix for the X server screen update v2

2016-09-19 Thread Daniel Vetter
On Mon, Sep 19, 2016 at 8:27 PM, poma  wrote:
> @@ -122,14 +126,14 @@ int udl_handle_damage(struct udl_framebuffer *fb, int 
> x, int y,
> return 0;
> cmd = urb->transfer_buffer;
>
> -   for (i = y; i < height ; i++) {
> +   for (i = y; i <= y2 ; i++) {

I think a simpler fix (which retains Noralf's nice cleanup would be to
change the loop condition to i < y + height. At least that seems to be
the underlying bug. Can you pls test that and then submit either that
one-liner (if it works) or your original patch (it's missing the
signed-off-by right now, so can't be merged as-is)? Either one has my
r-b (preemptive since I'm travelling).

Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PULL] drm-amdkfd-next

2016-09-19 Thread Oded Gabbay
Hi Dave,

This is amdkfd's pull request for kernel 4.9. It contains a fix to a possible
infinite loop bug and a couple of other minor "cleaning" patches.

Thanks,
Oded

The following changes since commit 9f8cf165c62913244479832f04c44cd77ffc9293:

  Merge tag 'topic/drm-misc-2016-09-19' of 
git://anongit.freedesktop.org/drm-intel into drm-next (2016-09-19 17:16:02 
+1000)

are available in the git repository at:

  git://people.freedesktop.org/~gabbayo/linux tags/drm-amdkfd-next-2016-09-19

for you to fetch changes up to e88a614c403573e861f82c063d8aee25cf109f17:

  drm/amdkfd: Pass 'struct queue_propertices' by reference (2016-09-19 20:58:35 
+0300)


Edward O'Callaghan (6):
  drm/amdkfd: Tidy up kfd_generate_gpu_id() uint64_t bitshift unpack
  drm/amdkfd: Add some missing memset zero'ing in queue init func
  drm/amdkfd: Reuse function to find a process through pasid
  drm/amdkfd: Fix possible infinite loop
  drm/amdkfd: Unify multiple calls to pr_debug() into one
  drm/amdkfd: Pass 'struct queue_propertices' by reference

 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c  | 17 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c  | 17 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c  | 16 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c  |  5 +-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h  |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c   | 61 +-
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_queue.c |  4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c  |  8 +--
 9 files changed, 65 insertions(+), 67 deletions(-)


[PATCH 5/5] drm/imx: add exclusive fence to plane state

2016-09-19 Thread Daniel Vetter
On Thu, Aug 11, 2016 at 11:18 AM, Lucas Stach  wrote:
> This allows the atomic helper to wait on them, instead of open-coding
> the same in the imx-drm driver.
>
> Signed-off-by: Lucas Stach 
> ---
>  drivers/gpu/drm/imx/imx-drm-core.c | 63 
> +-
>  1 file changed, 28 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
> b/drivers/gpu/drm/imx/imx-drm-core.c
> index 66b3556f7b79..2d3f32f1b13b 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -152,50 +152,43 @@ static void imx_drm_output_poll_changed(struct 
> drm_device *drm)
> drm_fbdev_cma_hotplug_event(imxdrm->fbhelper);
>  }
>
> +static int imx_drm_atomic_commit(struct drm_device *dev,
> +struct drm_atomic_state *state,
> +bool nonblock)
> +{
> +   struct drm_plane_state *plane_state;
> +   struct drm_plane *plane;
> +   struct dma_buf *dma_buf;
> +   int i;
> +
> +   /*
> +* If the plane fb has an dma-buf attached, fish out the exclusive
> +* fence for the atomic helper to wait on.
> +*/
> +   for_each_plane_in_state(state, plane, plane_state, i) {
> +   if ((plane->state->fb != plane_state->fb) && plane_state->fb) 
> {
> +   dma_buf = drm_fb_cma_get_gem_obj(plane_state->fb,
> +0)->base.dma_buf;
> +   if (!dma_buf)
> +   continue;
> +   plane_state->fence =
> +   
> reservation_object_get_excl_rcu(dma_buf->resv);
> +   }
> +   }

Just an fyi, but the idea was that you could do this in youre
prepare_plane hook, assuming that only when userspace flips is it
interested in syncing (for backwards compat reasons). But this gets
the job done too.

The upshot of doing this consistently in a prepare_plane hook is that
it would then allow us to have a shared implementation for all cma
based kms drivers. If you feel bored, I'd be happy to take a look at a
refactor patch which would extract that helper (and wire it up for
imx).

Just a drive-by comment since I stumbled over this as a conflict
between -next and -fixes when rebuilding intel trees.
-Daniel

> +
> +   return drm_atomic_helper_commit(dev, state, nonblock);
> +}
> +
>  static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
> .fb_create = drm_fb_cma_create,
> .output_poll_changed = imx_drm_output_poll_changed,
> .atomic_check = drm_atomic_helper_check,
> -   .atomic_commit = drm_atomic_helper_commit,
> +   .atomic_commit = imx_drm_atomic_commit,
>  };
>
>  static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state)
>  {
> struct drm_device *dev = state->dev;
> -   struct drm_crtc *crtc;
> -   struct drm_crtc_state *crtc_state;
> -   struct drm_plane_state *plane_state;
> -   struct drm_gem_cma_object *cma_obj;
> -   struct fence *excl;
> -   unsigned shared_count;
> -   struct fence **shared;
> -   unsigned int i, j;
> -   int ret;
> -
> -   /* Wait for fences. */
> -   for_each_crtc_in_state(state, crtc, crtc_state, i) {
> -   plane_state = crtc->primary->state;
> -   if (plane_state->fb) {
> -   cma_obj = drm_fb_cma_get_gem_obj(plane_state->fb, 0);
> -   if (cma_obj->base.dma_buf) {
> -   ret = reservation_object_get_fences_rcu(
> -   cma_obj->base.dma_buf->resv, &excl,
> -   &shared_count, &shared);
> -   if (unlikely(ret))
> -   DRM_ERROR("failed to get fences "
> - "for buffer\n");
> -
> -   if (excl) {
> -   fence_wait(excl, false);
> -   fence_put(excl);
> -   }
> -   for (j = 0; j < shared_count; i++) {
> -   fence_wait(shared[j], false);
> -   fence_put(shared[j]);
> -   }
> -   }
> -   }
> -   }
>
> drm_atomic_helper_commit_modeset_disables(dev, state);
>
> --
> 2.8.1
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH 3/3] drm/sun4i: Fix the high buffer address mask

2016-09-19 Thread Maxime Ripard
The highest 3bits of the 4 layers buffers are all part of the same
register. However, our mask computation was wrong, leading to all the
lowest register bits being removed when we use regmap_update_bits, which
will lead to the buffers being set to some random part of the RAM.

Fix our mask.

Signed-off-by: Maxime Ripard 
---
 drivers/gpu/drm/sun4i/sun4i_backend.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.h 
b/drivers/gpu/drm/sun4i/sun4i_backend.h
index 7070bb3434e5..19c9b2a84b9c 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.h
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.h
@@ -52,8 +52,8 @@
 #define SUN4I_BACKEND_LAYFB_L32ADD_REG(l)  (0x850 + (0x4 * (l)))

 #define SUN4I_BACKEND_LAYFB_H4ADD_REG  0x860
-#define SUN4I_BACKEND_LAYFB_H4ADD_MSK(l)   GENMASK(3 + ((l) * 8), 
0)
-#define SUN4I_BACKEND_LAYFB_H4ADD(l, val)  ((val) << ((l) 
* 8))
+#define SUN4I_BACKEND_LAYFB_H4ADD_MSK(l)   GENMASK(3 + ((l) * 8), 
(l) * 8)
+#define SUN4I_BACKEND_LAYFB_H4ADD(l, val)  ((val) << ((l) * 8))

 #define SUN4I_BACKEND_REGBUFFCTL_REG   0x870
 #define SUN4I_BACKEND_REGBUFFCTL_AUTOLOAD_DIS  BIT(1)
-- 
2.9.3



[PATCH 2/3] drm/sun4i: tv: Check mode pointer

2016-09-19 Thread Maxime Ripard
The drm_mode_create call might return NULL in case of a failure, and the
current code doesn't check for that. Make sure it does.

Reported-by: Dan Carpenter 
Signed-off-by: Maxime Ripard 
---
 drivers/gpu/drm/sun4i/sun4i_tv.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c b/drivers/gpu/drm/sun4i/sun4i_tv.c
index b84147896294..6bf1057c132b 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
@@ -507,9 +507,15 @@ static int sun4i_tv_comp_get_modes(struct drm_connector 
*connector)
int i;

for (i = 0; i < ARRAY_SIZE(tv_modes); i++) {
-   struct drm_display_mode *mode = drm_mode_create(connector->dev);
+   struct drm_display_mode *mode;
struct tv_mode *tv_mode = &tv_modes[i];

+   mode = drm_mode_create(connector->dev);
+   if (!mode) {
+   DRM_ERROR("Failed to create a new display mode\n");
+   return 0;
+   }
+
strcpy(mode->name, tv_mode->name);

sun4i_tv_mode_to_drm_mode(tv_mode, mode);
-- 
2.9.3



[PATCH 1/3] drm/sun4i: Fix formats usable by the primary plane

2016-09-19 Thread Maxime Ripard
Even though all our planes can support the ARGB formats, the lowest plane
(ie the primary plane) cannot use the alpha component, otherwise it will
just result in the transparent area being entirely black.

Since some applications will still require the ARGB format, let's force the
format to XRGB to drop the alpha component entirely.

Signed-off-by: Maxime Ripard 
---
 drivers/gpu/drm/sun4i/sun4i_backend.c |  9 --
 drivers/gpu/drm/sun4i/sun4i_layer.c   | 56 ---
 2 files changed, 46 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c 
b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 3ab560450a82..df7e95ac8e56 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -83,8 +83,13 @@ void sun4i_backend_layer_enable(struct sun4i_backend 
*backend,
 }
 EXPORT_SYMBOL(sun4i_backend_layer_enable);

-static int sun4i_backend_drm_format_to_layer(u32 format, u32 *mode)
+static int sun4i_backend_drm_format_to_layer(struct drm_plane *plane,
+u32 format, u32 *mode)
 {
+   if ((plane->type == DRM_PLANE_TYPE_PRIMARY) &&
+   (format == DRM_FORMAT_ARGB))
+   format = DRM_FORMAT_XRGB;
+
switch (format) {
case DRM_FORMAT_ARGB:
*mode = SUN4I_BACKEND_LAY_FBFMT_ARGB;
@@ -164,7 +169,7 @@ int sun4i_backend_update_layer_formats(struct sun4i_backend 
*backend,
DRM_DEBUG_DRIVER("Switching display backend interlaced mode %s\n",
 interlaced ? "on" : "off");

-   ret = sun4i_backend_drm_format_to_layer(fb->pixel_format, &val);
+   ret = sun4i_backend_drm_format_to_layer(plane, fb->pixel_format, &val);
if (ret) {
DRM_DEBUG_DRIVER("Invalid format\n");
return val;
diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c 
b/drivers/gpu/drm/sun4i/sun4i_layer.c
index 068ab806309b..ea9a42176bd5 100644
--- a/drivers/gpu/drm/sun4i/sun4i_layer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
@@ -19,7 +19,12 @@
 #include "sun4i_drv.h"
 #include "sun4i_layer.h"

-#define SUN4I_NUM_LAYERS   2
+struct sun4i_plane_desc {
+  enum drm_plane_type type;
+  u8  pipe;
+  const uint32_t  *formats;
+  uint32_tnformats;
+};

 static int sun4i_backend_layer_atomic_check(struct drm_plane *plane,
struct drm_plane_state *state)
@@ -65,14 +70,35 @@ static const struct drm_plane_funcs 
sun4i_backend_layer_funcs = {
.update_plane   = drm_atomic_helper_update_plane,
 };

-static const uint32_t sun4i_backend_layer_formats[] = {
+static const uint32_t sun4i_backend_layer_formats_primary[] = {
DRM_FORMAT_ARGB,
+   DRM_FORMAT_RGB888,
DRM_FORMAT_XRGB,
+};
+
+static const uint32_t sun4i_backend_layer_formats_overlay[] = {
+   DRM_FORMAT_ARGB,
DRM_FORMAT_RGB888,
+   DRM_FORMAT_XRGB,
+};
+
+static const struct sun4i_plane_desc sun4i_backend_planes[] = {
+   {
+  .type = DRM_PLANE_TYPE_PRIMARY,
+  .pipe = 0,
+  .formats = sun4i_backend_layer_formats_primary,
+  .nformats = ARRAY_SIZE(sun4i_backend_layer_formats_primary),
+   },
+   {
+  .type = DRM_PLANE_TYPE_OVERLAY,
+  .pipe = 1,
+  .formats = sun4i_backend_layer_formats_overlay,
+  .nformats = ARRAY_SIZE(sun4i_backend_layer_formats_overlay),
+   },
 };

 static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
-   enum drm_plane_type type)
+   const struct sun4i_plane_desc 
*plane)
 {
struct sun4i_drv *drv = drm->dev_private;
struct sun4i_layer *layer;
@@ -84,10 +110,8 @@ static struct sun4i_layer *sun4i_layer_init_one(struct 
drm_device *drm,

ret = drm_universal_plane_init(drm, &layer->plane, BIT(0),
   &sun4i_backend_layer_funcs,
-  sun4i_backend_layer_formats,
-  ARRAY_SIZE(sun4i_backend_layer_formats),
-  type,
-  NULL);
+  plane->formats, plane->nformats,
+  plane->type, NULL);
if (ret) {
dev_err(drm->dev, "Couldn't initialize layer\n");
return ERR_PTR(ret);
@@ -97,7 +121,7 @@ static struct sun4i_layer *sun4i_layer_init_one(struct 
drm_device *drm,
 &sun4i_backend_layer_helper_funcs);
layer->drv = drv;

-   if (type == DRM_PLANE_TYPE_PRIMARY)
+   if (plane->type == DRM_PLANE_TYPE_PRIMARY)
drv->primary = &layer->plane;

return layer;
@@ -109,8

[PATCH 13/14] drm/sun4i: Fix sparse warnings

2016-09-19 Thread Maxime Ripard
1;4402;0c
On Mon, Sep 19, 2016 at 04:33:54PM +0300, ville.syrjala at linux.intel.com 
wrote:
> From: Ville Syrjälä 
> 
> drm/sun4i/sun4i_tv.c:181:21: warning: symbol 'ntsc_video_levels' was not 
> declared. Should it be static?
> drm/sun4i/sun4i_tv.c:185:21: warning: symbol 'pal_video_levels' was not 
> declared. Should it be static?
> drm/sun4i/sun4i_tv.c:189:21: warning: symbol 'ntsc_burst_levels' was not 
> declared. Should it be static?
> drm/sun4i/sun4i_tv.c:193:21: warning: symbol 'pal_burst_levels' was not 
> declared. Should it be static?
> drm/sun4i/sun4i_tv.c:197:20: warning: symbol 'ntsc_color_gains' was not 
> declared. Should it be static?
> drm/sun4i/sun4i_tv.c:201:20: warning: symbol 'pal_color_gains' was not 
> declared. Should it be static?
> drm/sun4i/sun4i_tv.c:205:26: warning: symbol 'ntsc_resync_parameters' was not 
> declared. Should it be static?
> drm/sun4i/sun4i_tv.c:209:26: warning: symbol 'pal_resync_parameters' was not 
> declared. Should it be static?
> drm/sun4i/sun4i_tv.c:213:16: warning: symbol 'tv_modes' was not declared. 
> Should it be static?
> 
> Cc: Maxime Ripard 
> Signed-off-by: Ville Syrjälä 

Applied, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/6e3f87ac/attachment.sig>


[Bug 97221] monitor miss detection, philips 242G5

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97221

--- Comment #6 from Thomas  ---
Same Probleme here with other monitors.
But the system freezes totally because i've two of the same.

The Effect is only when the monitor is going in engery saving mode. (Not the 
system, this is disabled).

After this the system did not wake up every time and i can't reactivate it.

Sometime i got an error under gnome like this:
could not set the configuration for CRTC79

Then the system is activated, but the second monitor is still offline afer a
couple of seconds an pressing the ok button everything works fine.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/4d2cc5d9/attachment.html>


[Bug 97221] monitor miss detection, philips 242G5

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97221

--- Comment #5 from Thomas  ---
Created attachment 126636
  --> https://bugs.freedesktop.org/attachment.cgi?id=126636&action=edit
syslog

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/ae6f1f83/attachment.html>


[Bug 97221] monitor miss detection, philips 242G5

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97221

--- Comment #4 from Thomas  ---
Created attachment 126635
  --> https://bugs.freedesktop.org/attachment.cgi?id=126635&action=edit
dmesg

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/03ed1e85/attachment.html>


[Bug 97221] monitor miss detection, philips 242G5

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97221

Thomas  changed:

   What|Removed |Added

 Attachment #126633|0   |1
is obsolete||

--- Comment #3 from Thomas  ---
Created attachment 126634
  --> https://bugs.freedesktop.org/attachment.cgi?id=126634&action=edit
Xorg.0.log

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/4f690625/attachment.html>


[PATCH] drm/udl: Fix for the X server screen update v2

2016-09-19 Thread poma
Fix for DisplayLink GPU USB2.0 device X server screen update

Within X server on top of DisplayLink GPU USB2.0 device,
screen content is not refreshed i.e. updated,
which is the most basic functionality of the screen.

This partially (udl_handle_damage()) reverts commit:

- e375882406d0cc24030746638592004755ed4ae0
  "drm/udl: Use drm_fb_helper deferred_io support"

Thanks Noralf for the comments.

Reported and
Tested-by: poma 
---
 drivers/gpu/drm/udl/udl_fb.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index d5df555..05ab114 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -90,6 +90,7 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int 
y,
struct urb *urb;
int aligned_x;
int bpp = (fb->base.bits_per_pixel / 8);
+   int x2, y2;

if (!fb->active_16)
return 0;
@@ -115,6 +116,9 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, 
int y,
(y + height > fb->base.height))
return -EINVAL;

+   x2 = x + width - 1;
+   y2 = y + height - 1;
+
start_cycles = get_cycles();

urb = udl_get_urb(dev);
@@ -122,14 +126,14 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, 
int y,
return 0;
cmd = urb->transfer_buffer;

-   for (i = y; i < height ; i++) {
+   for (i = y; i <= y2 ; i++) {
const int line_offset = fb->base.pitches[0] * i;
const int byte_offset = line_offset + (x * bpp);
const int dev_byte_offset = (fb->base.width * bpp * i) + (x * 
bpp);
if (udl_render_hline(dev, bpp, &urb,
 (char *) fb->obj->vmapping,
 &cmd, byte_offset, dev_byte_offset,
-width * bpp,
+(x2 - x + 1) * bpp,
 &bytes_identical, &bytes_sent))
goto error;
}
-- 
2.7.4




[Bug 97221] monitor miss detection, philips 242G5

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97221

Thomas  changed:

   What|Removed |Added

 CC||w3bm4573r at gmx.de

--- Comment #2 from Thomas  ---
Created attachment 126633
  --> https://bugs.freedesktop.org/attachment.cgi?id=126633&action=edit
syslog

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/7e54e9f8/attachment.html>


[Bug 97856] Computer restart playing 3D games (possibly overheating)

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97856

--- Comment #7 from Alex Henry  ---
Created attachment 126631
  --> https://bugs.freedesktop.org/attachment.cgi?id=126631&action=edit
Xorg log and dmesg from a radeon.dpm=1 boot

Rebooted my system as you've asked. /sys/class/drm/card0/device/power_method
does indeed show "dpm" now (was "profile" last boot).

In my research so far, the only thing that I've saw in the logs that could have
been related to this issue was the IOMMU warning in dmesg but as far as I can
tell this isn't supported by my motherboard (asus-m5a78l-m-lx) since I can't
find anything related on the BIOS setup utility.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/5b75d207/attachment-0001.html>


[PATCH 09/14] drm/msm: Fix sparse warnings

2016-09-19 Thread Jani Nikula
On Mon, 19 Sep 2016, Emil Velikov  wrote:
> On 19 September 2016 at 14:33,   wrote:
>
>> --- a/drivers/gpu/drm/msm/msm_fb.c
>> +++ b/drivers/gpu/drm/msm/msm_fb.c
>> @@ -132,7 +132,7 @@ const struct msm_format *msm_framebuffer_format(struct 
>> drm_framebuffer *fb)
>>  struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
>> struct drm_file *file, const struct drm_mode_fb_cmd2 
>> *mode_cmd)
>>  {
>> -   struct drm_gem_object *bos[4] = {0};
>> +   struct drm_gem_object *bos[4] = {};
> Fwiw I was reminded using empty initializers isn't standard C [1].

Well, meh, we're not doing -std=c11 -pedantic. Arguably {} is neater.

I guess the commit message lacks the sparse warning about using plain
integer 0 as NULL pointer.

BR,
Jani.



>
> Regards,
> Emil
>
> [1] 
> http://stackoverflow.com/questions/17589533/is-an-empty-initializer-list-valid-c-code
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH 00/27] drm/rockchip: MIPI fixes & improvements

2016-09-19 Thread John Keeping
D'oh, I got send-email horribly wrong here.  Please ignore the n/27
patches following this message - the n/26 versions are correct.

I won't spam the list with a cleaned-up v2 immediately, but I'll make
extra sure to clean out my working directory when I do send the re-roll!

On Mon, 19 Sep 2016 18:17:10 +0100, John Keeping wrote:

> This is a bit of a mixed selection of patches to all areas of the
> Rockchip dw-mipi-dsi driver, which I've been using for a while.
> 
> The first few patches fix the driver's use of the atomic API by removing
> hardware manipulation from the mode_set hook:
> 
>   drm/rockchip: dw-mipi-dsi: use mode from display state
>   drm/rockchip: dw-mipi-dsi: pass new mode into MIPI mode set
>   drm/rockchip: dw-mipi-dsi: don't configure hardware in mode_set for
> MIPI
>   drm/rockchip: dw-mipi-dsi: rename commit hook to enable
> 
> The following several patches fix various aspects of DSI host transfers
> in order to improve support for displays that need to be set up via DSI
> commands:
> 
>   drm/rockchip: dw-mipi-dsi: fix command header writes
>   drm/rockchip: dw-mipi-dsi: fix generic packet status check
>   drm/rockchip: dw-mipi-dsi: avoid out-of-bounds read on tx_buf
>   drm/rockchip: dw-mipi-dsi: include bad value in error message
>   drm/rockchip: dw-mipi-dsi: respect message flags
>   drm/rockchip: dw-mipi-dsi: only request HS clock when required
>   drm/rockchip: dw-mipi-dsi: don't assume buffer is aligned
>   drm/rockchip: dw-mipi-dsi: prepare panel after phy init
>   drm/rockchip: dw-mipi-dsi: allow commands in panel_disable
> 
> Then a bunch of patches to improve the PHY PLL and other clock setup:
> 
>   drm/rockchip: dw-mipi-dsi: fix escape clock rate
>   drm/rockchip: dw-mipi-dsi: ensure PHY is reset
>   drm/rockchip: dw-mipi-dsi: configure bias and bandgap before enable
>   drm/rockchip: dw-mipi-dsi: don't enable PHY PLL until it's configured
>   drm/rockchip: dw-mipi-dsi: properly configure PHY timing
>   drm/rockchip: dw-mipi-dsi: improve PLL configuration
> 
> A couple of patches make the VOP and MIPI host consistent when panels do
> not set explicit hsync/vsync polarities:
> 
>   drm/rockchip: dw-mipi-dsi: use positive check for N{H,V}SYNC
>   drm/rockchip: vop: test for P{H,V}SYNC
> 
> The following patch fixes fbcon by making sure that the output
> resolution is known before it loads:
> 
>   drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded
> 
> Then a patch that should be self-explanatory:
> 
>   drm/rockchip: dw-mipi-dsi: support non-burst modes
> 
> And the final two patches were useful in development but aren't really
> needed once everything's working:
> 
>   drm/rockchip: dw-mipi-dsi: add reset control
>   drm/rockchip: dw-mipi-dsi: support read commands
> 
> 
> John Keeping (26):
>   drm/rockchip: dw-mipi-dsi: use mode from display state
>   drm/rockchip: dw-mipi-dsi: pass new mode into MIPI mode set
>   drm/rockchip: dw-mipi-dsi: don't configure hardware in mode_set for
> MIPI
>   drm/rockchip: dw-mipi-dsi: rename commit hook to enable
>   drm/rockchip: dw-mipi-dsi: fix command header writes
>   drm/rockchip: dw-mipi-dsi: fix generic packet status check
>   drm/rockchip: dw-mipi-dsi: avoid out-of-bounds read on tx_buf
>   drm/rockchip: dw-mipi-dsi: include bad value in error message
>   drm/rockchip: dw-mipi-dsi: respect message flags
>   drm/rockchip: dw-mipi-dsi: only request HS clock when required
>   drm/rockchip: dw-mipi-dsi: don't assume buffer is aligned
>   drm/rockchip: dw-mipi-dsi: prepare panel after phy init
>   drm/rockchip: dw-mipi-dsi: allow commands in panel_disable
>   drm/rockchip: dw-mipi-dsi: fix escape clock rate
>   drm/rockchip: dw-mipi-dsi: ensure PHY is reset
>   drm/rockchip: dw-mipi-dsi: configure bias and bandgap before enable
>   drm/rockchip: dw-mipi-dsi: don't enable PHY PLL until it's configured
>   drm/rockchip: dw-mipi-dsi: properly configure PHY timing
>   drm/rockchip: dw-mipi-dsi: improve PLL configuration
>   drm/rockchip: dw-mipi-dsi: use specific poll helper
>   drm/rockchip: dw-mipi-dsi: use positive check for N{H,V}SYNC
>   drm/rockchip: vop: test for P{H,V}SYNC
>   drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded
>   drm/rockchip: dw-mipi-dsi: support non-burst modes
>   drm/rockchip: dw-mipi-dsi: add reset control
>   drm/rockchip: dw-mipi-dsi: support read commands
> 
>  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 325 
> 
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |   4 +-
>  2 files changed, 234 insertions(+), 95 deletions(-)
> 


[PATCH 26/26] drm/rockchip: dw-mipi-dsi: support read commands

2016-09-19 Thread John Keeping
I haven't found any method for getting the length of a response, so this
just uses the requested rx_len

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 54 ++
 1 file changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index d0b2f6e9517d..6dc43c024bca 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -676,6 +676,54 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi 
*dsi,
return dw_mipi_dsi_gen_pkt_hdr_write(dsi, hdr_val);
 }

+static int dw_mipi_dsi_dcs_read(struct dw_mipi_dsi *dsi,
+   const struct mipi_dsi_msg *msg)
+{
+   const u8 *tx_buf = msg->tx_buf;
+   u8 *rx_buf = msg->rx_buf;
+   size_t i;
+   int ret, val;
+
+   dsi_write(dsi, DSI_PCKHDL_CFG, EN_CRC_RX | EN_ECC_RX | EN_BTA);
+   dsi_write(dsi, DSI_GEN_HDR, GEN_HDATA(tx_buf[0]) | 
GEN_HTYPE(msg->type));
+
+   ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS,
+val, !(val & GEN_RD_CMD_BUSY), 1000,
+CMD_PKT_STATUS_TIMEOUT_US);
+   if (ret < 0) {
+   dev_err(dsi->dev, "failed to read command response\n");
+   return ret;
+   }
+
+   for (i = 0; i < msg->rx_len;) {
+   u32 pld = dsi_read(dsi, DSI_GEN_PLD_DATA);
+   while (i < msg->rx_len) {
+   rx_buf[i] = pld & 0xff;
+   pld >>= 8;
+   i++;
+   }
+   }
+
+   return msg->rx_len;
+}
+
+static int dw_mipi_dsi_set_max_return_packet_size(struct dw_mipi_dsi *dsi,
+ size_t len)
+{
+   u8 val[] = { len & 0xff, (len >> 8) & 0xff };
+   struct mipi_dsi_msg msg = {
+   .channel = dsi->channel,
+   .type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE,
+   .tx_buf = val,
+   .tx_len = 2,
+   };
+
+   if (len > 0x)
+   return -EINVAL;
+
+   return dw_mipi_dsi_dcs_short_write(dsi, &msg);
+}
+
 static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host,
 const struct mipi_dsi_msg *msg)
 {
@@ -693,6 +741,12 @@ static ssize_t dw_mipi_dsi_host_transfer(struct 
mipi_dsi_host *host,
case MIPI_DSI_DCS_LONG_WRITE:
ret = dw_mipi_dsi_dcs_long_write(dsi, msg);
break;
+   case MIPI_DSI_DCS_READ:
+   ret = dw_mipi_dsi_set_max_return_packet_size(dsi, msg->rx_len);
+   if (ret < 0)
+   return ret;
+   ret = dw_mipi_dsi_dcs_read(dsi, msg);
+   break;
default:
dev_err(dsi->dev, "unsupported message type 0x%02x\n",
msg->type);
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 25/26] drm/rockchip: dw-mipi-dsi: add reset control

2016-09-19 Thread John Keeping
In order to fully reset the state of the MIPI controller we must assert
this reset.

This is slightly more complicated than it could be in order to maintain
compatibility with device trees that do not specify the reset property.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index d93e620adea6..d0b2f6e9517d 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1134,6 +1135,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct 
device *master,
of_match_device(dw_mipi_dsi_dt_ids, dev);
const struct dw_mipi_dsi_plat_data *pdata = of_id->data;
struct platform_device *pdev = to_platform_device(dev);
+   struct reset_control *apb_rst;
struct drm_device *drm = data;
struct dw_mipi_dsi *dsi;
struct resource *res;
@@ -1172,6 +1174,34 @@ static int dw_mipi_dsi_bind(struct device *dev, struct 
device *master,
return ret;
}

+   /*
+* Note that the reset was not defined in the initial device tree, so
+* we have to be prepared for it not being found.
+*/
+   apb_rst = devm_reset_control_get(dev, "apb");
+   if (IS_ERR(apb_rst)) {
+   if (PTR_ERR(apb_rst) == -ENODEV) {
+   apb_rst = NULL;
+   } else {
+   dev_err(dev, "Unable to get reset control: %d\n", ret);
+   return PTR_ERR(apb_rst);
+   }
+   }
+
+   if (apb_rst) {
+   ret = clk_prepare_enable(dsi->pclk);
+   if (ret) {
+   dev_err(dev, "%s: Failed to enable pclk\n", __func__);
+   return ret;
+   }
+
+   reset_control_assert(apb_rst);
+   usleep_range(10, 20);
+   reset_control_deassert(apb_rst);
+
+   clk_disable_unprepare(dsi->pclk);
+   }
+
ret = clk_prepare_enable(dsi->pllref_clk);
if (ret) {
dev_err(dev, "%s: Failed to enable pllref_clk\n", __func__);
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 24/27] drm/rockchip: vop: test for P{H,V}SYNC

2016-09-19 Thread John Keeping
When connected to the MIPI DSI output, we need to use N{H,V}SYNC for the
internal connection but these flags are meaningless for DSI panels.
Switch the test so that we do not set the P{H,V}SYNC bits unless the
mode requires it.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index d486049f9722..7c4ce1b2e694 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1030,8 +1030,8 @@ static void vop_crtc_enable(struct drm_crtc *crtc)
}

pin_pol = 0x8;
-   pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC) ? 0 : 1;
-   pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC) ? 0 : (1 << 1);
+   pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) ? 1 : 0;
+   pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) ? (1 << 1) : 0;
VOP_CTRL_SET(vop, pin_pol, pin_pol);

switch (s->output_type) {
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 24/26] drm/rockchip: dw-mipi-dsi: support non-burst modes

2016-09-19 Thread John Keeping
Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 5ecb03c24c2f..d93e620adea6 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -82,6 +82,7 @@
 #define FRAME_BTA_ACK  BIT(14)
 #define ENABLE_LOW_POWER   (0x3f << 8)
 #define ENABLE_LOW_POWER_MASK  (0x3f << 8)
+#define VID_MODE_TYPE_NON_BURST_SYNC_EVENTS0x1
 #define VID_MODE_TYPE_BURST_SYNC_PULSES0x2
 #define VID_MODE_TYPE_MASK 0x3

@@ -286,6 +287,7 @@ struct dw_mipi_dsi {
u32 format;
u16 input_div;
u16 feedback_div;
+   unsigned long mode_flags;

const struct dw_mipi_dsi_plat_data *pdata;
 };
@@ -549,15 +551,10 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host 
*host,
return -EINVAL;
}

-   if (!(device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) ||
-   !(device->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)) {
-   dev_err(dsi->dev, "device mode is unsupported\n");
-   return -EINVAL;
-   }
-
dsi->lanes = device->lanes;
dsi->channel = device->channel;
dsi->format = device->format;
+   dsi->mode_flags = device->mode_flags;
dsi->panel = of_drm_find_panel(device->dev.of_node);
if (dsi->panel)
return drm_panel_attach(dsi->panel, &dsi->connector);
@@ -714,7 +711,12 @@ static void dw_mipi_dsi_video_mode_config(struct 
dw_mipi_dsi *dsi)
 {
u32 val;

-   val = VID_MODE_TYPE_BURST_SYNC_PULSES | ENABLE_LOW_POWER;
+   val = ENABLE_LOW_POWER;
+
+   if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
+   val |= VID_MODE_TYPE_BURST_SYNC_PULSES;
+   else if (!(dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE))
+   val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;

dsi_write(dsi, DSI_VID_MODE_CFG, val);
 }
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 23/27] drm/rockchip: dw-mipi-dsi: support non-burst modes

2016-09-19 Thread John Keeping
Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 5ecb03c24c2f..d93e620adea6 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -82,6 +82,7 @@
 #define FRAME_BTA_ACK  BIT(14)
 #define ENABLE_LOW_POWER   (0x3f << 8)
 #define ENABLE_LOW_POWER_MASK  (0x3f << 8)
+#define VID_MODE_TYPE_NON_BURST_SYNC_EVENTS0x1
 #define VID_MODE_TYPE_BURST_SYNC_PULSES0x2
 #define VID_MODE_TYPE_MASK 0x3

@@ -286,6 +287,7 @@ struct dw_mipi_dsi {
u32 format;
u16 input_div;
u16 feedback_div;
+   unsigned long mode_flags;

const struct dw_mipi_dsi_plat_data *pdata;
 };
@@ -549,15 +551,10 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host 
*host,
return -EINVAL;
}

-   if (!(device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) ||
-   !(device->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)) {
-   dev_err(dsi->dev, "device mode is unsupported\n");
-   return -EINVAL;
-   }
-
dsi->lanes = device->lanes;
dsi->channel = device->channel;
dsi->format = device->format;
+   dsi->mode_flags = device->mode_flags;
dsi->panel = of_drm_find_panel(device->dev.of_node);
if (dsi->panel)
return drm_panel_attach(dsi->panel, &dsi->connector);
@@ -714,7 +711,12 @@ static void dw_mipi_dsi_video_mode_config(struct 
dw_mipi_dsi *dsi)
 {
u32 val;

-   val = VID_MODE_TYPE_BURST_SYNC_PULSES | ENABLE_LOW_POWER;
+   val = ENABLE_LOW_POWER;
+
+   if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
+   val |= VID_MODE_TYPE_BURST_SYNC_PULSES;
+   else if (!(dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE))
+   val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;

dsi_write(dsi, DSI_VID_MODE_CFG, val);
 }
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 23/26] drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded

2016-09-19 Thread John Keeping
This ensures that the output resolution is known before fbcon loads.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 2b26a54972da..5ecb03c24c2f 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -1186,10 +1186,17 @@ static int dw_mipi_dsi_bind(struct device *dev, struct 
device *master,

dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
dsi->dsi_host.dev = dev;
-   return mipi_dsi_host_register(&dsi->dsi_host);
+   ret = mipi_dsi_host_register(&dsi->dsi_host);
+   if (!ret && !dsi->panel) {
+   mipi_dsi_host_unregister(&dsi->dsi_host);
+   drm_encoder_cleanup(&dsi->encoder);
+   drm_connector_cleanup(&dsi->connector);
+   ret = -EPROBE_DEFER;
+   }

 err_pllref:
-   clk_disable_unprepare(dsi->pllref_clk);
+   if (ret)
+   clk_disable_unprepare(dsi->pllref_clk);
return ret;
 }

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 22/26] drm/rockchip: vop: test for P{H,V}SYNC

2016-09-19 Thread John Keeping
When connected to the MIPI DSI output, we need to use N{H,V}SYNC for the
internal connection but these flags are meaningless for DSI panels.
Switch the test so that we do not set the P{H,V}SYNC bits unless the
mode requires it.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index d486049f9722..7c4ce1b2e694 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1030,8 +1030,8 @@ static void vop_crtc_enable(struct drm_crtc *crtc)
}

pin_pol = 0x8;
-   pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC) ? 0 : 1;
-   pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC) ? 0 : (1 << 1);
+   pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) ? 1 : 0;
+   pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) ? (1 << 1) : 0;
VOP_CTRL_SET(vop, pin_pol, pin_pol);

switch (s->output_type) {
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 22/27] drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded

2016-09-19 Thread John Keeping
This ensures that the output resolution is known before fbcon loads.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 2b26a54972da..5ecb03c24c2f 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -1186,10 +1186,17 @@ static int dw_mipi_dsi_bind(struct device *dev, struct 
device *master,

dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
dsi->dsi_host.dev = dev;
-   return mipi_dsi_host_register(&dsi->dsi_host);
+   ret = mipi_dsi_host_register(&dsi->dsi_host);
+   if (!ret && !dsi->panel) {
+   mipi_dsi_host_unregister(&dsi->dsi_host);
+   drm_encoder_cleanup(&dsi->encoder);
+   drm_connector_cleanup(&dsi->connector);
+   ret = -EPROBE_DEFER;
+   }

 err_pllref:
-   clk_disable_unprepare(dsi->pllref_clk);
+   if (ret)
+   clk_disable_unprepare(dsi->pllref_clk);
return ret;
 }

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 21/26] drm/rockchip: dw-mipi-dsi: use positive check for N{H, V}SYNC

2016-09-19 Thread John Keeping
This matches other drivers.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index ae7c330cb7ac..2b26a54972da 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -772,9 +772,9 @@ static void dw_mipi_dsi_dpi_config(struct dw_mipi_dsi *dsi)
break;
}

-   if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
+   if (mode->flags & DRM_MODE_FLAG_NVSYNC)
val |= VSYNC_ACTIVE_LOW;
-   if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
+   if (mode->flags & DRM_MODE_FLAG_NHSYNC)
val |= HSYNC_ACTIVE_LOW;

dsi_write(dsi, DSI_DPI_VCID, DPI_VID(dsi->channel));
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 21/27] drm/rockchip: dw-mipi-dsi: improve PLL configuration

2016-09-19 Thread John Keeping
The multiplication ratio for the PLL is required to be even due to the
use of a "by 2 pre-scaler".  Currently we are likely to end up with an
odd multiplier even though there is an equivalent set of parameters with
an even multiplier.

For example, using the 324MHz bit rate with a reference clock of 24MHz
we end up with M = 27, N = 2 whereas the example in the PHY databook
gives M = 54, N = 4 for this bit rate and reference clock.

By walking down through the available multiplier instead of up we are
more likely to hit an even multiplier.  With the above example we do now
get M = 54, N = 4 as given by the databook.

While doing this, change the loop limits to encode the actual limits on
the divisor, which are:

40MHz >= (pllref / N) >= 5MHz

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 911ddcbab00d..2b26a54972da 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -520,7 +520,7 @@ static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi,
pllref = DIV_ROUND_UP(clk_get_rate(dsi->pllref_clk), USEC_PER_SEC);
tmp = pllref;

-   for (i = 1; i < 6; i++) {
+   for (i = pllref / 5; i > (pllref / 40); i--) {
pre = pllref / i;
if ((tmp > (target_mbps % pre)) && (target_mbps / pre < 512)) {
tmp = target_mbps % pre;
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 20/26] drm/rockchip: dw-mipi-dsi: use specific poll helper

2016-09-19 Thread John Keeping
As the documentation for readx_poll_timeout says, we want to use the
specialized macro for readl rather than using the generic version
directly.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 7983b2749518..ae7c330cb7ac 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -472,14 +472,14 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 PHY_UNRSTZ | PHY_UNSHUTDOWNZ);


-   ret = readx_poll_timeout(readl, dsi->base + DSI_PHY_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_PHY_STATUS,
 val, val & LOCK, 1000, PHY_STATUS_TIMEOUT_US);
if (ret < 0) {
dev_err(dsi->dev, "failed to wait for phy lock state\n");
return ret;
}

-   ret = readx_poll_timeout(readl, dsi->base + DSI_PHY_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_PHY_STATUS,
 val, val & STOP_STATE_CLK_LANE, 1000,
 PHY_STATUS_TIMEOUT_US);
if (ret < 0) {
@@ -595,7 +595,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi 
*dsi, u32 hdr_val)
int ret;
u32 val, mask;

-   ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS,
 val, !(val & GEN_CMD_FULL), 1000,
 CMD_PKT_STATUS_TIMEOUT_US);
if (ret < 0) {
@@ -606,7 +606,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi 
*dsi, u32 hdr_val)
dsi_write(dsi, DSI_GEN_HDR, hdr_val);

mask = GEN_CMD_EMPTY | GEN_PLD_W_EMPTY;
-   ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS,
 val, (val & mask) == mask,
 1000, CMD_PKT_STATUS_TIMEOUT_US);
if (ret < 0) {
@@ -665,7 +665,7 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi 
*dsi,
len -= pld_data_bytes;
}

-   ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS,
 val, !(val & GEN_PLD_W_FULL), 1000,
 CMD_PKT_STATUS_TIMEOUT_US);
if (ret < 0) {
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 20/27] drm/rockchip: dw-mipi-dsi: properly configure PHY timing

2016-09-19 Thread John Keeping
These values are specified as constant time periods but the PHY
configuration is in terms of the current lane byte clock so using
constant values guarantees that the timings will be outside the
specification with some display configurations.

Derive the necessary configuration from the byte clock in order to
ensure that the PHY configuration is correct.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 36 ++
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 61cee02e5f72..911ddcbab00d 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -384,6 +384,26 @@ static void dw_mipi_dsi_phy_write(struct dw_mipi_dsi *dsi, 
u8 test_code,
dsi_write(dsi, DSI_PHY_TST_CTRL0, PHY_TESTCLK | PHY_UNTESTCLR);
 }

+/**
+ * ns2bc - Nanoseconds to byte clock cycles
+ */
+static inline unsigned int ns2bc(struct dw_mipi_dsi *dsi, int ns)
+{
+   unsigned long byte_clk_khz = dsi->lane_mbps * MSEC_PER_SEC / 8;
+
+   return (ns * (byte_clk_khz / 1000) + 999) / 1000;
+}
+
+/**
+ * ns2ui - Nanoseconds to UI time periods
+ */
+static inline unsigned int ns2ui(struct dw_mipi_dsi *dsi, int ns)
+{
+   unsigned long byte_clk_khz = dsi->lane_mbps * MSEC_PER_SEC;
+
+   return (ns * (byte_clk_khz / 1000) + 999) / 1000;
+}
+
 static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 {
int ret, testdin, vco, val;
@@ -435,10 +455,18 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 SETRD_MAX | POWER_MANAGE |
 TER_RESISTORS_ON);

-
-   dw_mipi_dsi_phy_write(dsi, 0x70, TLP_PROGRAM_EN | 0xf);
-   dw_mipi_dsi_phy_write(dsi, 0x71, THS_PRE_PROGRAM_EN | 0x55);
-   dw_mipi_dsi_phy_write(dsi, 0x72, THS_ZERO_PROGRAM_EN | 0xa);
+   dw_mipi_dsi_phy_write(dsi, 0x60, TLP_PROGRAM_EN | ns2bc(dsi, 500));
+   dw_mipi_dsi_phy_write(dsi, 0x61, THS_PRE_PROGRAM_EN | ns2ui(dsi, 40));
+   dw_mipi_dsi_phy_write(dsi, 0x62, THS_ZERO_PROGRAM_EN | ns2bc(dsi, 300));
+   dw_mipi_dsi_phy_write(dsi, 0x63, THS_PRE_PROGRAM_EN | ns2ui(dsi, 100));
+   dw_mipi_dsi_phy_write(dsi, 0x64, BIT(5) | ns2bc(dsi, 100));
+   dw_mipi_dsi_phy_write(dsi, 0x65, BIT(5) | (ns2bc(dsi, 60) + 7));
+
+   dw_mipi_dsi_phy_write(dsi, 0x70, TLP_PROGRAM_EN | ns2bc(dsi, 500));
+   dw_mipi_dsi_phy_write(dsi, 0x71, THS_PRE_PROGRAM_EN | (ns2ui(dsi, 50) + 
5));
+   dw_mipi_dsi_phy_write(dsi, 0x72, THS_ZERO_PROGRAM_EN | (ns2bc(dsi, 140) 
+ 2));
+   dw_mipi_dsi_phy_write(dsi, 0x73, THS_PRE_PROGRAM_EN | (ns2ui(dsi, 60) + 
8));
+   dw_mipi_dsi_phy_write(dsi, 0x74, BIT(5) | ns2bc(dsi, 100));

dsi_write(dsi, DSI_PHY_RSTZ, PHY_ENFORCEPLL | PHY_ENABLECLK |
 PHY_UNRSTZ | PHY_UNSHUTDOWNZ);
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 19/26] drm/rockchip: dw-mipi-dsi: improve PLL configuration

2016-09-19 Thread John Keeping
The multiplication ratio for the PLL is required to be even due to the
use of a "by 2 pre-scaler".  Currently we are likely to end up with an
odd multiplier even though there is an equivalent set of parameters with
an even multiplier.

For example, using the 324MHz bit rate with a reference clock of 24MHz
we end up with M = 27, N = 2 whereas the example in the PHY databook
gives M = 54, N = 4 for this bit rate and reference clock.

By walking down through the available multiplier instead of up we are
more likely to hit an even multiplier.  With the above example we do now
get M = 54, N = 4 as given by the databook.

While doing this, change the loop limits to encode the actual limits on
the divisor, which are:

40MHz >= (pllref / N) >= 5MHz

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 55237d72f3f9..7983b2749518 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -520,7 +520,7 @@ static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi,
pllref = DIV_ROUND_UP(clk_get_rate(dsi->pllref_clk), USEC_PER_SEC);
tmp = pllref;

-   for (i = 1; i < 6; i++) {
+   for (i = pllref / 5; i > (pllref / 40); i--) {
pre = pllref / i;
if ((tmp > (target_mbps % pre)) && (target_mbps / pre < 512)) {
tmp = target_mbps % pre;
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 19/27] drm/rockchip: dw-mipi-dsi: don't enable PHY PLL until it's configured

2016-09-19 Thread John Keeping
Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 65c89367d8b2..61cee02e5f72 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -414,12 +414,12 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)

dw_mipi_dsi_phy_write(dsi, 0x44, HSFREQRANGE_SEL(testdin));

-   dw_mipi_dsi_phy_write(dsi, 0x19, PLL_LOOP_DIV_EN | PLL_INPUT_DIV_EN);
dw_mipi_dsi_phy_write(dsi, 0x17, INPUT_DIVIDER(dsi->input_div));
dw_mipi_dsi_phy_write(dsi, 0x18, LOOP_DIV_LOW_SEL(dsi->feedback_div) |
 LOW_PROGRAM_EN);
dw_mipi_dsi_phy_write(dsi, 0x18, LOOP_DIV_HIGH_SEL(dsi->feedback_div) |
 HIGH_PROGRAM_EN);
+   dw_mipi_dsi_phy_write(dsi, 0x19, PLL_LOOP_DIV_EN | PLL_INPUT_DIV_EN);

dw_mipi_dsi_phy_write(dsi, 0x22, LOW_PROGRAM_EN |
 BIASEXTR_SEL(BIASEXTR_127_7));
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 18/26] drm/rockchip: dw-mipi-dsi: properly configure PHY timing

2016-09-19 Thread John Keeping
These values are specified as constant time periods but the PHY
configuration is in terms of the current lane byte clock so using
constant values guarantees that the timings will be outside the
specification with some display configurations.

Derive the necessary configuration from the byte clock in order to
ensure that the PHY configuration is correct.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 36 ++
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 463e469fd1b8..55237d72f3f9 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -384,6 +384,26 @@ static void dw_mipi_dsi_phy_write(struct dw_mipi_dsi *dsi, 
u8 test_code,
dsi_write(dsi, DSI_PHY_TST_CTRL0, PHY_TESTCLK | PHY_UNTESTCLR);
 }

+/**
+ * ns2bc - Nanoseconds to byte clock cycles
+ */
+static inline unsigned int ns2bc(struct dw_mipi_dsi *dsi, int ns)
+{
+   unsigned long byte_clk_khz = dsi->lane_mbps * MSEC_PER_SEC / 8;
+
+   return (ns * (byte_clk_khz / 1000) + 999) / 1000;
+}
+
+/**
+ * ns2ui - Nanoseconds to UI time periods
+ */
+static inline unsigned int ns2ui(struct dw_mipi_dsi *dsi, int ns)
+{
+   unsigned long byte_clk_khz = dsi->lane_mbps * MSEC_PER_SEC;
+
+   return (ns * (byte_clk_khz / 1000) + 999) / 1000;
+}
+
 static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 {
int ret, testdin, vco, val;
@@ -435,10 +455,18 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 SETRD_MAX | POWER_MANAGE |
 TER_RESISTORS_ON);

-
-   dw_mipi_dsi_phy_write(dsi, 0x70, TLP_PROGRAM_EN | 0xf);
-   dw_mipi_dsi_phy_write(dsi, 0x71, THS_PRE_PROGRAM_EN | 0x55);
-   dw_mipi_dsi_phy_write(dsi, 0x72, THS_ZERO_PROGRAM_EN | 0xa);
+   dw_mipi_dsi_phy_write(dsi, 0x60, TLP_PROGRAM_EN | ns2bc(dsi, 500));
+   dw_mipi_dsi_phy_write(dsi, 0x61, THS_PRE_PROGRAM_EN | ns2ui(dsi, 40));
+   dw_mipi_dsi_phy_write(dsi, 0x62, THS_ZERO_PROGRAM_EN | ns2bc(dsi, 300));
+   dw_mipi_dsi_phy_write(dsi, 0x63, THS_PRE_PROGRAM_EN | ns2ui(dsi, 100));
+   dw_mipi_dsi_phy_write(dsi, 0x64, BIT(5) | ns2bc(dsi, 100));
+   dw_mipi_dsi_phy_write(dsi, 0x65, BIT(5) | (ns2bc(dsi, 60) + 7));
+
+   dw_mipi_dsi_phy_write(dsi, 0x70, TLP_PROGRAM_EN | ns2bc(dsi, 500));
+   dw_mipi_dsi_phy_write(dsi, 0x71, THS_PRE_PROGRAM_EN | (ns2ui(dsi, 50) + 
5));
+   dw_mipi_dsi_phy_write(dsi, 0x72, THS_ZERO_PROGRAM_EN | (ns2bc(dsi, 140) 
+ 2));
+   dw_mipi_dsi_phy_write(dsi, 0x73, THS_PRE_PROGRAM_EN | (ns2ui(dsi, 60) + 
8));
+   dw_mipi_dsi_phy_write(dsi, 0x74, BIT(5) | ns2bc(dsi, 100));

dsi_write(dsi, DSI_PHY_RSTZ, PHY_ENFORCEPLL | PHY_ENABLECLK |
 PHY_UNRSTZ | PHY_UNSHUTDOWNZ);
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 18/27] drm/rockchip: dw-mipi-dsi: configure bias and bandgap before enable

2016-09-19 Thread John Keeping
We should configure these functions before enabling them.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index e310c3d81bb8..65c89367d8b2 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -421,6 +421,11 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
dw_mipi_dsi_phy_write(dsi, 0x18, LOOP_DIV_HIGH_SEL(dsi->feedback_div) |
 HIGH_PROGRAM_EN);

+   dw_mipi_dsi_phy_write(dsi, 0x22, LOW_PROGRAM_EN |
+BIASEXTR_SEL(BIASEXTR_127_7));
+   dw_mipi_dsi_phy_write(dsi, 0x22, HIGH_PROGRAM_EN |
+BANDGAP_SEL(BANDGAP_96_10));
+
dw_mipi_dsi_phy_write(dsi, 0x20, POWER_CONTROL | INTERNAL_REG_CURRENT |
 BIAS_BLOCK_ON | BANDGAP_ON);

@@ -430,10 +435,6 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 SETRD_MAX | POWER_MANAGE |
 TER_RESISTORS_ON);

-   dw_mipi_dsi_phy_write(dsi, 0x22, LOW_PROGRAM_EN |
-BIASEXTR_SEL(BIASEXTR_127_7));
-   dw_mipi_dsi_phy_write(dsi, 0x22, HIGH_PROGRAM_EN |
-BANDGAP_SEL(BANDGAP_96_10));

dw_mipi_dsi_phy_write(dsi, 0x70, TLP_PROGRAM_EN | 0xf);
dw_mipi_dsi_phy_write(dsi, 0x71, THS_PRE_PROGRAM_EN | 0x55);
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 17/27] drm/rockchip: dw-mipi-dsi: ensure PHY is reset

2016-09-19 Thread John Keeping
Also don't power up the DSI host at this point since this is not
necessary in order to configure the PHY and we do so later when
selecting video or command mode.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index e621b66b9617..e310c3d81bb8 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -398,7 +398,10 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
return testdin;
}

-   dsi_write(dsi, DSI_PWR_UP, POWERUP);
+   /* Start by clearing PHY state */
+   dsi_write(dsi, DSI_PHY_TST_CTRL0, PHY_UNTESTCLR);
+   dsi_write(dsi, DSI_PHY_TST_CTRL0, PHY_TESTCLR);
+   dsi_write(dsi, DSI_PHY_TST_CTRL0, PHY_UNTESTCLR);

dw_mipi_dsi_phy_write(dsi, 0x10, BYPASS_VCO_RANGE |
 VCO_RANGE_CON_SEL(vco) |
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 17/26] drm/rockchip: dw-mipi-dsi: don't enable PHY PLL until it's configured

2016-09-19 Thread John Keeping
Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index f824c99b872e..463e469fd1b8 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -414,12 +414,12 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)

dw_mipi_dsi_phy_write(dsi, 0x44, HSFREQRANGE_SEL(testdin));

-   dw_mipi_dsi_phy_write(dsi, 0x19, PLL_LOOP_DIV_EN | PLL_INPUT_DIV_EN);
dw_mipi_dsi_phy_write(dsi, 0x17, INPUT_DIVIDER(dsi->input_div));
dw_mipi_dsi_phy_write(dsi, 0x18, LOOP_DIV_LOW_SEL(dsi->feedback_div) |
 LOW_PROGRAM_EN);
dw_mipi_dsi_phy_write(dsi, 0x18, LOOP_DIV_HIGH_SEL(dsi->feedback_div) |
 HIGH_PROGRAM_EN);
+   dw_mipi_dsi_phy_write(dsi, 0x19, PLL_LOOP_DIV_EN | PLL_INPUT_DIV_EN);

dw_mipi_dsi_phy_write(dsi, 0x22, LOW_PROGRAM_EN |
 BIASEXTR_SEL(BIASEXTR_127_7));
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 16/27] drm/rockchip: dw-mipi-dsi: fix escape clock rate

2016-09-19 Thread John Keeping
Use the same calculation as the vendor kernel to derive the escape clock
speed.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 7b4f4f150a0d..e621b66b9617 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -711,11 +711,13 @@ static void dw_mipi_dsi_disable(struct dw_mipi_dsi *dsi)

 static void dw_mipi_dsi_init(struct dw_mipi_dsi *dsi)
 {
+   u32 esc_clk_division = (dsi->lane_mbps >> 3) / 20 + 1;
+
dsi_write(dsi, DSI_PWR_UP, RESET);
dsi_write(dsi, DSI_PHY_RSTZ, PHY_DISFORCEPLL | PHY_DISABLECLK
  | PHY_RSTZ | PHY_SHUTDOWNZ);
dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVIDSION(10) |
- TX_ESC_CLK_DIVIDSION(7));
+ TX_ESC_CLK_DIVIDSION(esc_clk_division));
 }

 static void dw_mipi_dsi_dpi_config(struct dw_mipi_dsi *dsi)
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 16/26] drm/rockchip: dw-mipi-dsi: configure bias and bandgap before enable

2016-09-19 Thread John Keeping
We should configure these functions before enabling them.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 73c28e205fc5..f824c99b872e 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -421,6 +421,11 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
dw_mipi_dsi_phy_write(dsi, 0x18, LOOP_DIV_HIGH_SEL(dsi->feedback_div) |
 HIGH_PROGRAM_EN);

+   dw_mipi_dsi_phy_write(dsi, 0x22, LOW_PROGRAM_EN |
+BIASEXTR_SEL(BIASEXTR_127_7));
+   dw_mipi_dsi_phy_write(dsi, 0x22, HIGH_PROGRAM_EN |
+BANDGAP_SEL(BANDGAP_96_10));
+
dw_mipi_dsi_phy_write(dsi, 0x20, POWER_CONTROL | INTERNAL_REG_CURRENT |
 BIAS_BLOCK_ON | BANDGAP_ON);

@@ -430,10 +435,6 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 SETRD_MAX | POWER_MANAGE |
 TER_RESISTORS_ON);

-   dw_mipi_dsi_phy_write(dsi, 0x22, LOW_PROGRAM_EN |
-BIASEXTR_SEL(BIASEXTR_127_7));
-   dw_mipi_dsi_phy_write(dsi, 0x22, HIGH_PROGRAM_EN |
-BANDGAP_SEL(BANDGAP_96_10));

dw_mipi_dsi_phy_write(dsi, 0x70, TLP_PROGRAM_EN | 0xf);
dw_mipi_dsi_phy_write(dsi, 0x71, THS_PRE_PROGRAM_EN | 0x55);
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 15/27] drm/rockchip: dw-mipi-dsi: use positive check for N{H, V}SYNC

2016-09-19 Thread John Keeping
This matches other drivers.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 097b3b0af78f..7b4f4f150a0d 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -738,9 +738,9 @@ static void dw_mipi_dsi_dpi_config(struct dw_mipi_dsi *dsi)
break;
}

-   if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
+   if (mode->flags & DRM_MODE_FLAG_NVSYNC)
val |= VSYNC_ACTIVE_LOW;
-   if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
+   if (mode->flags & DRM_MODE_FLAG_NHSYNC)
val |= HSYNC_ACTIVE_LOW;

dsi_write(dsi, DSI_DPI_VCID, DPI_VID(dsi->channel));
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 15/26] drm/rockchip: dw-mipi-dsi: ensure PHY is reset

2016-09-19 Thread John Keeping
Also don't power up the DSI host at this point since this is not
necessary in order to configure the PHY and we do so later when
selecting video or command mode.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 8854b8670d72..73c28e205fc5 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -398,7 +398,10 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
return testdin;
}

-   dsi_write(dsi, DSI_PWR_UP, POWERUP);
+   /* Start by clearing PHY state */
+   dsi_write(dsi, DSI_PHY_TST_CTRL0, PHY_UNTESTCLR);
+   dsi_write(dsi, DSI_PHY_TST_CTRL0, PHY_TESTCLR);
+   dsi_write(dsi, DSI_PHY_TST_CTRL0, PHY_UNTESTCLR);

dw_mipi_dsi_phy_write(dsi, 0x10, BYPASS_VCO_RANGE |
 VCO_RANGE_CON_SEL(vco) |
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 14/27] drm/rockchip: dw-mipi-dsi: use specific poll helper

2016-09-19 Thread John Keeping
As the documentation for readx_poll_timeout says, we want to use the
specialized macro for readl rather than using the generic version
directly.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 5e343b54f0d0..097b3b0af78f 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -440,14 +440,14 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 PHY_UNRSTZ | PHY_UNSHUTDOWNZ);


-   ret = readx_poll_timeout(readl, dsi->base + DSI_PHY_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_PHY_STATUS,
 val, val & LOCK, 1000, PHY_STATUS_TIMEOUT_US);
if (ret < 0) {
dev_err(dsi->dev, "failed to wait for phy lock state\n");
return ret;
}

-   ret = readx_poll_timeout(readl, dsi->base + DSI_PHY_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_PHY_STATUS,
 val, val & STOP_STATE_CLK_LANE, 1000,
 PHY_STATUS_TIMEOUT_US);
if (ret < 0) {
@@ -563,7 +563,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi 
*dsi, u32 hdr_val)
int ret;
u32 val, mask;

-   ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS,
 val, !(val & GEN_CMD_FULL), 1000,
 CMD_PKT_STATUS_TIMEOUT_US);
if (ret < 0) {
@@ -574,7 +574,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi 
*dsi, u32 hdr_val)
dsi_write(dsi, DSI_GEN_HDR, hdr_val);

mask = GEN_CMD_EMPTY | GEN_PLD_W_EMPTY;
-   ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS,
 val, (val & mask) == mask,
 1000, CMD_PKT_STATUS_TIMEOUT_US);
if (ret < 0) {
@@ -633,7 +633,7 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi 
*dsi,
len -= pld_data_bytes;
}

-   ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
+   ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS,
 val, !(val & GEN_PLD_W_FULL), 1000,
 CMD_PKT_STATUS_TIMEOUT_US);
if (ret < 0) {
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 14/26] drm/rockchip: dw-mipi-dsi: fix escape clock rate

2016-09-19 Thread John Keeping
Use the same calculation as the vendor kernel to derive the escape clock
speed.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 5e343b54f0d0..8854b8670d72 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -711,11 +711,13 @@ static void dw_mipi_dsi_disable(struct dw_mipi_dsi *dsi)

 static void dw_mipi_dsi_init(struct dw_mipi_dsi *dsi)
 {
+   u32 esc_clk_division = (dsi->lane_mbps >> 3) / 20 + 1;
+
dsi_write(dsi, DSI_PWR_UP, RESET);
dsi_write(dsi, DSI_PHY_RSTZ, PHY_DISFORCEPLL | PHY_DISABLECLK
  | PHY_RSTZ | PHY_SHUTDOWNZ);
dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVIDSION(10) |
- TX_ESC_CLK_DIVIDSION(7));
+ TX_ESC_CLK_DIVIDSION(esc_clk_division));
 }

 static void dw_mipi_dsi_dpi_config(struct dw_mipi_dsi *dsi)
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 13/26] drm/rockchip: dw-mipi-dsi: allow commands in panel_disable

2016-09-19 Thread John Keeping
Panel drivers may want to sent commands during the disable function, for
example MIPI_DCS_SET_DISPLAY_OFF before the video signal ends.  In order
to send commands we need to write to registers, so pclk must be enabled.

While changing this, remove the unnecessary code after the panel
unprepare call which seems to be a workaround for a specific panel and
thus belongs in the panel driver.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 9ff1cac5ef63..5e343b54f0d0 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -857,24 +857,16 @@ static void dw_mipi_dsi_encoder_disable(struct 
drm_encoder *encoder)
 {
struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder);

-   drm_panel_disable(dsi->panel);
-
if (clk_prepare_enable(dsi->pclk)) {
dev_err(dsi->dev, "%s: Failed to enable pclk\n", __func__);
return;
}

+   drm_panel_disable(dsi->panel);
+
dw_mipi_dsi_set_mode(dsi, DW_MIPI_DSI_CMD_MODE);
drm_panel_unprepare(dsi->panel);
-   dw_mipi_dsi_set_mode(dsi, DW_MIPI_DSI_VID_MODE);

-   /*
-* This is necessary to make sure the peripheral will be driven
-* normally when the display is enabled again later.
-*/
-   msleep(120);
-
-   dw_mipi_dsi_set_mode(dsi, DW_MIPI_DSI_CMD_MODE);
dw_mipi_dsi_disable(dsi);
clk_disable_unprepare(dsi->pclk);
 }
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 12/26] drm/rockchip: dw-mipi-dsi: prepare panel after phy init

2016-09-19 Thread John Keeping
Some panels need to be configured with commands sent over the MIPI link,
which they will do in the prepare hook.  Call this after the PHY has
been initialized so that we are able to send commands to the panel.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 4c945cc4d31a..9ff1cac5ef63 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -901,12 +901,14 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder 
*encoder)
dw_mipi_dsi_dphy_timing_config(dsi);
dw_mipi_dsi_dphy_interface_config(dsi);
dw_mipi_dsi_clear_err(dsi);
-   if (drm_panel_prepare(dsi->panel))
-   dev_err(dsi->dev, "failed to prepare panel\n");

dw_mipi_dsi_phy_init(dsi);
dw_mipi_dsi_wait_for_two_frames(dsi);

+   dw_mipi_dsi_set_mode(dsi, DW_MIPI_DSI_CMD_MODE);
+   if (drm_panel_prepare(dsi->panel))
+   dev_err(dsi->dev, "failed to prepare panel\n");
+
dw_mipi_dsi_set_mode(dsi, DW_MIPI_DSI_VID_MODE);
drm_panel_enable(dsi->panel);

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 11/26] drm/rockchip: dw-mipi-dsi: don't assume buffer is aligned

2016-09-19 Thread John Keeping
By dereferencing the MIPI command buffer as a u32* we rely on it being
correctly aligned on ARM, but this may not be the case.  Copy it into a
stack variable that will be correctly aligned.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index ed2da1bbada9..4c945cc4d31a 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -608,10 +608,10 @@ static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi 
*dsi,
 static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi *dsi,
  const struct mipi_dsi_msg *msg)
 {
-   const u32 *tx_buf = msg->tx_buf;
-   int len = msg->tx_len, pld_data_bytes = sizeof(*tx_buf), ret;
+   const u8 *tx_buf = msg->tx_buf;
+   int len = msg->tx_len, pld_data_bytes = sizeof(u32), ret;
u32 hdr_val = GEN_HDATA(msg->tx_len) | GEN_HTYPE(msg->type);
-   u32 remainder = 0;
+   u32 remainder;
u32 val;

if (msg->tx_len < 3) {
@@ -622,12 +622,14 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi 
*dsi,

while (DIV_ROUND_UP(len, pld_data_bytes)) {
if (len < pld_data_bytes) {
+   remainder = 0;
memcpy(&remainder, tx_buf, len);
dsi_write(dsi, DSI_GEN_PLD_DATA, remainder);
len = 0;
} else {
-   dsi_write(dsi, DSI_GEN_PLD_DATA, *tx_buf);
-   tx_buf++;
+   memcpy(&remainder, tx_buf, pld_data_bytes);
+   dsi_write(dsi, DSI_GEN_PLD_DATA, remainder);
+   tx_buf += pld_data_bytes;
len -= pld_data_bytes;
}

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 10/26] drm/rockchip: dw-mipi-dsi: only request HS clock when required

2016-09-19 Thread John Keeping
Requesting the HS clock from the PHY before we initialize it causes an
invalid signal to be sent out since the input clock is not yet
configured.  The PHY databook suggests only asserting this signal when
performing HS transfers, so let's do that.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 554336f8023e..ed2da1bbada9 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -546,13 +546,15 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host 
*host,
 static void dw_mipi_message_config(struct dw_mipi_dsi *dsi,
   const struct mipi_dsi_msg *msg)
 {
+   bool lpm = msg->flags & MIPI_DSI_MSG_USE_LPM;
u32 val = 0;

if (msg->flags & MIPI_DSI_MSG_REQ_ACK)
val |= EN_ACK_RQST;
-   if (msg->flags & MIPI_DSI_MSG_USE_LPM)
+   if (lpm)
val |= CMD_MODE_ALL_LP;

+   dsi_write(dsi, DSI_LPCLK_CTRL, lpm ? 0 : PHY_TXREQUESTCLKHS);
dsi_write(dsi, DSI_CMD_MODE_CFG, val);
 }

@@ -694,6 +696,7 @@ static void dw_mipi_dsi_set_mode(struct dw_mipi_dsi *dsi,
dsi_write(dsi, DSI_PWR_UP, RESET);
dsi_write(dsi, DSI_MODE_CFG, ENABLE_VIDEO_MODE);
dw_mipi_dsi_video_mode_config(dsi);
+   dsi_write(dsi, DSI_LPCLK_CTRL, PHY_TXREQUESTCLKHS);
dsi_write(dsi, DSI_PWR_UP, POWERUP);
}
 }
@@ -711,7 +714,6 @@ static void dw_mipi_dsi_init(struct dw_mipi_dsi *dsi)
  | PHY_RSTZ | PHY_SHUTDOWNZ);
dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVIDSION(10) |
  TX_ESC_CLK_DIVIDSION(7));
-   dsi_write(dsi, DSI_LPCLK_CTRL, PHY_TXREQUESTCLKHS);
 }

 static void dw_mipi_dsi_dpi_config(struct dw_mipi_dsi *dsi)
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 09/26] drm/rockchip: dw-mipi-dsi: respect message flags

2016-09-19 Thread John Keeping
Instead of always sending commands in LP mode, respect the
MIPI_DSI_MSG_USE_LPM flag to decide how to send each message.  Also
request acks if MIPI_DSI_MSG_REQ_ACK is set.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index a25db02e1c19..554336f8023e 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -543,6 +543,19 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host 
*host,
return 0;
 }

+static void dw_mipi_message_config(struct dw_mipi_dsi *dsi,
+  const struct mipi_dsi_msg *msg)
+{
+   u32 val = 0;
+
+   if (msg->flags & MIPI_DSI_MSG_REQ_ACK)
+   val |= EN_ACK_RQST;
+   if (msg->flags & MIPI_DSI_MSG_USE_LPM)
+   val |= CMD_MODE_ALL_LP;
+
+   dsi_write(dsi, DSI_CMD_MODE_CFG, val);
+}
+
 static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val)
 {
int ret;
@@ -635,6 +648,8 @@ static ssize_t dw_mipi_dsi_host_transfer(struct 
mipi_dsi_host *host,
struct dw_mipi_dsi *dsi = host_to_dsi(host);
int ret;

+   dw_mipi_message_config(dsi, msg);
+
switch (msg->type) {
case MIPI_DSI_DCS_SHORT_WRITE:
case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
@@ -747,7 +762,6 @@ static void dw_mipi_dsi_command_mode_config(struct 
dw_mipi_dsi *dsi)
 {
dsi_write(dsi, DSI_TO_CNT_CFG, HSTX_TO_CNT(1000) | LPRX_TO_CNT(1000));
dsi_write(dsi, DSI_BTA_TO_CNT, 0xd00);
-   dsi_write(dsi, DSI_CMD_MODE_CFG, CMD_MODE_ALL_LP);
dsi_write(dsi, DSI_MODE_CFG, ENABLE_CMD_MODE);
 }

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 08/26] drm/rockchip: dw-mipi-dsi: include bad value in error message

2016-09-19 Thread John Keeping
As an aid to debugging.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 38186df8476e..a25db02e1c19 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -645,7 +645,8 @@ static ssize_t dw_mipi_dsi_host_transfer(struct 
mipi_dsi_host *host,
ret = dw_mipi_dsi_dcs_long_write(dsi, msg);
break;
default:
-   dev_err(dsi->dev, "unsupported message type\n");
+   dev_err(dsi->dev, "unsupported message type 0x%02x\n",
+   msg->type);
ret = -EINVAL;
}

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 07/26] drm/rockchip: dw-mipi-dsi: avoid out-of-bounds read on tx_buf

2016-09-19 Thread John Keeping
As a side-effect of this, encode the endianness explicitly rather than
casting a u16.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index f2bed2a0f907..38186df8476e 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -573,8 +573,13 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct 
dw_mipi_dsi *dsi, u32 hdr_val)
 static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi *dsi,
   const struct mipi_dsi_msg *msg)
 {
-   const u16 *tx_buf = msg->tx_buf;
-   u32 val = GEN_HDATA(*tx_buf) | GEN_HTYPE(msg->type);
+   const u8 *tx_buf = msg->tx_buf;
+   u32 val = GEN_HTYPE(msg->type);
+
+   if (msg->tx_len > 0)
+   val |= GEN_HDATA(tx_buf[0]);
+   if (msg->tx_len > 1)
+   val |= GEN_HDATA(tx_buf[1] << 8);

if (msg->tx_len > 2) {
dev_err(dsi->dev, "too long tx buf length %zu for short 
write\n",
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 06/26] drm/rockchip: dw-mipi-dsi: fix generic packet status check

2016-09-19 Thread John Keeping
We want to check that both the GEN_CMD_EMPTY and GEN_PLD_W_EMPTY bits
are set so we can't just check "val & mask" because that will be true if
either bit is set.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 03915bf9c97d..f2bed2a0f907 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -546,7 +546,7 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host 
*host,
 static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val)
 {
int ret;
-   u32 val;
+   u32 val, mask;

ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
 val, !(val & GEN_CMD_FULL), 1000,
@@ -558,8 +558,9 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi 
*dsi, u32 hdr_val)

dsi_write(dsi, DSI_GEN_HDR, hdr_val);

+   mask = GEN_CMD_EMPTY | GEN_PLD_W_EMPTY;
ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
-val, val & (GEN_CMD_EMPTY | GEN_PLD_W_EMPTY),
+val, (val & mask) == mask,
 1000, CMD_PKT_STATUS_TIMEOUT_US);
if (ret < 0) {
dev_err(dsi->dev, "failed to write command FIFO\n");
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 05/26] drm/rockchip: dw-mipi-dsi: fix command header writes

2016-09-19 Thread John Keeping
In a couple of places here we use "val" for the value that is about to
be written to a register but then reuse the same variable for the value
of a status register before we get around to writing it.  Rename the
value to be written to so that we write the value we intend to and not
what we have just read from the status register.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index fac2429b9d6d..03915bf9c97d 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -543,9 +543,10 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host 
*host,
return 0;
 }

-static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 val)
+static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val)
 {
int ret;
+   u32 val;

ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
 val, !(val & GEN_CMD_FULL), 1000,
@@ -555,7 +556,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi 
*dsi, u32 val)
return ret;
}

-   dsi_write(dsi, DSI_GEN_HDR, val);
+   dsi_write(dsi, DSI_GEN_HDR, hdr_val);

ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS,
 val, val & (GEN_CMD_EMPTY | GEN_PLD_W_EMPTY),
@@ -588,8 +589,9 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi 
*dsi,
 {
const u32 *tx_buf = msg->tx_buf;
int len = msg->tx_len, pld_data_bytes = sizeof(*tx_buf), ret;
-   u32 val = GEN_HDATA(msg->tx_len) | GEN_HTYPE(msg->type);
+   u32 hdr_val = GEN_HDATA(msg->tx_len) | GEN_HTYPE(msg->type);
u32 remainder = 0;
+   u32 val;

if (msg->tx_len < 3) {
dev_err(dsi->dev, "wrong tx buf length %zu for long write\n",
@@ -618,7 +620,7 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi 
*dsi,
}
}

-   return dw_mipi_dsi_gen_pkt_hdr_write(dsi, val);
+   return dw_mipi_dsi_gen_pkt_hdr_write(dsi, hdr_val);
 }

 static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host,
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 04/26] drm/rockchip: dw-mipi-dsi: rename commit hook to enable

2016-09-19 Thread John Keeping
Rockchip DRM is fully atomic and commit is deprecated for atomic
drivers.  No changed are needed beyond renaming the function.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 5925a185ed76..fac2429b9d6d 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -852,7 +852,7 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder 
*encoder)
clk_disable_unprepare(dsi->pclk);
 }

-static void dw_mipi_dsi_encoder_commit(struct drm_encoder *encoder)
+static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)
 {
struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder);
int mux = drm_of_encoder_active_endpoint_id(dsi->dev->of_node, encoder);
@@ -924,7 +924,7 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder 
*encoder,

 static struct drm_encoder_helper_funcs
 dw_mipi_dsi_encoder_helper_funcs = {
-   .commit = dw_mipi_dsi_encoder_commit,
+   .enable = dw_mipi_dsi_encoder_enable,
.mode_set = dw_mipi_dsi_encoder_mode_set,
.disable = dw_mipi_dsi_encoder_disable,
.atomic_check = dw_mipi_dsi_encoder_atomic_check,
-- 
2.10.0.278.g4f427b1.dirty



[PATCH 03/26] drm/rockchip: dw-mipi-dsi: don't configure hardware in mode_set for MIPI

2016-09-19 Thread John Keeping
With atomic modesetting the hardware will be powered off when the
mode_set function is called.  We should configure the hardware in the
commit function (or even the enable function, but switching from commit
to enable is left for a future patch).

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 40 +-
 1 file changed, 15 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index fa90bb615fd0..5925a185ed76 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -822,32 +822,8 @@ static void dw_mipi_dsi_encoder_mode_set(struct 
drm_encoder *encoder,
struct drm_display_mode *adjusted_mode)
 {
struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder);
-   int ret;
-
-   ret = dw_mipi_dsi_get_lane_bps(dsi, adjusted_mode);
-   if (ret < 0)
-   return;
-
-   if (clk_prepare_enable(dsi->pclk)) {
-   dev_err(dsi->dev, "%s: Failed to enable pclk\n", __func__);
-   return;
-   }

-   dw_mipi_dsi_init(dsi);
-   dw_mipi_dsi_dpi_config(dsi);
-   dw_mipi_dsi_packet_handler_config(dsi);
-   dw_mipi_dsi_video_mode_config(dsi);
-   dw_mipi_dsi_video_packet_config(dsi);
-   dw_mipi_dsi_command_mode_config(dsi);
-   dw_mipi_dsi_line_timer_config(dsi);
-   dw_mipi_dsi_vertical_timing_config(dsi);
-   dw_mipi_dsi_dphy_timing_config(dsi);
-   dw_mipi_dsi_dphy_interface_config(dsi);
-   dw_mipi_dsi_clear_err(dsi);
-   if (drm_panel_prepare(dsi->panel))
-   dev_err(dsi->dev, "failed to prepare panel\n");
-
-   clk_disable_unprepare(dsi->pclk);
+   dw_mipi_dsi_get_lane_bps(dsi, adjusted_mode);
 }

 static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder)
@@ -887,6 +863,20 @@ static void dw_mipi_dsi_encoder_commit(struct drm_encoder 
*encoder)
return;
}

+   dw_mipi_dsi_init(dsi);
+   dw_mipi_dsi_dpi_config(dsi);
+   dw_mipi_dsi_packet_handler_config(dsi);
+   dw_mipi_dsi_video_mode_config(dsi);
+   dw_mipi_dsi_video_packet_config(dsi);
+   dw_mipi_dsi_command_mode_config(dsi);
+   dw_mipi_dsi_line_timer_config(dsi);
+   dw_mipi_dsi_vertical_timing_config(dsi);
+   dw_mipi_dsi_dphy_timing_config(dsi);
+   dw_mipi_dsi_dphy_interface_config(dsi);
+   dw_mipi_dsi_clear_err(dsi);
+   if (drm_panel_prepare(dsi->panel))
+   dev_err(dsi->dev, "failed to prepare panel\n");
+
dw_mipi_dsi_phy_init(dsi);
dw_mipi_dsi_wait_for_two_frames(dsi);

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 02/26] drm/rockchip: dw-mipi-dsi: pass new mode into MIPI mode set

2016-09-19 Thread John Keeping
In the atomic world the new connector state is not set when mode_set is
called and we should use the adjusted_mode parameter.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index a87037556f5c..fa90bb615fd0 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -459,9 +459,9 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
return ret;
 }

-static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi)
+static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi,
+   struct drm_display_mode *mode)
 {
-   struct drm_display_mode *mode = 
&dsi->connector.state->crtc->state->adjusted_mode;
unsigned int i, pre;
unsigned long mpclk, pllref, tmp;
unsigned int m = 1, n = 1, target_mbps = 1000;
@@ -824,7 +824,7 @@ static void dw_mipi_dsi_encoder_mode_set(struct drm_encoder 
*encoder,
struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder);
int ret;

-   ret = dw_mipi_dsi_get_lane_bps(dsi);
+   ret = dw_mipi_dsi_get_lane_bps(dsi, adjusted_mode);
if (ret < 0)
return;

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 01/26] drm/rockchip: dw-mipi-dsi: use mode from display state

2016-09-19 Thread John Keeping
There is no need to keep a pointer to the mode around since we know it
will be present in the connector state.

Signed-off-by: John Keeping 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index ca22e5ee89ca..a87037556f5c 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -286,7 +286,6 @@ struct dw_mipi_dsi {
u32 format;
u16 input_div;
u16 feedback_div;
-   struct drm_display_mode *mode;

const struct dw_mipi_dsi_plat_data *pdata;
 };
@@ -332,9 +331,10 @@ static int max_mbps_to_testdin(unsigned int max_mbps)
  */
 static void dw_mipi_dsi_wait_for_two_frames(struct dw_mipi_dsi *dsi)
 {
+   struct drm_display_mode *mode = 
&dsi->connector.state->crtc->state->adjusted_mode;
int refresh, two_frames;

-   refresh = drm_mode_vrefresh(dsi->mode);
+   refresh = drm_mode_vrefresh(mode);
two_frames = DIV_ROUND_UP(MSEC_PER_SEC, refresh) * 2;
msleep(two_frames);
 }
@@ -461,6 +461,7 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)

 static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi)
 {
+   struct drm_display_mode *mode = 
&dsi->connector.state->crtc->state->adjusted_mode;
unsigned int i, pre;
unsigned long mpclk, pllref, tmp;
unsigned int m = 1, n = 1, target_mbps = 1000;
@@ -474,7 +475,7 @@ static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi)
return bpp;
}

-   mpclk = DIV_ROUND_UP(dsi->mode->clock, MSEC_PER_SEC);
+   mpclk = DIV_ROUND_UP(mode->clock, MSEC_PER_SEC);
if (mpclk) {
/* take 1 / 0.9, since mbps must big than bandwidth of RGB */
tmp = mpclk * (bpp / dsi->lanes) * 10 / 9;
@@ -689,9 +690,9 @@ static void dw_mipi_dsi_init(struct dw_mipi_dsi *dsi)
dsi_write(dsi, DSI_LPCLK_CTRL, PHY_TXREQUESTCLKHS);
 }

-static void dw_mipi_dsi_dpi_config(struct dw_mipi_dsi *dsi,
-  struct drm_display_mode *mode)
+static void dw_mipi_dsi_dpi_config(struct dw_mipi_dsi *dsi)
 {
+   struct drm_display_mode *mode = 
&dsi->connector.state->crtc->state->adjusted_mode;
u32 val = 0, color = 0;

switch (dsi->format) {
@@ -726,9 +727,10 @@ static void dw_mipi_dsi_packet_handler_config(struct 
dw_mipi_dsi *dsi)
dsi_write(dsi, DSI_PCKHDL_CFG, EN_CRC_RX | EN_ECC_RX | EN_BTA);
 }

-static void dw_mipi_dsi_video_packet_config(struct dw_mipi_dsi *dsi,
-   struct drm_display_mode *mode)
+static void dw_mipi_dsi_video_packet_config(struct dw_mipi_dsi *dsi)
 {
+   struct drm_display_mode *mode = 
&dsi->connector.state->crtc->state->adjusted_mode;
+
dsi_write(dsi, DSI_VID_PKT_SIZE, VID_PKT_SIZE(mode->hdisplay));
 }

@@ -744,12 +746,13 @@ static void dw_mipi_dsi_command_mode_config(struct 
dw_mipi_dsi *dsi)
 static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
   u32 hcomponent)
 {
+   struct drm_display_mode *mode = 
&dsi->connector.state->crtc->state->adjusted_mode;
u32 frac, lbcc;

lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;

-   frac = lbcc % dsi->mode->clock;
-   lbcc = lbcc / dsi->mode->clock;
+   frac = lbcc % mode->clock;
+   lbcc = lbcc / mode->clock;
if (frac)
lbcc++;

@@ -759,7 +762,7 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct 
dw_mipi_dsi *dsi,
 static void dw_mipi_dsi_line_timer_config(struct dw_mipi_dsi *dsi)
 {
u32 htotal, hsa, hbp, lbcc;
-   struct drm_display_mode *mode = dsi->mode;
+   struct drm_display_mode *mode = 
&dsi->connector.state->crtc->state->adjusted_mode;

htotal = mode->htotal;
hsa = mode->hsync_end - mode->hsync_start;
@@ -778,7 +781,7 @@ static void dw_mipi_dsi_line_timer_config(struct 
dw_mipi_dsi *dsi)
 static void dw_mipi_dsi_vertical_timing_config(struct dw_mipi_dsi *dsi)
 {
u32 vactive, vsa, vfp, vbp;
-   struct drm_display_mode *mode = dsi->mode;
+   struct drm_display_mode *mode = 
&dsi->connector.state->crtc->state->adjusted_mode;

vactive = mode->vdisplay;
vsa = mode->vsync_end - mode->vsync_start;
@@ -821,8 +824,6 @@ static void dw_mipi_dsi_encoder_mode_set(struct drm_encoder 
*encoder,
struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder);
int ret;

-   dsi->mode = adjusted_mode;
-
ret = dw_mipi_dsi_get_lane_bps(dsi);
if (ret < 0)
return;
@@ -833,10 +834,10 @@ static void dw_mipi_dsi_encoder_mode_set(struct 
drm_encoder *encoder,
}

dw_mipi_dsi_init(dsi);
-   dw_mipi_dsi_dpi_config(dsi, mode);
+   dw_mipi_dsi_dpi_config(dsi);
dw_mipi_dsi_packet_handler_config(dsi);
dw_mipi_dsi_video_m

[PATCH 00/27] drm/rockchip: MIPI fixes & improvements

2016-09-19 Thread John Keeping
This is a bit of a mixed selection of patches to all areas of the
Rockchip dw-mipi-dsi driver, which I've been using for a while.

The first few patches fix the driver's use of the atomic API by removing
hardware manipulation from the mode_set hook:

  drm/rockchip: dw-mipi-dsi: use mode from display state
  drm/rockchip: dw-mipi-dsi: pass new mode into MIPI mode set
  drm/rockchip: dw-mipi-dsi: don't configure hardware in mode_set for
MIPI
  drm/rockchip: dw-mipi-dsi: rename commit hook to enable

The following several patches fix various aspects of DSI host transfers
in order to improve support for displays that need to be set up via DSI
commands:

  drm/rockchip: dw-mipi-dsi: fix command header writes
  drm/rockchip: dw-mipi-dsi: fix generic packet status check
  drm/rockchip: dw-mipi-dsi: avoid out-of-bounds read on tx_buf
  drm/rockchip: dw-mipi-dsi: include bad value in error message
  drm/rockchip: dw-mipi-dsi: respect message flags
  drm/rockchip: dw-mipi-dsi: only request HS clock when required
  drm/rockchip: dw-mipi-dsi: don't assume buffer is aligned
  drm/rockchip: dw-mipi-dsi: prepare panel after phy init
  drm/rockchip: dw-mipi-dsi: allow commands in panel_disable

Then a bunch of patches to improve the PHY PLL and other clock setup:

  drm/rockchip: dw-mipi-dsi: fix escape clock rate
  drm/rockchip: dw-mipi-dsi: ensure PHY is reset
  drm/rockchip: dw-mipi-dsi: configure bias and bandgap before enable
  drm/rockchip: dw-mipi-dsi: don't enable PHY PLL until it's configured
  drm/rockchip: dw-mipi-dsi: properly configure PHY timing
  drm/rockchip: dw-mipi-dsi: improve PLL configuration

A couple of patches make the VOP and MIPI host consistent when panels do
not set explicit hsync/vsync polarities:

  drm/rockchip: dw-mipi-dsi: use positive check for N{H,V}SYNC
  drm/rockchip: vop: test for P{H,V}SYNC

The following patch fixes fbcon by making sure that the output
resolution is known before it loads:

  drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded

Then a patch that should be self-explanatory:

  drm/rockchip: dw-mipi-dsi: support non-burst modes

And the final two patches were useful in development but aren't really
needed once everything's working:

  drm/rockchip: dw-mipi-dsi: add reset control
  drm/rockchip: dw-mipi-dsi: support read commands


John Keeping (26):
  drm/rockchip: dw-mipi-dsi: use mode from display state
  drm/rockchip: dw-mipi-dsi: pass new mode into MIPI mode set
  drm/rockchip: dw-mipi-dsi: don't configure hardware in mode_set for
MIPI
  drm/rockchip: dw-mipi-dsi: rename commit hook to enable
  drm/rockchip: dw-mipi-dsi: fix command header writes
  drm/rockchip: dw-mipi-dsi: fix generic packet status check
  drm/rockchip: dw-mipi-dsi: avoid out-of-bounds read on tx_buf
  drm/rockchip: dw-mipi-dsi: include bad value in error message
  drm/rockchip: dw-mipi-dsi: respect message flags
  drm/rockchip: dw-mipi-dsi: only request HS clock when required
  drm/rockchip: dw-mipi-dsi: don't assume buffer is aligned
  drm/rockchip: dw-mipi-dsi: prepare panel after phy init
  drm/rockchip: dw-mipi-dsi: allow commands in panel_disable
  drm/rockchip: dw-mipi-dsi: fix escape clock rate
  drm/rockchip: dw-mipi-dsi: ensure PHY is reset
  drm/rockchip: dw-mipi-dsi: configure bias and bandgap before enable
  drm/rockchip: dw-mipi-dsi: don't enable PHY PLL until it's configured
  drm/rockchip: dw-mipi-dsi: properly configure PHY timing
  drm/rockchip: dw-mipi-dsi: improve PLL configuration
  drm/rockchip: dw-mipi-dsi: use specific poll helper
  drm/rockchip: dw-mipi-dsi: use positive check for N{H,V}SYNC
  drm/rockchip: vop: test for P{H,V}SYNC
  drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded
  drm/rockchip: dw-mipi-dsi: support non-burst modes
  drm/rockchip: dw-mipi-dsi: add reset control
  drm/rockchip: dw-mipi-dsi: support read commands

 drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 325 
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |   4 +-
 2 files changed, 234 insertions(+), 95 deletions(-)

-- 
2.10.0.278.g4f427b1.dirty



[PATCH 5/5] GPU-DRM: Rename a jump label in drm_legacy_mapbufs()

2016-09-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 19 Sep 2016 17:37:27 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/drm_bufs.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index adb1dd7..0d5ee1e 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1476,7 +1476,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,

if (!map) {
retcode = -EINVAL;
-   goto done;
+   goto status_indication;
}
virtual = vm_mmap(file_priv->filp, 0, map->size,
  PROT_READ | PROT_WRITE,
@@ -1490,7 +1490,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
if (virtual > -1024UL) {
/* Real error */
retcode = (signed long)virtual;
-   goto done;
+   goto status_indication;
}
request->virtual = (void __user *)virtual;

@@ -1499,28 +1499,28 @@ int drm_legacy_mapbufs(struct drm_device *dev, void 
*data,
 &dma->buflist[i]->idx,
 sizeof(request->list[0].idx))) {
retcode = -EFAULT;
-   goto done;
+   goto status_indication;
}
if (copy_to_user(&request->list[i].total,
 &dma->buflist[i]->total,
 sizeof(request->list[0].total))) {
retcode = -EFAULT;
-   goto done;
+   goto status_indication;
}
if (copy_to_user(&request->list[i].used,
 &zero, sizeof(zero))) {
retcode = -EFAULT;
-   goto done;
+   goto status_indication;
}
address = virtual + dma->buflist[i]->offset;/* *** 
*/
if (copy_to_user(&request->list[i].address,
 &address, sizeof(address))) {
retcode = -EFAULT;
-   goto done;
+   goto status_indication;
}
}
}
-  done:
+ status_indication:
request->count = dma->buf_count;
DRM_DEBUG("%d buffers, retcode = %d\n", request->count, retcode);

-- 
2.10.0



[PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()

2016-09-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 19 Sep 2016 17:30:31 +0200

The script "checkpatch.pl" can point information out like the following.

WARNING: Prefer kcalloc over kzalloc with multiply

Thus fix the affected source code place.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/drm_bufs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 36dd685..adb1dd7 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1117,8 +1117,7 @@ static int drm_legacy_addbufs_sg(struct drm_device *dev,
return -EINVAL;
}

-   entry->buflist = kzalloc(count * sizeof(*entry->buflist),
-   GFP_KERNEL);
+   entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
if (!entry->buflist) {
mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
-- 
2.10.0



[PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp()

2016-09-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 19 Sep 2016 17:24:20 +0200

The script "checkpatch.pl" can point information out like the following.

WARNING: Prefer kcalloc over kzalloc with multiply

Thus fix the affected source code place.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/drm_bufs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 8a31dac..36dd685 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -755,7 +755,7 @@ int drm_legacy_addbufs_agp(struct drm_device *dev,
return -EINVAL;
}

-   entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
+   entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
if (!entry->buflist) {
mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
-- 
2.10.0



[PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() in drm_legacy_addbufs_pci()

2016-09-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 19 Sep 2016 17:17:34 +0200

The script "checkpatch.pl" can point information out like the following.

WARNING: Prefer kcalloc over kzalloc with multiply

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/drm_bufs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index ed33f43..8a31dac 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -905,14 +905,14 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
return -EINVAL;
}

-   entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
+   entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
if (!entry->buflist) {
mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}

-   entry->seglist = kzalloc(count * sizeof(*entry->seglist), GFP_KERNEL);
+   entry->seglist = kcalloc(count, sizeof(*entry->seglist), GFP_KERNEL);
if (!entry->seglist) {
kfree(entry->buflist);
mutex_unlock(&dev->struct_mutex);
-- 
2.10.0



[PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci()

2016-09-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 19 Sep 2016 17:07:06 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/drm_bufs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 3219151..ed33f43 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -923,8 +923,9 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
/* Keep the original pagelist until we know all the allocations
 * have succeeded
 */
-   temp_pagelist = kmalloc((dma->page_count + (count << page_order)) *
-  sizeof(*dma->pagelist), GFP_KERNEL);
+   temp_pagelist = kmalloc_array(dma->page_count + (count << page_order),
+ sizeof(*dma->pagelist),
+ GFP_KERNEL);
if (!temp_pagelist) {
kfree(entry->buflist);
kfree(entry->seglist);
-- 
2.10.0



[PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations

2016-09-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 19 Sep 2016 17:47:37 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
  Use kmalloc_array() in drm_legacy_addbufs_pci()
  Replace two kzalloc() calls by kcalloc() in drm_legacy_addbufs_pci()
  Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp()
  Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()
  Rename a jump label in drm_legacy_mapbufs()

 drivers/gpu/drm/drm_bufs.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

-- 
2.10.0



[git pull] drm fixes for 4.8

2016-09-19 Thread Dave Airlie
Hi Linus,

One important drm 32/64 ABI fix came in so I'll dequeue what I have, the rest is
just exynos runtime pm fixes, but the net removal of code seems like a
win to me.

I'm going to be sporadic this week due to school holidays, so if anything urgent
turns up, Daniel will take care of it.

Dave.

The following changes since commit 09cb5b78af52208afb9f1b194c8a9154df4a4782:

  Merge tag 'drm-vc4-fixes-2016-09-14' of
https://github.com/anholt/linux into drm-fixes (2016-09-17 07:57:55
+1000)

are available in the git repository at:

  git://people.freedesktop.org/~airlied/linux tags/drm-fixes-for-4.8-rc7

for you to fetch changes up to 47a66e45d7a7613322549c2475ea9d809baaf514:

  drm: Only use compat ioctl for addfb2 on X86/IA64 (2016-09-19 17:28:20 +1000)


exynos and one stable ABI fix


Arnd Bergmann (1):
  Subject: [PATCH, RESEND] drm: exynos: avoid unused function warning

Dave Airlie (1):
  Merge branch 'exynos-drm-fixes' of
git://git.kernel.org/.../daeinki/drm-exynos into drm-fixes

Kristian H. Kristensen (1):
  drm: Only use compat ioctl for addfb2 on X86/IA64

Marek Szyprowski (4):
  drm/exynos: fimc: fix system and runtime pm integration
  drm/exynos: gsc: fix system and runtime pm integration
  drm/exynos: rotator: fix system and runtime pm integration
  drm/exynos: g2d: fix system and runtime pm integration

Shuah Khan (1):
  exynos-drm: Fix unsupported GEM memory type error message to be clear

 drivers/gpu/drm/drm_ioc32.c |  4 
 drivers/gpu/drm/exynos/exynos_drm_fb.c  |  6 ++---
 drivers/gpu/drm/exynos/exynos_drm_fimc.c| 29 ++--
 drivers/gpu/drm/exynos/exynos_drm_g2d.c | 29 ++--
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 35 -
 drivers/gpu/drm/exynos/exynos_drm_rotator.c | 26 ++---
 6 files changed, 22 insertions(+), 107 deletions(-)


[GIT PULL] imx-drm fixes, cleanups, image conversion

2016-09-19 Thread Dave Airlie
On 19 September 2016 at 17:31, Philipp Zabel  wrote:
> Hi Dave,
>
> please consider merging this tag containing the latest active plane
> reconfiguration patches, several fixes and cleanups, and image
> conversion support for the V4L2 drivers to build upon.
>
> The active plane reconfiguration patch (v4) will conflict with the v2
> patch that already went into v4.8-rc5 to fix a regression. I have not
> yet included a backmerge with this tag, because that would mean also
> pulling in v4.8-rc3. Please let me know if I also should prepare a pull
> request containing the merges.

fatal: unable to connect to git.pengutronix.de:
git.pengutronix.de[0: 5.9.183.235]: errno=Connection refused

temporary?

How conflicty is the backmerge, might be nice to just post an extra
branch for reference if it's too messy..

I probably won't get to a backmerge to -next this week.

Dave.


[Bug 97856] Computer restart playing 3D games (possibly overheating)

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97856

--- Comment #6 from Alex Deucher  ---
Please attach your xorg log and dmesg from a regular boot and from booting with
radeon.dpm=1.  It doesn't have to be after it crashes.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/86018659/attachment.html>


[Bug 97856] Computer restart playing 3D games (possibly overheating)

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97856

--- Comment #5 from Alex Henry  ---
Created attachment 126629
  --> https://bugs.freedesktop.org/attachment.cgi?id=126629&action=edit
Zipped Xorg log file from last session (over 8MB uncompressed)

Obviously this is a text file. It can be opened with a text editor even if your
system doesn't automatically recognize it as a text file due to the .old
extension.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/478fe858/attachment.html>


[Bug 97856] Computer restart playing 3D games (possibly overheating)

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97856

--- Comment #4 from Alex Henry  ---
I've reproduced the bug again (this time it took around 5 minutes to crash my
system after opening up a game) to make sure the xorg log had nothing of value
since I was not sure I had checked this file in specific. I'll attach my log
file next. Of particular note are almost 8 lines of output similar to this:

[  6115.586] (II) RADEON(0): EDID vendor "AOC", prod id 6512
[  6115.587] (II) RADEON(0): Printing DDC gathered Modelines:
[  6115.587] (II) RADEON(0): Modeline "1366x768"x0.0   85.50  1366 1436 1579
1792  768 771 774 798 +hsync +vsync (47.7 kHz eP)
[  6115.587] (II) RADEON(0): Modeline "1360x768"x0.0   85.50  1360 1424 1536
1792  768 771 777 795 +hsync +vsync (47.7 kHz e)
...

Also I forgot to mention there are two types of crashes: one in which the
computer instantly reboots and the other in which the image on-screen freezes
in the last drawn frame, the sounds enters a short loop around half a second
long (probably the sound buffer repeating its last contents) and the entire
system becomes unresponsive, which forces a manual reboot.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/8383fde9/attachment.html>


[PATCH] drm/ast: free correct pointer in astfb_create() error paths

2016-09-19 Thread Andrew Donnellan
In the err_free_vram and err_release_fbi error paths in astfb_create(), we
attempt to free afbdev->sysram. The only jumps to these error paths occur
before we assign afbdev->sysram = sysram. Free sysram instead.

Signed-off-by: Andrew Donnellan 

---

Found by Coverity Scan. Compile tested only.
---
 drivers/gpu/drm/ast/ast_fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index c017a93..0fef8ea 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -254,7 +254,7 @@ static int astfb_create(struct drm_fb_helper *helper,
 err_release_fbi:
drm_fb_helper_release_fbi(helper);
 err_free_vram:
-   vfree(afbdev->sysram);
+   vfree(sysram);
return ret;
 }

-- 
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com  IBM Australia Limited



[PATCH 09/14] drm/msm: Fix sparse warnings

2016-09-19 Thread Emil Velikov
On 19 September 2016 at 16:33, Jani Nikula  
wrote:
> On Mon, 19 Sep 2016, Emil Velikov  wrote:
>> On 19 September 2016 at 14:33,   wrote:
>>
>>> --- a/drivers/gpu/drm/msm/msm_fb.c
>>> +++ b/drivers/gpu/drm/msm/msm_fb.c
>>> @@ -132,7 +132,7 @@ const struct msm_format *msm_framebuffer_format(struct 
>>> drm_framebuffer *fb)
>>>  struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
>>> struct drm_file *file, const struct drm_mode_fb_cmd2 
>>> *mode_cmd)
>>>  {
>>> -   struct drm_gem_object *bos[4] = {0};
>>> +   struct drm_gem_object *bos[4] = {};
>> Fwiw I was reminded using empty initializers isn't standard C [1].
>
> Well, meh, we're not doing -std=c11 -pedantic. Arguably {} is neater.
>
> I guess the commit message lacks the sparse warning about using plain
> integer 0 as NULL pointer.
>
Ack. Just pointing it out for people, who weren't familiar. Fwiw this
is one of the bigger bikesheding topics I've seen, esp. since
different compiler (versions) produce warnings for each permutation
:-\

Sparse shouldn't produce warning since the spec explicitly states that
0 should be 'good enough' for anyone ;-)

Regards,
Emil


[PATCH 12/14] drm/sti: Fix sparse warnings

2016-09-19 Thread Vincent ABRIOU
Acked-by: Vincent Abriou 

On 09/19/2016 03:33 PM, ville.syrjala at linux.intel.com wrote:
> From: Ville Syrjälä 
>
> drm/sti/sti_mixer.c:361:6: warning: symbol 'sti_mixer_set_matrix' was not 
> declared. Should it be static?
> drm/sti/sti_gdp.c:476:5: warning: symbol 'sti_gdp_field_cb' was not declared. 
> Should it be static?
> drm/sti/sti_gdp.c:885:24: warning: symbol 'sti_gdp_plane_helpers_funcs' was 
> not declared. Should it be static?
> drm/sti/sti_cursor.c:348:24: warning: symbol 'sti_cursor_plane_helpers_funcs' 
> was not declared. Should it be static?
> drm/sti/sti_compositor.c:28:28: warning: symbol 'stih407_compositor_data' was 
> not declared. Should it be static?
> drm/sti/sti_compositor.c:49:28: warning: symbol 'stih416_compositor_data' was 
> not declared. Should it be static?
> drm/sti/sti_vtg.c:75:1: warning: symbol 'vtg_lookup' was not declared. Should 
> it be static?
> drm/sti/sti_vtg.c:476:24: warning: symbol 'sti_vtg_driver' was not declared. 
> Should it be static?
> drm/sti/sti_dvo.c:109:5: warning: symbol 'dvo_awg_generate_code' was not 
> declared. Should it be static?
> drm/sti/sti_dvo.c:602:24: warning: symbol 'sti_dvo_driver' was not declared. 
> Should it be static?
> drm/sti/sti_vtac.c:209:24: warning: symbol 'sti_vtac_driver' was not 
> declared. Should it be static?
> drm/sti/sti_tvout.c:914:24: warning: symbol 'sti_tvout_driver' was not 
> declared. Should it be static?
> drm/sti/sti_hqvdp.c:786:5: warning: symbol 'sti_hqvdp_vtg_cb' was not 
> declared. Should it be static?
> drm/sti/sti_hqvdp.c:1253:24: warning: symbol 'sti_hqvdp_plane_helpers_funcs' 
> was not declared. Should it be static?
> drm/sti/sti_hqvdp.c:1292:5: warning: symbol 'sti_hqvdp_bind' was not 
> declared. Should it be static?
> drm/sti/sti_hqvdp.c:1385:24: warning: symbol 'sti_hqvdp_driver' was not 
> declared. Should it be static?
> drm/sti/sti_drv.c:143:6: warning: symbol 'sti_drm_dbg_cleanup' was not 
> declared. Should it be static?
>
> Cc: Benjamin Gaignard 
> Cc: Vincent Abriou 
> Signed-off-by: Ville Syrjälä 
> ---
>  drivers/gpu/drm/sti/sti_compositor.c | 4 ++--
>  drivers/gpu/drm/sti/sti_cursor.c | 2 +-
>  drivers/gpu/drm/sti/sti_drv.c| 2 +-
>  drivers/gpu/drm/sti/sti_dvo.c| 3 ++-
>  drivers/gpu/drm/sti/sti_gdp.c| 6 +++---
>  drivers/gpu/drm/sti/sti_hqvdp.c  | 7 ---
>  drivers/gpu/drm/sti/sti_mixer.c  | 2 +-
>  drivers/gpu/drm/sti/sti_tvout.c  | 1 +
>  drivers/gpu/drm/sti/sti_vtac.c   | 2 ++
>  drivers/gpu/drm/sti/sti_vtg.c| 3 ++-
>  10 files changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_compositor.c 
> b/drivers/gpu/drm/sti/sti_compositor.c
> index 134201ecc6fd..a8441ae2623a 100644
> --- a/drivers/gpu/drm/sti/sti_compositor.c
> +++ b/drivers/gpu/drm/sti/sti_compositor.c
> @@ -25,7 +25,7 @@
>  /*
>   * stiH407 compositor properties
>   */
> -struct sti_compositor_data stih407_compositor_data = {
> +static const struct sti_compositor_data stih407_compositor_data = {
>   .nb_subdev = 8,
>   .subdev_desc = {
>   {STI_CURSOR_SUBDEV, (int)STI_CURSOR, 0x000},
> @@ -46,7 +46,7 @@ struct sti_compositor_data stih407_compositor_data = {
>   * Moreover, GDPx is different for Main and Aux Mixer. So this subdev map 
> does
>   * not fit for stiH416 if we want to enable the MIXER_AUX.
>   */
> -struct sti_compositor_data stih416_compositor_data = {
> +static const struct sti_compositor_data stih416_compositor_data = {
>   .nb_subdev = 3,
>   .subdev_desc = {
>   {STI_GPD_SUBDEV, (int)STI_GDP_0, 0x100},
> diff --git a/drivers/gpu/drm/sti/sti_cursor.c 
> b/drivers/gpu/drm/sti/sti_cursor.c
> index 3b53f7f2e3fc..651f231c4615 100644
> --- a/drivers/gpu/drm/sti/sti_cursor.c
> +++ b/drivers/gpu/drm/sti/sti_cursor.c
> @@ -345,7 +345,7 @@ static int sti_cursor_late_register(struct drm_plane 
> *drm_plane)
>   return cursor_debugfs_init(cursor, drm_plane->dev->primary);
>  }
>
> -struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
> +static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
>   .update_plane = drm_atomic_helper_update_plane,
>   .disable_plane = drm_atomic_helper_disable_plane,
>   .destroy = sti_cursor_destroy,
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 7cd3804c6dee..e6f0706bc6c7 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -140,7 +140,7 @@ err:
>   return ret;
>  }
>
> -void sti_drm_dbg_cleanup(struct drm_minor *minor)
> +static void sti_drm_dbg_cleanup(struct drm_minor *minor)
>  {
>   drm_debugfs_remove_files(sti_drm_dbg_list,
>ARRAY_SIZE(sti_drm_dbg_list), minor);
> diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
> index 00881eb4536e..e8c1ed08a9f7 100644
> --- a/drivers/gpu/drm/sti/sti_dvo.c
> +++ b/drivers/gpu/drm/sti/sti_dvo.c
> @@ -17,6 +17,7 @@
>  #include 

[PATCH 03/14] drm/fb-helper: Fix sparse warnings

2016-09-19 Thread Daniel Vetter
On Mon, Sep 19, 2016 at 04:33:44PM +0300, ville.syrjala at linux.intel.com 
wrote:
> From: Ville Syrjälä 
> 
> drm/drm_fb_helper.c:2306:12: warning: symbol 'drm_fb_helper_modinit' was not 
> declared. Should it be static?
> 
> While at it, move the lefover static inline to the right place.
> 
> Cc: Daniel Vetter 
> Cc: Sean Paul 
> Signed-off-by: Ville Syrjälä 

Merged the first 3 core patches to drm-misc. For the others a bit more
soaking time for maintainers to ack them I guess.
-Daniel

> ---
>  drivers/gpu/drm/drm_crtc_helper_internal.h | 7 +++
>  drivers/gpu/drm/drm_fb_helper.c| 2 ++
>  include/drm/drm_fb_helper.h| 5 -
>  3 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc_helper_internal.h 
> b/drivers/gpu/drm/drm_crtc_helper_internal.h
> index 4e6b57ae7188..28295e5d0d9e 100644
> --- a/drivers/gpu/drm/drm_crtc_helper_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_helper_internal.h
> @@ -29,7 +29,14 @@
>  #include 
>  
>  /* drm_fb_helper.c */
> +#ifdef CONFIG_DRM_FBDEV_EMULATION
>  int drm_fb_helper_modinit(void);
> +#else
> +static inline int drm_fb_helper_modinit(void)
> +{
> + return 0;
> +}
> +#endif
>  
>  /* drm_dp_aux_dev.c */
>  #ifdef CONFIG_DRM_DP_AUX_CHARDEV
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index dd8e3b68fd53..03414bde1f15 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -41,6 +41,8 @@
>  #include 
>  #include 
>  
> +#include "drm_crtc_helper_internal.h"
> +
>  static bool drm_fbdev_emulation = true;
>  module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
>  MODULE_PARM_DESC(fbdev_emulation,
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index 797fb5f80c45..e19458dd1a43 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -287,11 +287,6 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper 
> *fb_helper, struct drm_
>  int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
>  struct drm_connector *connector);
>  #else
> -static inline int drm_fb_helper_modinit(void)
> -{
> - return 0;
> -}
> -
>  static inline void drm_fb_helper_prepare(struct drm_device *dev,
>   struct drm_fb_helper *helper,
>   const struct drm_fb_helper_funcs *funcs)
> -- 
> 2.7.4
> 

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


[Bug 97856] Computer restart playing 3D games (possibly overheating)

2016-09-19 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97856

--- Comment #3 from Alex Henry  ---
Hi Alex! As I've said there is no error log that I can find. I assume the
hardware fails and reboots before it has any chance to write anything to disk.
Or are you looking for some other type of information from the logs?

I did try manually adding radeon.dpm=1 as a kernel parameter to GRUB and I also
tried setting the driver profile to low to see if it would use less energy;
also enabling dyndpm to try and produce less heat; I've also tried setting my
BIOS fan speed control to turbo. None of that helped. On my alternate system
fglrx works fine with my BIOS and the Catalyst control panel in their default
options.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160919/9e27a51e/attachment.html>


[Intel-gfx] [PATCH] drm: fix implicit declaration build error on ia64

2016-09-19 Thread Daniel Vetter
On Fri, Sep 16, 2016 at 01:06:36PM +0300, Jani Nikula wrote:
>drivers/gpu/drm/drm_dp_helper.c: In function 'drm_dp_downstream_debug':
> >> drivers/gpu/drm/drm_dp_helper.c:551:2: error: implicit declaration of
> >> function 'seq_printf' [-Werror=implicit-function-declaration]
>  seq_printf(m, "\tDP branch device present: %s\n",
>  ^
> >> drivers/gpu/drm/drm_dp_helper.c:559:3: error: implicit declaration of
> >> function 'seq_puts' [-Werror=implicit-function-declaration]
>  seq_puts(m, "\t\tType: DisplayPort\n");
>  ^
> 
> Reported-by: kbuild test robot 
> References: 
> https://lists.freedesktop.org/archives/intel-gfx/2016-September/106638.html
> Fixes: 80209e5f2c42 ("drm: Add DP branch device info on debugfs")
> Cc: Mika Kahola 
> Signed-off-by: Jani Nikula 

Applied to drm-misc (yeah wrong branch, but easier that way ...).

Thanks, Daniel

> 
> ---
> 
> The commit being fixed is only in drm-intel tree. I failed at actually
> testing this, but I presume this is the fix...
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index a5365142cdba..894a6ac6f6e7 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> -- 
> 2.1.4
> 
> ___
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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


[PATCH 14/14] drm/tilcdc: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/tilcdc/tilcdc_tfp410.c:385:24: warning: symbol 'tfp410_driver' was not 
declared. Should it be static?
drm/tilcdc/tilcdc_tfp410.c:395:12: warning: symbol 'tilcdc_tfp410_init' was not 
declared. Should it be static?
drm/tilcdc/tilcdc_tfp410.c:400:13: warning: symbol 'tilcdc_tfp410_fini' was not 
declared. Should it be static?
drm/tilcdc/tilcdc_panel.c:436:24: warning: symbol 'panel_driver' was not 
declared. Should it be static?
drm/tilcdc/tilcdc_panel.c:446:12: warning: symbol 'tilcdc_panel_init' was not 
declared. Should it be static?
drm/tilcdc/tilcdc_panel.c:451:13: warning: symbol 'tilcdc_panel_fini' was not 
declared. Should it be static?
drm/tilcdc/tilcdc_drv.c:78:5: warning: symbol 'tilcdc_atomic_check' was not 
declared. Should it be static?

Cc: Jyri Sarha 
Cc: Tomi Valkeinen 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c| 4 ++--
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  | 3 ++-
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index f8892e9ad169..d6f8780e41df 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -75,8 +75,8 @@ static void tilcdc_fb_output_poll_changed(struct drm_device 
*dev)
drm_fbdev_cma_hotplug_event(priv->fbdev);
 }

-int tilcdc_atomic_check(struct drm_device *dev,
-   struct drm_atomic_state *state)
+static int tilcdc_atomic_check(struct drm_device *dev,
+  struct drm_atomic_state *state)
 {
int ret;

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c 
b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
index 7b3650901930..b8dbcc2a4b7c 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
@@ -25,6 +25,7 @@
 #include 

 #include "tilcdc_drv.h"
+#include "tilcdc_panel.h"

 struct panel_module {
struct tilcdc_module base;
@@ -433,7 +434,7 @@ static struct of_device_id panel_of_match[] = {
{ },
 };

-struct platform_driver panel_driver = {
+static struct platform_driver panel_driver = {
.probe = panel_probe,
.remove = panel_remove,
.driver = {
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c 
b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
index c6a70da6473d..2247150f326a 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
@@ -23,6 +23,7 @@
 #include 

 #include "tilcdc_drv.h"
+#include "tilcdc_tfp410.h"

 struct tfp410_module {
struct tilcdc_module base;
@@ -382,7 +383,7 @@ static struct of_device_id tfp410_of_match[] = {
{ },
 };

-struct platform_driver tfp410_driver = {
+static struct platform_driver tfp410_driver = {
.probe = tfp410_probe,
.remove = tfp410_remove,
.driver = {
-- 
2.7.4



[PATCH 13/14] drm/sun4i: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/sun4i/sun4i_tv.c:181:21: warning: symbol 'ntsc_video_levels' was not 
declared. Should it be static?
drm/sun4i/sun4i_tv.c:185:21: warning: symbol 'pal_video_levels' was not 
declared. Should it be static?
drm/sun4i/sun4i_tv.c:189:21: warning: symbol 'ntsc_burst_levels' was not 
declared. Should it be static?
drm/sun4i/sun4i_tv.c:193:21: warning: symbol 'pal_burst_levels' was not 
declared. Should it be static?
drm/sun4i/sun4i_tv.c:197:20: warning: symbol 'ntsc_color_gains' was not 
declared. Should it be static?
drm/sun4i/sun4i_tv.c:201:20: warning: symbol 'pal_color_gains' was not 
declared. Should it be static?
drm/sun4i/sun4i_tv.c:205:26: warning: symbol 'ntsc_resync_parameters' was not 
declared. Should it be static?
drm/sun4i/sun4i_tv.c:209:26: warning: symbol 'pal_resync_parameters' was not 
declared. Should it be static?
drm/sun4i/sun4i_tv.c:213:16: warning: symbol 'tv_modes' was not declared. 
Should it be static?

Cc: Maxime Ripard 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/sun4i/sun4i_tv.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c b/drivers/gpu/drm/sun4i/sun4i_tv.c
index b84147896294..3d69bd34f36c 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
@@ -161,10 +161,10 @@ struct tv_mode {
booldac3_en;
booldac_bit25_en;

-   struct color_gains  *color_gains;
-   struct burst_levels *burst_levels;
-   struct video_levels *video_levels;
-   struct resync_parameters*resync_params;
+   const struct color_gains*color_gains;
+   const struct burst_levels   *burst_levels;
+   const struct video_levels   *video_levels;
+   const struct resync_parameters  *resync_params;
 };

 struct sun4i_tv {
@@ -178,39 +178,39 @@ struct sun4i_tv {
struct sun4i_drv*drv;
 };

-struct video_levels ntsc_video_levels = {
+static const struct video_levels ntsc_video_levels = {
.black = 282,   .blank = 240,
 };

-struct video_levels pal_video_levels = {
+static const struct video_levels pal_video_levels = {
.black = 252,   .blank = 252,
 };

-struct burst_levels ntsc_burst_levels = {
+static const struct burst_levels ntsc_burst_levels = {
.cb = 79,   .cr = 0,
 };

-struct burst_levels pal_burst_levels = {
+static const struct burst_levels pal_burst_levels = {
.cb = 40,   .cr = 40,
 };

-struct color_gains ntsc_color_gains = {
+static const struct color_gains ntsc_color_gains = {
.cb = 160,  .cr = 160,
 };

-struct color_gains pal_color_gains = {
+static const struct color_gains pal_color_gains = {
.cb = 224,  .cr = 224,
 };

-struct resync_parameters ntsc_resync_parameters = {
+static const struct resync_parameters ntsc_resync_parameters = {
.field = false, .line = 14, .pixel = 12,
 };

-struct resync_parameters pal_resync_parameters = {
+static const struct resync_parameters pal_resync_parameters = {
.field = true,  .line = 13, .pixel = 12,
 };

-struct tv_mode tv_modes[] = {
+static const struct tv_mode tv_modes[] = {
{
.name   = "NTSC",
.mode   = SUN4I_TVE_CFG0_RES_480i,
@@ -289,13 +289,13 @@ drm_connector_to_sun4i_tv(struct drm_connector *connector)
  * So far, it doesn't seem to be preserved when the mode is passed by
  * to mode_set for some reason.
  */
-static struct tv_mode *sun4i_tv_find_tv_by_mode(struct drm_display_mode *mode)
+static const struct tv_mode *sun4i_tv_find_tv_by_mode(const struct 
drm_display_mode *mode)
 {
int i;

/* First try to identify the mode by name */
for (i = 0; i < ARRAY_SIZE(tv_modes); i++) {
-   struct tv_mode *tv_mode = &tv_modes[i];
+   const struct tv_mode *tv_mode = &tv_modes[i];

DRM_DEBUG_DRIVER("Comparing mode %s vs %s",
 mode->name, tv_mode->name);
@@ -306,7 +306,7 @@ static struct tv_mode *sun4i_tv_find_tv_by_mode(struct 
drm_display_mode *mode)

/* Then by number of lines */
for (i = 0; i < ARRAY_SIZE(tv_modes); i++) {
-   struct tv_mode *tv_mode = &tv_modes[i];
+   const struct tv_mode *tv_mode = &tv_modes[i];

DRM_DEBUG_DRIVER("Comparing mode %s vs %s (X: %d vs %d)",
 mode->name, tv_mode->name,
@@ -319,7 +319,7 @@ static struct tv_mode *sun4i_tv_find_tv_by_mode(struct 
drm_display_mode *mode)
return NULL;
 }

-static void sun4i_tv_mode_to_drm_mode(struct tv_mode *tv_mode,
+static void sun4i_tv_mode_to_drm_mode(const struct tv_mode *tv_mode,
  struct drm_display_mode *mode)
 {
DRM_DEBUG_DRIVER("Creating mode %s\n", mode->name);
@@ -386,7 +386,7 @@ static void sun4i_tv_mode_set(struct drm_encode

[PATCH 12/14] drm/sti: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/sti/sti_mixer.c:361:6: warning: symbol 'sti_mixer_set_matrix' was not 
declared. Should it be static?
drm/sti/sti_gdp.c:476:5: warning: symbol 'sti_gdp_field_cb' was not declared. 
Should it be static?
drm/sti/sti_gdp.c:885:24: warning: symbol 'sti_gdp_plane_helpers_funcs' was not 
declared. Should it be static?
drm/sti/sti_cursor.c:348:24: warning: symbol 'sti_cursor_plane_helpers_funcs' 
was not declared. Should it be static?
drm/sti/sti_compositor.c:28:28: warning: symbol 'stih407_compositor_data' was 
not declared. Should it be static?
drm/sti/sti_compositor.c:49:28: warning: symbol 'stih416_compositor_data' was 
not declared. Should it be static?
drm/sti/sti_vtg.c:75:1: warning: symbol 'vtg_lookup' was not declared. Should 
it be static?
drm/sti/sti_vtg.c:476:24: warning: symbol 'sti_vtg_driver' was not declared. 
Should it be static?
drm/sti/sti_dvo.c:109:5: warning: symbol 'dvo_awg_generate_code' was not 
declared. Should it be static?
drm/sti/sti_dvo.c:602:24: warning: symbol 'sti_dvo_driver' was not declared. 
Should it be static?
drm/sti/sti_vtac.c:209:24: warning: symbol 'sti_vtac_driver' was not declared. 
Should it be static?
drm/sti/sti_tvout.c:914:24: warning: symbol 'sti_tvout_driver' was not 
declared. Should it be static?
drm/sti/sti_hqvdp.c:786:5: warning: symbol 'sti_hqvdp_vtg_cb' was not declared. 
Should it be static?
drm/sti/sti_hqvdp.c:1253:24: warning: symbol 'sti_hqvdp_plane_helpers_funcs' 
was not declared. Should it be static?
drm/sti/sti_hqvdp.c:1292:5: warning: symbol 'sti_hqvdp_bind' was not declared. 
Should it be static?
drm/sti/sti_hqvdp.c:1385:24: warning: symbol 'sti_hqvdp_driver' was not 
declared. Should it be static?
drm/sti/sti_drv.c:143:6: warning: symbol 'sti_drm_dbg_cleanup' was not 
declared. Should it be static?

Cc: Benjamin Gaignard 
Cc: Vincent Abriou 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/sti/sti_compositor.c | 4 ++--
 drivers/gpu/drm/sti/sti_cursor.c | 2 +-
 drivers/gpu/drm/sti/sti_drv.c| 2 +-
 drivers/gpu/drm/sti/sti_dvo.c| 3 ++-
 drivers/gpu/drm/sti/sti_gdp.c| 6 +++---
 drivers/gpu/drm/sti/sti_hqvdp.c  | 7 ---
 drivers/gpu/drm/sti/sti_mixer.c  | 2 +-
 drivers/gpu/drm/sti/sti_tvout.c  | 1 +
 drivers/gpu/drm/sti/sti_vtac.c   | 2 ++
 drivers/gpu/drm/sti/sti_vtg.c| 3 ++-
 10 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_compositor.c 
b/drivers/gpu/drm/sti/sti_compositor.c
index 134201ecc6fd..a8441ae2623a 100644
--- a/drivers/gpu/drm/sti/sti_compositor.c
+++ b/drivers/gpu/drm/sti/sti_compositor.c
@@ -25,7 +25,7 @@
 /*
  * stiH407 compositor properties
  */
-struct sti_compositor_data stih407_compositor_data = {
+static const struct sti_compositor_data stih407_compositor_data = {
.nb_subdev = 8,
.subdev_desc = {
{STI_CURSOR_SUBDEV, (int)STI_CURSOR, 0x000},
@@ -46,7 +46,7 @@ struct sti_compositor_data stih407_compositor_data = {
  * Moreover, GDPx is different for Main and Aux Mixer. So this subdev map does
  * not fit for stiH416 if we want to enable the MIXER_AUX.
  */
-struct sti_compositor_data stih416_compositor_data = {
+static const struct sti_compositor_data stih416_compositor_data = {
.nb_subdev = 3,
.subdev_desc = {
{STI_GPD_SUBDEV, (int)STI_GDP_0, 0x100},
diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
index 3b53f7f2e3fc..651f231c4615 100644
--- a/drivers/gpu/drm/sti/sti_cursor.c
+++ b/drivers/gpu/drm/sti/sti_cursor.c
@@ -345,7 +345,7 @@ static int sti_cursor_late_register(struct drm_plane 
*drm_plane)
return cursor_debugfs_init(cursor, drm_plane->dev->primary);
 }

-struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
+static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = sti_cursor_destroy,
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 7cd3804c6dee..e6f0706bc6c7 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -140,7 +140,7 @@ err:
return ret;
 }

-void sti_drm_dbg_cleanup(struct drm_minor *minor)
+static void sti_drm_dbg_cleanup(struct drm_minor *minor)
 {
drm_debugfs_remove_files(sti_drm_dbg_list,
 ARRAY_SIZE(sti_drm_dbg_list), minor);
diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index 00881eb4536e..e8c1ed08a9f7 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -17,6 +17,7 @@
 #include 

 #include "sti_awg_utils.h"
+#include "sti_drv.h"
 #include "sti_mixer.h"

 /* DVO registers */
@@ -106,7 +107,7 @@ struct sti_dvo_connector {
container_of(x, struct sti_dvo_connector, drm_connector)

 #define BLANKING_LEVEL 16
-int dvo_awg_generate_code(struct sti_dvo *dvo

[PATCH 11/14] drm/rockchip: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/rockchip/rockchip_drm_drv.c:312:6: warning: symbol 
'rockchip_drm_fb_suspend' was not declared. Should it be static?
drm/rockchip/rockchip_drm_drv.c:321:6: warning: symbol 'rockchip_drm_fb_resume' 
was not declared. Should it be static?
drm/rockchip/rockchip_drm_fbdev.c:130:5: warning: symbol 
'rockchip_drm_fbdev_init' was not declared. Should it be static?
drm/rockchip/rockchip_drm_fbdev.c:173:6: warning: symbol 
'rockchip_drm_fbdev_fini' was not declared. Should it be static?

Cc: Mark Yao 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   | 4 ++--
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 76eaf1de52e4..38c3be5f2c67 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -309,7 +309,7 @@ static struct drm_driver rockchip_drm_driver = {
 };

 #ifdef CONFIG_PM_SLEEP
-void rockchip_drm_fb_suspend(struct drm_device *drm)
+static void rockchip_drm_fb_suspend(struct drm_device *drm)
 {
struct rockchip_drm_private *priv = drm->dev_private;

@@ -318,7 +318,7 @@ void rockchip_drm_fb_suspend(struct drm_device *drm)
console_unlock();
 }

-void rockchip_drm_fb_resume(struct drm_device *drm)
+static void rockchip_drm_fb_resume(struct drm_device *drm)
 {
struct rockchip_drm_private *priv = drm->dev_private;

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
index 207e01de6e32..a16c69f96ed5 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
@@ -20,6 +20,7 @@
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_gem.h"
 #include "rockchip_drm_fb.h"
+#include "rockchip_drm_fbdev.h"

 #define PREFERRED_BPP  32
 #define to_drm_private(x) \
-- 
2.7.4



[PATCH 10/14] drm/nouveau: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/nouveau/dispnv04/overlay.c:496:1: warning: symbol 'nouveau_overlay_init' 
was not declared. Should it be static?
drm/nouveau/nouveau_connector.c:63:5: warning: symbol 'nouveau_hdmimhz' was not 
declared. Should it be static?
drm/nouveau/nouveau_display.c:96:1: warning: symbol 
'nouveau_display_scanoutpos_head' was not declared. Should it be static?
drm/nouveau/nv10_fence.c:70:1: warning: symbol 'nv10_fence_context_new' was not 
declared. Should it be static?
drm/nouveau/nvif/client.c:58:26: warning: symbol 'nvif_drivers' was not 
declared. Should it be static?
drm/nouveau/nvkm/core/firmware.c:34:1: warning: symbol 'nvkm_firmware_get' was 
not declared. Should it be static?
drm/nouveau/nvkm/core/firmware.c:58:1: warning: symbol 'nvkm_firmware_put' was 
not declared. Should it be static?
drm/nouveau/nvkm/engine/device/user.c:330:1: warning: symbol 'nvkm_udevice_new' 
was not declared. Should it be static?
drm/nouveau/nvkm/engine/disp/channv50.c:157:1: warning: symbol 
'nv50_disp_chan_rd32' was not declared. Should it be static?
drm/nouveau/nvkm/engine/disp/channv50.c:167:1: warning: symbol 
'nv50_disp_chan_wr32' was not declared. Should it be static?
drm/nouveau/nvkm/engine/disp/channv50.c:177:1: warning: symbol 
'nv50_disp_chan_ntfy' was not declared. Should it be static?
drm/nouveau/nvkm/engine/disp/channv50.c:193:1: warning: symbol 
'nv50_disp_chan_map' was not declared. Should it be static?
drm/nouveau/nvkm/engine/disp/coreg94.c:30:1: warning: symbol 
'g94_disp_core_mthd_sor' was not declared. Should it be static?
drm/nouveau/nvkm/engine/disp/coregp104.c:63:1: warning: symbol 
'gp104_disp_core_func' was not declared. Should it be static?
drm/nouveau/nvkm/engine/disp/rootnv50.c:70:1: warning: symbol 
'nv50_disp_root_mthd_' was not declared. Should it be static?
drm/nouveau/nvkm/engine/disp/sorg94.c:49:1: warning: symbol 
'g94_sor_output_new' was not declared. Should it be static?
drm/nouveau/nvkm/engine/fifo/chang84.c:133:1: warning: symbol 
'g84_fifo_chan_engine_init' was not declared. Should it be static?
drm/nouveau/nvkm/engine/fifo/chang84.c:174:1: warning: symbol 
'g84_fifo_chan_object_ctor' was not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/ctxgf117.c:222:1: warning: symbol 
'gf117_grctx_generate_main' was not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/ctxgm107.c:937:1: warning: symbol 
'gm107_grctx_generate_tpcid' was not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/ctxnv50.c:255:1: warning: symbol 'nv50_grctx_fill' 
was not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/ctxnv50.c:265:1: warning: symbol 'nv50_grctx_init' 
was not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/gf100.c:1388:1: warning: symbol 'gf100_gr_init_fw' 
was not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/gf100.c:1705:1: warning: symbol 'gf100_gr_init_' was 
not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/gf117.c:106:1: warning: symbol 'gf117_gr_fecs_ucode' 
was not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/gf117.c:116:1: warning: symbol 
'gf117_gr_gpccs_ucode' was not declared. Should it be static?
drm/nouveau/nvkm/engine/gr/gm107.c:312:1: warning: symbol 'gm107_gr_init' was 
not declared. Should it be static?
drm/nouveau/nvkm/engine/pm/base.c:703:1: warning: symbol 'nvkm_perfsrc_new' was 
not declared. Should it be static?
drm/nouveau/nvkm/engine/pm/base.c:74:21: warning: symbol 'nvkm_perfsig_find' 
was not declared. Should it be static?
drm/nouveau/nvkm/engine/pm/gf100.c:106:1: warning: symbol 'gf100_pm_part' was 
not declared. Should it be static?
drm/nouveau/nvkm/subdev/bios/fan.c:29:1: warning: symbol 'nvbios_fan_table' was 
not declared. Should it be static?
drm/nouveau/nvkm/subdev/bios/fan.c:56:1: warning: symbol 'nvbios_fan_entry' was 
not declared. Should it be static?
drm/nouveau/nvkm/subdev/clk/gt215.c:184:1: warning: symbol 'gt215_clk_info' was 
not declared. Should it be static?
drm/nouveau/nvkm/subdev/fb/ramgt215.c:153:1: warning: symbol 'gt215_link_train' 
was not declared. Should it be static?
drm/nouveau/nvkm/subdev/fb/ramgt215.c:271:1: warning: symbol 
'gt215_link_train_init' was not declared. Should it be static?
drm/nouveau/nvkm/subdev/fb/ramgt215.c:337:1: warning: symbol 
'gt215_link_train_fini' was not declared. Should it be static?
drm/nouveau/nvkm/subdev/fb/ramgt215.c:99:1: warning: symbol 
'gt215_link_train_calc' was not declared. Should it be static?
drm/nouveau/nvkm/subdev/fb/sddr2.c:60:1: warning: symbol 'nvkm_sddr2_calc' was 
not declared. Should it be static?
drm/nouveau/nvkm/subdev/fb/sddr3.c:69:1: warning: symbol 'nvkm_sddr3_calc' was 
not declared. Should it be static?
drm/nouveau/nvkm/subdev/gpio/gk104.c:41:1: warning: symbol 
'gk104_gpio_intr_mask' was not declared. Should it be static?
drm/nouveau/nvkm/subdev/i2c/aux.c:78:1: warning: symbol 'nvkm_i2c_aux_i2c_algo' 
was not declared. Should it be static?
drm/nouveau/nvkm/subdev/iccsense/base.c:332:25: warn

[PATCH 09/14] drm/msm: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/msm/mdp/mdp4/mdp4_lcdc_encoder.c:96:22: warning: symbol 'get_connector' was 
not declared. Should it be static?
drm/msm/mdp/mdp4/mdp4_plane.c:84:5: warning: symbol 'mdp4_plane_set_property' 
was not declared. Should it be static?
drm/msm/mdp/mdp5/mdp5_cfg.c:25:26: warning: symbol 'msm8x74v1_config' was not 
declared. Should it be static?
drm/msm/mdp/mdp5/mdp5_cfg.c:95:26: warning: symbol 'msm8x74v2_config' was not 
declared. Should it be static?
drm/msm/mdp/mdp5/mdp5_cfg.c:165:26: warning: symbol 'apq8084_config' was not 
declared. Should it be static?
drm/msm/mdp/mdp5/mdp5_cfg.c:243:26: warning: symbol 'msm8x16_config' was not 
declared. Should it be static?
drm/msm/mdp/mdp5/mdp5_cfg.c:304:26: warning: symbol 'msm8x94_config' was not 
declared. Should it be static?
drm/msm/mdp/mdp5/mdp5_cfg.c:382:26: warning: symbol 'msm8x96_config' was not 
declared. Should it be static?

Cc: Rob Clark 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_lcdc_encoder.c |  2 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c|  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c  | 12 ++--
 drivers/gpu/drm/msm/msm_fb.c |  2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lcdc_encoder.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lcdc_encoder.c
index bc3d8e719c6c..a06b064f86c1 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lcdc_encoder.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lcdc_encoder.c
@@ -93,7 +93,7 @@ static const struct drm_encoder_funcs mdp4_lcdc_encoder_funcs 
= {
 };

 /* this should probably be a helper: */
-struct drm_connector *get_connector(struct drm_encoder *encoder)
+static struct drm_connector *get_connector(struct drm_encoder *encoder)
 {
struct drm_device *dev = encoder->dev;
struct drm_connector *connector;
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
index 7c9626d92019..3903dbcda763 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
@@ -81,7 +81,7 @@ static void mdp4_plane_install_properties(struct drm_plane 
*plane,
// XXX
 }

-int mdp4_plane_set_property(struct drm_plane *plane,
+static int mdp4_plane_set_property(struct drm_plane *plane,
struct drm_property *property, uint64_t val)
 {
// XXX
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
index ac9e4cde1380..94f9d1ad45b1 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
@@ -22,7 +22,7 @@ struct mdp5_cfg_handler {
 /* mdp5_cfg must be exposed (used in mdp5.xml.h) */
 const struct mdp5_cfg_hw *mdp5_cfg = NULL;

-const struct mdp5_cfg_hw msm8x74v1_config = {
+static const struct mdp5_cfg_hw msm8x74v1_config = {
.name = "msm8x74v1",
.mdp = {
.count = 1,
@@ -92,7 +92,7 @@ const struct mdp5_cfg_hw msm8x74v1_config = {
.max_clk = 2,
 };

-const struct mdp5_cfg_hw msm8x74v2_config = {
+static const struct mdp5_cfg_hw msm8x74v2_config = {
.name = "msm8x74",
.mdp = {
.count = 1,
@@ -162,7 +162,7 @@ const struct mdp5_cfg_hw msm8x74v2_config = {
.max_clk = 2,
 };

-const struct mdp5_cfg_hw apq8084_config = {
+static const struct mdp5_cfg_hw apq8084_config = {
.name = "apq8084",
.mdp = {
.count = 1,
@@ -240,7 +240,7 @@ const struct mdp5_cfg_hw apq8084_config = {
.max_clk = 32000,
 };

-const struct mdp5_cfg_hw msm8x16_config = {
+static const struct mdp5_cfg_hw msm8x16_config = {
.name = "msm8x16",
.mdp = {
.count = 1,
@@ -301,7 +301,7 @@ const struct mdp5_cfg_hw msm8x16_config = {
.max_clk = 32000,
 };

-const struct mdp5_cfg_hw msm8x94_config = {
+static const struct mdp5_cfg_hw msm8x94_config = {
.name = "msm8x94",
.mdp = {
.count = 1,
@@ -379,7 +379,7 @@ const struct mdp5_cfg_hw msm8x94_config = {
.max_clk = 4,
 };

-const struct mdp5_cfg_hw msm8x96_config = {
+static const struct mdp5_cfg_hw msm8x96_config = {
.name = "msm8x96",
.mdp = {
.count = 1,
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 95cf8fe72ee5..8c5b399f387e 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -132,7 +132,7 @@ const struct msm_format *msm_framebuffer_format(struct 
drm_framebuffer *fb)
 struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-   struct drm_gem_object *bos[4] = {0};
+   struct drm_gem_object *bos[4] = {};
struct drm_framebuffer *fb;
int ret, i, n = drm_format_num_planes(mode_cmd->pixel_format);

-- 
2.7.4



[PATCH 08/14] drm/mgag200: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/mgag200/mgag200_drv.c:24:5: warning: symbol 'mgag200_modeset' was not 
declared. Should it be static?
drm/mgag200/mgag200_ttm.c:227:22: warning: symbol 'mgag200_bo_driver' was not 
declared. Should it be static?

Cc: Dave Airlie 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 2 +-
 drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 1443b3a34775..9c02a22451d2 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -21,7 +21,7 @@
  * which then performs further device association and calls our graphics init
  * functions
  */
-int mgag200_modeset = -1;
+static int mgag200_modeset = -1;

 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, mgag200_modeset, int, 0400);
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c 
b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 68268e55d595..88604af23382 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -224,7 +224,7 @@ static void mgag200_ttm_tt_unpopulate(struct ttm_tt *ttm)
ttm_pool_unpopulate(ttm);
 }

-struct ttm_bo_driver mgag200_bo_driver = {
+static struct ttm_bo_driver mgag200_bo_driver = {
.ttm_tt_create = mgag200_ttm_tt_create,
.ttm_tt_populate = mgag200_ttm_tt_populate,
.ttm_tt_unpopulate = mgag200_ttm_tt_unpopulate,
-- 
2.7.4



[PATCH 07/14] drm/cirrus: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/cirrus/cirrus_drv.c:18:5: warning: symbol 'cirrus_modeset' was not 
declared. Should it be static?
drm/cirrus/cirrus_ttm.c:227:22: warning: symbol 'cirrus_bo_driver' was not 
declared. Should it be static?

Cc: Dave Airlie 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/cirrus/cirrus_drv.c | 2 +-
 drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 6c76d125995b..94928af5e7a4 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -15,7 +15,7 @@

 #include "cirrus_drv.h"

-int cirrus_modeset = -1;
+static int cirrus_modeset = -1;
 int cirrus_bpp = 24;

 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c 
b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 1cc9ee607128..13c2303e1d3e 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -224,7 +224,7 @@ static void cirrus_ttm_tt_unpopulate(struct ttm_tt *ttm)
ttm_pool_unpopulate(ttm);
 }

-struct ttm_bo_driver cirrus_bo_driver = {
+static struct ttm_bo_driver cirrus_bo_driver = {
.ttm_tt_create = cirrus_ttm_tt_create,
.ttm_tt_populate = cirrus_ttm_tt_populate,
.ttm_tt_unpopulate = cirrus_ttm_tt_unpopulate,
-- 
2.7.4



[PATCH 06/14] drm/bochs: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/bochs/bochs_mm.c:196:22: warning: symbol 'bochs_bo_driver' was not 
declared. Should it be static?
drm/bochs/bochs_kms.c:181:5: warning: symbol 'bochs_connector_get_modes' was 
not declared. Should it be static?

Cc: Gerd Hoffmann 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/bochs/bochs_kms.c | 2 +-
 drivers/gpu/drm/bochs/bochs_mm.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c 
b/drivers/gpu/drm/bochs/bochs_kms.c
index 207a2cbcc113..0b4e5d117043 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -178,7 +178,7 @@ static void bochs_encoder_init(struct drm_device *dev)
 }


-int bochs_connector_get_modes(struct drm_connector *connector)
+static int bochs_connector_get_modes(struct drm_connector *connector)
 {
int count;

diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index 5c5638a777a1..dafd764134e8 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -193,7 +193,7 @@ static struct ttm_tt *bochs_ttm_tt_create(struct 
ttm_bo_device *bdev,
return tt;
 }

-struct ttm_bo_driver bochs_bo_driver = {
+static struct ttm_bo_driver bochs_bo_driver = {
.ttm_tt_create = bochs_ttm_tt_create,
.ttm_tt_populate = ttm_pool_populate,
.ttm_tt_unpopulate = ttm_pool_unpopulate,
-- 
2.7.4



[PATCH 05/14] drm/ast: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/ast/ast_drv.c:36:5: warning: symbol 'ast_modeset' was not declared. Should 
it be static?
drm/ast/ast_ttm.c:227:22: warning: symbol 'ast_bo_driver' was not declared. 
Should it be static?

Cc: Dave Airlie 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/ast/ast_drv.c | 2 +-
 drivers/gpu/drm/ast/ast_ttm.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index f54afd2113a9..3d16d9f1f3ec 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -33,7 +33,7 @@

 #include "ast_drv.h"

-int ast_modeset = -1;
+static int ast_modeset = -1;

 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, ast_modeset, int, 0400);
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index b29a41218fc9..899ee7711f15 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -224,7 +224,7 @@ static void ast_ttm_tt_unpopulate(struct ttm_tt *ttm)
ttm_pool_unpopulate(ttm);
 }

-struct ttm_bo_driver ast_bo_driver = {
+static struct ttm_bo_driver ast_bo_driver = {
.ttm_tt_create = ast_ttm_tt_create,
.ttm_tt_populate = ast_ttm_tt_populate,
.ttm_tt_unpopulate = ast_ttm_tt_unpopulate,
-- 
2.7.4



[PATCH 04/14] drm/arm: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/arm/malidp_planes.c:49:24: warning: symbol 'malidp_duplicate_plane_state' 
was not declared. Should it be static?
drm/arm/malidp_planes.c:66:6: warning: symbol 'malidp_destroy_plane_state' was 
not declared. Should it be static?

Cc: Liviu Dudau 
Cc: Brian Starkey 
Cc: Mali DP Maintainers 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/arm/malidp_planes.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
b/drivers/gpu/drm/arm/malidp_planes.c
index 82c193e5e0d6..cc9b8e02904d 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -46,7 +46,7 @@ static void malidp_de_plane_destroy(struct drm_plane *plane)
devm_kfree(plane->dev->dev, mp);
 }

-struct drm_plane_state *malidp_duplicate_plane_state(struct drm_plane *plane)
+static struct drm_plane_state *malidp_duplicate_plane_state(struct drm_plane 
*plane)
 {
struct malidp_plane_state *state, *m_state;

@@ -63,8 +63,8 @@ struct drm_plane_state *malidp_duplicate_plane_state(struct 
drm_plane *plane)
return &state->base;
 }

-void malidp_destroy_plane_state(struct drm_plane *plane,
-   struct drm_plane_state *state)
+static void malidp_destroy_plane_state(struct drm_plane *plane,
+  struct drm_plane_state *state)
 {
struct malidp_plane_state *m_state = to_malidp_plane_state(state);

-- 
2.7.4



[PATCH 03/14] drm/fb-helper: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/drm_fb_helper.c:2306:12: warning: symbol 'drm_fb_helper_modinit' was not 
declared. Should it be static?

While at it, move the lefover static inline to the right place.

Cc: Daniel Vetter 
Cc: Sean Paul 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_crtc_helper_internal.h | 7 +++
 drivers/gpu/drm/drm_fb_helper.c| 2 ++
 include/drm/drm_fb_helper.h| 5 -
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_helper_internal.h 
b/drivers/gpu/drm/drm_crtc_helper_internal.h
index 4e6b57ae7188..28295e5d0d9e 100644
--- a/drivers/gpu/drm/drm_crtc_helper_internal.h
+++ b/drivers/gpu/drm/drm_crtc_helper_internal.h
@@ -29,7 +29,14 @@
 #include 

 /* drm_fb_helper.c */
+#ifdef CONFIG_DRM_FBDEV_EMULATION
 int drm_fb_helper_modinit(void);
+#else
+static inline int drm_fb_helper_modinit(void)
+{
+   return 0;
+}
+#endif

 /* drm_dp_aux_dev.c */
 #ifdef CONFIG_DRM_DP_AUX_CHARDEV
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index dd8e3b68fd53..03414bde1f15 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -41,6 +41,8 @@
 #include 
 #include 

+#include "drm_crtc_helper_internal.h"
+
 static bool drm_fbdev_emulation = true;
 module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
 MODULE_PARM_DESC(fbdev_emulation,
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 797fb5f80c45..e19458dd1a43 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -287,11 +287,6 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper 
*fb_helper, struct drm_
 int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
   struct drm_connector *connector);
 #else
-static inline int drm_fb_helper_modinit(void)
-{
-   return 0;
-}
-
 static inline void drm_fb_helper_prepare(struct drm_device *dev,
struct drm_fb_helper *helper,
const struct drm_fb_helper_funcs *funcs)
-- 
2.7.4



[PATCH 02/14] drm/blend: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/drm_blend.c:207:5: warning: symbol 'drm_atomic_normalize_zpos' was not 
declared. Should it be static?

Cc: Marek Szyprowski 
Cc: Benjamin Gaignard 
Cc: Laurent Pinchart 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_blend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
index 0813b7e021be..0a0b9357db35 100644
--- a/drivers/gpu/drm/drm_blend.c
+++ b/drivers/gpu/drm/drm_blend.c
@@ -30,7 +30,7 @@
 #include 
 #include 

-#include "drm_internal.h"
+#include "drm_crtc_internal.h"

 /**
  * drm_plane_create_zpos_property - create mutable zpos property
-- 
2.7.4



[PATCH 01/14] drm/atomic-helper: Fix sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm/drm_atomic_helper.c:1696:6: warning: symbol 'plane_crtc_active' was not 
declared. Should it be static?

Cc: Daniel Vetter 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_atomic_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index ea78d70de9f3..c3f83476f996 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1693,7 +1693,7 @@ fail:
 }
 EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);

-bool plane_crtc_active(struct drm_plane_state *state)
+static bool plane_crtc_active(const struct drm_plane_state *state)
 {
return state->crtc && state->crtc->state->active;
 }
-- 
2.7.4



[PATCH 00/14] drm: Fix a bunch of sparse warnings

2016-09-19 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

I got a bit fed up from the sparse noise during a full build,
so I tried to shut some of it up. Mostly missing statics or function
declarations.

I didn't touch the main offender (radeon/amdgpu) since there was enough
of this stuff in the other drivers as well. Nouveau was pretty bad too,
but it was spread around mode so I didn't realize how much there was
until I was already half way through. If I had, I probably wouldn't
have bothered. There's still a bunch of warnings left in many of the
drivers (__mmio type of stuff is probably responsible for most of it).

Entire series avaialable here:
git://github.com/vsyrjala/linux.git drm_sparse_warn

Ville Syrjälä (14):
  drm/atomic-helper: Fix sparse warnings
  drm/blend: Fix sparse warnings
  drm/fb-helper: Fix sparse warnings
  drm/arm: Fix sparse warnings
  drm/ast: Fix sparse warnings
  drm/bochs: Fix sparse warnings
  drm/cirrus: Fix sparse warnings
  drm/mgag200: Fix sparse warnings
  drm/msm: Fix sparse warnings
  drm/nouveau: Fix sparse warnings
  drm/rockchip: Fix sparse warnings
  drm/sti: Fix sparse warnings
  drm/sun4i: Fix sparse warnings
  drm/tilcdc: Fix sparse warnings

 drivers/gpu/drm/arm/malidp_planes.c|  6 ++--
 drivers/gpu/drm/ast/ast_drv.c  |  2 +-
 drivers/gpu/drm/ast/ast_ttm.c  |  2 +-
 drivers/gpu/drm/bochs/bochs_kms.c  |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c   |  2 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c|  2 +-
 drivers/gpu/drm/cirrus/cirrus_ttm.c|  2 +-
 drivers/gpu/drm/drm_atomic_helper.c|  2 +-
 drivers/gpu/drm/drm_blend.c|  2 +-
 drivers/gpu/drm/drm_crtc_helper_internal.h |  7 
 drivers/gpu/drm/drm_fb_helper.c|  2 ++
 drivers/gpu/drm/mgag200/mgag200_drv.c  |  2 +-
 drivers/gpu/drm/mgag200/mgag200_ttm.c  |  2 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_lcdc_encoder.c   |  2 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c  |  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c| 12 +++
 drivers/gpu/drm/msm/msm_fb.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/overlay.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_connector.c|  2 +-
 drivers/gpu/drm/nouveau/nouveau_display.c  |  2 +-
 drivers/gpu/drm/nouveau/nv10_fence.c   |  2 +-
 drivers/gpu/drm/nouveau/nvif/client.c  |  2 +-
 drivers/gpu/drm/nouveau/nvkm/core/firmware.c   |  1 +
 drivers/gpu/drm/nouveau/nvkm/engine/device/user.c  |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/channv50.c|  8 ++---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/coreg94.c |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/coregp104.c   |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c|  2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/sorg94.c  |  2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/chang84.c |  4 +--
 drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf117.c  |  2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm107.c  |  2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxnv50.c   |  1 +
 drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c |  4 +--
 drivers/gpu/drm/nouveau/nvkm/engine/gr/gf117.c |  4 +--
 drivers/gpu/drm/nouveau/nvkm/engine/gr/gm107.c |  2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c  |  4 +--
 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.c |  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/fan.c |  4 +--
 drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c|  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c  |  8 ++---
 drivers/gpu/drm/nouveau/nvkm/subdev/fb/sddr2.c |  1 +
 drivers/gpu/drm/nouveau/nvkm/subdev/fb/sddr3.c |  1 +
 drivers/gpu/drm/nouveau/nvkm/subdev/gpio/gk104.c   |  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c  |  2 +-
 .../gpu/drm/nouveau/nvkm/subdev/iccsense/base.c|  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c |  4 +--
 drivers/gpu/drm/nouveau/nvkm/subdev/mc/g84.c   |  2 +-
 .../gpu/drm/nouveau/nvkm/subdev/secboot/gm200.c|  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk104.c   |  4 +--
 drivers/gpu/drm/nouveau/nvkm/subdev/volt/gm20b.c   |  4 +--
 drivers/gpu/drm/nouveau/nvkm/subdev/volt/gpio.c|  1 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c|  4 +--
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c  |  1 +
 drivers/gpu/drm/sti/sti_compositor.c   |  4 +--
 drivers/gpu/drm/sti/sti_cursor.c   |  2 +-
 drivers/gpu/drm/sti/sti_drv.c  |  2 +-
 drivers/gpu/drm/sti/sti_dvo.c  |  3 +-
 drivers/gpu/drm/sti/sti_gdp.c  |  6 ++--
 drivers/gpu/drm/sti/sti_hqvdp.c|  7 ++--
 drivers/gpu/drm/sti/sti_mixer.c|  2 +-
 drivers/gpu/drm/sti/sti_tvout.c|  1 +
 drivers/gpu/drm/sti/sti_vtac.c |  2 ++
 drivers/gpu/drm/sti/st

[PATCH 03/10] drm: Move all decl for drm_edid.c to drm_edid.h

2016-09-19 Thread Daniel Vetter
On Tue, Sep 06, 2016 at 12:59:39PM -0400, Sean Paul wrote:
> On Wed, Aug 31, 2016 at 12:09 PM, Daniel Vetter  
> wrote:
> > Some were still left in drm_crtc.h. Also include drm_edid.h in the
> > rst files.
> >
> > Signed-off-by: Daniel Vetter 
> 
> Reviewed-by: Sean Paul 

Merged up to this patch, thanks for the review.
-Daniel

> 
> > ---
> >  Documentation/gpu/drm-kms-helpers.rst |  3 +++
> >  include/drm/drm_crtc.h| 30 +-
> >  include/drm/drm_edid.h| 30 ++
> >  3 files changed, 34 insertions(+), 29 deletions(-)
> >
> > diff --git a/Documentation/gpu/drm-kms-helpers.rst 
> > b/Documentation/gpu/drm-kms-helpers.rst
> > index 48fc5a96bf95..bb4254d19cbb 100644
> > --- a/Documentation/gpu/drm-kms-helpers.rst
> > +++ b/Documentation/gpu/drm-kms-helpers.rst
> > @@ -208,6 +208,9 @@ Output Probing Helper Functions Reference
> >  EDID Helper Functions Reference
> >  ===
> >
> > +.. kernel-doc:: include/drm/drm_edid.h
> > +   :internal:
> > +
> >  .. kernel-doc:: drivers/gpu/drm/drm_edid.c
> > :export:
> >
> > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> > index bf9ee1b97c26..7bb3aa87a8be 100644
> > --- a/include/drm/drm_crtc.h
> > +++ b/include/drm/drm_crtc.h
> > @@ -43,6 +43,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  struct drm_device;
> >  struct drm_mode_set;
> > @@ -1992,33 +1993,4 @@ assert_drm_connector_list_read_locked(struct 
> > drm_mode_config *mode_config)
> > !drm_modeset_is_locked(&mode_config->connection_mutex));
> >  }
> >
> > -/* drm_edid.c */
> > -bool drm_probe_ddc(struct i2c_adapter *adapter);
> > -struct edid *drm_get_edid(struct drm_connector *connector,
> > - struct i2c_adapter *adapter);
> > -struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
> > -struct i2c_adapter *adapter);
> > -struct edid *drm_edid_duplicate(const struct edid *edid);
> > -int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
> > -
> > -u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
> > -enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
> > -bool drm_detect_hdmi_monitor(struct edid *edid);
> > -bool drm_detect_monitor_audio(struct edid *edid);
> > -bool drm_rgb_quant_range_selectable(struct edid *edid);
> > -int drm_add_modes_noedid(struct drm_connector *connector,
> > -int hdisplay, int vdisplay);
> > -void drm_set_preferred_mode(struct drm_connector *connector,
> > -   int hpref, int vpref);
> > -
> > -int drm_edid_header_is_valid(const u8 *raw_edid);
> > -bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
> > - bool *edid_corrupt);
> > -bool drm_edid_is_valid(struct edid *edid);
> > -void drm_edid_get_monitor_name(struct edid *edid, char *name,
> > -  int buflen);
> > -struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
> > -  int hsize, int vsize, int fresh,
> > -  bool rb);
> > -
> >  #endif /* __DRM_CRTC_H__ */
> > diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
> > index 919933d1beb4..c3a7d440bc11 100644
> > --- a/include/drm/drm_edid.h
> > +++ b/include/drm/drm_edid.h
> > @@ -25,6 +25,9 @@
> >
> >  #include 
> >
> > +struct drm_device;
> > +struct i2c_adapter;
> > +
> >  #define EDID_LENGTH 128
> >  #define DDC_ADDR 0x50
> >  #define DDC_ADDR2 0x52 /* E-DDC 1.2 - where DisplayID can hide */
> > @@ -423,9 +426,36 @@ static inline u8 drm_eld_get_conn_type(const uint8_t 
> > *eld)
> > return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK;
> >  }
> >
> > +bool drm_probe_ddc(struct i2c_adapter *adapter);
> >  struct edid *drm_do_get_edid(struct drm_connector *connector,
> > int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
> >   size_t len),
> > void *data);
> > +struct edid *drm_get_edid(struct drm_connector *connector,
> > + struct i2c_adapter *adapter);
> > +struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
> > +struct i2c_adapter *adapter);
> > +struct edid *drm_edid_duplicate(const struct edid *edid);
> > +int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
> > +
> > +u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
> > +enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
> > +bool drm_detect_hdmi_monitor(struct edid *edid);
> > +bool drm_detect_monitor_audio(struct edid *edid);
> > +bool drm_rgb_quant_range_selectable(struct edid *edid);
> > +int drm_add_modes_noedid(struct drm_connector *connector,
> > +int hdisplay, int vdisplay);

[PATCH] drm: include linux/seq_file.h as needed

2016-09-19 Thread Jani Nikula
On Mon, 19 Sep 2016, Arnd Bergmann  wrote:
> The addition of the debugfs info created references to seq_puts() and
> seq_printf(), but relied on the debugfs header to be included implicitly,
> which apparently doesn't happen all the time, as seen from this randconfig
> build output:
>
> drivers/gpu/drm/drm_dp_helper.c: In function 'drm_dp_downstream_debug':
> drivers/gpu/drm/drm_dp_helper.c:552:2: error: implicit declaration of 
> function 'seq_printf' [-Werror=implicit-function-declaration]
> drivers/gpu/drm/drm_dp_helper.c:560:3: error: implicit declaration of 
> function 'seq_puts' [-Werror=implicit-function-declaration]
>
> Adding the extra include brings back a clean build.

Beat you to it, but no review/acks...

http://patchwork.freedesktop.org/patch/msgid/1474020396-14875-1-git-send-email-jani.nikula
 at intel.com

BR,
Jani.


>
> Fixes: 80209e5f2c42 ("drm: Add DP branch device info on debugfs")
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index a07adf0a07db..3e6fe82c6d64 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 

-- 
Jani Nikula, Intel Open Source Technology Center


[RFC 2/2] drm/exynos: mixer: configure layers once in mixer_atomic_flush()

2016-09-19 Thread Tobias Jakobi
Only manipulate the MXR_CFG and MXR_LAYER_CFG registers once
in mixer_cfg_layer().
Trigger this via atomic flush.

Signed-off-by: Tobias Jakobi 
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 104 ++
 drivers/gpu/drm/exynos/regs-mixer.h   |   2 +
 2 files changed, 69 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 1e78d57..d4efd9c 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -99,6 +99,7 @@ struct mixer_context {
struct drm_device   *drm_dev;
struct exynos_drm_crtc  *crtc;
struct exynos_drm_plane planes[MIXER_WIN_NR];
+   unsigned long   state_cache;
int pipe;
unsigned long   flags;

@@ -418,37 +419,68 @@ static void mixer_cfg_rgb_fmt(struct mixer_context *ctx, 
unsigned int height)
mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_RGB_FMT_MASK);
 }

-static void mixer_cfg_layer(struct mixer_context *ctx, unsigned int win,
-   unsigned int priority, bool enable)
+static void mixer_cfg_layer(struct mixer_context *ctx)
 {
struct mixer_resources *res = &ctx->mixer_res;
-   u32 val = enable ? ~0 : 0;
-
-   switch (win) {
-   case 0:
-   mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_GRP0_ENABLE);
-   mixer_reg_writemask(res, MXR_LAYER_CFG,
-   MXR_LAYER_CFG_GRP0_VAL(priority),
-   MXR_LAYER_CFG_GRP0_MASK);
-   break;
-   case 1:
-   mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_GRP1_ENABLE);
-   mixer_reg_writemask(res, MXR_LAYER_CFG,
-   MXR_LAYER_CFG_GRP1_VAL(priority),
-   MXR_LAYER_CFG_GRP1_MASK);
+   unsigned int win;

-   break;
-   case VP_DEFAULT_WIN:
-   if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
-   vp_reg_writemask(res, VP_ENABLE, val, VP_ENABLE_ON);
-   mixer_reg_writemask(res, MXR_CFG, val,
-   MXR_CFG_VP_ENABLE);
-   mixer_reg_writemask(res, MXR_LAYER_CFG,
-   MXR_LAYER_CFG_VP_VAL(priority),
-   MXR_LAYER_CFG_VP_MASK);
+   struct exynos_drm_plane_state *state;
+   struct drm_framebuffer *fb;
+   unsigned int priority;
+   u32 mxr_cfg = 0, mxr_layer_cfg = 0, vp_enable = 0;
+   bool enable;
+
+   for (win = 0; win < MIXER_WIN_NR; ++win) {
+   state = to_exynos_plane_state(ctx->planes[win].base.state);
+   fb = state->fb;
+
+   priority = state->base.normalized_zpos + 1;
+   enable = test_bit(win, &ctx->state_cache);
+
+   if (!enable)
+   continue;
+
+   switch (win) {
+   case 0:
+   mxr_cfg |=  MXR_CFG_GRP0_ENABLE;
+   mxr_layer_cfg |= MXR_LAYER_CFG_GRP0_VAL(priority);
+   break;
+
+   case 1:
+   mxr_cfg |=  MXR_CFG_GRP1_ENABLE;
+   mxr_layer_cfg |= MXR_LAYER_CFG_GRP1_VAL(priority);
+   break;
+
+   case VP_DEFAULT_WIN:
+   vp_enable = VP_ENABLE_ON;
+   mxr_cfg |=  MXR_CFG_VP_ENABLE;
+   mxr_layer_cfg |= MXR_LAYER_CFG_VP_VAL(priority);
+   break;
+   }
+
+   if (!fb)
+   continue;
+
+   /*
+* TODO: Don't enable alpha blending for the bottom window.
+*/
+   switch (win) {
+   case 0:
+   case 1:
+   mixer_cfg_gfx_blend(ctx, win, 
is_alpha_format(fb->pixel_format));
+   break;
+
+   case VP_DEFAULT_WIN:
+   mixer_cfg_vp_blend(ctx);
+   break;
}
-   break;
}
+
+   if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags))
+   vp_reg_writemask(res, VP_ENABLE, vp_enable, VP_ENABLE_ON);
+
+   mixer_reg_writemask(res, MXR_CFG, mxr_cfg, MXR_CFG_ENABLE_MASK);
+   mixer_reg_writemask(res, MXR_LAYER_CFG, mxr_layer_cfg, 
MXR_LAYER_CFG_MASK);
 }

 static void mixer_run(struct mixer_context *ctx)
@@ -478,7 +510,6 @@ static void vp_video_buffer(struct mixer_context *ctx,
struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode;
struct mixer_resources *res = &ctx->mixer_res;
struct drm_framebuffer *fb = state->fb;
-   unsigned int priority = state->base.normalized_zpos + 1;
unsigned long flags;
dma_addr_t luma_addr[2], chroma_addr[2];
bool tiled_mode = false;

[PATCH 0/3] ARM: dts: am335x-* Add blue-and-red-wiring propery to lcdc nodes

2016-09-19 Thread Tony Lindgren
* Jyri Sarha  [160919 00:31]:
> On 09/16/16 18:02, Tony Lindgren wrote:
> > * Jyri Sarha  [160916 04:50]:
> >> > These patches complete the am335x LCDC color errata fix[1]. The
> >> > functional patches are now queued for v4.9.
> >> > 
> >> > The patch for am335x-boneblack.dts is delayed until v4.10 or v4.9-rc
> >> > phase to avoid conflickt with BBB HDMI audio DTS patch that slipped
> >> > into tda998x pull request.
> >> > 
> >> > [1] http://www.spinics.net/lists/devicetree/msg141246.html
> > OK. Are these safe to merge even if the dts changes get merged before
> > the driver changes? Or does it break something if merged out of order?
> 
> Yes, they are safe. The new property just simply is not interpreted and
> everything works as before.

OK applying into omap-for-v4.9/dt-v2 thanks.

Tony


[RFC PATCH v3 1/2] ARM: dts: samsung: add rga-lvds panel in itop elite

2016-09-19 Thread Fabio Estevam
On Mon, Sep 19, 2016 at 4:02 PM, Randy Li  wrote:

> +   vcc_sys_lcd: sys-lcd {
> +   compatible = "regulator-fixed";
> +   regulator-name = "vcc_5v";
> +   regulator-min-microvolt = <500>;
> +   regulator-max-microvolt = <500>;
> +   gpio = <&gpl0 4 GPIO_ACTIVE_HIGH>;

Is this really active high? If so, you should add the
'enable-active-high' property.


[RFC 1/2] drm/exynos: mixer: convert booleans to flags in mixer context

2016-09-19 Thread Tobias Jakobi
The mixer context struct already has a 'flags' field, so
we can use it to store the 'interlace', 'vp_enabled' and
'has_sclk' booleans.
We use the non-atomic helper functions to access these bits.

Signed-off-by: Tobias Jakobi 
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 54 +++
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 9a48aa1..1e78d57 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -73,6 +73,9 @@ enum mixer_version_id {
 enum mixer_flag_bits {
MXR_BIT_POWERED,
MXR_BIT_VSYNC,
+   MXR_BIT_INTERLACE,
+   MXR_BIT_VP_ENABLED,
+   MXR_BIT_HAS_SCLK,
 };

 static const uint32_t mixer_formats[] = {
@@ -98,9 +101,6 @@ struct mixer_context {
struct exynos_drm_plane planes[MIXER_WIN_NR];
int pipe;
unsigned long   flags;
-   boolinterlace;
-   boolvp_enabled;
-   boolhas_sclk;

struct mixer_resources  mixer_res;
enum mixer_version_id   mxr_ver;
@@ -346,7 +346,7 @@ static void mixer_vsync_set_update(struct mixer_context 
*ctx, bool enable)
mixer_reg_writemask(res, MXR_STATUS, enable ?
MXR_STATUS_SYNC_ENABLE : 0, MXR_STATUS_SYNC_ENABLE);

-   if (ctx->vp_enabled)
+   if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags))
vp_reg_write(res, VP_SHADOW_UPDATE, enable ?
VP_SHADOW_UPDATE_ENABLE : 0);
 }
@@ -357,8 +357,8 @@ static void mixer_cfg_scan(struct mixer_context *ctx, 
unsigned int height)
u32 val;

/* choosing between interlace and progressive mode */
-   val = (ctx->interlace ? MXR_CFG_SCAN_INTERLACE :
-   MXR_CFG_SCAN_PROGRESSIVE);
+   val = test_bit(MXR_BIT_INTERLACE, &ctx->flags) ?
+   MXR_CFG_SCAN_INTERLACE : MXR_CFG_SCAN_PROGRESSIVE;

if (ctx->mxr_ver != MXR_VER_128_0_0_184) {
/* choosing between proper HD and SD mode */
@@ -436,9 +436,10 @@ static void mixer_cfg_layer(struct mixer_context *ctx, 
unsigned int win,
mixer_reg_writemask(res, MXR_LAYER_CFG,
MXR_LAYER_CFG_GRP1_VAL(priority),
MXR_LAYER_CFG_GRP1_MASK);
+
break;
case VP_DEFAULT_WIN:
-   if (ctx->vp_enabled) {
+   if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
vp_reg_writemask(res, VP_ENABLE, val, VP_ENABLE_ON);
mixer_reg_writemask(res, MXR_CFG, val,
MXR_CFG_VP_ENABLE);
@@ -501,7 +502,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
chroma_addr[0] = exynos_drm_fb_dma_addr(fb, 1);

if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
-   ctx->interlace = true;
+   __set_bit(MXR_BIT_INTERLACE, &ctx->flags);
if (tiled_mode) {
luma_addr[1] = luma_addr[0] + 0x40;
chroma_addr[1] = chroma_addr[0] + 0x40;
@@ -510,7 +511,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
chroma_addr[1] = chroma_addr[0] + fb->pitches[0];
}
} else {
-   ctx->interlace = false;
+   __clear_bit(MXR_BIT_INTERLACE, &ctx->flags);
luma_addr[1] = 0;
chroma_addr[1] = 0;
}
@@ -518,7 +519,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
spin_lock_irqsave(&res->reg_slock, flags);

/* interlace or progressive scan mode */
-   val = (ctx->interlace ? ~0 : 0);
+   val = (test_bit(MXR_BIT_INTERLACE, &ctx->flags) ? ~0 : 0);
vp_reg_writemask(res, VP_MODE, val, VP_MODE_LINE_SKIP);

/* setup format */
@@ -541,7 +542,7 @@ static void vp_video_buffer(struct mixer_context *ctx,

vp_reg_write(res, VP_DST_WIDTH, state->crtc.w);
vp_reg_write(res, VP_DST_H_POSITION, state->crtc.x);
-   if (ctx->interlace) {
+   if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) {
vp_reg_write(res, VP_DST_HEIGHT, state->crtc.h / 2);
vp_reg_write(res, VP_DST_V_POSITION, state->crtc.y / 2);
} else {
@@ -636,9 +637,9 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
src_y_offset = 0;

if (mode->flags & DRM_MODE_FLAG_INTERLACE)
-   ctx->interlace = true;
+   __set_bit(MXR_BIT_INTERLACE, &ctx->flags);
else
-   ctx->interlace = false;
+   __clear_bit(MXR_BIT_INTERLACE, &ctx->flags);

spin_lock_irqsave(&res->reg_slock, flags);

@@ -733,7 +734,7 @@ static void mixer_win_reset(struct mixer_context *ctx)
mixer_reg_write(res, MXR_BG_COLOR1, 0x008080);
mixer_reg_write(res, MXR_

[RFC 0/2] drm/exynos: mixer: small optimisations

2016-09-19 Thread Tobias Jakobi
Hello,

I had these two patches in my private tree for some time. Might as well ask if 
there is any interested in merging these.

The first is just some unification on how booleans are used in the mixer code. 
The second one reduces register manipulation by moving stuff to the atomic 
flush call. I think one could even move more code there, like e.g. 
mixer_cfg_scan() and mixer_cfg_rgb_fmt().

Anyway, feedback is appreciated a lot!

With best wishes,
Tobias

Tobias Jakobi (2):
  drm/exynos: mixer: convert booleans to flags in mixer context
  drm/exynos: mixer: configure layers once in mixer_atomic_flush()

 drivers/gpu/drm/exynos/exynos_mixer.c | 156 +-
 drivers/gpu/drm/exynos/regs-mixer.h   |   2 +
 2 files changed, 97 insertions(+), 61 deletions(-)

-- 
2.7.3



[PATCH] drm/amd/powerplay/smumgr: mark symbols static where possible

2016-09-19 Thread Huang Rui
Hi Baoyou,

On Mon, Sep 19, 2016 at 03:28:39PM +0800, Baoyou Xie wrote:
> We get a few warnings when building kernel with W=1:
> drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/tonga_smumgr.c:146:5: warning: 
> no previous prototype for 'tonga_program_jump_on_start' [-Wmissing-prototypes]
> drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/fiji_smumgr.c:816:5: warning: 
> no previous prototype for 'fiji_save_vft_table' [-Wmissing-prototypes]
> drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/polaris10_smumgr.c:743:5: 
> warning: no previous prototype for 'polaris10_avfs_event_mgr' 
> [-Wmissing-prototypes]
> drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/iceland_smumgr.c:167:5: 
> warning: no previous prototype for 'iceland_program_jump_on_start' 
> [-Wmissing-prototypes]
> 
> 
> In fact, these functions are only used in the file in which they are
> declared and don't need a declaration, but can be made static.
> So this patch marks these functions with 'static'.
> 

+ amd-gfx mail list.

Thanks to your patch. But powerplay part is refactored recently below, some
functions are already updated. So you might need rebase them. :-)

https://lists.freedesktop.org/archives/amd-gfx/2016-September/002118.html

Thanks,
Rui


[PATCH] drm/amd/powerplay/hwmgr: mark symbols static where possible

2016-09-19 Thread Baoyou Xie
We get a few warnings when building kernel with W=1:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/cz_hwmgr.c:69:10: warning: no 
previous prototype for 'cz_get_eclk_level' [-Wmissing-prototypes]
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/tonga_hwmgr.c:117:27: warning: no 
previous prototype for 'cast_phw_tonga_power_state' [-Wmissing-prototypes]
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/tonga_thermal.c:363:5: warning: 
no previous prototype for 'tf_tonga_thermal_setup_fan_table' 
[-Wmissing-prototypes]
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/iceland_hwmgr.c:139:5: warning: 
no previous prototype for 'iceland_get_memory_type' [-Wmissing-prototypes]
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/iceland_thermal.c:363:5: warning: 
no previous prototype for 'tf_iceland_thermal_setup_fan_table' 
[-Wmissing-prototypes]


In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
So this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c |   8 +-
 .../gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c|  92 +++--
 .../gpu/drm/amd/powerplay/hwmgr/iceland_thermal.c  |   9 +-
 .../amd/powerplay/hwmgr/tonga_clockpowergating.c   |   4 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c  | 148 +++--
 .../amd/powerplay/hwmgr/tonga_processpptables.c|   2 +-
 .../gpu/drm/amd/powerplay/hwmgr/tonga_thermal.c|   8 +-
 7 files changed, 147 insertions(+), 124 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
index 5ecef17..5afb034 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
@@ -66,7 +66,7 @@ static const struct cz_power_state 
*cast_const_PhwCzPowerState(
return (struct cz_power_state *)hw_ps;
 }

-uint32_t cz_get_eclk_level(struct pp_hwmgr *hwmgr,
+static uint32_t cz_get_eclk_level(struct pp_hwmgr *hwmgr,
uint32_t clock, uint32_t msg)
 {
int i = 0;
@@ -1225,7 +1225,7 @@ static int cz_hwmgr_backend_fini(struct pp_hwmgr *hwmgr)
return 0;
 }

-int cz_phm_force_dpm_highest(struct pp_hwmgr *hwmgr)
+static int cz_phm_force_dpm_highest(struct pp_hwmgr *hwmgr)
 {
struct cz_hwmgr *cz_hwmgr = (struct cz_hwmgr *)(hwmgr->backend);

@@ -1239,7 +1239,7 @@ int cz_phm_force_dpm_highest(struct pp_hwmgr *hwmgr)
return 0;
 }

-int cz_phm_unforce_dpm_levels(struct pp_hwmgr *hwmgr)
+static int cz_phm_unforce_dpm_levels(struct pp_hwmgr *hwmgr)
 {
struct cz_hwmgr *cz_hwmgr = (struct cz_hwmgr *)(hwmgr->backend);
struct phm_clock_voltage_dependency_table *table =
@@ -1277,7 +1277,7 @@ int cz_phm_unforce_dpm_levels(struct pp_hwmgr *hwmgr)
return 0;
 }

-int cz_phm_force_dpm_lowest(struct pp_hwmgr *hwmgr)
+static int cz_phm_force_dpm_lowest(struct pp_hwmgr *hwmgr)
 {
struct cz_hwmgr *cz_hwmgr = (struct cz_hwmgr *)(hwmgr->backend);

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c
index 8a7ada5..547fb36 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c
@@ -136,7 +136,7 @@ static int iceland_read_clock_registers(struct pp_hwmgr 
*hwmgr)
  * @paramhwmgr  the address of the powerplay hardware manager.
  * @return   always 0
  */
-int iceland_get_memory_type(struct pp_hwmgr *hwmgr)
+static int iceland_get_memory_type(struct pp_hwmgr *hwmgr)
 {
iceland_hwmgr *data = (iceland_hwmgr *)(hwmgr->backend);
uint32_t temp;
@@ -162,7 +162,7 @@ int iceland_update_uvd_dpm(struct pp_hwmgr *hwmgr, bool 
bgate)
  * @paramhwmgr  the address of the powerplay hardware manager.
  * @return   always 0
  */
-int iceland_enable_acpi_power_management(struct pp_hwmgr *hwmgr)
+static int iceland_enable_acpi_power_management(struct pp_hwmgr *hwmgr)
 {
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, 
GENERAL_PWRMGT, STATIC_PM_EN, 1);

@@ -175,7 +175,7 @@ int iceland_enable_acpi_power_management(struct pp_hwmgr 
*hwmgr)
  * @paramhwmgr  the address of the powerplay hardware manager.
  * @return   always 0
  */
-int iceland_get_mc_microcode_version(struct pp_hwmgr *hwmgr)
+static int iceland_get_mc_microcode_version(struct pp_hwmgr *hwmgr)
 {
cgs_write_register(hwmgr->device, mmMC_SEQ_IO_DEBUG_INDEX, 0x9F);

@@ -262,7 +262,7 @@ static void iceland_trim_voltage_table_to_fit_state_table(
  * @paramhwmgr  the address of the powerplay hardware manager.
  * @return   always 0
  */
-int iceland_enable_voltage_control(struct pp_hwmgr *hwmgr)
+static int iceland_enable_voltage_control(struct pp_hwmgr *hwmgr)
 {
/* enable voltage control */
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, 
GENERAL_PWRMGT, VOLT_PWRMGT_EN

[PATCH] drm: Fix typo in encoder docs

2016-09-19 Thread Dhinakaran Pandiyan
Corrected typo in bridge and encoder comparison. Also, added a one-line
encoder description from the previous documentation.

Cc: Daniel Vetter 
Cc: Archit Taneja 

Signed-off-by: Dhinakaran Pandiyan 
---
 drivers/gpu/drm/drm_encoder.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index 998a674..5c06771 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -31,20 +31,21 @@
  *
  * Encoders represent the connecting element between the CRTC (as the overall
  * pixel pipeline, represented by struct &drm_crtc) and the connectors (as the
- * generic sink entity, represented by struct &drm_connector). Encoders are
- * objects exposed to userspace, originally to allow userspace to infer cloning
- * and connector/CRTC restrictions. Unfortunately almost all drivers get this
- * wrong, making the uabi pretty much useless. On top of that the exposed
- * restrictions are too simple for todays hardware, and the recommend way to
- * infer restrictions is by using the DRM_MODE_ATOMIC_TEST_ONLY flag for the
- * atomic IOCTL.
+ * generic sink entity, represented by struct &drm_connector). An encoder takes
+ * pixel data from a CRTC and converts it to a format suitable for any attached
+ * connector. Encoders are objects exposed to userspace, originally to allow
+ * userspace to infer cloning and connector/CRTC restrictions. Unfortunately
+ * almost all drivers get this wrong, making the uabi pretty much useless. On
+ * top of that the exposed restrictions are too simple for today's hardware, 
and
+ * the recommended way to infer restrictions is by using the
+ * DRM_MODE_ATOMIC_TEST_ONLY flag for the atomic IOCTL.
  *
  * Otherwise encoders aren't used in the uapi at all (any modeset request from
  * userspace directly connects a connector with a CRTC), drivers are therefore
  * free to use them however they wish. Modeset helper libraries make strong use
  * of encoders to facilitate code sharing. But for more complex settings it is
  * usually better to move shared code into a separate &drm_bridge. Compared to
- * encoders bridges also have the benefit of not being purely an internal
+ * encoders, bridges also have the benefit of being purely an internal
  * abstraction since they are not exposed to userspace at all.
  *
  * Encoders are initialized with drm_encoder_init() and cleaned up using
-- 
2.5.0



[PATCH] drm/amd/powerplay/hwmgr: add missing header dependencies

2016-09-19 Thread Baoyou Xie
We get 3 warnings when building kernel with W=1:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/pp_acpi.c:29:6: warning: no 
previous prototype for 'acpi_atcs_functions_supported' [-Wmissing-prototypes]
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/pp_acpi.c:47:6: warning: no 
previous prototype for 'acpi_atcs_notify_pcie_device_ready' 
[-Wmissing-prototypes]
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/pp_acpi.c:61:5: warning: no 
previous prototype for 'acpi_pcie_perf_request' [-Wmissing-prototypes]

In fact, these functions are declared in
drivers/gpu/drm/amd/powerplay/inc/pp_acpi.h,
so this patch adds missing header dependencies.

Signed-off-by: Baoyou Xie 
---
 drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c
index 1944d28..f5e8fda 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c
@@ -25,6 +25,7 @@
 #include "linux/delay.h"
 #include "hwmgr.h"
 #include "amd_acpi.h"
+#include "pp_acpi.h"

 bool acpi_atcs_functions_supported(void *device, uint32_t index)
 {
-- 
2.7.4



  1   2   >