[Bug 97157] MST displays fail to wake

2016-08-21 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97157

--- Comment #3 from Dan Doel  ---
Turns out I was wrong. It does still happen with a single display, but it takes
much longer. After over 6 days of uptime, my single display failed to wake up.
I'll attach dmesg output for that case.

It appears that the numbers in the debug message don't go way up when the
problem happens with a single display. So I guess maybe that isn't as much of a
clue as I'd hoped.

-- 
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/20160821/0f0ecd76/attachment.html>


[Bug 97157] MST displays fail to wake

2016-08-21 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97157

--- Comment #4 from Dan Doel  ---
Created attachment 125935
  --> https://bugs.freedesktop.org/attachment.cgi?id=125935&action=edit
dmesg output with a single MST monitor

-- 
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/20160821/18b278ad/attachment.html>


[Bug 97428] Specific OpenGL applications deadlock on AMD GPU drivers

2016-08-21 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97428

Bug ID: 97428
   Summary: Specific OpenGL applications deadlock on AMD GPU
drivers
   Product: DRI
   Version: unspecified
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: major
  Priority: medium
 Component: DRM/AMDgpu
  Assignee: dri-devel at lists.freedesktop.org
  Reporter: tmp6154 at yandex.ru

I've been experiencing problems with open-source AMD GPU driver and specific
OpenGL applications. Particularly, Tabletop Simulator and Left 4 Dead 2 exhibit
this behavior. After a few minutes since game launches, it (apparently
randomly) deadlocks, screen stops to refresh. If game is minimized and
maximized again, it will show black screen. From this state, it could only be
closed with SIGINT in terminal or SIGKILL. Left 4 Dead 2 has similar issue, but
unlike Tabletop Simulator, it doesn't seem to deadlock in main menu.

My configuration:

Gentoo Linux
Dual AMD Radeon RX 480 (Polaris 10).
4.7.0 kernel with AMD GPU built as module (PowerPlay component enabled).
mesa git ().
xf86-video-amdgpu git ().
XOrg 1.17.4

Direct Rendering works, GPU is detected according to glxinfo:

direct rendering: Yes

OpenGL renderer string: Gallium 0.4 on AMD POLARIS10 (DRM 3.2.0 / 4.7.1-gentoo,
LLVM 3.7.1)

XOrg log shows GPUs are initialized:

[30.903] (II) AMDGPU(G0): [DRI2] Setup complete 
[30.903] (II) AMDGPU(G0): [DRI2]   DRI driver: radeonsi 
[30.903] (II) AMDGPU(G0): [DRI2]   VDPAU driver: radeonsi 
[30.905] (**) AMDGPU(G0): DRI3 enabled 
[30.963] (II) AMDGPU(0): [DRI2] Setup complete 
[30.963] (II) AMDGPU(0): [DRI2]   DRI driver: radeonsi 
[30.963] (II) AMDGPU(0): [DRI2]   VDPAU driver: radeonsi 
[30.964] (**) AMDGPU(0): DRI3 enabled 
[31.036] (II) GLX: Initialized DRI2 GL provider for screen 0

DRI3 is enabled (though GLX uses DRI2 for some reason).

Here's my device configuration:

Section "Device" 
Identifier  "AMD Radeon RX 480 (POLARIS10)" 
Driver  "amdgpu" 
BusID   "PCI:1:0:0" 
Option  "DRI" "3" 
Option  "AccelMethod" "glamor" 
EndSection

-- 
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/20160821/7a2a988c/attachment.html>


[Bug 97428] Specific OpenGL applications deadlock on AMD GPU drivers

2016-08-21 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97428

--- Comment #1 from Vitaly Ostrosablin  ---
Before deadlock, nothing is printed to terminal. I've also attempted using
GALLIUM_HUD environment variable to display various information. There's
nothing unusual right before deadlock (no VRAM usage spike, no high GPU load,
etc). Deadlocks seem to be completely random (I see no relation between scene
complexity, CPU load, etc). I.e. it may deadlock both on idle scene and during
active physics simulation (in case of Tabletop Simulator). Looks like an AMD
GPU issue.

If additional info is needed, let me know.

-- 
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/20160821/3e7e3e0a/attachment.html>


[PATCH 1/2] Revert "include/uapi/drm/amdgpu_drm.h: use __u32 and __u64 from "

2016-08-21 Thread Christian König
Am 20.08.2016 um 19:58 schrieb Mikko Rapeli:
> Cc'ing lkml too.
>
> On Fri, Aug 19, 2016 at 11:54:21PM +0100, Emil Velikov wrote:
>> Story time:
>> I was dreaming of a day were we can stop installing these headers,
>> thus making deprecation a bit easier process.
>> Yet after failing to convince Dave and Daniel on a number of occasions
>> I've accepted that those headers _are_ here to stay. And yes they
>> _are_ the UAPI, even though no applications are meant to use them but
>> the libdrm 'version'.
>> Thus any changes to the libdrm ones should be a mirror of the ones
>> here and libdrm should _not_ differ.
> Another day dream:
>
> Wouldn't it be nice if the uapi headers from Linux kernel would pass
> a simple quality check of compiling in userspace where they are meant to be
> used?

libdrm has a whole bunch of unit tests exercising the kernel UAPI 
headers for both API and ABI compatibility.

So to be honest I see your good intentions here, but no those checks are 
completely useless for us.

Christian.

