[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #12 from Bryan Quigley  ---
Adding the patch from comment #8 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/20130115/f92da5be/attachment.html>


Re: [Linaro-mm-sig] [PATCH 5/7] seqno-fence: Hardware dma-buf implementation of fencing (v4)

2013-01-15 Thread Inki Dae
2013/1/15 Maarten Lankhorst :
> This type of fence can be used with hardware synchronization for simple
> hardware that can block execution until the condition
> (dma_buf[offset] - value) >= 0 has been met.
>
> A software fallback still has to be provided in case the fence is used
> with a device that doesn't support this mechanism. It is useful to expose
> this for graphics cards that have an op to support this.
>
> Some cards like i915 can export those, but don't have an option to wait,
> so they need the software fallback.
>
> I extended the original patch by Rob Clark.
>
> v1: Original
> v2: Renamed from bikeshed to seqno, moved into dma-fence.c since
> not much was left of the file. Lots of documentation added.
> v3: Use fence_ops instead of custom callbacks. Moved to own file
> to avoid circular dependency between dma-buf.h and fence.h
> v4: Add spinlock pointer to seqno_fence_init
>
> Signed-off-by: Maarten Lankhorst 
> ---
>  Documentation/DocBook/device-drivers.tmpl |   1 +
>  drivers/base/fence.c  |  38 +++
>  include/linux/seqno-fence.h   | 105 
> ++
>  3 files changed, 144 insertions(+)
>  create mode 100644 include/linux/seqno-fence.h
>
> diff --git a/Documentation/DocBook/device-drivers.tmpl 
> b/Documentation/DocBook/device-drivers.tmpl
> index 6f53fc0..ad14396 100644
> --- a/Documentation/DocBook/device-drivers.tmpl
> +++ b/Documentation/DocBook/device-drivers.tmpl
> @@ -128,6 +128,7 @@ X!Edrivers/base/interface.c
>  !Edrivers/base/dma-buf.c
>  !Edrivers/base/fence.c
>  !Iinclude/linux/fence.h
> +!Iinclude/linux/seqno-fence.h
>  !Edrivers/base/dma-coherent.c
>  !Edrivers/base/dma-mapping.c
>   
> diff --git a/drivers/base/fence.c b/drivers/base/fence.c
> index 28e5ffd..1d3f29c 100644
> --- a/drivers/base/fence.c
> +++ b/drivers/base/fence.c
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  atomic_t fence_context_counter = ATOMIC_INIT(0);
>  EXPORT_SYMBOL(fence_context_counter);
> @@ -284,3 +285,40 @@ out:
> return ret;
>  }
>  EXPORT_SYMBOL(fence_default_wait);
> +
> +static bool seqno_enable_signaling(struct fence *fence)
> +{
> +   struct seqno_fence *seqno_fence = to_seqno_fence(fence);
> +   return seqno_fence->ops->enable_signaling(fence);
> +}
> +
> +static bool seqno_signaled(struct fence *fence)
> +{
> +   struct seqno_fence *seqno_fence = to_seqno_fence(fence);
> +   return seqno_fence->ops->signaled && 
> seqno_fence->ops->signaled(fence);
> +}
> +
> +static void seqno_release(struct fence *fence)
> +{
> +   struct seqno_fence *f = to_seqno_fence(fence);
> +
> +   dma_buf_put(f->sync_buf);
> +   if (f->ops->release)
> +   f->ops->release(fence);
> +   else
> +   kfree(f);
> +}
> +
> +static long seqno_wait(struct fence *fence, bool intr, signed long timeout)
> +{
> +   struct seqno_fence *f = to_seqno_fence(fence);
> +   return f->ops->wait(fence, intr, timeout);
> +}
> +
> +const struct fence_ops seqno_fence_ops = {
> +   .enable_signaling = seqno_enable_signaling,
> +   .signaled = seqno_signaled,
> +   .wait = seqno_wait,
> +   .release = seqno_release
> +};
> +EXPORT_SYMBOL_GPL(seqno_fence_ops);
> diff --git a/include/linux/seqno-fence.h b/include/linux/seqno-fence.h
> new file mode 100644
> index 000..603adc0
> --- /dev/null
> +++ b/include/linux/seqno-fence.h
> @@ -0,0 +1,105 @@
> +/*
> + * seqno-fence, using a dma-buf to synchronize fencing
> + *
> + * Copyright (C) 2012 Texas Instruments
> + * Copyright (C) 2012 Canonical Ltd
> + * Authors:
> + *   Rob Clark 
> + *   Maarten Lankhorst 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published 
> by
> + * the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but 
> WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +#ifndef __LINUX_SEQNO_FENCE_H
> +#define __LINUX_SEQNO_FENCE_H
> +
> +#include 
> +#include 
> +
> +struct seqno_fence {
> +   struct fence base;
> +
> +   const struct fence_ops *ops;
> +   struct dma_buf *sync_buf;
> +   uint32_t seqno_ofs;
> +};

Hi maarten,

I'm applying dma-fence v11 and seqno-fence v4 to exynos drm and have
some proposals.

The above seqno_fence structure has only one dmabuf. Shouldn't it have
mutiple dmabufs? For example, in case of drm driver, when pageflip is
requested, one framebuffer could have one more gem buffer for NV12M
format. And this means that one more exported dmabufs should be
sychronized with other devices. Belo

[PATCH] ttm: on move memory failure don't leave a node dangling

2013-01-15 Thread Dave Airlie
if we have a move notify callback, when moving fails, we call move notify
the opposite way around, however this ends up with *mem containing the mm_node
from the bo, which means we double free it. This is a follow on to the previous
fix.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index cd64ead..076024e 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -434,6 +434,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object 
*bo,
bo->mem = tmp_mem;
bdev->driver->move_notify(bo, mem);
bo->mem = *mem;
+   *mem = tmp_mem;
}
 
goto out_err;
-- 
1.8.1

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


Re: [PATCHv5 7/8] ARM: tegra: Add board data and 2D clocks

2013-01-15 Thread Terje Bergström
On 15.01.2013 20:44, Stephen Warren wrote:
>> diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c 
>> b/arch/arm/mach-tegra/board-dt-tegra20.c
> 
>> +OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x5414, "gr2d", NULL),
> 
> I assume the only reason to add AUXDATA is to give the device a specific
> name, which will then match the driver name in the clock driver:
> 
>> -CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"),
>> +CLK_DUPLICATE("2d", "gr2d", "gr2d"),
> 
> If so, this shouldn't be needed once the common clock framework patches
> are applied, since all device clocks will be retrieved from device tree,
> and hence the device name will be irrelevant; the phandle in device tree
> is all that will matter.

Yes, clock binding is the only reason for the OF_DEV_AUXDATA line. I'll
need to look into Prashant's clock changes, but I assume it's going to
be a trivial change to host1x patches.

Thanks for the heads-up.

Terje

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


[Bug 30151] HDMI audio via radeon DRM driver is not working.

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=30151

mtzseb at yahoo.fr changed:

   What|Removed |Added

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

--- Comment #7 from mtzseb at yahoo.fr ---
Everything works fine now on Rosa. Certainly an update yesterday and today on
this young distro (because I've had several) which resolved a conflict. So,
this system approaches perfection. My best linux distro I installed on my PC!
Bug resolved ! I'm sorry for the soliciting caused by this digging out bug, but
thank you for the time you have given me for his resolution.

-- 
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/20130115/22e87f34/attachment.html>


[PATCH 5/5] drm/tegra: Implement page-flipping support

2013-01-15 Thread Thierry Reding
On Tue, Jan 15, 2013 at 06:53:19PM +0100, Daniel Vetter wrote:
> On Mon, Jan 14, 2013 at 4:55 PM, Thierry Reding
>  wrote:
> > +static void tegra_drm_preclose(struct drm_device *drm, struct drm_file 
> > *file)
> > +{
> > +   struct drm_crtc *crtc;
> > +
> > +   list_for_each_entry(crtc, &drm->mode_config.crtc_list, head)
> > +   tegra_dc_cancel_page_flip(crtc, file);
> > +}
> > +
> 
> Why that? If userspace dies while a flip is outstanding, it's imo ok
> to execute it - otherwise there might be an accounting mismatch if the
> hw still scans out the old fb, but drm believes the new one is used.
> Or do I miss something?

I looked at the shmobile driver for inspiration and they do this as
well. Doing so seemed reasonable since there'd be no file to deliver the
event to.

> The reason I've skimmed through the patches is to check for
> implications with my modeset locking rework. Review on that would be
> highly appreciated ...

I'm not sure how suited I am for review given my limited experience, but
I'll see if I can make some time to take a look.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130115/5c644ba9/attachment.pgp>


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #12 from Alex Deucher   2013-01-15 
20:57:27 ---
Same issue as:
https://bugs.freedesktop.org/show_bug.cgi?id=58659

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.


[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #11 from Alex Deucher  ---
Same issue as:
https://bugzilla.kernel.org/show_bug.cgi?id=52491

-- 
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/20130115/64a1989b/attachment.html>


[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #10 from Bryan Quigley  ---
Reverting commit d025e9e2b890db679f1246037bf65bd4be512627 does indeed fix the
Big Picture issue.  Will test the patch now..

-- 
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/20130115/be288caf/attachment.html>


[PATCH] ttm: don't destroy old mm_node on memcpy failure

2013-01-15 Thread Dave Airlie
When we are using memcpy to move objects around, and we fail to memcpy
due to lack of memory to populate or failure to finish the copy, we don't
want to destroy the mm_node that has been copied into old_copy.

While working on a new kms driver that uses memcpy, if I overallocated bo's
up to the memory limits, and eviction failed, then machine would oops soon
after due to having an active bo with an already freed drm_mm embedded in it,
freeing it a second time didn't end well.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index ed42323..a2aab88 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -344,8 +344,12 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 
if (ttm->state == tt_unpopulated) {
ret = ttm->bdev->driver->ttm_tt_populate(ttm);
-   if (ret)
+   if (ret) {
+   /* if we fail here don't nuke the mm node
+* as the bo still owns it */
+   old_copy.mm_node = NULL;
goto out1;
+   }
}
 
add = 0;
@@ -371,8 +375,11 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
   prot);
} else
ret = ttm_copy_io_page(new_iomap, old_iomap, page);
-   if (ret)
+   if (ret) {
+   /* failing here, means keep old copy as-is */
+   old_copy.mm_node = NULL;
goto out1;
+   }
}
mb();
 out2:
-- 
1.8.1

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


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #11 from Bruno Jacquet   2013-01-15 19:38:05 ---
(In reply to comment #9)
> Does reverting the following commit fix the issue?
> 
> commit d025e9e2b890db679f1246037bf65bd4be512627
> Author: Jerome Glisse 
> Date:   Thu Nov 29 10:35:41 2012 -0500
> 
> drm/radeon: do not move bo to different placement at each cs
> 
> The bo creation placement is where the bo will be. Instead of trying
> to move bo at each command stream let this work to another worker
> thread that will use more advance heuristic.
> 
> agd5f: remove leftover unused variable
> 
> Signed-off-by: Jerome Glisse 
> Reviewed-by: Alex Deucher 

It does fix the corruption.

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.


[Bug 30151] HDMI audio via radeon DRM driver is not working.

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=30151

--- Comment #6 from Andy Furniss  ---
(In reply to comment #5)
> Off course !
> 
> cat /proc/asound/cards
>  0 [Intel  ]: HDA-Intel - HDA Intel
>   HDA Intel at 0xfc50 irq 47
>  1 [HDMI   ]: HDA-Intel - HDA ATI HDMI
>   HDA ATI HDMI at 0xfc01 irq 48
> 
> cat /proc/asound/devices
>   2: [ 0- 0]: digital audio playback
>   3: [ 0- 0]: digital audio capture
>   4: [ 0- 0]: hardware dependent
>   5: [ 0]   : control
>   6: [ 1- 3]: digital audio playback
>   7: [ 1- 0]: hardware dependent
>   8: [ 1]   : control
>  33:: timer

Looks like vlc is trying the wrong device - from your output -

"Audio device 'hdmi: CARD = HDMI, DEV = 0 "can not be used:"

You need to get vlc to use card 1 device 3, I don't use vlc so can't help with
that. I don't use smplayer either but with plain mplayer you would do -

mplayer -ao alsa:device=hw=1.3

Pulse may complicate things - I don't know as I don't use that.

If you still can't get any playback run alsamixer press F6 select hdmi and make
sure it says OO not MM. Pressing m will toggle between Open and Mute.

-- 
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/20130115/a7814575/attachment-0001.html>


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #10 from Bruno Jacquet   2013-01-15 19:26:08 ---
(In reply to comment #8)
> (In reply to comment #6)
> > ==> So maybe dd54fef DID fix the kernel crash but replaced it with the
> > corruption I'm seeing ?
> 
> Does the corruption also occur with dd54fee7d440c4a9756cce2c24a50c15e4c17ccb
> applied manually on top of 0d0b3e7443bed6b49cb90fe7ddc4b5578a83a88d?

g0d0b3e7 with patch dd54fee7d I see no corruption

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.


[PATCH 5/5] drm/tegra: Implement page-flipping support

2013-01-15 Thread Daniel Vetter
On Mon, Jan 14, 2013 at 4:55 PM, Thierry Reding
 wrote:
> +static void tegra_drm_preclose(struct drm_device *drm, struct drm_file *file)
> +{
> +   struct drm_crtc *crtc;
> +
> +   list_for_each_entry(crtc, &drm->mode_config.crtc_list, head)
> +   tegra_dc_cancel_page_flip(crtc, file);
> +}
> +

Why that? If userspace dies while a flip is outstanding, it's imo ok
to execute it - otherwise there might be an accounting mismatch if the
hw still scans out the old fb, but drm believes the new one is used.
Or do I miss something?

The reason I've skimmed through the patches is to check for
implications with my modeset locking rework. Review on that would be
highly appreciated ...


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


[Bug 59332] Problems building 32bit Mesa

2013-01-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=59332

Mike Lothian  changed:

   What|Removed |Added

 CC||m...@fireburn.co.uk

--- Comment #1 from Mike Lothian  ---
I think the issue is in egl - mesa builds fine on 32bit without it

The 64bit version builds fine with it

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] gpu: drm/nouveau/nouveau_fence.c: remove unnecessary null pointer check

2013-01-15 Thread Cong Ding
the variable chan is dereferenced in line 190, so it is no reason to check
null again in line 198.

Signed-off-by: Cong Ding 
---
 drivers/gpu/drm/nouveau/nouveau_fence.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c 
b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 1d049be..b6b8e49 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -195,11 +195,9 @@ nouveau_fence_new(struct nouveau_channel *chan, struct 
nouveau_fence **pfence)
return -ENOMEM;
kref_init(&fence->kref);

-   if (chan) {
-   ret = nouveau_fence_emit(fence, chan);
-   if (ret)
-   nouveau_fence_unref(&fence);
-   }
+   ret = nouveau_fence_emit(fence, chan);
+   if (ret)
+   nouveau_fence_unref(&fence);

*pfence = fence;
return ret;
-- 
1.7.10.4



Re: [PATCH] drm/exynos: Replace mdelay with usleep_range

2013-01-15 Thread Inki Dae
Applied.

Thanks,
Inki Dae

2013/1/15 Sean Paul :
> Replace the unnecessary atomic mdelay calls with usleep_range calls.
>
> Signed-off-by: Sean Paul 
> ---
>  drivers/gpu/drm/exynos/exynos_hdmi.c  |   14 +++---
>  drivers/gpu/drm/exynos/exynos_mixer.c |2 +-
>  2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
> b/drivers/gpu/drm/exynos/exynos_hdmi.c
> index b2f8de9..4cf01f3 100644
> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> @@ -1646,9 +1646,9 @@ static void hdmi_conf_reset(struct hdmi_context *hdata)
>
> /* resetting HDMI core */
> hdmi_reg_writemask(hdata, reg,  0, HDMI_CORE_SW_RSTOUT);
> -   mdelay(10);
> +   usleep_range(1, 12000);
> hdmi_reg_writemask(hdata, reg, ~0, HDMI_CORE_SW_RSTOUT);
> -   mdelay(10);
> +   usleep_range(1, 12000);
>  }
>
>  static void hdmi_conf_init(struct hdmi_context *hdata)
> @@ -1773,7 +1773,7 @@ static void hdmi_v13_timing_apply(struct hdmi_context 
> *hdata)
> u32 val = hdmi_reg_read(hdata, HDMI_V13_PHY_STATUS);
> if (val & HDMI_PHY_STATUS_READY)
> break;
> -   mdelay(1);
> +   usleep_range(1000, 2000);
> }
> /* steady state not achieved */
> if (tries == 0) {
> @@ -1940,7 +1940,7 @@ static void hdmi_v14_timing_apply(struct hdmi_context 
> *hdata)
> u32 val = hdmi_reg_read(hdata, HDMI_PHY_STATUS_0);
> if (val & HDMI_PHY_STATUS_READY)
> break;
> -   mdelay(1);
> +   usleep_range(1000, 2000);
> }
> /* steady state not achieved */
> if (tries == 0) {
> @@ -1992,9 +1992,9 @@ static void hdmiphy_conf_reset(struct hdmi_context 
> *hdata)
>
> /* reset hdmiphy */
> hdmi_reg_writemask(hdata, reg, ~0, HDMI_PHY_SW_RSTOUT);
> -   mdelay(10);
> +   usleep_range(1, 12000);
> hdmi_reg_writemask(hdata, reg,  0, HDMI_PHY_SW_RSTOUT);
> -   mdelay(10);
> +   usleep_range(1, 12000);
>  }
>
>  static void hdmiphy_poweron(struct hdmi_context *hdata)
> @@ -2042,7 +2042,7 @@ static void hdmiphy_conf_apply(struct hdmi_context 
> *hdata)
> return;
> }
>
> -   mdelay(10);
> +   usleep_range(1, 12000);
>
> /* operation mode */
> operation[0] = 0x1f;
> diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
> b/drivers/gpu/drm/exynos/exynos_mixer.c
> index e9dbf79..2be9833 100644
> --- a/drivers/gpu/drm/exynos/exynos_mixer.c
> +++ b/drivers/gpu/drm/exynos/exynos_mixer.c
> @@ -600,7 +600,7 @@ static void vp_win_reset(struct mixer_context *ctx)
> /* waiting until VP_SRESET_PROCESSING is 0 */
> if (~vp_reg_read(res, VP_SRESET) & VP_SRESET_PROCESSING)
> break;
> -   mdelay(10);
> +   usleep_range(1, 12000);
> }
> WARN(tries == 0, "failed to reset Video Processor\n");
>  }
> --
> 1.7.7.3
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/exynos: Remove "internal" interrupt handling

2013-01-15 Thread Inki Dae
2013/1/15 Sean Paul :
> Remove the "internal" interrupt handling since it's never invoked and

Right, internal interrupt handler isn't used yet. It's better to add
when used actually. And below is my comment.


