[Intel-gfx] [PATCH] drm/dp/mst: Remove port after removing connector.

2015-08-15 Thread Daniel Vetter
On Sat, Aug 15, 2015 at 02:56:57PM +1000, Dave Airlie wrote:
> On 11 August 2015 at 17:54, Maarten Lankhorst
>  wrote:
> > The port is removed synchronously, but the connector delayed.
> > This causes a use after free which can cause a kernel BUG with
> > slug_debug=FPZU. This is fixed by freeing the port after the
> > connector.
> 
> Where is the use after free btw? I'm not sure I like delaying the port
> destruction, there should be no need to.
> 
> The connector->port pointer shouldn't be used without validation
> anywhere, and if it is that is a bug.
> 
> I'd like to reproduce this before pulling this in.

The remove function needs to lock at the connector->port to shut down the
dp mst link. Before your patch that was done _before_ the final kfree on
the port, but with your patch that's now the other way round: First we
synchronously kfree the port, then we call the driver's connector cleanup
function asynchronously. And that is very unhappy that the port is now
gone.

So perfectly ok regression fix imo to restore the ordering we had before
your patch in the cleanup code.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[pull] drm/msm: msm-next for 4.3

2015-08-15 Thread Rob Clark
Hi Dave,

Main pull req for 4.3.. main highlights:

1) includes all the drm/msm side of things for upstream kernel working
on dragonboard 410c (still some pending work on adv7533 bridge chip)
2) initial support for msm8x94 (snapdragon 810)
3) support for msm8x74v1 (in addition to existing v2 support)
4) support for dma planes on mdp5 (additional planes that cannot scale/csc)
5) more yuv format support for mdp5 (single plane vyuy/uyvy/yuyv/yvyu,
two plane nv16/nv61, and three plane yuv420/yvu420)
6) rotation support for mdp5
7) initial hdcp support
8) fixes, etc

The following changes since commit 8f9cb50789e76f3e224e8861adf650e55c747af4:

  Merge tag 'drm-amdkfd-next-fixes-2015-08-05' of
git://people.freedesktop.org/~gabbayo/linux into drm-next (2015-08-14
10:15:24 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~robclark/linux msm-next

for you to fetch changes up to d248b61f611463cca906d5663a9a0de63ade97a9:

  drm/msm/dsi: Introduce DSI configuration module (2015-08-15 18:27:29 -0400)


Archit Taneja (10):
  drm/msm: mdp4: Fix drm_framebuffer dereference crash
  drm/msm/dsi: Report PHY errors only when they really occur
  drm/msm: dsi host: add missing of_node_put()
  drm/msm: dsi host: Use device graph parsing to parse connected panel
  drm/msm: mdp4 lvds: get panel node via of graph parsing
  drm/msm/dsi: Make TE gpio optional
  drm/msm/dsi: Refer to connected device as 'device' instead of 'panel'
  drm/msm/dsi: Create a helper to check if there is a connected device
  drm/msm/dsi: Allow dsi to connect to an external bridge
  drm/msm/dsi: Modify dsi manager bridge ops to work with external bridges

Hai Li (14):
  drm/msm/dsi: Update source PLL selection in DSI PHY
  drm/msm/dsi: Rename *dual panel* to *dual DSI*
  drm/msm/dsi: Use pinctrl in DSI driver
  drm/msm/dsi: Add support for msm8x94
  drm/msm: Set different display size limitation on each target
  drm/msm/mdp5: Allocate CTL for each display interface
  drm/msm/mdp5: Allocate CTL0/1 for dual DSI single FLUSH
  drm/msm/dsi: Save/Restore PLL status across PHY reset
  drm/msm: Enable clocks during enable/disable_vblank() callbacks
  drm/msm/dsi: Specify bitmask to set source PLL
  drm/msm/dsi: Return void from msm_dsi_phy_disable()
  drm/msm/dsi: Split PHY drivers to separate files
  drm/msm/dsi: Make each PHY type compilation independent
  drm/msm/dsi: Introduce DSI configuration module

Markus Elfring (2):
  drm/msm/dsi: Delete an unnecessary check before the function
call "dsi_destroy"
  drm/msm/dsi: One function call less in dsi_init() after error detection

Rob Clark (4):
  drm/msm: fix msm_gem_prime_get_sg_table()
  drm/msm: update generated headers
  drm/msm/hdmi: standardize on lead chip for compatible names
  drm/msm: don't install plane properties on crtc

Srinivas Kandagatla (1):
  drm/msm: add calls to prepare and unprepare panel

Stephane Viau (3):
  drm/msm/hdmi: remove ->reset() from HDMI PHY
  drm/msm: Add support for msm8x94
  drm/msm/mdp5: add more YUV formats for MDP5

Uwe Kleine-König (1):
  drm/msm/dp: use flags argument of devm_gpiod_get to set direction

Wentao Xu (4):
  drm/msm: change to uninterruptible wait in atomic commit
  drm/msm/mdp5: release SMB (shared memory blocks) in various cases
  drm/msm/mdp: mark if a MDP format is YUV at definition
  drm/msm/mdp5: use 2 memory clients for YUV formats on newer mdp5

jilai wang (7):
  drm/msm/hdmi: add hdmi hdcp support (V3)
  drm/msm/mdp5: Add plane blending operation support for MDP5 (v2)
  drm/msm/mdp: Add capabilities to MDP planes (v2)
  drm/msm/mdp5: Add DMA pipe planes for MDP5
  drm/msm/mdp5: Add support for msm8x74v1
  drm/msm/mdp5: Add rotation (hflip/vflip) support to MDP5 planes (v2)
  drm/msm/mdp: Clear pending interrupt status before enable interrupt

 Documentation/devicetree/bindings/drm/msm/dsi.txt  |   41 +-
 Documentation/devicetree/bindings/drm/msm/hdmi.txt |3 +-
 drivers/gpu/drm/msm/Kconfig|   15 +
 drivers/gpu/drm/msm/Makefile   |   15 +-
 drivers/gpu/drm/msm/adreno/a2xx.xml.h  |   18 +-
 drivers/gpu/drm/msm/adreno/a3xx.xml.h  |   33 +-
 drivers/gpu/drm/msm/adreno/a4xx.xml.h  |  206 ++-
 drivers/gpu/drm/msm/adreno/adreno_common.xml.h |   18 +-
 drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h|   18 +-
 drivers/gpu/drm/msm/dsi/dsi.c  |   58 +-
 drivers/gpu/drm/msm/dsi/dsi.h  |   43 +-
 drivers/gpu/drm/msm/dsi/dsi.xml.h  |  211 ++-
 drivers/gpu/drm/msm/dsi/dsi_cfg.c  |   92 ++
 drivers/gpu/drm/msm/dsi/dsi_cfg.h  |   44 +
 drivers/gpu/drm/msm/dsi/dsi_host.c |  270 ++--
 

[Intel-gfx] [PATCH] drm/dp/mst: Remove port after removing connector.

2015-08-15 Thread Dave Airlie
On 11 August 2015 at 17:54, Maarten Lankhorst
 wrote:
> The port is removed synchronously, but the connector delayed.
> This causes a use after free which can cause a kernel BUG with
> slug_debug=FPZU. This is fixed by freeing the port after the
> connector.

Where is the use after free btw? I'm not sure I like delaying the port
destruction, there should be no need to.

The connector->port pointer shouldn't be used without validation
anywhere, and if it is that is a bug.

I'd like to reproduce this before pulling this in.

Dave.


[PATCH] drm/exynos: add cursor plane support

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

Set one of the planes for each crtc driver as a cursor plane enabled
window managers to fully work on exynos.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  9 ++---
 drivers/gpu/drm/exynos/exynos7_drm_decon.c|  8 ++--
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  3 +++
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  |  8 ++--
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 16 ++--
 drivers/gpu/drm/exynos/exynos_drm_plane.h |  3 +--
 drivers/gpu/drm/exynos/exynos_drm_vidi.c  |  9 ++---
 drivers/gpu/drm/exynos/exynos_mixer.c | 10 +++---
 8 files changed, 29 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 8d65e45..fdc04d0 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -33,7 +33,6 @@ struct decon_context {
struct exynos_drm_plane planes[WINDOWS_NR];
void __iomem*addr;
struct clk  *clks[6];
-   unsigned intdefault_win;
unsigned long   irq_flags;
int pipe;
boolsuspended;
@@ -466,7 +465,6 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
struct drm_device *drm_dev = data;
struct exynos_drm_private *priv = drm_dev->dev_private;
struct exynos_drm_plane *exynos_plane;
-   enum drm_plane_type type;
unsigned int zpos;
int ret;

@@ -474,15 +472,13 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
ctx->pipe = priv->pipe++;

for (zpos = 0; zpos < WINDOWS_NR; zpos++) {
-   type = (zpos == ctx->default_win) ? DRM_PLANE_TYPE_PRIMARY :
-   DRM_PLANE_TYPE_OVERLAY;
ret = exynos_plane_init(drm_dev, >planes[zpos],
-   1 << ctx->pipe, type, zpos);
+   1 << ctx->pipe, zpos);
if (ret)
return ret;
}

-   exynos_plane = >planes[ctx->default_win];
+   exynos_plane = >planes[DEFAULT_WIN];
ctx->crtc = exynos_drm_crtc_create(drm_dev, _plane->base,
ctx->pipe, EXYNOS_DISPLAY_TYPE_LCD,
_crtc_ops, ctx);
@@ -579,7 +575,6 @@ static int exynos5433_decon_probe(struct platform_device 
*pdev)
if (!ctx)
return -ENOMEM;

-   ctx->default_win = 0;
ctx->suspended = true;
ctx->dev = dev;
if (of_get_child_by_name(dev->of_node, "i80-if-timings"))
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 7651499..569a666 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -52,7 +52,6 @@ struct decon_context {
struct clk  *eclk;
struct clk  *vclk;
void __iomem*regs;
-   unsigned intdefault_win;
unsigned long   irq_flags;
booli80_if;
boolsuspended;
@@ -661,7 +660,6 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
struct decon_context *ctx = dev_get_drvdata(dev);
struct drm_device *drm_dev = data;
struct exynos_drm_plane *exynos_plane;
-   enum drm_plane_type type;
unsigned int zpos;
int ret;

@@ -672,15 +670,13 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
}

for (zpos = 0; zpos < WINDOWS_NR; zpos++) {
-   type = (zpos == ctx->default_win) ? DRM_PLANE_TYPE_PRIMARY :
-   DRM_PLANE_TYPE_OVERLAY;
ret = exynos_plane_init(drm_dev, >planes[zpos],
-   1 << ctx->pipe, type, zpos);
+   1 << ctx->pipe, zpos);
if (ret)
return ret;
}

-   exynos_plane = >planes[ctx->default_win];
+   exynos_plane = >planes[DEFAULT_WIN];
ctx->crtc = exynos_drm_crtc_create(drm_dev, _plane->base,
   ctx->pipe, EXYNOS_DISPLAY_TYPE_LCD,
   _crtc_ops, ctx);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 5d052235..1631024 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -22,6 +22,9 @@
 #define MAX_PLANE  5
 #define 

[PATCH 11/11] drm/exynos: Enable atomic modesetting feature

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