>   Stand alone. Without magic tricks and additional libraries and their
> headers. Without glibc or any other libc implementation specific additions.
> The uapi headers define many parts of the Linux kernel API and ABI, and thus
> compiling them also without the 'official' GNU/Linux userspace libraries
> like glibc or libdrm does have some uses. For example API and ABI
> compatibility checks and API/ABI/system call fuzzers.
>
> Many headers required stdint.h types but Linux kernel headers do not
> define them in userspace, and then Linus has said that uapi headers
> should use the linux/types.h with double underscores. Thus my patches
> for fixing trivial compile errors turned into changing several stdint.h
> definitions to linux/types.h.
>
> Yes, there have been some regressions in this work but to err is human.
> What is the actual problem and how can we (yes, including me) try to
> solve it?
>
> -Mikko




[PATCH] drm/tegra: Fix window[0] base address corruption

2016-08-21 Thread Dmitry Osipenko
Window uses shared stride for UV planes and tegra_dc_window struct
defines array of 2 strides per window. That's not taken in account
during setting up of the window addresses and strides, resulting in
out-of-bounds write of the 3-rd (non-existent) V plane stride that
overwrites Y plane base address.

Signed-off-by: Dmitry Osipenko 
---
 drivers/gpu/drm/tegra/dc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 39940f5..a98dd3e 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -590,7 +590,9 @@ static void tegra_plane_atomic_update(struct drm_plane 
*plane,
struct tegra_bo *bo = tegra_fb_get_plane(fb, i);

window.base[i] = bo->paddr + fb->offsets[i];
-   window.stride[i] = fb->pitches[i];
+
+   if (i < 2)
+   window.stride[i] = fb->pitches[i];
}

tegra_dc_setup_window(dc, p->index, &window);
-- 
2.9.3



[Bug 93475] Saints Row IV causes GPU lockup on Linux

2016-08-21 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=93475

--- Comment #5 from Jan Holthuis  ---
I uploaded an apitrace file at: https://transfer.sh/ufSHo/saintsrow4.trace

I've set the Steam launch options to this:
MESA_GL_VERSION_OVERRIDE=4.1 MESA_GLSL_VERSION_OVERRIDE=410 apitrace32 trace -a
gl -o ~/saintsrow4.trace %command%

Using R600_DEBUG=nosb fixes the GPU lockup. 

Here's my setup:

$ cat /proc/cpuinfo | grep -m 1 "model name"
model name  : AMD A6-3410MX APU with Radeon(tm) HD Graphics

$ glxinfo | grep -E "^OpenGL.*string:"  
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD SUMO (DRM 2.45.0 / 4.7.1-1-ARCH,
LLVM 3.8.1)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 12.0.1
OpenGL core profile shading language version string: 3.30
OpenGL version string: 3.0 Mesa 12.0.1
OpenGL shading language version string: 1.30
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 12.0.1
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

-- 
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/20160821/f46d0c72/attachment.html>


[Bug 97025] flip queue failed: Device or resource busy

2016-08-21 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=97025

--- Comment #14 from Bernd Steinhauser  ---
Ok, it's not egl, the same happens with glx/OpenGL3.

-- 
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/20160821/c3f8699a/attachment.html>


[PATCH 1/1] drm/amdgpu/gmc7: remove dead code

2016-08-21 Thread Joe Perches
On Sun, 2016-08-21 at 20:06 +0200, Heinrich Schuchardt wrote:
> In an if block for (running == 0) running cannot be non-zero.

This code could also be better unindented by one level
(all of the block would fit 80 columns) by changing:

if (running == 0) {
[code...]
}

return 0;

to:

if (running)
return 0;

[code...]

return 0;
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
[]
> @@ -203,11 +203,6 @@ static int gmc_v7_0_mc_load_microcode(struct 
> amdgpu_device *adev)
>  running = REG_GET_FIELD(RREG32(mmMC_SEQ_SUP_CNTL), MC_SEQ_SUP_CNTL, 
> RUN);
>  
>  if (running == 0) {
> - if (running) {
> - blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
> - WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout | 1);
> - }
> -
>  /* reset the engine and set to writable */
>  WREG32(mmMC_SEQ_SUP_CNTL, 0x0008);
>  WREG32(mmMC_SEQ_SUP_CNTL, 0x0010);
> @@ -239,9 +234,6 @@ static int gmc_v7_0_mc_load_microcode(struct 
> amdgpu_device *adev)
>  break;
>  udelay(1);
>  }
> -
> - if (running)
> - WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout);
>  }
>  
>  return 0;


[PATCH] drm/gma500: dont expose bytes from kernel stack

2016-08-21 Thread Joe Perches
On Sun, 2016-08-21 at 20:39 +0200, Heinrich Schuchardt wrote:
> Components m1, m2, p2, dot, vco of variable clock should be
> initialized to avoid bytes from the kernel stack to be
> exposed.

How was this found? visual code inspection?

And isn't this true for mrst_lvds_find_best_pll as well?

