[PATCH 11/11] drm: Fix vblank timestamp races

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

The vblank timestamp ringbuffer only has two entries, so if the
vblank->count is incremented by an even number readers may end up seeing
the new vblank timestamp alongside the old vblank counter value.

Fix the problem by storing the vblank counter in a ringbuffer as well,
and always increment the ringbuffer "slot" by one when storing a new
timestamp+counter pair.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 40 
 include/drm/drmP.h| 12 ++--
 2 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 88fbee4..8de236a 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -43,8 +43,10 @@
 #include 

 /* Access macro for slots in vblank timestamp ringbuffer. */
-#define vblanktimestamp(dev, pipe, count) \
-   ((dev)->vblank[pipe].time[(count) % DRM_VBLANKTIME_RBSIZE])
+#define vblanktimestamp(dev, pipe, slot) \
+   ((dev)->vblank[pipe].time[(slot) % DRM_VBLANK_RBSIZE])
+#define vblankcount(dev, pipe, slot) \
+   ((dev)->vblank[pipe].count[(slot) % DRM_VBLANK_RBSIZE])

 /* Retry timestamp calculation up to 3 times to satisfy
  * drm_timestamp_precision before giving up.
@@ -76,20 +78,23 @@ module_param_named(timestamp_monotonic, 
drm_timestamp_monotonic, int, 0600);

 static void store_vblank(struct drm_device *dev, unsigned int pipe,
 u32 vblank_count_inc,
-struct timeval *t_vblank, u32 last)
+const struct timeval *t_vblank, u32 last)
 {
struct drm_vblank_crtc *vblank = >vblank[pipe];
-   u32 tslot;
+   u32 slot;

assert_spin_locked(>vblank_time_lock);

+   slot = vblank->slot + 1;
+
vblank->last = last;

/* All writers hold the spinlock, but readers are serialized by
-* the latching of vblank->count below.
+* the latching of vblank->slot below.
 */
-   tslot = vblank->count + vblank_count_inc;
-   vblanktimestamp(dev, pipe, tslot) = *t_vblank;
+   vblankcount(dev, pipe, slot) =
+   vblankcount(dev, pipe, vblank->slot) + vblank_count_inc;
+   vblanktimestamp(dev, pipe, slot) = *t_vblank;

/*
 * vblank timestamp updates are protected on the write side with
@@ -100,7 +105,7 @@ static void store_vblank(struct drm_device *dev, unsigned 
int pipe,
 * The read-side barriers for this are in drm_vblank_count_and_time.
 */
smp_wmb();
-   vblank->count += vblank_count_inc;
+   vblank->slot = slot;
smp_wmb();
 }

@@ -202,7 +207,7 @@ static void drm_update_vblank_count(struct drm_device *dev, 
unsigned int pipe,
const struct timeval *t_old;
u64 diff_ns;

-   t_old = (dev, pipe, vblank->count);
+   t_old = (dev, pipe, vblank->slot);
diff_ns = timeval_to_ns(_vblank) - timeval_to_ns(t_old);

/*
@@ -223,7 +228,8 @@ static void drm_update_vblank_count(struct drm_device *dev, 
unsigned int pipe,

DRM_DEBUG("updating vblank count on crtc %u:"
  " current=%u, diff=%u, hw=%u hw_last=%u\n",
- pipe, vblank->count, diff, cur_vblank, vblank->last);
+ pipe, vblankcount(dev, pipe, vblank->slot),
+ diff, cur_vblank, vblank->last);

if (diff == 0) {
WARN_ON_ONCE(cur_vblank != vblank->last);
@@ -883,7 +889,7 @@ u32 drm_vblank_count(struct drm_device *dev, int pipe)
if (WARN_ON(pipe >= dev->num_crtcs))
return 0;

-   return vblank->count;
+   return vblankcount(dev, pipe, vblank->slot);
 }
 EXPORT_SYMBOL(drm_vblank_count);

@@ -923,7 +929,8 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, 
unsigned int pipe,
 {
struct drm_vblank_crtc *vblank = >vblank[pipe];
int count = DRM_TIMESTAMP_MAXRETRIES;
-   u32 cur_vblank;
+   u32 vblankcount;
+   u32 slot;

if (WARN_ON(pipe >= dev->num_crtcs))
return 0;
@@ -934,13 +941,14 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, 
unsigned int pipe,
 * This works like a seqlock. The write-side barriers are in 
store_vblank.
 */
do {
-   cur_vblank = vblank->count;
+   slot = vblank->slot;
smp_rmb();
-   *vblanktime = vblanktimestamp(dev, pipe, cur_vblank);
+   *vblanktime = vblanktimestamp(dev, pipe, slot);
+   vblankcount = vblankcount(dev, pipe, slot);
smp_rmb();
-   } while (cur_vblank != vblank->count && --count > 0);
+   } while (slot != vblank->slot && --count > 0);

-   return cur_vblank;
+   return vblankcount;
 }
 EXPORT_SYMBOL(drm_vblank_count_and_time);

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 6717a7d..9de9fde 100644
--- 

[PATCH 10/11] drm: Use vblank timestamps to guesstimate how many vblanks were missed

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

When lacking am accurate hardware frame counter, we can fall back to
using the vblank timestamps to guesstimagte how many vblanks have
elapsed since the last time the vblank counter was updated.

Take the oppostunity to unify the vblank_disable_and_save() and
drm_handle_vblank_events() to call the same function
(drm_update_vblank_count()) to perform the vblank updates.

If the hardware/driver has an accurate frame counter use it instead of
the timestamp based guesstimate. If the hardware/driver has neither
a frame counter nor acurate vblank timestamps, we fall back to assuming
that each drm_handle_vblank_events() should increment the vblank count
by one.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 206 --
 1 file changed, 91 insertions(+), 115 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 07b0cb1..88fbee4 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -76,13 +76,15 @@ module_param_named(timestamp_monotonic, 
drm_timestamp_monotonic, int, 0600);

 static void store_vblank(struct drm_device *dev, unsigned int pipe,
 u32 vblank_count_inc,
-struct timeval *t_vblank)
+struct timeval *t_vblank, u32 last)
 {
struct drm_vblank_crtc *vblank = >vblank[pipe];
u32 tslot;

assert_spin_locked(>vblank_time_lock);

+   vblank->last = last;
+
/* All writers hold the spinlock, but readers are serialized by
 * the latching of vblank->count below.
 */
@@ -103,6 +105,54 @@ static void store_vblank(struct drm_device *dev, unsigned 
int pipe,
 }

 /**
+ * drm_reset_vblank_timestamp - reset the last timestamp to the last vblank
+ * @dev: DRM device
+ * @pipe: index of CRTC for which to reset the timestamp
+ *
+ * Reset the stored timestamp for the current vblank count to correspond
+ * to the last vblank occurred.
+ *
+ * Only to be called from drm_vblank_on().
+ *
+ * Note: caller must hold dev->vbl_lock since this reads & writes
+ * device vblank fields.
+ */
+static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int 
pipe)
+{
+   u32 cur_vblank;
+   bool rc;
+   struct timeval t_vblank;
+   int count = DRM_TIMESTAMP_MAXRETRIES;
+
+   spin_lock(>vblank_time_lock);
+
+   /*
+* sample the current counter to avoid random jumps
+* when drm_vblank_enable() applies the diff
+*/
+   do {
+   cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
+   rc = drm_get_last_vbltimestamp(dev, pipe, _vblank, 0);
+   } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
--count > 0);
+
+   /*
+* Only reinitialize corresponding vblank timestamp if high-precision 
query
+* available and didn't fail. Otherwise reinitialize delayed at next 
vblank
+* interrupt and assign 0 for now, to mark the vblanktimestamp as 
invalid.
+*/
+   if (!rc)
+   t_vblank = (struct timeval) {0, 0};
+
+   /*
+* +1 to make sure user will never see the same
+* vblank counter value before and after a modeset
+*/
+   store_vblank(dev, pipe, 1, _vblank, cur_vblank);
+
+   spin_unlock(>vblank_time_lock);
+}
+
+/**
  * drm_update_vblank_count - update the master vblank counter
  * @dev: DRM device
  * @pipe: counter to update
@@ -126,6 +176,7 @@ static void drm_update_vblank_count(struct drm_device *dev, 
unsigned int pipe,
bool rc;
struct timeval t_vblank;
int count = DRM_TIMESTAMP_MAXRETRIES;
+   int framedur_ns = vblank->framedur_ns;

/*
 * Interrupts were disabled prior to this call, so deal with counter
@@ -144,20 +195,40 @@ static void drm_update_vblank_count(struct drm_device 
*dev, unsigned int pipe,
rc = drm_get_last_vbltimestamp(dev, pipe, _vblank, flags);
} while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
--count > 0);

-   /* Deal with counter wrap */
-   diff = cur_vblank - vblank->last;
-   if (cur_vblank < vblank->last) {
-   diff += dev->max_vblank_count + 1;
+   if (dev->max_vblank_count != 0) {
+   /* trust the hw counter when it's around */
+   diff = (cur_vblank - vblank->last) & dev->max_vblank_count;
+   } else if (rc && framedur_ns) {
+   const struct timeval *t_old;
+   u64 diff_ns;
+
+   t_old = (dev, pipe, vblank->count);
+   diff_ns = timeval_to_ns(_vblank) - timeval_to_ns(t_old);

-   DRM_DEBUG("last_vblank[%u]=0x%x, cur_vblank=0x%x => 
diff=0x%x\n",
- pipe, vblank->last, cur_vblank, diff);
+   /*
+* Figure out how many vblanks we've missed based
+* on the difference in the 

[PATCH 09/11] drm: store_vblank() is never called with NULL timestamp

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

Remove the NULL 't_vblank' checks from store_vblank() since that will
never happen.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index aad4f1d..07b0cb1 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -83,13 +83,11 @@ static void store_vblank(struct drm_device *dev, unsigned 
int pipe,

assert_spin_locked(>vblank_time_lock);

-   if (t_vblank) {
-   /* All writers hold the spinlock, but readers are serialized by
-* the latching of vblank->count below.
-*/
-   tslot = vblank->count + vblank_count_inc;
-   vblanktimestamp(dev, pipe, tslot) = *t_vblank;
-   }
+   /* All writers hold the spinlock, but readers are serialized by
+* the latching of vblank->count below.
+*/
+   tslot = vblank->count + vblank_count_inc;
+   vblanktimestamp(dev, pipe, tslot) = *t_vblank;

/*
 * vblank timestamp updates are protected on the write side with
-- 
2.4.6



[PATCH 08/11] drm: Clean up drm_calc_vbltimestamp_from_scanoutpos() vbl_status

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

Avoid confusion and don't use 'vbl_status' as both the
.get_scanout_position() return value and the return value from
drm_calc_vbltimestamp_from_scanoutpos().

While at it make 'vbl_status' unsigned and print it as hex in the
debug prints since it's a bitmask.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 93fe582..aad4f1d 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -695,10 +695,10 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
 {
struct timeval tv_etime;
ktime_t stime, etime;
-   int vbl_status;
+   unsigned int vbl_status;
+   int ret = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
int vpos, hpos, i;
int delta_ns, duration_ns;
-   bool invbl;

if (pipe >= dev->num_crtcs) {
DRM_ERROR("Invalid crtc %u\n", pipe);
@@ -738,7 +738,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device 
*dev,

/* Return as no-op if scanout query unsupported or failed. */
if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
-   DRM_DEBUG("crtc %u : scanoutpos query failed [%d].\n",
+   DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
  pipe, vbl_status);
return -EIO;
}
@@ -765,7 +765,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device 
*dev,
 * within vblank area, counting down the number of lines until
 * start of scanout.
 */
-   invbl = vbl_status & DRM_SCANOUTPOS_IN_VBLANK;
+   if (vbl_status & DRM_SCANOUTPOS_IN_VBLANK)
+   ret |= DRM_VBLANKTIME_IN_VBLANK;

/* Convert scanout position into elapsed time at raw_time query
 * since start of scanout at first display scanline. delta_ns
@@ -788,17 +789,13 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
etime = ktime_sub_ns(etime, delta_ns);
*vblank_time = ktime_to_timeval(etime);

-   DRM_DEBUG("crtc %u : v %d p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d 
rep]\n",
- pipe, (int)vbl_status, hpos, vpos,
+   DRM_DEBUG("crtc %u : v 0x%x p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d 
rep]\n",
+ pipe, vbl_status, hpos, vpos,
  (long)tv_etime.tv_sec, (long)tv_etime.tv_usec,
  (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
  duration_ns/1000, i);

-   vbl_status = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
-   if (invbl)
-   vbl_status |= DRM_VBLANKTIME_IN_VBLANK;
-
-   return vbl_status;
+   return ret;
 }
 EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos);

-- 
2.4.6



[PATCH 07/11] drm: Limit the number of .get_vblank_counter() retries

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

Pontential infinite loops in the vblank code are a bad idea. Add some
limits.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 0353224..93fe582 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -127,6 +127,7 @@ static void drm_update_vblank_count(struct drm_device *dev, 
unsigned int pipe,
u32 cur_vblank, diff;
bool rc;
struct timeval t_vblank;
+   int count = DRM_TIMESTAMP_MAXRETRIES;

/*
 * Interrupts were disabled prior to this call, so deal with counter
@@ -143,7 +144,7 @@ static void drm_update_vblank_count(struct drm_device *dev, 
unsigned int pipe,
do {
cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, _vblank, flags);
-   } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe));
+   } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
--count > 0);

/* Deal with counter wrap */
diff = cur_vblank - vblank->last;
@@ -914,6 +915,7 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, 
unsigned int pipe,
  struct timeval *vblanktime)
 {
struct drm_vblank_crtc *vblank = >vblank[pipe];
+   int count = DRM_TIMESTAMP_MAXRETRIES;
u32 cur_vblank;

if (WARN_ON(pipe >= dev->num_crtcs))
@@ -929,7 +931,7 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, 
unsigned int pipe,
smp_rmb();
*vblanktime = vblanktimestamp(dev, pipe, cur_vblank);
smp_rmb();
-   } while (cur_vblank != vblank->count);
+   } while (cur_vblank != vblank->count && --count > 0);

return cur_vblank;
 }
-- 
2.4.6



[PATCH 06/11] drm: Pass flags to drm_update_vblank_count()

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

We'll soon have use for the 'flags' in drm_update_vblank_count() so pass
it in.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index ac17602..0353224 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -120,7 +120,8 @@ static void store_vblank(struct drm_device *dev, unsigned 
int pipe,
  * Note: caller must hold dev->vbl_lock since this reads & writes
  * device vblank fields.
  */
-static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe)
+static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
+   unsigned long flags)
 {
struct drm_vblank_crtc *vblank = >vblank[pipe];
u32 cur_vblank, diff;
@@ -141,7 +142,7 @@ static void drm_update_vblank_count(struct drm_device *dev, 
unsigned int pipe)
 */
do {
cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
-   rc = drm_get_last_vbltimestamp(dev, pipe, _vblank, 0);
+   rc = drm_get_last_vbltimestamp(dev, pipe, _vblank, flags);
} while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe));

/* Deal with counter wrap */
@@ -207,7 +208,7 @@ static void vblank_disable_and_save(struct drm_device *dev, 
unsigned int pipe)
 */
if (!vblank->enabled &&
drm_get_last_vbltimestamp(dev, pipe, , 0)) {
-   drm_update_vblank_count(dev, pipe);
+   drm_update_vblank_count(dev, pipe, 0);
spin_unlock_irqrestore(>vblank_time_lock, irqflags);
return;
}
@@ -1027,7 +1028,7 @@ static int drm_vblank_enable(struct drm_device *dev, 
unsigned int pipe)
atomic_dec(>refcount);
else {
vblank->enabled = true;
-   drm_update_vblank_count(dev, pipe);
+   drm_update_vblank_count(dev, pipe, 0);
}
}

-- 
2.4.6



[PATCH 05/11] drm/i915: Fix vblank count variable types

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

The vblank counts are u32 so make flip_queued_vblank and
flip_ready_vblank u32 as well.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/i915/intel_drv.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 02a755a..0475f89 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -862,8 +862,8 @@ struct intel_unpin_work {
u32 flip_count;
u32 gtt_offset;
struct drm_i915_gem_request *flip_queued_req;
-   int flip_queued_vblank;
-   int flip_ready_vblank;
+   u32 flip_queued_vblank;
+   u32 flip_ready_vblank;
bool enable_stall_check;
 };

-- 
2.4.6



[PATCH 04/11] drm: Kill pixeldur_ns

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

pixeldur_ns is now unsued, so kill it from drm_vblank_crtc. framedur_ns
is also currently unused but we will have use for it in the near future
so leave it be. linedur_ns is still used by nouveau for some internal
delays.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 13 +
 include/drm/drmP.h|  1 -
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 9fab333..ac17602 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -604,7 +604,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 const struct drm_display_mode *mode)
 {
struct drm_vblank_crtc *vblank = 
>dev->vblank[drm_crtc_index(crtc)];
-   int linedur_ns = 0, pixeldur_ns = 0, framedur_ns = 0;
+   int linedur_ns = 0, framedur_ns = 0;
int dotclock = mode->crtc_clock;

/* Valid dotclock? */
@@ -613,10 +613,9 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,

/*
 * Convert scanline length in pixels and video
-* dot clock to line duration, frame duration
-* and pixel duration in nanoseconds:
+* dot clock to line duration and frame duration
+* in nanoseconds:
 */
-   pixeldur_ns = 100 / dotclock;
linedur_ns  = div_u64((u64) mode->crtc_htotal * 100, 
dotclock);
framedur_ns = div_u64((u64) frame_size * 100, dotclock);

@@ -629,16 +628,14 @@ void drm_calc_timestamping_constants(struct drm_crtc 
*crtc,
DRM_ERROR("crtc %u: Can't calculate constants, dotclock = 0!\n",
  crtc->base.id);

-   vblank->pixeldur_ns = pixeldur_ns;
vblank->linedur_ns  = linedur_ns;
vblank->framedur_ns = framedur_ns;

DRM_DEBUG("crtc %u: hwmode: htotal %d, vtotal %d, vdisplay %d\n",
  crtc->base.id, mode->crtc_htotal,
  mode->crtc_vtotal, mode->crtc_vdisplay);
-   DRM_DEBUG("crtc %u: clock %d kHz framedur %d linedur %d, pixeldur %d\n",
- crtc->base.id, dotclock, framedur_ns,
- linedur_ns, pixeldur_ns);
+   DRM_DEBUG("crtc %u: clock %d kHz framedur %d linedur %d\n",
+ crtc->base.id, dotclock, framedur_ns, linedur_ns);
 }
 EXPORT_SYMBOL(drm_calc_timestamping_constants);

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index b2a95e7..6717a7d 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -705,7 +705,6 @@ struct drm_vblank_crtc {
unsigned int pipe;  /* crtc index */
int framedur_ns;/* frame/field duration in ns */
int linedur_ns; /* line duration in ns */
-   int pixeldur_ns;/* pixel duration in ns */
bool enabled;   /* so we don't call enable more than
   once per disable */
 };
-- 
2.4.6



[PATCH 03/11] drm: Stop using linedur_ns and pixeldur_ns for vblank timestamps

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

linedur_ns, and especially pixeldur_ns are becoming rather inaccurate
to be used for the vblank timestamp correction. With 4k at 60 the pixel
duration is already below 2ns, so the amount of error due to the
truncation to nanoseconds is introducing quite a bit of error.

We can avoid such problems if we instead calculate the timestamp
delta_ns directly from the dislay timings, avoiding the use of
these intermediate truncated values.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 19 ---
 drivers/gpu/drm/i915/i915_irq.c   |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.c |  3 ++-
 drivers/gpu/drm/nouveau/nouveau_display.h |  3 ++-
 drivers/gpu/drm/radeon/radeon_display.c   | 14 --
 drivers/gpu/drm/radeon/radeon_drv.c   |  5 +++--
 drivers/gpu/drm/radeon/radeon_mode.h  |  5 +++--
 drivers/gpu/drm/radeon/radeon_pm.c|  4 +++-
 include/drm/drmP.h|  6 --
 9 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 6b2fefd..9fab333 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -694,12 +694,11 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
  unsigned flags,
  const struct drm_display_mode *mode)
 {
-   struct drm_vblank_crtc *vblank = >vblank[pipe];
struct timeval tv_etime;
ktime_t stime, etime;
int vbl_status;
int vpos, hpos, i;
-   int framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns;
+   int delta_ns, duration_ns;
bool invbl;

if (pipe >= dev->num_crtcs) {
@@ -713,15 +712,10 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
return -EIO;
}

-   /* Durations of frames, lines, pixels in nanoseconds. */
-   framedur_ns = vblank->framedur_ns;
-   linedur_ns  = vblank->linedur_ns;
-   pixeldur_ns = vblank->pixeldur_ns;
-
/* If mode timing undefined, just return as no-op:
 * Happens during initial modesetting of a crtc.
 */
-   if (framedur_ns == 0) {
+   if (mode->crtc_clock == 0) {
DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
return -EAGAIN;
}
@@ -738,8 +732,10 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
 * Get vertical and horizontal scanout position vpos, hpos,
 * and bounding timestamps stime, etime, pre/post query.
 */
-   vbl_status = dev->driver->get_scanout_position(dev, pipe, 
flags, ,
-  , , 
);
+   vbl_status = dev->driver->get_scanout_position(dev, pipe, flags,
+  , ,
+  , ,
+  mode);

/* Return as no-op if scanout query unsupported or failed. */
if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
@@ -776,7 +772,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device 
*dev,
 * since start of scanout at first display scanline. delta_ns
 * can be negative if start of scanout hasn't happened yet.
 */
-   delta_ns = vpos * linedur_ns + hpos * pixeldur_ns;
+   delta_ns = div_s64(100LL * (vpos * mode->crtc_htotal + hpos),
+  mode->crtc_clock);

if (!drm_timestamp_monotonic)
etime = ktime_mono_to_real(etime);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 4aee725..77e8718 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -705,12 +705,12 @@ static int __intel_get_crtc_scanline(struct intel_crtc 
*crtc)

 static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
unsigned int flags, int *vpos, int *hpos,
-   ktime_t *stime, ktime_t *etime)
+   ktime_t *stime, ktime_t *etime,
+   const struct drm_display_mode *mode)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-   const struct drm_display_mode *mode = _crtc->base.hwmode;
int position;
int vbl_start, vbl_end, hsync_start, htotal, vtotal;
bool in_vbl = true;
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index 425515f..a82c3cb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ 

[PATCH 02/11] drm: Move timestamping constants into drm_vblank_crtc

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

Collect the timestamping constants alongside the rest of the relevant
stuff under drm_vblank_crtc.

We can now get rid of the 'refcrtc' parameter to
drm_calc_vbltimestamp_from_scanoutpos().

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |  2 +-
 drivers/gpu/drm/drm_irq.c | 16 
 drivers/gpu/drm/i915/i915_irq.c   |  1 -
 drivers/gpu/drm/nouveau/nouveau_display.c |  5 +++--
 drivers/gpu/drm/radeon/radeon_kms.c   |  2 +-
 include/drm/drmP.h|  4 +++-
 include/drm/drm_crtc.h|  6 --
 7 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 2236793..ecfa703 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -681,7 +681,7 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, 
int crtc,
/* Helper routine in DRM core does all the work: */
return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
 vblank_time, flags,
-drmcrtc, >hwmode);
+>hwmode);
 }

 const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 8df4133..6b2fefd 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -603,6 +603,7 @@ int drm_control(struct drm_device *dev, void *data,
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 const struct drm_display_mode *mode)
 {
+   struct drm_vblank_crtc *vblank = 
>dev->vblank[drm_crtc_index(crtc)];
int linedur_ns = 0, pixeldur_ns = 0, framedur_ns = 0;
int dotclock = mode->crtc_clock;

@@ -628,9 +629,9 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
DRM_ERROR("crtc %u: Can't calculate constants, dotclock = 0!\n",
  crtc->base.id);

-   crtc->pixeldur_ns = pixeldur_ns;
-   crtc->linedur_ns  = linedur_ns;
-   crtc->framedur_ns = framedur_ns;
+   vblank->pixeldur_ns = pixeldur_ns;
+   vblank->linedur_ns  = linedur_ns;
+   vblank->framedur_ns = framedur_ns;

DRM_DEBUG("crtc %u: hwmode: htotal %d, vtotal %d, vdisplay %d\n",
  crtc->base.id, mode->crtc_htotal,
@@ -651,7 +652,6 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * @flags: Flags to pass to driver:
  * 0 = Default,
  * DRM_CALLED_FROM_VBLIRQ = If function is called from vbl IRQ handler
- * @refcrtc: CRTC which defines scanout timing
  * @mode: mode which defines the scanout timings
  *
  * Implements calculation of exact vblank timestamps from given 
drm_display_mode
@@ -692,9 +692,9 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device 
*dev,
  int *max_error,
  struct timeval *vblank_time,
  unsigned flags,
- const struct drm_crtc *refcrtc,
  const struct drm_display_mode *mode)
 {
+   struct drm_vblank_crtc *vblank = >vblank[pipe];
struct timeval tv_etime;
ktime_t stime, etime;
int vbl_status;
@@ -714,9 +714,9 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device 
*dev,
}

/* Durations of frames, lines, pixels in nanoseconds. */
-   framedur_ns = refcrtc->framedur_ns;
-   linedur_ns  = refcrtc->linedur_ns;
-   pixeldur_ns = refcrtc->pixeldur_ns;
+   framedur_ns = vblank->framedur_ns;
+   linedur_ns  = vblank->linedur_ns;
+   pixeldur_ns = vblank->pixeldur_ns;

/* If mode timing undefined, just return as no-op:
 * Happens during initial modesetting of a crtc.
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 90bc6c2..4aee725 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -867,7 +867,6 @@ static int i915_get_vblank_timestamp(struct drm_device 
*dev, int pipe,
/* Helper routine in DRM core does all the work: */
return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
 vblank_time, flags,
-crtc,
 >hwmode);
 }

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index cc6c228..425515f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -103,6 +103,7 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int 
*vpos, int *hpos,

[PATCH 01/11] drm: s/int crtc/unsigned int pipe/ straggles

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

Finish the recent replacement of 'int pipe' with 'unsigned int pipe'

Cc: Thierry Reding 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_irq.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 22d207e..8df4133 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -74,11 +74,11 @@ module_param_named(vblankoffdelay, drm_vblank_offdelay, 
int, 0600);
 module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 
0600);
 module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);

-static void store_vblank(struct drm_device *dev, int crtc,
+static void store_vblank(struct drm_device *dev, unsigned int pipe,
 u32 vblank_count_inc,
 struct timeval *t_vblank)
 {
-   struct drm_vblank_crtc *vblank = >vblank[crtc];
+   struct drm_vblank_crtc *vblank = >vblank[pipe];
u32 tslot;

assert_spin_locked(>vblank_time_lock);
@@ -88,7 +88,7 @@ static void store_vblank(struct drm_device *dev, int crtc,
 * the latching of vblank->count below.
 */
tslot = vblank->count + vblank_count_inc;
-   vblanktimestamp(dev, crtc, tslot) = *t_vblank;
+   vblanktimestamp(dev, pipe, tslot) = *t_vblank;
}

/*
@@ -110,7 +110,7 @@ static void store_vblank(struct drm_device *dev, int crtc,
  * @pipe: counter to update
  *
  * Call back into the driver to update the appropriate vblank counter
- * (specified by @crtc).  Deal with wraparound, if it occurred, and
+ * (specified by @pipe).  Deal with wraparound, if it occurred, and
  * update the last read value so we can deal with wraparound on the next
  * call if necessary.
  *
@@ -1154,8 +1154,8 @@ EXPORT_SYMBOL(drm_crtc_vblank_put);
  * @dev: DRM device
  * @pipe: CRTC index
  *
- * This waits for one vblank to pass on @crtc, using the irq driver interfaces.
- * It is a failure to call this when the vblank irq for @crtc is disabled, e.g.
+ * This waits for one vblank to pass on @pipe, using the irq driver interfaces.
+ * It is a failure to call this when the vblank irq for @pipe is disabled, e.g.
  * due to lack of driver support or because the crtc is off.
  */
 void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe)
@@ -1288,8 +1288,8 @@ void drm_crtc_vblank_reset(struct drm_crtc *drm_crtc)
 {
struct drm_device *dev = drm_crtc->dev;
unsigned long irqflags;
-   int crtc = drm_crtc_index(drm_crtc);
-   struct drm_vblank_crtc *vblank = >vblank[crtc];
+   unsigned int pipe = drm_crtc_index(drm_crtc);
+   struct drm_vblank_crtc *vblank = >vblank[pipe];

spin_lock_irqsave(>vbl_lock, irqflags);
/*
-- 
2.4.6



[PATCH 00/11] drm: vblank fixes and timestamp based missed vblank guesttimation

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

This series has a few goals:
- make timestamps more accurate by not using rounded pixel/line durations
- avoid infinite loops in vblank code
- use the timestamps to guesttimate the number of missed vblanks, in case
  there's no hardware frame counter, or it can't be trusted
- fix bogus vblank counts/timstamps when the vblank counter incerements
  by an even number

Also available in my git repo (with a few hacks on top):
git://github.com/vsyrjala/linux.git vblank_ts_diff_5

Ville Syrjälä (11):
  drm: s/int crtc/unsigned int pipe/ straggles
  drm: Move timestamping constants into drm_vblank_crtc
  drm: Stop using linedur_ns and pixeldur_ns for vblank timestamps
  drm: Kill pixeldur_ns
  drm/i915: Fix vblank count variable types
  drm: Pass flags to drm_update_vblank_count()
  drm: Limit the number of .get_vblank_counter() retries
  drm: Clean up drm_calc_vbltimestamp_from_scanoutpos() vbl_status
  drm: store_vblank() is never called with NULL timestamp
  drm: Use vblank timestamps to guesstimate how many vblanks were missed
  drm: Fix vblank timestamp races

 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |   2 +-
 drivers/gpu/drm/drm_irq.c | 328 ++
 drivers/gpu/drm/i915/i915_irq.c   |   5 +-
 drivers/gpu/drm/i915/intel_drv.h  |   4 +-
 drivers/gpu/drm/nouveau/nouveau_display.c |   8 +-
 drivers/gpu/drm/nouveau/nouveau_display.h |   3 +-
 drivers/gpu/drm/radeon/radeon_display.c   |  14 +-
 drivers/gpu/drm/radeon/radeon_drv.c   |   5 +-
 drivers/gpu/drm/radeon/radeon_kms.c   |   2 +-
 drivers/gpu/drm/radeon/radeon_mode.h  |   5 +-
 drivers/gpu/drm/radeon/radeon_pm.c|   4 +-
 include/drm/drmP.h|  21 +-
 include/drm/drm_crtc.h|   6 -
 13 files changed, 194 insertions(+), 213 deletions(-)

-- 
2.4.6



[Bug 103271] AMD R9 270X Flickering with DPM Enabled on Linux 4.1 with RadeonSI

2015-09-14 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=103271

--- Comment #17 from Kevin McCormack  ---
I have been bisecting when I have a chance and it is coming along slowly. I did
figure out a nice way to reduce compile times from 90min+ down to 20min using
`MAKEFLAGS=-j8 makepkg -e` with my FX-8370. I have been running into a lot of
bisected kernels that simply won't boot and running git bisect skip but this
seems to be prolonging the process. I do hope I am on the right track as I
think the issue is somewhere between 4.0 and 4.1. Here is my log so far...

$ git bisect log
git bisect start
# good: [39a8804455fb23f09157341d3ba7db6d7ae6ee76] Linux 4.0
git bisect good 39a8804455fb23f09157341d3ba7db6d7ae6ee76
# bad: [b953c0d234bc72e8489d3bf51a276c5c4ec85345] Linux 4.1
git bisect bad b953c0d234bc72e8489d3bf51a276c5c4ec85345
# bad: [b953c0d234bc72e8489d3bf51a276c5c4ec85345] Linux 4.1
git bisect bad b953c0d234bc72e8489d3bf51a276c5c4ec85345
# good: [d0a3997c0c3f9351e24029349dee65dd1d9e8d84] Merge tag 'sound-4.1-rc1' of
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
git bisect good d0a3997c0c3f9351e24029349dee65dd1d9e8d84
# skip: [cf82f52d3619d2e15c83ec9a03c6ce8cdf6c6b58] watchdog: stmp3xxx_rtc_wdt:
fix broken email address
git bisect skip cf82f52d3619d2e15c83ec9a03c6ce8cdf6c6b58
# skip: [cf82f52d3619d2e15c83ec9a03c6ce8cdf6c6b58] watchdog: stmp3xxx_rtc_wdt:
fix broken email address
git bisect skip cf82f52d3619d2e15c83ec9a03c6ce8cdf6c6b58
# skip: [cf82f52d3619d2e15c83ec9a03c6ce8cdf6c6b58] watchdog: stmp3xxx_rtc_wdt:
fix broken email address
git bisect skip cf82f52d3619d2e15c83ec9a03c6ce8cdf6c6b58
# skip: [3e1b0c4a9d563d7fc6e22dc92613cd3237bb5ce0] ALSA: hda - Fix click noise
at start on Dell XPS13
git bisect skip 3e1b0c4a9d563d7fc6e22dc92613cd3237bb5ce0
# good: [d24363a5a40a3b7f976faada311b623fc8047b1e] ARM: dts: fix typo in
makefile for alpine-db
git bisect good d24363a5a40a3b7f976faada311b623fc8047b1e
# skip: [0c8027d50c070859314a88aaff42453ff4f71819] Merge tag 'media/v4.1-2' of
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
git bisect skip 0c8027d50c070859314a88aaff42453ff4f71819
# skip: [94435f764cc5838a7e94008f17628ad63384bf06] net:treewide: Fix typo in
drivers/net
git bisect skip 94435f764cc5838a7e94008f17628ad63384bf06
# good: [97b290b5637f473588a297834c10cd750718e980] MIPS: Octeon: Fix to IP
checksum offloading in Little Endian
git bisect good 97b290b5637f473588a297834c10cd750718e980
# skip: [38eb1dbb0d7d190bdfe2ea824e94dab19e32737f] Merge tag 'armsoc-fixes' of
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
git bisect skip 38eb1dbb0d7d190bdfe2ea824e94dab19e32737f
# good: [964aa8d9e4d36e0e54a88683d14c7d5b9d02aed8] xfs: remove
xfs_mod_incore_sb API
git bisect good 964aa8d9e4d36e0e54a88683d14c7d5b9d02aed8
# good: [964aa8d9e4d36e0e54a88683d14c7d5b9d02aed8] xfs: remove
xfs_mod_incore_sb API
git bisect good 964aa8d9e4d36e0e54a88683d14c7d5b9d02aed8
# skip: [6c28ab9fef9b4eca350d68ed0090f92fe37f969f] Merge tag
'v4.1-rockchip-socfixes2' of
git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip into fixes
git bisect skip 6c28ab9fef9b4eca350d68ed0090f92fe37f969f
# skip: [6c28ab9fef9b4eca350d68ed0090f92fe37f969f] Merge tag
'v4.1-rockchip-socfixes2' of
git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip into fixes
git bisect skip 6c28ab9fef9b4eca350d68ed0090f92fe37f969f
# good: [f549e94effa163ea170d2f0c12d307cb602431c6] serial: 8250_pci: add Intel
Penwell ports
git bisect good f549e94effa163ea170d2f0c12d307cb602431c6
# good: [8d76612bd49a73dca018e6fe5c790c943dbde98f] drm/cma: use correct fb
width/height
git bisect good 8d76612bd49a73dca018e6fe5c790c943dbde98f
# skip: [e6c81cce5699ec6be3a7533b5ad7a062ab3357f2] Merge tag 'armsoc-soc' of
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
git bisect skip e6c81cce5699ec6be3a7533b5ad7a062ab3357f2
# skip: [e35d1d8a1d16e9f56a9b54c96d0cb85ed621bb89] mtd: mxc-nand: Add a timeout
when waiting for interrupt
git bisect skip e35d1d8a1d16e9f56a9b54c96d0cb85ed621bb89
# skip: [e35d1d8a1d16e9f56a9b54c96d0cb85ed621bb89] mtd: mxc-nand: Add a timeout
when waiting for interrupt
git bisect skip e35d1d8a1d16e9f56a9b54c96d0cb85ed621bb89
# good: [e93cd95029c3b8aa628f0204e80e66fc61b57f12] Merge branch 'fixes' of
git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal into
for-rc
git bisect good e93cd95029c3b8aa628f0204e80e66fc61b57f12

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


[Bug 91982] [radeonsi] fs leak in get_radeon_bo()

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91982

--- Comment #7 from Dave Airlie  ---
does it happen with the original untrimmed trace?

this seems like an apitrace bug not a mesa 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/20150914/27049ac1/attachment.html>


[PATCH] drm/mgag200: fix memory leak

2015-09-14 Thread Archit Taneja
Hi,

On 9/14/2015 3:35 PM, Dave Airlie wrote:
> (this time with correct email address).
>
> On 14 September 2015 at 20:04, Dave Airlie  wrote:
>>>
 If drm_fb_helper_alloc_fbi() fails then we were directly returning
 without freeing sysram. Also if drm_fb_helper_alloc_fbi() succeeds but
 mgag200_framebuffer_init() fails then we were not releasing sysram and
 we were not releasing fbi helper also.

 Signed-off-by: Sudip Mukherjee 
 ---
   drivers/gpu/drm/mgag200/mgag200_fb.c | 15 ---
   1 file changed, 12 insertions(+), 3 deletions(-)

 diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
 b/drivers/gpu/drm/mgag200/mgag200_fb.c
 index 87de15e..5fe476a 100644
 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c
 +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
 @@ -189,14 +189,16 @@ static int mgag200fb_create(struct drm_fb_helper 
 *helper,
return -ENOMEM;

info = drm_fb_helper_alloc_fbi(helper);
 - if (IS_ERR(info))
 - return PTR_ERR(info);
 + if (IS_ERR(info)) {
 + ret = PTR_ERR(info);
 + goto err_alloc_fbi;
 + }

info->par = mfbdev;

ret = mgag200_framebuffer_init(dev, >mfb, _cmd, gobj);
if (ret)
 - return ret;
 + goto err_framebuffer_init;

mfbdev->sysram = sysram;
mfbdev->size = size;
 @@ -226,6 +228,13 @@ static int mgag200fb_create(struct drm_fb_helper 
 *helper,
DRM_DEBUG_KMS("allocated %dx%d\n",
  fb->width, fb->height);
return 0;
 +
 +err_framebuffer_init:
 + drm_fb_helper_release_fbi(helper);
 +
 +err_alloc_fbi:
 + vfree(sysram);
 + return ret;
   }

   static int mga_fbdev_destroy(struct drm_device *dev,
>>>
>>> There's a new regression: v4.3-rc1 crashes on bootup on non-supported 
>>> hardware, if
>>> CONFIG_DRM_MGAG200=y (built into the kernel).
>>
>> Archit, I'm guessing this is some fallout from the fbdev changes.
>>
>> There is no reason we should need CONFIG_FB_LITTLE_ENDIAN I don't think.

It looks like the mgag200 driver load fails and we crash in the error 
handling path. drm_fb_helper_fini ends up being called twice. The second
call tries to free resources that were already free'd.

The erroneous path above should have existed even without the recent
fbdev helper changes. I'm not sure what's causing the driver load
to fail in the first place. It looks like it's failing at
register_framebuffer. Is it possible that we never tried running
this driver before with Big Endian set?

The patch below fixes the problem with the error path mentioned
above. Could we try this?

From: Archit Taneja 
Date: Mon, 14 Sep 2015 20:11:43 +0530
Subject: [PATCH] drm/mgag200: Prevent calling drm_fb_helper_fini twice

mgag200_fbdev_init's error handling path calls drm_fb_helper_fini before
bailing out. The error handling path of mgag200_driver_load also ends
up calling drm_fb_helper_fini.

This results in drm_fb_helper_fini being called twice if the driver load
drm op fails somewhere in between.

Make only mgag200_driver_unload call drm_fb_helper_fini, remove the call
from mgag200_fbdev_init.

Signed-off-by: Archit Taneja 
---
  drivers/gpu/drm/mgag200/mgag200_fb.c | 8 ++--
  1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 87de15e..6259b0a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -280,20 +280,16 @@ int mgag200_fbdev_init(struct mga_device *mdev)

ret = drm_fb_helper_single_add_all_connectors(>helper);
if (ret)
-   goto fini;
+   return ret;

/* disable all the possible outputs/crtcs before entering KMS mode */
drm_helper_disable_unused_functions(mdev->dev);

ret = drm_fb_helper_initial_config(>helper, bpp_sel);
if (ret)
-   goto fini;
+   return ret;

return 0;
-
-fini:
-   drm_fb_helper_fini(>helper);
-   return ret;
  }

  void mgag200_fbdev_fini(struct mga_device *mdev)



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


[PATCH] drm/mgag200: fix memory leak

2015-09-14 Thread Dave Airlie
(this time with correct email address).

On 14 September 2015 at 20:04, Dave Airlie  wrote:
>>
>>> If drm_fb_helper_alloc_fbi() fails then we were directly returning
>>> without freeing sysram. Also if drm_fb_helper_alloc_fbi() succeeds but
>>> mgag200_framebuffer_init() fails then we were not releasing sysram and
>>> we were not releasing fbi helper also.
>>>
>>> Signed-off-by: Sudip Mukherjee 
>>> ---
>>>  drivers/gpu/drm/mgag200/mgag200_fb.c | 15 ---
>>>  1 file changed, 12 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
>>> b/drivers/gpu/drm/mgag200/mgag200_fb.c
>>> index 87de15e..5fe476a 100644
>>> --- a/drivers/gpu/drm/mgag200/mgag200_fb.c
>>> +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
>>> @@ -189,14 +189,16 @@ static int mgag200fb_create(struct drm_fb_helper 
>>> *helper,
>>>   return -ENOMEM;
>>>
>>>   info = drm_fb_helper_alloc_fbi(helper);
>>> - if (IS_ERR(info))
>>> - return PTR_ERR(info);
>>> + if (IS_ERR(info)) {
>>> + ret = PTR_ERR(info);
>>> + goto err_alloc_fbi;
>>> + }
>>>
>>>   info->par = mfbdev;
>>>
>>>   ret = mgag200_framebuffer_init(dev, >mfb, _cmd, gobj);
>>>   if (ret)
>>> - return ret;
>>> + goto err_framebuffer_init;
>>>
>>>   mfbdev->sysram = sysram;
>>>   mfbdev->size = size;
>>> @@ -226,6 +228,13 @@ static int mgag200fb_create(struct drm_fb_helper 
>>> *helper,
>>>   DRM_DEBUG_KMS("allocated %dx%d\n",
>>> fb->width, fb->height);
>>>   return 0;
>>> +
>>> +err_framebuffer_init:
>>> + drm_fb_helper_release_fbi(helper);
>>> +
>>> +err_alloc_fbi:
>>> + vfree(sysram);
>>> + return ret;
>>>  }
>>>
>>>  static int mga_fbdev_destroy(struct drm_device *dev,
>>
>> There's a new regression: v4.3-rc1 crashes on bootup on non-supported 
>> hardware, if
>> CONFIG_DRM_MGAG200=y (built into the kernel).
>
> Archit, I'm guessing this is some fallout from the fbdev changes.
>
> There is no reason we should need CONFIG_FB_LITTLE_ENDIAN I don't think.
>
> Dave.
>
>>
>> [   10.191561] bus: 'i2c': add device i2c-0
>> [   10.227367] mgadrmfb: enable CONFIG_FB_LITTLE_ENDIAN to support this 
>> framebuffer
>> [   10.235781] [drm:mgag200_modeset_init] *ERROR* mga_fbdev_init failed
>> [   10.242992] mgag200 :0b:00.0: Fatal error during modeset init: -22
>> [   10.250456] kfree_debugcheck: out of range ptr 6b6b6b6b6b6b6b6bh.
>> [   10.257378] invalid opcode:  [#1] PREEMPT SMP DEBUG_PAGEALLOC
>> [   10.264730] Modules linked in:
>> [   10.268319] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 
>> 4.3.0-rc1-01643-g6013d75-dirty #15
>> [   10.277498] Hardware name: Intel Corporation S2600GZ/S2600GZ, BIOS 
>> SE5C600.86B.02.02.0002.122320131210 12/23/2013
>> [   10.289111] task: 88017fb6c040 ti: 88017fb7 task.ti: 
>> 88017fb7
>> [   10.297611] RIP: 0010:[]  [] 
>> kfree_debugcheck+0x20/0x25
>> [   10.307170] RSP: :88017fb73b28  EFLAGS: 00010086
>> [   10.313213] RAX: 0035 RBX: 6b6b6b6b6b6b6b6b RCX: 
>> 
>> [   10.321297] RDX: a489ac8f RSI: a489b27b RDI: 
>> a489b11e
>> [   10.329381] RBP: 88017fb73b30 R08: 0001 R09: 
>> 
>> [   10.337466] R10: a537dec0 R11:  R12: 
>> 0001
>> [   10.345549] R13: a4c2c22a R14: 0202 R15: 
>> 8807ee3f1018
>> [   10.353632] FS:  () GS:88081b20() 
>> knlGS:
>> [   10.362812] CS:  0010 DS:  ES:  CR0: 80050033
>> [   10.369330] CR2:  CR3: 258c CR4: 
>> 001406f0
>> [   10.377415] Stack:
>> [   10.379761]  6b6b6b6b6b6b6b6b 88017fb73b70 a493e421 
>> 8807ee784ea0
>> [   10.388499]  8807ee784e18 0001 8807ee361060 
>> ffea
>> [   10.397238]  8807ee3f1018 88017fb73b98 a4c2c22a 
>> 8807ee784e18
>> [   10.405968] Call Trace:
>> [   10.408804]  [] kfree+0x5a/0x195
>> [   10.414256]  [] drm_fb_helper_crtc_free+0x28/0x75
>> [   10.421368]  [] drm_fb_helper_fini+0x6b/0x6e
>> [   10.427996]  [] mgag200_fbdev_fini+0x8a/0xb9
>> [   10.434621]  [] mgag200_driver_unload+0x23/0x43
>> [   10.441539]  [] mgag200_driver_load+0x4aa/0x4bc
>> [   10.448458]  [] drm_dev_register+0x6a/0xab
>> [   10.454889]  [] drm_get_pci_dev+0xe8/0x1ab
>> [   10.461322]  [] mga_pci_probe+0xa1/0xaa
>> [   10.467465]  [] pci_device_probe+0x7e/0xe8
>> ...
>>
>> Thanks,
>>
>> Ingo
>> --
>> 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/


[PATCH] drm/mgag200: fix memory leak

2015-09-14 Thread Dave Airlie
>
>> If drm_fb_helper_alloc_fbi() fails then we were directly returning
>> without freeing sysram. Also if drm_fb_helper_alloc_fbi() succeeds but
>> mgag200_framebuffer_init() fails then we were not releasing sysram and
>> we were not releasing fbi helper also.
>>
>> Signed-off-by: Sudip Mukherjee 
>> ---
>>  drivers/gpu/drm/mgag200/mgag200_fb.c | 15 ---
>>  1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
>> b/drivers/gpu/drm/mgag200/mgag200_fb.c
>> index 87de15e..5fe476a 100644
>> --- a/drivers/gpu/drm/mgag200/mgag200_fb.c
>> +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
>> @@ -189,14 +189,16 @@ static int mgag200fb_create(struct drm_fb_helper 
>> *helper,
>>   return -ENOMEM;
>>
>>   info = drm_fb_helper_alloc_fbi(helper);
>> - if (IS_ERR(info))
>> - return PTR_ERR(info);
>> + if (IS_ERR(info)) {
>> + ret = PTR_ERR(info);
>> + goto err_alloc_fbi;
>> + }
>>
>>   info->par = mfbdev;
>>
>>   ret = mgag200_framebuffer_init(dev, >mfb, _cmd, gobj);
>>   if (ret)
>> - return ret;
>> + goto err_framebuffer_init;
>>
>>   mfbdev->sysram = sysram;
>>   mfbdev->size = size;
>> @@ -226,6 +228,13 @@ static int mgag200fb_create(struct drm_fb_helper 
>> *helper,
>>   DRM_DEBUG_KMS("allocated %dx%d\n",
>> fb->width, fb->height);
>>   return 0;
>> +
>> +err_framebuffer_init:
>> + drm_fb_helper_release_fbi(helper);
>> +
>> +err_alloc_fbi:
>> + vfree(sysram);
>> + return ret;
>>  }
>>
>>  static int mga_fbdev_destroy(struct drm_device *dev,
>
> There's a new regression: v4.3-rc1 crashes on bootup on non-supported 
> hardware, if
> CONFIG_DRM_MGAG200=y (built into the kernel).

Archit, I'm guessing this is some fallout from the fbdev changes.

There is no reason we should need CONFIG_FB_LITTLE_ENDIAN I don't think.

Dave.

>
> [   10.191561] bus: 'i2c': add device i2c-0
> [   10.227367] mgadrmfb: enable CONFIG_FB_LITTLE_ENDIAN to support this 
> framebuffer
> [   10.235781] [drm:mgag200_modeset_init] *ERROR* mga_fbdev_init failed
> [   10.242992] mgag200 :0b:00.0: Fatal error during modeset init: -22
> [   10.250456] kfree_debugcheck: out of range ptr 6b6b6b6b6b6b6b6bh.
> [   10.257378] invalid opcode:  [#1] PREEMPT SMP DEBUG_PAGEALLOC
> [   10.264730] Modules linked in:
> [   10.268319] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 
> 4.3.0-rc1-01643-g6013d75-dirty #15
> [   10.277498] Hardware name: Intel Corporation S2600GZ/S2600GZ, BIOS 
> SE5C600.86B.02.02.0002.122320131210 12/23/2013
> [   10.289111] task: 88017fb6c040 ti: 88017fb7 task.ti: 
> 88017fb7
> [   10.297611] RIP: 0010:[]  [] 
> kfree_debugcheck+0x20/0x25
> [   10.307170] RSP: :88017fb73b28  EFLAGS: 00010086
> [   10.313213] RAX: 0035 RBX: 6b6b6b6b6b6b6b6b RCX: 
> 
> [   10.321297] RDX: a489ac8f RSI: a489b27b RDI: 
> a489b11e
> [   10.329381] RBP: 88017fb73b30 R08: 0001 R09: 
> 
> [   10.337466] R10: a537dec0 R11:  R12: 
> 0001
> [   10.345549] R13: a4c2c22a R14: 0202 R15: 
> 8807ee3f1018
> [   10.353632] FS:  () GS:88081b20() 
> knlGS:
> [   10.362812] CS:  0010 DS:  ES:  CR0: 80050033
> [   10.369330] CR2:  CR3: 258c CR4: 
> 001406f0
> [   10.377415] Stack:
> [   10.379761]  6b6b6b6b6b6b6b6b 88017fb73b70 a493e421 
> 8807ee784ea0
> [   10.388499]  8807ee784e18 0001 8807ee361060 
> ffea
> [   10.397238]  8807ee3f1018 88017fb73b98 a4c2c22a 
> 8807ee784e18
> [   10.405968] Call Trace:
> [   10.408804]  [] kfree+0x5a/0x195
> [   10.414256]  [] drm_fb_helper_crtc_free+0x28/0x75
> [   10.421368]  [] drm_fb_helper_fini+0x6b/0x6e
> [   10.427996]  [] mgag200_fbdev_fini+0x8a/0xb9
> [   10.434621]  [] mgag200_driver_unload+0x23/0x43
> [   10.441539]  [] mgag200_driver_load+0x4aa/0x4bc
> [   10.448458]  [] drm_dev_register+0x6a/0xab
> [   10.454889]  [] drm_get_pci_dev+0xe8/0x1ab
> [   10.461322]  [] mga_pci_probe+0xa1/0xaa
> [   10.467465]  [] pci_device_probe+0x7e/0xe8
> ...
>
> Thanks,
>
> Ingo
> --
> 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/


[PATCHv3 3/3] drm: bridge: anx78xx: Add anx78xx driver support by analogix.

2015-09-14 Thread Nicolas Boichat
Hi Enric,

Partial review for now, thanks for you work.

Best,

On Thu, Sep 10, 2015 at 06:35:52PM +0200, Enric Balletbo i Serra wrote:
> At the moment it only supports ANX7814.
> 
> The ANX7814 is an ultra-low power Full-HD (1080p60) SlimPort transmitter
> designed for portable devices.
> 
> This driver adds initial support and supports HDMI to DP pass-through mode.
> 
> Signed-off-by: Enric Balletbo i Serra 
> ---

Please include a revision log here, stating what you changed between each
version.

>  drivers/gpu/drm/bridge/Kconfig   |2 +
>  drivers/gpu/drm/bridge/Makefile  |1 +
>  drivers/gpu/drm/bridge/anx78xx/Kconfig   |7 +
>  drivers/gpu/drm/bridge/anx78xx/Makefile  |4 +
>  drivers/gpu/drm/bridge/anx78xx/anx78xx.h |   44 +
>  drivers/gpu/drm/bridge/anx78xx/anx78xx_main.c|  241 ++
>  drivers/gpu/drm/bridge/anx78xx/slimport_tx_drv.c | 3198 
> ++
>  drivers/gpu/drm/bridge/anx78xx/slimport_tx_drv.h |  215 ++
>  drivers/gpu/drm/bridge/anx78xx/slimport_tx_reg.h |  786 ++
>  9 files changed, 4498 insertions(+)
>  create mode 100644 drivers/gpu/drm/bridge/anx78xx/Kconfig
>  create mode 100644 drivers/gpu/drm/bridge/anx78xx/Makefile
>  create mode 100644 drivers/gpu/drm/bridge/anx78xx/anx78xx.h
>  create mode 100644 drivers/gpu/drm/bridge/anx78xx/anx78xx_main.c
>  create mode 100644 drivers/gpu/drm/bridge/anx78xx/slimport_tx_drv.c
>  create mode 100644 drivers/gpu/drm/bridge/anx78xx/slimport_tx_drv.h
>  create mode 100644 drivers/gpu/drm/bridge/anx78xx/slimport_tx_reg.h
> 
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index 2de52a5..aa6fe12 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -29,4 +29,6 @@ config DRM_PARADE_PS8622
>   ---help---
> Parade eDP-LVDS bridge chip driver.
>  
> +source "drivers/gpu/drm/bridge/anx78xx/Kconfig"
> +
>  endmenu
> diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
> index e2eef1c..e5bd38b 100644
> --- a/drivers/gpu/drm/bridge/Makefile
> +++ b/drivers/gpu/drm/bridge/Makefile
> @@ -3,3 +3,4 @@ ccflags-y := -Iinclude/drm
>  obj-$(CONFIG_DRM_DW_HDMI) += dw_hdmi.o
>  obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
>  obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o
> +obj-$(CONFIG_DRM_ANX78XX) += anx78xx/
> diff --git a/drivers/gpu/drm/bridge/anx78xx/Kconfig 
> b/drivers/gpu/drm/bridge/anx78xx/Kconfig
> new file mode 100644
> index 000..08f9c08
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/anx78xx/Kconfig
> @@ -0,0 +1,7 @@
> +config DRM_ANX78XX
> + tristate "Analogix ANX78XX bridge"
> + help
> + ANX78XX is a HD video transmitter chip over micro-USB
> + connector for smartphone device.
> +
> +
> diff --git a/drivers/gpu/drm/bridge/anx78xx/Makefile 
> b/drivers/gpu/drm/bridge/anx78xx/Makefile
> new file mode 100644
> index 000..a843733
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/anx78xx/Makefile
> @@ -0,0 +1,4 @@
> +obj-${CONFIG_DRM_ANX78XX} :=  anx78xx.o
> +
> +anx78xx-y += anx78xx_main.o
> +anx78xx-y += slimport_tx_drv.o
> diff --git a/drivers/gpu/drm/bridge/anx78xx/anx78xx.h 
> b/drivers/gpu/drm/bridge/anx78xx/anx78xx.h
> new file mode 100644
> index 000..4f6dd1d
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/anx78xx/anx78xx.h
> @@ -0,0 +1,44 @@
> +/*
> + * Copyright(c) 2015, Analogix Semiconductor. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only 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 __ANX78xx_H
> +#define __ANX78xx_H
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define AUX_ERR  1
> +#define AUX_OK   0
> +
> +struct anx78xx_platform_data {
> + struct gpio_desc *gpiod_pd;
> + struct gpio_desc *gpiod_reset;
> + spinlock_t lock;
> +};
> +
> +struct anx78xx {
> + struct i2c_client *client;
> + struct anx78xx_platform_data *pdata;
> + struct delayed_work work;
> + struct workqueue_struct *workqueue;
> + struct mutex lock;
> +};
> +
> +void anx78xx_poweron(struct anx78xx *data);
> +void anx78xx_poweroff(struct anx78xx *data);
> +
> +#endif
> diff --git a/drivers/gpu/drm/bridge/anx78xx/anx78xx_main.c 
> b/drivers/gpu/drm/bridge/anx78xx/anx78xx_main.c
> new file mode 100644
> index 000..b92d2bc
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/anx78xx/anx78xx_main.c
> @@ -0,0 +1,241 @@
> +/*
> + * Copyright(c) 2015, Analogix Semiconductor. All rights reserved.
> + *
> + * This program is free software; you can redistribute 

[Bug 91982] [radeonsi] fs leak in get_radeon_bo()

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91982

--- Comment #6 from Shawn Starr  ---
Created attachment 118270
  --> https://bugs.freedesktop.org/attachment.cgi?id=118270=edit
Valgrind output with ulimit capped at 1GB (Virtual)

This is stdout output only

-- 
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/20150914/5f50c0ea/attachment.html>


[PATCH] drm/cma-helper: Add multi buffer support for cma fbdev

2015-09-14 Thread Xinliang Liu
This patch add a config to support to create multi buffer for cma fbdev. Such as
double buffer and triple buffer.

Cma fbdev is convient to add a legency fbdev. And still many Android devices use
fbdev now and at least double buffer is needed for these Android devices, so
that a buffer flip can be operated. It will need some time for Android device
vendors to abondon legency fbdev. So multi buffer for fbdev is needed.

Signed-off-by: Xinliang Liu 
---
 drivers/gpu/drm/Kconfig | 8 
 drivers/gpu/drm/drm_fb_cma_helper.c | 8 +++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 1a0a8df..577f790 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -97,6 +97,14 @@ config DRM_KMS_CMA_HELPER
help
  Choose this if you need the KMS CMA helper functions

+config DRM_CMA_FBDEV_BUFFER_NUM
+   int "Cma Fbdev Buffer Number"
+   depends on DRM_KMS_CMA_HELPER
+   default 1
+   help
+ Defines the buffer number of cma fbdev.  Default is one buffer.
+ For double buffer please set to 2 and 3 for triple buffer.
+
 source "drivers/gpu/drm/i2c/Kconfig"

 config DRM_TDFX
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index c19a625..26051b8 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -25,6 +25,12 @@
 #include 
 #include 

+#ifdef CONFIG_DRM_CMA_FBDEV_BUFFER_NUM
+#define FBDEV_BUFFER_NUM CONFIG_DRM_CMA_FBDEV_BUFFER_NUM
+#else
+#define FBDEV_BUFFER_NUM 1
+#endif
+
 struct drm_fb_cma {
struct drm_framebuffer  fb;
struct drm_gem_cma_object   *obj[4];
@@ -253,7 +259,7 @@ static int drm_fbdev_cma_create(struct drm_fb_helper 
*helper,
bytes_per_pixel = DIV_ROUND_UP(sizes->surface_bpp, 8);

mode_cmd.width = sizes->surface_width;
-   mode_cmd.height = sizes->surface_height;
+   mode_cmd.height = sizes->surface_height * FBDEV_BUFFER_NUM;
mode_cmd.pitches[0] = sizes->surface_width * bytes_per_pixel;
mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
sizes->surface_depth);
-- 
1.9.1



[Bug 100351] System freezes for 2 seconds while opening apps

2015-09-14 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=100351

--- Comment #6 from yaroslav.sapozhnik at gmail.com ---
Seems like it's fixed with 4.1.6-200.fc22.x86_64. I'll monitor this for some
time.

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


[PULL] topic/drm-misc

2015-09-14 Thread Daniel Vetter
Hi Dave,

-rc1 is out the door and here's my first pull request for drm-next. It's
all over:
- better atomic helpers for runtime pm drivers
- atomic fbdev
- dp aux i2c STATUS_UPDATE handling (for short i2c replies from the sink)
- bunch of constify patches
- various polish all over

There's a few atomic drivers who want the goodies in here (at least rcar
and i915).

Cheers, Daniel


The following changes since commit 73bf1b7be7aab60d7c651402441dd0b0b4991098:

  Merge branch 'drm-next-4.3' of git://people.freedesktop.org/~agd5f/linux into 
drm-next (2015-09-05 07:46:09 +1000)

are available in the git repository at:

  git://anongit.freedesktop.org/drm-intel tags/topic/drm-misc-2015-09-14

for you to fetch changes up to 216c59d65f99aa1ef1a92e1ae64f1f1c2590dddc:

  drm/atomic-helper: Don't skip plane disabling on active CRTC (2015-09-13 
23:20:54 +0200)


Bob Paauwe (1):
  dtrm/edid: Allow comma separated edid binaries. (v3)

Daniel Vetter (8):
  drm/atomic-helper: properly annotate functions in kerneldoc
  drm/fb-helper: Use -errno return in restore_mode_unlocked
  drm: Make drm_fb_unregister/remove accept NULL fb
  drm/fb-helper: Add module option to disable fbdev emulation
  drm/atomic: refuse changing CRTC for planes directly
  drm/atomic-helper: Add option to update planes only on active crtc
  drm/atomic-helper: Pimp docs with recommendations for rpm drivers
  drm: Nuke drm_framebuffer->helper_private

Danilo Cesar Lemes de Paula (1):
  drm/doc: Fixing xml documentation warning

David Herrmann (2):
  drm: simplify drm_sysfs_destroy() via IS_ERR_OR_NULL()
  drm: move drm_class into drm_sysfs.c

Gustavo Padovan (1):
  drm: WARN_ON if a modeset driver uses legacy suspend/resume helpers

Laurent Pinchart (1):
  drm/atomic-helper: Don't skip plane disabling on active CRTC

Maarten Lankhorst (3):
  drm/atomic: Make sure lock is held in trylock contexts.
  drm/atomic: Make prepare_fb/cleanup_fb only take state, v3.
  drm/core: Do not call drm_framebuffer_remove internally during teardown.

Michel Thierry (1):
  drm/mm: Do DRM_MM_CREATE_TOP adj_start calculation after color_adjust

Rob Clark (1):
  drm: cleanup modesetting ioctls, one param per line

Thierry Reding (1):
  drm/atomic-helper: Implement drm_atomic_helper_duplicate_state()

Ville Syrjälä (11):
  drm: Constify generic_edid_names[]
  drm: Constify TV mode names
  drm/i2c/ch7006: Constify ch7006_tv_norms[] and ch7006_modes[]
  drm/dp: s/I2C_STATUS/I2C_WRITE_STATUS_UPDATE/
  drm/i915: Handle DP_AUX_I2C_WRITE_STATUS_UPDATE
  drm/radeon: Handle DP_AUX_I2C_WRITE_STATUS_UPDATE
  drm/tegra: Handle I2C_WRITE_STATUS_UPDATE for address only writes
  drm/dp: Use I2C_WRITE_STATUS_UPDATE to drain partial I2C_WRITE requests
  drm: Make some modes const when iterating through them
  drm: Remove the 'mode' argument from drm_select_eld()
  drm: Make drm_av_sync_delay() 'mode' argument const

 Documentation/kernel-parameters.txt |  15 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c |   4 +-
 drivers/gpu/drm/drm_atomic.c|  25 
 drivers/gpu/drm/drm_atomic_helper.c | 185 
 drivers/gpu/drm/drm_crtc.c  |  18 ++-
 drivers/gpu/drm/drm_dp_helper.c |  43 +-
 drivers/gpu/drm/drm_drv.c   |   8 +-
 drivers/gpu/drm/drm_edid.c  |   8 +-
 drivers/gpu/drm/drm_edid_load.c |  43 --
 drivers/gpu/drm/drm_fb_helper.c |  48 +-
 drivers/gpu/drm/drm_internal.h  |   2 +-
 drivers/gpu/drm/drm_mm.c|   6 +-
 drivers/gpu/drm/drm_modeset_lock.c  |   2 +
 drivers/gpu/drm/drm_plane_helper.c  |   6 +-
 drivers/gpu/drm/drm_sysfs.c |  49 +++
 drivers/gpu/drm/exynos/exynos_drm_drv.c |   2 +-
 drivers/gpu/drm/i2c/ch7006_drv.c|   6 +-
 drivers/gpu/drm/i2c/ch7006_mode.c   |  26 ++--
 drivers/gpu/drm/i2c/ch7006_priv.h   |  12 +-
 drivers/gpu/drm/i915/intel_audio.c  |   2 +-
 drivers/gpu/drm/i915/intel_display.c|   9 +-
 drivers/gpu/drm/i915/intel_dp.c |   1 +
 drivers/gpu/drm/i915/intel_drv.h|   2 -
 drivers/gpu/drm/i915/intel_tv.c |   4 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c   |  10 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c   |  10 +-
 drivers/gpu/drm/msm/msm_atomic.c|   2 +-
 drivers/gpu/drm/nouveau/dispnv04/tvmodesnv17.c  |   2 +-
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.h   |   2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c  |   2 +-
 drivers/gpu/drm/omapdrm/omap_plane.c|  10 +-
 drivers/gpu/drm/radeon/atombios_dp.c|   1 +
 

[PATCH 3/3] drm/dp: Add a drm_aux-dev module for reading/writing dpcd registers.

2015-09-14 Thread Rafael Antognolli
This module is heavily based on i2c-dev. Once loaded, it provides one
dev node per DP AUX channel, named drm_aux-N.

It's possible to know which connector owns this aux channel by looking
at the respective sysfs /sys/class/drm_aux-dev/drm_aux-N/connector, if
the connector device pointer was correctly set in the aux helper struct.

Two main operations are provided on the registers through ioctls: read
and write; and a helper struct is provided for that, used as:

- address is the address of the register to read/write;
- len is the number of bytes to read/write;
- buf is a pointer to a buffer where to store the read data, or
  where the data to be written is already stored;
- the return value is the number of bytes read/written, on
  success, or the error code otherwise. The number of
  read/written bytes is also stored on the len field of the
  struct.

Signed-off-by: Rafael Antognolli 
---
 Documentation/ioctl/ioctl-number.txt |   1 +
 drivers/gpu/drm/Kconfig  |   4 +
 drivers/gpu/drm/Makefile |   1 +
 drivers/gpu/drm/drm_aux-dev.c| 390 +++
 include/uapi/linux/Kbuild|   1 +
 include/uapi/linux/drm_aux-dev.h |  45 
 6 files changed, 442 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_aux-dev.c
 create mode 100644 include/uapi/linux/drm_aux-dev.h

diff --git a/Documentation/ioctl/ioctl-number.txt 
b/Documentation/ioctl/ioctl-number.txt
index 611c522..ea76980 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -93,6 +93,7 @@ Code  Seq#(hex)   Include FileComments
 ';'64-7F   linux/vfio.h
 '@'00-0F   linux/radeonfb.hconflict!
 '@'00-0F   drivers/video/aty/aty128fb.cconflict!
+'@'10-2F   drm_aux-dev
 'A'00-1F   linux/apm_bios.hconflict!
 'A'00-0F   linux/agpgart.h conflict!
and drivers/char/agp/compat_ioctl.h
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 1a0a8df..eae847c 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -25,6 +25,10 @@ config DRM_MIPI_DSI
bool
depends on DRM

+config DRM_AUX_CHARDEV
+   tristate "DRM DP AUX Interface"
+   depends on DRM
+
 config DRM_KMS_HELPER
tristate
depends on DRM
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 45e7719..a1a94306 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -32,6 +32,7 @@ CFLAGS_drm_trace_points.o := -I$(src)

 obj-$(CONFIG_DRM)  += drm.o
 obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
+obj-$(CONFIG_DRM_AUX_CHARDEV) += drm_aux-dev.o
 obj-$(CONFIG_DRM_TTM)  += ttm/
 obj-$(CONFIG_DRM_TDFX) += tdfx/
 obj-$(CONFIG_DRM_R128) += r128/
diff --git a/drivers/gpu/drm/drm_aux-dev.c b/drivers/gpu/drm/drm_aux-dev.c
new file mode 100644
index 000..3ae9064
--- /dev/null
+++ b/drivers/gpu/drm/drm_aux-dev.c
@@ -0,0 +1,390 @@
+/*
+ * 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:
+ *Rafael Antognolli 
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct drm_aux_dev {
+   struct list_head list;
+   unsigned index;
+   struct drm_dp_aux *aux;
+   struct device *dev;
+};
+
+#define DRM_AUX_MINORS 256
+static int drm_aux_dev_count = 0;
+static LIST_HEAD(drm_aux_dev_list);
+static DEFINE_SPINLOCK(drm_aux_dev_list_lock);
+
+static struct drm_aux_dev *drm_aux_dev_get_by_minor(unsigned index)
+{
+   struct drm_aux_dev *aux_dev;
+
+   spin_lock(_aux_dev_list_lock);
+   list_for_each_entry(aux_dev, _aux_dev_list, list) {
+   if (aux_dev->index == index)
+   goto found;
+   }
+
+   aux_dev = NULL;
+found:
+   

[PATCH 2/3] drm/dp: Store the drm_connector device pointer on the helper.

2015-09-14 Thread Rafael Antognolli
This is useful to determine which connector owns this AUX channel.

Signed-off-by: Rafael Antognolli 
---
 drivers/gpu/drm/i915/intel_dp.c | 1 +
 include/drm/drm_dp_helper.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f8f4d99..6f481fc 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1078,6 +1078,7 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct 
intel_connector *connector)

intel_dp->aux.name = name;
intel_dp->aux.dev = dev->dev;
+   intel_dp->aux.connector = connector->base.kdev;
intel_dp->aux.transfer = intel_dp_aux_transfer;

DRM_DEBUG_KMS("registering %s bus for %s\n", name,
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 023620c..e481fbd 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -702,6 +702,7 @@ struct drm_dp_aux {
const char *name;
struct i2c_adapter ddc;
struct device *dev;
+   struct device *connector;
struct mutex hw_mutex;
ssize_t (*transfer)(struct drm_dp_aux *aux,
struct drm_dp_aux_msg *msg);
-- 
2.4.0



[PATCH 1/3] drm/dp: Keep a list of drm_dp_aux helper.

2015-09-14 Thread Rafael Antognolli
This list will be used to get the aux channels registered through the
helpers. Two functions are provided to register/unregister notifier
listeners on the list, and another functiont to iterate over the list of
aux channels.

Signed-off-by: Rafael Antognolli 
---
 drivers/gpu/drm/drm_dp_helper.c | 71 +
 include/drm/drm_dp_helper.h |  6 
 2 files changed, 77 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index 291734e..01a1489 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -710,6 +710,54 @@ static const struct i2c_algorithm drm_dp_i2c_algo = {
.master_xfer = drm_dp_i2c_xfer,
 };

+struct drm_dp_aux_node {
+   struct klist_node list;
+   struct drm_dp_aux *aux;
+};
+
+static DEFINE_KLIST(drm_dp_aux_list, NULL, NULL);
+
+static BLOCKING_NOTIFIER_HEAD(aux_notifier);
+
+int drm_dp_aux_register_notifier(struct notifier_block *nb)
+{
+   return blocking_notifier_chain_register(_notifier, nb);
+}
+EXPORT_SYMBOL(drm_dp_aux_register_notifier);
+
+int drm_dp_aux_unregister_notifier(struct notifier_block *nb)
+{
+   return blocking_notifier_chain_unregister(_notifier, nb);
+}
+EXPORT_SYMBOL(drm_dp_aux_unregister_notifier);
+
+static struct drm_dp_aux *next_aux(struct klist_iter *i)
+{
+   struct klist_node *n = klist_next(i);
+   struct drm_dp_aux *aux = NULL;
+   struct drm_dp_aux_node *aux_node;
+
+   if (n) {
+   aux_node = container_of(n, struct drm_dp_aux_node, list);
+   aux = aux_node->aux;
+   }
+   return aux;
+}
+
+int drm_dp_aux_for_each(void *data, int (*fn)(struct drm_dp_aux *, void *))
+{
+   struct klist_iter i;
+   struct drm_dp_aux *aux;
+   int error = 0;
+
+   klist_iter_init(_dp_aux_list, );
+   while ((aux = next_aux()) && !error)
+   error = fn(aux, data);
+   klist_iter_exit();
+   return error;
+}
+EXPORT_SYMBOL(drm_dp_aux_for_each);
+
 /**
  * drm_dp_aux_register() - initialise and register aux channel
  * @aux: DisplayPort AUX channel
@@ -718,6 +766,7 @@ static const struct i2c_algorithm drm_dp_i2c_algo = {
  */
 int drm_dp_aux_register(struct drm_dp_aux *aux)
 {
+   struct drm_dp_aux_node *aux_node;
mutex_init(>hw_mutex);

aux->ddc.algo = _dp_i2c_algo;
@@ -732,6 +781,14 @@ int drm_dp_aux_register(struct drm_dp_aux *aux)
strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
sizeof(aux->ddc.name));

+   /* add aux to list and notify listeners */
+   aux_node = kzalloc(sizeof(*aux_node), GFP_KERNEL);
+   if (!aux_node)
+   return -ENOMEM;
+   aux_node->aux = aux;
+   klist_add_tail(_node->list, _dp_aux_list);
+   blocking_notifier_call_chain(_notifier, DRM_DP_ADD_AUX, aux);
+
return i2c_add_adapter(>ddc);
 }
 EXPORT_SYMBOL(drm_dp_aux_register);
@@ -742,6 +799,20 @@ EXPORT_SYMBOL(drm_dp_aux_register);
  */
 void drm_dp_aux_unregister(struct drm_dp_aux *aux)
 {
+   struct klist_iter i;
+   struct klist_node *n;
+
+   klist_iter_init(_dp_aux_list, );
+   while ((n = klist_next())) {
+   struct drm_dp_aux_node *aux_node =
+   container_of(n, struct drm_dp_aux_node, list);
+   if (aux_node->aux == aux) {
+   klist_del(n);
+   kfree(aux_node);
+   break;
+   }
+   }
+   blocking_notifier_call_chain(_notifier, DRM_DP_DEL_AUX, aux);
i2c_del_adapter(>ddc);
 }
 EXPORT_SYMBOL(drm_dp_aux_unregister);
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 8c52d0ef1..023620c 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -763,7 +763,13 @@ int drm_dp_link_power_up(struct drm_dp_aux *aux, struct 
drm_dp_link *link);
 int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link);
 int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link);

+#define DRM_DP_ADD_AUX 0x01
+#define DRM_DP_DEL_AUX 0x02
+
 int drm_dp_aux_register(struct drm_dp_aux *aux);
 void drm_dp_aux_unregister(struct drm_dp_aux *aux);
+int drm_dp_aux_register_notifier(struct notifier_block *nb);
+int drm_dp_aux_unregister_notifier(struct notifier_block *nb);
+int drm_dp_aux_for_each(void *data, int (*fn)(struct drm_dp_aux *, void *));

 #endif /* _DRM_DP_HELPER_H_ */
-- 
2.4.0



[PATCH 0/3] RFC: Add a drm_aux-dev module.

2015-09-14 Thread Rafael Antognolli
This is a tentative implementation of a module that allows reading/writing
arbitrary dpcd registers, following the suggestion from Daniel Vetter. It
assumes the drm aux helpers were used by the driver.

I tried to follow the i2c-dev implementation as close as possible, but the only
operations that are provided on the dev node are two different ioctl's, one for
reading a register and another one for writing it.

I have at least 2 open questions:

 * Right now the AUX channels are stored in a global list inside the
   drm_dp_helper implementation, and I assume that's not ideal. A different
   approach would be to iterate over the list of connectors, instead of the
   list of AUX channels, but that would require the struct drm_connector or
   similar to know about the respective aux helper. It could be added as a
   function to register that, or as a new method on the drm_connector_funcs to
   retrieve the aux channel helper.

 * From the created sysfs drm_aux-dev device it's possible to know what is the
   respective connector, but not the other way around. Is this good enough?

Please provide any feedback you have and tell me if this is the idea you had
initially for this kind of implementation. Or, if it's nothing like this, let
me know what else you had in mind.

If I'm going in the right direction, I'll refine the patch to provide full
documentation and tests if needed.

Rafael Antognolli (3):
  drm/dp: Keep a list of drm_dp_aux helper.
  drm/dp: Store the drm_connector device pointer on the helper.
  drm/dp: Add a drm_aux-dev module for reading/writing dpcd registers.

 Documentation/ioctl/ioctl-number.txt |   1 +
 drivers/gpu/drm/Kconfig  |   4 +
 drivers/gpu/drm/Makefile |   1 +
 drivers/gpu/drm/drm_aux-dev.c| 390 +++
 drivers/gpu/drm/drm_dp_helper.c  |  71 +++
 drivers/gpu/drm/i915/intel_dp.c  |   1 +
 include/drm/drm_dp_helper.h  |   7 +
 include/uapi/linux/Kbuild|   1 +
 include/uapi/linux/drm_aux-dev.h |  45 
 9 files changed, 521 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_aux-dev.c
 create mode 100644 include/uapi/linux/drm_aux-dev.h

-- 
2.4.0



[PATCH] drm/mgag200: fix memory leak

2015-09-14 Thread Sudip Mukherjee
On Mon, Sep 14, 2015 at 08:05:37PM +1000, Dave Airlie wrote:
> (this time with correct email address).
> 
> On 14 September 2015 at 20:04, Dave Airlie  wrote:
> >>
> >>
> >> There's a new regression: v4.3-rc1 crashes on bootup on non-supported 
> >> hardware, if
> >> CONFIG_DRM_MGAG200=y (built into the kernel).
> >
> > Archit, I'm guessing this is some fallout from the fbdev changes.
> >
> > There is no reason we should need CONFIG_FB_LITTLE_ENDIAN I don't think.
I am assuming v4.2 has worked for Ingo. So in that case I don't see any
change in fbdev/core/fbmem.c between 4.2 and 4.3-rc1. But in drm (I
almost know nothing about drm) commit e829d7ef9f17 changes few codes
related to the card revision. Can this help?

regards
sudip


diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
b/drivers/gpu/drm/mgag200/mgag200_mode.c
index c99d3fe..5cdfa53 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -1602,7 +1602,7 @@ static int mga_vga_mode_valid(struct drm_connector 
*connector,
if (mga_vga_calculate_mode_bandwidth(mode, bpp)
> (24400 * 1024))
return MODE_BANDWIDTH;
-   } else if (mdev->unique_rev_id == 0x02) {
+   } else if (mdev->unique_rev_id >= 0x02) {
if (mode->hdisplay > 1920)
return MODE_VIRTUAL_X;
if (mode->vdisplay > 1200)


[PATCH v4 1/2] intel: 48b ppgtt support (EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag)

2015-09-14 Thread Michał Winiarski
On Thu, Sep 03, 2015 at 03:23:58PM +0100, Michel Thierry wrote:
> Gen8+ supports 48-bit virtual addresses, but some objects must always be
> allocated inside the 32-bit address range.
> 
> In specific, any resource used with flat/heapless (0x-0xf000)
> General State Heap (GSH) or Instruction State Heap (ISH) must be in a
> 32-bit range, because the General State Offset and Instruction State Offset
> are limited to 32-bits.
> 
> The i915 driver has been modified to provide a flag to set when the 4GB
> limit is not necessary in a given bo (EXEC_OBJECT_SUPPORTS_48B_ADDRESS).
> 48-bit range will only be used when explicitly requested.
> 
> Callers to the existing drm_intel_bo_emit_reloc function should set the
> use_48b_address_range flag beforehand, in order to use full ppgtt range.
> 
> v2: Make set/clear functions nops on pre-gen8 platforms, and use them
> internally in emit_reloc functions (Ben)
> s/48BADDRESS/48B_ADDRESS/ (Dave)
> v3: Keep set/clear functions internal, no-one needs to use them directly.
> v4: Don't set 48bit-support flag in emit reloc, check for ppgtt type
> before enabling set/clear function, print full offsets in debug
> statements, using port of lower_32_bits and upper_32_bits from linux
> kernel (Michał)
> 
> References: 
> http://lists.freedesktop.org/archives/intel-gfx/2015-July/072612.html
> Cc: Ben Widawsky 
> Cc: Michał Winiarski 

+Kristian

LGTM.
Acked-by: Michał Winiarski 

> Signed-off-by: Michel Thierry 
> ---
>  include/drm/i915_drm.h|  3 +-
>  intel/intel_bufmgr.c  | 11 ++
>  intel/intel_bufmgr.h  |  1 +
>  intel/intel_bufmgr_gem.c  | 88 
> +--
>  intel/intel_bufmgr_priv.h | 14 
>  5 files changed, 97 insertions(+), 20 deletions(-)
> 
> diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
> index ded43b1..426b25c 100644
> --- a/include/drm/i915_drm.h
> +++ b/include/drm/i915_drm.h
> @@ -680,7 +680,8 @@ struct drm_i915_gem_exec_object2 {
>  #define EXEC_OBJECT_NEEDS_FENCE (1<<0)
>  #define EXEC_OBJECT_NEEDS_GTT(1<<1)
>  #define EXEC_OBJECT_WRITE(1<<2)
> -#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_WRITE<<1)
> +#define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
> +#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_SUPPORTS_48B_ADDRESS<<1)
>   __u64 flags;
>  
>   __u64 rsvd1;
> diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
> index 14ea9f9..0856e60 100644
> --- a/intel/intel_bufmgr.c
> +++ b/intel/intel_bufmgr.c
> @@ -293,6 +293,17 @@ drm_intel_bo_madvise(drm_intel_bo *bo, int madv)
>  }
>  
>  int
> +drm_intel_bo_use_48b_address_range(drm_intel_bo *bo, uint32_t enable)
> +{
> + if (bo->bufmgr->bo_use_48b_address_range) {
> + bo->bufmgr->bo_use_48b_address_range(bo, enable);
> + return 0;
> + }
> +
> + return -ENODEV;
> +}
> +
> +int
>  drm_intel_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo)
>  {
>   return bo->bufmgr->bo_references(bo, target_bo);
> diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
> index 95eecb8..a14c78f 100644
> --- a/intel/intel_bufmgr.h
> +++ b/intel/intel_bufmgr.h
> @@ -164,6 +164,7 @@ int drm_intel_bo_get_tiling(drm_intel_bo *bo, uint32_t * 
> tiling_mode,
>  int drm_intel_bo_flink(drm_intel_bo *bo, uint32_t * name);
>  int drm_intel_bo_busy(drm_intel_bo *bo);
>  int drm_intel_bo_madvise(drm_intel_bo *bo, int madv);
> +int drm_intel_bo_use_48b_address_range(drm_intel_bo *bo, uint32_t enable);
>  
>  int drm_intel_bo_disable_reuse(drm_intel_bo *bo);
>  int drm_intel_bo_is_reusable(drm_intel_bo *bo);
> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
> index 2723e21..09d82d2 100644
> --- a/intel/intel_bufmgr_gem.c
> +++ b/intel/intel_bufmgr_gem.c
> @@ -83,6 +83,22 @@
>  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
>  #define MAX2(A, B) ((A) > (B) ? (A) : (B))
>  
> +/**
> + * upper_32_bits - return bits 32-63 of a number
> + * @n: the number we're accessing
> + *
> + * A basic shift-right of a 64- or 32-bit quantity.  Use this to suppress
> + * the "right shift count >= width of type" warning when that quantity is
> + * 32-bits.
> + */
> +#define upper_32_bits(n) ((__u32)(((n) >> 16) >> 16))
> +
> +/**
> + * lower_32_bits - return bits 0-31 of a number
> + * @n: the number we're accessing
> + */
> +#define lower_32_bits(n) ((__u32)(n))
> +
>  typedef struct _drm_intel_bo_gem drm_intel_bo_gem;
>  
>  struct drm_intel_gem_bo_bucket {
> @@ -237,6 +253,15 @@ struct _drm_intel_bo_gem {
>   bool is_userptr;
>  
>   /**
> +  * Boolean of whether this buffer can be placed in the full 48-bit
> +  * address range on gen8+.
> +  *
> +  * By default, buffers will be keep in a 32-bit range, unless this
> +  * flag is explicitly set.
> +  */
> + bool use_48b_address_range;
> +
> + /**
>* Size in bytes of this buffer and its relocation descendents.
>*
>* Used to avoid costly tree 

[Bug 91998] Object rendered completely black in The Book of Unwritten Tales: The Critter Chronicles

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91998

--- Comment #4 from smoki  ---
(In reply to Daniel Scharrer from comment #0)
> 
> The pipe behind the character is rendered completely black. The object is
> rendered without any shader but with fixed-function lighting enabled.

 Description sounds to me like bug 84156. Similar thing happens in 3DMark2001
with GLSL disabled in wine or what happens in that Pedal to the Metal game.

-- 
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/20150914/e7443386/attachment.html>


[PATCH] drm/i915: Fix warnings while make xmldocs caused by intel_lrc.c

2015-09-14 Thread Daniel Vetter
On Sun, Sep 13, 2015 at 09:08:31PM +0900, Masanari Iida wrote:
> This patch fix following warnings while "make xmldocs".
> .//drivers/gpu/drm/i915/intel_lrc.c:780: warning: No description
> found for parameter 'req'
> .//drivers/gpu/drm/i915/intel_lrc.c:780: warning: Excess function
>  parameter 'request' description in 'intel_logical_ring_begin'
> .//drivers/gpu/drm/i915/intel_lrc.c:780: warning: Excess function
>  parameter 'ctx' description in 'intel_logical_ring_begin'
> 
> Signed-off-by: Masanari Iida 

Queued for -next, thanks for the patch.
-Daniel

> ---
>  drivers/gpu/drm/i915/intel_lrc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c 
> b/drivers/gpu/drm/i915/intel_lrc.c
> index 72e0edd..963992a 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -765,8 +765,7 @@ static int logical_ring_prepare(struct 
> drm_i915_gem_request *req, int bytes)
>  /**
>   * intel_logical_ring_begin() - prepare the logical ringbuffer to accept 
> some commands
>   *
> - * @request: The request to start some new work for
> - * @ctx: Logical ring context whose ringbuffer is being prepared.
> + * @req: The request to start some new work for
>   * @num_dwords: number of DWORDs that we plan to write to the ringbuffer.
>   *
>   * The ringbuffer might not be ready to accept the commands right away 
> (maybe it needs to
> -- 
> 2.6.0.rc0.24.gec371ff
> 
> ___
> 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] drm/mgag200: fix memory leak

2015-09-14 Thread Sudip Mukherjee
On Sun, Sep 13, 2015 at 11:36:07AM +0200, Ingo Molnar wrote:
> 
> * Sudip Mukherjee  wrote:
> 

> 
> There's a new regression: v4.3-rc1 crashes on bootup on non-supported 
> hardware, if 
> CONFIG_DRM_MGAG200=y (built into the kernel).

I am not able to reproduce it with and without my patch applied.
I have attached my config file. Compiled and booted on my test system
also tried on qemu. Can you please give your .config file.

regards
sudip
-- next part --
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 4.3.0-rc1 Kernel Configuration
#
# CONFIG_64BIT is not set
CONFIG_X86_32=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_PERF_EVENTS_INTEL_UNCORE=y
CONFIG_OUTPUT_FORMAT="elf32-i386"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_HAVE_LATENCYTOP_SUPPORT=y
CONFIG_MMU=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ARCH_HAS_CPU_RELAX=y
CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
CONFIG_HAVE_SETUP_PER_CPU_AREA=y
CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_HAVE_INTEL_TXT=y
CONFIG_X86_32_SMP=y
CONFIG_X86_32_LAZY_GS=y
CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-ecx -fcall-saved-edx"
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_PGTABLE_LEVELS=3
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
CONFIG_SYSVIPC_SYSCTL=y
CONFIG_POSIX_MQUEUE=y
CONFIG_POSIX_MQUEUE_SYSCTL=y
CONFIG_CROSS_MEMORY_ATTACH=y
CONFIG_FHANDLE=y
CONFIG_USELIB=y
CONFIG_AUDIT=y
CONFIG_HAVE_ARCH_AUDITSYSCALL=y
CONFIG_AUDITSYSCALL=y
CONFIG_AUDIT_WATCH=y
CONFIG_AUDIT_TREE=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_GENERIC_PENDING_IRQ=y
CONFIG_IRQ_DOMAIN=y
CONFIG_IRQ_DOMAIN_HIERARCHY=y
CONFIG_GENERIC_MSI_IRQ=y
CONFIG_GENERIC_MSI_IRQ_DOMAIN=y
# CONFIG_IRQ_DOMAIN_DEBUG is not set
CONFIG_IRQ_FORCED_THREADING=y
CONFIG_SPARSE_IRQ=y
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_ARCH_CLOCKSOURCE_DATA=y
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
CONFIG_GENERIC_TIME_VSYSCALL=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y
CONFIG_GENERIC_CMOS_UPDATE=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y

#
# CPU/Task time and stats accounting
#
CONFIG_TICK_CPU_ACCOUNTING=y
# CONFIG_IRQ_TIME_ACCOUNTING is not set
CONFIG_BSD_PROCESS_ACCT=y
CONFIG_BSD_PROCESS_ACCT_V3=y
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y

#
# RCU Subsystem
#
CONFIG_TREE_RCU=y
# CONFIG_RCU_EXPERT is not set
CONFIG_SRCU=y
# CONFIG_TASKS_RCU is not set
CONFIG_RCU_STALL_COMMON=y
# CONFIG_TREE_RCU_TRACE is not set
# CONFIG_RCU_EXPEDITE_BOOT is not set
CONFIG_BUILD_BIN2C=y
CONFIG_IKCONFIG=m
# CONFIG_IKCONFIG_PROC is not set
CONFIG_LOG_BUF_SHIFT=17
CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y
CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
CONFIG_CGROUP_FREEZER=y
# CONFIG_CGROUP_PIDS is not set
CONFIG_CGROUP_DEVICE=y
CONFIG_CPUSETS=y
CONFIG_PROC_PID_CPUSET=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_PAGE_COUNTER=y
CONFIG_MEMCG=y
CONFIG_MEMCG_SWAP=y
# CONFIG_MEMCG_SWAP_ENABLED is not set
CONFIG_MEMCG_KMEM=y
CONFIG_CGROUP_HUGETLB=y
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_CFS_BANDWIDTH=y
# CONFIG_RT_GROUP_SCHED is not set
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_CGROUP_WRITEBACK=y
CONFIG_CHECKPOINT_RESTORE=y
CONFIG_NAMESPACES=y
CONFIG_UTS_NS=y
CONFIG_IPC_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_NS=y
CONFIG_SCHED_AUTOGROUP=y
# CONFIG_SYSFS_DEPRECATED is not set
CONFIG_RELAY=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
CONFIG_RD_GZIP=y
CONFIG_RD_BZIP2=y
CONFIG_RD_LZMA=y
CONFIG_RD_XZ=y
CONFIG_RD_LZO=y
CONFIG_RD_LZ4=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_SYSCTL=y

[PATCH 00/39] drop null test before destroy functions

2015-09-14 Thread SF Markus Elfring
> Recent commits to kernel/git/torvalds/linux.git have made the following
> functions able to tolerate NULL arguments:
>
> kmem_cache_destroy (commit 3942d29918522)
> mempool_destroy (commit 4e3ca3e033d1)
> dma_pool_destroy (commit 44d7175da6ea)

How do you think about to extend an other SmPL script?

Related topic:
scripts/coccinelle/free: Delete NULL test before freeing functions
https://systeme.lip6.fr/pipermail/cocci/2015-May/001960.html
https://www.mail-archive.com/cocci at systeme.lip6.fr/msg01855.html


> If these changes are OK, I will address the remainder later.

Would anybody like to reuse my general SmPL approach for similar source
code clean-up?

Regards,
Markus


XDC 2015: Updated Schedule, Social Event, Video release form

2015-09-14 Thread Tom Stellard
Hi,

I just wanted to pass along a few XDC updates:

- I have made some changes to the schedule, but it should still be
considered tentative.  I will let announce once it has been finalized.

- There is an informal get together planned for Tuesday night if you
are in town early.  Please sign up on the wiki[1].  If transportation
is an issue, please let me know and we can help organize something.

- The conference talks as well as Q/A sessions of the conference will
be video recorded, so we will be asking attendees to sign a video
release form[2].  Please review the form and let me know if you have
any questions.


-Tom

[1] http://www.x.org/wiki/Events/XDC2015/Social/
[2] http://www.x.org/wiki/Events/XDC2015/XDC2015-Video-Waiver.pdf


[PATCH 1/2] drm/atomic: Make prepare_fb/cleanup_fb only take state, v3.

2015-09-14 Thread Maarten Lankhorst
Op 02-09-15 om 17:24 schreef Daniel Vetter:
> On Wed, Sep 02, 2015 at 03:36:33PM +0100, Daniel Stone wrote:
>> On 2 September 2015 at 09:42, Maarten Lankhorst
>>  wrote:
>>> This removes the need to separately track fb changes i915.
>>> That will be done as a separate commit, however.
>>>
>>> Changes since v1:
>>> - Add dri-devel to cc.
>>> - Fix a check in intel's prepare and cleanup fb to take rotation
>>>   into account.
>>> Changes since v2:
>>> - Split out i915 changes to a separate commit.
>>>
>>> Cc: dri-devel at lists.freedesktop.org
>>> Signed-off-by: Maarten Lankhorst 
>> I'd probably prefer to see the change to call them unconditionally
>> (regardless of fb != NULL) in a separate patch, but with or without:
>> Reviewed-by: Daniel Stone 
> Applied to drm-misc, thanks.
> -Daniel
Daniel Stone, can you review 2/2 too?

~Maarten


[PATCH] drm/mgag200: fix memory leak

2015-09-14 Thread Ingo Molnar

* Sudip Mukherjee  wrote:

> On Sun, Sep 13, 2015 at 11:36:07AM +0200, Ingo Molnar wrote:
> > 
> > * Sudip Mukherjee  wrote:
> > 
> 
> > 
> > There's a new regression: v4.3-rc1 crashes on bootup on non-supported 
> > hardware, if 
> > CONFIG_DRM_MGAG200=y (built into the kernel).
> 
> I am not able to reproduce it with and without my patch applied.
> I have attached my config file. Compiled and booted on my test system
> also tried on qemu. Can you please give your .config file.

Sure - config and full crash.log attached.

NOTE: I booted this on native hardware that _does_ have MGAG200 hardware:

  model name  : Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz

  BIOS Information
  Vendor: Intel Corp.
  Version: SE5C600

  0b:00.0 VGA compatible controller: Matrox Electronics Systems Ltd. MGA G200e 
[Pilot] ServerEngines (SEP1) (rev 05)

So that's likely why you didn't see the crash under Qemu.

Thanks,

Ingo
-- next part --
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86_64 4.3.0-rc1 Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_PERF_EVENTS_INTEL_UNCORE=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_HAVE_LATENCYTOP_SUPPORT=y
CONFIG_MMU=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ARCH_HAS_CPU_RELAX=y
CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
CONFIG_HAVE_SETUP_PER_CPU_AREA=y
CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
CONFIG_ZONE_DMA32=y
CONFIG_AUDIT_ARCH=y
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_X86_64_SMP=y
CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx 
-fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 
-fcall-saved-r11"
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_PGTABLE_LEVELS=4
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
CONFIG_COMPILE_TEST=y
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
# CONFIG_KERNEL_GZIP is not set
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
CONFIG_KERNEL_XZ=y
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
# CONFIG_SWAP is not set
# CONFIG_SYSVIPC is not set
# CONFIG_POSIX_MQUEUE is not set
CONFIG_CROSS_MEMORY_ATTACH=y
CONFIG_FHANDLE=y
# CONFIG_USELIB is not set
CONFIG_AUDIT=y
CONFIG_HAVE_ARCH_AUDITSYSCALL=y
CONFIG_AUDITSYSCALL=y
CONFIG_AUDIT_WATCH=y
CONFIG_AUDIT_TREE=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_GENERIC_PENDING_IRQ=y
CONFIG_GENERIC_IRQ_CHIP=y
CONFIG_IRQ_DOMAIN=y
CONFIG_IRQ_DOMAIN_HIERARCHY=y
CONFIG_GENERIC_MSI_IRQ=y
CONFIG_GENERIC_MSI_IRQ_DOMAIN=y
# CONFIG_IRQ_DOMAIN_DEBUG is not set
CONFIG_IRQ_FORCED_THREADING=y
CONFIG_SPARSE_IRQ=y
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_ARCH_CLOCKSOURCE_DATA=y
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
CONFIG_GENERIC_TIME_VSYSCALL=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y
CONFIG_GENERIC_CMOS_UPDATE=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_HZ_PERIODIC=y
# CONFIG_NO_HZ_IDLE is not set
# CONFIG_NO_HZ_FULL is not set
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y

#
# CPU/Task time and stats accounting
#
CONFIG_TICK_CPU_ACCOUNTING=y
# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
# CONFIG_IRQ_TIME_ACCOUNTING is not set
# CONFIG_BSD_PROCESS_ACCT is not set
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
# CONFIG_TASK_XACCT is not set

#
# RCU Subsystem
#
CONFIG_PREEMPT_RCU=y
# CONFIG_RCU_EXPERT is not set
CONFIG_SRCU=y
CONFIG_TASKS_RCU=y
CONFIG_RCU_STALL_COMMON=y
CONFIG_TREE_RCU_TRACE=y
# CONFIG_RCU_EXPEDITE_BOOT is not set
CONFIG_BUILD_BIN2C=y
CONFIG_IKCONFIG=y
# CONFIG_IKCONFIG_PROC is not set
CONFIG_LOG_BUF_SHIFT=20
CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y
CONFIG_ARCH_SUPPORTS_INT128=y
CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
# CONFIG_CGROUP_FREEZER is not set
CONFIG_CGROUP_PIDS=y
# CONFIG_CGROUP_DEVICE is not set
# CONFIG_CPUSETS is not set
# CONFIG_CGROUP_CPUACCT is not set
CONFIG_PAGE_COUNTER=y
CONFIG_MEMCG=y
CONFIG_MEMCG_KMEM=y
CONFIG_CGROUP_HUGETLB=y
# CONFIG_CGROUP_PERF is not set

free resource

2015-09-14 Thread Alex Vazquez
Hi!
I want to know if when i use  drmModeFreeResources() i need free the
resources crtc, encoder and connector before or it is not necessary.

Regards.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20150914/b8d64e21/attachment.html>


[PATCH 00/22] R-Car DU: Add Gen3 support

2015-09-14 Thread Geert Uytterhoeven
On Mon, Sep 14, 2015 at 9:52 AM, Geert Uytterhoeven
 wrote:
> On Mon, Sep 14, 2015 at 12:50 AM, Laurent Pinchart
>  wrote:
>> This patch series adds support for the Display Unit found in the R-Car Gen3
>> SoC series.
>>
>> The third generation differs significantly from the previous ones in that the
>> DU has lost its ability to source data from memory. It must instead use an
>> external hardware composer named VSP to read planes from memory and blend
>> them.
>>
>> The VSP has a V4L2 driver in mainline that can be used in conjunction with 
>> the
>> DU through the live sources API (submitted previously as an RFC). However, as
>> VSP usage is mandatory in Gen3 and as no native DU planes are available, we
>> have decided that forcing userspace to use both KMS and V4L2 to display any
>> content wouldn't be very friendly. Instead the VSP driver has been extended 
>> to
>> make the device directly controllable by the DU driver ([1]) and this patch
>> series builds on top of it.
>>
>> [1] http://www.spinics.net/lists/linux-media/msg93575.html
>
> Against which tree is this series?
>
> From patch 1, I derived it's against drm-misc
> (git://anongit.freedesktop.org/drm-intel#topic/drm-misc), but later patches
> have other requirements.
> E.g. patch 13 assumes DRM_RCAR_DU has a dependency on OF, but that's nowhere
> to be found in -next.
> It is in git://linuxtv.org/pinchartl/media#vsp1-kms-gen3-20150909.2, but that
> conflicts badly with your R-Car Gen3 VSP series.

Or shall I just use vsp1-kms-gen3-20150913?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 
linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH 00/22] R-Car DU: Add Gen3 support

2015-09-14 Thread Geert Uytterhoeven
Hi Laurent,

On Mon, Sep 14, 2015 at 12:50 AM, Laurent Pinchart
 wrote:
> This patch series adds support for the Display Unit found in the R-Car Gen3
> SoC series.
>
> The third generation differs significantly from the previous ones in that the
> DU has lost its ability to source data from memory. It must instead use an
> external hardware composer named VSP to read planes from memory and blend
> them.
>
> The VSP has a V4L2 driver in mainline that can be used in conjunction with the
> DU through the live sources API (submitted previously as an RFC). However, as
> VSP usage is mandatory in Gen3 and as no native DU planes are available, we
> have decided that forcing userspace to use both KMS and V4L2 to display any
> content wouldn't be very friendly. Instead the VSP driver has been extended to
> make the device directly controllable by the DU driver ([1]) and this patch
> series builds on top of it.
>
> [1] http://www.spinics.net/lists/linux-media/msg93575.html

Against which tree is this series?

>From patch 1, I derived it's against drm-misc
(git://anongit.freedesktop.org/drm-intel#topic/drm-misc), but later patches
have other requirements.
E.g. patch 13 assumes DRM_RCAR_DU has a dependency on OF, but that's nowhere
to be found in -next.
It is in git://linuxtv.org/pinchartl/media#vsp1-kms-gen3-20150909.2, but that
conflicts badly with your R-Car Gen3 VSP series.

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 
linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH 08/22] drm: rcar-du: Restart the DU group when a plane source changes

2015-09-14 Thread Daniel Vetter
On Mon, Sep 14, 2015 at 01:50:55AM +0300, Laurent Pinchart wrote:
> Plane sources are configured by the VSPS bit in the PnDDCR4 register.
> Although the datasheet states that the bit is updated during vertical
> blanking, it seems that updates only occur when the DU group is held in
> reset through the DSYSR.DRES bit. Restart the group if the source
> changes.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.c  |  4 
>  drivers/gpu/drm/rcar-du/rcar_du_group.c |  2 ++
>  drivers/gpu/drm/rcar-du/rcar_du_group.h |  2 ++
>  drivers/gpu/drm/rcar-du/rcar_du_plane.c | 22 --
>  4 files changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> index 48cb19949ca3..7e2f5c26d589 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> @@ -272,6 +272,10 @@ static void rcar_du_crtc_update_planes(struct 
> rcar_du_crtc *rcrtc)
>   rcar_du_group_restart(rcrtc->group);
>   }
>  
> + /* Restart the group if plane sources have changed. */
> + if (rcrtc->group->need_restart)
> + rcar_du_group_restart(rcrtc->group);
> +
>   mutex_unlock(>group->lock);
>  
>   rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR,
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_group.c
> index 4a44ddd51766..0e2b46dce563 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
> @@ -162,6 +162,8 @@ void rcar_du_group_start_stop(struct rcar_du_group *rgrp, 
> bool start)
>  
>  void rcar_du_group_restart(struct rcar_du_group *rgrp)
>  {
> + rgrp->need_restart = false;
> +
>   __rcar_du_group_start_stop(rgrp, false);
>   __rcar_du_group_start_stop(rgrp, true);
>  }
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h 
> b/drivers/gpu/drm/rcar-du/rcar_du_group.h
> index 4b1952fd4e7d..5e3adc6b31b5 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
> @@ -32,6 +32,7 @@ struct rcar_du_device;
>   * @dptsr_planes: bitmask of planes driven by dot-clock and timing generator 
> 1
>   * @num_planes: number of planes in the group
>   * @planes: planes handled by the group
> + * @need_restart: the group needs to be restarted due to a configuration 
> change
>   */
>  struct rcar_du_group {
>   struct rcar_du_device *dev;
> @@ -47,6 +48,7 @@ struct rcar_du_group {
>  
>   unsigned int num_planes;
>   struct rcar_du_plane planes[RCAR_DU_NUM_KMS_PLANES];
> + bool need_restart;

My recommendation is to keep any of these intermediate values in state
objects too. The reason is that eventually we want to also support real
queues of atomic commits, and then anything stored globally (well, outside
of the state objects) won't work. And yes it's ok to push that kind of
stuff into helper, this isn't really any different than e.g.
crtc_state->active_changed and similar booleans indicating that something
special needs to be done when committing.

Cheers, Daniel

>  };
>  
>  u32 rcar_du_group_read(struct rcar_du_group *rgrp, u32 reg);
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> index 78ca353bfcf0..c7e0535c0e77 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> @@ -275,9 +275,27 @@ static void rcar_du_plane_atomic_update(struct drm_plane 
> *plane,
>   struct drm_plane_state *old_state)
>  {
>   struct rcar_du_plane *rplane = to_rcar_plane(plane);
> + struct rcar_du_plane_state *old_rstate;
> + struct rcar_du_plane_state *new_rstate;
>  
> - if (plane->state->crtc)
> - rcar_du_plane_setup(rplane);
> + if (!plane->state->crtc)
> + return;
> +
> + rcar_du_plane_setup(rplane);
> +
> + /* Check whether the source has changed from memory to live source or
> +  * from live source to memory. The source has been configured by the
> +  * VSPS bit in the PnDDCR4 register. Although the datasheet states that
> +  * the bit is updated during vertical blanking, it seems that updates
> +  * only occur when the DU group is held in reset through the DSYSR.DRES
> +  * bit. We thus need to restart the group if the source changes.
> +  */
> + old_rstate = to_rcar_plane_state(old_state);
> + new_rstate = to_rcar_plane_state(plane->state);
> +
> + if ((old_rstate->source == RCAR_DU_PLANE_MEMORY) !=
> + (new_rstate->source == RCAR_DU_PLANE_MEMORY))
> + rplane->group->need_restart = true;
>  }
>  
>  static const struct drm_plane_helper_funcs rcar_du_plane_helper_funcs = {
> -- 
> 2.4.6
> 
> ___
> dri-devel mailing list
> dri-devel at 

[PATCH RFCv2 3/4] staging: etnaviv: add drm driver

2015-09-14 Thread Rob Clark
On Fri, Sep 11, 2015 at 10:10 AM, Lucas Stach  wrote:
> From: Christian Gmeiner 
>
> This is a squashed commit of the complete etnaviv DRM driver in order
> to make it easy for people to review the code by seeing the driver as a
> whole and is not intended for merging in this form.
>
> If you are interested in the history of individual commits:
> git://git.pengutronix.de/git/lst/linux.git etnaviv-for-upstream
>
> Signed-off-by: Christian Gmeiner 
> Signed-off-by: Russell King 
> Signed-off-by: Lucas Stach 
> ---
>  drivers/staging/Kconfig  |2 +
>  drivers/staging/Makefile |1 +
>  drivers/staging/etnaviv/Kconfig  |   20 +
>  drivers/staging/etnaviv/Makefile |   18 +
>  drivers/staging/etnaviv/cmdstream.xml.h  |  218 
>  drivers/staging/etnaviv/common.xml.h |  249 +
>  drivers/staging/etnaviv/etnaviv_buffer.c |  271 +
>  drivers/staging/etnaviv/etnaviv_cmd_parser.c |  119 +++
>  drivers/staging/etnaviv/etnaviv_drv.c|  705 +
>  drivers/staging/etnaviv/etnaviv_drv.h|  138 +++
>  drivers/staging/etnaviv/etnaviv_gem.c|  887 
>  drivers/staging/etnaviv/etnaviv_gem.h|  141 +++
>  drivers/staging/etnaviv/etnaviv_gem_prime.c  |  121 +++
>  drivers/staging/etnaviv/etnaviv_gem_submit.c |  421 
>  drivers/staging/etnaviv/etnaviv_gpu.c| 1468 
> ++
>  drivers/staging/etnaviv/etnaviv_gpu.h|  198 
>  drivers/staging/etnaviv/etnaviv_iommu.c  |  221 
>  drivers/staging/etnaviv/etnaviv_iommu.h  |   28 +
>  drivers/staging/etnaviv/etnaviv_iommu_v2.c   |   33 +
>  drivers/staging/etnaviv/etnaviv_iommu_v2.h   |   25 +
>  drivers/staging/etnaviv/etnaviv_mmu.c|  282 +
>  drivers/staging/etnaviv/etnaviv_mmu.h|   58 +
>  drivers/staging/etnaviv/state.xml.h  |  351 ++
>  drivers/staging/etnaviv/state_hi.xml.h   |  407 +++
>  include/uapi/drm/etnaviv_drm.h   |  215 
>  25 files changed, 6597 insertions(+)
>  create mode 100644 drivers/staging/etnaviv/Kconfig
>  create mode 100644 drivers/staging/etnaviv/Makefile
>  create mode 100644 drivers/staging/etnaviv/cmdstream.xml.h
>  create mode 100644 drivers/staging/etnaviv/common.xml.h
>  create mode 100644 drivers/staging/etnaviv/etnaviv_buffer.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_cmd_parser.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_drv.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_drv.h
>  create mode 100644 drivers/staging/etnaviv/etnaviv_gem.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_gem.h
>  create mode 100644 drivers/staging/etnaviv/etnaviv_gem_prime.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_gem_submit.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_gpu.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_gpu.h
>  create mode 100644 drivers/staging/etnaviv/etnaviv_iommu.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_iommu.h
>  create mode 100644 drivers/staging/etnaviv/etnaviv_iommu_v2.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_iommu_v2.h
>  create mode 100644 drivers/staging/etnaviv/etnaviv_mmu.c
>  create mode 100644 drivers/staging/etnaviv/etnaviv_mmu.h
>  create mode 100644 drivers/staging/etnaviv/state.xml.h
>  create mode 100644 drivers/staging/etnaviv/state_hi.xml.h
>  create mode 100644 include/uapi/drm/etnaviv_drm.h
>
> diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
> index 7f6cae5beb90..5446fe4859ce 100644
> --- a/drivers/staging/Kconfig
> +++ b/drivers/staging/Kconfig
> @@ -112,4 +112,6 @@ source "drivers/staging/fsl-mc/Kconfig"
>
>  source "drivers/staging/wilc1000/Kconfig"
>
> +source "drivers/staging/etnaviv/Kconfig"
> +
>  endif # STAGING
> diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
> index 347f6477aa3e..9fd3c06b6bfd 100644
> --- a/drivers/staging/Makefile
> +++ b/drivers/staging/Makefile
> @@ -48,3 +48,4 @@ obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/
>  obj-$(CONFIG_FB_TFT)   += fbtft/
>  obj-$(CONFIG_FSL_MC_BUS)   += fsl-mc/
>  obj-$(CONFIG_WILC1000) += wilc1000/
> +obj-$(CONFIG_DRM_ETNAVIV)  += etnaviv/
> diff --git a/drivers/staging/etnaviv/Kconfig b/drivers/staging/etnaviv/Kconfig
> new file mode 100644
> index ..6f034eda914c
> --- /dev/null
> +++ b/drivers/staging/etnaviv/Kconfig
> @@ -0,0 +1,20 @@
> +
> +config DRM_ETNAVIV
> +   tristate "etnaviv DRM"
> +   depends on DRM
> +   select SHMEM
> +   select TMPFS
> +   select IOMMU_API
> +   select IOMMU_SUPPORT
> +   default y
> +   help
> + DRM driver for Vivante GPUs.
> +
> +config DRM_ETNAVIV_REGISTER_LOGGING
> +   bool "etnaviv DRM register logging"
> +   depends on DRM_ETNAVIV
> +   default n
> +   help
> + Compile in support for logging register 

free resource

2015-09-14 Thread Rob Clark
On Mon, Sep 14, 2015 at 4:44 AM, Alex Vazquez  wrote:
> Hi!
> I want to know if when i use  drmModeFreeResources() i need free the
> resources crtc, encoder and connector before or it is not necessary.

drmModeFreeResources() only frees the drmModeResPtr object (including
it's arrays of connector-id's, etc).. you would independently need to
match calls to drmModeGet{Crtc,Connector,etc}() to
drmModeFree{Crtc,Connector,etc}()

BR,
-R

> Regards.
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>


[PATCH 0/6] scripts/kernel-doc: Kernel-doc improvements

2015-09-14 Thread Danilo Cesar Lemes de Paula
On 09/13/2015 05:58 PM, Daniel Vetter wrote:
> On Sun, Sep 13, 2015 at 9:13 PM, Jonathan Corbet  wrote:
>> On Sun, 13 Sep 2015 12:36:07 +0200
>> Daniel Vetter  wrote:
>>
>>> Personally I don't care which kind of text markup we pick and wich
>>> converter, as long as the project looks reasonable far away from
>>> immeninent death (way too many one-person projects on github in this
>>> area).

I wouldn't care either. I choose pandoc as it's old, kind of stable and
has a decent community around it, so it won't probably die due the lack
of interested developers.

That said, cmark is not a option (at least for now). With the current
approach we need a tool capable of reading markdown text and output
DocBook tags, as we're actually still using docbook to spit all kinds of
Documentation formats (html, man, pdf). Looks like cmark can only do
markdown->html.

I did look into other options though, but they were all mostly one-man
job. But yeah, basically any tool capable of converting
markdown->docbook will work. I'm always listening to suggestions =)


>>>
>>> But if we have this discussion I'd like to decouple it from the other
>>> kerneldoc improvemnts in this series (patches 1, 5 and 6). If we cant
>>> agree on the text markup then drm docs will simply look a bit funny for
>>> everyone else. But if the inline struct stuff won't happen 0-day will
>>> scream around (and there's already patches which use the new layout).
>>
>> Those patches are:
>>
>> 1)  scripts/kernel-doc: Replacing highlights hash by an array
>> 5)  scripts/kernel-doc: Improve Markdown results
>> 6)  scripts/kernel-doc: Processing -nofunc for functions only
>>
>> #1 is fine, I'll merge that today.  #6 is already merged.  #5 is a markdown
>> patch, though, and doesn't make sense without the others?  Are you thinking
>> about #3 (drm/doc: Convert to markdown)?  That one would almost work (it
>> depends on #2 currently) and it nicely shows *why* I'd like to get away from
>> XML...

#5 is the DRM markdown conversion, which depends on #2 and #4. So if a
decision about this is going during KS, we need to hold those three patches.

> 
> Sorry I mixed things up, #5 is ok to leave out. I thought about
> "scripts/kernel-doc Allow struct arguments documentation in struct
> body" but you already merged that one for 4.2. Which I missed, but
> which is great since that's the one that would cause the big
> conflicts.
> 
 2 We're constructing an increasingly complicated document-processing
   mechanism with a lot of independently moving parts.  What if we
   converted the whole document to markdown and dispensed with the XML
   part altogether?  Making the source files simpler and dispensing with
   the xmlto requirement would be a big win, IMO.
>>>
>>> Who's going to convert the almost 30kloc of xml template (which often have
>>> large amounts of texts) and the over 60k kerneldoc comments that we have
>>> already?
>>
>> I thought you'd do that :)
>>
>> Seriously, though, a change would be a big job.  There's a reason I've said
>> several times that it would make no sense to delay the work at hand in the
>> hopes of somebody doing this whole job instead.  But we can certainly
>> ponder what might be better.
>>
>> Getting rid of the XML stuff may well simplify the whole process and make
>> the documentation much more accessible for those who would change it; that
>> could be a goal worth going for.  Oh, and anything requiring changes to the
>> kerneldoc comments is going nowhere, that was never something I'd
>> contemplated.  Those comments are fine.
> 
> Well my goal is to be able to have all the programmer docs in the
> code, including any high-level overview sections to tie everything
> together (hence hyperlinks and better formatting). But then you still
> need some skeleton to make a coherent whole out of all the parts, and
> I think the docbook xml templates we have serve rather fine for that
> role. Writing text in xml is indeed horrid, but if we can create
> in-line DOC: sections with decent formatting there's really no need
> for that. From that angle this work here already has the goal to get
> rid of the xml - I plane to move all the existing text in the drm.tmpl
> xml into inline DOC: kerneldoc commets.
> 
> And at least gtkdoc (which we use extensively for the userpace
> test/tools repo) relies on some xml thing to tie different topics
> together too. So that seems pretty standard.
> 
>> But any such change needs a lot of thought and a reasonable proof of
>> concept.  Meanwhile we have work that can make the docs better now, and I
>> want to merge it.  But we should choose the tools we use carefully, and I
>> anticipate a lot of opposition to one that has to drag in 70 Haskell
>> packages with it.
> 
> Well personally I don't care about the exact tooling, as long as:
> - it's a reasonable alive project
> - packages available on distros (works for me on both debian and fedora)
> - we can muck around with how things are integrated 

[Bug 91982] [radeonsi] fs leak in get_radeon_bo()

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91982

iive  changed:

   What|Removed |Added

 CC||ikalvachev at gmail.com

--- Comment #5 from iive  ---
Created attachment 118258
  --> https://bugs.freedesktop.org/attachment.cgi?id=118258=edit
Valgrind trace of memory leaks in Mesa3D when compiling same shader over and
over. R600 Redwood variant.

You need to run valgrind with `--trace-children` to check something else than
apitrace itself. :)

I'm attaching log created with the following command:

`valgrind  --log-file=mesa.memleak.r600.valgrind.txt --trace-children=yes 
--leak-check=full --undef-value-errors=no --partial-loads-ok=yes
--freelist-vol=2 apitrace replay --loop -b bl2469.trace`

I didn't let it die from memory exhaustion, I pressed ESC and exited normally,
so the leaks in this log are definitely lost.

-- 
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/20150914/57544491/attachment.html>


[Bug 91998] Object rendered completely black in The Book of Unwritten Tales: The Critter Chronicles

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91998

--- Comment #3 from Ilia Mirkin  ---
Interesting, the pipe is all-white on nvc0. I checked if this was an instance
of https://bugs.winehq.org/show_bug.cgi?id=38869, but that doesn't seem to be
the case.

-- 
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/20150914/56cd7ebc/attachment.html>


[Bug 91998] Object rendered completely black in The Book of Unwritten Tales: The Critter Chronicles

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91998

--- Comment #2 from Daniel Scharrer  ---
Created attachment 118257
  --> https://bugs.freedesktop.org/attachment.cgi?id=118257=edit
correct rendering with LIBGL_ALWAYS_SOFTWARE=1

-- 
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/20150914/2ad46bf2/attachment.html>


[Bug 91998] Object rendered completely black in The Book of Unwritten Tales: The Critter Chronicles

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91998

--- Comment #1 from Daniel Scharrer  ---
Created attachment 118256
  --> https://bugs.freedesktop.org/attachment.cgi?id=118256=edit
incorrect rendering with radeonsi

-- 
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/20150914/df645afb/attachment.html>


[Bug 91998] Object rendered completely black in The Book of Unwritten Tales: The Critter Chronicles

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91998

Bug ID: 91998
   Summary: Object rendered completely black in The Book of
Unwritten Tales: The Critter Chronicles
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: minor
  Priority: medium
 Component: Drivers/Gallium/radeonsi
  Assignee: dri-devel at lists.freedesktop.org
  Reporter: daniel at constexpr.org
QA Contact: dri-devel at lists.freedesktop.org

apitrace: http://constexpr.org/tmp/BOUT-CC-radeonsi.1.trace.xz (95 MiB)

The pipe behind the character is rendered completely black. The object is
rendered without any shader but with fixed-function lighting enabled.

Relevant draw call: 2336877 (in frame 1699)

Disabling GL_LIGHTING, GL_LIGHT3 or setting the GL_DIFFUSE material to [0, 0,
0, 0] (including alpha) causes the pipe to be rendered correctly. Disabling the
other lights has no effect.

The GL_EMISSION material is set to [1, 1, 1, 1] for this draw call so the other
lighting parameters should have no effect (unless they result in NaNs or
negative values).

GPU; Radeon HD 7950 (TAHITI)
Mesa 11.1.0-devel (git-0337a9b)
LLVM r247497
Linux 4.2.0-gentoo-r1

Everything is rendered correctly with llvmpipe.

So far I have only found one object in the game affected by this.

-- 
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/20150914/b4dc1f76/attachment.html>


[Bug 91982] [radeonsi] fs leak in get_radeon_bo()

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91982

--- Comment #4 from Shawn Starr  ---
Created attachment 118252
  --> https://bugs.freedesktop.org/attachment.cgi?id=118252=edit
More detailed valgrind trace

-- 
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/20150914/f37023d2/attachment.html>


[PATCH 22/22] drm: rcar-du: lvds: Add R-Car Gen3 support

2015-09-14 Thread Laurent Pinchart
From: Koji Matsuoka 

The LVDS encoder differs slightly in Gen3 SoCs in its PLL configuration.
Add support for the Gen3 LVDS PLL parameters and startup procedure.

Signed-off-by: Koji Matsuoka 
Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/Kconfig   |   4 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |  10 ++-
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 133 ++
 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h  |  24 --
 4 files changed, 123 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index 6c3e49e9e290..971ab014eee5 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -21,10 +21,8 @@ config DRM_RCAR_HDMI
 config DRM_RCAR_LVDS
bool "R-Car DU LVDS Encoder Support"
depends on DRM_RCAR_DU
-   depends on ARCH_R8A7790 || ARCH_R8A7791 || COMPILE_TEST
help
- Enable support for the R-Car Display Unit embedded LVDS encoders
- (currently only on R8A7790 and R8A7791).
+ Enable support for the R-Car Display Unit embedded LVDS encoders.

 config DRM_RCAR_VSP
bool "R-Car DU VSP Compositor Support"
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 4909db60971a..87eedb7fee28 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -140,15 +140,21 @@ static const struct rcar_du_device_info 
rcar_du_r8a7795_info = {
  | RCAR_DU_FEATURE_VSP1_SOURCE,
.num_crtcs = 4,
.routes = {
-   /* R8A7795 has one RGB output, and two HDMI and one LVDS
-* (currently unsupported) outputs
+   /* R8A7795 has one RGB output, one LVDS output and two
+* (currently unsupported) HDMI outputs.
 */
[RCAR_DU_OUTPUT_DPAD0] = {
.possible_crtcs = BIT(3),
.encoder_type = DRM_MODE_ENCODER_NONE,
.port = 0,
},
+   [RCAR_DU_OUTPUT_LVDS0] = {
+   .possible_crtcs = BIT(0),
+   .encoder_type = DRM_MODE_ENCODER_LVDS,
+   .port = 3,
+   },
},
+   .num_lvds = 1,
 };

 static const struct of_device_id rcar_du_of_table[] = {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
index 02acebadf7d6..ef3a50321ecc 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
@@ -38,22 +38,13 @@ static void rcar_lvds_write(struct rcar_du_lvdsenc *lvds, 
u32 reg, u32 data)
iowrite32(data, lvds->mmio + reg);
 }

-static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds,
-struct rcar_du_crtc *rcrtc)
+static void rcar_du_lvdsenc_start_gen2(struct rcar_du_lvdsenc *lvds,
+  struct rcar_du_crtc *rcrtc)
 {
const struct drm_display_mode *mode = >crtc.mode;
unsigned int freq = mode->clock;
u32 lvdcr0;
-   u32 lvdhcr;
u32 pllcr;
-   int ret;
-
-   if (lvds->enabled)
-   return 0;
-
-   ret = clk_prepare_enable(lvds->clock);
-   if (ret < 0)
-   return ret;

/* PLL clock configuration */
if (freq < 39000)
@@ -67,26 +58,6 @@ static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc 
*lvds,

rcar_lvds_write(lvds, LVDPLLCR, pllcr);

-   /* Hardcode the channels and control signals routing for now.
-*
-* HSYNC -> CTRL0
-* VSYNC -> CTRL1
-* DISP  -> CTRL2
-* 0 -> CTRL3
-*/
-   rcar_lvds_write(lvds, LVDCTRCR, LVDCTRCR_CTR3SEL_ZERO |
-   LVDCTRCR_CTR2SEL_DISP | LVDCTRCR_CTR1SEL_VSYNC |
-   LVDCTRCR_CTR0SEL_HSYNC);
-
-   if (rcar_du_needs(lvds->dev, RCAR_DU_QUIRK_LVDS_LANES))
-   lvdhcr = LVDCHCR_CHSEL_CH(0, 0) | LVDCHCR_CHSEL_CH(1, 3)
-  | LVDCHCR_CHSEL_CH(2, 2) | LVDCHCR_CHSEL_CH(3, 1);
-   else
-   lvdhcr = LVDCHCR_CHSEL_CH(0, 0) | LVDCHCR_CHSEL_CH(1, 1)
-  | LVDCHCR_CHSEL_CH(2, 2) | LVDCHCR_CHSEL_CH(3, 3);
-
-   rcar_lvds_write(lvds, LVDCHCR, lvdhcr);
-
/* Select the input, hardcode mode 0, enable LVDS operation and turn
 * bias circuitry on.
 */
@@ -96,8 +67,10 @@ static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc 
*lvds,
rcar_lvds_write(lvds, LVDCR0, lvdcr0);

/* Turn all the channels on. */
-   rcar_lvds_write(lvds, LVDCR1, LVDCR1_CHSTBY(3) | LVDCR1_CHSTBY(2) |
-   LVDCR1_CHSTBY(1) | LVDCR1_CHSTBY(0) | LVDCR1_CLKSTBY);
+   rcar_lvds_write(lvds, LVDCR1,
+   LVDCR1_CHSTBY_GEN2(3) | 

[PATCH 21/22] drm: rcar-du: lvds: Rename PLLEN bit to PLLON

2015-09-14 Thread Laurent Pinchart
The bit is named PLLON in the datasheet, rename it.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 2 +-
 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
index e044a17a2a2f..02acebadf7d6 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
@@ -102,7 +102,7 @@ static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc 
*lvds,
/* Turn the PLL on, wait for the startup delay, and turn the output
 * on.
 */
-   lvdcr0 |= LVDCR0_PLLEN;
+   lvdcr0 |= LVDCR0_PLLON;
rcar_lvds_write(lvds, LVDCR0, lvdcr0);

usleep_range(100, 150);
diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h 
b/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h
index 77cf9289ab65..b1eafd097a79 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds_regs.h
@@ -18,7 +18,7 @@
 #define LVDCR0_DMD (1 << 12)
 #define LVDCR0_LVMD_MASK   (0xf << 8)
 #define LVDCR0_LVMD_SHIFT  8
-#define LVDCR0_PLLEN   (1 << 4)
+#define LVDCR0_PLLON   (1 << 4)
 #define LVDCR0_BEN (1 << 2)
 #define LVDCR0_LVEN(1 << 1)
 #define LVDCR0_LVRES   (1 << 0)
-- 
2.4.6



[PATCH 20/22] drm: rcar-du: lvds: Fix PLL frequency-related configuration

2015-09-14 Thread Laurent Pinchart
The frequency checks don't match the datasheet, fix them.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
index 937b2da98814..e044a17a2a2f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
@@ -56,11 +56,11 @@ static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc 
*lvds,
return ret;

/* PLL clock configuration */
-   if (freq <= 38000)
+   if (freq < 39000)
pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_38M;
-   else if (freq <= 6)
+   else if (freq < 61000)
pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_60M;
-   else if (freq <= 121000)
+   else if (freq < 121000)
pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | 
LVDPLLCR_PLLDLYCNT_121M;
else
pllcr = LVDPLLCR_PLLDLYCNT_150M;
-- 
2.4.6



[PATCH 19/22] drm: rcar-du: lvds: Avoid duplication of clock clamp code

2015-09-14 Thread Laurent Pinchart
Replace the duplicate code by a single central function.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 6 +-
 drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c | 7 ++-
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 9 +
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h | 6 ++
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c 
b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
index d0ae1e8009c6..b7d64336fb3b 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -89,12 +89,8 @@ static int rcar_du_encoder_atomic_check(struct drm_encoder 
*encoder,
/* The flat panel mode is fixed, just copy it to the adjusted mode. */
drm_mode_copy(adjusted_mode, panel_mode);

-   /* The internal LVDS encoder has a clock frequency operating range of
-* 30MHz to 150MHz. Clamp the clock accordingly.
-*/
if (renc->lvds)
-   adjusted_mode->clock = clamp(adjusted_mode->clock,
-3, 15);
+   rcar_du_lvdsenc_atomic_check(renc->lvds, adjusted_mode);

return 0;
 }
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
index 81da8419282b..c45b626c7d66 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
@@ -71,12 +71,9 @@ static int rcar_du_hdmienc_atomic_check(struct drm_encoder 
*encoder,
struct drm_display_mode *adjusted_mode = _state->adjusted_mode;
const struct drm_display_mode *mode = _state->mode;

-   /* The internal LVDS encoder has a clock frequency operating range of
-* 30MHz to 150MHz. Clamp the clock accordingly.
-*/
if (hdmienc->renc->lvds)
-   adjusted_mode->clock = clamp(adjusted_mode->clock,
-3, 15);
+   rcar_du_lvdsenc_atomic_check(hdmienc->renc->lvds,
+adjusted_mode);

if (sfuncs->mode_fixup == NULL)
return 0;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
index 85043c5bad03..937b2da98814 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
@@ -140,6 +140,15 @@ int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds, 
struct drm_crtc *crtc,
return -EINVAL;
 }

+void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
+ struct drm_display_mode *mode)
+{
+   /* The internal LVDS encoder has a clock frequency operating range of
+* 30MHz to 150MHz. Clamp the clock accordingly.
+*/
+   mode->clock = clamp(mode->clock, 3, 15);
+}
+
 static int rcar_du_lvdsenc_get_resources(struct rcar_du_lvdsenc *lvds,
 struct platform_device *pdev)
 {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h 
b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
index 9a6001c07303..dfdba746edf4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
@@ -30,6 +30,8 @@ enum rcar_lvds_input {
 int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu);
 int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds,
   struct drm_crtc *crtc, bool enable);
+void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
+ struct drm_display_mode *mode);
 #else
 static inline int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu)
 {
@@ -40,6 +42,10 @@ static inline int rcar_du_lvdsenc_enable(struct 
rcar_du_lvdsenc *lvds,
 {
return 0;
 }
+static inline void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
+   struct drm_display_mode *mode)
+{
+}
 #endif

 #endif /* __RCAR_DU_LVDSENC_H__ */
-- 
2.4.6



[PATCH 18/22] drm: rcar-du: Add R8A7795 device support

2015-09-14 Thread Laurent Pinchart
Document the R8A7795-specific DT bindings and support them in the
driver. The HDMI and LVDS outputs are currently not supported.

Cc: devicetree at vger.kernel.org
Signed-off-by: Koji Matsuoka 
Signed-off-by: Laurent Pinchart 
---
 .../devicetree/bindings/video/renesas,du.txt   | 16 ---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 11 +++--
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  | 25 ++-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h  |  4 +-
 drivers/gpu/drm/rcar-du/rcar_du_group.c| 50 --
 drivers/gpu/drm/rcar-du/rcar_du_kms.c  | 11 +++--
 drivers/gpu/drm/rcar-du/rcar_du_plane.c| 49 -
 drivers/gpu/drm/rcar-du/rcar_du_regs.h | 17 +++-
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  | 12 --
 9 files changed, 149 insertions(+), 46 deletions(-)

diff --git a/Documentation/devicetree/bindings/video/renesas,du.txt 
b/Documentation/devicetree/bindings/video/renesas,du.txt
index eccd4f4867b2..0d30e42e40be 100644
--- a/Documentation/devicetree/bindings/video/renesas,du.txt
+++ b/Documentation/devicetree/bindings/video/renesas,du.txt
@@ -8,6 +8,7 @@ Required Properties:
 - "renesas,du-r8a7791" for R8A7791 (R-Car M2-W) compatible DU
 - "renesas,du-r8a7793" for R8A7793 (R-Car M2-N) compatible DU
 - "renesas,du-r8a7794" for R8A7794 (R-Car E2) compatible DU
+- "renesas,du-r8a7795" for R8A7795 (R-Car H3) compatible DU

   - reg: A list of base address and length of each memory resource, one for
 each entry in the reg-names property.
@@ -24,7 +25,7 @@ Required Properties:
   - clock-names: Name of the clocks. This property is model-dependent.
 - R8A7779 uses a single functional clock. The clock doesn't need to be
   named.
-- R8A779[0134] use one functional clock per channel and one clock per LVDS
+- R8A779[01345] use one functional clock per channel and one clock per LVDS
   encoder (if available). The functional clocks must be named "du.x" with
   "x" being the channel numerical index. The LVDS clocks must be named
   "lvds.x" with "x" being the LVDS encoder numerical index.
@@ -41,13 +42,14 @@ bindings specified in 
Documentation/devicetree/bindings/graph.txt.
 The following table lists for each supported model the port number
 corresponding to each DU output.

-   Port 0  Port1   Port2
+   Port 0  Port1   Port2   Port3
 -
- R8A7779 (H1)  DPAD 0  DPAD 1  -
- R8A7790 (H2)  DPADLVDS 0  LVDS 1
- R8A7791 (M2-W)DPADLVDS 0  -
- R8A7793 (M2-N)DPADLVDS 0  -
- R8A7794 (E2)  DPAD 0  DPAD 1  -
+ R8A7779 (H1)  DPAD 0  DPAD 1  -   -
+ R8A7790 (H2)  DPADLVDS 0  LVDS 1  -
+ R8A7791 (M2-W)DPADLVDS 0  -   -
+ R8A7793 (M2-N)DPADLVDS 0  -   -
+ R8A7794 (E2)  DPAD 0  DPAD 1  -   -
+ R8A7795 (H3)  DPADHDMI 0  HDMI 1  LVDS


 Example: R8A7790 (R-Car H2) DU
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 15bf57de106b..ed71d1dc0790 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -1,7 +1,7 @@
 /*
  * rcar_du_crtc.c  --  R-Car Display Unit CRTCs
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart at ideasonboard.com)
  *
@@ -254,8 +254,13 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc 
*rcrtc)

/* If VSP+DU integration is enabled the plane assignment is fixed. */
if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
-   dspr = (rcrtc->index % 2) + 1;
-   hwplanes = 1 << (rcrtc->index % 2);
+   if (rcdu->info->gen < 3) {
+   dspr = (rcrtc->index % 2) + 1;
+   hwplanes = 1 << (rcrtc->index % 2);
+   } else {
+   dspr = (rcrtc->index % 2) ? 3 : 1;
+   hwplanes = 1 << ((rcrtc->index % 2) ? 2 : 0);
+   }
}

/* Update the planes to display timing and dot clock generator
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 326d040515e4..4909db60971a 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -1,7 +1,7 @@
 /*
  * rcar_du_drv.c  --  R-Car Display Unit DRM driver
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
 

[PATCH 17/22] drm: rcar-du: Output the DISP signal on the ODDF pin

2015-09-14 Thread Laurent Pinchart
The ODDF signal, output by default on the ODDF pin, isn't used on any
board supported in the kernel. As the Gen3 Salvator-X board uses the
ODDF pin as a DISP signal, hardcode that configuration in the driver.

Use of the ODDF signal will be implemented later through proper DT-based
configuration of the DU pins.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_group.c | 12 
 drivers/gpu/drm/rcar-du/rcar_du_regs.h  |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 0e2b46dce563..144d1e0a7a4a 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -44,6 +44,16 @@ void rcar_du_group_write(struct rcar_du_group *rgrp, u32 
reg, u32 data)
rcar_du_write(rgrp->dev, rgrp->mmio_offset + reg, data);
 }

+static void rcar_du_group_setup_pins(struct rcar_du_group *rgrp)
+{
+   u32 defr6 = DEFR6_CODE | DEFR6_ODPM12_DISP;
+
+   if (rgrp->num_crtcs > 1)
+   defr6 |= DEFR6_ODPM22_DISP;
+
+   rcar_du_group_write(rgrp, DEFR6, defr6);
+}
+
 static void rcar_du_group_setup_defr8(struct rcar_du_group *rgrp)
 {
u32 defr8 = DEFR8_CODE | DEFR8_DEFE8;
@@ -71,6 +81,8 @@ static void rcar_du_group_setup(struct rcar_du_group *rgrp)
rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE);
rcar_du_group_write(rgrp, DEFR5, DEFR5_CODE | DEFR5_DEFE5);

+   rcar_du_group_setup_pins(rgrp);
+
if (rcar_du_has(rgrp->dev, RCAR_DU_FEATURE_EXT_CTRL_REGS)) {
rcar_du_group_setup_defr8(rgrp);

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h 
b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
index 95add71a33c8..2ccb1a241fc4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
@@ -187,7 +187,7 @@

 #define DEFR6  0x000e8
 #define DEFR6_CODE (0x7778 << 16)
-#define DEFR6_ODPM22_D2SMR (0 << 10)
+#define DEFR6_ODPM22_DSMR  (0 << 10)
 #define DEFR6_ODPM22_DISP  (2 << 10)
 #define DEFR6_ODPM22_CDE   (3 << 10)
 #define DEFR6_ODPM22_MASK  (3 << 10)
-- 
2.4.6



[PATCH 16/22] drm: rcar-du: Output the DISP signal on the DISP pin

2015-09-14 Thread Laurent Pinchart
The DE signal is currently configured to be identical to the DISP
signal and is used for the same purpose. To make it clearer that the
DISP pin outputs the DISP signal, select it explicitly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 9f0d94b3ec10..15bf57de106b 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -151,7 +151,7 @@ static void rcar_du_crtc_set_display_timing(struct 
rcar_du_crtc *rcrtc)
/* Signal polarities */
value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL)
  | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? 0 : DSMR_HSL)
- | DSMR_DIPM_DE | DSMR_CSPM;
+ | DSMR_DIPM_DISP | DSMR_CSPM;
rcar_du_crtc_write(rcrtc, DSMR, value);

/* Display timings */
-- 
2.4.6



[PATCH 15/22] drm: rcar-du: Support up to 4 CRTCs

2015-09-14 Thread Laurent Pinchart
From: Koji Matsuoka 

The Gen3 R8A7795 DU has 4 CRTCs, support them all.

Signed-off-by: Koji Matsuoka 
Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h  | 2 +-
 drivers/gpu/drm/rcar-du/rcar_du_regs.h | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index b63bdd12609e..9f0d94b3ec10 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -600,7 +600,7 @@ static irqreturn_t rcar_du_crtc_irq(int irq, void *arg)
 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index)
 {
static const unsigned int mmio_offsets[] = {
-   DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET
+   DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET, DU3_REG_OFFSET
};

struct rcar_du_device *rcdu = rgrp->dev;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index a81eb3281e7f..ce359edc9ab9 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -67,7 +67,7 @@ struct rcar_du_device_info {
unsigned int num_lvds;
 };

-#define RCAR_DU_MAX_CRTCS  3
+#define RCAR_DU_MAX_CRTCS  4
 #define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
 #define RCAR_DU_MAX_LVDS   2
 #define RCAR_DU_MAX_VSPS   4
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h 
b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
index ac9c3e511e79..95add71a33c8 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h
@@ -16,6 +16,7 @@
 #define DU0_REG_OFFSET 0x0
 #define DU1_REG_OFFSET 0x3
 #define DU2_REG_OFFSET 0x4
+#define DU3_REG_OFFSET 0x7

 /* 
-
  * Display Control Registers
-- 
2.4.6



[PATCH 14/22] drm: rcar-du: Drop LVDS double dependency on OF

2015-09-14 Thread Laurent Pinchart
LVDS support depends on DRM_RCAR_DU which already depends on OF. Drop
the explicit dependency.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index 7c465ee7aec3..6c3e49e9e290 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -15,7 +15,6 @@ config DRM_RCAR_DU
 config DRM_RCAR_HDMI
bool "R-Car DU HDMI Encoder Support"
depends on DRM_RCAR_DU
-   depends on OF
help
  Enable support for external HDMI encoders.

-- 
2.4.6



[PATCH 13/22] drm: rcar-du: Enable compilation on ARM64

2015-09-14 Thread Laurent Pinchart
From: Koji Matsuoka 

The R8A7795 SoC is ARM64-based and include a DU. Enable driver
compilation on ARM64.

Signed-off-by: Koji Matsuoka 
Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index 62650abc3120..7c465ee7aec3 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -1,6 +1,7 @@
 config DRM_RCAR_DU
tristate "DRM Support for R-Car Display Unit"
-   depends on DRM && ARM && HAVE_DMA_ATTRS && OF
+   depends on DRM && HAVE_DMA_ATTRS && OF
+   depends on ARM || ARM64
depends on ARCH_SHMOBILE || COMPILE_TEST
select DRM_KMS_HELPER
select DRM_KMS_CMA_HELPER
-- 
2.4.6



[PATCH 12/22] drm: rcar-du: Fix compile warning on 64-bit platforms

2015-09-14 Thread Laurent Pinchart
From: Koji Matsuoka 

Use %tu instead of %u to print difference between pointers.

Signed-off-by: Koji Matsuoka 
Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index 4a38ced4b952..7d2e301df042 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -153,7 +153,7 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
plane = to_rcar_plane(state->planes[i]);
plane_state = to_rcar_plane_state(state->plane_states[i]);

-   dev_dbg(rcdu->dev, "%s: checking plane (%u,%u)\n", __func__,
+   dev_dbg(rcdu->dev, "%s: checking plane (%u,%tu)\n", __func__,
plane->group->index, plane - plane->group->planes);

/* If the plane is being disabled we don't need to go through
@@ -221,7 +221,7 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
 */
if (group_freed_planes[index] & (1 << i)) {
dev_dbg(rcdu->dev,
-   "%s: plane (%u,%u) has been freed, 
skipping\n",
+   "%s: plane (%u,%tu) has been freed, 
skipping\n",
__func__, plane->group->index,
plane - plane->group->planes);
continue;
@@ -231,7 +231,7 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
used_planes |= rcar_du_plane_hwmask(plane_state);

dev_dbg(rcdu->dev,
-   "%s: plane (%u,%u) uses %u hwplanes (index 
%d)\n",
+   "%s: plane (%u,%tu) uses %u hwplanes (index 
%d)\n",
__func__, plane->group->index,
plane - plane->group->planes,
plane_state->format ?
@@ -260,7 +260,7 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
plane = to_rcar_plane(state->planes[i]);
plane_state = to_rcar_plane_state(state->plane_states[i]);

-   dev_dbg(rcdu->dev, "%s: allocating plane (%u,%u)\n", __func__,
+   dev_dbg(rcdu->dev, "%s: allocating plane (%u,%tu)\n", __func__,
plane->group->index, plane - plane->group->planes);

/* Skip planes that are being disabled or don't need to be
-- 
2.4.6



[PATCH 11/22] drm: rcar-du: Use the VSP atomic update API

2015-09-14 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  6 ++
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  | 18 ++
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h  |  4 
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 196b940ea8d7..b63bdd12609e 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -538,6 +538,9 @@ static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
rcrtc->event = event;
spin_unlock_irqrestore(>event_lock, flags);
}
+
+   if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+   rcar_du_vsp_atomic_begin(rcrtc);
 }

 static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
@@ -546,6 +549,9 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);

rcar_du_crtc_update_planes(rcrtc);
+
+   if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+   rcar_du_vsp_atomic_flush(rcrtc);
 }

 static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 6e34dfd0ef42..f01c089881e0 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -69,6 +69,16 @@ void rcar_du_vsp_disable(struct rcar_du_crtc *crtc)
vsp1_du_setup_lif(crtc->vsp->vsp, 0, 0);
 }

+void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc)
+{
+   vsp1_du_atomic_begin(crtc->vsp->vsp);
+}
+
+void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc)
+{
+   vsp1_du_atomic_flush(crtc->vsp->vsp);
+}
+
 /* Keep the two tables in sync. */
 static const u32 formats_kms[] = {
DRM_FORMAT_RGB332,
@@ -155,8 +165,8 @@ static void rcar_du_vsp_plane_setup(struct 
rcar_du_vsp_plane *plane)

WARN_ON(!pixelformat);

-   vsp1_du_setup_rpf(plane->vsp->vsp, plane->index, pixelformat,
- fb->pitches[0], paddr, , );
+   vsp1_du_atomic_update(plane->vsp->vsp, plane->index, pixelformat,
+ fb->pitches[0], paddr, , );
 }

 static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
@@ -195,8 +205,8 @@ static void rcar_du_vsp_plane_atomic_update(struct 
drm_plane *plane,
if (plane->state->crtc)
rcar_du_vsp_plane_setup(rplane);
else
-   vsp1_du_setup_rpf(rplane->vsp->vsp, rplane->index, 0, 0, 0,
- NULL, NULL);
+   vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, 0, 0, 0,
+ NULL, NULL);
 }

 static const struct drm_plane_helper_funcs rcar_du_vsp_plane_helper_funcs = {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
index 7a6ed21ebcd3..df3bf3805c69 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
@@ -63,10 +63,14 @@ to_rcar_vsp_plane_state(struct drm_plane_state *state)
 int rcar_du_vsp_init(struct rcar_du_vsp *vsp);
 void rcar_du_vsp_enable(struct rcar_du_crtc *crtc);
 void rcar_du_vsp_disable(struct rcar_du_crtc *crtc);
+void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc);
+void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc);
 #else
 static inline int rcar_du_vsp_init(struct rcar_du_vsp *vsp) { return 0; };
 static inline void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) { };
 static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { };
+static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { };
+static inline void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { };
 #endif

 #endif /* __RCAR_DU_VSP_H__ */
-- 
2.4.6



[PATCH 10/22] drm: rcar-du: Expose the VSP1 compositor through KMS planes

2015-09-14 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 

---
 drivers/gpu/drm/rcar-du/Kconfig |   7 +
 drivers/gpu/drm/rcar-du/Makefile|   2 +
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  |  42 +++-
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h  |   2 +
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   |   4 +
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   |  28 ++-
 drivers/gpu/drm/rcar-du/rcar_du_plane.c |   7 +-
 drivers/gpu/drm/rcar-du/rcar_du_plane.h |  11 +-
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c   | 359 
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h   |  72 +++
 10 files changed, 518 insertions(+), 16 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vsp.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vsp.h

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index d4e0a39568f6..62650abc3120 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -25,3 +25,10 @@ config DRM_RCAR_LVDS
help
  Enable support for the R-Car Display Unit embedded LVDS encoders
  (currently only on R8A7790 and R8A7791).
+
+config DRM_RCAR_VSP
+   bool "R-Car DU VSP Compositor Support"
+   depends on DRM_RCAR_DU
+   depends on VIDEO_RENESAS_VSP1
+   help
+ Enable support to expose the R-Car VSP Compositor as KMS planes.
diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 05de1c4097af..827711e28226 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -11,4 +11,6 @@ rcar-du-drm-$(CONFIG_DRM_RCAR_HDMI)   += rcar_du_hdmicon.o \
   rcar_du_hdmienc.o
 rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_lvdsenc.o

