[PATCH V8 00/14] drm/exynos: few patches to enhance bridge chip support

2014-12-16 Thread Laurent Pinchart
Hi Javier,

On Friday 12 December 2014 10:51:50 Javier Martinez Canillas wrote:
> Hello,
> 
> On 11/18/2014 07:20 AM, Ajay kumar wrote:
> > On Sat, Nov 15, 2014 at 3:24 PM, Ajay Kumar wrote:
> >> This series is based on master branch of Linus tree at:
> >> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> 
> This series has been in the mailing lists for months and have been tested
> by many people. What else is missing before it can be merged?
> 
> It would be great to have proper display support on platforms that have a
> eDP to LVDS bridge chip (e.g: Snow, Peach Pit and Spring Chromebooks) and
> everything is in place but this series which had been missing many kernel
> releases already.
> 
> >> Changes since V7:
> >> -- Address comments from Tomi and Laurent:
> >> -- Use videoports and endpoints to represent the
> >> connection between
> >> 
> >>encoder, bridge and the panel, instead of using
> >>phandles.
> >> 
> >> -- Address comments from Daniel:
> >> -- Make the patch description more descriptive.
> >> -- remove device pointer from drm_bridge, and just use
> >> 
> >>device_node instead.
> >> 
> >> -- don't pass encoder pointer to bridge_attach.
> >> 
> >> -- Address comments from Sean Paul:
> >> -- Remove bridge from mode_config, and pull out
> >> drm_bridge
> >> 
> >>functions from drm_crtc.c to drm_bridge.c
> 
> Tomi and Laurent,
> 
> You asked Ajay to change his series to use the video port and enpoints DT
> bindings instead of phandles, could you please review his latest version?
> 
> I guess is now too late for 3.19 since we are in the middle of the merge
> window but it would be great if this series can at least made it to 3.20.

I don't have time to review the series in details right now, but I'm happy 
with the DT bindings, and have no big issue with the rest of the patches. I 
don't really like the of_drm_find_bridge() concept introduced in 03/14 but I 
won't nack it given lack of time to implement an alternative proposal. It's an 
internal API, it can always be reworked later anyway.

-- 
Regards,

Laurent Pinchart



[git pull] drm for 3.19-rc1

2014-12-16 Thread Dave Airlie
On 16 December 2014 at 10:35, Linus Torvalds
 wrote:
> On Sun, Dec 14, 2014 at 11:17 PM, Dave Airlie  wrote:
>>
>> i915:
>> Initial Skylake (SKL) support
>> gen3/4 reset work
>> start of dri1/ums removal
>> infoframe tracking
>> fixes for lots of things.
>
> So I'm not sure how happy I am about this. It seems to work, but on
> the very first boot I get this:
>
>   [ cut here ]
>   WARNING: CPU: 1 PID: 1292 at
> drivers/gpu/drm/i915/i915_gem_execbuffer.c:125
> eb_lookup_vmas.isra.18+0x333/0x3d0 [i915]()
>   GPU use of dumb buffer is illegal.
>   Modules linked in: ip6t_rpfilter bnep ip6t_REJECT nf_reject_ipv6
> bluetooth nf_conntrack_ipv6 ...
>video
>   CPU: 1 PID: 1292 Comm: Xorg Not tainted 3.18.0-09423-g988adfdffdd4 #1
>   Hardware name:  /DH87RL, BIOS
> RLH8710H.86A.0327.2014.0924.1645 09/24/2014
>   Call Trace:
> dump_stack+0x45/0x57
> warn_slowpath_common+0x80/0xc0
> warn_slowpath_fmt+0x41/0x50
> ? sg_kfree+0x30/0x30
> eb_lookup_vmas.isra.18+0x333/0x3d0 [i915]
> i915_gem_do_execbuffer.isra.25+0x50d/0xd80 [i915]
> ? unlock_page+0x6d/0x80
> i915_gem_execbuffer2+0xb1/0x2c0 [i915]
> drm_ioctl+0x19c/0x630 [drm]
> do_vfs_ioctl+0x2e0/0x4e0
> ? file_has_perm+0x87/0xa0
> ? __audit_syscall_entry+0xac/0x100
> SyS_ioctl+0x81/0xa0
> ? do_page_fault+0xc/0x10
> system_call_fastpath+0x12/0x17
>   ---[ end trace cb3c78163212ca1d ]---
>
> apparently Introduced by commit 355a70183848 ("drm/gem: Warn on
> illegal use of the dumb buffer interface v2")
>
> The commit says "the next step is to fail".
>
> And I want to make it painfully clear that if somebody breaks existing
> working setups, they don't get to work on the kernel.
>
> So get rid of the warning. And get rid of the notion that you can just
> fail. You can try to fix Xorg, and then come back to this - in a
> couple of years - when it no longer happens.
>

I'd be inclined to just revert this for now, it is annoying we let
userspace away with this, but we probably need to find a better
way to enforce it, since the cat is out of the bag.

Dave.


[git pull] drm for 3.19-rc1

2014-12-16 Thread Dave Airlie
On 16 December 2014 at 11:03, Linus Torvalds
 wrote:
> On Mon, Dec 15, 2014 at 4:48 PM, Dave Airlie  wrote:
>>
>> I'd be inclined to just revert this for now, it is annoying we let
>> userspace away with this, but we probably need to find a better
>> way to enforce it, since the cat is out of the bag.
>
> .. why did that commit ever even get far enough to get to me?
>
> It seems to happen on any reasonably modern Intel graphics - at least
> it happens on both my laptop and my desktop. And I'm running
> bog-standard F20, so either nobody ever even tested that broken thing,
> or nobody bothered to look at the messages to notice it was broken.
> Either way, it shows a rather distinct lack of actual testing,
> wouldn't you say?
>
> I really see no excuse for crap like this. If I find obvious bugs
> immediately, on my very normal hardware and very normal distribution,
> that means that there is something wrong in the development process.
> If I was some subtle timing-dependent thing, or I were to be using
> eally odd hardware, or I had to do something special to trigger it,
> that would be one thing. But that's definitely not the case here.

Its a rather straightforward revert, patch should have used an
DRM_INFO rather than WARN at this point, people like WARN
because automatic tools find them on the Internet and make it
easier to track down, but it also freaks everyone out when they
see a backtrace, and there are ongoing discussion with the WARN
fans to tone them down. especially where things continue fine after
them. I think a few people have become immune to i915 WARNs
in logs, and we are trying to bring that back a bit.

Now you might complain that printing anything in this case is bad,
but I've got machines with buckets of deprecated sysctl warnings
etc, so the precedent has well been set for at least trying to track
down bad userspace behaviour.
e.g. I see
WARNING! power/level is deprecated; use power/control instead

This patch was just over zealous in picking it reporting method.

I'd have to ask the i915 folks why it didn't get seen there,
I haven't had the bandwidth to test -next on the haswell laptop
I have here and I expect this would happen on it fine, but I've been
running it on a few amd/nvidia laptops to diversify testing a bit.

The patch came from VMware developers and maybe it
didn't get into the Intel developers test cycle early enough
for them to notice it. Its main job was to find out early if
userspace things were breaking the rules, and it looks
like yes they were, and its a pity nobody noticed earlier.

Dave.


[git pull] drm for 3.19-rc1

2014-12-16 Thread Dave Airlie
> Having a quiet deprecation warning with the understanding that things
> will stay around for *years* is fine. Although it makes me wonder how
> much value the deprecation message really adds. I mean, why the hell
> print a message, when the only correct thing to do is to just look at
> and fix Xorg?
>
> And if you can't get Xorg fixed, then the message is kind of pointless too?
>
> So really, I don't see the point of even a oneliner message. You guys
> know who the user is. There's no value in the message. Either you fix
> the user or you don't.
>
> It's not like "oh, it's Xorg that uses our drm interfaces" is a big
> surprise, is it?

Its not X.org the X server,

it is the X.org Intel driver, which has currently 3 different
acceleration architectures
for distros to choose from.

F20 ships UXA,
F21 ships SNA,
F22 will hopefully ship glamor.

Now I've no idea if this happens with SNA it probably does, but it it
didn't then
F20 is using UXA so hardly anyone at Intel would see it.

So yes its full of surprises, version 3.0 of the Intel DDX has been in
pre-release
for 2-3 years now I think.

Dave.


[RFC] drm: add support for tiled/compressed/etc modifier in addfb2

2014-12-16 Thread Michel Dänzer
On 12.12.2014 20:27, Daniel Stone wrote:
> On 10 December 2014 at 17:17, Rob Clark  > wrote:
> 
> In DRM/KMS we are lacking a good way to deal with tiled/compressed
> formats.  Especially in the case of dmabuf/prime buffer sharing, where
> we cannot always rely on under-the-hood flags passed to driver specific
> gem-create ioctl to pass around these extra flags.
> 
> The proposal is to add a per-plane format modifier.  This allows to, if
> necessary, use different tiling patters for sub-sampled planes, etc.
> The format modifiers are added at the end of the ioctl struct, so for
> legacy userspace it will be zero padded.
> 
> 
> Cool, thanks a lot for looking at this! My one comment is that we could
> maybe go even further: keep the current modifier as a strict
> pixel-layout modifier (e.g. tiled, compressed - anything that affects
> how you actually determine pixel location), and then support an extra
> (perhaps non-vendor-namespaced) argument for optional pixel
> _interpretation_ modifiers, e.g. the hints in
> EGL_EXT_image_dma_buf_import. V4L2 is starting to properly attack things
> like chroma siting, and being able to specify narrow/wide YUV range is
> pretty important for STB/DTV in particular. And they're actually
> starting to move to KMS, too ...
> 
> It might be useful to make the interpretation modifiers bitmaskable, so
> they can be combined (e.g. wide-range/unclamped YUV | whatever chroma
> siting), but I can't think of a usecase for combining multiple layout
> modifiers (e.g. this tiling | that compression).

I might be misunderstanding what you're referring to, but FWIW: With AMD
GPUs, the compression format and tiling parameters can be chosen
(mostly) independently.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer


[Bug 89461] [Radeon - FirePro M7740] Dual screen fails with kernel version 3.17

2014-12-16 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=89461

--- Comment #2 from Glenn Larsen  ---
Confirmed, the attached patch did fix the issue! Thank you!

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


[git pull] drm for 3.19-rc1

2014-12-16 Thread Thomas Hellstrom
On 12/16/2014 01:35 AM, Linus Torvalds wrote:
> On Sun, Dec 14, 2014 at 11:17 PM, Dave Airlie  wrote:
>> i915:
>> Initial Skylake (SKL) support
>> gen3/4 reset work
>> start of dri1/ums removal
>> infoframe tracking
>> fixes for lots of things.
> So I'm not sure how happy I am about this. It seems to work, but on
> the very first boot I get this:
>
>

So this is my fault.

I posted the patch and there was a discussion with Chris Wilson at Intel
on dri-devel following the post concluding that the intel user-space
driver was type-casting dumb buffers, and that that was legitimate since
it didn't take place in generic user-space, but in a driver that had
detailed knowledge of the driver.

So I should have explicitly have withdrawn the patch. I'm sorry about this.

Thanks,
Thomas






[git pull] drm for 3.19-rc1

2014-12-16 Thread Thomas Hellstrom
On 12/16/2014 07:18 AM, Thomas Hellstrom wrote:
> On 12/16/2014 01:35 AM, Linus Torvalds wrote:
>> On Sun, Dec 14, 2014 at 11:17 PM, Dave Airlie  wrote:
>>> i915:
>>> Initial Skylake (SKL) support
>>> gen3/4 reset work
>>> start of dri1/ums removal
>>> infoframe tracking
>>> fixes for lots of things.
>> So I'm not sure how happy I am about this. It seems to work, but on
>> the very first boot I get this:
>>
>>
> So this is my fault.
>
> I posted the patch and there was a discussion with Chris Wilson at Intel
> on dri-devel following the post concluding that the intel user-space
> driver was type-casting dumb buffers, and that that was legitimate since
> it didn't take place in generic user-space, but in a driver that had
> detailed knowledge of the driver.

...detailed knowledge of the buffer.

>
> So I should have explicitly have withdrawn the patch. I'm sorry about this.
>
> Thanks,
> Thomas
>
>
/Thomas


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



[PATCH] nouveau: bring back legacy mmap handler

2014-12-16 Thread Dave Airlie
From: Dave Airlie 

nouveau userspace back at 1.0.1 used to call the X server
DRIOpenDRMMaster interface even for DRI2 (doh!), this attempts
to map the sarea and fails if it can't.

Since 884c6dabb0eafe7227f099c9e78e514191efaf13 from Daniel,
this fails, but only ancient drivers would see it.

Revert the nouveau bits of that fix, and hope it works.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c 
b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 753a6de..3d1cfcb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -28,6 +28,7 @@
 #include "nouveau_ttm.h"
 #include "nouveau_gem.h"

+#include "drm_legacy.h"
 static int
 nouveau_vram_manager_init(struct ttm_mem_type_manager *man, unsigned long 
psize)
 {
@@ -281,7 +282,7 @@ nouveau_ttm_mmap(struct file *filp, struct vm_area_struct 
*vma)
struct nouveau_drm *drm = nouveau_drm(file_priv->minor->dev);

if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
-   return -EINVAL;
+   return drm_legacy_mmap(filp, vma);

return ttm_bo_mmap(filp, vma, &drm->ttm.bdev);
 }
-- 
1.9.3



[git pull] drm for 3.19-rc1

2014-12-16 Thread Chris Wilson
On Tue, Dec 16, 2014 at 12:37:52PM +1000, Dave Airlie wrote:
> > Having a quiet deprecation warning with the understanding that things
> > will stay around for *years* is fine. Although it makes me wonder how
> > much value the deprecation message really adds. I mean, why the hell
> > print a message, when the only correct thing to do is to just look at
> > and fix Xorg?
> >
> > And if you can't get Xorg fixed, then the message is kind of pointless too?
> >
> > So really, I don't see the point of even a oneliner message. You guys
> > know who the user is. There's no value in the message. Either you fix
> > the user or you don't.
> >
> > It's not like "oh, it's Xorg that uses our drm interfaces" is a big
> > surprise, is it?
> 
> Its not X.org the X server,

It is plymouthd using libkms. It affects -radeon, -nouveau and -intel
who all try to copy the fbcon created using a dumb buffer into the
Screen Pixmap.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[Intel-gfx] [PATCH] [v2] drm/cache: Use wbinvd helpers

2014-12-16 Thread Daniel Vetter
On Mon, Dec 15, 2014 at 12:26:46PM -0800, Ben Widawsky wrote:
> From: Ben Widawsky 
> 
> When the original drm code was written there were no centralized functions for
> doing a coordinated wbinvd across all CPUs. Now (since 2010) there are, so use
> them instead of rolling a new one.
> 
> v2: On x86 UP systems the wbinvd_on_all_cpus() is defined as a static inline 
> in
> smp.h. We must therefore include this file so we don't get compiler errors.
> This error was found by 0-DAY kernel test infrastructure. We only need this 
> for
> x86.

Oh dear UP ;-) Thanks for the quick updated, new patch merged to dinq.
-Daniel