> a@@ -138,6 +138,7 @@ static bool mrst_sdvo_find_best_pll(const struct 
> gma_limit_t *limit,
>  u32 target_vco, actual_freq;
>  s32 freq_error, min_error = 10;
>  
> + memset(clock, 0, sizeof(struct gma_clock_t));
>  memset(best_clock, 0, sizeof(*best_clock));
>  
>  for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {


[PATCH 1/1] drm/amdgpu/gmc7: remove dead code

2016-08-21 Thread Joe Perches
On Sun, 2016-08-21 at 20:45 +0200, Heinrich Schuchardt wrote:
> On 08/21/2016 08:29 PM, Joe Perches wrote:
> > On Sun, 2016-08-21 at 20:06 +0200, Heinrich Schuchardt wrote:
> > > In an if block for (running == 0) running cannot be non-zero.
> > This code could also be better unindented by one level
> > (all of the block would fit 80 columns) by changing:
> > 
> > if (running == 0) {
> > [code...]
> > }
> > 
> > return 0;
> > 
> > to:
> > 
> > if (running)
> > return 0;
> > 
> > [code...]
> > 
> > return 0;
> Should I revise my patch?
> Or should this be an additional patch?

If you want to do it, an additional patch is probably best.


[PATCH] drm/gma500: dont expose bytes from kernel stack

2016-08-21 Thread Joe Perches
On Sun, 2016-08-21 at 21:35 +0200, Heinrich Schuchardt wrote:
> On 08/21/2016 08:46 PM, Joe Perches wrote:
> > On Sun, 2016-08-21 at 20:39 +0200, Heinrich Schuchardt wrote:
> > > Components m1, m2, p2, dot, vco of variable clock should be
> > > initialized to avoid bytes from the kernel stack to be
> > > exposed.
> > How was this found? visual code inspection?
> cppcheck (http://cppcheck.sourceforge.net/)

This should probably be mentioned in the changelog.

What about mrst_lvds_find_best_pll ?


[PATCH 1/1] drm/radeon: avoid NULL dereference, si_get_vce_clock_voltage

2016-08-21 Thread Joe Perches
On Sun, 2016-08-21 at 22:52 +0200, Heinrich Schuchardt wrote:
> It does not make sense to check if table is NULL
> and afterwards to dereference it without
> considering the result.

This makes no sense.

> The inconsistency was indicated by cppcheck.

Perhaps this is a defect in cppcheck?

> An actual NULL pointer dereference was not observed.
[]
> diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
[]
> @@ -2962,7 +2962,7 @@ static int si_get_vce_clock_voltage(struct 
> radeon_device *rdev,
>  &rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;
>  
>  if (((evclk == 0) && (ecclk == 0)) ||
> -     (table && (table->count == 0))) {

Here table is only dereferenced if table is non-null

> +     table == NULL || table->count == 0) {
>  *voltage = 0;
>  return 0;
>  }

Perhaps the unnecessary parentheses can be reduce though.

   if ((evclk == 0 && ecclk == 0) || (table && table->count == 0)) {


[PATCH 1/1] drm/radeon: avoid NULL dereference, si_get_vce_clock_voltage

2016-08-21 Thread Joe Perches
On Sun, 2016-08-21 at 23:20 +0200, Heinrich Schuchardt wrote:
> On 08/21/2016 11:06 PM, Joe Perches wrote:
> > On Sun, 2016-08-21 at 22:52 +0200, Heinrich Schuchardt wrote:
> > > 
> > > It does not make sense to check if table is NULL
> > > and afterwards to dereference it without
> > > considering the result.
> > This makes no sense.
> > > The inconsistency was indicated by cppcheck.
> > Perhaps this is a defect in cppcheck?
> > > An actual NULL pointer dereference was not observed.
> > []
> > > diff --git a/drivers/gpu/drm/radeon/si_dpm.c 
> > > b/drivers/gpu/drm/radeon/si_dpm.c
> > []
> > > @@ -2962,7 +2962,7 @@ static int si_get_vce_clock_voltage(struct 
> > > radeon_device *rdev,
> > >  
> > > &rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;
> > >  
> > >  if (((evclk == 0) && (ecclk == 0)) ||
> > > -     (table && (table->count == 0))) {
> > Here table is only dereferenced if table is non-null
> > > 
> > > +     table == NULL || table->count == 0) {
> > >  *voltage = 0;
> > >  return 0;
> > >  }
> > Perhaps the unnecessary parentheses can be reduce though.
> > 
> >    if ((evclk == 0 && ecclk == 0) || (table && table->count == 0)) {
> > 
> The possible NULL pointer dereference would occur here:
> 
> 2970        for (i = 0; i < table->count; i++) {

This still doesn't make any sense as table is known non-null
at line 2961

struct radeon_vce_clock_voltage_dependency_table *table =
&rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;

So I now suggest simply removing the test for table.

Perhaps cppcheck can be improved to know about known non-null pointers.



[PATCH 1/3] drm/etnaviv: check for errors when enabling clocks

2016-08-21 Thread Fabio Estevam
clk_prepare_enable() may fail, so we should better check for its return
value and propagate it in the case of failure.

Signed-off-by: Fabio Estevam 
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 30 --
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 87ef341..efee7d47 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -872,12 +872,25 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct 
seq_file *m)
  */
 static int enable_clk(struct etnaviv_gpu *gpu)
 {
-   if (gpu->clk_core)
-   clk_prepare_enable(gpu->clk_core);
-   if (gpu->clk_shader)
-   clk_prepare_enable(gpu->clk_shader);
+   int ret;
+
+   if (gpu->clk_core) {
+   ret = clk_prepare_enable(gpu->clk_core);
+   if (ret)
+   return ret;
+   }
+
+   if (gpu->clk_shader) {
+   ret = clk_prepare_enable(gpu->clk_shader);
+   if (ret)
+   goto disable_clk_core;
+   }

return 0;
+
+disable_clk_core:
+   clk_disable_unprepare(gpu->clk_core);
+   return ret;
 }

 static int disable_clk(struct etnaviv_gpu *gpu)
@@ -892,8 +905,13 @@ static int disable_clk(struct etnaviv_gpu *gpu)

 static int enable_axi(struct etnaviv_gpu *gpu)
 {
-   if (gpu->clk_bus)
-   clk_prepare_enable(gpu->clk_bus);
+   int ret;
+
+   if (gpu->clk_bus) {
+   ret = clk_prepare_enable(gpu->clk_bus);
+   if (ret)
+   return ret;
+   }

return 0;
 }
-- 
1.9.1



[PATCH 2/3] drm/etnaviv: remove unneeded 'fail' label

2016-08-21 Thread Fabio Estevam
In the etnaviv_gpu_platform_probe() error path the 'fail' label is
used to just return the error code.

This can be simplified by returning the error code immediately, so
get rid of the unneeded 'fail' label.

Signed-off-by: Fabio Estevam 
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index efee7d47..d93eb8c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1669,16 +1669,15 @@ static int etnaviv_gpu_platform_probe(struct 
platform_device *pdev)
/* Get Interrupt: */
gpu->irq = platform_get_irq(pdev, 0);
if (gpu->irq < 0) {
-   err = gpu->irq;
-   dev_err(dev, "failed to get irq: %d\n", err);
-   goto fail;
+   dev_err(dev, "failed to get irq: %d\n", gpu->irq);
+   return gpu->irq;
}

err = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, 0,
   dev_name(gpu->dev), gpu);
if (err) {
dev_err(dev, "failed to request IRQ%u: %d\n", gpu->irq, err);
-   goto fail;
+   return err;
}

/* Get Clocks: */
@@ -1712,13 +1711,10 @@ static int etnaviv_gpu_platform_probe(struct 
platform_device *pdev)
err = component_add(&pdev->dev, &gpu_ops);
if (err < 0) {
dev_err(&pdev->dev, "failed to register component: %d\n", err);
-   goto fail;
+   return err;
}

return 0;
-
-fail:
-   return err;
 }

 static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
-- 
1.9.1



[PATCH 3/3] drm/etnaviv: remove unneeded variable initialization

2016-08-21 Thread Fabio Estevam
There is no need to initialize variable 'err' with 0 because it will
be properly assigned later on. 

Signed-off-by: Fabio Estevam 
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index d93eb8c..27f34f5 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1652,7 +1652,7 @@ static int etnaviv_gpu_platform_probe(struct 
platform_device *pdev)
 {
struct device *dev = &pdev->dev;
struct etnaviv_gpu *gpu;
-   int err = 0;
+   int err;

gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL);
if (!gpu)
-- 
1.9.1



[PATCH -next] drm/i915: Fix non static symbol warning

2016-08-21 Thread Wei Yongjun
From: Wei Yongjun 

Fixes the following sparse warning:

drivers/gpu/drm/i915/intel_hotplug.c:480:6: warning:
 symbol 'i915_hpd_poll_init_work' was not declared. Should it be static?

Also move the '{' to new line.

Signed-off-by: Wei Yongjun 
---
 drivers/gpu/drm/i915/intel_hotplug.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_hotplug.c 
b/drivers/gpu/drm/i915/intel_hotplug.c
index 5dc2c20..334d47b 100644
--- a/drivers/gpu/drm/i915/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/intel_hotplug.c
@@ -477,7 +477,8 @@ void intel_hpd_init(struct drm_i915_private *dev_priv)
spin_unlock_irq(&dev_priv->irq_lock);
 }

-void i915_hpd_poll_init_work(struct work_struct *work) {
+static void i915_hpd_poll_init_work(struct work_struct *work)
+{
struct drm_i915_private *dev_priv =
container_of(work, struct drm_i915_private,
 hotplug.poll_init_work);



[PATCH 1/1] drm/amdgpu/gmc7: remove dead code

2016-08-21 Thread Heinrich Schuchardt
In an if block for (running == 0) running cannot be non-zero.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index 0b0f086..1239463 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -203,11 +203,6 @@ static int gmc_v7_0_mc_load_microcode(struct amdgpu_device 
*adev)
running = REG_GET_FIELD(RREG32(mmMC_SEQ_SUP_CNTL), MC_SEQ_SUP_CNTL, 
RUN);

if (running == 0) {
-   if (running) {
-   blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
-   WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout | 1);
-   }
-
/* reset the engine and set to writable */
WREG32(mmMC_SEQ_SUP_CNTL, 0x0008);
WREG32(mmMC_SEQ_SUP_CNTL, 0x0010);
@@ -239,9 +234,6 @@ static int gmc_v7_0_mc_load_microcode(struct amdgpu_device 
*adev)
break;
udelay(1);
}
-
-   if (running)
-   WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout);
}

return 0;
-- 
2.1.4



[PATCH 1/1] drm/amd/powerplay: avoid NULL pointer dereference

2016-08-21 Thread Heinrich Schuchardt
if (a == NULL || a->b == NULL)
leads to a NULL pointer dereference if a == NULL.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c 
b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index abbb658..456a339 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -162,12 +162,12 @@ static int pp_hw_fini(void *handle)
pp_handle = (struct pp_instance *)handle;
eventmgr = pp_handle->eventmgr;

-   if (eventmgr != NULL || eventmgr->pp_eventmgr_fini != NULL)
+   if (eventmgr != NULL && eventmgr->pp_eventmgr_fini != NULL)
eventmgr->pp_eventmgr_fini(eventmgr);

smumgr = pp_handle->smu_mgr;

-   if (smumgr != NULL || smumgr->smumgr_funcs != NULL ||
+   if (smumgr != NULL && smumgr->smumgr_funcs != NULL &&
smumgr->smumgr_funcs->smu_fini != NULL)
smumgr->smumgr_funcs->smu_fini(smumgr);

-- 
2.1.4



[PATCH 1/1] drm/amd/powerplay: avoid NULL dereference, cz_hwmgr.c

2016-08-21 Thread Heinrich Schuchardt
if (a == NULL || a->b == NULL)
leads to a NULL pointer dereference if a == NULL.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
index 8cc0df9..5e2d4cf 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
@@ -1246,7 +1246,7 @@ static int cz_hwmgr_backend_init(struct pp_hwmgr *hwmgr)

 static int cz_hwmgr_backend_fini(struct pp_hwmgr *hwmgr)
 {
-   if (hwmgr != NULL || hwmgr->backend != NULL) {
+   if (hwmgr != NULL && hwmgr->backend != NULL) {
kfree(hwmgr->backend);
kfree(hwmgr);
}
-- 
2.1.4



[PATCH] drm/gma500: dont expose bytes from kernel stack

2016-08-21 Thread Heinrich Schuchardt
On 08/21/2016 08:46 PM, Joe Perches wrote:
> On Sun, 2016-08-21 at 20:39 +0200, Heinrich Schuchardt wrote:
>> Components m1, m2, p2, dot, vco of variable clock should be
>> initialized to avoid bytes from the kernel stack to be
>> exposed.
> 
> How was this found? visual code inspection?

cppcheck (http://cppcheck.sourceforge.net/)



[PATCH 1/1] drm/radeon/cik: remove dead code

2016-08-21 Thread Heinrich Schuchardt
In an if block for (running == 0) running cannot be non-zero.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/radeon/cik.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 0c1b9ff..c8e1515 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -1912,11 +1912,6 @@ int ci_mc_load_microcode(struct radeon_device *rdev)
running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK;

if (running == 0) {
-   if (running) {
-   blackout = RREG32(MC_SHARED_BLACKOUT_CNTL);
-   WREG32(MC_SHARED_BLACKOUT_CNTL, blackout | 1);
-   }
-
/* reset the engine and set to writable */
WREG32(MC_SEQ_SUP_CNTL, 0x0008);
WREG32(MC_SEQ_SUP_CNTL, 0x0010);
@@ -1964,9 +1959,6 @@ int ci_mc_load_microcode(struct radeon_device *rdev)
break;
udelay(1);
}
-
-   if (running)
-   WREG32(MC_SHARED_BLACKOUT_CNTL, blackout);
}

return 0;
-- 
2.1.4



[PATCH 1/1] drm/gma500: dont expose stack, mrst_lvds_find_best_pll

2016-08-21 Thread Heinrich Schuchardt
All components of variable clock should be initialized
to avoid bytes from the kernel stack to be exposed.

Reported-by: Joe Perches 
Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/gma500/oaktrail_crtc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c 
b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index 28bd8f3..0277d85 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -195,6 +195,7 @@ static bool mrst_lvds_find_best_pll(const struct 
gma_limit_t *limit,
struct gma_clock_t clock;
int err = target;

+   memset(clock, 0, sizeof(struct gma_clock_t));
memset(best_clock, 0, sizeof(*best_clock));

for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {
-- 
2.1.4



[PATCH 1/1] drm/radeon: remove dead code, si_mc_load_microcode

2016-08-21 Thread Heinrich Schuchardt
In an if block for (running == 0) running cannot be non-zero.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/radeon/si.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 2523ca9..41da47d 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -1598,11 +1598,6 @@ int si_mc_load_microcode(struct radeon_device *rdev)
running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK;

if (running == 0) {
-   if (running) {
-   blackout = RREG32(MC_SHARED_BLACKOUT_CNTL);
-   WREG32(MC_SHARED_BLACKOUT_CNTL, blackout | 1);
-   }
-
/* reset the engine and set to writable */
WREG32(MC_SEQ_SUP_CNTL, 0x0008);
WREG32(MC_SEQ_SUP_CNTL, 0x0010);
@@ -1641,9 +1636,6 @@ int si_mc_load_microcode(struct radeon_device *rdev)
break;
udelay(1);
}
-
-   if (running)
-   WREG32(MC_SHARED_BLACKOUT_CNTL, blackout);
}

return 0;
-- 
2.1.4



[PATCH 1/1] drm/amdgpu/gmc8: remove dead code

2016-08-21 Thread Heinrich Schuchardt
In an if block for (running == 0) running cannot be non-zero.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 2aee2c6..92407cb 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -287,11 +287,6 @@ static int gmc_v8_0_mc_load_microcode(struct amdgpu_device 
*adev)
running = REG_GET_FIELD(RREG32(mmMC_SEQ_SUP_CNTL), MC_SEQ_SUP_CNTL, 
RUN);

if (running == 0) {
-   if (running) {
-   blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
-   WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout | 1);
-   }
-
/* reset the engine and set to writable */
WREG32(mmMC_SEQ_SUP_CNTL, 0x0008);
WREG32(mmMC_SEQ_SUP_CNTL, 0x0010);
@@ -323,9 +318,6 @@ static int gmc_v8_0_mc_load_microcode(struct amdgpu_device 
*adev)
break;
udelay(1);
}
-
-   if (running)
-   WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout);
}

return 0;
-- 
2.1.4



[PATCH] drm/gma500: dont expose bytes from kernel stack

2016-08-21 Thread Heinrich Schuchardt
Components m1, m2, p2, dot, vco of variable clock should be
initialized to avoid bytes from the kernel stack to be
exposed.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/gma500/oaktrail_crtc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c 
b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index da9fd34..28bd8f3 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -138,6 +138,7 @@ static bool mrst_sdvo_find_best_pll(const struct 
gma_limit_t *limit,
u32 target_vco, actual_freq;
s32 freq_error, min_error = 10;

+   memset(clock, 0, sizeof(struct gma_clock_t));
memset(best_clock, 0, sizeof(*best_clock));

for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {
-- 
2.1.4



[PATCH 1/1] drm/amdgpu/gmc7: remove dead code

2016-08-21 Thread Heinrich Schuchardt
On 08/21/2016 08:29 PM, Joe Perches wrote:
> On Sun, 2016-08-21 at 20:06 +0200, Heinrich Schuchardt wrote:
>> In an if block for (running == 0) running cannot be non-zero.
> 
> This code could also be better unindented by one level
> (all of the block would fit 80 columns) by changing:
> 
>   if (running == 0) {
>   [code...]
>   }
> 
>   return 0;
> 
> to:
> 
>   if (running)
>   return 0;
> 
>   [code...]
> 
>   return 0;

Should I revise my patch?
Or should this be an additional patch?




[PATCH 1/1] drm/radeon: avoid NULL dereference, si_get_vce_clock_voltage

2016-08-21 Thread Heinrich Schuchardt
It does not make sense to check if table is NULL
and afterwards to dereference it without
considering the result.

The inconsistency was indicated by cppcheck.
An actual NULL pointer dereference was not observed.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/radeon/si_dpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index e6abc09..ba2cf12 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -2962,7 +2962,7 @@ static int si_get_vce_clock_voltage(struct radeon_device 
*rdev,
&rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;

if (((evclk == 0) && (ecclk == 0)) ||
-   (table && (table->count == 0))) {
+   table == NULL || table->count == 0) {
*voltage = 0;
return 0;
}
-- 
2.1.4



[PATCH 1/1] drm/radeon: avoid NULL dereference, si_get_vce_clock_voltage

2016-08-21 Thread Heinrich Schuchardt
On 08/21/2016 11:06 PM, Joe Perches wrote:
> On Sun, 2016-08-21 at 22:52 +0200, Heinrich Schuchardt wrote:
>> It does not make sense to check if table is NULL
>> and afterwards to dereference it without
>> considering the result.
> 
> This makes no sense.
> 
>> The inconsistency was indicated by cppcheck.
> 
> Perhaps this is a defect in cppcheck?
> 
>> An actual NULL pointer dereference was not observed.
> []
>> diff --git a/drivers/gpu/drm/radeon/si_dpm.c 
>> b/drivers/gpu/drm/radeon/si_dpm.c
> []
>> @@ -2962,7 +2962,7 @@ static int si_get_vce_clock_voltage(struct 
>> radeon_device *rdev,
>>  &rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;
>>  
>>  if (((evclk == 0) && (ecclk == 0)) ||
>> -(table && (table->count == 0))) {
> 
> Here table is only dereferenced if table is non-null
> 
>> +table == NULL || table->count == 0) {
>>  *voltage = 0;
>>  return 0;
>>  }
> 
> Perhaps the unnecessary parentheses can be reduce though.
> 
>   if ((evclk == 0 && ecclk == 0) || (table && table->count == 0)) {
> 
The possible NULL pointer dereference would occur here:

2970for (i = 0; i < table->count; i++) {




[PATCH 1/1] virtio-gpu: avoid possible NULL pointer dereference

2016-08-21 Thread Heinrich Schuchardt
If output is NULL it is not permissable to dereference it.
So we should leave the respective function in this case.

The inconsistency was indicated by cppcheck.
No actual NULL pointer dereference was observed.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c 
b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 925ca25..ba28c0f 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -76,7 +76,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane 
*plane,
output = drm_crtc_to_virtio_gpu_output(plane->state->crtc);
if (old_state->crtc)
output = drm_crtc_to_virtio_gpu_output(old_state->crtc);
-   WARN_ON(!output);
+   if (WARN_ON(!output))
+   return;

if (plane->state->fb) {
vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
@@ -129,7 +130,8 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane 
*plane,
output = drm_crtc_to_virtio_gpu_output(plane->state->crtc);
if (old_state->crtc)
output = drm_crtc_to_virtio_gpu_output(old_state->crtc);
-   WARN_ON(!output);
+   if (WARN_ON(!output))
+   return;

if (plane->state->fb) {
vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
-- 
2.1.4



[PATCH 1/1] drm/vmwgfx: avoid possible NULL pointer dereference

2016-08-21 Thread Heinrich Schuchardt
The comment describing function vmw_cmd_res_reloc_add
explicitely mentions p_val may be NULL.

We should not assign a value (NULL) to *p_val in this case.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index dc5beff..0363989 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -652,7 +652,11 @@ static int vmw_cmd_res_reloc_add(struct vmw_private 
*dev_priv,
int ret;
struct vmw_resource_val_node *node;

+   if (!p_val)
+   return;
+
*p_val = NULL;
+
ret = vmw_resource_relocation_add(&sw_context->res_relocations,
  res,
  id_loc - sw_context->buf_start);
@@ -663,8 +667,7 @@ static int vmw_cmd_res_reloc_add(struct vmw_private 
*dev_priv,
if (unlikely(ret != 0))
return ret;

-   if (p_val)
-   *p_val = node;
+   *p_val = node;

return 0;
 }
-- 
2.1.4



[PATCH 1/1] drm: avoid exposing kernel stack in compat_drm_getstats

2016-08-21 Thread Heinrich Schuchardt
The C standard does not specify the size of the integer used
to store an enum. Hence in structure drm_stats32_t alignment
bytes may exist.

To avoid exposing bytes from the kernel stack it is
necessary to initialize variable s32 completely.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/gpu/drm/drm_ioc32.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 57676f8..32a489b 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -346,6 +346,7 @@ static int compat_drm_getstats(struct file *file, unsigned 
int cmd,
struct drm_stats __user *stats;
int i, err;

+   memset(&s32, 0, sizeof(drm_stats32_t));
stats = compat_alloc_user_space(sizeof(*stats));
if (!stats)
return -EFAULT;
-- 
2.1.4



[PATCH] drm/fsl-dcu: disable clock on error path

2016-08-21 Thread Fabio Estevam
From: Fabio Estevam 

In fsl_dcu_drm_pm_resume() we should disable the previously enabled
clock (fsl_dev->clk) when enabling fsl_dev->pix_clk fails.

Signed-off-by: Fabio Estevam 
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index 7882387..76ae558 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -270,7 +270,7 @@ static int fsl_dcu_drm_pm_resume(struct device *dev)
ret = clk_prepare_enable(fsl_dev->pix_clk);
if (ret < 0) {
dev_err(dev, "failed to enable pix clk\n");
-   return ret;
+   goto disable_dcu_clk;
}

fsl_dcu_drm_init_planes(fsl_dev->drm);
@@ -284,6 +284,10 @@ static int fsl_dcu_drm_pm_resume(struct device *dev)
enable_irq(fsl_dev->irq);

return 0;
+
+disable_dcu_clk:
+   clk_disable_unprepare(fsl_dev->clk);
+   return ret;
 }
 #endif

-- 
1.9.1



[v13 PATCH 5/5] drm/rockchip: cdn-dp: add cdn DP support for rk3399

2016-08-21 Thread Chris Zhong
Add support for cdn DP controller which is embedded in the rk3399
SoCs. The DP is compliant with DisplayPort Specification,
Version 1.3, This IP is compatible with the rockchip type-c PHY IP.
There is a uCPU in DP controller, it need a firmware to work,
please put the firmware file to /lib/firmware/rockchip/dptx.bin. The
uCPU in charge of aux communication and link training, the host use
mailbox to communicate with the ucpu.
The dclk pin_pol of vop must not be invert for DP.

Signed-off-by: Chris Zhong 
Reviewed-by: Sean Paul 
Acked-by: Mark Yao 

---

Changes in v13:
- support suspend/resume
- switch power domain dynamically
- re-training when hpd signal is triggered

Changes in v12:
- use EXTCON_PROP_USB_SUPERSPEED to replace EXTCON_USB_HOST

Changes in v11:
- add best_encoder back, since it required by drm_atomic_helper_check

Changes in v10:
- remove best_encoder ops
- support read sink count from DPCD
- control the grf_clk in DP

Changes in v9:
- do not need reset the phy before power_on
- add a orientation information for set_capability
- retry to read dpcd in 10 seconds

Changes in v8:
- optimization the err log

Changes in v7:
- support firmware standby when no dptx connection
- optimization the calculation of tu size and valid symbol

Changes in v6:
- add a port struct
- select SND_SOC_HDMI_CODEC
- force reset the phy when hpd detected

Changes in v5:
- alphabetical order
- do not use long, use u32 or u64
- return MODE_CLOCK_HIGH when requested > actual
- Optimized Coding Style
- add a formula to get better tu size and symbol value.
- modify according to Sean Paul's comments
- fixed the fw_wait always 0

Changes in v4:
- use phy framework to control DP phy
- support 2 phys

Changes in v3:
- use EXTCON_DISP_DP and EXTCON_DISP_DP_ALT cable to get dp port state.
- reset spdif before config it
- modify the firmware clk to 100Mhz
- retry load firmware if fw file is requested too early

Changes in v2:
- Alphabetic order
- remove excess error message
- use define clk_rate
- check all return value
- remove dev_set_name(dp->dev, "cdn-dp");
- use schedule_delayed_work
- remove never-called functions
- remove some unnecessary ()

Changes in v1:
- use extcon API
- use hdmi-codec for the DP Asoc
- do not initialize the "ret"
- printk a err log when drm_of_encoder_active_endpoint_id
- modify the dclk pin_pol to a single line

 drivers/gpu/drm/rockchip/Kconfig|   10 +
 drivers/gpu/drm/rockchip/Makefile   |1 +
 drivers/gpu/drm/rockchip/cdn-dp-core.c  | 1052 +++
 drivers/gpu/drm/rockchip/cdn-dp-core.h  |  106 +++
 drivers/gpu/drm/rockchip/cdn-dp-reg.c   |  959 
 drivers/gpu/drm/rockchip/cdn-dp-reg.h   |  482 
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |   13 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h |9 +
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c |2 +
 9 files changed, 2631 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/rockchip/cdn-dp-core.c
 create mode 100644 drivers/gpu/drm/rockchip/cdn-dp-core.h
 create mode 100644 drivers/gpu/drm/rockchip/cdn-dp-reg.c
 create mode 100644 drivers/gpu/drm/rockchip/cdn-dp-reg.h

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index d30bdc3..20aaafe 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -25,6 +25,16 @@ config ROCKCHIP_ANALOGIX_DP
  for the Analogix Core DP driver. If you want to enable DP
  on RK3288 based SoC, you should selet this option.

+config ROCKCHIP_CDN_DP
+tristate "Rockchip cdn DP"
+depends on DRM_ROCKCHIP
+   select SND_SOC_HDMI_CODEC if SND_SOC
+help
+ This selects support for Rockchip SoC specific extensions
+ for the cdn DP driver. If you want to enable Dp on
+ RK3399 based SoC, you should select this
+ option.
+
 config ROCKCHIP_DW_HDMI
 tristate "Rockchip specific extensions for Synopsys DW HDMI"
 depends on DRM_ROCKCHIP
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index 9746365..6a07809 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -7,6 +7,7 @@ rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \
 rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o

 obj-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
+obj-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
 obj-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
 obj-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
 obj-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c 
b/drivers/gpu/drm/rockchip/cdn-dp-core.c
new file mode 100644
index 000..9be551d
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -0,0 +1,1052 @@
+/*
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ * Author: Chris Zhong 
+ *
+ * This software is licensed under th

[v13 PATCH 0/5] Rockchip Type-C and DisplayPort driver

2016-08-21 Thread Chris Zhong

Hi all

This series patch is for rockchip Type-C phy and DisplayPort controller
driver.

The USB Type-C PHY is designed to support the USB3 and DP applications.
The PHY basically has two main components: USB3 and DisplyPort. USB3
operates in SuperSpeed mode and the DP can operate at RBR, HBR and HBR2
data rates. The Type-C cable orientation detection and Power Delivery
(PD) is accomplished using a PD PHY or a exernal PD chip.

The DP controller is compliant with DisplayPort Specification,
Version 1.3, This IP is compatible with the rockchip type-c PHY IP.
There is a uCPU in DP controller, it need a firmware to work, please
put the firmware file[0] rockchip/dptx.bin to
/lib/firmware/rockchip/dptx.bin. The uCPU in charge of aux communication
and link training, the host use mailbox to communicate with the ucpu.

The DP contoller has register a notification with extcon API, to get the
alt mode from PD, the PD driver need call the devm_extcon_dev_allocate
to create a extcon device and use extcon_set_state to notify DP
controller. And call extcon_set_cable_property to set orientation.

About the DP audio, cdn-dp registered 2 DAIs: 0 is I2S, 1 is SPDIF.
We can reference them in simple-card.

This series is based on Mark Yao's branch[1] and Chanwoo Choi's
extcon-next branch[2], and Guenter's patch about
EXTCON_PROP_USB_SUPERSPEED[3], and Heiko's clk patch[4].

I test this patches on the rk3399-evb board, with a fusb302 driver,
this branch has no rk3399.dtsi, so the patch about dts is not included
in this series.

>From V9, the Type-C PHY is split into two PHYs: DP and USB3. The PHY
will be init, no matter which PHY be power_on. The DP module will
enter A2 mode (standby mode) after phy_init, if DP PHY is powered on,
the DP module will enter to A0 mode(running mode). Then if DP PHY is
powered off, DP module will back to A2 mode. If everything is
un-plugged, phy will be deinit.

[0]
kernel/git/firmware/linux-firmware.git
[1]
https://github.com/markyzq/kernel-drm-rockchip/tree/drm-rockchip-next-2016-05-23
[2]
https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git extcon-next
[3]
https://patchwork.kernel.org/patch/9280955/
[4]
https://git.kernel.org/cgit/linux/kernel/git/mmind/linux-rockchip.git
/commit/?h=v4.9-clk/next&id=54479449c801e46ee2b6ba08e2f19cd810f74f94
https://git.kernel.org/cgit/linux/kernel/git/mmind/linux-rockchip.git
/commit/?h=v4.8-clk/fixes&id=a3f457d9636b3f5ae4fc6502cb0c95f60f5e342b


Changes in v13:
- do not return err if nothing connected with Type-C, when usb phy power on,
  since the USB core driver will call phy power without USB3 device connected.
- add dptx and apb reset
- support suspend/resume
- switch power domain dynamically
- re-training when hpd signal is triggered

Changes in v12:
- enable DP+USB3 mode, only when EXTCON_PROP_USB_SUPERSPEED equal 1
  and DP is attached
- use EXTCON_PROP_USB_SUPERSPEED to replace EXTCON_USB_HOST

Changes in v11:
- make a clearer emarcation between usb phy and dp phy
- make a clearer demarcation between usb phy and dp phy.
- split the dp-phy and usb3-phy to 2 child-node
- refer dp phy
- add best_encoder back, since it required by drm_atomic_helper_check

Changes in v10:
- remove rockchip,uphy-dp-sel property
- do not control dp select and hpd config in phy driver
- remove rockchip,uphy-dp-sel property
- add pclk_vio_grf clock
- remove best_encoder ops
- support read sink count from DPCD
- control the grf_clk in DP

Changes in v9:
- change #phy-cells to 1
- the new_mode should be int not u8
- move mutex_lock(&tcphy->lock); to earlier place. in
  rockchip_usb3_phy_power_off
- better mutex lock for phy mode and flip
- split the Type-C PHY into two PHYs: USB3 and DP
- change #phy-cells to 1
- modify the reference phy = <&tcphy0 0>, <&tcphy1 0>;
- do not need reset the phy before power_on
- add a orientation information for set_capability
- retry to read dpcd in 10 seconds

Changes in v8:
- set the default cable id to EXTCON_USB_HOST
- optimization Error log
- optimization the err log

Changes in v7:
- support new API of extcon
- support firmware standby when no dptx connection
- optimization the calculation of tu size and valid symbol

Changes in v6:
- add assigned-clocks and assigned-clock-rates
- delete the support of PIN_ASSIGN_A/B
- set the default mode to MODE_DFP_USB
- disable DP PLL at USB3 only mode
- add assigned-clocks and assigned-clock-rates
- add power-domains
- add a port struct
- select SND_SOC_HDMI_CODEC
- force reset the phy when hpd detected

Changes in v5:
- support get property from extcon
- remove PIN ASSIGN A/B support
- alphabetical order
- do not use long, use u32 or u64
- return MODE_CLOCK_HIGH when requested > actual
- Optimized Coding Style
- add a formula to get better tu size and symbol value.
- modify according to Sean Paul's comments
- fixed the fw_wait always 0

Changes in v4:
- add a #phy-cells node
- select EXTCON
- use phy framework to control the USB3 and DP function
- rename PIN_MAP_ to PIN_ASSIGN_
- add a reset no