+rcar-du-drm-$(CONFIG_DRM_RCAR_VSP) += rcar_du_vsp.o
+
 obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 7e2f5c26d589..196b940ea8d7 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -28,6 +28,7 @@
 #include "rcar_du_kms.h"
 #include "rcar_du_plane.h"
 #include "rcar_du_regs.h"
+#include "rcar_du_vsp.h"

 static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg)
 {
@@ -207,6 +208,7 @@ plane_format(struct rcar_du_plane *plane)
 static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
 {
struct rcar_du_plane *planes[RCAR_DU_NUM_HW_PLANES];
+   struct rcar_du_device *rcdu = rcrtc->group->dev;
unsigned int num_planes = 0;
unsigned int dptsr_planes;
unsigned int hwplanes = 0;
@@ -250,6 +252,12 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc 
*rcrtc)
}
}

+   /* If VSP+DU integration is enabled the plane assignment is fixed. */
+   if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
+   dspr = (rcrtc->index % 2) + 1;
+   hwplanes = 1 << (rcrtc->index % 2);
+   }
+
/* Update the planes to display timing and dot clock generator
 * associations.
 *
@@ -389,6 +397,10 @@ static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc)

rcar_du_group_start_stop(rcrtc->group, true);

+   /* Enable the VSP compositor. */
+   if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+   rcar_du_vsp_enable(rcrtc);
+
/* Turn vertical blanking interrupt reporting back on. */
drm_crtc_vblank_on(crtc);

@@ -422,6 +434,10 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)
rcar_du_crtc_wait_page_flip(rcrtc);
drm_crtc_vblank_off(crtc);

+   /* Disable the VSP compositor. */
+   if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+   rcar_du_vsp_disable(rcrtc);
+
/* Select switch sync mode. This stops display operation and configures
 * the HSYNC and VSYNC signals as inputs.
 */
@@ -434,6 +450,9 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)

 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc)
 {
+   if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+   rcar_du_vsp_disable(rcrtc);
+
rcar_du_crtc_stop(rcrtc);
rcar_du_crtc_put(rcrtc);
 }
@@ -449,13 +468,17 @@ void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc)
rcar_du_crtc_start(rcrtc);

/* Commit the planes state. */
-   for (i = 0; i < rcrtc->group->num_planes; ++i) {
-   struct rcar_du_plane *plane = >group->planes[i];
+   if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE)) {
+   rcar_du_vsp_enable(rcrtc);
+   } else {
+   for (i = 0; i < rcrtc->group->num_planes; ++i) {
+   struct rcar_du_plane *plane = >group->planes[i];

-   if (plane->plane.state->crtc != >crtc)
-   continue;
+  

[PATCH 09/22] drm: rcar-du: Move plane allocator to rcar_du_plane.c

2015-09-14 Thread Laurent Pinchart
The plane allocator is specific to DU planes and won't be used for
VSP-based planes, move it with the rest of the DU planes code where it
belongs.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 276 +-
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 286 
 drivers/gpu/drm/rcar-du/rcar_du_plane.h |   3 +
 3 files changed, 290 insertions(+), 275 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index ba4e100e5b0f..6196410b9e98 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -192,290 +192,16 @@ static void rcar_du_output_poll_changed(struct 
drm_device *dev)
  * Atomic Check and Update
  */

-/*
- * Atomic hardware plane allocator
- *
- * The hardware plane allocator is solely based on the atomic plane states
- * without keeping any external state to avoid races between .atomic_check()
- * and .atomic_commit().
- *
- * The core idea is to avoid using a free planes bitmask that would need to be
- * shared between check and commit handlers with a collective knowledge based 
on
- * the allocated hardware plane(s) for each KMS plane. The allocator then loops
- * over all plane states to compute the free planes bitmask, allocates hardware
- * planes based on that bitmask, and stores the result back in the plane 
states.
- *
- * For this to work we need to access the current state of planes not touched 
by
- * the atomic update. To ensure that it won't be modified, we need to lock all
- * planes using drm_atomic_get_plane_state(). This effectively serializes 
atomic
- * updates from .atomic_check() up to completion (when swapping the states if
- * the check step has succeeded) or rollback (when freeing the states if the
- * check step has failed).
- *
- * Allocation is performed in the .atomic_check() handler and applied
- * automatically when the core swaps the old and new states.
- */
-
-static bool rcar_du_plane_needs_realloc(struct rcar_du_plane *plane,
-   struct rcar_du_plane_state *new_state)
-{
-   struct rcar_du_plane_state *cur_state;
-
-   cur_state = to_rcar_plane_state(plane->plane.state);
-
-   /* Lowering the number of planes doesn't strictly require reallocation
-* as the extra hardware plane will be freed when committing, but doing
-* so could lead to more fragmentation.
-*/
-   if (!cur_state->format ||
-   cur_state->format->planes != new_state->format->planes)
-   return true;
-
-   /* Reallocate hardware planes if the source has changed. */
-   if (cur_state->source != new_state->source)
-   return true;
-
-   return false;
-}
-
-static unsigned int rcar_du_plane_hwmask(struct rcar_du_plane_state *state)
-{
-   unsigned int mask;
-
-   if (state->hwindex == -1)
-   return 0;
-
-   mask = 1 << state->hwindex;
-   if (state->format->planes == 2)
-   mask |= 1 << ((state->hwindex + 1) % 8);
-
-   return mask;
-}
-
-/*
- * The R8A7790 DU can source frames directly from the VSP1 devices VSPD0 and
- * VSPD1. VSPD0 feeds DU0/1 plane 0, and VSPD1 feeds either DU2 plane 0 or
- * DU0/1 plane 1.
- *
- * Allocate the correct fixed plane when sourcing frames from VSPD0 or VSPD1,
- * and allocate planes in reverse index order otherwise to ensure maximum
- * availability of planes 0 and 1.
- *
- * The caller is responsible for ensuring that the requested source is
- * compatible with the DU revision.
- */
-static int rcar_du_plane_hwalloc(struct rcar_du_plane *plane,
-struct rcar_du_plane_state *state,
-unsigned int free)
-{
-   unsigned int num_planes = state->format->planes;
-   int fixed = -1;
-   int i;
-
-   if (state->source == RCAR_DU_PLANE_VSPD0) {
-   /* VSPD0 feeds plane 0 on DU0/1. */
-   if (plane->group->index != 0)
-   return -EINVAL;
-
-   fixed = 0;
-   } else if (state->source == RCAR_DU_PLANE_VSPD1) {
-   /* VSPD1 feeds plane 1 on DU0/1 or plane 0 on DU2. */
-   fixed = plane->group->index == 0 ? 1 : 0;
-   }
-
-   if (fixed >= 0)
-   return free & (1 << fixed) ? fixed : -EBUSY;
-
-   for (i = RCAR_DU_NUM_HW_PLANES - 1; i >= 0; --i) {
-   if (!(free & (1 << i)))
-   continue;
-
-   if (num_planes == 1 || free & (1 << ((i + 1) % 8)))
-   break;
-   }
-
-   return i < 0 ? -EBUSY : i;
-}
-
 static int rcar_du_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state)
 {
-   struct rcar_du_device *rcdu = dev->dev_private;
-   unsigned int group_freed_planes[RCAR_DU_MAX_GROUPS] = { 0, };
-   

[PATCH 08/22] drm: rcar-du: Restart the DU group when a plane source changes

2015-09-14 Thread Laurent Pinchart
Plane sources are configured by the VSPS bit in the PnDDCR4 register.
Although the datasheet states that the bit is updated during vertical
blanking, it seems that updates only occur when the DU group is held in
reset through the DSYSR.DRES bit. Restart the group if the source
changes.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  |  4 
 drivers/gpu/drm/rcar-du/rcar_du_group.c |  2 ++
 drivers/gpu/drm/rcar-du/rcar_du_group.h |  2 ++
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 22 --
 4 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 48cb19949ca3..7e2f5c26d589 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -272,6 +272,10 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc 
*rcrtc)
rcar_du_group_restart(rcrtc->group);
}

+   /* Restart the group if plane sources have changed. */
+   if (rcrtc->group->need_restart)
+   rcar_du_group_restart(rcrtc->group);
+
mutex_unlock(>group->lock);

rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 4a44ddd51766..0e2b46dce563 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -162,6 +162,8 @@ void rcar_du_group_start_stop(struct rcar_du_group *rgrp, 
bool start)

 void rcar_du_group_restart(struct rcar_du_group *rgrp)
 {
+   rgrp->need_restart = false;
+
__rcar_du_group_start_stop(rgrp, false);
__rcar_du_group_start_stop(rgrp, true);
 }
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h 
b/drivers/gpu/drm/rcar-du/rcar_du_group.h
index 4b1952fd4e7d..5e3adc6b31b5 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
@@ -32,6 +32,7 @@ struct rcar_du_device;
  * @dptsr_planes: bitmask of planes driven by dot-clock and timing generator 1
  * @num_planes: number of planes in the group
  * @planes: planes handled by the group
+ * @need_restart: the group needs to be restarted due to a configuration change
  */
 struct rcar_du_group {
struct rcar_du_device *dev;
@@ -47,6 +48,7 @@ struct rcar_du_group {

unsigned int num_planes;
struct rcar_du_plane planes[RCAR_DU_NUM_KMS_PLANES];
+   bool need_restart;
 };

 u32 rcar_du_group_read(struct rcar_du_group *rgrp, u32 reg);
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index 78ca353bfcf0..c7e0535c0e77 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -275,9 +275,27 @@ static void rcar_du_plane_atomic_update(struct drm_plane 
*plane,
struct drm_plane_state *old_state)
 {
struct rcar_du_plane *rplane = to_rcar_plane(plane);
+   struct rcar_du_plane_state *old_rstate;
+   struct rcar_du_plane_state *new_rstate;

-   if (plane->state->crtc)
-   rcar_du_plane_setup(rplane);
+   if (!plane->state->crtc)
+   return;
+
+   rcar_du_plane_setup(rplane);
+
+   /* Check whether the source has changed from memory to live source or
+* from live source to memory. The source has been configured by the
+* VSPS bit in the PnDDCR4 register. Although the datasheet states that
+* the bit is updated during vertical blanking, it seems that updates
+* only occur when the DU group is held in reset through the DSYSR.DRES
+* bit. We thus need to restart the group if the source changes.
+*/
+   old_rstate = to_rcar_plane_state(old_state);
+   new_rstate = to_rcar_plane_state(plane->state);
+
+   if ((old_rstate->source == RCAR_DU_PLANE_MEMORY) !=
+   (new_rstate->source == RCAR_DU_PLANE_MEMORY))
+   rplane->group->need_restart = true;
 }

 static const struct drm_plane_helper_funcs rcar_du_plane_helper_funcs = {
-- 
2.4.6



[PATCH 07/22] drm: rcar-du: Add VSP1 compositor support

2015-09-14 Thread Laurent Pinchart
Configure the plane source at plane setup time to source frames from
memory or from the VSP1.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   |  2 +
 drivers/gpu/drm/rcar-du/rcar_du_group.c | 24 +
 drivers/gpu/drm/rcar-du/rcar_du_group.h |  2 +
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 16 --
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 86 +++--
 drivers/gpu/drm/rcar-du/rcar_du_regs.h  |  1 +
 6 files changed, 82 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index 9f34fc86436a..e10b4f0d8f83 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -90,6 +90,8 @@ struct rcar_du_device {
} props;

unsigned int dpad0_source;
+   unsigned int vspd1_sink;
+
struct rcar_du_lvdsenc *lvds[RCAR_DU_MAX_LVDS];

struct {
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 8e2ffe025153..4a44ddd51766 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -49,11 +49,15 @@ static void rcar_du_group_setup_defr8(struct rcar_du_group 
*rgrp)
u32 defr8 = DEFR8_CODE | DEFR8_DEFE8;

/* The DEFR8 register for the first group also controls RGB output
-* routing to DPAD0 for DU instances that support it.
+* routing to DPAD0 and VSPD1 routing to DU0/1/2 for DU instances that
+* support it.
 */
-   if (rgrp->dev->info->routes[RCAR_DU_OUTPUT_DPAD0].possible_crtcs > 1 &&
-   rgrp->index == 0)
-   defr8 |= DEFR8_DRGBS_DU(rgrp->dev->dpad0_source);
+   if (rgrp->index == 0) {
+   if 
(rgrp->dev->info->routes[RCAR_DU_OUTPUT_DPAD0].possible_crtcs > 1)
+   defr8 |= DEFR8_DRGBS_DU(rgrp->dev->dpad0_source);
+   if (rgrp->dev->vspd1_sink == 2)
+   defr8 |= DEFR8_VSCS;
+   }

rcar_du_group_write(rgrp, DEFR8, defr8);
 }
@@ -162,17 +166,17 @@ void rcar_du_group_restart(struct rcar_du_group *rgrp)
__rcar_du_group_start_stop(rgrp, true);
 }

-static int rcar_du_set_dpad0_routing(struct rcar_du_device *rcdu)
+int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu)
 {
int ret;

if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_EXT_CTRL_REGS))
return 0;