> 
> Cc: Intel GFX 
> Signed-off-by: Ben Widawsky 
> Reviewed-by: Chris Wilson  (v1)
> ---
>  drivers/gpu/drm/drm_cache.c | 13 -
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
> index a6b6906..9a62d7a 100644
> --- a/drivers/gpu/drm/drm_cache.c
> +++ b/drivers/gpu/drm/drm_cache.c
> @@ -32,6 +32,7 @@
>  #include 
>  
>  #if defined(CONFIG_X86)
> +#include 
>  
>  /*
>   * clflushopt is an unordered instruction which needs fencing with mfence or
> @@ -64,12 +65,6 @@ static void drm_cache_flush_clflush(struct page *pages[],
>   drm_clflush_page(*pages++);
>   mb();
>  }
> -
> -static void
> -drm_clflush_ipi_handler(void *null)
> -{
> - wbinvd();
> -}
>  #endif
>  
>  void
> @@ -82,7 +77,7 @@ drm_clflush_pages(struct page *pages[], unsigned long 
> num_pages)
>   return;
>   }
>  
> - if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
> + if (wbinvd_on_all_cpus())
>   printk(KERN_ERR "Timed out waiting for cache flush.\n");
>  
>  #elif defined(__powerpc__)
> @@ -121,7 +116,7 @@ drm_clflush_sg(struct sg_table *st)
>   return;
>   }
>  
> - if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
> + if (wbinvd_on_all_cpus())
>   printk(KERN_ERR "Timed out waiting for cache flush.\n");
>  #else
>   printk(KERN_ERR "Architecture has no drm_cache.c support\n");
> @@ -144,7 +139,7 @@ drm_clflush_virt_range(void *addr, unsigned long length)
>   return;
>   }
>  
> - if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
> + if (wbinvd_on_all_cpus())
>   printk(KERN_ERR "Timed out waiting for cache flush.\n");
>  #else
>   printk(KERN_ERR "Architecture has no drm_cache.c support\n");
> -- 
> 2.1.3
> 
> ___
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[Intel-gfx] [PATCH 4/4] drm/i915: Opportunistically reduce flushing at execbuf

2014-12-16 Thread Chris Wilson
On Mon, Dec 15, 2014 at 01:06:40PM -0800, Ben Widawsky wrote:
> On Mon, Dec 15, 2014 at 08:39:35PM +, Chris Wilson wrote:
> > On Mon, Dec 15, 2014 at 11:56:05AM -0800, Ben Widawsky wrote:
> > > On Mon, Dec 15, 2014 at 08:20:50AM +, Chris Wilson wrote:
> > > > On Mon, Dec 15, 2014 at 08:55:32AM +0100, Daniel Vetter wrote:
> > > > > On Sun, Dec 14, 2014 at 03:37:36PM -0800, Ben Widawsky wrote:
> > > > > > It's not hard, and I think that's a good idea as well. One reason I 
> > > > > > didn't put
> > > > > > such code in this series is that moves away from a global DRM 
> > > > > > solution (and like
> > > > > > I said in the cover-letter, I am fine with that). Implementing 
> > > > > > this, I think in
> > > > > > the i915 code we'd just iterate through the BOs until we got to a 
> > > > > > certain
> > > > > > threshold, then just call wbinvd() from i915 and not even both with 
> > > > > > drm_cache.
> > > > > > You could also maybe try to shorcut if there are more than X 
> > > > > > buffers.
> > > > > 
> > > > > I don't mind an i915 specific solution (we have them already in many
> > > > > places). So will wait for the results of this experiments before 
> > > > > merging
> > > > > more patches.
> > > > 
> > > > I actually think an i915 specific solution is required, as the making
> > > > drm_clflush_pages autoselect is likely to cause regressions on unaware
> > > > drivers (e.g. anything that has a reservation loop in execbuf like 
> > > > i915).
> > > 
> > > Assuming the stall is gone as Jesse said in the other thread, I can't 
> > > envision a
> > > scenario where wbinvd would do worse on large objects.
> > 
> > It is the multiple wbinvd performed at each execbuffer that is worrisome.
> 
> This patch attempts to avoid that by dropping all flushing after the first
> WBINVD.

But you can't make the central change to drm_clflush_* without driver
specific workarounds like this patch...
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


Long radeon stalls on recent kernels

2014-12-16 Thread Michel Dänzer
On 11.12.2014 14:13, Andy Lutomirski wrote:
> On Wed, Dec 10, 2014 at 8:24 PM, Michel Dänzer  wrote:
>> On 11.12.2014 05:28, Andy Lutomirski wrote:
>>> On Wed, Dec 10, 2014 at 1:44 AM, Michel Dänzer  
>>> wrote:
 On 10.12.2014 06:39, Andy Lutomirski wrote:
> On Tue, Dec 9, 2014 at 8:06 AM, Andy Lutomirski  
> wrote:
>> On Tue, Dec 9, 2014 at 1:18 AM, Michel Dänzer  
>> wrote:
>>> On 09.12.2014 09:24, Andy Lutomirski wrote:

 The relevant line from latencytop seems to be:

 154 20441402 489139 radeon_fence_default_wait [radeon]
 fence_wait_timeout ttm_bo_wait [ttm] ttm_bo_move_accel_cleanup [ttm]
 radeon_move_blit.isra.12 [radeon] radeon_bo_move [radeon]
 ttm_bo_handle_move_mem [ttm] ttm_bo_evict [ttm] ttm_mem_evict_first
 [ttm] ttm_bo_mem_space [ttm] ttm_bo_validate [ttm]
 radeon_bo_fault_reserve_notify [radeon]
>>>
>>> Which process is this?
>>
>> Xorg
>>
>>>
>>> Looks like CPU access to a BO in VRAM, but the BO is located outside of
>>> the CPU visible area of VRAM, so it has to be moved into the CPU visible
>>> area first.
>>
>> [...]
>>
> But I'm still waiting for the day that buggy userspace *can't* cause
> kernel graphics stalls.

 Actually, this looks more like buggy userspace stalling itself. :)
>>>
>>> I thought the stall was the kernel evicting things from vram.  Why
>>> does it need to wait for userspace for that?  Is it that userspace is
>>> actively using whatever's being evicted?
>>
>> As I explained above, the stall happens because userspace does CPU
>> access to a BO which resides in the CPU-inaccessible part of VRAM. The
>> kernel has to move the BO into the CPU accessible part of VRAM before it
>> can let userspace proceed.
> 
> Sure, but why does that take nearly 500ms?  Even if the object in
> question is the entire framebuffer, that still seems extraordinarily
> slow.

It has to wait for any previously queued GPU operations and the eviction
of other buffers. Also, TTM buffer moves are currently synchronous, i.e.
TTM waits for a buffer to become idle before starting its move, which
means we don't get maximum throughput for a series of buffer moves.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer


[RFC] drm: add support for tiled/compressed/etc modifier in addfb2

2014-12-16 Thread Daniel Stone
Hi,

On 16 December 2014 at 03:56, Michel Dänzer  wrote:
>
> On 12.12.2014 20:27, Daniel Stone wrote:
> > It might be useful to make the interpretation modifiers bitmaskable, so
> > they can be combined (e.g. wide-range/unclamped YUV | whatever chroma
> > siting), but I can't think of a usecase for combining multiple layout
> > modifiers (e.g. this tiling | that compression).
>
> I might be misunderstanding what you're referring to, but FWIW: With AMD
> GPUs, the compression format and tiling parameters can be chosen
> (mostly) independently.


Should've been a little more clear. Definitely each vendor will have their
own combination of modes, but I mostly meant that I don't really see a use
for VENDOR_AMD(compression_1) | VENDOR_OTHER(tiling_N), or VENDOR_ARM(afbc)
| VENDOR_SAMSUNG(tiling_12x64). Each vendor's space would be free to use
the 24 sub-bits as a bitmask, but I don't think there's a need for
combining tokens from multiple vendor spaces.

Cheers,
Daniel
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20141216/10f4554f/attachment.html>


[PATCH] Add new DRM_MODE_CONNECTOR and _ENCODER defines

2014-12-16 Thread Jani Nikula
On Tue, 16 Dec 2014, Adam Cheney  wrote:
> ---
> This email message is for the sole use of the intended recipient(s) and may 
> contain
> confidential information.  Any unauthorized review, use, disclosure or 
> distribution
> is prohibited.  If you are not the intended recipient, please contact the 
> sender by
> reply email and destroy all copies of the original message.
> ---

Can you try to get rid of this please?

Thanks,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center


[git pull] drm for 3.19-rc1

2014-12-16 Thread Daniel Vetter
On Mon, Dec 15, 2014 at 04:35:29PM -0800, Linus Torvalds wrote:
> On Sun, Dec 14, 2014 at 11:17 PM, Dave Airlie  wrote:
> >
> > i915:
> > Initial Skylake (SKL) support
> > gen3/4 reset work
> > start of dri1/ums removal
> > infoframe tracking
> > fixes for lots of things.
> 
> So I'm not sure how happy I am about this. It seems to work, but on
> the very first boot I get this:
> 
>   [ cut here ]
>   WARNING: CPU: 1 PID: 1292 at
> drivers/gpu/drm/i915/i915_gem_execbuffer.c:125
> eb_lookup_vmas.isra.18+0x333/0x3d0 [i915]()
>   GPU use of dumb buffer is illegal.
>   Modules linked in: ip6t_rpfilter bnep ip6t_REJECT nf_reject_ipv6
> bluetooth nf_conntrack_ipv6 ...
>video
>   CPU: 1 PID: 1292 Comm: Xorg Not tainted 3.18.0-09423-g988adfdffdd4 #1
>   Hardware name:  /DH87RL, BIOS
> RLH8710H.86A.0327.2014.0924.1645 09/24/2014
>   Call Trace:
> dump_stack+0x45/0x57
> warn_slowpath_common+0x80/0xc0
> warn_slowpath_fmt+0x41/0x50
> ? sg_kfree+0x30/0x30
> eb_lookup_vmas.isra.18+0x333/0x3d0 [i915]
> i915_gem_do_execbuffer.isra.25+0x50d/0xd80 [i915]
> ? unlock_page+0x6d/0x80
> i915_gem_execbuffer2+0xb1/0x2c0 [i915]
> drm_ioctl+0x19c/0x630 [drm]
> do_vfs_ioctl+0x2e0/0x4e0
> ? file_has_perm+0x87/0xa0
> ? __audit_syscall_entry+0xac/0x100
> SyS_ioctl+0x81/0xa0
> ? do_page_fault+0xc/0x10
> system_call_fastpath+0x12/0x17
>   ---[ end trace cb3c78163212ca1d ]---
> 
> apparently Introduced by commit 355a70183848 ("drm/gem: Warn on
> illegal use of the dumb buffer interface v2")
> 
> The commit says "the next step is to fail".
> 
> And I want to make it painfully clear that if somebody breaks existing
> working setups, they don't get to work on the kernel.
> 
> So get rid of the warning. And get rid of the notion that you can just
> fail. You can try to fix Xorg, and then come back to this - in a
> couple of years - when it no longer happens.

Yeah this patch should have been merged ever, I guess Chris reply' in the
original was lost. Anyway the real fail here is that we didn't spot this
in time. Well QA reported a bug, but 2 weeks after the patch landed, not
marked as a regression, not handled by the bug team and no one else seems
to have noticed either. Like I've mentioned at KS we have a bit a problem
with this stuff in i915 land, I'll chase people some more. Maybe it helps.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[Bug 87278] Packet0 not allowed and GPU fault detected errors with Serious Engine games

2014-12-16 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=87278

--- Comment #3 from Michel Dänzer  ---
Does the environment variable R600_DEBUG=nodma avoid this problem?

-- 
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/20141216/1100e4b4/attachment.html>


[PATCH] drm/i915: tame the chattermouth (v2)

2014-12-16 Thread Daniel Vetter
On Mon, Dec 15, 2014 at 10:22:49PM +0200, Jani Nikula wrote:
> On Mon, 15 Dec 2014, Rob Clark  wrote:
> > Many distro's have mechanism in place to collect and automatically file
> > bugs for failed WARN()s.  And since i915 has a lot of hw state sanity
> > checks which result in WARN(), it generates quite a lot of noise which
> > is somewhat disconcerting to the end user.
> >
> > Separate out the internal hw-is-in-the-state-I-expected checks into
> > I915_STATE_WARN()s and allow configuration via i915.verbose_checks module
> > param about whether this will generate a full blown stacktrace or just
> > DRM_ERROR().  The new moduleparam defaults to true, so by default there
> > is no change in behavior.  And even when disabled, you will still get
> > an error message logged.
> >
> > v2: paint the macro names blue, clarify that the default behavior
> > remains the same as before
> >
> > Signed-off-by: Rob Clark 
> 
> FWIW this is
> 
> Acked-by: Jani Nikula 
> 
> even though I opposed v1. While I'm still not thrilled by an extra
> module param, my main concern was alleviated by Rob pointing out to me
> the default of that param leaves old behaviour unchanged.

Queued for -next, thanks for the patch.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[Bug 87265] display turned off during normal work, radeon GPU lockup

2014-12-16 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=87265

Michel Dänzer  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #2 from Michel Dänzer  ---
Indeed, there was a fix in Mesa 10.3.4 which helped for issues like this for
some people.

-- 
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/20141216/58176bf1/attachment.html>


[PATCH] nouveau: bring back legacy mmap handler

2014-12-16 Thread Daniel Vetter
On Tue, Dec 16, 2014 at 04:34:39PM +1000, Dave Airlie wrote:
> From: Dave Airlie 
> 
> nouveau userspace back at 1.0.1 used to call the X server
> DRIOpenDRMMaster interface even for DRI2 (doh!), this attempts
> to map the sarea and fails if it can't.
> 
> Since 884c6dabb0eafe7227f099c9e78e514191efaf13 from Daniel,
> this fails, but only ancient drivers would see it.
> 
> Revert the nouveau bits of that fix, and hope it works.
> 
> Signed-off-by: Dave Airlie 

Argh, sorry for missing that in my git history digging.

Acked-by: Daniel Vetter 

Now curious question: Would return 0 also work? As long as userspace only
cares about the errno of the ioctl call and doesn't actually look at the
sarea itself we could keep the cake and eat it, too. I've used a similar
trick in legacy context code, again because old nouveau had copypasta from
dri1, but only cared about the errno and not whether the contexts actually
did anything useful.

I'd really prefer the return 0; patch if possible.

Cheers, Daniel
> ---
>  drivers/gpu/drm/nouveau/nouveau_ttm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c 
> b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 753a6de..3d1cfcb 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -28,6 +28,7 @@
>  #include "nouveau_ttm.h"
>  #include "nouveau_gem.h"
>  
> +#include "drm_legacy.h"
>  static int
>  nouveau_vram_manager_init(struct ttm_mem_type_manager *man, unsigned long 
> psize)
>  {
> @@ -281,7 +282,7 @@ nouveau_ttm_mmap(struct file *filp, struct vm_area_struct 
> *vma)
>   struct nouveau_drm *drm = nouveau_drm(file_priv->minor->dev);
>  
>   if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
> - return -EINVAL;
> + return drm_legacy_mmap(filp, vma);
>  
>   return ttm_bo_mmap(filp, vma, &drm->ttm.bdev);
>  }
> -- 
> 1.9.3
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[Bug 87278] Packet0 not allowed and GPU fault detected errors with Serious Engine games

2014-12-16 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=87278

--- Comment #4 from Christoph Haag  ---
(In reply to Michel Dänzer from comment #3)
> Does the environment variable R600_DEBUG=nodma avoid this problem?

No, R600_DEBUG=nodma does not help.

-- 
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/20141216/32d2fdda/attachment.html>


[PATCH 5/6] dt-bindings: Add documentation for Rockchip hdmi-audio

2014-12-16 Thread Kuankuan.Yang

在 2014年12月16日 00:18, Mark Brown 写道:
> On Mon, Dec 15, 2014 at 09:10:26PM +0800, Kuankuan.Yang wrote:
>> Hi Mark & Russell:
> Please don't top post, that way people have some context for what you're
> saying - look at how people normally format their mails on thelist.
>
>> In that way, dt will only need compatible for creating sound device. is it
>> ok  ?
>> sound {
>>  compatible = "rockchip,rk3288-hdmi-audio";
>>  status = "okay";
>> }
>> could you give me some advises.
> That'd be good, though the other question is if this can be made to use
> simple-card so we can avoid having a custom driver for this.
Hi Russell  & Mark:

hdmi-audio driver share irq with dw_hdmi driver,  for continuing 
AHBAUDDMA or for detecting hdmi insert.
So maybe it's hard to switch to simple-card way,  Russell what's your 
opinion ?

Best Regards.




[PATCH 5/6] dt-bindings: Add documentation for Rockchip hdmi-audio

2014-12-16 Thread Kuankuan.Yang
Hi Mark :

Got it, it will be good to use simple-card. i will try it in next version.

Best Regards.

在 2014年12月16日 00:18, Mark Brown 写道:
> On Mon, Dec 15, 2014 at 09:10:26PM +0800, Kuankuan.Yang wrote:
>> Hi Mark & Russell:
> Please don't top post, that way people have some context for what you're
> saying - look at how people normally format their mails on thelist.
>
>> In that way, dt will only need compatible for creating sound device. is it
>> ok  ?
>> sound {
>>  compatible = "rockchip,rk3288-hdmi-audio";
>>  status = "okay";
>> }
>> could you give me some advises.
> That'd be good, though the other question is if this can be made to use
> simple-card so we can avoid having a custom driver for this.




[PATCH 5/6] dt-bindings: Add documentation for Rockchip hdmi-audio

2014-12-16 Thread Kuankuan.Yang

在 2014年12月16日 00:18, Mark Brown 写道:
> On Mon, Dec 15, 2014 at 09:10:26PM +0800, Kuankuan.Yang wrote:
>> Hi Mark & Russell:
> Please don't top post, that way people have some context for what you're
> saying - look at how people normally format their mails on thelist.

got it,  thanks for your remind.

>> In that way, dt will only need compatible for creating sound device. is it
>> ok  ?
>> sound {
>>  compatible = "rockchip,rk3288-hdmi-audio";
>>  status = "okay";
>> }
>> could you give me some advises.
> That'd be good, though the other question is if this can be made to use
> simple-card so we can avoid having a custom driver for this.




[Regression] 83f45fc turns machine's screen off

2014-12-16 Thread Heinz Diehl
On 14.12.2014, Emmanuel Benisty wrote: 

> >>> The following commit permanently turns my screen off when x server is
> >>> started (i3 330M Ironlake):
> >>>
> >>> [83f45fc360c8e16a330474860ebda872d1384c8c] drm: Don't grab an fb
> >>> reference for the idr
> >>>
> >>> Reverting this commit fixed the issue.

Haven't seen your mail until now. Seems to be the same bug that I'm 
encountering.

https://bugs.freedesktop.org/show_bug.cgi?id=87330
https://lkml.org/lkml/2014/12/14/26



[PATCH] drm/info: Remove unused code

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

Commit 28a62277e06f ("drm: Convert proc files to seq_file and introduce
debugfs") converted /proc files to debugfs and in the process dropped
the entry for the vblank statistics. Since that file has been gone for
almost five years, there is no use to keep the code that provides the
file's content around.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_info.c | 24 
 drivers/gpu/drm/drm_internal.h |  1 -
 2 files changed, 25 deletions(-)

diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index 51efebd434f3..f1b32f91d941 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -153,30 +153,6 @@ int drm_bufs_info(struct seq_file *m, void *data)
 }

 /**
- * Called when "/proc/dri/.../vblank" is read.
- */
-int drm_vblank_info(struct seq_file *m, void *data)
-{
-   struct drm_info_node *node = (struct drm_info_node *) m->private;
-   struct drm_device *dev = node->minor->dev;
-   int crtc;
-
-   mutex_lock(&dev->struct_mutex);
-   for (crtc = 0; crtc < dev->num_crtcs; crtc++) {
-   seq_printf(m, "CRTC %d enable: %d\n",
-  crtc, atomic_read(&dev->vblank[crtc].refcount));
-   seq_printf(m, "CRTC %d counter:%d\n",
-  crtc, drm_vblank_count(dev, crtc));
-   seq_printf(m, "CRTC %d last wait:  %d\n",
-  crtc, dev->vblank[crtc].last_wait);
-   seq_printf(m, "CRTC %d in modeset: %d\n",
-  crtc, dev->vblank[crtc].inmodeset);
-   }
-   mutex_unlock(&dev->struct_mutex);
-   return 0;
-}
-
-/**
  * Called when "/proc/dri/.../clients" is read.
  *
  */
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 7cc0a3516871..12a61d706827 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -55,7 +55,6 @@ void drm_prime_remove_buf_handle_locked(struct 
drm_prime_file_private *prime_fpr
 int drm_name_info(struct seq_file *m, void *data);
 int drm_vm_info(struct seq_file *m, void *data);
 int drm_bufs_info(struct seq_file *m, void *data);
-int drm_vblank_info(struct seq_file *m, void *data);
 int drm_clients_info(struct seq_file *m, void* data);
 int drm_gem_name_info(struct seq_file *m, void *data);

-- 
2.1.3



[Bug 89661] Kernel panic when trying use amdkfd driver on Kaveri

2014-12-16 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=89661

--- Comment #6 from Bernd Steinhauser  ---
Tried the patch, exactly the same result.

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


[Bug 89661] Kernel panic when trying use amdkfd driver on Kaveri

2014-12-16 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=89661

--- Comment #7 from Oded Gabbay  ---
Created attachment 160751
  --> https://bugzilla.kernel.org/attachment.cgi?id=160751&action=edit
More checks on pointers being used

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


[Bug 89661] Kernel panic when trying use amdkfd driver on Kaveri

2014-12-16 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=89661

--- Comment #8 from Oded Gabbay  ---
Hi,
Three things, please:

1. Please try the attached patch. It tries to verify more pointers before using
them.

2. You said CONFIG_HSA_AMD=y. What's the value of CONFIG_DRM_RADEON ? If its
"m", could you change it to "y" ?

3. I would still like to ask if you could check with the following config:
CONFIG_DRM_RADEON="m"
CONFIG_HSA_AMD="m"

Thanks

Oded

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


[Bug 89661] Kernel panic when trying use amdkfd driver on Kaveri

2014-12-16 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=89661

--- Comment #9 from Oded Gabbay  ---
One more thing,
I'm trying to understand the exact tree you are using so we will look at the
same code.
Did you just took drm-next, or did you manually merged between trees ?
If you did a manual merge, could you try instead to just take drm-next ? It's
already based on 3.18.0

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


drm: rockchip: Add basic drm driver

2014-12-16 Thread Dan Carpenter
Hello Mark Yao,

The patch 2048e3286f34: "drm: rockchip: Add basic drm driver" from
Aug 22, 2014, leads to the following static checker warning:

drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1383 vop_bind()
warn: unsigned 'vop->irq' is never less than zero.

drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  1381  
  1382  vop->irq = platform_get_irq(pdev, 0);
  1383  if (vop->irq < 0) {

Doesn't work.

  1384  dev_err(dev, "cannot find irq for vop\n");
  1385  return vop->irq;
  1386  }
  1387  

drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1188 vop_create_crtc()
warn: missing error code here? 'of_get_child_by_name()' failed.

  1184  port = of_get_child_by_name(dev->of_node, "port");
  1185  if (!port) {
  1186  DRM_ERROR("no port node found in %s\n",
  1187dev->of_node->full_name);

Probably, "ret = -ENODEV;"

  1188  goto err_cleanup_crtc;
  1189  }
  1190  


regards,
dan carpenter


[PATCH v2] drm/exynos/fimd: only finish pageflip if START == START_S

2014-12-16 Thread Inki Dae
On 2014년 12월 11일 01:57, Gustavo Padovan wrote:
> From: Daniel Kurtz 
> 
> A framebuffer gets committed to FIMD's default window like this:
>  exynos_drm_crtc_update()
>   exynos_plane_commit()
>fimd_win_commit()
> 
> fimd_win_commit() programs BUF_START[0].  At each vblank, FIMD hardware
> copies the value from BUF_START to BUF_START_S (BUF_START's shadow
> register), starts scanning out from BUF_START_S, and asserts its irq.
> 
> This irq is handled by fimd_irq_handler(), which calls
> exynos_drm_crtc_finish_pageflip() to free the old buffer that FIMD just
> finished scanning out, and potentially commit the next pending flip.
> 
> There is a race, however, if fimd_win_commit() programs BUF_START(0)
> between the actual vblank irq, and its corresponding fimd_irq_handler().
> 
>  => FIMD vblank: BUF_START_S[0] := BUF_START[0], and irq asserted
>  | => fimd_win_commit(0) writes new BUF_START[0]
>  |exynos_drm_crtc_try_do_flip() marks exynos_fb as prepared
>  => fimd_irq_handler()
> exynos_drm_crtc_finish_pageflip() sees prepared exynos_fb,
>  and unmaps "old" fb
>  ==> but, since BUF_START_S[0] still points to that "old" fb...
>  ==> FIMD iommu fault
> 
> This patch ensures that fimd_irq_handler() only calls
> exynos_drm_crtc_finish_pageflip() if any previously scheduled flip
> has really completed.
> 
> This works because exynos_drm_crtc's flip fifo ensures that
> fimd_win_commit() is never called more than once per
> exynos_drm_crtc_finish_pageflip().
> 
> Signed-off-by: Daniel Kurtz 
> Reviewed-by: Sean Paul 
> Signed-off-by: Gustavo Padovan 
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c | 31 ---
>  include/video/samsung_fimd.h |  1 +
>  2 files changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
> b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> index e5810d1..95bac27 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> @@ -55,6 +55,7 @@
>  #define VIDOSD_D(win)(VIDOSD_BASE + 0x0C + (win) * 16)
>  
>  #define VIDWx_BUF_START(win, buf)(VIDW_BUF_START(buf) + (win) * 8)
> +#define VIDWx_BUF_START_S(win, buf) (VIDW_BUF_START_S(buf) + (win) * 8)
>  #define VIDWx_BUF_END(win, buf)  (VIDW_BUF_END(buf) + (win) * 8)
>  #define VIDWx_BUF_SIZE(win, buf) (VIDW_BUF_SIZE(buf) + (win) * 4)
>  
> @@ -1039,6 +1040,7 @@ static irqreturn_t fimd_irq_handler(int irq, void 
> *dev_id)
>  {
>   struct fimd_context *ctx = (struct fimd_context *)dev_id;
>   u32 val, clear_bit;
> + u32 start, start_s;
>  
>   val = readl(ctx->regs + VIDINTCON1);
>  
> @@ -1051,19 +1053,34 @@ static irqreturn_t fimd_irq_handler(int irq, void 
> *dev_id)
>   goto out;
>  
>   if (ctx->i80_if) {
> - exynos_drm_crtc_finish_pageflip(ctx->drm_dev, ctx->pipe);
> -
>   /* Exits triggering mode */
>   atomic_set(&ctx->triggering, 0);
>   } else {
>   drm_handle_vblank(ctx->drm_dev, ctx->pipe);
> + }
> +
> + /*
> +  * Ensure finish_pageflip is called iff a pending flip has completed.
> +  * This works around a race between a page_flip request and the latency
> +  * between vblank interrupt and this irq_handler:
> +  *   => FIMD vblank: BUF_START_S[0] := BUF_START[0], and asserts irq
> +  *   | => fimd_win_commit(0) writes new BUF_START[0]
> +  *   |exynos_drm_crtc_try_do_flip() marks exynos_fb as prepared
> +  *   => fimd_irq_handler()
> +  *   exynos_drm_crtc_finish_pageflip() sees prepared exynos_fb,
> +  *   and unmaps "old" fb
> +  *   ==> but, since BUF_START_S[0] still points to that "old" fb...
> +  *   ==> FIMD iommu fault
> +  */
> + start = readl(ctx->regs + VIDWx_BUF_START(0, 0));
> + start_s = readl(ctx->regs + VIDWx_BUF_START_S(0, 0));
> + if (start == start_s)
>   exynos_drm_crtc_finish_pageflip(ctx->drm_dev, ctx->pipe);

Did you test abvoe codes on I80 mode? If not so, I think this function
should be called only in case of RGB mode until checked.

>  
> - /* set wait vsync event to zero and wake up queue. */
> - if (atomic_read(&ctx->wait_vsync_event)) {
> - atomic_set(&ctx->wait_vsync_event, 0);
> - wake_up(&ctx->wait_vsync_queue);
> - }
> + /* set wait vsync event to zero and wake up queue. */
> + if (atomic_read(&ctx->wait_vsync_event)) {
> + atomic_set(&ctx->wait_vsync_event, 0);
> + wake_up(&ctx->wait_vsync_queue);

And in case of i80 mode, wait_vsync_queue will be waked up by
fimd_te_handler so I think above relevant codes should be called only in
case of RGB mode.

Thanks,
Inki Dae

>   }
>  
>  out:
> diff --git a/include/video/samsung_fimd.h b/include/video/samsung_fimd.h
> index a20e4a3..f81d081 100644
> --- a/include/video/samsung_fimd.h

[PATCH] drm: sti: add DVO output connector

2014-12-16 Thread Benjamin Gaignard
Digital Video Out connector driver LCD panels.
Like HDMI and HDA it create bridge, encoder and connector
drm object.
Add binding descrition.

Signed-off-by: Benjamin Gaignard 
---
 .../devicetree/bindings/gpu/st,stih4xx.txt |  29 ++
 drivers/gpu/drm/sti/Makefile   |   4 +
 drivers/gpu/drm/sti/sti_awg_utils.c| 184 +++
 drivers/gpu/drm/sti/sti_awg_utils.h|  34 ++
 drivers/gpu/drm/sti/sti_dvo.c  | 551 +
 drivers/gpu/drm/sti/sti_tvout.c| 118 +
 6 files changed, 920 insertions(+)
 create mode 100644 drivers/gpu/drm/sti/sti_awg_utils.c
 create mode 100644 drivers/gpu/drm/sti/sti_awg_utils.h
 create mode 100644 drivers/gpu/drm/sti/sti_dvo.c

diff --git a/Documentation/devicetree/bindings/gpu/st,stih4xx.txt 
b/Documentation/devicetree/bindings/gpu/st,stih4xx.txt
index c99eb34..6b1d75f 100644
--- a/Documentation/devicetree/bindings/gpu/st,stih4xx.txt
+++ b/Documentation/devicetree/bindings/gpu/st,stih4xx.txt
@@ -83,6 +83,22 @@ sti-hda:
   - clock-names: names of the clocks listed in clocks property in the same
 order.

+sti-dvo:
+  Required properties:
+  must be a child of sti-tvout
+  - compatible: "st,stih-dvo"
+  - reg: Physical base address of the IP registers and length of memory mapped 
region.
+  - reg-names: names of the mapped memory regions listed in regs property in
+the same order.
+  - clocks: from common clock binding: handle hardware IP needed clocks, the
+number of clocks may depend of the SoC type.
+See ../clocks/clock-bindings.txt for details.
+  - clock-names: names of the clocks listed in clocks property in the same
+order.
+  - pinctrl-0: pin control handle
+  - pinctrl-name: names of the pin control to use
+  - sti,panel: phandle of the panel connected to the DVO output
+
 sti-hqvdp:
   must be a child of sti-display-subsystem
   Required properties:
@@ -198,6 +214,19 @@ Example:
clock-names = "pix", "hddac";
clocks  = <&clockgen_c_vcc 
CLK_S_PIX_HD>, <&clockgen_c_vcc CLK_S_HDDAC>;
};
+
+   sti-dvo at 8d00400 {
+   compatible  = "st,stih407-dvo";
+   reg = <0x8d00400 0x200>;
+   reg-names   = "dvo-reg";
+   clock-names = "dvo_pix", "dvo",
+ "main_parent", "aux_parent";
+   clocks  = <&clk_s_d2_flexgen 
CLK_PIX_DVO>, <&clk_s_d2_flexgen CLK_DVO>,
+ <&clk_s_d2_quadfs 0>, 
<&clk_s_d2_quadfs 1>;
+   pinctrl-names   = "default";
+   pinctrl-0   = <&pinctrl_dvo>;
+   sti,panel   = <&panel_dvo>;
+   };
};

