[PATCH v2 02/17] drm/atomic: Allow drivers to subclass drm_atomic_state, v2

2015-05-13 Thread Maarten Lankhorst
Drivers may need to store the state of shared resources, such as PLLs
or FIFO space, into the atomic state. Allow this by making it possible
to subclass drm_atomic_state.

Changes since v1:
- Change member names for functions to atomic_state_(alloc,clear)
- Change __drm_atomic_state_new to drm_atomic_state_init
- Allow free function to be overridden too, in case extra memory is
  allocated in alloc.

Cc: dri-devel at lists.freedesktop.org
Acked-by: Ander Conselvan de Oliveira 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_atomic.c | 116 ---
 include/drm/drm_atomic.h |   5 ++
 include/drm/drm_crtc.h   |   6 +++
 3 files changed, 99 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index c6277a4a1f2f..47364f244dc0 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -30,7 +30,15 @@
 #include 
 #include 

-static void kfree_state(struct drm_atomic_state *state)
+/**
+ * drm_atomic_state_default_free -
+ * free memory initialized by drm_atomic_state_init
+ * @state: atomic state
+ *
+ * Free all the memory allocated by drm_atomic_state_init.
+ * This is useful for drivers that subclass the atomic state.
+ */
+void drm_atomic_state_default_free(struct drm_atomic_state *state)
 {
kfree(state->connectors);
kfree(state->connector_states);
@@ -38,24 +46,20 @@ static void kfree_state(struct drm_atomic_state *state)
kfree(state->crtc_states);
kfree(state->planes);
kfree(state->plane_states);
-   kfree(state);
 }
+EXPORT_SYMBOL(drm_atomic_state_default_free);

 /**
- * drm_atomic_state_alloc - allocate atomic state
+ * drm_atomic_state_init - init new atomic state
  * @dev: DRM device
+ * @state: atomic state
  *
- * This allocates an empty atomic state to track updates.
+ * Default implementation for filling in a new atomic state.
+ * This is useful for drivers that subclass the atomic state.
  */
-struct drm_atomic_state *
-drm_atomic_state_alloc(struct drm_device *dev)
+int
+drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)
 {
-   struct drm_atomic_state *state;
-
-   state = kzalloc(sizeof(*state), GFP_KERNEL);
-   if (!state)
-   return NULL;
-
/* TODO legacy paths should maybe do a better job about
 * setting this appropriately?
 */
@@ -92,31 +96,50 @@ drm_atomic_state_alloc(struct drm_device *dev)

state->dev = dev;

-   DRM_DEBUG_ATOMIC("Allocate atomic state %p\n", state);
+   DRM_DEBUG_ATOMIC("Allocated atomic state %p\n", state);

-   return state;
+   return 0;
 fail:
-   kfree_state(state);
+   drm_atomic_state_default_free(state);
+   return -ENOMEM;
+}
+EXPORT_SYMBOL(drm_atomic_state_init);
+
+/**
+ * drm_atomic_state_alloc - allocate atomic state
+ * @dev: DRM device
+ *
+ * This allocates an empty atomic state to track updates.
+ */
+struct drm_atomic_state *
+drm_atomic_state_alloc(struct drm_device *dev)
+{
+   struct drm_mode_config *config = >mode_config;
+   struct drm_atomic_state *state;
+
+   if (!config->funcs->atomic_state_alloc) {
+   state = kzalloc(sizeof(*state), GFP_KERNEL);
+   if (!state)
+   return NULL;
+   if (drm_atomic_state_init(dev, state) < 0) {
+   kfree(state);
+   return NULL;
+   }
+   return state;
+   }

-   return NULL;
+   return config->funcs->atomic_state_alloc(dev);
 }
 EXPORT_SYMBOL(drm_atomic_state_alloc);

 /**
- * drm_atomic_state_clear - clear state object
+ * drm_atomic_state_default_clear - clear base atomic state
  * @state: atomic state
  *
- * When the w/w mutex algorithm detects a deadlock we need to back off and drop
- * all locks. So someone else could sneak in and change the current modeset
- * configuration. Which means that all the state assembled in @state is no
- * longer an atomic update to the current state, but to some arbitrary earlier
- * state. Which could break assumptions the driver's ->atomic_check likely
- * relies on.
- *
- * Hence we must clear all cached state and completely start over, using this
- * function.
+ * Default implementation for clearing atomic state.
+ * This is useful for drivers that subclass the atomic state.
  */
-void drm_atomic_state_clear(struct drm_atomic_state *state)
+void drm_atomic_state_default_clear(struct drm_atomic_state *state)
 {
struct drm_device *dev = state->dev;
struct drm_mode_config *config = >mode_config;
@@ -162,6 +185,32 @@ void drm_atomic_state_clear(struct drm_atomic_state *state)
state->plane_states[i] = NULL;
}
 }
+EXPORT_SYMBOL(drm_atomic_state_default_clear);
+
+/**
+ * drm_atomic_state_clear - clear state object
+ * @state: atomic state
+ *
+ * When the w/w mutex algorithm detects a deadlock we need to back off 

[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Matt Roper
On Tue, May 12, 2015 at 09:54:07PM +0200, Thomas Gummerer wrote:
> 
> Hi,
> 
> I noticed that on my machine the screen starts to flicker after I
> suspend and resume my machine, on the main laptop display if an external
> display is attached with kernel v4.1-rc1.  I tracked the regression down
> to commit c9f038a1a592 ("drm/i915: Don't assume primary & cursor are
> always on for wm calculation (v4)"), and sent a patch that fixes that
> behavior at [1] about two weeks ago, although I'm not sure it's the
> right thing to do, as I'm not very familiar with the code.  The same bug
> still exists in vv4.1-rc3.
> 
> Jan Niehusmann confirmed the behavior, but there has been no further
> discussion on the topic.  I also forgot to cc the people that were
> involved in the patch that caused the regression (sorry about that).
> 
> Is there anything else that I can do to help fixing this issue?
> 
> Thanks,
> Thomas
> 
> [1] http://lists.freedesktop.org/archives/intel-gfx/2015-April/065494.html

Sorry, I missed your patch when you first sent it.  That type of fix
looks like an okay workaround while we do a more in-depth rework of the
watermark system.  However I think your patch could cause a crash if we
disable the primary plane via the universal plane interface; if we do
that, p->pri.bytes_per_pixel is set to 0, but since we're now pretending
the primary plane is always enabled, ilk_wm_fbc() can eventually get
called and use that 0 in the denominator of a division operation.

If you just squash the following change into your patch, I think it should be
safe:

diff --git a/drivers/gpu/drm/i915/intel_pm.c 
b/drivers/gpu/drm/i915/intel_pm.c
index eb97cbe..99fa8ee 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -2076,7 +2076,7 @@ static void ilk_compute_wm_parameters(struct 
drm_crtc *crtc,
p->pri.bytes_per_pixel =
crtc->primary->state->fb->bits_per_pixel / 8;
else
-   p->pri.bytes_per_pixel = 0;
+   p->pri.bytes_per_pixel = 4;

p->cur.bytes_per_pixel = 4;
/*


Matt

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795


[PATCH early RFC 0/2] Implement ASoC HDMI codec library

2015-05-13 Thread Jean-Francois Moine
On Wed, 13 May 2015 12:23:45 +0300
Jyri Sarha  wrote:

> Jean-Francois, would you consider trying the generic ASoC patch with
> your HW, as I can not test the spdif functionality with mine?

Hi Jyri,

I am not sure to need all the stuff you coded.

My tda998x CODEC is quite empty and it works fine in my system.
If you look at my last patch request ([PATCH v12 6/6] ASoC: tda998x:
add a codec to the HDMI transmitter -
http://mailman.alsa-project.org/pipermail/alsa-devel/2015-May/091758.html),
the code is much smaller than yours and does not ask for a structure
constraint (+/* Has to be the first member of the hdmi endcoder's
drvdata */).

So, I'd rather see a real hdmi codec library, i.e. a set of common
functions as Russell's DRM ELD helper, each specific hdmi codec being
free about the mechanism used for the exchanges with the hdmi
transmitter.

-- 
Ken ar c'hentañ| ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/


[PATCH v4 9/9] exynos/fimg2d: simplify g2d_fini()

2015-05-13 Thread Tobias Jakobi
free()ing a nullptr is a noop, so remove the check.