-   /* RGB output routing to DPAD0 is configured in the DEFR8 register of
-* the first group. As this function can be called with the DU0 and DU1
-* CRTCs disabled, we need to enable the first group clock before
-* accessing the register.
+   /* RGB output routing to DPAD0 and VSP1D routing to DU0/1/2 are
+* configured in the DEFR8 register of the first group. As this function
+* can be called with the DU0 and DU1 CRTCs disabled, we need to enable
+* the first group clock before accessing the register.
 */
ret = clk_prepare_enable(rcdu->crtcs[0].clock);
if (ret < 0)
@@ -203,5 +207,5 @@ int rcar_du_group_set_routing(struct rcar_du_group *rgrp)

rcar_du_group_write(rgrp, DORCR, dorcr);

-   return rcar_du_set_dpad0_routing(rgrp->dev);
+   return rcar_du_set_dpad0_vsp1_routing(rgrp->dev);
 }
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h 
b/drivers/gpu/drm/rcar-du/rcar_du_group.h
index d7318e1a6b00..4b1952fd4e7d 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
@@ -58,4 +58,6 @@ void rcar_du_group_start_stop(struct rcar_du_group *rgrp, 
bool start);
 void rcar_du_group_restart(struct rcar_du_group *rgrp);
 int rcar_du_group_set_routing(struct rcar_du_group *rgrp);

+int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu);
+
 #endif /* __RCAR_DU_GROUP_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 455f7e466181..ba4e100e5b0f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -217,17 +217,25 @@ static void rcar_du_output_poll_changed(struct drm_device 
*dev)
  */

 static bool rcar_du_plane_needs_realloc(struct rcar_du_plane *plane,
-   struct rcar_du_plane_state *state)
+   struct rcar_du_plane_state *new_state)
 {
-   const struct rcar_du_format_info *cur_format;
+   struct rcar_du_plane_state *cur_state;

-   cur_format = to_rcar_plane_state(plane->plane.state)->format;
+   cur_state = to_rcar_plane_state(plane->plane.state);

/* Lowering the number of planes doesn't strictly require reallocation
 * as the extra hardware plane will be freed when committing, but doing
 * so could lead to more fragmentation.
 */
-   return !cur_format || cur_format->planes != 

[PATCH 06/22] drm: rcar-du: Add VSP1 support to the planes allocator

2015-09-14 Thread Laurent Pinchart
The R8A7790 DU can source frames directly from the VSP1 devices VSPD0
and VSPD1. VSPD0 feeds DU0/1 plane 0, and VSPD1 feeds either DU2 plane 0
or DU0/1 plane 1.

Allocate the correct fixed plane when sourcing frames from VSPD0 or
VSPD1, and allocate planes in reverse index order otherwise to ensure
maximum availability of planes 0 and 1.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 42 -
 drivers/gpu/drm/rcar-du/rcar_du_plane.c |  1 +
 drivers/gpu/drm/rcar-du/rcar_du_plane.h |  7 ++
 3 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 20813582fbf1..455f7e466181 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -244,11 +244,41 @@ static unsigned int rcar_du_plane_hwmask(struct 
rcar_du_plane_state *state)
return mask;
 }

-static int rcar_du_plane_hwalloc(unsigned int num_planes, unsigned int free)
+/*
+ * The R8A7790 DU can source frames directly from the VSP1 devices VSPD0 and
+ * VSPD1. VSPD0 feeds DU0/1 plane 0, and VSPD1 feeds either DU2 plane 0 or
+ * DU0/1 plane 1.
+ *
+ * Allocate the correct fixed plane when sourcing frames from VSPD0 or VSPD1,
+ * and allocate planes in reverse index order otherwise to ensure maximum
+ * availability of planes 0 and 1.
+ *
+ * The caller is responsible for ensuring that the requested source is
+ * compatible with the DU revision.
+ */
+static int rcar_du_plane_hwalloc(struct rcar_du_plane *plane,
+struct rcar_du_plane_state *state,
+unsigned int free)
 {
-   unsigned int i;
+   unsigned int num_planes = state->format->planes;
+   int fixed = -1;
+   int i;
+
+   if (state->source == RCAR_DU_PLANE_VSPD0) {
+   /* VSPD0 feeds plane 0 on DU0/1. */
+   if (plane->group->index != 0)
+   return -EINVAL;
+
+   fixed = 0;
+   } else if (state->source == RCAR_DU_PLANE_VSPD1) {
+   /* VSPD1 feeds plane 1 on DU0/1 or plane 0 on DU2. */
+   fixed = plane->group->index == 0 ? 1 : 0;
+   }
+
+   if (fixed >= 0)
+   return free & (1 << fixed) ? fixed : -EBUSY;

-   for (i = 0; i < RCAR_DU_NUM_HW_PLANES; ++i) {
+   for (i = RCAR_DU_NUM_HW_PLANES - 1; i >= 0; --i) {
if (!(free & (1 << i)))
continue;

@@ -256,7 +286,7 @@ static int rcar_du_plane_hwalloc(unsigned int num_planes, 
unsigned int free)
break;
}

-   return i == RCAR_DU_NUM_HW_PLANES ? -EBUSY : i;
+   return i < 0 ? -EBUSY : i;
 }

 static int rcar_du_atomic_check(struct drm_device *dev,
@@ -413,10 +443,10 @@ static int rcar_du_atomic_check(struct drm_device *dev,
: ~plane->group->dptsr_planes;
free = group_free_planes[plane->group->index];

-   idx = rcar_du_plane_hwalloc(plane_state->format->planes,
+   idx = rcar_du_plane_hwalloc(plane, plane_state,
free & crtc_planes);
if (idx < 0)
-   idx = rcar_du_plane_hwalloc(plane_state->format->planes,
+   idx = rcar_du_plane_hwalloc(plane, plane_state,
free);
if (idx < 0) {
dev_dbg(rcdu->dev, "%s: no available hardware plane\n",
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index d64b23027749..f301c15934cc 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -309,6 +309,7 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
return;

state->hwindex = -1;
+   state->source = RCAR_DU_PLANE_MEMORY;
state->alpha = 255;
state->colorkey = RCAR_DU_COLORKEY_NONE;
state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
index 9732bff1911b..e24e45828d6a 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
@@ -28,6 +28,12 @@ struct rcar_du_group;
 #define RCAR_DU_NUM_KMS_PLANES 9
 #define RCAR_DU_NUM_HW_PLANES  8

+enum rcar_du_plane_source {
+   RCAR_DU_PLANE_MEMORY,
+   RCAR_DU_PLANE_VSPD0,
+   RCAR_DU_PLANE_VSPD1,
+};
+
 struct rcar_du_plane {
struct drm_plane plane;
struct rcar_du_group *group;
@@ -52,6 +58,7 @@ struct rcar_du_plane_state {

const struct rcar_du_format_info *format;
int hwindex;
+   enum rcar_du_plane_source source;

unsigned int alpha;
unsigned int colorkey;
-- 
2.4.6



[PATCH 05/22] drm: rcar-du: Refactor plane setup

2015-09-14 Thread Laurent Pinchart
Rename plane setup functions using more explicit names, and use local
variables to store intermediate values to increase readability. This
also prepares for VSP compositor support.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 39 ++---
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index b20f3ceb55e6..d64b23027749 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -35,7 +35,7 @@ static void rcar_du_plane_write(struct rcar_du_group *rgrp,
  data);
 }

-static void rcar_du_plane_setup_fb(struct rcar_du_plane *plane)
+static void rcar_du_plane_setup_scanout(struct rcar_du_plane *plane)
 {
struct rcar_du_plane_state *state =
to_rcar_plane_state(plane->plane.state);
@@ -45,8 +45,10 @@ static void rcar_du_plane_setup_fb(struct rcar_du_plane 
*plane)
unsigned int src_y = state->state.src_y >> 16;
unsigned int index = state->hwindex;
struct drm_gem_cma_object *gem;
+   unsigned int pitch;
bool interlaced;
-   u32 mwr;
+   unsigned int i;
+   u32 dma[2];

interlaced = state->state.crtc->state->adjusted_mode.flags
   & DRM_MODE_FLAG_INTERLACE;
@@ -55,14 +57,18 @@ static void rcar_du_plane_setup_fb(struct rcar_du_plane 
*plane)
 * operation with 32bpp formats.
 */
if (state->format->planes == 2)
-   mwr = fb->pitches[0];
+   pitch = fb->pitches[0];
else
-   mwr = fb->pitches[0] * 8 / state->format->bpp;
+   pitch = fb->pitches[0] * 8 / state->format->bpp;

-   if (interlaced && state->format->bpp == 32)
-   mwr *= 2;
+   for (i = 0; i < state->format->planes; ++i) {
+   gem = drm_fb_cma_get_gem_obj(fb, i);
+   dma[i] = gem->paddr + fb->offsets[i];
+   }

-   rcar_du_plane_write(rgrp, index, PnMWR, mwr);
+   rcar_du_plane_write(rgrp, index, PnMWR,
+   (interlaced && state->format->bpp == 32) ?
+   pitch * 2 : pitch);

/* The Y position is expressed in raster line units and must be doubled
 * for 32bpp formats, according to the R8A7790 datasheet. No mention of
@@ -80,21 +86,18 @@ static void rcar_du_plane_setup_fb(struct rcar_du_plane 
*plane)
rcar_du_plane_write(rgrp, index, PnSPYR, src_y *
(!interlaced && state->format->bpp == 32 ? 2 : 1));

-   gem = drm_fb_cma_get_gem_obj(fb, 0);
-   rcar_du_plane_write(rgrp, index, PnDSA0R, gem->paddr + fb->offsets[0]);
+   rcar_du_plane_write(rgrp, index, PnDSA0R, dma[0]);

if (state->format->planes == 2) {
index = (index + 1) % 8;

-   rcar_du_plane_write(rgrp, index, PnMWR, fb->pitches[0]);
+   rcar_du_plane_write(rgrp, index, PnMWR, pitch);

rcar_du_plane_write(rgrp, index, PnSPXR, src_x);
rcar_du_plane_write(rgrp, index, PnSPYR, src_y *
(state->format->bpp == 16 ? 2 : 1) / 2);

-   gem = drm_fb_cma_get_gem_obj(fb, 1);
-   rcar_du_plane_write(rgrp, index, PnDSA0R,
-   gem->paddr + fb->offsets[1]);
+   rcar_du_plane_write(rgrp, index, PnDSA0R, dma[1]);
}
 }

@@ -161,8 +164,8 @@ static void rcar_du_plane_setup_mode(struct rcar_du_plane 
*plane,
}
 }

-static void __rcar_du_plane_setup(struct rcar_du_plane *plane,
- unsigned int index)
+static void rcar_du_plane_setup_format(struct rcar_du_plane *plane,
+  unsigned int index)
 {
struct rcar_du_plane_state *state =
to_rcar_plane_state(plane->plane.state);
@@ -217,11 +220,11 @@ void rcar_du_plane_setup(struct rcar_du_plane *plane)
struct rcar_du_plane_state *state =
to_rcar_plane_state(plane->plane.state);

-   __rcar_du_plane_setup(plane, state->hwindex);
+   rcar_du_plane_setup_format(plane, state->hwindex);
if (state->format->planes == 2)
-   __rcar_du_plane_setup(plane, (state->hwindex + 1) % 8);
+   rcar_du_plane_setup_format(plane, (state->hwindex + 1) % 8);

-   rcar_du_plane_setup_fb(plane);
+   rcar_du_plane_setup_scanout(plane);
 }

 static int rcar_du_plane_atomic_check(struct drm_plane *plane,
-- 
2.4.6



[PATCH 04/22] drm: rcar-du: Compute plane DDCR4 register value directly

2015-09-14 Thread Laurent Pinchart
There's no need for a read-modify-write pattern, all register bits can
be set explicitly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index ffa583712cd9..b20f3ceb55e6 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -28,13 +28,6 @@
 #define RCAR_DU_COLORKEY_SOURCE(1 << 24)
 #define RCAR_DU_COLORKEY_MASK  (1 << 24)

-static u32 rcar_du_plane_read(struct rcar_du_group *rgrp,
- unsigned int index, u32 reg)
-{
-   return rcar_du_read(rgrp->dev,
-   rgrp->mmio_offset + index * PLANE_OFF + reg);
-}
-
 static void rcar_du_plane_write(struct rcar_du_group *rgrp,
unsigned int index, u32 reg, u32 data)
 {
@@ -182,9 +175,6 @@ static void __rcar_du_plane_setup(struct rcar_du_plane 
*plane,
 * The data format is selected by the DDDF field in PnMR and the EDF
 * field in DDCR4.
 */
-   ddcr4 = rcar_du_plane_read(rgrp, index, PnDDCR4);
-   ddcr4 &= ~PnDDCR4_EDF_MASK;
-   ddcr4 |= state->format->edf | PnDDCR4_CODE;

rcar_du_plane_setup_mode(plane, index);

@@ -204,6 +194,9 @@ static void __rcar_du_plane_setup(struct rcar_du_plane 
*plane,
}

rcar_du_plane_write(rgrp, index, PnDDCR2, ddcr2);
+
+   ddcr4 = state->format->edf | PnDDCR4_CODE;
+
rcar_du_plane_write(rgrp, index, PnDDCR4, ddcr4);

/* Destination position and size */
-- 
2.4.6



[PATCH 03/22] drm: rcar-du: Add support for the R8A7794 DU

2015-09-14 Thread Laurent Pinchart
The R8A7794 DU has a fixed output routing configuration with one RGB
output per CRTC and thus lacks the RGB output routing register field.

Cc: devicetree at vger.kernel.org
Signed-off-by: Laurent Pinchart 
---
 .../devicetree/bindings/video/renesas,du.txt   |  4 +++-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  | 23 ++
 drivers/gpu/drm/rcar-du/rcar_du_group.c|  5 +++--
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/video/renesas,du.txt 
b/Documentation/devicetree/bindings/video/renesas,du.txt
index d05be121486f..eccd4f4867b2 100644
--- a/Documentation/devicetree/bindings/video/renesas,du.txt
+++ b/Documentation/devicetree/bindings/video/renesas,du.txt
@@ -7,6 +7,7 @@ Required Properties:
 - "renesas,du-r8a7790" for R8A7790 (R-Car H2) compatible DU
 - "renesas,du-r8a7791" for R8A7791 (R-Car M2-W) compatible DU
 - "renesas,du-r8a7793" for R8A7793 (R-Car M2-N) compatible DU
+- "renesas,du-r8a7794" for R8A7794 (R-Car E2) compatible DU

   - reg: A list of base address and length of each memory resource, one for
 each entry in the reg-names property.
@@ -23,7 +24,7 @@ Required Properties:
   - clock-names: Name of the clocks. This property is model-dependent.
 - R8A7779 uses a single functional clock. The clock doesn't need to be
   named.
-- R8A779[013] use one functional clock per channel and one clock per LVDS
+- R8A779[0134] use one functional clock per channel and one clock per LVDS
   encoder (if available). The functional clocks must be named "du.x" with
   "x" being the channel numerical index. The LVDS clocks must be named
   "lvds.x" with "x" being the LVDS encoder numerical index.
@@ -46,6 +47,7 @@ corresponding to each DU output.
  R8A7790 (H2)  DPADLVDS 0  LVDS 1
  R8A7791 (M2-W)DPADLVDS 0  -
  R8A7793 (M2-N)DPADLVDS 0  -
+ R8A7794 (E2)  DPAD 0  DPAD 1  -


 Example: R8A7790 (R-Car H2) DU
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 90d19fb976ab..326d040515e4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -107,11 +107,34 @@ static const struct rcar_du_device_info 
rcar_du_r8a7791_info = {
.num_lvds = 1,
 };

+static const struct rcar_du_device_info rcar_du_r8a7794_info = {
+   .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
+ | RCAR_DU_FEATURE_EXT_CTRL_REGS,
+   .num_crtcs = 2,
+   .routes = {
+   /* R8A7794 has two RGB outputs and one (currently unsupported)
+* TCON output.
+*/
+   [RCAR_DU_OUTPUT_DPAD0] = {
+   .possible_crtcs = BIT(0),
+   .encoder_type = DRM_MODE_ENCODER_NONE,
+   .port = 0,
+   },
+   [RCAR_DU_OUTPUT_DPAD1] = {
+   .possible_crtcs = BIT(1),
+   .encoder_type = DRM_MODE_ENCODER_NONE,
+   .port = 1,
+   },
+   },
+   .num_lvds = 0,
+};
+
 static const struct of_device_id rcar_du_of_table[] = {
{ .compatible = "renesas,du-r8a7779", .data = _du_r8a7779_info },
{ .compatible = "renesas,du-r8a7790", .data = _du_r8a7790_info },
{ .compatible = "renesas,du-r8a7791", .data = _du_r8a7791_info },
{ .compatible = "renesas,du-r8a7793", .data = _du_r8a7791_info },
+   { .compatible = "renesas,du-r8a7794", .data = _du_r8a7794_info },
{ }
 };

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 7fd39a7d91c8..8e2ffe025153 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -49,9 +49,10 @@ static void rcar_du_group_setup_defr8(struct rcar_du_group 
*rgrp)
u32 defr8 = DEFR8_CODE | DEFR8_DEFE8;

/* The DEFR8 register for the first group also controls RGB output
-* routing to DPAD0
+* routing to DPAD0 for DU instances that support it.
 */
-   if (rgrp->index == 0)
+   if (rgrp->dev->info->routes[RCAR_DU_OUTPUT_DPAD0].possible_crtcs > 1 &&
+   rgrp->index == 0)
defr8 |= DEFR8_DRGBS_DU(rgrp->dev->dpad0_source);

rcar_du_group_write(rgrp, DEFR8, defr8);
-- 
2.4.6



[PATCH 02/22] drm: rcar-du: Add support for the R8A7793 DU

2015-09-14 Thread Laurent Pinchart
The R8A7793 DU is identical to the R8A7791 and thus only requires a new
DT compatible string.

Cc: devicetree at vger.kernel.org
Signed-off-by: Laurent Pinchart 
---
 Documentation/devicetree/bindings/video/renesas,du.txt | 12 +++-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  |  4 +++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/video/renesas,du.txt 
b/Documentation/devicetree/bindings/video/renesas,du.txt
index c902323928f7..d05be121486f 100644
--- a/Documentation/devicetree/bindings/video/renesas,du.txt
+++ b/Documentation/devicetree/bindings/video/renesas,du.txt
@@ -5,7 +5,8 @@ Required Properties:
   - compatible: must be one of the following.
 - "renesas,du-r8a7779" for R8A7779 (R-Car H1) compatible DU
 - "renesas,du-r8a7790" for R8A7790 (R-Car H2) compatible DU
-- "renesas,du-r8a7791" for R8A7791 (R-Car M2) compatible DU
+- "renesas,du-r8a7791" for R8A7791 (R-Car M2-W) compatible DU
+- "renesas,du-r8a7793" for R8A7793 (R-Car M2-N) compatible DU

   - reg: A list of base address and length of each memory resource, one for
 each entry in the reg-names property.
@@ -22,9 +23,9 @@ Required Properties:
   - clock-names: Name of the clocks. This property is model-dependent.
 - R8A7779 uses a single functional clock. The clock doesn't need to be
   named.
-- R8A7790 and R8A7791 use one functional clock per channel and one clock
-  per LVDS encoder. The functional clocks must be named "du.x" with "x"
-  being the channel numerical index. The LVDS clocks must be named
+- R8A779[013] use one functional clock per channel and one clock per LVDS
+  encoder (if available). The functional clocks must be named "du.x" with
+  "x" being the channel numerical index. The LVDS clocks must be named
   "lvds.x" with "x" being the LVDS encoder numerical index.
 - In addition to the functional and encoder clocks, all DU versions also
   support externally supplied pixel clocks. Those clocks are optional.
@@ -43,7 +44,8 @@ corresponding to each DU output.
 -
  R8A7779 (H1)  DPAD 0  DPAD 1  -
  R8A7790 (H2)  DPADLVDS 0  LVDS 1
- R8A7791 (M2)  DPADLVDS 0  -
+ R8A7791 (M2-W)DPADLVDS 0  -
+ R8A7793 (M2-N)DPADLVDS 0  -


 Example: R8A7790 (R-Car H2) DU
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 44879136e933..90d19fb976ab 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -84,12 +84,13 @@ static const struct rcar_du_device_info 
rcar_du_r8a7790_info = {
.num_lvds = 2,
 };

+/* M2-W (r8a7791) and M2-N (r8a7793) are identical */
 static const struct rcar_du_device_info rcar_du_r8a7791_info = {
.features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
  | RCAR_DU_FEATURE_EXT_CTRL_REGS,
.num_crtcs = 2,
.routes = {
-   /* R8A7791 has one RGB output, one LVDS output and one
+   /* R8A779[13] has one RGB output, one LVDS output and one
 * (currently unsupported) TCON output.
 */
[RCAR_DU_OUTPUT_DPAD0] = {
@@ -110,6 +111,7 @@ static const struct of_device_id rcar_du_of_table[] = {
{ .compatible = "renesas,du-r8a7779", .data = _du_r8a7779_info },
{ .compatible = "renesas,du-r8a7790", .data = _du_r8a7790_info },
{ .compatible = "renesas,du-r8a7791", .data = _du_r8a7791_info },
+   { .compatible = "renesas,du-r8a7793", .data = _du_r8a7791_info },
{ }
 };

-- 
2.4.6



[PATCH 01/22] drm: rcar-du: Don't update planes on disabled CRTCs

2015-09-14 Thread Laurent Pinchart
A disabled CRTC can't display planes, the driver shouldn't try to
configure it when updating planes. The DRM core will store the plane
state for us, and the plane will be configured appropriately the next
time the CRTC is enabled.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index ca12e8ca5552..20813582fbf1 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -456,7 +456,7 @@ static void rcar_du_atomic_complete(struct rcar_du_commit 
*commit)
/* Apply the atomic update. */
drm_atomic_helper_commit_modeset_disables(dev, old_state);
drm_atomic_helper_commit_modeset_enables(dev, old_state);
-   drm_atomic_helper_commit_planes(dev, old_state, false);
+   drm_atomic_helper_commit_planes(dev, old_state, true);

drm_atomic_helper_wait_for_vblanks(dev, old_state);

-- 
2.4.6



[PATCH 00/22] R-Car DU: Add Gen3 support

2015-09-14 Thread Laurent Pinchart
Hello,

This patch series adds support for the Display Unit found in the R-Car Gen3
SoC series.

The third generation differs significantly from the previous ones in that the
DU has lost its ability to source data from memory. It must instead use an
external hardware composer named VSP to read planes from memory and blend
them.

The VSP has a V4L2 driver in mainline that can be used in conjunction with the
DU through the live sources API (submitted previously as an RFC). However, as
VSP usage is mandatory in Gen3 and as no native DU planes are available, we
have decided that forcing userspace to use both KMS and V4L2 to display any
content wouldn't be very friendly. Instead the VSP driver has been extended to
make the device directly controllable by the DU driver ([1]) and this patch
series builds on top of it.

[1] http://www.spinics.net/lists/linux-media/msg93575.html

Koji Matsuoka (4):
  drm: rcar-du: Fix compile warning on 64-bit platforms
  drm: rcar-du: Enable compilation on ARM64
  drm: rcar-du: Support up to 4 CRTCs
  drm: rcar-du: lvds: Add R-Car Gen3 support

Laurent Pinchart (18):
  drm: rcar-du: Don't update planes on disabled CRTCs
  drm: rcar-du: Add support for the R8A7793 DU
  drm: rcar-du: Add support for the R8A7794 DU
  drm: rcar-du: Compute plane DDCR4 register value directly
  drm: rcar-du: Refactor plane setup
  drm: rcar-du: Add VSP1 support to the planes allocator
  drm: rcar-du: Add VSP1 compositor support
  drm: rcar-du: Restart the DU group when a plane source changes
  drm: rcar-du: Move plane allocator to rcar_du_plane.c
  drm: rcar-du: Expose the VSP1 compositor through KMS planes
  drm: rcar-du: Use the VSP atomic update API
  drm: rcar-du: Drop LVDS double dependency on OF
  drm: rcar-du: Output the DISP signal on the DISP pin
  drm: rcar-du: Output the DISP signal on the ODDF pin
  drm: rcar-du: Add R8A7795 device support
  drm: rcar-du: lvds: Avoid duplication of clock clamp code
  drm: rcar-du: lvds: Fix PLL frequency-related configuration
  drm: rcar-du: lvds: Rename PLLEN bit to PLLON

 .../devicetree/bindings/video/renesas,du.txt   |  22 +-
 drivers/gpu/drm/rcar-du/Kconfig|  15 +-
 drivers/gpu/drm/rcar-du/Makefile   |   2 +
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  63 ++-
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h |   2 +
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  |  58 ++-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h  |  12 +-
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c  |   6 +-
 drivers/gpu/drm/rcar-du/rcar_du_group.c|  73 +++-
 drivers/gpu/drm/rcar-du/rcar_du_group.h|   4 +
 drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c  |   7 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c  | 273 ++--
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c  | 142 +--
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h  |   6 +
 drivers/gpu/drm/rcar-du/rcar_du_plane.c| 465 ++---
 drivers/gpu/drm/rcar-du/rcar_du_plane.h|  21 +-
 drivers/gpu/drm/rcar-du/rcar_du_regs.h |  21 +-
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  | 373 +
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h  |  76 
 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h   |  26 +-
 20 files changed, 1263 insertions(+), 404 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vsp.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vsp.h

-- 
Regards,

Laurent Pinchart



[Bug 91982] [radeonsi] fs leak in get_radeon_bo()

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91982

--- Comment #3 from Shawn Starr  ---
Created attachment 118251
  --> https://bugs.freedesktop.org/attachment.cgi?id=118251=edit
Valgrind output

-- 
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/20150914/e9450c8d/attachment.html>


[Bug 91545] [BONAIRE][ARK: Survival Evolved] Regression: radeonsi: flush if the memory usage for an IB is too high

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91545

Shawn Starr  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |NOTOURBUG

--- Comment #5 from Shawn Starr  ---
This has been reported outside of Mesa, as such the rain corruption is not a
Mesa 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/20150914/1d5e8305/attachment.html>


[Bug 91543] [BONAIRE] ARK: Survival Evolved: corruption with certain textures inside cave (spider web)

2015-09-14 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=91543

--- Comment #2 from Shawn Starr  ---
I am not sure this is Mesa or game/engine related, so keeping this open until I
have more info but I'm leaning towards non-Mesa issue

-- 
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/20150914/c30d6952/attachment.html>


AGP cards in PCI mode (fake slots like AGPro, AGP Express, AGI, AGX, XGP)

2015-09-14 Thread Ondrej Zary
On Sunday 13 September 2015 21:12:25 Ilia Mirkin wrote:
> On Sun, Sep 13, 2015 at 2:57 PM, Ondrej Zary  
> wrote:
> > Hello,
> > I have a PC Chips A31G board with AGPro slot and found that nouveau does
> > not work properly with it. Console works but reverts to software mode,
> > X11 hangs with mouse cursor only.
> >
> > The slot is physically AGP 1.5V but is wired to PCI bus as the chipset
> > (SiS 761) does not support AGP cards. To further complicate things, the
> > chipset has AGP capability - but only for the integrated video. You can
> > see that in the lspci output below - the AGP card is on bus 0 and SiS
> > card on bus 1 (AGP bus behind the AGP bridge). The SiS card is not used
> > (can be disabled in BIOS but it does not improve things - as the AGP
> > capability of the host bridge remains active).
>
> I believe we can handle it with a blacklist. If the chipset just
> doesn't support AGP at all, we should just set agpmode=0 irrespective
> of the card plugged in, right?
>
> Shouldn't the agpgart know about this and not even allow any setting
> at all? This is where we get the idea to set 8x AGP from. See
> drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c for details.

The chipset does not support AGP slot but supports AGP for the integrated
video. So it shouldn't be completely disabled.

> The alternative is to add to nvkm_device_agp_quirks, and just add
> something that matches just the host bridge vendor/device, ignoring
> the chip.

Something like this?

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
index 814cb51..385a90f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
@@ -35,6 +35,8 @@ static const struct nvkm_device_agp_quirk
 nvkm_device_agp_quirks[] = {
/* VIA Apollo PRO133x / GeForce FX 5600 Ultra - fdo#20341 */
{ PCI_VENDOR_ID_VIA, 0x0691, PCI_VENDOR_ID_NVIDIA, 0x0311, 2 },
+   /* SiS 761 does not support AGP cards, use PCI mode */
+   { PCI_VENDOR_ID_SI, 0x0761, PCI_ANY_ID, PCI_ANY_ID, 0 },
{},
 };

@@ -137,8 +139,10 @@ nvkm_agp_ctor(struct nvkm_pci *pci)
while (quirk->hostbridge_vendor) {
if (info.device->vendor == quirk->hostbridge_vendor &&
info.device->device == quirk->hostbridge_device &&
-   pci->pdev->vendor == quirk->chip_vendor &&
-   pci->pdev->device == quirk->chip_device) {
+   (quirk->chip_vendor == (u16)PCI_ANY_ID ||
+   pci->pdev->vendor == quirk->chip_vendor) &&
+   (quirk->chip_device == (u16)PCI_ANY_ID ||
+   pci->pdev->device == quirk->chip_device)) {
nvkm_info(subdev, "forcing default agp mode to %dX, "
  "use NvAGP= to override\n",
  quirk->mode);
-- 
Ondrej Zary


[PATCH] drm/atomic-helper: Don't skip plane disabling on active CRTC

2015-09-14 Thread Laurent Pinchart
Hi Daniel,

I've successfully tested the following patch with the rcar-du-drm driver. I'm 
not sure who else passes a true active_only argument to 
drm_atomic_helper_commit_planes() out-of-tree so I don't know who you would 
like to received a Tested-by tag from, but I'll need both your base patch and 
this fix for my next rcar-du-drm pull request.

On Friday 11 September 2015 00:07:19 Laurent Pinchart wrote:
> Since commit "drm/atomic-helper: Add option to update planes only on
> active crtc" the drm_atomic_helper_commit_planes() function accepts an
> active_only argument to skip updating planes when the associated CRTC is
> inactive. Planes being disabled on an active CRTC are incorrectly
> considered as associated with an inactive CRTC and are thus skipped,
> preventing any plane disabling update from reaching drivers.
> 
> Fix it by checking the state of the CRTC stored in the old plane state
> for planes being disabled.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 24 ++--
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> Hi Daniel,
> 
> This fixes the patch mentioned in the commit message. Please feel free to
> squash the fix into the original patch if it's not too late, or take it in
> your branch otherwise (in which case a Fixes: line might be appropriate).
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c
> b/drivers/gpu/drm/drm_atomic_helper.c index a067ddb1b443..0aa19fa0a5d5
> 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1201,23 +1201,35 @@ void drm_atomic_helper_commit_planes(struct
> drm_device *dev,
> 
>   for_each_plane_in_state(old_state, plane, old_plane_state, i) {
>   const struct drm_plane_helper_funcs *funcs;
> + bool disabling;
> 
>   funcs = plane->helper_private;
> 
>   if (!funcs)
>   continue;
> 
> - if (active_only && !plane_crtc_active(plane->state))
> - continue;
> + disabling = drm_atomic_plane_disabling(plane, old_plane_state);
> +
> + if (active_only) {
> + /*
> +  * Skip planes related to inactive CRTCs. If the plane
> +  * is enabled use the state of the current CRTC. If the
> +  * plane is being disabled use the state of the old
> +  * CRTC to avoid skipping planes being disabled on an
> +  * active CRTC.
> +  */
> + if (!disabling && !plane_crtc_active(plane->state))
> + continue;
> + if (disabling && !plane_crtc_active(old_plane_state))
> + continue;
> + }
> 
>   /*
>* Special-case disabling the plane if drivers support it.
>*/
> - if (drm_atomic_plane_disabling(plane, old_plane_state) &&
> - funcs->atomic_disable)
> + if (disabling && funcs->atomic_disable)
>   funcs->atomic_disable(plane, old_plane_state);
> - else if (plane->state->crtc ||
> -  drm_atomic_plane_disabling(plane, old_plane_state))
> + else if (plane->state->crtc || disabling)
>   funcs->atomic_update(plane, old_plane_state);
>   }

-- 
Regards,

Laurent Pinchart



[PATCH] drm/atomic-helper: Don't skip plane disabling on active CRTC

2015-09-14 Thread Daniel Vetter
On Sun, Sep 13, 2015 at 11:33:26PM +0300, Laurent Pinchart wrote:
> Hi Daniel,
> 
> I've successfully tested the following patch with the rcar-du-drm driver. I'm 
> not sure who else passes a true active_only argument to 
> drm_atomic_helper_commit_planes() out-of-tree so I don't know who you would 
> like to received a Tested-by tag from, but I'll need both your base patch and 
> this fix for my next rcar-du-drm pull request.

I've pulled this one into drm-misc and I plan to send out a pull request
to Dave (now that -rc1 is out) next week sometimes. Then you can just
rebase the rcar parts on top of drm-next.

Thanks, Daniel

> 
> On Friday 11 September 2015 00:07:19 Laurent Pinchart wrote:
> > Since commit "drm/atomic-helper: Add option to update planes only on
> > active crtc" the drm_atomic_helper_commit_planes() function accepts an
> > active_only argument to skip updating planes when the associated CRTC is
> > inactive. Planes being disabled on an active CRTC are incorrectly
> > considered as associated with an inactive CRTC and are thus skipped,
> > preventing any plane disabling update from reaching drivers.
> > 
> > Fix it by checking the state of the CRTC stored in the old plane state
> > for planes being disabled.
> > 
> > Signed-off-by: Laurent Pinchart  > ideasonboard.com>
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c | 24 ++--
> >  1 file changed, 18 insertions(+), 6 deletions(-)
> > 
> > Hi Daniel,
> > 
> > This fixes the patch mentioned in the commit message. Please feel free to
> > squash the fix into the original patch if it's not too late, or take it in
> > your branch otherwise (in which case a Fixes: line might be appropriate).
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c
> > b/drivers/gpu/drm/drm_atomic_helper.c index a067ddb1b443..0aa19fa0a5d5
> > 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -1201,23 +1201,35 @@ void drm_atomic_helper_commit_planes(struct
> > drm_device *dev,
> > 
> > for_each_plane_in_state(old_state, plane, old_plane_state, i) {
> > const struct drm_plane_helper_funcs *funcs;
> > +   bool disabling;
> > 
> > funcs = plane->helper_private;
> > 
> > if (!funcs)
> > continue;
> > 
> > -   if (active_only && !plane_crtc_active(plane->state))
> > -   continue;
> > +   disabling = drm_atomic_plane_disabling(plane, old_plane_state);
> > +
> > +   if (active_only) {
> > +   /*
> > +* Skip planes related to inactive CRTCs. If the plane
> > +* is enabled use the state of the current CRTC. If the
> > +* plane is being disabled use the state of the old
> > +* CRTC to avoid skipping planes being disabled on an
> > +* active CRTC.
> > +*/
> > +   if (!disabling && !plane_crtc_active(plane->state))
> > +   continue;
> > +   if (disabling && !plane_crtc_active(old_plane_state))
> > +   continue;
> > +   }
> > 
> > /*
> >  * Special-case disabling the plane if drivers support it.
> >  */
> > -   if (drm_atomic_plane_disabling(plane, old_plane_state) &&
> > -   funcs->atomic_disable)
> > +   if (disabling && funcs->atomic_disable)
> > funcs->atomic_disable(plane, old_plane_state);
> > -   else if (plane->state->crtc ||
> > -drm_atomic_plane_disabling(plane, old_plane_state))
> > +   else if (plane->state->crtc || disabling)
> > funcs->atomic_update(plane, old_plane_state);
> > }
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> 

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


[PATCH 1/6] scripts/kernel-doc: Replacing highlights hash by an array

2015-09-14 Thread Lukas Wunner
Hi,

On Sun, Sep 13, 2015 at 02:36:47PM -0600, Jonathan Corbet wrote:
> On Mon,  7 Sep 2015 17:01:59 -0300
> Danilo Cesar Lemes de Paula  wrote:
> > The "highlight" code is very sensible to the order of the hash keys,
> > but the order of the keys cannot be predicted. It generates
> > faulty DocBook entries like:
> > - @device_for_each_child
> > 
> > Sorting the result is not enough some times (as it's deterministic but
> > we can't control it).
> > We should use an array for that job, so we can guarantee that the order
> > of the regex execution on dohighlight is correct.
> OK, I've spent a bunch of time with this, comparing the results before
> and after.  The output you mention is clearly wrong, but there might be
> room to differ over what the root cause is.
> 
> That output is caused by @device_for_each_child() in the comments.  This
> happens for a few other functions as well, and I think it's wrong.  @ is
> used to indicate parameters (or structure fields); I'm not sure why
> people are using it for functions that are *not* one of the above.
> Formatting the function names as a parameter doesn't seem right either.

Shouldn't kernel-doc print a warning for syntactic mistakes like this
rather than silently accomodating to it in whatever way?

As to the usage of markdown in general, there's documentation coming up
for vga_switcheroo which makes use of that so I'd love to see it merged:
https://github.com/l1k/linux/commit/d1476d748b5f1adf5bffe8e0a8bafad1e879d22f
https://github.com/l1k/linux/commit/11c55ae65788162970d8fa23cd1fd2518af55d34

The large set of dependencies pulled in on Fedora is likely to be blamed
on the RedHat packaging being notoriously coarse-grained. By comparison,
Debian is extremely fine-grained, kind of the opposite extreme, and
therefore has comparatively few prerequisites:
https://packages.debian.org/jessie/pandoc

I do agree however that alternative tools with fewer dependencies should
be supported and it would be great if the markdown patches were amended
to that end.

Best regards,

Lukas