sti-hqvdp at 9c00 {
diff --git a/drivers/gpu/drm/sti/Makefile b/drivers/gpu/drm/sti/Makefile
index 6ba9d27..f0f1e4e 100644
--- a/drivers/gpu/drm/sti/Makefile
+++ b/drivers/gpu/drm/sti/Makefile
@@ -12,6 +12,9 @@ stihdmi-y := sti_hdmi.o \
sti_hdmi_tx3g0c55phy.o \
sti_hdmi_tx3g4c28phy.o \

+stidvo-y := sti_dvo.o \
+   sti_awg_utils.o
+
 obj-$(CONFIG_DRM_STI) = \
sti_vtg.o \
sti_vtac.o \
@@ -20,4 +23,5 @@ obj-$(CONFIG_DRM_STI) = \
sti_tvout.o \
sticompositor.o \
sti_hqvdp.o \
+   stidvo.o \
sti_drm_drv.o
diff --git a/drivers/gpu/drm/sti/sti_awg_utils.c 
b/drivers/gpu/drm/sti/sti_awg_utils.c
new file mode 100644
index 000..9fde3ee
--- /dev/null
+++ b/drivers/gpu/drm/sti/sti_awg_utils.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Author: Vincent Abriou  for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include "sti_awg_utils.h"
+
+#define AWG_OPCODE_OFFSET 10
+
+enum opcode {
+   SET,
+   RPTSET,
+   RPLSET,
+   SKIP,
+   STOP,
+   REPEAT,
+   REPLAY,
+   JUMP,
+   HOLD,
+};
+
+static int awg_generate_instr(enum opcode opcode,
+ long int arg,
+ long int mux_sel,
+ long int data_en,
+ struct awg_code_generation_params *fwparams)
+{
+   u32 instruction = 0;
+   u32 mux = (mux_sel << 8) & 0x1ff;
+   u32 data_enable = (data_en << 9) & 0x2ff;
+   long int arg_tmp = arg;
+
+   /* skip, repeat and replay arg should not exceed 1023.
+* If user wants to exceed this value, the instruction should be
+* duplicate and arg should be adjust for each duplicated instruction.
+*/
+
+   while (arg_tmp > 0) {
+   arg = arg_tmp;
+   if (fwparams->instruction_offset >= AWG_MAX_INST) {
+  

[RFC] drm: add support for tiled/compressed/etc modifier in addfb2

2014-12-16 Thread Rob Clark
On Tue, Dec 16, 2014 at 3:01 AM, Daniel Stone  wrote:
> Hi,
>
> On 16 December 2014 at 03:56, Michel Dänzer  wrote:
>>
>> On 12.12.2014 20:27, Daniel Stone wrote:
>> > It might be useful to make the interpretation modifiers bitmaskable, so
>> > they can be combined (e.g. wide-range/unclamped YUV | whatever chroma
>> > siting), but I can't think of a usecase for combining multiple layout
>> > modifiers (e.g. this tiling | that compression).
>>
>> I might be misunderstanding what you're referring to, but FWIW: With AMD
>> GPUs, the compression format and tiling parameters can be chosen
>> (mostly) independently.
>
>
> Should've been a little more clear. Definitely each vendor will have their
> own combination of modes, but I mostly meant that I don't really see a use
> for VENDOR_AMD(compression_1) | VENDOR_OTHER(tiling_N), or VENDOR_ARM(afbc)
> | VENDOR_SAMSUNG(tiling_12x64). Each vendor's space would be free to use the
> 24 sub-bits as a bitmask, but I don't think there's a need for combining
> tokens from multiple vendor spaces.
>

fwiw, I bumped it up to 64b (but haven't resent yet).. so now there
are 56bits to divide as vendor sees fit between tiling/compression..
56bits ought to be enough for anyone, right? :-P

BR,
-R

> Cheers,
> Daniel


[RFC] drm: add support for tiled/compressed/etc modifier in addfb2

2014-12-16 Thread Ville Syrjälä
On Mon, Dec 15, 2014 at 10:19:47PM +, Daniel Stone wrote:
> Hi,
> 
> On 12 December 2014 at 18:22, Ville Syrjälä  linux.intel.com>
> wrote:
> >
> > On Fri, Dec 12, 2014 at 06:05:49PM +, Daniel Stone wrote:
> > > On 12 December 2014 at 18:00, Ville Syrjälä <
> > ville.syrjala at linux.intel.com>
> > > wrote:
> > > > Well anyone who is serious about quality ought to handle that stuff.
> > > > Or at least make sure both GL/whatever and planes ignore the hints in
> > > > the same way. So if you GL implementation is lax then you anyway need
> > > > to have some driver/hardware specific knowledge to know which way to go
> > > > when using the plane path to get matching output.
> > > >
> > >
> > > Anyone who's serious about quality and is also using GL for video, is not
> > > serious about quality. Or accurate timing.
> >
> > You're too hung up on the "GL" there. It doesn't actually matter what
> > you use to render the video when not using the display hardware. The
> > same problem remains.
> 
> 
> Yes, the problem being that sometimes you want to force the hardware to do
> exactly what you want and literally nothing else, and sometimes you don't
> care.
> 
> I posit that a hint-with-optional-force interface is best, because:
>   - if your hint isn't supported, what do you do? fall back to software?
>   - the number of people who care enough to force it is vanishingly small,
> which is partly shown by how:
>   - it matches GL semantics
>   - not a great deal of hardware supports them
> 
> 
> > > > I was more thinking of some global "I want exactly what I said" kind
> > > > of knob. Maybe as a client cap type of thingy.
> > >
> > > I like the idea of keeping it local to the chroma-siting/range hints,
> > > because it makes it far more clear exactly what it affects.
> >
> > You're not thinking wide enough. We would need to add similar hints
> > to pretty much every property.
> 
> 
> Which other properties do we have right now that drivers treat as optional
> hints?

All the src/dst coordinates for one.

> If the answer involves hypothetical new properties, what are they?

Future ones might involve various color adjustment controls, at least if
we want to attempt to make them hardware agnostic.

Color keying properties might be have the same problem. I realize that
treating color keying properties as hints doesn't really make much sense,
but I'm not sure we have any sane alternative since the specific values
you need to plug into the color keying register is rather hardware
specific, and eg. with dst color keying it often depends on the pixel
format of some other plane.

-- 
Ville Syrjälä
Intel OTC


[Bug 89661] Kernel panic when trying use amdkfd driver on Kaveri

2014-12-16 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=89661

--- Comment #10 from Oded Gabbay  ---
Hi,
So I managed to recreate the bug on my setup.
This is happening because you compiled all the modules inside the kernel. I
need to address that, but for now, if you will compile them as "m", everything
is supposed to work.

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


[PATCH 0/8] drm/tegra: Fixes for v3.19-rc1

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

Hi,

This is a set of fixes for two regressions and one bug in the IOMMU
mapping code. It turns out that all of these issues turn up primarily
on Tegra30 hardware. The IOMMU mapping bug only manifests on buffers
that aren't multiples of the page size. I happened to be testing HDMI
with 1080p while writing the code and framebuffers for that happen to
fit exactly within 2025 pages of 4 KiB each.

One of the regressions is caused by the IOMMU code allocating pages from
shmem which can have associated cache lines. If the pages aren't flushed
then these cache lines may be flushed later on and cause framebuffer
corruption. I'm not sure why I didn't see this before. Perhaps the board
that I was using had enough RAM so that the pages shmem would hand out
had a better chance of being unused. Or maybe I didn't look too closely.
The fix for this, implementing drm_clflush_*() for ARM, has also been
tested by Rob. The long-term plan is to make architectures expose an API
to flush pages, but for now drm_clflush_*() provides exactly what we
need.

The second regression is caused by a mismatch between the hardware pipe
number and the CRTC's DRM index. These were used inconsistently, which
could cause one code location to call drm_vblank_get() with a different
pipe than the corresponding drm_vblank_put(), thereby causing the
reference count to become unbalanced. Alexandre also reported a possible
race condition related to this, which this series also fixes.

I'm hoping to get reviews on this, especially the drm/irq and drm/cache
patches, quickly so that I can send a pull request to Dave, hopefully to
get this included, given the size, in v3.19-rc1 still.

Thierry

Thierry Reding (8):
  drm/irq: Add drm_crtc_send_vblank_event()
  drm/irq: Add drm_crtc_handle_vblank()
  drm/irq: Add drm_crtc_vblank_count()
  drm/tegra: dc: Consistently use the same pipe
  drm/tegra: dc: Fix a potential race on page-flip completion
  drm/cache: Implement drm_clflush_*() for ARM
  drm/tegra: gem: Flush buffer objects upon allocation
  drm/tegra: gem: Use the proper size for GEM objects

 drivers/gpu/drm/drm_cache.c | 45 ++
 drivers/gpu/drm/drm_irq.c   | 60 +
 drivers/gpu/drm/tegra/dc.c  | 24 ++
 drivers/gpu/drm/tegra/drm.c | 16 +++-
 drivers/gpu/drm/tegra/gem.c | 16 ++--
 include/drm/drmP.h  |  4 +++
 6 files changed, 142 insertions(+), 23 deletions(-)

-- 
2.1.3



[PATCH 1/8] drm/irq: Add drm_crtc_send_vblank_event()

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

This function is the KMS native variant of drm_send_vblank_event(). It
takes a struct drm_crtc * instead of a struct drm_device * and an index
of the CRTC.

Eventually the goal is to access vblank data through the CRTC only so
that the per-CRTC data can be moved to struct drm_crtc.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_irq.c | 19 +++
 include/drm/drmP.h|  2 ++
 2 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 920cdb91e9d0..795cff890114 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -904,6 +904,8 @@ static void send_vblank_event(struct drm_device *dev,
  *
  * Updates sequence # and timestamp on event, and sends it to userspace.
  * Caller must hold event lock.
+ *
+ * This is the legacy version of drm_crtc_send_vblank_event().
  */
 void drm_send_vblank_event(struct drm_device *dev, int crtc,
struct drm_pending_vblank_event *e)
@@ -924,6 +926,23 @@ void drm_send_vblank_event(struct drm_device *dev, int 
crtc,
 EXPORT_SYMBOL(drm_send_vblank_event);

 /**
+ * drm_crtc_send_vblank_event - helper to send vblank event after pageflip
+ * @crtc: the source CRTC of the vblank event
+ * @e: the event to send
+ *
+ * Updates sequence # and timestamp on event, and sends it to userspace.
+ * Caller must hold event lock.
+ *
+ * This is the native KMS version of drm_send_vblank_event().
+ */
+void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
+   struct drm_pending_vblank_event *e)
+{
+   drm_send_vblank_event(crtc->dev, drm_crtc_index(crtc), e);
+}
+EXPORT_SYMBOL(drm_crtc_send_vblank_event);
+
+/**
  * drm_vblank_enable - enable the vblank interrupt on a CRTC
  * @dev: DRM device
  * @crtc: CRTC in question
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8ba35c622e22..b78601bb7c46 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -905,6 +905,8 @@ extern u32 drm_vblank_count_and_time(struct drm_device 
*dev, int crtc,
 struct timeval *vblanktime);
 extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
 struct drm_pending_vblank_event *e);
+extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
+  struct drm_pending_vblank_event *e);
 extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
 extern int drm_vblank_get(struct drm_device *dev, int crtc);
 extern void drm_vblank_put(struct drm_device *dev, int crtc);
-- 
2.1.3



[PATCH 2/8] drm/irq: Add drm_crtc_handle_vblank()

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

This function is the KMS native variant of drm_handle_vblank(). It takes
a struct drm_crtc * instead of a struct drm_device * and an index of the
CRTC.

Eventually the goal is to access vblank data through the CRTC only so
that the per-CRTC data can be moved to struct drm_crtc.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_irq.c | 20 
 include/drm/drmP.h|  1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 795cff890114..f7f1b579526e 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1614,6 +1614,8 @@ static void drm_handle_vblank_events(struct drm_device 
*dev, int crtc)
  *
  * Drivers should call this routine in their vblank interrupt handlers to
  * update the vblank counter and send any signals that may be pending.
+ *
+ * This is the legacy version of drm_crtc_handle_vblank().
  */
 bool drm_handle_vblank(struct drm_device *dev, int crtc)
 {
@@ -1690,3 +1692,21 @@ bool drm_handle_vblank(struct drm_device *dev, int crtc)
return true;
 }
 EXPORT_SYMBOL(drm_handle_vblank);
+
+/**
+ * drm_crtc_handle_vblank - handle a vblank event
+ * @crtc: where this event occurred
+ *
+ * Drivers should call this routine in their vblank interrupt handlers to
+ * update the vblank counter and send any signals that may be pending.
+ *
+ * This is the native KMS version of drm_handle_vblank().
+ *
+ * Returns:
+ * True if the event was successfully handled, false on failure.
+ */
+bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
+{
+   return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
+}
+EXPORT_SYMBOL(drm_crtc_handle_vblank);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index b78601bb7c46..f1f7f15ce0f3 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -908,6 +908,7 @@ extern void drm_send_vblank_event(struct drm_device *dev, 
int crtc,
 extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
   struct drm_pending_vblank_event *e);
 extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
+extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
 extern int drm_vblank_get(struct drm_device *dev, int crtc);
 extern void drm_vblank_put(struct drm_device *dev, int crtc);
 extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
-- 
2.1.3



[PATCH 3/8] drm/irq: Add drm_crtc_vblank_count()

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

This function is the KMS native variant of drm_vblank_count(). It takes
a struct drm_crtc * instead of a struct drm_device * and an index of the
CRTC.

Eventually the goal is to access vblank data through the CRTC only so
that the per-CRTC data can be moved to struct drm_crtc.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_irq.c | 21 +
 include/drm/drmP.h|  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index f7f1b579526e..75647e7f012b 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -830,6 +830,8 @@ drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
  * vblank events since the system was booted, including lost events due to
  * modesetting activity.
  *
+ * This is the legacy version of drm_crtc_vblank_count().
+ *
  * Returns:
  * The software vblank counter.
  */
@@ -844,6 +846,25 @@ u32 drm_vblank_count(struct drm_device *dev, int crtc)
 EXPORT_SYMBOL(drm_vblank_count);

 /**
+ * drm_crtc_vblank_count - retrieve "cooked" vblank counter value
+ * @crtc: which counter to retrieve
+ *
+ * Fetches the "cooked" vblank count value that represents the number of
+ * vblank events since the system was booted, including lost events due to
+ * modesetting activity.
+ *
+ * This is the native KMS version of drm_vblank_count().
+ *
+ * Returns:
+ * The software vblank counter.
+ */
+u32 drm_crtc_vblank_count(struct drm_crtc *crtc)
+{
+   return drm_vblank_count(crtc->dev, drm_crtc_index(crtc));
+}
+EXPORT_SYMBOL(drm_crtc_vblank_count);
+
+/**
  * drm_vblank_count_and_time - retrieve "cooked" vblank counter value
  * and the system timestamp corresponding to that vblank counter value.
  *
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index f1f7f15ce0f3..e1b2e8b98af7 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -901,6 +901,7 @@ extern int drm_vblank_init(struct drm_device *dev, int 
num_crtcs);
 extern int drm_wait_vblank(struct drm_device *dev, void *data,
   struct drm_file *filp);
 extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
+extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
 extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
 struct timeval *vblanktime);
 extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
-- 
2.1.3



[PATCH 4/8] drm/tegra: dc: Consistently use the same pipe

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

The hardware pipe numbers don't always match the DRM CRTC indices. This
can happen for example if the first display controller defers probe,
causing it to be registered with DRM after the second display
controller. When that happens the hardware pipe numbers and DRM CRTC
indices become different. Make sure that the CRTC index is always used
when accessing per-CRTC VBLANK data. This can be ensured by using the
drm_crtc_vblank_*() API, which will do the right thing automatically
given a struct drm_crtc *.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/tegra/dc.c  | 14 +++---
 drivers/gpu/drm/tegra/drm.c | 16 ++--
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 7fe7bb1227cf..4c6a8a828475 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -826,8 +826,8 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)

if (base == bo->paddr + crtc->primary->fb->offsets[0]) {
spin_lock_irqsave(&drm->event_lock, flags);
-   drm_send_vblank_event(drm, dc->pipe, dc->event);
-   drm_vblank_put(drm, dc->pipe);
+   drm_crtc_send_vblank_event(crtc, dc->event);
+   drm_crtc_vblank_put(crtc);
dc->event = NULL;
spin_unlock_irqrestore(&drm->event_lock, flags);
}
@@ -843,7 +843,7 @@ void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, 
struct drm_file *file)

if (dc->event && dc->event->base.file_priv == file) {
dc->event->base.destroy(&dc->event->base);
-   drm_vblank_put(drm, dc->pipe);
+   drm_crtc_vblank_put(crtc);
dc->event = NULL;
}

@@ -853,16 +853,16 @@ void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, 
struct drm_file *file)
 static int tegra_dc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer 
*fb,
  struct drm_pending_vblank_event *event, uint32_t 
page_flip_flags)
 {
+   unsigned int pipe = drm_crtc_index(crtc);
struct tegra_dc *dc = to_tegra_dc(crtc);
-   struct drm_device *drm = crtc->dev;

if (dc->event)
return -EBUSY;

if (event) {
-   event->pipe = dc->pipe;
+   event->pipe = pipe;
dc->event = event;
-   drm_vblank_get(drm, dc->pipe);
+   drm_crtc_vblank_get(crtc);
}

tegra_dc_set_base(dc, 0, 0, fb);
@@ -1122,7 +1122,7 @@ static irqreturn_t tegra_dc_irq(int irq, void *data)
/*
dev_dbg(dc->dev, "%s(): vertical blank\n", __func__);
*/
-   drm_handle_vblank(dc->base.dev, dc->pipe);
+   drm_crtc_handle_vblank(&dc->base);
tegra_dc_finish_page_flip(dc);
}

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index e549afeece1f..d4f827593dfa 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -694,24 +694,28 @@ static const struct file_operations tegra_drm_fops = {
.llseek = noop_llseek,
 };

-static struct drm_crtc *tegra_crtc_from_pipe(struct drm_device *drm, int pipe)
+static struct drm_crtc *tegra_crtc_from_pipe(struct drm_device *drm,
+unsigned int pipe)
 {
struct drm_crtc *crtc;

list_for_each_entry(crtc, &drm->mode_config.crtc_list, head) {
-   struct tegra_dc *dc = to_tegra_dc(crtc);
-
-   if (dc->pipe == pipe)
+   if (pipe == drm_crtc_index(crtc))
return crtc;
}

return NULL;
 }

-static u32 tegra_drm_get_vblank_counter(struct drm_device *dev, int crtc)
+static u32 tegra_drm_get_vblank_counter(struct drm_device *drm, int pipe)
 {
+   struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
+
+   if (!crtc)
+   return 0;
+
/* TODO: implement real hardware counter using syncpoints */
-   return drm_vblank_count(dev, crtc);
+   return drm_crtc_vblank_count(crtc);
 }

 static int tegra_drm_enable_vblank(struct drm_device *drm, int pipe)
-- 
2.1.3



[PATCH 5/8] drm/tegra: dc: Fix a potential race on page-flip completion

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

Page-flip completion could race with page-flip submission, so extend the
critical section to include all accesses to page-flip related data.

Reported-by: Alexandre Courbot 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/tegra/dc.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 4c6a8a828475..28040f7e4a43 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -814,8 +814,12 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
unsigned long flags, base;
struct tegra_bo *bo;

-   if (!dc->event)
+   spin_lock_irqsave(&drm->event_lock, flags);
+
+   if (!dc->event) {
+   spin_unlock_irqrestore(&drm->event_lock, flags);
return;
+   }

bo = tegra_fb_get_plane(crtc->primary->fb, 0);

@@ -825,12 +829,12 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);

if (base == bo->paddr + crtc->primary->fb->offsets[0]) {
-   spin_lock_irqsave(&drm->event_lock, flags);
drm_crtc_send_vblank_event(crtc, dc->event);
drm_crtc_vblank_put(crtc);
dc->event = NULL;
-   spin_unlock_irqrestore(&drm->event_lock, flags);
}
+
+   spin_unlock_irqrestore(&drm->event_lock, flags);
 }

 void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file)
-- 
2.1.3



[PATCH 6/8] drm/cache: Implement drm_clflush_*() for ARM

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

Add implementations for drm_clflush_*() on ARM by borrowing code from
the DMA mapping API implementation. Unfortunately ARM doesn't export an
API to flush caches on a page by page basis, so this replicates most of
the code.

Reviewed--by: Rob Clark 
Tested-by: Rob Clark 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_cache.c | 45 +
 1 file changed, 45 insertions(+)

diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
index a6b690626a6b..fca0b8994c77 100644
--- a/drivers/gpu/drm/drm_cache.c
+++ b/drivers/gpu/drm/drm_cache.c
@@ -72,6 +72,41 @@ drm_clflush_ipi_handler(void *null)
 }
 #endif

+#if defined(CONFIG_ARM)
+
+#include 
+#include 
+#include 
+#include 
+
+static void drm_clflush_page(struct page *page)
+{
+   enum dma_data_direction dir = DMA_TO_DEVICE;
+   phys_addr_t phys = page_to_phys(page);
+   size_t size = PAGE_SIZE;
+   void *virt;
+
+   if (PageHighMem(page)) {
+   if (cache_is_vipt_nonaliasing()) {
+   virt = kmap_atomic(page);
+   dmac_map_area(virt, size, dir);
+   kunmap_atomic(virt);
+   } else {
+   virt = kmap_high_get(page);
+   if (virt) {
+   dmac_map_area(virt, size, dir);
+   kunmap_high(page);
+   }
+   }
+   } else {
+   virt = page_address(page);
+   dmac_map_area(virt, size, dir);
+   }
+
+   outer_flush_range(phys, phys + PAGE_SIZE);
+}
+#endif
+
 void
 drm_clflush_pages(struct page *pages[], unsigned long num_pages)
 {
@@ -99,6 +134,11 @@ drm_clflush_pages(struct page *pages[], unsigned long 
num_pages)
   (unsigned long)page_virtual + PAGE_SIZE);
kunmap_atomic(page_virtual);
}
+#elif defined(CONFIG_ARM)
+   unsigned long i;
+
+   for (i = 0; i < num_pages; i++)
+   drm_clflush_page(pages[i]);
 #else
printk(KERN_ERR "Architecture has no drm_cache.c support\n");
WARN_ON_ONCE(1);
@@ -123,6 +163,11 @@ drm_clflush_sg(struct sg_table *st)

if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
printk(KERN_ERR "Timed out waiting for cache flush.\n");
+#elif defined(CONFIG_ARM)
+   struct sg_page_iter sg_iter;
+
+   for_each_sg_page(st->sgl, &sg_iter, st->nents, 0)
+   drm_clflush_page(sg_page_iter_page(&sg_iter));
 #else
printk(KERN_ERR "Architecture has no drm_cache.c support\n");
WARN_ON_ONCE(1);
-- 
2.1.3



[PATCH 7/8] drm/tegra: gem: Flush buffer objects upon allocation

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

Buffers obtained via shmem may still have associated cachelines. If they
aren't properly flushed they may cause framebuffer corruption if the
cache gets flushed after the application has drawn to it.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/tegra/gem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index da32086cbeaf..9a12adf708db 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -231,6 +231,8 @@ static int tegra_bo_get_pages(struct drm_device *drm, 
struct tegra_bo *bo,
return PTR_ERR(bo->sgt);
}

+   drm_clflush_sg(bo->sgt);
+
return 0;
 }

-- 
2.1.3



[PATCH 8/8] drm/tegra: gem: Use the proper size for GEM objects

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

If the requested buffer size wasn't a multiple of the page size, the
IOMMU code would round down the size to the next multiple of the page
size, thereby causing translation errors. To fix this we no longer pass
around the requested size but reuse the computed size of the GEM object.
This is already rounded to the next page boundary, so mapping that size
works out fine.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/tegra/gem.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index 9a12adf708db..676d9a9f8d70 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -216,14 +216,13 @@ static void tegra_bo_free(struct drm_device *drm, struct 
tegra_bo *bo)
}
 }

-static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo,
- size_t size)
+static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo)
 {
bo->pages = drm_gem_get_pages(&bo->gem);
if (IS_ERR(bo->pages))
return PTR_ERR(bo->pages);

-   bo->num_pages = size >> PAGE_SHIFT;
+   bo->num_pages = bo->gem.size >> PAGE_SHIFT;

bo->sgt = drm_prime_pages_to_sg(bo->pages, bo->num_pages);
if (IS_ERR(bo->sgt)) {
@@ -236,14 +235,13 @@ static int tegra_bo_get_pages(struct drm_device *drm, 
struct tegra_bo *bo,
return 0;
 }

-static int tegra_bo_alloc(struct drm_device *drm, struct tegra_bo *bo,
- size_t size)
+static int tegra_bo_alloc(struct drm_device *drm, struct tegra_bo *bo)
 {
struct tegra_drm *tegra = drm->dev_private;
int err;

if (tegra->domain) {
-   err = tegra_bo_get_pages(drm, bo, size);
+   err = tegra_bo_get_pages(drm, bo);
if (err < 0)
return err;

@@ -253,6 +251,8 @@ static int tegra_bo_alloc(struct drm_device *drm, struct 
tegra_bo *bo,
return err;
}
} else {
+   size_t size = bo->gem.size;
+
bo->vaddr = dma_alloc_writecombine(drm->dev, size, &bo->paddr,
   GFP_KERNEL | __GFP_NOWARN);
if (!bo->vaddr) {
@@ -276,7 +276,7 @@ struct tegra_bo *tegra_bo_create(struct drm_device *drm, 
size_t size,
if (IS_ERR(bo))
return bo;

-   err = tegra_bo_alloc(drm, bo, size);
+   err = tegra_bo_alloc(drm, bo);
if (err < 0)
goto release;

-- 
2.1.3



[PATCH 01/13] drm/irq: Remove negative CRTC index special-case

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

The drm_send_vblank_event() function treats negative CRTC indices as
meaning that a driver doesn't have proper VBLANK handling. This is the
only place where DRM needs negative CRTC indices, so in order to enable
subsequent cleanup, remove this special case and replace it by the more
obvious check for whether or not VBLANK support was initialized.

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

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 75647e7f012b..a24658162284 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -934,7 +934,7 @@ void drm_send_vblank_event(struct drm_device *dev, int crtc,
struct timeval now;
unsigned int seq;

-   if (crtc >= 0) {
+   if (dev->num_crtcs > 0) {
seq = drm_vblank_count_and_time(dev, crtc, &now);
} else {
seq = 0;
-- 
2.1.3



[PATCH 02/13] drm/bochs: Store correct CRTC index in events

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

Previously a negative pipe caused a special case to be triggered for
drivers that didn't have proper VBLANK support. The trigger for this
special case is now independent of the pipe, so the correct CRTC index
can now be stored in events.

Cc: Gerd Hoffmann 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/bochs/bochs_kms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c 
b/drivers/gpu/drm/bochs/bochs_kms.c
index 26bcd03a8cb6..c219c1de3722 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -113,13 +113,14 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,
struct bochs_device *bochs =
container_of(crtc, struct bochs_device, crtc);
struct drm_framebuffer *old_fb = crtc->primary->fb;
+   unsigned int pipe = drm_crtc_index(crtc);
unsigned long irqflags;

crtc->primary->fb = fb;
bochs_crtc_mode_set_base(crtc, 0, 0, old_fb);
if (event) {
spin_lock_irqsave(&bochs->dev->event_lock, irqflags);
-   drm_send_vblank_event(bochs->dev, -1, event);
+   drm_send_vblank_event(bochs->dev, pipe, event);
spin_unlock_irqrestore(&bochs->dev->event_lock, irqflags);
}
return 0;
-- 
2.1.3



[PATCH 03/13] drm/exynos: Store correct CRTC index in events

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

A negative pipe causes a special case to be triggered for drivers that
don't have proper VBLANK support. Exynos does support VBLANKs, so there
is no need for the fallback code.

Cc: Inki Dae 
Cc: Joonyoung Shim 
Cc: Seung-Woo Kim 
Cc: Kyungmin Park 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 7615bb1b76de..f20fa537945c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -537,7 +537,7 @@ void exynos_drm_crtc_finish_pageflip(struct drm_device 
*dev, int pipe)
continue;

list_del(&e->base.link);
-   drm_send_vblank_event(dev, -1, e);
+   drm_send_vblank_event(dev, pipe, e);
drm_vblank_put(dev, pipe);
atomic_set(&exynos_crtc->pending_flip, 0);
wake_up(&exynos_crtc->pending_flip_queue);
-- 
2.1.3



[PATCH 04/13] drm/imx: Make pipe number unsigned

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

There's no reason whatsoever why this should ever be negative.

Cc: Philipp Zabel 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 4 ++--
 drivers/gpu/drm/imx/imx-drm.h  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index b250130debc8..c52eccc58a95 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -44,7 +44,7 @@ struct imx_drm_device {

 struct imx_drm_crtc {
struct drm_crtc *crtc;
-   int pipe;
+   unsigned intpipe;
struct imx_drm_crtc_helper_funcsimx_drm_helper_funcs;
struct device_node  *port;
 };
@@ -52,7 +52,7 @@ struct imx_drm_crtc {
 static int legacyfb_depth = 16;
 module_param(legacyfb_depth, int, 0444);

-int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
+unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
 {
return crtc->pipe;
 }
diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h
index 7453ae00c412..a15b80319a6a 100644
--- a/drivers/gpu/drm/imx/imx-drm.h
+++ b/drivers/gpu/drm/imx/imx-drm.h
@@ -12,7 +12,7 @@ struct drm_framebuffer;
 struct imx_drm_crtc;
 struct platform_device;

-int imx_drm_crtc_id(struct imx_drm_crtc *crtc);
+unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc);

 struct imx_drm_crtc_helper_funcs {
int (*enable_vblank)(struct drm_crtc *crtc);
-- 
2.1.3



[PATCH 05/13] drm/imx: Store correct CRTC index in events

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

A negative pipe causes a special case to be triggered for drivers that
don't have proper VBLANK support. i.MX does support VBLANKs, so there is
no need for the fallback code.

Cc: Philipp Zabel 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index ebee59cb96d8..df3e8b6101b3 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -209,7 +209,8 @@ static void ipu_crtc_handle_pageflip(struct ipu_crtc 
*ipu_crtc)

spin_lock_irqsave(&drm->event_lock, flags);
if (ipu_crtc->page_flip_event)
-   drm_send_vblank_event(drm, -1, ipu_crtc->page_flip_event);
+   drm_send_vblank_event(drm, imx_drm_crtc_id(ipu_crtc->imx_crtc),
+ ipu_crtc->page_flip_event);
ipu_crtc->page_flip_event = NULL;
imx_drm_crtc_vblank_put(ipu_crtc->imx_crtc);
spin_unlock_irqrestore(&drm->event_lock, flags);
-- 
2.1.3



[PATCH 06/13] drm/rockchip: Store correct CRTC index in events

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

A negative pipe causes a special case to be triggered for drivers that
don't have proper VBLANK support. Rockchip does support VBLANKs, so
there is no need for the fallback code.

Cc: Mark Yao 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index e7ca25b3fb38..999616d216ac 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -958,7 +958,7 @@ static void vop_win_state_complete(struct vop_win *vop_win,

if (state->event) {
spin_lock_irqsave(&drm->event_lock, flags);
-   drm_send_vblank_event(drm, -1, state->event);
+   drm_send_vblank_event(drm, vop->pipe, state->event);
spin_unlock_irqrestore(&drm->event_lock, flags);
}

-- 
2.1.3



[PATCH 07/13] drm/sti: Store correct CRTC index in events

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

A negative pipe causes a special case to be triggered for drivers that
don't have proper VBLANK support. STi does support VBLANKs, so there is
no need for the fallback code.

Cc: Benjamin Gaignard 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/sti/sti_drm_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sti/sti_drm_crtc.c 
b/drivers/gpu/drm/sti/sti_drm_crtc.c
index e6f6ef7c4866..13bfe7bcb167 100644
--- a/drivers/gpu/drm/sti/sti_drm_crtc.c
+++ b/drivers/gpu/drm/sti/sti_drm_crtc.c
@@ -332,7 +332,7 @@ int sti_drm_crtc_vblank_cb(struct notifier_block *nb,

spin_lock_irqsave(&drm_dev->event_lock, flags);
if (compo->mixer[*crtc]->pending_event) {
-   drm_send_vblank_event(drm_dev, -1,
+   drm_send_vblank_event(drm_dev, *crtc,
compo->mixer[*crtc]->pending_event);
drm_vblank_put(drm_dev, *crtc);
compo->mixer[*crtc]->pending_event = NULL;
-- 
2.1.3



[PATCH 08/13] drm/irq: Check for valid VBLANK before dereference

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

When accessing the array of per-CRTC VBLANK structures we must always
check that the index into the array is valid before dereferencing to
avoid crashing.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_irq.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index a24658162284..cb207e047505 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1070,10 +1070,10 @@ void drm_vblank_put(struct drm_device *dev, int crtc)
 {
struct drm_vblank_crtc *vblank = &dev->vblank[crtc];

-   if (WARN_ON(atomic_read(&vblank->refcount) == 0))
+   if (WARN_ON(crtc >= dev->num_crtcs))
return;

-   if (WARN_ON(crtc >= dev->num_crtcs))
+   if (WARN_ON(atomic_read(&vblank->refcount) == 0))
return;

/* Last user schedules interrupt disable */
@@ -1356,6 +1356,9 @@ void drm_vblank_post_modeset(struct drm_device *dev, int 
crtc)
if (!dev->num_crtcs)
return;

+   if (WARN_ON(crtc >= dev->num_crtcs))
+   return;
+
if (vblank->inmodeset) {
spin_lock_irqsave(&dev->vbl_lock, irqflags);
dev->vblank_disable_allowed = true;
-- 
2.1.3



[PATCH 09/13] drm/irq: Make pipe unsigned and name consistent

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

Name all references to the pipe number (CRTC index) consistently to make
it easier to distinguish which is a pipe number and which is a pointer
to struct drm_crtc.

While at it also make all references to the pipe number unsigned because
there is no longer any reason why it should ever be negative.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_irq.c | 319 +++---
 include/drm/drmP.h|  34 ++---
 2 files changed, 179 insertions(+), 174 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index cb207e047505..9c32a1d7aec2 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -43,8 +43,8 @@
 #include 

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

 /* Retry timestamp calculation up to 3 times to satisfy
  * drm_timestamp_precision before giving up.
@@ -57,7 +57,7 @@
 #define DRM_REDUNDANT_VBLIRQ_THRESH_NS 100

 static bool
-drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
+drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
  struct timeval *tvblank, unsigned flags);

 static unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
@@ -77,7 +77,7 @@ module_param_named(timestamp_monotonic, 
drm_timestamp_monotonic, int, 0600);
 /**
  * drm_update_vblank_count - update the master vblank counter
  * @dev: DRM device
- * @crtc: counter to update
+ * @pipe: counter to update
  *
  * Call back into the driver to update the appropriate vblank counter
  * (specified by @crtc).  Deal with wraparound, if it occurred, and
@@ -90,9 +90,9 @@ module_param_named(timestamp_monotonic, 
drm_timestamp_monotonic, int, 0600);
  * Note: caller must hold dev->vbl_lock since this reads & writes
  * device vblank fields.
  */
-static void drm_update_vblank_count(struct drm_device *dev, int crtc)
+static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe)
 {
-   struct drm_vblank_crtc *vblank = &dev->vblank[crtc];
+   struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
u32 cur_vblank, diff, tslot;
bool rc;
struct timeval t_vblank;
@@ -110,21 +110,21 @@ static void drm_update_vblank_count(struct drm_device 
*dev, int crtc)
 * corresponding vblank timestamp.
 */
do {
-   cur_vblank = dev->driver->get_vblank_counter(dev, crtc);
-   rc = drm_get_last_vbltimestamp(dev, crtc, &t_vblank, 0);
-   } while (cur_vblank != dev->driver->get_vblank_counter(dev, crtc));
+   cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
+   rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, 0);
+   } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe));

/* Deal with counter wrap */
diff = cur_vblank - vblank->last;
if (cur_vblank < vblank->last) {
diff += dev->max_vblank_count;

-   DRM_DEBUG("last_vblank[%d]=0x%x, cur_vblank=0x%x => 
diff=0x%x\n",
- crtc, vblank->last, cur_vblank, diff);
+   DRM_DEBUG("last_vblank[%u]=0x%x, cur_vblank=0x%x => 
diff=0x%x\n",
+ pipe, vblank->last, cur_vblank, diff);
}

-   DRM_DEBUG("updating vblank count on crtc %d, missed %d\n",
- crtc, diff);
+   DRM_DEBUG("updating vblank count on crtc %u, missed %d\n",
+ pipe, diff);

if (diff == 0)
return;
@@ -135,7 +135,7 @@ static void drm_update_vblank_count(struct drm_device *dev, 
int crtc)
 */
if (rc) {
tslot = atomic_read(&vblank->count) + diff;
-   vblanktimestamp(dev, crtc, tslot) = t_vblank;
+   vblanktimestamp(dev, pipe, tslot) = t_vblank;
}

smp_mb__before_atomic();
@@ -149,9 +149,9 @@ static void drm_update_vblank_count(struct drm_device *dev, 
int crtc)
  * are preserved, even if there are any spurious vblank irq's after
  * disable.
  */
-static void vblank_disable_and_save(struct drm_device *dev, int crtc)
+static void vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
 {
-   struct drm_vblank_crtc *vblank = &dev->vblank[crtc];
+   struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
unsigned long irqflags;
u32 vblcount;
s64 diff_ns;
@@ -179,13 +179,13 @@ static void vblank_disable_and_save(struct drm_device 
*dev, int crtc)
 * vblank interrupt is disabled.
 */
if (!vblank->enabled &&
-   drm_get_last_vbltimestamp(dev, crtc, &tvblank, 0)) {
-   drm_update_vblank_count(dev, crtc);
+   drm_get_last_vbltimestamp(dev, pipe, &tvblank, 0)) {
+  

[PATCH 10/13] drm/irq: Add drm_crtc_vblank_count_and_time()

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

This function is the KMS native variant of drm_vblank_count_and_time().
It takes a struct drm_crtc * instead of a struct drm_device * and an
index of the CRTC.

Eventually the goal is to access vblank data through the CRTC only so
that the per-CRTC data can be moved to struct drm_crtc.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_irq.c | 23 +++
 include/drm/drmP.h|  2 ++
 2 files changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 9c32a1d7aec2..b34900a8e172 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -877,6 +877,8 @@ EXPORT_SYMBOL(drm_crtc_vblank_count);
  * vblank events since the system was booted, including lost events due to
  * modesetting activity. Returns corresponding system timestamp of the time
  * of the vblank interval that corresponds to the current vblank counter value.
+ *
+ * This is the legacy version of drm_crtc_vblank_count_and_time().
  */
 u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
  struct timeval *vblanktime)
@@ -902,6 +904,27 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, 
unsigned int pipe,
 }
 EXPORT_SYMBOL(drm_vblank_count_and_time);

+/**
+ * drm_crtc_vblank_count_and_time - retrieve "cooked" vblank counter value
+ * and the system timestamp corresponding to that vblank counter value
+ * @crtc: which counter to retrieve
+ * @vblanktime: Pointer to struct timeval to receive the vblank timestamp.
+ *
+ * Fetches the "cooked" vblank count value that represents the number of
+ * vblank events since the system was booted, including lost events due to
+ * modesetting activity. Returns corresponding system timestamp of the time
+ * of the vblank interval that corresponds to the current vblank counter value.
+ *
+ * This is the native KMS version of drm_vblank_count_and_time().
+ */
+u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
+  struct timeval *vblanktime)
+{
+   return drm_vblank_count_and_time(crtc->dev, drm_crtc_index(crtc),
+vblanktime);
+}
+EXPORT_SYMBOL(drm_crtc_vblank_count_and_time);
+
 static void send_vblank_event(struct drm_device *dev,
struct drm_pending_vblank_event *e,
unsigned long seq, struct timeval *now)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index de3d3f7091fb..7baef1dff5f3 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1072,6 +1072,8 @@ extern u32 drm_vblank_count(struct drm_device *dev, int 
pipe);
 extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
 extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 struct timeval *vblanktime);
+extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
+ struct timeval *vblanktime);
 extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe,
  struct drm_pending_vblank_event *e);
 extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
-- 
2.1.3



[PATCH 11/13] drm/irq: Document return values more consistently

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

Some of the functions are documented inconsistently. Add Returns:
sections where missing and use consistent style to describe the return
value.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_irq.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index b34900a8e172..ef5d993f06ee 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -991,6 +991,9 @@ EXPORT_SYMBOL(drm_crtc_send_vblank_event);
  * drm_vblank_enable - enable the vblank interrupt on a CRTC
  * @dev: DRM device
  * @pipe: CRTC index
+ *
+ * Returns:
+ * Zero on success or a negative error code on failure.
  */
 static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
 {
@@ -1035,7 +1038,7 @@ static int drm_vblank_enable(struct drm_device *dev, 
unsigned int pipe)
  * This is the legacy version of drm_crtc_vblank_get().
  *
  * Returns:
- * Zero on success, nonzero on failure.
+ * Zero on success or a negative error code on failure.
  */
 int drm_vblank_get(struct drm_device *dev, unsigned int pipe)
 {
@@ -1072,7 +1075,7 @@ EXPORT_SYMBOL(drm_vblank_get);
  * This is the native kms version of drm_vblank_off().
  *
  * Returns:
- * Zero on success, nonzero on failure.
+ * Zero on success or a negative error code on failure.
  */
 int drm_crtc_vblank_get(struct drm_crtc *crtc)
 {
-- 
2.1.3



[PATCH 12/13] drm/irq: Expel legacy API

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

These legacy functions all operate on the struct drm_device * and an
index to the CRTC that they should access. This is bad because it
requires keeping track of a global data structures to resolve the index
to CRTC object lookup. In order to get rid of this global data new APIs
have been introduced that operate directly on these objects. Currently
the new functions still operate on the old data, but the goal is to
eventually move that data into struct drm_crtc. In order to start
conversion of drivers to the new API, move the old API away.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/Makefile |2 +-
 drivers/gpu/drm/drm_internal.h   |2 +
 drivers/gpu/drm/drm_irq.c| 1121 +
 drivers/gpu/drm/drm_irq_legacy.c | 1144 ++
 4 files changed, 1165 insertions(+), 1104 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_irq_legacy.c

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 66e40398b3d3..c0d93beda612 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -5,7 +5,7 @@
 ccflags-y := -Iinclude/drm

 drm-y   := drm_auth.o drm_bufs.o drm_cache.o \
-   drm_context.o drm_dma.o \
+   drm_context.o drm_dma.o drm_irq_legacy.o \
drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
drm_lock.o drm_memory.o drm_drv.o drm_vm.o \
drm_agpsupport.o drm_scatter.o drm_pci.o \
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 12a61d706827..61d83b581c8b 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -22,7 +22,9 @@
  */

 /* drm_irq.c */
+extern unsigned int drm_timestamp_precision;
 extern unsigned int drm_timestamp_monotonic;
+extern int drm_vblank_offdelay;

 /* drm_fops.c */
 extern struct mutex drm_global_mutex;
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index ef5d993f06ee..37b536c57cd2 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -32,15 +32,13 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */

-#include 
-#include "drm_trace.h"
-#include "drm_internal.h"
-
+#include 
 #include/* For task queue support */
 #include 

-#include 
-#include 
+#include 
+
+#include "drm_trace.h"

 /* Access macro for slots in vblank timestamp ringbuffer. */
 #define vblanktimestamp(dev, pipe, count) \
@@ -51,16 +49,7 @@
  */
 #define DRM_TIMESTAMP_MAXRETRIES 3

-/* Threshold in nanoseconds for detection of redundant
- * vblank irq in drm_handle_vblank(). 1 msec should be ok.
- */
-#define DRM_REDUNDANT_VBLIRQ_THRESH_NS 100
-
-static bool
-drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
- struct timeval *tvblank, unsigned flags);
-
-static unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
+unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */

 /*
  * Default to use monotonic timestamps for wait-for-vblank and page-flip
@@ -68,492 +57,13 @@ static unsigned int drm_timestamp_precision = 20;  /* 
Default to 20 usecs. */
  */
 unsigned int drm_timestamp_monotonic = 1;

-static int drm_vblank_offdelay = 5000;/* Default to 5000 msecs. */
+int drm_vblank_offdelay = 5000;/* Default to 5000 msecs. */

 module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600);
 module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 
0600);
 module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);

 /**
- * drm_update_vblank_count - update the master vblank counter
- * @dev: DRM device
- * @pipe: counter to update
- *
- * Call back into the driver to update the appropriate vblank counter
- * (specified by @crtc).  Deal with wraparound, if it occurred, and
- * update the last read value so we can deal with wraparound on the next
- * call if necessary.
- *
- * Only necessary when going from off->on, to account for frames we
- * didn't get an interrupt for.
- *
- * Note: caller must hold dev->vbl_lock since this reads & writes
- * device vblank fields.
- */
-static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe)
-{
-   struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
-   u32 cur_vblank, diff, tslot;
-   bool rc;
-   struct timeval t_vblank;
-
-   /*
-* Interrupts were disabled prior to this call, so deal with counter
-* wrap if needed.
-* NOTE!  It's possible we lost a full dev->max_vblank_count events
-* here if the register is small or we had vblank interrupts off for
-* a long time.
-*
-* We repeat the hardware vblank counter & timestamp query until
-* we get consistent results. This to prevent races between gpu
-* updating its hardware counter while we are retrieving the
-* corresponding vblank timestamp.
-*/
-   do {
-   cur_vblank = d

[PATCH 13/13] drm/irq: Move some prototypes to drm_crtc.h

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

The new prototypes that deal with struct drm_crtc * directly are better
located in include/drm/drm_crtc.h along with the other functions that
deal with CRTCs.

Signed-off-by: Thierry Reding 
---
 include/drm/drmP.h | 17 -
 include/drm/drm_crtc.h | 15 +++
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 7baef1dff5f3..4809b6f8be8b 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1069,27 +1069,16 @@ extern int drm_vblank_init(struct drm_device *dev, 
unsigned int num_crtcs);
 extern int drm_wait_vblank(struct drm_device *dev, void *data,
   struct drm_file *filp);
 extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
-extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
 extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 struct timeval *vblanktime);
-extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
- struct timeval *vblanktime);
 extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe,
  struct drm_pending_vblank_event *e);
-extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
-  struct drm_pending_vblank_event *e);
 extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe);
-extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
 extern int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
 extern void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
-extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
-extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
 extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe);
-extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
 extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe);
 extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe);
-extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
-extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
 extern void drm_vblank_cleanup(struct drm_device *dev);

 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
@@ -1098,8 +1087,6 @@ extern int drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
 unsigned flags,
 const struct drm_crtc *refcrtc,
 const struct drm_display_mode 
*mode);
-extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
-   const struct drm_display_mode 
*mode);

 /**
  * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
@@ -1107,6 +1094,10 @@ extern void drm_calc_timestamping_constants(struct 
drm_crtc *crtc,
  *
  * This function returns a pointer to the vblank waitqueue for the CRTC.
  * Drivers can use this to implement vblank waits using wait_event() & co.
+ *
+ * XXX: Move this to include/drm/drm_crtc.h once per-CRTC VBLANK data has
+ * moved into struct drm_crtc. It can't currently be moved because drm_crtc.h
+ * doesn't know the definition of struct drm_device.
  */
 static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc 
*crtc)
 {
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index ea4dc4cc49c6..c1b639f55401 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1147,6 +1147,21 @@ extern int drm_crtc_init_with_planes(struct drm_device 
*dev,
 extern void drm_crtc_cleanup(struct drm_crtc *crtc);
 extern unsigned int drm_crtc_index(struct drm_crtc *crtc);

+extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
+extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
+ struct timeval *vblanktime);
+extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
+  struct drm_pending_vblank_event *e);
+extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
+extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
+extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
+extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
+extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
+extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
+
+extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
+   const struct drm_display_mode 
*mode);
+
 /**
  * drm_crtc_mask - find the mask of a registered CRTC
  * @crtc: CRTC to find mask for
-- 
2.1.3



[PATCH] drm: Move ->get_scanout_position() to struct drm_crtc_funcs

2014-12-16 Thread Thierry Reding
From: Thierry Reding 

None of the drivers use this in legacy mode, so it can be converted to
use struct drm_crtc * directly. While at it, also make the sole user of
the callback, drm_calc_vbltimestamp_from_scanoutpos(), pass through the
CRTC directly.

Cc: Daniel Vetter 
Cc: Jani Nikula 
Cc: Ben Skeggs 
Cc: Alex Deucher 
Cc: Christian König 
Signed-off-by: Thierry Reding 
---
Note: This is compile-tested only. It is a straightforward conversion so
I wouldn't expect any fallout, but it'd certainly be best if this can be
tested on all three drivers.

 drivers/gpu/drm/drm_irq.c | 34 +-
 drivers/gpu/drm/i915/i915_irq.c   | 15 +-
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  3 ++
 drivers/gpu/drm/nouveau/dispnv04/crtc.c   |  1 +
 drivers/gpu/drm/nouveau/nouveau_display.c | 25 
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 +--
 drivers/gpu/drm/nouveau/nouveau_drm.c |  1 -
 drivers/gpu/drm/nouveau/nv50_display.c|  1 +
 drivers/gpu/drm/radeon/radeon_display.c   | 39 -
 drivers/gpu/drm/radeon/radeon_drv.c   |  1 -
 drivers/gpu/drm/radeon/radeon_kms.c   |  2 +-
 drivers/gpu/drm/radeon/radeon_mode.h  |  2 +-
 drivers/gpu/drm/radeon/radeon_pm.c|  4 ++-
 include/drm/drmP.h| 47 ---
 include/drm/drm_crtc.h| 45 +
 16 files changed, 104 insertions(+), 121 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 37b536c57cd2..18f1ccad7ee0 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -161,14 +161,14 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval.
  *
  */
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
- unsigned int pipe,
+int drm_calc_vbltimestamp_from_scanoutpos(struct drm_crtc *crtc,
  int *max_error,
  struct timeval *vblank_time,
  unsigned flags,
  const struct drm_crtc *refcrtc,
  const struct drm_display_mode *mode)
 {
+   const struct drm_crtc_funcs *funcs = crtc->funcs;
struct timeval tv_etime;
ktime_t stime, etime;
int vbl_status;
@@ -176,16 +176,9 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
int framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns;
bool invbl;

-   if (pipe >= dev->num_crtcs) {
-   DRM_ERROR("Invalid crtc %u\n", pipe);
-   return -EINVAL;
-   }
-
/* Scanout position query not supported? Should not happen. */
-   if (!dev->driver->get_scanout_position) {
-   DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
-   return -EIO;
-   }
+   if (WARN_ON(funcs->get_scanout_position == NULL))
+   return -ENOSYS;

/* Durations of frames, lines, pixels in nanoseconds. */
framedur_ns = refcrtc->framedur_ns;
@@ -196,7 +189,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device 
*dev,
 * Happens during initial modesetting of a crtc.
 */
if (framedur_ns == 0) {
-   DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
+   DRM_DEBUG("crtc %x: Noop due to uninitialized mode.\n",
+ crtc->base.id);
return -EAGAIN;
}

@@ -212,13 +206,13 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
 * Get vertical and horizontal scanout position vpos, hpos,
 * and bounding timestamps stime, etime, pre/post query.
 */
-   vbl_status = dev->driver->get_scanout_position(dev, pipe, 
flags, &vpos,
-  &hpos, &stime, 
&etime);
+   vbl_status = funcs->get_scanout_position(crtc, flags, &vpos,
+&hpos, &stime, &etime);

/* Return as no-op if scanout query unsupported or failed. */
if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
-   DRM_DEBUG("crtc %u : scanoutpos query failed [%d].\n",
- pipe, vbl_status);
+   DRM_DEBUG("crtc %x: scanoutpos query failed [%d].\n",
+ crtc->base.id, vbl_status);
return -EIO;
}

@@ -232,8 +226,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device 
*dev,

/* Noisy system timing? */
if (i == DRM_TIMESTAMP_MAXRETRIES) {
-   DRM_DEBUG("cr

[Bug 85421] radeon stalled, GPU lockup, reset and failed on resume; crashed by firefox.

2014-12-16 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=85421

--- Comment #20 from Hin-Tak Leung  ---
mesa 10.4.0 also crashed on me (fedora provides it so I thought I'll let my
10.2.9 upgrade to have a go), on the first day. first there are some errors in
dmesg (running mplayer , not as much as under 10.3.3); on suspend/resume, the
screen lighted up again but not shows anything (e.g. busy on resume, I guess).

So my experience so far is that if I ever see any errors under dmesg, I should
reboot as soon as is convenient, instead of trying to suspend/resume to
continue, as it will not survive a suspend resume.

I am going back to 10.2.9 patched, until the next mesa that's not 10.3.5 and
10.4.0...

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


[PATCH 04/13] drm/imx: Make pipe number unsigned

2014-12-16 Thread Philipp Zabel
Am Dienstag, den 16.12.2014, 17:53 +0100 schrieb Thierry Reding:
> From: Thierry Reding 
> 
> There's no reason whatsoever why this should ever be negative.
> 
> Cc: Philipp Zabel 
> Signed-off-by: Thierry Reding 

Acked-by: Philipp Zabel 

thanks
Philipp



[PATCH 05/13] drm/imx: Store correct CRTC index in events

2014-12-16 Thread Philipp Zabel
Am Dienstag, den 16.12.2014, 17:53 +0100 schrieb Thierry Reding:
> From: Thierry Reding 
> 
> A negative pipe causes a special case to be triggered for drivers that
> don't have proper VBLANK support. i.MX does support VBLANKs, so there is
> no need for the fallback code.
> 
> Cc: Philipp Zabel 
> Signed-off-by: Thierry Reding 

Acked-by: Philipp Zabel 

regards
Philipp



[PATCH] drm/info: Remove unused code

2014-12-16 Thread Daniel Vetter
On Tue, Dec 16, 2014 at 12:02:13PM +0100, Thierry Reding wrote:
> From: Thierry Reding 
> 
> Commit 28a62277e06f ("drm: Convert proc files to seq_file and introduce
> debugfs") converted /proc files to debugfs and in the process dropped
> the entry for the vblank statistics. Since that file has been gone for
> almost five years, there is no use to keep the code that provides the
> file's content around.
> 
> Signed-off-by: Thierry Reding 

Applied to drm-misc, thanks.
-Daniel

> ---
>  drivers/gpu/drm/drm_info.c | 24 
>  drivers/gpu/drm/drm_internal.h |  1 -
>  2 files changed, 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
> index 51efebd434f3..f1b32f91d941 100644
> --- a/drivers/gpu/drm/drm_info.c
> +++ b/drivers/gpu/drm/drm_info.c
> @@ -153,30 +153,6 @@ int drm_bufs_info(struct seq_file *m, void *data)
>  }
>  
>  /**
> - * Called when "/proc/dri/.../vblank" is read.
> - */
> -int drm_vblank_info(struct seq_file *m, void *data)
> -{
> - struct drm_info_node *node = (struct drm_info_node *) m->private;
> - struct drm_device *dev = node->minor->dev;
> - int crtc;
> -
> - mutex_lock(&dev->struct_mutex);
> - for (crtc = 0; crtc < dev->num_crtcs; crtc++) {
> - seq_printf(m, "CRTC %d enable: %d\n",
> -crtc, atomic_read(&dev->vblank[crtc].refcount));
> - seq_printf(m, "CRTC %d counter:%d\n",
> -crtc, drm_vblank_count(dev, crtc));
> - seq_printf(m, "CRTC %d last wait:  %d\n",
> -crtc, dev->vblank[crtc].last_wait);
> - seq_printf(m, "CRTC %d in modeset: %d\n",
> -crtc, dev->vblank[crtc].inmodeset);
> - }
> - mutex_unlock(&dev->struct_mutex);
> - return 0;
> -}
> -
> -/**
>   * Called when "/proc/dri/.../clients" is read.
>   *
>   */
> diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
> index 7cc0a3516871..12a61d706827 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -55,7 +55,6 @@ void drm_prime_remove_buf_handle_locked(struct 
> drm_prime_file_private *prime_fpr
>  int drm_name_info(struct seq_file *m, void *data);
>  int drm_vm_info(struct seq_file *m, void *data);
>  int drm_bufs_info(struct seq_file *m, void *data);
> -int drm_vblank_info(struct seq_file *m, void *data);
>  int drm_clients_info(struct seq_file *m, void* data);
>  int drm_gem_name_info(struct seq_file *m, void *data);
>  
> -- 
> 2.1.3
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH 09/13] drm/irq: Make pipe unsigned and name consistent

2014-12-16 Thread Daniel Vetter
On Tue, Dec 16, 2014 at 05:53:31PM +0100, Thierry Reding wrote:
> -void drm_wait_one_vblank(struct drm_device *dev, int crtc)
> +void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe)
>  {
> + struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
>   int ret;
>   u32 last;
>  
> - ret = drm_vblank_get(dev, crtc);
> - if (WARN(ret, "vblank not available on crtc %i, ret=%i\n", crtc, ret))
> + if (WARN_ON(pipe >= dev->num_crtcs))

This addition should be in the previous patch. I didn't spot anything else
but it's a bit a tedious patch. But makes sense.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH 12/13] drm/irq: Expel legacy API

2014-12-16 Thread Daniel Vetter
On Tue, Dec 16, 2014 at 05:53:34PM +0100, Thierry Reding wrote:
> From: Thierry Reding 
> 
> These legacy functions all operate on the struct drm_device * and an
> index to the CRTC that they should access. This is bad because it
> requires keeping track of a global data structures to resolve the index
> to CRTC object lookup. In order to get rid of this global data new APIs
> have been introduced that operate directly on these objects. Currently
> the new functions still operate on the old data, but the goal is to
> eventually move that data into struct drm_crtc. In order to start
> conversion of drivers to the new API, move the old API away.
> 
> Signed-off-by: Thierry Reding 

Imo we should try to share code between the legacy vblank code and what
we're now building up with the drm_crtc_ prefixed functions for native kms
drivers. Instead I think we should do full copies with the following
recipe:
- Look at a given function and make sure all kms drivers (and any
  callchains used by kms drivers) uses the drm_crtc_ variant and that any
  ums drivers uses the drm_vblank_ version. So big audit.
- Then for each such function copy it to drm_irq_legacy.c and mark the old
  copy in drm_irq.c as static and drop the EXPORT_SYMBOL for it.
- Then inline the logic for native kms drivers.

Just moving the functions around doesn't really help us at all since we
still have the problem that both ums and kms code uses them. Which means
we can't use drm_crtc and store vblank data in there.
-Daniel

> ---
>  drivers/gpu/drm/Makefile |2 +-
>  drivers/gpu/drm/drm_internal.h   |2 +
>  drivers/gpu/drm/drm_irq.c| 1121 +
>  drivers/gpu/drm/drm_irq_legacy.c | 1144 
> ++
>  4 files changed, 1165 insertions(+), 1104 deletions(-)
>  create mode 100644 drivers/gpu/drm/drm_irq_legacy.c
> 
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 66e40398b3d3..c0d93beda612 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -5,7 +5,7 @@
>  ccflags-y := -Iinclude/drm
>  
>  drm-y   :=   drm_auth.o drm_bufs.o drm_cache.o \
> - drm_context.o drm_dma.o \
> + drm_context.o drm_dma.o drm_irq_legacy.o \
>   drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
>   drm_lock.o drm_memory.o drm_drv.o drm_vm.o \
>   drm_agpsupport.o drm_scatter.o drm_pci.o \
> diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
> index 12a61d706827..61d83b581c8b 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -22,7 +22,9 @@
>   */
>  
>  /* drm_irq.c */
> +extern unsigned int drm_timestamp_precision;
>  extern unsigned int drm_timestamp_monotonic;
> +extern int drm_vblank_offdelay;
>  
>  /* drm_fops.c */
>  extern struct mutex drm_global_mutex;
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index ef5d993f06ee..37b536c57cd2 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -32,15 +32,13 @@
>   * OTHER DEALINGS IN THE SOFTWARE.
>   */
>  
> -#include 
> -#include "drm_trace.h"
> -#include "drm_internal.h"
> -
> +#include 
>  #include  /* For task queue support */
>  #include 
>  
> -#include 
> -#include 
> +#include 
> +
> +#include "drm_trace.h"
>  
>  /* Access macro for slots in vblank timestamp ringbuffer. */
>  #define vblanktimestamp(dev, pipe, count) \
> @@ -51,16 +49,7 @@
>   */
>  #define DRM_TIMESTAMP_MAXRETRIES 3
>  
> -/* Threshold in nanoseconds for detection of redundant
> - * vblank irq in drm_handle_vblank(). 1 msec should be ok.
> - */
> -#define DRM_REDUNDANT_VBLIRQ_THRESH_NS 100
> -
> -static bool
> -drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
> -   struct timeval *tvblank, unsigned flags);
> -
> -static unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
> +unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
>  
>  /*
>   * Default to use monotonic timestamps for wait-for-vblank and page-flip
> @@ -68,492 +57,13 @@ static unsigned int drm_timestamp_precision = 20;  /* 
> Default to 20 usecs. */
>   */
>  unsigned int drm_timestamp_monotonic = 1;
>  
> -static int drm_vblank_offdelay = 5000;/* Default to 5000 msecs. */
> +int drm_vblank_offdelay = 5000;/* Default to 5000 msecs. */
>  
>  module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600);
>  module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 
> 0600);
>  module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);
>  
>  /**
> - * drm_update_vblank_count - update the master vblank counter
> - * @dev: DRM device
> - * @pipe: counter to update
> - *
> - * Call back into the driver to update the appropriate vblank counter
> - * (specified by @crtc).  Deal with wraparound, if it occurred, and
> - * update the last read value so we can de

[PATCH 12/13] drm/irq: Expel legacy API

2014-12-16 Thread Daniel Vetter
On Tue, Dec 16, 2014 at 06:59:28PM +0100, Daniel Vetter wrote:
> On Tue, Dec 16, 2014 at 05:53:34PM +0100, Thierry Reding wrote:
> > From: Thierry Reding 
> > 
> > These legacy functions all operate on the struct drm_device * and an
> > index to the CRTC that they should access. This is bad because it
> > requires keeping track of a global data structures to resolve the index
> > to CRTC object lookup. In order to get rid of this global data new APIs
> > have been introduced that operate directly on these objects. Currently
> > the new functions still operate on the old data, but the goal is to
> > eventually move that data into struct drm_crtc. In order to start
> > conversion of drivers to the new API, move the old API away.
> > 
> > Signed-off-by: Thierry Reding 
> 
> Imo we should try to share code between the legacy vblank code and what
> we're now building up with the drm_crtc_ prefixed functions for native kms
> drivers. Instead I think we should do full copies with the following
> recipe:
> - Look at a given function and make sure all kms drivers (and any
>   callchains used by kms drivers) uses the drm_crtc_ variant and that any
>   ums drivers uses the drm_vblank_ version. So big audit.
> - Then for each such function copy it to drm_irq_legacy.c and mark the old
>   copy in drm_irq.c as static and drop the EXPORT_SYMBOL for it.
> - Then inline the logic for native kms drivers.
> 
> Just moving the functions around doesn't really help us at all since we
> still have the problem that both ums and kms code uses them. Which means
> we can't use drm_crtc and store vblank data in there.

There's the added problem that moving breaks git blame (at least in
default mode) a bit, so better to keep the version that we want to
transform into the kms-native ones where they currently are.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH 11/13] drm/irq: Document return values more consistently

2014-12-16 Thread Daniel Vetter
On Tue, Dec 16, 2014 at 05:53:33PM +0100, Thierry Reding wrote:
> From: Thierry Reding 
> 
> Some of the functions are documented inconsistently. Add Returns:
> sections where missing and use consistent style to describe the return
> value.
> 
> Signed-off-by: Thierry Reding 

With the comment in patch 9 addressed patches 1-11 are

Reviewed-by: Daniel Vetter 

> ---
>  drivers/gpu/drm/drm_irq.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index b34900a8e172..ef5d993f06ee 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -991,6 +991,9 @@ EXPORT_SYMBOL(drm_crtc_send_vblank_event);
>   * drm_vblank_enable - enable the vblank interrupt on a CRTC
>   * @dev: DRM device
>   * @pipe: CRTC index
> + *
> + * Returns:
> + * Zero on success or a negative error code on failure.
>   */
>  static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
>  {
> @@ -1035,7 +1038,7 @@ static int drm_vblank_enable(struct drm_device *dev, 
> unsigned int pipe)
>   * This is the legacy version of drm_crtc_vblank_get().
>   *
>   * Returns:
> - * Zero on success, nonzero on failure.
> + * Zero on success or a negative error code on failure.
>   */
>  int drm_vblank_get(struct drm_device *dev, unsigned int pipe)
>  {
> @@ -1072,7 +1075,7 @@ EXPORT_SYMBOL(drm_vblank_get);
>   * This is the native kms version of drm_vblank_off().
>   *
>   * Returns:
> - * Zero on success, nonzero on failure.
> + * Zero on success or a negative error code on failure.
>   */
>  int drm_crtc_vblank_get(struct drm_crtc *crtc)
>  {
> -- 
> 2.1.3
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH 0/8] drm/tegra: Fixes for v3.19-rc1

2014-12-16 Thread Sean Paul
On Tue, Dec 16, 2014 at 11:15 AM, Thierry Reding
 wrote:
> From: Thierry Reding 
>
> Hi,
>
> This is a set of fixes for two regressions and one bug in the IOMMU
> mapping code. It turns out that all of these issues turn up primarily
> on Tegra30 hardware. The IOMMU mapping bug only manifests on buffers
> that aren't multiples of the page size. I happened to be testing HDMI
> with 1080p while writing the code and framebuffers for that happen to
> fit exactly within 2025 pages of 4 KiB each.
>
> One of the regressions is caused by the IOMMU code allocating pages from
> shmem which can have associated cache lines. If the pages aren't flushed
> then these cache lines may be flushed later on and cause framebuffer
> corruption. I'm not sure why I didn't see this before. Perhaps the board
> that I was using had enough RAM so that the pages shmem would hand out
> had a better chance of being unused. Or maybe I didn't look too closely.
> The fix for this, implementing drm_clflush_*() for ARM, has also been
> tested by Rob. The long-term plan is to make architectures expose an API
> to flush pages, but for now drm_clflush_*() provides exactly what we
> need.
>
> The second regression is caused by a mismatch between the hardware pipe
> number and the CRTC's DRM index. These were used inconsistently, which
> could cause one code location to call drm_vblank_get() with a different
> pipe than the corresponding drm_vblank_put(), thereby causing the
> reference count to become unbalanced. Alexandre also reported a possible
> race condition related to this, which this series also fixes.
>
> I'm hoping to get reviews on this, especially the drm/irq and drm/cache
> patches, quickly so that I can send a pull request to Dave, hopefully to
> get this included, given the size, in v3.19-rc1 still.
>

Hi Thierry,
Have you made a determination on "drm/tegra: Select root window for
event dispatch"? The bug it fixes makes concurrent flips and overlay
updates impossible.

Sean


> Thierry
>
> Thierry Reding (8):
>   drm/irq: Add drm_crtc_send_vblank_event()
>   drm/irq: Add drm_crtc_handle_vblank()
>   drm/irq: Add drm_crtc_vblank_count()
>   drm/tegra: dc: Consistently use the same pipe
>   drm/tegra: dc: Fix a potential race on page-flip completion
>   drm/cache: Implement drm_clflush_*() for ARM
>   drm/tegra: gem: Flush buffer objects upon allocation
>   drm/tegra: gem: Use the proper size for GEM objects
>
>  drivers/gpu/drm/drm_cache.c | 45 ++
>  drivers/gpu/drm/drm_irq.c   | 60 
> +
>  drivers/gpu/drm/tegra/dc.c  | 24 ++
>  drivers/gpu/drm/tegra/drm.c | 16 +++-
>  drivers/gpu/drm/tegra/gem.c | 16 ++--
>  include/drm/drmP.h  |  4 +++
>  6 files changed, 142 insertions(+), 23 deletions(-)
>
> --
> 2.1.3
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm: Move ->get_scanout_position() to struct drm_crtc_funcs

2014-12-16 Thread Ville Syrjälä
On Tue, Dec 16, 2014 at 06:00:14PM +0100, Thierry Reding wrote:
> From: Thierry Reding 
> 
> None of the drivers use this in legacy mode, so it can be converted to
> use struct drm_crtc * directly. While at it, also make the sole user of
> the callback, drm_calc_vbltimestamp_from_scanoutpos(), pass through the
> CRTC directly.
> 
> Cc: Daniel Vetter 
> Cc: Jani Nikula 
> Cc: Ben Skeggs 
> Cc: Alex Deucher 
> Cc: Christian König 
> Signed-off-by: Thierry Reding 
> ---
> Note: This is compile-tested only. It is a straightforward conversion so
> I wouldn't expect any fallout, but it'd certainly be best if this can be
> tested on all three drivers.
> 
>  drivers/gpu/drm/drm_irq.c | 34 +-
>  drivers/gpu/drm/i915/i915_irq.c   | 15 +-
>  drivers/gpu/drm/i915/intel_display.c  |  1 +
>  drivers/gpu/drm/i915/intel_drv.h  |  3 ++
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c   |  1 +
>  drivers/gpu/drm/nouveau/nouveau_display.c | 25 
>  drivers/gpu/drm/nouveau/nouveau_display.h |  4 +--
>  drivers/gpu/drm/nouveau/nouveau_drm.c |  1 -
>  drivers/gpu/drm/nouveau/nv50_display.c|  1 +
>  drivers/gpu/drm/radeon/radeon_display.c   | 39 -
>  drivers/gpu/drm/radeon/radeon_drv.c   |  1 -
>  drivers/gpu/drm/radeon/radeon_kms.c   |  2 +-
>  drivers/gpu/drm/radeon/radeon_mode.h  |  2 +-
>  drivers/gpu/drm/radeon/radeon_pm.c|  4 ++-
>  include/drm/drmP.h| 47 
> ---
>  include/drm/drm_crtc.h| 45 +
>  16 files changed, 104 insertions(+), 121 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 37b536c57cd2..18f1ccad7ee0 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -161,14 +161,14 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
>   * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank 
> interval.
>   *
>   */
> -int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
> -   unsigned int pipe,
> +int drm_calc_vbltimestamp_from_scanoutpos(struct drm_crtc *crtc,
> int *max_error,
> struct timeval *vblank_time,
> unsigned flags,
> const struct drm_crtc *refcrtc,
> const struct drm_display_mode *mode)
>  {
> + const struct drm_crtc_funcs *funcs = crtc->funcs;
>   struct timeval tv_etime;
>   ktime_t stime, etime;
>   int vbl_status;
> @@ -176,16 +176,9 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
> drm_device *dev,
>   int framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns;
>   bool invbl;
>  
> - if (pipe >= dev->num_crtcs) {
> - DRM_ERROR("Invalid crtc %u\n", pipe);
> - return -EINVAL;
> - }
> -
>   /* Scanout position query not supported? Should not happen. */
> - if (!dev->driver->get_scanout_position) {
> - DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
> - return -EIO;
> - }
> + if (WARN_ON(funcs->get_scanout_position == NULL))
> + return -ENOSYS;
>  
>   /* Durations of frames, lines, pixels in nanoseconds. */
>   framedur_ns = refcrtc->framedur_ns;
> @@ -196,7 +189,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct 
> drm_device *dev,
>* Happens during initial modesetting of a crtc.
>*/
>   if (framedur_ns == 0) {
> - DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
> + DRM_DEBUG("crtc %x: Noop due to uninitialized mode.\n",
> +   crtc->base.id);

I don't think we want the obj ID in hex.

And I must say I hate looking at obj IDs. You basically need to build
some kind of obj ID to hw crtc cross reference every time you try to
read a log. So keeping to drm_crtc_index() would better IMO. Or maybe
even add crtc->name so each driver could provide its own name for the
thing, but that would be a slightly bigger task.

-- 
Ville Syrjälä
Intel OTC


[Intel-gfx] [PATCH 4/4] drm/i915: Opportunistically reduce flushing at execbuf

2014-12-16 Thread Ben Widawsky
On Tue, Dec 16, 2014 at 07:57:39AM +, Chris Wilson wrote:
> On Mon, Dec 15, 2014 at 01:06:40PM -0800, Ben Widawsky wrote:
> > On Mon, Dec 15, 2014 at 08:39:35PM +, Chris Wilson wrote:
> > > On Mon, Dec 15, 2014 at 11:56:05AM -0800, Ben Widawsky wrote:
> > > > On Mon, Dec 15, 2014 at 08:20:50AM +, Chris Wilson wrote:
> > > > > On Mon, Dec 15, 2014 at 08:55:32AM +0100, Daniel Vetter wrote:
> > > > > > On Sun, Dec 14, 2014 at 03:37:36PM -0800, Ben Widawsky wrote:
> > > > > > > It's not hard, and I think that's a good idea as well. One reason 
> > > > > > > I didn't put
> > > > > > > such code in this series is that moves away from a global DRM 
> > > > > > > solution (and like
> > > > > > > I said in the cover-letter, I am fine with that). Implementing 
> > > > > > > this, I think in
> > > > > > > the i915 code we'd just iterate through the BOs until we got to a 
> > > > > > > certain
> > > > > > > threshold, then just call wbinvd() from i915 and not even both 
> > > > > > > with drm_cache.
> > > > > > > You could also maybe try to shorcut if there are more than X 
> > > > > > > buffers.
> > > > > > 
> > > > > > I don't mind an i915 specific solution (we have them already in many
> > > > > > places). So will wait for the results of this experiments before 
> > > > > > merging
> > > > > > more patches.
> > > > > 
> > > > > I actually think an i915 specific solution is required, as the making
> > > > > drm_clflush_pages autoselect is likely to cause regressions on unaware
> > > > > drivers (e.g. anything that has a reservation loop in execbuf like 
> > > > > i915).
> > > > 
> > > > Assuming the stall is gone as Jesse said in the other thread, I can't 
> > > > envision a
> > > > scenario where wbinvd would do worse on large objects.
> > > 
> > > It is the multiple wbinvd performed at each execbuffer that is worrisome.
> > 
> > This patch attempts to avoid that by dropping all flushing after the first
> > WBINVD.
> 
> But you can't make the central change to drm_clflush_* without driver
> specific workarounds like this patch...

Good point. I'll do an i915 one when I find the time. I was still hoping to get
some numbers from Eero on this series.


[PATCH 3/8] drm/irq: Add drm_crtc_vblank_count()

2014-12-16 Thread Daniel Vetter
On Tue, Dec 16, 2014 at 05:15:10PM +0100, Thierry Reding wrote:
> From: Thierry Reding 
> 
> This function is the KMS native variant of drm_vblank_count(). It takes
> a struct drm_crtc * instead of a struct drm_device * and an index of the
> CRTC.
> 
> Eventually the goal is to access vblank data through the CRTC only so
> that the per-CRTC data can be moved to struct drm_crtc.
> 
> Signed-off-by: Thierry Reding 

On the first 3 patches:

Reviewed-by: Daniel Vetter 


> ---
>  drivers/gpu/drm/drm_irq.c | 21 +
>  include/drm/drmP.h|  1 +
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index f7f1b579526e..75647e7f012b 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -830,6 +830,8 @@ drm_get_last_vbltimestamp(struct drm_device *dev, int 
> crtc,
>   * vblank events since the system was booted, including lost events due to
>   * modesetting activity.
>   *
> + * This is the legacy version of drm_crtc_vblank_count().
> + *
>   * Returns:
>   * The software vblank counter.
>   */
> @@ -844,6 +846,25 @@ u32 drm_vblank_count(struct drm_device *dev, int crtc)
>  EXPORT_SYMBOL(drm_vblank_count);
>  
>  /**
> + * drm_crtc_vblank_count - retrieve "cooked" vblank counter value
> + * @crtc: which counter to retrieve
> + *
> + * Fetches the "cooked" vblank count value that represents the number of
> + * vblank events since the system was booted, including lost events due to
> + * modesetting activity.
> + *
> + * This is the native KMS version of drm_vblank_count().
> + *
> + * Returns:
> + * The software vblank counter.
> + */
> +u32 drm_crtc_vblank_count(struct drm_crtc *crtc)
> +{
> + return drm_vblank_count(crtc->dev, drm_crtc_index(crtc));
> +}
> +EXPORT_SYMBOL(drm_crtc_vblank_count);
> +
> +/**
>   * drm_vblank_count_and_time - retrieve "cooked" vblank counter value
>   * and the system timestamp corresponding to that vblank counter value.
>   *
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index f1f7f15ce0f3..e1b2e8b98af7 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -901,6 +901,7 @@ extern int drm_vblank_init(struct drm_device *dev, int 
> num_crtcs);
>  extern int drm_wait_vblank(struct drm_device *dev, void *data,
>  struct drm_file *filp);
>  extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
> +extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
>  extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
>struct timeval *vblanktime);
>  extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
> -- 
> 2.1.3
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[Bug 89661] Kernel panic when trying use amdkfd driver on Kaveri

2014-12-16 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=89661

--- Comment #11 from Bernd Steinhauser  ---
Hm, ok. So should I still try the steps above? Because trying to use drm_radeon
as a module would require me to do some testing with that setup before.

(In reply to Oded Gabbay from comment #8)

> 2. You said CONFIG_HSA_AMD=y. What's the value of CONFIG_DRM_RADEON ? If its
> "m", could you change it to "y" ?
I'm using a static initrd (only a basic system, but doesn't contain any kernel
modules), so all drivers necessary to start the system (including drm_radeon)
are compiled in.

Regarding the tree:
I took plain 3.18 (b2776b) and then merged the drm-next branch from the repo
mentioned above.
iirc, it was a fast forward.

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


[PATCH 00/13] Atomic Properties

2014-12-16 Thread Rob Clark
Now that we have core atomic helpers, let's expose that to userspace!
The first step here is to, for drivers supporting atomic, expose all
the core plane/CRTC/connector state as properties.  Once this is in
place, all that remains is the atomic ioctl to allow userspace to
atomically set a bunch of properties on a bunch of objects (RFC patch
at the end).

All of the core properties have their set/get/check's handled  by the
drm_atomic core, so drivers needn't be bothered about that.

NOTE: that there is one notable omission here.  The 'MODE' property
on the CRTC.  Without this, you can do atomic pageflip but not yet
atomic modeset.  I am debating between three paths for handling MODE:

 1) Add back blob property support to atomic ioctl
 2) Add ioctls to create/destroy blob properties, and then simply
pass blob property id to atomic ioctl.
 3) Stick our head in the sands and expose mode as a bunch of descrete
properties.

Of these, at the moment I prefer #2, since it is more consistent with
how userspace currently reads blob properties, and it avoids making the
atomic ioctl function even more gnarly.

The whole patchset can also be found at:

 http://cgit.freedesktop.org/~robclark/linux/log/?h=atomic-properties
 git://people.freedesktop.org/~robclark/linux atomic-properties

Rob Clark (13):
  drm: allow property validation for refcnted props
  drm: store property instead of id in obj attachment
  drm: get rid of direct property value access
  drm: add atomic_set_property wrappers
  drm: add atomic_get_property
  drm: add atomic hook to read property plus helper
  drm: small property creation cleanup
  drm: tweak getconnector locking
  drm/atomic: atomic_check functions
  drm/atomic: atomic plane properties
  drm/atomic: atomic connector properties
  drm/msm: atomic property support
  RFC: drm: Atomic modeset ioctl

 Documentation/DocBook/drm.tmpl |  83 ++-
 drivers/gpu/drm/drm_atomic.c   | 613 +
 drivers/gpu/drm/drm_atomic_helper.c| 105 +++-
 drivers/gpu/drm/drm_crtc.c | 230 ++--
 drivers/gpu/drm/drm_ioctl.c|   1 +
 drivers/gpu/drm/msm/hdmi/hdmi_connector.c  |   1 +
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c   |   1 +
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c |   1 +
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c  |   1 +
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c   |   1 +
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c  |   2 +
 drivers/gpu/drm/msm/msm_drv.c  |   1 +
 include/drm/drm_atomic.h   |  22 +
 include/drm/drm_atomic_helper.h|   2 +
 include/drm/drm_crtc.h |  50 +-
 include/uapi/drm/drm.h |   1 +
 include/uapi/drm/drm_mode.h|  21 +
 17 files changed, 1063 insertions(+), 73 deletions(-)

-- 
2.1.0



[PATCH 01/13] drm: allow property validation for refcnted props

2014-12-16 Thread Rob Clark
We can already have object properties, which technically can be fb's.
Switch the property validation logic over to a get/put style interface
so it can take a ref to refcnt'd objects, and then drop that ref after
the driver has a chance to take it's own ref.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_crtc.c | 58 ++
 1 file changed, 43 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 5213da4..5ee4b88 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4193,12 +4193,22 @@ int drm_mode_connector_update_edid_property(struct 
drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_mode_connector_update_edid_property);

-static bool drm_property_change_is_valid(struct drm_property *property,
-uint64_t value)
+/* Some properties could refer to dynamic refcnt'd objects, or things that
+ * need special locking to handle lifetime issues (ie. to ensure the prop
+ * value doesn't become invalid part way through the property update due to
+ * race).  The value returned by reference via 'obj' should be passed back
+ * to drm_property_change_valid_put() after the property is set (and the
+ * object to which the property is attached has a chance to take it's own
+ * reference).
+ */
+static bool drm_property_change_valid_get(struct drm_property *property,
+uint64_t value, struct drm_mode_object 
**ref)
 {
if (property->flags & DRM_MODE_PROP_IMMUTABLE)
return false;

+   *ref = NULL;
+
if (drm_property_type_is(property, DRM_MODE_PROP_RANGE)) {
if (value < property->values[0] || value > property->values[1])
return false;
@@ -4219,19 +4229,23 @@ static bool drm_property_change_is_valid(struct 
drm_property *property,
/* Only the driver knows */
return true;
} else if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) {
-   struct drm_mode_object *obj;
/* a zero value for an object property translates to null: */
if (value == 0)
return true;
-   /*
-* NOTE: use _object_find() directly to bypass restriction on
-* looking up refcnt'd objects (ie. fb's).  For a refcnt'd
-* object this could race against object finalization, so it
-* simply tells us that the object *was* valid.  Which is good
-* enough.
-*/
-   obj = _object_find(property->dev, value, property->values[0]);
-   return obj != NULL;
+
+   /* handle refcnt'd objects specially: */
+   if (property->values[0] == DRM_MODE_OBJECT_FB) {
+   struct drm_framebuffer *fb;
+   fb = drm_framebuffer_lookup(property->dev, value);
+   if (fb) {
+   *ref = &fb->base;
+   return true;
+   } else {
+   return false;
+   }
+   } else {
+   return _object_find(property->dev, value, 
property->values[0]) != NULL;
+   }
} else {
int i;
for (i = 0; i < property->num_values; i++)
@@ -4241,6 +4255,18 @@ static bool drm_property_change_is_valid(struct 
drm_property *property,
}
 }

+static void drm_property_change_valid_put(struct drm_property *property,
+   struct drm_mode_object *ref)
+{
+   if (!ref)
+   return;
+
+   if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) {
+   if (property->values[0] == DRM_MODE_OBJECT_FB)
+   drm_framebuffer_unreference(obj_to_fb(ref));
+   }
+}
+
 /**
  * drm_mode_connector_property_set_ioctl - set the current value of a 
connector property
  * @dev: DRM device
@@ -4429,8 +4455,8 @@ int drm_mode_obj_set_property_ioctl(struct drm_device 
*dev, void *data,
struct drm_mode_object *arg_obj;
struct drm_mode_object *prop_obj;
struct drm_property *property;
-   int ret = -EINVAL;
-   int i;
+   int i, ret = -EINVAL;
+   struct drm_mode_object *ref;

if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
@@ -4460,7 +4486,7 @@ int drm_mode_obj_set_property_ioctl(struct drm_device 
*dev, void *data,
}
property = obj_to_property(prop_obj);

-   if (!drm_property_change_is_valid(property, arg->value))
+   if (!drm_property_change_valid_get(property, arg->value, &ref))
goto out;

switch (arg_obj->type) {
@@ -4477,6 +4503,8 @@ int drm_mode_obj_set_property_ioctl(struct drm_device 
*dev, void *data,
break;
}

+   drm_property_change_valid

[PATCH 02/13] drm: store property instead of id in obj attachment

2014-12-16 Thread Rob Clark
Keep property pointer, instead of id, in per mode-object attachments.
This will simplify things in later patches.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_crtc.c | 17 -
 include/drm/drm_crtc.h |  7 ++-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 5ee4b88..2780a08 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2105,12 +2105,11 @@ int drm_mode_getconnector(struct drm_device *dev, void 
*data,
prop_ptr = (uint32_t __user *)(unsigned 
long)(out_resp->props_ptr);
prop_values = (uint64_t __user *)(unsigned 
long)(out_resp->prop_values_ptr);
for (i = 0; i < connector->properties.count; i++) {
-   if (put_user(connector->properties.ids[i],
-prop_ptr + copied)) {
+   struct drm_property *prop = 
connector->properties.properties[i];
+   if (put_user(prop->base.id, prop_ptr + copied)) {
ret = -EFAULT;
goto out;
}
-
if (put_user(connector->properties.values[i],
 prop_values + copied)) {
ret = -EFAULT;
@@ -3822,7 +3821,7 @@ void drm_object_attach_property(struct drm_mode_object 
*obj,
return;
}

-   obj->properties->ids[count] = property->base.id;
+   obj->properties->properties[count] = property;
obj->properties->values[count] = init_val;
obj->properties->count++;
 }
@@ -3847,7 +3846,7 @@ int drm_object_property_set_value(struct drm_mode_object 
*obj,
int i;

for (i = 0; i < obj->properties->count; i++) {
-   if (obj->properties->ids[i] == property->base.id) {
+   if (obj->properties->properties[i] == property) {
obj->properties->values[i] = val;
return 0;
}
@@ -3877,7 +3876,7 @@ int drm_object_property_get_value(struct drm_mode_object 
*obj,
int i;

for (i = 0; i < obj->properties->count; i++) {
-   if (obj->properties->ids[i] == property->base.id) {
+   if (obj->properties->properties[i] == property) {
*val = obj->properties->values[i];
return 0;
}
@@ -4413,8 +4412,8 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device 
*dev, void *data,
prop_values_ptr = (uint64_t __user *)(unsigned long)
  (arg->prop_values_ptr);
for (i = 0; i < props_count; i++) {
-   if (put_user(obj->properties->ids[i],
-props_ptr + copied)) {
+   struct drm_property *prop = 
obj->properties->properties[i];
+   if (put_user(prop->base.id, props_ptr + copied)) {
ret = -EFAULT;
goto out;
}
@@ -4472,7 +4471,7 @@ int drm_mode_obj_set_property_ioctl(struct drm_device 
*dev, void *data,
goto out;

for (i = 0; i < arg_obj->properties->count; i++)
-   if (arg_obj->properties->ids[i] == arg->prop_id)
+   if (arg_obj->properties->properties[i]->base.id == arg->prop_id)
break;

if (i == arg_obj->properties->count)
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b863298..02758e8 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -64,7 +64,12 @@ struct drm_mode_object {
 #define DRM_OBJECT_MAX_PROPERTY 24
 struct drm_object_properties {
int count;
-   uint32_t ids[DRM_OBJECT_MAX_PROPERTY];
+   /* NOTE: if we ever start dynamically destroying properties (ie.
+* not at drm_mode_config_cleanup() time), then we'd have to do
+* a better job of detaching property from mode objects to avoid
+* dangling property pointers:
+*/
+   struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY];
uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };

-- 
2.1.0



[PATCH 03/13] drm: get rid of direct property value access

2014-12-16 Thread Rob Clark
For atomic drivers, we won't use the values array but instead shunt
things off to obj->atomic_get_property().  So to simplify things make
all read/write of properties values go through the accessors.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_crtc.c | 19 +++
 include/drm/drm_crtc.h |  3 +++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 2780a08..481bb25 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2106,12 +2106,17 @@ int drm_mode_getconnector(struct drm_device *dev, void 
*data,
prop_values = (uint64_t __user *)(unsigned 
long)(out_resp->prop_values_ptr);
for (i = 0; i < connector->properties.count; i++) {
struct drm_property *prop = 
connector->properties.properties[i];
+   uint64_t val;
+
+   ret = drm_object_property_get_value(&connector->base, 
prop, &val);
+   if (ret)
+   goto out;
+
if (put_user(prop->base.id, prop_ptr + copied)) {
ret = -EFAULT;
goto out;
}
-   if (put_user(connector->properties.values[i],
-prop_values + copied)) {
+   if (put_user(val, prop_values + copied)) {
ret = -EFAULT;
goto out;
}
@@ -4413,12 +4418,18 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device 
*dev, void *data,
  (arg->prop_values_ptr);
for (i = 0; i < props_count; i++) {
struct drm_property *prop = 
obj->properties->properties[i];
+   uint64_t val;
+
+   ret = drm_object_property_get_value(obj, prop, &val);
+   if (ret)
+   goto out;
+
if (put_user(prop->base.id, props_ptr + copied)) {
ret = -EFAULT;
goto out;
}
-   if (put_user(obj->properties->values[i],
-prop_values_ptr + copied)) {
+
+   if (put_user(val, prop_values_ptr + copied)) {
ret = -EFAULT;
goto out;
}
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 02758e8..61ab3e5 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -70,6 +70,9 @@ struct drm_object_properties {
 * dangling property pointers:
 */
struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY];
+   /* do not read/write values directly, but use 
drm_object_property_get_value()
+* and drm_object_property_set_value():
+*/
uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };

-- 
2.1.0



[PATCH 04/13] drm: add atomic_set_property wrappers

2014-12-16 Thread Rob Clark
As we add properties for all the standard plane/crtc/connector
attributes (in preperation for the atomic ioctl), we are going to want
to handle core state in core (rather than per driver).  Intercepting the
core properties will be easier if the atomic_set_property vfuncs are not
called directly, but instead have a mandatory wrapper function (which
will later serve as the point to intercept core properties).

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_atomic.c| 78 +
 drivers/gpu/drm/drm_atomic_helper.c | 12 +++---
 include/drm/drm_atomic.h|  9 +
 include/drm/drm_crtc.h  |  3 ++
 4 files changed, 96 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index ff5f034..1261ade 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -217,6 +217,28 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
 EXPORT_SYMBOL(drm_atomic_get_crtc_state);

 /**
+ * drm_atomic_crtc_set_property - set property on connector
+ * @crtc: the drm CRTC to set a property on
+ * @state: the state object to update with the new property value
+ * @property: the property to set
+ * @val: the new property value
+ *
+ * Use this instead of calling crtc->atomic_set_property directly
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
+   struct drm_crtc_state *state, struct drm_property *property,
+   uint64_t val)
+{
+   if (crtc->funcs->atomic_set_property)
+   return crtc->funcs->atomic_set_property(crtc, state, property, 
val);
+   return -EINVAL;
+}
+EXPORT_SYMBOL(drm_atomic_crtc_set_property);
+
+/**
  * drm_atomic_get_plane_state - get plane state
  * @state: global atomic state object
  * @plane: plane to get state object for
@@ -272,6 +294,28 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
 EXPORT_SYMBOL(drm_atomic_get_plane_state);

 /**
+ * drm_atomic_plane_set_property - set property on plane
+ * @plane: the drm plane to set a property on
+ * @state: the state object to update with the new property value
+ * @property: the property to set
+ * @val: the new property value
+ *
+ * Use this instead of calling plane->atomic_set_property directly
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_plane_set_property(struct drm_plane *plane,
+   struct drm_plane_state *state, struct drm_property *property,
+   uint64_t val)
+{
+   if (plane->funcs->atomic_set_property)
+   return plane->funcs->atomic_set_property(plane, state, 
property, val);
+   return -EINVAL;
+}
+EXPORT_SYMBOL(drm_atomic_plane_set_property);
+
+/**
  * drm_atomic_get_connector_state - get connector state
  * @state: global atomic state object
  * @connector: connector to get state object for
@@ -343,6 +387,40 @@ drm_atomic_get_connector_state(struct drm_atomic_state 
*state,
 EXPORT_SYMBOL(drm_atomic_get_connector_state);

 /**
+ * drm_atomic_connector_set_property - set property on connector.
+ * @connector: the drm connector to set a property on
+ * @state: the state object to update with the new property value
+ * @property: the property to set
+ * @val: the new property value
+ *
+ * Use this instead of calling connector->atomic_set_property directly
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_connector_set_property(struct drm_connector *connector,
+   struct drm_connector_state *state, struct drm_property 
*property,
+   uint64_t val)
+{
+   struct drm_device *dev = connector->dev;
+   struct drm_mode_config *config = &dev->mode_config;
+
+   if (property == config->dpms_property) {
+   /* setting DPMS property requires special handling, which
+* is done in legacy setprop path for us.  Disallow (for
+* now?) atomic writes to DPMS property:
+*/
+   return -EINVAL;
+   } else if (connector->funcs->atomic_set_property) {
+   return connector->funcs->atomic_set_property(connector,
+   state, property, val);
+   } else {
+   return -EINVAL;
+   }
+}
+EXPORT_SYMBOL(drm_atomic_connector_set_property);
+
+/**
  * drm_atomic_set_crtc_for_plane - set crtc for plane
  * @state: the incoming atomic state
  * @plane: the plane whose incoming state to update
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 4a78a77..d42fdb1 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1558,8 +1558,8 @@ retry:
goto fail;
}

-   ret = crtc->funcs->atomic_set_property(crtc, crtc_state,
-  property, val);
+   ret = drm_atomic_crtc_set_property(crtc, crtc_state,
+   

[PATCH 05/13] drm: add atomic_get_property

2014-12-16 Thread Rob Clark
Since we won't be using the obj->properties->values[] array to shadow
property values for atomic drivers, we are going to need a vfunc for
getting prop values.  Add that along w/ mandatory wrapper fxns.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_atomic.c | 76 
 include/drm/drm_atomic.h |  9 ++
 include/drm/drm_crtc.h   | 18 +++
 3 files changed, 103 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 1261ade..4099b44 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -239,6 +239,28 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 EXPORT_SYMBOL(drm_atomic_crtc_set_property);

 /**
+ * drm_atomic_crtc_get_property - get property on connector
+ * @crtc: the drm CRTC to get a property on
+ * @state: the state object with the property value to read
+ * @property: the property to get
+ * @val: the property value (returned by reference)
+ *
+ * Use this instead of calling crtc->atomic_get_property directly
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_crtc_get_property(struct drm_crtc *crtc,
+   const struct drm_crtc_state *state,
+   struct drm_property *property, uint64_t *val)
+{
+   if (crtc->funcs->atomic_get_property)
+   return crtc->funcs->atomic_get_property(crtc, state, property, 
val);
+   return -EINVAL;
+}
+EXPORT_SYMBOL(drm_atomic_crtc_get_property);
+
+/**
  * drm_atomic_get_plane_state - get plane state
  * @state: global atomic state object
  * @plane: plane to get state object for
@@ -316,6 +338,28 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
 EXPORT_SYMBOL(drm_atomic_plane_set_property);

 /**
+ * drm_atomic_plane_get_property - get property on plane
+ * @plane: the drm plane to get a property on
+ * @state: the state object with the property value to read
+ * @property: the property to get
+ * @val: the property value (returned by reference)
+ *
+ * Use this instead of calling plane->atomic_get_property directly
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_plane_get_property(struct drm_plane *plane,
+   const struct drm_plane_state *state,
+   struct drm_property *property, uint64_t *val)
+{
+   if (plane->funcs->atomic_get_property)
+   return plane->funcs->atomic_get_property(plane, state, 
property, val);
+   return -EINVAL;
+}
+EXPORT_SYMBOL(drm_atomic_plane_get_property);
+
+/**
  * drm_atomic_get_connector_state - get connector state
  * @state: global atomic state object
  * @connector: connector to get state object for
@@ -421,6 +465,38 @@ int drm_atomic_connector_set_property(struct drm_connector 
*connector,
 EXPORT_SYMBOL(drm_atomic_connector_set_property);

 /**
+ * drm_atomic_connector_get_property - get property on connector
+ * @connector: the drm connector to get a property on
+ * @state: the state object with the property value to read
+ * @property: the property to get
+ * @val: the property value (returned by reference)
+ *
+ * Use this instead of calling connector->atomic_get_property directly
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_connector_get_property(struct drm_connector *connector,
+   const struct drm_connector_state *state,
+   struct drm_property *property, uint64_t *val)
+{
+   struct drm_device *dev = connector->dev;
+   struct drm_mode_config *config = &dev->mode_config;
+
+   if (property == config->dpms_property) {
+   *val = connector->dpms;
+   } else if (connector->funcs->atomic_get_property) {
+   return connector->funcs->atomic_get_property(connector,
+   state, property, val);
+   } else {
+   return -EINVAL;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_atomic_connector_get_property);
+
+/**
  * drm_atomic_set_crtc_for_plane - set crtc for plane
  * @state: the incoming atomic state
  * @plane: the plane whose incoming state to update
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index b0834dc..b34224a 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -41,18 +41,27 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
 int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
struct drm_crtc_state *state, struct drm_property *property,
uint64_t val);
+int drm_atomic_crtc_get_property(struct drm_crtc *crtc,
+   const struct drm_crtc_state *state,
+   struct drm_property *property, uint64_t *val);
 struct drm_plane_state * __must_check
 drm_atomic_get_plane_state(struct drm_atomic_state *state,
   struct drm_plane *plane);
 int drm_atomic_plane_set_property(struct drm_plane *plane,
struct drm_plane_state *state, struct drm_property *proper

[PATCH 06/13] drm: add atomic hook to read property plus helper

2014-12-16 Thread Rob Clark
Once a driver is using atomic helpers for modeset, the next step is to
switch over to atomic properties.  To do this, plug in the helper
function to your modeconfig funcs and be sure to implement the plane/
crtc/connector atomic_{get,set}_property vfuncs for any of your mode-
objects which have driver custom properties.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_atomic_helper.c | 46 +
 drivers/gpu/drm/drm_crtc.c  |  9 
 include/drm/drm_atomic_helper.h |  2 ++
 include/drm/drm_crtc.h  |  3 +++
 4 files changed, 60 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index d42fdb1..1a1ab34 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1703,6 +1703,52 @@ backoff:
 EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);

 /**
+ * drm_atomic_helper_get_property - helper to read atomic property
+ * @obj: drm mode object whose property to read
+ * @property: the property to read
+ * @val: the read value, returned by reference
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_helper_get_property(struct drm_mode_object *obj,
+   struct drm_property *property, uint64_t *val)
+{
+   struct drm_device *dev = property->dev;
+   int ret;
+
+   switch (obj->type) {
+   case DRM_MODE_OBJECT_CONNECTOR: {
+   struct drm_connector *connector = obj_to_connector(obj);
+   
WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
+   ret = connector->funcs->atomic_get_property(connector,
+   connector->state, property, val);
+   break;
+   }
+   case DRM_MODE_OBJECT_CRTC: {
+   struct drm_crtc *crtc = obj_to_crtc(obj);
+   WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
+   ret = crtc->funcs->atomic_get_property(crtc,
+   crtc->state, property, val);
+   break;
+   }
+   case DRM_MODE_OBJECT_PLANE: {
+   struct drm_plane *plane = obj_to_plane(obj);
+   WARN_ON(!drm_modeset_is_locked(&plane->mutex));
+   ret = plane->funcs->atomic_get_property(plane,
+   plane->state, property, val);
+   break;
+   }
+   default:
+   ret = -EINVAL;
+   break;
+   }
+
+   return ret;
+}
+EXPORT_SYMBOL(drm_atomic_helper_get_property);
+
+/**
  * drm_atomic_helper_page_flip - execute a legacy page flip
  * @crtc: DRM crtc
  * @fb: DRM framebuffer
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 481bb25..57cd950 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3878,8 +3878,17 @@ EXPORT_SYMBOL(drm_object_property_set_value);
 int drm_object_property_get_value(struct drm_mode_object *obj,
  struct drm_property *property, uint64_t *val)
 {
+   struct drm_mode_config *config = &property->dev->mode_config;
int i;

+   /* read-only properties bypass atomic mechanism and still store
+* their value in obj->properties->values[].. mostly to avoid
+* having to deal w/ EDID and similar props in atomic paths:
+*/
+   if (config->funcs->atomic_get_property &&
+   !(property->flags & DRM_MODE_PROP_IMMUTABLE))
+   return config->funcs->atomic_get_property(obj, property, val);
+
for (i = 0; i < obj->properties->count; i++) {
if (obj->properties->properties[i] == property) {
*val = obj->properties->values[i];
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index f956b41..5e72b82 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -74,6 +74,8 @@ int drm_atomic_helper_plane_set_property(struct drm_plane 
*plane,
 int drm_atomic_helper_connector_set_property(struct drm_connector *connector,
struct drm_property *property,
uint64_t val);
+int drm_atomic_helper_get_property(struct drm_mode_object *obj,
+  struct drm_property *property, uint64_t *val);
 int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event,
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index e6cfdaf..ca8ba72 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -941,6 +941,7 @@ struct drm_mode_set {
  * struct drm_mode_config_funcs - basic driver provided mode setting functions
  * @fb_create: create a new framebuffer object
  * @output_poll_changed: function to handle output configuration changes
+ * @atomic_get_property: atomic way to read property value

[PATCH 07/13] drm: small property creation cleanup

2014-12-16 Thread Rob Clark
Getting ready to add a lot more standard properties for atomic.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_crtc.c | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 57cd950..96965ec 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1330,33 +1330,40 @@ EXPORT_SYMBOL(drm_plane_force_disable);

 static int drm_mode_create_standard_connector_properties(struct drm_device 
*dev)
 {
-   struct drm_property *edid;
-   struct drm_property *dpms;
-   struct drm_property *dev_path;
+   struct drm_property *prop;

/*
 * Standard properties (apply to all connectors)
 */
-   edid = drm_property_create(dev, DRM_MODE_PROP_BLOB |
+   prop = drm_property_create(dev, DRM_MODE_PROP_BLOB |
   DRM_MODE_PROP_IMMUTABLE,
   "EDID", 0);
-   dev->mode_config.edid_property = edid;
+   if (!prop)
+   return -ENOMEM;
+   dev->mode_config.edid_property = prop;

-   dpms = drm_property_create_enum(dev, 0,
+   prop = drm_property_create_enum(dev, 0,
   "DPMS", drm_dpms_enum_list,
   ARRAY_SIZE(drm_dpms_enum_list));
-   dev->mode_config.dpms_property = dpms;
+   if (!prop)
+   return -ENOMEM;
+   dev->mode_config.dpms_property = prop;

-   dev_path = drm_property_create(dev,
+   prop = drm_property_create(dev,
   DRM_MODE_PROP_BLOB |
   DRM_MODE_PROP_IMMUTABLE,
   "PATH", 0);
-   dev->mode_config.path_property = dev_path;
+   if (!prop)
+   return -ENOMEM;
+   dev->mode_config.path_property = prop;

-   dev->mode_config.tile_property = drm_property_create(dev,
+   prop = drm_property_create(dev,
 DRM_MODE_PROP_BLOB 
|
 
DRM_MODE_PROP_IMMUTABLE,
 "TILE", 0);
+   if (!prop)
+   return -ENOMEM;
+   dev->mode_config.tile_property = prop;

return 0;
 }
-- 
2.1.0



[PATCH 08/13] drm: tweak getconnector locking

2014-12-16 Thread Rob Clark
We need to hold connection_mutex as we read the properties.  Easiest
thing is just widen the scope where connection_mutex is held.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_crtc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 96965ec..62f5dc8 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2043,6 +2043,7 @@ int drm_mode_getconnector(struct drm_device *dev, void 
*data,
DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id);

mutex_lock(&dev->mode_config.mutex);
+   drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);

connector = drm_connector_find(dev, out_resp->connector_id);
if (!connector) {
@@ -2076,14 +2077,11 @@ int drm_mode_getconnector(struct drm_device *dev, void 
*data,
out_resp->mm_height = connector->display_info.height_mm;
out_resp->subpixel = connector->display_info.subpixel_order;
out_resp->connection = connector->status;
-   drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
-
encoder = drm_connector_get_encoder(connector);
if (encoder)
out_resp->encoder_id = encoder->base.id;
else
out_resp->encoder_id = 0;
-   drm_modeset_unlock(&dev->mode_config.connection_mutex);

/*
 * This ioctl is called twice, once to determine how much space is
@@ -2149,6 +2147,7 @@ int drm_mode_getconnector(struct drm_device *dev, void 
*data,
out_resp->count_encoders = encoders_count;

 out:
+   drm_modeset_unlock(&dev->mode_config.connection_mutex);
mutex_unlock(&dev->mode_config.mutex);

return ret;
-- 
2.1.0



[PATCH 09/13] drm/atomic: atomic_check functions

2014-12-16 Thread Rob Clark
Add functions to check core plane/crtc state.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_atomic.c| 87 +
 drivers/gpu/drm/drm_atomic_helper.c | 47 ++--
 include/drm/drm_atomic.h|  4 ++
 3 files changed, 124 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 4099b44..afb830d 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -261,6 +261,27 @@ int drm_atomic_crtc_get_property(struct drm_crtc *crtc,
 EXPORT_SYMBOL(drm_atomic_crtc_get_property);

 /**
+ * drm_atomic_crtc_check - check crtc state
+ * @crtc: crtc to check
+ * @state: crtc state to check
+ *
+ * Provides core sanity checks for crtc state.
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_crtc_check(struct drm_crtc *crtc,
+   struct drm_crtc_state *state)
+{
+   /* TODO anything to check?  I think if drivers want to enforce that
+* primary layer covers entire screen, they should do that in their
+* own crtc->atomic_check() vfunc..
+*/
+   return 0;
+}
+EXPORT_SYMBOL(drm_atomic_crtc_check);
+
+/**
  * drm_atomic_get_plane_state - get plane state
  * @state: global atomic state object
  * @plane: plane to get state object for
@@ -360,6 +381,72 @@ int drm_atomic_plane_get_property(struct drm_plane *plane,
 EXPORT_SYMBOL(drm_atomic_plane_get_property);

 /**
+ * drm_atomic_plane_check - check plane state
+ * @plane: plane to check
+ * @state: plane state to check
+ *
+ * Provides core sanity checks for plane state.
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_plane_check(struct drm_plane *plane,
+   struct drm_plane_state *state)
+{
+   unsigned int fb_width, fb_height;
+   unsigned int i;
+
+   /* either *both* CRTC and FB must be set, or neither */
+   if (WARN_ON(state->crtc && !state->fb)) {
+   DRM_DEBUG_KMS("CRTC set but no FB\n");
+   return -EINVAL;
+   } else if (WARN_ON(state->fb && !state->crtc)) {
+   DRM_DEBUG_KMS("FB set but no CRTC\n");
+   return -EINVAL;
+   }
+
+   /* if disabled, we don't care about the rest of the state: */
+   if (!state->crtc)
+   return 0;
+
+   /* Check whether this plane is usable on this CRTC */
+   if (!(plane->possible_crtcs & drm_crtc_mask(state->crtc))) {
+   DRM_DEBUG_KMS("Invalid crtc for plane\n");
+   return -EINVAL;
+   }
+
+   /* Check whether this plane supports the fb pixel format. */
+   for (i = 0; i < plane->format_count; i++)
+   if (state->fb->pixel_format == plane->format_types[i])
+   break;
+   if (i == plane->format_count) {
+   DRM_DEBUG_KMS("Invalid pixel format %s\n",
+ drm_get_format_name(state->fb->pixel_format));
+   return -EINVAL;
+   }
+
+   fb_width = state->fb->width << 16;
+   fb_height = state->fb->height << 16;
+
+   /* Make sure source coordinates are inside the fb. */
+   if (state->src_w > fb_width ||
+   state->src_x > fb_width - state->src_w ||
+   state->src_h > fb_height ||
+   state->src_y > fb_height - state->src_h) {
+   DRM_DEBUG_KMS("Invalid source coordinates "
+ "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n",
+ state->src_w >> 16, ((state->src_w & 0x) * 
15625) >> 10,
+ state->src_h >> 16, ((state->src_h & 0x) * 
15625) >> 10,
+ state->src_x >> 16, ((state->src_x & 0x) * 
15625) >> 10,
+ state->src_y >> 16, ((state->src_y & 0x) * 
15625) >> 10);
+   return -ENOSPC;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_atomic_plane_check);
+
+/**
  * drm_atomic_get_connector_state - get connector state
  * @state: global atomic state object
  * @connector: connector to get state object for
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 1a1ab34..55b6981 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -407,6 +407,37 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
return mode_fixup(state);
 }

+static int plane_check(struct drm_plane *plane, struct drm_plane_state *state)
+{
+   struct drm_plane_helper_funcs *funcs = plane->helper_private;
+   int ret;
+
+   ret = drm_atomic_plane_check(plane, state);
+   if (ret)
+   return ret;
+
+
+   if (funcs && funcs->atomic_check)
+   ret = funcs->atomic_check(plane, state);
+
+   return ret;
+}
+
+static int crtc_check(struct drm_crtc *crtc, struct drm_crtc_state *state)
+{
+   struct drm_crtc_helper_funcs *funcs = crtc->helper_private;
+   int r

[PATCH 10/13] drm/atomic: atomic plane properties

2014-12-16 Thread Rob Clark
Expose the core plane state as properties, so they can be updated via
atomic ioctl.

Signed-off-by: Rob Clark 
---
 Documentation/DocBook/drm.tmpl | 74 --
 drivers/gpu/drm/drm_atomic.c   | 69 ---
 drivers/gpu/drm/drm_crtc.c | 82 +++---
 include/drm/drm_crtc.h | 10 ++
 4 files changed, 224 insertions(+), 11 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4b592ff..282fa6b 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2564,7 +2564,7 @@ void intel_crt_init(struct drm_device *dev)
Description/Restrictions


-   DRM
+   DRM
Generic
“EDID”
BLOB | IMMUTABLE
@@ -2594,7 +2594,7 @@ void intel_crt_init(struct drm_device *dev)
Contains tiling information for a connector.


-   Plane
+   Plane
“type”
ENUM | IMMUTABLE
{ "Overlay", "Primary", "Cursor" }
@@ -2602,6 +2602,76 @@ void intel_crt_init(struct drm_device *dev)
Plane type


+   “SRC_X”
+   RANGE
+   Min=0, Max=UINT_MAX
+   Plane
+   Scanout source x coordinate in 16.16 fixed point 
(atomic)
+   
+   
+   “SRC_Y”
+   RANGE
+   Min=0, Max=UINT_MAX
+   Plane
+   Scanout source y coordinate in 16.16 fixed point 
(atomic)
+   
+   
+   “SRC_W”
+   RANGE
+   Min=0, Max=UINT_MAX
+   Plane
+   Scanout source width in 16.16 fixed point 
(atomic)
+   
+   
+   “SRC_H”
+   RANGE
+   Min=0, Max=UINT_MAX
+   Plane
+   Scanout source height in 16.16 fixed point 
(atomic)
+   
+   
+   “CRTC_X”
+   SIGNED_RANGE
+   Min=INT_MIN, Max=INT_MAX
+   Plane
+   Scanout CRTC (destination) x coordinate (atomic)
+   
+   
+   “CRTC_Y”
+   SIGNED_RANGE
+   Min=INT_MIN, Max=INT_MAX
+   Plane
+   Scanout CRTC (destination) y coordinate (atomic)
+   
+   
+   “CRTC_W”
+   RANGE
+   Min=0, Max=UINT_MAX
+   Plane
+   Scanout CRTC (destination) width (atomic)
+   
+   
+   “CRTC_H”
+   RANGE
+   Min=0, Max=UINT_MAX
+   Plane
+   Scanout CRTC (destination) height (atomic)
+   
+   
+   “FB_ID”
+   OBJECT
+   DRM_MODE_OBJECT_FB
+   Plane
+   Scanout framebuffer (atomic)
+   
+   
+   “CRTC_ID”
+   OBJECT
+   DRM_MODE_OBJECT_CRTC
+   Plane
+   CRTC that plane is attached to (atomic)
+   
+   
DVI-I
“subconnector”
ENUM
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index afb830d..c09a05a 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -352,9 +352,41 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
struct drm_plane_state *state, struct drm_property *property,
uint64_t val)
 {
-   if (plane->funcs->atomic_set_property)
-   return plane->funcs->atomic_set_property(plane, state, 
property, val);
-   return -EINVAL;
+   struct drm_device *dev = plane->dev;
+   struct drm_mode_config *config = &dev->mode_config;
+
+   if (property == config->prop_fb_id) {
+   struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, val);
+   drm_atomic_set_fb_for_plane(state, fb);
+   if (fb)
+   drm_framebuffer_unreference(fb);
+   } else if (property == config->prop_crtc_id) {
+   struct drm_crtc *crtc = drm_crtc_find(dev, val);
+   return drm_atomic_set_crtc_for_plane(state->state, plane, crtc);
+   } else if (property == config->prop_crtc_x) {
+   state->crtc_x = U642I64(val);
+   } else if (property == config->prop_crtc_y) {
+   state->crtc_y = U642I64(val);
+   } else if (property == config->prop_crtc_w) {
+   state->crtc_w = val;
+   } else if (property == config->prop_crtc_h) {
+   state->crtc_h = val;
+   } else if (property == config->prop_src_x) {
+   state->src_x = val;
+   } else if (property == config->prop_src_y) {
+   state->src_y = val;
+   } else if (property == config->prop_src_w) {
+   state->src_w = val;
+   } else if (property == config->prop_src_h) {
+   state->src_h = val;
+   } else if (plane->funcs->atomic_set_property) {
+   return plane->funcs->atomic_set_property(plane, state,
+   property, val);
+   } else {
+   return -EINVAL;
+   }
+
+   return 0;
 }
 EXPORT_SYMBOL(drm_atomic_plane_set_property);

@@ -374,9 +406,36 @@ int drm_atomic_plane_get_property(struct drm_plane *plane,
const 

[PATCH 11/13] drm/atomic: atomic connector properties

2014-12-16 Thread Rob Clark
Expose the core connector state as properties so it can be updated via
atomic ioctl.

Signed-off-by: Rob Clark 
---
 Documentation/DocBook/drm.tmpl | 11 +--
 drivers/gpu/drm/drm_atomic.c   |  9 +++--
 drivers/gpu/drm/drm_crtc.c | 13 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 282fa6b..15cb9b9 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2564,8 +2564,8 @@ void intel_crt_init(struct drm_device *dev)
Description/Restrictions


-   DRM
-   Generic
+   DRM
+   Connector
“EDID”
BLOB | IMMUTABLE
0
@@ -2594,6 +2594,13 @@ void intel_crt_init(struct drm_device *dev)
Contains tiling information for a connector.


+   “CRTC_ID”
+   OBJECT
+   DRM_MODE_OBJECT_CRTC
+   Connector
+   CRTC that connector is attached to (atomic)
+   
+   
Plane
“type”
ENUM | IMMUTABLE
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index c09a05a..71b48a0 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -595,7 +595,10 @@ int drm_atomic_connector_set_property(struct drm_connector 
*connector,
struct drm_device *dev = connector->dev;
struct drm_mode_config *config = &dev->mode_config;

-   if (property == config->dpms_property) {
+   if (property == config->prop_crtc_id) {
+   struct drm_crtc *crtc = drm_crtc_find(dev, val);
+   return drm_atomic_set_crtc_for_connector(state, crtc);
+   } else if (property == config->dpms_property) {
/* setting DPMS property requires special handling, which
 * is done in legacy setprop path for us.  Disallow (for
 * now?) atomic writes to DPMS property:
@@ -629,7 +632,9 @@ int drm_atomic_connector_get_property(struct drm_connector 
*connector,
struct drm_device *dev = connector->dev;
struct drm_mode_config *config = &dev->mode_config;

-   if (property == config->dpms_property) {
+   if (property == config->prop_crtc_id) {
+   *val = (state->crtc) ? state->crtc->base.id : 0;
+   } else if (property == config->dpms_property) {
*val = connector->dpms;
} else if (connector->funcs->atomic_get_property) {
return connector->funcs->atomic_get_property(connector,
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index fd6f91d..39c3e06 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -844,6 +844,7 @@ int drm_connector_init(struct drm_device *dev,
   const struct drm_connector_funcs *funcs,
   int connector_type)
 {
+   struct drm_mode_config *config = &dev->mode_config;
int ret;
struct ida *connector_ida =
&drm_connector_enum_list[connector_type].ida;
@@ -882,16 +883,20 @@ int drm_connector_init(struct drm_device *dev,

/* We should add connectors at the end to avoid upsetting the connector
 * index too much. */
-   list_add_tail(&connector->head, &dev->mode_config.connector_list);
-   dev->mode_config.num_connector++;
+   list_add_tail(&connector->head, &config->connector_list);
+   config->num_connector++;

if (connector_type != DRM_MODE_CONNECTOR_VIRTUAL)
drm_object_attach_property(&connector->base,
- dev->mode_config.edid_property,
+ config->edid_property,
  0);

drm_object_attach_property(&connector->base,
- dev->mode_config.dpms_property, 0);
+ config->dpms_property, 0);
+
+   if (has_atomic_properties(dev)) {
+   drm_object_attach_property(&connector->base, 
config->prop_crtc_id, 0);
+   }

connector->debugfs_entry = NULL;

-- 
2.1.0



[PATCH 12/13] drm/msm: atomic property support

2014-12-16 Thread Rob Clark
Not too much to do, as we haven't exposed any driver custom properties
yet, so all we need to do is plug in the helpers.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/hdmi/hdmi_connector.c  | 1 +
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c   | 1 +
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c | 1 +
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c  | 1 +
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c   | 1 +
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c  | 2 ++
 drivers/gpu/drm/msm/msm_drv.c  | 1 +
 7 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c 
b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
index fbebb04..3db9e71 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
@@ -399,6 +399,7 @@ static const struct drm_connector_funcs 
hdmi_connector_funcs = {
.detect = hdmi_connector_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.destroy = hdmi_connector_destroy,
+   .set_property = drm_atomic_helper_connector_set_property,
.reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
index 786efb3..2e6e431 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
@@ -501,6 +501,7 @@ static const struct drm_crtc_funcs mdp4_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
.destroy = mdp4_crtc_destroy,
.page_flip = drm_atomic_helper_page_flip,
+   .set_property = drm_atomic_helper_crtc_set_property,
.cursor_set = mdp4_crtc_cursor_set,
.cursor_move = mdp4_crtc_cursor_move,
.reset = drm_atomic_helper_crtc_reset,
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
index 4ddc28e1..583baac 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
@@ -98,6 +98,7 @@ static const struct drm_connector_funcs 
mdp4_lvds_connector_funcs = {
.detect = mdp4_lvds_connector_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.destroy = mdp4_lvds_connector_destroy,
+   .set_property = drm_atomic_helper_connector_set_property,
.reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
index e6d31db..d102d98 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
@@ -60,6 +60,7 @@ static const struct drm_plane_funcs mdp4_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = mdp4_plane_destroy,
+   .set_property = drm_atomic_helper_plane_set_property,
.reset = drm_atomic_helper_plane_reset,
.atomic_duplicate_state = 
drm_atomic_helper_plane_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
index 538967d..17fc4ae 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
@@ -386,6 +386,7 @@ static const struct drm_crtc_funcs mdp5_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
.destroy = mdp5_crtc_destroy,
.page_flip = drm_atomic_helper_page_flip,
+   .set_property = drm_atomic_helper_crtc_set_property,
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 67a4e80..134b47b 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -136,6 +136,8 @@ static const struct drm_plane_funcs mdp5_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = mdp5_plane_destroy,
+   .set_property = drm_atomic_helper_plane_set_property,
+   /* TODO expose zpos property and override atomic_get/set: */
.reset = mdp5_plane_reset,
.atomic_duplicate_state = mdp5_plane_duplicate_state,
.atomic_destroy_state = mdp5_plane_destroy_sta

[PATCH 13/13] RFC: drm: Atomic modeset ioctl

2014-12-16 Thread Rob Clark
The atomic modeset ioctl can be used to push any number of new values
for object properties. The driver can then check the full device
configuration as single unit, and try to apply the changes atomically.

The ioctl simply takes a list of object IDs and property IDs and their
values.

Originally based on a patch from Ville Syrjälä, although it has mutated
(mutilated?) enough since then that you probably shouldn't blame it on
him ;-)

TODO:
 * hide behind moduleparam initially
 * either bring back blob property support, or add ioctls for create/
   destroy blob properties so they can be passed in by id in this
   ioctl.  I'm leaning towards the latter approach as (a) it is more
   in line with how blob properties are read, and (b) the atomic
   ioctl function is big enough already.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/drm_atomic.c | 308 +++
 drivers/gpu/drm/drm_crtc.c   |   4 +-
 drivers/gpu/drm/drm_ioctl.c  |   1 +
 include/drm/drm_crtc.h   |   6 +
 include/uapi/drm/drm.h   |   1 +
 include/uapi/drm/drm_mode.h  |  21 +++
 6 files changed, 339 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 71b48a0..e7a45ec 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -960,3 +960,311 @@ int drm_atomic_async_commit(struct drm_atomic_state 
*state)
return config->funcs->atomic_commit(state->dev, state, true);
 }
 EXPORT_SYMBOL(drm_atomic_async_commit);
+
+/*
+ * The big monstor ioctl
+ */
+
+static struct drm_pending_vblank_event *create_vblank_event(
+   struct drm_device *dev, struct drm_file *file_priv, uint64_t 
user_data)
+{
+   struct drm_pending_vblank_event *e = NULL;
+   unsigned long flags;
+
+   spin_lock_irqsave(&dev->event_lock, flags);
+   if (file_priv->event_space < sizeof e->event) {
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   goto out;
+   }
+   file_priv->event_space -= sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+
+   e = kzalloc(sizeof *e, GFP_KERNEL);
+   if (e == NULL) {
+   spin_lock_irqsave(&dev->event_lock, flags);
+   file_priv->event_space += sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   goto out;
+   }
+
+   e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
+   e->event.base.length = sizeof e->event;
+   e->event.user_data = user_data;
+   e->base.event = &e->event.base;
+   e->base.file_priv = file_priv;
+   e->base.destroy = (void (*) (struct drm_pending_event *)) kfree;
+
+out:
+   return e;
+}
+
+static void destroy_vblank_event(struct drm_device *dev,
+   struct drm_file *file_priv, struct drm_pending_vblank_event *e)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(&dev->event_lock, flags);
+   file_priv->event_space += sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   kfree(e);
+}
+
+int drm_mode_atomic_ioctl(struct drm_device *dev,
+ void *data, struct drm_file *file_priv)
+{
+   struct drm_mode_atomic *arg = data;
+   uint32_t __user *objs_ptr = (uint32_t __user *)(unsigned 
long)(arg->objs_ptr);
+   uint32_t __user *count_props_ptr = (uint32_t __user *)(unsigned 
long)(arg->count_props_ptr);
+   uint32_t __user *props_ptr = (uint32_t __user *)(unsigned 
long)(arg->props_ptr);
+   uint64_t __user *prop_values_ptr = (uint64_t __user *)(unsigned 
long)(arg->prop_values_ptr);
+   unsigned int copied_objs, copied_props;
+   struct drm_atomic_state *state;
+   struct drm_modeset_acquire_ctx ctx;
+   struct drm_plane *plane;
+   unsigned plane_mask = 0;
+   int ret = 0;
+   unsigned int i, j;
+
+   if (arg->flags & ~DRM_MODE_ATOMIC_FLAGS)
+   return -EINVAL;
+
+   /* can't test and expect an event at the same time. */
+   if ((arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) &&
+   (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+   return -EINVAL;
+
+   drm_modeset_acquire_init(&ctx, 0);
+
+   state = drm_atomic_state_alloc(dev);
+   if (!state)
+   return -ENOMEM;
+
+   state->acquire_ctx = &ctx;
+
+retry:
+   copied_objs = 0;
+   copied_props = 0;
+
+   for (i = 0; i < arg->count_objs; i++) {
+   uint32_t obj_id, count_props;
+   struct drm_mode_object *obj;
+
+   if (get_user(obj_id, objs_ptr + copied_objs)) {
+   ret = -EFAULT;
+   goto fail;
+   }
+
+   obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY);
+   if (!obj || !obj->properties) {
+   ret = -ENOENT;
+   goto fail;
+   }
+
+   if (obj->type == DRM_MODE_OBJECT_PLANE) 

[PATCH] drm/dsi: Do the 'msg' check prior to dereferencing it.

2014-12-16 Thread Fabio Estevam
From: Fabio Estevam 

Commit a52879e8d7cb ("drm/dsi: Add message to packet translator") caused the
following Smatch complaint:

drivers/gpu/drm/drm_mipi_dsi.c:328 mipi_dsi_create_packet()
 warn: variable dereferenced before check 'msg' (see line 326)

Do the 'msg' check prior to dereferencing it.

Reported-by: Dan Carpenter  
Signed-off-by: Fabio Estevam 
---
 drivers/gpu/drm/drm_mipi_dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index c0644bb..a9812db 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -323,11 +323,13 @@ EXPORT_SYMBOL(mipi_dsi_packet_format_is_long);
 int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
   const struct mipi_dsi_msg *msg)
 {
-   const u8 *tx = msg->tx_buf;
+   const u8 *tx;

if (!packet || !msg)
return -EINVAL;

+   tx = msg->tx_buf;
+
/* do some minimum sanity checking */
if (!mipi_dsi_packet_format_is_short(msg->type) &&
!mipi_dsi_packet_format_is_long(msg->type))
-- 
1.9.1



[PATCH 5/6] dt-bindings: Add documentation for Rockchip hdmi-audio

2014-12-16 Thread Russell King - ARM Linux
On Tue, Dec 16, 2014 at 02:17:51PM +0800, Kuankuan.Yang wrote:
> hdmi-audio driver share irq with dw_hdmi driver,  for continuing AHBAUDDMA
> or for detecting hdmi insert.
> So maybe it's hard to switch to simple-card way,  Russell what's your
> opinion ?

My "opinion" is that I need to spend some time looking in depth at both
your code and my code before I can form an idea of how to proceed.

However, since I seem to be spending a lot of time chasing regressions
which have appeared in v3.18, I don't have a lot of time to look at this
right now.

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.


[PATCH 5/6] dt-bindings: Add documentation for Rockchip hdmi-audio

2014-12-16 Thread Kuankuan.Yang

在 2014年12月16日 17:34, Russell King - ARM Linux 写道:
> On Tue, Dec 16, 2014 at 02:17:51PM +0800, Kuankuan.Yang wrote:
>> hdmi-audio driver share irq with dw_hdmi driver,  for continuing AHBAUDDMA
>> or for detecting hdmi insert.
>> So maybe it's hard to switch to simple-card way,  Russell what's your
>> opinion ?
> My "opinion" is that I need to spend some time looking in depth at both
> your code and my code before I can form an idea of how to proceed.
>
> However, since I seem to be spending a lot of time chasing regressions
> which have appeared in v3.18, I don't have a lot of time to look at this
> right now.
>
okay, if u got any ideas, wish u can let me know, thks.