Signed-off-by: Tobias Jakobi 
---
 exynos/exynos_fimg2d.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 9bf2aa9..8527dde 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -261,8 +261,7 @@ struct g2d_context *g2d_init(int fd)

 void g2d_fini(struct g2d_context *ctx)
 {
-   if (ctx)
-   free(ctx);
+   free(ctx);
 }

 /**
-- 
2.0.5



[PATCH v4 8/9] tests/exynos: use XRGB8888 for framebuffer

2015-05-13 Thread Tobias Jakobi
This matches the G2D color mode that is used in the entire code.
The previous (incorrect) RGBA would only work since the
Exynos mixer did its configuration based on the bpp, and not
based on the actual pixelformat.

Signed-off-by: Tobias Jakobi 
---
 tests/exynos/exynos_fimg2d_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/exynos/exynos_fimg2d_test.c 
b/tests/exynos/exynos_fimg2d_test.c
index 64dacfa..ce32045 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -745,7 +745,7 @@ int main(int argc, char **argv)
offsets[0] = 0;

ret = drmModeAddFB2(dev->fd, screen_width, screen_height,
-   DRM_FORMAT_RGBA, handles,
+   DRM_FORMAT_XRGB, handles,
pitches, offsets, _id, 0);
if (ret < 0)
goto err_destroy_buffer;
-- 
2.0.5



[PATCH v4 7/9] tests/exynos: replace return by break

2015-05-13 Thread Tobias Jakobi
The 'usage' function already does exit(0), so that this
'return -EINVAL' is never called. Just put a break there
to avoid confusion.

Signed-off-by: Tobias Jakobi 
---
 tests/exynos/exynos_fimg2d_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/exynos/exynos_fimg2d_test.c 
b/tests/exynos/exynos_fimg2d_test.c
index e64bb32..64dacfa 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -689,7 +689,7 @@ int main(int argc, char **argv)
break;
default:
usage(argv[0]);
-   return -EINVAL;
+   break;
}
}

-- 
2.0.5



[PATCH v4 6/9] exynos: fimg2d: fix return codes

2015-05-13 Thread Tobias Jakobi
Even if flushing the command buffer doesn't succeed, the
G2D calls would still return zero. Fix this by just passing
the flush return code.

Signed-off-by: Tobias Jakobi 
---
 exynos/exynos_fimg2d.c | 20 +---
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index b1fd0a5..9bf2aa9 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -364,9 +364,7 @@ g2d_solid_fill(struct g2d_context *ctx, struct g2d_image 
*img,
bitblt.data.fast_solid_color_fill_en = 1;
g2d_add_cmd(ctx, BITBLT_COMMAND_REG, bitblt.val);

-   g2d_flush(ctx);
-
-   return 0;
+   return g2d_flush(ctx);
 }

 /**
@@ -449,9 +447,7 @@ g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
rop4.data.unmasked_rop3 = G2D_ROP3_SRC;
g2d_add_cmd(ctx, ROP4_REG, rop4.val);

-   g2d_flush(ctx);
-
-   return 0;
+   return g2d_flush(ctx);
 }

 /**
@@ -561,9 +557,7 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct 
g2d_image *src,
pt.data.y = dst_y + dst_h;
g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);

-   g2d_flush(ctx);
-
-   return 0;
+   return g2d_flush(ctx);
 }

 /**
@@ -670,9 +664,7 @@ g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
pt.data.y = dst_y + h;
g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);

-   g2d_flush(ctx);
-
-   return 0;
+   return g2d_flush(ctx);
 }

 /**
@@ -800,7 +792,5 @@ g2d_scale_and_blend(struct g2d_context *ctx, struct 
g2d_image *src,
pt.data.y = dst_y + dst_h;
g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);

-   g2d_flush(ctx);
-
-   return 0;
+   return g2d_flush(ctx);
 }
-- 
2.0.5



[PATCH v4 5/9] tests/exynos: add fimg2d event test

2015-05-13 Thread Tobias Jakobi
This tests async processing of G2D jobs. A separate thread is spawned
to monitor the DRM fd for events and check whether a G2D job was
completed.

v2: Add GPLv2 header, argument handling and documentation.
Test is only installed when requested.
v3: Allocate G2D jobs with calloc which fixes 'busy' being
potentially uninitialized. Also enable timeout for poll()
in the monitor thread. This fixes pthread_join() not working
because of poll() not returning.

Signed-off-by: Tobias Jakobi 
---
 tests/exynos/Makefile.am   |  11 +-
 tests/exynos/exynos_fimg2d_event.c | 326 +
 2 files changed, 335 insertions(+), 2 deletions(-)
 create mode 100644 tests/exynos/exynos_fimg2d_event.c

diff --git a/tests/exynos/Makefile.am b/tests/exynos/Makefile.am
index e82d199..357d6b8 100644
--- a/tests/exynos/Makefile.am
+++ b/tests/exynos/Makefile.am
@@ -20,16 +20,23 @@ endif

 if HAVE_INSTALL_TESTS
 bin_PROGRAMS += \
-   exynos_fimg2d_perf
+   exynos_fimg2d_perf \
+   exynos_fimg2d_event
 else
 noinst_PROGRAMS += \
-   exynos_fimg2d_perf
+   exynos_fimg2d_perf \
+   exynos_fimg2d_event
 endif

 exynos_fimg2d_perf_LDADD = \
$(top_builddir)/libdrm.la \
$(top_builddir)/exynos/libdrm_exynos.la

+exynos_fimg2d_event_LDADD = \
+   $(top_builddir)/libdrm.la \
+   $(top_builddir)/exynos/libdrm_exynos.la \
+   -lpthread
+
 exynos_fimg2d_test_LDADD = \
$(top_builddir)/libdrm.la \
$(top_builddir)/libkms/libkms.la \
diff --git a/tests/exynos/exynos_fimg2d_event.c 
b/tests/exynos/exynos_fimg2d_event.c
new file mode 100644
index 000..c03dcff
--- /dev/null
+++ b/tests/exynos/exynos_fimg2d_event.c
@@ -0,0 +1,326 @@
+/*
+ * Copyright (C) 2015 - Tobias Jakobi
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with it. If not, see .
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include "exynos_drm.h"
+#include "exynos_drmif.h"
+#include "exynos_fimg2d.h"
+
+struct g2d_job {
+   unsigned int id;
+   unsigned int busy;
+};
+
+struct exynos_evhandler {
+   struct pollfd fds;
+   struct exynos_event_context evctx;
+};
+
+struct threaddata {
+   unsigned int stop;
+   struct exynos_device *dev;
+   struct exynos_evhandler evhandler;
+};
+
+static void g2d_event_handler(int fd, unsigned int cmdlist_no, unsigned int 
tv_sec,
+   unsigned int tv_usec, 
void *user_data)
+{
+   struct g2d_job *job = user_data;
+
+   fprintf(stderr, "info: g2d job (id = %u, cmdlist number = %u) 
finished!\n",
+   job->id, cmdlist_no);
+
+   job->busy = 0;
+}
+
+static void setup_g2d_event_handler(struct exynos_evhandler *evhandler, int fd)
+{
+   evhandler->fds.fd = fd;
+   evhandler->fds.events = POLLIN;
+   evhandler->evctx.base.version = DRM_EVENT_CONTEXT_VERSION;
+   evhandler->evctx.version = EXYNOS_EVENT_CONTEXT_VERSION;
+   evhandler->evctx.g2d_event_handler = g2d_event_handler;
+}
+
+static void* threadfunc(void *arg) {
+   const int timeout = 0;
+   struct threaddata *data;
+
+   data = arg;
+
+   while (1) {
+   if (data->stop) break;
+
+   usleep(500);
+
+   data->evhandler.fds.revents = 0;
+
+   if (poll(>evhandler.fds, 1, timeout) < 0)
+   continue;
+
+   if (data->evhandler.fds.revents & (POLLHUP | POLLERR))
+   continue;
+
+   if (data->evhandler.fds.revents & POLLIN)
+   exynos_handle_event(data->dev, >evhandler.evctx);
+   }
+
+   pthread_exit(0);
+}
+
+/*
+ * We need to wait until all G2D jobs are finished, otherwise we
+ * potentially remove a BO which the engine still operates on.
+ * This results in the following kernel message:
+ * [drm:exynos_drm_gem_put_dma_addr] *ERROR* failed to lookup gem object.
+ * Also any subsequent BO allocations fail then with:
+ * [drm:exynos_drm_alloc_buf] *ERROR* failed to allocate buffer.
+ */
+static void wait_all_jobs(struct g2d_job* jobs, unsigned num_jobs)
+{
+   unsigned i;
+
+   for (i = 0; i < num_jobs; ++i) {
+   while (jobs[i].busy)
+   usleep(500);
+   }
+
+}
+
+static struct g2d_job* free_job(struct g2d_job* jobs, unsigned num_jobs)
+{
+   unsigned i;

[PATCH v4 4/9] exynos: fimg2d: add g2d_exec2

2015-05-13 Thread Tobias Jakobi
This is a more 'flexible' version of g2d_exec allowing to pass
some flags which modify the behaviour of g2d_exec. Currently
only the 'async' operation flag is supported.

v2: Add g2d_exec2() to Exynos symbol test.
Signed-off-by: Tobias Jakobi 
---
 exynos/exynos-symbol-check |  1 +
 exynos/exynos_fimg2d.c | 15 +--
 exynos/exynos_fimg2d.h |  6 ++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/exynos/exynos-symbol-check b/exynos/exynos-symbol-check
index bb12315..2bb7718 100755
--- a/exynos/exynos-symbol-check
+++ b/exynos/exynos-symbol-check
@@ -27,6 +27,7 @@ g2d_blend
 g2d_copy
 g2d_copy_with_scale
 g2d_exec
+g2d_exec2
 g2d_config_event
 g2d_fini
 g2d_init
diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 3a5f20a..b1fd0a5 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -288,13 +288,24 @@ void g2d_config_event(struct g2d_context *ctx, void 
*userdata)
  */
 int g2d_exec(struct g2d_context *ctx)
 {
-   struct drm_exynos_g2d_exec exec;
+   return g2d_exec2(ctx, G2D_EXEC_FLAG_NORMAL);
+}
+
+/**
+ * g2d_exec2 - same as 'g2d_exec' but allow to pass some flags.
+ *
+ * @ctx: a pointer to g2d_context structure.
+ */
+int g2d_exec2(struct g2d_context *ctx, unsigned int flags)
+{
+   struct drm_exynos_g2d_exec exec = {0};
int ret;

if (ctx->cmdlist_nr == 0)
return -EINVAL;

-   exec.async = 0;
+   if (flags & G2D_EXEC_FLAG_ASYNC)
+   exec.async = 1;

ret = drmIoctl(ctx->fd, DRM_IOCTL_EXYNOS_G2D_EXEC, );
if (ret < 0) {
diff --git a/exynos/exynos_fimg2d.h b/exynos/exynos_fimg2d.h
index 421249d..8f9ba23 100644
--- a/exynos/exynos_fimg2d.h
+++ b/exynos/exynos_fimg2d.h
@@ -187,6 +187,11 @@ enum e_g2d_acoeff_mode {
G2D_ACOEFF_MODE_MASK
 };

+enum e_g2d_exec_flag {
+   G2D_EXEC_FLAG_NORMAL = (0 << 0),
+   G2D_EXEC_FLAG_ASYNC = (1 << 0)
+};
+
 union g2d_point_val {
unsigned int val;
struct {
@@ -305,6 +310,7 @@ struct g2d_context *g2d_init(int fd);
 void g2d_fini(struct g2d_context *ctx);
 void g2d_config_event(struct g2d_context *ctx, void *userdata);
 int g2d_exec(struct g2d_context *ctx);
+int g2d_exec2(struct g2d_context *ctx, unsigned int flags);
 int g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img,
unsigned int x, unsigned int y, unsigned int w,
unsigned int h);
-- 
2.0.5



[PATCH v4 3/9] exynos/fimg2d: add g2d_config_event

2015-05-13 Thread Tobias Jakobi
This enables us to pass command buffers to the kernel which
trigger an event on the DRM fd upon completion.
The final goal is to enable asynchronous operation of the
G2D engine, similar to async page flips.

Passing the event userdata pointer through the G2D context
was chosen to not change the current API (e.g. by adding
a userdata argument to each public functions).

v2: Add g2d_config_event() to Exynos symbol test.
Signed-off-by: Tobias Jakobi 
---
 exynos/exynos-symbol-check |  1 +
 exynos/exynos_fimg2d.c | 27 +--
 exynos/exynos_fimg2d.h |  2 ++
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/exynos/exynos-symbol-check b/exynos/exynos-symbol-check
index c3ddbe4..bb12315 100755
--- a/exynos/exynos-symbol-check
+++ b/exynos/exynos-symbol-check
@@ -27,6 +27,7 @@ g2d_blend
 g2d_copy
 g2d_copy_with_scale
 g2d_exec
+g2d_config_event
 g2d_fini
 g2d_init
 g2d_scale_and_blend
diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 86ae898..3a5f20a 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -202,8 +202,15 @@ static int g2d_flush(struct g2d_context *ctx)
cmdlist.cmd_buf = (uint64_t)(uintptr_t)>cmd_buf[0];
cmdlist.cmd_nr = ctx->cmd_nr;
cmdlist.cmd_buf_nr = ctx->cmd_buf_nr;
-   cmdlist.event_type = G2D_EVENT_NOT;
-   cmdlist.user_data = 0;
+
+   if (ctx->event_userdata) {
+   cmdlist.event_type = G2D_EVENT_NONSTOP;
+   cmdlist.user_data = (uint64_t)(uintptr_t)(ctx->event_userdata);
+   ctx->event_userdata = NULL;
+   } else {
+   cmdlist.event_type = G2D_EVENT_NOT;
+   cmdlist.user_data = 0;
+   }

ctx->cmd_nr = 0;
ctx->cmd_buf_nr = 0;
@@ -259,6 +266,22 @@ void g2d_fini(struct g2d_context *ctx)
 }

 /**
+ * g2d_config_event - setup userdata configuration for a g2d event.
+ * The next invocation of a g2d call (e.g. g2d_solid_fill) is
+ * then going to flag the command buffer as 'nonstop'.
+ * Completion of the command buffer execution can then be
+ * determined by using drmHandleEvent on the DRM fd.
+ * The userdata is 'consumed' in the process.
+ *
+ * @ctx: a pointer to g2d_context structure.
+ * @userdata: a pointer to the user data
+ */
+void g2d_config_event(struct g2d_context *ctx, void *userdata)
+{
+   ctx->event_userdata = userdata;
+}
+
+/**
  * g2d_exec - start the dma to process all commands summited by g2d_flush().
  *
  * @ctx: a pointer to g2d_context structure.
diff --git a/exynos/exynos_fimg2d.h b/exynos/exynos_fimg2d.h
index 9db0c88..421249d 100644
--- a/exynos/exynos_fimg2d.h
+++ b/exynos/exynos_fimg2d.h
@@ -298,10 +298,12 @@ struct g2d_context {
unsigned intcmd_nr;
unsigned intcmd_buf_nr;
unsigned intcmdlist_nr;
+   void*event_userdata;
 };

 struct g2d_context *g2d_init(int fd);
 void g2d_fini(struct g2d_context *ctx);
+void g2d_config_event(struct g2d_context *ctx, void *userdata);
 int g2d_exec(struct g2d_context *ctx);
 int g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img,
unsigned int x, unsigned int y, unsigned int w,
-- 
2.0.5



[PATCH v4 2/9] tests/exynos: add fimg2d performance analysis

2015-05-13 Thread Tobias Jakobi
Currently only fast solid color clear performance is measured.
A large buffer is allocated and solid color clear operations
are executed on it with randomly chosen properties (position
and size of the region, clear color). Execution time is
measured and output together with the amount of pixels
processed.

The 'simple' variant only executes one G2D command buffer at
a time, while the 'multi' variant executes multiple ones. This
can be used to measure setup/exec overhead.

The test also serves a stability check. If clocks/voltages are
too high or low respectively, the test quickly reveals this.

v2: Add GPLv2 header, argument handling and documentation.
Tool is only installed when requested.

Signed-off-by: Tobias Jakobi 
---
 tests/exynos/Makefile.am  |  19 ++-
 tests/exynos/exynos_fimg2d_perf.c | 320 ++
 2 files changed, 337 insertions(+), 2 deletions(-)
 create mode 100644 tests/exynos/exynos_fimg2d_perf.c

diff --git a/tests/exynos/Makefile.am b/tests/exynos/Makefile.am
index b21d016..e82d199 100644
--- a/tests/exynos/Makefile.am
+++ b/tests/exynos/Makefile.am
@@ -5,16 +5,31 @@ AM_CFLAGS = \
-I $(top_srcdir)/exynos \
-I $(top_srcdir)

+bin_PROGRAMS =
+noinst_PROGRAMS =
+
 if HAVE_LIBKMS
 if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
+bin_PROGRAMS += \
exynos_fimg2d_test
 else
-noinst_PROGRAMS = \
+noinst_PROGRAMS += \
exynos_fimg2d_test
 endif
 endif

+if HAVE_INSTALL_TESTS
+bin_PROGRAMS += \
+   exynos_fimg2d_perf
+else
+noinst_PROGRAMS += \
+   exynos_fimg2d_perf
+endif
+
+exynos_fimg2d_perf_LDADD = \
+   $(top_builddir)/libdrm.la \
+   $(top_builddir)/exynos/libdrm_exynos.la
+
 exynos_fimg2d_test_LDADD = \
$(top_builddir)/libdrm.la \
$(top_builddir)/libkms/libkms.la \
diff --git a/tests/exynos/exynos_fimg2d_perf.c 
b/tests/exynos/exynos_fimg2d_perf.c
new file mode 100644
index 000..e52e0d8
--- /dev/null
+++ b/tests/exynos/exynos_fimg2d_perf.c
@@ -0,0 +1,320 @@
+/*
+ * Copyright (C) 2015 - Tobias Jakobi
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with it. If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "exynos_drm.h"
+#include "exynos_drmif.h"
+#include "exynos_fimg2d.h"
+
+static int output_mathematica = 0;
+
+static int fimg2d_perf_simple(struct exynos_bo *bo, struct g2d_context *ctx,
+   unsigned buf_width, unsigned buf_height, unsigned 
iterations)
+{
+   struct timespec tspec = { 0 };
+   struct g2d_image img = { 0 };
+
+   unsigned long long g2d_time;
+   unsigned i;
+   int ret = 0;
+
+   img.width = buf_width;
+   img.height = buf_height;
+   img.stride = buf_width * 4;
+   img.color_mode = G2D_COLOR_FMT_ARGB | G2D_ORDER_AXRGB;
+   img.buf_type = G2D_IMGBUF_GEM;
+   img.bo[0] = bo->handle;
+
+   srand(time(NULL));
+
+   printf("starting simple G2D performance test\n");
+   printf("buffer width = %u, buffer height = %u, iterations = %u\n",
+   buf_width, buf_height, iterations);
+
+   if (output_mathematica)
+   putchar('{');
+
+   for (i = 0; i < iterations; ++i) {
+   unsigned x, y, w, h;
+
+   x = rand() % buf_width;
+   y = rand() % buf_height;
+
+   if (x == (buf_width - 1))
+   x -= 1;
+   if (y == (buf_height - 1))
+   y -= 1;
+
+   w = rand() % (buf_width - x);
+   h = rand() % (buf_height - y);
+
+   if (w == 0) w = 1;
+   if (h == 0) h = 1;
+
+   img.color = rand();
+
+   ret = g2d_solid_fill(ctx, , x, y, w, h);
+
+   clock_gettime(CLOCK_MONOTONIC, );
+
+   if (ret == 0)
+   ret = g2d_exec(ctx);
+
+   if (ret != 0) {
+   fprintf(stderr, "error: iteration %u failed (x = %u, y 
= %u, w = %u, h = %u)\n",
+   i, x, y, w, h);
+   break;
+   } else {
+   struct timespec end = { 0 };
+   clock_gettime(CLOCK_MONOTONIC, );
+
+   g2d_time = (end.tv_sec - tspec.tv_sec) * 10ULL;
+   g2d_time += (end.tv_nsec - tspec.tv_nsec);
+
+   if (output_mathematica) {
+  

[PATCH v4 1/9] exynos: Introduce exynos_handle_event()

2015-05-13 Thread Tobias Jakobi
Used to handle kernel events specific to the Exynos platform.
Currently only G2D events are handled.

v2: Adapt to container approach.
v3: Add exynos_handle_event() to Exynos symbol test.
Signed-off-by: Tobias Jakobi 
---
 exynos/exynos-symbol-check |  1 +
 exynos/exynos_drm.c| 28 
 exynos/exynos_drm.h| 12 
 exynos/exynos_drmif.h  | 26 ++
 4 files changed, 67 insertions(+)

diff --git a/exynos/exynos-symbol-check b/exynos/exynos-symbol-check
index 1a1be89..c3ddbe4 100755
--- a/exynos/exynos-symbol-check
+++ b/exynos/exynos-symbol-check
@@ -22,6 +22,7 @@ exynos_device_destroy
 exynos_prime_fd_to_handle
 exynos_prime_handle_to_fd
 exynos_vidi_connection
+exynos_handle_event
 g2d_blend
 g2d_copy
 g2d_copy_with_scale
diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c
index df9b8ed..7a400ad 100644
--- a/exynos/exynos_drm.c
+++ b/exynos/exynos_drm.c
@@ -42,6 +42,8 @@
 #include "exynos_drm.h"
 #include "exynos_drmif.h"

+#define U642VOID(x) ((void *)(unsigned long)(x))
+
 /*
  * Create exynos drm device object.
  *
@@ -374,3 +376,29 @@ exynos_vidi_connection(struct exynos_device *dev, uint32_t 
connect,

return 0;
 }
+
+static void
+exynos_handle_vendor(int fd, struct drm_event *e, void *ctx)
+{
+   struct drm_exynos_g2d_event *g2d;
+   struct exynos_event_context *ectx = ctx;
+
+   switch (e->type) {
+   case DRM_EXYNOS_G2D_EVENT:
+   if (ectx->version < 1 || ectx->g2d_event_handler == 
NULL)
+   break;
+   g2d = (struct drm_exynos_g2d_event *)e;
+   ectx->g2d_event_handler(fd, g2d->cmdlist_no, 
g2d->tv_sec,
+   g2d->tv_usec, 
U642VOID(g2d->user_data));
+   break;
+
+   default:
+   break;
+   }
+}
+
+int
+exynos_handle_event(struct exynos_device *dev, struct exynos_event_context 
*ctx)
+{
+   return drmHandleEvent2(dev->fd, >base, exynos_handle_vendor);
+}
diff --git a/exynos/exynos_drm.h b/exynos/exynos_drm.h
index 256c02f..c3af0ac 100644
--- a/exynos/exynos_drm.h
+++ b/exynos/exynos_drm.h
@@ -157,4 +157,16 @@ struct drm_exynos_g2d_exec {
 #define DRM_IOCTL_EXYNOS_G2D_EXEC  DRM_IOWR(DRM_COMMAND_BASE + \
DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)

+/* EXYNOS specific events */
+#define DRM_EXYNOS_G2D_EVENT   0x8000
+
+struct drm_exynos_g2d_event {
+   struct drm_eventbase;
+   __u64   user_data;
+   __u32   tv_sec;
+   __u32   tv_usec;
+   __u32   cmdlist_no;
+   __u32   reserved;
+};
+
 #endif
diff --git a/exynos/exynos_drmif.h b/exynos/exynos_drmif.h
index c7c1d44..626e399 100644
--- a/exynos/exynos_drmif.h
+++ b/exynos/exynos_drmif.h
@@ -54,6 +54,25 @@ struct exynos_bo {
uint32_tname;
 };

+#define EXYNOS_EVENT_CONTEXT_VERSION 1
+
+/*
+ * Exynos Event Context structure.
+ *
+ * @base: base context (for core events).
+ * @version: version info similar to the one in 'drmEventContext'.
+ * @g2d_event_handler: handler for G2D events.
+ */
+struct exynos_event_context {
+   drmEventContext base;
+
+   int version;
+
+   void (*g2d_event_handler)(int fd, unsigned int cmdlist_no,
+ unsigned int tv_sec, 
unsigned int tv_usec,
+ void *user_data);
+};
+
 /*
  * device related functions:
  */
@@ -83,4 +102,11 @@ int exynos_prime_fd_to_handle(struct exynos_device *dev, 
int fd,
 int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect,
uint32_t ext, void *edid);

+/*
+ * event handling related functions:
+ */
+int exynos_handle_event(struct exynos_device *dev,
+   struct exynos_event_context *ctx);
+
+
 #endif /* EXYNOS_DRMIF_H_ */
-- 
2.0.5



[PATCH v4 0/9] drm/exynos: add async G2D execution to libdrm

2015-05-13 Thread Tobias Jakobi
Hello,

this series exposes async execution of G2D command buffers to userspace. Also 
includes is a small performance analysis test, which can also be used to stress 
test the engine. The async operation is of course also tested.

Please review and let me know what I can improve.

v3: Rewrote handling of vendor-specific events. The series is now based on [1]. 
Also added two small fixes (error handling, break statement).

v4: Minor modification to the vendor-event handling code (drop opaque ptr). 
Series is based on this version [2] of the patch. Another two small fixes 
(buffer pixelformat, g2d_fini) added. The pixelformat issue surfaced after the 
recent changes to the Exynos mixer code. Also fixed a thread bug in the event 
test (application should always exit properly now).


With best wishes,
Tobias

[1] https://patchwork.kernel.org/patch/6262541/
[2] https://patchwork.kernel.org/patch/6391301/

Tobias Jakobi (9):
  exynos: Introduce exynos_handle_event()
  tests/exynos: add fimg2d performance analysis
  exynos/fimg2d: add g2d_config_event
  exynos: fimg2d: add g2d_exec2
  tests/exynos: add fimg2d event test
  exynos: fimg2d: fix return codes
  tests/exynos: replace return by break
  tests/exynos: use XRGB for framebuffer
  exynos/fimg2d: simplify g2d_fini()

 exynos/exynos-symbol-check |   3 +
 exynos/exynos_drm.c|  28 
 exynos/exynos_drm.h|  12 ++
 exynos/exynos_drmif.h  |  26 +++
 exynos/exynos_fimg2d.c |  65 +---
 exynos/exynos_fimg2d.h |   8 +
 tests/exynos/Makefile.am   |  26 ++-
 tests/exynos/exynos_fimg2d_event.c | 326 +
 tests/exynos/exynos_fimg2d_perf.c  | 320 
 tests/exynos/exynos_fimg2d_test.c  |   4 +-
 10 files changed, 793 insertions(+), 25 deletions(-)
 create mode 100644 tests/exynos/exynos_fimg2d_event.c
 create mode 100644 tests/exynos/exynos_fimg2d_perf.c

-- 
2.0.5



[Bug 90439] Xonotic render green (bisected)

2015-05-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=90439

--- Comment #2 from smoki  ---

 mesa is 58715b72396133350c1549381553121f936a198e, kernel 4.1-rc3, hardware
Athlon 5350 (Kabini), etc...

-- 
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/20150513/21790f40/attachment.html>


[Bug 90439] Xonotic render green (bisected)

2015-05-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=90439

--- Comment #1 from smoki  ---
Created attachment 115747
  --> https://bugs.freedesktop.org/attachment.cgi?id=115747=edit
Bad


 And bad with llvm r237140

-- 
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/20150513/f34398fb/attachment.html>


[Bug 90439] Xonotic render green (bisected)

2015-05-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=90439

Bug ID: 90439
   Summary: Xonotic render green (bisected)
   Product: Mesa
   Version: git
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/radeonsi
  Assignee: dri-devel at lists.freedesktop.org
  Reporter: smoki00790 at gmail.com
QA Contact: dri-devel at lists.freedesktop.org

Created attachment 115745
  --> https://bugs.freedesktop.org/attachment.cgi?id=115745=edit
Good

llvm r237140 bisected where Xonotic start to render mostly green artifacts on
textures.

 Attached R600_DEBUG=ps,vs,gs outputs from good on llvm r237139

-- 
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/20150513/27092fa2/attachment-0001.html>


[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Sudip Mukherjee
On Wed, May 13, 2015 at 01:27:06PM +0200, Thomas Gummerer wrote:
> Sudip Mukherjee  writes:
> 
> > On Wed, May 13, 2015 at 11:53:19AM +0200, Jan Niehusmann wrote:
> > http://patchwork.freedesktop.org/patch/46071/
> 
> Thank you for the pointer, but this seems to be an unrelated issue.  I
> tried applying the patch, but it doesn't fix the issues that I'm
> experiencing.
thanks for confirming. I am out of this thread now :)

regards
sudip
> 
> > regards
> > sudip


[RFC][PATCH 2/2] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.

2015-05-13 Thread Daniel Stone
Hi,

On 13 May 2015 at 16:23, CK Hu  wrote:
> +   /*
> +* copy the mode data adjusted by mode_fixup() into crtc->mode
> +* so that hardware can be seet to proper mode.
> +*/
> +   memcpy(>mode, adjusted_mode, sizeof(*adjusted_mode));

Please do not do this. adjusted_mode is already available in crtc->hwmode.

Please also restructure this driver to use the atomic infrastructure.
A good example of how to do this can be found in the Rockchip RK3288
driver which was submitted a while ago: it started off as a legacy
driver like this, but was converted during the submission phase.

I'm sure there are many more comments to come, but certainly
converting to be an atomic driver is the very first step.

Cheers,
Daniel


[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Sudip Mukherjee
On Wed, May 13, 2015 at 01:10:11PM +0200, Jan Niehusmann wrote:
> On Wed, May 13, 2015 at 04:02:25PM +0530, Sudip Mukherjee wrote:
> > > What I'm missing in the report, are some log entries I'm seeing on my
> > > notebook:
> > > 
> > > Apr 30 08:50:23 localhost kernel: 
> > > [drm:intel_cpu_fifo_underrun_irq_handler [i915]] *ERROR* CPU pipe B FIFO 
> > > underrun
> > > Apr 30 08:50:23 localhost kernel: 
> > > [drm:intel_pch_fifo_underrun_irq_handler [i915]] *ERROR* PCH transcoder B 
> > > FIFO underrun
> > > Apr 30 08:50:29 localhost kernel: 
> > > [drm:intel_cpu_fifo_underrun_irq_handler [i915]] *ERROR* CPU pipe A FIFO 
> > > underrun
> > > Apr 30 08:50:29 localhost kernel: 
> > > [drm:intel_pch_fifo_underrun_irq_handler [i915]] *ERROR* PCH transcoder A 
> > > FIFO underrun
> > hi,
> > I also have the similar entries in my dmesg, though my problem is a
> > little different from yours and my bisect lead to another commit.
> > And that also is still not fixed (last tested with 4.0).
> 
> (Please note that I didn't do a bisect - that was Thomas. I only noted
> that I can confirm his observations and that his patch helps to prevent
> or hide the issue.)
> 
> Perhaps these are two completely unrelated issues?
yes, maybe unrelated issue. since I am also having similar errors in
dmesg and also having a similar type of problem so replied here.

regards
sudip
> 
> Jan
> 


[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Sudip Mukherjee
On Wed, May 13, 2015 at 11:53:19AM +0200, Jan Niehusmann wrote:
> Hi,
> 
> On Wed, May 13, 2015 at 12:14:39PM +0300, Jani Nikula wrote:
> > Is this the same as https://bugzilla.kernel.org/show_bug.cgi?id=98141 ?
> 
> The visible effect in the video is similar to what I see on the LVDS
> display. I also see some influence of the mouse pointer position on the
> blanked areas.
> 
> The effect on the external screen is more like single scan
> lines jumping to the right and back, at a high (but still visible)
> frequency.
> 
> What I'm missing in the report, are some log entries I'm seeing on my
> notebook:
> 
> Apr 30 08:50:23 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
> [i915]] *ERROR* CPU pipe B FIFO underrun
> Apr 30 08:50:23 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
> [i915]] *ERROR* PCH transcoder B FIFO underrun
> Apr 30 08:50:29 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
> [i915]] *ERROR* CPU pipe A FIFO underrun
> Apr 30 08:50:29 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
> [i915]] *ERROR* PCH transcoder A FIFO underrun
hi,
I also have the similar entries in my dmesg, though my problem is a
little different from yours and my bisect lead to another commit.
And that also is still not fixed (last tested with 4.0).

http://patchwork.freedesktop.org/patch/46071/

regards
sudip


> 
> Jan
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


[PULL] drm-intel-fixes

2015-05-13 Thread Jani Nikula

Hi Dave, one i915 gpu hang fix on resume.

BR,
Jani.

The following changes since commit 030bbdbf4c833bc69f502eae58498bc5572db736:

  Linux 4.1-rc3 (2015-05-10 15:12:29 -0700)

are available in the git repository at:

  git://anongit.freedesktop.org/drm-intel tags/drm-intel-fixes-2015-05-13

for you to fetch changes up to 364aece01a2dd748fc36a1e8bf52ef639b0857bd:

  drm/i915: Avoid GPU hang when coming out of s3 or s4 (2015-05-11 16:27:08 
+0300)


Peter Antoine (1):
  drm/i915: Avoid GPU hang when coming out of s3 or s4

 drivers/gpu/drm/i915/i915_drv.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

-- 
Jani Nikula, Intel Open Source Technology Center


[Bug 90320] Lenovo ThinkPad E455 (Kaveri A10-7300): Blank built-in screen with radeon kms driver

2015-05-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=90320

--- Comment #9 from Samir Ibradžić  ---
Created attachment 115742
  --> https://bugs.freedesktop.org/attachment.cgi?id=115742=edit
HB140FH1-401 datasheet

Finally got my hands on some p-coins (damn the neo-capitalist China!) and
fetched the datasheet for my panel (or at least what i think i have inside my
E455 according to EDID, but it seems right as several other Lenovo laptops
comes with the same thing included). The timings looks the same as U38N, it is
definitely 2 2.7Gbps lanes, but I can't claim i understand much besides that
inside the datasheet. Yes, the panel is is full HD 1920x1080, here in Lenovo
Japan it is available as an +$20 option, which was the main reason I bought
this particular machine (besides the fact its AMD APU of course).

I can help debugging any patches or code hacks, so if you have any ideas,
onegaishimasu.

-- 
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/20150513/0255d454/attachment.html>


[PATCH 9/9] drm/exynos: Convert g2d_userptr_get_dma_addr() to use get_vaddr_frames()

2015-05-13 Thread Jan Kara
Convert g2d_userptr_get_dma_addr() to pin pages using get_vaddr_frames().
This removes the knowledge about vmas and mmap_sem locking from exynos
driver. Also it fixes a problem that the function has been mapping user
provided address without holding mmap_sem.

Signed-off-by: Jan Kara 
---
 drivers/gpu/drm/exynos/exynos_drm_g2d.c | 89 ++
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 97 -
 2 files changed, 29 insertions(+), 157 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c 
b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index 81a250830808..265519c0fe2d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -190,10 +190,8 @@ struct g2d_cmdlist_userptr {
dma_addr_t  dma_addr;
unsigned long   userptr;
unsigned long   size;
-   struct page **pages;
-   unsigned intnpages;
+   struct frame_vector *vec;
struct sg_table *sgt;
-   struct vm_area_struct   *vma;
atomic_trefcount;
boolin_pool;
boolout_of_list;
@@ -363,6 +361,7 @@ static void g2d_userptr_put_dma_addr(struct drm_device 
*drm_dev,
 {
struct g2d_cmdlist_userptr *g2d_userptr =
(struct g2d_cmdlist_userptr *)obj;
+   struct page **pages;

if (!obj)
return;
@@ -382,19 +381,21 @@ out:
exynos_gem_unmap_sgt_from_dma(drm_dev, g2d_userptr->sgt,
DMA_BIDIRECTIONAL);

-   exynos_gem_put_pages_to_userptr(g2d_userptr->pages,
-   g2d_userptr->npages,
-   g2d_userptr->vma);
+   pages = frame_vector_pages(g2d_userptr->vec);
+   if (!IS_ERR(pages)) {
+   int i;

-   exynos_gem_put_vma(g2d_userptr->vma);
+   for (i = 0; i < frame_vector_count(g2d_userptr->vec); i++)
+   set_page_dirty_lock(pages[i]);
+   }
+   put_vaddr_frames(g2d_userptr->vec);
+   frame_vector_destroy(g2d_userptr->vec);

if (!g2d_userptr->out_of_list)
list_del_init(_userptr->list);

sg_free_table(g2d_userptr->sgt);
kfree(g2d_userptr->sgt);
-
-   drm_free_large(g2d_userptr->pages);
kfree(g2d_userptr);
 }

@@ -413,6 +414,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
struct vm_area_struct *vma;
unsigned long start, end;
unsigned int npages, offset;
+   struct frame_vector *vec;
int ret;

if (!size) {
@@ -456,65 +458,37 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
return ERR_PTR(-ENOMEM);

atomic_set(_userptr->refcount, 1);
+   g2d_userptr->size = size;

start = userptr & PAGE_MASK;
offset = userptr & ~PAGE_MASK;
end = PAGE_ALIGN(userptr + size);
npages = (end - start) >> PAGE_SHIFT;
-   g2d_userptr->npages = npages;
-
-   pages = drm_calloc_large(npages, sizeof(struct page *));
-   if (!pages) {
-   DRM_ERROR("failed to allocate pages.\n");
-   ret = -ENOMEM;
+   vec = g2d_userptr->vec = frame_vector_create(npages);
+   if (!vec)
goto err_free;
-   }

-   down_read(>mm->mmap_sem);
-   vma = find_vma(current->mm, userptr);
-   if (!vma) {
-   up_read(>mm->mmap_sem);
-   DRM_ERROR("failed to get vm region.\n");
+   ret = get_vaddr_frames(start, npages, 1, 1, vec);
+   if (ret != npages) {
+   DRM_ERROR("failed to get user pages from userptr.\n");
+   if (ret < 0)
+   goto err_destroy_framevec;
ret = -EFAULT;
-   goto err_free_pages;
+   goto err_put_framevec;
}
-
-   if (vma->vm_end < userptr + size) {
-   up_read(>mm->mmap_sem);
-   DRM_ERROR("vma is too small.\n");
+   if (frame_vector_to_pages(vec) < 0) {
ret = -EFAULT;
-   goto err_free_pages;
+   goto err_put_framevec;
}

-   g2d_userptr->vma = exynos_gem_get_vma(vma);
-   if (!g2d_userptr->vma) {
-   up_read(>mm->mmap_sem);
-   DRM_ERROR("failed to copy vma.\n");
-   ret = -ENOMEM;
-   goto err_free_pages;
-   }
-
-   g2d_userptr->size = size;
-
-   ret = exynos_gem_get_pages_from_userptr(start & PAGE_MASK,
-   npages, pages, vma);
-   if (ret < 0) {
-   up_read(>mm->mmap_sem);
-   DRM_ERROR("failed to get user pages from userptr.\n");
-   goto err_put_vma;
-   }
-
-   up_read(>mm->mmap_sem);
-   g2d_userptr->pages = pages;
-

[PATCH 8/9] media: vb2: Remove unused functions

2015-05-13 Thread Jan Kara
Conversion to the use of pinned pfns made some functions unused. Remove
them. Also there's no need to lock mmap_sem in __buf_prepare() anymore.

Acked-by: Marek Szyprowski 
Tested-by: Marek Szyprowski 
Signed-off-by: Jan Kara 
---
 drivers/media/v4l2-core/videobuf2-memops.c | 114 -
 include/media/videobuf2-memops.h   |   6 --
 2 files changed, 120 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-memops.c 
b/drivers/media/v4l2-core/videobuf2-memops.c
index 0ec186d41b9b..48c6a49c4928 100644
--- a/drivers/media/v4l2-core/videobuf2-memops.c
+++ b/drivers/media/v4l2-core/videobuf2-memops.c
@@ -23,120 +23,6 @@
 #include 

 /**
- * vb2_get_vma() - acquire and lock the virtual memory area
- * @vma:   given virtual memory area
- *
- * This function attempts to acquire an area mapped in the userspace for
- * the duration of a hardware operation. The area is "locked" by performing
- * the same set of operation that are done when process calls fork() and
- * memory areas are duplicated.
- *
- * Returns a copy of a virtual memory region on success or NULL.
- */
-struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma)
-{
-   struct vm_area_struct *vma_copy;
-
-   vma_copy = kmalloc(sizeof(*vma_copy), GFP_KERNEL);
-   if (vma_copy == NULL)
-   return NULL;
-
-   if (vma->vm_ops && vma->vm_ops->open)
-   vma->vm_ops->open(vma);
-
-   if (vma->vm_file)
-   get_file(vma->vm_file);
-
-   memcpy(vma_copy, vma, sizeof(*vma));
-
-   vma_copy->vm_mm = NULL;
-   vma_copy->vm_next = NULL;
-   vma_copy->vm_prev = NULL;
-
-   return vma_copy;
-}
-EXPORT_SYMBOL_GPL(vb2_get_vma);
-
-/**
- * vb2_put_userptr() - release a userspace virtual memory area
- * @vma:   virtual memory region associated with the area to be released
- *
- * This function releases the previously acquired memory area after a hardware
- * operation.
- */
-void vb2_put_vma(struct vm_area_struct *vma)
-{
-   if (!vma)
-   return;
-
-   if (vma->vm_ops && vma->vm_ops->close)
-   vma->vm_ops->close(vma);
-
-   if (vma->vm_file)
-   fput(vma->vm_file);
-
-   kfree(vma);
-}
-EXPORT_SYMBOL_GPL(vb2_put_vma);
-
-/**
- * vb2_get_contig_userptr() - lock physically contiguous userspace mapped 
memory
- * @vaddr: starting virtual address of the area to be verified
- * @size:  size of the area
- * @res_paddr: will return physical address for the given vaddr
- * @res_vma:   will return locked copy of struct vm_area for the given area
- *
- * This function will go through memory area of size @size mapped at @vaddr and
- * verify that the underlying physical pages are contiguous. If they are
- * contiguous the virtual memory area is locked and a @res_vma is filled with
- * the copy and @res_pa set to the physical address of the buffer.
- *
- * Returns 0 on success.
- */
-int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size,
-  struct vm_area_struct **res_vma, dma_addr_t *res_pa)
-{
-   struct mm_struct *mm = current->mm;
-   struct vm_area_struct *vma;
-   unsigned long offset, start, end;
-   unsigned long this_pfn, prev_pfn;
-   dma_addr_t pa = 0;
-
-   start = vaddr;
-   offset = start & ~PAGE_MASK;
-   end = start + size;
-
-   vma = find_vma(mm, start);
-
-   if (vma == NULL || vma->vm_end < end)
-   return -EFAULT;
-
-   for (prev_pfn = 0; start < end; start += PAGE_SIZE) {
-   int ret = follow_pfn(vma, start, _pfn);
-   if (ret)
-   return ret;
-
-   if (prev_pfn == 0)
-   pa = this_pfn << PAGE_SHIFT;
-   else if (this_pfn != prev_pfn + 1)
-   return -EFAULT;
-
-   prev_pfn = this_pfn;
-   }
-
-   /*
-* Memory is contigous, lock vma and return to the caller
-*/
-   *res_vma = vb2_get_vma(vma);
-   if (*res_vma == NULL)
-   return -ENOMEM;
-
-   *res_pa = pa + offset;
-   return 0;
-}
-EXPORT_SYMBOL_GPL(vb2_get_contig_userptr);
-
-/**
  * vb2_create_framevec() - map virtual addresses to pfns
  * @start: Virtual user address where we start mapping
  * @length:Length of a range to map
diff --git a/include/media/videobuf2-memops.h b/include/media/videobuf2-memops.h
index 2f0564ff5f31..830b5239fd8b 100644
--- a/include/media/videobuf2-memops.h
+++ b/include/media/videobuf2-memops.h
@@ -31,12 +31,6 @@ struct vb2_vmarea_handler {

 extern const struct vm_operations_struct vb2_common_vm_ops;

-int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size,
-  struct vm_area_struct **res_vma, dma_addr_t *res_pa);
-
-struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma);
-void vb2_put_vma(struct vm_area_struct *vma);
-
 struct frame_vector *vb2_create_framevec(unsigned long start,
   

[PATCH 7/9] media: vb2: Convert vb2_dc_get_userptr() to use frame vector

2015-05-13 Thread Jan Kara
Convert vb2_dc_get_userptr() to use frame vector infrastructure. When we
are doing that there's no need to allocate page array and some code can
be simplified.

Acked-by: Marek Szyprowski 
Tested-by: Marek Szyprowski 
Signed-off-by: Jan Kara 
---
 drivers/media/v4l2-core/videobuf2-dma-contig.c | 214 -
 1 file changed, 34 insertions(+), 180 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c 
b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 620c4aa78881..e6cea452302b 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -32,15 +32,13 @@ struct vb2_dc_buf {
dma_addr_t  dma_addr;
enum dma_data_direction dma_dir;
struct sg_table *dma_sgt;
+   struct frame_vector *vec;

/* MMAP related */
struct vb2_vmarea_handler   handler;
atomic_trefcount;
struct sg_table *sgt_base;

-   /* USERPTR related */
-   struct vm_area_struct   *vma;
-
/* DMABUF related */
struct dma_buf_attachment   *db_attach;
 };
@@ -49,24 +47,6 @@ struct vb2_dc_buf {
 /*scatterlist table functions*/
 /*/

-
-static void vb2_dc_sgt_foreach_page(struct sg_table *sgt,
-   void (*cb)(struct page *pg))
-{
-   struct scatterlist *s;
-   unsigned int i;
-
-   for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
-   struct page *page = sg_page(s);
-   unsigned int n_pages = PAGE_ALIGN(s->offset + s->length)
-   >> PAGE_SHIFT;
-   unsigned int j;
-
-   for (j = 0; j < n_pages; ++j, ++page)
-   cb(page);
-   }
-}
-
 static unsigned long vb2_dc_get_contiguous_size(struct sg_table *sgt)
 {
struct scatterlist *s;
@@ -429,92 +409,12 @@ static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv, 
unsigned long flags)
 /*   callbacks for USERPTR buffers   */
 /*/

-static inline int vma_is_io(struct vm_area_struct *vma)
-{
-   return !!(vma->vm_flags & (VM_IO | VM_PFNMAP));
-}
-
-static int vb2_dc_get_user_pfn(unsigned long start, int n_pages,
-   struct vm_area_struct *vma, unsigned long *res)
-{
-   unsigned long pfn, start_pfn, prev_pfn;
-   unsigned int i;
-   int ret;
-
-   if (!vma_is_io(vma))
-   return -EFAULT;
-
-   ret = follow_pfn(vma, start, );
-   if (ret)
-   return ret;
-
-   start_pfn = pfn;
-   start += PAGE_SIZE;
-
-   for (i = 1; i < n_pages; ++i, start += PAGE_SIZE) {
-   prev_pfn = pfn;
-   ret = follow_pfn(vma, start, );
-
-   if (ret) {
-   pr_err("no page for address %lu\n", start);
-   return ret;
-   }
-   if (pfn != prev_pfn + 1)
-   return -EINVAL;
-   }
-
-   *res = start_pfn;
-   return 0;
-}
-
-static int vb2_dc_get_user_pages(unsigned long start, struct page **pages,
-   int n_pages, struct vm_area_struct *vma,
-   enum dma_data_direction dma_dir)
-{
-   if (vma_is_io(vma)) {
-   unsigned int i;
-
-   for (i = 0; i < n_pages; ++i, start += PAGE_SIZE) {
-   unsigned long pfn;
-   int ret = follow_pfn(vma, start, );
-
-   if (!pfn_valid(pfn))
-   return -EINVAL;
-
-   if (ret) {
-   pr_err("no page for address %lu\n", start);
-   return ret;
-   }
-   pages[i] = pfn_to_page(pfn);
-   }
-   } else {
-   int n;
-
-   n = get_user_pages(current, current->mm, start & PAGE_MASK,
-   n_pages, dma_dir == DMA_FROM_DEVICE, 1, pages, NULL);
-   /* negative error means that no page was pinned */
-   n = max(n, 0);
-   if (n != n_pages) {
-   pr_err("got only %d of %d user pages\n", n, n_pages);
-   while (n)
-   put_page(pages[--n]);
-   return -EFAULT;
-   }
-   }
-
-   return 0;
-}
-
-static void vb2_dc_put_dirty_page(struct page *page)
-{
-   set_page_dirty_lock(page);
-   put_page(page);
-}
-
 static void vb2_dc_put_userptr(void *buf_priv)
 {
struct vb2_dc_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;
+   int i;
+   struct page **pages;

if (sgt) {
DEFINE_DMA_ATTRS(attrs);
@@ -526,15 +426,15 @@ static void vb2_dc_put_userptr(void *buf_priv)
 */
dma_unmap_sg_attrs(buf->dev, sgt->sgl, 

[PATCH 6/9] media: vb2: Convert vb2_vmalloc_get_userptr() to use frame vector

2015-05-13 Thread Jan Kara
Convert vb2_vmalloc_get_userptr() to use frame vector infrastructure.
When we are doing that there's no need to allocate page array and some
code can be simplified.

Acked-by: Marek Szyprowski 
Tested-by: Marek Szyprowski 
Signed-off-by: Jan Kara 
---
 drivers/media/v4l2-core/videobuf2-vmalloc.c | 94 +++--
 1 file changed, 36 insertions(+), 58 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c 
b/drivers/media/v4l2-core/videobuf2-vmalloc.c
index 0ba40be21ebd..d2ce81fa2cdf 100644
--- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
+++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
@@ -23,11 +23,9 @@

 struct vb2_vmalloc_buf {
void*vaddr;
-   struct page **pages;
-   struct vm_area_struct   *vma;
+   struct frame_vector *vec;
enum dma_data_direction dma_dir;
unsigned long   size;
-   unsigned intn_pages;
atomic_trefcount;
struct vb2_vmarea_handler   handler;
struct dma_buf  *dbuf;
@@ -76,10 +74,8 @@ static void *vb2_vmalloc_get_userptr(void *alloc_ctx, 
unsigned long vaddr,
 enum dma_data_direction dma_dir)
 {
struct vb2_vmalloc_buf *buf;
-   unsigned long first, last;
-   int n_pages, offset;
-   struct vm_area_struct *vma;
-   dma_addr_t physp;
+   struct frame_vector *vec;
+   int n_pages, offset, i;

buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
@@ -88,53 +84,36 @@ static void *vb2_vmalloc_get_userptr(void *alloc_ctx, 
unsigned long vaddr,
buf->dma_dir = dma_dir;
offset = vaddr & ~PAGE_MASK;
buf->size = size;
-
-   down_read(>mm->mmap_sem);
-   vma = find_vma(current->mm, vaddr);
-   if (vma && (vma->vm_flags & VM_PFNMAP) && (vma->vm_pgoff)) {
-   if (vb2_get_contig_userptr(vaddr, size, , ))
-   goto fail_pages_array_alloc;
-   buf->vma = vma;
-   buf->vaddr = (__force void *)ioremap_nocache(physp, size);
-   if (!buf->vaddr)
-   goto fail_pages_array_alloc;
+   vec = vb2_create_framevec(vaddr, size, dma_dir == DMA_FROM_DEVICE);
+   if (IS_ERR(vec))
+   goto fail_pfnvec_create;
+   buf->vec = vec;
+   n_pages = frame_vector_count(vec);
+   if (frame_vector_to_pages(vec) < 0) {
+   unsigned long *nums = frame_vector_pfns(vec);
+
+   /*
+* We cannot get page pointers for these pfns. Check memory is
+* physically contiguous and use direct mapping.
+*/
+   for (i = 1; i < n_pages; i++)
+   if (nums[i-1] + 1 != nums[i])
+   goto fail_map;
+   buf->vaddr = (__force void *)
+   ioremap_nocache(nums[0] << PAGE_SHIFT, size);
} else {
-   first = vaddr >> PAGE_SHIFT;
-   last  = (vaddr + size - 1) >> PAGE_SHIFT;
-   buf->n_pages = last - first + 1;
-   buf->pages = kzalloc(buf->n_pages * sizeof(struct page *),
-GFP_KERNEL);
-   if (!buf->pages)
-   goto fail_pages_array_alloc;
-
-   /* current->mm->mmap_sem is taken by videobuf2 core */
-   n_pages = get_user_pages(current, current->mm,
-vaddr & PAGE_MASK, buf->n_pages,
-dma_dir == DMA_FROM_DEVICE,
-1, /* force */
-buf->pages, NULL);
-   if (n_pages != buf->n_pages)
-   goto fail_get_user_pages;
-
-   buf->vaddr = vm_map_ram(buf->pages, buf->n_pages, -1,
+   buf->vaddr = vm_map_ram(frame_vector_pages(vec), n_pages, -1,
PAGE_KERNEL);
-   if (!buf->vaddr)
-   goto fail_get_user_pages;
}
-   up_read(>mm->mmap_sem);

+   if (!buf->vaddr)
+   goto fail_map;
buf->vaddr += offset;
return buf;

-fail_get_user_pages:
-   pr_debug("get_user_pages requested/got: %d/%d]\n", n_pages,
-buf->n_pages);
-   while (--n_pages >= 0)
-   put_page(buf->pages[n_pages]);
-   kfree(buf->pages);
-
-fail_pages_array_alloc:
-   up_read(>mm->mmap_sem);
+fail_map:
+   vb2_destroy_framevec(vec);
+fail_pfnvec_create:
kfree(buf);

return NULL;
@@ -145,22 +124,21 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
struct vb2_vmalloc_buf *buf = buf_priv;
unsigned long vaddr = (unsigned long)buf->vaddr & PAGE_MASK;
unsigned int i;
+   struct page **pages;
+   

[PATCH 5/9] media: vb2: Convert vb2_dma_sg_get_userptr() to use frame vector

2015-05-13 Thread Jan Kara
Acked-by: Marek Szyprowski 
Tested-by: Marek Szyprowski 
Signed-off-by: Jan Kara 
---
 drivers/media/v4l2-core/videobuf2-dma-sg.c | 97 +-
 1 file changed, 15 insertions(+), 82 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c 
b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index afd4b514affc..4ee1b3fbfe2a 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
@@ -38,6 +38,7 @@ struct vb2_dma_sg_buf {
struct device   *dev;
void*vaddr;
struct page **pages;
+   struct frame_vector *vec;
int offset;
enum dma_data_direction dma_dir;
struct sg_table sg_table;
@@ -51,7 +52,6 @@ struct vb2_dma_sg_buf {
unsigned intnum_pages;
atomic_trefcount;
struct vb2_vmarea_handler   handler;
-   struct vm_area_struct   *vma;

struct dma_buf_attachment   *db_attach;
 };
@@ -224,25 +224,17 @@ static void vb2_dma_sg_finish(void *buf_priv)
dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
 }

-static inline int vma_is_io(struct vm_area_struct *vma)
-{
-   return !!(vma->vm_flags & (VM_IO | VM_PFNMAP));
-}
-
 static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
unsigned long size,
enum dma_data_direction dma_dir)
 {
struct vb2_dma_sg_conf *conf = alloc_ctx;
struct vb2_dma_sg_buf *buf;
-   unsigned long first, last;
-   int num_pages_from_user;
-   struct vm_area_struct *vma;
struct sg_table *sgt;
DEFINE_DMA_ATTRS(attrs);
+   struct frame_vector *vec;

dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, );
-
buf = kzalloc(sizeof *buf, GFP_KERNEL);
if (!buf)
return NULL;
@@ -253,63 +245,19 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, 
unsigned long vaddr,
buf->offset = vaddr & ~PAGE_MASK;
buf->size = size;
buf->dma_sgt = >sg_table;
+   vec = vb2_create_framevec(vaddr, size, buf->dma_dir == DMA_FROM_DEVICE);
+   if (IS_ERR(vec))
+   goto userptr_fail_pfnvec;
+   buf->vec = vec;

-   first = (vaddr   & PAGE_MASK) >> PAGE_SHIFT;
-   last  = ((vaddr + size - 1) & PAGE_MASK) >> PAGE_SHIFT;
-   buf->num_pages = last - first + 1;
-
-   buf->pages = kzalloc(buf->num_pages * sizeof(struct page *),
-GFP_KERNEL);
-   if (!buf->pages)
-   goto userptr_fail_alloc_pages;
-
-   down_read(>mm->mmap_sem);
-   vma = find_vma(current->mm, vaddr);
-   if (!vma) {
-   dprintk(1, "no vma for address %lu\n", vaddr);
-   goto userptr_fail_find_vma;
-   }
-
-   if (vma->vm_end < vaddr + size) {
-   dprintk(1, "vma at %lu is too small for %lu bytes\n",
-   vaddr, size);
-   goto userptr_fail_find_vma;
-   }
-
-   buf->vma = vb2_get_vma(vma);
-   if (!buf->vma) {
-   dprintk(1, "failed to copy vma\n");
-   goto userptr_fail_find_vma;
-   }
-
-   if (vma_is_io(buf->vma)) {
-   for (num_pages_from_user = 0;
-num_pages_from_user < buf->num_pages;
-++num_pages_from_user, vaddr += PAGE_SIZE) {
-   unsigned long pfn;
-
-   if (follow_pfn(vma, vaddr, )) {
-   dprintk(1, "no page for address %lu\n", vaddr);
-   break;
-   }
-   buf->pages[num_pages_from_user] = pfn_to_page(pfn);
-   }
-   } else
-   num_pages_from_user = get_user_pages(current, current->mm,
-vaddr & PAGE_MASK,
-buf->num_pages,
-buf->dma_dir == DMA_FROM_DEVICE,
-1, /* force */
-buf->pages,
-NULL);
-   up_read(>mm->mmap_sem);
-
-   if (num_pages_from_user != buf->num_pages)
-   goto userptr_fail_get_user_pages;
+   buf->pages = frame_vector_pages(vec);
+   if (IS_ERR(buf->pages))
+   goto userptr_fail_sgtable;
+   buf->num_pages = frame_vector_count(vec);

if (sg_alloc_table_from_pages(buf->dma_sgt, buf->pages,
buf->num_pages, buf->offset, size, 0))
-   goto userptr_fail_alloc_table_from_pages;
+   goto userptr_fail_sgtable;

sgt = >sg_table;
/*
@@ -323,19 +271,9 @@ static void *vb2_dma_sg_get_userptr(void 

[PATCH 3/9] media: omap_vout: Convert omap_vout_uservirt_to_phys() to use get_vaddr_pfns()

2015-05-13 Thread Jan Kara
Convert omap_vout_uservirt_to_phys() to use get_vaddr_pfns() instead of
hand made mapping of virtual address to physical address. Also the
function leaked page reference from get_user_pages() so fix that by
properly release the reference when omap_vout_buffer_release() is
called.

Signed-off-by: Jan Kara 
---
 drivers/media/platform/omap/omap_vout.c | 67 +++--
 1 file changed, 31 insertions(+), 36 deletions(-)

diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index 17b189a81ec5..0e4b3cfacc5d 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -195,46 +195,34 @@ static int omap_vout_try_format(struct v4l2_pix_format 
*pix)
 }

 /*
- * omap_vout_uservirt_to_phys: This inline function is used to convert user
- * space virtual address to physical address.
+ * omap_vout_get_userptr: Convert user space virtual address to physical
+ * address.
  */
-static unsigned long omap_vout_uservirt_to_phys(unsigned long virtp)
+static int omap_vout_get_userptr(struct videobuf_buffer *vb, u32 virtp,
+u32 *physp)
 {
-   unsigned long physp = 0;
-   struct vm_area_struct *vma;
-   struct mm_struct *mm = current->mm;
+   struct frame_vector *vec;
+   int ret;

/* For kernel direct-mapped memory, take the easy way */
-   if (virtp >= PAGE_OFFSET)
-   return virt_to_phys((void *) virtp);
-
-   down_read(>mm->mmap_sem);
-   vma = find_vma(mm, virtp);
-   if (vma && (vma->vm_flags & VM_IO) && vma->vm_pgoff) {
-   /* this will catch, kernel-allocated, mmaped-to-usermode
-  addresses */
-   physp = (vma->vm_pgoff << PAGE_SHIFT) + (virtp - vma->vm_start);
-   up_read(>mm->mmap_sem);
-   } else {
-   /* otherwise, use get_user_pages() for general userland pages */
-   int res, nr_pages = 1;
-   struct page *pages;
+   if (virtp >= PAGE_OFFSET) {
+   *physp = virt_to_phys((void *)virtp);
+   return 0;
+   }

-   res = get_user_pages(current, current->mm, virtp, nr_pages, 1,
-   0, , NULL);
-   up_read(>mm->mmap_sem);
+   vec = frame_vector_create(1);
+   if (!vec)
+   return -ENOMEM;

-   if (res == nr_pages) {
-   physp =  __pa(page_address([0]) +
-   (virtp & ~PAGE_MASK));
-   } else {
-   printk(KERN_WARNING VOUT_NAME
-   "get_user_pages failed\n");
-   return 0;
-   }
+   ret = get_vaddr_frames(virtp, 1, true, false, vec);
+   if (ret != 1) {
+   frame_vector_destroy(vec);
+   return -EINVAL;
}
+   *physp = __pfn_to_phys(frame_vector_pfns(vec)[0]);
+   vb->priv = vec;

-   return physp;
+   return 0;
 }

 /*
@@ -788,11 +776,15 @@ static int omap_vout_buffer_prepare(struct videobuf_queue 
*q,
 * address of the buffer
 */
if (V4L2_MEMORY_USERPTR == vb->memory) {
+   int ret;
+
if (0 == vb->baddr)
return -EINVAL;
/* Physical address */
-   vout->queued_buf_addr[vb->i] = (u8 *)
-   omap_vout_uservirt_to_phys(vb->baddr);
+   ret = omap_vout_get_userptr(vb, vb->baddr,
+   (u32 *)>queued_buf_addr[vb->i]);
+   if (ret < 0)
+   return ret;
} else {
unsigned long addr, dma_addr;
unsigned long size;
@@ -841,9 +833,12 @@ static void omap_vout_buffer_release(struct videobuf_queue 
*q,
struct omap_vout_device *vout = q->priv_data;

vb->state = VIDEOBUF_NEEDS_INIT;
+   if (vb->memory == V4L2_MEMORY_USERPTR && vb->priv) {
+   struct frame_vector *vec = vb->priv;

-   if (V4L2_MEMORY_MMAP != vout->memory)
-   return;
+   put_vaddr_frames(vec);
+   frame_vector_destroy(vec);
+   }
 }

 /*
-- 
2.1.4



[PATCH 2/9] mm: Provide new get_vaddr_frames() helper

2015-05-13 Thread Jan Kara
Provide new function get_vaddr_frames().  This function maps virtual
addresses from given start and fills given array with page frame numbers of
the corresponding pages. If given start belongs to a normal vma, the function
grabs reference to each of the pages to pin them in memory. If start
belongs to VM_IO | VM_PFNMAP vma, we don't touch page structures. Caller
must make sure pfns aren't reused for anything else while he is using
them.

This function is created for various drivers to simplify handling of
their buffers.

Acked-by: Mel Gorman 
Acked-by: Vlastimil Babka 
Signed-off-by: Jan Kara 
---
 include/linux/mm.h |  44 +++
 mm/gup.c   | 226 +
 2 files changed, 270 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0755b9fd03a7..dcd1f02a78e9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 

 struct mempolicy;
 struct anon_vma;
@@ -1197,6 +1198,49 @@ long get_user_pages_unlocked(struct task_struct *tsk, 
struct mm_struct *mm,
int write, int force, struct page **pages);
 int get_user_pages_fast(unsigned long start, int nr_pages, int write,
struct page **pages);
+
+/* Container for pinned pfns / pages */
+struct frame_vector {
+   unsigned int nr_allocated;  /* Number of frames we have space for */
+   unsigned int nr_frames; /* Number of frames stored in ptrs array */
+   bool got_ref;   /* Did we pin pages by getting page ref? */
+   bool is_pfns;   /* Does array contain pages or pfns? */
+   void *ptrs[0];  /* Array of pinned pfns / pages. Use
+* pfns_vector_pages() or pfns_vector_pfns()
+* for access */
+};
+
+struct frame_vector *frame_vector_create(unsigned int nr_frames);
+void frame_vector_destroy(struct frame_vector *vec);
+int get_vaddr_frames(unsigned long start, unsigned int nr_pfns,
+bool write, bool force, struct frame_vector *vec);
+void put_vaddr_frames(struct frame_vector *vec);
+int frame_vector_to_pages(struct frame_vector *vec);
+void frame_vector_to_pfns(struct frame_vector *vec);
+
+static inline unsigned int frame_vector_count(struct frame_vector *vec)
+{
+   return vec->nr_frames;
+}
+
+static inline struct page **frame_vector_pages(struct frame_vector *vec)
+{
+   if (vec->is_pfns) {
+   int err = frame_vector_to_pages(vec);
+
+   if (err)
+   return ERR_PTR(err);
+   }
+   return (struct page **)(vec->ptrs);
+}
+
+static inline unsigned long *frame_vector_pfns(struct frame_vector *vec)
+{
+   if (!vec->is_pfns)
+   frame_vector_to_pfns(vec);
+   return (unsigned long *)(vec->ptrs);
+}
+
 struct kvec;
 int get_kernel_pages(const struct kvec *iov, int nr_pages, int write,
struct page **pages);
diff --git a/mm/gup.c b/mm/gup.c
index 6297f6bccfb1..9d7f4fde30cb 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -936,6 +937,231 @@ int __mm_populate(unsigned long start, unsigned long len, 
int ignore_errors)
return ret; /* 0 or negative error code */
 }

+/*
+ * get_vaddr_frames() - map virtual addresses to pfns
+ * @start: starting user address
+ * @nr_frames: number of pages / pfns from start to map
+ * @write: whether pages will be written to by the caller
+ * @force: whether to force write access even if user mapping is
+ * readonly. See description of the same argument of
+   get_user_pages().
+ * @vec:   structure which receives pages / pfns of the addresses mapped.
+ * It should have space for at least nr_frames entries.
+ *
+ * This function maps virtual addresses from @start and fills @vec structure
+ * with page frame numbers or page pointers to corresponding pages (choice
+ * depends on the type of the vma underlying the virtual address). If @start
+ * belongs to a normal vma, the function grabs reference to each of the pages
+ * to pin them in memory. If @start belongs to VM_IO | VM_PFNMAP vma, we don't
+ * touch page structures and the caller must make sure pfns aren't reused for
+ * anything else while he is using them.
+ *
+ * The function returns number of pages mapped which may be less than
+ * @nr_frames. In particular we stop mapping if there are more vmas of
+ * different type underlying the specified range of virtual addresses.
+ * When the function isn't able to map a single page, it returns error.
+ *
+ * This function takes care of grabbing mmap_sem as necessary.
+ */
+int get_vaddr_frames(unsigned long start, unsigned int nr_frames,
+bool write, bool force, struct frame_vector *vec)
+{
+   struct mm_struct *mm = current->mm;
+   struct vm_area_struct *vma;
+   int 

[PATCH 1/9] [media] vb2: Push mmap_sem down to memops

2015-05-13 Thread Jan Kara
Currently vb2 core acquires mmap_sem just around call to
__qbuf_userptr(). However since commit f035eb4e976ef5 (videobuf2: fix
lockdep warning) it isn't necessary to acquire it so early as we no
longer have to drop queue mutex before acquiring mmap_sem. So push
acquisition of mmap_sem down into .get_userptr and .put_userptr memops
so that the semaphore is acquired for a shorter time and it is clearer
what it is needed for.

Signed-off-by: Jan Kara 
---
 drivers/media/v4l2-core/videobuf2-core.c   | 2 --
 drivers/media/v4l2-core/videobuf2-dma-contig.c | 7 +++
 drivers/media/v4l2-core/videobuf2-dma-sg.c | 6 ++
 drivers/media/v4l2-core/videobuf2-vmalloc.c| 6 +-
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 66ada01c796c..20cdbc0900ea 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1657,9 +1657,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
ret = __qbuf_mmap(vb, b);
break;
case V4L2_MEMORY_USERPTR:
-   down_read(>mm->mmap_sem);
ret = __qbuf_userptr(vb, b);
-   up_read(>mm->mmap_sem);
break;
case V4L2_MEMORY_DMABUF:
ret = __qbuf_dmabuf(vb, b);
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c 
b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 644dec73d220..620c4aa78881 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -532,7 +532,9 @@ static void vb2_dc_put_userptr(void *buf_priv)
sg_free_table(sgt);
kfree(sgt);
}
+   down_read(>mm->mmap_sem);
vb2_put_vma(buf->vma);
+   up_read(>mm->mmap_sem);
kfree(buf);
 }

@@ -616,6 +618,7 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned 
long vaddr,
goto fail_buf;
}

+   down_read(>mm->mmap_sem);
/* current->mm->mmap_sem is taken by videobuf2 core */
vma = find_vma(current->mm, vaddr);
if (!vma) {
@@ -642,6 +645,7 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned 
long vaddr,
if (ret) {
unsigned long pfn;
if (vb2_dc_get_user_pfn(start, n_pages, vma, ) == 0) {
+   up_read(>mm->mmap_sem);
buf->dma_addr = vb2_dc_pfn_to_dma(buf->dev, pfn);
buf->size = size;
kfree(pages);
@@ -651,6 +655,7 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned 
long vaddr,
pr_err("failed to get user pages\n");
goto fail_vma;
}
+   up_read(>mm->mmap_sem);

sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
if (!sgt) {
@@ -713,10 +718,12 @@ fail_get_user_pages:
while (n_pages)
put_page(pages[--n_pages]);

+   down_read(>mm->mmap_sem);
 fail_vma:
vb2_put_vma(buf->vma);

 fail_pages:
+   up_read(>mm->mmap_sem);
kfree(pages); /* kfree is NULL-proof */

 fail_buf:
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c 
b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index 45c708e463b9..afd4b514affc 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
@@ -263,6 +263,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, 
unsigned long vaddr,
if (!buf->pages)
goto userptr_fail_alloc_pages;

+   down_read(>mm->mmap_sem);
vma = find_vma(current->mm, vaddr);
if (!vma) {
dprintk(1, "no vma for address %lu\n", vaddr);
@@ -301,6 +302,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, 
unsigned long vaddr,
 1, /* force */
 buf->pages,
 NULL);
+   up_read(>mm->mmap_sem);

if (num_pages_from_user != buf->num_pages)
goto userptr_fail_get_user_pages;
@@ -328,8 +330,10 @@ userptr_fail_get_user_pages:
if (!vma_is_io(buf->vma))
while (--num_pages_from_user >= 0)
put_page(buf->pages[num_pages_from_user]);
+   down_read(>mm->mmap_sem);
vb2_put_vma(buf->vma);
 userptr_fail_find_vma:
+   up_read(>mm->mmap_sem);
kfree(buf->pages);
 userptr_fail_alloc_pages:
kfree(buf);
@@ -362,7 +366,9 @@ static void vb2_dma_sg_put_userptr(void *buf_priv)
put_page(buf->pages[i]);
}
kfree(buf->pages);
+   down_read(>mm->mmap_sem);
vb2_put_vma(buf->vma);
+   up_read(>mm->mmap_sem);
kfree(buf);
 }

diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c 
b/drivers/media/v4l2-core/videobuf2-vmalloc.c
index 

[PATCH 0/9 v5] Helper to abstract vma handling in media layer

2015-05-13 Thread Jan Kara
  Hello,

I'm sending the fifth version of my patch series to abstract vma handling
from the various media drivers. The patches got some review from mm people and
testing from device driver guys so unless someone objects, patches will be
queued in media tree for the next merge window.

After this patch set drivers have to know much less details about vmas, their
types, and locking. Also quite some code is removed from them. As a bonus
drivers get automatically VM_FAULT_RETRY handling. The primary motivation for
this series is to remove knowledge about mmap_sem locking from as many places a
possible so that we can change it with reasonable effort.

The core of the series is the new helper get_vaddr_frames() which is given a
virtual address and it fills in PFNs / struct page pointers (depending on VMA
type) into the provided array. If PFNs correspond to normal pages it also grabs
references to these pages. The difference from get_user_pages() is that this
function can also deal with pfnmap, and io mappings which is what the media
drivers need.

I have tested the patches with vivid driver so at least vb2 code got some
exposure. Conversion of other drivers was just compile-tested (for x86 so e.g.
exynos driver which is only for Samsung platform is completely untested).

Honza
Changes since v4:
* Minor cleanups and fixes pointed out by Mel and Vlasta
* Added Acked-by tags

Changes since v3:
* Added include  into mm/gup.c as it's needed for some archs
* Fixed error path for exynos driver

Changes since v2:
* Renamed functions and structures as Mel suggested
* Other minor changes suggested by Mel
* Rebased on top of 4.1-rc2
* Changed functions to get pointer to array of pages / pfns to perform
  conversion if necessary. This fixes possible issue in the omap I may have
  introduced in v2 and generally makes the API less errorprone.


[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Thomas Gummerer
Sudip Mukherjee  writes:

> On Wed, May 13, 2015 at 11:53:19AM +0200, Jan Niehusmann wrote:
>> Apr 30 08:50:23 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
>> [i915]] *ERROR* CPU pipe B FIFO underrun
>> Apr 30 08:50:23 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
>> [i915]] *ERROR* PCH transcoder B FIFO underrun
>> Apr 30 08:50:29 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
>> [i915]] *ERROR* CPU pipe A FIFO underrun
>> Apr 30 08:50:29 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
>> [i915]] *ERROR* PCH transcoder A FIFO underrun
> hi,
> I also have the similar entries in my dmesg, though my problem is a
> little different from yours and my bisect lead to another commit.
> And that also is still not fixed (last tested with 4.0).
>
> http://patchwork.freedesktop.org/patch/46071/

Thank you for the pointer, but this seems to be an unrelated issue.  I
tried applying the patch, but it doesn't fix the issues that I'm
experiencing.

> regards
> sudip


[PATCH 2/2] drm/exynos: 'win' is always unsigned

2015-05-13 Thread Inki Dae
On 2015년 05월 12일 03:04, Tobias Jakobi wrote:
> Hey Inki,
> 
> Inki Dae wrote:
>> On 2015년 05월 06일 21:10, Tobias Jakobi wrote:
>>> The index for the hardware layer is always >=0. Previous
>>> code that also used -1 as special index is now gone.
>>>
>>> Also apply this to 'ch_enabled' (decon/fimd), since the
>>> variable is on the same line (and is again always unsigned).
>>
>> I can see below error with checkpatch.pl,
>>
>> WARNING: line over 80 characters
>> #125: FILE: drivers/gpu/drm/exynos/exynos_drm_fimd.c:232:
>> +static void fimd_enable_shadow_channel_path(struct fimd_context *ctx,
>> unsigned int win,
>>
>> WARNING: line over 80 characters
>> #147: FILE: drivers/gpu/drm/exynos/exynos_mixer.c:336:
>> +static void mixer_cfg_layer(struct mixer_context *ctx, unsigned int
>> win, bool enable)
>>
>> Please check coding style with checkpath.pl before posting it next time.
>> I modified and merged them.
> sorry, I'm going to check more thoroughly next time.
> 
> Also, I think you might have missed one of my cleanup patches:
> https://patchwork.kernel.org/patch/6275111/

Right, that is one I missed. Applied.

> 
> At least I haven't seen it yet in for-next or fixes.
> 
> And if you could say a few words about the layer rework series
> (http://www.spinics.net/lists/linux-samsung-soc/msg44199.html), that
> would be great! :)
> 

Got it. I will take a look at this patch series soon.

Thanks,
Inki Dae

> 
> 
> With best wishes,
> Tobias
> 
>>
>> Thanks,
>> Inki Dae
>>
>>>
>>> Signed-off-by: Tobias Jakobi 
>>> ---
>>>  drivers/gpu/drm/exynos/exynos7_drm_decon.c | 2 +-
>>>  drivers/gpu/drm/exynos/exynos_drm_fimd.c   | 6 +++---
>>>  drivers/gpu/drm/exynos/exynos_mixer.c  | 6 +++---
>>>  3 files changed, 7 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
>>> b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
>>> index 1f7e33f..5c0b2cc 100644
>>> --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
>>> +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
>>> @@ -91,7 +91,7 @@ static void decon_wait_for_vblank(struct exynos_drm_crtc 
>>> *crtc)
>>>  
>>>  static void decon_clear_channel(struct decon_context *ctx)
>>>  {
>>> -   int win, ch_enabled = 0;
>>> +   unsigned int win, ch_enabled = 0;
>>>  
>>> DRM_DEBUG_KMS("%s\n", __FILE__);
>>>  
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
>>> b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>>> index 9819fa6..ee11ea6 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>>> @@ -216,7 +216,7 @@ static void fimd_wait_for_vblank(struct exynos_drm_crtc 
>>> *crtc)
>>> DRM_DEBUG_KMS("vblank wait timed out.\n");
>>>  }
>>>  
>>> -static void fimd_enable_video_output(struct fimd_context *ctx, int win,
>>> +static void fimd_enable_video_output(struct fimd_context *ctx, unsigned 
>>> int win,
>>> bool enable)
>>>  {
>>> u32 val = readl(ctx->regs + WINCON(win));
>>> @@ -229,7 +229,7 @@ static void fimd_enable_video_output(struct 
>>> fimd_context *ctx, int win,
>>> writel(val, ctx->regs + WINCON(win));
>>>  }
>>>  
>>> -static void fimd_enable_shadow_channel_path(struct fimd_context *ctx, int 
>>> win,
>>> +static void fimd_enable_shadow_channel_path(struct fimd_context *ctx, 
>>> unsigned int win,
>>> bool enable)
>>>  {
>>> u32 val = readl(ctx->regs + SHADOWCON);
>>> @@ -244,7 +244,7 @@ static void fimd_enable_shadow_channel_path(struct 
>>> fimd_context *ctx, int win,
>>>  
>>>  static void fimd_clear_channel(struct fimd_context *ctx)
>>>  {
>>> -   int win, ch_enabled = 0;
>>> +   unsigned int win, ch_enabled = 0;
>>>  
>>> DRM_DEBUG_KMS("%s\n", __FILE__);
>>>  
>>> diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
>>> b/drivers/gpu/drm/exynos/exynos_mixer.c
>>> index ff15702..4a1656b 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_mixer.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_mixer.c
>>> @@ -333,7 +333,7 @@ static void mixer_cfg_rgb_fmt(struct mixer_context 
>>> *ctx, unsigned int height)
>>> mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_RGB_FMT_MASK);
>>>  }
>>>  
>>> -static void mixer_cfg_layer(struct mixer_context *ctx, int win, bool 
>>> enable)
>>> +static void mixer_cfg_layer(struct mixer_context *ctx, unsigned int win, 
>>> bool enable)
>>>  {
>>> struct mixer_resources *res = >mixer_res;
>>> u32 val = enable ? ~0 : 0;
>>> @@ -379,7 +379,7 @@ static void mixer_stop(struct mixer_context *ctx)
>>> usleep_range(1, 12000);
>>>  }
>>>  
>>> -static void vp_video_buffer(struct mixer_context *ctx, int win)
>>> +static void vp_video_buffer(struct mixer_context *ctx, unsigned int win)
>>>  {
>>> struct mixer_resources *res = >mixer_res;
>>> unsigned long flags;
>>> @@ -511,7 +511,7 @@ fail:
>>> return -ENOTSUPP;
>>>  }
>>>  
>>> -static void mixer_graph_buffer(struct mixer_context *ctx, int win)
>>> +static void 

[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Thomas Gummerer
Jan Niehusmann  writes:

> Hi,
>
> On Wed, May 13, 2015 at 12:14:39PM +0300, Jani Nikula wrote:
>> Is this the same as https://bugzilla.kernel.org/show_bug.cgi?id=98141 ?
>
> The visible effect in the video is similar to what I see on the LVDS
> display. I also see some influence of the mouse pointer position on the
> blanked areas.

I can see the same thing, though it looks slightly different to me, but
the slight difference might be unrelated.

> The effect on the external screen is more like single scan
> lines jumping to the right and back, at a high (but still visible)
> frequency.

I don't see the behavior on my external screen.  Maybe some more
information that might help:

The laptop is a dell XPS 15 9530, screen resolution 3200x1800.  The
external display is connected via DisplayPort, resulution 1920x1080.
Output from lspci:

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor 
DRAM Controller (rev 06)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor 
PCI Express x16 Controller (rev 06)
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor 
Integrated Graphics Controller (rev 06)
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor 
HD Audio Controller (rev 06)
00:04.0 Signal processing controller: Intel Corporation Device 0c03 (rev 06)
00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family 
USB xHCI (rev 05)
00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series 
Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family 
USB EHCI #2 (rev 05)
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High 
Definition Audio Controller (rev 05)
00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI 
Express Root Port #1 (rev d5)
00:1c.2 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI 
Express Root Port #3 (rev d5)
00:1c.3 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI 
Express Root Port #4 (rev d5)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family 
USB EHCI #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation HM87 Express LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 
6-port SATA Controller 1 [AHCI mode] (rev 05)
00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus 
Controller (rev 05)
00:1f.6 Signal processing controller: Intel Corporation 8 Series Chipset Family 
Thermal Management Controller (rev 05)
02:00.0 3D controller: NVIDIA Corporation GK107M [GeForce GT 750M] (rev a1)
06:00.0 Network controller: Intel Corporation Wireless 7260 (rev 6b)
07:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5249 PCI 
Express Card Reader (rev 01)

> What I'm missing in the report, are some log entries I'm seeing on my
> notebook:
>
> Apr 30 08:50:23 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
> [i915]] *ERROR* CPU pipe B FIFO underrun
> Apr 30 08:50:23 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
> [i915]] *ERROR* PCH transcoder B FIFO underrun
> Apr 30 08:50:29 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
> [i915]] *ERROR* CPU pipe A FIFO underrun
> Apr 30 08:50:29 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
> [i915]] *ERROR* PCH transcoder A FIFO underrun

I see the last two messages in my dmesg output, but not the first two.

>
> Jan


[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Jan Niehusmann
On Wed, May 13, 2015 at 04:02:25PM +0530, Sudip Mukherjee wrote:
> > What I'm missing in the report, are some log entries I'm seeing on my
> > notebook:
> > 
> > Apr 30 08:50:23 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
> > [i915]] *ERROR* CPU pipe B FIFO underrun
> > Apr 30 08:50:23 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
> > [i915]] *ERROR* PCH transcoder B FIFO underrun
> > Apr 30 08:50:29 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
> > [i915]] *ERROR* CPU pipe A FIFO underrun
> > Apr 30 08:50:29 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
> > [i915]] *ERROR* PCH transcoder A FIFO underrun
> hi,
> I also have the similar entries in my dmesg, though my problem is a
> little different from yours and my bisect lead to another commit.
> And that also is still not fixed (last tested with 4.0).

(Please note that I didn't do a bisect - that was Thomas. I only noted
that I can confirm his observations and that his patch helps to prevent
or hide the issue.)

Perhaps these are two completely unrelated issues?

Jan



[PATCH v2 2/2] drm: Make Legacy Context access functions optional.

2015-05-13 Thread Ville Syrjälä
On Wed, May 13, 2015 at 09:19:09AM +0200, Daniel Vetter wrote:
> On Wed, May 13, 2015 at 07:54:48AM +0100, Peter Antoine wrote:
> > As these functions are only used by one driver and there are security holes
> > in these functions. Make the functions optional.
> > 
> > These changes are based on the two patches:
> >   commit c21eb21cb50d58e7cbdcb8b9e7ff68b85cfa5095
> >   Author: Dave Airlie 
> > 
> > And the commit that the above patch reverts:
> >   commit 7c510133d93dd6f15ca040733ba7b2891ed61fd1
> >   Author: Daniel Vetter 
> > 
> > This should now turn off the context feature.
> > 
> > Issue: VIZ-5485
> > Signed-off-by: Peter Antoine 
> 
> Please cc drm core patches to dri-devel. Review below.
> -Daniel
> 
> > ---
> >  drivers/gpu/drm/drm_context.c | 36 
> >  drivers/gpu/drm/drm_drv.c | 12 +++-
> >  2 files changed, 43 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> > index 9b23525..574be2a 100644
> > --- a/drivers/gpu/drm/drm_context.c
> > +++ b/drivers/gpu/drm/drm_context.c
> > @@ -53,6 +53,9 @@ struct drm_ctx_list {
> >   */
> >  void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
> >  {
> > +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> > +   return -EINVAL;
> 
> This doesn't compile too well. Also like with the previous patch, drivers
> without DRIVER_MODESET still need these ioctls.

Only via actually needs them AFAIK, but continuing to allow them for the
rest of the old drivers is no worse than what we have today.

And I think nouveau just needs a nop create/destroy ioctls, so I think
we should really just make those two nops for nouveau (or maybe for all
modern drivers?) and reject the rest of the ioctls even for nouveau.

-- 
Ville Syrjälä
Intel OTC


[PATCH] drm/dp: Fix comment in DP helper

2015-05-13 Thread Jon Hunter
Commit 4f71d0cb76339 ("drm/dp: add a hw mutex around the transfer
functions. (v2)"), renamed the functions drm_dp_aux_register_i2c_bus()
and drm_dp_aux_unregister_i2c_bus() to drm_dp_aux_register() and
drm_dp_aux_unregister(), respectively. However, a comment referring to
the original names was not updated in the DP helper header file. Hence,
correct these names.

Signed-off-by: Jon Hunter 
---
 include/drm/drm_dp_helper.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 523f04c90dea..2e86f642fc33 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -679,9 +679,9 @@ struct drm_dp_aux_msg {
  * An AUX channel can also be used to transport I2C messages to a sink. A
  * typical application of that is to access an EDID that's present in the
  * sink device. The .transfer() function can also be used to execute such
- * transactions. The drm_dp_aux_register_i2c_bus() function registers an
- * I2C adapter that can be passed to drm_probe_ddc(). Upon removal, drivers
- * should call drm_dp_aux_unregister_i2c_bus() to remove the I2C adapter.
+ * transactions. The drm_dp_aux_register() function registers an I2C
+ * adapter that can be passed to drm_probe_ddc(). Upon removal, drivers
+ * should call drm_dp_aux_unregister() to remove the I2C adapter.
  * The I2C adapter uses long transfers by default; if a partial response is
  * received, the adapter will drop down to the size given by the partial
  * response for this transaction only.
-- 
1.9.1



[PATCH early RFC 1/2] ASoC: hdmi-codec-lib: Add hdmi-codec-lib for external HDMI-encoders

2015-05-13 Thread Jyri Sarha
The hdmi-codec-lib is a library for registering an ASoC codec under an
external HDMI encoder driver with I2S and/or spdif interface.

The structures and definitions in the API header are mostly redundant
copies of similar structures in ASoC headers. This is on purpose to
avoid direct dependencies to ASoC structures in video side driver.

Signed-off-by: Jyri Sarha 
---
 include/sound/hdmi-codec-lib.h| 105 
 sound/soc/codecs/Kconfig  |   4 +
 sound/soc/codecs/Makefile |   2 +
 sound/soc/codecs/hdmi-codec-lib.c | 536 ++
 4 files changed, 647 insertions(+)
 create mode 100644 include/sound/hdmi-codec-lib.h
 create mode 100644 sound/soc/codecs/hdmi-codec-lib.c

diff --git a/include/sound/hdmi-codec-lib.h b/include/sound/hdmi-codec-lib.h
new file mode 100644
index 000..9acf9f7
--- /dev/null
+++ b/include/sound/hdmi-codec-lib.h
@@ -0,0 +1,105 @@
+/*
+ * hdmi-codec-lib.h - HDMI codec library API
+ *
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Author: Jyri Sarha 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef __HDMI_CODEC_LIB_H__
+#define __HDMI_CODEC_LIB_H__
+
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * Protocol between ASoC cpu-dai and HDMI-encoder
+ */
+struct hdmi_codec_daifmt {
+   enum {
+   HDMI_I2S,
+   HDMI_RIGHT_J,
+   HDMI_LEFT_J,
+   HDMI_DSP_A,
+   HDMI_DSP_B,
+   HDMI_AC97,
+   HDMI_SPDIF,
+   } fmt;
+   int bit_clk_inv:1;
+   int frame_clk_inv:1;
+   int bit_clk_master:1;
+   int frame_clk_master:1;
+};
+
+/*
+ * HDMI audio parameters
+ */
+struct hdmi_codec_params {
+   struct hdmi_audio_infoframe cea;
+   struct snd_aes_iec958 iec;
+   int sample_rate;
+   int sample_width;
+   int channels;
+};
+
+struct hdmi_codec_ops {
+   /* For runtime clock configuration from ASoC machine driver.
+* A direct forward from set_sysclk in struct snd_soc_dai_ops.
+* Optional */
+   int (*set_clk)(struct device *dev, int clk_id, int freq);
+
+   /* Called when ASoC starts an audio stream setup. The call
+* provides an audio abort callback for stoping an ongoing
+* stream if the HDMI audio becomes unavailable.
+* Optional */
+   int (*audio_startup)(struct device *dev,
+void (*abort_cb)(struct device *dev));
+
+   /* Configures HDMI-encoder for audio stream.
+* Mandatory */
+   int (*hw_params)(struct device *dev,
+struct hdmi_codec_daifmt *fmt,
+struct hdmi_codec_params *hparms);
+
+   /* Shuts down the audio stream.
+* Mandatory */
+   void (*audio_shutdown)(struct device *dev);
+
+   /* Mute/unmute HDMI audio stream.
+* Optional */
+   int (*digital_mute)(struct device *dev, bool enable);
+
+   /* Provides EDID short audio descriptors from connected HDMI device.
+* Optional */
+   int (*get_sads)(struct device *dev, struct cea_sad **sads);
+};
+
+/* HDMI codec initalization data */
+struct hdmi_codec_data {
+   struct device *dev; /* The HDMI encoder registering the codec */
+   const struct hdmi_codec_ops *ops;
+   uint i2s:1;
+   uint spdif:1;
+   int max_i2s_channels;
+};
+
+/* Has to be the first member of the hdmi endcoder's drvdata */
+struct hdmi_codec_drvdata {
+   void *codec_data;
+};
+
+int asoc_hdmi_codec_register(struct hdmi_codec_data *data);
+void asoc_hdmi_codec_unregister(struct device *dev);
+
+#endif /* __HDMI_CODEC_LIB_H__ */
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 061c465..05fabf4 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -77,6 +77,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_MC13783 if MFD_MC13XXX
select SND_SOC_ML26124 if I2C
select SND_SOC_HDMI_CODEC
+   select SND_SOC_HDMI_CODEC_LIB
select SND_SOC_PCM1681 if I2C
select SND_SOC_PCM1792A if SPI_MASTER
select SND_SOC_PCM3008
@@ -433,6 +434,9 @@ config SND_SOC_DMIC
 config SND_SOC_HDMI_CODEC
tristate "HDMI stub CODEC"

+config SND_SOC_HDMI_CODEC_LIB
+   tristate "lib for HDMI encoders with i2s or spdif interface"
+
 config SND_SOC_ES8328
tristate "Everest Semi ES8328 CODEC"

diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index abe2d7e..ed1c15d 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -70,6 

[PATCH early RFC 0/2] Implement ASoC HDMI codec library

2015-05-13 Thread Jyri Sarha
This is on early RFC and should not be merged yet. The idea is just
to share my ideas early on as there has been a lot of development
going on around HDMI audio.

The I2S DAI of the ASoC side patch is usable already, the spdif
support has not been tested and the EDID SADs handling should use
Russel's DRM ELD helper when it is ready.

The tda998x patch is just to demonstrate the usage of the
HDMI-codec-lib. At least the audio related DT-bindings are missing
completely and the configuration is hard coded to work on
Beaglebone-Black.

Jean-Francois, would you consider trying the generic ASoC patch with
your HW, as I can not test the spdif functionality with mine?

The library could also be implemented as a separate platform driver,
but then adding a pointer for private data to struct
snd_soc_dai_driver, snd_soc_codec, or to snd_soc_component would be of
great help.

These patches, my tilcdc refactoring[1], and my latest BCLK fixes for
davinci-mcasp diver [2], can found in a branch that produces a working
HDMI audio on Beaglebone-Black here:

https://github.com/jsarha/linux.git linux-master-bbb-hdmi-20150512

[1] http://lists.freedesktop.org/archives/dri-devel/2015-May/082537.html
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2015-April/090974.html

Jyri Sarha (2):
  ASoC: hdmi-codec-lib: Add hdmi-codec-lib for external HDMI-encoders
  drm/i2c: tda998x: HACK Implement primitive HDMI audio with ASoC
hdmi-code-lib

 drivers/gpu/drm/i2c/Kconfig   |   1 +
 drivers/gpu/drm/i2c/tda998x_drv.c | 238 +
 include/sound/hdmi-codec-lib.h| 105 
 sound/soc/codecs/Kconfig  |   4 +
 sound/soc/codecs/Makefile |   2 +
 sound/soc/codecs/hdmi-codec-lib.c | 536 ++
 6 files changed, 886 insertions(+)
 create mode 100644 include/sound/hdmi-codec-lib.h
 create mode 100644 sound/soc/codecs/hdmi-codec-lib.c

-- 
1.9.1



[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Jani Nikula
On Tue, 12 May 2015, Thomas Gummerer  wrote:
> Hi,
>
> I noticed that on my machine the screen starts to flicker after I
> suspend and resume my machine, on the main laptop display if an external
> display is attached with kernel v4.1-rc1.  I tracked the regression down
> to commit c9f038a1a592 ("drm/i915: Don't assume primary & cursor are
> always on for wm calculation (v4)"), and sent a patch that fixes that
> behavior at [1] about two weeks ago, although I'm not sure it's the
> right thing to do, as I'm not very familiar with the code.  The same bug
> still exists in vv4.1-rc3.
>
> Jan Niehusmann confirmed the behavior, but there has been no further
> discussion on the topic.  I also forgot to cc the people that were
> involved in the patch that caused the regression (sorry about that).
>
> Is there anything else that I can do to help fixing this issue?

Is this the same as https://bugzilla.kernel.org/show_bug.cgi?id=98141 ?

BR,
Jani.


>
> Thanks,
> Thomas
>
> [1] http://lists.freedesktop.org/archives/intel-gfx/2015-April/065494.html

-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH v6 06/11] cec: add HDMI CEC framework

2015-05-13 Thread Sean Young
On Mon, May 04, 2015 at 07:32:59PM +0200, Kamil Debski wrote:
> From: Hans Verkuil 
> 
> The added HDMI CEC framework provides a generic kernel interface for
> HDMI CEC devices.
> 
> Signed-off-by: Hans Verkuil 

-snip-

> +int cec_create_adapter(struct cec_adapter *adap, const char *name, u32 caps)
> +{
> + int res = 0;
> +
> + adap->state = CEC_ADAP_STATE_DISABLED;
> + adap->name = name;
> + adap->phys_addr = 0x;
> + adap->capabilities = caps;
> + adap->version = CEC_VERSION_1_4;
> + adap->sequence = 0;
> + mutex_init(>lock);
> + adap->kthread = kthread_run(cec_thread_func, adap, name);
> + init_waitqueue_head(>kthread_waitq);
> + init_waitqueue_head(>waitq);
> + if (IS_ERR(adap->kthread)) {
> + pr_err("cec-%s: kernel_thread() failed\n", name);
> + return PTR_ERR(adap->kthread);
> + }
> + if (caps) {
> + res = cec_devnode_register(>devnode, adap->owner);
> + if (res)
> + kthread_stop(adap->kthread);
> + }
> + adap->recv_notifier = cec_receive_notify;
> +
> + /* Prepare the RC input device */
> + adap->rc = rc_allocate_device();
> + if (!adap->rc) {
> + pr_err("cec-%s: failed to allocate memory for rc_dev\n", name);
> + cec_devnode_unregister(>devnode);
> + kthread_stop(adap->kthread);
> + return -ENOMEM;
> + }
> +
> + snprintf(adap->input_name, sizeof(adap->input_name), "RC for %s", name);
> + snprintf(adap->input_phys, sizeof(adap->input_phys), "%s/input0", name);
> + strncpy(adap->input_drv, name, sizeof(adap->input_drv));
> +
> + adap->rc->input_name = adap->input_name;
> + adap->rc->input_phys = adap->input_phys;
> + adap->rc->dev.parent = >devnode.dev;
> + adap->rc->driver_name = adap->input_drv;
> + adap->rc->driver_type = RC_DRIVER_CEC;
> + adap->rc->allowed_protocols = RC_BIT_CEC;
> + adap->rc->priv = adap;
> + adap->rc->map_name = RC_MAP_CEC;
> + adap->rc->timeout = MS_TO_NS(100);
> +

rc->input_id is not populated. It would be nice if input_phys has some 
resemblance to a physical path (like the output of usb_make_path() if it
is a usb device).

> + res = rc_register_device(adap->rc);
> +
> + if (res) {
> + pr_err("cec-%s: failed to prepare input device\n", name);
> + cec_devnode_unregister(>devnode);
> + rc_free_device(adap->rc);
> + kthread_stop(adap->kthread);
> + }
> +
> + return res;
> +}
> +EXPORT_SYMBOL_GPL(cec_create_adapter);
> +
> +void cec_delete_adapter(struct cec_adapter *adap)
> +{
> + if (adap->kthread == NULL)
> + return;
> + kthread_stop(adap->kthread);
> + if (adap->kthread_config)
> + kthread_stop(adap->kthread_config);
> + adap->state = CEC_ADAP_STATE_DISABLED;
> + if (cec_devnode_is_registered(>devnode))
> + cec_devnode_unregister(>devnode);

I think you're missing a rc_unregister_device() here.

> +}
> +EXPORT_SYMBOL_GPL(cec_delete_adapter);


Sean


[BUG/REGRESSION] Screen flickering

2015-05-13 Thread Jan Niehusmann
Hi,

On Wed, May 13, 2015 at 12:14:39PM +0300, Jani Nikula wrote:
> Is this the same as https://bugzilla.kernel.org/show_bug.cgi?id=98141 ?

The visible effect in the video is similar to what I see on the LVDS
display. I also see some influence of the mouse pointer position on the
blanked areas.

The effect on the external screen is more like single scan
lines jumping to the right and back, at a high (but still visible)
frequency.

What I'm missing in the report, are some log entries I'm seeing on my
notebook:

Apr 30 08:50:23 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
[i915]] *ERROR* CPU pipe B FIFO underrun
Apr 30 08:50:23 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
[i915]] *ERROR* PCH transcoder B FIFO underrun
Apr 30 08:50:29 localhost kernel: [drm:intel_cpu_fifo_underrun_irq_handler 
[i915]] *ERROR* CPU pipe A FIFO underrun
Apr 30 08:50:29 localhost kernel: [drm:intel_pch_fifo_underrun_irq_handler 
[i915]] *ERROR* PCH transcoder A FIFO underrun

Jan



[PATCH v6 06/11] cec: add HDMI CEC framework

2015-05-13 Thread Hans Verkuil
Typo and question:

On 05/04/15 19:32, Kamil Debski wrote:
> +static long cec_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> +{
> + struct cec_devnode *cecdev = cec_devnode_data(filp);
> + struct cec_adapter *adap = to_cec_adapter(cecdev);
> + void __user *parg = (void __user *)arg;
> + int err;
> +
> + if (!cec_devnode_is_registered(cecdev))
> + return -EIO;
> +
> + switch (cmd) {

snip

> + case CEC_G_ADAP_STATE: {
> + u32 state = adap->state != CEC_ADAP_STATE_DISABLED;
> +
> + if (copy_to_user(parg, , sizeof(state)))
> + return -EFAULT;
> + break;
> + }
> +
> + case CEC_S_ADAP_STATE: {
> + u32 state;
> +
> + if (!(adap->capabilities & CEC_CAP_STATE))
> + return -ENOTTY;
> + if (copy_from_user(, parg, sizeof(state)))
> + return -EFAULT;
> + if (!state && adap->state == CEC_ADAP_STATE_DISABLED)
> + return 0;
> + if (state && adap->state != CEC_ADAP_STATE_DISABLED)
> + return 0;
> + cec_enable(adap, !!state);
> + break;
> + }
> +
> + case CEC_G_ADAP_PHYS_ADDR:
> + if (copy_to_user(parg, >phys_addr,
> + sizeof(adap->phys_addr)))
> + return -EFAULT;

If the adapter requires that userspace sets up the phys addr, then what
should this return if no such address has been set up?

I see two options: either 0x (which should be used if the HDMI cable
is disconnected), or return an error (perhaps ENODATA).

I think 0x might be best. This will still allow the unregistered
logical address.

Note that the comment in uapi/linux/cec.h for G_ADAP_LOG_ADDRS says that it
will return an error if the physical address is not set. That's not true
as far as I can tell, and if we go for 0x as the default in a case like
that, then it isn't necessary either to return an error.

cec_create_adapter already initialized the physical address to 0x, so
that looks good. But it should be documented in cec-ioc-g-adap-phys-addr.xml.

> + break;
> +
> + case CEC_S_ADAP_PHYS_ADDR: {
> + u16 phys_addr;
> +
> + if (!(adap->capabilities & CEC_CAP_PHYS_ADDR))
> + return -ENOTTY;
> + if (copy_from_user(_addr, parg, sizeof(phys_addr)))
> + return -EFAULT;
> + adap->phys_addr = phys_addr;
> + break;
> + }
> +
> + case CEC_G_ADAP_LOG_ADDRS: {
> + struct cec_log_addrs log_addrs;
> +
> + log_addrs.cec_version = adap->version;
> + log_addrs.num_log_addrs = adap->num_log_addrs;
> + memcpy(log_addrs.primary_device_type, adap->prim_device,
> + CEC_MAX_LOG_ADDRS);
> + memcpy(log_addrs.log_addr_type, adap->log_addr_type,
> + CEC_MAX_LOG_ADDRS);
> + memcpy(log_addrs.log_addr, adap->log_addr,
> + CEC_MAX_LOG_ADDRS);
> +
> + if (copy_to_user(parg, _addrs, sizeof(log_addrs)))
> + return -EFAULT;
> + break;
> + }
> +
> + case CEC_S_ADAP_LOG_ADDRS: {
> + struct cec_log_addrs log_addrs;
> +
> + if (!(adap->capabilities & CEC_CAP_LOG_ADDRS))
> + return -ENOTTY;
> + if (copy_from_user(_addrs, parg, sizeof(log_addrs)))
> + return -EFAULT;
> + err = cec_claim_log_addrs(adap, _addrs,
> + !(filp->f_flags & O_NONBLOCK));
> + if (err)
> + return err;
> +
> + if (copy_to_user(parg, _addrs, sizeof(log_addrs)))
> + return -EFAULT;
> + break;
> + }
> +
> + case CEC_G_VENDOR_ID:
> + if (copy_to_user(parg, >vendor_id,
> + sizeof(adap->vendor_id)))
> + return -EFAULT;

I've been reading up on this. If I understand it correctly, then this is
optional (only if a device supports vendor commands does it have to implement
this).

So if the VENDOR capability is set, then userspace *may* change it. If it is
left undefined, then no vendor commands are allowed.

I think this should be redesigned:

One CEC_CAP_VENDOR_CMDS: if set, then vendor commands are allowed.
One CEC_CAP_VENDOR_ID: userspace may set the Vendor ID. No vendor commands are
allowed as long as no vendor ID was set.

So if VENDOR_CMDS is set and VENDOR_ID isn't, then that means that the driver
will have set the vendor ID and the application can retrieve it with 
G_VENDOR_ID.
If both are set, then userspace has to provide a vendor ID before vendor 
commands
will be 

[Intel-gfx] [PATCH] drm/atomic: add drm_atomic_get_existing_*_state helpers

2015-05-13 Thread Daniel Vetter
On Wed, May 13, 2015 at 10:37:25AM +0200, Maarten Lankhorst wrote:
> There are cases where we want to test if a given object is
> part of the state, but don't want to add them if they're not.
> 
> Signed-off-by: Maarten Lankhorst 

Yeah makes sense to wrap these. Applied to topic/drm-misc, thanks.
-Daniel

> ---
>  drivers/gpu/drm/drm_atomic.c | 18 +++-
>  include/drm/drm_atomic.h | 50 
> 
>  2 files changed, 58 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 88259057f87b..47364f244dc0 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -263,13 +263,12 @@ struct drm_crtc_state *
>  drm_atomic_get_crtc_state(struct drm_atomic_state *state,
> struct drm_crtc *crtc)
>  {
> - int ret, index;
> + int ret, index = drm_crtc_index(crtc);
>   struct drm_crtc_state *crtc_state;
>  
> - index = drm_crtc_index(crtc);
> -
> - if (state->crtc_states[index])
> - return state->crtc_states[index];
> + crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
> + if (crtc_state)
> + return crtc_state;
>  
>   ret = drm_modeset_lock(>mutex, state->acquire_ctx);
>   if (ret)
> @@ -397,13 +396,12 @@ struct drm_plane_state *
>  drm_atomic_get_plane_state(struct drm_atomic_state *state,
> struct drm_plane *plane)
>  {
> - int ret, index;
> + int ret, index = drm_plane_index(plane);
>   struct drm_plane_state *plane_state;
>  
> - index = drm_plane_index(plane);
> -
> - if (state->plane_states[index])
> - return state->plane_states[index];
> + plane_state = drm_atomic_get_existing_plane_state(state, plane);
> + if (plane_state)
> + return plane_state;
>  
>   ret = drm_modeset_lock(>mutex, state->acquire_ctx);
>   if (ret)
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 953af6bd7430..6445970535ec 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -59,6 +59,56 @@ int drm_atomic_connector_set_property(struct drm_connector 
> *connector,
>   struct drm_connector_state *state, struct drm_property 
> *property,
>   uint64_t val);
>  
> +/**
> + * drm_atomic_get_existing_crtc_state - get crtc state, if it exists
> + * @state: global atomic state object
> + * @crtc: crtc to grab
> + *
> + * This function returns the crtc state for the given crtc, or NULL
> + * if the crtc is not part of the global atomic state.
> + */
> +static inline struct drm_crtc_state *
> +drm_atomic_get_existing_crtc_state(struct drm_atomic_state *state,
> +struct drm_crtc *crtc)
> +{
> + return state->crtc_states[drm_crtc_index(crtc)];
> +}
> +
> +/**
> + * drm_atomic_get_existing_plane_state - get plane state, if it exists
> + * @state: global atomic state object
> + * @plane: plane to grab
> + *
> + * This function returns the plane state for the given plane, or NULL
> + * if the plane is not part of the global atomic state.
> + */
> +static inline struct drm_plane_state *
> +drm_atomic_get_existing_plane_state(struct drm_atomic_state *state,
> + struct drm_plane *plane)
> +{
> + return state->plane_states[drm_plane_index(plane)];
> +}
> +
> +/**
> + * drm_atomic_get_existing_connector_state - get connector state, if it 
> exists
> + * @state: global atomic state object
> + * @connector: connector to grab
> + *
> + * This function returns the connector state for the given connector,
> + * or NULL if the connector is not part of the global atomic state.
> + */
> +static inline struct drm_connector_state *
> +drm_atomic_get_existing_connector_state(struct drm_atomic_state *state,
> + struct drm_connector *connector)
> +{
> + int index = drm_connector_index(connector);
> +
> + if (index >= state->num_connector)
> + return NULL;
> +
> + return state->connector_states[index];
> +}
> +
>  int __must_check
>  drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
> struct drm_crtc *crtc);
> -- 
> 2.1.0
> 
> ___
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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


[PATCH 3/3] drm/atomic: Allow drivers to subclass drm_atomic_state, v2

2015-05-13 Thread Daniel Vetter
On Wed, May 13, 2015 at 09:56:02AM +0200, Maarten Lankhorst wrote:
> Drivers may need to store the state of shared resources, such as PLLs
> or FIFO space, into the atomic state. Allow this by making it possible
> to subclass drm_atomic_state.
> 
> Changes since v1:
> - Change member names for functions to atomic_state_(alloc,clear)
> - Change __drm_atomic_state_new to drm_atomic_state_init
> - Allow free function to be overridden too, in case extra memory is
>   allocated in alloc.
> 
> Cc: dri-devel at lists.freedesktop.org
> Acked-by: Ander Conselvan de Oliveira  intel.com>
> Signed-off-by: Maarten Lankhorst 
> ---
>  drivers/gpu/drm/drm_atomic.c | 116 
> ---
>  include/drm/drm_atomic.h |   5 ++
>  include/drm/drm_crtc.h   |   6 +++
>  3 files changed, 99 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 6e3b78ee7d16..88259057f87b 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -30,7 +30,15 @@
>  #include 
>  #include 
>  
> -static void kfree_state(struct drm_atomic_state *state)
> +/**
> + * drm_atomic_state_default_free -
> + * free memory initialized by drm_atomic_state_init
> + * @state: atomic state
> + *
> + * Free all the memory allocated by drm_atomic_state_init.
> + * This is useful for drivers that subclass the atomic state.
> + */
> +void drm_atomic_state_default_free(struct drm_atomic_state *state)
>  {
>   kfree(state->connectors);
>   kfree(state->connector_states);
> @@ -38,24 +46,20 @@ static void kfree_state(struct drm_atomic_state *state)
>   kfree(state->crtc_states);
>   kfree(state->planes);
>   kfree(state->plane_states);
> - kfree(state);

Once more a naming thing: Since this doesn't free the state structure
itself I think we should call it _release. Or keep the name and also keep
the kfree(state) here and remove it from drm_atomic_state_free. I can do
that when applying if you're ok with that. lgtm otherwise.

I also merged the preceeding 2 patches to drm-misc, thanks.
-Daniel


>  }
> +EXPORT_SYMBOL(drm_atomic_state_default_free);
>  
>  /**
> - * drm_atomic_state_alloc - allocate atomic state
> + * drm_atomic_state_init - init new atomic state
>   * @dev: DRM device
> + * @state: atomic state
>   *
> - * This allocates an empty atomic state to track updates.
> + * Default implementation for filling in a new atomic state.
> + * This is useful for drivers that subclass the atomic state.
>   */
> -struct drm_atomic_state *
> -drm_atomic_state_alloc(struct drm_device *dev)
> +int
> +drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)
>  {
> - struct drm_atomic_state *state;
> -
> - state = kzalloc(sizeof(*state), GFP_KERNEL);
> - if (!state)
> - return NULL;
> -
>   /* TODO legacy paths should maybe do a better job about
>* setting this appropriately?
>*/
> @@ -92,31 +96,50 @@ drm_atomic_state_alloc(struct drm_device *dev)
>  
>   state->dev = dev;
>  
> - DRM_DEBUG_ATOMIC("Allocate atomic state %p\n", state);
> + DRM_DEBUG_ATOMIC("Allocated atomic state %p\n", state);
>  
> - return state;
> + return 0;
>  fail:
> - kfree_state(state);
> + drm_atomic_state_default_free(state);
> + return -ENOMEM;
> +}
> +EXPORT_SYMBOL(drm_atomic_state_init);
> +
> +/**
> + * drm_atomic_state_alloc - allocate atomic state
> + * @dev: DRM device
> + *
> + * This allocates an empty atomic state to track updates.
> + */
> +struct drm_atomic_state *
> +drm_atomic_state_alloc(struct drm_device *dev)
> +{
> + struct drm_mode_config *config = >mode_config;
> + struct drm_atomic_state *state;
> +
> + if (!config->funcs->atomic_state_alloc) {
> + state = kzalloc(sizeof(*state), GFP_KERNEL);
> + if (!state)
> + return NULL;
> + if (drm_atomic_state_init(dev, state) < 0) {
> + kfree(state);
> + return NULL;
> + }
> + return state;
> + }
>  
> - return NULL;
> + return config->funcs->atomic_state_alloc(dev);
>  }
>  EXPORT_SYMBOL(drm_atomic_state_alloc);
>  
>  /**
> - * drm_atomic_state_clear - clear state object
> + * drm_atomic_state_default_clear - clear base atomic state
>   * @state: atomic state
>   *
> - * When the w/w mutex algorithm detects a deadlock we need to back off and 
> drop
> - * all locks. So someone else could sneak in and change the current modeset
> - * configuration. Which means that all the state assembled in @state is no
> - * longer an atomic update to the current state, but to some arbitrary 
> earlier
> - * state. Which could break assumptions the driver's ->atomic_check likely
> - * relies on.
> - *
> - * Hence we must clear all cached state and completely start over, using this
> - * function.
> + * Default implementation for clearing atomic state.
> + * This is 

[PATCH v6 06/11] cec: add HDMI CEC framework

2015-05-13 Thread Hans Verkuil
Hi Kamil,

Here is the first cec-compliance bug report:

CEC_G_CAPS doesn't zero the reserved field!

cec.c needs a memset there.

I think this is missing in cec.c for all structs with a reserved
field in them. Only G_EVENT looks to be OK.

Regards,

Hans


[PATCH v6 06/11] cec: add HDMI CEC framework

2015-05-13 Thread Hans Verkuil
Hi Kamil,

I've started work on a cec-compliance utility and while doing that I
noticed a confusing name:

On 05/04/15 19:32, Kamil Debski wrote:
> +struct cec_caps {
> + __u32 available_log_addrs;
> + __u32 capabilities;
> + __u32 vendor_id;
> + __u8  version;
> + __u8  reserved[35];
> +};

I think 'version' should be renamed to 'cec_version' to indicate that we
are talking about the CEC version that the adapter supports, and not about
the driver version.

Regards,

Hans


[Intel-gfx] [PATCH] Documentation/drm: Update rotation property with 90/270 and description

2015-05-13 Thread Jindal, Sonika


On 5/12/2015 6:20 PM, Ville Syrjälä wrote:
> On Wed, Apr 15, 2015 at 04:05:19PM +0530, Sonika Jindal wrote:
>> Cc: dri-devel at lists.freedesktop.org
>> Signed-off-by: Sonika Jindal 
>> ---
>>   Documentation/DocBook/drm.tmpl |7 +--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
>> index f4976cd..266d50a 100644
>> --- a/Documentation/DocBook/drm.tmpl
>> +++ b/Documentation/DocBook/drm.tmpl
>> @@ -2853,9 +2853,12 @@ void intel_crt_init(struct drm_device *dev)
>>  Plane
>>  “rotation”
>>  BITMASK
>> -{ 0, "rotate-0" }, { 2, "rotate-180" }
>> +{ 0, "rotate-0" }, { 1, "rotate-90" },
>> +{ 2, "rotate-180" }, { 3, "rotate-270" }
>>  Plane
>> -TBD
>> +To set plane HW rotation. This rotation property does
>> +the plane rotation in counter clockwise direction which is
>> +inline with the way XRandr works.
>
> I would suggest moving the thing to the generci props section since we
> have omap and i915 both supporting it.
You mean in DRM properties section?
Right now, OMAP section also has rotation property. I will remove it 
from OMAP section as well if you think drm is the better place.

>
> As for the description, we should also document the reflect flags.
>
> I might write it as something like this:
> "rotate-0,rotate-90,rotate-180,rotate-270 rotate the image by the
> specified amount in degrees in a counter clockwise direction.
> reflect-x,reflect-y reflect the image along the specified axis,
> prior to rotation."
>
>>  
>>  
>>  SDVO-TV
>> --
>> 1.7.10.4
>>
>> ___
>> Intel-gfx mailing list
>> Intel-gfx at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>


[PATCH 3/3] drm/atomic: Allow drivers to subclass drm_atomic_state, v2

2015-05-13 Thread Maarten Lankhorst
Drivers may need to store the state of shared resources, such as PLLs
or FIFO space, into the atomic state. Allow this by making it possible
to subclass drm_atomic_state.

Changes since v1:
- Change member names for functions to atomic_state_(alloc,clear)
- Change __drm_atomic_state_new to drm_atomic_state_init
- Allow free function to be overridden too, in case extra memory is
  allocated in alloc.

Cc: dri-devel at lists.freedesktop.org
Acked-by: Ander Conselvan de Oliveira 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_atomic.c | 116 ---
 include/drm/drm_atomic.h |   5 ++
 include/drm/drm_crtc.h   |   6 +++
 3 files changed, 99 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 6e3b78ee7d16..88259057f87b 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -30,7 +30,15 @@
 #include 
 #include 

-static void kfree_state(struct drm_atomic_state *state)
+/**
+ * drm_atomic_state_default_free -
+ * free memory initialized by drm_atomic_state_init
+ * @state: atomic state
+ *
+ * Free all the memory allocated by drm_atomic_state_init.
+ * This is useful for drivers that subclass the atomic state.
+ */
+void drm_atomic_state_default_free(struct drm_atomic_state *state)
 {
kfree(state->connectors);
kfree(state->connector_states);
@@ -38,24 +46,20 @@ static void kfree_state(struct drm_atomic_state *state)
kfree(state->crtc_states);
kfree(state->planes);
kfree(state->plane_states);
-   kfree(state);
 }
+EXPORT_SYMBOL(drm_atomic_state_default_free);

 /**
- * drm_atomic_state_alloc - allocate atomic state
+ * drm_atomic_state_init - init new atomic state
  * @dev: DRM device
+ * @state: atomic state
  *
- * This allocates an empty atomic state to track updates.
+ * Default implementation for filling in a new atomic state.
+ * This is useful for drivers that subclass the atomic state.
  */
-struct drm_atomic_state *
-drm_atomic_state_alloc(struct drm_device *dev)
+int
+drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)
 {
-   struct drm_atomic_state *state;
-
-   state = kzalloc(sizeof(*state), GFP_KERNEL);
-   if (!state)
-   return NULL;
-
/* TODO legacy paths should maybe do a better job about
 * setting this appropriately?
 */
@@ -92,31 +96,50 @@ drm_atomic_state_alloc(struct drm_device *dev)

state->dev = dev;

-   DRM_DEBUG_ATOMIC("Allocate atomic state %p\n", state);
+   DRM_DEBUG_ATOMIC("Allocated atomic state %p\n", state);

-   return state;
+   return 0;
 fail:
-   kfree_state(state);
+   drm_atomic_state_default_free(state);
+   return -ENOMEM;
+}
+EXPORT_SYMBOL(drm_atomic_state_init);
+
+/**
+ * drm_atomic_state_alloc - allocate atomic state
+ * @dev: DRM device
+ *
+ * This allocates an empty atomic state to track updates.
+ */
+struct drm_atomic_state *
+drm_atomic_state_alloc(struct drm_device *dev)
+{
+   struct drm_mode_config *config = >mode_config;
+   struct drm_atomic_state *state;
+
+   if (!config->funcs->atomic_state_alloc) {
+   state = kzalloc(sizeof(*state), GFP_KERNEL);
+   if (!state)
+   return NULL;
+   if (drm_atomic_state_init(dev, state) < 0) {
+   kfree(state);
+   return NULL;
+   }
+   return state;
+   }

-   return NULL;
+   return config->funcs->atomic_state_alloc(dev);
 }
 EXPORT_SYMBOL(drm_atomic_state_alloc);

 /**
- * drm_atomic_state_clear - clear state object
+ * drm_atomic_state_default_clear - clear base atomic state
  * @state: atomic state
  *
- * When the w/w mutex algorithm detects a deadlock we need to back off and drop
- * all locks. So someone else could sneak in and change the current modeset
- * configuration. Which means that all the state assembled in @state is no
- * longer an atomic update to the current state, but to some arbitrary earlier
- * state. Which could break assumptions the driver's ->atomic_check likely
- * relies on.
- *
- * Hence we must clear all cached state and completely start over, using this
- * function.
+ * Default implementation for clearing atomic state.
+ * This is useful for drivers that subclass the atomic state.
  */
-void drm_atomic_state_clear(struct drm_atomic_state *state)
+void drm_atomic_state_default_clear(struct drm_atomic_state *state)
 {
struct drm_device *dev = state->dev;
struct drm_mode_config *config = >mode_config;
@@ -162,6 +185,32 @@ void drm_atomic_state_clear(struct drm_atomic_state *state)
state->plane_states[i] = NULL;
}
 }
+EXPORT_SYMBOL(drm_atomic_state_default_clear);
+
+/**
+ * drm_atomic_state_clear - clear state object
+ * @state: atomic state
+ *
+ * When the w/w mutex algorithm detects a deadlock we need to back off 

[PATCH 2/3] drm/core: get rid of -Iinclude/drm

2015-05-13 Thread Maarten Lankhorst
This results in a warning when building out of tree:
"cc1: warning: include/drm: No such file or directory [enabled by default]"

Most code already uses #include  correctly, so fix the
instances that don't.

Reported-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/Makefile| 2 --
 drivers/gpu/drm/drm_flip_work.c | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 7d4944e1a60c..4de8d9b006ec 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -2,8 +2,6 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

-ccflags-y := -Iinclude/drm
-
 drm-y   := drm_auth.o drm_bufs.o drm_cache.o \
drm_context.o drm_dma.o \
drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
diff --git a/drivers/gpu/drm/drm_flip_work.c b/drivers/gpu/drm/drm_flip_work.c
index 43d9b950ef9f..12dea16f22a8 100644
--- a/drivers/gpu/drm/drm_flip_work.c
+++ b/drivers/gpu/drm/drm_flip_work.c
@@ -21,8 +21,8 @@
  * SOFTWARE.
  */

-#include "drmP.h"
-#include "drm_flip_work.h"
+#include 
+#include 

 /**
  * drm_flip_work_allocate_task - allocate a flip-work task
-- 
2.1.0



[PATCH 1/3] drm/i915: get rid of -Iinclude/drm

2015-05-13 Thread Maarten Lankhorst
This results in a warning when building out of tree:
"cc1: warning: include/drm: No such file or directory [enabled by default]"

Most code already uses #include  correctly, so fix the
instances that don't.

Reported-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/Makefile   | 2 --
 drivers/gpu/drm/i915/i915_gem_userptr.c | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 5238deb64505..b7ddf48e1d75 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -2,8 +2,6 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

-ccflags-y := -Iinclude/drm
-
 # Please keep these build lists sorted!

 # core driver code
diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
b/drivers/gpu/drm/i915/i915_gem_userptr.c
index 1719078c763a..4039ede158be 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -22,8 +22,8 @@
  *
  */

-#include "drmP.h"
-#include "i915_drm.h"
+#include 
+#include 
 #include "i915_drv.h"
 #include "i915_trace.h"
 #include "intel_drv.h"
-- 
2.1.0



[PATCH] drm/radeon: don't do mst probing is MST isn't enabled.

2015-05-13 Thread Dave Airlie
From: Dave Airlie 

This causes an oops as we haven't initialised the mst
layer.

Reported-by: Dave Jones <
Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/radeon/radeon_dp_mst.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c 
b/drivers/gpu/drm/radeon/radeon_dp_mst.c
index 1017338..2b98ed3 100644
--- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
+++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
@@ -666,6 +666,9 @@ radeon_dp_mst_probe(struct radeon_connector 
*radeon_connector)
int ret;
u8 msg[1];

+   if (!radeon_mst)
+   return 0;
+
if (dig_connector->dpcd[DP_DPCD_REV] < 0x12)
return 0;

-- 
2.1.0



[PATCH] drm/radeon: don't do mst probing is MST isn't enabled.

2015-05-13 Thread Alex Deucher
2015-05-12 19:51 GMT-04:00 Dave Airlie :
> From: Dave Airlie 
>
> This causes an oops as we haven't initialised the mst
> layer.
>
> Reported-by: Dave Jones <
> Signed-off-by: Dave Airlie 

Applied to my fixes branch.  Thanks!

Alex

> ---
>  drivers/gpu/drm/radeon/radeon_dp_mst.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c 
> b/drivers/gpu/drm/radeon/radeon_dp_mst.c
> index 1017338..2b98ed3 100644
> --- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
> +++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
> @@ -666,6 +666,9 @@ radeon_dp_mst_probe(struct radeon_connector 
> *radeon_connector)
> int ret;
> u8 msg[1];
>
> +   if (!radeon_mst)
> +   return 0;
> +
> if (dig_connector->dpcd[DP_DPCD_REV] < 0x12)
> return 0;
>
> --
> 2.1.0
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 1/2] drm: Make HW_LOCK access functions optional.

2015-05-13 Thread Daniel Vetter
Adding dri-devel, I've forgotten to do that ...
-Daniel

On Wed, May 13, 2015 at 09:14:29AM +0200, Daniel Vetter wrote:
> On Wed, May 13, 2015 at 07:54:47AM +0100, Peter Antoine wrote:
> > As these functions are only used by one driver and there are security holes
> > in these functions. Make the functions optional.
> 
> Is there a reference for why nouveau needs hw locks too? Also have you
> done an audit of mesa history and X history to make sure there's no other
> driver accidentally using it with a modern kms driver?
> 
> > Issue: VIZ-5485
> > Signed-off-by: Peter Antoine 
> > ---
> >  drivers/gpu/drm/drm_lock.c|  6 ++
> >  drivers/gpu/drm/nouveau/nouveau_drm.c |  3 ++-
> >  include/drm/drmP.h| 23 ---
> >  3 files changed, 20 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
> > index f861361..21eb180 100644
> > --- a/drivers/gpu/drm/drm_lock.c
> > +++ b/drivers/gpu/drm/drm_lock.c
> > @@ -61,6 +61,9 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
> > struct drm_master *master = file_priv->master;
> > int ret = 0;
> >  
> > +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> 
> You also need to allow these for all legacy drivers, i.e. without
> DRIVER_MODESET.
> -Daniel
> 
> > +   return -EINVAL;
> > +
> > ++file_priv->lock_count;
> >  
> > if (lock->context == DRM_KERNEL_CONTEXT) {
> > @@ -153,6 +156,9 @@ int drm_legacy_unlock(struct drm_device *dev, void 
> > *data, struct drm_file *file_
> > struct drm_lock *lock = data;
> > struct drm_master *master = file_priv->master;
> >  
> > +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> > +   return -EINVAL;
> > +
> > if (lock->context == DRM_KERNEL_CONTEXT) {
> > DRM_ERROR("Process %d using kernel context %d\n",
> >   task_pid_nr(current), lock->context);
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
> > b/drivers/gpu/drm/nouveau/nouveau_drm.c
> > index 8904933..9624b38 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> > @@ -941,7 +941,8 @@ static struct drm_driver
> >  driver_stub = {
> > .driver_features =
> > DRIVER_USE_AGP |
> > -   DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
> > +   DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
> > +   DRIVER_KMS_LEGACY_CONTEXT,
> >  
> > .load = nouveau_drm_load,
> > .unload = nouveau_drm_unload,
> > diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> > index df6d997..3874942 100644
> > --- a/include/drm/drmP.h
> > +++ b/include/drm/drmP.h
> > @@ -137,17 +137,18 @@ void drm_err(const char *format, ...);
> >  /*@{*/
> >  
> >  /* driver capabilities and requirements mask */
> > -#define DRIVER_USE_AGP 0x1
> > -#define DRIVER_PCI_DMA 0x8
> > -#define DRIVER_SG  0x10
> > -#define DRIVER_HAVE_DMA0x20
> > -#define DRIVER_HAVE_IRQ0x40
> > -#define DRIVER_IRQ_SHARED  0x80
> > -#define DRIVER_GEM 0x1000
> > -#define DRIVER_MODESET 0x2000
> > -#define DRIVER_PRIME   0x4000
> > -#define DRIVER_RENDER  0x8000
> > -#define DRIVER_ATOMIC  0x1
> > +#define DRIVER_USE_AGP 0x1
> > +#define DRIVER_PCI_DMA 0x8
> > +#define DRIVER_SG  0x10
> > +#define DRIVER_HAVE_DMA0x20
> > +#define DRIVER_HAVE_IRQ0x40
> > +#define DRIVER_IRQ_SHARED  0x80
> > +#define DRIVER_GEM 0x1000
> > +#define DRIVER_MODESET 0x2000
> > +#define DRIVER_PRIME   0x4000
> > +#define DRIVER_RENDER  0x8000
> > +#define DRIVER_ATOMIC  0x1
> > +#define DRIVER_KMS_LEGACY_CONTEXT  0x2
> >  
> >  /***/
> >  /** \name Macros to make printk easier */
> > -- 
> > 1.9.1
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

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


[patch] drm/edid: fix a debug message

2015-05-13 Thread Daniel Vetter
On Tue, May 12, 2015 at 09:07:37PM +0300, Dan Carpenter wrote:
> There is an extra semi-colon on the if statement so the debug output
> always says "Failed to write EDID checksum" even when it didn't fail.
> 
> Fixes: 559be30cb74d ('drm/i915: Implement the intel_dp_autotest_edid function 
> for DP EDID complaince tests')
> Signed-off-by: Dan Carpenter 

Oops, thanks a lot for catching this.
-Daniel

> 
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index eca82cf..75bccd6 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -4142,7 +4142,7 @@ static uint8_t intel_dp_autotest_edid(struct intel_dp 
> *intel_dp)
>   if (!drm_dp_dpcd_write(_dp->aux,
>   DP_TEST_EDID_CHECKSUM,
>   _connector->detect_edid->checksum,
> - 1));
> + 1))
>   DRM_DEBUG_KMS("Failed to write EDID checksum\n");
>  
>   test_result = DP_TEST_ACK | DP_TEST_EDID_CHECKSUM_WRITE;
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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


[PATCH v2 2/2] drm: Make Legacy Context access functions optional.

2015-05-13 Thread Daniel Vetter
On Wed, May 13, 2015 at 07:54:48AM +0100, Peter Antoine wrote:
> As these functions are only used by one driver and there are security holes
> in these functions. Make the functions optional.
> 
> These changes are based on the two patches:
>   commit c21eb21cb50d58e7cbdcb8b9e7ff68b85cfa5095
>   Author: Dave Airlie 
> 
> And the commit that the above patch reverts:
>   commit 7c510133d93dd6f15ca040733ba7b2891ed61fd1
>   Author: Daniel Vetter 
> 
> This should now turn off the context feature.
> 
> Issue: VIZ-5485
> Signed-off-by: Peter Antoine 

Please cc drm core patches to dri-devel. Review below.
-Daniel

> ---
>  drivers/gpu/drm/drm_context.c | 36 
>  drivers/gpu/drm/drm_drv.c | 12 +++-
>  2 files changed, 43 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index 9b23525..574be2a 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -53,6 +53,9 @@ struct drm_ctx_list {
>   */
>  void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>  {
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;

This doesn't compile too well. Also like with the previous patch, drivers
without DRIVER_MODESET still need these ioctls.

> +
>   mutex_lock(>struct_mutex);
>   idr_remove(>ctx_idr, ctx_handle);
>   mutex_unlock(>struct_mutex);
> @@ -87,6 +90,9 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * 
> dev)
>   */
>  int drm_legacy_ctxbitmap_init(struct drm_device * dev)
>  {
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;

This is redundant with the check you've added around the caller. Looking
at other places wrapping callers of _legacy_ functions with these checks
is the more common pattern in drm.

> +
>   idr_init(>ctx_idr);
>   return 0;
>  }
> @@ -101,6 +107,9 @@ int drm_legacy_ctxbitmap_init(struct drm_device * dev)
>   */
>  void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>  {
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;

Same issue with compiling. And probably better to move the check out into
callers.

> +
>   mutex_lock(>struct_mutex);
>   idr_destroy(>ctx_idr);
>   mutex_unlock(>struct_mutex);
> @@ -119,6 +128,9 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, 
> struct drm_file *file)
>  {
>   struct drm_ctx_list *pos, *tmp;
>  
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;

Same as above.

> +
>   mutex_lock(>ctxlist_mutex);
>  
>   list_for_each_entry_safe(pos, tmp, >ctxlist, head) {
> @@ -161,6 +173,9 @@ int drm_legacy_getsareactx(struct drm_device *dev, void 
> *data,
>   struct drm_local_map *map;
>   struct drm_map_list *_entry;
>  
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;
> +
>   mutex_lock(>struct_mutex);
>  
>   map = idr_find(>ctx_idr, request->ctx_id);
> @@ -205,6 +220,9 @@ int drm_legacy_setsareactx(struct drm_device *dev, void 
> *data,
>   struct drm_local_map *map = NULL;
>   struct drm_map_list *r_list = NULL;
>  
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;
> +
>   mutex_lock(>struct_mutex);
>   list_for_each_entry(r_list, >maplist, head) {
>   if (r_list->map
> @@ -305,6 +323,9 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>   struct drm_ctx ctx;
>   int i;
>  
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;
> +
>   if (res->count >= DRM_RESERVED_CONTEXTS) {
>   memset(, 0, sizeof(ctx));
>   for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
> @@ -335,6 +356,9 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>   struct drm_ctx_list *ctx_entry;
>   struct drm_ctx *ctx = data;
>  
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;
> +
>   ctx->handle = drm_legacy_ctxbitmap_next(dev);
>   if (ctx->handle == DRM_KERNEL_CONTEXT) {
>   /* Skip kernel's context and get a new one. */
> @@ -378,6 +402,9 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>  {
>   struct drm_ctx *ctx = data;
>  
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;
> +
>   /* This is 0, because we don't handle any context flags */
>   ctx->flags = 0;
>  
> @@ -400,6 +427,9 @@ int drm_legacy_switchctx(struct drm_device *dev, void 
> *data,
>  {
>   struct drm_ctx *ctx = data;
>  
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
> + return -EINVAL;
> +
>   DRM_DEBUG("%d\n", ctx->handle);
>   return drm_context_switch(dev, 

[Bug 98101] kernel BUG at drivers/gpu/drm/drm_vma_manager.c:209!

2015-05-13 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=98101

--- Comment #3 from Apostolos B.  ---
I had similar crashes requiring a hard reset but the log messages were
different. This is the first time i see something like that. And also it points
at where the bug is. 

Cant reproduce it. Its random.

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


[Bug 90370] [radeonsi] dota2 suffers from many glitches

2015-05-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=90370

--- Comment #5 from Michel Dänzer  ---
Can you attach a screenshot showing the artifacts?

What does "mini-hang" mean?

P.S. Please attach files here directly. If your browser can't do that, please
find one that can.

-- 
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/20150513/bbd572bc/attachment.html>


[Bug 98101] kernel BUG at drivers/gpu/drm/drm_vma_manager.c:209!

2015-05-13 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=98101

--- Comment #2 from Apostolos B.  ---
Created attachment 176601
  --> https://bugzilla.kernel.org/attachment.cgi?id=176601=edit
dmesg

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


[Intel-gfx] [PATCH 01/42] drm/atomic: Allow drivers to subclass drm_atomic_state

2015-05-13 Thread Daniel Vetter
On Mon, May 11, 2015 at 4:24 PM, Maarten Lankhorst
 wrote:
> Drivers may need to store the state of shared resources, such as PLLs
> or FIFO space, into the atomic state. Allow this by making it possible
> to subclass drm_atomic_state.
>
> Cc: dri-devel at lists.freedesktop.org
> Acked-by: Ander Conselvan de Oliveira  intel.com>
> Signed-off-by: Maarten Lankhorst 

A few naming change suggestions below ...
> ---
>  drivers/gpu/drm/drm_atomic.c | 91 
> 
>  include/drm/drm_atomic.h |  4 ++
>  include/drm/drm_crtc.h   |  4 ++
>  3 files changed, 74 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 6e3b78ee7d16..f0f914591f1d 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -38,24 +38,19 @@ static void kfree_state(struct drm_atomic_state *state)
> kfree(state->crtc_states);
> kfree(state->planes);
> kfree(state->plane_states);
> -   kfree(state);
>  }
>
>  /**
> - * drm_atomic_state_alloc - allocate atomic state
> + * __drm_atomic_new_state - init new atomic state
>   * @dev: DRM device
> + * @state: atomic state
>   *
> - * This allocates an empty atomic state to track updates.
> + * Default implementation for filling in a new atomic state.
> + * This is useful for drivers that subclass the atomic state.
>   */
> -struct drm_atomic_state *
> -drm_atomic_state_alloc(struct drm_device *dev)
> +int __drm_atomic_new_state(struct drm_device *dev,
> +  struct drm_atomic_state *state)

Generally the naming pattern is _object_create/alloc for
allocating+initializing an object, and _object_init for just
initializing it. So imo better to call this drm_atomic_state_init
without any __ prefix or similar.

>  {
> -   struct drm_atomic_state *state;
> -
> -   state = kzalloc(sizeof(*state), GFP_KERNEL);
> -   if (!state)
> -   return NULL;
> -
> /* TODO legacy paths should maybe do a better job about
>  * setting this appropriately?
>  */
> @@ -92,31 +87,50 @@ drm_atomic_state_alloc(struct drm_device *dev)
>
> state->dev = dev;
>
> -   DRM_DEBUG_ATOMIC("Allocate atomic state %p\n", state);
> +   DRM_DEBUG_ATOMIC("Allocated atomic state %p\n", state);
>
> -   return state;
> +   return 0;
>  fail:
> kfree_state(state);
> +   return -ENOMEM;
> +}
> +EXPORT_SYMBOL(__drm_atomic_new_state);
>
> -   return NULL;
> +/**
> + * drm_atomic_state_alloc - allocate atomic state
> + * @dev: DRM device
> + *
> + * This allocates an empty atomic state to track updates.
> + */
> +struct drm_atomic_state *
> +drm_atomic_state_alloc(struct drm_device *dev)
> +{
> +   struct drm_mode_config *config = >mode_config;
> +   struct drm_atomic_state *state;
> +
> +   if (!config->funcs->atomic_new_state) {
> +   state = kzalloc(sizeof(*state), GFP_KERNEL);
> +   if (!state)
> +   return NULL;
> +   if (__drm_atomic_new_state(dev, state) < 0) {
> +   kfree(state);
> +   return NULL;
> +   }
> +   return state;
> +   }
> +
> +   return config->funcs->atomic_new_state(dev);

Since this vfunc replaces drm_atomic_state_alloc completely I think it
should be called atomic_state_alloc to match that. And not the
init-only function above.

>  }
>  EXPORT_SYMBOL(drm_atomic_state_alloc);
>
>  /**
> - * drm_atomic_state_clear - clear state object
> + * __drm_atomic_clear_state - clear atomic state
>   * @state: atomic state
>   *
> - * When the w/w mutex algorithm detects a deadlock we need to back off and 
> drop
> - * all locks. So someone else could sneak in and change the current modeset
> - * configuration. Which means that all the state assembled in @state is no
> - * longer an atomic update to the current state, but to some arbitrary 
> earlier
> - * state. Which could break assumptions the driver's ->atomic_check likely
> - * relies on.
> - *
> - * Hence we must clear all cached state and completely start over, using this
> - * function.
> + * Default implementation for clearing atomic state.
> + * This is useful for drivers that subclass the atomic state.
>   */
> -void drm_atomic_state_clear(struct drm_atomic_state *state)
> +void __drm_atomic_clear_state(struct drm_atomic_state *state)

We've gone with __ in the duplicate/destroy functions for lack of any
good names, but here drm_atomic_state_default_clear looks imo good and
is much clearer.

>  {
> struct drm_device *dev = state->dev;
> struct drm_mode_config *config = >mode_config;
> @@ -162,6 +176,32 @@ void drm_atomic_state_clear(struct drm_atomic_state 
> *state)
> state->plane_states[i] = NULL;
> }
>  }
> +EXPORT_SYMBOL(__drm_atomic_clear_state);
> +
> +/**
> + * drm_atomic_state_clear - clear state object
> + * @state: atomic 

[Bug 95771] Crash when trying to hibernate

2015-05-13 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=95771

--- Comment #2 from Michel Dänzer  ---
(In reply to higuita from comment #1)
> New crash dump

Does building the kernel without CONFIG_HSA_AMD avoid this one?

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


[Bug 98101] kernel BUG at drivers/gpu/drm/drm_vma_manager.c:209!

2015-05-13 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=98101

--- Comment #1 from Michel Dänzer  ---
Please attach the full dmesg output.

Can you reproduce this problem by doing something in particular, or is it
random? Is it a regression, i.e. didn't it happen with an older kernel version?

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


[Bug 90320] Lenovo ThinkPad E455 (Kaveri A10-7300): Blank built-in screen with radeon kms driver

2015-05-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=90320

N.Leiten  changed:

   What|Removed |Added

 CC||nickleiten at gmail.com

--- Comment #8 from N.Leiten  ---
Created attachment 115731
  --> https://bugs.freedesktop.org/attachment.cgi?id=115731=edit
FHD Panel Datasheet.

Due this datasheet the panel looks the same as for DP configuration comparing
whith N133HSE-EA1 (asus u38n) panel. So it needs 2 lanes to init video stream.

As for your dmesg, I see problem in dp_aux_ch and training procedure (the
voltage and emphasis is 0 which is not right at this point). Need to debug
further when I publish my patch and if it not help.

One more thing, do you have FullHD (1920x1080) panel or WHD (1366x768) one.
Because on Lenovo site I see Thinkpad e455 base model with WHD. The last one
need only 1 DisplayPort lane to work.

-- 
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/20150513/1157f36f/attachment-0001.html>


[PATCH i-g-t] tests/drm_hw_lock: Tests for hw_lock fixes.

2015-05-13 Thread Antoine, Peter
Please ignore this test as fixes are being implemented differently.

On Thu, 2015-04-23 at 15:07 +0100, Peter Antoine wrote:
> There are several issues with the hardware locks functions that stretch
> from kernel crashes to priority escalations. This new test will test the
> the fixes for these features.
> 
> This test will cause a driver/kernel crash on un-patched kernels, the
> following patches should be applied to stop the crashes:
> 
>   drm: Kernel Crash in drm_unlock
>   drm: Fixes unsafe deference in locks.
> 
> Issue: VIZ-5485
> Signed-off-by: Peter Antoine 
> ---
>  lib/ioctl_wrappers.c   |  19 +
>  lib/ioctl_wrappers.h   |   1 +
>  tests/Makefile.sources |   1 +
>  tests/drm_hw_lock.c| 207 
> +
>  4 files changed, 228 insertions(+)
>  create mode 100644 tests/drm_hw_lock.c
> 
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 000d394..ad8b3d3 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -964,6 +964,25 @@ bool gem_has_bsd2(int fd)
>  {
>   return gem_has_enable_ring(fd,LOCAL_I915_PARAM_HAS_BSD2);
>  }
> +#define I915_PARAM_HAS_LEGACY_CONTEXT 35
> +bool drm_has_legacy_context(int fd)
> +{
> + int tmp = 0;
> + drm_i915_getparam_t gp;
> +
> + memset(, 0, sizeof(gp));
> + gp.value = 
> + gp.param = I915_PARAM_HAS_LEGACY_CONTEXT;
> +
> + /*
> +  * if legacy context param is not supported, then it's old and we
> +  * can assume that the HW_LOCKS are supported.
> +  */
> + if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, ) != 0)
> + return true;
> +
> + return tmp == 1;
> +}
>  /**
>   * gem_available_aperture_size:
>   * @fd: open i915 drm file descriptor
> diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
> index ced7ef3..3adc700 100644
> --- a/lib/ioctl_wrappers.h
> +++ b/lib/ioctl_wrappers.h
> @@ -120,6 +120,7 @@ bool gem_has_bsd(int fd);
>  bool gem_has_blt(int fd);
>  bool gem_has_vebox(int fd);
>  bool gem_has_bsd2(int fd);
> +bool drm_has_legacy_context(int fd);
>  bool gem_uses_aliasing_ppgtt(int fd);
>  int gem_available_fences(int fd);
>  uint64_t gem_available_aperture_size(int fd);
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 71de6de..2f69afc 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -84,6 +84,7 @@ TESTS_progs_M = \
>   pm_sseu \
>   prime_self_import \
>   template \
> + drm_hw_lock \
>   $(NULL)
>  
>  TESTS_progs = \
> diff --git a/tests/drm_hw_lock.c b/tests/drm_hw_lock.c
> new file mode 100644
> index 000..aad50ba
> --- /dev/null
> +++ b/tests/drm_hw_lock.c
> @@ -0,0 +1,207 @@
> +/*
> + * Copyright © 2015 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Authors:
> + *Peter Antoine 
> + */
> +
> +/*
> + * Testcase: Test the HW_LOCKs for correct support and non-crashing.
> + *
> + * This test will check that he hw_locks are only g_supported for drivers 
> that
> + * require that support. If it is not g_supported then the functions all 
> return
> + * the correct error code.
> + *
> + * If g_supported it will check that the functions do not crash when the 
> crash
> + * tests are used, also that one of the tests is a security level escalation
> + * that should be rejected.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "drmtest.h"
> +#include "igt_core.h"
> +#include "ioctl_wrappers.h"
> +
> +#ifndef DRM_KERNEL_CONTEXT
> +#define DRM_KERNEL_CONTEXT   (0)
> +#endif
> +
> +#ifndef _DRM_LOCK_HELD
> +#define _DRM_LOCK_HELD   0x8000U /**< Hardware lock is held */
> +#endif
> +
> +#ifndef _DRM_LOCK_CONT
> +#define _DRM_LOCK_CONT   0x4000U /**< Hardware lock is contended */
> +#endif
> +
> +static bool  g_sig_fired;
> +static bool  g_supported;
> +static struct sigaction 

[PATCH v5 1/3] drm/layerscape: Add Freescale DCU DRM driver

2015-05-13 Thread Wang J.W.
Hi David,

Can you help me review this patch? Thanks.

Jianwei

> -Original Message-
> From: Jianwei Wang [mailto:jianwei.wang at freescale.com]
> Sent: Friday, April 17, 2015 2:36 PM
> To: airlied at linux.ie; daniel.vetter at intel.com; stefan at agner.ch; Wood
> Scott-B07421; dri-devel at lists.freedesktop.org
> Cc: linux-kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org;
> Jin Zhengxiong-R64188; Wang Jianwei-B52261; Wang Huan-B18965; Xiubo Li;
> Wang Jianwei-B52261
> Subject: [PATCH v5 1/3] drm/layerscape: Add Freescale DCU DRM driver
> 
> From: Jianwei Wang 
> 
> This patch add support for Two Dimensional Animation and Compositing
> Engine (2D-ACE) on the Freescale SoCs.
> 
> 2D-ACE is a Freescale display controller. 2D-ACE describes the
> functionality of the module extremely well its name is a value that cannot
> be used as a token in programming languages.
> Instead the valid token "DCU" is used to tag the register names and
> function names.
> 
> The Display Controller Unit (DCU) module is a system master that fetches
> graphics stored in internal or external memory and displays them on a TFT
> LCD panel. A wide range of panel sizes is supported and the timing of the
> interface signals is highly configurable.
> Graphics are read directly from memory and then blended in real-time,
> which allows for dynamic content creation with minimal CPU intervention.
> 
> The features:
> (1) Full RGB888 output to TFT LCD panel.
> (2) For the current LCD panel, WQVGA "480x272" is supported.
> (3) Blending of each pixel using up to 4 source layers dependent on size
> of panel.
> (4) Each graphic layer can be placed with one pixel resolution in either
> axis.
> (5) Each graphic layer support RGB565 and RGB888 direct colors without
> alpha channel and BGRA BGRA ARGB1555 direct colors with an alpha
> channel and YUV422 format.
> (6) Each graphic layer support alpha blending with 8-bit resolution.
> 
> This is a simplified version, only one primary plane, one framebuffer
> created for fbdev, one crtc, one connector for TFT LCD panel, an encoder.
> 
> Signed-off-by: Alison Wang 
> Signed-off-by: Xiubo Li 
> Signed-off-by: Jianwei Wang 
> ---
> 
> Changed in V5
> 
> - Update commit message
> - Add layer registers initialization
> - Remove unused functions
> - Rename driver folder
> - Move pixel clock control functions to fsl_dcu_drm_drv.c
> - remove redundant enable the clock implicitly using regmap
> - Add maintainer message
> 
> Changed in V4:
> 
> -This version doesn't have functionality changed  Just a minor adjustment.
> 
> Changed in V3:
> 
> - Test driver on Vybrid board and add compatible string
> - Remove unused functions
> - set default crtc for encoder
> - replace legacy functions with atomic help functions
> - Set the unique name of the DRM device
> - Implement irq handle function for vblank interrupt
> 
> Changed in v2:
> - Add atomic support
> - Modify bindings file
> - Rename node for compatibility
> - Move platform related code out for compatibility
> 
>  .../devicetree/bindings/drm/fsl-dcu/fsl,dcu.txt|  50 +++
>  MAINTAINERS|   8 +
>  drivers/gpu/drm/Kconfig|   2 +
>  drivers/gpu/drm/Makefile   |   1 +
>  drivers/gpu/drm/fsl-dcu/Kconfig|  17 +
>  drivers/gpu/drm/fsl-dcu/Makefile   |   7 +
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_connector.c| 194 +++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_connector.h|  30 ++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 172 ++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.h |  22 ++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c  | 373
> +
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h  | 223 
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_fbdev.c|  26 ++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c  |  42 +++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.h  |  17 +
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c| 192 +++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.h|  23 ++
>  17 files changed, 1399 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/drm/fsl-
> dcu/fsl,dcu.txt
>  create mode 100644 drivers/gpu/drm/fsl-dcu/Kconfig  create mode 100644
> drivers/gpu/drm/fsl-dcu/Makefile  create mode 100644 drivers/gpu/drm/fsl-
> dcu/fsl_dcu_drm_connector.c
>  create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_connector.h
>  create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
>  create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.h
>  create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
>  create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h
>  create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_fbdev.c
>  create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c
>  create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.h
>  

[Bug 90421] DOTA2 when selecting naga clones locks GPU

2015-05-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=90421

Michel Dänzer  changed:

   What|Removed |Added

 Resolution|FIXED   |DUPLICATE

--- Comment #3 from Michel Dänzer  ---


*** This bug has been marked as a duplicate of bug 89685 ***

-- 
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/20150513/b00e1786/attachment.html>


[Bug 89685] Cripling Dota 2 freeze with Morphling at hero selection or loadout

2015-05-13 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=89685

Michel Dänzer  changed:

   What|Removed |Added

 CC||hypnodreams at gmail.com

--- Comment #24 from Michel Dänzer  ---
*** Bug 90421 has been marked as a duplicate of this bug. ***

-- 
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/20150513/92dd2e5d/attachment.html>