> remove "external" reference. This patch removes a bunch of dead code
> and clarifies how hotplugging is handled in the HDMI driver.
>
> Signed-off-by: Sean Paul 
> ---
>  drivers/gpu/drm/exynos/exynos_hdmi.c |   74 
> +++---
>  1 files changed, 15 insertions(+), 59 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
> b/drivers/gpu/drm/exynos/exynos_hdmi.c
> index 36e9214..b2f8de9 100644
> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> @@ -98,8 +98,7 @@ struct hdmi_context {
>
> void __iomem*regs;
> void*parent_ctx;
> -   int external_irq;
> -   int internal_irq;
> +   int irq;
>
> struct i2c_client   *ddc_port;
> struct i2c_client   *hdmiphy_port;
> @@ -1656,7 +1655,7 @@ static void hdmi_conf_init(struct hdmi_context *hdata)
>  {
> struct hdmi_infoframe infoframe;
>
> -   /* disable HPD interrupts */
> +   /* disable HPD interrupts from HDMI IP block, use GPIO instead */
> hdmi_reg_writemask(hdata, HDMI_INTC_CON, 0, HDMI_INTC_EN_GLOBAL |
> HDMI_INTC_EN_HPD_PLUG | HDMI_INTC_EN_HPD_UNPLUG);
>
> @@ -2260,7 +2259,7 @@ static struct exynos_hdmi_ops hdmi_ops = {
> .dpms   = hdmi_dpms,
>  };
>
> -static irqreturn_t hdmi_external_irq_thread(int irq, void *arg)
> +static irqreturn_t hdmi_irq_thread(int irq, void *arg)
>  {
> struct exynos_drm_hdmi_context *ctx = arg;
> struct hdmi_context *hdata = ctx->ctx;
> @@ -2275,31 +2274,6 @@ static irqreturn_t hdmi_external_irq_thread(int irq, 
> void *arg)
> return IRQ_HANDLED;
>  }
>
> -static irqreturn_t hdmi_internal_irq_thread(int irq, void *arg)
> -{
> -   struct exynos_drm_hdmi_context *ctx = arg;
> -   struct hdmi_context *hdata = ctx->ctx;
> -   u32 intc_flag;
> -
> -   intc_flag = hdmi_reg_read(hdata, HDMI_INTC_FLAG);
> -   /* clearing flags for HPD plug/unplug */
> -   if (intc_flag & HDMI_INTC_FLAG_HPD_UNPLUG) {
> -   DRM_DEBUG_KMS("unplugged\n");
> -   hdmi_reg_writemask(hdata, HDMI_INTC_FLAG, ~0,
> -   HDMI_INTC_FLAG_HPD_UNPLUG);
> -   }
> -   if (intc_flag & HDMI_INTC_FLAG_HPD_PLUG) {
> -   DRM_DEBUG_KMS("plugged\n");
> -   hdmi_reg_writemask(hdata, HDMI_INTC_FLAG, ~0,
> -   HDMI_INTC_FLAG_HPD_PLUG);
> -   }
> -
> -   if (ctx->drm_dev)
> -   drm_helper_hpd_irq_event(ctx->drm_dev);
> -
> -   return IRQ_HANDLED;
> -}
> -
>  static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
>  {
> struct device *dev = hdata->dev;
> @@ -2550,39 +2524,24 @@ static int __devinit hdmi_probe(struct 
> platform_device *pdev)
>
> hdata->hdmiphy_port = hdmi_hdmiphy;
>
> -   hdata->external_irq = gpio_to_irq(hdata->hpd_gpio);
> -   if (hdata->external_irq < 0) {
> -   DRM_ERROR("failed to get GPIO external irq\n");
> -   ret = hdata->external_irq;
> -   goto err_hdmiphy;
> -   }
> -
> -   hdata->internal_irq = platform_get_irq(pdev, 0);
> -   if (hdata->internal_irq < 0) {
> -   DRM_ERROR("failed to get platform internal irq\n");
> -   ret = hdata->internal_irq;
> +   hdata->irq = gpio_to_irq(hdata->hpd_gpio);
> +   if (hdata->irq < 0) {
> +   DRM_ERROR("failed to get GPIO irq\n");
> +   ret = hdata->irq;
> goto err_hdmiphy;
> }
>
> hdata->hpd = gpio_get_value(hdata->hpd_gpio);
>
> -   ret = request_threaded_irq(hdata->external_irq, NULL,
> -   hdmi_external_irq_thread, IRQF_TRIGGER_RISING |
> +   ret = request_threaded_irq(hdata->irq, NULL,
> +   hdmi_irq_thread, IRQF_TRIGGER_RISING |
> IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> -   "hdmi_external", drm_hdmi_ctx);
> +   "hdmi", drm_hdmi_ctx);
> if (ret) {
> -   DRM_ERROR("failed to register hdmi external interrupt\n");
> +   DRM_ERROR("failed to register hdmi interrupt\n");
> goto err_hdmiphy;
> }
>
> -   ret = request_threaded_irq(hdata->internal_irq, NULL,
> -   hdmi_internal_irq_thread, IRQF_ONESHOT,
> -   "hdmi_internal", drm_hdmi_ctx);
> -   if (ret) {
> -   DRM_ERROR("failed to register hdmi internal interrupt\n");
> -   goto err_free_irq;
> -   }
> -
> /* Attach HDMI Driver to common hdmi. */
>   

[PATCH] drm/ttm: fix delayed ttm_bo_cleanup_refs_and_unlock delayed handling

2013-01-15 Thread Markus Trippelsdorf
On 2013.01.15 at 17:32 +0100, Markus Trippelsdorf wrote:
> On 2013.01.15 at 16:26 +0100, Michel D?nzer wrote:
> > On Die, 2013-01-15 at 16:23 +0100, Markus Trippelsdorf wrote: 
> > > On 2013.01.15 at 15:43 +0100, Michel D?nzer wrote:
> > > > On Sam, 2013-01-05 at 11:41 +0100, Markus Trippelsdorf wrote: 
> > > > > On 2012.12.20 at 14:58 +0100, Markus Trippelsdorf wrote:
> > > > > > 
> > > > > > And just in case it got lost in the noise yesterday: 
> > > > > > The image corruption is caused by Dave's commit:
> > > > > > 
> > > > > > commit dd54fee7d440c4a9756cce2c24a50c15e4c17ccb
> > > > > > Author: Dave Airlie 
> > > > > > Date:   Fri Dec 14 21:04:46 2012 +1000
> > > > > > 
> > > > > > radeon: fix regression with eviction since evict caching changes
> > > > > > 
> > > > > > Reverting it 'fixes' the issue.
> > > > > 
> > > > > Ping.
> > > > > The issue still happens with todays Linus git tree.
> > > > 
> > > > Does the corruption also occur with
> > > > dd54fee7d440c4a9756cce2c24a50c15e4c17ccb applied manually on top of
> > > > 0d0b3e7443bed6b49cb90fe7ddc4b5578a83a88d?
> > > 
> > > No.
> > 
> > So, can you bisect which change between those two actually introduced
> > the corruption?
> 
> 86a1881d08f65a42c17071a59c0088dbe2870246 is the first bad commit

Sorry, the bisection above was wrong. Please ignore.

The real cause of the image corruption is:

d025e9e2b890db679f1246037bf65bd4be512627 is the first bad commit
commit d025e9e2b890db679f1246037bf65bd4be512627
Author: Jerome Glisse 
Date:   Thu Nov 29 10:35:41 2012 -0500

drm/radeon: do not move bo to different placement at each cs

The bo creation placement is where the bo will be. Instead of trying
to move bo at each command stream let this work to another worker
thread that will use more advance heuristic.

agd5f: remove leftover unused variable

Signed-off-by: Jerome Glisse 
Reviewed-by: Alex Deucher 

Reverting d025e9e2b890d on top of Linus' tree fixes the issue.

-- 
Markus


[PATCH v2 2/5] drm/tegra: Add plane support

2013-01-15 Thread Mark Zhang
On 01/15/2013 12:05 AM, Thierry Reding wrote:
> Add support for the B and C planes which support RGB and YUV pixel
> formats and can be used as overlays or hardware cursor.

I think "hardware cursor" has specific meaning for Tegra(e.g: Tegra30
has a 32x32 24bpp or 64x64 2bpp hardware cursor). So you may change it
to "hardware accelerated cursor"?

> 
> Signed-off-by: Thierry Reding 
> ---
[...]
> +
> +static const uint32_t plane_formats[] = {
> + DRM_FORMAT_XRGB,
> + DRM_FORMAT_YUV422,

I haven't found something related with YUV format in this patch set. For
example, "tegra_dc_format" also doesn't take YUV into consideration. So
remove this line.

> +};
> +
> +static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc)
> +{
> + unsigned int i;
> + int err = 0;
> +
> + for (i = 0; i < 2; i++) {
> + struct tegra_plane *plane;
> +
> + plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
> + if (!plane)
> + return -ENOMEM;
> +
> + plane->index = i;

I suggest to change this line to: "plane->index = i + 1;". This makes
the plane's index be consistent with Tegra's windows number. And also we
don't need to worry about passing "plane->index + 1" to some functions
which need to know which window is operating on.

> +
> + err = drm_plane_init(drm, &plane->base, 1 << dc->pipe,
> +  &tegra_plane_funcs, plane_formats,
> +  ARRAY_SIZE(plane_formats), false);
> + if (err < 0)
> + return err;
> + }
> +
> + return 0;
> +}
> +
[...]
>  
> +int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
> +   const struct tegra_dc_window *window)
> +{
> + unsigned h_offset, v_offset, h_size, v_size, h_dda, v_dda, bpp;
> + unsigned long value;
> +
> + bpp = window->bits_per_pixel / 8;
> +
> + value = WINDOW_A_SELECT << index;
> + tegra_dc_writel(dc, value, DC_CMD_DISPLAY_WINDOW_HEADER);
> +
> + tegra_dc_writel(dc, window->format, DC_WIN_COLOR_DEPTH);
> + tegra_dc_writel(dc, 0, DC_WIN_BYTE_SWAP);
> +
> + value = V_POSITION(window->dst.y) | H_POSITION(window->dst.x);
> + tegra_dc_writel(dc, value, DC_WIN_POSITION);
> +
> + value = V_SIZE(window->dst.h) | H_SIZE(window->dst.w);
> + tegra_dc_writel(dc, value, DC_WIN_SIZE);
> +
> + h_offset = window->src.x * bpp;
> + v_offset = window->src.y;
> + h_size = window->src.w * bpp;
> + v_size = window->src.h;
> +
> + value = V_PRESCALED_SIZE(v_size) | H_PRESCALED_SIZE(h_size);
> + tegra_dc_writel(dc, value, DC_WIN_PRESCALED_SIZE);
> +
> + h_dda = compute_dda_inc(window->src.w, window->dst.w, false, bpp);
> + v_dda = compute_dda_inc(window->src.h, window->dst.h, true, bpp);
> +
> + value = V_DDA_INC(v_dda) | H_DDA_INC(h_dda);
> + tegra_dc_writel(dc, value, DC_WIN_DDA_INC);
> +
> + h_dda = compute_initial_dda(window->src.x);
> + v_dda = compute_initial_dda(window->src.y);
> +

In current implementation, "compute_initial_dda" always returns zero. So
why we need it? Although according to TRM, typically we set H/V initial
dda to zero.

> + tegra_dc_writel(dc, h_dda, DC_WIN_H_INITIAL_DDA);
> + tegra_dc_writel(dc, v_dda, DC_WIN_V_INITIAL_DDA);
> +
> + tegra_dc_writel(dc, 0, DC_WIN_UV_BUF_STRIDE);
> + tegra_dc_writel(dc, 0, DC_WIN_BUF_STRIDE);
> +
> + tegra_dc_writel(dc, window->base, DC_WINBUF_START_ADDR);
> + tegra_dc_writel(dc, window->stride, DC_WIN_LINE_STRIDE);
> + tegra_dc_writel(dc, h_offset, DC_WINBUF_ADDR_H_OFFSET);
> + tegra_dc_writel(dc, v_offset, DC_WINBUF_ADDR_V_OFFSET);
> +
> + value = WIN_ENABLE;
> +
> + if (bpp < 24)
> + value |= COLOR_EXPAND;
> +
> + tegra_dc_writel(dc, value, DC_WIN_WIN_OPTIONS);
> +
> + /*
> +  * Disable blending and assume Window A is the bottom-most window,
> +  * Window C is the top-most window and Window B is in the middle.
> +  */
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_NOKEY);
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_1WIN);
> +
> + switch (index) {
> + case 0:
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_2WIN_X);
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_2WIN_Y);
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_3WIN_XY);
> + break;
> +
> + case 1:
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_2WIN_X);
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_2WIN_Y);
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_3WIN_XY);
> + break;
> +
> + case 2:
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_2WIN_X);
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_2WIN_Y);
> + tegra_dc_writel(dc, 0x00, DC_WIN_BLEND_3WIN_XY);
> + break;
> + }
> +
> + value = (WIN_A_ACT_REQ

[Bug 30151] HDMI audio via radeon DRM driver is not working.

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=30151

--- Comment #5 from mtzseb at yahoo.fr ---
Off course !

cat /proc/asound/cards
 0 [Intel  ]: HDA-Intel - HDA Intel
  HDA Intel at 0xfc50 irq 47
 1 [HDMI   ]: HDA-Intel - HDA ATI HDMI
  HDA ATI HDMI at 0xfc01 irq 48

cat /proc/asound/devices
  2: [ 0- 0]: digital audio playback
  3: [ 0- 0]: digital audio capture
  4: [ 0- 0]: hardware dependent
  5: [ 0]   : control
  6: [ 1- 3]: digital audio playback
  7: [ 1- 0]: hardware dependent
  8: [ 1]   : control
 33:: timer

-- 
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/20130115/f73069c9/attachment.html>


[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #9 from Alex Deucher  ---
Does reverting the following commit fix the corruption issue?

commit d025e9e2b890db679f1246037bf65bd4be512627
Author: Jerome Glisse 
Date:   Thu Nov 29 10:35:41 2012 -0500

drm/radeon: do not move bo to different placement at each cs

The bo creation placement is where the bo will be. Instead of trying
to move bo at each command stream let this work to another worker
thread that will use more advance heuristic.

agd5f: remove leftover unused variable

Signed-off-by: Jerome Glisse 
Reviewed-by: Alex Deucher 

-- 
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/20130115/41029dbe/attachment.html>


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #9 from Alex Deucher   2013-01-15 
17:37:44 ---
Does reverting the following commit fix the issue?

commit d025e9e2b890db679f1246037bf65bd4be512627
Author: Jerome Glisse 
Date:   Thu Nov 29 10:35:41 2012 -0500

drm/radeon: do not move bo to different placement at each cs

The bo creation placement is where the bo will be. Instead of trying
to move bo at each command stream let this work to another worker
thread that will use more advance heuristic.

agd5f: remove leftover unused variable

Signed-off-by: Jerome Glisse 
Reviewed-by: Alex Deucher 

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.


[PATCH] drm/ttm: fix delayed ttm_bo_cleanup_refs_and_unlock delayed handling

2013-01-15 Thread Markus Trippelsdorf
On 2013.01.15 at 16:26 +0100, Michel D?nzer wrote:
> On Die, 2013-01-15 at 16:23 +0100, Markus Trippelsdorf wrote: 
> > On 2013.01.15 at 15:43 +0100, Michel D?nzer wrote:
> > > On Sam, 2013-01-05 at 11:41 +0100, Markus Trippelsdorf wrote: 
> > > > On 2012.12.20 at 14:58 +0100, Markus Trippelsdorf wrote:
> > > > > 
> > > > > And just in case it got lost in the noise yesterday: 
> > > > > The image corruption is caused by Dave's commit:
> > > > > 
> > > > > commit dd54fee7d440c4a9756cce2c24a50c15e4c17ccb
> > > > > Author: Dave Airlie 
> > > > > Date:   Fri Dec 14 21:04:46 2012 +1000
> > > > > 
> > > > > radeon: fix regression with eviction since evict caching changes
> > > > > 
> > > > > Reverting it 'fixes' the issue.
> > > > 
> > > > Ping.
> > > > The issue still happens with todays Linus git tree.
> > > 
> > > Does the corruption also occur with
> > > dd54fee7d440c4a9756cce2c24a50c15e4c17ccb applied manually on top of
> > > 0d0b3e7443bed6b49cb90fe7ddc4b5578a83a88d?
> > 
> > No.
> 
> So, can you bisect which change between those two actually introduced
> the corruption?

86a1881d08f65a42c17071a59c0088dbe2870246 is the first bad commit
commit 86a1881d08f65a42c17071a59c0088dbe2870246
Author: Jerome Glisse 
Date:   Wed Dec 12 16:43:15 2012 -0500

drm/radeon: fix fence driver for dma ring when wb is disabled

The dma ring can't write to register thus have to write to memory
its fence value. This ensure that it doesn't try to use scratch
register for dma ring fence driver.

Should fix:
https://bugs.freedesktop.org/show_bug.cgi?id=58166

Signed-off-by: Jerome Glisse 
Reviewed-by: Alex Deucher 

-- 
Markus


[PATCH] gpu: drm/nouveau/nouveau_fence.c: remove unnecessary null pointer check

2013-01-15 Thread David Howells
Cong Ding  wrote:

> > > the variable sender is dereferenced in line 190, so it is no reason to 
> > > check
> > > null again in line 198.
> > 
> > Did you mean "The variable 'chan'"?
> sorry, my fault. so should I send a new version to correct the typo?

Yep.

David


[PATCH] drm/ttm: fix delayed ttm_bo_cleanup_refs_and_unlock delayed handling

2013-01-15 Thread Michel Dänzer
On Die, 2013-01-15 at 16:23 +0100, Markus Trippelsdorf wrote: 
> On 2013.01.15 at 15:43 +0100, Michel D?nzer wrote:
> > On Sam, 2013-01-05 at 11:41 +0100, Markus Trippelsdorf wrote: 
> > > On 2012.12.20 at 14:58 +0100, Markus Trippelsdorf wrote:
> > > > 
> > > > And just in case it got lost in the noise yesterday: 
> > > > The image corruption is caused by Dave's commit:
> > > > 
> > > > commit dd54fee7d440c4a9756cce2c24a50c15e4c17ccb
> > > > Author: Dave Airlie 
> > > > Date:   Fri Dec 14 21:04:46 2012 +1000
> > > > 
> > > > radeon: fix regression with eviction since evict caching changes
> > > > 
> > > > Reverting it 'fixes' the issue.
> > > 
> > > Ping.
> > > The issue still happens with todays Linus git tree.
> > 
> > Does the corruption also occur with
> > dd54fee7d440c4a9756cce2c24a50c15e4c17ccb applied manually on top of
> > 0d0b3e7443bed6b49cb90fe7ddc4b5578a83a88d?
> 
> No.

So, can you bisect which change between those two actually introduced
the corruption?


-- 
Earthling Michel D?nzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer


Patch "drm: Add EDID_QUIRK_FORCE_REDUCED_BLANKING for ASUS VW222S" has been added to the 3.4-stable tree

2013-01-15 Thread Daniel Vetter
On Tue, Jan 15, 2013 at 3:31 PM, Ilija Hadzic
 wrote:
> I thought I saw a revert for that patch on the mailing list yesterday:
>
> http://lists.freedesktop.org/archives/dri-devel/2013-January/033322.html

Yeah, patch is bogus and the revert is already acked by the original author.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH] drm/ttm: fix delayed ttm_bo_cleanup_refs_and_unlock delayed handling

2013-01-15 Thread Markus Trippelsdorf
On 2013.01.15 at 15:43 +0100, Michel D?nzer wrote:
> On Sam, 2013-01-05 at 11:41 +0100, Markus Trippelsdorf wrote: 
> > On 2012.12.20 at 14:58 +0100, Markus Trippelsdorf wrote:
> > > 
> > > And just in case it got lost in the noise yesterday: 
> > > The image corruption is caused by Dave's commit:
> > > 
> > > commit dd54fee7d440c4a9756cce2c24a50c15e4c17ccb
> > > Author: Dave Airlie 
> > > Date:   Fri Dec 14 21:04:46 2012 +1000
> > > 
> > > radeon: fix regression with eviction since evict caching changes
> > > 
> > > Reverting it 'fixes' the issue.
> > 
> > Ping.
> > The issue still happens with todays Linus git tree.
> 
> Does the corruption also occur with
> dd54fee7d440c4a9756cce2c24a50c15e4c17ccb applied manually on top of
> 0d0b3e7443bed6b49cb90fe7ddc4b5578a83a88d?

No.

-- 
Markus


nouveau lockdep splat on init

2013-01-15 Thread Maarten Lankhorst
Testing airlied's current drm-fixes branch gives me this, with lockdep enabled:

[   40.864179] =
[   40.864179] [ INFO: possible recursive locking detected ]
[   40.864179] 3.8.0-rc3-patser+ #915 Tainted: GW   
[   40.864179] -
[   40.864179] modprobe/524 is trying to acquire lock:
[   40.864179]  (&subdev->mutex){+.+.+.}, at: [] 
nouveau_instobj_create_+0x43/0x90 [nouveau]
[   40.864179] 
[   40.864179] but task is already holding lock:
[   40.864179]  (&subdev->mutex){+.+.+.}, at: [] 
nv50_disp_data_ctor+0x94/0x160 [nouveau]
[   40.864179] 
[   40.864179] other info that might help us debug this:
[   40.864179]  Possible unsafe locking scenario:
[   40.864179] 
[   40.864179]CPU0
[   40.864179]
[   40.864179]   lock(&subdev->mutex);
[   40.864179]   lock(&subdev->mutex);
[   40.864179] 
[   40.864179]  *** DEADLOCK ***
[   40.864179] 
[   40.864179]  May be due to missing lock nesting notation
[   40.864179] 
[   40.864179] 4 locks held by modprobe/524:
[   40.864179]  #0:  (&__lockdep_no_validate__){..}, at: 
[] __driver_attach+0x53/0xb0
[   40.864179]  #1:  (&__lockdep_no_validate__){..}, at: 
[] __driver_attach+0x61/0xb0
[   40.864179]  #2:  (drm_global_mutex){+.+.+.}, at: [] 
drm_get_pci_dev+0xb7/0x2a0 [drm]
[   40.864179]  #3:  (&subdev->mutex){+.+.+.}, at: [] 
nv50_disp_data_ctor+0x94/0x160 [nouveau]
[   40.864179] 
[   40.864179] stack backtrace:
[   40.864179] Pid: 524, comm: modprobe Tainted: GW
3.8.0-rc3-patser+ #915
[   40.864179] Call Trace:
[   40.864179]  [] __lock_acquire+0x783/0x1d90
[   40.864179]  [] ? __lock_acquire+0x3ef/0x1d90
[   40.864179]  [] ? mark_held_locks+0x82/0x130
[   40.864179]  [] ? trace_hardirqs_on_thunk+0x3a/0x3f
[   40.864179]  [] lock_acquire+0x96/0xc0
[   40.864179]  [] ? nouveau_instobj_create_+0x43/0x90 
[nouveau]
[   40.864179]  [] ? nouveau_object_create_+0x9c/0xf0 
[nouveau]
[   40.864179]  [] ? nouveau_instobj_create_+0x43/0x90 
[nouveau]
[   40.864179]  [] mutex_lock_nested+0x5e/0x390
[   40.864179]  [] ? nouveau_instobj_create_+0x43/0x90 
[nouveau]
[   40.864179]  [] ? _raw_spin_unlock+0x30/0x60
[   40.864179]  [] ? nouveau_object_create_+0xce/0xf0 
[nouveau]
[   40.864179]  [] ? _raw_spin_unlock_irq+0x2b/0x60
[   40.864179]  [] nouveau_instobj_create_+0x43/0x90 [nouveau]
[   40.864179]  [] nv50_instobj_ctor+0xa1/0x1b0 [nouveau]
[   40.864179]  [] ? finish_task_switch+0x3a/0x110
[   40.864179]  [] nouveau_object_ctor+0x33/0xe0 [nouveau]
[   40.864179]  [] nv50_instmem_alloc+0x2f/0x40 [nouveau]
[   40.864179]  [] nouveau_gpuobj_create_+0x38d/0x4c0 
[nouveau]
[   40.864179]  [] nouveau_engctx_create_+0x17c/0x3d0 
[nouveau]
[   40.864179]  [] nv50_disp_data_ctor+0x131/0x160 [nouveau]
[   40.864179]  [] ? nouveau_subdev_reset+0x72/0xb0 [nouveau]
[   40.864179]  [] nouveau_object_ctor+0x33/0xe0 [nouveau]
[   40.864179]  [] nouveau_object_new+0x14a/0x2b0 [nouveau]
[   40.864179]  [] nv50_display_create+0x1ea/0x9a0 [nouveau]
[   40.864179]  [] ? __cancel_work_timer+0x72/0xc0
[   40.864179]  [] nouveau_display_create+0x4c4/0x900 
[nouveau]
[   40.864179]  [] nouveau_drm_load+0x3b2/0x960 [nouveau]
[   40.864179]  [] ? device_register+0x19/0x20
[   40.864179]  [] ? drm_sysfs_device_add+0x81/0xb0 [drm]
[   40.864179]  [] drm_get_pci_dev+0x179/0x2a0 [drm]
[   40.864179]  [] ? __pci_set_master+0x4d/0x80
[   40.864179]  [] nouveau_drm_probe+0x25a/0x290 [nouveau]
[   40.864179]  [] ? _raw_spin_unlock_irqrestore+0x3d/0x80
[   40.864179]  [] local_pci_probe+0x46/0x80
[   40.864179]  [] pci_device_probe+0xf9/0x120
[   40.864179]  [] driver_probe_device+0x76/0x240
[   40.864179]  [] __driver_attach+0xa3/0xb0
[   40.864179]  [] ? driver_probe_device+0x240/0x240
[   40.864179]  [] bus_for_each_dev+0x56/0x90
[   40.864179]  [] driver_attach+0x19/0x20
[   40.864179]  [] bus_add_driver+0x188/0x270
[   40.864179]  [] driver_register+0x75/0x150
[   40.864179]  [] __pci_register_driver+0x5f/0x70
[   40.864179]  [] drm_pci_init+0x11a/0x130 [drm]
[   40.864179]  [] ? vga_switcheroo_register_handler+0x40/0x90
[   40.864179]  [] ? 0xa04a2fff
[   40.864179]  [] nouveau_drm_init+0x4d/0x1000 [nouveau]
[   40.864179]  [] do_one_initcall+0x3a/0x170
[   40.864179]  [] load_module+0x1a52/0x2020
[   40.864179]  [] ? get_modinfo.isra.30+0xc0/0xc0
[   40.864179]  [] ? trace_hardirqs_on_thunk+0x3a/0x3f
[   40.864179]  [] sys_init_module+0xd1/0x100
[   40.864179]  [] system_call_fastpath+0x16/0x1b

I don't understand the need for the mutex_lock in that code though, wouldn't it 
be better for the caller to ensure that this code is only called once?

~Maarten



[PATCH] drm/ttm: fix delayed ttm_bo_cleanup_refs_and_unlock delayed handling

2013-01-15 Thread Michel Dänzer
On Sam, 2013-01-05 at 11:41 +0100, Markus Trippelsdorf wrote: 
> On 2012.12.20 at 14:58 +0100, Markus Trippelsdorf wrote:
> > 
> > And just in case it got lost in the noise yesterday: 
> > The image corruption is caused by Dave's commit:
> > 
> > commit dd54fee7d440c4a9756cce2c24a50c15e4c17ccb
> > Author: Dave Airlie 
> > Date:   Fri Dec 14 21:04:46 2012 +1000
> > 
> > radeon: fix regression with eviction since evict caching changes
> > 
> > Reverting it 'fixes' the issue.
> 
> Ping.
> The issue still happens with todays Linus git tree.

Does the corruption also occur with
dd54fee7d440c4a9756cce2c24a50c15e4c17ccb applied manually on top of
0d0b3e7443bed6b49cb90fe7ddc4b5578a83a88d?


-- 
Earthling Michel D?nzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer


[PATCH 1/7] arch: add __mutex_fastpath_lock_retval_arg to generic/sh/x86/powerpc/ia64

2013-01-15 Thread Maarten Lankhorst
Again, missing entry :(

Op 15-01-13 13:33, Maarten Lankhorst schreef:
> Needed for reservation slowpath.

I was hoping to convert the 'mutexes' in ttm to proper mutexes, so I extended 
the
core mutex code slightly to add support for reservations. This requires however
passing an argument to __mutex_fastpath_lock_retval, so I added this for all 
archs
based on their existing __mutex_fastpath_lock_retval implementation.

I'm guessing this would have to be split up in the final version, but for now 
it's
easier to edit as a single patch.

> ---
>  arch/ia64/include/asm/mutex.h| 20 
>  arch/powerpc/include/asm/mutex.h | 20 
>  arch/sh/include/asm/mutex-llsc.h | 20 
>  arch/x86/include/asm/mutex_32.h  | 20 
>  arch/x86/include/asm/mutex_64.h  | 20 
>  include/asm-generic/mutex-dec.h  | 20 
>  include/asm-generic/mutex-null.h |  1 +
>  include/asm-generic/mutex-xchg.h | 21 +
>  8 files changed, 142 insertions(+)
>
> diff --git a/arch/ia64/include/asm/mutex.h b/arch/ia64/include/asm/mutex.h
> index bed73a6..2510058 100644
> --- a/arch/ia64/include/asm/mutex.h
> +++ b/arch/ia64/include/asm/mutex.h
> @@ -44,6 +44,26 @@ __mutex_fastpath_lock_retval(atomic_t *count, int 
> (*fail_fn)(atomic_t *))
>  }
>  
>  /**
> + *  __mutex_fastpath_lock_retval_arg - try to take the lock by moving the 
> count
> + * from 1 to a 0 value
> + *  @count: pointer of type atomic_t
> + *  @arg: argument to pass along if fastpath fails.
> + *  @fail_fn: function to call if the original value was not 1
> + *
> + * Change the count from 1 to a value lower than 1, and call  if
> + * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
> + * or anything the slow path function returns.
> + */
> +static inline int __mutex_fastpath_lock_retval_arg(atomic_t *count,
> + void *arg, int (*fail_fn)(atomic_t *, void*))
> +{
> + if (unlikely(ia64_fetchadd4_acq(count, -1) != 1))
> + return fail_fn(count, arg);
> + else
> + return 0;
> +}
> +
> +/**
>   *  __mutex_fastpath_unlock - try to promote the count from 0 to 1
>   *  @count: pointer of type atomic_t
>   *  @fail_fn: function to call if the original value was not 0
> diff --git a/arch/powerpc/include/asm/mutex.h 
> b/arch/powerpc/include/asm/mutex.h
> index 5399f7e..df4bcff 100644
> --- a/arch/powerpc/include/asm/mutex.h
> +++ b/arch/powerpc/include/asm/mutex.h
> @@ -97,6 +97,26 @@ __mutex_fastpath_lock_retval(atomic_t *count, int 
> (*fail_fn)(atomic_t *))
>  }
>  
>  /**
> + *  __mutex_fastpath_lock_retval_arg - try to take the lock by moving the 
> count
> + * from 1 to a 0 value
> + *  @count: pointer of type atomic_t
> + *  @arg: argument to pass along if fastpath fails.
> + *  @fail_fn: function to call if the original value was not 1
> + *
> + * Change the count from 1 to a value lower than 1, and call  if
> + * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
> + * or anything the slow path function returns.
> + */
> +static inline int __mutex_fastpath_lock_retval_arg(atomic_t *count,
> + void *arg, int (*fail_fn)(atomic_t *, void*))
> +{
> + if (unlikely(__mutex_dec_return_lock(count) < 0))
> + return fail_fn(count, arg);
> + else
> + return 0;
> +}
> +
> +/**
>   *  __mutex_fastpath_unlock - try to promote the count from 0 to 1
>   *  @count: pointer of type atomic_t
>   *  @fail_fn: function to call if the original value was not 0
> diff --git a/arch/sh/include/asm/mutex-llsc.h 
> b/arch/sh/include/asm/mutex-llsc.h
> index 090358a..b68dd6d 100644
> --- a/arch/sh/include/asm/mutex-llsc.h
> +++ b/arch/sh/include/asm/mutex-llsc.h
> @@ -56,6 +56,26 @@ __mutex_fastpath_lock_retval(atomic_t *count, int 
> (*fail_fn)(atomic_t *))
>   return __res;
>  }
>  
> +static inline int __mutex_fastpath_lock_retval_arg(atomic_t *count,
> + void *arg, int (*fail_fn)(atomic_t *, void *))
> +{
> + int __done, __res;
> +
> + __asm__ __volatile__ (
> + "movli.l@%2, %0 \n"
> + "add#-1, %0 \n"
> + "movco.l%0, @%2 \n"
> + "movt   %1  \n"
> + : "=&z" (__res), "=&r" (__done)
> + : "r" (&(count)->counter)
> + : "t");
> +
> + if (unlikely(!__done || __res != 0))
> + __res = fail_fn(count, arg);
> +
> + return __res;
> +}
> +
>  static inline void
>  __mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *))
>  {
> diff --git a/arch/x86/include/asm/mutex_32.h b/arch/x86/include/asm/mutex_32.h
> index 03f90c8..34f77f9 100644
> --- a/arch/x86/include/asm/mutex_32.h
> +++ b/arch/x86/include/asm/mutex_32.h
> @@ -58,6 +58,26 @@ static inline int __mutex_

[PATCH 2/7] mutex: add support for reservation style locks

2013-01-15 Thread Maarten Lankhorst
Woops, missed the updated patch description..

Op 15-01-13 13:33, Maarten Lankhorst schreef:
> makes it easier to port ttm over..
>
> Signed-off-by: Maarten Lankhorst 

mutex_reserve_lock, and mutex_reserve_lock_interruptible:
  Lock a buffer with a reservation_id set. reservation_id must not be set to 0,
  since this is a special value that means no reservation_id.

  Normally if reservation_id is not set, or is older than the reservation_id 
that's
  currently set on the mutex, the behavior will be to wait normally.

  However, if  the reservation_id is newer than the current reservation_id, 
-EAGAIN
  will be returned, and this function must unreserve all other mutexes and then 
redo
  a blocking lock with normal mutex calls to prevent a deadlock, then call
  mutex_locked_set_reservation on successful locking to set the reservation_id 
inside
  the lock.

  These functions will return -EDEADLK instead of -EAGAIN if reservation_id is 
the same
  as the reservation_id that's attempted to lock the mutex with, since in that 
case you
  presumably attempted to lock the same lock twice.

mutex_reserve_lock_slow and mutex_reserve_lock_intr_slow:
  Similar to mutex_reserve_lock, except it won't backoff with -EAGAIN. This is 
useful
  after mutex_reserve_lock failed with -EAGAIN, and you unreserved all buffers 
so no
  deadlock can occur.

mutex_unreserve_unlock:
   Unlock a buffer reserved with the previous calls.

Missing at the moment, maybe TODO?
  * lockdep warnings when wrongly calling mutex_unreserve_unlock or 
mutex_unlock,
depending on whether reservation_id was set previously or not.
- Does lockdep have something for this or do I need to extend struct mutex?

  * Check if lockdep warns if you unlock a lock that other locks were nested to.
- spin_lock(m); spin_lock_nest_lock(a, m); spin_unlock(m); spin_unlock(a);
  would be nice if it gave a splat. Have to recheck if it does, though..

Design:
  I chose for ticket_mutex to encapsulate struct mutex, so the extra memory 
usage and
  atomic set on init will only happen when you deliberately create a ticket 
lock.

  Since the mutexes are mostly meant to protect buffer object serialization in 
ttm, not
  much contention is expected. I could be slightly smarter with wakeups, but 
this would
  be at the expense at adding a field to struct mutex_waiter. Because this 
would add
  overhead to all cases where ticket_mutexes are not used, and ticket_mutexes 
are less
  performance sensitive anyway since they only protect buffer objects, I didn't 
want to
  do this. It's still better than ttm always calling wake_up_all, which does a
  unconditional spin_lock_irqsave/irqrestore.

  I needed this in kernel/mutex.c because of the extensions to __lock_common, 
which are
  hopefully optimized away for all normal paths.

Changes since RFC patch v1:
 - Updated to use atomic_long instead of atomic, since the reservation_id was a 
long.
 - added mutex_reserve_lock_slow and mutex_reserve_lock_intr_slow
 - removed mutex_locked_set_reservation_id (or w/e it was called)

Signed-off-by: Maarten Lankhorst 

> ---
>  include/linux/mutex.h |  86 +-
>  kernel/mutex.c| 317 
> +++---
>  2 files changed, 387 insertions(+), 16 deletions(-)
>
> diff --git a/include/linux/mutex.h b/include/linux/mutex.h
> index 9121595..602c247 100644
> --- a/include/linux/mutex.h
> +++ b/include/linux/mutex.h
> @@ -62,6 +62,11 @@ struct mutex {
>  #endif
>  };
>  
> +struct ticket_mutex {
> + struct mutex base;
> + atomic_long_t reservation_id;
> +};
> +
>  /*
>   * This is the control structure for tasks blocked on mutex,
>   * which resides on the blocked task's kernel stack:
> @@ -109,12 +114,24 @@ static inline void mutex_destroy(struct mutex *lock) {}
>   __DEBUG_MUTEX_INITIALIZER(lockname) \
>   __DEP_MAP_MUTEX_INITIALIZER(lockname) }
>  
> +#define __TICKET_MUTEX_INITIALIZER(lockname) \
> + { .base = __MUTEX_INITIALIZER(lockname) \
> + , .reservation_id = ATOMIC_LONG_INIT(0) }
> +
>  #define DEFINE_MUTEX(mutexname) \
>   struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
>  
>  extern void __mutex_init(struct mutex *lock, const char *name,
>struct lock_class_key *key);
>  
> +static inline void __ticket_mutex_init(struct ticket_mutex *lock,
> +const char *name,
> +struct lock_class_key *key)
> +{
> + __mutex_init(&lock->base, name, key);
> + atomic_long_set(&lock->reservation_id, 0);
> +}
> +
>  /**
>   * mutex_is_locked - is the mutex locked
>   * @lock: the mutex to be queried
> @@ -133,26 +150,91 @@ static inline int mutex_is_locked(struct mutex *lock)
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>  extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
>  extern void _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map 
> *nest_lock)

[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #12 from Bryan Quigley  ---
Adding the patch from comment #8 does not help.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 59211] Acer 19" display AL1917WA requires quirk

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=59211

Alex Deucher  changed:

   What|Removed |Added

Summary|Radeon FireGL RV630 black   |Acer 19" display AL1917WA
   |screen after bootup,|requires quirk
   |incorrect modesetting   |

-- 
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/20130115/b0bc547d/attachment.html>


[Bug 59211] Radeon FireGL RV630 black screen after bootup, incorrect modesetting

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=59211

Alex Deucher  changed:

   What|Removed |Added

   Assignee|xorg-driver-ati at lists.x.org |dri-devel at 
lists.freedesktop
   ||.org
 QA Contact|xorg-team at lists.x.org   |
Product|xorg|DRI
  Component|Driver/Radeon   |General

-- 
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/20130115/6e78972b/attachment.html>


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #8 from Michel D?nzer   2013-01-15 14:36:15 
---
(In reply to comment #6)
> ==> So maybe dd54fef DID fix the kernel crash but replaced it with the
> corruption I'm seeing ?

Does the corruption also occur with dd54fee7d440c4a9756cce2c24a50c15e4c17ccb
applied manually on top of 0d0b3e7443bed6b49cb90fe7ddc4b5578a83a88d?

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.


[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #8 from Alex Deucher  ---
Created attachment 73088
  --> https://bugs.freedesktop.org/attachment.cgi?id=73088&action=edit
possible fix

Does the attached kernel patch 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/20130115/ceb53bc1/attachment.html>


[PATCHv5,RESEND 8/8] drm: tegra: Add gr2d device

2013-01-15 Thread Terje Bergstrom
Add client driver for 2D device, and IOCTLs to pass work to host1x
channel for 2D.

Also adds functions that can be called to access sync points from DRM.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile   |1 +
 drivers/gpu/host1x/dev.c  |7 +
 drivers/gpu/host1x/drm/drm.c  |  226 +++-
 drivers/gpu/host1x/drm/drm.h  |   28 
 drivers/gpu/host1x/drm/gr2d.c |  325 +
 drivers/gpu/host1x/syncpt.c   |5 +
 drivers/gpu/host1x/syncpt.h   |3 +
 include/drm/tegra_drm.h   |  131 +
 8 files changed, 725 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/drm/tegra_drm.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index c35ee19..c2120ad 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -18,4 +18,5 @@ ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG

 host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o
 host1x-$(CONFIG_DRM_TEGRA) += drm/output.o drm/rgb.o drm/hdmi.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/gr2d.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index 17ee01c..40d9938 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -214,11 +214,17 @@ static int __init tegra_host1x_init(void)
err = platform_driver_register(&tegra_hdmi_driver);
if (err < 0)
goto unregister_dc;
+
+   err = platform_driver_register(&tegra_gr2d_driver);
+   if (err < 0)
+   goto unregister_hdmi;
 #endif

return 0;

 #ifdef CONFIG_TEGRA_DRM
+unregister_hdmi:
+   platform_driver_unregister(&tegra_hdmi_driver);
 unregister_dc:
platform_driver_unregister(&tegra_dc_driver);
 unregister_host1x:
@@ -231,6 +237,7 @@ module_init(tegra_host1x_init);
 static void __exit tegra_host1x_exit(void)
 {
 #ifdef CONFIG_TEGRA_DRM
+   platform_driver_unregister(&tegra_gr2d_driver);
platform_driver_unregister(&tegra_hdmi_driver);
platform_driver_unregister(&tegra_dc_driver);
 #endif
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index bef9051..f8f8508 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -14,9 +14,11 @@
 #include 
 #include 
 #include 
+#include 

 #include "drm.h"
 #include "host1x_client.h"
+#include "syncpt.h"

 #define DRIVER_NAME "tegra"
 #define DRIVER_DESC "NVIDIA Tegra graphics"
@@ -78,8 +80,10 @@ static int host1x_parse_dt(struct host1x *host1x)
static const char * const compat[] = {
"nvidia,tegra20-dc",
"nvidia,tegra20-hdmi",
+   "nvidia,tegra20-gr2d",
"nvidia,tegra30-dc",
"nvidia,tegra30-hdmi",
+   "nvidia,tegra30-gr2d",
};
unsigned int i;
int err;
@@ -270,7 +274,29 @@ static int tegra_drm_unload(struct drm_device *drm)

 static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
 {
-   return 0;
+   struct host1x_drm_fpriv *fpriv;
+   int err = 0;
+
+   fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
+   if (!fpriv)
+   return -ENOMEM;
+
+   INIT_LIST_HEAD(&fpriv->contexts);
+   filp->driver_priv = fpriv;
+
+   return err;
+}
+
+static void tegra_drm_close(struct drm_device *drm, struct drm_file *filp)
+{
+   struct host1x_drm_fpriv *fpriv = host1x_drm_fpriv(filp);
+   struct host1x_drm_context *context, *tmp;
+
+   list_for_each_entry_safe(context, tmp, &fpriv->contexts, list) {
+   context->client->ops->close_channel(context);
+   kfree(context);
+   }
+   kfree(fpriv);
 }

 static void tegra_drm_lastclose(struct drm_device *drm)
@@ -280,7 +306,204 @@ static void tegra_drm_lastclose(struct drm_device *drm)
drm_fbdev_cma_restore_mode(host1x->fbdev);
 }

+static int
+tegra_drm_ioctl_syncpt_read(struct drm_device *drm, void *data,
+struct drm_file *file_priv)
+{
+   struct host1x *host1x = drm->dev_private;
+   struct tegra_drm_syncpt_read_args *args = data;
+   struct host1x_syncpt *sp =
+   host1x_syncpt_get_bydev(host1x->dev, args->id);
+
+   if (!sp)
+   return -EINVAL;
+
+   args->value = host1x_syncpt_read_min(sp);
+   return 0;
+}
+
+static int
+tegra_drm_ioctl_syncpt_incr(struct drm_device *drm, void *data,
+struct drm_file *file_priv)
+{
+   struct host1x *host1x = drm->dev_private;
+   struct tegra_drm_syncpt_incr_args *args = data;
+   struct host1x_syncpt *sp =
+   host1x_syncpt_get_bydev(host1x->dev, args->id);
+
+   if (!sp)
+   return -EINVAL;
+
+   host1x_syncpt_incr(sp);
+   return 0;
+}
+
+static int
+tegra_drm_ioctl_syncpt_wait(struct drm_device *drm, void *data,
+struct drm_file *file

[PATCHv5,RESEND 7/8] ARM: tegra: Add board data and 2D clocks

2013-01-15 Thread Terje Bergstrom
Add a driver alias gr2d for Tegra 2D device, and assign a duplicate
of 2D clock to that driver alias.

Signed-off-by: Terje Bergstrom 
---
 arch/arm/mach-tegra/board-dt-tegra20.c|1 +
 arch/arm/mach-tegra/board-dt-tegra30.c|1 +
 arch/arm/mach-tegra/tegra20_clocks_data.c |2 +-
 arch/arm/mach-tegra/tegra30_clocks_data.c |1 +
 4 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c 
b/arch/arm/mach-tegra/board-dt-tegra20.c
index 171ba3c..9fcc800 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -96,6 +96,7 @@ static struct of_dev_auxdata tegra20_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("nvidia,tegra20-slink", 0x7000D800, "spi_tegra.2", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-slink", 0x7000DA00, "spi_tegra.3", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-host1x", 0x5000, "host1x", NULL),
+   OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x5414, "gr2d", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-dc", 0x5420, "tegradc.0", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-dc", 0x5424, "tegradc.1", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-hdmi", 0x5428, "hdmi", NULL),
diff --git a/arch/arm/mach-tegra/board-dt-tegra30.c 
b/arch/arm/mach-tegra/board-dt-tegra30.c
index cfe5fc0..0b4a1f0 100644
--- a/arch/arm/mach-tegra/board-dt-tegra30.c
+++ b/arch/arm/mach-tegra/board-dt-tegra30.c
@@ -59,6 +59,7 @@ static struct of_dev_auxdata tegra30_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("nvidia,tegra30-slink", 0x7000DC00, "spi_tegra.4", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-slink", 0x7000DE00, "spi_tegra.5", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-host1x", 0x5000, "host1x", NULL),
+   OF_DEV_AUXDATA("nvidia,tegra30-gr2d", 0x5414, "gr2d", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-dc", 0x5420, "tegradc.0", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-dc", 0x5424, "tegradc.1", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-hdmi", 0x5428, "hdmi", NULL),
diff --git a/arch/arm/mach-tegra/tegra20_clocks_data.c 
b/arch/arm/mach-tegra/tegra20_clocks_data.c
index a23a073..15d440a 100644
--- a/arch/arm/mach-tegra/tegra20_clocks_data.c
+++ b/arch/arm/mach-tegra/tegra20_clocks_data.c
@@ -1041,7 +1041,7 @@ static struct clk_duplicate tegra_clk_duplicates[] = {
CLK_DUPLICATE("usbd",   "utmip-pad",NULL),
CLK_DUPLICATE("usbd",   "tegra-ehci.0", NULL),
CLK_DUPLICATE("usbd",   "tegra-otg",NULL),
-   CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"),
+   CLK_DUPLICATE("2d", "gr2d", "gr2d"),
CLK_DUPLICATE("3d", "tegra_grhost", "gr3d"),
CLK_DUPLICATE("epp","tegra_grhost", "epp"),
CLK_DUPLICATE("mpe","tegra_grhost", "mpe"),
diff --git a/arch/arm/mach-tegra/tegra30_clocks_data.c 
b/arch/arm/mach-tegra/tegra30_clocks_data.c
index 741d264..5c4b7b7 100644
--- a/arch/arm/mach-tegra/tegra30_clocks_data.c
+++ b/arch/arm/mach-tegra/tegra30_clocks_data.c
@@ -1338,6 +1338,7 @@ static struct clk_duplicate tegra_clk_duplicates[] = {
CLK_DUPLICATE("pll_p", "tegradc.0", "parent"),
CLK_DUPLICATE("pll_p", "tegradc.1", "parent"),
CLK_DUPLICATE("pll_d2_out0", "hdmi", "parent"),
+   CLK_DUPLICATE("2d", "gr2d", "gr2d"),
 };

 static struct clk *tegra_ptr_clks[] = {
-- 
1.7.9.5



[PATCHv5,RESEND 6/8] gpu: host1x: Remove second host1x driver

2013-01-15 Thread Terje Bergstrom
Remove second host1x driver, and bind tegra-drm to the new host1x driver. The
logic to parse device tree and track clients is moved to drm.c.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile|2 +-
 drivers/gpu/host1x/dev.c   |   58 +-
 drivers/gpu/host1x/dev.h   |6 +
 drivers/gpu/host1x/drm/Kconfig |2 +-
 drivers/gpu/host1x/drm/dc.c|7 +-
 drivers/gpu/host1x/drm/drm.c   |  213 +++-
 drivers/gpu/host1x/drm/drm.h   |3 -
 drivers/gpu/host1x/drm/hdmi.c  |7 +-
 drivers/gpu/host1x/host1x_client.h |9 ++
 9 files changed, 294 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index ffc8bf1..c35ee19 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -16,6 +16,6 @@ host1x-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
 ccflags-y += -Iinclude/drm
 ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG

-host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o drm/host1x.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o
 host1x-$(CONFIG_DRM_TEGRA) += drm/output.o drm/rgb.o drm/hdmi.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index 5aa7d28..17ee01c 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -28,12 +28,25 @@
 #include "channel.h"
 #include "debug.h"
 #include "hw/host1x01.h"
+#include "host1x_client.h"

 #define CREATE_TRACE_POINTS
 #include 

 #define DRIVER_NAME"tegra-host1x"

+void host1x_set_drm_data(struct platform_device *pdev, void *data)
+{
+   struct host1x *host1x = platform_get_drvdata(pdev);
+   host1x->drm_data = data;
+}
+
+void *host1x_get_drm_data(struct platform_device *pdev)
+{
+   struct host1x *host1x = platform_get_drvdata(pdev);
+   return host1x->drm_data;
+}
+
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
 {
void __iomem *sync_regs = host1x->regs + host1x->info.sync_offset;
@@ -153,6 +166,8 @@ static int host1x_probe(struct platform_device *dev)

host1x_debug_init(host);

+   host1x_drm_alloc(dev);
+
dev_info(&dev->dev, "initialized\n");

return 0;
@@ -173,7 +188,7 @@ static int __exit host1x_remove(struct platform_device *dev)
return 0;
 }

-static struct platform_driver platform_driver = {
+static struct platform_driver tegra_host1x_driver = {
.probe = host1x_probe,
.remove = __exit_p(host1x_remove),
.driver = {
@@ -183,8 +198,47 @@ static struct platform_driver platform_driver = {
},
 };

-module_platform_driver(platform_driver);
+static int __init tegra_host1x_init(void)
+{
+   int err;
+
+   err = platform_driver_register(&tegra_host1x_driver);
+   if (err < 0)
+   return err;
+
+#ifdef CONFIG_TEGRA_DRM
+   err = platform_driver_register(&tegra_dc_driver);
+   if (err < 0)
+   goto unregister_host1x;
+
+   err = platform_driver_register(&tegra_hdmi_driver);
+   if (err < 0)
+   goto unregister_dc;
+#endif
+
+   return 0;
+
+#ifdef CONFIG_TEGRA_DRM
+unregister_dc:
+   platform_driver_unregister(&tegra_dc_driver);
+unregister_host1x:
+   platform_driver_unregister(&tegra_host1x_driver);
+   return err;
+#endif
+}
+module_init(tegra_host1x_init);
+
+static void __exit tegra_host1x_exit(void)
+{
+#ifdef CONFIG_TEGRA_DRM
+   platform_driver_unregister(&tegra_hdmi_driver);
+   platform_driver_unregister(&tegra_dc_driver);
+#endif
+   platform_driver_unregister(&tegra_host1x_driver);
+}
+module_exit(tegra_host1x_exit);

+MODULE_AUTHOR("Thierry Reding ");
 MODULE_AUTHOR("Terje Bergstrom ");
 MODULE_DESCRIPTION("Host1x driver for Tegra products");
 MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index 467a92e..ff3a365 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -142,6 +142,8 @@ struct host1x {
int allocated_channels;

struct dentry *debugfs;
+
+   void *drm_data;
 };

 static inline
@@ -161,4 +163,8 @@ u32 host1x_sync_readl(struct host1x *host1x, u32 r);
 void host1x_ch_writel(struct host1x_channel *ch, u32 r, u32 v);
 u32 host1x_ch_readl(struct host1x_channel *ch, u32 r);

+extern struct platform_driver tegra_hdmi_driver;
+extern struct platform_driver tegra_dc_driver;
+extern struct platform_driver tegra_gr2d_driver;
+
 #endif
diff --git a/drivers/gpu/host1x/drm/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index be1daf7..7db9b3a 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -1,5 +1,5 @@
 config DRM_TEGRA
-   tristate "NVIDIA Tegra DRM"
+   bool "NVIDIA Tegra DRM"
depends on DRM && OF && ARCH_TEGRA
select DRM_KMS_HELPER
select DRM_GEM_CMA_HELPER
diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index 656b2e3..ac31e96 100644
--- a/dr

[PATCHv5,RESEND 5/8] drm: tegra: Move drm to live under host1x

2013-01-15 Thread Terje Bergstrom
Make drm part of host1x driver.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/drm/Kconfig|2 --
 drivers/gpu/drm/Makefile   |1 -
 drivers/gpu/drm/tegra/Makefile |7 ---
 drivers/gpu/host1x/Kconfig |3 +++
 drivers/gpu/host1x/Makefile|6 ++
 drivers/gpu/{drm/tegra => host1x/drm}/Kconfig  |0
 drivers/gpu/{drm/tegra => host1x/drm}/dc.c |0
 drivers/gpu/{drm/tegra => host1x/drm}/dc.h |0
 drivers/gpu/{drm/tegra => host1x/drm}/drm.c|0
 drivers/gpu/{drm/tegra => host1x/drm}/drm.h|6 +++---
 drivers/gpu/{drm/tegra => host1x/drm}/fb.c |0
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c   |0
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h   |0
 drivers/gpu/{drm/tegra => host1x/drm}/host1x.c |0
 drivers/gpu/{drm/tegra => host1x/drm}/output.c |0
 drivers/gpu/{drm/tegra => host1x/drm}/rgb.c|0
 drivers/gpu/host1x/host1x_client.h |   25 
 17 files changed, 37 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/gpu/drm/tegra/Makefile
 rename drivers/gpu/{drm/tegra => host1x/drm}/Kconfig (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/dc.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/dc.h (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/drm.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/drm.h (98%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/fb.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/host1x.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/output.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/rgb.c (100%)
 create mode 100644 drivers/gpu/host1x/host1x_client.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 983201b..18321b68b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -210,5 +210,3 @@ source "drivers/gpu/drm/mgag200/Kconfig"
 source "drivers/gpu/drm/cirrus/Kconfig"

 source "drivers/gpu/drm/shmobile/Kconfig"
-
-source "drivers/gpu/drm/tegra/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 6f58c81..f54c72a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -49,5 +49,4 @@ obj-$(CONFIG_DRM_GMA500) += gma500/
 obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
 obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/
-obj-$(CONFIG_DRM_TEGRA) += tegra/
 obj-y  += i2c/
diff --git a/drivers/gpu/drm/tegra/Makefile b/drivers/gpu/drm/tegra/Makefile
deleted file mode 100644
index 80f73d1..000
--- a/drivers/gpu/drm/tegra/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-ccflags-y := -Iinclude/drm
-ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG
-
-tegra-drm-y := drm.o fb.o dc.o host1x.o
-tegra-drm-y += output.o rgb.o hdmi.o
-
-obj-$(CONFIG_DRM_TEGRA) += tegra-drm.o
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
index 57680a6..558b660 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -1,4 +1,5 @@
 config TEGRA_HOST1X
+   depends on DRM
tristate "Tegra host1x driver"
help
  Driver for the Tegra host1x hardware.
@@ -26,4 +27,6 @@ config TEGRA_HOST1X_FIREWALL

  If unsure, choose Y.

+source "drivers/gpu/host1x/drm/Kconfig"
+
 endif
diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 697d49a..ffc8bf1 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -12,4 +12,10 @@ host1x-y = \
hw/host1x01.o

 host1x-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
+
+ccflags-y += -Iinclude/drm
+ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG
+
+host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o drm/host1x.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/output.o drm/rgb.o drm/hdmi.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/host1x/drm/Kconfig
similarity index 100%
rename from drivers/gpu/drm/tegra/Kconfig
rename to drivers/gpu/host1x/drm/Kconfig
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/host1x/drm/dc.c
similarity index 100%
rename from drivers/gpu/drm/tegra/dc.c
rename to drivers/gpu/host1x/drm/dc.c
diff --git a/drivers/gpu/drm/tegra/dc.h b/drivers/gpu/host1x/drm/dc.h
similarity index 100%
rename from drivers/gpu/drm/tegra/dc.h
rename to drivers/gpu/host1x/drm/dc.h
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/host1x/drm/drm.c
similarity index 100%
rename from drivers/gpu/drm/tegra/drm.c
rename to drivers/gpu/host1x/drm/drm.c
diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/host1x/drm/drm.h
similarity index 98%
rename from drivers/gpu/drm/tegra/drm.h
rename to drivers/gpu/host1x/drm/drm.h
index 741b5dc..e68b4ac 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/host1x/drm/drm.h
@@ -7,8 +7,8 @@
  * published by the Free Software Foundation.
  */

-#

[PATCHv5,RESEND 4/8] gpu: host1x: Add debug support

2013-01-15 Thread Terje Bergstrom
Add support for host1x debugging. Adds debugfs entries, and dumps
channel state to UART in case of stuck job.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile |1 +
 drivers/gpu/host1x/cdma.c   |   34 +++
 drivers/gpu/host1x/debug.c  |  215 ++
 drivers/gpu/host1x/debug.h  |   50 
 drivers/gpu/host1x/dev.c|3 +
 drivers/gpu/host1x/dev.h|   17 ++
 drivers/gpu/host1x/hw/cdma_hw.c |3 +
 drivers/gpu/host1x/hw/debug_hw.c|  400 +++
 drivers/gpu/host1x/hw/host1x01.c|2 +
 drivers/gpu/host1x/hw/hw_host1x01_channel.h |   18 ++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h|  115 
 drivers/gpu/host1x/hw/syncpt_hw.c   |1 +
 drivers/gpu/host1x/syncpt.c |3 +
 13 files changed, 862 insertions(+)
 create mode 100644 drivers/gpu/host1x/debug.c
 create mode 100644 drivers/gpu/host1x/debug.h
 create mode 100644 drivers/gpu/host1x/hw/debug_hw.c

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index cdd87c8..697d49a 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -7,6 +7,7 @@ host1x-y = \
cdma.o \
channel.o \
job.o \
+   debug.o \
memmgr.o \
hw/host1x01.o

diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index d6a38d2..12dd46c 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -19,6 +19,7 @@
 #include "cdma.h"
 #include "channel.h"
 #include "dev.h"
+#include "debug.h"
 #include "memmgr.h"
 #include "job.h"
 #include 
@@ -370,12 +371,42 @@ int host1x_cdma_begin(struct host1x_cdma *cdma, struct 
host1x_job *job)
return 0;
 }

+static void trace_write_gather(struct host1x_cdma *cdma,
+   struct mem_handle *ref,
+   u32 offset, u32 words)
+{
+   void *mem = NULL;
+
+   if (host1x_debug_trace_cmdbuf)
+   mem = host1x_memmgr_mmap(ref);
+
+   if (mem) {
+   u32 i;
+   /*
+* Write in batches of 128 as there seems to be a limit
+* of how much you can output to ftrace at once.
+*/
+   for (i = 0; i < words; i += TRACE_MAX_LENGTH) {
+   trace_host1x_cdma_push_gather(
+   cdma_to_channel(cdma)->dev->name,
+   (u32)ref,
+   min(words - i, TRACE_MAX_LENGTH),
+   offset + i * sizeof(u32),
+   mem);
+   }
+   host1x_memmgr_munmap(ref, mem);
+   }
+}
+
 /*
  * Push two words into a push buffer slot
  * Blocks as necessary if the push buffer is full.
  */
 void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2)
 {
+   if (host1x_debug_trace_cmdbuf)
+   trace_host1x_cdma_push(cdma_to_channel(cdma)->dev->name,
+   op1, op2);
host1x_cdma_push_gather(cdma, NULL, 0, op1, op2);
 }

@@ -391,6 +422,9 @@ void host1x_cdma_push_gather(struct host1x_cdma *cdma,
u32 slots_free = cdma->slots_free;
struct push_buffer *pb = &cdma->push_buffer;

+   if (handle)
+   trace_write_gather(cdma, handle, offset, op1 & 0x);
+
if (slots_free == 0) {
host1x->cdma_op.kick(cdma);
slots_free = host1x_cdma_wait_locked(cdma,
diff --git a/drivers/gpu/host1x/debug.c b/drivers/gpu/host1x/debug.c
new file mode 100644
index 000..29cbe93
--- /dev/null
+++ b/drivers/gpu/host1x/debug.c
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ * Author: Erik Gilling 
+ *
+ * Copyright (C) 2011-2012 NVIDIA Corporation
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "dev.h"
+#include "debug.h"
+#include "channel.h"
+
+static pid_t host1x_debug_null_kickoff_pid;
+unsigned int host1x_debug_trace_cmdbuf;
+
+static pid_t host1x_debug_force_timeout_pid;
+static u32 host1x_debug_force_timeout_val;
+static u32 host1x_debug_force_timeout_channel;
+
+void host1x_debug_output(struct output *o, const char *fmt, ...)
+{
+   va_list args;
+   int len;
+
+   va_start(args, fmt);
+   len = vsnprintf(o->buf, sizeof(o->buf), fmt, args);
+   va_end(args);
+   o->fn(o->ctx, o->buf, len);
+}
+
+static int show_channels(struct host1x_channel *ch, void *data)
+{

[PATCHv5,RESEND 3/8] gpu: host1x: Add channel support

2013-01-15 Thread Terje Bergstrom
Add support for host1x client modules, and host1x channels to submit
work to the clients. The work is submitted in GEM CMA buffers, so
this patch adds support for them.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Kconfig  |   25 +-
 drivers/gpu/host1x/Makefile |5 +
 drivers/gpu/host1x/cdma.c   |  439 +++
 drivers/gpu/host1x/cdma.h   |  107 +
 drivers/gpu/host1x/channel.c|  140 ++
 drivers/gpu/host1x/channel.h|   58 +++
 drivers/gpu/host1x/cma.c|  116 +
 drivers/gpu/host1x/cma.h|   43 ++
 drivers/gpu/host1x/dev.c|   13 +
 drivers/gpu/host1x/dev.h|   59 +++
 drivers/gpu/host1x/host1x.h |   29 ++
 drivers/gpu/host1x/hw/cdma_hw.c |  475 +
 drivers/gpu/host1x/hw/cdma_hw.h |   37 ++
 drivers/gpu/host1x/hw/channel_hw.c  |  148 +++
 drivers/gpu/host1x/hw/host1x01.c|6 +
 drivers/gpu/host1x/hw/host1x01_hardware.h   |  124 ++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h |  102 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h|   12 +
 drivers/gpu/host1x/hw/hw_host1x01_uclass.h  |  168 
 drivers/gpu/host1x/hw/syncpt_hw.c   |   10 +
 drivers/gpu/host1x/intr.c   |   29 +-
 drivers/gpu/host1x/intr.h   |6 +
 drivers/gpu/host1x/job.c|  612 +++
 drivers/gpu/host1x/job.h|  164 +++
 drivers/gpu/host1x/memmgr.c |  173 
 drivers/gpu/host1x/memmgr.h |   72 
 drivers/gpu/host1x/syncpt.c |   11 +
 drivers/gpu/host1x/syncpt.h |4 +
 include/trace/events/host1x.h   |  211 +
 29 files changed, 3396 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/host1x/cdma.c
 create mode 100644 drivers/gpu/host1x/cdma.h
 create mode 100644 drivers/gpu/host1x/channel.c
 create mode 100644 drivers/gpu/host1x/channel.h
 create mode 100644 drivers/gpu/host1x/cma.c
 create mode 100644 drivers/gpu/host1x/cma.h
 create mode 100644 drivers/gpu/host1x/host1x.h
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.h
 create mode 100644 drivers/gpu/host1x/hw/channel_hw.c
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_channel.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_uclass.h
 create mode 100644 drivers/gpu/host1x/job.c
 create mode 100644 drivers/gpu/host1x/job.h
 create mode 100644 drivers/gpu/host1x/memmgr.c
 create mode 100644 drivers/gpu/host1x/memmgr.h

diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
index e89fb2b..57680a6 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -3,4 +3,27 @@ config TEGRA_HOST1X
help
  Driver for the Tegra host1x hardware.

- Required for enabling tegradrm.
+ Required for enabling tegradrm and 2D acceleration.
+
+if TEGRA_HOST1X
+
+config TEGRA_HOST1X_CMA
+   bool "Support DRM CMA buffers"
+   depends on DRM
+   default y
+   select DRM_GEM_CMA_HELPER
+   select DRM_KMS_CMA_HELPER
+   help
+ Say yes if you wish to use DRM CMA buffers.
+
+ If unsure, choose Y.
+
+config TEGRA_HOST1X_FIREWALL
+   bool "Enable HOST1X security firewall"
+   default y
+   help
+ Say yes if kernel should protect command streams from tampering.
+
+ If unsure, choose Y.
+
+endif
diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 5ef47ff..cdd87c8 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -4,6 +4,11 @@ host1x-y = \
syncpt.o \
dev.o \
intr.o \
+   cdma.o \
+   channel.o \
+   job.o \
+   memmgr.o \
hw/host1x01.o

+host1x-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
new file mode 100644
index 000..d6a38d2
--- /dev/null
+++ b/drivers/gpu/host1x/cdma.c
@@ -0,0 +1,439 @@
+/*
+ * Tegra host1x Command DMA
+ *
+ * Copyright (c) 2010-2013, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include "cdma.h"
+#include "channel.h"
+#in

[PATCHv5,RESEND 2/8] gpu: host1x: Add syncpoint wait and interrupts

2013-01-15 Thread Terje Bergstrom
Add support for sync point interrupts, and sync point wait. Sync
point wait used interrupts for unblocking wait.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile  |1 +
 drivers/gpu/host1x/dev.c |   21 +-
 drivers/gpu/host1x/dev.h |   17 +-
 drivers/gpu/host1x/hw/host1x01.c |2 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h |   42 
 drivers/gpu/host1x/hw/intr_hw.c  |  178 +++
 drivers/gpu/host1x/intr.c|  356 ++
 drivers/gpu/host1x/intr.h|  103 +
 drivers/gpu/host1x/syncpt.c  |  163 ++
 drivers/gpu/host1x/syncpt.h  |5 +
 10 files changed, 883 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/host1x/hw/intr_hw.c
 create mode 100644 drivers/gpu/host1x/intr.c
 create mode 100644 drivers/gpu/host1x/intr.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 363e6ab..5ef47ff 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -3,6 +3,7 @@ ccflags-y = -Idrivers/gpu/host1x
 host1x-y = \
syncpt.o \
dev.o \
+   intr.o \
hw/host1x01.o

 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index cd2b1ef..7f9f389 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include "dev.h"
+#include "intr.h"
 #include "hw/host1x01.h"

 #define CREATE_TRACE_POINTS
@@ -95,7 +96,6 @@ static int host1x_probe(struct platform_device *dev)

/* set common host1x device data */
platform_set_drvdata(dev, host);
-
host->regs = devm_request_and_ioremap(&dev->dev, regs);
if (!host->regs) {
dev_err(&dev->dev, "failed to remap host registers\n");
@@ -109,28 +109,40 @@ static int host1x_probe(struct platform_device *dev)
}

err = host1x_syncpt_init(host);
-   if (err)
+   if (err) {
+   dev_err(&dev->dev, "failed to init sync points");
return err;
+   }
+
+   err = host1x_intr_init(&host->intr, syncpt_irq);
+   if (err) {
+   dev_err(&dev->dev, "failed to init irq");
+   goto fail_deinit_syncpt;
+   }

host->clk = devm_clk_get(&dev->dev, NULL);
if (IS_ERR(host->clk)) {
dev_err(&dev->dev, "failed to get clock\n");
err = PTR_ERR(host->clk);
-   goto fail_deinit_syncpt;
+   goto fail_deinit_intr;
}

err = clk_prepare_enable(host->clk);
if (err < 0) {
dev_err(&dev->dev, "failed to enable clock\n");
-   goto fail_deinit_syncpt;
+   goto fail_deinit_intr;
}

host1x_syncpt_reset(host);

+   host1x_intr_start(&host->intr, clk_get_rate(host->clk));
+
dev_info(&dev->dev, "initialized\n");

return 0;

+fail_deinit_intr:
+   host1x_intr_deinit(&host->intr);
 fail_deinit_syncpt:
host1x_syncpt_deinit(host);
return err;
@@ -139,6 +151,7 @@ fail_deinit_syncpt:
 static int __exit host1x_remove(struct platform_device *dev)
 {
struct host1x *host = platform_get_drvdata(dev);
+   host1x_intr_deinit(&host->intr);
host1x_syncpt_deinit(host);
clk_disable_unprepare(host->clk);
return 0;
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index d8f5979..8376092 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -17,11 +17,12 @@
 #ifndef HOST1X_DEV_H
 #define HOST1X_DEV_H

+#include 
 #include "syncpt.h"
+#include "intr.h"

 struct host1x;
 struct host1x_syncpt;
-struct platform_device;

 struct host1x_syncpt_ops {
void (*reset)(struct host1x_syncpt *);
@@ -34,6 +35,18 @@ struct host1x_syncpt_ops {
const char * (*name)(struct host1x_syncpt *);
 };

+struct host1x_intr_ops {
+   void (*init_host_sync)(struct host1x_intr *);
+   void (*set_host_clocks_per_usec)(
+   struct host1x_intr *, u32 clocks);
+   void (*set_syncpt_threshold)(
+   struct host1x_intr *, u32 id, u32 thresh);
+   void (*enable_syncpt_intr)(struct host1x_intr *, u32 id);
+   void (*disable_syncpt_intr)(struct host1x_intr *, u32 id);
+   void (*disable_all_syncpt_intrs)(struct host1x_intr *);
+   int (*free_syncpt_irq)(struct host1x_intr *);
+};
+
 struct host1x_device_info {
int nb_channels;/* host1x: num channels supported */
int nb_pts; /* host1x: num syncpoints supported */
@@ -46,11 +59,13 @@ struct host1x_device_info {
 struct host1x {
void __iomem *regs;
struct host1x_syncpt *syncpt;
+   struct host1x_intr intr;
struct platform_device *dev;
struct host1x_device_info info;
struct clk *clk;

struct host1x_syncpt_ops syncpt_op;
+   str

[PATCHv5,RESEND 1/8] gpu: host1x: Add host1x driver

2013-01-15 Thread Terje Bergstrom
Add host1x, the driver for host1x and its client unit 2D.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/Makefile  |1 +
 drivers/gpu/host1x/Kconfig|6 +
 drivers/gpu/host1x/Makefile   |8 ++
 drivers/gpu/host1x/dev.c  |  161 +
 drivers/gpu/host1x/dev.h  |   73 ++
 drivers/gpu/host1x/hw/Makefile|6 +
 drivers/gpu/host1x/hw/host1x01.c  |   35 +
 drivers/gpu/host1x/hw/host1x01.h  |   25 
 drivers/gpu/host1x/hw/host1x01_hardware.h |   26 
 drivers/gpu/host1x/hw/hw_host1x01_sync.h  |   72 ++
 drivers/gpu/host1x/hw/syncpt_hw.c |  146 +++
 drivers/gpu/host1x/syncpt.c   |  217 +
 drivers/gpu/host1x/syncpt.h   |  153 
 drivers/video/Kconfig |2 +
 include/trace/events/host1x.h |   61 
 15 files changed, 992 insertions(+)
 create mode 100644 drivers/gpu/host1x/Kconfig
 create mode 100644 drivers/gpu/host1x/Makefile
 create mode 100644 drivers/gpu/host1x/dev.c
 create mode 100644 drivers/gpu/host1x/dev.h
 create mode 100644 drivers/gpu/host1x/hw/Makefile
 create mode 100644 drivers/gpu/host1x/hw/host1x01.c
 create mode 100644 drivers/gpu/host1x/hw/host1x01.h
 create mode 100644 drivers/gpu/host1x/hw/host1x01_hardware.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_sync.h
 create mode 100644 drivers/gpu/host1x/hw/syncpt_hw.c
 create mode 100644 drivers/gpu/host1x/syncpt.c
 create mode 100644 drivers/gpu/host1x/syncpt.h
 create mode 100644 include/trace/events/host1x.h

diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index cc92778..7e227097 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1 +1,2 @@
 obj-y  += drm/ vga/ stub/
+obj-$(CONFIG_TEGRA_HOST1X) += host1x/
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
new file mode 100644
index 000..e89fb2b
--- /dev/null
+++ b/drivers/gpu/host1x/Kconfig
@@ -0,0 +1,6 @@
+config TEGRA_HOST1X
+   tristate "Tegra host1x driver"
+   help
+ Driver for the Tegra host1x hardware.
+
+ Required for enabling tegradrm.
diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
new file mode 100644
index 000..363e6ab
--- /dev/null
+++ b/drivers/gpu/host1x/Makefile
@@ -0,0 +1,8 @@
+ccflags-y = -Idrivers/gpu/host1x
+
+host1x-y = \
+   syncpt.o \
+   dev.o \
+   hw/host1x01.o
+
+obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
new file mode 100644
index 000..cd2b1ef
--- /dev/null
+++ b/drivers/gpu/host1x/dev.c
@@ -0,0 +1,161 @@
+/*
+ * Tegra host1x driver
+ *
+ * Copyright (c) 2010-2013, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "dev.h"
+#include "hw/host1x01.h"
+
+#define CREATE_TRACE_POINTS
+#include 
+
+#define DRIVER_NAME"tegra-host1x"
+
+void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
+{
+   void __iomem *sync_regs = host1x->regs + host1x->info.sync_offset;
+
+   writel(v, sync_regs + r);
+}
+
+u32 host1x_sync_readl(struct host1x *host1x, u32 r)
+{
+   void __iomem *sync_regs = host1x->regs + host1x->info.sync_offset;
+
+   return readl(sync_regs + r);
+}
+
+static struct host1x_device_info host1x_info = {
+   .nb_channels= 8,
+   .nb_pts = 32,
+   .nb_mlocks  = 16,
+   .nb_bases   = 8,
+   .init   = host1x01_init,
+   .sync_offset= 0x3000,
+};
+
+static struct of_device_id host1x_match[] = {
+   { .compatible = "nvidia,tegra30-host1x", .data = &host1x_info, },
+   { .compatible = "nvidia,tegra20-host1x", .data = &host1x_info, },
+   { },
+};
+
+static int host1x_probe(struct platform_device *dev)
+{
+   struct host1x *host;
+   struct resource *regs;
+   int syncpt_irq;
+   int err;
+   const struct of_device_id *devid =
+   of_match_device(host1x_match, &dev->dev);
+
+   if (!devid)
+   return -EINVAL;
+
+   regs = platform_get_resource(dev, IORESOURCE_MEM, 0);
+   if (!regs) {
+   dev_err(&dev->dev, "missing regs\n");
+   return -ENXIO;
+

[PATCHv5,RESEND 0/8] Support for Tegra 2D hardware

2013-01-15 Thread Terje Bergstrom
This set of patches adds support for Tegra20 and Tegra30 host1x and
2D. It is based on linux-next-20130114. The set was regenerated with
git format-patch -M.

The fifth version merges DRM and host1x drivers into one driver. This
allowed moving include/linux/host1x.h back into the driver and removed
the need for a dummy platform device. This version also uses the code
from tegradrm driver almost as is, so there are a lot less actual code
changes.

This patch set does not have the host1x allocator, but it uses CMA
helpers for memory management.

host1x is the driver that controls host1x hardware. It supports
host1x command channels, synchronization, and memory management. It
is sectioned into logical driver under drivers/gpu/host1x and
physical driver under drivers/host1x/hw. The physical driver is
compiled with the hardware headers of the particular host1x version.

The hardware units are described (briefly) in the Tegra2 TRM. Wiki
page https://gitorious.org/linux-tegra-drm/pages/Host1xIntroduction
also contains a short description of the functionality.

The patch set merges tegradrm into host1x and adds 2D driver, which
uses host1x channels and sync points. The patch set also adds user
space API to tegradrm for accessing host1x and 2D.


Terje Bergstrom (8):
  gpu: host1x: Add host1x driver
  gpu: host1x: Add syncpoint wait and interrupts
  gpu: host1x: Add channel support
  gpu: host1x: Add debug support
  drm: tegra: Move drm to live under host1x
  gpu: host1x: Remove second host1x driver
  ARM: tegra: Add board data and 2D clocks
  drm: tegra: Add gr2d device

 arch/arm/mach-tegra/board-dt-tegra20.c |1 +
 arch/arm/mach-tegra/board-dt-tegra30.c |1 +
 arch/arm/mach-tegra/tegra20_clocks_data.c  |2 +-
 arch/arm/mach-tegra/tegra30_clocks_data.c  |1 +
 drivers/gpu/Makefile   |1 +
 drivers/gpu/drm/Kconfig|2 -
 drivers/gpu/drm/Makefile   |1 -
 drivers/gpu/drm/tegra/Makefile |7 -
 drivers/gpu/drm/tegra/drm.c|  115 -
 drivers/gpu/host1x/Kconfig |   32 ++
 drivers/gpu/host1x/Makefile|   22 +
 drivers/gpu/host1x/cdma.c  |  473 ++
 drivers/gpu/host1x/cdma.h  |  107 +
 drivers/gpu/host1x/channel.c   |  140 ++
 drivers/gpu/host1x/channel.h   |   58 +++
 drivers/gpu/host1x/cma.c   |  116 +
 drivers/gpu/host1x/cma.h   |   43 ++
 drivers/gpu/host1x/debug.c |  215 +
 drivers/gpu/host1x/debug.h |   50 ++
 drivers/gpu/host1x/dev.c   |  251 ++
 drivers/gpu/host1x/dev.h   |  170 +++
 drivers/gpu/{drm/tegra => host1x/drm}/Kconfig  |2 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.c |7 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.h |0
 drivers/gpu/host1x/drm/drm.c   |  548 +
 drivers/gpu/{drm/tegra => host1x/drm}/drm.h|   37 +-
 drivers/gpu/{drm/tegra => host1x/drm}/fb.c |0
 drivers/gpu/host1x/drm/gr2d.c  |  325 +
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c   |7 +-
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h   |0
 drivers/gpu/{drm/tegra => host1x/drm}/host1x.c |0
 drivers/gpu/{drm/tegra => host1x/drm}/output.c |0
 drivers/gpu/{drm/tegra => host1x/drm}/rgb.c|0
 drivers/gpu/host1x/host1x.h|   29 ++
 drivers/gpu/host1x/host1x_client.h |   34 ++
 drivers/gpu/host1x/hw/Makefile |6 +
 drivers/gpu/host1x/hw/cdma_hw.c|  478 ++
 drivers/gpu/host1x/hw/cdma_hw.h|   37 ++
 drivers/gpu/host1x/hw/channel_hw.c |  148 ++
 drivers/gpu/host1x/hw/debug_hw.c   |  400 
 drivers/gpu/host1x/hw/host1x01.c   |   45 ++
 drivers/gpu/host1x/hw/host1x01.h   |   25 +
 drivers/gpu/host1x/hw/host1x01_hardware.h  |  150 ++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h|  120 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h   |  241 ++
 drivers/gpu/host1x/hw/hw_host1x01_uclass.h |  168 +++
 drivers/gpu/host1x/hw/intr_hw.c|  178 +++
 drivers/gpu/host1x/hw/syncpt_hw.c  |  157 ++
 drivers/gpu/host1x/intr.c  |  383 +++
 drivers/gpu/host1x/intr.h  |  109 +
 drivers/gpu/host1x/job.c   |  612 
 drivers/gpu/host1x/job.h   |  164 +++
 drivers/gpu/host1x/memmgr.c|  173 +++
 drivers/gpu/host1x/memmgr.h|   72 +++
 drivers/gpu/host1x/syncpt.c|  399 +++
 drivers/gpu/host1x/syncpt.h  

[RFC v2 6/8] gpu: drm: tegra: Remove redundant host1x

2013-01-15 Thread Terje Bergström
On 15.01.2013 13:30, Thierry Reding wrote:
> Sorry for not getting back to you on this earlier. I just remembered
> this thread when I saw Terje's latest patch series.
> 
> I agree that having everything in one location will make things a lot
> easier, even if it means we have to add the tegra-drm driver to a new
> location. In the long run I think this will pay off, though.
> 
> That said, I see that Terje has chosen this approach in his latest
> series, so it's all good.

*whew* Thanks Thierry. I'm not entirely sure that drivers/gpu/host1x is
the correct location, though - host1x looks pretty lonely there. If
anybody has a strong opinion about the location, I'm willing to adjust.

Terje


[Bug 30151] HDMI audio via radeon DRM driver is not working.

2013-01-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=30151

mtz...@yahoo.fr changed:

   What|Removed |Added

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

--- Comment #7 from mtz...@yahoo.fr ---
Everything works fine now on Rosa. Certainly an update yesterday and today on
this young distro (because I've had several) which resolved a conflict. So,
this system approaches perfection. My best linux distro I installed on my PC!
Bug resolved ! I'm sorry for the soliciting caused by this digging out bug, but
thank you for the time you have given me for his resolution.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 2/5] drm/tegra: Add plane support

2013-01-15 Thread Ville Syrjälä
On Tue, Jan 15, 2013 at 05:53:03PM +0800, Mark Zhang wrote:
> On 01/15/2013 12:05 AM, Thierry Reding wrote:
> > Add support for the B and C planes which support RGB and YUV pixel
> > formats and can be used as overlays or hardware cursor.
> 
> I think "hardware cursor" has specific meaning for Tegra(e.g: Tegra30
> has a 32x32 24bpp or 64x64 2bpp hardware cursor). So you may change it
> to "hardware accelerated cursor"?
> 
> > 
> > Signed-off-by: Thierry Reding 
> > ---
> [...]
> > +
> > +static const uint32_t plane_formats[] = {
> > +   DRM_FORMAT_XRGB,
> > +   DRM_FORMAT_YUV422,
> 
> I haven't found something related with YUV format in this patch set. For
> example, "tegra_dc_format" also doesn't take YUV into consideration. So
> remove this line.

Also note that YUV422 is a planar format. And since it's not the most
common 4:2:2 format, my first guess would be that it's probably not
what you wanted. YUYV or UYVY is more likely the one you're after.

-- 
Ville Syrj?l?
Intel OTC


[PATCH 7/7] reservation: Add lockdep annotation and selftests

2013-01-15 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 

---

The self-tests will fail if the commit "lockdep: Check if nested
lock is actually held" from linux tip core/locking is not applied.
---
 lib/Kconfig.debug  |   1 +
 lib/locking-selftest.c | 385 ++---
 2 files changed, 367 insertions(+), 19 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 67604e5..017bcea 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -716,6 +716,7 @@ config DEBUG_ATOMIC_SLEEP
 config DEBUG_LOCKING_API_SELFTESTS
bool "Locking API boot-time self-tests"
depends on DEBUG_KERNEL
+   select CONFIG_DMA_SHARED_BUFFER
help
  Say Y here if you want the kernel to run a short self-test during
  bootup. The self-test checks whether common types of locking bugs
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 7aae0f2..7fe22c2 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 

 /*
  * Change this to 1 if you want to see the failure printouts:
@@ -42,6 +43,7 @@ __setup("debug_locks_verbose=", setup_debug_locks_verbose);
 #define LOCKTYPE_RWLOCK0x2
 #define LOCKTYPE_MUTEX 0x4
 #define LOCKTYPE_RWSEM 0x8
+#define LOCKTYPE_RESERVATION   0x10

 /*
  * Normal standalone locks, for the circular and irq-context
@@ -920,11 +922,17 @@ GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion_soft)
 static void reset_locks(void)
 {
local_irq_disable();
+   lockdep_free_key_range(&reservation_object_class, 1);
+   lockdep_free_key_range(&reservation_ticket_class, 1);
+
I1(A); I1(B); I1(C); I1(D);
I1(X1); I1(X2); I1(Y1); I1(Y2); I1(Z1); I1(Z2);
lockdep_reset();
I2(A); I2(B); I2(C); I2(D);
init_shared_classes();
+
+   memset(&reservation_object_class, 0, sizeof reservation_object_class);
+   memset(&reservation_ticket_class, 0, sizeof reservation_ticket_class);
local_irq_enable();
 }

@@ -938,7 +946,6 @@ static int unexpected_testcase_failures;
 static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
 {
unsigned long saved_preempt_count = preempt_count();
-   int expected_failure = 0;

WARN_ON(irqs_disabled());

@@ -946,26 +953,16 @@ static void dotest(void (*testcase_fn)(void), int 
expected, int lockclass_mask)
/*
 * Filter out expected failures:
 */
+   if (debug_locks != expected) {
 #ifndef CONFIG_PROVE_LOCKING
-   if ((lockclass_mask & LOCKTYPE_SPIN) && debug_locks != expected)
-   expected_failure = 1;
-   if ((lockclass_mask & LOCKTYPE_RWLOCK) && debug_locks != expected)
-   expected_failure = 1;
-   if ((lockclass_mask & LOCKTYPE_MUTEX) && debug_locks != expected)
-   expected_failure = 1;
-   if ((lockclass_mask & LOCKTYPE_RWSEM) && debug_locks != expected)
-   expected_failure = 1;
+   expected_testcase_failures++;
+   printk("failed|");
+#else
+   unexpected_testcase_failures++;
+   printk("FAILED|");
+
+   dump_stack();
 #endif
-   if (debug_locks != expected) {
-   if (expected_failure) {
-   expected_testcase_failures++;
-   printk("failed|");
-   } else {
-   unexpected_testcase_failures++;
-
-   printk("FAILED|");
-   dump_stack();
-   }
} else {
testcase_successes++;
printk("  ok  |");
@@ -1108,6 +1105,354 @@ static inline void print_testname(const char *testname)
DO_TESTCASE_6IRW(desc, name, 312);  \
DO_TESTCASE_6IRW(desc, name, 321);

+static void reservation_test_fail_reserve(void)
+{
+   struct reservation_ticket t;
+   struct reservation_object o;
+   int ret;
+
+   reservation_object_init(&o);
+   reservation_ticket_init(&t);
+   t.seqno++;
+
+   ret = mutex_reserve_lock(&o.lock, &t, t.seqno);
+
+   BUG_ON(!atomic_long_read(&o.lock.reservation_id));
+
+   /* No lockdep test, pure API */
+   ret = mutex_reserve_lock(&o.lock, &t, t.seqno);
+   WARN_ON(ret != -EDEADLK);
+
+   t.seqno++;
+   ret = mutex_trylock(&o.lock.base);
+   WARN_ON(ret);
+
+   ret = mutex_reserve_lock(&o.lock, &t, t.seqno);
+   WARN_ON(ret != -EAGAIN);
+   mutex_unlock(&o.lock.base);
+
+   if (mutex_trylock(&o.lock.base))
+   mutex_unlock(&o.lock.base);
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+   else DEBUG_LOCKS_WARN_ON(1);
+#endif
+
+   reservation_ticket_fini(&t);
+}
+
+static void reservation_test_two_tickets(void)
+{
+   struct reservation_ticket t, t2;
+
+   reservation_ticket_init(&t);
+   reservation_ticket_init(&t2);
+
+   reservation_ticket_fini(&t2);
+   reservation_ticket_fini(&t);

[PATCH 6/7] reservation: cross-device reservation support

2013-01-15 Thread Maarten Lankhorst
This adds support for a generic reservations framework that can be
hooked up to ttm and dma-buf and allows easy sharing of reservations
across devices.

The idea is that a dma-buf and ttm object both will get a pointer
to a struct reservation_object, which has to be reserved before
anything is done with the contents of the dma-buf.

Signed-off-by: Maarten Lankhorst 
---
 Documentation/DocBook/device-drivers.tmpl |   2 +
 drivers/base/Makefile |   2 +-
 drivers/base/reservation.c| 251 ++
 include/linux/reservation.h   | 182 ++
 4 files changed, 436 insertions(+), 1 deletion(-)
 create mode 100644 drivers/base/reservation.c
 create mode 100644 include/linux/reservation.h

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index ad14396..24e6e80 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -129,6 +129,8 @@ X!Edrivers/base/interface.c
 !Edrivers/base/fence.c
 !Iinclude/linux/fence.h
 !Iinclude/linux/seqno-fence.h
+!Edrivers/base/reservation.c
+!Iinclude/linux/reservation.h
 !Edrivers/base/dma-coherent.c
 !Edrivers/base/dma-mapping.c
  
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 0026563..f6f731d 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_CMA) += dma-contiguous.o
 obj-y  += power/
 obj-$(CONFIG_HAS_DMA)  += dma-mapping.o
 obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
-obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o fence.o
+obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o fence.o reservation.o
 obj-$(CONFIG_ISA)  += isa.o
 obj-$(CONFIG_FW_LOADER)+= firmware_class.o
 obj-$(CONFIG_NUMA) += node.o
diff --git a/drivers/base/reservation.c b/drivers/base/reservation.c
new file mode 100644
index 000..07584dd
--- /dev/null
+++ b/drivers/base/reservation.c
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2012 Canonical Ltd
+ *
+ * Based on bo.c which bears the following copyright notice,
+ * but is dual licensed:
+ *
+ * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **/
+/*
+ * Authors: Thomas Hellstrom 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+atomic_long_t reservation_counter = ATOMIC_LONG_INIT(1);
+EXPORT_SYMBOL(reservation_counter);
+
+const char reservation_object_name[] = "reservation_object";
+EXPORT_SYMBOL(reservation_object_name);
+
+const char reservation_ticket_name[] = "reservation_ticket";
+EXPORT_SYMBOL(reservation_ticket_name);
+
+struct lock_class_key reservation_object_class;
+EXPORT_SYMBOL(reservation_object_class);
+
+struct lock_class_key reservation_ticket_class;
+EXPORT_SYMBOL(reservation_ticket_class);
+
+/**
+ * ticket_backoff - cancel a reservation
+ * @ticket:[in] a reservation_ticket
+ * @entries:   [in] the list list of reservation_entry entries to unreserve
+ *
+ * This function cancels a previous reservation done by
+ * ticket_reserve. This is useful in case something
+ * goes wrong between reservation and committing.
+ *
+ * This should only be called after ticket_reserve returns success.
+ */
+void
+ticket_backoff(struct reservation_ticket *ticket, struct list_head *entries)
+{
+   struct list_head *cur;
+
+   if (list_empty(entries))
+   return;
+
+   list_for_each(cur, entries) {
+   struct reservation_object *obj;
+
+   reservation_entry_get(cur, &obj, NULL);
+
+   mutex_unreserve_unlock(&obj->lock);
+   }
+   reservation_ticket_fini(ticket);
+}
+EXPORT_SYMBOL(ticket_backoff);
+
+static void
+ticket_backoff_early(struct list_head *list, str

[PATCH 5/7] seqno-fence: Hardware dma-buf implementation of fencing (v4)

2013-01-15 Thread Maarten Lankhorst
This type of fence can be used with hardware synchronization for simple
hardware that can block execution until the condition
(dma_buf[offset] - value) >= 0 has been met.

A software fallback still has to be provided in case the fence is used
with a device that doesn't support this mechanism. It is useful to expose
this for graphics cards that have an op to support this.

Some cards like i915 can export those, but don't have an option to wait,
so they need the software fallback.

I extended the original patch by Rob Clark.

v1: Original
v2: Renamed from bikeshed to seqno, moved into dma-fence.c since
not much was left of the file. Lots of documentation added.
v3: Use fence_ops instead of custom callbacks. Moved to own file
to avoid circular dependency between dma-buf.h and fence.h
v4: Add spinlock pointer to seqno_fence_init

Signed-off-by: Maarten Lankhorst 
---
 Documentation/DocBook/device-drivers.tmpl |   1 +
 drivers/base/fence.c  |  38 +++
 include/linux/seqno-fence.h   | 105 ++
 3 files changed, 144 insertions(+)
 create mode 100644 include/linux/seqno-fence.h

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index 6f53fc0..ad14396 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -128,6 +128,7 @@ X!Edrivers/base/interface.c
 !Edrivers/base/dma-buf.c
 !Edrivers/base/fence.c
 !Iinclude/linux/fence.h
+!Iinclude/linux/seqno-fence.h
 !Edrivers/base/dma-coherent.c
 !Edrivers/base/dma-mapping.c
  
diff --git a/drivers/base/fence.c b/drivers/base/fence.c
index 28e5ffd..1d3f29c 100644
--- a/drivers/base/fence.c
+++ b/drivers/base/fence.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 

 atomic_t fence_context_counter = ATOMIC_INIT(0);
 EXPORT_SYMBOL(fence_context_counter);
@@ -284,3 +285,40 @@ out:
return ret;
 }
 EXPORT_SYMBOL(fence_default_wait);
+
+static bool seqno_enable_signaling(struct fence *fence)
+{
+   struct seqno_fence *seqno_fence = to_seqno_fence(fence);
+   return seqno_fence->ops->enable_signaling(fence);
+}
+
+static bool seqno_signaled(struct fence *fence)
+{
+   struct seqno_fence *seqno_fence = to_seqno_fence(fence);
+   return seqno_fence->ops->signaled && seqno_fence->ops->signaled(fence);
+}
+
+static void seqno_release(struct fence *fence)
+{
+   struct seqno_fence *f = to_seqno_fence(fence);
+
+   dma_buf_put(f->sync_buf);
+   if (f->ops->release)
+   f->ops->release(fence);
+   else
+   kfree(f);
+}
+
+static long seqno_wait(struct fence *fence, bool intr, signed long timeout)
+{
+   struct seqno_fence *f = to_seqno_fence(fence);
+   return f->ops->wait(fence, intr, timeout);
+}
+
+const struct fence_ops seqno_fence_ops = {
+   .enable_signaling = seqno_enable_signaling,
+   .signaled = seqno_signaled,
+   .wait = seqno_wait,
+   .release = seqno_release
+};
+EXPORT_SYMBOL_GPL(seqno_fence_ops);
diff --git a/include/linux/seqno-fence.h b/include/linux/seqno-fence.h
new file mode 100644
index 000..603adc0
--- /dev/null
+++ b/include/linux/seqno-fence.h
@@ -0,0 +1,105 @@
+/*
+ * seqno-fence, using a dma-buf to synchronize fencing
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Copyright (C) 2012 Canonical Ltd
+ * Authors:
+ *   Rob Clark 
+ *   Maarten Lankhorst 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+#ifndef __LINUX_SEQNO_FENCE_H
+#define __LINUX_SEQNO_FENCE_H
+
+#include 
+#include 
+
+struct seqno_fence {
+   struct fence base;
+
+   const struct fence_ops *ops;
+   struct dma_buf *sync_buf;
+   uint32_t seqno_ofs;
+};
+
+extern const struct fence_ops seqno_fence_ops;
+
+/**
+ * to_seqno_fence - cast a fence to a seqno_fence
+ * @fence: fence to cast to a seqno_fence
+ *
+ * Returns NULL if the fence is not a seqno_fence,
+ * or the seqno_fence otherwise.
+ */
+static inline struct seqno_fence *
+to_seqno_fence(struct fence *fence)
+{
+   if (fence->ops != &seqno_fence_ops)
+   return NULL;
+   return container_of(fence, struct seqno_fence, base);
+}
+
+/**
+ * seqno_fence_init - initialize a seqno fence
+ * @fence: seqno_fence to initialize
+ * @lock: pointer to spinlock to use for fence
+ * @sync_buf: buffer containing the memory location to signal on
+ * @context: the execution context this fence is 

[PATCH 4/7] fence: dma-buf cross-device synchronization (v11)

2013-01-15 Thread Maarten Lankhorst
A fence can be attached to a buffer which is being filled or consumed
by hw, to allow userspace to pass the buffer without waiting to another
device.  For example, userspace can call page_flip ioctl to display the
next frame of graphics after kicking the GPU but while the GPU is still
rendering.  The display device sharing the buffer with the GPU would
attach a callback to get notified when the GPU's rendering-complete IRQ
fires, to update the scan-out address of the display, without having to
wake up userspace.

A driver must allocate a fence context for each execution ring that can
run in parallel. The function for this takes an argument with how many
contexts to allocate:
  + fence_context_alloc()

A fence is transient, one-shot deal.  It is allocated and attached
to one or more dma-buf's.  When the one that attached it is done, with
the pending operation, it can signal the fence:
  + fence_signal()

To have a rough approximation whether a fence is fired, call:
  + fence_is_signaled()

The dma-buf-mgr handles tracking, and waiting on, the fences associated
with a dma-buf.

The one pending on the fence can add an async callback:
  + fence_add_callback()

The callback can optionally be cancelled with:
  + fence_remove_callback()

To wait synchronously, optionally with a timeout:
  + fence_wait()
  + fence_wait_timeout()

A default software-only implementation is provided, which can be used
by drivers attaching a fence to a buffer when they have no other means
for hw sync.  But a memory backed fence is also envisioned, because it
is common that GPU's can write to, or poll on some memory location for
synchronization.  For example:

  fence = custom_get_fence(...);
  if ((seqno_fence = to_seqno_fence(fence)) != NULL) {
dma_buf *fence_buf = fence->sync_buf;
get_dma_buf(fence_buf);

... tell the hw the memory location to wait ...
custom_wait_on(fence_buf, fence->seqno_ofs, fence->seqno);
  } else {
/* fall-back to sw sync * /
fence_add_callback(fence, my_cb);
  }

On SoC platforms, if some other hw mechanism is provided for synchronizing
between IP blocks, it could be supported as an alternate implementation
with it's own fence ops in a similar way.

enable_signaling callback is used to provide sw signaling in case a cpu
waiter is requested or no compatible hardware signaling could be used.

The intention is to provide a userspace interface (presumably via eventfd)
later, to be used in conjunction with dma-buf's mmap support for sw access
to buffers (or for userspace apps that would prefer to do their own
synchronization).

v1: Original
v2: After discussion w/ danvet and mlankhorst on #dri-devel, we decided
that dma-fence didn't need to care about the sw->hw signaling path
(it can be handled same as sw->sw case), and therefore the fence->ops
can be simplified and more handled in the core.  So remove the signal,
add_callback, cancel_callback, and wait ops, and replace with a simple
enable_signaling() op which can be used to inform a fence supporting
hw->hw signaling that one or more devices which do not support hw
signaling are waiting (and therefore it should enable an irq or do
whatever is necessary in order that the CPU is notified when the
fence is passed).
v3: Fix locking fail in attach_fence() and get_fence()
v4: Remove tie-in w/ dma-buf..  after discussion w/ danvet and mlankorst
we decided that we need to be able to attach one fence to N dma-buf's,
so using the list_head in dma-fence struct would be problematic.
v5: [ Maarten Lankhorst ] Updated for dma-bikeshed-fence and dma-buf-manager.
v6: [ Maarten Lankhorst ] I removed dma_fence_cancel_callback and some comments
about checking if fence fired or not. This is broken by design.
waitqueue_active during destruction is now fatal, since the signaller
should be holding a reference in enable_signalling until it signalled
the fence. Pass the original dma_fence_cb along, and call __remove_wait
in the dma_fence_callback handler, so that no cleanup needs to be
performed.
v7: [ Maarten Lankhorst ] Set cb->func and only enable sw signaling if
fence wasn't signaled yet, for example for hardware fences that may
choose to signal blindly.
v8: [ Maarten Lankhorst ] Tons of tiny fixes, moved __dma_fence_init to
header and fixed include mess. dma-fence.h now includes dma-buf.h
All members are now initialized, so kmalloc can be used for
allocating a dma-fence. More documentation added.
v9: Change compiler bitfields to flags, change return type of
enable_signaling to bool. Rework dma_fence_wait. Added
dma_fence_is_signaled and dma_fence_wait_timeout.
s/dma// and change exports to non GPL. Added fence_is_signaled and
fence_enable_sw_signaling calls, add ability to override default
wait operation.
v10: remove event_queue, use a custom list, export try_to_wake_up from
scheduler. Remove fence lock and use a global spinlock instead,
this s

[PATCH 3/7] sched: allow try_to_wake_up to be used internally outside of core.c

2013-01-15 Thread Maarten Lankhorst
Not exported, since only used by the fence implementation.

Signed-off-by: Maarten Lankhorst 
---
 include/linux/wait.h | 1 +
 kernel/sched/core.c  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 7cb64d4..7aaba95 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -11,6 +11,7 @@
 typedef struct __wait_queue wait_queue_t;
 typedef int (*wait_queue_func_t)(wait_queue_t *wait, unsigned mode, int flags, 
void *key);
 int default_wake_function(wait_queue_t *wait, unsigned mode, int flags, void 
*key);
+int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags);

 struct __wait_queue {
unsigned int flags;
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 257002c..5f23fe3 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1425,7 +1425,7 @@ static void ttwu_queue(struct task_struct *p, int cpu)
  * Returns %true if @p was woken up, %false if it was already running
  * or @state didn't match @p's state.
  */
-static int
+int
 try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
 {
unsigned long flags;
-- 
1.8.0.3



[PATCH 2/7] mutex: add support for reservation style locks

2013-01-15 Thread Maarten Lankhorst
makes it easier to port ttm over..

Signed-off-by: Maarten Lankhorst 
---
 include/linux/mutex.h |  86 +-
 kernel/mutex.c| 317 +++---
 2 files changed, 387 insertions(+), 16 deletions(-)

diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index 9121595..602c247 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -62,6 +62,11 @@ struct mutex {
 #endif
 };

+struct ticket_mutex {
+   struct mutex base;
+   atomic_long_t reservation_id;
+};
+
 /*
  * This is the control structure for tasks blocked on mutex,
  * which resides on the blocked task's kernel stack:
@@ -109,12 +114,24 @@ static inline void mutex_destroy(struct mutex *lock) {}
__DEBUG_MUTEX_INITIALIZER(lockname) \
__DEP_MAP_MUTEX_INITIALIZER(lockname) }

+#define __TICKET_MUTEX_INITIALIZER(lockname) \
+   { .base = __MUTEX_INITIALIZER(lockname) \
+   , .reservation_id = ATOMIC_LONG_INIT(0) }
+
 #define DEFINE_MUTEX(mutexname) \
struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)

 extern void __mutex_init(struct mutex *lock, const char *name,
 struct lock_class_key *key);

+static inline void __ticket_mutex_init(struct ticket_mutex *lock,
+  const char *name,
+  struct lock_class_key *key)
+{
+   __mutex_init(&lock->base, name, key);
+   atomic_long_set(&lock->reservation_id, 0);
+}
+
 /**
  * mutex_is_locked - is the mutex locked
  * @lock: the mutex to be queried
@@ -133,26 +150,91 @@ static inline int mutex_is_locked(struct mutex *lock)
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
 extern void _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map 
*nest_lock);
+
 extern int __must_check mutex_lock_interruptible_nested(struct mutex *lock,
unsigned int subclass);
 extern int __must_check mutex_lock_killable_nested(struct mutex *lock,
unsigned int subclass);

+extern int __must_check _mutex_reserve_lock(struct ticket_mutex *lock,
+   struct lockdep_map *nest_lock,
+   unsigned long reservation_id);
+
+extern int __must_check _mutex_reserve_lock_interruptible(struct ticket_mutex 
*,
+   struct lockdep_map *nest_lock,
+   unsigned long reservation_id);
+
+extern void _mutex_reserve_lock_slow(struct ticket_mutex *lock,
+struct lockdep_map *nest_lock,
+unsigned long reservation_id);
+
+extern int __must_check _mutex_reserve_lock_intr_slow(struct ticket_mutex *,
+   struct lockdep_map *nest_lock,
+   unsigned long reservation_id);
+
 #define mutex_lock(lock) mutex_lock_nested(lock, 0)
 #define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(lock, 0)
 #define mutex_lock_killable(lock) mutex_lock_killable_nested(lock, 0)

 #define mutex_lock_nest_lock(lock, nest_lock)  \
 do {   \
-   typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
+   typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
_mutex_lock_nest_lock(lock, &(nest_lock)->dep_map); \
 } while (0)

+#define mutex_reserve_lock(lock, nest_lock, reservation_id)\
+({ \
+   typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
+   _mutex_reserve_lock(lock, &(nest_lock)->dep_map, reservation_id);   
\
+})
+
+#define mutex_reserve_lock_interruptible(lock, nest_lock, reservation_id)  
\
+({ \
+   typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
+   _mutex_reserve_lock_interruptible(lock, &(nest_lock)->dep_map,  \
+  reservation_id); \
+})
+
+#define mutex_reserve_lock_slow(lock, nest_lock, reservation_id)   \
+do {   \
+   typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
+   _mutex_reserve_lock_slow(lock, &(nest_lock)->dep_map, reservation_id);  
\
+} while (0)
+
+#define mutex_reserve_lock_intr_slow(lock, nest_lock, reservation_id)  \
+({ \
+   typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
+   _mutex_reserve_lock_intr_slow(lock, &(nest_lock)->dep_map,  \
+ reservation_id);  \
+})
+
 #else
 extern void mutex_lo

[PATCH 1/7] arch: add __mutex_fastpath_lock_retval_arg to generic/sh/x86/powerpc/ia64

2013-01-15 Thread Maarten Lankhorst
Needed for reservation slowpath.
---
 arch/ia64/include/asm/mutex.h| 20 
 arch/powerpc/include/asm/mutex.h | 20 
 arch/sh/include/asm/mutex-llsc.h | 20 
 arch/x86/include/asm/mutex_32.h  | 20 
 arch/x86/include/asm/mutex_64.h  | 20 
 include/asm-generic/mutex-dec.h  | 20 
 include/asm-generic/mutex-null.h |  1 +
 include/asm-generic/mutex-xchg.h | 21 +
 8 files changed, 142 insertions(+)

diff --git a/arch/ia64/include/asm/mutex.h b/arch/ia64/include/asm/mutex.h
index bed73a6..2510058 100644
--- a/arch/ia64/include/asm/mutex.h
+++ b/arch/ia64/include/asm/mutex.h
@@ -44,6 +44,26 @@ __mutex_fastpath_lock_retval(atomic_t *count, int 
(*fail_fn)(atomic_t *))
 }

 /**
+ *  __mutex_fastpath_lock_retval_arg - try to take the lock by moving the count
+ * from 1 to a 0 value
+ *  @count: pointer of type atomic_t
+ *  @arg: argument to pass along if fastpath fails.
+ *  @fail_fn: function to call if the original value was not 1
+ *
+ * Change the count from 1 to a value lower than 1, and call  if
+ * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
+ * or anything the slow path function returns.
+ */
+static inline int __mutex_fastpath_lock_retval_arg(atomic_t *count,
+   void *arg, int (*fail_fn)(atomic_t *, void*))
+{
+   if (unlikely(ia64_fetchadd4_acq(count, -1) != 1))
+   return fail_fn(count, arg);
+   else
+   return 0;
+}
+
+/**
  *  __mutex_fastpath_unlock - try to promote the count from 0 to 1
  *  @count: pointer of type atomic_t
  *  @fail_fn: function to call if the original value was not 0
diff --git a/arch/powerpc/include/asm/mutex.h b/arch/powerpc/include/asm/mutex.h
index 5399f7e..df4bcff 100644
--- a/arch/powerpc/include/asm/mutex.h
+++ b/arch/powerpc/include/asm/mutex.h
@@ -97,6 +97,26 @@ __mutex_fastpath_lock_retval(atomic_t *count, int 
(*fail_fn)(atomic_t *))
 }

 /**
+ *  __mutex_fastpath_lock_retval_arg - try to take the lock by moving the count
+ * from 1 to a 0 value
+ *  @count: pointer of type atomic_t
+ *  @arg: argument to pass along if fastpath fails.
+ *  @fail_fn: function to call if the original value was not 1
+ *
+ * Change the count from 1 to a value lower than 1, and call  if
+ * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
+ * or anything the slow path function returns.
+ */
+static inline int __mutex_fastpath_lock_retval_arg(atomic_t *count,
+   void *arg, int (*fail_fn)(atomic_t *, void*))
+{
+   if (unlikely(__mutex_dec_return_lock(count) < 0))
+   return fail_fn(count, arg);
+   else
+   return 0;
+}
+
+/**
  *  __mutex_fastpath_unlock - try to promote the count from 0 to 1
  *  @count: pointer of type atomic_t
  *  @fail_fn: function to call if the original value was not 0
diff --git a/arch/sh/include/asm/mutex-llsc.h b/arch/sh/include/asm/mutex-llsc.h
index 090358a..b68dd6d 100644
--- a/arch/sh/include/asm/mutex-llsc.h
+++ b/arch/sh/include/asm/mutex-llsc.h
@@ -56,6 +56,26 @@ __mutex_fastpath_lock_retval(atomic_t *count, int 
(*fail_fn)(atomic_t *))
return __res;
 }

+static inline int __mutex_fastpath_lock_retval_arg(atomic_t *count,
+   void *arg, int (*fail_fn)(atomic_t *, void *))
+{
+   int __done, __res;
+
+   __asm__ __volatile__ (
+   "movli.l@%2, %0 \n"
+   "add#-1, %0 \n"
+   "movco.l%0, @%2 \n"
+   "movt   %1  \n"
+   : "=&z" (__res), "=&r" (__done)
+   : "r" (&(count)->counter)
+   : "t");
+
+   if (unlikely(!__done || __res != 0))
+   __res = fail_fn(count, arg);
+
+   return __res;
+}
+
 static inline void
 __mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *))
 {
diff --git a/arch/x86/include/asm/mutex_32.h b/arch/x86/include/asm/mutex_32.h
index 03f90c8..34f77f9 100644
--- a/arch/x86/include/asm/mutex_32.h
+++ b/arch/x86/include/asm/mutex_32.h
@@ -58,6 +58,26 @@ static inline int __mutex_fastpath_lock_retval(atomic_t 
*count,
 }

 /**
+ *  __mutex_fastpath_lock_retval_arg - try to take the lock by moving the count
+ * from 1 to a 0 value
+ *  @count: pointer of type atomic_t
+ *  @arg: argument to pass along if fastpath fails.
+ *  @fail_fn: function to call if the original value was not 1
+ *
+ * Change the count from 1 to a value lower than 1, and call  if
+ * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
+ * or anything the slow path function returns.
+ */
+static inline int __mutex_fastpath_lock_retval_arg(atomic_t *count,
+   void *arg, int (*fail_fn)(atomic_t *, void*))
+{
+

[PATCH 0/7] cross-device reservation for dma-buf support

2013-01-15 Thread Maarten Lankhorst
So I'm resending the patch series for reservations. This is identical to my git
tree at

http://cgit.freedesktop.org/~mlankhorst/linux/

Some changes have been made since my last version. Most notably is the use of
mutexes now instead of creating my own lock primitive, that would end up being
duplicate anyway.

The git tree also has a version of i915 and radeon working together like that.
It's probably a bit hacky, but it works on my macbook pro 8.2. :)

I haven't had any reply on the mutex extensions when I sent them out separately,
so I'm including it in the series.

The idea is that for lockdep purposes, the seqno is tied to a locking a class.
This locking class it not exclusive, but as can be seen from the last patch in
the series, it catches all violations we care about.



[PATCHv5 8/8] drm: tegra: Add gr2d device

2013-01-15 Thread Terje Bergstrom
Add client driver for 2D device, and IOCTLs to pass work to host1x
channel for 2D.

Also adds functions that can be called to access sync points from DRM.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile   |1 +
 drivers/gpu/host1x/dev.c  |7 +
 drivers/gpu/host1x/drm/drm.c  |  226 +++-
 drivers/gpu/host1x/drm/drm.h  |   28 
 drivers/gpu/host1x/drm/gr2d.c |  325 +
 drivers/gpu/host1x/syncpt.c   |5 +
 drivers/gpu/host1x/syncpt.h   |3 +
 include/drm/tegra_drm.h   |  131 +
 8 files changed, 725 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/drm/tegra_drm.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index c35ee19..c2120ad 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -18,4 +18,5 @@ ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG

 host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o
 host1x-$(CONFIG_DRM_TEGRA) += drm/output.o drm/rgb.o drm/hdmi.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/gr2d.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index 17ee01c..40d9938 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -214,11 +214,17 @@ static int __init tegra_host1x_init(void)
err = platform_driver_register(&tegra_hdmi_driver);
if (err < 0)
goto unregister_dc;
+
+   err = platform_driver_register(&tegra_gr2d_driver);
+   if (err < 0)
+   goto unregister_hdmi;
 #endif

return 0;

 #ifdef CONFIG_TEGRA_DRM
+unregister_hdmi:
+   platform_driver_unregister(&tegra_hdmi_driver);
 unregister_dc:
platform_driver_unregister(&tegra_dc_driver);
 unregister_host1x:
@@ -231,6 +237,7 @@ module_init(tegra_host1x_init);
 static void __exit tegra_host1x_exit(void)
 {
 #ifdef CONFIG_TEGRA_DRM
+   platform_driver_unregister(&tegra_gr2d_driver);
platform_driver_unregister(&tegra_hdmi_driver);
platform_driver_unregister(&tegra_dc_driver);
 #endif
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index bef9051..f8f8508 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -14,9 +14,11 @@
 #include 
 #include 
 #include 
+#include 

 #include "drm.h"
 #include "host1x_client.h"
+#include "syncpt.h"

 #define DRIVER_NAME "tegra"
 #define DRIVER_DESC "NVIDIA Tegra graphics"
@@ -78,8 +80,10 @@ static int host1x_parse_dt(struct host1x *host1x)
static const char * const compat[] = {
"nvidia,tegra20-dc",
"nvidia,tegra20-hdmi",
+   "nvidia,tegra20-gr2d",
"nvidia,tegra30-dc",
"nvidia,tegra30-hdmi",
+   "nvidia,tegra30-gr2d",
};
unsigned int i;
int err;
@@ -270,7 +274,29 @@ static int tegra_drm_unload(struct drm_device *drm)

 static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
 {
-   return 0;
+   struct host1x_drm_fpriv *fpriv;
+   int err = 0;
+
+   fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
+   if (!fpriv)
+   return -ENOMEM;
+
+   INIT_LIST_HEAD(&fpriv->contexts);
+   filp->driver_priv = fpriv;
+
+   return err;
+}
+
+static void tegra_drm_close(struct drm_device *drm, struct drm_file *filp)
+{
+   struct host1x_drm_fpriv *fpriv = host1x_drm_fpriv(filp);
+   struct host1x_drm_context *context, *tmp;
+
+   list_for_each_entry_safe(context, tmp, &fpriv->contexts, list) {
+   context->client->ops->close_channel(context);
+   kfree(context);
+   }
+   kfree(fpriv);
 }

 static void tegra_drm_lastclose(struct drm_device *drm)
@@ -280,7 +306,204 @@ static void tegra_drm_lastclose(struct drm_device *drm)
drm_fbdev_cma_restore_mode(host1x->fbdev);
 }

+static int
+tegra_drm_ioctl_syncpt_read(struct drm_device *drm, void *data,
+struct drm_file *file_priv)
+{
+   struct host1x *host1x = drm->dev_private;
+   struct tegra_drm_syncpt_read_args *args = data;
+   struct host1x_syncpt *sp =
+   host1x_syncpt_get_bydev(host1x->dev, args->id);
+
+   if (!sp)
+   return -EINVAL;
+
+   args->value = host1x_syncpt_read_min(sp);
+   return 0;
+}
+
+static int
+tegra_drm_ioctl_syncpt_incr(struct drm_device *drm, void *data,
+struct drm_file *file_priv)
+{
+   struct host1x *host1x = drm->dev_private;
+   struct tegra_drm_syncpt_incr_args *args = data;
+   struct host1x_syncpt *sp =
+   host1x_syncpt_get_bydev(host1x->dev, args->id);
+
+   if (!sp)
+   return -EINVAL;
+
+   host1x_syncpt_incr(sp);
+   return 0;
+}
+
+static int
+tegra_drm_ioctl_syncpt_wait(struct drm_device *drm, void *data,
+struct drm_file *file

[PATCHv5 7/8] ARM: tegra: Add board data and 2D clocks

2013-01-15 Thread Terje Bergstrom
Add a driver alias gr2d for Tegra 2D device, and assign a duplicate
of 2D clock to that driver alias.

Signed-off-by: Terje Bergstrom 
---
 arch/arm/mach-tegra/board-dt-tegra20.c|1 +
 arch/arm/mach-tegra/board-dt-tegra30.c|1 +
 arch/arm/mach-tegra/tegra20_clocks_data.c |2 +-
 arch/arm/mach-tegra/tegra30_clocks_data.c |1 +
 4 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c 
b/arch/arm/mach-tegra/board-dt-tegra20.c
index 171ba3c..9fcc800 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -96,6 +96,7 @@ static struct of_dev_auxdata tegra20_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("nvidia,tegra20-slink", 0x7000D800, "spi_tegra.2", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-slink", 0x7000DA00, "spi_tegra.3", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-host1x", 0x5000, "host1x", NULL),
+   OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x5414, "gr2d", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-dc", 0x5420, "tegradc.0", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-dc", 0x5424, "tegradc.1", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-hdmi", 0x5428, "hdmi", NULL),
diff --git a/arch/arm/mach-tegra/board-dt-tegra30.c 
b/arch/arm/mach-tegra/board-dt-tegra30.c
index cfe5fc0..0b4a1f0 100644
--- a/arch/arm/mach-tegra/board-dt-tegra30.c
+++ b/arch/arm/mach-tegra/board-dt-tegra30.c
@@ -59,6 +59,7 @@ static struct of_dev_auxdata tegra30_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("nvidia,tegra30-slink", 0x7000DC00, "spi_tegra.4", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-slink", 0x7000DE00, "spi_tegra.5", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-host1x", 0x5000, "host1x", NULL),
+   OF_DEV_AUXDATA("nvidia,tegra30-gr2d", 0x5414, "gr2d", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-dc", 0x5420, "tegradc.0", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-dc", 0x5424, "tegradc.1", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-hdmi", 0x5428, "hdmi", NULL),
diff --git a/arch/arm/mach-tegra/tegra20_clocks_data.c 
b/arch/arm/mach-tegra/tegra20_clocks_data.c
index a23a073..15d440a 100644
--- a/arch/arm/mach-tegra/tegra20_clocks_data.c
+++ b/arch/arm/mach-tegra/tegra20_clocks_data.c
@@ -1041,7 +1041,7 @@ static struct clk_duplicate tegra_clk_duplicates[] = {
CLK_DUPLICATE("usbd",   "utmip-pad",NULL),
CLK_DUPLICATE("usbd",   "tegra-ehci.0", NULL),
CLK_DUPLICATE("usbd",   "tegra-otg",NULL),
-   CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"),
+   CLK_DUPLICATE("2d", "gr2d", "gr2d"),
CLK_DUPLICATE("3d", "tegra_grhost", "gr3d"),
CLK_DUPLICATE("epp","tegra_grhost", "epp"),
CLK_DUPLICATE("mpe","tegra_grhost", "mpe"),
diff --git a/arch/arm/mach-tegra/tegra30_clocks_data.c 
b/arch/arm/mach-tegra/tegra30_clocks_data.c
index 741d264..5c4b7b7 100644
--- a/arch/arm/mach-tegra/tegra30_clocks_data.c
+++ b/arch/arm/mach-tegra/tegra30_clocks_data.c
@@ -1338,6 +1338,7 @@ static struct clk_duplicate tegra_clk_duplicates[] = {
CLK_DUPLICATE("pll_p", "tegradc.0", "parent"),
CLK_DUPLICATE("pll_p", "tegradc.1", "parent"),
CLK_DUPLICATE("pll_d2_out0", "hdmi", "parent"),
+   CLK_DUPLICATE("2d", "gr2d", "gr2d"),
 };

 static struct clk *tegra_ptr_clks[] = {
-- 
1.7.9.5



[PATCHv5 6/8] gpu: host1x: Remove second host1x driver

2013-01-15 Thread Terje Bergstrom
Remove second host1x driver, and bind tegra-drm to the new host1x driver. The
logic to parse device tree and track clients is moved to drm.c.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile|2 +-
 drivers/gpu/host1x/dev.c   |   58 +-
 drivers/gpu/host1x/dev.h   |6 +
 drivers/gpu/host1x/drm/Kconfig |2 +-
 drivers/gpu/host1x/drm/dc.c|7 +-
 drivers/gpu/host1x/drm/drm.c   |  213 +++-
 drivers/gpu/host1x/drm/drm.h   |3 -
 drivers/gpu/host1x/drm/hdmi.c  |7 +-
 drivers/gpu/host1x/host1x_client.h |9 ++
 9 files changed, 294 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index ffc8bf1..c35ee19 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -16,6 +16,6 @@ host1x-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
 ccflags-y += -Iinclude/drm
 ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG

-host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o drm/host1x.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o
 host1x-$(CONFIG_DRM_TEGRA) += drm/output.o drm/rgb.o drm/hdmi.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index 5aa7d28..17ee01c 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -28,12 +28,25 @@
 #include "channel.h"
 #include "debug.h"
 #include "hw/host1x01.h"
+#include "host1x_client.h"

 #define CREATE_TRACE_POINTS
 #include 

 #define DRIVER_NAME"tegra-host1x"

+void host1x_set_drm_data(struct platform_device *pdev, void *data)
+{
+   struct host1x *host1x = platform_get_drvdata(pdev);
+   host1x->drm_data = data;
+}
+
+void *host1x_get_drm_data(struct platform_device *pdev)
+{
+   struct host1x *host1x = platform_get_drvdata(pdev);
+   return host1x->drm_data;
+}
+
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
 {
void __iomem *sync_regs = host1x->regs + host1x->info.sync_offset;
@@ -153,6 +166,8 @@ static int host1x_probe(struct platform_device *dev)

host1x_debug_init(host);

+   host1x_drm_alloc(dev);
+
dev_info(&dev->dev, "initialized\n");

return 0;
@@ -173,7 +188,7 @@ static int __exit host1x_remove(struct platform_device *dev)
return 0;
 }

-static struct platform_driver platform_driver = {
+static struct platform_driver tegra_host1x_driver = {
.probe = host1x_probe,
.remove = __exit_p(host1x_remove),
.driver = {
@@ -183,8 +198,47 @@ static struct platform_driver platform_driver = {
},
 };

-module_platform_driver(platform_driver);
+static int __init tegra_host1x_init(void)
+{
+   int err;
+
+   err = platform_driver_register(&tegra_host1x_driver);
+   if (err < 0)
+   return err;
+
+#ifdef CONFIG_TEGRA_DRM
+   err = platform_driver_register(&tegra_dc_driver);
+   if (err < 0)
+   goto unregister_host1x;
+
+   err = platform_driver_register(&tegra_hdmi_driver);
+   if (err < 0)
+   goto unregister_dc;
+#endif
+
+   return 0;
+
+#ifdef CONFIG_TEGRA_DRM
+unregister_dc:
+   platform_driver_unregister(&tegra_dc_driver);
+unregister_host1x:
+   platform_driver_unregister(&tegra_host1x_driver);
+   return err;
+#endif
+}
+module_init(tegra_host1x_init);
+
+static void __exit tegra_host1x_exit(void)
+{
+#ifdef CONFIG_TEGRA_DRM
+   platform_driver_unregister(&tegra_hdmi_driver);
+   platform_driver_unregister(&tegra_dc_driver);
+#endif
+   platform_driver_unregister(&tegra_host1x_driver);
+}
+module_exit(tegra_host1x_exit);

+MODULE_AUTHOR("Thierry Reding ");
 MODULE_AUTHOR("Terje Bergstrom ");
 MODULE_DESCRIPTION("Host1x driver for Tegra products");
 MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index 467a92e..ff3a365 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -142,6 +142,8 @@ struct host1x {
int allocated_channels;

struct dentry *debugfs;
+
+   void *drm_data;
 };

 static inline
@@ -161,4 +163,8 @@ u32 host1x_sync_readl(struct host1x *host1x, u32 r);
 void host1x_ch_writel(struct host1x_channel *ch, u32 r, u32 v);
 u32 host1x_ch_readl(struct host1x_channel *ch, u32 r);

+extern struct platform_driver tegra_hdmi_driver;
+extern struct platform_driver tegra_dc_driver;
+extern struct platform_driver tegra_gr2d_driver;
+
 #endif
diff --git a/drivers/gpu/host1x/drm/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index be1daf7..7db9b3a 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -1,5 +1,5 @@
 config DRM_TEGRA
-   tristate "NVIDIA Tegra DRM"
+   bool "NVIDIA Tegra DRM"
depends on DRM && OF && ARCH_TEGRA
select DRM_KMS_HELPER
select DRM_GEM_CMA_HELPER
diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index 656b2e3..ac31e96 100644
--- a/dr

[PATCHv5 5/8] drm: tegra: Move drm to live under host1x

2013-01-15 Thread Terje Bergstrom
Make drm part of host1x driver.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/drm/Kconfig|2 -
 drivers/gpu/drm/Makefile   |1 -
 drivers/gpu/drm/tegra/Kconfig  |   23 -
 drivers/gpu/drm/tegra/Makefile |7 -
 drivers/gpu/drm/tegra/dc.c |  833 ---
 drivers/gpu/drm/tegra/dc.h |  388 ---
 drivers/gpu/drm/tegra/drm.c|  115 
 drivers/gpu/drm/tegra/drm.h|  216 --
 drivers/gpu/drm/tegra/fb.c |   56 --
 drivers/gpu/drm/tegra/hdmi.c   | 1321 
 drivers/gpu/drm/tegra/hdmi.h   |  575 
 drivers/gpu/drm/tegra/host1x.c |  327 -
 drivers/gpu/drm/tegra/output.c |  272 
 drivers/gpu/drm/tegra/rgb.c|  228 ---
 drivers/gpu/host1x/Kconfig |3 +
 drivers/gpu/host1x/Makefile|6 +
 drivers/gpu/host1x/drm/Kconfig |   23 +
 drivers/gpu/host1x/drm/dc.c|  833 +++
 drivers/gpu/host1x/drm/dc.h|  388 +++
 drivers/gpu/host1x/drm/drm.c   |  115 
 drivers/gpu/host1x/drm/drm.h   |  216 ++
 drivers/gpu/host1x/drm/fb.c|   56 ++
 drivers/gpu/host1x/drm/hdmi.c  | 1321 
 drivers/gpu/host1x/drm/hdmi.h  |  575 
 drivers/gpu/host1x/drm/host1x.c|  327 +
 drivers/gpu/host1x/drm/output.c|  272 
 drivers/gpu/host1x/drm/rgb.c   |  228 +++
 drivers/gpu/host1x/host1x_client.h |   25 +
 28 files changed, 4388 insertions(+), 4364 deletions(-)
 delete mode 100644 drivers/gpu/drm/tegra/Kconfig
 delete mode 100644 drivers/gpu/drm/tegra/Makefile
 delete mode 100644 drivers/gpu/drm/tegra/dc.c
 delete mode 100644 drivers/gpu/drm/tegra/dc.h
 delete mode 100644 drivers/gpu/drm/tegra/drm.c
 delete mode 100644 drivers/gpu/drm/tegra/drm.h
 delete mode 100644 drivers/gpu/drm/tegra/fb.c
 delete mode 100644 drivers/gpu/drm/tegra/hdmi.c
 delete mode 100644 drivers/gpu/drm/tegra/hdmi.h
 delete mode 100644 drivers/gpu/drm/tegra/host1x.c
 delete mode 100644 drivers/gpu/drm/tegra/output.c
 delete mode 100644 drivers/gpu/drm/tegra/rgb.c
 create mode 100644 drivers/gpu/host1x/drm/Kconfig
 create mode 100644 drivers/gpu/host1x/drm/dc.c
 create mode 100644 drivers/gpu/host1x/drm/dc.h
 create mode 100644 drivers/gpu/host1x/drm/drm.c
 create mode 100644 drivers/gpu/host1x/drm/drm.h
 create mode 100644 drivers/gpu/host1x/drm/fb.c
 create mode 100644 drivers/gpu/host1x/drm/hdmi.c
 create mode 100644 drivers/gpu/host1x/drm/hdmi.h
 create mode 100644 drivers/gpu/host1x/drm/host1x.c
 create mode 100644 drivers/gpu/host1x/drm/output.c
 create mode 100644 drivers/gpu/host1x/drm/rgb.c
 create mode 100644 drivers/gpu/host1x/host1x_client.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 983201b..18321b68b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -210,5 +210,3 @@ source "drivers/gpu/drm/mgag200/Kconfig"
 source "drivers/gpu/drm/cirrus/Kconfig"

 source "drivers/gpu/drm/shmobile/Kconfig"
-
-source "drivers/gpu/drm/tegra/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 6f58c81..f54c72a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -49,5 +49,4 @@ obj-$(CONFIG_DRM_GMA500) += gma500/
 obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
 obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/
-obj-$(CONFIG_DRM_TEGRA) += tegra/
 obj-y  += i2c/
diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
deleted file mode 100644
index be1daf7..000
--- a/drivers/gpu/drm/tegra/Kconfig
+++ /dev/null
@@ -1,23 +0,0 @@
-config DRM_TEGRA
-   tristate "NVIDIA Tegra DRM"
-   depends on DRM && OF && ARCH_TEGRA
-   select DRM_KMS_HELPER
-   select DRM_GEM_CMA_HELPER
-   select DRM_KMS_CMA_HELPER
-   select FB_CFB_FILLRECT
-   select FB_CFB_COPYAREA
-   select FB_CFB_IMAGEBLIT
-   help
- Choose this option if you have an NVIDIA Tegra SoC.
-
- To compile this driver as a module, choose M here: the module
- will be called tegra-drm.
-
-if DRM_TEGRA
-
-config DRM_TEGRA_DEBUG
-   bool "NVIDIA Tegra DRM debug support"
-   help
- Say yes here to enable debugging support.
-
-endif
diff --git a/drivers/gpu/drm/tegra/Makefile b/drivers/gpu/drm/tegra/Makefile
deleted file mode 100644
index 80f73d1..000
--- a/drivers/gpu/drm/tegra/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-ccflags-y := -Iinclude/drm
-ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG
-
-tegra-drm-y := drm.o fb.o dc.o host1x.o
-tegra-drm-y += output.o rgb.o hdmi.o
-
-obj-$(CONFIG_DRM_TEGRA) += tegra-drm.o
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
deleted file mode 100644
index 656b2e3..000
--- a/drivers/gpu/drm/tegra/dc.c
+++ /dev/null
@@ -1,833 +0,0 @@
-/*
- * Copyright (C) 2012 Avionic Design GmbH
- * Copyright (C) 2012 NVIDIA CORP

[PATCHv5 4/8] gpu: host1x: Add debug support

2013-01-15 Thread Terje Bergstrom
Add support for host1x debugging. Adds debugfs entries, and dumps
channel state to UART in case of stuck job.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile |1 +
 drivers/gpu/host1x/cdma.c   |   34 +++
 drivers/gpu/host1x/debug.c  |  215 ++
 drivers/gpu/host1x/debug.h  |   50 
 drivers/gpu/host1x/dev.c|3 +
 drivers/gpu/host1x/dev.h|   17 ++
 drivers/gpu/host1x/hw/cdma_hw.c |3 +
 drivers/gpu/host1x/hw/debug_hw.c|  400 +++
 drivers/gpu/host1x/hw/host1x01.c|2 +
 drivers/gpu/host1x/hw/hw_host1x01_channel.h |   18 ++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h|  115 
 drivers/gpu/host1x/hw/syncpt_hw.c   |1 +
 drivers/gpu/host1x/syncpt.c |3 +
 13 files changed, 862 insertions(+)
 create mode 100644 drivers/gpu/host1x/debug.c
 create mode 100644 drivers/gpu/host1x/debug.h
 create mode 100644 drivers/gpu/host1x/hw/debug_hw.c

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index cdd87c8..697d49a 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -7,6 +7,7 @@ host1x-y = \
cdma.o \
channel.o \
job.o \
+   debug.o \
memmgr.o \
hw/host1x01.o

diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index d6a38d2..12dd46c 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -19,6 +19,7 @@
 #include "cdma.h"
 #include "channel.h"
 #include "dev.h"
+#include "debug.h"
 #include "memmgr.h"
 #include "job.h"
 #include 
@@ -370,12 +371,42 @@ int host1x_cdma_begin(struct host1x_cdma *cdma, struct 
host1x_job *job)
return 0;
 }

+static void trace_write_gather(struct host1x_cdma *cdma,
+   struct mem_handle *ref,
+   u32 offset, u32 words)
+{
+   void *mem = NULL;
+
+   if (host1x_debug_trace_cmdbuf)
+   mem = host1x_memmgr_mmap(ref);
+
+   if (mem) {
+   u32 i;
+   /*
+* Write in batches of 128 as there seems to be a limit
+* of how much you can output to ftrace at once.
+*/
+   for (i = 0; i < words; i += TRACE_MAX_LENGTH) {
+   trace_host1x_cdma_push_gather(
+   cdma_to_channel(cdma)->dev->name,
+   (u32)ref,
+   min(words - i, TRACE_MAX_LENGTH),
+   offset + i * sizeof(u32),
+   mem);
+   }
+   host1x_memmgr_munmap(ref, mem);
+   }
+}
+
 /*
  * Push two words into a push buffer slot
  * Blocks as necessary if the push buffer is full.
  */
 void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2)
 {
+   if (host1x_debug_trace_cmdbuf)
+   trace_host1x_cdma_push(cdma_to_channel(cdma)->dev->name,
+   op1, op2);
host1x_cdma_push_gather(cdma, NULL, 0, op1, op2);
 }

@@ -391,6 +422,9 @@ void host1x_cdma_push_gather(struct host1x_cdma *cdma,
u32 slots_free = cdma->slots_free;
struct push_buffer *pb = &cdma->push_buffer;

+   if (handle)
+   trace_write_gather(cdma, handle, offset, op1 & 0x);
+
if (slots_free == 0) {
host1x->cdma_op.kick(cdma);
slots_free = host1x_cdma_wait_locked(cdma,
diff --git a/drivers/gpu/host1x/debug.c b/drivers/gpu/host1x/debug.c
new file mode 100644
index 000..29cbe93
--- /dev/null
+++ b/drivers/gpu/host1x/debug.c
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ * Author: Erik Gilling 
+ *
+ * Copyright (C) 2011-2012 NVIDIA Corporation
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "dev.h"
+#include "debug.h"
+#include "channel.h"
+
+static pid_t host1x_debug_null_kickoff_pid;
+unsigned int host1x_debug_trace_cmdbuf;
+
+static pid_t host1x_debug_force_timeout_pid;
+static u32 host1x_debug_force_timeout_val;
+static u32 host1x_debug_force_timeout_channel;
+
+void host1x_debug_output(struct output *o, const char *fmt, ...)
+{
+   va_list args;
+   int len;
+
+   va_start(args, fmt);
+   len = vsnprintf(o->buf, sizeof(o->buf), fmt, args);
+   va_end(args);
+   o->fn(o->ctx, o->buf, len);
+}
+
+static int show_channels(struct host1x_channel *ch, void *data)
+{

[PATCHv5 3/8] gpu: host1x: Add channel support

2013-01-15 Thread Terje Bergstrom
Add support for host1x client modules, and host1x channels to submit
work to the clients. The work is submitted in GEM CMA buffers, so
this patch adds support for them.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Kconfig  |   25 +-
 drivers/gpu/host1x/Makefile |5 +
 drivers/gpu/host1x/cdma.c   |  439 +++
 drivers/gpu/host1x/cdma.h   |  107 +
 drivers/gpu/host1x/channel.c|  140 ++
 drivers/gpu/host1x/channel.h|   58 +++
 drivers/gpu/host1x/cma.c|  116 +
 drivers/gpu/host1x/cma.h|   43 ++
 drivers/gpu/host1x/dev.c|   13 +
 drivers/gpu/host1x/dev.h|   59 +++
 drivers/gpu/host1x/host1x.h |   29 ++
 drivers/gpu/host1x/hw/cdma_hw.c |  475 +
 drivers/gpu/host1x/hw/cdma_hw.h |   37 ++
 drivers/gpu/host1x/hw/channel_hw.c  |  148 +++
 drivers/gpu/host1x/hw/host1x01.c|6 +
 drivers/gpu/host1x/hw/host1x01_hardware.h   |  124 ++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h |  102 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h|   12 +
 drivers/gpu/host1x/hw/hw_host1x01_uclass.h  |  168 
 drivers/gpu/host1x/hw/syncpt_hw.c   |   10 +
 drivers/gpu/host1x/intr.c   |   29 +-
 drivers/gpu/host1x/intr.h   |6 +
 drivers/gpu/host1x/job.c|  612 +++
 drivers/gpu/host1x/job.h|  164 +++
 drivers/gpu/host1x/memmgr.c |  173 
 drivers/gpu/host1x/memmgr.h |   72 
 drivers/gpu/host1x/syncpt.c |   11 +
 drivers/gpu/host1x/syncpt.h |4 +
 include/trace/events/host1x.h   |  211 +
 29 files changed, 3396 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/host1x/cdma.c
 create mode 100644 drivers/gpu/host1x/cdma.h
 create mode 100644 drivers/gpu/host1x/channel.c
 create mode 100644 drivers/gpu/host1x/channel.h
 create mode 100644 drivers/gpu/host1x/cma.c
 create mode 100644 drivers/gpu/host1x/cma.h
 create mode 100644 drivers/gpu/host1x/host1x.h
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.h
 create mode 100644 drivers/gpu/host1x/hw/channel_hw.c
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_channel.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_uclass.h
 create mode 100644 drivers/gpu/host1x/job.c
 create mode 100644 drivers/gpu/host1x/job.h
 create mode 100644 drivers/gpu/host1x/memmgr.c
 create mode 100644 drivers/gpu/host1x/memmgr.h

diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
index e89fb2b..57680a6 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -3,4 +3,27 @@ config TEGRA_HOST1X
help
  Driver for the Tegra host1x hardware.

- Required for enabling tegradrm.
+ Required for enabling tegradrm and 2D acceleration.
+
+if TEGRA_HOST1X
+
+config TEGRA_HOST1X_CMA
+   bool "Support DRM CMA buffers"
+   depends on DRM
+   default y
+   select DRM_GEM_CMA_HELPER
+   select DRM_KMS_CMA_HELPER
+   help
+ Say yes if you wish to use DRM CMA buffers.
+
+ If unsure, choose Y.
+
+config TEGRA_HOST1X_FIREWALL
+   bool "Enable HOST1X security firewall"
+   default y
+   help
+ Say yes if kernel should protect command streams from tampering.
+
+ If unsure, choose Y.
+
+endif
diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 5ef47ff..cdd87c8 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -4,6 +4,11 @@ host1x-y = \
syncpt.o \
dev.o \
intr.o \
+   cdma.o \
+   channel.o \
+   job.o \
+   memmgr.o \
hw/host1x01.o

+host1x-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
new file mode 100644
index 000..d6a38d2
--- /dev/null
+++ b/drivers/gpu/host1x/cdma.c
@@ -0,0 +1,439 @@
+/*
+ * Tegra host1x Command DMA
+ *
+ * Copyright (c) 2010-2013, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include "cdma.h"
+#include "channel.h"
+#in

[PATCHv5 2/8] gpu: host1x: Add syncpoint wait and interrupts

2013-01-15 Thread Terje Bergstrom
Add support for sync point interrupts, and sync point wait. Sync
point wait used interrupts for unblocking wait.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile  |1 +
 drivers/gpu/host1x/dev.c |   21 +-
 drivers/gpu/host1x/dev.h |   17 +-
 drivers/gpu/host1x/hw/host1x01.c |2 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h |   42 
 drivers/gpu/host1x/hw/intr_hw.c  |  178 +++
 drivers/gpu/host1x/intr.c|  356 ++
 drivers/gpu/host1x/intr.h|  103 +
 drivers/gpu/host1x/syncpt.c  |  163 ++
 drivers/gpu/host1x/syncpt.h  |5 +
 10 files changed, 883 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/host1x/hw/intr_hw.c
 create mode 100644 drivers/gpu/host1x/intr.c
 create mode 100644 drivers/gpu/host1x/intr.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 363e6ab..5ef47ff 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -3,6 +3,7 @@ ccflags-y = -Idrivers/gpu/host1x
 host1x-y = \
syncpt.o \
dev.o \
+   intr.o \
hw/host1x01.o

 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index cd2b1ef..7f9f389 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include "dev.h"
+#include "intr.h"
 #include "hw/host1x01.h"

 #define CREATE_TRACE_POINTS
@@ -95,7 +96,6 @@ static int host1x_probe(struct platform_device *dev)

/* set common host1x device data */
platform_set_drvdata(dev, host);
-
host->regs = devm_request_and_ioremap(&dev->dev, regs);
if (!host->regs) {
dev_err(&dev->dev, "failed to remap host registers\n");
@@ -109,28 +109,40 @@ static int host1x_probe(struct platform_device *dev)
}

err = host1x_syncpt_init(host);
-   if (err)
+   if (err) {
+   dev_err(&dev->dev, "failed to init sync points");
return err;
+   }
+
+   err = host1x_intr_init(&host->intr, syncpt_irq);
+   if (err) {
+   dev_err(&dev->dev, "failed to init irq");
+   goto fail_deinit_syncpt;
+   }

host->clk = devm_clk_get(&dev->dev, NULL);
if (IS_ERR(host->clk)) {
dev_err(&dev->dev, "failed to get clock\n");
err = PTR_ERR(host->clk);
-   goto fail_deinit_syncpt;
+   goto fail_deinit_intr;
}

err = clk_prepare_enable(host->clk);
if (err < 0) {
dev_err(&dev->dev, "failed to enable clock\n");
-   goto fail_deinit_syncpt;
+   goto fail_deinit_intr;
}

host1x_syncpt_reset(host);

+   host1x_intr_start(&host->intr, clk_get_rate(host->clk));
+
dev_info(&dev->dev, "initialized\n");

return 0;

+fail_deinit_intr:
+   host1x_intr_deinit(&host->intr);
 fail_deinit_syncpt:
host1x_syncpt_deinit(host);
return err;
@@ -139,6 +151,7 @@ fail_deinit_syncpt:
 static int __exit host1x_remove(struct platform_device *dev)
 {
struct host1x *host = platform_get_drvdata(dev);
+   host1x_intr_deinit(&host->intr);
host1x_syncpt_deinit(host);
clk_disable_unprepare(host->clk);
return 0;
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index d8f5979..8376092 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -17,11 +17,12 @@
 #ifndef HOST1X_DEV_H
 #define HOST1X_DEV_H

+#include 
 #include "syncpt.h"
+#include "intr.h"

 struct host1x;
 struct host1x_syncpt;
-struct platform_device;

 struct host1x_syncpt_ops {
void (*reset)(struct host1x_syncpt *);
@@ -34,6 +35,18 @@ struct host1x_syncpt_ops {
const char * (*name)(struct host1x_syncpt *);
 };

+struct host1x_intr_ops {
+   void (*init_host_sync)(struct host1x_intr *);
+   void (*set_host_clocks_per_usec)(
+   struct host1x_intr *, u32 clocks);
+   void (*set_syncpt_threshold)(
+   struct host1x_intr *, u32 id, u32 thresh);
+   void (*enable_syncpt_intr)(struct host1x_intr *, u32 id);
+   void (*disable_syncpt_intr)(struct host1x_intr *, u32 id);
+   void (*disable_all_syncpt_intrs)(struct host1x_intr *);
+   int (*free_syncpt_irq)(struct host1x_intr *);
+};
+
 struct host1x_device_info {
int nb_channels;/* host1x: num channels supported */
int nb_pts; /* host1x: num syncpoints supported */
@@ -46,11 +59,13 @@ struct host1x_device_info {
 struct host1x {
void __iomem *regs;
struct host1x_syncpt *syncpt;
+   struct host1x_intr intr;
struct platform_device *dev;
struct host1x_device_info info;
struct clk *clk;

struct host1x_syncpt_ops syncpt_op;
+   str

[PATCHv5 1/8] gpu: host1x: Add host1x driver

2013-01-15 Thread Terje Bergstrom
Add host1x, the driver for host1x and its client unit 2D.

Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/Makefile  |1 +
 drivers/gpu/host1x/Kconfig|6 +
 drivers/gpu/host1x/Makefile   |8 ++
 drivers/gpu/host1x/dev.c  |  161 +
 drivers/gpu/host1x/dev.h  |   73 ++
 drivers/gpu/host1x/hw/Makefile|6 +
 drivers/gpu/host1x/hw/host1x01.c  |   35 +
 drivers/gpu/host1x/hw/host1x01.h  |   25 
 drivers/gpu/host1x/hw/host1x01_hardware.h |   26 
 drivers/gpu/host1x/hw/hw_host1x01_sync.h  |   72 ++
 drivers/gpu/host1x/hw/syncpt_hw.c |  146 +++
 drivers/gpu/host1x/syncpt.c   |  217 +
 drivers/gpu/host1x/syncpt.h   |  153 
 drivers/video/Kconfig |2 +
 include/trace/events/host1x.h |   61 
 15 files changed, 992 insertions(+)
 create mode 100644 drivers/gpu/host1x/Kconfig
 create mode 100644 drivers/gpu/host1x/Makefile
 create mode 100644 drivers/gpu/host1x/dev.c
 create mode 100644 drivers/gpu/host1x/dev.h
 create mode 100644 drivers/gpu/host1x/hw/Makefile
 create mode 100644 drivers/gpu/host1x/hw/host1x01.c
 create mode 100644 drivers/gpu/host1x/hw/host1x01.h
 create mode 100644 drivers/gpu/host1x/hw/host1x01_hardware.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_sync.h
 create mode 100644 drivers/gpu/host1x/hw/syncpt_hw.c
 create mode 100644 drivers/gpu/host1x/syncpt.c
 create mode 100644 drivers/gpu/host1x/syncpt.h
 create mode 100644 include/trace/events/host1x.h

diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index cc92778..7e227097 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1 +1,2 @@
 obj-y  += drm/ vga/ stub/
+obj-$(CONFIG_TEGRA_HOST1X) += host1x/
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
new file mode 100644
index 000..e89fb2b
--- /dev/null
+++ b/drivers/gpu/host1x/Kconfig
@@ -0,0 +1,6 @@
+config TEGRA_HOST1X
+   tristate "Tegra host1x driver"
+   help
+ Driver for the Tegra host1x hardware.
+
+ Required for enabling tegradrm.
diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
new file mode 100644
index 000..363e6ab
--- /dev/null
+++ b/drivers/gpu/host1x/Makefile
@@ -0,0 +1,8 @@
+ccflags-y = -Idrivers/gpu/host1x
+
+host1x-y = \
+   syncpt.o \
+   dev.o \
+   hw/host1x01.o
+
+obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
new file mode 100644
index 000..cd2b1ef
--- /dev/null
+++ b/drivers/gpu/host1x/dev.c
@@ -0,0 +1,161 @@
+/*
+ * Tegra host1x driver
+ *
+ * Copyright (c) 2010-2013, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "dev.h"
+#include "hw/host1x01.h"
+
+#define CREATE_TRACE_POINTS
+#include 
+
+#define DRIVER_NAME"tegra-host1x"
+
+void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
+{
+   void __iomem *sync_regs = host1x->regs + host1x->info.sync_offset;
+
+   writel(v, sync_regs + r);
+}
+
+u32 host1x_sync_readl(struct host1x *host1x, u32 r)
+{
+   void __iomem *sync_regs = host1x->regs + host1x->info.sync_offset;
+
+   return readl(sync_regs + r);
+}
+
+static struct host1x_device_info host1x_info = {
+   .nb_channels= 8,
+   .nb_pts = 32,
+   .nb_mlocks  = 16,
+   .nb_bases   = 8,
+   .init   = host1x01_init,
+   .sync_offset= 0x3000,
+};
+
+static struct of_device_id host1x_match[] = {
+   { .compatible = "nvidia,tegra30-host1x", .data = &host1x_info, },
+   { .compatible = "nvidia,tegra20-host1x", .data = &host1x_info, },
+   { },
+};
+
+static int host1x_probe(struct platform_device *dev)
+{
+   struct host1x *host;
+   struct resource *regs;
+   int syncpt_irq;
+   int err;
+   const struct of_device_id *devid =
+   of_match_device(host1x_match, &dev->dev);
+
+   if (!devid)
+   return -EINVAL;
+
+   regs = platform_get_resource(dev, IORESOURCE_MEM, 0);
+   if (!regs) {
+   dev_err(&dev->dev, "missing regs\n");
+   return -ENXIO;
+

[PATCHv5 0/8] Support for Tegra 2D hardware

2013-01-15 Thread Terje Bergstrom
This set of patches adds support for Tegra20 and Tegra30 host1x and
2D. It is based on linux-next-20130114.

The fifth version merges DRM and host1x drivers into one driver. This
allowed moving include/linux/host1x.h back into the driver and removed
the need for a dummy platform device. This version also uses the code
from tegradrm driver almost as is, so there are a lot less actual code
changes.

This patch set does not have the host1x allocator, but it uses CMA
helpers for memory management.

host1x is the driver that controls host1x hardware. It supports
host1x command channels, synchronization, and memory management. It
is sectioned into logical driver under drivers/gpu/host1x and
physical driver under drivers/host1x/hw. The physical driver is
compiled with the hardware headers of the particular host1x version.

The hardware units are described (briefly) in the Tegra2 TRM. Wiki
page https://gitorious.org/linux-tegra-drm/pages/Host1xIntroduction
also contains a short description of the functionality.

The patch set merges tegradrm into host1x and adds 2D driver, which
uses host1x channels and sync points. The patch set also adds user
space API to tegradrm for accessing host1x and 2D.

Terje Bergstrom (8):
  gpu: host1x: Add host1x driver
  gpu: host1x: Add syncpoint wait and interrupts
  gpu: host1x: Add channel support
  gpu: host1x: Add debug support
  drm: tegra: Move drm to live under host1x
  gpu: host1x: Remove second host1x driver
  ARM: tegra: Add board data and 2D clocks
  drm: tegra: Add gr2d device

 arch/arm/mach-tegra/board-dt-tegra20.c  |1 +
 arch/arm/mach-tegra/board-dt-tegra30.c  |1 +
 arch/arm/mach-tegra/tegra20_clocks_data.c   |2 +-
 arch/arm/mach-tegra/tegra30_clocks_data.c   |1 +
 drivers/gpu/Makefile|1 +
 drivers/gpu/drm/Kconfig |2 -
 drivers/gpu/drm/Makefile|1 -
 drivers/gpu/drm/tegra/Kconfig   |   23 -
 drivers/gpu/drm/tegra/Makefile  |7 -
 drivers/gpu/drm/tegra/dc.c  |  833 -
 drivers/gpu/drm/tegra/dc.h  |  388 
 drivers/gpu/drm/tegra/drm.c |  115 ---
 drivers/gpu/drm/tegra/drm.h |  216 -
 drivers/gpu/drm/tegra/fb.c  |   56 --
 drivers/gpu/drm/tegra/hdmi.c| 1321 --
 drivers/gpu/drm/tegra/hdmi.h|  575 
 drivers/gpu/drm/tegra/host1x.c  |  327 ---
 drivers/gpu/drm/tegra/output.c  |  272 --
 drivers/gpu/drm/tegra/rgb.c |  228 -
 drivers/gpu/host1x/Kconfig  |   32 +
 drivers/gpu/host1x/Makefile |   22 +
 drivers/gpu/host1x/cdma.c   |  473 ++
 drivers/gpu/host1x/cdma.h   |  107 +++
 drivers/gpu/host1x/channel.c|  140 +++
 drivers/gpu/host1x/channel.h|   58 ++
 drivers/gpu/host1x/cma.c|  116 +++
 drivers/gpu/host1x/cma.h|   43 +
 drivers/gpu/host1x/debug.c  |  215 +
 drivers/gpu/host1x/debug.h  |   50 +
 drivers/gpu/host1x/dev.c|  251 +
 drivers/gpu/host1x/dev.h|  170 
 drivers/gpu/host1x/drm/Kconfig  |   23 +
 drivers/gpu/host1x/drm/dc.c |  836 +
 drivers/gpu/host1x/drm/dc.h |  388 
 drivers/gpu/host1x/drm/drm.c|  548 +++
 drivers/gpu/host1x/drm/drm.h|  241 +
 drivers/gpu/host1x/drm/fb.c |   56 ++
 drivers/gpu/host1x/drm/gr2d.c   |  325 +++
 drivers/gpu/host1x/drm/hdmi.c   | 1324 +++
 drivers/gpu/host1x/drm/hdmi.h   |  575 
 drivers/gpu/host1x/drm/host1x.c |  327 +++
 drivers/gpu/host1x/drm/output.c |  272 ++
 drivers/gpu/host1x/drm/rgb.c|  228 +
 drivers/gpu/host1x/host1x.h |   29 +
 drivers/gpu/host1x/host1x_client.h  |   34 +
 drivers/gpu/host1x/hw/Makefile  |6 +
 drivers/gpu/host1x/hw/cdma_hw.c |  478 ++
 drivers/gpu/host1x/hw/cdma_hw.h |   37 +
 drivers/gpu/host1x/hw/channel_hw.c  |  148 +++
 drivers/gpu/host1x/hw/debug_hw.c|  400 
 drivers/gpu/host1x/hw/host1x01.c|   45 +
 drivers/gpu/host1x/hw/host1x01.h|   25 +
 drivers/gpu/host1x/hw/host1x01_hardware.h   |  150 +++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h |  120 +++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h|  241 +
 drivers/gpu/host1x/hw/hw_host1x01_uclass.h  |  168 
 drivers/gpu/host1x/hw/intr_hw.c |  178 
 drivers/gpu/host1x/hw/syncpt_hw.c   |  157 
 drivers/gpu/host1x/intr.c   |  383 
 drivers/gpu/host1x/intr.h 

radeon 0000:02:00.0: GPU lockup CP stall for more than 10000msec

2013-01-15 Thread Borislav Petkov
On Fri, Jan 11, 2013 at 12:43:36PM +0100, Borislav Petkov wrote:
> Ok, I'm running -rc3 with this and will watch it for any changes in
> behavior.

AFAICT, this fixes the CP stalls, for I haven't seen any of them in
dmesg for the last couple of days after applying your revert.

Thanks.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #12 from Alex Deucher   2013-01-15 20:57:27 
---
Same issue as:
https://bugs.freedesktop.org/show_bug.cgi?id=58659

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #11 from Alex Deucher  ---
Same issue as:
https://bugzilla.kernel.org/show_bug.cgi?id=52491

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm/radeon: use prime helpers

2013-01-15 Thread Aaron Plattner
Simplify the Radeon prime implementation by using the default behavior provided
by drm_gem_prime_import and drm_gem_prime_export.

v2:
- Rename functions to radeon_gem_prime_get_sg_table and
  radeon_gem_prime_import_sg_table.
- Delete the now-unused vmapping_count variable.

Signed-off-by: Aaron Plattner 
Cc: Daniel Vetter 
Cc: David Airlie 
---
 drivers/gpu/drm/radeon/radeon.h   |   1 -
 drivers/gpu/drm/radeon/radeon_drv.c   |  21 +++--
 drivers/gpu/drm/radeon/radeon_prime.c | 170 +-
 3 files changed, 35 insertions(+), 157 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 34e5230..48bb80e 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -342,7 +342,6 @@ struct radeon_bo {
struct drm_gem_object   gem_base;
 
struct ttm_bo_kmap_obj dma_buf_vmap;
-   int vmapping_count;
 };
 #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
 
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index dff6cf7..7a63817 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -117,11 +117,13 @@ int radeon_mode_dumb_create(struct drm_file *file_priv,
 int radeon_mode_dumb_destroy(struct drm_file *file_priv,
 struct drm_device *dev,
 uint32_t handle);
-struct dma_buf *radeon_gem_prime_export(struct drm_device *dev,
-   struct drm_gem_object *obj,
-   int flags);
-struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev,
-  struct dma_buf *dma_buf);
+struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj);
+struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
+   size_t size,
+   struct sg_table *sg);
+int radeon_gem_prime_pin(struct drm_gem_object *obj);
+void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
+void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
 
 #if defined(CONFIG_DEBUG_FS)
 int radeon_debugfs_init(struct drm_minor *minor);
@@ -396,8 +398,13 @@ static struct drm_driver kms_driver = {
 
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-   .gem_prime_export = radeon_gem_prime_export,
-   .gem_prime_import = radeon_gem_prime_import,
+   .gem_prime_export = drm_gem_prime_export,
+   .gem_prime_import = drm_gem_prime_import,
+   .gem_prime_pin = radeon_gem_prime_pin,
+   .gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
+   .gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
+   .gem_prime_vmap = radeon_gem_prime_vmap,
+   .gem_prime_vunmap = radeon_gem_prime_vunmap,
 
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/radeon/radeon_prime.c 
b/drivers/gpu/drm/radeon/radeon_prime.c
index 26c23bb..4940af7 100644
--- a/drivers/gpu/drm/radeon/radeon_prime.c
+++ b/drivers/gpu/drm/radeon/radeon_prime.c
@@ -28,199 +28,71 @@
 #include "radeon.h"
 #include 
 
-#include 
-
-static struct sg_table *radeon_gem_map_dma_buf(struct dma_buf_attachment 
*attachment,
-  enum dma_data_direction dir)
+struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj)
 {
-   struct radeon_bo *bo = attachment->dmabuf->priv;
-   struct drm_device *dev = bo->rdev->ddev;
+   struct radeon_bo *bo = gem_to_radeon_bo(obj);
int npages = bo->tbo.num_pages;
-   struct sg_table *sg;
-   int nents;
-
-   mutex_lock(&dev->struct_mutex);
-   sg = drm_prime_pages_to_sg(bo->tbo.ttm->pages, npages);
-   nents = dma_map_sg(attachment->dev, sg->sgl, sg->nents, dir);
-   mutex_unlock(&dev->struct_mutex);
-   return sg;
-}
-
-static void radeon_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
-struct sg_table *sg, enum 
dma_data_direction dir)
-{
-   dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir);
-   sg_free_table(sg);
-   kfree(sg);
-}
-
-static void radeon_gem_dmabuf_release(struct dma_buf *dma_buf)
-{
-   struct radeon_bo *bo = dma_buf->priv;
-
-   if (bo->gem_base.export_dma_buf == dma_buf) {
-   DRM_ERROR("unreference dmabuf %p\n", &bo->gem_base);
-   bo->gem_base.export_dma_buf = NULL;
-   drm_gem_object_unreference_unlocked(&bo->gem_base);
-   }
-}
-
-static void *radeon_gem_kmap_atomic(struct dma_buf *dma_buf, unsigned long 
page_num)
-{
-   return NULL;
-}
-
-static void radeon_gem_kunmap_atomic(struct dma_buf *dma_buf, unsigned long 
page_num, void *addr)
-{
-
-}
-static void *radeon

[PATCH v2 2/5] drm/tegra: Add plane support

2013-01-15 Thread Thierry Reding
On Tue, Jan 15, 2013 at 01:35:32PM +0200, Ville Syrj?l? wrote:
> On Tue, Jan 15, 2013 at 05:53:03PM +0800, Mark Zhang wrote:
> > On 01/15/2013 12:05 AM, Thierry Reding wrote:
> > > Add support for the B and C planes which support RGB and YUV pixel
> > > formats and can be used as overlays or hardware cursor.
> > 
> > I think "hardware cursor" has specific meaning for Tegra(e.g: Tegra30
> > has a 32x32 24bpp or 64x64 2bpp hardware cursor). So you may change it
> > to "hardware accelerated cursor"?
> > 
> > > 
> > > Signed-off-by: Thierry Reding 
> > > ---
> > [...]
> > > +
> > > +static const uint32_t plane_formats[] = {
> > > + DRM_FORMAT_XRGB,
> > > + DRM_FORMAT_YUV422,
> > 
> > I haven't found something related with YUV format in this patch set. For
> > example, "tegra_dc_format" also doesn't take YUV into consideration. So
> > remove this line.
> 
> Also note that YUV422 is a planar format. And since it's not the most
> common 4:2:2 format, my first guess would be that it's probably not
> what you wanted. YUYV or UYVY is more likely the one you're after.

Yes, I copied it from the TRM, which has YUV422 listed as non-planar
format (it has YUV422, which is the planar variant). It isn't very
specific about which variant YUV422 really is, though.

As Mark said, the window setup code can't handle planar formats yet
and tegra_dc_format() doesn't convert between DRM and Tegra formats
other than 32-bit and 16-bit RGB either, so maybe I should just drop
it instead.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130115/c0deb9cd/attachment-0001.pgp>


[PATCH 2/3] drm/nouveau: use prime helpers

2013-01-15 Thread Aaron Plattner
Simplify the Nouveau prime implementation by using the default behavior provided
by drm_gem_prime_import and drm_gem_prime_export.

v2: Rename functions to nouveau_gem_prime_get_sg_table and
nouveau_gem_prime_import_sg_table.

Signed-off-by: Aaron Plattner 
Cc: Daniel Vetter 
Cc: David Airlie 
---
 drivers/gpu/drm/nouveau/nouveau_bo.h|   1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   |   9 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c   |   2 -
 drivers/gpu/drm/nouveau/nouveau_gem.h   |  10 +-
 drivers/gpu/drm/nouveau/nouveau_prime.c | 173 
 5 files changed, 34 insertions(+), 161 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h 
b/drivers/gpu/drm/nouveau/nouveau_bo.h
index 25ca379..836677a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.h
@@ -31,7 +31,6 @@ struct nouveau_bo {
int pin_refcnt;
 
struct ttm_bo_kmap_obj dma_buf_vmap;
-   int vmapping_count;
 };
 
 static inline struct nouveau_bo *
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 180a45e..5de1f9a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -645,8 +645,13 @@ driver = {
 
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-   .gem_prime_export = nouveau_gem_prime_export,
-   .gem_prime_import = nouveau_gem_prime_import,
+   .gem_prime_export = drm_gem_prime_export,
+   .gem_prime_import = drm_gem_prime_import,
+   .gem_prime_pin = nouveau_gem_prime_pin,
+   .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table,
+   .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
+   .gem_prime_vmap = nouveau_gem_prime_vmap,
+   .gem_prime_vunmap = nouveau_gem_prime_vunmap,
 
.gem_init_object = nouveau_gem_object_new,
.gem_free_object = nouveau_gem_object_del,
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 8bf695c..24e0aab 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -24,8 +24,6 @@
  *
  */
 
-#include 
-
 #include 
 
 #include "nouveau_drm.h"
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.h 
b/drivers/gpu/drm/nouveau/nouveau_gem.h
index 5c10492..8d7a3f0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.h
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.h
@@ -35,9 +35,11 @@ extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *, 
void *,
 extern int nouveau_gem_ioctl_info(struct drm_device *, void *,
  struct drm_file *);
 
-extern struct dma_buf *nouveau_gem_prime_export(struct drm_device *dev,
-   struct drm_gem_object *obj, int flags);
-extern struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev,
-   struct dma_buf *dma_buf);
+extern int nouveau_gem_prime_pin(struct drm_gem_object *);
+extern struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object 
*);
+extern struct drm_gem_object *nouveau_gem_prime_import_sg_table(
+   struct drm_device *, size_t size, struct sg_table *);
+extern void *nouveau_gem_prime_vmap(struct drm_gem_object *);
+extern void nouveau_gem_prime_vunmap(struct drm_gem_object *, void *);
 
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c 
b/drivers/gpu/drm/nouveau/nouveau_prime.c
index b8e05ae..f53e108 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -22,126 +22,42 @@
  * Authors: Dave Airlie
  */
 
-#include 
-
 #include 
 
 #include "nouveau_drm.h"
 #include "nouveau_gem.h"
 
-static struct sg_table *nouveau_gem_map_dma_buf(struct dma_buf_attachment 
*attachment,
- enum dma_data_direction dir)
+struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object *obj)
 {
-   struct nouveau_bo *nvbo = attachment->dmabuf->priv;
-   struct drm_device *dev = nvbo->gem->dev;
+   struct nouveau_bo *nvbo = nouveau_gem_object(obj);
int npages = nvbo->bo.num_pages;
-   struct sg_table *sg;
-   int nents;
-
-   mutex_lock(&dev->struct_mutex);
-   sg = drm_prime_pages_to_sg(nvbo->bo.ttm->pages, npages);
-   nents = dma_map_sg(attachment->dev, sg->sgl, sg->nents, dir);
-   mutex_unlock(&dev->struct_mutex);
-   return sg;
-}
-
-static void nouveau_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
- struct sg_table *sg, enum 
dma_data_direction dir)
-{
-   dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir);
-   sg_free_table(sg);
-   kfree(sg);
-}
-
-static void nouveau_gem_dmabuf_release(struct dma_buf *dma_buf)
-{
-   struct nouveau_bo *nvbo = dma_buf->priv;
-
-   if (nvbo->gem->export_dma_buf == dma_buf) {
-   nvbo->gem->export_dma_buf = NULL;
-   dr

[PATCH v3 1/3] drm: add prime helpers

2013-01-15 Thread Aaron Plattner
Instead of reimplementing all of the dma_buf functionality in every driver,
create helpers drm_prime_import and drm_prime_export that implement them in
terms of new, lower-level hook functions:

  gem_prime_pin: callback when a buffer is created, used to pin buffers into GTT
  gem_prime_get_sg_table: convert a drm_gem_object to an sg_table for export
  gem_prime_import_sg_table: convert an sg_table into a drm_gem_object
  gem_prime_vmap, gem_prime_vunmap: map and unmap an object

These hooks are optional; drivers can opt in by using drm_gem_prime_import and
drm_gem_prime_export as the .gem_prime_import and .gem_prime_export fields of
struct drm_driver.

v2:
- Drop .begin_cpu_access.  None of the drivers this code replaces implemented
  it.  Having it here was a leftover from when I was trying to include i915 in
  this rework.
- Use mutex_lock instead of mutex_lock_interruptible, as these three drivers
  did.  This patch series shouldn't change that behavior.
- Rename helpers to gem_prime_get_sg_table and gem_prime_import_sg_table.
  Rename struct sg_table* variables to 'sgt' for clarity.
- Update drm.tmpl for these new hooks.

v3:
- Pass the vaddr down to the driver.  This lets drivers that just call vunmap on
  the pointer avoid having to store the pointer in their GEM private structures.
- Move documentation into a /** DOC */ comment in drm_prime.c and include it in
  drm.tmpl with a !P line.  I tried to use !F lines to include documentation of
  the individual functions from drmP.h, but the docproc / kernel-doc scripts
  barf on that file, so hopefully this is good enough for now.
- apply refcount fix from commit be8a42ae60addd8b6092535c11b42d099d6470ec
  ("drm/prime: drop reference on imported dma-buf come from gem")

Signed-off-by: Aaron Plattner 
Cc: Daniel Vetter 
Cc: David Airlie 
---
 Documentation/DocBook/drm.tmpl |   4 +
 drivers/gpu/drm/drm_prime.c| 186 -
 include/drm/drmP.h |  12 +++
 3 files changed, 201 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4ee2304..ed40576 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -743,6 +743,10 @@ char *date;
   These two operations are mandatory for GEM drivers that support DRM
   PRIME.
 
+
+  DRM PRIME Helper Functions Reference
+!Pdrivers/gpu/drm/drm_prime.c PRIME Helpers
+
   
   
 GEM Objects Mapping
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 7f12573..366910d 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -53,7 +53,8 @@
  * Self-importing: if userspace is using PRIME as a replacement for flink
  * then it will get a fd->handle request for a GEM object that it created.
  * Drivers should detect this situation and return back the gem object
- * from the dma-buf private.
+ * from the dma-buf private.  Prime will do this automatically for drivers that
+ * use the drm_gem_prime_{import,export} helpers.
  */
 
 struct drm_prime_member {
@@ -62,6 +63,137 @@ struct drm_prime_member {
uint32_t handle;
 };
 
+static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
+   enum dma_data_direction dir)
+{
+   struct drm_gem_object *obj = attach->dmabuf->priv;
+   struct sg_table *sgt;
+
+   mutex_lock(&obj->dev->struct_mutex);
+
+   sgt = obj->dev->driver->gem_prime_get_sg_table(obj);
+
+   if (!IS_ERR_OR_NULL(sgt))
+   dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir);
+
+   mutex_unlock(&obj->dev->struct_mutex);
+   return sgt;
+}
+
+static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
+   struct sg_table *sgt, enum dma_data_direction dir)
+{
+   dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents, dir);
+   sg_free_table(sgt);
+   kfree(sgt);
+}
+
+static void drm_gem_dmabuf_release(struct dma_buf *dma_buf)
+{
+   struct drm_gem_object *obj = dma_buf->priv;
+
+   if (obj->export_dma_buf == dma_buf) {
+   /* drop the reference on the export fd holds */
+   obj->export_dma_buf = NULL;
+   drm_gem_object_unreference_unlocked(obj);
+   }
+}
+
+static void *drm_gem_dmabuf_vmap(struct dma_buf *dma_buf)
+{
+   struct drm_gem_object *obj = dma_buf->priv;
+   struct drm_device *dev = obj->dev;
+
+   return dev->driver->gem_prime_vmap(obj);
+}
+
+static void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
+{
+   struct drm_gem_object *obj = dma_buf->priv;
+   struct drm_device *dev = obj->dev;
+
+   dev->driver->gem_prime_vunmap(obj, vaddr);
+}
+
+static void *drm_gem_dmabuf_kmap_atomic(struct dma_buf *dma_buf,
+   unsigned long page_num)
+{
+   return NULL;
+}
+
+static void drm_gem_dmabuf_kunmap_atomic(struct dma_buf *dma_buf,
+   unsigned long page_num, void *addr

[PATCH v3 0/3] Prime helpers

2013-01-15 Thread Aaron Plattner
This series adds helper functions that abstract the core parts of
.gem_prime_import and .gem_prime_export so that drivers don't have to worry
about the low-level details.  These helpers are optional.  A driver can use them
by plugging in drm_gem_prime_import and drm_gem_prime_export into the drm_driver
structure, or it can bypass them by plugging in its own functions.  The first
patch adds these helpers, and the later patches switch three drivers over to
using them.

This version of the series addresses concerns raised by Daniel Vetter, and to
leave the vmap locking and refcounting to the dma-buf core code.  It also drops
Exynos from the series since its driver diverged between when I first sent out
this series and now.

This series depends on commit 90b6e90cb03352a352015ca213ac9f4fab3308f3 of the
for-next branch of git://git.linaro.org/people/sumitsemwal/linux-dma-buf

Aaron Plattner (3):
  drm: add prime helpers
  drm/nouveau: use prime helpers
  drm/radeon: use prime helpers

 Documentation/DocBook/drm.tmpl  |   4 +
 drivers/gpu/drm/drm_prime.c | 186 +++-
 drivers/gpu/drm/nouveau/nouveau_bo.h|   1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   |   9 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c   |   2 -
 drivers/gpu/drm/nouveau/nouveau_gem.h   |  10 +-
 drivers/gpu/drm/nouveau/nouveau_prime.c | 173 -
 drivers/gpu/drm/radeon/radeon.h |   1 -
 drivers/gpu/drm/radeon/radeon_drv.c |  21 ++--
 drivers/gpu/drm/radeon/radeon_prime.c   | 170 -
 include/drm/drmP.h  |  12 +++
 11 files changed, 270 insertions(+), 319 deletions(-)

-- 
1.8.1.1

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


[PATCH 3/3] drm/radeon: use prime helpers

2013-01-15 Thread Aaron Plattner
Simplify the Radeon prime implementation by using the default behavior provided
by drm_gem_prime_import and drm_gem_prime_export.

v2:
- Rename functions to radeon_gem_prime_get_sg_table and
  radeon_gem_prime_import_sg_table.
- Delete the now-unused vmapping_count variable.

Signed-off-by: Aaron Plattner 
Cc: Daniel Vetter 
Cc: David Airlie 
---
 drivers/gpu/drm/radeon/radeon.h   |   1 -
 drivers/gpu/drm/radeon/radeon_drv.c   |  21 +++--
 drivers/gpu/drm/radeon/radeon_prime.c | 170 +-
 3 files changed, 35 insertions(+), 157 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 34e5230..48bb80e 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -342,7 +342,6 @@ struct radeon_bo {
struct drm_gem_object   gem_base;

struct ttm_bo_kmap_obj dma_buf_vmap;
-   int vmapping_count;
 };
 #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index dff6cf7..7a63817 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -117,11 +117,13 @@ int radeon_mode_dumb_create(struct drm_file *file_priv,
 int radeon_mode_dumb_destroy(struct drm_file *file_priv,
 struct drm_device *dev,
 uint32_t handle);
-struct dma_buf *radeon_gem_prime_export(struct drm_device *dev,
-   struct drm_gem_object *obj,
-   int flags);
-struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev,
-  struct dma_buf *dma_buf);
+struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj);
+struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
+   size_t size,
+   struct sg_table *sg);
+int radeon_gem_prime_pin(struct drm_gem_object *obj);
+void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
+void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);

 #if defined(CONFIG_DEBUG_FS)
 int radeon_debugfs_init(struct drm_minor *minor);
@@ -396,8 +398,13 @@ static struct drm_driver kms_driver = {

.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-   .gem_prime_export = radeon_gem_prime_export,
-   .gem_prime_import = radeon_gem_prime_import,
+   .gem_prime_export = drm_gem_prime_export,
+   .gem_prime_import = drm_gem_prime_import,
+   .gem_prime_pin = radeon_gem_prime_pin,
+   .gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
+   .gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
+   .gem_prime_vmap = radeon_gem_prime_vmap,
+   .gem_prime_vunmap = radeon_gem_prime_vunmap,

.name = DRIVER_NAME,
.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/radeon/radeon_prime.c 
b/drivers/gpu/drm/radeon/radeon_prime.c
index 26c23bb..4940af7 100644
--- a/drivers/gpu/drm/radeon/radeon_prime.c
+++ b/drivers/gpu/drm/radeon/radeon_prime.c
@@ -28,199 +28,71 @@
 #include "radeon.h"
 #include 

-#include 
-
-static struct sg_table *radeon_gem_map_dma_buf(struct dma_buf_attachment 
*attachment,
-  enum dma_data_direction dir)
+struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj)
 {
-   struct radeon_bo *bo = attachment->dmabuf->priv;
-   struct drm_device *dev = bo->rdev->ddev;
+   struct radeon_bo *bo = gem_to_radeon_bo(obj);
int npages = bo->tbo.num_pages;
-   struct sg_table *sg;
-   int nents;
-
-   mutex_lock(&dev->struct_mutex);
-   sg = drm_prime_pages_to_sg(bo->tbo.ttm->pages, npages);
-   nents = dma_map_sg(attachment->dev, sg->sgl, sg->nents, dir);
-   mutex_unlock(&dev->struct_mutex);
-   return sg;
-}
-
-static void radeon_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
-struct sg_table *sg, enum 
dma_data_direction dir)
-{
-   dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir);
-   sg_free_table(sg);
-   kfree(sg);
-}
-
-static void radeon_gem_dmabuf_release(struct dma_buf *dma_buf)
-{
-   struct radeon_bo *bo = dma_buf->priv;
-
-   if (bo->gem_base.export_dma_buf == dma_buf) {
-   DRM_ERROR("unreference dmabuf %p\n", &bo->gem_base);
-   bo->gem_base.export_dma_buf = NULL;
-   drm_gem_object_unreference_unlocked(&bo->gem_base);
-   }
-}
-
-static void *radeon_gem_kmap_atomic(struct dma_buf *dma_buf, unsigned long 
page_num)
-{
-   return NULL;
-}
-
-static void radeon_gem_kunmap_atomic(struct dma_buf *dma_buf, unsigned long 
page_num, void *addr)
-{
-
-}
-static void *radeon_gem_k

[PATCH 2/3] drm/nouveau: use prime helpers

2013-01-15 Thread Aaron Plattner
Simplify the Nouveau prime implementation by using the default behavior provided
by drm_gem_prime_import and drm_gem_prime_export.

v2: Rename functions to nouveau_gem_prime_get_sg_table and
nouveau_gem_prime_import_sg_table.

Signed-off-by: Aaron Plattner 
Cc: Daniel Vetter 
Cc: David Airlie 
---
 drivers/gpu/drm/nouveau/nouveau_bo.h|   1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   |   9 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c   |   2 -
 drivers/gpu/drm/nouveau/nouveau_gem.h   |  10 +-
 drivers/gpu/drm/nouveau/nouveau_prime.c | 173 
 5 files changed, 34 insertions(+), 161 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h 
b/drivers/gpu/drm/nouveau/nouveau_bo.h
index 25ca379..836677a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.h
@@ -31,7 +31,6 @@ struct nouveau_bo {
int pin_refcnt;

struct ttm_bo_kmap_obj dma_buf_vmap;
-   int vmapping_count;
 };

 static inline struct nouveau_bo *
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 180a45e..5de1f9a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -645,8 +645,13 @@ driver = {

.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-   .gem_prime_export = nouveau_gem_prime_export,
-   .gem_prime_import = nouveau_gem_prime_import,
+   .gem_prime_export = drm_gem_prime_export,
+   .gem_prime_import = drm_gem_prime_import,
+   .gem_prime_pin = nouveau_gem_prime_pin,
+   .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table,
+   .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
+   .gem_prime_vmap = nouveau_gem_prime_vmap,
+   .gem_prime_vunmap = nouveau_gem_prime_vunmap,

.gem_init_object = nouveau_gem_object_new,
.gem_free_object = nouveau_gem_object_del,
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 8bf695c..24e0aab 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -24,8 +24,6 @@
  *
  */

-#include 
-
 #include 

 #include "nouveau_drm.h"
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.h 
b/drivers/gpu/drm/nouveau/nouveau_gem.h
index 5c10492..8d7a3f0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.h
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.h
@@ -35,9 +35,11 @@ extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *, 
void *,
 extern int nouveau_gem_ioctl_info(struct drm_device *, void *,
  struct drm_file *);

-extern struct dma_buf *nouveau_gem_prime_export(struct drm_device *dev,
-   struct drm_gem_object *obj, int flags);
-extern struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev,
-   struct dma_buf *dma_buf);
+extern int nouveau_gem_prime_pin(struct drm_gem_object *);
+extern struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object 
*);
+extern struct drm_gem_object *nouveau_gem_prime_import_sg_table(
+   struct drm_device *, size_t size, struct sg_table *);
+extern void *nouveau_gem_prime_vmap(struct drm_gem_object *);
+extern void nouveau_gem_prime_vunmap(struct drm_gem_object *, void *);

 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c 
b/drivers/gpu/drm/nouveau/nouveau_prime.c
index b8e05ae..f53e108 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -22,126 +22,42 @@
  * Authors: Dave Airlie
  */

-#include 
-
 #include 

 #include "nouveau_drm.h"
 #include "nouveau_gem.h"

-static struct sg_table *nouveau_gem_map_dma_buf(struct dma_buf_attachment 
*attachment,
- enum dma_data_direction dir)
+struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object *obj)
 {
-   struct nouveau_bo *nvbo = attachment->dmabuf->priv;
-   struct drm_device *dev = nvbo->gem->dev;
+   struct nouveau_bo *nvbo = nouveau_gem_object(obj);
int npages = nvbo->bo.num_pages;
-   struct sg_table *sg;
-   int nents;
-
-   mutex_lock(&dev->struct_mutex);
-   sg = drm_prime_pages_to_sg(nvbo->bo.ttm->pages, npages);
-   nents = dma_map_sg(attachment->dev, sg->sgl, sg->nents, dir);
-   mutex_unlock(&dev->struct_mutex);
-   return sg;
-}
-
-static void nouveau_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
- struct sg_table *sg, enum 
dma_data_direction dir)
-{
-   dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir);
-   sg_free_table(sg);
-   kfree(sg);
-}
-
-static void nouveau_gem_dmabuf_release(struct dma_buf *dma_buf)
-{
-   struct nouveau_bo *nvbo = dma_buf->priv;
-
-   if (nvbo->gem->export_dma_buf == dma_buf) {
-   nvbo->gem->export_dma_buf = NULL;
-   drm_gem_objec

[PATCH v3 1/3] drm: add prime helpers

2013-01-15 Thread Aaron Plattner
Instead of reimplementing all of the dma_buf functionality in every driver,
create helpers drm_prime_import and drm_prime_export that implement them in
terms of new, lower-level hook functions:

  gem_prime_pin: callback when a buffer is created, used to pin buffers into GTT
  gem_prime_get_sg_table: convert a drm_gem_object to an sg_table for export
  gem_prime_import_sg_table: convert an sg_table into a drm_gem_object
  gem_prime_vmap, gem_prime_vunmap: map and unmap an object

These hooks are optional; drivers can opt in by using drm_gem_prime_import and
drm_gem_prime_export as the .gem_prime_import and .gem_prime_export fields of
struct drm_driver.

v2:
- Drop .begin_cpu_access.  None of the drivers this code replaces implemented
  it.  Having it here was a leftover from when I was trying to include i915 in
  this rework.
- Use mutex_lock instead of mutex_lock_interruptible, as these three drivers
  did.  This patch series shouldn't change that behavior.
- Rename helpers to gem_prime_get_sg_table and gem_prime_import_sg_table.
  Rename struct sg_table* variables to 'sgt' for clarity.
- Update drm.tmpl for these new hooks.

v3:
- Pass the vaddr down to the driver.  This lets drivers that just call vunmap on
  the pointer avoid having to store the pointer in their GEM private structures.
- Move documentation into a /** DOC */ comment in drm_prime.c and include it in
  drm.tmpl with a !P line.  I tried to use !F lines to include documentation of
  the individual functions from drmP.h, but the docproc / kernel-doc scripts
  barf on that file, so hopefully this is good enough for now.
- apply refcount fix from commit be8a42ae60addd8b6092535c11b42d099d6470ec
  ("drm/prime: drop reference on imported dma-buf come from gem")

Signed-off-by: Aaron Plattner 
Cc: Daniel Vetter 
Cc: David Airlie 
---
 Documentation/DocBook/drm.tmpl |   4 +
 drivers/gpu/drm/drm_prime.c| 186 -
 include/drm/drmP.h |  12 +++
 3 files changed, 201 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4ee2304..ed40576 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -743,6 +743,10 @@ char *date;
   These two operations are mandatory for GEM drivers that support DRM
   PRIME.
 
+
+  DRM PRIME Helper Functions Reference
+!Pdrivers/gpu/drm/drm_prime.c PRIME Helpers
+
   
   
 GEM Objects Mapping
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 7f12573..366910d 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -53,7 +53,8 @@
  * Self-importing: if userspace is using PRIME as a replacement for flink
  * then it will get a fd->handle request for a GEM object that it created.
  * Drivers should detect this situation and return back the gem object
- * from the dma-buf private.
+ * from the dma-buf private.  Prime will do this automatically for drivers that
+ * use the drm_gem_prime_{import,export} helpers.
  */

 struct drm_prime_member {
@@ -62,6 +63,137 @@ struct drm_prime_member {
uint32_t handle;
 };

+static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
+   enum dma_data_direction dir)
+{
+   struct drm_gem_object *obj = attach->dmabuf->priv;
+   struct sg_table *sgt;
+
+   mutex_lock(&obj->dev->struct_mutex);
+
+   sgt = obj->dev->driver->gem_prime_get_sg_table(obj);
+
+   if (!IS_ERR_OR_NULL(sgt))
+   dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir);
+
+   mutex_unlock(&obj->dev->struct_mutex);
+   return sgt;
+}
+
+static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
+   struct sg_table *sgt, enum dma_data_direction dir)
+{
+   dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents, dir);
+   sg_free_table(sgt);
+   kfree(sgt);
+}
+
+static void drm_gem_dmabuf_release(struct dma_buf *dma_buf)
+{
+   struct drm_gem_object *obj = dma_buf->priv;
+
+   if (obj->export_dma_buf == dma_buf) {
+   /* drop the reference on the export fd holds */
+   obj->export_dma_buf = NULL;
+   drm_gem_object_unreference_unlocked(obj);
+   }
+}
+
+static void *drm_gem_dmabuf_vmap(struct dma_buf *dma_buf)
+{
+   struct drm_gem_object *obj = dma_buf->priv;
+   struct drm_device *dev = obj->dev;
+
+   return dev->driver->gem_prime_vmap(obj);
+}
+
+static void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
+{
+   struct drm_gem_object *obj = dma_buf->priv;
+   struct drm_device *dev = obj->dev;
+
+   dev->driver->gem_prime_vunmap(obj, vaddr);
+}
+
+static void *drm_gem_dmabuf_kmap_atomic(struct dma_buf *dma_buf,
+   unsigned long page_num)
+{
+   return NULL;
+}
+
+static void drm_gem_dmabuf_kunmap_atomic(struct dma_buf *dma_buf,
+   unsigned long page_num, void *addr)

[PATCH v3 0/3] Prime helpers

2013-01-15 Thread Aaron Plattner
This series adds helper functions that abstract the core parts of
.gem_prime_import and .gem_prime_export so that drivers don't have to worry
about the low-level details.  These helpers are optional.  A driver can use them
by plugging in drm_gem_prime_import and drm_gem_prime_export into the drm_driver
structure, or it can bypass them by plugging in its own functions.  The first
patch adds these helpers, and the later patches switch three drivers over to
using them.

This version of the series addresses concerns raised by Daniel Vetter, and to
leave the vmap locking and refcounting to the dma-buf core code.  It also drops
Exynos from the series since its driver diverged between when I first sent out
this series and now.

This series depends on commit 90b6e90cb03352a352015ca213ac9f4fab3308f3 of the
for-next branch of git://git.linaro.org/people/sumitsemwal/linux-dma-buf

Aaron Plattner (3):
  drm: add prime helpers
  drm/nouveau: use prime helpers
  drm/radeon: use prime helpers

 Documentation/DocBook/drm.tmpl  |   4 +
 drivers/gpu/drm/drm_prime.c | 186 +++-
 drivers/gpu/drm/nouveau/nouveau_bo.h|   1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   |   9 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c   |   2 -
 drivers/gpu/drm/nouveau/nouveau_gem.h   |  10 +-
 drivers/gpu/drm/nouveau/nouveau_prime.c | 173 -
 drivers/gpu/drm/radeon/radeon.h |   1 -
 drivers/gpu/drm/radeon/radeon_drv.c |  21 ++--
 drivers/gpu/drm/radeon/radeon_prime.c   | 170 -
 include/drm/drmP.h  |  12 +++
 11 files changed, 270 insertions(+), 319 deletions(-)

-- 
1.8.1.1



[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #10 from Bryan Quigley  ---
Reverting commit d025e9e2b890db679f1246037bf65bd4be512627 does indeed fix the
Big Picture issue.  Will test the patch now..

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCHv5 0/8] Support for Tegra 2D hardware

2013-01-15 Thread Thierry Reding
On Tue, Jan 15, 2013 at 01:26:14PM +0200, Terje Bergstrom wrote:
> This set of patches adds support for Tegra20 and Tegra30 host1x and
> 2D. It is based on linux-next-20130114.
> 
> The fifth version merges DRM and host1x drivers into one driver. This
> allowed moving include/linux/host1x.h back into the driver and removed
> the need for a dummy platform device. This version also uses the code
> from tegradrm driver almost as is, so there are a lot less actual code
> changes.
> 
> This patch set does not have the host1x allocator, but it uses CMA
> helpers for memory management.
> 
> host1x is the driver that controls host1x hardware. It supports
> host1x command channels, synchronization, and memory management. It
> is sectioned into logical driver under drivers/gpu/host1x and
> physical driver under drivers/host1x/hw. The physical driver is
> compiled with the hardware headers of the particular host1x version.
> 
> The hardware units are described (briefly) in the Tegra2 TRM. Wiki
> page https://gitorious.org/linux-tegra-drm/pages/Host1xIntroduction
> also contains a short description of the functionality.
> 
> The patch set merges tegradrm into host1x and adds 2D driver, which
> uses host1x channels and sync points. The patch set also adds user
> space API to tegradrm for accessing host1x and 2D.
> 
> Terje Bergstrom (8):
>   gpu: host1x: Add host1x driver
>   gpu: host1x: Add syncpoint wait and interrupts
>   gpu: host1x: Add channel support
>   gpu: host1x: Add debug support
>   drm: tegra: Move drm to live under host1x
>   gpu: host1x: Remove second host1x driver
>   ARM: tegra: Add board data and 2D clocks
>   drm: tegra: Add gr2d device

Hi Terje,

Just by a quick glance this looks like we're getting closer. To make
reviewing easier, would you mind resending patches formatted with -M so
that git actually detects that tegra-drm was moved. That should make it
easy to see what exactly needed to be changed besides the relocation.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130115/949584bb/attachment.pgp>


[RFC v2 6/8] gpu: drm: tegra: Remove redundant host1x

2013-01-15 Thread Thierry Reding
On Fri, Jan 04, 2013 at 01:25:06PM -0700, Stephen Warren wrote:
> On 01/04/2013 03:09 AM, Terje Bergstr?m wrote:
> ...
> > I think we have now two ways to go forward with cons and pros:
> >  1) Keep host1x and tegra-drm as separate driver
> >+ Code almost done
> >- we need dummy device and dummy driver
> >- extra code and API when host1x creates dummy device and its passed
> > to tegra-drm
> 
> Just to play devil's advocate:
> 
> I suspect that's only a few lines of code.
> 
> >- tegra-drm device would need to be a child of host1x device. Having
> > virtual and real devices as host1x children sounds weird.
> 
> And I doubt that would cause problems.
> 
> >  2) Merge host1x and tegra-drm into one module. drm is a subcomponent,
> > and whatever other personalities we wish would also be subcomponents of
> > host1x. host1x calls tegra-drm directly to handle preparation for drm
> > initialization. As they're in the same module, circular dependency is ok.
> >+ Simpler conceptually (no dummy device/driver)
> >+ Less code
> >- Proposal doesn't yet exist
> 
> But that said, I agree this approach would be very reasonable; it seems
> to me that host1x really is the main HW behind a DRM driver or a V4L2
> driver or ... As such, it seems quite reasonable for a single struct
> device to exist that represents host1x, and for the driver for that
> device to register both a DRM and a V4L2 driver etc. The code could
> physically be organized into separate modules, and under different
> Kconfig options for configurability etc.
> 
> But either way, I'll let you (Thierry and Terje) work out which way to go.

Sorry for not getting back to you on this earlier. I just remembered
this thread when I saw Terje's latest patch series.

I agree that having everything in one location will make things a lot
easier, even if it means we have to add the tegra-drm driver to a new
location. In the long run I think this will pay off, though.

That said, I see that Terje has chosen this approach in his latest
series, so it's all good.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130115/8ecb3af9/attachment.pgp>


[PATCH v2 2/5] drm/tegra: Add plane support

2013-01-15 Thread Thierry Reding
On Mon, Jan 14, 2013 at 06:03:44PM +0100, Lucas Stach wrote:
> Am Montag, den 14.01.2013, 17:05 +0100 schrieb Thierry Reding:
[...]
> > +   value = (WIN_A_ACT_REQ << index) | (WIN_A_UPDATE << index);
> > +   tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
> This should be two separate writes to the register. I don't know how
> relevant this is on real HW, but the TRM states: "Restrictions: ACT_REQ
> cannot be programmed at the same time the corresponding "UPDATE" is
> programmed."
> 
> Better be safe than sorry and split it up.

It doesn't seem to make a difference, but I can split it up anyway.

[...]
> > +   /*
> > +* Disable blending and assume Window A is the bottom-most window,
> > +* Window C is the top-most window and Window B is in the middle.
> > +*/
> I would like to see the root window using WIN_C, so we only loose the
> least capable plane (WIN_A: no filtering or YUV conversion) when using a
> plane for the hardware cursor. Maybe you can fold this in, otherwise
> I'll send a patch on top of this series.

On the other hand, doing so will loose a perfectly good video overlay
plane.

[...]
> > +   value = (WIN_A_ACT_REQ << index) | (WIN_A_UPDATE << index);
> > +   tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
> Same comment as above.

Done. I'll fold a similar change into the .mode_set_base() patch and
will also add a patch that converts the remaining occurrences in
tegra_crtc_commit().

Thanks,
Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130115/22486929/attachment.pgp>


Re: [PATCH 5/5] drm/tegra: Implement page-flipping support

2013-01-15 Thread Thierry Reding
On Tue, Jan 15, 2013 at 06:53:19PM +0100, Daniel Vetter wrote:
> On Mon, Jan 14, 2013 at 4:55 PM, Thierry Reding
>  wrote:
> > +static void tegra_drm_preclose(struct drm_device *drm, struct drm_file 
> > *file)
> > +{
> > +   struct drm_crtc *crtc;
> > +
> > +   list_for_each_entry(crtc, &drm->mode_config.crtc_list, head)
> > +   tegra_dc_cancel_page_flip(crtc, file);
> > +}
> > +
> 
> Why that? If userspace dies while a flip is outstanding, it's imo ok
> to execute it - otherwise there might be an accounting mismatch if the
> hw still scans out the old fb, but drm believes the new one is used.
> Or do I miss something?

I looked at the shmobile driver for inspiration and they do this as
well. Doing so seemed reasonable since there'd be no file to deliver the
event to.

> The reason I've skimmed through the patches is to check for
> implications with my modeset locking rework. Review on that would be
> highly appreciated ...

I'm not sure how suited I am for review given my limited experience, but
I'll see if I can make some time to take a look.

Thierry


pgplU1grdcx6f.pgp
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 2/5] drm/tegra: Add plane support

2013-01-15 Thread Lucas Stach
Am Dienstag, den 15.01.2013, 17:53 +0800 schrieb Mark Zhang:
> On 01/15/2013 12:05 AM, Thierry Reding wrote:
> > Add support for the B and C planes which support RGB and YUV pixel
> > formats and can be used as overlays or hardware cursor.
> 
> I think "hardware cursor" has specific meaning for Tegra(e.g: Tegra30
> has a 32x32 24bpp or 64x64 2bpp hardware cursor). So you may change it
> to "hardware accelerated cursor"?
> 
According to the TRM no Tegra has ARGB hardware cursor support, but only
2-color. So we talked about doing the hardware cursor by using a plane.
If the TRM is wrong in this regard and we can get a ARGB cursor on Tegra
3 it would be nice to know.

> > 
> > Signed-off-by: Thierry Reding 
> > ---
> [...]
> > +};
> > +
> > +static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc)
> > +{
> > +   unsigned int i;
> > +   int err = 0;
> > +
> > +   for (i = 0; i < 2; i++) {
> > +   struct tegra_plane *plane;
> > +
> > +   plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
> > +   if (!plane)
> > +   return -ENOMEM;
> > +
> > +   plane->index = i;
> 
> I suggest to change this line to: "plane->index = i + 1;". This makes
> the plane's index be consistent with Tegra's windows number. And also we
> don't need to worry about passing "plane->index + 1" to some functions
> which need to know which window is operating on.
> 
Again, if we make WIN_C the root window, we can keep the plane index
assignment as is and get rid of the "index + 1" passing.




[PATCHv5 7/8] ARM: tegra: Add board data and 2D clocks

2013-01-15 Thread Stephen Warren
On 01/15/2013 04:26 AM, Terje Bergstrom wrote:
> Add a driver alias gr2d for Tegra 2D device, and assign a duplicate
> of 2D clock to that driver alias.

FYI on this one patch - it won't be applied to the Tegra tree until
after Prashant's common clock framework changes are applied. As such, it
will need some rework once those patches are applied, or perhaps won't
even be relevant any more; see below.

> diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c 
> b/arch/arm/mach-tegra/board-dt-tegra20.c

> + OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x5414, "gr2d", NULL),

I assume the only reason to add AUXDATA is to give the device a specific
name, which will then match the driver name in the clock driver:

> - CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"),
> + CLK_DUPLICATE("2d", "gr2d", "gr2d"),

If so, this shouldn't be needed once the common clock framework patches
are applied, since all device clocks will be retrieved from device tree,
and hence the device name will be irrelevant; the phandle in device tree
is all that will matter.


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #11 from Bruno Jacquet   2013-01-15 19:38:05 ---
(In reply to comment #9)
> Does reverting the following commit fix the issue?
> 
> commit d025e9e2b890db679f1246037bf65bd4be512627
> Author: Jerome Glisse 
> Date:   Thu Nov 29 10:35:41 2012 -0500
> 
> drm/radeon: do not move bo to different placement at each cs
> 
> The bo creation placement is where the bo will be. Instead of trying
> to move bo at each command stream let this work to another worker
> thread that will use more advance heuristic.
> 
> agd5f: remove leftover unused variable
> 
> Signed-off-by: Jerome Glisse 
> Reviewed-by: Alex Deucher 

It does fix the corruption.

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 30151] HDMI audio via radeon DRM driver is not working.

2013-01-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=30151

--- Comment #6 from Andy Furniss  ---
(In reply to comment #5)
> Off course !
> 
> cat /proc/asound/cards
>  0 [Intel  ]: HDA-Intel - HDA Intel
>   HDA Intel at 0xfc50 irq 47
>  1 [HDMI   ]: HDA-Intel - HDA ATI HDMI
>   HDA ATI HDMI at 0xfc01 irq 48
> 
> cat /proc/asound/devices
>   2: [ 0- 0]: digital audio playback
>   3: [ 0- 0]: digital audio capture
>   4: [ 0- 0]: hardware dependent
>   5: [ 0]   : control
>   6: [ 1- 3]: digital audio playback
>   7: [ 1- 0]: hardware dependent
>   8: [ 1]   : control
>  33:: timer

Looks like vlc is trying the wrong device - from your output -

"Audio device 'hdmi: CARD = HDMI, DEV = 0 "can not be used:"

You need to get vlc to use card 1 device 3, I don't use vlc so can't help with
that. I don't use smplayer either but with plain mplayer you would do -

mplayer -ao alsa:device=hw=1.3

Pulse may complicate things - I don't know as I don't use that.

If you still can't get any playback run alsamixer press F6 select hdmi and make
sure it says OO not MM. Pressing m will toggle between Open and Mute.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #10 from Bruno Jacquet   2013-01-15 19:26:08 ---
(In reply to comment #8)
> (In reply to comment #6)
> > ==> So maybe dd54fef DID fix the kernel crash but replaced it with the
> > corruption I'm seeing ?
> 
> Does the corruption also occur with dd54fee7d440c4a9756cce2c24a50c15e4c17ccb
> applied manually on top of 0d0b3e7443bed6b49cb90fe7ddc4b5578a83a88d?

g0d0b3e7 with patch dd54fee7d I see no corruption

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu: drm/nouveau/nouveau_fence.c: remove unnecessary null pointer check

2013-01-15 Thread Cong Ding
On Tue, Jan 15, 2013 at 10:39:23AM +, David Howells wrote:
> Cong Ding  wrote:
> 
> > the variable sender is dereferenced in line 190, so it is no reason to check
> > null again in line 198.
> 
> Did you mean "The variable 'chan'"?
sorry, my fault. so should I send a new version to correct the typo?
- cong



Re: [PATCHv5 7/8] ARM: tegra: Add board data and 2D clocks

2013-01-15 Thread Stephen Warren
On 01/15/2013 04:26 AM, Terje Bergstrom wrote:
> Add a driver alias gr2d for Tegra 2D device, and assign a duplicate
> of 2D clock to that driver alias.

FYI on this one patch - it won't be applied to the Tegra tree until
after Prashant's common clock framework changes are applied. As such, it
will need some rework once those patches are applied, or perhaps won't
even be relevant any more; see below.

> diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c 
> b/arch/arm/mach-tegra/board-dt-tegra20.c

> + OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x5414, "gr2d", NULL),

I assume the only reason to add AUXDATA is to give the device a specific
name, which will then match the driver name in the clock driver:

> - CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"),
> + CLK_DUPLICATE("2d", "gr2d", "gr2d"),

If so, this shouldn't be needed once the common clock framework patches
are applied, since all device clocks will be retrieved from device tree,
and hence the device name will be irrelevant; the phandle in device tree
is all that will matter.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu: drm/nouveau/nouveau_fence.c: remove unnecessary null pointer check

2013-01-15 Thread David Howells
Cong Ding  wrote:

> the variable sender is dereferenced in line 190, so it is no reason to check
> null again in line 198.

Did you mean "The variable 'chan'"?

David


Re: Patch "drm: Add EDID_QUIRK_FORCE_REDUCED_BLANKING for ASUS VW222S" has been added to the 3.4-stable tree

2013-01-15 Thread Greg KH
On Tue, Jan 15, 2013 at 04:23:41PM +0100, Daniel Vetter wrote:
> On Tue, Jan 15, 2013 at 3:31 PM, Ilija Hadzic
>  wrote:
> > I thought I saw a revert for that patch on the mailing list yesterday:
> >
> > http://lists.freedesktop.org/archives/dri-devel/2013-January/033322.html
> 
> Yeah, patch is bogus and the revert is already acked by the original author.

Thanks for letting me know, now dropped from the 3.4-stable queue.

greg k-h
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 30151] HDMI audio via radeon DRM driver is not working.

2013-01-15 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=30151

--- Comment #4 from Andy Furniss  ---
(In reply to comment #3)
> No sound with HDMI port on my Radeon HD3650 mobility (with free drivers
> because Kernel>3.2)
> 
> Description of problem:
> I have no sound with my HDMI port, but the image is OK.
> I use it with the VLC player or smplayer with HDMI audio output alsa. 
> With Kernels <= 3.2, I used the fglrx catalyst drivers, that worked
> perfectly.
> I tested the solution for adding the entry "radeon.audio = 1" in Grub2 but
> without success.
> With smplayer, videos plays too fast and without sound.
> With vlc, I receive an error message, also without sound.
> "The audio output failed:
> Audio device 'hdmi: CARD = HDMI, DEV = 0 "can not be used:
> Device or resource busy. "
> 
> 
> Version-Release number of selected component (if applicable):
> Rosa Desktop 2012 "fresh", lib64drm_radeon1 2.4.40, radeon-firmware
> 20120322, Kernel 3.6.10, alsa 1.0.26, pulseaudio 2.1, rosa mediaplayer
> 1.5.1, smplayer 0.8.3, vlc 2.0.4
> 
> I don't know what to do ... only using analog output and a simple converter
> jack / rca ... Good Bye Dolby Digital !

Can you post the output from 

cat /proc/asound/cards
and
cat /proc/asound/devices

-- 
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/20130115/7a6b526c/attachment.html>


Re: [PATCH 5/5] drm/tegra: Implement page-flipping support

2013-01-15 Thread Daniel Vetter
On Mon, Jan 14, 2013 at 4:55 PM, Thierry Reding
 wrote:
> +static void tegra_drm_preclose(struct drm_device *drm, struct drm_file *file)
> +{
> +   struct drm_crtc *crtc;
> +
> +   list_for_each_entry(crtc, &drm->mode_config.crtc_list, head)
> +   tegra_dc_cancel_page_flip(crtc, file);
> +}
> +

Why that? If userspace dies while a flip is outstanding, it's imo ok
to execute it - otherwise there might be an accounting mismatch if the
hw still scans out the old fb, but drm believes the new one is used.
Or do I miss something?

The reason I've skimmed through the patches is to check for
implications with my modeset locking rework. Review on that would be
highly appreciated ...


Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 30151] HDMI audio via radeon DRM driver is not working.

2013-01-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=30151

--- Comment #5 from mtz...@yahoo.fr ---
Off course !

cat /proc/asound/cards
 0 [Intel  ]: HDA-Intel - HDA Intel
  HDA Intel at 0xfc50 irq 47
 1 [HDMI   ]: HDA-Intel - HDA ATI HDMI
  HDA ATI HDMI at 0xfc01 irq 48

cat /proc/asound/devices
  2: [ 0- 0]: digital audio playback
  3: [ 0- 0]: digital audio capture
  4: [ 0- 0]: hardware dependent
  5: [ 0]   : control
  6: [ 1- 3]: digital audio playback
  7: [ 1- 0]: hardware dependent
  8: [ 1]   : control
 33:: timer

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Patch "drm: Add EDID_QUIRK_FORCE_REDUCED_BLANKING for ASUS VW222S" has been added to the 3.4-stable tree

2013-01-15 Thread Greg KH
On Tue, Jan 15, 2013 at 04:23:41PM +0100, Daniel Vetter wrote:
> On Tue, Jan 15, 2013 at 3:31 PM, Ilija Hadzic
>  wrote:
> > I thought I saw a revert for that patch on the mailing list yesterday:
> >
> > http://lists.freedesktop.org/archives/dri-devel/2013-January/033322.html
> 
> Yeah, patch is bogus and the revert is already acked by the original author.

Thanks for letting me know, now dropped from the 3.4-stable queue.

greg k-h


[Bug 58659] With latest kernel 3.8-rc1, compiz crashes after boot

2013-01-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=58659

--- Comment #9 from Alex Deucher  ---
Does reverting the following commit fix the corruption issue?

commit d025e9e2b890db679f1246037bf65bd4be512627
Author: Jerome Glisse 
Date:   Thu Nov 29 10:35:41 2012 -0500

drm/radeon: do not move bo to different placement at each cs

The bo creation placement is where the bo will be. Instead of trying
to move bo at each command stream let this work to another worker
thread that will use more advance heuristic.

agd5f: remove leftover unused variable

Signed-off-by: Jerome Glisse 
Reviewed-by: Alex Deucher 

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 52491] radeon massive screen corruption BARTS HD6870

2013-01-15 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=52491





--- Comment #9 from Alex Deucher   2013-01-15 17:37:44 
---
Does reverting the following commit fix the issue?

commit d025e9e2b890db679f1246037bf65bd4be512627
Author: Jerome Glisse 
Date:   Thu Nov 29 10:35:41 2012 -0500

drm/radeon: do not move bo to different placement at each cs

The bo creation placement is where the bo will be. Instead of trying
to move bo at each command stream let this work to another worker
thread that will use more advance heuristic.

agd5f: remove leftover unused variable

Signed-off-by: Jerome Glisse 
Reviewed-by: Alex Deucher 

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] gpu: drm/nouveau/nouveau_fence.c: remove unnecessary null pointer check

2013-01-15 Thread Cong Ding
the variable chan is dereferenced in line 190, so it is no reason to check
null again in line 198.

Signed-off-by: Cong Ding 
---
 drivers/gpu/drm/nouveau/nouveau_fence.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c 
b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 1d049be..b6b8e49 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -195,11 +195,9 @@ nouveau_fence_new(struct nouveau_channel *chan, struct 
nouveau_fence **pfence)
return -ENOMEM;
kref_init(&fence->kref);
 
-   if (chan) {
-   ret = nouveau_fence_emit(fence, chan);
-   if (ret)
-   nouveau_fence_unref(&fence);
-   }
+   ret = nouveau_fence_emit(fence, chan);
+   if (ret)
+   nouveau_fence_unref(&fence);
 
*pfence = fence;
return ret;
-- 
1.7.10.4

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


Re: [PATCH] gpu: drm/nouveau/nouveau_fence.c: remove unnecessary null pointer check

2013-01-15 Thread David Howells
Cong Ding  wrote:

> > > the variable sender is dereferenced in line 190, so it is no reason to 
> > > check
> > > null again in line 198.
> > 
> > Did you mean "The variable 'chan'"?
> sorry, my fault. so should I send a new version to correct the typo?

Yep.

David
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >