TILCDC driver - Array to keep register values during PM suspend is too small

2015-07-01 Thread Michael Bode
Hi,

i currently try to write a LIDD version of the TILCDC driver in 
driver/gpu/drm.

During my investigations I found the function "tilcdc_pm_suspend" in 
tilcdc_drv.c:

#ifdef CONFIG_PM_SLEEP
static int tilcdc_pm_suspend(struct device *dev)
{
  .

 /* Save register state: */
 for (i = 0; i < ARRAY_SIZE(registers); i++)
 if (registers[i].save && (priv->rev >= registers[i].rev))
 priv->saved_register[n++] = tilcdc_read(ddev, 
registers[i].reg);

 priv->ctx_valid = true;

 return 0;
}

The member "saved_register" that is filled with register values here is 
an array defined in tilcdc_drv.h:

struct tilcdc_drm_private {
.
 /* register contents saved across suspend/resume: */
 u32 saved_register[12];
 bool ctx_valid;
.

As you can see the size of that array is 12 times u32, so it can keep 12 
register values.

But if you have a look at the register list to be saved, you will find:

#if defined(CONFIG_DEBUG_FS) || defined(CONFIG_PM_SLEEP)
static const struct {
 const char *name;
 uint8_t  rev;
 uint8_t  save;
 uint32_t reg;
} registers[] ={
#define REG(rev, save, reg) { #reg, rev, save, reg }
 /* exists in revision 1: */
 REG(1, false, LCDC_PID_REG),
 REG(1, true,  LCDC_CTRL_REG),
 REG(1, false, LCDC_STAT_REG),
 REG(1, true,  LCDC_RASTER_CTRL_REG),
 REG(1, true,  LCDC_RASTER_TIMING_0_REG),
 REG(1, true,  LCDC_RASTER_TIMING_1_REG),
 REG(1, true,  LCDC_RASTER_TIMING_2_REG),
 REG(1, true,  LCDC_DMA_CTRL_REG),
 REG(1, true,  LCDC_DMA_FB_BASE_ADDR_0_REG),
 REG(1, true,  LCDC_DMA_FB_CEILING_ADDR_0_REG),
 REG(1, true,  LCDC_DMA_FB_BASE_ADDR_1_REG),
 REG(1, true,  LCDC_DMA_FB_CEILING_ADDR_1_REG),
 /* new in revision 2: */
 REG(2, false, LCDC_RAW_STAT_REG),
 REG(2, false, LCDC_MASKED_STAT_REG),
 REG(2, false, LCDC_INT_ENABLE_SET_REG),
 REG(2, false, LCDC_INT_ENABLE_CLR_REG),
 REG(2, false, LCDC_END_OF_INT_IND_REG),
 REG(2, true,  LCDC_CLK_ENABLE_REG),
 REG(2, true,  LCDC_INT_ENABLE_SET_REG),
#undef REG
};
#endif

And if I count correctly in case you have an LCDC Revision 2, there will 
be 19 registers saved to the array.
So probably you will write over the end of that array.

I hope the form of my post fits the posting rules of this forum. If not, 
sorry. It is my very first post!

Br,
Michael


[PATCH v2 01/12] drm: panel: Add a new private mode flag: DRM_PANEL_FLAG_PREFER_ONE_SHOT

2015-07-01 Thread Mark Zhang
On 07/01/2015 04:54 PM, Daniel Vetter wrote:
> On Wed, Jul 01, 2015 at 04:21:44PM +0800, Mark Zhang wrote:
>> Normally this flag is set by panel driver so that crtc can enable
>> the "one-shot" mode(not scan frames continuously).
>>
>> Signed-off-by: Mark Zhang 
>> ---
>>  include/drm/drm_panel.h |2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
>> index 13ff44b28893..4d51cb380c75 100644
>> --- a/include/drm/drm_panel.h
>> +++ b/include/drm/drm_panel.h
>> @@ -26,6 +26,8 @@
>>  
>>  #include 
>>  
>> +#define DRM_PANEL_FLAG_PREFER_ONE_SHOT  (1 << 0)
> 
> This is a panel property, not a mode property. I think it would be much
> better to put this directly into the panel struct, or maybe the dsi sink
> device stuff or wherever. But mode really doesn't have anything to do how
> exactly the pixels get to the panel.

Yeah, we've talked about this in patch set v1. I think putting this in
drm_display_mode->private_flags already makes things better. If we want
to completely remove this in drm_display_mode, I think we need to create
some mechanism which panel can use to notify crtc to enable the one-shot
mode, or crtc is able to send out a query, if somebody answers, one-shot
will be enabled.

Mark
> -Daniel
> 


[PATCH v2 12/12] JUST FOR TEST: Add one-shot trigger to update display

2015-07-01 Thread Mark Zhang
On 07/01/2015 04:46 PM, Daniel Vetter wrote:
> On Wed, Jul 01, 2015 at 10:36:17AM +0200, Daniel Vetter wrote:
>> On Wed, Jul 01, 2015 at 04:21:55PM +0800, Mark Zhang wrote:
>>> This HACK adds a workqueue to refresh the display periodically.
>>> This is used just for testing.
>>
>> ->dirty is the drm hook you're looking for, it's meant to flush out any
>> frontbuffer rendering. Generic kms clients using the dumb buffers (e.g.
>> fedora boot splash) use this already.
>>
>> And of course you need to upload a new frame every time an (atomic) flip
>> happens too, but I guess you have that already. No need at all for a
>> periodic upload hack like this.
> 
> btw the nice thing with dirty is that it hands you the exact invalidation
> rectangle, which means you can minimize uploads. For atomic flips we plan
> to have the same, but it's not implemented yet.
> 
> Another problem is that currently the fbdev helper in drm_fb_helper.c
> doesn't support the dirty callback. But there's other drivers which need
> this too (e.g. i915 will gain a dirty callback soon) and qxl has all the
> code implemented already. So the only thing you need to do is move the qxl
> code into drm_fb_helper.c and adapt it to use the dirty callback instead
> of directly calling qxl code. Then you should be all set. Note that simply
> calling ->dirty from fbdev hooks doesn't work since a lot of those hooks
> are called from irq context (cursors and stuff) and hence you need a
> workqueue to do the actual dirty call.
> 

I got it. So this is the kernel part I need. Thanks.

Mark
> Cheers, Daniel
> 


[PATCH v2 12/12] JUST FOR TEST: Add one-shot trigger to update display

2015-07-01 Thread Mark Zhang
On 07/01/2015 06:34 PM, Daniel Vetter wrote:
> On Wed, Jul 01, 2015 at 05:01:52PM +0800, Mark Zhang wrote:
>> On 07/01/2015 04:36 PM, Daniel Vetter wrote:
>>> On Wed, Jul 01, 2015 at 04:21:55PM +0800, Mark Zhang wrote:
 This HACK adds a workqueue to refresh the display periodically.
 This is used just for testing.
>>>
>>> ->dirty is the drm hook you're looking for, it's meant to flush out any
>>> frontbuffer rendering. Generic kms clients using the dumb buffers (e.g.
>>> fedora boot splash) use this already.
>>>
>>
>> Oh... I did a grep in drm source and are you talking about
>> "drm_framebuffer_funcs->dirty"? Yeah, that should work for me.. but that
>> requires userspace sending IOCTL to trigger, right? Honestly I'm lazy so
>> I created this HACK so that I don't need userspace to test.
> 
> Yeah userspace needs to send ioctl already after each drawing. Generic
> userspace does that already since it's required by qxl, udl, soon i915 and
> probably a few others too. fbdev emulation is more annyoing but there's
> code to move around in these drivers (qxl seems best to me as a starting
> point) too.
> 

Alright, this makes sense. I have no idea about qxl, what I have now is
an ubuntu running on Tegra114. So I'm wondering what I suppose to do is
installing qemu on the ubuntu?

Mark

> Imo without this you shouldn't merge one-shot, at least not enabled by
> default.
> -Daniel
> 


[PATCH 2/2] drm/exynos: gsc: Handles the combination of rotation and flip

2015-07-01 Thread Hyungwon Hwang
The unique results of all the combination of rotation and flip can
be represented by just 8 states. This patch handles all the combination
correctly.

Signed-off-by: Hyungwon Hwang 
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index f1c6b76..808a0a0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -582,9 +582,17 @@ static int gsc_src_set_transf(struct device *dev,
break;
case EXYNOS_DRM_DEGREE_180:
cfg |= GSC_IN_ROT_180;
+   if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+   cfg &= ~GSC_IN_ROT_XFLIP;
+   if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+   cfg &= ~GSC_IN_ROT_YFLIP;
break;
case EXYNOS_DRM_DEGREE_270:
cfg |= GSC_IN_ROT_270;
+   if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+   cfg &= ~GSC_IN_ROT_XFLIP;
+   if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+   cfg &= ~GSC_IN_ROT_YFLIP;
break;
default:
dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
@@ -845,9 +853,17 @@ static int gsc_dst_set_transf(struct device *dev,
break;
case EXYNOS_DRM_DEGREE_180:
cfg |= GSC_IN_ROT_180;
+   if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+   cfg &= ~GSC_IN_ROT_XFLIP;
+   if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+   cfg &= ~GSC_IN_ROT_YFLIP;
break;
case EXYNOS_DRM_DEGREE_270:
cfg |= GSC_IN_ROT_270;
+   if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+   cfg &= ~GSC_IN_ROT_XFLIP;
+   if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+   cfg &= ~GSC_IN_ROT_YFLIP;
break;
default:
dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
-- 
1.9.1



[PATCH 1/2] drm/exynos: gsc: fix wrong bitwise operation for swap detection

2015-07-01 Thread Hyungwon Hwang
The bits for rotation are not used as exclusively. So GSC_IN_ROT_270 can
not be used for swap detection. The definition of it is same with
GSC_IN_ROT_MASK. It is enough to check GSC_IN_ROT_90 bit is set or not to
check whether width / height size swapping is needed.

Signed-off-by: Hyungwon Hwang 
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 8040ed2..f1c6b76 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -593,8 +593,7 @@ static int gsc_src_set_transf(struct device *dev,

gsc_write(cfg, GSC_IN_CON);

-   ctx->rotation = cfg &
-   (GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
+   ctx->rotation = (cfg & GSC_IN_ROT_90) ? 1 : 0;
*swap = ctx->rotation;

return 0;
@@ -857,8 +856,7 @@ static int gsc_dst_set_transf(struct device *dev,

gsc_write(cfg, GSC_IN_CON);

-   ctx->rotation = cfg &
-   (GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
+   ctx->rotation = (cfg & GSC_IN_ROT_90) ? 1 : 0;
*swap = ctx->rotation;

return 0;
-- 
1.9.1



[PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized

2015-07-01 Thread Emil Velikov
On 1 July 2015 at 18:37, Ilia Mirkin  wrote:
> On Wed, Jul 1, 2015 at 1:18 PM, Colin Ian King  
> wrote:
>> On 01/07/15 18:12, Emil Velikov wrote:
>>> On 1 July 2015 at 17:56, Ilia Mirkin  wrote:
 On Wed, Jul 1, 2015 at 12:51 PM, Colin King  
 wrote:
> From: Colin Ian King 
>
> Various usif_ioctl helper functions do not initialize the
> return variable ret and some of the error handling return
> paths just return garbage values that were on the stack (or
> in a register).  I believe that in all the cases, the
> initial ret variable should be set to -EINVAL and subsequent
> paths through these helper functions set it appropriately
> otherwise.
>
> Found via static analysis using cppcheck:
>
> [drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
> (error) Uninitialized variable: ret

 It sure would seem that way, wouldn't it?

 #define nvif_unpack(d,vl,vh,m) ({  
 \
 if ((vl) == 0 || ret == -ENOSYS) { 
 \
 int _size = sizeof(d); 
 \
 if (_size <= size && (d).version >= (vl) &&
 \
  (d).version <= (vh)) {
 \
 data = (u8 *)data + _size; 
 \
 size = size - _size;   
 \
 ret = ((m) || !size) ? 0 : -E2BIG; 
 \
 } else {   
 \
 ret = -ENOSYS; 
 \
 }  
 \
 }  
 \
 (ret == 0);
 \
 })

 So actually it does get initialized, and I guess cppcheck doesn't know
 about macros?
>>
>> Hrm, what about the case when ((vl) == 0 || ret == -ENOSYS) is false,
>> where is ret being set in that case?
>
> Is that actually the case for any of the callsites? gcc would complain
> about that...
There is one:

drm/nouveau/nvkm/engine/disp/nv50.c: if (nvif_unpack(args->v1, 1, 1, true))

Seems like a recent addition though,  I don't recall it with back when
was introduced.

-Emil


[PATCH v2 11/12] ASoC: tegra: register dependency parser for firmware nodes

2015-07-01 Thread Mark Brown
On Wed, Jul 01, 2015 at 11:41:06AM +0200, Tomeu Vizoso wrote:

> +static void tegra_max98090_get_dependencies(struct fwnode_handle *fwnode,
> + struct list_head *deps)
> +{
> + add_dependency(fwnode, "nvidia,i2s-controller", deps);
> + add_dependency(fwnode, "nvidia,audio-codec", deps);
> +}

Why is this all being open coded in an individual driver (we already
know about and manage all these dependencies in the core...)?  If we're
going to do this I'd expect the interface for specifying DT nodes to the
core to be changed to support this.
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20150701/2c5a6bc4/attachment.sig>


[Bug 82186] [r600g] BARTS GPU lockup with minecraft shaders

2015-07-01 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=82186

--- Comment #10 from MirceaKitsune  ---
Alright, I finished testing the 3 problematic games which this bug affected for
me, to see how they behave with R600_DEBUG=notiling enabled. I don't use
shaders for MineCraft so I can't test them specifically, although we're
obviously talking about the same issue so this is still relevant. My results
are:

Second Life: No more GPU freeze when Advanced Lighting is enabled! This was one
of the most immediate triggers for the issue in my case, and in most scenarios
it immediately brought down the X server... now there is not a single hiccup.

Stunt Rally: No more freezes when enabling shaders! In its case however the
problem is more probabilistic, so this isn't 100% guaranteed.

One Late Night: The crash still exists, even with notiling. So there are still
cases where this variable does not solve the problem, although in most engines
it does and I'm happy enough with that for the time being.

-- 
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/20150701/e74622cb/attachment.html>


[Bug 73528] Deferred lighting in Second Life causes system hiccups and screen flickering

2015-07-01 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=73528

MirceaKitsune  changed:

   What|Removed |Added

   Severity|critical|major

--- Comment #33 from MirceaKitsune  ---
At last, I found a partial workaround! More precisely, the solution was posted
in #82186 by MWATTT. I must simply export the following environment variable:

R600_DEBUG=notiling

I can confirm that with this, I can freely enable all shaders in Second Life
and get no crash for the first time. Stunt Rally also seems to no longer cause
the freezes. However, the new game that I posted about in the above comment
(One Late Night) still produces the freeze even with this enabled.

Until the problem is fixed in the code, I will add this to my ~./profile file.
Does it disable anything important? I'm also setting the bug back from Urgent
to Major, since at least now there is now an acceptable solution to prevent it
in most cases.

-- 
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/20150701/ae2ab906/attachment-0001.html>


[PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized

2015-07-01 Thread Colin Ian King
On 01/07/15 18:12, Emil Velikov wrote:
> On 1 July 2015 at 17:56, Ilia Mirkin  wrote:
>> On Wed, Jul 1, 2015 at 12:51 PM, Colin King  
>> wrote:
>>> From: Colin Ian King 
>>>
>>> Various usif_ioctl helper functions do not initialize the
>>> return variable ret and some of the error handling return
>>> paths just return garbage values that were on the stack (or
>>> in a register).  I believe that in all the cases, the
>>> initial ret variable should be set to -EINVAL and subsequent
>>> paths through these helper functions set it appropriately
>>> otherwise.
>>>
>>> Found via static analysis using cppcheck:
>>>
>>> [drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
>>> (error) Uninitialized variable: ret
>>
>> It sure would seem that way, wouldn't it?
>>
>> #define nvif_unpack(d,vl,vh,m) ({
>>   \
>> if ((vl) == 0 || ret == -ENOSYS) {   
>>   \
>> int _size = sizeof(d);   
>>   \
>> if (_size <= size && (d).version >= (vl) &&  
>>   \
>>  (d).version <= (vh)) {  
>>   \
>> data = (u8 *)data + _size;   
>>   \
>> size = size - _size; 
>>   \
>> ret = ((m) || !size) ? 0 : -E2BIG;   
>>   \
>> } else { 
>>   \
>> ret = -ENOSYS;   
>>   \
>> }
>>   \
>> }
>>   \
>> (ret == 0);  
>>   \
>> })
>>
>> So actually it does get initialized, and I guess cppcheck doesn't know
>> about macros?

Hrm, what about the case when ((vl) == 0 || ret == -ENOSYS) is false,
where is ret being set in that case?

>>
> I think I'm having deja-vu, but I do recall a similar mention to Ben.
> Although in my defence I've assumed that nvif_unpack was a function,
> as macros normally are normally all caps. Seems like the patch that
> capitalises nvif_unpack never made it upstream :'-(
> 
> Cheers,
> Emil
> 



[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Tomasz Figa
On Wed, Jul 1, 2015 at 6:13 PM, Mark yao  wrote:
 By the way, if we're using window 3 for cursor plane, because the
 cursor window needs special handling, is it okay to expose the cusor
 window as an overlay plane to userspace, as we do currently?
>>>
>>>
>>> special handling? what means? "switch cursor plane to window 3" patch
>>> only
>>> switch cursor
>>>   windows from win1 to win3. tag window 3 as DRM_PLANE_TYPE_CURSOR,
>>> userspace
>>> only
>>> can found window 3 is a cursor plane.
>>>
>> Ah, this was a question slightly unrelated to that patch, but I just
>> noticed in that patch that the hardware cursor window is still exposed
>> to the userspace as overlay plane, even if it's not quite suitable for
>> being such.
>
>
> Oh, I know your mean, you mean that code:
> { .base = 0x00, .phy = &cursor_data, .type = DRM_PLANE_TYPE_OVERLAY
> },
>
> right?
>
> That is I plan to do.
>
> hardware cursor window have a problem that hard to resolved.
> the window can't support width virtual and can't move out of left top top.
> But linux desktop or chromiumos should move cursor out of left or top.
>
> I'm considering remove it or find a another way to reuse it.

I think we should remove it for now, because I believe this breaks
applications that enumerate all available planes and use them for
hardware compose. Otherwise they will try to use the hardware cursor
window and will fail, because hardware cursor window has quite strict
requirements.

Best regards,
Tomasz


[PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized

2015-07-01 Thread Emil Velikov
On 1 July 2015 at 17:56, Ilia Mirkin  wrote:
> On Wed, Jul 1, 2015 at 12:51 PM, Colin King  
> wrote:
>> From: Colin Ian King 
>>
>> Various usif_ioctl helper functions do not initialize the
>> return variable ret and some of the error handling return
>> paths just return garbage values that were on the stack (or
>> in a register).  I believe that in all the cases, the
>> initial ret variable should be set to -EINVAL and subsequent
>> paths through these helper functions set it appropriately
>> otherwise.
>>
>> Found via static analysis using cppcheck:
>>
>> [drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
>> (error) Uninitialized variable: ret
>
> It sure would seem that way, wouldn't it?
>
> #define nvif_unpack(d,vl,vh,m) ({ 
>  \
> if ((vl) == 0 || ret == -ENOSYS) {
>  \
> int _size = sizeof(d);
>  \
> if (_size <= size && (d).version >= (vl) &&   
>  \
>  (d).version <= (vh)) {   
>  \
> data = (u8 *)data + _size;
>  \
> size = size - _size;  
>  \
> ret = ((m) || !size) ? 0 : -E2BIG;
>  \
> } else {  
>  \
> ret = -ENOSYS;
>  \
> } 
>  \
> } 
>  \
> (ret == 0);   
>  \
> })
>
> So actually it does get initialized, and I guess cppcheck doesn't know
> about macros?
>
I think I'm having deja-vu, but I do recall a similar mention to Ben.
Although in my defence I've assumed that nvif_unpack was a function,
as macros normally are normally all caps. Seems like the patch that
capitalises nvif_unpack never made it upstream :'-(

Cheers,
Emil


[PATCH libdrm v2 1/2] intel: Add EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag.

2015-07-01 Thread Emil Velikov
Hi Michel,

Although I cannot comment on the exact implementation I can give you
general some tips which you might find useful.

On 1 July 2015 at 16:28, 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 Intruction State Heap (ISH) must be in a
> 32-bit range, because the General State Offset and Instruction State Offset
> are limited to 32-bits.
>
> Provide a flag to set when the 4GB limit is not necessary in a given bo.
> 48-bit range will only be used when explicitly requested.
>
> Calls to the new drm_intel_bo_emit_reloc_48bit function will have this flag
> set automatically, while calls to drm_intel_bo_emit_reloc will clear it.
>
> v2: Make set/clear functions nops on pre-gen8 platforms, and use them
> internally in emit_reloc functions (Ben)
> s/48BADDRESS/48B_ADDRESS/ (Dave)
>
> Cc: Ben Widawsky 
> Cc: Dave Gordon 
> Cc: dri-devel at lists.freedesktop.org
> Signed-off-by: Michel Thierry 
> ---
>  include/drm/i915_drm.h|  3 ++-
>  intel/intel_bufmgr.c  | 24 +
>  intel/intel_bufmgr.h  |  8 ++-
>  intel/intel_bufmgr_gem.c  | 54 
> +++
>  intel/intel_bufmgr_priv.h | 11 ++
>  5 files changed, 94 insertions(+), 6 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)
Perhaps you already know this but changes like these go in _after_ the
updated kernel header is part of linux-next or a released kernel
version.

> __u64 flags;
>
> __u64 rsvd1;
> diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
> index 14ea9f9..590a855 100644
> --- a/intel/intel_bufmgr.c
> +++ b/intel/intel_bufmgr.c
> @@ -188,6 +188,18 @@ drm_intel_bufmgr_check_aperture_space(drm_intel_bo ** 
> bo_array, int count)
> return bo_array[0]->bufmgr->check_aperture_space(bo_array, count);
>  }
>
> +void drm_intel_bo_set_supports_48b_address(drm_intel_bo *bo)
> +{
> +   if (bo->bufmgr->bo_set_supports_48b_address)
> +   bo->bufmgr->bo_set_supports_48b_address(bo);
> +}
> +
> +void drm_intel_bo_clear_supports_48b_address(drm_intel_bo *bo)
> +{
> +   if (bo->bufmgr->bo_clear_supports_48b_address)
> +   bo->bufmgr->bo_clear_supports_48b_address(bo);
> +}
> +
>  int
>  drm_intel_bo_flink(drm_intel_bo *bo, uint32_t * name)
>  {
> @@ -202,6 +214,18 @@ drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t 
> offset,
> drm_intel_bo *target_bo, uint32_t target_offset,
> uint32_t read_domains, uint32_t write_domain)
>  {
> +   drm_intel_bo_clear_supports_48b_address(target_bo);
> +   return bo->bufmgr->bo_emit_reloc(bo, offset,
> +target_bo, target_offset,
> +read_domains, write_domain);
> +}
> +
> +int
> +drm_intel_bo_emit_reloc_48bit(drm_intel_bo *bo, uint32_t offset,
> +   drm_intel_bo *target_bo, uint32_t target_offset,
> +   uint32_t read_domains, uint32_t write_domain)
> +{
> +   drm_intel_bo_set_supports_48b_address(target_bo);
> return bo->bufmgr->bo_emit_reloc(bo, offset,
>  target_bo, target_offset,
>  read_domains, write_domain);
> diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
> index 285919e..62480cb 100644
> --- a/intel/intel_bufmgr.h
> +++ b/intel/intel_bufmgr.h
> @@ -87,7 +87,8 @@ struct _drm_intel_bo {
> /**
>  * Last seen card virtual address (offset from the beginning of the
>  * aperture) for the object.  This should be used to fill relocation
> -* entries when calling drm_intel_bo_emit_reloc()
> +* entries when calling drm_intel_bo_emit_reloc() or
> +* drm_intel_bo_emit_reloc_48bit()
>  */
> uint64_t offset64;
>  };
> @@ -137,6 +138,8 @@ void drm_intel_bo_wait_rendering(drm_intel_bo *bo);
>
>  void drm_intel_bufmgr_set_debug(drm_intel_bufmgr *bufmgr, int enable_debug);
>  void drm_intel_bufmgr_destroy(drm_intel_bufmgr *bufmgr);
> +void drm_intel_bo_set_supports_48b_address(drm_intel_bo *bo);
> +void drm_intel_bo_clear_supports_48b_address(drm_intel_bo *bo);
Are these two are internal/implementation specific functions ? If so
please don't include them in this public heade

[Bug 82186] [r600g] BARTS GPU lockup with minecraft shaders

2015-07-01 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=82186

--- Comment #9 from MirceaKitsune  ---
Argh, I wish I could have found this report earlier! I discovered it by doing a
Google search on commit edbbfac6cfc634e697d7f981155a5072c52d77ac which
introduced the exact same lockup for my video card. I've been maintaining the
following report for years now, about the same bug apparently:

https://bugs.freedesktop.org/show_bug.cgi?id=73528

So from what I understand, setting R600_DEBUG=notiling should prevent
fast-clear from freezing the GPU? I will gladly try this for Second Life and
other programs that trigger the problem, and see if there are any changes.

-- 
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/20150701/ffa82daf/attachment.html>


[Intel-gfx] [PATCH] drm/i915: Clear pipe's pll hw state in hsw_dp_set_ddi_pll_sel()

2015-07-01 Thread Ander Conselvan De Oliveira
On Tue, 2015-06-30 at 18:41 +0300, Jani Nikula wrote:
> On Tue, 30 Jun 2015, Daniel Vetter  wrote:
> > On Tue, Jun 30, 2015 at 04:47:06PM +0300, Jani Nikula wrote:
> >> On Tue, 30 Jun 2015, Ander Conselvan de Oliveira 
> >>  wrote:
> >> > Similarly to what is done for SKL, clear the dpll_hw_state of the pipe
> >> > config in hsw_dp_set_ddi_pll_sel(), since it main contain stale values.
> >> > That can happen if a crtc that was previously driving an HDMI connector
> >> > switches to a DP connector. In that case, the wrpll field was left with
> >> > its old value, leading to warnings like the one below:
> >> >
> >> > [drm:check_crtc_state [i915]] *ERROR* mismatch in dpll_hw_state.wrpll 
> >> > (expected 0xb035061f, found 0x)
> >> > [ cut here ]
> >> > WARNING: CPU: 1 PID: 767 at drivers/gpu/drm/i915/intel_display.c:12324 
> >> > check_crtc_state+0x975/0x10b0 [i915]()
> >> > pipe state doesn't match!
> >> >
> >> > This regression was indroduced in
> >> >
> >> > commit dd3cd74acf12723045a64f1f2c6298ac7b34a5d5
> >> > Author: Ander Conselvan de Oliveira  >> > intel.com>
> >> > Date:   Fri May 15 13:34:29 2015 +0300
> >> >
> >> > drm/i915: Don't overwrite (e)DP PLL selection on SKL
> >> >
> >> > Signed-off-by: Ander Conselvan de Oliveira  >> > at intel.com>
> >> 
> >> Reported-by: Linus Torvalds 
> >> Tested-by: Jani Nikula 
> >
> > Yeah makes sense as a fix for 4.2. But for 4.3 I wonder whether the
> > original commit that started this chain needs to be changed a bit:
> >
> > commit 4978cc93d9ac240b435ce60431aef24239b4c270
> > Author: Ander Conselvan de Oliveira  > intel.com>
> > Date:   Tue Apr 21 17:13:21 2015 +0300
> >
> > drm/i915: Preserve shared DPLL information in new pipe_config
> >
> > All the trouble this caused is because it not only preserves the sharing
> > config (in crtc_state->shared_dpll) but also the ->dpll_hw_state. And I
> > think with Maarten's latest code (for 4.3) we'd just do an unconditional
> > compute_config (need it for fast pfit updates and fastboot), which means
> > the bogus values in ->dpll_hw_state aren't a problem any more since we'll
> > overwrite them again. And then we could remove that sprinkle of memsets we
> > have all over, which would be good (since the current approach is
> > obviously a bit fragile). Anyway:
> >
> > Reviewed-by: Daniel Vetter 
> 
> Pushed to drm-intel-next-fixes, thanks for the patch and review. One
> down, another one left to fix.

I made some progress on the second issue, but I'm afraid Jani might have
a found a third bug. The warning he gets happens because we try to wait
for vblanks while updating the primary plane during the modeset. At that
point, the crtc is off. The problem is in intel_check_primary_plane(),
which is called from drm_atomic_helper_check_planes(). That function
makes decisions about waiting for a vblank based on intel_crtc->active.
Since the check is called before we disable the crtcs, active might be
true, even though the plane update is done with crtcs disable.

The patch below makes the warning go away, but I still need to figure
out how to set crtc_state->planes_changed properly if we are going down
that route.

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index dcb1d25..f14727c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12480,10 +12480,6 @@ intel_modeset_compute_config(struct drm_crtc *crtc,

intel_dump_pipe_config(to_intel_crtc(crtc), pipe_config,"[modeset]");

-   ret = drm_atomic_helper_check_planes(state->dev, state);
-   if (ret)
-   return ERR_PTR(ret);
-
return pipe_config;
 }


The backtrace on Linus' machine is different, though. It comes from the
call to intel_crtc_disable_planes() in __intel_set_mode(). That would
indicate we have a crtc with crtc->state->enable == true but that is
actually inactive. I'm still not sure how we can get in that state.

Ander



[PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized

2015-07-01 Thread Colin King
From: Colin Ian King 

Various usif_ioctl helper functions do not initialize the
return variable ret and some of the error handling return
paths just return garbage values that were on the stack (or
in a register).  I believe that in all the cases, the
initial ret variable should be set to -EINVAL and subsequent
paths through these helper functions set it appropriately
otherwise.

Found via static analysis using cppcheck:

[drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
(error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:179]:
(error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:202]:
(error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:241]:
(error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:157]:
(error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:288]:
(error) Uninitialized variable: ret

Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/nouveau/nouveau_usif.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c 
b/drivers/gpu/drm/nouveau/nouveau_usif.c
index cb1182d..01b50a2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -129,7 +129,7 @@ usif_notify_new(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct nvif_notify_req_v0 v0;
} *req;
struct usif_notify *ntfy;
-   int ret;
+   int ret = -EINVAL;

if (nvif_unpack(args->v0, 0, 0, true)) {
if (usif_notify_find(f, args->v0.index))
@@ -170,7 +170,7 @@ usif_notify_del(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct nvif_ioctl_ntfy_del_v0 v0;
} *args = data;
struct usif_notify *ntfy;
-   int ret;
+   int ret = -EINVAL;

if (nvif_unpack(args->v0, 0, 0, true)) {
if (!(ntfy = usif_notify_find(f, args->v0.index)))
@@ -193,7 +193,7 @@ usif_notify_get(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct nvif_ioctl_ntfy_del_v0 v0;
} *args = data;
struct usif_notify *ntfy;
-   int ret;
+   int ret = -EINVAL;

if (nvif_unpack(args->v0, 0, 0, true)) {
if (!(ntfy = usif_notify_find(f, args->v0.index)))
@@ -232,7 +232,7 @@ usif_notify_put(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct nvif_ioctl_ntfy_put_v0 v0;
} *args = data;
struct usif_notify *ntfy;
-   int ret;
+   int ret = -EINVAL;

if (nvif_unpack(args->v0, 0, 0, true)) {
if (!(ntfy = usif_notify_find(f, args->v0.index)))
@@ -269,7 +269,7 @@ usif_object_new(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct nvif_ioctl_new_v0 v0;
} *args = data;
struct usif_object *object;
-   int ret;
+   int ret = -EINVAL;

if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
return -ENOMEM;
-- 
2.1.4



[PATCH] drm/rockchip: vop: remove hardware cursor window

2015-07-01 Thread Mark Yao
hardware cursor windows only have some fixed size, and not support
width virtual, when move hardware cursor windows outside of left,
the display would be wrong, so this window can't for cursor now.

And Tag hardware cursor window as a overlay is wrong, will make
userspace wrong behaviour.

So just remove the hardware cursor window

Signed-off-by: Mark Yao 
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 4603412..7373ba1 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -368,7 +368,6 @@ static const struct vop_win_data rk3288_vop_win_data[] = {
{ .base = 0x40, .phy = &win01_data, .type = DRM_PLANE_TYPE_OVERLAY },
{ .base = 0x00, .phy = &win23_data, .type = DRM_PLANE_TYPE_OVERLAY },
{ .base = 0x50, .phy = &win23_data, .type = DRM_PLANE_TYPE_CURSOR },
-   { .base = 0x00, .phy = &cursor_data, .type = DRM_PLANE_TYPE_OVERLAY },
 };

 static const struct vop_data rk3288_vop = {
-- 
1.7.9.5




[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Tomasz Figa
On Wed, Jul 1, 2015 at 5:32 PM, Mark yao  wrote:
> On 2015年07月01日 16:03, Tomasz Figa wrote:
>>
>> Hi Mark,
>>
>> On Tue, Jun 30, 2015 at 3:50 PM, Mark yao  wrote:
>>>
>>> Hi Dave.
>>>
>>>  Some fixes and some new features. I'd like you can pull them.
>>>
>>> The following changes since commit
>>> c5fd936e992dd2829167d2adc63e151675ca6898:
>>>
>>>drm/nouveau: Pause between setting gpu to D3hot and cutting the power
>>> (2015-06-26 10:26:37 +1000)
>>>
>>> are available in the git repository at:
>>>
>>>https://github.com/markyzq/kernel-drm-rockchip.git
>>> drm-rockchip-2015-06-30
>>>
>>> for you to fetch changes up to 5295c05eb30d743987172853179333c80b8242bc:
>>>
>>>drm/rockchip: default enable win2/3 area0 bit (2015-06-30 14:24:10
>>> +0800)
>>>
>>> 
>>> Heiko Stübner (1):
>>>drm/rockchip: only call drm_fb_helper_hotplug_event if fb_helper
>>> present
>>>
>>> Mark Yao (6):
>>>drm/rockchip: import dma_buf to gem
>>>drm/rockchip: vop: optimize virtual stride calculate
>>>drm/rockchip: vop: fix yuv plane support
>>>drm/rockchip: vop: support plane scale
>>>drm/rockchip: vop: switch cursor plane to window 3
>>>drm/rockchip: default enable win2/3 area0 bit
>>
>> Has this series been reviewed properly? I can see that at least
>> "drm/rockchip: vop: support plane scale" is kind of "controversial".
>
>
> Sorry for that, can you review those patches, and give me some advices?
>
> https://lkml.org/lkml/2015/6/18/77
> v2: https://lkml.org/lkml/2015/6/26/192
>

Yes, will do that.

By the way, please feel free to ping patches on the lists if they idle
without any comments or tags for while.

>> By the way, if we're using window 3 for cursor plane, because the
>> cursor window needs special handling, is it okay to expose the cusor
>> window as an overlay plane to userspace, as we do currently?
>
>
> special handling? what means? "switch cursor plane to window 3" patch only
> switch cursor
>  windows from win1 to win3. tag window 3 as DRM_PLANE_TYPE_CURSOR, userspace
> only
> can found window 3 is a cursor plane.
>

Ah, this was a question slightly unrelated to that patch, but I just
noticed in that patch that the hardware cursor window is still exposed
to the userspace as overlay plane, even if it's not quite suitable for
being such.

Best regards,
Tomasz


[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Tomasz Figa
On Wed, Jul 1, 2015 at 5:20 PM, Daniel Vetter  wrote:
> On Wed, Jul 01, 2015 at 05:03:39PM +0900, Tomasz Figa wrote:
>> Hi Mark,
>>
>> On Tue, Jun 30, 2015 at 3:50 PM, Mark yao  wrote:
>> >
>> > Hi Dave.
>> >
>> > Some fixes and some new features. I'd like you can pull them.
>> >
>> > The following changes since commit 
>> > c5fd936e992dd2829167d2adc63e151675ca6898:
>> >
>> >   drm/nouveau: Pause between setting gpu to D3hot and cutting the power 
>> > (2015-06-26 10:26:37 +1000)
>> >
>> > are available in the git repository at:
>> >
>> >   https://github.com/markyzq/kernel-drm-rockchip.git 
>> > drm-rockchip-2015-06-30
>> >
>> > for you to fetch changes up to 5295c05eb30d743987172853179333c80b8242bc:
>> >
>> >   drm/rockchip: default enable win2/3 area0 bit (2015-06-30 14:24:10 +0800)
>> >
>> > 
>> > Heiko Stübner (1):
>> >   drm/rockchip: only call drm_fb_helper_hotplug_event if fb_helper 
>> > present
>> >
>> > Mark Yao (6):
>> >   drm/rockchip: import dma_buf to gem
>> >   drm/rockchip: vop: optimize virtual stride calculate
>> >   drm/rockchip: vop: fix yuv plane support
>> >   drm/rockchip: vop: support plane scale
>> >   drm/rockchip: vop: switch cursor plane to window 3
>> >   drm/rockchip: default enable win2/3 area0 bit
>>
>> Has this series been reviewed properly? I can see that at least
>> "drm/rockchip: vop: support plane scale" is kind of "controversial".
>
> I don't see any discussion of this patch at all on dri-devel, where's this
> controversy?

Well, it adds a lot of seemingly complex, hard to read code with
obvious style issues. I'll review the series later this week.

Best regards,
Tomasz


[PATCH] drm/ttm: recognize ARM64 arch in ioprot handler

2015-07-01 Thread Alexandre Courbot
Return proper pgprot for ARM64. This is required for objects like
Nouveau fences to be mapped with expected coherency.

Signed-off-by: Alexandre Courbot 
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 882cccdad272..ac6fe40b99f7 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -490,7 +490,8 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp)
else if (boot_cpu_data.x86 > 3)
tmp = pgprot_noncached(tmp);
 #endif
-#if defined(__ia64__) || defined(__arm__) || defined(__powerpc__)
+#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \
+defined(__powerpc__)
if (caching_flags & TTM_PL_FLAG_WC)
tmp = pgprot_writecombine(tmp);
else
-- 
2.4.4



[pull] radeon and amdgpu drm-next-4.2

2015-07-01 Thread Alex Deucher
Hi Dave,

First round of fixes for 4.2 for radeon and amdgpu.  Stuff all over the
place:
- hibernation, suspend fixes for radeon and amdgpu
- radeon audio fix
- amdgpu ioctl optimzations and fixes
- amdgpu VCE cs checker improvements
- misc bug fixes

The following changes since commit c5fd936e992dd2829167d2adc63e151675ca6898:

  drm/nouveau: Pause between setting gpu to D3hot and cutting the power 
(2015-06-26 10:26:37 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~agd5f/linux drm-next-4.2

for you to fetch changes up to 479e9a95120aaae0bf0d3e0b5b26b36ac4a347b6:

  drm/radeon: only check the sink type on DP connectors (2015-06-30 09:30:01 
-0400)


Alex Deucher (4):
  drm/amdgpu: fix hpd range check in dce_v8_0_hpd_irq()
  drm/amdgpu: allocate ip_block_enabled memory in common code
  Revert "drm/radeon: dont switch vt on suspend"
  drm/radeon: only check the sink type on DP connectors

Alexander Kuleshov (1):
  gpu/drm/amdgpu: Fix build when CONFIG_DEBUG_FS is not set

Ben Goz (2):
  drm/amdgpu: Initialize compute sdma and memory from kgd
  drm/amdgpu: Configure doorbell to maximum slots

Christian König (14):
  drm/amdgpu: simplify fence debugfs output a bit
  drm/amdgpu: add BO map/unmap trace point
  drm/amdgpu: add amdgpu_bo_list_set trace point
  drm/amdgpu: print the bo_list in the CS trace point as well
  drm/amdgpu: silence invalid error message
  drm/amdgpu: check VCE relocation buffer range
  drm/amdgpu: make VCE handle check more strict
  drm/amdgpu: check VCE feedback and bitstream index
  drm/amdgpu: fix crash on invalid CS IOCTL
  drm/amdgpu: add chunk id validity check
  drm/radeon: fix adding all VAs to the freed list on remove v2
  drm/amdgpu: recreate fence from user seq
  drm/amdgpu: add optional dependencies to the CS IOCTL v2
  drm/amdgpu: add flag to delay VM updates

Jérôme Glisse (2):
  drm/radeon: compute ring fix hibernation (CI GPU family) v2.
  drm/radeon: SDMA fix hibernation (CI GPU family).

Maninder Singh (3):
  drm/radeon: use kzalloc for allocating one thing
  drm/amdgpu: use kzalloc for allocating one thing
  drm/amdgpu: remove unnecessary check before kfree

Sonny Jiang (3):
  drm/amdgpu: reset wptr at cp compute resume (v2)
  drm/amdgpu: correct define SMU_EnabledFeatureScoreboard_SclkDpmOn
  drm/amdgpu: disable enable_nb_ps_policy temporarily

monk.liu (1):
  drm/amdgpu: fix wrong type

 drivers/gpu/drm/amd/amdgpu/amdgpu.h |   6 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c |   3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c  |  89 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  |  13 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c   |  45 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c |   8 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h   |  69 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 173 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h |   1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  |   4 +
 drivers/gpu/drm/amd/amdgpu/cik.c|   4 -
 drivers/gpu/drm/amd/amdgpu/cikd.h   |   6 +
 drivers/gpu/drm/amd/amdgpu/cz_dpm.c |   2 +-
 drivers/gpu/drm/amd/amdgpu/cz_dpm.h |   2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   |   2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   |  42 +++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   |  55 -
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c  |  28 +
 drivers/gpu/drm/amd/amdgpu/vi.c |   4 -
 drivers/gpu/drm/radeon/cik.c|  34 ++
 drivers/gpu/drm/radeon/cik_sdma.c   |  11 ++
 drivers/gpu/drm/radeon/radeon_audio.c   |  18 +--
 drivers/gpu/drm/radeon/radeon_fb.c  |   1 -
 drivers/gpu/drm/radeon/radeon_ttm.c |   2 +-
 drivers/gpu/drm/radeon/radeon_vm.c  |   4 +-
 include/uapi/drm/amdgpu_drm.h   |  12 ++
 27 files changed, 551 insertions(+), 89 deletions(-)


[PATCH v2 08/12] drm: dsi: Add "enter idle" & "exit idle" dcs functions

2015-07-01 Thread Mark Zhang
Oh, yes, if so we need to change most of the functions in drm_mipi_dsi.c.

Mark
On 07/01/2015 05:08 PM, Varka Bhadram wrote:
> On 07/01/2015 01:51 PM, Mark Zhang wrote:
>> Signed-off-by: Mark Zhang
>> ---
>>   drivers/gpu/drm/drm_mipi_dsi.c |   36 
>>   include/drm/drm_mipi_dsi.h |2 ++
>>   2 files changed, 38 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
>> index 2d5ca8eec13a..9bc6ff75eb8f 100644
>> --- a/drivers/gpu/drm/drm_mipi_dsi.c
>> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
>> @@ -862,6 +862,42 @@ int mipi_dsi_dcs_set_pixel_format(struct 
>> mipi_dsi_device *dsi, u8 format)
>>   }
>>   EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);
>>   
>> +/**
>> + * mipi_dsi_dcs_enter_idle_mode()
>> + * @dsi: DSI peripheral device
>> + *
>> + * Return: 0 on success or a negative error code on failure.
>> + */
>> +int mipi_dsi_dcs_enter_idle_mode(struct mipi_dsi_device *dsi)
>> +{
>> +ssize_t err;
>> +
>> +err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_IDLE_MODE, NULL, 0);
>> +if (err < 0)
>> +return err;
>> +
>> +return 0;
>> +}
> 
> This we can do simply as:
>   return mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_IDLE_MODE, NULL, 0);
> 
>> +EXPORT_SYMBOL(mipi_dsi_dcs_enter_idle_mode);
>> +
>> +/**
>> + * mipi_dsi_dcs_exit_idle_mode()
>> + * @dsi: DSI peripheral device
>> + *
>> + * Return: 0 on success or a negative error code on failure.
>> + */
>> +int mipi_dsi_dcs_exit_idle_mode(struct mipi_dsi_device *dsi)
>> +{
>> +ssize_t err;
>> +
>> +err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_IDLE_MODE, NULL, 0);
>> +if (err < 0)
>> +return err;
>> +
>> +return 0;
> 
> For this one also: return mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_IDLE_MODE, 
> NULL, 0);
> 
> 


[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Mark yao
On 2015年07月01日 16:42, Tomasz Figa wrote:
> On Wed, Jul 1, 2015 at 5:32 PM, Mark yao  wrote:
>> On 2015年07月01日 16:03, Tomasz Figa wrote:
>>> Hi Mark,
>>>
>>> On Tue, Jun 30, 2015 at 3:50 PM, Mark yao  
>>> wrote:
 Hi Dave.

   Some fixes and some new features. I'd like you can pull them.

 The following changes since commit
 c5fd936e992dd2829167d2adc63e151675ca6898:

 drm/nouveau: Pause between setting gpu to D3hot and cutting the power
 (2015-06-26 10:26:37 +1000)

 are available in the git repository at:

 https://github.com/markyzq/kernel-drm-rockchip.git
 drm-rockchip-2015-06-30

 for you to fetch changes up to 5295c05eb30d743987172853179333c80b8242bc:

 drm/rockchip: default enable win2/3 area0 bit (2015-06-30 14:24:10
 +0800)

 
 Heiko Stübner (1):
 drm/rockchip: only call drm_fb_helper_hotplug_event if fb_helper
 present

 Mark Yao (6):
 drm/rockchip: import dma_buf to gem
 drm/rockchip: vop: optimize virtual stride calculate
 drm/rockchip: vop: fix yuv plane support
 drm/rockchip: vop: support plane scale
 drm/rockchip: vop: switch cursor plane to window 3
 drm/rockchip: default enable win2/3 area0 bit
>>> Has this series been reviewed properly? I can see that at least
>>> "drm/rockchip: vop: support plane scale" is kind of "controversial".
>>
>> Sorry for that, can you review those patches, and give me some advices?
>>
>> https://lkml.org/lkml/2015/6/18/77
>> v2: https://lkml.org/lkml/2015/6/26/192
>>
> Yes, will do that.
>
> By the way, please feel free to ping patches on the lists if they idle
> without any comments or tags for while.
>
>>> By the way, if we're using window 3 for cursor plane, because the
>>> cursor window needs special handling, is it okay to expose the cusor
>>> window as an overlay plane to userspace, as we do currently?
>>
>> special handling? what means? "switch cursor plane to window 3" patch only
>> switch cursor
>>   windows from win1 to win3. tag window 3 as DRM_PLANE_TYPE_CURSOR, userspace
>> only
>> can found window 3 is a cursor plane.
>>
> Ah, this was a question slightly unrelated to that patch, but I just
> noticed in that patch that the hardware cursor window is still exposed
> to the userspace as overlay plane, even if it's not quite suitable for
> being such.

Oh, I know your mean, you mean that code:
 { .base = 0x00, .phy = &cursor_data, .type = 
DRM_PLANE_TYPE_OVERLAY },

right?

That is I plan to do.

hardware cursor window have a problem that hard to resolved.
the window can't support width virtual and can't move out of left top top.
But linux desktop or chromiumos should move cursor out of left or top.

I'm considering remove it or find a another way to reuse it.

> Best regards,
> Tomasz
>
>
>


-- 
ï¼­ark




[PATCH 2/2] drm/mgag200: remove unneeded variable

2015-07-01 Thread Sudip Mukherjee
ttm_bo_validate() returns 0 or error. So we can return the value
directly and remove the variable 'ret'.

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

diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c 
b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index d16964e..05108b5 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -378,7 +378,7 @@ int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 
*gpu_addr)

 int mgag200_bo_unpin(struct mgag200_bo *bo)
 {
-   int i, ret;
+   int i;
if (!bo->pin_count) {
DRM_ERROR("unpin bad %p\n", bo);
return 0;
@@ -389,11 +389,7 @@ int mgag200_bo_unpin(struct mgag200_bo *bo)

for (i = 0; i < bo->placement.num_placement ; i++)
bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
-   ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
-   if (ret)
-   return ret;
-
-   return 0;
+   return ttm_bo_validate(&bo->bo, &bo->placement, false, false);
 }

 int mgag200_bo_push_sysram(struct mgag200_bo *bo)
-- 
1.8.1.2



[PATCH 1/2] drm/mgag200: remove unused variables

2015-07-01 Thread Sudip Mukherjee
These variables were assigned some values but they were never used.

Signed-off-by: Sudip Mukherjee 
---
 drivers/gpu/drm/mgag200/mgag200_fb.c   | 2 --
 drivers/gpu/drm/mgag200/mgag200_mode.c | 9 +++--
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
b/drivers/gpu/drm/mgag200/mgag200_fb.c
index c36b830..958cf3c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -167,7 +167,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
struct drm_framebuffer *fb;
struct drm_gem_object *gobj = NULL;
struct device *device = &dev->pdev->dev;
-   struct mgag200_bo *bo;
int ret;
void *sysram;
int size;
@@ -185,7 +184,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
DRM_ERROR("failed to create fbcon backing object %d\n", ret);
return ret;
}
-   bo = gem_to_mga_bo(gobj);

sysram = vmalloc(size);
if (!sysram)
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
b/drivers/gpu/drm/mgag200/mgag200_mode.c
index ad4b901..cd75cff 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -158,7 +158,7 @@ static int mga_g200se_set_plls(struct mga_device *mdev, 
long clock)
 static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
 {
unsigned int vcomax, vcomin, pllreffreq;
-   unsigned int delta, tmpdelta, permitteddelta;
+   unsigned int delta, tmpdelta;
unsigned int testp, testm, testn;
unsigned int p, m, n;
unsigned int computed;
@@ -172,7 +172,6 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, 
long clock)
pllreffreq = 48000;

delta = 0x;
-   permitteddelta = clock * 5 / 1000;

for (testp = 1; testp < 9; testp++) {
if (clock * testp > vcomax)
@@ -298,7 +297,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, 
long clock)
 static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
 {
unsigned int vcomax, vcomin, pllreffreq;
-   unsigned int delta, tmpdelta, permitteddelta;
+   unsigned int delta, tmpdelta;
unsigned int testp, testm, testn;
unsigned int p, m, n;
unsigned int computed;
@@ -310,7 +309,6 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, 
long clock)
pllreffreq = 5;

delta = 0x;
-   permitteddelta = clock * 5 / 1000;

for (testp = 16; testp > 0; testp--) {
if (clock * testp > vcomax)
@@ -392,7 +390,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, 
long clock)
 static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
 {
unsigned int vcomax, vcomin, pllreffreq;
-   unsigned int delta, tmpdelta, permitteddelta;
+   unsigned int delta, tmpdelta;
unsigned int testp, testm, testn;
unsigned int p, m, n;
unsigned int computed;
@@ -406,7 +404,6 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, 
long clock)
pllreffreq = 3;

delta = 0x;
-   permitteddelta = clock * 5 / 1000;

for (testp = 16; testp > 0; testp >>= 1) {
if (clock * testp > vcomax)
-- 
1.8.1.2



[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Tomasz Figa
Hi Mark,

On Tue, Jun 30, 2015 at 3:50 PM, Mark yao  wrote:
>
> Hi Dave.
>
> Some fixes and some new features. I'd like you can pull them.
>
> The following changes since commit c5fd936e992dd2829167d2adc63e151675ca6898:
>
>   drm/nouveau: Pause between setting gpu to D3hot and cutting the power 
> (2015-06-26 10:26:37 +1000)
>
> are available in the git repository at:
>
>   https://github.com/markyzq/kernel-drm-rockchip.git drm-rockchip-2015-06-30
>
> for you to fetch changes up to 5295c05eb30d743987172853179333c80b8242bc:
>
>   drm/rockchip: default enable win2/3 area0 bit (2015-06-30 14:24:10 +0800)
>
> 
> Heiko Stübner (1):
>   drm/rockchip: only call drm_fb_helper_hotplug_event if fb_helper present
>
> Mark Yao (6):
>   drm/rockchip: import dma_buf to gem
>   drm/rockchip: vop: optimize virtual stride calculate
>   drm/rockchip: vop: fix yuv plane support
>   drm/rockchip: vop: support plane scale
>   drm/rockchip: vop: switch cursor plane to window 3
>   drm/rockchip: default enable win2/3 area0 bit

Has this series been reviewed properly? I can see that at least
"drm/rockchip: vop: support plane scale" is kind of "controversial".

By the way, if we're using window 3 for cursor plane, because the
cursor window needs special handling, is it okay to expose the cusor
window as an overlay plane to userspace, as we do currently?

Best regards,
Tomasz


[PATCH v2 10/12] drm/tegra: Suspend dc/dsi/panel in one-shot mode

2015-07-01 Thread Mark Zhang
On 07/01/2015 05:00 PM, Daniel Vetter wrote:
> On Wed, Jul 01, 2015 at 04:21:53PM +0800, Mark Zhang wrote:
>> @@ -756,7 +752,11 @@ tegra_dsi_connector_duplicate_state(struct 
>> drm_connector *connector)
>>  }
>>  
>>  static const struct drm_connector_funcs tegra_dsi_connector_funcs = {
>> -.dpms = tegra_dsi_connector_dpms,
>> +/*
>> + * drm_atomic_helper_connector_dpms only handles DPMS ON/OFF,
>> + * so use drm_helper_connector_dpms instead.
>> + */
>> +.dpms = drm_helper_connector_dpms,
> 
> Nope, mixing legacy dpms handling into an atomic driver is a no-go. You
> need to use drm_atomic_helper_connector_dpms here.

yeah, so I have to change "drm_atomic_helper_connector_dpms"?

Mark
> -Daniel
> 


[Intel-gfx] [PATCH] drm/i915: Clear pipe's pll hw state in hsw_dp_set_ddi_pll_sel()

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 05:54:06PM +0300, Ander Conselvan De Oliveira wrote:
> On Tue, 2015-06-30 at 18:41 +0300, Jani Nikula wrote:
> > On Tue, 30 Jun 2015, Daniel Vetter  wrote:
> > > On Tue, Jun 30, 2015 at 04:47:06PM +0300, Jani Nikula wrote:
> > >> On Tue, 30 Jun 2015, Ander Conselvan de Oliveira 
> > >>  wrote:
> > >> > Similarly to what is done for SKL, clear the dpll_hw_state of the pipe
> > >> > config in hsw_dp_set_ddi_pll_sel(), since it main contain stale values.
> > >> > That can happen if a crtc that was previously driving an HDMI connector
> > >> > switches to a DP connector. In that case, the wrpll field was left with
> > >> > its old value, leading to warnings like the one below:
> > >> >
> > >> > [drm:check_crtc_state [i915]] *ERROR* mismatch in dpll_hw_state.wrpll 
> > >> > (expected 0xb035061f, found 0x)
> > >> > [ cut here ]
> > >> > WARNING: CPU: 1 PID: 767 at drivers/gpu/drm/i915/intel_display.c:12324 
> > >> > check_crtc_state+0x975/0x10b0 [i915]()
> > >> > pipe state doesn't match!
> > >> >
> > >> > This regression was indroduced in
> > >> >
> > >> > commit dd3cd74acf12723045a64f1f2c6298ac7b34a5d5
> > >> > Author: Ander Conselvan de Oliveira  > >> > intel.com>
> > >> > Date:   Fri May 15 13:34:29 2015 +0300
> > >> >
> > >> > drm/i915: Don't overwrite (e)DP PLL selection on SKL
> > >> >
> > >> > Signed-off-by: Ander Conselvan de Oliveira 
> > >> > 
> > >> 
> > >> Reported-by: Linus Torvalds 
> > >> Tested-by: Jani Nikula 
> > >
> > > Yeah makes sense as a fix for 4.2. But for 4.3 I wonder whether the
> > > original commit that started this chain needs to be changed a bit:
> > >
> > > commit 4978cc93d9ac240b435ce60431aef24239b4c270
> > > Author: Ander Conselvan de Oliveira  > > intel.com>
> > > Date:   Tue Apr 21 17:13:21 2015 +0300
> > >
> > > drm/i915: Preserve shared DPLL information in new pipe_config
> > >
> > > All the trouble this caused is because it not only preserves the sharing
> > > config (in crtc_state->shared_dpll) but also the ->dpll_hw_state. And I
> > > think with Maarten's latest code (for 4.3) we'd just do an unconditional
> > > compute_config (need it for fast pfit updates and fastboot), which means
> > > the bogus values in ->dpll_hw_state aren't a problem any more since we'll
> > > overwrite them again. And then we could remove that sprinkle of memsets we
> > > have all over, which would be good (since the current approach is
> > > obviously a bit fragile). Anyway:
> > >
> > > Reviewed-by: Daniel Vetter 
> > 
> > Pushed to drm-intel-next-fixes, thanks for the patch and review. One
> > down, another one left to fix.
> 
> I made some progress on the second issue, but I'm afraid Jani might have
> a found a third bug. The warning he gets happens because we try to wait
> for vblanks while updating the primary plane during the modeset. At that
> point, the crtc is off. The problem is in intel_check_primary_plane(),
> which is called from drm_atomic_helper_check_planes(). That function
> makes decisions about waiting for a vblank based on intel_crtc->active.
> Since the check is called before we disable the crtcs, active might be
> true, even though the plane update is done with crtcs disable.
> 
> The patch below makes the warning go away, but I still need to figure
> out how to set crtc_state->planes_changed properly if we are going down
> that route.
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c 
> b/drivers/gpu/drm/i915/intel_display.c
> index dcb1d25..f14727c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -12480,10 +12480,6 @@ intel_modeset_compute_config(struct drm_crtc *crtc,
>  
> intel_dump_pipe_config(to_intel_crtc(crtc), pipe_config,"[modeset]");
>  
> -   ret = drm_atomic_helper_check_planes(state->dev, state);
> -   if (ret)
> -   return ERR_PTR(ret);
> -
> return pipe_config;
>  }
>  
> 
> The backtrace on Linus' machine is different, though. It comes from the
> call to intel_crtc_disable_planes() in __intel_set_mode(). That would
> indicate we have a crtc with crtc->state->enable == true but that is
> actually inactive. I'm still not sure how we can get in that state.

Using intel_crtc->active to precompute any kind of decisions won't work. I
guess we just need to delay the decision whether to make a vblank wait or
not to where we do the vblank wait, and use the (then current
intel_crtc->active) there. This will be fixed properly in 4.3.

I suspect Linus' backtrace is something similar - we try to precompute
what needs to be updated, get it wrong and the go boom. Sprinkling an

if (!intel_crtc->active)
return;

early return into the set_mode should help. But I haven't looked at what
4.2 looks precisely yet in this area - too much flux because of the atomic
conversion.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v2 12/12] JUST FOR TEST: Add one-shot trigger to update display

2015-07-01 Thread Mark Zhang
On 07/01/2015 04:36 PM, Daniel Vetter wrote:
> On Wed, Jul 01, 2015 at 04:21:55PM +0800, Mark Zhang wrote:
>> This HACK adds a workqueue to refresh the display periodically.
>> This is used just for testing.
> 
> ->dirty is the drm hook you're looking for, it's meant to flush out any
> frontbuffer rendering. Generic kms clients using the dumb buffers (e.g.
> fedora boot splash) use this already.
> 

Oh... I did a grep in drm source and are you talking about
"drm_framebuffer_funcs->dirty"? Yeah, that should work for me.. but that
requires userspace sending IOCTL to trigger, right? Honestly I'm lazy so
I created this HACK so that I don't need userspace to test.

> And of course you need to upload a new frame every time an (atomic) flip
> happens too, but I guess you have that already. No need at all for a
> periodic upload hack like this.
> 

Yep. Thanks Daniel.

Mark
> Cheers, Daniel
> 
>>
>> Signed-off-by: Mark Zhang 
>> ---
>>  drivers/gpu/drm/tegra/dc.c  |   37 +
>>  drivers/gpu/drm/tegra/drm.h |1 +
>>  2 files changed, 38 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
>> index 24a91613c4f5..4381691c73f7 100644
>> --- a/drivers/gpu/drm/tegra/dc.c
>> +++ b/drivers/gpu/drm/tegra/dc.c
>> @@ -1296,6 +1296,8 @@ static void tegra_crtc_mode_set_nofb(struct drm_crtc 
>> *crtc)
>>  value &= ~DISP_CTRL_MODE_MASK;
>>  value |= DISP_CTRL_MODE_NC_DISPLAY;
>>  tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
>> +
>> +schedule_work(&dc->one_shot_trigger);
>>  } else {
>>  value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
>>  value &= ~DISP_CTRL_MODE_MASK;
>> @@ -1958,6 +1960,40 @@ static void tegra_dc_one_shot_work(struct work_struct 
>> *work)
>>  drm_modeset_unlock_all(drm);
>>  }
>>  
>> +static void tegra_dc_one_shot_trigger(struct work_struct *work)
>> +{
>> +struct tegra_dc *dc;
>> +struct drm_connector *connector;
>> +struct drm_device *drm;
>> +unsigned long update_mask = GENERAL_ACT_REQ | NC_HOST_TRIG;
>> +static int first_trigger = 1;
>> +
>> +dc = container_of(work, struct tegra_dc, one_shot_trigger);
>> +drm = dc->base.dev;
>> +msleep(5000);
>> +
>> +if (first_trigger) {
>> +dev_info(dc->dev, "First one-shot triggered.\n");
>> +tegra_dc_writel(dc, update_mask, DC_CMD_STATE_CONTROL);
>> +first_trigger = 0;
>> +schedule_work(&dc->one_shot_trigger);
>> +return;
>> +}
>> +
>> +dev_info(dc->dev, "one-shot: Wakeup dc/dsi/panel.\n");
>> +drm_modeset_lock_all(drm);
>> +list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
>> +if (connector->funcs->dpms)
>> +connector->funcs->dpms(connector,
>> +DRM_MODE_DPMS_STANDBY);
>> +}
>> +drm_modeset_unlock_all(drm);
>> +
>> +/* Trigger the one-shot */
>> +tegra_dc_writel(dc, update_mask, DC_CMD_STATE_CONTROL);
>> +schedule_work(&dc->one_shot_trigger);
>> +}
>> +
>>  static int tegra_dc_probe(struct platform_device *pdev)
>>  {
>>  unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED;
>> @@ -1977,6 +2013,7 @@ static int tegra_dc_probe(struct platform_device *pdev)
>>  spin_lock_init(&dc->lock);
>>  INIT_LIST_HEAD(&dc->list);
>>  INIT_WORK(&dc->one_shot_work, tegra_dc_one_shot_work);
>> +INIT_WORK(&dc->one_shot_trigger, tegra_dc_one_shot_trigger);
>>  dc->dev = &pdev->dev;
>>  dc->soc = id->data;
>>  
>> diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
>> index 00daf427c831..5d606cacb098 100644
>> --- a/drivers/gpu/drm/tegra/drm.h
>> +++ b/drivers/gpu/drm/tegra/drm.h
>> @@ -132,6 +132,7 @@ struct tegra_dc {
>>  struct drm_pending_vblank_event *event;
>>  
>>  struct work_struct one_shot_work;
>> +struct work_struct one_shot_trigger;
>>  
>>  const struct tegra_dc_soc_info *soc;
>>  
>> -- 
>> 1.7.9.5
>>
> 


[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Mark yao
On 2015年07月01日 16:32, Tomasz Figa wrote:
> On Wed, Jul 1, 2015 at 5:20 PM, Daniel Vetter  wrote:
>> On Wed, Jul 01, 2015 at 05:03:39PM +0900, Tomasz Figa wrote:
>>> Hi Mark,
>>>
>>> On Tue, Jun 30, 2015 at 3:50 PM, Mark yao  
>>> wrote:
 Hi Dave.

  Some fixes and some new features. I'd like you can pull them.

 The following changes since commit 
 c5fd936e992dd2829167d2adc63e151675ca6898:

drm/nouveau: Pause between setting gpu to D3hot and cutting the power 
 (2015-06-26 10:26:37 +1000)

 are available in the git repository at:

https://github.com/markyzq/kernel-drm-rockchip.git 
 drm-rockchip-2015-06-30

 for you to fetch changes up to 5295c05eb30d743987172853179333c80b8242bc:

drm/rockchip: default enable win2/3 area0 bit (2015-06-30 14:24:10 
 +0800)

 
 Heiko Stübner (1):
drm/rockchip: only call drm_fb_helper_hotplug_event if fb_helper 
 present

 Mark Yao (6):
drm/rockchip: import dma_buf to gem
drm/rockchip: vop: optimize virtual stride calculate
drm/rockchip: vop: fix yuv plane support
drm/rockchip: vop: support plane scale
drm/rockchip: vop: switch cursor plane to window 3
drm/rockchip: default enable win2/3 area0 bit
>>> Has this series been reviewed properly? I can see that at least
>>> "drm/rockchip: vop: support plane scale" is kind of "controversial".
>> I don't see any discussion of this patch at all on dri-devel, where's this
>> controversy?
> Well, it adds a lot of seemingly complex, hard to read code with
> obvious style issues. I'll review the series later this week.
>
> Best regards,
> Tomasz
>
>
Hi Tomasz

 Thanks, those compute code you can found from RK3288 TRM->"27.3.3 
Win Scaling", too complex.
I had do some clean for the code, but for full function and little bug, 
hard to cleanup.

Best regards,

-- 
ï¼­ark




[PATCH v2 12/12] JUST FOR TEST: Add one-shot trigger to update display

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 08:43:01PM +0800, Mark Zhang wrote:
> On 07/01/2015 06:34 PM, Daniel Vetter wrote:
> > On Wed, Jul 01, 2015 at 05:01:52PM +0800, Mark Zhang wrote:
> >> On 07/01/2015 04:36 PM, Daniel Vetter wrote:
> >>> On Wed, Jul 01, 2015 at 04:21:55PM +0800, Mark Zhang wrote:
>  This HACK adds a workqueue to refresh the display periodically.
>  This is used just for testing.
> >>>
> >>> ->dirty is the drm hook you're looking for, it's meant to flush out any
> >>> frontbuffer rendering. Generic kms clients using the dumb buffers (e.g.
> >>> fedora boot splash) use this already.
> >>>
> >>
> >> Oh... I did a grep in drm source and are you talking about
> >> "drm_framebuffer_funcs->dirty"? Yeah, that should work for me.. but that
> >> requires userspace sending IOCTL to trigger, right? Honestly I'm lazy so
> >> I created this HACK so that I don't need userspace to test.
> > 
> > Yeah userspace needs to send ioctl already after each drawing. Generic
> > userspace does that already since it's required by qxl, udl, soon i915 and
> > probably a few others too. fbdev emulation is more annyoing but there's
> > code to move around in these drivers (qxl seems best to me as a starting
> > point) too.
> > 
> 
> Alright, this makes sense. I have no idea about qxl, what I have now is
> an ubuntu running on Tegra114. So I'm wondering what I suppose to do is
> installing qemu on the ubuntu?

My suggestion is just to take the qxl code, move it to the fbdev emulation
helper, make it generic and use it. If you want you can do a
compile-tested patch on top to switch qxl over to the newly added helpers.
No need to install/run qxl itself. Just that qxl seems to have the most
complete solution for what you need.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Mark yao
On 2015年07月01日 16:32, Mark yao wrote:
> On 2015年07月01日 16:03, Tomasz Figa wrote:
>> Hi Mark,
>>
>> On Tue, Jun 30, 2015 at 3:50 PM, Mark yao  
>> wrote:
>>> Hi Dave.
>>>
>>>  Some fixes and some new features. I'd like you can pull them.
>>>
>>> The following changes since commit 
>>> c5fd936e992dd2829167d2adc63e151675ca6898:
>>>
>>>drm/nouveau: Pause between setting gpu to D3hot and cutting the 
>>> power (2015-06-26 10:26:37 +1000)
>>>
>>> are available in the git repository at:
>>>
>>>https://github.com/markyzq/kernel-drm-rockchip.git 
>>> drm-rockchip-2015-06-30
>>>
>>> for you to fetch changes up to 
>>> 5295c05eb30d743987172853179333c80b8242bc:
>>>
>>>drm/rockchip: default enable win2/3 area0 bit (2015-06-30 
>>> 14:24:10 +0800)
>>>
>>> 
>>> Heiko Stübner (1):
>>>drm/rockchip: only call drm_fb_helper_hotplug_event if 
>>> fb_helper present
>>>
>>> Mark Yao (6):
>>>drm/rockchip: import dma_buf to gem
>>>drm/rockchip: vop: optimize virtual stride calculate
>>>drm/rockchip: vop: fix yuv plane support
>>>drm/rockchip: vop: support plane scale
>>>drm/rockchip: vop: switch cursor plane to window 3
>>>drm/rockchip: default enable win2/3 area0 bit
>> Has this series been reviewed properly? I can see that at least
>> "drm/rockchip: vop: support plane scale" is kind of "controversial".
>
> Sorry for that, can you review those patches, and give me some advices?
>
> https://lkml.org/lkml/2015/6/18/77
> v2: https://lkml.org/lkml/2015/6/26/192
>
>> By the way, if we're using window 3 for cursor plane, because the
>> cursor window needs special handling, is it okay to expose the cusor
>> window as an overlay plane to userspace, as we do currently?
>
> special handling? what means? "switch cursor plane to window 3" patch 
> only switch cursor
>  windows from win1 to win3. tag window 3 as DRM_PLANE_TYPE_CURSOR, 
> userspace only
> can found window 3 is a cursor plane.

switch cursor win1 to win3 because we want to use win1 as a overlay for 
yuv image, win3 not
support yuv format.  not for special handling.

By the way, win3 power power consume less than win1, cursor use win3 
would save power.

>
>>
>> Best regards,
>> Tomasz
>>
>>
>>
>
> Best regards,
> ï¼­ark
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


-- 
ï¼­ark




[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Mark yao
On 2015年07月01日 16:03, Tomasz Figa wrote:
> Hi Mark,
>
> On Tue, Jun 30, 2015 at 3:50 PM, Mark yao  wrote:
>> Hi Dave.
>>
>>  Some fixes and some new features. I'd like you can pull them.
>>
>> The following changes since commit c5fd936e992dd2829167d2adc63e151675ca6898:
>>
>>drm/nouveau: Pause between setting gpu to D3hot and cutting the power 
>> (2015-06-26 10:26:37 +1000)
>>
>> are available in the git repository at:
>>
>>https://github.com/markyzq/kernel-drm-rockchip.git drm-rockchip-2015-06-30
>>
>> for you to fetch changes up to 5295c05eb30d743987172853179333c80b8242bc:
>>
>>drm/rockchip: default enable win2/3 area0 bit (2015-06-30 14:24:10 +0800)
>>
>> 
>> Heiko Stübner (1):
>>drm/rockchip: only call drm_fb_helper_hotplug_event if fb_helper 
>> present
>>
>> Mark Yao (6):
>>drm/rockchip: import dma_buf to gem
>>drm/rockchip: vop: optimize virtual stride calculate
>>drm/rockchip: vop: fix yuv plane support
>>drm/rockchip: vop: support plane scale
>>drm/rockchip: vop: switch cursor plane to window 3
>>drm/rockchip: default enable win2/3 area0 bit
> Has this series been reviewed properly? I can see that at least
> "drm/rockchip: vop: support plane scale" is kind of "controversial".

Sorry for that, can you review those patches, and give me some advices?

https://lkml.org/lkml/2015/6/18/77
v2: https://lkml.org/lkml/2015/6/26/192

> By the way, if we're using window 3 for cursor plane, because the
> cursor window needs special handling, is it okay to expose the cusor
> window as an overlay plane to userspace, as we do currently?

special handling? what means? "switch cursor plane to window 3" patch 
only switch cursor
  windows from win1 to win3. tag window 3 as DRM_PLANE_TYPE_CURSOR, 
userspace only
can found window 3 is a cursor plane.

>
> Best regards,
> Tomasz
>
>
>

Best regards,
ï¼­ark



[PATCH libdrm v2 2/2] configure.ac: bump version to 2.4.63

2015-07-01 Thread Michel Thierry
Cc: dri-devel at lists.freedesktop.org
Signed-off-by: Michel Thierry 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 001fd3d..12b8465 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@

 AC_PREREQ([2.63])
 AC_INIT([libdrm],
-[2.4.62],
+[2.4.63],
 [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI],
 [libdrm])

-- 
2.4.5



[PATCH libdrm v2 1/2] intel: Add EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag.

2015-07-01 Thread Michel Thierry
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 Intruction State Heap (ISH) must be in a
32-bit range, because the General State Offset and Instruction State Offset
are limited to 32-bits.

Provide a flag to set when the 4GB limit is not necessary in a given bo.
48-bit range will only be used when explicitly requested.

Calls to the new drm_intel_bo_emit_reloc_48bit function will have this flag
set automatically, while calls to drm_intel_bo_emit_reloc will clear it.

v2: Make set/clear functions nops on pre-gen8 platforms, and use them
internally in emit_reloc functions (Ben)
s/48BADDRESS/48B_ADDRESS/ (Dave)

Cc: Ben Widawsky 
Cc: Dave Gordon 
Cc: dri-devel at lists.freedesktop.org
Signed-off-by: Michel Thierry 
---
 include/drm/i915_drm.h|  3 ++-
 intel/intel_bufmgr.c  | 24 +
 intel/intel_bufmgr.h  |  8 ++-
 intel/intel_bufmgr_gem.c  | 54 +++
 intel/intel_bufmgr_priv.h | 11 ++
 5 files changed, 94 insertions(+), 6 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..590a855 100644
--- a/intel/intel_bufmgr.c
+++ b/intel/intel_bufmgr.c
@@ -188,6 +188,18 @@ drm_intel_bufmgr_check_aperture_space(drm_intel_bo ** 
bo_array, int count)
return bo_array[0]->bufmgr->check_aperture_space(bo_array, count);
 }

+void drm_intel_bo_set_supports_48b_address(drm_intel_bo *bo)
+{
+   if (bo->bufmgr->bo_set_supports_48b_address)
+   bo->bufmgr->bo_set_supports_48b_address(bo);
+}
+
+void drm_intel_bo_clear_supports_48b_address(drm_intel_bo *bo)
+{
+   if (bo->bufmgr->bo_clear_supports_48b_address)
+   bo->bufmgr->bo_clear_supports_48b_address(bo);
+}
+
 int
 drm_intel_bo_flink(drm_intel_bo *bo, uint32_t * name)
 {
@@ -202,6 +214,18 @@ drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
drm_intel_bo *target_bo, uint32_t target_offset,
uint32_t read_domains, uint32_t write_domain)
 {
+   drm_intel_bo_clear_supports_48b_address(target_bo);
+   return bo->bufmgr->bo_emit_reloc(bo, offset,
+target_bo, target_offset,
+read_domains, write_domain);
+}
+
+int
+drm_intel_bo_emit_reloc_48bit(drm_intel_bo *bo, uint32_t offset,
+   drm_intel_bo *target_bo, uint32_t target_offset,
+   uint32_t read_domains, uint32_t write_domain)
+{
+   drm_intel_bo_set_supports_48b_address(target_bo);
return bo->bufmgr->bo_emit_reloc(bo, offset,
 target_bo, target_offset,
 read_domains, write_domain);
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index 285919e..62480cb 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -87,7 +87,8 @@ struct _drm_intel_bo {
/**
 * Last seen card virtual address (offset from the beginning of the
 * aperture) for the object.  This should be used to fill relocation
-* entries when calling drm_intel_bo_emit_reloc()
+* entries when calling drm_intel_bo_emit_reloc() or
+* drm_intel_bo_emit_reloc_48bit()
 */
uint64_t offset64;
 };
@@ -137,6 +138,8 @@ void drm_intel_bo_wait_rendering(drm_intel_bo *bo);

 void drm_intel_bufmgr_set_debug(drm_intel_bufmgr *bufmgr, int enable_debug);
 void drm_intel_bufmgr_destroy(drm_intel_bufmgr *bufmgr);
+void drm_intel_bo_set_supports_48b_address(drm_intel_bo *bo);
+void drm_intel_bo_clear_supports_48b_address(drm_intel_bo *bo);
 int drm_intel_bo_exec(drm_intel_bo *bo, int used,
  struct drm_clip_rect *cliprects, int num_cliprects, int 
DR4);
 int drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used,
@@ -147,6 +150,9 @@ int drm_intel_bufmgr_check_aperture_space(drm_intel_bo ** 
bo_array, int count);
 int drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
drm_intel_bo *target_bo, uint32_t target_offset,
uint32_t read_domains, uint32_t write_domain);
+int drm_intel_bo_emit_reloc_48bit(drm_intel_bo *bo, uint32_t offset,
+ drm_intel_bo *target_bo, uint32_t 
ta

[PATCH v2 12/12] JUST FOR TEST: Add one-shot trigger to update display

2015-07-01 Thread Mark Zhang
This HACK adds a workqueue to refresh the display periodically.
This is used just for testing.

Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/tegra/dc.c  |   37 +
 drivers/gpu/drm/tegra/drm.h |1 +
 2 files changed, 38 insertions(+)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 24a91613c4f5..4381691c73f7 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -1296,6 +1296,8 @@ static void tegra_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
value &= ~DISP_CTRL_MODE_MASK;
value |= DISP_CTRL_MODE_NC_DISPLAY;
tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
+
+   schedule_work(&dc->one_shot_trigger);
} else {
value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
value &= ~DISP_CTRL_MODE_MASK;
@@ -1958,6 +1960,40 @@ static void tegra_dc_one_shot_work(struct work_struct 
*work)
drm_modeset_unlock_all(drm);
 }

+static void tegra_dc_one_shot_trigger(struct work_struct *work)
+{
+   struct tegra_dc *dc;
+   struct drm_connector *connector;
+   struct drm_device *drm;
+   unsigned long update_mask = GENERAL_ACT_REQ | NC_HOST_TRIG;
+   static int first_trigger = 1;
+
+   dc = container_of(work, struct tegra_dc, one_shot_trigger);
+   drm = dc->base.dev;
+   msleep(5000);
+
+   if (first_trigger) {
+   dev_info(dc->dev, "First one-shot triggered.\n");
+   tegra_dc_writel(dc, update_mask, DC_CMD_STATE_CONTROL);
+   first_trigger = 0;
+   schedule_work(&dc->one_shot_trigger);
+   return;
+   }
+
+   dev_info(dc->dev, "one-shot: Wakeup dc/dsi/panel.\n");
+   drm_modeset_lock_all(drm);
+   list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
+   if (connector->funcs->dpms)
+   connector->funcs->dpms(connector,
+   DRM_MODE_DPMS_STANDBY);
+   }
+   drm_modeset_unlock_all(drm);
+
+   /* Trigger the one-shot */
+   tegra_dc_writel(dc, update_mask, DC_CMD_STATE_CONTROL);
+   schedule_work(&dc->one_shot_trigger);
+}
+
 static int tegra_dc_probe(struct platform_device *pdev)
 {
unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED;
@@ -1977,6 +2013,7 @@ static int tegra_dc_probe(struct platform_device *pdev)
spin_lock_init(&dc->lock);
INIT_LIST_HEAD(&dc->list);
INIT_WORK(&dc->one_shot_work, tegra_dc_one_shot_work);
+   INIT_WORK(&dc->one_shot_trigger, tegra_dc_one_shot_trigger);
dc->dev = &pdev->dev;
dc->soc = id->data;

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 00daf427c831..5d606cacb098 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -132,6 +132,7 @@ struct tegra_dc {
struct drm_pending_vblank_event *event;

struct work_struct one_shot_work;
+   struct work_struct one_shot_trigger;

const struct tegra_dc_soc_info *soc;

-- 
1.7.9.5



[PATCH v2 11/12] drm/tegra: dsi: Set connector DPMS state when enable/disable

2015-07-01 Thread Mark Zhang
This patch fixes a bug when drm_helper_connector_dpms tries to
switch connector/encoder/crtc DPMS status.

Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/tegra/dsi.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
index 1d21f149d7f2..7917b7875496 100644
--- a/drivers/gpu/drm/tegra/dsi.c
+++ b/drivers/gpu/drm/tegra/dsi.c
@@ -898,6 +898,8 @@ static void tegra_dsi_encoder_mode_set(struct drm_encoder 
*encoder,
if (output->panel)
drm_panel_enable(output->panel);

+   output->connector.dpms = DRM_MODE_DPMS_ON;
+
return;
 }

@@ -937,6 +939,7 @@ static void tegra_dsi_encoder_disable(struct drm_encoder 
*encoder)

tegra_dsi_disable(dsi);

+   output->connector.dpms = DRM_MODE_DPMS_OFF;
return;
 }

-- 
1.7.9.5



[PATCH v2 10/12] drm/tegra: Suspend dc/dsi/panel in one-shot mode

2015-07-01 Thread Mark Zhang
Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/tegra/dc.c  |   58 +
 drivers/gpu/drm/tegra/drm.h |3 ++
 drivers/gpu/drm/tegra/dsi.c |   76 ---
 3 files changed, 132 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 2fdbed9b2b04..24a91613c4f5 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -1089,6 +1089,39 @@ static int tegra_dc_wait_idle(struct tegra_dc *dc, 
unsigned long timeout)
return -ETIMEDOUT;
 }

+static void tegra_dc_dpms(struct drm_crtc *crtc, int mode)
+{
+   struct tegra_dc *dc = to_tegra_dc(crtc);
+   int err;
+   unsigned long value;
+
+   if (mode == DRM_MODE_DPMS_SUSPEND) {
+   tegra_dc_stop(dc);
+   clk_disable_unprepare(dc->clk);
+
+   /*
+* TODO: Powergate dc. This requires we re-init all stuffs
+* next time we want to trigger the one-shot.
+*/
+   }
+
+   if (mode == DRM_MODE_DPMS_STANDBY) {
+   /*
+* TODO: Unpowergate dc if dc is powergated during DPMS SUSPEND
+*/
+   err = clk_prepare_enable(dc->clk);
+   if (err < 0) {
+   dev_err(dc->dev, "failed to enable clock: %d\n", err);
+   return;
+   }
+
+   value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
+   value &= ~DISP_CTRL_MODE_MASK;
+   value |= DISP_CTRL_MODE_NC_DISPLAY;
+   tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
+   }
+}
+
 static void tegra_crtc_disable(struct drm_crtc *crtc)
 {
struct tegra_dc *dc = to_tegra_dc(crtc);
@@ -1318,6 +1351,7 @@ static void tegra_crtc_atomic_flush(struct drm_crtc *crtc)
 }

 static const struct drm_crtc_helper_funcs tegra_crtc_helper_funcs = {
+   .dpms = tegra_dc_dpms,
.disable = tegra_crtc_disable,
.mode_fixup = tegra_crtc_mode_fixup,
.mode_set_nofb = tegra_crtc_mode_set_nofb,
@@ -1331,6 +1365,7 @@ static const struct drm_crtc_helper_funcs 
tegra_crtc_helper_funcs = {
 static irqreturn_t tegra_dc_irq(int irq, void *data)
 {
struct tegra_dc *dc = data;
+   struct drm_display_mode *mode = &dc->base.state->adjusted_mode;
unsigned long status;

status = tegra_dc_readl(dc, DC_CMD_INT_STATUS);
@@ -1348,6 +1383,9 @@ static irqreturn_t tegra_dc_irq(int irq, void *data)
*/
drm_crtc_handle_vblank(&dc->base);
tegra_dc_finish_page_flip(dc);
+
+   if (mode->private_flags & DRM_PANEL_FLAG_PREFER_ONE_SHOT)
+   schedule_work(&dc->one_shot_work);
}

if (status & (WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT)) {
@@ -1901,6 +1939,25 @@ static int tegra_dc_parse_dt(struct tegra_dc *dc)
return 0;
 }

+static void tegra_dc_one_shot_work(struct work_struct *work)
+{
+   struct tegra_dc *dc;
+   struct drm_connector *connector;
+   struct drm_device *drm;
+
+   dc = container_of(work, struct tegra_dc, one_shot_work);
+   drm = dc->base.dev;
+
+   dev_dbg(dc->dev, "one-shot: Suspend encoder & connector.\n");
+   drm_modeset_lock_all(drm);
+   list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
+   if (connector->funcs->dpms)
+   connector->funcs->dpms(connector,
+   DRM_MODE_DPMS_SUSPEND);
+   }
+   drm_modeset_unlock_all(drm);
+}
+
 static int tegra_dc_probe(struct platform_device *pdev)
 {
unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED;
@@ -1919,6 +1976,7 @@ static int tegra_dc_probe(struct platform_device *pdev)

spin_lock_init(&dc->lock);
INIT_LIST_HEAD(&dc->list);
+   INIT_WORK(&dc->one_shot_work, tegra_dc_one_shot_work);
dc->dev = &pdev->dev;
dc->soc = id->data;

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 659b2fcc986d..00daf427c831 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -12,6 +12,7 @@

 #include 
 #include 
+#include 

 #include 
 #include 
@@ -130,6 +131,8 @@ struct tegra_dc {
/* page-flip handling */
struct drm_pending_vblank_event *event;

+   struct work_struct one_shot_work;
+
const struct tegra_dc_soc_info *soc;

struct iommu_domain *domain;
diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
index ed970f622903..1d21f149d7f2 100644
--- a/drivers/gpu/drm/tegra/dsi.c
+++ b/drivers/gpu/drm/tegra/dsi.c
@@ -726,10 +726,6 @@ static void tegra_dsi_soft_reset(struct tegra_dsi *dsi)
tegra_dsi_soft_reset(dsi->slave);
 }

-static void tegra_dsi_connector_dpms(struct drm_connector *connector, int mode)
-{
-}
-
 static void tegra_dsi_connector_reset(struct drm_connector *connector)
 {

[PATCH v2 09/12] drm: panel: Add idle/busy in Sharp lq101r1sx01 driver

2015-07-01 Thread Mark Zhang
Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c |   26 +++
 1 file changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c 
b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
index e32f1449b067..64eb437ee7b3 100644
--- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
+++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
@@ -89,6 +89,18 @@ static __maybe_unused int sharp_panel_read(struct 
sharp_panel *sharp,
return err;
 }

+static int sharp_panel_idle(struct drm_panel *panel)
+{
+   struct sharp_panel *sharp = to_sharp_panel(panel);
+   int err = 0;
+
+   err = mipi_dsi_dcs_enter_idle_mode(sharp->link1);
+   if (err < 0)
+   dev_err(panel->dev, "failed to enter idle: %d\n", err);
+
+   return err;
+}
+
 static int sharp_panel_disable(struct drm_panel *panel)
 {
struct sharp_panel *sharp = to_sharp_panel(panel);
@@ -167,6 +179,18 @@ static int sharp_setup_symmetrical_split(struct 
mipi_dsi_device *left,
return 0;
 }

+static int sharp_panel_busy(struct drm_panel *panel)
+{
+   struct sharp_panel *sharp = to_sharp_panel(panel);
+   int err = 0;
+
+   err = mipi_dsi_dcs_exit_idle_mode(sharp->link1);
+   if (err < 0)
+   dev_err(panel->dev, "failed to exit idle: %d\n", err);
+
+   return err;
+}
+
 static int sharp_panel_prepare(struct drm_panel *panel)
 {
struct sharp_panel *sharp = to_sharp_panel(panel);
@@ -318,6 +342,8 @@ static int sharp_panel_get_modes(struct drm_panel *panel)
 }

 static const struct drm_panel_funcs sharp_panel_funcs = {
+   .idle = sharp_panel_idle,
+   .busy = sharp_panel_busy,
.disable = sharp_panel_disable,
.unprepare = sharp_panel_unprepare,
.prepare = sharp_panel_prepare,
-- 
1.7.9.5



[PATCH v2 08/12] drm: dsi: Add "enter idle" & "exit idle" dcs functions

2015-07-01 Thread Mark Zhang
Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/drm_mipi_dsi.c |   36 
 include/drm/drm_mipi_dsi.h |2 ++
 2 files changed, 38 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 2d5ca8eec13a..9bc6ff75eb8f 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -862,6 +862,42 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device 
*dsi, u8 format)
 }
 EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);

+/**
+ * mipi_dsi_dcs_enter_idle_mode()
+ * @dsi: DSI peripheral device
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int mipi_dsi_dcs_enter_idle_mode(struct mipi_dsi_device *dsi)
+{
+   ssize_t err;
+
+   err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_IDLE_MODE, NULL, 0);
+   if (err < 0)
+   return err;
+
+   return 0;
+}
+EXPORT_SYMBOL(mipi_dsi_dcs_enter_idle_mode);
+
+/**
+ * mipi_dsi_dcs_exit_idle_mode()
+ * @dsi: DSI peripheral device
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int mipi_dsi_dcs_exit_idle_mode(struct mipi_dsi_device *dsi)
+{
+   ssize_t err;
+
+   err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_IDLE_MODE, NULL, 0);
+   if (err < 0)
+   return err;
+
+   return 0;
+}
+EXPORT_SYMBOL(mipi_dsi_dcs_exit_idle_mode);
+
 static int mipi_dsi_drv_probe(struct device *dev)
 {
struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index f1d8d0dbb4f1..d949a8ef389f 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -214,6 +214,8 @@ int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
 int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
 enum mipi_dsi_dcs_tear_mode mode);
 int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);
+int mipi_dsi_dcs_enter_idle_mode(struct mipi_dsi_device *dsi);
+int mipi_dsi_dcs_exit_idle_mode(struct mipi_dsi_device *dsi);

 /**
  * struct mipi_dsi_driver - DSI driver
-- 
1.7.9.5



[PATCH v2 07/12] drm/panel: Add panel func: idle/busy

2015-07-01 Thread Mark Zhang
The "idle" function of a drm panel is used to tell panel
there are no more frames coming in and it should remain the
last frame it gets.
Normally this only makes sense for smart panels which has
internal framebuffer.

The "busy" function is opposite to "idle".

Signed-off-by: Mark Zhang 
---
 include/drm/drm_panel.h |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index e53f48aa070f..77da292ad2fb 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -70,6 +70,8 @@ struct display_timing;
  * the panel. This is the job of the .unprepare() function.
  */
 struct drm_panel_funcs {
+   int (*idle)(struct drm_panel *panel);
+   int (*busy)(struct drm_panel *panel);
int (*disable)(struct drm_panel *panel);
int (*unprepare)(struct drm_panel *panel);
int (*prepare)(struct drm_panel *panel);
@@ -89,6 +91,22 @@ struct drm_panel {
struct list_head list;
 };

+static inline int drm_panel_idle(struct drm_panel *panel)
+{
+   if (panel && panel->funcs && panel->funcs->idle)
+   return panel->funcs->idle(panel);
+
+   return panel ? -ENOSYS : -EINVAL;
+}
+
+static inline int drm_panel_busy(struct drm_panel *panel)
+{
+   if (panel && panel->funcs && panel->funcs->busy)
+   return panel->funcs->busy(panel);
+
+   return panel ? -ENOSYS : -EINVAL;
+}
+
 static inline int drm_panel_unprepare(struct drm_panel *panel)
 {
if (panel && panel->funcs && panel->funcs->unprepare)
-- 
1.7.9.5



[PATCH v2 06/12] drm/tegra: Set NC(Non-contiguous) mode to dc for one-shot

2015-07-01 Thread Mark Zhang
If dc is about to work in one-shot mode, we need to set dc's scan
mode to NC(Non-contiguous).
There are 2 things which can make dc send frame again:
- TE signal is received
- Driver sets the NC_HOST_TRIG_ENABLE

Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/tegra/dc.c |   33 +++--
 drivers/gpu/drm/tegra/dc.h |5 +
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index a287e4fec865..2fdbed9b2b04 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -18,6 +18,7 @@
 #include "drm.h"
 #include "gem.h"

+#include 
 #include 
 #include 
 #include 
@@ -1248,10 +1249,26 @@ static void tegra_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
tegra_dc_writel(dc, value, DC_DISP_INTERLACE_CONTROL);
}

-   value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
-   value &= ~DISP_CTRL_MODE_MASK;
-   value |= DISP_CTRL_MODE_C_DISPLAY;
-   tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
+   if (mode->private_flags & DRM_PANEL_FLAG_PREFER_ONE_SHOT) {
+   /* enable MSF & set MSF polarity */
+   value = MSF_ENABLE | MSF_LSPI;
+   if (mode->private_flags & DRM_PANEL_FLAG_TE_POLARITY_HIGH)
+   value |= MSF_POLARITY_HIGH;
+   else
+   value |= MSF_POLARITY_LOW;
+   tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND_OPTION0);
+
+   /* set non-continuous mode */
+   value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
+   value &= ~DISP_CTRL_MODE_MASK;
+   value |= DISP_CTRL_MODE_NC_DISPLAY;
+   tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
+   } else {
+   value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
+   value &= ~DISP_CTRL_MODE_MASK;
+   value |= DISP_CTRL_MODE_C_DISPLAY;
+   tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
+   }

value = tegra_dc_readl(dc, DC_CMD_DISPLAY_POWER_CONTROL);
value |= PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
@@ -1339,6 +1356,9 @@ static irqreturn_t tegra_dc_irq(int irq, void *data)
*/
}

+   if (status & MSF_INT)
+   dev_dbg(dc->dev, "MSF_INT received.\n");
+
return IRQ_HANDLED;
 }

@@ -1732,10 +1752,11 @@ static int tegra_dc_init(struct host1x_client *client)
WINDOW_B_THRESHOLD(1) | WINDOW_C_THRESHOLD(1);
tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY_TIMER);

-   value = VBLANK_INT | WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT;
+   value = VBLANK_INT | WIN_A_UF_INT | WIN_B_UF_INT |
+   WIN_C_UF_INT | MSF_INT;
tegra_dc_writel(dc, value, DC_CMD_INT_ENABLE);

-   value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT;
+   value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | MSF_INT;
tegra_dc_writel(dc, value, DC_CMD_INT_MASK);

if (dc->soc->supports_border_color)
diff --git a/drivers/gpu/drm/tegra/dc.h b/drivers/gpu/drm/tegra/dc.h
index 55792daabbb5..4a2d0fec5853 100644
--- a/drivers/gpu/drm/tegra/dc.h
+++ b/drivers/gpu/drm/tegra/dc.h
@@ -27,6 +27,10 @@
 #define DC_CMD_CONT_SYNCPT_VSYNC   0x028
 #define  SYNCPT_VSYNC_ENABLE (1 << 8)
 #define DC_CMD_DISPLAY_COMMAND_OPTION0 0x031
+#define MSF_ENABLE (1 << 1)
+#define MSF_LSPI   (0 << 2)
+#define MSF_POLARITY_HIGH  (0 << 0)
+#define MSF_POLARITY_LOW   (1 << 0)
 #define DC_CMD_DISPLAY_COMMAND 0x032
 #define DISP_CTRL_MODE_STOP (0 << 5)
 #define DISP_CTRL_MODE_C_DISPLAY (1 << 5)
@@ -53,6 +57,7 @@
 #define WIN_A_UF_INT  (1 << 8)
 #define WIN_B_UF_INT  (1 << 9)
 #define WIN_C_UF_INT  (1 << 10)
+#define MSF_INT   (1 << 12)
 #define WIN_A_OF_INT  (1 << 14)
 #define WIN_B_OF_INT  (1 << 15)
 #define WIN_C_OF_INT  (1 << 16)
-- 
1.7.9.5



[PATCH v2 05/12] drm: panel: Set TE polarity flag in Sharp lq101r1sx01 driver

2015-07-01 Thread Mark Zhang
Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c 
b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
index fd04c419190c..e32f1449b067 100644
--- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
+++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
@@ -291,7 +291,8 @@ static const struct drm_display_mode default_mode = {
.vsync_end = 1600 + 4 + 8,
.vtotal = 1600 + 4 + 8 + 32,
.vrefresh = 60,
-   .private_flags = DRM_PANEL_FLAG_PREFER_ONE_SHOT,
+   .private_flags = DRM_PANEL_FLAG_PREFER_ONE_SHOT |
+DRM_PANEL_FLAG_TE_POLARITY_LOW,
 };

 static int sharp_panel_get_modes(struct drm_panel *panel)
-- 
1.7.9.5



[PATCH v2 04/12] drm: panel: Add DRM panel private mode flag: TE polarity

2015-07-01 Thread Mark Zhang
Add 2 DRM panel private mode flag: TE polarity high/low.

Signed-off-by: Mark Zhang 
---
 include/drm/drm_panel.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index 4d51cb380c75..e53f48aa070f 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -27,6 +27,8 @@
 #include 

 #define DRM_PANEL_FLAG_PREFER_ONE_SHOT (1 << 0)
+#define DRM_PANEL_FLAG_TE_POLARITY_HIGH(1 << 1)
+#define DRM_PANEL_FLAG_TE_POLARITY_LOW (1 << 2)

 struct drm_connector;
 struct drm_device;
-- 
1.7.9.5



[PATCH v2 03/12] drm: panel: Turn on TE(Tearing Effect) on Sharp lq101r1sx01

2015-07-01 Thread Mark Zhang
Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c 
b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
index da2cf7ab64c2..fd04c419190c 100644
--- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
+++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
@@ -238,6 +238,13 @@ static int sharp_panel_prepare(struct drm_panel *panel)
goto poweroff;
}

+   err = mipi_dsi_dcs_set_tear_on(sharp->link1,
+   MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+   if (err < 0) {
+   dev_err(panel->dev, "failed to turn on TE: %d\n", err);
+   goto poweroff;
+   }
+
err = mipi_dsi_dcs_set_display_on(sharp->link1);
if (err < 0) {
dev_err(panel->dev, "failed to set display on: %d\n", err);
-- 
1.7.9.5



[PATCH v2 02/12] drm: panel: Add one-shot flag to Sharp lq101r1sx01 driver

2015-07-01 Thread Mark Zhang
Sharp lq101r1sx01 has internal framebuffer so it doesn't
require crtc sending frames to it continuously.

Signed-off-by: Mark Zhang 
---
 drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c 
b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
index 3cce3ca19601..da2cf7ab64c2 100644
--- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
+++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
@@ -284,6 +284,7 @@ static const struct drm_display_mode default_mode = {
.vsync_end = 1600 + 4 + 8,
.vtotal = 1600 + 4 + 8 + 32,
.vrefresh = 60,
+   .private_flags = DRM_PANEL_FLAG_PREFER_ONE_SHOT,
 };

 static int sharp_panel_get_modes(struct drm_panel *panel)
-- 
1.7.9.5



[PATCH v2 01/12] drm: panel: Add a new private mode flag: DRM_PANEL_FLAG_PREFER_ONE_SHOT

2015-07-01 Thread Mark Zhang
Normally this flag is set by panel driver so that crtc can enable
the "one-shot" mode(not scan frames continuously).

Signed-off-by: Mark Zhang 
---
 include/drm/drm_panel.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index 13ff44b28893..4d51cb380c75 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -26,6 +26,8 @@

 #include 

+#define DRM_PANEL_FLAG_PREFER_ONE_SHOT (1 << 0)
+
 struct drm_connector;
 struct drm_device;
 struct drm_panel;
-- 
1.7.9.5



[PATCH v2 00/12] Tegra: Add DC one-shot support

2015-07-01 Thread Mark Zhang
This patch set adds the Tegra dc one-shot support. The patch set is
tested on Dalmore + Sharp lq101r1sx01.

Please be noticed that the patch #12 is not part of the feature,
it's just used for testing.

Changes in v2:
- Define one-shot flag in drm_display_mode->private_flags, according
  to Daniel's comments
- Remove the "te-polarity" property in dts. The TE polarity is determined
  by panel so there is not necessary to define it in DTS. We can define
  it in panel driver.
- Rebased the patch series on top of 6/29 linux-next.
- Fix a bug in DSI suspend DPMS event, to wait DSI idle before suspend
- Fix a bug in DSI driver to correct the DPMS state(patch #11)

Mark Zhang (12):
  drm: panel: Add a new private mode flag:
DRM_PANEL_FLAG_PREFER_ONE_SHOT
  drm: panel: Add one-shot flag to Sharp lq101r1sx01 driver
  drm: panel: Turn on TE(Tearing Effect) on Sharp lq101r1sx01
  drm: panel: Add DRM panel private mode flag: TE polarity
  drm: panel: Set TE polarity flag in Sharp lq101r1sx01 driver
  drm/tegra: Set NC(Non-contiguous) mode to dc for one-shot
  drm/panel: Add panel func: idle/busy
  drm: dsi: Add "enter idle" & "exit idle" dcs functions
  drm: panel: Add idle/busy in Sharp lq101r1sx01 driver
  drm/tegra: Suspend dc/dsi/panel in one-shot mode
  drm/tegra: dsi: Set connector DPMS state when enable/disable
  JUST FOR TEST: Add one-shot trigger to update display

 drivers/gpu/drm/drm_mipi_dsi.c  |   36 +++
 drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c |   35 +++
 drivers/gpu/drm/tegra/dc.c  |  128 +--
 drivers/gpu/drm/tegra/dc.h  |5 +
 drivers/gpu/drm/tegra/drm.h |4 +
 drivers/gpu/drm/tegra/dsi.c |   79 +-
 include/drm/drm_mipi_dsi.h  |2 +
 include/drm/drm_panel.h |   22 
 8 files changed, 300 insertions(+), 11 deletions(-)

-- 
1.7.9.5



WARNING: CPU: 0 PID: 3634 at drivers/gpu/drm/drm_irq.c:1141 drm_wait_one_vblank

2015-07-01 Thread Jani Nikula

+intel-gfx and Matt

On Wed, 01 Jul 2015, Michal Hocko  wrote:
> On Wed 01-07-15 10:26:39, Daniel Vetter wrote:
>> On Tue, Jun 30, 2015 at 10:13:35PM +0200, Michal Hocko wrote:
>> > On Tue 30-06-15 18:59:29, Daniel Vetter wrote:
> [...]
>> > > Also it might be time to start bisecting this if you can readily 
>> > > reproduce it.
>> > 
>> > Yes, I can reproduce it just by switching to the text console. Sometimes
>> > it is the first attempt already but sometimes it takes several attempts.
>> > I will try to go back to 4.0 and bisect it then.
>> 
>> Yes please do, since this is a confusing regression I think the bisect
>> result will be the fastest way forward.
>
> OK, managed to bisect to cf4c7c12258e ("drm/i915: Make all plane
> disables use 'update_plane' (v5)") (CC people involved - the thread
> starts here: http://marc.info/?l=dri-devel&m=143566543432613&w=2 for
> your reference).
>
> I do not see the warning when I revert the commit directly on top of
> cf4c7c12258e but I cannot cleanly revert it on top of the current Linus'
> tree. Anything more I can give you to help to further debug the issue?
>
> Bisect log is:
> git bisect start
> # bad: [c517d838eb7d07bbe9507871fab3931deccff539] Linux 4.0-rc1
> git bisect bad c517d838eb7d07bbe9507871fab3931deccff539
> # good: [bfa76d49576599a4b9f9b7a71f23d73d6dcff735] Linux 3.19
> git bisect good bfa76d49576599a4b9f9b7a71f23d73d6dcff735
> # good: [02f1f2170d2831b3233e91091c60a66622f29e82] kernel.h: remove ancient 
> __FUNCTION__ hack
> git bisect good 02f1f2170d2831b3233e91091c60a66622f29e82
> # bad: [796e1c55717e9a6ff5c81b12289ffa1ffd919b6f] Merge branch 'drm-next' of 
> git://people.freedesktop.org/~airlied/linux
> git bisect bad 796e1c55717e9a6ff5c81b12289ffa1ffd919b6f
> # good: [9682ec9692e5ac11c6caebd079324e727b19e7ce] Merge tag 
> 'driver-core-3.20-rc1' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
> git bisect good 9682ec9692e5ac11c6caebd079324e727b19e7ce
> # good: [a9724125ad014decf008d782e60447c811391326] Merge tag 'tty-3.20-rc1' 
> of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
> git bisect good a9724125ad014decf008d782e60447c811391326
> # bad: [f43dff0ee00a259f524ce17ba4f8030553c66590] Merge tag 
> 'drm-amdkfd-next-fixes-2015-01-25' of 
> git://people.freedesktop.org/~gabbayo/linux into drm-next
> git bisect bad f43dff0ee00a259f524ce17ba4f8030553c66590
> # good: [b942c653ae265abbd31032f3b4f5f857e5c7c723] Merge tag 'trace-sh-3.19' 
> of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
> git bisect good b942c653ae265abbd31032f3b4f5f857e5c7c723
> # good: [fcf3aac5fc307f0cae429f5844ddc25761662858] drm/i915: remove unused 
> power_well/get_cdclk_freq api
> git bisect good fcf3aac5fc307f0cae429f5844ddc25761662858
> # bad: [4f4d89af78682f2ed1cf6745794804817f867bba] Merge tag 
> 'drm-amdkfd-next-2015-01-09' of git://people.freedesktop.org/~gabbayo/linux 
> into drm-next
> git bisect bad 4f4d89af78682f2ed1cf6745794804817f867bba
> # bad: [64387b613a43713d0e03d9d43bfbb1727e8475e1] drm/i915: Protect against 
> leaks in pipe_crc_set_source
> git bisect bad 64387b613a43713d0e03d9d43bfbb1727e8475e1
> # good: [bfc882b4e30fbc169ecfe3508378623743806f56] drm/i915: Flatten engine 
> init control flow
> git bisect good bfc882b4e30fbc169ecfe3508378623743806f56
> # good: [2b875c22fa77dfc895d3cf8287a553813d3e64c8] drm/i915: Make 
> intel_plane_state subclass drm_plane_state
> git bisect good 2b875c22fa77dfc895d3cf8287a553813d3e64c8
> # bad: [15a17aae5f803551981a7acc6a4058b247a7452c] drm/i915: Check mask/bit 
> helper functions
> git bisect bad 15a17aae5f803551981a7acc6a4058b247a7452c
> # bad: [146d84f0f2707bfe2c67114eeefac30da8584b3b] drm/i915: Fix up seqno -> 
> request merge issues
> git bisect bad 146d84f0f2707bfe2c67114eeefac30da8584b3b
> # good: [c59cb179aaf444931cf9c547a514e383da3d2526] drm/i915: Consolidate 
> top-level .update_plane() handlers
> git bisect good c59cb179aaf444931cf9c547a514e383da3d2526
> # bad: [cf4c7c12258ed9367f4fc45238f5f50d2db892c1] drm/i915: Make all plane 
> disables use 'update_plane' (v5)
> git bisect bad cf4c7c12258ed9367f4fc45238f5f50d2db892c1
> # good: [e614c3c946ae5b50a679d65d2c981615d8ceccab] drm/i915: Ensure 
> state->crtc is non-NULL for plane updates
> git bisect good e614c3c946ae5b50a679d65d2c981615d8ceccab
> # first bad commit: [cf4c7c12258ed9367f4fc45238f5f50d2db892c1] drm/i915: Make 
> all plane disables use 'update_plane' (v5)
> -- 
> Michal Hocko
> SUSE Labs
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH v2 08/12] drm: dsi: Add "enter idle" & "exit idle" dcs functions

2015-07-01 Thread Varka Bhadram
On 07/01/2015 01:51 PM, Mark Zhang wrote:
> Signed-off-by: Mark Zhang
> ---
>   drivers/gpu/drm/drm_mipi_dsi.c |   36 
>   include/drm/drm_mipi_dsi.h |2 ++
>   2 files changed, 38 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index 2d5ca8eec13a..9bc6ff75eb8f 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -862,6 +862,42 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device 
> *dsi, u8 format)
>   }
>   EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);
>   
> +/**
> + * mipi_dsi_dcs_enter_idle_mode()
> + * @dsi: DSI peripheral device
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int mipi_dsi_dcs_enter_idle_mode(struct mipi_dsi_device *dsi)
> +{
> + ssize_t err;
> +
> + err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_IDLE_MODE, NULL, 0);
> + if (err < 0)
> + return err;
> +
> + return 0;
> +}

This we can do simply as:
return mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_IDLE_MODE, NULL, 0);

> +EXPORT_SYMBOL(mipi_dsi_dcs_enter_idle_mode);
> +
> +/**
> + * mipi_dsi_dcs_exit_idle_mode()
> + * @dsi: DSI peripheral device
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int mipi_dsi_dcs_exit_idle_mode(struct mipi_dsi_device *dsi)
> +{
> + ssize_t err;
> +
> + err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_IDLE_MODE, NULL, 0);
> + if (err < 0)
> + return err;
> +
> + return 0;

For this one also: return mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_IDLE_MODE, 
NULL, 0);


-- 
Varka Bhadram.



[PATCH] intel: wrap intel_bufmgr.h C code for C++ compilation/linking

2015-07-01 Thread Tapani Pälli
(We need this include in porting changes for the OpenGL ES
conformance suite.)

Signed-off-by: Tapani Pälli 
---
 intel/intel_bufmgr.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index 285919e..f061454 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -38,6 +38,10 @@
 #include 
 #include 

+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 struct drm_clip_rect;

 typedef struct _drm_intel_bufmgr drm_intel_bufmgr;
@@ -308,4 +312,8 @@ int drm_intel_get_eu_total(int fd, unsigned int *eu_total);

 /** @{ */

+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
 #endif /* INTEL_BUFMGR_H */
-- 
2.1.0



[PATCH] drm: Remove useless blank line

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 02:05:09PM +0200, Thierry Reding wrote:
> From: Thierry Reding 
> 
> Blank lines at the end of a function definition are not useful, so get
> rid of it.
> 
> Signed-off-by: Thierry Reding 

Applied to topic/drm-misc, thanks.
-Daniel

> ---
>  drivers/gpu/drm/drm_crtc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 2906694012b8..4997541c93fc 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -4298,7 +4298,6 @@ void drm_property_unreference_blob(struct 
> drm_property_blob *blob)
>   mutex_unlock(&dev->mode_config.blob_lock);
>   else
>   might_lock(&dev->mode_config.blob_lock);
> -
>  }
>  EXPORT_SYMBOL(drm_property_unreference_blob);
>  
> -- 
> 2.4.1
> 
> ___
> 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


WARNING: CPU: 0 PID: 3634 at drivers/gpu/drm/drm_irq.c:1141 drm_wait_one_vblank

2015-07-01 Thread Michal Hocko
On Wed 01-07-15 10:26:39, Daniel Vetter wrote:
> On Tue, Jun 30, 2015 at 10:13:35PM +0200, Michal Hocko wrote:
> > On Tue 30-06-15 18:59:29, Daniel Vetter wrote:
[...]
> > > Also it might be time to start bisecting this if you can readily 
> > > reproduce it.
> > 
> > Yes, I can reproduce it just by switching to the text console. Sometimes
> > it is the first attempt already but sometimes it takes several attempts.
> > I will try to go back to 4.0 and bisect it then.
> 
> Yes please do, since this is a confusing regression I think the bisect
> result will be the fastest way forward.

OK, managed to bisect to cf4c7c12258e ("drm/i915: Make all plane
disables use 'update_plane' (v5)") (CC people involved - the thread
starts here: http://marc.info/?l=dri-devel&m=143566543432613&w=2 for
your reference).

I do not see the warning when I revert the commit directly on top of
cf4c7c12258e but I cannot cleanly revert it on top of the current Linus'
tree. Anything more I can give you to help to further debug the issue?

Bisect log is:
git bisect start
# bad: [c517d838eb7d07bbe9507871fab3931deccff539] Linux 4.0-rc1
git bisect bad c517d838eb7d07bbe9507871fab3931deccff539
# good: [bfa76d49576599a4b9f9b7a71f23d73d6dcff735] Linux 3.19
git bisect good bfa76d49576599a4b9f9b7a71f23d73d6dcff735
# good: [02f1f2170d2831b3233e91091c60a66622f29e82] kernel.h: remove ancient 
__FUNCTION__ hack
git bisect good 02f1f2170d2831b3233e91091c60a66622f29e82
# bad: [796e1c55717e9a6ff5c81b12289ffa1ffd919b6f] Merge branch 'drm-next' of 
git://people.freedesktop.org/~airlied/linux
git bisect bad 796e1c55717e9a6ff5c81b12289ffa1ffd919b6f
# good: [9682ec9692e5ac11c6caebd079324e727b19e7ce] Merge tag 
'driver-core-3.20-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
git bisect good 9682ec9692e5ac11c6caebd079324e727b19e7ce
# good: [a9724125ad014decf008d782e60447c811391326] Merge tag 'tty-3.20-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
git bisect good a9724125ad014decf008d782e60447c811391326
# bad: [f43dff0ee00a259f524ce17ba4f8030553c66590] Merge tag 
'drm-amdkfd-next-fixes-2015-01-25' of 
git://people.freedesktop.org/~gabbayo/linux into drm-next
git bisect bad f43dff0ee00a259f524ce17ba4f8030553c66590
# good: [b942c653ae265abbd31032f3b4f5f857e5c7c723] Merge tag 'trace-sh-3.19' of 
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
git bisect good b942c653ae265abbd31032f3b4f5f857e5c7c723
# good: [fcf3aac5fc307f0cae429f5844ddc25761662858] drm/i915: remove unused 
power_well/get_cdclk_freq api
git bisect good fcf3aac5fc307f0cae429f5844ddc25761662858
# bad: [4f4d89af78682f2ed1cf6745794804817f867bba] Merge tag 
'drm-amdkfd-next-2015-01-09' of git://people.freedesktop.org/~gabbayo/linux 
into drm-next
git bisect bad 4f4d89af78682f2ed1cf6745794804817f867bba
# bad: [64387b613a43713d0e03d9d43bfbb1727e8475e1] drm/i915: Protect against 
leaks in pipe_crc_set_source
git bisect bad 64387b613a43713d0e03d9d43bfbb1727e8475e1
# good: [bfc882b4e30fbc169ecfe3508378623743806f56] drm/i915: Flatten engine 
init control flow
git bisect good bfc882b4e30fbc169ecfe3508378623743806f56
# good: [2b875c22fa77dfc895d3cf8287a553813d3e64c8] drm/i915: Make 
intel_plane_state subclass drm_plane_state
git bisect good 2b875c22fa77dfc895d3cf8287a553813d3e64c8
# bad: [15a17aae5f803551981a7acc6a4058b247a7452c] drm/i915: Check mask/bit 
helper functions
git bisect bad 15a17aae5f803551981a7acc6a4058b247a7452c
# bad: [146d84f0f2707bfe2c67114eeefac30da8584b3b] drm/i915: Fix up seqno -> 
request merge issues
git bisect bad 146d84f0f2707bfe2c67114eeefac30da8584b3b
# good: [c59cb179aaf444931cf9c547a514e383da3d2526] drm/i915: Consolidate 
top-level .update_plane() handlers
git bisect good c59cb179aaf444931cf9c547a514e383da3d2526
# bad: [cf4c7c12258ed9367f4fc45238f5f50d2db892c1] drm/i915: Make all plane 
disables use 'update_plane' (v5)
git bisect bad cf4c7c12258ed9367f4fc45238f5f50d2db892c1
# good: [e614c3c946ae5b50a679d65d2c981615d8ceccab] drm/i915: Ensure state->crtc 
is non-NULL for plane updates
git bisect good e614c3c946ae5b50a679d65d2c981615d8ceccab
# first bad commit: [cf4c7c12258ed9367f4fc45238f5f50d2db892c1] drm/i915: Make 
all plane disables use 'update_plane' (v5)
-- 
Michal Hocko
SUSE Labs


[PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized

2015-07-01 Thread Ilia Mirkin
On Wed, Jul 1, 2015 at 1:59 PM, Emil Velikov  
wrote:
> On 1 July 2015 at 18:37, Ilia Mirkin  wrote:
>> On Wed, Jul 1, 2015 at 1:18 PM, Colin Ian King  
>> wrote:
>>> On 01/07/15 18:12, Emil Velikov wrote:
 On 1 July 2015 at 17:56, Ilia Mirkin  wrote:
> On Wed, Jul 1, 2015 at 12:51 PM, Colin King  
> wrote:
>> From: Colin Ian King 
>>
>> Various usif_ioctl helper functions do not initialize the
>> return variable ret and some of the error handling return
>> paths just return garbage values that were on the stack (or
>> in a register).  I believe that in all the cases, the
>> initial ret variable should be set to -EINVAL and subsequent
>> paths through these helper functions set it appropriately
>> otherwise.
>>
>> Found via static analysis using cppcheck:
>>
>> [drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
>> (error) Uninitialized variable: ret
>
> It sure would seem that way, wouldn't it?
>
> #define nvif_unpack(d,vl,vh,m) ({ 
>  \
> if ((vl) == 0 || ret == -ENOSYS) {
>  \
> int _size = sizeof(d);
>  \
> if (_size <= size && (d).version >= (vl) &&   
>  \
>  (d).version <= (vh)) {   
>  \
> data = (u8 *)data + _size;
>  \
> size = size - _size;  
>  \
> ret = ((m) || !size) ? 0 : -E2BIG;
>  \
> } else {  
>  \
> ret = -ENOSYS;
>  \
> } 
>  \
> } 
>  \
> (ret == 0);   
>  \
> })
>
> So actually it does get initialized, and I guess cppcheck doesn't know
> about macros?
>>>
>>> Hrm, what about the case when ((vl) == 0 || ret == -ENOSYS) is false,
>>> where is ret being set in that case?
>>
>> Is that actually the case for any of the callsites? gcc would complain
>> about that...
> There is one:
>
> drm/nouveau/nvkm/engine/disp/nv50.c: if (nvif_unpack(args->v1, 1, 1, true))
>
> Seems like a recent addition though,  I don't recall it with back when
> was introduced.

It follows a call to nvif_unpack(0) though, which will initialize ret.


[PATCH] drm: Remove useless blank line

2015-07-01 Thread Thierry Reding
From: Thierry Reding 

Blank lines at the end of a function definition are not useful, so get
rid of it.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_crtc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 2906694012b8..4997541c93fc 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4298,7 +4298,6 @@ void drm_property_unreference_blob(struct 
drm_property_blob *blob)
mutex_unlock(&dev->mode_config.blob_lock);
else
might_lock(&dev->mode_config.blob_lock);
-
 }
 EXPORT_SYMBOL(drm_property_unreference_blob);

-- 
2.4.1



[Bug 73528] Deferred lighting in Second Life causes system hiccups and screen flickering

2015-07-01 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=73528

MirceaKitsune  changed:

   What|Removed |Added

Version|10.3|git
   Severity|major   |critical

--- Comment #32 from MirceaKitsune  ---
Today I downloaded a new Linux native game. One of its shaders also triggers
this issue, causing the GPU to freeze and the monitor to keep resetting while
the shader is active. Unfortunately, the game didn't include any settings to
disable this specific shader. I had to abandon playing it for the time being,
as doing so it eventually brought down my X server and forced me to restart.

I understand that Mesa is open-source software, which the developers are
probably not paid to maintain and do so voluntarily. Even so, it's becoming
frustrating that for two years there is barely anyone even taking notice of
this report. Especially after I found the guilty commit in a GIT bisect, tested
two patches, and even posted a replicable trace!

I'm setting the task's priority to Urgent, since I don't know what else I can
do to get the developer's attention. I'm also changing the version to GIT,
because latest master itself still has this problem.

Please, help fix this major issue! This is a major problem and has no
workarounds!

-- 
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/20150701/954c6122/attachment-0001.html>


[PATCH] drm/rockchip: vop: remove hardware cursor window

2015-07-01 Thread Heiko Stübner
Hi Mark,

Am Mittwoch, 1. Juli 2015, 17:49:33 schrieb Mark Yao:
> hardware cursor windows only have some fixed size, and not support
> width virtual, when move hardware cursor windows outside of left,
> the display would be wrong, so this window can't for cursor now.
> 
> And Tag hardware cursor window as a overlay is wrong, will make
> userspace wrong behaviour.
> 
> So just remove the hardware cursor window
> 
> Signed-off-by: Mark Yao 
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 4603412..7373ba1 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -368,7 +368,6 @@ static const struct vop_win_data rk3288_vop_win_data[] =
> { { .base = 0x40, .phy = &win01_data, .type = DRM_PLANE_TYPE_OVERLAY }, {
> .base = 0x00, .phy = &win23_data, .type = DRM_PLANE_TYPE_OVERLAY }, { .base
> = 0x50, .phy = &win23_data, .type = DRM_PLANE_TYPE_CURSOR }, -{ .base 
> =
> 0x00, .phy = &cursor_data, .type = DRM_PLANE_TYPE_OVERLAY }, };
> 
>  static const struct vop_data rk3288_vop = {

you should probably also remove the

static const struct vop_win_phy cursor_data

completely then, as it is now unused?


Heiko


[PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized

2015-07-01 Thread Ilia Mirkin
On Wed, Jul 1, 2015 at 1:18 PM, Colin Ian King  
wrote:
> On 01/07/15 18:12, Emil Velikov wrote:
>> On 1 July 2015 at 17:56, Ilia Mirkin  wrote:
>>> On Wed, Jul 1, 2015 at 12:51 PM, Colin King  
>>> wrote:
 From: Colin Ian King 

 Various usif_ioctl helper functions do not initialize the
 return variable ret and some of the error handling return
 paths just return garbage values that were on the stack (or
 in a register).  I believe that in all the cases, the
 initial ret variable should be set to -EINVAL and subsequent
 paths through these helper functions set it appropriately
 otherwise.

 Found via static analysis using cppcheck:

 [drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
 (error) Uninitialized variable: ret
>>>
>>> It sure would seem that way, wouldn't it?
>>>
>>> #define nvif_unpack(d,vl,vh,m) ({   
>>>\
>>> if ((vl) == 0 || ret == -ENOSYS) {  
>>>\
>>> int _size = sizeof(d);  
>>>\
>>> if (_size <= size && (d).version >= (vl) && 
>>>\
>>>  (d).version <= (vh)) { 
>>>\
>>> data = (u8 *)data + _size;  
>>>\
>>> size = size - _size;
>>>\
>>> ret = ((m) || !size) ? 0 : -E2BIG;  
>>>\
>>> } else {
>>>\
>>> ret = -ENOSYS;  
>>>\
>>> }   
>>>\
>>> }   
>>>\
>>> (ret == 0); 
>>>\
>>> })
>>>
>>> So actually it does get initialized, and I guess cppcheck doesn't know
>>> about macros?
>
> Hrm, what about the case when ((vl) == 0 || ret == -ENOSYS) is false,
> where is ret being set in that case?

Is that actually the case for any of the callsites? gcc would complain
about that...


[PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized

2015-07-01 Thread Ilia Mirkin
On Wed, Jul 1, 2015 at 12:51 PM, Colin King  wrote:
> From: Colin Ian King 
>
> Various usif_ioctl helper functions do not initialize the
> return variable ret and some of the error handling return
> paths just return garbage values that were on the stack (or
> in a register).  I believe that in all the cases, the
> initial ret variable should be set to -EINVAL and subsequent
> paths through these helper functions set it appropriately
> otherwise.
>
> Found via static analysis using cppcheck:
>
> [drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
> (error) Uninitialized variable: ret

It sure would seem that way, wouldn't it?

#define nvif_unpack(d,vl,vh,m) ({  \
if ((vl) == 0 || ret == -ENOSYS) { \
int _size = sizeof(d); \
if (_size <= size && (d).version >= (vl) &&\
 (d).version <= (vh)) {\
data = (u8 *)data + _size; \
size = size - _size;   \
ret = ((m) || !size) ? 0 : -E2BIG; \
} else {   \
ret = -ENOSYS; \
}  \
}  \
(ret == 0);\
})

So actually it does get initialized, and I guess cppcheck doesn't know
about macros?

> [drivers/gpu/drm/nouveau/nouveau_usif.c:179]:
> (error) Uninitialized variable: ret
> [drivers/gpu/drm/nouveau/nouveau_usif.c:202]:
> (error) Uninitialized variable: ret
> [drivers/gpu/drm/nouveau/nouveau_usif.c:241]:
> (error) Uninitialized variable: ret
> [drivers/gpu/drm/nouveau/nouveau_usif.c:157]:
> (error) Uninitialized variable: ret
> [drivers/gpu/drm/nouveau/nouveau_usif.c:288]:
> (error) Uninitialized variable: ret
>
> Signed-off-by: Colin Ian King 
> ---
>  drivers/gpu/drm/nouveau/nouveau_usif.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c 
> b/drivers/gpu/drm/nouveau/nouveau_usif.c
> index cb1182d..01b50a2 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_usif.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
> @@ -129,7 +129,7 @@ usif_notify_new(struct drm_file *f, void *data, u32 size, 
> void *argv, u32 argc)
> struct nvif_notify_req_v0 v0;
> } *req;
> struct usif_notify *ntfy;
> -   int ret;
> +   int ret = -EINVAL;
>
> if (nvif_unpack(args->v0, 0, 0, true)) {
> if (usif_notify_find(f, args->v0.index))
> @@ -170,7 +170,7 @@ usif_notify_del(struct drm_file *f, void *data, u32 size, 
> void *argv, u32 argc)
> struct nvif_ioctl_ntfy_del_v0 v0;
> } *args = data;
> struct usif_notify *ntfy;
> -   int ret;
> +   int ret = -EINVAL;
>
> if (nvif_unpack(args->v0, 0, 0, true)) {
> if (!(ntfy = usif_notify_find(f, args->v0.index)))
> @@ -193,7 +193,7 @@ usif_notify_get(struct drm_file *f, void *data, u32 size, 
> void *argv, u32 argc)
> struct nvif_ioctl_ntfy_del_v0 v0;
> } *args = data;
> struct usif_notify *ntfy;
> -   int ret;
> +   int ret = -EINVAL;
>
> if (nvif_unpack(args->v0, 0, 0, true)) {
> if (!(ntfy = usif_notify_find(f, args->v0.index)))
> @@ -232,7 +232,7 @@ usif_notify_put(struct drm_file *f, void *data, u32 size, 
> void *argv, u32 argc)
> struct nvif_ioctl_ntfy_put_v0 v0;
> } *args = data;
> struct usif_notify *ntfy;
> -   int ret;
> +   int ret = -EINVAL;
>
> if (nvif_unpack(args->v0, 0, 0, true)) {
> if (!(ntfy = usif_notify_find(f, args->v0.index)))
> @@ -269,7 +269,7 @@ usif_object_new(struct drm_file *f, void *data, u32 size, 
> void *argv, u32 argc)
> struct nvif_ioctl_new_v0 v0;
> } *args = data;
> struct usif_object *object;
> -   int ret;
> +   int ret = -EINVAL;
>
> if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
> return -ENOMEM;
> --
> 2.1.4
>
> --
> 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 v2 12/12] JUST FOR TEST: Add one-shot trigger to update display

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 05:01:52PM +0800, Mark Zhang wrote:
> On 07/01/2015 04:36 PM, Daniel Vetter wrote:
> > On Wed, Jul 01, 2015 at 04:21:55PM +0800, Mark Zhang wrote:
> >> This HACK adds a workqueue to refresh the display periodically.
> >> This is used just for testing.
> > 
> > ->dirty is the drm hook you're looking for, it's meant to flush out any
> > frontbuffer rendering. Generic kms clients using the dumb buffers (e.g.
> > fedora boot splash) use this already.
> > 
> 
> Oh... I did a grep in drm source and are you talking about
> "drm_framebuffer_funcs->dirty"? Yeah, that should work for me.. but that
> requires userspace sending IOCTL to trigger, right? Honestly I'm lazy so
> I created this HACK so that I don't need userspace to test.

Yeah userspace needs to send ioctl already after each drawing. Generic
userspace does that already since it's required by qxl, udl, soon i915 and
probably a few others too. fbdev emulation is more annyoing but there's
code to move around in these drivers (qxl seems best to me as a starting
point) too.

Imo without this you shouldn't merge one-shot, at least not enabled by
default.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH] drm: remove redundant code form drm_ioc32.c

2015-07-01 Thread Jarkko Sakkinen
The compat ioctl handler ends up calling access_ok() twice: first
indirectly inside compat_alloc_user_space() and then after returning
from that function. This patch fixes issue.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/gpu/drm/drm_ioc32.c | 55 +
 1 file changed, 26 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index aa8bbb4..77b63e7 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -93,7 +93,7 @@ static int compat_drm_version(struct file *file, unsigned int 
cmd,
return -EFAULT;

version = compat_alloc_user_space(sizeof(*version));
-   if (!access_ok(VERIFY_WRITE, version, sizeof(*version)))
+   if (!version)
return -EFAULT;
if (__put_user(v32.name_len, &version->name_len)
|| __put_user((void __user *)(unsigned long)v32.name,
@@ -140,7 +140,7 @@ static int compat_drm_getunique(struct file *file, unsigned 
int cmd,
return -EFAULT;

u = compat_alloc_user_space(sizeof(*u));
-   if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
+   if (!u)
return -EFAULT;
if (__put_user(uq32.unique_len, &u->unique_len)
|| __put_user((void __user *)(unsigned long)uq32.unique,
@@ -168,7 +168,7 @@ static int compat_drm_setunique(struct file *file, unsigned 
int cmd,
return -EFAULT;

u = compat_alloc_user_space(sizeof(*u));
-   if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
+   if (!u)
return -EFAULT;
if (__put_user(uq32.unique_len, &u->unique_len)
|| __put_user((void __user *)(unsigned long)uq32.unique,
@@ -200,7 +200,7 @@ static int compat_drm_getmap(struct file *file, unsigned 
int cmd,
return -EFAULT;

map = compat_alloc_user_space(sizeof(*map));
-   if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
+   if (!map)
return -EFAULT;
if (__put_user(idx, &map->offset))
return -EFAULT;
@@ -237,7 +237,7 @@ static int compat_drm_addmap(struct file *file, unsigned 
int cmd,
return -EFAULT;

map = compat_alloc_user_space(sizeof(*map));
-   if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
+   if (!map)
return -EFAULT;
if (__put_user(m32.offset, &map->offset)
|| __put_user(m32.size, &map->size)
@@ -277,7 +277,7 @@ static int compat_drm_rmmap(struct file *file, unsigned int 
cmd,
return -EFAULT;

map = compat_alloc_user_space(sizeof(*map));
-   if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
+   if (!map)
return -EFAULT;
if (__put_user((void *)(unsigned long)handle, &map->handle))
return -EFAULT;
@@ -306,7 +306,7 @@ static int compat_drm_getclient(struct file *file, unsigned 
int cmd,
return -EFAULT;

client = compat_alloc_user_space(sizeof(*client));
-   if (!access_ok(VERIFY_WRITE, client, sizeof(*client)))
+   if (!client)
return -EFAULT;
if (__put_user(idx, &client->idx))
return -EFAULT;
@@ -345,7 +345,7 @@ static int compat_drm_getstats(struct file *file, unsigned 
int cmd,
int i, err;

stats = compat_alloc_user_space(sizeof(*stats));
-   if (!access_ok(VERIFY_WRITE, stats, sizeof(*stats)))
+   if (!stats)
return -EFAULT;

err = drm_ioctl(file, DRM_IOCTL_GET_STATS, (unsigned long)stats);
@@ -382,8 +382,7 @@ static int compat_drm_addbufs(struct file *file, unsigned 
int cmd,
unsigned long agp_start;

buf = compat_alloc_user_space(sizeof(*buf));
-   if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf))
-   || !access_ok(VERIFY_WRITE, argp, sizeof(*argp)))
+   if (!buf || !argp)
return -EFAULT;

if (__copy_in_user(buf, argp, offsetof(drm_buf_desc32_t, agp_start))
@@ -414,7 +413,7 @@ static int compat_drm_markbufs(struct file *file, unsigned 
int cmd,
return -EFAULT;

buf = compat_alloc_user_space(sizeof(*buf));
-   if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf)))
+   if (!buf)
return -EFAULT;

if (__put_user(b32.size, &buf->size)
@@ -455,7 +454,7 @@ static int compat_drm_infobufs(struct file *file, unsigned 
int cmd,

nbytes = sizeof(*request) + count * sizeof(struct drm_buf_desc);
request = compat_alloc_user_space(nbytes);
-   if (!access_ok(VERIFY_WRITE, request, nbytes))
+   if (!request)
return -EFAULT;
list = (struct drm_buf_desc *) (request + 1);

@@ -516,7 +515,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned 
int cmd,
return -EINVAL;
nbytes = sizeof(*request) + count * sizeof(struct drm_buf_pub);
request = compat_alloc_user_space(nbytes);
-   if (!access_ok(VERIFY_WRITE, request,

[PATCH v2 12/12] driver-core: probe dependencies before probing

2015-07-01 Thread Tomeu Vizoso
Before actually probing a device, find out what dependencies it has and
do our best to ensure that they are available at this point.

This is accomplished by finding out what platform devices need to be
probed and probing them. Non-platform devices will be probed when the
closest ancestor that is a platform device is probed.

If any dependencies are still unavailable after that (most probably a
missing driver or an error in the HW description from the firmware), we
print a nice error message so that people don't have to add a zillion of
printks to find out why a device asked for its probe to be deferred.

Dependencies are discovered with the help of the code that is already
implementing the specification of the firmware bindings, via the
callbacks registered with fwnode_add_dependency_parser().

Currently the dependencies list is discarded but it could be stored for
later usage.

Signed-off-by: Tomeu Vizoso 
tegra, kernel, usb
---

Changes in v2:
- Allocate the list of dependencies and pass it to the function that
  fills it.

 drivers/base/dd.c | 139 ++
 1 file changed, 139 insertions(+)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a638bbb..c8a1aff 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -25,6 +25,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 

 #include "base.h"
 #include "power/power.h"
@@ -54,6 +57,140 @@ static LIST_HEAD(deferred_probe_active_list);
 static struct workqueue_struct *deferred_wq;
 static atomic_t deferred_trigger_count = ATOMIC_INIT(0);

+static bool device_is_bound(struct device *dev)
+{
+   return klist_node_attached(&dev->p->knode_driver);
+}
+
+static int fwnode_match(struct device *dev, void *data)
+{
+   return dev->fwnode == data;
+}
+
+static bool fwnode_is_bound(struct fwnode_handle *fwnode)
+{
+   struct device *dev;
+
+   dev = bus_find_device(&platform_bus_type, NULL, fwnode, fwnode_match);
+
+   /* Check whether device is bound or is being probed right now */
+   return dev ? dev->driver : false;
+}
+
+static bool fwnode_is_platform(struct fwnode_handle *fwnode)
+{
+   struct fwnode_handle *parent;
+   const char *compatible;
+   int count;
+
+   count = fwnode_property_read_string_array(fwnode, "compatible", NULL,
+ 0);
+
+   /* The node has to have a compatible string */
+   if (!count)
+   return false;
+
+   /* But it cannot be only simple-bus */
+   if ((count == 1) &&
+   !fwnode_property_read_string(fwnode, "compatible", &compatible) &&
+   !strcmp(compatible, "simple-bus"))
+   return false;
+
+   parent = fwnode_get_parent(fwnode);
+
+   /* Node is immediately below root */
+   if (!fwnode_get_parent(parent))
+   return true;
+
+   /* If its parent is a simple-bus */
+   if (fwnode_is_compatible(parent, "simple-bus"))
+   return true;
+
+   return false;
+}
+
+static struct fwnode_handle *get_enclosing_platform_dev(
+   struct fwnode_handle *fwnode)
+{
+   struct fwnode_handle *iter, *node = NULL;
+
+   for (iter = fwnode;
+iter && fwnode_get_parent(iter);
+iter = fwnode_get_parent(iter)) {
+
+   /*
+* If we already have a platform device and an ancestor is
+* already bound, the first is the one we want to probe.
+*/
+   if (node && fwnode_is_bound(iter))
+   break;
+
+   if (fwnode_is_platform(iter))
+   node = iter;
+   }
+
+   return node;
+}
+
+static bool check_dependency(struct fwnode_handle *fwnode)
+{
+   struct fwnode_handle *target;
+   struct device *dev;
+
+   if (!fwnode)
+   return true;
+
+   target = get_enclosing_platform_dev(fwnode);
+   if (!target)
+   return true;
+
+   dev = bus_find_device(&platform_bus_type, NULL, target, fwnode_match);
+   if (!dev) {
+   pr_debug("Couldn't find device for %s\n",
+fwnode_get_name(fwnode));
+   return false;
+   }
+
+   /*
+* Device is bound or is being probed right now. If we have bad luck
+* and the dependency isn't ready when it's needed, deferred probe
+* will save us.
+*/
+   if (dev->driver)
+   return true;
+
+   bus_probe_device(dev);
+
+   /* If the dependency hasn't finished probing, we'll want a warning */
+   return device_is_bound(dev);
+}
+
+static void check_dependencies(struct device *dev)
+{
+   struct fwnode_dependency *dep, *tmp;
+   LIST_HEAD(deps);
+
+   if (dev->parent && !check_dependency(dev->parent->fwnode))
+   pr_debug("Parent '%s' of device '%s' not available\n",
+dev_nam

[PATCH v2 11/12] ASoC: tegra: register dependency parser for firmware nodes

2015-07-01 Thread Tomeu Vizoso
So others can find out what dependencies a nvidia,tegra-audio-max98090
device has, as specified in
bindings/sound/nvidia,tegra-audio-max98090.txt.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2: None

 sound/soc/tegra/tegra_max98090.c | 42 +++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c
index 902da36..0f7cbf3 100644
--- a/sound/soc/tegra/tegra_max98090.c
+++ b/sound/soc/tegra/tegra_max98090.c
@@ -316,7 +316,47 @@ static struct platform_driver tegra_max98090_driver = {
.probe = tegra_max98090_probe,
.remove = tegra_max98090_remove,
 };
-module_platform_driver(tegra_max98090_driver);
+
+static void add_dependency(struct fwnode_handle *fwnode,
+  const char *property,
+  struct list_head *deps)
+{
+   struct device_node *np;
+
+   np = of_parse_phandle(to_of_node(fwnode), property, 0);
+   if (!np)
+   return;
+
+   fwnode_add_dependency(&np->fwnode, deps);
+}
+
+static void tegra_max98090_get_dependencies(struct fwnode_handle *fwnode,
+   struct list_head *deps)
+{
+   add_dependency(fwnode, "nvidia,i2s-controller", deps);
+   add_dependency(fwnode, "nvidia,audio-codec", deps);
+}
+
+static int __init tegra_max98090_init(void)
+{
+   int err;
+
+   err = platform_driver_register(&tegra_max98090_driver);
+   if (err < 0)
+   return err;
+
+   fwnode_add_dependency_parser(tegra_max98090_get_dependencies);
+
+   return 0;
+}
+module_init(tegra_max98090_init);
+
+static void __exit tegra_max98090_exit(void)
+{
+   fwnode_remove_dependency_parser(tegra_max98090_get_dependencies);
+   platform_driver_unregister(&tegra_max98090_driver);
+}
+module_exit(tegra_max98090_exit);

 MODULE_AUTHOR("Stephen Warren ");
 MODULE_DESCRIPTION("Tegra max98090 machine ASoC driver");
-- 
2.4.1



[PATCH v2 10/12] pwm: register dependency parser for firmware nodes

2015-07-01 Thread Tomeu Vizoso
So others can find out what depends on pwm controllers, as specified
in bindings/pwm/pwm.txt.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2: None

 drivers/pwm/core.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 3a7769f..81b4fc0 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -917,11 +917,39 @@ static const struct file_operations pwm_debugfs_ops = {
.release = seq_release,
 };

+static void pwm_get_dependencies(struct fwnode_handle *fwnode,
+struct list_head *deps)
+{
+   struct device_node *np;
+   struct of_phandle_args pspec;
+   int count, i, ret;
+
+   np = to_of_node(fwnode);
+   if (!np)
+   return;
+
+   count = of_count_phandle_with_args(np, "pwms",
+  "#pwm-cells");
+   for (i = 0; i < count; i++) {
+   ret = of_parse_phandle_with_args(np, "pwms",
+"#pwm-cells", i,
+&pspec);
+   if (ret || !pspec.np)
+   continue;
+
+   fwnode_add_dependency(&pspec.np->fwnode, deps);
+
+   of_node_put(pspec.np);
+   }
+}
+
 static int __init pwm_debugfs_init(void)
 {
debugfs_create_file("pwm", S_IFREG | S_IRUGO, NULL, NULL,
&pwm_debugfs_ops);

+   fwnode_add_dependency_parser(pwm_get_dependencies);
+
return 0;
 }

-- 
2.4.1



[PATCH v2 09/12] regulator: register dependency parser for firmware nodes

2015-07-01 Thread Tomeu Vizoso
So others can find out what depends on regulators, as specified
in bindings/regulator/regulator.txt.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2: None

 drivers/regulator/core.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c9f7201..535cad0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4112,6 +4112,31 @@ static const struct file_operations 
regulator_summary_fops = {
 #endif
 };

+static void regulator_get_dependencies(struct fwnode_handle *fwnode,
+  struct list_head *deps)
+{
+   struct device_node *np;
+   struct property *pp;
+   struct device_node *dep;
+
+   np = to_of_node(fwnode);
+   if (!np)
+   return;
+
+   for_each_property_of_node(np, pp) {
+   if (!strends(pp->name, "-supply"))
+   continue;
+
+   dep = of_parse_phandle(np, pp->name, 0);
+   if (!dep)
+   continue;
+
+   fwnode_add_dependency(&dep->fwnode, deps);
+
+   of_node_put(dep);
+   }
+}
+
 static int __init regulator_init(void)
 {
int ret;
@@ -4130,6 +4155,8 @@ static int __init regulator_init(void)

regulator_dummy_init();

+   fwnode_add_dependency_parser(regulator_get_dependencies);
+
return ret;
 }

-- 
2.4.1



[PATCH v2 08/12] USB: EHCI: register dependency parser for firmware nodes

2015-07-01 Thread Tomeu Vizoso
So others can find out whether a firmware node depends on a phy as
specified in bindings/usb/nvidia,tegra20-ehci.txt.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2: None

 drivers/usb/host/ehci-tegra.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 4031b37..3665eaa 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -589,6 +589,18 @@ static const struct ehci_driver_overrides tegra_overrides 
__initconst = {
.reset  = tegra_ehci_reset,
 };

+static void tegra_ehci_get_dependencies(struct fwnode_handle *fwnode,
+   struct list_head *deps)
+{
+   struct device_node *np;
+
+   np = of_parse_phandle(to_of_node(fwnode), "nvidia,phy", 0);
+   if (!np)
+   return;
+
+   fwnode_add_dependency(&np->fwnode, deps);
+}
+
 static int __init ehci_tegra_init(void)
 {
if (usb_disabled())
@@ -611,6 +623,8 @@ static int __init ehci_tegra_init(void)
tegra_ehci_hc_driver.unmap_urb_for_dma = tegra_ehci_unmap_urb_for_dma;
tegra_ehci_hc_driver.hub_control = tegra_ehci_hub_control;

+   fwnode_add_dependency_parser(tegra_ehci_get_dependencies);
+
return platform_driver_register(&tegra_ehci_driver);
 }
 module_init(ehci_tegra_init);
@@ -618,6 +632,8 @@ module_init(ehci_tegra_init);
 static void __exit ehci_tegra_cleanup(void)
 {
platform_driver_unregister(&tegra_ehci_driver);
+
+   fwnode_remove_dependency_parser(tegra_ehci_get_dependencies);
 }
 module_exit(ehci_tegra_cleanup);

-- 
2.4.1



[PATCH v2 07/12] backlight: register dependency parser for firmware nodes

2015-07-01 Thread Tomeu Vizoso
So others can find out what depends on backlight devices, as specified
in bindings/video/backlight/backlight.txt.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2: None

 drivers/video/backlight/backlight.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/video/backlight/backlight.c 
b/drivers/video/backlight/backlight.c
index bddc8b1..ab8f5e7 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -566,8 +566,22 @@ struct backlight_device *of_find_backlight_by_node(struct 
device_node *node)
 EXPORT_SYMBOL(of_find_backlight_by_node);
 #endif

+static void backlight_get_dependencies(struct fwnode_handle *fwnode,
+ struct list_head *deps)
+{
+   struct device_node *np;
+
+   np = of_parse_phandle(to_of_node(fwnode), "backlight", 0);
+   if (!np)
+   return;
+
+   fwnode_add_dependency(&np->fwnode, deps);
+}
+
 static void __exit backlight_class_exit(void)
 {
+   fwnode_remove_dependency_parser(backlight_get_dependencies);
+
class_destroy(backlight_class);
 }

@@ -586,6 +600,8 @@ static int __init backlight_class_init(void)
mutex_init(&backlight_dev_list_mutex);
BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);

+   fwnode_add_dependency_parser(backlight_get_dependencies);
+
return 0;
 }

-- 
2.4.1



[PATCH v2 06/12] backlight: Document consumers of backlight nodes

2015-07-01 Thread Tomeu Vizoso
Add a small note that makes explicit that properties named 'backlight'
contain phandles to backlight nodes.

This is needed so that we can automatically extract dependencies on
backlight devices by assuming that a property with that name contains a
phandle to such a device.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2:
- Document that consumers of backlight devices can use the 'backlight'
  property to hold a phandle to the backlight device.

 .../bindings/video/backlight/backlight.txt | 22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/video/backlight/backlight.txt

diff --git a/Documentation/devicetree/bindings/video/backlight/backlight.txt 
b/Documentation/devicetree/bindings/video/backlight/backlight.txt
new file mode 100644
index 000..309949d
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/backlight/backlight.txt
@@ -0,0 +1,22 @@
+Specifying backlight information for devices
+
+
+Backlight user nodes
+
+
+Nodes such as display panels that refer to backlight devices can do so by 
simply having a property named 'backlight' that contains a phandle to a 
backlight node.
+
+Example:
+
+   backlight: backlight {
+   compatible = "gpio-backlight";
+   gpios = <&gpio3 4 GPIO_ACTIVE_HIGH>;
+   };
+
+   [...]
+
+   panel: panel {
+   compatible = "cptt,claa101wb01";
+
+   backlight = <&backlight>;
+   };
-- 
2.4.1



[PATCH v2 05/12] gpu: host1x: register dependency parser for firmware nodes

2015-07-01 Thread Tomeu Vizoso
So others can find out dependencies of host1x clients, as specified in
bindings/gpu/nvidia,tegra20-host1x.txt.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2: None

 drivers/gpu/host1x/dev.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index 53d3d1d..5bb10b8 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -212,6 +212,29 @@ static struct platform_driver tegra_host1x_driver = {
.remove = host1x_remove,
 };

+static void add_dependency(struct fwnode_handle *fwnode,
+  const char *property,
+  struct list_head *deps)
+{
+   struct device_node *np;
+
+   np = of_parse_phandle(to_of_node(fwnode), property, 0);
+   if (!np)
+   return;
+
+   fwnode_add_dependency(&np->fwnode, deps);
+}
+
+static void host1x_get_dependencies(struct fwnode_handle *fwnode,
+   struct list_head *deps)
+{
+   add_dependency(fwnode, "nvidia,dpaux", deps);
+   add_dependency(fwnode, "nvidia,panel", deps);
+   add_dependency(fwnode, "nvidia,ddc-i2c-bus", deps);
+   add_dependency(fwnode, "nvidia,hpd-gpio", deps);
+   add_dependency(fwnode, "ddc-i2c-bus", deps);
+}
+
 static int __init tegra_host1x_init(void)
 {
int err;
@@ -228,6 +251,8 @@ static int __init tegra_host1x_init(void)
if (err < 0)
goto unregister_host1x;

+   fwnode_add_dependency_parser(host1x_get_dependencies);
+
return 0;

 unregister_host1x:
@@ -240,6 +265,7 @@ module_init(tegra_host1x_init);

 static void __exit tegra_host1x_exit(void)
 {
+   fwnode_remove_dependency_parser(host1x_get_dependencies);
platform_driver_unregister(&tegra_mipi_driver);
platform_driver_unregister(&tegra_host1x_driver);
bus_unregister(&host1x_bus_type);
-- 
2.4.1



[PATCH v2 04/12] gpio: register dependency parser for firmware nodes

2015-07-01 Thread Tomeu Vizoso
So the GPIO subsystem can be queried about the dependencies of nodes
that consume GPIOs, as specified in bindings/gpio/gpio.txt.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2: None

 drivers/gpio/gpiolib.c | 54 ++
 1 file changed, 54 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index bf4bd1d..6a3e83f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2388,4 +2388,58 @@ static int __init gpiolib_debugfs_init(void)
 }
 subsys_initcall(gpiolib_debugfs_init);

+static void gpio_get_dependencies(struct fwnode_handle *fwnode,
+ struct list_head *deps)
+{
+   struct device_node *np;
+   struct property *pp;
+   struct of_phandle_args pspec;
+   int count, i, ret;
+
+   np = to_of_node(fwnode);
+   if (!np)
+   return;
+
+   for_each_property_of_node(np, pp) {
+   if (strcmp(pp->name, "gpio") &&
+   strcmp(pp->name, "gpios") &&
+   !strends(pp->name, "-gpios") &&
+   !strends(pp->name, "-gpio"))
+   continue;
+
+   count = of_count_phandle_with_args(np, pp->name,
+  "#gpio-cells");
+   for (i = 0; i < count; i++) {
+   ret = of_parse_phandle_with_args(np, pp->name,
+"#gpio-cells", i,
+&pspec);
+   if (ret || !pspec.np)
+   continue;
+
+   fwnode_add_dependency(&pspec.np->fwnode, deps);
+
+   of_node_put(pspec.np);
+   }
+   }
+
+   for (i = 0;; i++) {
+   ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
+  i, &pspec);
+   if (ret)
+   break;
+
+   fwnode_add_dependency(&pspec.np->fwnode, deps);
+
+   of_node_put(pspec.np);
+   }
+}
+
+static int __init gpiolib_init(void)
+{
+   fwnode_add_dependency_parser(gpio_get_dependencies);
+
+   return 0;
+}
+device_initcall(gpiolib_init);
+
 #endif /* DEBUG_FS */
-- 
2.4.1



[PATCH v2 03/12] string: Introduce strends()

2015-07-01 Thread Tomeu Vizoso
To avoid duplicating code in upcoming patches that will check for
postfixes in strings, add strends().

Signed-off-by: Tomeu Vizoso 
---

Changes in v2:
- Move strends to string.h

 include/linux/string.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index d5dfe3e..4244363 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -146,6 +146,19 @@ static inline bool strstarts(const char *str, const char 
*prefix)
return strncmp(str, prefix, strlen(prefix)) == 0;
 }

+/**
+ * strends - does @str end with @postfix?
+ * @str: string to examine
+ * @postfix: postfix to look for
+ */
+static inline bool strends(const char *str, const char *postfix)
+{
+   if (strlen(str) < strlen(postfix))
+   return false;
+
+   return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
+}
+
 size_t memweight(const void *ptr, size_t bytes);
 void memzero_explicit(void *s, size_t count);

-- 
2.4.1



[PATCH v2 02/12] device: property: find dependencies of a firmware node

2015-07-01 Thread Tomeu Vizoso
Adds API that allows callers to find out what other firmware nodes a
node depends on.

Implementors of bindings documentation can register callbacks that
return the dependencies of a node.

Dependency information can be used to change the order in which devices
are probed, or to print a warning when a device node is going to be
probed without all its dependencies fulfilled.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2:
- Allow bindings implementations register a function instead of using
  class callbacks, as not only subsystems implement firmware bindings.

 drivers/base/property.c  | 91 
 include/linux/fwnode.h   |  5 +++
 include/linux/property.h | 12 +++
 3 files changed, 108 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 8ead1ba..9d38ede 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -19,7 +19,13 @@
 #include 
 #include 

+struct dependency_parser {
+   struct list_head parser;
+   void (*func)(struct fwnode_handle *fwnode, struct list_head *deps);
+};
+
 static bool fwnode_match_enable = false;
+static LIST_HEAD(dependency_parsers);

 /**
  * device_add_property_set - Add a collection of properties to a device object.
@@ -553,6 +559,27 @@ bool device_dma_is_coherent(struct device *dev)
 EXPORT_SYMBOL_GPL(device_dma_is_coherent);

 /**
+ * fwnode_add_dependency - add firmware node to the passed dependency list
+ * @fwnode: Firmware node to add to dependency list
+ * @list: Dependency list to add the fwnode to
+ */
+void fwnode_add_dependency(struct fwnode_handle *fwnode,
+  struct list_head *list)
+{
+   struct fwnode_dependency *dep;
+
+   dep = kzalloc(sizeof(*dep), GFP_KERNEL);
+   if (!dep)
+   return;
+
+   INIT_LIST_HEAD(&dep->dependency);
+   dep->fwnode = fwnode;
+
+   list_add_tail(&dep->dependency, list);
+}
+EXPORT_SYMBOL_GPL(fwnode_add_dependency);
+
+/**
  * fwnode_get_parent - return the parent node of a device node
  * @fwnode: Device node to find the parent node of
  */
@@ -600,6 +627,70 @@ bool fwnode_is_compatible(struct fwnode_handle *fwnode, 
const char *compatible)
 EXPORT_SYMBOL_GPL(fwnode_is_compatible);

 /**
+ * fwnode_add_dependency_parser - register dependency parser
+ * @func: Function that will be called to find out dependencies of a node
+ *
+ * Registers a callback that will be called when collecting the dependencies
+ * of a firmware node. The callback should inspect the properties of the node
+ * and call fwnode_add_dependency() for each dependency it recognizes, from
+ * the bindings documentation.
+ */
+void fwnode_add_dependency_parser(
+   void (*func)(struct fwnode_handle *fwnode, struct list_head *deps))
+{
+   struct dependency_parser *parser;
+
+   parser = kzalloc(sizeof(*parser), GFP_KERNEL);
+   if (!parser)
+   return;
+
+   INIT_LIST_HEAD(&parser->parser);
+   parser->func = func;
+
+   list_add_tail(&parser->parser, &dependency_parsers);
+}
+EXPORT_SYMBOL_GPL(fwnode_add_dependency_parser);
+
+/**
+ * fwnode_remove_dependency_parser - unregister dependency parser
+ * @func: Function that was to be called to find out dependencies of a node
+ */
+void fwnode_remove_dependency_parser(
+   void (*func)(struct fwnode_handle *fwnode, struct list_head *deps))
+{
+   struct dependency_parser *parser, *tmp;
+
+   list_for_each_entry_safe(parser, tmp, &dependency_parsers, parser) {
+   if (parser->func == func) {
+   list_del(&parser->parser);
+   kfree(parser);
+   return;
+   }
+   }
+}
+EXPORT_SYMBOL_GPL(fwnode_remove_dependency_parser);
+
+/**
+ * fwnode_get_dependencies - find out what dependencies a firmware node has
+ * @fwnode: firmware node to find its dependencies
+ * @deps: list of struct fwnode_dependency in which dependencies will be placed
+ */
+void fwnode_get_dependencies(struct fwnode_handle *fwnode,
+struct list_head *deps)
+{
+   struct dependency_parser *parser;
+   struct fwnode_handle *child;
+
+   list_for_each_entry(parser, &dependency_parsers, parser)
+   parser->func(fwnode, deps);
+
+   /* Some device nodes will have dependencies in non-device sub-nodes */
+   fwnode_for_each_child_node(fwnode, child)
+   if (!fwnode_property_present(child, "compatible"))
+   fwnode_get_dependencies(child, deps);
+}
+
+/**
  * fwnode_driver_match_device - Tell if a driver matches a device.
  * @drv: the device_driver structure to test
  * @dev: the device structure to match against
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 0408545..68ab558 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -24,4 +24,9 @@ struct fwnode_handle {
struct fwnode_handle *secondary;
 };

+struct fwnode_dependency {
+  

[PATCH v2 01/12] device: property: delay device-driver matches

2015-07-01 Thread Tomeu Vizoso
Delay matches of platform devices until late_initcall, when we are sure
that all built-in drivers have been registered already. This is needed
to prevent deferred probes because of some dependencies' drivers not
having registered yet.

This reduces the total amount of work that the kernel does during boot
because it won't try to match devices to drivers when built-in drivers
are still registering but also reduces some parallelism, so total boot
time might slightly increase or decrease depending on the platform and
kernel configuration.

This change will make make possible to prevent any deferred probes once
devices are probed in dependency order.

Signed-off-by: Tomeu Vizoso 
---

Changes in v2:
- Instead of delaying all probes until late_initcall, only delay matches
  of platform devices that have a firmware node attached.

 drivers/base/property.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 8528eb9..8ead1ba 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -16,8 +16,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 

+static bool fwnode_match_enable = false;
+
 /**
  * device_add_property_set - Add a collection of properties to a device object.
  * @dev: Device to add properties to.
@@ -604,6 +607,15 @@ EXPORT_SYMBOL_GPL(fwnode_is_compatible);
 bool fwnode_driver_match_device(struct device *dev,
const struct device_driver *drv)
 {
+   /*
+* Delay matches of platform devices until late_initcall, when we are
+* sure that all built-in drivers have been registered already. This
+* is needed to prevent deferred probes because of some drivers
+* not having registered yet.
+*/
+   if(dev->bus == &platform_bus_type && !fwnode_match_enable)
+   return false;
+
if (is_of_node(dev->fwnode))
return of_driver_match_device(dev, drv);
else if (is_acpi_node(dev->fwnode))
@@ -612,3 +624,20 @@ bool fwnode_driver_match_device(struct device *dev,
return false;
 }
 EXPORT_SYMBOL_GPL(fwnode_driver_match_device);
+
+static int __device_attach(struct device *dev, void *data)
+{
+   device_initial_probe(dev);
+
+   return 0;
+}
+
+static int fwnode_match_initcall(void)
+{
+   fwnode_match_enable = true;
+
+   bus_for_each_dev(&platform_bus_type, NULL, NULL, __device_attach);
+
+   return 0;
+}
+late_initcall(fwnode_match_initcall);
-- 
2.4.1



[PATCH v2 0/12] Discover and probe dependencies

2015-07-01 Thread Tomeu Vizoso
Hi,

this is version 2 of a series that probes devices in dependency order so
as to avoid deferred probes. While deferred probing is a powerful
solution that makes sure that you eventually get a working system at the
end of the boot, can make it very time consuming to find out why a
device didn't probe and can also introduce big delays in when a device
actually probes by sending it to the end of the deferred queue.

So far I have only tested on a Tegra124 Chromebook.

Thanks,

Tomeu

Changes in v2:
- Instead of delaying all probes until late_initcall, only delay matches
  of platform devices that have a firmware node attached.
- Allow bindings implementations register a function instead of using
  class callbacks, as not only subsystems implement firmware bindings.
- Move strends to string.h
- Document that consumers of backlight devices can use the 'backlight'
  property to hold a phandle to the backlight device.
- Allocate the list of dependencies and pass it to the function that
  fills it.

Tomeu Vizoso (12):
  device: property: delay device-driver matches
  device: property: find dependencies of a firmware node
  string: Introduce strends()
  gpio: register dependency parser for firmware nodes
  gpu: host1x: register dependency parser for firmware nodes
  backlight: Document consumers of backlight nodes
  backlight: register dependency parser for firmware nodes
  USB: EHCI: register dependency parser for firmware nodes
  regulator: register dependency parser for firmware nodes
  pwm: register dependency parser for firmware nodes
  ASoC: tegra: register dependency parser for firmware nodes
  driver-core: probe dependencies before probing

 .../bindings/video/backlight/backlight.txt |  22 
 drivers/base/dd.c  | 139 +
 drivers/base/property.c| 120 ++
 drivers/gpio/gpiolib.c |  54 
 drivers/gpu/host1x/dev.c   |  26 
 drivers/pwm/core.c |  28 +
 drivers/regulator/core.c   |  27 
 drivers/usb/host/ehci-tegra.c  |  16 +++
 drivers/video/backlight/backlight.c|  16 +++
 include/linux/fwnode.h |   5 +
 include/linux/property.h   |  12 ++
 include/linux/string.h |  13 ++
 sound/soc/tegra/tegra_max98090.c   |  42 ++-
 13 files changed, 519 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/video/backlight/backlight.txt

-- 
2.4.1



[PATCH v2 10/12] drm/tegra: Suspend dc/dsi/panel in one-shot mode

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 04:21:53PM +0800, Mark Zhang wrote:
> @@ -756,7 +752,11 @@ tegra_dsi_connector_duplicate_state(struct drm_connector 
> *connector)
>  }
>  
>  static const struct drm_connector_funcs tegra_dsi_connector_funcs = {
> - .dpms = tegra_dsi_connector_dpms,
> + /*
> +  * drm_atomic_helper_connector_dpms only handles DPMS ON/OFF,
> +  * so use drm_helper_connector_dpms instead.
> +  */
> + .dpms = drm_helper_connector_dpms,

Nope, mixing legacy dpms handling into an atomic driver is a no-go. You
need to use drm_atomic_helper_connector_dpms here.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v2 01/12] drm: panel: Add a new private mode flag: DRM_PANEL_FLAG_PREFER_ONE_SHOT

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 04:21:44PM +0800, Mark Zhang wrote:
> Normally this flag is set by panel driver so that crtc can enable
> the "one-shot" mode(not scan frames continuously).
> 
> Signed-off-by: Mark Zhang 
> ---
>  include/drm/drm_panel.h |2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
> index 13ff44b28893..4d51cb380c75 100644
> --- a/include/drm/drm_panel.h
> +++ b/include/drm/drm_panel.h
> @@ -26,6 +26,8 @@
>  
>  #include 
>  
> +#define DRM_PANEL_FLAG_PREFER_ONE_SHOT   (1 << 0)

This is a panel property, not a mode property. I think it would be much
better to put this directly into the panel struct, or maybe the dsi sink
device stuff or wherever. But mode really doesn't have anything to do how
exactly the pixels get to the panel.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v2 12/12] JUST FOR TEST: Add one-shot trigger to update display

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 10:36:17AM +0200, Daniel Vetter wrote:
> On Wed, Jul 01, 2015 at 04:21:55PM +0800, Mark Zhang wrote:
> > This HACK adds a workqueue to refresh the display periodically.
> > This is used just for testing.
> 
> ->dirty is the drm hook you're looking for, it's meant to flush out any
> frontbuffer rendering. Generic kms clients using the dumb buffers (e.g.
> fedora boot splash) use this already.
> 
> And of course you need to upload a new frame every time an (atomic) flip
> happens too, but I guess you have that already. No need at all for a
> periodic upload hack like this.

btw the nice thing with dirty is that it hands you the exact invalidation
rectangle, which means you can minimize uploads. For atomic flips we plan
to have the same, but it's not implemented yet.

Another problem is that currently the fbdev helper in drm_fb_helper.c
doesn't support the dirty callback. But there's other drivers which need
this too (e.g. i915 will gain a dirty callback soon) and qxl has all the
code implemented already. So the only thing you need to do is move the qxl
code into drm_fb_helper.c and adapt it to use the dirty callback instead
of directly calling qxl code. Then you should be all set. Note that simply
calling ->dirty from fbdev hooks doesn't work since a lot of those hooks
are called from irq context (cursors and stuff) and hence you need a
workqueue to do the actual dirty call.

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


[PATCH v2 12/12] JUST FOR TEST: Add one-shot trigger to update display

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 04:21:55PM +0800, Mark Zhang wrote:
> This HACK adds a workqueue to refresh the display periodically.
> This is used just for testing.

->dirty is the drm hook you're looking for, it's meant to flush out any
frontbuffer rendering. Generic kms clients using the dumb buffers (e.g.
fedora boot splash) use this already.

And of course you need to upload a new frame every time an (atomic) flip
happens too, but I guess you have that already. No need at all for a
periodic upload hack like this.

Cheers, Daniel

> 
> Signed-off-by: Mark Zhang 
> ---
>  drivers/gpu/drm/tegra/dc.c  |   37 +
>  drivers/gpu/drm/tegra/drm.h |1 +
>  2 files changed, 38 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
> index 24a91613c4f5..4381691c73f7 100644
> --- a/drivers/gpu/drm/tegra/dc.c
> +++ b/drivers/gpu/drm/tegra/dc.c
> @@ -1296,6 +1296,8 @@ static void tegra_crtc_mode_set_nofb(struct drm_crtc 
> *crtc)
>   value &= ~DISP_CTRL_MODE_MASK;
>   value |= DISP_CTRL_MODE_NC_DISPLAY;
>   tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
> +
> + schedule_work(&dc->one_shot_trigger);
>   } else {
>   value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
>   value &= ~DISP_CTRL_MODE_MASK;
> @@ -1958,6 +1960,40 @@ static void tegra_dc_one_shot_work(struct work_struct 
> *work)
>   drm_modeset_unlock_all(drm);
>  }
>  
> +static void tegra_dc_one_shot_trigger(struct work_struct *work)
> +{
> + struct tegra_dc *dc;
> + struct drm_connector *connector;
> + struct drm_device *drm;
> + unsigned long update_mask = GENERAL_ACT_REQ | NC_HOST_TRIG;
> + static int first_trigger = 1;
> +
> + dc = container_of(work, struct tegra_dc, one_shot_trigger);
> + drm = dc->base.dev;
> + msleep(5000);
> +
> + if (first_trigger) {
> + dev_info(dc->dev, "First one-shot triggered.\n");
> + tegra_dc_writel(dc, update_mask, DC_CMD_STATE_CONTROL);
> + first_trigger = 0;
> + schedule_work(&dc->one_shot_trigger);
> + return;
> + }
> +
> + dev_info(dc->dev, "one-shot: Wakeup dc/dsi/panel.\n");
> + drm_modeset_lock_all(drm);
> + list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
> + if (connector->funcs->dpms)
> + connector->funcs->dpms(connector,
> + DRM_MODE_DPMS_STANDBY);
> + }
> + drm_modeset_unlock_all(drm);
> +
> + /* Trigger the one-shot */
> + tegra_dc_writel(dc, update_mask, DC_CMD_STATE_CONTROL);
> + schedule_work(&dc->one_shot_trigger);
> +}
> +
>  static int tegra_dc_probe(struct platform_device *pdev)
>  {
>   unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED;
> @@ -1977,6 +2013,7 @@ static int tegra_dc_probe(struct platform_device *pdev)
>   spin_lock_init(&dc->lock);
>   INIT_LIST_HEAD(&dc->list);
>   INIT_WORK(&dc->one_shot_work, tegra_dc_one_shot_work);
> + INIT_WORK(&dc->one_shot_trigger, tegra_dc_one_shot_trigger);
>   dc->dev = &pdev->dev;
>   dc->soc = id->data;
>  
> diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
> index 00daf427c831..5d606cacb098 100644
> --- a/drivers/gpu/drm/tegra/drm.h
> +++ b/drivers/gpu/drm/tegra/drm.h
> @@ -132,6 +132,7 @@ struct tegra_dc {
>   struct drm_pending_vblank_event *event;
>  
>   struct work_struct one_shot_work;
> + struct work_struct one_shot_trigger;
>  
>   const struct tegra_dc_soc_info *soc;
>  
> -- 
> 1.7.9.5
> 

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


WARNING: CPU: 0 PID: 3634 at drivers/gpu/drm/drm_irq.c:1141 drm_wait_one_vblank

2015-07-01 Thread Daniel Vetter
On Tue, Jun 30, 2015 at 10:13:35PM +0200, Michal Hocko wrote:
> On Tue 30-06-15 18:59:29, Daniel Vetter wrote:
> [...]
> > I looked at dmesg, nothing out of the ordinary there. Unfortunately also
> > no hints why the pipe is somehow off when we think it's on. Can you please
> > test the below patch and grab a new dmesg?
> 
> Attached.

I'm still baffled - looking at the code intel_crtc->active should be set,
but somehow the real hw pipe is dead. Or at least we don't get a vblank
irq for it somehow. Confusing.

> > Also it might be time to start bisecting this if you can readily reproduce 
> > it.
> 
> Yes, I can reproduce it just by switching to the text console. Sometimes
> it is the first attempt already but sometimes it takes several attempts.
> I will try to go back to 4.0 and bisect it then.

Yes please do, since this is a confusing regression I think the bisect
result will be the fastest way forward.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[GIT PULL] drm/rockchip: fixes and new features

2015-07-01 Thread Daniel Vetter
On Wed, Jul 01, 2015 at 05:03:39PM +0900, Tomasz Figa wrote:
> Hi Mark,
> 
> On Tue, Jun 30, 2015 at 3:50 PM, Mark yao  wrote:
> >
> > Hi Dave.
> >
> > Some fixes and some new features. I'd like you can pull them.
> >
> > The following changes since commit c5fd936e992dd2829167d2adc63e151675ca6898:
> >
> >   drm/nouveau: Pause between setting gpu to D3hot and cutting the power 
> > (2015-06-26 10:26:37 +1000)
> >
> > are available in the git repository at:
> >
> >   https://github.com/markyzq/kernel-drm-rockchip.git drm-rockchip-2015-06-30
> >
> > for you to fetch changes up to 5295c05eb30d743987172853179333c80b8242bc:
> >
> >   drm/rockchip: default enable win2/3 area0 bit (2015-06-30 14:24:10 +0800)
> >
> > 
> > Heiko Stübner (1):
> >   drm/rockchip: only call drm_fb_helper_hotplug_event if fb_helper 
> > present
> >
> > Mark Yao (6):
> >   drm/rockchip: import dma_buf to gem
> >   drm/rockchip: vop: optimize virtual stride calculate
> >   drm/rockchip: vop: fix yuv plane support
> >   drm/rockchip: vop: support plane scale
> >   drm/rockchip: vop: switch cursor plane to window 3
> >   drm/rockchip: default enable win2/3 area0 bit
> 
> Has this series been reviewed properly? I can see that at least
> "drm/rockchip: vop: support plane scale" is kind of "controversial".

I don't see any discussion of this patch at all on dri-devel, where's this
controversy?
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


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

2015-07-01 Thread Mark yao
On 2015年06月30日 18:01, Wang J.W. wrote:
> From: Jianwei Wang 
>
> This patch add support for Two Dimensional Animation and Compositing Engine 
> (2D-ACE) on the Freescale SoCs.
>
> 2D-ACE is a Freescale display controller. 2D-ACE describes the functionality 
> of the module extremely well its name is a value that cannot be used as a 
> token in programming languages.
> Instead the valid token "DCU" is used to tag the register names and function 
> names.
>
> The Display Controller Unit (DCU) module is a system master that fetches 
> graphics stored in internal or external memory and displays them on a TFT LCD 
> panel. A wide range of panel sizes is supported and the timing of the 
> interface signals is highly configurable.
> Graphics are read directly from memory and then blended in real-time, which 
> allows for dynamic content creation with minimal CPU intervention.
>
> The features:
> (1) Full RGB888 output to TFT LCD panel.
> (2) For the current LCD panel, WQVGA "480x272" is supported.
> (3) Blending of each pixel using up to 4 source layers dependent on size of 
> panel.
> (4) Each graphic layer can be placed with one pixel resolution in either axis.
> (5) Each graphic layer support RGB565 and RGB888 direct colors without alpha 
> channel and BGRA BGRA ARGB1555 direct colors with an alpha channel 
> and YUV422 format.
> (6) Each graphic layer support alpha blending with 8-bit resolution.
>
> This is a simplified version, only one primary plane, one framebuffer created 
> for fbdev, one crtc, one connector for TFT LCD panel, an encoder.
>
> Signed-off-by: Alison Wang 
> Signed-off-by: Xiubo Li 
> Signed-off-by: Jianwei Wang 
> ---
>
> Changed in V5
>
> - Update commit message
> - Add layer registers initialization
> - Remove unused functions
> - Rename driver folder
> - Move pixel clock control functions to fsl_dcu_drm_drv.c
> - remove redundant enable the clock implicitly using regmap
> - Add maintainer message
>
> Changed in V4:
>
> -This version doesn't have functionality changed  Just a minor adjustment.
>
> Changed in V3:
>
> - Test driver on Vybrid board and add compatible string
> - Remove unused functions
> - set default crtc for encoder
> - replace legacy functions with atomic help functions
> - Set the unique name of the DRM device
> - Implement irq handle function for vblank interrupt
>
> Changed in v2:
> - Add atomic support
> - Modify bindings file
> - Rename node for compatibility
> - Move platform related code out for compatibility
>
>   .../devicetree/bindings/drm/fsl-dcu/fsl,dcu.txt|  50 +++
>   MAINTAINERS|   8 +
>   drivers/gpu/drm/Kconfig|   2 +
>   drivers/gpu/drm/Makefile   |   1 +
>   drivers/gpu/drm/fsl-dcu/Kconfig|  17 +
>   drivers/gpu/drm/fsl-dcu/Makefile   |   7 +
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_connector.c| 194 +++
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_connector.h|  30 ++
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 172 ++
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.h |  22 ++
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c  | 373 
> +
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h  | 223 
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_fbdev.c|  26 ++
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c  |  42 +++
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.h  |  17 +
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c| 192 +++
>   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.h|  23 ++
>   17 files changed, 1399 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/drm/fsl-dcu/fsl,dcu.txt
>   create mode 100644 drivers/gpu/drm/fsl-dcu/Kconfig  create mode 100644 
> drivers/gpu/drm/fsl-dcu/Makefile  create mode 100644 
> drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_connector.c
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_connector.h
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.h
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_fbdev.c
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.h
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
>   create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.h
>
> diff --git a/Documentation/devicetree/bindings/drm/fsl-dcu/fsl,dcu.txt 
> b/Documentation/devicetree/bindings/drm/fsl-dcu/fsl,dcu.txt
> new file mode 100644
> index 000..bdc7d5b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/drm/fsl-dcu/fsl,dcu.txt
> @@ -0,0 +1,49 @@
> +Device Tree bindings for Freescale DCU DRM Driver
> +
> +Required properties:
> +- comp

[v3 1/7] gpiolib: Add support for removing registered consumer lookup table

2015-07-01 Thread Lee Jones
On Fri, 26 Jun 2015, Shobhit Kumar wrote:

> In case we unload and load a driver module again that is registering a
> lookup table, without this it will result in multiple entries. Provide
> an option to remove the lookup table on driver unload
> 
> Cc: Samuel Ortiz 
> Cc: Linus Walleij 
> Cc: Alexandre Courbot 
> Cc: Thierry Reding 
> Reviewed-by: Alexandre Courbot 
> Reviewed-by: Linus Walleij 
> Tested-by: Ville Syrjälä 
> Signed-off-by: Shobhit Kumar 
> ---
> v2: Ccing maintainers
> v3: Correct the subject line (Lee jones)

Acked-by: Lee Jones 

>  drivers/gpio/gpiolib.c   | 13 +
>  include/linux/gpio/machine.h |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 957ede5..9d3ea4e 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1675,6 +1675,19 @@ void gpiod_add_lookup_table(struct gpiod_lookup_table 
> *table)
>   mutex_unlock(&gpio_lookup_lock);
>  }
>  
> +/**
> + * gpiod_remove_lookup_table() - unregister GPIO device consumers
> + * @table: table of consumers to unregister
> + */
> +void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
> +{
> + mutex_lock(&gpio_lookup_lock);
> +
> + list_del(&table->list);
> +
> + mutex_unlock(&gpio_lookup_lock);
> +}
> +
>  static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
> unsigned int idx,
> enum gpio_lookup_flags *flags)
> diff --git a/include/linux/gpio/machine.h b/include/linux/gpio/machine.h
> index e270614..c0d712d 100644
> --- a/include/linux/gpio/machine.h
> +++ b/include/linux/gpio/machine.h
> @@ -57,5 +57,6 @@ struct gpiod_lookup_table {
>  }
>  
>  void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
> +void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
>  
>  #endif /* __LINUX_GPIO_MACHINE_H */

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


[Bug 91172] [4.1.0][radeonsi][BONAIRE] Playing Ark Survival Evolved (new game) - IH ring buffer overflow

2015-07-01 Thread bugzilla-dae...@freedesktop.org
single+0x97/0x190
[80256.925230]  [] intel_map_page+0x39/0x40
[80256.925530]  [] radeon_ttm_tt_populate+0x105/0x2b0
[radeon]
[80256.925893]  [] ttm_tt_bind+0x40/0x80 [ttm]
[80256.926187]  [] ttm_bo_handle_move_mem+0x5df/0x670 [ttm]
[80256.926534]  [] ? ttm_bo_mem_space+0x28e/0x3b0 [ttm]
[80256.926857]  [] ttm_bo_evict+0x15a/0x350 [ttm]
[80256.927173]  [] ? drm_vma_offset_add+0xc3/0xe0 [drm]
[80256.927506]  [] ttm_mem_evict_first+0x1a6/0x220 [ttm]
[80256.927837]  [] ttm_bo_mem_space+0x2b2/0x3b0 [ttm]
[80256.928160]  [] ttm_bo_validate+0x1aa/0x220 [ttm]
[80256.928478]  [] ? ttm_eu_reserve_buffers+0x16b/0x320 [ttm]
[80256.928836]  [] radeon_bo_list_validate+0xd7/0x230
[radeon]
[80256.929202]  [] radeon_cs_parser_relocs+0x3ab/0x480
[radeon]
[80256.929575]  [] radeon_cs_ioctl+0x273/0x7b0 [radeon]
[80256.929896]  [] ? __slab_free+0xbf/0x260
[80256.930165]  [] ? __vunmap+0xa2/0x100
[80256.930436]  [] drm_ioctl+0x12f/0x620 [drm]
[80256.930736]  [] ? radeon_cs_parser_init+0x4d0/0x4d0
[radeon]
[80256.931096]  [] ? handle_mm_fault+0x506/0x1840
[80256.931402]  [] radeon_drm_ioctl+0x4c/0x80 [radeon]
[80256.931724]  [] do_vfs_ioctl+0x2c6/0x4d0
[80256.931994]  [] ? __do_page_fault+0x1b1/0x440
[80256.932283]  [] SyS_ioctl+0x81/0xa0
[80256.932536]  [] ? do_page_fault+0x2f/0x80
[80256.932814]  [] system_call_fastpath+0x12/0x71
[80256.933115] Code: d0 f0 0f b1 0f 39 d0 75 e5 b8 01 00 00 00 5d c3 66 0f 1f
84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 66 83 07 01 48 89 f7 57 9d <0f> 1f
44 00 00 5d c3 0f 1f 80 00 00 00 00 0f 1f 44 00 00 55 48

-- 
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/20150701/f11a2116/attachment-0001.html>