Now that atomic modesetting is implemented for exynos enable the
DRIVER_ATOMIC flag on the driver's features.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 241453f..0ebe04f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -439,7 +439,8 @@ static const struct file_operations exynos_drm_driver_fops 
= {
 };

 static struct drm_driver exynos_drm_driver = {
-   .driver_features= DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
+   .driver_features= DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME
+ | DRIVER_ATOMIC,
.load   = exynos_drm_load,
.unload = exynos_drm_unload,
.open   = exynos_drm_open,
-- 
2.1.0



[PATCH 10/11] drm/exynos: remove wait queue for pending page flip

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

Exynos atomic commit procedures already does this job of waiting for
pending updates to finish, that means using pending_flip_queue is
pointless now because the disable CRTC procedure will never happen
during a page_flip.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 11 +--
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |  1 -
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 049ab67..44bb30e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -35,11 +35,6 @@ static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
 {
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);

-   /* wait for the completion of page flip. */
-   if (!wait_event_timeout(exynos_crtc->pending_flip_queue,
-   (exynos_crtc->event == NULL), HZ/20))
-   exynos_crtc->event = NULL;
-
drm_crtc_vblank_off(crtc);

if (exynos_crtc->ops->disable)
@@ -144,8 +139,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct 
drm_device *drm_dev,
if (!exynos_crtc)
return ERR_PTR(-ENOMEM);

-   init_waitqueue_head(_crtc->pending_flip_queue);
-
exynos_crtc->pipe = pipe;
exynos_crtc->type = type;
exynos_crtc->ops = ops;
@@ -213,10 +206,8 @@ void exynos_drm_crtc_finish_update(struct exynos_drm_crtc 
*exynos_crtc,
wake_up(_crtc->wait_update);

spin_lock_irqsave(>dev->event_lock, flags);
-   if (exynos_crtc->event) {
+   if (exynos_crtc->event)
drm_crtc_send_vblank_event(crtc, exynos_crtc->event);
-   wake_up(_crtc->pending_flip_queue);
-   }

exynos_crtc->event = NULL;
spin_unlock_irqrestore(>dev->event_lock, flags);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index d77dca4..5d052235 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -145,7 +145,6 @@ struct exynos_drm_crtc {
struct drm_crtc base;
enum exynos_drm_output_type type;
unsigned intpipe;
-   wait_queue_head_t   pending_flip_queue;
struct drm_pending_vblank_event *event;
wait_queue_head_t   wait_update;
atomic_tpending_update;
-- 
2.1.0



[PATCH 09/11] drm/exynos: wait all planes updates to finish

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

Add infrastructure to wait for all planes updates to finish by using
an atomic_t variable to track how many pending updates we are waiting
plus a wait_queue for the wait part.

It also changes vblank behaviour and keeps it enabled for all types
of updates

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 18 +
 drivers/gpu/drm/exynos/exynos_drm_crtc.h |  1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c  | 44 +++-
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |  4 +++
 4 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 7a2ad3e..049ab67 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -74,10 +74,7 @@ static void exynos_crtc_atomic_begin(struct drm_crtc *crtc)
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
struct drm_plane *plane;

-   if (crtc->state->event) {
-   WARN_ON(drm_crtc_vblank_get(crtc) != 0);
-   exynos_crtc->event = crtc->state->event;
-   }
+   exynos_crtc->event = crtc->state->event;

drm_atomic_crtc_for_each_plane(plane, crtc) {
struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
@@ -154,6 +151,8 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct 
drm_device *drm_dev,
exynos_crtc->ops = ops;
exynos_crtc->ctx = ctx;

+   init_waitqueue_head(_crtc->wait_update);
+
crtc = _crtc->base;

private->crtc[pipe] = crtc;
@@ -195,6 +194,13 @@ void exynos_drm_crtc_disable_vblank(struct drm_device 
*dev, int pipe)
exynos_crtc->ops->disable_vblank(exynos_crtc);
 }

+void exynos_drm_crtc_wait_pending_update(struct exynos_drm_crtc *exynos_crtc)
+{
+   wait_event_timeout(exynos_crtc->wait_update,
+  (atomic_read(_crtc->pending_update) == 0),
+  msecs_to_jiffies(50));
+}
+
 void exynos_drm_crtc_finish_update(struct exynos_drm_crtc *exynos_crtc,
struct exynos_drm_plane *exynos_plane)
 {
@@ -203,10 +209,12 @@ void exynos_drm_crtc_finish_update(struct exynos_drm_crtc 
*exynos_crtc,

exynos_plane->pending_fb = NULL;

+   if (atomic_dec_and_test(_crtc->pending_update))
+   wake_up(_crtc->wait_update);
+
spin_lock_irqsave(>dev->event_lock, flags);
if (exynos_crtc->event) {
drm_crtc_send_vblank_event(crtc, exynos_crtc->event);
-   drm_crtc_vblank_put(crtc);
wake_up(_crtc->pending_flip_queue);
}

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 8bedfde..f87d4ab 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -25,6 +25,7 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct 
drm_device *drm_dev,
void *context);
 int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe);
 void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe);
+void exynos_drm_crtc_wait_pending_update(struct exynos_drm_crtc *exynos_crtc);
 void exynos_drm_crtc_finish_update(struct exynos_drm_crtc *exynos_crtc,
   struct exynos_drm_plane *exynos_plane);
 void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index a4937b5..241453f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -46,11 +46,37 @@ struct exynos_atomic_commit {
u32 crtcs;
 };

+static void exynos_atomic_wait_for_commit(struct drm_atomic_state *state)
+{
+   struct drm_crtc_state *crtc_state;
+   struct drm_crtc *crtc;
+   int i, ret;
+
+   for_each_crtc_in_state(state, crtc, crtc_state, i) {
+   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+
+   if (!crtc->state->enable)
+   continue;
+
+   ret = drm_crtc_vblank_get(crtc);
+   if (ret)
+   continue;
+
+   exynos_drm_crtc_wait_pending_update(exynos_crtc);
+   drm_crtc_vblank_put(crtc);
+   }
+}
+
 static void exynos_atomic_commit_complete(struct exynos_atomic_commit *commit)
 {
struct drm_device *dev = commit->dev;
struct exynos_drm_private *priv = dev->dev_private;
struct drm_atomic_state *state = commit->state;
+   struct drm_plane *plane;
+   struct drm_crtc *crtc;
+   struct drm_plane_state *plane_state;
+   struct drm_crtc_state *crtc_state;
+   int i;

drm_atomic_helper_commit_modeset_disables(dev, state);

@@ -64,9 +90,25 @@ static void 

[PATCH 08/11] drm/exynos: add atomic asynchronous commit

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

The atomic modesetting interfaces supports async commits that should be
implemented by the drivers. If drm core requests an async commit
exynos_atomic_commit() will now schedule a work task to run the update later.

It also serializes commits that needs to run on the same crtc, putting the
following commit to wait until the current one is finished.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 113 
 drivers/gpu/drm/exynos/exynos_drm_drv.h |  11 
 drivers/gpu/drm/exynos/exynos_drm_fb.c  |  35 --
 3 files changed, 124 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index e8db234..a4937b5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -13,6 +13,8 @@

 #include 
 #include 
+#include 
+#include 
 #include 

 #include 
@@ -37,6 +39,56 @@
 #define DRIVER_MAJOR   1
 #define DRIVER_MINOR   0

+struct exynos_atomic_commit {
+   struct work_struct  work;
+   struct drm_device   *dev;
+   struct drm_atomic_state *state;
+   u32 crtcs;
+};
+
+static void exynos_atomic_commit_complete(struct exynos_atomic_commit *commit)
+{
+   struct drm_device *dev = commit->dev;
+   struct exynos_drm_private *priv = dev->dev_private;
+   struct drm_atomic_state *state = commit->state;
+
+   drm_atomic_helper_commit_modeset_disables(dev, state);
+
+   drm_atomic_helper_commit_modeset_enables(dev, state);
+
+   /*
+* Exynos can't update planes with CRTCs and encoders disabled,
+* its updates routines, specially for FIMD, requires the clocks
+* to be enabled. So it is necessary to handle the modeset operations
+* *before* the commit_planes() step, this way it will always
+* have the relevant clocks enabled to perform the update.
+*/
+
+   drm_atomic_helper_commit_planes(dev, state);
+
+   drm_atomic_helper_wait_for_vblanks(dev, state);
+
+   drm_atomic_helper_cleanup_planes(dev, state);
+
+   drm_atomic_state_free(state);
+
+   spin_lock(>lock);
+   priv->pending &= ~commit->crtcs;
+   spin_unlock(>lock);
+
+   wake_up_all(>wait);
+
+   kfree(commit);
+}
+
+static void exynos_drm_atomic_work(struct work_struct *work)
+{
+   struct exynos_atomic_commit *commit = container_of(work,
+   struct exynos_atomic_commit, work);
+
+   exynos_atomic_commit_complete(commit);
+}
+
 static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
 {
struct exynos_drm_private *private;
@@ -48,6 +100,9 @@ static int exynos_drm_load(struct drm_device *dev, unsigned 
long flags)
if (!private)
return -ENOMEM;

+   init_waitqueue_head(>wait);
+   spin_lock_init(>lock);
+
dev_set_drvdata(dev->dev, dev);
dev->dev_private = (void *)private;

@@ -150,6 +205,64 @@ static int exynos_drm_unload(struct drm_device *dev)
return 0;
 }

+static int commit_is_pending(struct exynos_drm_private *priv, u32 crtcs)
+{
+   bool pending;
+
+   spin_lock(>lock);
+   pending = priv->pending & crtcs;
+   spin_unlock(>lock);
+
+   return pending;
+}
+
+int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state 
*state,
+bool async)
+{
+   struct exynos_drm_private *priv = dev->dev_private;
+   struct exynos_atomic_commit *commit;
+   int i, ret;
+
+   commit = kzalloc(sizeof(*commit), GFP_KERNEL);
+   if (!commit)
+   return -ENOMEM;
+
+   ret = drm_atomic_helper_prepare_planes(dev, state);
+   if (ret) {
+   kfree(commit);
+   return ret;
+   }
+
+   /* This is the point of no return */
+
+   INIT_WORK(>work, exynos_drm_atomic_work);
+   commit->dev = dev;
+   commit->state = state;
+
+   /* Wait until all affected CRTCs have completed previous commits and
+* mark them as pending.
+*/
+   for (i = 0; i < dev->mode_config.num_crtc; ++i) {
+   if (state->crtcs[i])
+   commit->crtcs |= 1 << drm_crtc_index(state->crtcs[i]);
+   }
+
+   wait_event(priv->wait, !commit_is_pending(priv, commit->crtcs));
+
+   spin_lock(>lock);
+   priv->pending |= commit->crtcs;
+   spin_unlock(>lock);
+
+   drm_atomic_helper_swap_state(dev, state);
+
+   if (async)
+   schedule_work(>work);
+   else
+   exynos_atomic_commit_complete(commit);
+
+   return 0;
+}
+
 static int exynos_drm_suspend(struct drm_device *dev, pm_message_t state)
 {
struct drm_connector *connector;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index de10cd1..406b278 100644
--- 

[PATCH 07/11] drm/exynos: fimd: only finish update if START == START_S

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

fimd_update_plane() programs BUF_START[win] and during the update
BUF_START[win] is copied to BUF_START_S[win] (its shadow register)
and starts scanning out, then it raises a irq.

The fimd_irq_handler, in the case we have a pending_fb, will check
the fb value was copied to START_S register and finish the update
in case of success.

Based on patch from Daniel Kurtz 

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index d41aa6a..c87b791 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -59,6 +59,7 @@
 #define VIDWnALPHA1(win)   (VIDW_ALPHA + 0x04 + (win) * 8)

 #define VIDWx_BUF_START(win, buf)  (VIDW_BUF_START(buf) + (win) * 8)
+#define VIDWx_BUF_START_S(win, buf)(VIDW_BUF_START_S(buf) + (win) * 8)
 #define VIDWx_BUF_END(win, buf)(VIDW_BUF_END(buf) + (win) * 8)
 #define VIDWx_BUF_SIZE(win, buf)   (VIDW_BUF_SIZE(buf) + (win) * 4)

@@ -895,7 +896,7 @@ static const struct exynos_drm_crtc_ops fimd_crtc_ops = {
 static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
 {
struct fimd_context *ctx = (struct fimd_context *)dev_id;
-   u32 val, clear_bit;
+   u32 val, clear_bit, start, start_s;
int win;

val = readl(ctx->regs + VIDINTCON1);
@@ -917,7 +918,10 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
if (!plane->pending_fb)
continue;

-   exynos_drm_crtc_finish_update(ctx->crtc, plane);
+   start = readl(ctx->regs + VIDWx_BUF_START(win, 0));
+   start_s = readl(ctx->regs + VIDWx_BUF_START_S(win, 0));
+   if (start == start_s)
+   exynos_drm_crtc_finish_update(ctx->crtc, plane);
}

if (ctx->i80_if) {
-- 
2.1.0



[PATCH 06/11] drm/exynos: add macro to get the address of START_S reg

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

This macro is need to get the value of the START shadow register, that
will tell if an framebuffer is currently displayed on the screen or not.

Signed-off-by: Gustavo Padovan 
---
 include/video/samsung_fimd.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/video/samsung_fimd.h b/include/video/samsung_fimd.h
index 0530e5a..d8fc96e 100644
--- a/include/video/samsung_fimd.h
+++ b/include/video/samsung_fimd.h
@@ -296,6 +296,7 @@

 /* Video buffer addresses */
 #define VIDW_BUF_START(_buff)  (0xA0 + ((_buff) * 8))
+#define VIDW_BUF_START_S(_buff)(0x40A0 + ((_buff) * 8))
 #define VIDW_BUF_START1(_buff) (0xA4 + ((_buff) * 8))
 #define VIDW_BUF_END(_buff)(0xD0 + ((_buff) * 8))
 #define VIDW_BUF_END1(_buff)   (0xD4 + ((_buff) * 8))
-- 
2.1.0



[PATCH 05/11] drm/exynos: check for pending fb before finish update

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

The current code was ignoring the end of update for all overlay planes,
caring only for the primary plane update in case of pageflip.

This change adds a change to start to check for pending updates for all
planes through exynos_plane->pending_fb. At the start of plane update the
pending_fb is set with the fb to be shown on the screen. Then only when to
fb is already presented in the screen we set pending_fb to NULL to
signal that the update was finished.

Signed-off-by: Gustavo Padovan 

fixup! drm/exynos: check for pending fb before finish update
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 10 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c| 10 +-
 drivers/gpu/drm/exynos/exynos_drm_crtc.c  |  7 ---
 drivers/gpu/drm/exynos/exynos_drm_crtc.h  |  3 ++-
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  1 +
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  | 10 +-
 drivers/gpu/drm/exynos/exynos_drm_plane.c |  2 ++
 drivers/gpu/drm/exynos/exynos_drm_vidi.c  | 10 +-
 drivers/gpu/drm/exynos/exynos_mixer.c | 10 +-
 9 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 484e312..8d65e45 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -542,13 +542,21 @@ static irqreturn_t decon_lcd_sys_irq_handler(int irq, 
void *dev_id)
 {
struct decon_context *ctx = dev_id;
u32 val;
+   int win;

if (!test_bit(BIT_CLKS_ENABLED, >enabled))
goto out;

val = readl(ctx->addr + DECON_VIDINTCON1);
if (val & VIDINTCON1_INTFRMDONEPEND) {
-   exynos_drm_crtc_finish_pageflip(ctx->crtc);
+   for (win = 0 ; win < WINDOWS_NR ; win++) {
+   struct exynos_drm_plane *plane = >planes[win];
+
+   if (!plane->pending_fb)
+   continue;
+
+   exynos_drm_crtc_finish_update(ctx->crtc, plane);
+   }

/* clear */
writel(VIDINTCON1_INTFRMDONEPEND,
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 0792654..7651499 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -623,6 +623,7 @@ static irqreturn_t decon_irq_handler(int irq, void *dev_id)
 {
struct decon_context *ctx = (struct decon_context *)dev_id;
u32 val, clear_bit;
+   int win;

val = readl(ctx->regs + VIDINTCON1);

@@ -636,7 +637,14 @@ static irqreturn_t decon_irq_handler(int irq, void *dev_id)

if (!ctx->i80_if) {
drm_crtc_handle_vblank(>crtc->base);
-   exynos_drm_crtc_finish_pageflip(ctx->crtc);
+   for (win = 0 ; win < WINDOWS_NR ; win++) {
+   struct exynos_drm_plane *plane = >planes[win];
+
+   if (!plane->pending_fb)
+   continue;
+
+   exynos_drm_crtc_finish_update(ctx->crtc, plane);
+   }

/* set wait vsync event to zero and wake up queue. */
if (atomic_read(>wait_vsync_event)) {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 3a89fc9..7a2ad3e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -195,18 +195,19 @@ void exynos_drm_crtc_disable_vblank(struct drm_device 
*dev, int pipe)
exynos_crtc->ops->disable_vblank(exynos_crtc);
 }

-void exynos_drm_crtc_finish_pageflip(struct exynos_drm_crtc *exynos_crtc)
+void exynos_drm_crtc_finish_update(struct exynos_drm_crtc *exynos_crtc,
+   struct exynos_drm_plane *exynos_plane)
 {
struct drm_crtc *crtc = _crtc->base;
unsigned long flags;

+   exynos_plane->pending_fb = NULL;
+
spin_lock_irqsave(>dev->event_lock, flags);
if (exynos_crtc->event) {
-
drm_crtc_send_vblank_event(crtc, exynos_crtc->event);
drm_crtc_vblank_put(crtc);
wake_up(_crtc->pending_flip_queue);
-
}

exynos_crtc->event = NULL;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 9e7027d..8bedfde 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -25,7 +25,8 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct 
drm_device *drm_dev,
void *context);
 int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe);
 void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe);
-void exynos_drm_crtc_finish_pageflip(struct exynos_drm_crtc 

[PATCH 04/11] drm/exynos: fimd: move window protect code to prepare/cleanup_plane

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

Only set/clear the update bit in the CRTC's .atomic_begin()/flush()
so all planes are really committed at the same time.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c | 57 +++-
 1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 30c1409..48d4fbe 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -591,6 +591,16 @@ static void fimd_shadow_protect_win(struct fimd_context 
*ctx,
 {
u32 reg, bits, val;

+   /*
+* SHADOWCON/PRTCON register is used for enabling timing.
+*
+* for example, once only width value of a register is set,
+* if the dma is started then fimd hardware could malfunction so
+* with protect window setting, the register fields with prefix '_F'
+* wouldn't be updated at vsync also but updated once unprotect window
+* is set.
+*/
+
if (ctx->driver_data->has_shadowcon) {
reg = SHADOWCON;
bits = SHADOWCON_WINx_PROTECT(win);
@@ -607,6 +617,28 @@ static void fimd_shadow_protect_win(struct fimd_context 
*ctx,
writel(val, ctx->regs + reg);
 }

+static void fimd_prepare_plane(struct exynos_drm_crtc *crtc,
+  struct exynos_drm_plane *plane)
+{
+   struct fimd_context *ctx = crtc->ctx;
+
+   if (ctx->suspended)
+   return;
+
+   fimd_shadow_protect_win(ctx, plane->zpos, true);
+}
+
+static void fimd_cleanup_plane(struct exynos_drm_crtc *crtc,
+  struct exynos_drm_plane *plane)
+{
+   struct fimd_context *ctx = crtc->ctx;
+
+   if (ctx->suspended)
+   return;
+
+   fimd_shadow_protect_win(ctx, plane->zpos, false);
+}
+
 static void fimd_update_plane(struct exynos_drm_crtc *crtc,
  struct exynos_drm_plane *plane)
 {
@@ -622,20 +654,6 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
if (ctx->suspended)
return;

-   /*
-* SHADOWCON/PRTCON register is used for enabling timing.
-*
-* for example, once only width value of a register is set,
-* if the dma is started then fimd hardware could malfunction so
-* with protect window setting, the register fields with prefix '_F'
-* wouldn't be updated at vsync also but updated once unprotect window
-* is set.
-*/
-
-   /* protect windows */
-   fimd_shadow_protect_win(ctx, win, true);
-
-
offset = plane->src_x * bpp;
offset += plane->src_y * pitch;

@@ -707,9 +725,6 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
if (ctx->driver_data->has_shadowcon)
fimd_enable_shadow_channel_path(ctx, win, true);

-   /* Enable DMA channel and unprotect windows */
-   fimd_shadow_protect_win(ctx, win, false);
-
if (ctx->i80_if)
atomic_set(>win_updated, 1);
 }
@@ -723,16 +738,10 @@ static void fimd_disable_plane(struct exynos_drm_crtc 
*crtc,
if (ctx->suspended)
return;

-   /* protect windows */
-   fimd_shadow_protect_win(ctx, win, true);
-
fimd_enable_video_output(ctx, win, false);

if (ctx->driver_data->has_shadowcon)
fimd_enable_shadow_channel_path(ctx, win, false);
-
-   /* unprotect windows */
-   fimd_shadow_protect_win(ctx, win, false);
 }

 static void fimd_enable(struct exynos_drm_crtc *crtc)
@@ -875,8 +884,10 @@ static const struct exynos_drm_crtc_ops fimd_crtc_ops = {
.enable_vblank = fimd_enable_vblank,
.disable_vblank = fimd_disable_vblank,
.wait_for_vblank = fimd_wait_for_vblank,
+   .prepare_plane = fimd_prepare_plane,
.update_plane = fimd_update_plane,
.disable_plane = fimd_disable_plane,
+   .cleanup_plane = fimd_cleanup_plane,
.te_handler = fimd_te_handler,
.clock_enable = fimd_dp_clock_enable,
 };
-- 
2.1.0



[PATCH 03/11] drm/exynos: add prepare and cleanup phases for planes

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

.prepare_plane() and .cleanup_plane() allows to perform extra operations
before and after the update of planes. For FIMD for example this will
be used to enable disable the shadow protection bit.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 19 +++
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |  6 ++
 2 files changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 5a19e16..3a89fc9 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -72,15 +72,34 @@ exynos_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
 static void exynos_crtc_atomic_begin(struct drm_crtc *crtc)
 {
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+   struct drm_plane *plane;

if (crtc->state->event) {
WARN_ON(drm_crtc_vblank_get(crtc) != 0);
exynos_crtc->event = crtc->state->event;
}
+
+   drm_atomic_crtc_for_each_plane(plane, crtc) {
+   struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
+
+   if (exynos_crtc->ops->prepare_plane)
+   exynos_crtc->ops->prepare_plane(exynos_crtc,
+   exynos_plane);
+   }
 }

 static void exynos_crtc_atomic_flush(struct drm_crtc *crtc)
 {
+   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+   struct drm_plane *plane;
+
+   drm_atomic_crtc_for_each_plane(plane, crtc) {
+   struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
+
+   if (exynos_crtc->ops->cleanup_plane)
+   exynos_crtc->ops->cleanup_plane(exynos_crtc,
+   exynos_plane);
+   }
 }

 static struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index a993aac..9f2b5c9 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -87,6 +87,8 @@ struct exynos_drm_plane {
  * @disable_vblank: specific driver callback for disabling vblank interrupt.
  * @wait_for_vblank: wait for vblank interrupt to make sure that
  * hardware overlay is updated.
+ * @prepare_plane: prepare a window to receive a update
+ * @cleanup_plane: mark the end of a window update
  * @update_plane: apply hardware specific overlay data to registers.
  * @disable_plane: disable hardware specific overlay.
  * @te_handler: trigger to transfer video image at the tearing effect
@@ -107,10 +109,14 @@ struct exynos_drm_crtc_ops {
int (*enable_vblank)(struct exynos_drm_crtc *crtc);
void (*disable_vblank)(struct exynos_drm_crtc *crtc);
void (*wait_for_vblank)(struct exynos_drm_crtc *crtc);
+   void (*prepare_plane)(struct exynos_drm_crtc *crtc,
+ struct exynos_drm_plane *plane);
void (*update_plane)(struct exynos_drm_crtc *crtc,
 struct exynos_drm_plane *plane);
void (*disable_plane)(struct exynos_drm_crtc *crtc,
  struct exynos_drm_plane *plane);
+   void (*cleanup_plane)(struct exynos_drm_crtc *crtc,
+ struct exynos_drm_plane *plane);
void (*te_handler)(struct exynos_drm_crtc *crtc);
void (*clock_enable)(struct exynos_drm_crtc *crtc, bool enable);
 };
-- 
2.1.0



[PATCH 02/11] drm/exynos: fimd: unify call to exynos_drm_crtc_finish_pageflip()

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

Unify handling of finished plane update to prepare for a following patch
that will check for the START and START_S regs to really make sure that
the plane was updated.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 5def6bc..30c1409 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -896,15 +896,15 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
if (ctx->pipe < 0 || !ctx->drm_dev)
goto out;

-   if (ctx->i80_if) {
-   exynos_drm_crtc_finish_pageflip(ctx->crtc);
+   if (!ctx->i80_if)
+   drm_crtc_handle_vblank(>crtc->base);
+
+   exynos_drm_crtc_finish_pageflip(ctx->crtc);

+   if (ctx->i80_if) {
/* Exits triggering mode */
atomic_set(>triggering, 0);
} else {
-   drm_crtc_handle_vblank(>crtc->base);
-   exynos_drm_crtc_finish_pageflip(ctx->crtc);
-
/* set wait vsync event to zero and wake up queue. */
if (atomic_read(>wait_vsync_event)) {
atomic_set(>wait_vsync_event, 0);
-- 
2.1.0



[PATCH 01/11] drm/exynos: don't track enabled state at exynos_crtc

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

struct drm_crtc already stores the enabled state of the crtc
thus we don't need to replicate enabled in exynos_drm_crtc.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 16 
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |  1 -
 2 files changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index b9b0e9c..5a19e16 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -25,14 +25,9 @@ static void exynos_drm_crtc_enable(struct drm_crtc *crtc)
 {
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);

-   if (exynos_crtc->enabled)
-   return;
-
if (exynos_crtc->ops->enable)
exynos_crtc->ops->enable(exynos_crtc);

-   exynos_crtc->enabled = true;
-
drm_crtc_vblank_on(crtc);
 }

@@ -40,9 +35,6 @@ static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
 {
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);

-   if (!exynos_crtc->enabled)
-   return;
-
/* wait for the completion of page flip. */
if (!wait_event_timeout(exynos_crtc->pending_flip_queue,
(exynos_crtc->event == NULL), HZ/20))
@@ -52,8 +44,6 @@ static void exynos_drm_crtc_disable(struct drm_crtc *crtc)

if (exynos_crtc->ops->disable)
exynos_crtc->ops->disable(exynos_crtc);
-
-   exynos_crtc->enabled = false;
 }

 static bool
@@ -170,9 +160,6 @@ int exynos_drm_crtc_enable_vblank(struct drm_device *dev, 
int pipe)
struct exynos_drm_crtc *exynos_crtc =
to_exynos_crtc(private->crtc[pipe]);

-   if (!exynos_crtc->enabled)
-   return -EPERM;
-
if (exynos_crtc->ops->enable_vblank)
return exynos_crtc->ops->enable_vblank(exynos_crtc);

@@ -185,9 +172,6 @@ void exynos_drm_crtc_disable_vblank(struct drm_device *dev, 
int pipe)
struct exynos_drm_crtc *exynos_crtc =
to_exynos_crtc(private->crtc[pipe]);

-   if (!exynos_crtc->enabled)
-   return;
-
if (exynos_crtc->ops->disable_vblank)
exynos_crtc->ops->disable_vblank(exynos_crtc);
 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 6b8a30f..a993aac 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -136,7 +136,6 @@ struct exynos_drm_crtc {
struct drm_crtc base;
enum exynos_drm_output_type type;
unsigned intpipe;
-   boolenabled;
wait_queue_head_t   pending_flip_queue;
struct drm_pending_vblank_event *event;
const struct exynos_drm_crtc_ops*ops;
-- 
2.1.0



[PATCH 00/11] drm/exynos: improve atomic modesetting

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

Hi,

This patchset adds a couple of changes to improve atomic modesetting:

 * add check for the START shadow register for FIMD to only finish the update
 when the screen was actually updated.
 * add asynchronous atomic commit, so now page flips can be run asynchronously.
 It also add infrastructure to serialize commits for the same CRTC and wait all
 plane updates to finish.
 * enable the DRIVER_ATOMIC feature to enable userspace to use atomic IOCTL with
 exynos.

Please review.

Gustavo

---
Gustavo Padovan (11):
  drm/exynos: don't track enabled state at exynos_crtc
  drm/exynos: fimd: unify call to exynos_drm_crtc_finish_pageflip()
  drm/exynos: add prepare and cleanup phases for planes
  drm/exynos: fimd: move window protect code to prepare/cleanup_plane
  drm/exynos: check for pending fb before finish update
  drm/exynos: add macro to get the address of START_S reg
  drm/exynos: fimd: only finish update if START == START_S
  drm/exynos: add atomic asynchronous commit
  drm/exynos: wait all planes updates to finish
  drm/exynos: remove wait queue for pending page flip
  drm/exynos: Enable atomic modesetting feature

 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  10 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c|  10 +-
 drivers/gpu/drm/exynos/exynos_drm_crtc.c  |  69 +--
 drivers/gpu/drm/exynos/exynos_drm_crtc.h  |   4 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.c   | 158 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  24 +++-
 drivers/gpu/drm/exynos/exynos_drm_fb.c|  35 --
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  |  81 -
 drivers/gpu/drm/exynos/exynos_drm_plane.c |   2 +
 drivers/gpu/drm/exynos/exynos_drm_vidi.c  |  10 +-
 drivers/gpu/drm/exynos/exynos_mixer.c |  10 +-
 include/video/samsung_fimd.h  |   1 +
 12 files changed, 309 insertions(+), 105 deletions(-)

-- 
2.1.0



[Bug 91641] white cursor with planetary annihilation

2015-08-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91641

--- Comment #6 from kdj0c at djinvi.net ---
Created attachment 117702
  --> https://bugs.freedesktop.org/attachment.cgi?id=117702=edit
original cursor from PA

this png has white transparent pixels, which are not transparent with xorg.

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


[Bug 89155] Dual monitor setup does not initialize

2015-08-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=89155

--- Comment #5 from Adam Reichold  ---
I had some more time to test this (now on kernel 4.1.4 and X server 1.17.2) and
have made two hopefully useful observations:

* The Catalyst driver (version 15.7) is always able to initialize the setup
even though VGA-connected monitor seems to always "flicker" two times before
reaching the final mode.

* I have found a somewhat reliable workaround to use with the free driver: By
adding

xrandr --output VGA-0 --off

before

xrandr \
--output VGA-0 --preferred --primary \
--output DVI-0 --preferred --rotate left --right-of VGA-0

to my .xinitrc, the system will properly initialize both displays even though
the first command seems to take around two seconds to complete.

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


[Bug 91641] white cursor with planetary annihilation

2015-08-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91641

--- Comment #5 from kdj0c at djinvi.net ---
I found a good workaround. the issue is with cursor.png.
I edited the cursor.png with gimp, and paint the "transparent square" with
black and then save with "save color of transparent pixel" checked and now it
works !

attached the modified cursor.png

just copy it to SteamApps/common/Planetary
Annihilation/media/ui/main/game/live_game/img/cursors/cursor.png and voila

so for some reason mesa/xcursor or radeonsi think transparent pixels with white
color are not transparent. (red are partialy transparent, and black are
completely transparent).

I attached the two cursor.png file, so it can be tested/reproduced easily.

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


[Bug 91641] white cursor with planetary annihilation

2015-08-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91641

--- Comment #4 from kdj0c at djinvi.net ---
Created attachment 117701
  --> https://bugs.freedesktop.org/attachment.cgi?id=117701=edit
cursor fixed

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


[Bug 102931] New: Radeon : EDID Reading Incorrectly

2015-08-15 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=102931

Bug ID: 102931
   Summary: Radeon : EDID Reading Incorrectly
   Product: Drivers
   Version: 2.5
Kernel Version: 4.1.5
  Hardware: All
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: Video(DRI - non Intel)
  Assignee: drivers_video-dri at kernel-bugs.osdl.org
  Reporter: contrib at kliznoe.com
Regression: No

When running get-edid | parse-edid with i2c-dev module loaded, It doesn't read
my monitor correctly. The EDID reads fine with Windows and xrandr.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[Bug 53118] Rendering error in unigine heaven when GL_ARB_shader_bit_encoding is used.

2015-08-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=53118

--- Comment #2 from Benjamin Bellec  ---
Can you retry with an up to date Mesa ?
I guess it's now fixed.

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


[PATCH v2 11/11] drm/exynos: remove struct exynos_drm_encoder layer

2015-08-15 Thread Gustavo Padovan
Hi Inki,

2015-08-15 Inki Dae :

> 2015-08-13 0:54 GMT+09:00 Gustavo Padovan :
> > 2015-08-12 Gustavo Padovan :
> >
> >> Hi Inki,
> >>
> >> 2015-08-11 Inki Dae :
> >>
> >> > On 2015년 08월 11일 09:38, Gustavo Padovan wrote:
> >> > > Hi Inki,
> >> > >
> >> > > 2015-08-07 Inki Dae :
> >> > >
> >> > >> Hi Gustavo,
> >> > >>
> >> > >> On 2015년 08월 06일 22:31, Gustavo Padovan wrote:
> >> > >>> From: Gustavo Padovan 
> >> > >>>
> >> > >>> struct exynos_drm_encoder was justing wrapping struct drm_encoder, 
> >> > >>> it had
> >> > >>> only a drm_encoder member and the internal exynos_drm_encoders ops 
> >> > >>> that
> >> > >>> was directly mapped to the drm_encoder helper funcs.
> >> > >>>
> >> > >>> So now exynos DRM uses struct drm_encoder directly, this removes
> >> > >>> completely the struct exynos_drm_encoder.
> >> > >>>
> >> > >>
> >> > >> Trats2 board, which uses Exynos4412 Soc, doesn't work after this patch
> >> > >> is applied. Below is the booting logs,
> >> > >> [1.171318] console [ttySAC2] enabled
> >> > >> [1.175522] 1383.serial: ttySAC3 at MMIO 0x1383 (irq = 60,
> >> > >> base_baud = 0) is a S3C6400/10
> >> > >> [1.185545] [drm] Initialized drm 1.1.0 20060810
> >> > >> [1.194104] exynos-drm exynos-drm: bound 11c0.fimd (ops
> >> > >> fimd_component_ops)
> >> > >> [1.200352] exynos-drm exynos-drm: bound 11c8.dsi (ops
> >> > >> exynos_dsi_component_ops)
> >> > >> [1.207688] [drm] Supports vblank timestamp caching Rev 2 
> >> > >> (21.10.2013).
> >> > >> [1.214313] [drm] No driver support for vblank timestamp query.
> >> > >> [1.220218] [drm] Initialized exynos 1.0.0 20110530 on minor 0
> >> > >>
> >> > >> Booting is locked up here. This patch looks good to me so I tried to
> >> > >> find why locked up and I found the booting is locked up as soon as
> >> > >> console_lock function is called. Can you and other guys look into this
> >> > >> issue?
> >> > >
> >> > > I've realized that I left a fix for patch 01 behind, it could be the
> >> > > cause of this issue. I've just resent this patch with the added v2 fix
> >> > > up.
> >> >
> >> > With above change, still locked up. So your updated patch doesn't
> >> > resolve this issue.
> >> >
> >> > Anyway, I tested it with fbdev emulation relevant patch series[1] and
> >> > the booting was ok with disabling fbdev emulation as Daniel commented.
> >> > However, I think the booting should also be ok with fbdev emulation so I
> >> > don't want for your last patch to be merged to mainline until the issue
> >> > is resolved.
> >>
> >> I've tried to reproduce your issue with these patches on a odroid-x2
> >> (exynos4412) but it seems to work fine for me with fbdev emulation
> >> enabled. In snow and peach-pi it also works fine. We would need
> >> to debug better on your side to figure out what is breaking for you.
> >
> > Can you please git bisect this? So we can figure out which commit is
> > causing the issue. That would be great.
> 
> I already commented above, your last patch - 11/11. Without 11/11, it
> worked well. Did you test odroid-x2 with LVDS based Display panel? If
> so, it's not different because I tested it with Trats2 board with
> MIPI-DSI + Display panel. AFAIK, Odroid-x2 board doesn't support
> MIPI-DSI panel. I will have a pull request soon without 11/11. After
> that, I think we could find and resolve the issue later.

Ah, I thougth your talking about whole patchset! I think I figured out
what was happend the .mode_fixup() and .mode_set() helpers for the DSI
drm_encoder was not set and leading to a null pointer at some pointer.
That is problably what you were experiencing. Could you please try the
new version of patch 11/11 that I've just sent to the mailing list?
And thanks for merging these patches!

Gustavo


[PATCH -v3 11/11] drm/exynos: remove struct exynos_drm_encoder layer

2015-08-15 Thread Gustavo Padovan
From: Gustavo Padovan 

struct exynos_drm_encoder was justing wrapping struct drm_encoder, it had
only a drm_encoder member and the internal exynos_drm_encoders ops that
was directly mapped to the drm_encoder helper funcs.

So now exynos DRM uses struct drm_encoder directly, this removes
completely the struct exynos_drm_encoder.

v2: add empty .mode_fixup() and .mode_set() to DSI and DPI to avoid null
pointer.

Signed-off-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/Makefile |   7 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c  |   2 +-
 drivers/gpu/drm/exynos/exynos_dp_core.c |  68 --
 drivers/gpu/drm/exynos/exynos_dp_core.h |   2 +-
 drivers/gpu/drm/exynos/exynos_drm_core.c|   1 -
 drivers/gpu/drm/exynos/exynos_drm_crtc.c|   1 -
 drivers/gpu/drm/exynos/exynos_drm_dpi.c |  66 +++--
 drivers/gpu/drm/exynos/exynos_drm_drv.c |   1 -
 drivers/gpu/drm/exynos/exynos_drm_drv.h |  47 ++---
 drivers/gpu/drm/exynos/exynos_drm_dsi.c |  88 +--
 drivers/gpu/drm/exynos/exynos_drm_encoder.c | 105 
 drivers/gpu/drm/exynos/exynos_drm_encoder.h |  22 --
 drivers/gpu/drm/exynos/exynos_drm_fimd.c|   2 +-
 drivers/gpu/drm/exynos/exynos_drm_vidi.c|  71 ++-
 drivers/gpu/drm/exynos/exynos_hdmi.c|  85 +-
 15 files changed, 259 insertions(+), 309 deletions(-)
 delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_encoder.c
 delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_encoder.h

diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 7de0b10..61c2906 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -3,10 +3,9 @@
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

 ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/exynos
-exynosdrm-y := exynos_drm_drv.o exynos_drm_encoder.o \
-   exynos_drm_crtc.o exynos_drm_fbdev.o exynos_drm_fb.o \
-   exynos_drm_buf.o exynos_drm_gem.o exynos_drm_core.o \
-   exynos_drm_plane.o exynos_drm_dmabuf.o
+exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fbdev.o \
+   exynos_drm_fb.o exynos_drm_buf.o exynos_drm_gem.o \
+   exynos_drm_core.o exynos_drm_plane.o exynos_drm_dmabuf.o

 exynosdrm-$(CONFIG_DRM_EXYNOS_IOMMU) += exynos_drm_iommu.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD)+= exynos_drm_fimd.o
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index e1a2ce7..0792654 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -61,7 +61,7 @@ struct decon_context {
atomic_twait_vsync_event;

struct exynos_drm_panel_info panel;
-   struct exynos_drm_encoder *encoder;
+   struct drm_encoder *encoder;
 };

 static const struct of_device_id decon_driver_dt_match[] = {
diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c 
b/drivers/gpu/drm/exynos/exynos_dp_core.c
index 67c5cd1..d66ade0 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.c
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
@@ -32,18 +32,18 @@
 #include 

 #include "exynos_dp_core.h"
-#include "exynos_drm_encoder.h"
+#include "exynos_drm_crtc.h"

 #define ctx_from_connector(c)  container_of(c, struct exynos_dp_device, \
connector)

 static inline struct exynos_drm_crtc *dp_to_crtc(struct exynos_dp_device *dp)
 {
-   return to_exynos_crtc(dp->encoder.base.crtc);
+   return to_exynos_crtc(dp->encoder.crtc);
 }

 static inline struct exynos_dp_device *encoder_to_dp(
-   struct exynos_drm_encoder *e)
+   struct drm_encoder *e)
 {
return container_of(e, struct exynos_dp_device, encoder);
 }
@@ -889,7 +889,7 @@ static void exynos_dp_hotplug(struct work_struct *work)
drm_helper_hpd_irq_event(dp->drm_dev);
 }

-static void exynos_dp_commit(struct exynos_drm_encoder *encoder)
+static void exynos_dp_commit(struct drm_encoder *encoder)
 {
struct exynos_dp_device *dp = encoder_to_dp(encoder);
int ret;
@@ -995,7 +995,7 @@ static struct drm_encoder *exynos_dp_best_encoder(
 {
struct exynos_dp_device *dp = ctx_from_connector(connector);

-   return >encoder.base;
+   return >encoder;
 }

 static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
@@ -1020,10 +1020,9 @@ static int exynos_drm_attach_lcd_bridge(struct 
exynos_dp_device *dp,
return 0;
 }

-static int exynos_dp_create_connector(struct exynos_drm_encoder 
*exynos_encoder)
+static int exynos_dp_create_connector(struct drm_encoder *encoder)
 {
-   struct exynos_dp_device *dp = encoder_to_dp(exynos_encoder);
-   struct drm_encoder *encoder = _encoder->base;
+   

[Bug 86720] [radeon] Europa Universalis 4 freezing during game start (10.3.3)

2015-08-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=86720

--- Comment #29 from noga.dany at gmail.com ---
Created attachment 117697
  --> https://bugs.freedesktop.org/attachment.cgi?id=117697=edit
screenshot with R600_DEBUG=nosb on Mesa 10.6.4 and AMD HD 6870

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 



[Bug 86720] [radeon] Europa Universalis 4 freezing during game start (10.3.3)

2015-08-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=86720

--- Comment #28 from noga.dany at gmail.com ---
(In reply to Benjamin Bellec from comment #27)
> (In reply to noga.dany from comment #26)
> > I tried run it with nosb parameters like mentioned above "R600_DEBUG=nosb
> > force_s3tc_enable=true /usr/bin/steam %U" and game works, but textures looks
> > very bad.
> 
> Remove the "force_s3tc_enable=true" in your command.
> 
> And be sure to have the s3tc lib installed (libtxc_dxtn). You can check that
> with this command:
> $ glxinfo |grep s3tc

Ok, I have installed libtxc_dxtn 64bit and 32bit and tried it with
"R600_DEBUG=nosb /usr/bin/steam %U". Unfortunately it doesn't look good either.
Screenshot attached.
Mesa 10.6.4
Kernel 4.1.1
AMD HD 6870

So with nosb works but looks bad and without nosb it looks good, but system
freezes.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: