[Bug 60879] X11 can't start with acceleration enabled

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=60879

--- Comment #17 from Alex Deucher  ---
(In reply to comment #16)
> Created attachment 76921 [details]
> Screenshots with and without glamor
> 
> X11 doesn't render properly. The pixels seem to be shuffled. Maybe a shader
> doesn't write where it's supposed to?

Looks like the tiling configuration is wrong on your system.

-- 
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/20130322/902a1833/attachment.html>


[Bug 60879] X11 can't start with acceleration enabled

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=60879

--- Comment #16 from Hristo Venev  ---
Created attachment 76921
  --> https://bugs.freedesktop.org/attachment.cgi?id=76921=edit
Screenshots with and without glamor

X11 doesn't render properly. The pixels seem to be shuffled. Maybe a shader
doesn't write where it's supposed to?

There is no kernel output caused by this.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130322/50868c61/attachment.html>


[Bug 60879] X11 can't start with acceleration enabled

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=60879

--- Comment #15 from Hristo Venev  ---
Now egl{tri,gears}_screen work. However they don't render properly. Square
pixel blocks seem to be "misplaced". I will test with Xorg and attach a
screenshot.

-- 
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/20130322/473c65ec/attachment.html>


[PATCH v3 2/2] drm: Add EDID force quirk for MMT Monitor2Go HD+

2013-03-22 Thread Dylan Semler
Set the new EDID_QUIRK_FORCE_MODE bit for the MMT Monitor2Go HD+ monitor
and add it to the edid_quirk_force_mode_list.

Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 38b8641..2f30be4 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },

+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -137,6 +140,8 @@ static struct edid_quirk_force_mode {
int vrefresh;
bool reduced;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, 1600, 900, 60, 1 },
 };

 /*
-- 
1.7.11.7



[PATCH v3 1/2] drm: Enhance EDID quirks to explicitly set a mode

2013-03-22 Thread Dylan Semler
There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this "just work".

This patch sets up a new quirk list where monitors' correct width,
height, refresh rate, and reduced blanking parameters are specified.
When a matching monitor is attached the full mode is calculated with
drm_cvt_mode() and added to the connector.  The DRM_MODE_TYPE_PREFERRED
bit is set on the new mode and unset from all other modes.

The patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.  This
bit needs to be set for the new quirk list discribed above to be
checked.

Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 78 ++
 1 file changed, 78 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..38b8641 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1 << 6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1 << 7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1 << 8)

 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,16 @@ static struct edid_quirk {
{ "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };

+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+   bool reduced;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2231,70 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }

+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh, bool reduced)
+{
+   struct drm_display_mode *mode, *t, *cur_mode;
+   struct drm_device *dev = connector->dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay < 0)
+   return 0;
+   if (vdisplay < 0)
+   return 0;
+   if (vrefresh < 0)
+   return 0;
+
+   /* loop through the probed modes and clear the preferred bit */
+   list_for_each_entry_safe(cur_mode, t, >probed_modes, head)
+   cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
+
+   mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, reduced, 0, 0);
+
+   if (mode) {
+   mode->type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = _quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode->vendor) &&
+   (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode->hdisplay,
+   quirk_mode->vdisplay,
+   quirk_mode->vrefresh,
+   quirk_mode->reduced);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2879,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)

if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks & EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);

drm_add_display_info(edid, >display_info);

-- 
1.7.11.7



[PATCH v3 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
Changes in this version
 * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
 * Adds bool to specify reduced blanking to edid_quirk_force_mode
 * Removes preferred bit from all other modes

There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this "just work".

The first patch in this series sets up a new quirk list where monitors'
correct width, height, refresh rate, and reduced blanking parameters are
specified.  When a matching monitor is attached the full mode is
calculated with drm_cvt_mode() and added to the connector.  The
DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
other modes.

The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
This bit needs to be set for the new quirk list discribed above to be
checked.

The second patch adds the offending monitor to the quirk lists.

Dylan Semler (2):
  drm: Enhance EDID quirks to explicitly set a mode
  drm: Add EDID force quirk for MMT Monitor2Go HD+

 drivers/gpu/drm/drm_edid.c | 83 ++
 1 file changed, 83 insertions(+)

-- 
1.7.11.7



nouveau shuts the machine down with v3.9-rc1 (temperature (72 C) hit the 'shutdown' threshold).

2013-03-22 Thread Rafał Miłecki
2013/3/15 Martin Peres 
> As a follow up, Konrad sent me in private his vbios and the issue turned out 
> to be trivial.
> The reason why it behaved this way was that his vbios didn't have sensor 
> calibration values.
> The fix is available here: 
> http://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commit/59b4006b5b30828bbd094dffe3937333b43d1e12
>
> This fix is part of a pull request I sent to Ben.
>
> Thanks again Konrad for reporting and testing the patches, I'll add you as a 
> tester to this patch :)

Thanks guys for debugging analyzing and fixing this. I got the same problem on
00:05.0 VGA compatible controller [0300]: NVIDIA Corporation C51G
[GeForce 6100] [10de:0242] (rev a2)
and now it's fixed.

It seems it wasn't just a one single BIOS like that in the world ;)

--
Rafa?
-- next part --
8698080ee092bdbd6ee2cd5e7f707ceea2812bd8
Merge branch 'drm-nouveau-fixes-3.9' of 
git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-next
Regression fixes and oops fixes for nouveau.
[   76.082597] nouveau  [  DEVICE][:00:05.0] BOOT0  : 0x04e000a2
[   76.082605] nouveau  [  DEVICE][:00:05.0] Chipset: C51 (NV4E)
[   76.082609] nouveau  [  DEVICE][:00:05.0] Family : NV40
[   76.084534] nouveau  [   VBIOS][:00:05.0] checking PRAMIN for image...
[   76.125409] nouveau  [   VBIOS][:00:05.0] ... appears to be valid
[   76.125418] nouveau  [   VBIOS][:00:05.0] using image from PRAMIN
[   76.125658] nouveau  [   VBIOS][:00:05.0] BIT signature found
[   76.125663] nouveau  [   VBIOS][:00:05.0] version 05.51.22.28.10
[   76.128699] nouveau  [ PFB][:00:05.0] RAM type: stolen system memory
[   76.128708] nouveau  [ PFB][:00:05.0] RAM size: 64 MiB
[   76.128711] nouveau  [ PFB][:00:05.0]ZCOMP: 0 tags
[   76.781036] nouveau  [  PTHERM][:00:05.0] FAN control: none / external
[   76.781053] nouveau  [  PTHERM][:00:05.0] Thermal management: disabled
[   76.781057] nouveau  [  PTHERM][:00:05.0] internal sensor: yes
[   76.791261] nouveau  [  PTHERM][:00:05.0] programmed thresholds [ 90(2), 
95(3), 145(2), 135(5) ]
[   76.791267] nouveau  [  PTHERM][:00:05.0] temperature (154 C) hit the 
'fanboost' threshold
[   76.791271] nouveau  [  PTHERM][:00:05.0] Thermal management: automatic
[   76.791277] nouveau  [  PTHERM][:00:05.0] temperature (154 C) hit the 
'downclock' threshold
[   76.791281] nouveau  [  PTHERM][:00:05.0] temperature (154 C) hit the 
'critical' threshold
[   76.791285] nouveau  [  PTHERM][:00:05.0] temperature (154 C) hit the 
'shutdown' threshold

cf9a625fae3d0ce8dffab53b2758d7c0cf4a5ad4
Merge branch 'drm-nouveau-fixes-3.9' of 
git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-next
Lots of thermal fixes and fix a lockdep warning we've been seeing.
[   55.668598] nouveau  [  DEVICE][:00:05.0] BOOT0  : 0x04e000a2
[   55.668606] nouveau  [  DEVICE][:00:05.0] Chipset: C51 (NV4E)
[   55.668609] nouveau  [  DEVICE][:00:05.0] Family : NV40
[   55.670533] nouveau  [   VBIOS][:00:05.0] checking PRAMIN for image...
[   55.711390] nouveau  [   VBIOS][:00:05.0] ... appears to be valid
[   55.711399] nouveau  [   VBIOS][:00:05.0] using image from PRAMIN
[   55.711639] nouveau  [   VBIOS][:00:05.0] BIT signature found
[   55.711644] nouveau  [   VBIOS][:00:05.0] version 05.51.22.28.10
[   55.714712] nouveau  [ PFB][:00:05.0] RAM type: stolen system memory
[   55.714721] nouveau  [ PFB][:00:05.0] RAM size: 64 MiB
[   55.714724] nouveau  [ PFB][:00:05.0]ZCOMP: 0 tags
[   56.367033] nouveau  [  PTHERM][:00:05.0] FAN control: none / external
[   56.367052] nouveau  [  PTHERM][:00:05.0] fan management: disabled
[   56.367056] nouveau  [  PTHERM][:00:05.0] internal sensor: no
[   56.387298] nouveau  [  PTHERM][:00:05.0] programmed thresholds [ 90(2), 
95(3), 145(2), 135(5) ]


[Bug 61182] r600g causes KWin crashes with kernel 3.8

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=61182

--- Comment #16 from J?rg Billeter  ---
No gnome-shell crashes since I've upgraded to Mesa 9.1.1. Will post an update
in a few days whether it remains stable or I was just lucky today.

-- 
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/20130322/a8013035/attachment.html>


[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #20 from Tom  ---
It fixes this issue for me too, thanks.

-- 
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/20130322/7f270362/attachment.html>


[PATCHv9 9/9] drm: tegra: Add gr2d device

2013-03-22 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: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile|1 +
 drivers/gpu/host1x/dev.c   |7 +
 drivers/gpu/host1x/drm/Kconfig |9 ++
 drivers/gpu/host1x/drm/drm.c   |  212 -
 drivers/gpu/host1x/drm/drm.h   |   27 +++-
 drivers/gpu/host1x/drm/gr2d.c  |  339 
 drivers/gpu/host1x/host1x.h|4 +-
 include/uapi/drm/Kbuild|1 +
 include/uapi/drm/tegra_drm.h   |  136 
 9 files changed, 733 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/uapi/drm/tegra_drm.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 3768dbc..3b037b6 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -16,4 +16,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/gem.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 8ce9889..28e28a2 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -209,11 +209,17 @@ static int __init tegra_host1x_init(void)
err = platform_driver_register(_hdmi_driver);
if (err < 0)
goto unregister_dc;
+
+   err = platform_driver_register(_gr2d_driver);
+   if (err < 0)
+   goto unregister_hdmi;
 #endif

return 0;

 #ifdef CONFIG_DRM_TEGRA
+unregister_hdmi:
+   platform_driver_unregister(_hdmi_driver);
 unregister_dc:
platform_driver_unregister(_dc_driver);
 unregister_host1x:
@@ -226,6 +232,7 @@ module_init(tegra_host1x_init);
 static void __exit tegra_host1x_exit(void)
 {
 #ifdef CONFIG_DRM_TEGRA
+   platform_driver_unregister(_gr2d_driver);
platform_driver_unregister(_hdmi_driver);
platform_driver_unregister(_dc_driver);
 #endif
diff --git a/drivers/gpu/host1x/drm/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index f743540..6e3f567 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -13,6 +13,15 @@ config DRM_TEGRA

 if DRM_TEGRA

+config DRM_TEGRA_STAGING
+   bool "Enable HOST1X interface"
+   depends on STAGING
+   default n
+   help
+ Say yes if HOST1X should be available for userspace DRM users.
+
+ If unsure, choose N.
+
 config DRM_TEGRA_DEBUG
bool "NVIDIA Tegra DRM debug support"
help
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index c4e45c1..2b561c9 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2012 Avionic Design GmbH
- * Copyright (C) 2012 NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (C) 2012-2013 NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -14,6 +14,9 @@
 #include 
 #include 

+#include 
+#include 
+
 #include "host1x_client.h"
 #include "dev.h"
 #include "drm.h"
@@ -81,8 +84,10 @@ static int host1x_parse_dt(struct host1x_drm *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;
@@ -277,9 +282,24 @@ static int tegra_drm_unload(struct drm_device *drm)

 static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
 {
+   struct host1x_drm_file *fpriv;
+
+   fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
+   if (!fpriv)
+   return -ENOMEM;
+
+   INIT_LIST_HEAD(>contexts);
+   filp->driver_priv = fpriv;
+
return 0;
 }

+static void host1x_drm_context_free(struct host1x_drm_context *context)
+{
+   context->client->ops->close_channel(context);
+   kfree(context);
+}
+
 static void tegra_drm_lastclose(struct drm_device *drm)
 {
struct host1x_drm *host1x = drm->dev_private;
@@ -287,7 +307,190 @@ static void tegra_drm_lastclose(struct drm_device *drm)
tegra_fbdev_restore_mode(host1x->fbdev);
 }

+#ifdef CONFIG_DRM_TEGRA_STAGING
+static bool host1x_drm_file_owns_context(struct host1x_drm_file *file,
+struct host1x_drm_context *context)
+{
+   struct host1x_drm_context *ctx;
+
+   list_for_each_entry(ctx, >contexts, list)
+   if (ctx == context)
+   return true;
+
+   return 

[PATCHv9 8/9] gpu: host1x: drm: Add memory manager and fb

2013-03-22 Thread Terje Bergstrom
From: Arto Merilainen 

This patch introduces a memory manager for tegra drm and moves
existing parts to use it. As cma framebuffer helpers can no more
be used, this patch adds also a separate framebuffer driver for
tegra.

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile|1 +
 drivers/gpu/host1x/drm/Kconfig |8 +-
 drivers/gpu/host1x/drm/dc.c|   23 +--
 drivers/gpu/host1x/drm/drm.c   |   17 +-
 drivers/gpu/host1x/drm/drm.h   |   18 ++-
 drivers/gpu/host1x/drm/fb.c|  336 +++-
 drivers/gpu/host1x/drm/gem.c   |  270 
 drivers/gpu/host1x/drm/gem.h   |   59 +++
 8 files changed, 698 insertions(+), 34 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gem.c
 create mode 100644 drivers/gpu/host1x/drm/gem.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 9a6fc76..3768dbc 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -15,4 +15,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/gem.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/drm/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index 7db9b3a..f743540 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -2,11 +2,9 @@ config DRM_TEGRA
bool "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
+   select FB_SYS_FILLRECT
+   select FB_SYS_COPYAREA
+   select FB_SYS_IMAGEBLIT
help
  Choose this option if you have an NVIDIA Tegra SoC.

diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index 29a79b6..85ea616 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -14,9 +14,10 @@
 #include 
 #include 

-#include "drm.h"
-#include "dc.h"
 #include "host1x_client.h"
+#include "dc.h"
+#include "drm.h"
+#include "gem.h"

 struct tegra_plane {
struct drm_plane base;
@@ -52,9 +53,9 @@ static int tegra_plane_update(struct drm_plane *plane, struct 
drm_crtc *crtc,
window.bits_per_pixel = fb->bits_per_pixel;

for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++) {
-   struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, i);
+   struct tegra_bo *bo = tegra_fb_get_plane(fb, i);

-   window.base[i] = gem->paddr + fb->offsets[i];
+   window.base[i] = bo->paddr + fb->offsets[i];

/*
 * Tegra doesn't support different strides for U and V planes
@@ -137,7 +138,7 @@ static int tegra_dc_add_planes(struct drm_device *drm, 
struct tegra_dc *dc)
 static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
 struct drm_framebuffer *fb)
 {
-   struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, 0);
+   struct tegra_bo *bo = tegra_fb_get_plane(fb, 0);
unsigned long value;

tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER);
@@ -145,7 +146,7 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, 
int y,
value = fb->offsets[0] + y * fb->pitches[0] +
x * fb->bits_per_pixel / 8;

-   tegra_dc_writel(dc, gem->paddr + value, DC_WINBUF_START_ADDR);
+   tegra_dc_writel(dc, bo->paddr + value, DC_WINBUF_START_ADDR);
tegra_dc_writel(dc, fb->pitches[0], DC_WIN_LINE_STRIDE);

value = GENERAL_UPDATE | WIN_A_UPDATE;
@@ -187,20 +188,20 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
 {
struct drm_device *drm = dc->base.dev;
struct drm_crtc *crtc = >base;
-   struct drm_gem_cma_object *gem;
unsigned long flags, base;
+   struct tegra_bo *bo;

if (!dc->event)
return;

-   gem = drm_fb_cma_get_gem_obj(crtc->fb, 0);
+   bo = tegra_fb_get_plane(crtc->fb, 0);

/* check if new start address has been latched */
tegra_dc_writel(dc, READ_MUX, DC_CMD_STATE_ACCESS);
base = tegra_dc_readl(dc, DC_WINBUF_START_ADDR);
tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);

-   if (base == gem->paddr + crtc->fb->offsets[0]) {
+   if (base == bo->paddr + crtc->fb->offsets[0]) {
spin_lock_irqsave(>event_lock, flags);
drm_send_vblank_event(drm, dc->pipe, dc->event);
drm_vblank_put(drm, dc->pipe);
@@ -570,7 +571,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
   struct drm_display_mode *adjusted,
   int x, int y, struct drm_framebuffer *old_fb)
 {
-   struct 

[PATCHv9 7/9] gpu: host1x: Remove second host1x driver

2013-03-22 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: Arto Merilainen 
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|5 +-
 drivers/gpu/host1x/drm/drm.c   |  214 ++-
 drivers/gpu/host1x/drm/drm.h   |3 -
 drivers/gpu/host1x/drm/hdmi.c  |5 +-
 drivers/gpu/host1x/drm/host1x.c|  329 
 drivers/gpu/host1x/host1x_client.h |   35 
 10 files changed, 317 insertions(+), 342 deletions(-)
 delete mode 100644 drivers/gpu/host1x/drm/host1x.c
 create mode 100644 drivers/gpu/host1x/host1x_client.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 4761e8a..9a6fc76 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -13,6 +13,6 @@ host1x-y = \
 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 9689724..8ce9889 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -32,6 +32,19 @@
 #include "channel.h"
 #include "debug.h"
 #include "hw/host1x01.h"
+#include "host1x_client.h"
+
+void host1x_set_drm_data(struct device *dev, void *data)
+{
+   struct host1x *host1x = dev_get_drvdata(dev);
+   host1x->drm_data = data;
+}
+
+void *host1x_get_drm_data(struct device *dev)
+{
+   struct host1x *host1x = dev_get_drvdata(dev);
+   return host1x->drm_data;
+}

 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
 {
@@ -150,6 +163,8 @@ static int host1x_probe(struct platform_device *pdev)

host1x_debug_init(host);

+   host1x_drm_alloc(pdev);
+
return 0;

 fail_deinit_syncpt:
@@ -168,7 +183,7 @@ static int __exit host1x_remove(struct platform_device 
*pdev)
return 0;
 }

-static struct platform_driver platform_driver = {
+static struct platform_driver tegra_host1x_driver = {
.probe = host1x_probe,
.remove = __exit_p(host1x_remove),
.driver = {
@@ -178,8 +193,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(_host1x_driver);
+   if (err < 0)
+   return err;
+
+#ifdef CONFIG_DRM_TEGRA
+   err = platform_driver_register(_dc_driver);
+   if (err < 0)
+   goto unregister_host1x;
+
+   err = platform_driver_register(_hdmi_driver);
+   if (err < 0)
+   goto unregister_dc;
+#endif
+
+   return 0;
+
+#ifdef CONFIG_DRM_TEGRA
+unregister_dc:
+   platform_driver_unregister(_dc_driver);
+unregister_host1x:
+   platform_driver_unregister(_host1x_driver);
+   return err;
+#endif
+}
+module_init(tegra_host1x_init);
+
+static void __exit tegra_host1x_exit(void)
+{
+#ifdef CONFIG_DRM_TEGRA
+   platform_driver_unregister(_hdmi_driver);
+   platform_driver_unregister(_dc_driver);
+#endif
+   platform_driver_unregister(_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 4d16fe9..a1607d6 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -124,6 +124,8 @@ struct host1x {
unsigned int num_allocated_channels;

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

 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -299,4 +301,8 @@ static inline void host1x_hw_show_mlocks(struct host1x 
*host, struct output *o)
host->debug_op->show_mlocks(host, o);
 }

+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 d1f6609..29a79b6 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -16,6 

[PATCHv9 6/9] gpu: host1x: drm: Rename host1x to host1x_drm

2013-03-22 Thread Terje Bergstrom
From: Arto Merilainen 

Both host1x and drm drivers have host1x structures. This patch
renames the host1x structure under drm to follow name host1x_drm.

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/drm/dc.c |4 ++--
 drivers/gpu/host1x/drm/drm.c|4 ++--
 drivers/gpu/host1x/drm/drm.h|   14 +++---
 drivers/gpu/host1x/drm/fb.c |6 +++---
 drivers/gpu/host1x/drm/hdmi.c   |4 ++--
 drivers/gpu/host1x/drm/host1x.c |   22 --
 6 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index de94707..d1f6609 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -1097,7 +1097,7 @@ static const struct host1x_client_ops dc_client_ops = {

 static int tegra_dc_probe(struct platform_device *pdev)
 {
-   struct host1x *host1x = dev_get_drvdata(pdev->dev.parent);
+   struct host1x_drm *host1x = dev_get_drvdata(pdev->dev.parent);
struct resource *regs;
struct tegra_dc *dc;
int err;
@@ -1160,7 +1160,7 @@ static int tegra_dc_probe(struct platform_device *pdev)

 static int tegra_dc_remove(struct platform_device *pdev)
 {
-   struct host1x *host1x = dev_get_drvdata(pdev->dev.parent);
+   struct host1x_drm *host1x = dev_get_drvdata(pdev->dev.parent);
struct tegra_dc *dc = platform_get_drvdata(pdev);
int err;

diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index 9d452df..6c59bcd 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -26,7 +26,7 @@
 static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 {
struct device *dev = drm->dev;
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
int err;

host1x = dev_get_drvdata(dev);
@@ -69,7 +69,7 @@ static int tegra_drm_open(struct drm_device *drm, struct 
drm_file *filp)

 static void tegra_drm_lastclose(struct drm_device *drm)
 {
-   struct host1x *host1x = drm->dev_private;
+   struct host1x_drm *host1x = drm->dev_private;

drm_fbdev_cma_restore_mode(host1x->fbdev);
 }
diff --git a/drivers/gpu/host1x/drm/drm.h b/drivers/gpu/host1x/drm/drm.h
index a6c011d..7fedb6c 100644
--- a/drivers/gpu/host1x/drm/drm.h
+++ b/drivers/gpu/host1x/drm/drm.h
@@ -18,7 +18,7 @@
 #include 
 #include 

-struct host1x {
+struct host1x_drm {
struct drm_device *drm;
struct device *dev;
void __iomem *regs;
@@ -44,7 +44,7 @@ struct host1x_client_ops {
 };

 struct host1x_client {
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
struct device *dev;

const struct host1x_client_ops *ops;
@@ -52,12 +52,12 @@ struct host1x_client {
struct list_head list;
 };

-extern int host1x_drm_init(struct host1x *host1x, struct drm_device *drm);
-extern int host1x_drm_exit(struct host1x *host1x);
+extern int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm);
+extern int host1x_drm_exit(struct host1x_drm *host1x);

-extern int host1x_register_client(struct host1x *host1x,
+extern int host1x_register_client(struct host1x_drm *host1x,
  struct host1x_client *client);
-extern int host1x_unregister_client(struct host1x *host1x,
+extern int host1x_unregister_client(struct host1x_drm *host1x,
struct host1x_client *client);

 struct tegra_output;
@@ -66,7 +66,7 @@ struct tegra_dc {
struct host1x_client client;
spinlock_t lock;

-   struct host1x *host1x;
+   struct host1x_drm *host1x;
struct device *dev;

struct drm_crtc base;
diff --git a/drivers/gpu/host1x/drm/fb.c b/drivers/gpu/host1x/drm/fb.c
index 0391495..6ed885a 100644
--- a/drivers/gpu/host1x/drm/fb.c
+++ b/drivers/gpu/host1x/drm/fb.c
@@ -11,7 +11,7 @@

 static void tegra_drm_fb_output_poll_changed(struct drm_device *drm)
 {
-   struct host1x *host1x = drm->dev_private;
+   struct host1x_drm *host1x = drm->dev_private;

drm_fbdev_cma_hotplug_event(host1x->fbdev);
 }
@@ -23,7 +23,7 @@ static const struct drm_mode_config_funcs 
tegra_drm_mode_funcs = {

 int tegra_drm_fb_init(struct drm_device *drm)
 {
-   struct host1x *host1x = drm->dev_private;
+   struct host1x_drm *host1x = drm->dev_private;
struct drm_fbdev_cma *fbdev;

drm->mode_config.min_width = 0;
@@ -46,7 +46,7 @@ int tegra_drm_fb_init(struct drm_device *drm)

 void tegra_drm_fb_exit(struct drm_device *drm)
 {
-   struct host1x *host1x = drm->dev_private;
+   struct host1x_drm *host1x = drm->dev_private;

drm_fbdev_cma_fini(host1x->fbdev);
 }
diff --git a/drivers/gpu/host1x/drm/hdmi.c b/drivers/gpu/host1x/drm/hdmi.c
index bb747f6..f438f80 100644
--- a/drivers/gpu/host1x/drm/hdmi.c
+++ b/drivers/gpu/host1x/drm/hdmi.c
@@ -1189,7 +1189,7 @@ static const struct host1x_client_ops hdmi_client_ops = 

[PATCHv9 5/9] drm: tegra: Move drm to live under host1x

2013-03-22 Thread Terje Bergstrom
Make drm part of host1x driver.

Signed-off-by: Arto Merilainen 
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 |2 ++
 drivers/gpu/host1x/Makefile|5 +
 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
 16 files changed, 10 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%)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 1e82882..9031bb7 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -215,8 +215,6 @@ source "drivers/gpu/drm/cirrus/Kconfig"

 source "drivers/gpu/drm/shmobile/Kconfig"

-source "drivers/gpu/drm/tegra/Kconfig"
-
 source "drivers/gpu/drm/omapdrm/Kconfig"

 source "drivers/gpu/drm/tilcdc/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 0d59b24..847b830 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -49,7 +49,6 @@ 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-$(CONFIG_DRM_OMAP) += omapdrm/
 obj-$(CONFIG_DRM_TILCDC)   += tilcdc/
 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 00f0859..ee3af1e 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -18,4 +18,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 49fd580..4761e8a 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -10,4 +10,9 @@ host1x-y = \
debug.o \
hw/host1x01.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 6dd75a2..a6c011d 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.
  */

-#ifndef TEGRA_DRM_H
-#define TEGRA_DRM_H 1
+#ifndef HOST1X_DRM_H
+#define HOST1X_DRM_H 1

 #include 
 #include 
@@ -234,4 +234,4 @@ extern struct platform_driver 

[PATCHv9 4/9] gpu: host1x: Add debug support

2013-03-22 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: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile |1 +
 drivers/gpu/host1x/cdma.c   |4 +
 drivers/gpu/host1x/debug.c  |  210 +
 drivers/gpu/host1x/debug.h  |   51 +
 drivers/gpu/host1x/dev.c|3 +
 drivers/gpu/host1x/dev.h|   42 
 drivers/gpu/host1x/hw/cdma_hw.c |2 +
 drivers/gpu/host1x/hw/channel_hw.c  |   25 +++
 drivers/gpu/host1x/hw/debug_hw.c|  322 +++
 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/hw_host1x01_uclass.h  |6 +
 drivers/gpu/host1x/hw/syncpt_hw.c   |1 +
 drivers/gpu/host1x/syncpt.c |5 +
 15 files changed, 807 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 06a995b..49fd580 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 \
hw/host1x01.o

 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index 33935de..de72172 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -439,6 +439,10 @@ void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, 
u32 op2)
struct push_buffer *pb = >push_buffer;
u32 slots_free = cdma->slots_free;

+   if (host1x_debug_trace_cmdbuf)
+   trace_host1x_cdma_push(dev_name(cdma_to_channel(cdma)->dev),
+  op1, op2);
+
if (slots_free == 0) {
host1x_hw_cdma_flush(host1x, 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..3ec7d77
--- /dev/null
+++ b/drivers/gpu/host1x/debug.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ * Author: Erik Gilling 
+ *
+ * Copyright (C) 2011-2013 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"
+
+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, bool show_fifo)
+{
+   struct host1x *m = dev_get_drvdata(ch->dev->parent);
+   struct output *o = data;
+
+   mutex_lock(>reflock);
+   if (ch->refcount) {
+   mutex_lock(>cdma.lock);
+   if (show_fifo)
+   host1x_hw_show_channel_fifo(m, ch, o);
+   host1x_hw_show_channel_cdma(m, ch, o);
+   mutex_unlock(>cdma.lock);
+   }
+   mutex_unlock(>reflock);
+
+   return 0;
+}
+
+static void show_syncpts(struct host1x *m, struct output *o)
+{
+   int i;
+   host1x_debug_output(o, " syncpts \n");
+   for (i = 0; i < host1x_syncpt_nb_pts(m); i++) {
+   u32 max = host1x_syncpt_read_max(m->syncpt + i);
+   u32 min = host1x_syncpt_load(m->syncpt + i);
+   if (!min && !max)
+   continue;
+   host1x_debug_output(o, "id %d (%s) min %d max %d\n",
+   i, m->syncpt[i].name, min, max);
+   }
+
+   for (i = 0; i < host1x_syncpt_nb_bases(m); i++) {
+   u32 base_val;
+   base_val = host1x_syncpt_load_wait_base(m->syncpt + i);
+   if (base_val)
+   host1x_debug_output(o, "waitbase id %d val %d\n", i,
+   base_val);
+   }
+
+   host1x_debug_output(o, "\n");
+}
+

[PATCHv9 3/9] gpu: host1x: Add channel support

2013-03-22 Thread Terje Bergstrom
Add support for host1x client modules, and host1x channels to submit
work to the clients.

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Kconfig  |   12 +
 drivers/gpu/host1x/Makefile |3 +
 drivers/gpu/host1x/cdma.c   |  487 +
 drivers/gpu/host1x/cdma.h   |  100 +
 drivers/gpu/host1x/channel.c|  126 ++
 drivers/gpu/host1x/channel.h|   52 +++
 drivers/gpu/host1x/dev.c|   17 +
 drivers/gpu/host1x/dev.h|  113 +
 drivers/gpu/host1x/host1x.h |   28 ++
 drivers/gpu/host1x/host1x_bo.h  |   87 
 drivers/gpu/host1x/hw/cdma_hw.c |  324 ++
 drivers/gpu/host1x/hw/channel_hw.c  |  143 +++
 drivers/gpu/host1x/hw/host1x01.c|5 +
 drivers/gpu/host1x/hw/host1x01_hardware.h   |  116 ++
 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   |   11 +
 drivers/gpu/host1x/intr.c   |   28 +-
 drivers/gpu/host1x/intr.h   |6 +
 drivers/gpu/host1x/job.c|  603 +++
 drivers/gpu/host1x/job.h|  162 +++
 drivers/gpu/host1x/syncpt.c |   11 +
 drivers/gpu/host1x/syncpt.h |6 +
 include/trace/events/host1x.h   |  211 ++
 25 files changed, 2932 insertions(+), 1 deletion(-)
 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/host1x.h
 create mode 100644 drivers/gpu/host1x/host1x_bo.h
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c
 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

diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
index c01c450..00f0859 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -7,3 +7,15 @@ config TEGRA_HOST1X
  Tegra's graphics- and multimedia-related modules. The modules served
  by host1x are referred to as clients. host1x includes some other
  functionality, such as synchronization.
+
+if TEGRA_HOST1X
+
+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..06a995b 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -4,6 +4,9 @@ host1x-y = \
syncpt.o \
dev.o \
intr.o \
+   cdma.o \
+   channel.o \
+   job.o \
hw/host1x01.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..33935de
--- /dev/null
+++ b/drivers/gpu/host1x/cdma.c
@@ -0,0 +1,487 @@
+/*
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cdma.h"
+#include "channel.h"
+#include "dev.h"
+#include "debug.h"
+#include "host1x_bo.h"
+#include "job.h"
+
+/*
+ * push_buffer
+ *
+ * The push buffer is a circular array of words to be fetched by command DMA.
+ * Note that it works slightly differently to the sync queue; fence == pos
+ * means that the push buffer is full, not empty.
+ */
+
+#define HOST1X_PUSHBUFFER_SLOTS512
+
+/*
+ * Clean up push buffer resources
+ */
+static void host1x_pushbuffer_destroy(struct push_buffer *pb)
+{
+   struct host1x_cdma *cdma = pb_to_cdma(pb);
+   struct host1x *host1x = cdma_to_host1x(cdma);
+
+   if (pb->phys != 0)
+   dma_free_writecombine(host1x->dev, pb->size_bytes + 4,

[PATCHv9 2/9] gpu: host1x: Add syncpoint wait and interrupts

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

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile  |1 +
 drivers/gpu/host1x/dev.c |   12 ++
 drivers/gpu/host1x/dev.h |   51 +
 drivers/gpu/host1x/hw/host1x01.c |2 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h |   42 
 drivers/gpu/host1x/hw/intr_hw.c  |  143 +
 drivers/gpu/host1x/intr.c|  328 ++
 drivers/gpu/host1x/intr.h|   96 +
 drivers/gpu/host1x/syncpt.c  |  159 +++
 drivers/gpu/host1x/syncpt.h  |   12 ++
 10 files changed, 846 insertions(+)
 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 0d6002c..b967f6e 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -28,6 +28,7 @@
 #include 

 #include "dev.h"
+#include "intr.h"
 #include "hw/host1x01.h"

 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
@@ -123,13 +124,24 @@ static int host1x_probe(struct platform_device *pdev)
return err;
}

+   err = host1x_intr_init(host, syncpt_irq);
+   if (err) {
+   dev_err(>dev, "failed to initialize interrupts\n");
+   goto fail_deinit_syncpt;
+   }
+
return 0;
+
+fail_deinit_syncpt:
+   host1x_syncpt_deinit(host);
+   return err;
 }

 static int __exit host1x_remove(struct platform_device *pdev)
 {
struct host1x *host = platform_get_drvdata(pdev);

+   host1x_intr_deinit(host);
host1x_syncpt_deinit(host);
clk_disable_unprepare(host->clk);

diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index eaf6026..caf9cc6 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -21,6 +21,7 @@
 #include 

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

 struct host1x_syncpt;

@@ -33,6 +34,17 @@ struct host1x_syncpt_ops {
int (*patch_wait)(struct host1x_syncpt *syncpt, void *patch_addr);
 };

+struct host1x_intr_ops {
+   int (*init_host_sync)(struct host1x *host, u32 cpm,
+   void (*syncpt_thresh_work)(struct work_struct *work));
+   void (*set_syncpt_threshold)(
+   struct host1x *host, u32 id, u32 thresh);
+   void (*enable_syncpt_intr)(struct host1x *host, u32 id);
+   void (*disable_syncpt_intr)(struct host1x *host, u32 id);
+   void (*disable_all_syncpt_intrs)(struct host1x *host);
+   int (*free_syncpt_irq)(struct host1x *host);
+};
+
 struct host1x_info {
int nb_channels;/* host1x: num channels supported */
int nb_pts; /* host1x: num syncpoints supported */
@@ -50,7 +62,13 @@ struct host1x {
struct device *dev;
struct clk *clk;

+   struct mutex intr_mutex;
+   struct workqueue_struct *intr_wq;
+   int intr_syncpt_irq;
+
const struct host1x_syncpt_ops *syncpt_op;
+   const struct host1x_intr_ops *intr_op;
+
 };

 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -93,4 +111,37 @@ static inline int host1x_hw_syncpt_patch_wait(struct host1x 
*host,
return host->syncpt_op->patch_wait(sp, patch_addr);
 }

+static inline int host1x_hw_intr_init_host_sync(struct host1x *host, u32 cpm,
+   void (*syncpt_thresh_work)(struct work_struct *))
+{
+   return host->intr_op->init_host_sync(host, cpm, syncpt_thresh_work);
+}
+
+static inline void host1x_hw_intr_set_syncpt_threshold(struct host1x *host,
+  u32 id, u32 thresh)
+{
+   host->intr_op->set_syncpt_threshold(host, id, thresh);
+}
+
+static inline void host1x_hw_intr_enable_syncpt_intr(struct host1x *host,
+u32 id)
+{
+   host->intr_op->enable_syncpt_intr(host, id);
+}
+
+static inline void host1x_hw_intr_disable_syncpt_intr(struct host1x *host,
+ u32 id)
+{
+   host->intr_op->disable_syncpt_intr(host, id);
+}
+
+static inline void host1x_hw_intr_disable_all_syncpt_intrs(struct host1x *host)
+{
+   host->intr_op->disable_all_syncpt_intrs(host);
+}
+
+static inline int host1x_hw_intr_free_syncpt_irq(struct host1x *host)
+{
+   return host->intr_op->free_syncpt_irq(host);
+}
 #endif
diff --git 

[PATCHv9 1/9] gpu: host1x: Add host1x driver

2013-03-22 Thread Terje Bergstrom
Add host1x, the driver for host1x and its client unit 2D. The Tegra
host1x module is the DMA engine for register access to Tegra's
graphics- and multimedia-related modules. The modules served by
host1x are referred to as clients. host1x includes some other
functionality, such as synchronization.

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/Makefile  |1 +
 drivers/gpu/host1x/Kconfig|9 ++
 drivers/gpu/host1x/Makefile   |8 ++
 drivers/gpu/host1x/dev.c  |  153 +
 drivers/gpu/host1x/dev.h  |   96 +
 drivers/gpu/host1x/hw/Makefile|6 +
 drivers/gpu/host1x/hw/host1x01.c  |   33 +
 drivers/gpu/host1x/hw/host1x01.h  |   25 
 drivers/gpu/host1x/hw/host1x01_hardware.h |   27 
 drivers/gpu/host1x/hw/hw_host1x01_sync.h  |   74 ++
 drivers/gpu/host1x/hw/syncpt_hw.c |  102 ++
 drivers/gpu/host1x/syncpt.c   |  212 +
 drivers/gpu/host1x/syncpt.h   |  147 
 drivers/video/Kconfig |2 +
 include/trace/events/host1x.h |   61 +
 15 files changed, 956 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 30879df..d8a22c2 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1 +1,2 @@
 obj-y  += drm/ vga/
+obj-$(CONFIG_TEGRA_HOST1X) += host1x/
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
new file mode 100644
index 000..c01c450
--- /dev/null
+++ b/drivers/gpu/host1x/Kconfig
@@ -0,0 +1,9 @@
+config TEGRA_HOST1X
+   tristate "NVIDIA Tegra host1x driver"
+   help
+ Driver for the NVIDIA Tegra host1x hardware.
+
+ The Tegra host1x module is the DMA engine for register access to
+ Tegra's graphics- and multimedia-related modules. The modules served
+ by host1x are referred to as clients. host1x includes some other
+ functionality, such as synchronization.
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..0d6002c
--- /dev/null
+++ b/drivers/gpu/host1x/dev.c
@@ -0,0 +1,153 @@
+/*
+ * 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 
+
+#define CREATE_TRACE_POINTS
+#include 
+
+#include "dev.h"
+#include "hw/host1x01.h"
+
+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 const struct host1x_info host1x01_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_of_match[] = {
+   { .compatible = "nvidia,tegra30-host1x", .data = _info, },
+   { .compatible = "nvidia,tegra20-host1x", .data = _info, },
+   { },
+};
+MODULE_DEVICE_TABLE(of, 

[PATCHv9 0/9] Support Tegra 2D hardware

2013-03-22 Thread Terje Bergstrom
This set of patches adds support for Tegra20 and Tegra30 host1x and
2D. It is based on linux-next-20130322 with RTC fixes applied.

Changes in this version:
 * Renaming in drivers/gpu/host1x/drm/drm.c to shorten function names
 * Whitespace and function order fixes
 * An extra struct (host1x_addr_reg) removed
 * Added uapi Kbuild entry

Changes in version 8:
 * Own version of framebuffer driver due to move to own allocator
   * Thanks to Thierry Reding for help
 * Miscellaneous variable name, whitespace and IOCTL interface cleanups
 * Bug fixes:
   * Validator enabled again
   * Added new class 2D strechblit
 * Dropped patch "Support CMA object preallocation"

Changes in version 7:
 * host1x memory data structures refactored
 * Some "nvhost" leftovers renamed to host1x

Changes in version 6:
 * Rebased on latest tegradrm
 * Renamed tegradrm's host1x to host1x_drm
 * Indentation and line split fixed to follow tegradrm convention
 * Pointers to platform_device replaced with pointers to device
 * Added host1x allocator, and wired it in
 * Debug spew code fixed to access mem handles from host1x_job
 * CDMA code doesn't keep the mem handles anymore
 * Push buffer ops have been made generic code
 * Removed the pin_array optimization in host1x_job to simplify code
 * Large number of smaller changes

The driver implements an allocator using the dma mapping API. Each buffer is
assigned an ops structure to operate on it.

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 http://http.download.nvidia.com/tegra-public-appnotes/host1x.html
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.

The changes to add support to libdrm are in
git at gitorious.org:linux-host1x/libdrm-host1x.git

Arto Merilainen (2):
  gpu: host1x: drm: Rename host1x to host1x_drm
  gpu: host1x: drm: Add memory manager and fb

Terje Bergstrom (7):
  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
  drm: tegra: Add gr2d device

 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|  217 
 drivers/gpu/drm/tegra/fb.c |   52 --
 drivers/gpu/drm/tegra/host1x.c |  327 
 drivers/gpu/host1x/Kconfig |   23 +
 drivers/gpu/host1x/Makefile|   20 +
 drivers/gpu/host1x/cdma.c  |  491 ++
 drivers/gpu/host1x/cdma.h  |  100 
 drivers/gpu/host1x/channel.c   |  126 +
 drivers/gpu/host1x/channel.h   |   52 ++
 drivers/gpu/host1x/debug.c |  210 
 drivers/gpu/host1x/debug.h |   51 ++
 drivers/gpu/host1x/dev.c   |  246 +
 drivers/gpu/host1x/dev.h   |  308 
 drivers/gpu/{drm/tegra => host1x/drm}/Kconfig  |   19 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.c |   26 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.h |0
 drivers/gpu/host1x/drm/drm.c   |  640 
 drivers/gpu/{drm/tegra => host1x/drm}/drm.h|   68 ++-
 drivers/gpu/host1x/drm/fb.c|  372 ++
 drivers/gpu/host1x/drm/gem.c   |  270 ++
 drivers/gpu/host1x/drm/gem.h   |   59 +++
 drivers/gpu/host1x/drm/gr2d.c  |  339 +
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c   |5 +-
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h   |0
 drivers/gpu/{drm/tegra => host1x/drm}/output.c |0
 drivers/gpu/{drm/tegra => host1x/drm}/rgb.c|0
 drivers/gpu/host1x/host1x.h|   30 ++
 drivers/gpu/host1x/host1x_bo.h |   87 
 drivers/gpu/host1x/host1x_client.h |   35 ++
 drivers/gpu/host1x/hw/Makefile |6 +
 drivers/gpu/host1x/hw/cdma_hw.c|  326 
 drivers/gpu/host1x/hw/channel_hw.c |  168 +++
 drivers/gpu/host1x/hw/debug_hw.c   |  322 
 drivers/gpu/host1x/hw/host1x01.c   

[PATCHv9 0/9] Support Tegra 2D hardware

2013-03-22 Thread Thierry Reding
On Fri, Mar 22, 2013 at 04:34:00PM +0200, Terje Bergstrom wrote:
> This set of patches adds support for Tegra20 and Tegra30 host1x and
> 2D. It is based on linux-next-20130322 with RTC fixes applied.
> 
> Changes in this version:
>  * Renaming in drivers/gpu/host1x/drm/drm.c to shorten function names
>  * Whitespace and function order fixes
>  * An extra struct (host1x_addr_reg) removed
>  * Added uapi Kbuild entry
> 
> Changes in version 8:
>  * Own version of framebuffer driver due to move to own allocator
>* Thanks to Thierry Reding for help
>  * Miscellaneous variable name, whitespace and IOCTL interface cleanups
>  * Bug fixes:
>* Validator enabled again
>* Added new class 2D strechblit
>  * Dropped patch "Support CMA object preallocation"
> 
> Changes in version 7:
>  * host1x memory data structures refactored
>  * Some "nvhost" leftovers renamed to host1x
> 
> Changes in version 6:
>  * Rebased on latest tegradrm
>  * Renamed tegradrm's host1x to host1x_drm
>  * Indentation and line split fixed to follow tegradrm convention
>  * Pointers to platform_device replaced with pointers to device
>  * Added host1x allocator, and wired it in
>  * Debug spew code fixed to access mem handles from host1x_job
>  * CDMA code doesn't keep the mem handles anymore
>  * Push buffer ops have been made generic code
>  * Removed the pin_array optimization in host1x_job to simplify code
>  * Large number of smaller changes
> 
> The driver implements an allocator using the dma mapping API. Each buffer is
> assigned an ops structure to operate on it.
> 
> 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 http://http.download.nvidia.com/tegra-public-appnotes/host1x.html
> 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.
> 
> The changes to add support to libdrm are in
> git at gitorious.org:linux-host1x/libdrm-host1x.git
> 
> Arto Merilainen (2):
>   gpu: host1x: drm: Rename host1x to host1x_drm
>   gpu: host1x: drm: Add memory manager and fb
> 
> Terje Bergstrom (7):
>   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
>   drm: tegra: Add gr2d device
> 
>  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|  217 
>  drivers/gpu/drm/tegra/fb.c |   52 --
>  drivers/gpu/drm/tegra/host1x.c |  327 
>  drivers/gpu/host1x/Kconfig |   23 +
>  drivers/gpu/host1x/Makefile|   20 +
>  drivers/gpu/host1x/cdma.c  |  491 ++
>  drivers/gpu/host1x/cdma.h  |  100 
>  drivers/gpu/host1x/channel.c   |  126 +
>  drivers/gpu/host1x/channel.h   |   52 ++
>  drivers/gpu/host1x/debug.c |  210 
>  drivers/gpu/host1x/debug.h |   51 ++
>  drivers/gpu/host1x/dev.c   |  246 +
>  drivers/gpu/host1x/dev.h   |  308 
>  drivers/gpu/{drm/tegra => host1x/drm}/Kconfig  |   19 +-
>  drivers/gpu/{drm/tegra => host1x/drm}/dc.c |   26 +-
>  drivers/gpu/{drm/tegra => host1x/drm}/dc.h |0
>  drivers/gpu/host1x/drm/drm.c   |  640 
> 
>  drivers/gpu/{drm/tegra => host1x/drm}/drm.h|   68 ++-
>  drivers/gpu/host1x/drm/fb.c|  372 ++
>  drivers/gpu/host1x/drm/gem.c   |  270 ++
>  drivers/gpu/host1x/drm/gem.h   |   59 +++
>  drivers/gpu/host1x/drm/gr2d.c  |  339 +
>  drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c   |5 +-
>  drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h   |0
>  drivers/gpu/{drm/tegra => host

Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Daniel Vetter
On Fri, Mar 22, 2013 at 3:02 PM, Dylan Semler  wrote:
> On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher  
> wrote:
>>
>> On Thu, Mar 21, 2013 at 5:42 PM, Dylan Semler 
>> wrote:
>> > Oops.  I neglected to preface this with my motivation:  I have a new
>> > monitor that doesn't report its native resolution in its EDID block.  It
>> > seemed to me this calls for an EDID quirk, but the current quirk
>> > infrastructure doesn't allow explicitly creating new modes.  So I set
>> > out
>> > to make a simple enhancement to allow specifying a new mode and then
>> > setting it as preferred.
>> >
>>
>> That's odd.  Maybe it's actually in an extension block or something like
>> that?
>
> Yeah, I agree.  According to edid-decode /sys/class/drm/card0-HDMI-A-1/edid
> there's one extension block, but none of those modes are the native
> resolution
> either.

Hm, we only recently added support for E-EDID (i.e. more than 1
extension block). Have you checked whether latest kernels fare better?
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


drm/nouveau: Possible hardware corruption of older GeForce card

2013-03-22 Thread Calvin Owens
On 03/21/13 02:56, Calvin Owens wrote:
> On 03/21/13 02:24, Calvin Owens wrote:
>> On 03/21/13 01:59, Ben Skeggs wrote:
>>> On Thu, 2013-03-21 at 01:34 -0500, Calvin Owens wrote:
 DRM hasn't worked on my desktop machine (GeForce 9800) with Nouveau for
 a little while (v3.9-rc1 didn't), but worked as of commit e204378 on
 Linus' tree for one boot, and subsequently always fails.

 After running that version, v3.6, which has always worked in the past,
 also fails, which is obviously somewhat troubling.

 The card will POST, but when modesetting tries to happen, errors result
 and the console remains in VGA mode. On a second computer (on which I
 have also used this card in the past), I now get the same "PRAMIN
 readback failed" error and no DRM console.

 I don't want to get ahead of myself, since I have no idea what exactly
 is happening, but it certainly appears that booting e204378 somehow
 changed something on the hardware that is preventing nouveau modesetting
 from being successful in that and previous vesrions of the kernel.

 I was going to add debugging output from the nouveau tree HEAD, but it
 locks the machine hard with strange visual artifacts. Any other info I
 can provide? Any idea where I should start digging?

 Thanks,
 Calvin Owens

 (e204378 just happened to be HEAD when I pulled from Linus' tree; I
 can't narrow it down to something in Nouveau or DRM since I don't yet
 know how to undo the apparent hardware alteration)
>>> Does doing a complete cold boot fix things temporarily until you run
>>> with that revision again, or, is it of a permanent nature?
>> No, it seems to be permanent.
>>
>>> If it's the latter, it sounds more like the hw (specifically, the ram
>>> chips) is dying honestly...
>>
>> Is there some way to test that? The suddenness of it is what made me
>> discount the possibility that the chip is dying - I've used this card
>> almost daily for years in that desktop, so I would've expected
>> intermittent failures rather than a sudden cutoff... but you could be right.
>>
> 
> Just noticed this: the semicolon fixed below causes
> nv50_display_flip_stop to return immediately instead of waiting for the
> memory writes to appear, which may be the cause of some of those
> DMA-related errors I was seeing. (I'll resend the patch separately)
> 
> diff --git a/drivers/gpu/drm/nouveau/nv50_display.c
> b/drivers/gpu/drm/nouveau/nv50_display.c
> index 2db5799..96bc2f3 100644
> --- a/drivers/gpu/drm/nouveau/nv50_display.c
> +++ b/drivers/gpu/drm/nouveau/nv50_display.c
> @@ -479,7 +479,7 @@ nv50_display_flip_wait(void *data)
>  {
>   struct nv50_display_flip *flip = data;
>   if (nouveau_bo_rd32(flip->disp->sync, flip->chan->addr / 4) ==
> -   flip->chan->data);
> +   flip->chan->data)
>   return true;
>   usleep_range(1, 2);
>   return false;
> 

I hope this whole thing doesn't seem to melodramatic... my thinking was simply
that, given that MTBF's of video cards tend to be quoted in the 5+ year range,
the probability of one dying in the 2-hour window between my rebooting with 
that 
kernel version had to be extremely low. It seemed as though the null hypothesis
was rather certainly disproven.

Is this worth pursuing? I can try to find an identical card and see if it
happens again... but if you're convinced it's a non-issue, I'll just forget
about it.

Thanks,
Calvin

>>> Ben.
>>>

 v3.9-rc2-00333-ge204378 worked the first time I booted it:
> [0.00] Linux version 3.9.0-rc2-amd-00333-ge204378 (calvinow at 
> Beethoven) (gcc version 4.6.3 (Gentoo 4.6.3 p1.11, pie-0.5.2) ) #45 SMP 
> Sat Mar 16 11:43:13 CDT 2013
> [0.00] Command line: console=ttyUSB0,115200n8
> [1.866715] nouveau :02:00.0: enabling device (0004 -> 0007)
> [1.866942] nouveau  [  DEVICE][:02:00.0] BOOT0  : 0x092a00a2
> [1.866944] nouveau  [  DEVICE][:02:00.0] Chipset: G92 (NV92)
> [1.866946] nouveau  [  DEVICE][:02:00.0] Family : NV50
> [1.867756] nouveau  [   VBIOS][:02:00.0] checking PRAMIN for 
> image...
> [1.867762] nouveau  [   VBIOS][:02:00.0] ... signature not found
> [1.867763] nouveau  [   VBIOS][:02:00.0] checking PROM for 
> image...
> [2.025439] nouveau  [   VBIOS][:02:00.0] ... appears to be valid
> [2.025440] nouveau  [   VBIOS][:02:00.0] using image from PROM
> [2.025544] nouveau  [   VBIOS][:02:00.0] BIT signature found
> [2.025546] nouveau  [   VBIOS][:02:00.0] version 62.92.52.00.07
> [2.025688] nouveau  [ DEVINIT][:02:00.0] adaptor not initialised
> [2.025690] nouveau  [   VBIOS][:02:00.0] running init tables
> [2.133248] nouveau  [ PFB][:02:00.0] RAM type: GDDR3
> [

[Bug 37696] [RADEON:KMS:PLL] frequent colored lines appear on screen

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=37696

--- Comment #4 from Alex Deucher  ---
Created attachment 76913
  --> https://bugs.freedesktop.org/attachment.cgi?id=76913=edit
possible fix

Does the attached 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/20130322/95130c9f/attachment.html>


[Bug 45641] Screen goes black randomly

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=45641

--- Comment #17 from Alex Deucher  ---
Created attachment 76907
  --> https://bugs.freedesktop.org/attachment.cgi?id=76907=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/20130322/b4e26cd4/attachment-0001.html>


[Bug 58150] LLVM regression on 4890 since r600g: Use default mul/mad function for tgsi-to-llvm

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=58150

Michel D?nzer  changed:

   What|Removed |Added

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

--- Comment #3 from Michel D?nzer  ---
commit c446baa0be1ed2a3bf157519f89a65d348aad17c
Author: Michel Danzer 
Date:   Fri Mar 22 14:09:10 2013 +

R600: Use legacy (0 * anything = 0) MUL instructions for pow intrinsics

Fixes wrong lighting in some corner cases with r600g and radeonsi, e.g.
manifested by failure of two piglit/glean tests and intermittent black
patches in many apps.

Tested on SI and RS880.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62012 [radeonsi]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58150 [r600g]

NOTE: This is a candidate for the Mesa stable branch.

Reviewed-by: Christian K?nig 

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk at 177730
91177308-0d34-0410-b5e6-96231b3b80d8

-- 
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/20130322/4a41fc26/attachment.html>


[Bug 62012] Intermittent black geometry

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62012

Michel D?nzer  changed:

   What|Removed |Added

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

--- Comment #1 from Michel D?nzer  ---
commit c446baa0be1ed2a3bf157519f89a65d348aad17c
Author: Michel Danzer 
Date:   Fri Mar 22 14:09:10 2013 +

R600: Use legacy (0 * anything = 0) MUL instructions for pow intrinsics

Fixes wrong lighting in some corner cases with r600g and radeonsi, e.g.
manifested by failure of two piglit/glean tests and intermittent black
patches in many apps.

Tested on SI and RS880.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62012 [radeonsi]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58150 [r600g]

NOTE: This is a candidate for the Mesa stable branch.

Reviewed-by: Christian K?nig 

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk at 177730
91177308-0d34-0410-b5e6-96231b3b80d8

-- 
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/20130322/5b73adc1/attachment.html>


[Bug 45641] Screen goes black randomly

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=45641

--- Comment #16 from Jan Pape? (honyczek)  ---
(Additional info to comment #12)
> Interesting: If I connect only one monitor (either on cable 1 or 2), it works 
> well.
It is not working well, but in only blinks in longer intervals. After resuming
from hibernation, it started blinking more.
(In reply to comment #13)
> 2. Disable acceleration (Option "NoAccel" "True" in the device section of 
> your xorg.conf)

After starting Xorg with NoAccel option, it is not blinking. But:
1. why don't use acceleration on accelerated graphic card?
2. I can't use rotated monitor, because it requires acceleration enabled.

-- 
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/20130322/c5b29704/attachment.html>


Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 10:41 AM, Daniel Vetter  wrote:
>
> On Fri, Mar 22, 2013 at 3:02 PM, Dylan Semler 
wrote:
> > On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher 
> > wrote:
> >>
> >> That's odd.  Maybe it's actually in an extension block or something
like
> >> that?
> >
> > Yeah, I agree.  According to edid-decode
/sys/class/drm/card0-HDMI-A-1/edid
> > there's one extension block, but none of those modes are the native
> > resolution either.
>
> Hm, we only recently added support for E-EDID (i.e. more than 1 extension
> block). Have you checked whether latest kernels fare better?

I just tried booting with 3.9rc3 and my distro's latest package of
xorg-utils;
I get the same results.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130322/e8b9cd5a/attachment.html>


[PATCHv8 9/9] drm: tegra: Add gr2d device

2013-03-22 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: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile|1 +
 drivers/gpu/host1x/dev.c   |7 +
 drivers/gpu/host1x/drm/Kconfig |9 ++
 drivers/gpu/host1x/drm/drm.c   |  213 -
 drivers/gpu/host1x/drm/drm.h   |   27 +++-
 drivers/gpu/host1x/drm/gr2d.c  |  340 
 drivers/gpu/host1x/host1x.h|4 +-
 include/uapi/drm/tegra_drm.h   |  136 
 8 files changed, 734 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/uapi/drm/tegra_drm.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 3768dbc..3b037b6 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -16,4 +16,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/gem.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 8ce9889..28e28a2 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -209,11 +209,17 @@ static int __init tegra_host1x_init(void)
err = platform_driver_register(_hdmi_driver);
if (err < 0)
goto unregister_dc;
+
+   err = platform_driver_register(_gr2d_driver);
+   if (err < 0)
+   goto unregister_hdmi;
 #endif

return 0;

 #ifdef CONFIG_DRM_TEGRA
+unregister_hdmi:
+   platform_driver_unregister(_hdmi_driver);
 unregister_dc:
platform_driver_unregister(_dc_driver);
 unregister_host1x:
@@ -226,6 +232,7 @@ module_init(tegra_host1x_init);
 static void __exit tegra_host1x_exit(void)
 {
 #ifdef CONFIG_DRM_TEGRA
+   platform_driver_unregister(_gr2d_driver);
platform_driver_unregister(_hdmi_driver);
platform_driver_unregister(_dc_driver);
 #endif
diff --git a/drivers/gpu/host1x/drm/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index f743540..6e3f567 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -13,6 +13,15 @@ config DRM_TEGRA

 if DRM_TEGRA

+config DRM_TEGRA_STAGING
+   bool "Enable HOST1X interface"
+   depends on STAGING
+   default n
+   help
+ Say yes if HOST1X should be available for userspace DRM users.
+
+ If unsure, choose N.
+
 config DRM_TEGRA_DEBUG
bool "NVIDIA Tegra DRM debug support"
help
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index c4e45c1..6db1bd6 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2012 Avionic Design GmbH
- * Copyright (C) 2012 NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (C) 2012-2013 NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -14,6 +14,11 @@
 #include 
 #include 

+#include 
+#include 
+
+#include 
+
 #include "host1x_client.h"
 #include "dev.h"
 #include "drm.h"
@@ -81,8 +86,10 @@ static int host1x_parse_dt(struct host1x_drm *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;
@@ -277,9 +284,24 @@ static int tegra_drm_unload(struct drm_device *drm)

 static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
 {
+   struct host1x_drm_file *fpriv;
+
+   fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
+   if (!fpriv)
+   return -ENOMEM;
+
+   INIT_LIST_HEAD(>contexts);
+   filp->driver_priv = fpriv;
+
return 0;
 }

+static void host1x_drm_context_free(struct host1x_drm_context *context)
+{
+   context->client->ops->close_channel(context);
+   kfree(context);
+}
+
 static void tegra_drm_lastclose(struct drm_device *drm)
 {
struct host1x_drm *host1x = drm->dev_private;
@@ -287,7 +309,189 @@ static void tegra_drm_lastclose(struct drm_device *drm)
tegra_fbdev_restore_mode(host1x->fbdev);
 }

+#ifdef CONFIG_DRM_TEGRA_STAGING
+static int tegra_drm_ioctl_syncpt_read(struct drm_device *drm, void *data,
+  struct drm_file *file)
+{
+   struct drm_tegra_syncpt_read *args = data;
+   struct host1x *host = dev_get_drvdata(drm->dev);
+   struct host1x_syncpt *sp = host1x_syncpt_get(host, args->id);
+
+   if (!sp)
+   return 

[PATCHv8 8/9] gpu: host1x: drm: Add memory manager and fb

2013-03-22 Thread Terje Bergstrom
From: Arto Merilainen 

This patch introduces a memory manager for tegra drm and moves
existing parts to use it. As cma framebuffer helpers can no more
be used, this patch adds also a separate framebuffer driver for
tegra.

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile|1 +
 drivers/gpu/host1x/drm/Kconfig |8 +-
 drivers/gpu/host1x/drm/dc.c|   23 +--
 drivers/gpu/host1x/drm/drm.c   |   17 +-
 drivers/gpu/host1x/drm/drm.h   |   18 ++-
 drivers/gpu/host1x/drm/fb.c|  338 +++-
 drivers/gpu/host1x/drm/gem.c   |  270 
 drivers/gpu/host1x/drm/gem.h   |   59 +++
 8 files changed, 700 insertions(+), 34 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gem.c
 create mode 100644 drivers/gpu/host1x/drm/gem.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 9a6fc76..3768dbc 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -15,4 +15,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/gem.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/drm/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index 7db9b3a..f743540 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -2,11 +2,9 @@ config DRM_TEGRA
bool "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
+   select FB_SYS_FILLRECT
+   select FB_SYS_COPYAREA
+   select FB_SYS_IMAGEBLIT
help
  Choose this option if you have an NVIDIA Tegra SoC.

diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index 29a79b6..85ea616 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -14,9 +14,10 @@
 #include 
 #include 

-#include "drm.h"
-#include "dc.h"
 #include "host1x_client.h"
+#include "dc.h"
+#include "drm.h"
+#include "gem.h"

 struct tegra_plane {
struct drm_plane base;
@@ -52,9 +53,9 @@ static int tegra_plane_update(struct drm_plane *plane, struct 
drm_crtc *crtc,
window.bits_per_pixel = fb->bits_per_pixel;

for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++) {
-   struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, i);
+   struct tegra_bo *bo = tegra_fb_get_plane(fb, i);

-   window.base[i] = gem->paddr + fb->offsets[i];
+   window.base[i] = bo->paddr + fb->offsets[i];

/*
 * Tegra doesn't support different strides for U and V planes
@@ -137,7 +138,7 @@ static int tegra_dc_add_planes(struct drm_device *drm, 
struct tegra_dc *dc)
 static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
 struct drm_framebuffer *fb)
 {
-   struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, 0);
+   struct tegra_bo *bo = tegra_fb_get_plane(fb, 0);
unsigned long value;

tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER);
@@ -145,7 +146,7 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, 
int y,
value = fb->offsets[0] + y * fb->pitches[0] +
x * fb->bits_per_pixel / 8;

-   tegra_dc_writel(dc, gem->paddr + value, DC_WINBUF_START_ADDR);
+   tegra_dc_writel(dc, bo->paddr + value, DC_WINBUF_START_ADDR);
tegra_dc_writel(dc, fb->pitches[0], DC_WIN_LINE_STRIDE);

value = GENERAL_UPDATE | WIN_A_UPDATE;
@@ -187,20 +188,20 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
 {
struct drm_device *drm = dc->base.dev;
struct drm_crtc *crtc = >base;
-   struct drm_gem_cma_object *gem;
unsigned long flags, base;
+   struct tegra_bo *bo;

if (!dc->event)
return;

-   gem = drm_fb_cma_get_gem_obj(crtc->fb, 0);
+   bo = tegra_fb_get_plane(crtc->fb, 0);

/* check if new start address has been latched */
tegra_dc_writel(dc, READ_MUX, DC_CMD_STATE_ACCESS);
base = tegra_dc_readl(dc, DC_WINBUF_START_ADDR);
tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);

-   if (base == gem->paddr + crtc->fb->offsets[0]) {
+   if (base == bo->paddr + crtc->fb->offsets[0]) {
spin_lock_irqsave(>event_lock, flags);
drm_send_vblank_event(drm, dc->pipe, dc->event);
drm_vblank_put(drm, dc->pipe);
@@ -570,7 +571,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
   struct drm_display_mode *adjusted,
   int x, int y, struct drm_framebuffer *old_fb)
 {
-   struct 

[PATCHv8 7/9] gpu: host1x: Remove second host1x driver

2013-03-22 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: Arto Merilainen 
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|5 +-
 drivers/gpu/host1x/drm/drm.c   |  214 ++-
 drivers/gpu/host1x/drm/drm.h   |3 -
 drivers/gpu/host1x/drm/hdmi.c  |5 +-
 drivers/gpu/host1x/drm/host1x.c|  329 
 drivers/gpu/host1x/host1x_client.h |   35 
 10 files changed, 317 insertions(+), 342 deletions(-)
 delete mode 100644 drivers/gpu/host1x/drm/host1x.c
 create mode 100644 drivers/gpu/host1x/host1x_client.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 4761e8a..9a6fc76 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -13,6 +13,6 @@ host1x-y = \
 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 9689724..8ce9889 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -32,6 +32,19 @@
 #include "channel.h"
 #include "debug.h"
 #include "hw/host1x01.h"
+#include "host1x_client.h"
+
+void host1x_set_drm_data(struct device *dev, void *data)
+{
+   struct host1x *host1x = dev_get_drvdata(dev);
+   host1x->drm_data = data;
+}
+
+void *host1x_get_drm_data(struct device *dev)
+{
+   struct host1x *host1x = dev_get_drvdata(dev);
+   return host1x->drm_data;
+}

 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
 {
@@ -150,6 +163,8 @@ static int host1x_probe(struct platform_device *pdev)

host1x_debug_init(host);

+   host1x_drm_alloc(pdev);
+
return 0;

 fail_deinit_syncpt:
@@ -168,7 +183,7 @@ static int __exit host1x_remove(struct platform_device 
*pdev)
return 0;
 }

-static struct platform_driver platform_driver = {
+static struct platform_driver tegra_host1x_driver = {
.probe = host1x_probe,
.remove = __exit_p(host1x_remove),
.driver = {
@@ -178,8 +193,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(_host1x_driver);
+   if (err < 0)
+   return err;
+
+#ifdef CONFIG_DRM_TEGRA
+   err = platform_driver_register(_dc_driver);
+   if (err < 0)
+   goto unregister_host1x;
+
+   err = platform_driver_register(_hdmi_driver);
+   if (err < 0)
+   goto unregister_dc;
+#endif
+
+   return 0;
+
+#ifdef CONFIG_DRM_TEGRA
+unregister_dc:
+   platform_driver_unregister(_dc_driver);
+unregister_host1x:
+   platform_driver_unregister(_host1x_driver);
+   return err;
+#endif
+}
+module_init(tegra_host1x_init);
+
+static void __exit tegra_host1x_exit(void)
+{
+#ifdef CONFIG_DRM_TEGRA
+   platform_driver_unregister(_hdmi_driver);
+   platform_driver_unregister(_dc_driver);
+#endif
+   platform_driver_unregister(_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 4d16fe9..a1607d6 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -124,6 +124,8 @@ struct host1x {
unsigned int num_allocated_channels;

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

 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -299,4 +301,8 @@ static inline void host1x_hw_show_mlocks(struct host1x 
*host, struct output *o)
host->debug_op->show_mlocks(host, o);
 }

+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 d1f6609..29a79b6 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -16,6 

[PATCHv8 6/9] gpu: host1x: drm: Rename host1x to host1x_drm

2013-03-22 Thread Terje Bergstrom
From: Arto Merilainen 

Both host1x and drm drivers have host1x structures. This patch
renames the host1x structure under drm to follow name host1x_drm.

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/drm/dc.c |4 ++--
 drivers/gpu/host1x/drm/drm.c|4 ++--
 drivers/gpu/host1x/drm/drm.h|   14 +++---
 drivers/gpu/host1x/drm/fb.c |6 +++---
 drivers/gpu/host1x/drm/hdmi.c   |4 ++--
 drivers/gpu/host1x/drm/host1x.c |   22 --
 6 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index de94707..d1f6609 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -1097,7 +1097,7 @@ static const struct host1x_client_ops dc_client_ops = {

 static int tegra_dc_probe(struct platform_device *pdev)
 {
-   struct host1x *host1x = dev_get_drvdata(pdev->dev.parent);
+   struct host1x_drm *host1x = dev_get_drvdata(pdev->dev.parent);
struct resource *regs;
struct tegra_dc *dc;
int err;
@@ -1160,7 +1160,7 @@ static int tegra_dc_probe(struct platform_device *pdev)

 static int tegra_dc_remove(struct platform_device *pdev)
 {
-   struct host1x *host1x = dev_get_drvdata(pdev->dev.parent);
+   struct host1x_drm *host1x = dev_get_drvdata(pdev->dev.parent);
struct tegra_dc *dc = platform_get_drvdata(pdev);
int err;

diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index 9d452df..6c59bcd 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -26,7 +26,7 @@
 static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 {
struct device *dev = drm->dev;
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
int err;

host1x = dev_get_drvdata(dev);
@@ -69,7 +69,7 @@ static int tegra_drm_open(struct drm_device *drm, struct 
drm_file *filp)

 static void tegra_drm_lastclose(struct drm_device *drm)
 {
-   struct host1x *host1x = drm->dev_private;
+   struct host1x_drm *host1x = drm->dev_private;

drm_fbdev_cma_restore_mode(host1x->fbdev);
 }
diff --git a/drivers/gpu/host1x/drm/drm.h b/drivers/gpu/host1x/drm/drm.h
index a6c011d..7fedb6c 100644
--- a/drivers/gpu/host1x/drm/drm.h
+++ b/drivers/gpu/host1x/drm/drm.h
@@ -18,7 +18,7 @@
 #include 
 #include 

-struct host1x {
+struct host1x_drm {
struct drm_device *drm;
struct device *dev;
void __iomem *regs;
@@ -44,7 +44,7 @@ struct host1x_client_ops {
 };

 struct host1x_client {
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
struct device *dev;

const struct host1x_client_ops *ops;
@@ -52,12 +52,12 @@ struct host1x_client {
struct list_head list;
 };

-extern int host1x_drm_init(struct host1x *host1x, struct drm_device *drm);
-extern int host1x_drm_exit(struct host1x *host1x);
+extern int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm);
+extern int host1x_drm_exit(struct host1x_drm *host1x);

-extern int host1x_register_client(struct host1x *host1x,
+extern int host1x_register_client(struct host1x_drm *host1x,
  struct host1x_client *client);
-extern int host1x_unregister_client(struct host1x *host1x,
+extern int host1x_unregister_client(struct host1x_drm *host1x,
struct host1x_client *client);

 struct tegra_output;
@@ -66,7 +66,7 @@ struct tegra_dc {
struct host1x_client client;
spinlock_t lock;

-   struct host1x *host1x;
+   struct host1x_drm *host1x;
struct device *dev;

struct drm_crtc base;
diff --git a/drivers/gpu/host1x/drm/fb.c b/drivers/gpu/host1x/drm/fb.c
index 0391495..6ed885a 100644
--- a/drivers/gpu/host1x/drm/fb.c
+++ b/drivers/gpu/host1x/drm/fb.c
@@ -11,7 +11,7 @@

 static void tegra_drm_fb_output_poll_changed(struct drm_device *drm)
 {
-   struct host1x *host1x = drm->dev_private;
+   struct host1x_drm *host1x = drm->dev_private;

drm_fbdev_cma_hotplug_event(host1x->fbdev);
 }
@@ -23,7 +23,7 @@ static const struct drm_mode_config_funcs 
tegra_drm_mode_funcs = {

 int tegra_drm_fb_init(struct drm_device *drm)
 {
-   struct host1x *host1x = drm->dev_private;
+   struct host1x_drm *host1x = drm->dev_private;
struct drm_fbdev_cma *fbdev;

drm->mode_config.min_width = 0;
@@ -46,7 +46,7 @@ int tegra_drm_fb_init(struct drm_device *drm)

 void tegra_drm_fb_exit(struct drm_device *drm)
 {
-   struct host1x *host1x = drm->dev_private;
+   struct host1x_drm *host1x = drm->dev_private;

drm_fbdev_cma_fini(host1x->fbdev);
 }
diff --git a/drivers/gpu/host1x/drm/hdmi.c b/drivers/gpu/host1x/drm/hdmi.c
index bb747f6..f438f80 100644
--- a/drivers/gpu/host1x/drm/hdmi.c
+++ b/drivers/gpu/host1x/drm/hdmi.c
@@ -1189,7 +1189,7 @@ static const struct host1x_client_ops hdmi_client_ops = 

[PATCHv8 5/9] drm: tegra: Move drm to live under host1x

2013-03-22 Thread Terje Bergstrom
Make drm part of host1x driver.

Signed-off-by: Arto Merilainen 
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 |2 ++
 drivers/gpu/host1x/Makefile|5 +
 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
 16 files changed, 10 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%)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 1e82882..9031bb7 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -215,8 +215,6 @@ source "drivers/gpu/drm/cirrus/Kconfig"

 source "drivers/gpu/drm/shmobile/Kconfig"

-source "drivers/gpu/drm/tegra/Kconfig"
-
 source "drivers/gpu/drm/omapdrm/Kconfig"

 source "drivers/gpu/drm/tilcdc/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 0d59b24..847b830 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -49,7 +49,6 @@ 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-$(CONFIG_DRM_OMAP) += omapdrm/
 obj-$(CONFIG_DRM_TILCDC)   += tilcdc/
 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 00f0859..ee3af1e 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -18,4 +18,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 49fd580..4761e8a 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -10,4 +10,9 @@ host1x-y = \
debug.o \
hw/host1x01.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 6dd75a2..a6c011d 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.
  */

-#ifndef TEGRA_DRM_H
-#define TEGRA_DRM_H 1
+#ifndef HOST1X_DRM_H
+#define HOST1X_DRM_H 1

 #include 
 #include 
@@ -234,4 +234,4 @@ extern struct platform_driver 

[PATCHv8 4/9] gpu: host1x: Add debug support

2013-03-22 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: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile |1 +
 drivers/gpu/host1x/cdma.c   |4 +
 drivers/gpu/host1x/debug.c  |  210 +
 drivers/gpu/host1x/debug.h  |   51 +
 drivers/gpu/host1x/dev.c|3 +
 drivers/gpu/host1x/dev.h|   42 
 drivers/gpu/host1x/hw/cdma_hw.c |2 +
 drivers/gpu/host1x/hw/channel_hw.c  |   25 +++
 drivers/gpu/host1x/hw/debug_hw.c|  322 +++
 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/hw_host1x01_uclass.h  |6 +
 drivers/gpu/host1x/hw/syncpt_hw.c   |1 +
 drivers/gpu/host1x/syncpt.c |5 +
 15 files changed, 807 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 06a995b..49fd580 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 \
hw/host1x01.o

 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index 33935de..de72172 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -439,6 +439,10 @@ void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, 
u32 op2)
struct push_buffer *pb = >push_buffer;
u32 slots_free = cdma->slots_free;

+   if (host1x_debug_trace_cmdbuf)
+   trace_host1x_cdma_push(dev_name(cdma_to_channel(cdma)->dev),
+  op1, op2);
+
if (slots_free == 0) {
host1x_hw_cdma_flush(host1x, 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..3ec7d77
--- /dev/null
+++ b/drivers/gpu/host1x/debug.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ * Author: Erik Gilling 
+ *
+ * Copyright (C) 2011-2013 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"
+
+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, bool show_fifo)
+{
+   struct host1x *m = dev_get_drvdata(ch->dev->parent);
+   struct output *o = data;
+
+   mutex_lock(>reflock);
+   if (ch->refcount) {
+   mutex_lock(>cdma.lock);
+   if (show_fifo)
+   host1x_hw_show_channel_fifo(m, ch, o);
+   host1x_hw_show_channel_cdma(m, ch, o);
+   mutex_unlock(>cdma.lock);
+   }
+   mutex_unlock(>reflock);
+
+   return 0;
+}
+
+static void show_syncpts(struct host1x *m, struct output *o)
+{
+   int i;
+   host1x_debug_output(o, " syncpts \n");
+   for (i = 0; i < host1x_syncpt_nb_pts(m); i++) {
+   u32 max = host1x_syncpt_read_max(m->syncpt + i);
+   u32 min = host1x_syncpt_load(m->syncpt + i);
+   if (!min && !max)
+   continue;
+   host1x_debug_output(o, "id %d (%s) min %d max %d\n",
+   i, m->syncpt[i].name, min, max);
+   }
+
+   for (i = 0; i < host1x_syncpt_nb_bases(m); i++) {
+   u32 base_val;
+   base_val = host1x_syncpt_load_wait_base(m->syncpt + i);
+   if (base_val)
+   host1x_debug_output(o, "waitbase id %d val %d\n", i,
+   base_val);
+   }
+
+   host1x_debug_output(o, "\n");
+}
+

[PATCHv8 3/9] gpu: host1x: Add channel support

2013-03-22 Thread Terje Bergstrom
Add support for host1x client modules, and host1x channels to submit
work to the clients.

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Kconfig  |   12 +
 drivers/gpu/host1x/Makefile |3 +
 drivers/gpu/host1x/cdma.c   |  487 +
 drivers/gpu/host1x/cdma.h   |  100 +
 drivers/gpu/host1x/channel.c|  126 ++
 drivers/gpu/host1x/channel.h|   52 +++
 drivers/gpu/host1x/dev.c|   17 +
 drivers/gpu/host1x/dev.h|  113 +
 drivers/gpu/host1x/host1x.h |   28 ++
 drivers/gpu/host1x/host1x_bo.h  |   87 
 drivers/gpu/host1x/hw/cdma_hw.c |  324 ++
 drivers/gpu/host1x/hw/channel_hw.c  |  143 +++
 drivers/gpu/host1x/hw/host1x01.c|5 +
 drivers/gpu/host1x/hw/host1x01_hardware.h   |  116 ++
 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   |   11 +
 drivers/gpu/host1x/intr.c   |   28 +-
 drivers/gpu/host1x/intr.h   |6 +
 drivers/gpu/host1x/job.c|  603 +++
 drivers/gpu/host1x/job.h|  167 
 drivers/gpu/host1x/syncpt.c |   11 +
 drivers/gpu/host1x/syncpt.h |6 +
 include/trace/events/host1x.h   |  211 ++
 25 files changed, 2937 insertions(+), 1 deletion(-)
 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/host1x.h
 create mode 100644 drivers/gpu/host1x/host1x_bo.h
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c
 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

diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
index c01c450..00f0859 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -7,3 +7,15 @@ config TEGRA_HOST1X
  Tegra's graphics- and multimedia-related modules. The modules served
  by host1x are referred to as clients. host1x includes some other
  functionality, such as synchronization.
+
+if TEGRA_HOST1X
+
+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..06a995b 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -4,6 +4,9 @@ host1x-y = \
syncpt.o \
dev.o \
intr.o \
+   cdma.o \
+   channel.o \
+   job.o \
hw/host1x01.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..33935de
--- /dev/null
+++ b/drivers/gpu/host1x/cdma.c
@@ -0,0 +1,487 @@
+/*
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cdma.h"
+#include "channel.h"
+#include "dev.h"
+#include "debug.h"
+#include "host1x_bo.h"
+#include "job.h"
+
+/*
+ * push_buffer
+ *
+ * The push buffer is a circular array of words to be fetched by command DMA.
+ * Note that it works slightly differently to the sync queue; fence == pos
+ * means that the push buffer is full, not empty.
+ */
+
+#define HOST1X_PUSHBUFFER_SLOTS512
+
+/*
+ * Clean up push buffer resources
+ */
+static void host1x_pushbuffer_destroy(struct push_buffer *pb)
+{
+   struct host1x_cdma *cdma = pb_to_cdma(pb);
+   struct host1x *host1x = cdma_to_host1x(cdma);
+
+   if (pb->phys != 0)
+   dma_free_writecombine(host1x->dev, pb->size_bytes + 

[PATCHv8 2/9] gpu: host1x: Add syncpoint wait and interrupts

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

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/host1x/Makefile  |1 +
 drivers/gpu/host1x/dev.c |   12 ++
 drivers/gpu/host1x/dev.h |   51 +
 drivers/gpu/host1x/hw/host1x01.c |2 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h |   42 
 drivers/gpu/host1x/hw/intr_hw.c  |  143 +
 drivers/gpu/host1x/intr.c|  328 ++
 drivers/gpu/host1x/intr.h|   96 +
 drivers/gpu/host1x/syncpt.c  |  159 +++
 drivers/gpu/host1x/syncpt.h  |   12 ++
 10 files changed, 846 insertions(+)
 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 0d6002c..b967f6e 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -28,6 +28,7 @@
 #include 

 #include "dev.h"
+#include "intr.h"
 #include "hw/host1x01.h"

 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
@@ -123,13 +124,24 @@ static int host1x_probe(struct platform_device *pdev)
return err;
}

+   err = host1x_intr_init(host, syncpt_irq);
+   if (err) {
+   dev_err(>dev, "failed to initialize interrupts\n");
+   goto fail_deinit_syncpt;
+   }
+
return 0;
+
+fail_deinit_syncpt:
+   host1x_syncpt_deinit(host);
+   return err;
 }

 static int __exit host1x_remove(struct platform_device *pdev)
 {
struct host1x *host = platform_get_drvdata(pdev);

+   host1x_intr_deinit(host);
host1x_syncpt_deinit(host);
clk_disable_unprepare(host->clk);

diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index eaf6026..caf9cc6 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -21,6 +21,7 @@
 #include 

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

 struct host1x_syncpt;

@@ -33,6 +34,17 @@ struct host1x_syncpt_ops {
int (*patch_wait)(struct host1x_syncpt *syncpt, void *patch_addr);
 };

+struct host1x_intr_ops {
+   int (*init_host_sync)(struct host1x *host, u32 cpm,
+   void (*syncpt_thresh_work)(struct work_struct *work));
+   void (*set_syncpt_threshold)(
+   struct host1x *host, u32 id, u32 thresh);
+   void (*enable_syncpt_intr)(struct host1x *host, u32 id);
+   void (*disable_syncpt_intr)(struct host1x *host, u32 id);
+   void (*disable_all_syncpt_intrs)(struct host1x *host);
+   int (*free_syncpt_irq)(struct host1x *host);
+};
+
 struct host1x_info {
int nb_channels;/* host1x: num channels supported */
int nb_pts; /* host1x: num syncpoints supported */
@@ -50,7 +62,13 @@ struct host1x {
struct device *dev;
struct clk *clk;

+   struct mutex intr_mutex;
+   struct workqueue_struct *intr_wq;
+   int intr_syncpt_irq;
+
const struct host1x_syncpt_ops *syncpt_op;
+   const struct host1x_intr_ops *intr_op;
+
 };

 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -93,4 +111,37 @@ static inline int host1x_hw_syncpt_patch_wait(struct host1x 
*host,
return host->syncpt_op->patch_wait(sp, patch_addr);
 }

+static inline int host1x_hw_intr_init_host_sync(struct host1x *host, u32 cpm,
+   void (*syncpt_thresh_work)(struct work_struct *))
+{
+   return host->intr_op->init_host_sync(host, cpm, syncpt_thresh_work);
+}
+
+static inline void host1x_hw_intr_set_syncpt_threshold(struct host1x *host,
+  u32 id, u32 thresh)
+{
+   host->intr_op->set_syncpt_threshold(host, id, thresh);
+}
+
+static inline void host1x_hw_intr_enable_syncpt_intr(struct host1x *host,
+u32 id)
+{
+   host->intr_op->enable_syncpt_intr(host, id);
+}
+
+static inline void host1x_hw_intr_disable_syncpt_intr(struct host1x *host,
+ u32 id)
+{
+   host->intr_op->disable_syncpt_intr(host, id);
+}
+
+static inline void host1x_hw_intr_disable_all_syncpt_intrs(struct host1x *host)
+{
+   host->intr_op->disable_all_syncpt_intrs(host);
+}
+
+static inline int host1x_hw_intr_free_syncpt_irq(struct host1x *host)
+{
+   return host->intr_op->free_syncpt_irq(host);
+}
 #endif
diff --git 

[PATCHv8 1/9] gpu: host1x: Add host1x driver

2013-03-22 Thread Terje Bergstrom
Add host1x, the driver for host1x and its client unit 2D. The Tegra
host1x module is the DMA engine for register access to Tegra's
graphics- and multimedia-related modules. The modules served by
host1x are referred to as clients. host1x includes some other
functionality, such as synchronization.

Signed-off-by: Arto Merilainen 
Signed-off-by: Terje Bergstrom 
---
 drivers/gpu/Makefile  |1 +
 drivers/gpu/host1x/Kconfig|9 ++
 drivers/gpu/host1x/Makefile   |8 ++
 drivers/gpu/host1x/dev.c  |  153 +
 drivers/gpu/host1x/dev.h  |   96 +
 drivers/gpu/host1x/hw/Makefile|6 +
 drivers/gpu/host1x/hw/host1x01.c  |   33 +
 drivers/gpu/host1x/hw/host1x01.h  |   25 
 drivers/gpu/host1x/hw/host1x01_hardware.h |   27 
 drivers/gpu/host1x/hw/hw_host1x01_sync.h  |   74 ++
 drivers/gpu/host1x/hw/syncpt_hw.c |  102 ++
 drivers/gpu/host1x/syncpt.c   |  212 +
 drivers/gpu/host1x/syncpt.h   |  147 
 drivers/video/Kconfig |2 +
 include/trace/events/host1x.h |   61 +
 15 files changed, 956 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 30879df..d8a22c2 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1 +1,2 @@
 obj-y  += drm/ vga/
+obj-$(CONFIG_TEGRA_HOST1X) += host1x/
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
new file mode 100644
index 000..c01c450
--- /dev/null
+++ b/drivers/gpu/host1x/Kconfig
@@ -0,0 +1,9 @@
+config TEGRA_HOST1X
+   tristate "NVIDIA Tegra host1x driver"
+   help
+ Driver for the NVIDIA Tegra host1x hardware.
+
+ The Tegra host1x module is the DMA engine for register access to
+ Tegra's graphics- and multimedia-related modules. The modules served
+ by host1x are referred to as clients. host1x includes some other
+ functionality, such as synchronization.
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..0d6002c
--- /dev/null
+++ b/drivers/gpu/host1x/dev.c
@@ -0,0 +1,153 @@
+/*
+ * 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 
+
+#define CREATE_TRACE_POINTS
+#include 
+
+#include "dev.h"
+#include "hw/host1x01.h"
+
+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 const struct host1x_info host1x01_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_of_match[] = {
+   { .compatible = "nvidia,tegra30-host1x", .data = _info, },
+   { .compatible = "nvidia,tegra20-host1x", .data = _info, },
+   { },
+};
+MODULE_DEVICE_TABLE(of, 

[PATCHv8 0/9] Support for Tegra 2D hardware

2013-03-22 Thread Terje Bergstrom
This set of patches adds support for Tegra20 and Tegra30 host1x and
2D. It is based on linux-next-20130322 with RTC fixes applied.

Changes in this version:
 * Own version of framebuffer driver due to move to own allocator
   * Thanks to Thierry Reding for help
 * Miscellaneous variable name, whitespace and IOCTL interface cleanups
 * Bug fixes:
   * Validator enabled again
   * Added new class 2D strechblit
 * Dropped patch "Support CMA object preallocation"

Changes in version 7:
 * host1x memory data structures refactored
 * Some "nvhost" leftovers renamed to host1x

Changes in version 6:
 * Rebased on latest tegradrm
 * Renamed tegradrm's host1x to host1x_drm
 * Indentation and line split fixed to follow tegradrm convention
 * Pointers to platform_device replaced with pointers to device
 * Added host1x allocator, and wired it in
 * Debug spew code fixed to access mem handles from host1x_job
 * CDMA code doesn't keep the mem handles anymore
 * Push buffer ops have been made generic code
 * Removed the pin_array optimization in host1x_job to simplify code
 * Large number of smaller changes

The driver implements an allocator using the dma mapping API. Each buffer is
assigned an ops structure to operate on it.

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 http://http.download.nvidia.com/tegra-public-appnotes/host1x.html
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.

The changes to add support to libdrm are in
git at gitorious.org:linux-host1x/libdrm-host1x.git

Arto Merilainen (2):
  gpu: host1x: drm: Rename host1x to host1x_drm
  gpu: host1x: drm: Add memory manager and fb

Terje Bergstrom (7):
  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
  drm: tegra: Add gr2d device

 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|  217 
 drivers/gpu/drm/tegra/fb.c |   52 --
 drivers/gpu/drm/tegra/host1x.c |  327 
 drivers/gpu/host1x/Kconfig |   23 +
 drivers/gpu/host1x/Makefile|   20 +
 drivers/gpu/host1x/cdma.c  |  491 ++
 drivers/gpu/host1x/cdma.h  |  100 
 drivers/gpu/host1x/channel.c   |  126 +
 drivers/gpu/host1x/channel.h   |   52 ++
 drivers/gpu/host1x/debug.c |  210 
 drivers/gpu/host1x/debug.h |   51 ++
 drivers/gpu/host1x/dev.c   |  246 +
 drivers/gpu/host1x/dev.h   |  308 
 drivers/gpu/{drm/tegra => host1x/drm}/Kconfig  |   19 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.c |   26 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.h |0
 drivers/gpu/host1x/drm/drm.c   |  641 
 drivers/gpu/{drm/tegra => host1x/drm}/drm.h|   68 ++-
 drivers/gpu/host1x/drm/fb.c|  374 ++
 drivers/gpu/host1x/drm/gem.c   |  270 ++
 drivers/gpu/host1x/drm/gem.h   |   59 +++
 drivers/gpu/host1x/drm/gr2d.c  |  340 +
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c   |5 +-
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h   |0
 drivers/gpu/{drm/tegra => host1x/drm}/output.c |0
 drivers/gpu/{drm/tegra => host1x/drm}/rgb.c|0
 drivers/gpu/host1x/host1x.h|   30 ++
 drivers/gpu/host1x/host1x_bo.h |   87 
 drivers/gpu/host1x/host1x_client.h |   35 ++
 drivers/gpu/host1x/hw/Makefile |6 +
 drivers/gpu/host1x/hw/cdma_hw.c|  326 
 drivers/gpu/host1x/hw/channel_hw.c |  168 +++
 drivers/gpu/host1x/hw/debug_hw.c   |  322 
 drivers/gpu/host1x/hw/host1x01.c   |   42 ++
 drivers/gpu/host1x/hw/host1x01.h   |   25 +
 drivers/gpu/host1x/hw/host1x01_hardware.h  |  143 ++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h|  120 +++

Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher  wrote:
>
> On Thu, Mar 21, 2013 at 5:42 PM, Dylan Semler 
wrote:
> > Oops.  I neglected to preface this with my motivation:  I have a new
> > monitor that doesn't report its native resolution in its EDID block.  It
> > seemed to me this calls for an EDID quirk, but the current quirk
> > infrastructure doesn't allow explicitly creating new modes.  So I set
out
> > to make a simple enhancement to allow specifying a new mode and then
> > setting it as preferred.
> >
>
> That's odd.  Maybe it's actually in an extension block or something like
> that?

Yeah, I agree.  According to edid-decode /sys/class/drm/card0-HDMI-A-1/edid
there's one extension block, but none of those modes are the native
resolution
either.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130322/905d4f65/attachment.html>


[PATCH 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.

2013-03-22 Thread Alex Deucher
On Thu, Mar 21, 2013 at 5:36 PM, Dylan Semler  wrote:
>
> Signed-off-by: Dylan Semler 
> ---
>  drivers/gpu/drm/drm_edid.c | 72 
> ++
>  1 file changed, 72 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index c194f4e..b1036b5 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -68,6 +68,8 @@
>  #define EDID_QUIRK_DETAILED_SYNC_PP(1 << 6)
>  /* Force reduced-blanking timings for detailed modes */
>  #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1 << 7)
> +/* Force specific mode for monitors that don't report correct EDIDs */
> +#define EDID_QUIRK_FORCE_MODE  (1 << 8)
>
>  struct detailed_mode_closure {
> struct drm_connector *connector;
> @@ -127,6 +129,15 @@ static struct edid_quirk {
> { "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
>  };
>
> +static struct edid_quirk_force_mode {
> +   char vendor[4];
> +   int product_id;
> +   int hdisplay;
> +   int vdisplay;
> +   int vrefresh;
> +} edid_quirk_force_mode_list[] = {
> +};
> +
>  /*
>   * Autogenerated from the DMT spec.
>   * This table is copied from xfree86/modes/xf86EdidModes.c.
> @@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, 
> struct edid *edid,
> return closure.modes;
>  }
>
> +/* Add an explicit mode based on a quirk
> + */
> +static int
> +do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
> +int vdisplay, int vrefresh)
> +{
> +   struct drm_display_mode *mode;
> +   struct drm_device *dev = connector->dev;
> +   int num_modes = 0;
> +
> +   /* sanity check display parameters */
> +   if (hdisplay < 0)
> +   return 0;
> +   if (vdisplay < 0)
> +   return 0;
> +   if (vrefresh < 0)
> +   return 0;
> +
> +   mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);

I would suggest using drm_cvt_mode() here since most modern monitors
prefer cvt timing and usually reduced blanking.  A lot of LCD monitors
don't like gtf timing.  You might also want to add a reduced blanking
field to the edid_quirk_force_mode struct so that you can specify on a
quirk by quirk basis.

Alex

> +
> +   if (mode) {
> +   mode->type |= DRM_MODE_TYPE_PREFERRED;
> +   drm_mode_probed_add(connector, mode);
> +   num_modes++;
> +   }
> +   return num_modes;
> +}
> +
> +/*
> + * add_force_quirk_modes - Add modes based on monitor's EDID quirks
> + * @connector: attached connector
> + * @edid: EDID block to scan
> + * @quirks: quirks to apply
> + *
> + * At least one monitor doesn't report its native resolution in its EDID 
> block.
> + * Here we add the native mode according to this quirk
> + */
> +static int
> +add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
> + u32 quirks)
> +{
> +   struct edid_quirk_force_mode *quirk_mode;
> +   int i, num_modes = 0;
> +
> +   for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
> +   quirk_mode = _quirk_force_mode_list[i];
> +
> +   if (edid_vendor(edid, quirk_mode->vendor) &&
> +   (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
> +   num_modes = do_force_quirk_modes(connector,
> +   quirk_mode->hdisplay,
> +   quirk_mode->vdisplay,
> +   quirk_mode->vrefresh);
> +   }
> +   }
> +   return num_modes;
> +
> +}
> +
>  #define HDMI_IDENTIFIER 0x000C03
>  #define AUDIO_BLOCK0x01
>  #define VIDEO_BLOCK 0x02
> @@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
> struct edid *edid)
>
> if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | 
> EDID_QUIRK_PREFER_LARGE_75))
> edid_fixup_preferred(connector, quirks);
> +   if (quirks & EDID_QUIRK_FORCE_MODE)
> +   num_modes += add_force_quirk_modes(connector, edid, quirks);
>
> drm_add_display_info(edid, >display_info);
>
> --
> 1.7.11.7
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Alex Deucher
On Thu, Mar 21, 2013 at 5:42 PM, Dylan Semler  wrote:
> Oops.  I neglected to preface this with my motivation:  I have a new monitor
> that doesn't report its native resolution in its EDID block.  It seemed to
> me
> this calls for an EDID quirk, but the current quirk infrastructure doesn't
> allow explicitly creating new modes.  So I set out to make a simple
> enhancement
> to allow specifying a new mode and then setting it as preferred.
>

That's odd.  Maybe it's actually in an extension block or something like that?

>
>
> On Thu, Mar 21, 2013 at 5:36 PM, Dylan Semler 
> wrote:
>>
>> The idea is setup a new quirk list with width, height, and refresh rates
>> for
>> each monitor that needs this quirk.  If a monitor is attached that matches
>> one
>> in this list, the full modeline is calculated with drm_gtf_mode, the
>> DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added to the
>> connector.
>>
>> The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit
>> needs
>> to be set for the new quirk list discribed above to be checked.
>>
>> The first patch enhances the quirk logic as described above.  The second
>> one
>> adds my new monitor to the quirk lists.
>
>
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>


[PATCH v2 2/2] Adds EDID force mode quirk for MMT Monitor2Go HD+.

2013-03-22 Thread Dylan Semler
Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b1036b5..b400971 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },

+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -136,6 +139,8 @@ static struct edid_quirk_force_mode {
int vdisplay;
int vrefresh;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, 1600, 900, 60 },
 };

 /*
-- 
1.7.11.7



[PATCH v2 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.

2013-03-22 Thread Dylan Semler
Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 72 ++
 1 file changed, 72 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..b1036b5 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1 << 6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1 << 7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1 << 8)

 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,15 @@ static struct edid_quirk {
{ "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };

+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }

+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh)
+{
+   struct drm_display_mode *mode;
+   struct drm_device *dev = connector->dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay < 0)
+   return 0;
+   if (vdisplay < 0)
+   return 0;
+   if (vrefresh < 0)
+   return 0;
+
+   mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);
+
+   if (mode) {
+   mode->type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = _quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode->vendor) &&
+   (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode->hdisplay,
+   quirk_mode->vdisplay,
+   quirk_mode->vrefresh);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)

if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks & EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);

drm_add_display_info(edid, >display_info);

-- 
1.7.11.7



[PATCH v2 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
Changes in this version
 * Fix missing commit messages in patch emails

These patches offer a fix for a monitor that doesn't report its native
resolution in its EDID.  The idea is setup a new quirk list with width, height,
and refresh rates for each monitor that needs this quirk.  If a monitor is
attached that matches one in this list, the full modeline is calculated with
drm_gtf_mode, the DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added
to the connector.

The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit needs
to be set for the new quirk list discribed above to be checked.

Dylan Semler (2):
  Enhances EDID quirks to allow for specifying and preferring a mode
not reported in the EDID block.
  Adds EDID force mode quirk for MMT Monitor2Go HD+.

 drivers/gpu/drm/drm_edid.c | 77 ++
 1 file changed, 77 insertions(+)

-- 
1.7.11.7



Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Daniel Vetter
On Thu, Mar 21, 2013 at 10:42 PM, Dylan Semler  
wrote:
> Oops.  I neglected to preface this with my motivation:  I have a new monitor
> that doesn't report its native resolution in its EDID block.  It seemed to
> me
> this calls for an EDID quirk, but the current quirk infrastructure doesn't
> allow explicitly creating new modes.  So I set out to make a simple
> enhancement
> to allow specifying a new mode and then setting it as preferred.
>
>
>
> On Thu, Mar 21, 2013 at 5:36 PM, Dylan Semler 
> wrote:
>>
>> The idea is setup a new quirk list with width, height, and refresh rates
>> for
>> each monitor that needs this quirk.  If a monitor is attached that matches
>> one
>> in this list, the full modeline is calculated with drm_gtf_mode, the
>> DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added to the
>> connector.
>>
>> The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit
>> needs
>> to be set for the new quirk list discribed above to be checked.
>>
>> The first patch enhances the quirk logic as described above.  The second
>> one
>> adds my new monitor to the quirk lists.

I think it'd be good to shovel these text blocks into the (currently
rather empty) commit messages of the patches. Since when reading old
commits with e.g. git blame that's what people will read.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 4:48 AM, Daniel Vetter  wrote:
>
> I think it'd be good to shovel these text blocks into the (currently
rather
> empty) commit messages of the patches. Since when reading old commits with
> e.g. git blame that's what people will read.

Yeah, I just noticed that.  For some reason my git format-patch didn't place
the commit messages above the signoff.  Here comes v2.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130322/3cd78647/attachment.html>


[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #19 from Andreas Boll  ---
Thanks Marek, your patch fixes the segfault.
Feel free to add my Tested-by on the patch.

-- 
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/20130322/7ce6ac9b/attachment.html>


[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #18 from Michel D?nzer  ---
Please attach the output from autogen.sh / configure. There's no point running
make until those have succeeded.

-- 
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/20130322/26694e42/attachment-0001.html>


[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #17 from Benjamin  ---
I checked out from git and applied the patch, BUT autogen.sh exits with code 1,
configure has a syntax error, and make says there is nothing to do.

-- 
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/20130322/382f0f35/attachment.html>


[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #16 from Marek Ol??k  ---
Sorry I don't really know what needs to be done if you have xorg-edgers. The
patch is supposed to be applied using the git command, so you basically need
the whole Mesa git repository.

-- 
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/20130322/f7f0/attachment.html>


[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #15 from Benjamin  ---
Since I'm using xorg-edgers, do I need to check out from git or can I just use
apt-get source?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 



[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #14 from Marek Ol??k  ---
It's a git patch for Mesa, applicable using "git am -3". Of course it's the DRI
driver.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 



[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #13 from Benjamin  ---
Comment on attachment 76887
  --> https://bugs.freedesktop.org/attachment.cgi?id=76887
possible fix

Which package is this? Is it libgl1-mesa-dri?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 



[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #12 from Marek Ol??k  ---
Created attachment 76887
  --> https://bugs.freedesktop.org/attachment.cgi?id=76887=edit
possible fix

(In reply to comment #10)
> Created attachment 76882 [details]
> gdb output
> 
> The interesting stuff is near the bottom. It segfaults on st_GetTexImage in
> st_cb_texture.c on line 895, which makes considering Andreas' post about
> Warcraft III in Wine.

Could you please try this patch?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 



[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #11 from Benjamin  ---
*makes sense, I meant to say makes sense.

It's interesting that it's segfaulting in different places for each of us.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 



[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #10 from Benjamin  ---
Created attachment 76882
  --> https://bugs.freedesktop.org/attachment.cgi?id=76882=edit
gdb output

The interesting stuff is near the bottom. It segfaults on st_GetTexImage in
st_cb_texture.c on line 895, which makes considering Andreas' post about
Warcraft III in Wine.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 



[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #18 from Michel Dänzer mic...@daenzer.net ---
Please attach the output from autogen.sh / configure. There's no point running
make until those have succeeded.

-- 
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 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #19 from Andreas Boll andreas.boll@gmail.com ---
Thanks Marek, your patch fixes the segfault.
Feel free to add my Tested-by on the patch.

-- 
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


[PATCHv8 0/9] Support for Tegra 2D hardware

2013-03-22 Thread Terje Bergstrom
This set of patches adds support for Tegra20 and Tegra30 host1x and
2D. It is based on linux-next-20130322 with RTC fixes applied.

Changes in this version:
 * Own version of framebuffer driver due to move to own allocator
   * Thanks to Thierry Reding for help
 * Miscellaneous variable name, whitespace and IOCTL interface cleanups
 * Bug fixes:
   * Validator enabled again
   * Added new class 2D strechblit
 * Dropped patch Support CMA object preallocation

Changes in version 7:
 * host1x memory data structures refactored
 * Some nvhost leftovers renamed to host1x

Changes in version 6:
 * Rebased on latest tegradrm
 * Renamed tegradrm's host1x to host1x_drm
 * Indentation and line split fixed to follow tegradrm convention
 * Pointers to platform_device replaced with pointers to device
 * Added host1x allocator, and wired it in
 * Debug spew code fixed to access mem handles from host1x_job
 * CDMA code doesn't keep the mem handles anymore
 * Push buffer ops have been made generic code
 * Removed the pin_array optimization in host1x_job to simplify code
 * Large number of smaller changes

The driver implements an allocator using the dma mapping API. Each buffer is
assigned an ops structure to operate on it.

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 http://http.download.nvidia.com/tegra-public-appnotes/host1x.html
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.

The changes to add support to libdrm are in
g...@gitorious.org:linux-host1x/libdrm-host1x.git

Arto Merilainen (2):
  gpu: host1x: drm: Rename host1x to host1x_drm
  gpu: host1x: drm: Add memory manager and fb

Terje Bergstrom (7):
  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
  drm: tegra: Add gr2d device

 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|  217 
 drivers/gpu/drm/tegra/fb.c |   52 --
 drivers/gpu/drm/tegra/host1x.c |  327 
 drivers/gpu/host1x/Kconfig |   23 +
 drivers/gpu/host1x/Makefile|   20 +
 drivers/gpu/host1x/cdma.c  |  491 ++
 drivers/gpu/host1x/cdma.h  |  100 
 drivers/gpu/host1x/channel.c   |  126 +
 drivers/gpu/host1x/channel.h   |   52 ++
 drivers/gpu/host1x/debug.c |  210 
 drivers/gpu/host1x/debug.h |   51 ++
 drivers/gpu/host1x/dev.c   |  246 +
 drivers/gpu/host1x/dev.h   |  308 
 drivers/gpu/{drm/tegra = host1x/drm}/Kconfig  |   19 +-
 drivers/gpu/{drm/tegra = host1x/drm}/dc.c |   26 +-
 drivers/gpu/{drm/tegra = host1x/drm}/dc.h |0
 drivers/gpu/host1x/drm/drm.c   |  641 
 drivers/gpu/{drm/tegra = host1x/drm}/drm.h|   68 ++-
 drivers/gpu/host1x/drm/fb.c|  374 ++
 drivers/gpu/host1x/drm/gem.c   |  270 ++
 drivers/gpu/host1x/drm/gem.h   |   59 +++
 drivers/gpu/host1x/drm/gr2d.c  |  340 +
 drivers/gpu/{drm/tegra = host1x/drm}/hdmi.c   |5 +-
 drivers/gpu/{drm/tegra = host1x/drm}/hdmi.h   |0
 drivers/gpu/{drm/tegra = host1x/drm}/output.c |0
 drivers/gpu/{drm/tegra = host1x/drm}/rgb.c|0
 drivers/gpu/host1x/host1x.h|   30 ++
 drivers/gpu/host1x/host1x_bo.h |   87 
 drivers/gpu/host1x/host1x_client.h |   35 ++
 drivers/gpu/host1x/hw/Makefile |6 +
 drivers/gpu/host1x/hw/cdma_hw.c|  326 
 drivers/gpu/host1x/hw/channel_hw.c |  168 +++
 drivers/gpu/host1x/hw/debug_hw.c   |  322 
 drivers/gpu/host1x/hw/host1x01.c   |   42 ++
 drivers/gpu/host1x/hw/host1x01.h   |   25 +
 drivers/gpu/host1x/hw/host1x01_hardware.h  |  143 ++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h|  120 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h   |  243

[PATCHv8 5/9] drm: tegra: Move drm to live under host1x

2013-03-22 Thread Terje Bergstrom
Make drm part of host1x driver.

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/drm/Kconfig|2 --
 drivers/gpu/drm/Makefile   |1 -
 drivers/gpu/drm/tegra/Makefile |7 ---
 drivers/gpu/host1x/Kconfig |2 ++
 drivers/gpu/host1x/Makefile|5 +
 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
 16 files changed, 10 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%)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 1e82882..9031bb7 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -215,8 +215,6 @@ source drivers/gpu/drm/cirrus/Kconfig
 
 source drivers/gpu/drm/shmobile/Kconfig
 
-source drivers/gpu/drm/tegra/Kconfig
-
 source drivers/gpu/drm/omapdrm/Kconfig
 
 source drivers/gpu/drm/tilcdc/Kconfig
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 0d59b24..847b830 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -49,7 +49,6 @@ 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-$(CONFIG_DRM_OMAP) += omapdrm/
 obj-$(CONFIG_DRM_TILCDC)   += tilcdc/
 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 00f0859..ee3af1e 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -18,4 +18,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 49fd580..4761e8a 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -10,4 +10,9 @@ host1x-y = \
debug.o \
hw/host1x01.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 6dd75a2..a6c011d 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.
  */
 
-#ifndef TEGRA_DRM_H
-#define TEGRA_DRM_H 1
+#ifndef HOST1X_DRM_H
+#define HOST1X_DRM_H 1
 
 #include drm/drmP.h
 #include drm/drm_crtc_helper.h
@@ -234,4 

[PATCHv8 4/9] gpu: host1x: Add debug support

2013-03-22 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: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/Makefile |1 +
 drivers/gpu/host1x/cdma.c   |4 +
 drivers/gpu/host1x/debug.c  |  210 +
 drivers/gpu/host1x/debug.h  |   51 +
 drivers/gpu/host1x/dev.c|3 +
 drivers/gpu/host1x/dev.h|   42 
 drivers/gpu/host1x/hw/cdma_hw.c |2 +
 drivers/gpu/host1x/hw/channel_hw.c  |   25 +++
 drivers/gpu/host1x/hw/debug_hw.c|  322 +++
 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/hw_host1x01_uclass.h  |6 +
 drivers/gpu/host1x/hw/syncpt_hw.c   |1 +
 drivers/gpu/host1x/syncpt.c |5 +
 15 files changed, 807 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 06a995b..49fd580 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 \
hw/host1x01.o
 
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index 33935de..de72172 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -439,6 +439,10 @@ void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, 
u32 op2)
struct push_buffer *pb = cdma-push_buffer;
u32 slots_free = cdma-slots_free;
 
+   if (host1x_debug_trace_cmdbuf)
+   trace_host1x_cdma_push(dev_name(cdma_to_channel(cdma)-dev),
+  op1, op2);
+
if (slots_free == 0) {
host1x_hw_cdma_flush(host1x, 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..3ec7d77
--- /dev/null
+++ b/drivers/gpu/host1x/debug.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ * Author: Erik Gilling konk...@android.com
+ *
+ * Copyright (C) 2011-2013 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 linux/debugfs.h
+#include linux/seq_file.h
+#include linux/uaccess.h
+
+#include linux/io.h
+
+#include dev.h
+#include debug.h
+#include channel.h
+
+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, bool show_fifo)
+{
+   struct host1x *m = dev_get_drvdata(ch-dev-parent);
+   struct output *o = data;
+
+   mutex_lock(ch-reflock);
+   if (ch-refcount) {
+   mutex_lock(ch-cdma.lock);
+   if (show_fifo)
+   host1x_hw_show_channel_fifo(m, ch, o);
+   host1x_hw_show_channel_cdma(m, ch, o);
+   mutex_unlock(ch-cdma.lock);
+   }
+   mutex_unlock(ch-reflock);
+
+   return 0;
+}
+
+static void show_syncpts(struct host1x *m, struct output *o)
+{
+   int i;
+   host1x_debug_output(o,  syncpts \n);
+   for (i = 0; i  host1x_syncpt_nb_pts(m); i++) {
+   u32 max = host1x_syncpt_read_max(m-syncpt + i);
+   u32 min = host1x_syncpt_load(m-syncpt + i);
+   if (!min  !max)
+   continue;
+   host1x_debug_output(o, id %d (%s) min %d max %d\n,
+   i, m-syncpt[i].name, min, max);
+   }
+
+   for (i = 0; i  host1x_syncpt_nb_bases(m); i++) {
+   u32 base_val;
+   base_val = host1x_syncpt_load_wait_base(m-syncpt + i);
+   if (base_val)
+   host1x_debug_output(o, waitbase id %d val %d\n, i,
+ 

[PATCHv8 2/9] gpu: host1x: Add syncpoint wait and interrupts

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

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/Makefile  |1 +
 drivers/gpu/host1x/dev.c |   12 ++
 drivers/gpu/host1x/dev.h |   51 +
 drivers/gpu/host1x/hw/host1x01.c |2 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h |   42 
 drivers/gpu/host1x/hw/intr_hw.c  |  143 +
 drivers/gpu/host1x/intr.c|  328 ++
 drivers/gpu/host1x/intr.h|   96 +
 drivers/gpu/host1x/syncpt.c  |  159 +++
 drivers/gpu/host1x/syncpt.h  |   12 ++
 10 files changed, 846 insertions(+)
 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 0d6002c..b967f6e 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -28,6 +28,7 @@
 #include trace/events/host1x.h
 
 #include dev.h
+#include intr.h
 #include hw/host1x01.h
 
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
@@ -123,13 +124,24 @@ static int host1x_probe(struct platform_device *pdev)
return err;
}
 
+   err = host1x_intr_init(host, syncpt_irq);
+   if (err) {
+   dev_err(pdev-dev, failed to initialize interrupts\n);
+   goto fail_deinit_syncpt;
+   }
+
return 0;
+
+fail_deinit_syncpt:
+   host1x_syncpt_deinit(host);
+   return err;
 }
 
 static int __exit host1x_remove(struct platform_device *pdev)
 {
struct host1x *host = platform_get_drvdata(pdev);
 
+   host1x_intr_deinit(host);
host1x_syncpt_deinit(host);
clk_disable_unprepare(host-clk);
 
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index eaf6026..caf9cc6 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -21,6 +21,7 @@
 #include linux/device.h
 
 #include syncpt.h
+#include intr.h
 
 struct host1x_syncpt;
 
@@ -33,6 +34,17 @@ struct host1x_syncpt_ops {
int (*patch_wait)(struct host1x_syncpt *syncpt, void *patch_addr);
 };
 
+struct host1x_intr_ops {
+   int (*init_host_sync)(struct host1x *host, u32 cpm,
+   void (*syncpt_thresh_work)(struct work_struct *work));
+   void (*set_syncpt_threshold)(
+   struct host1x *host, u32 id, u32 thresh);
+   void (*enable_syncpt_intr)(struct host1x *host, u32 id);
+   void (*disable_syncpt_intr)(struct host1x *host, u32 id);
+   void (*disable_all_syncpt_intrs)(struct host1x *host);
+   int (*free_syncpt_irq)(struct host1x *host);
+};
+
 struct host1x_info {
int nb_channels;/* host1x: num channels supported */
int nb_pts; /* host1x: num syncpoints supported */
@@ -50,7 +62,13 @@ struct host1x {
struct device *dev;
struct clk *clk;
 
+   struct mutex intr_mutex;
+   struct workqueue_struct *intr_wq;
+   int intr_syncpt_irq;
+
const struct host1x_syncpt_ops *syncpt_op;
+   const struct host1x_intr_ops *intr_op;
+
 };
 
 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -93,4 +111,37 @@ static inline int host1x_hw_syncpt_patch_wait(struct host1x 
*host,
return host-syncpt_op-patch_wait(sp, patch_addr);
 }
 
+static inline int host1x_hw_intr_init_host_sync(struct host1x *host, u32 cpm,
+   void (*syncpt_thresh_work)(struct work_struct *))
+{
+   return host-intr_op-init_host_sync(host, cpm, syncpt_thresh_work);
+}
+
+static inline void host1x_hw_intr_set_syncpt_threshold(struct host1x *host,
+  u32 id, u32 thresh)
+{
+   host-intr_op-set_syncpt_threshold(host, id, thresh);
+}
+
+static inline void host1x_hw_intr_enable_syncpt_intr(struct host1x *host,
+u32 id)
+{
+   host-intr_op-enable_syncpt_intr(host, id);
+}
+
+static inline void host1x_hw_intr_disable_syncpt_intr(struct host1x *host,
+ u32 id)
+{
+   host-intr_op-disable_syncpt_intr(host, id);
+}
+
+static inline void host1x_hw_intr_disable_all_syncpt_intrs(struct host1x *host)
+{
+   host-intr_op-disable_all_syncpt_intrs(host);
+}
+
+static inline int host1x_hw_intr_free_syncpt_irq(struct host1x *host)
+{
+   return 

[PATCHv8 1/9] gpu: host1x: Add host1x driver

2013-03-22 Thread Terje Bergstrom
Add host1x, the driver for host1x and its client unit 2D. The Tegra
host1x module is the DMA engine for register access to Tegra's
graphics- and multimedia-related modules. The modules served by
host1x are referred to as clients. host1x includes some other
functionality, such as synchronization.

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/Makefile  |1 +
 drivers/gpu/host1x/Kconfig|9 ++
 drivers/gpu/host1x/Makefile   |8 ++
 drivers/gpu/host1x/dev.c  |  153 +
 drivers/gpu/host1x/dev.h  |   96 +
 drivers/gpu/host1x/hw/Makefile|6 +
 drivers/gpu/host1x/hw/host1x01.c  |   33 +
 drivers/gpu/host1x/hw/host1x01.h  |   25 
 drivers/gpu/host1x/hw/host1x01_hardware.h |   27 
 drivers/gpu/host1x/hw/hw_host1x01_sync.h  |   74 ++
 drivers/gpu/host1x/hw/syncpt_hw.c |  102 ++
 drivers/gpu/host1x/syncpt.c   |  212 +
 drivers/gpu/host1x/syncpt.h   |  147 
 drivers/video/Kconfig |2 +
 include/trace/events/host1x.h |   61 +
 15 files changed, 956 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 30879df..d8a22c2 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1 +1,2 @@
 obj-y  += drm/ vga/
+obj-$(CONFIG_TEGRA_HOST1X) += host1x/
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
new file mode 100644
index 000..c01c450
--- /dev/null
+++ b/drivers/gpu/host1x/Kconfig
@@ -0,0 +1,9 @@
+config TEGRA_HOST1X
+   tristate NVIDIA Tegra host1x driver
+   help
+ Driver for the NVIDIA Tegra host1x hardware.
+
+ The Tegra host1x module is the DMA engine for register access to
+ Tegra's graphics- and multimedia-related modules. The modules served
+ by host1x are referred to as clients. host1x includes some other
+ functionality, such as synchronization.
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..0d6002c
--- /dev/null
+++ b/drivers/gpu/host1x/dev.c
@@ -0,0 +1,153 @@
+/*
+ * 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 http://www.gnu.org/licenses/.
+ */
+
+#include linux/module.h
+#include linux/list.h
+#include linux/slab.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/clk.h
+#include linux/io.h
+
+#define CREATE_TRACE_POINTS
+#include trace/events/host1x.h
+
+#include dev.h
+#include hw/host1x01.h
+
+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 const struct host1x_info host1x01_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_of_match[] = {
+   { .compatible = 

[PATCHv8 6/9] gpu: host1x: drm: Rename host1x to host1x_drm

2013-03-22 Thread Terje Bergstrom
From: Arto Merilainen amerilai...@nvidia.com

Both host1x and drm drivers have host1x structures. This patch
renames the host1x structure under drm to follow name host1x_drm.

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/drm/dc.c |4 ++--
 drivers/gpu/host1x/drm/drm.c|4 ++--
 drivers/gpu/host1x/drm/drm.h|   14 +++---
 drivers/gpu/host1x/drm/fb.c |6 +++---
 drivers/gpu/host1x/drm/hdmi.c   |4 ++--
 drivers/gpu/host1x/drm/host1x.c |   22 --
 6 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index de94707..d1f6609 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -1097,7 +1097,7 @@ static const struct host1x_client_ops dc_client_ops = {
 
 static int tegra_dc_probe(struct platform_device *pdev)
 {
-   struct host1x *host1x = dev_get_drvdata(pdev-dev.parent);
+   struct host1x_drm *host1x = dev_get_drvdata(pdev-dev.parent);
struct resource *regs;
struct tegra_dc *dc;
int err;
@@ -1160,7 +1160,7 @@ static int tegra_dc_probe(struct platform_device *pdev)
 
 static int tegra_dc_remove(struct platform_device *pdev)
 {
-   struct host1x *host1x = dev_get_drvdata(pdev-dev.parent);
+   struct host1x_drm *host1x = dev_get_drvdata(pdev-dev.parent);
struct tegra_dc *dc = platform_get_drvdata(pdev);
int err;
 
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index 9d452df..6c59bcd 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -26,7 +26,7 @@
 static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 {
struct device *dev = drm-dev;
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
int err;
 
host1x = dev_get_drvdata(dev);
@@ -69,7 +69,7 @@ static int tegra_drm_open(struct drm_device *drm, struct 
drm_file *filp)
 
 static void tegra_drm_lastclose(struct drm_device *drm)
 {
-   struct host1x *host1x = drm-dev_private;
+   struct host1x_drm *host1x = drm-dev_private;
 
drm_fbdev_cma_restore_mode(host1x-fbdev);
 }
diff --git a/drivers/gpu/host1x/drm/drm.h b/drivers/gpu/host1x/drm/drm.h
index a6c011d..7fedb6c 100644
--- a/drivers/gpu/host1x/drm/drm.h
+++ b/drivers/gpu/host1x/drm/drm.h
@@ -18,7 +18,7 @@
 #include drm/drm_fb_cma_helper.h
 #include drm/drm_fixed.h
 
-struct host1x {
+struct host1x_drm {
struct drm_device *drm;
struct device *dev;
void __iomem *regs;
@@ -44,7 +44,7 @@ struct host1x_client_ops {
 };
 
 struct host1x_client {
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
struct device *dev;
 
const struct host1x_client_ops *ops;
@@ -52,12 +52,12 @@ struct host1x_client {
struct list_head list;
 };
 
-extern int host1x_drm_init(struct host1x *host1x, struct drm_device *drm);
-extern int host1x_drm_exit(struct host1x *host1x);
+extern int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm);
+extern int host1x_drm_exit(struct host1x_drm *host1x);
 
-extern int host1x_register_client(struct host1x *host1x,
+extern int host1x_register_client(struct host1x_drm *host1x,
  struct host1x_client *client);
-extern int host1x_unregister_client(struct host1x *host1x,
+extern int host1x_unregister_client(struct host1x_drm *host1x,
struct host1x_client *client);
 
 struct tegra_output;
@@ -66,7 +66,7 @@ struct tegra_dc {
struct host1x_client client;
spinlock_t lock;
 
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
struct device *dev;
 
struct drm_crtc base;
diff --git a/drivers/gpu/host1x/drm/fb.c b/drivers/gpu/host1x/drm/fb.c
index 0391495..6ed885a 100644
--- a/drivers/gpu/host1x/drm/fb.c
+++ b/drivers/gpu/host1x/drm/fb.c
@@ -11,7 +11,7 @@
 
 static void tegra_drm_fb_output_poll_changed(struct drm_device *drm)
 {
-   struct host1x *host1x = drm-dev_private;
+   struct host1x_drm *host1x = drm-dev_private;
 
drm_fbdev_cma_hotplug_event(host1x-fbdev);
 }
@@ -23,7 +23,7 @@ static const struct drm_mode_config_funcs 
tegra_drm_mode_funcs = {
 
 int tegra_drm_fb_init(struct drm_device *drm)
 {
-   struct host1x *host1x = drm-dev_private;
+   struct host1x_drm *host1x = drm-dev_private;
struct drm_fbdev_cma *fbdev;
 
drm-mode_config.min_width = 0;
@@ -46,7 +46,7 @@ int tegra_drm_fb_init(struct drm_device *drm)
 
 void tegra_drm_fb_exit(struct drm_device *drm)
 {
-   struct host1x *host1x = drm-dev_private;
+   struct host1x_drm *host1x = drm-dev_private;
 
drm_fbdev_cma_fini(host1x-fbdev);
 }
diff --git a/drivers/gpu/host1x/drm/hdmi.c b/drivers/gpu/host1x/drm/hdmi.c
index bb747f6..f438f80 100644
--- a/drivers/gpu/host1x/drm/hdmi.c
+++ 

[PATCHv8 8/9] gpu: host1x: drm: Add memory manager and fb

2013-03-22 Thread Terje Bergstrom
From: Arto Merilainen amerilai...@nvidia.com

This patch introduces a memory manager for tegra drm and moves
existing parts to use it. As cma framebuffer helpers can no more
be used, this patch adds also a separate framebuffer driver for
tegra.

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/Makefile|1 +
 drivers/gpu/host1x/drm/Kconfig |8 +-
 drivers/gpu/host1x/drm/dc.c|   23 +--
 drivers/gpu/host1x/drm/drm.c   |   17 +-
 drivers/gpu/host1x/drm/drm.h   |   18 ++-
 drivers/gpu/host1x/drm/fb.c|  338 +++-
 drivers/gpu/host1x/drm/gem.c   |  270 
 drivers/gpu/host1x/drm/gem.h   |   59 +++
 8 files changed, 700 insertions(+), 34 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gem.c
 create mode 100644 drivers/gpu/host1x/drm/gem.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 9a6fc76..3768dbc 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -15,4 +15,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/gem.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/drm/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index 7db9b3a..f743540 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -2,11 +2,9 @@ config DRM_TEGRA
bool 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
+   select FB_SYS_FILLRECT
+   select FB_SYS_COPYAREA
+   select FB_SYS_IMAGEBLIT
help
  Choose this option if you have an NVIDIA Tegra SoC.
 
diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index 29a79b6..85ea616 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -14,9 +14,10 @@
 #include linux/platform_device.h
 #include linux/clk/tegra.h
 
-#include drm.h
-#include dc.h
 #include host1x_client.h
+#include dc.h
+#include drm.h
+#include gem.h
 
 struct tegra_plane {
struct drm_plane base;
@@ -52,9 +53,9 @@ static int tegra_plane_update(struct drm_plane *plane, struct 
drm_crtc *crtc,
window.bits_per_pixel = fb-bits_per_pixel;
 
for (i = 0; i  drm_format_num_planes(fb-pixel_format); i++) {
-   struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, i);
+   struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
 
-   window.base[i] = gem-paddr + fb-offsets[i];
+   window.base[i] = bo-paddr + fb-offsets[i];
 
/*
 * Tegra doesn't support different strides for U and V planes
@@ -137,7 +138,7 @@ static int tegra_dc_add_planes(struct drm_device *drm, 
struct tegra_dc *dc)
 static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
 struct drm_framebuffer *fb)
 {
-   struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, 0);
+   struct tegra_bo *bo = tegra_fb_get_plane(fb, 0);
unsigned long value;
 
tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER);
@@ -145,7 +146,7 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, 
int y,
value = fb-offsets[0] + y * fb-pitches[0] +
x * fb-bits_per_pixel / 8;
 
-   tegra_dc_writel(dc, gem-paddr + value, DC_WINBUF_START_ADDR);
+   tegra_dc_writel(dc, bo-paddr + value, DC_WINBUF_START_ADDR);
tegra_dc_writel(dc, fb-pitches[0], DC_WIN_LINE_STRIDE);
 
value = GENERAL_UPDATE | WIN_A_UPDATE;
@@ -187,20 +188,20 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
 {
struct drm_device *drm = dc-base.dev;
struct drm_crtc *crtc = dc-base;
-   struct drm_gem_cma_object *gem;
unsigned long flags, base;
+   struct tegra_bo *bo;
 
if (!dc-event)
return;
 
-   gem = drm_fb_cma_get_gem_obj(crtc-fb, 0);
+   bo = tegra_fb_get_plane(crtc-fb, 0);
 
/* check if new start address has been latched */
tegra_dc_writel(dc, READ_MUX, DC_CMD_STATE_ACCESS);
base = tegra_dc_readl(dc, DC_WINBUF_START_ADDR);
tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);
 
-   if (base == gem-paddr + crtc-fb-offsets[0]) {
+   if (base == bo-paddr + crtc-fb-offsets[0]) {
spin_lock_irqsave(drm-event_lock, flags);
drm_send_vblank_event(drm, dc-pipe, dc-event);
drm_vblank_put(drm, dc-pipe);
@@ -570,7 +571,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
   struct drm_display_mode *adjusted,
   int x, 

[PATCHv8 9/9] drm: tegra: Add gr2d device

2013-03-22 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: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/Makefile|1 +
 drivers/gpu/host1x/dev.c   |7 +
 drivers/gpu/host1x/drm/Kconfig |9 ++
 drivers/gpu/host1x/drm/drm.c   |  213 -
 drivers/gpu/host1x/drm/drm.h   |   27 +++-
 drivers/gpu/host1x/drm/gr2d.c  |  340 
 drivers/gpu/host1x/host1x.h|4 +-
 include/uapi/drm/tegra_drm.h   |  136 
 8 files changed, 734 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/uapi/drm/tegra_drm.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 3768dbc..3b037b6 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -16,4 +16,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/gem.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 8ce9889..28e28a2 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -209,11 +209,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_DRM_TEGRA
+unregister_hdmi:
+   platform_driver_unregister(tegra_hdmi_driver);
 unregister_dc:
platform_driver_unregister(tegra_dc_driver);
 unregister_host1x:
@@ -226,6 +232,7 @@ module_init(tegra_host1x_init);
 static void __exit tegra_host1x_exit(void)
 {
 #ifdef CONFIG_DRM_TEGRA
+   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/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index f743540..6e3f567 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -13,6 +13,15 @@ config DRM_TEGRA
 
 if DRM_TEGRA
 
+config DRM_TEGRA_STAGING
+   bool Enable HOST1X interface
+   depends on STAGING
+   default n
+   help
+ Say yes if HOST1X should be available for userspace DRM users.
+
+ If unsure, choose N.
+
 config DRM_TEGRA_DEBUG
bool NVIDIA Tegra DRM debug support
help
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index c4e45c1..6db1bd6 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2012 Avionic Design GmbH
- * Copyright (C) 2012 NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (C) 2012-2013 NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -14,6 +14,11 @@
 #include linux/dma-mapping.h
 #include asm/dma-iommu.h
 
+#include drm/drm.h
+#include drm/drmP.h
+
+#include uapi/drm/tegra_drm.h
+
 #include host1x_client.h
 #include dev.h
 #include drm.h
@@ -81,8 +86,10 @@ static int host1x_parse_dt(struct host1x_drm *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;
@@ -277,9 +284,24 @@ static int tegra_drm_unload(struct drm_device *drm)
 
 static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
 {
+   struct host1x_drm_file *fpriv;
+
+   fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
+   if (!fpriv)
+   return -ENOMEM;
+
+   INIT_LIST_HEAD(fpriv-contexts);
+   filp-driver_priv = fpriv;
+
return 0;
 }
 
+static void host1x_drm_context_free(struct host1x_drm_context *context)
+{
+   context-client-ops-close_channel(context);
+   kfree(context);
+}
+
 static void tegra_drm_lastclose(struct drm_device *drm)
 {
struct host1x_drm *host1x = drm-dev_private;
@@ -287,7 +309,189 @@ static void tegra_drm_lastclose(struct drm_device *drm)
tegra_fbdev_restore_mode(host1x-fbdev);
 }
 
+#ifdef CONFIG_DRM_TEGRA_STAGING
+static int tegra_drm_ioctl_syncpt_read(struct drm_device *drm, void *data,
+  struct drm_file *file)
+{
+   struct drm_tegra_syncpt_read *args = data;
+   struct host1x *host = 

[PATCHv8 7/9] gpu: host1x: Remove second host1x driver

2013-03-22 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: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 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|5 +-
 drivers/gpu/host1x/drm/drm.c   |  214 ++-
 drivers/gpu/host1x/drm/drm.h   |3 -
 drivers/gpu/host1x/drm/hdmi.c  |5 +-
 drivers/gpu/host1x/drm/host1x.c|  329 
 drivers/gpu/host1x/host1x_client.h |   35 
 10 files changed, 317 insertions(+), 342 deletions(-)
 delete mode 100644 drivers/gpu/host1x/drm/host1x.c
 create mode 100644 drivers/gpu/host1x/host1x_client.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 4761e8a..9a6fc76 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -13,6 +13,6 @@ host1x-y = \
 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 9689724..8ce9889 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -32,6 +32,19 @@
 #include channel.h
 #include debug.h
 #include hw/host1x01.h
+#include host1x_client.h
+
+void host1x_set_drm_data(struct device *dev, void *data)
+{
+   struct host1x *host1x = dev_get_drvdata(dev);
+   host1x-drm_data = data;
+}
+
+void *host1x_get_drm_data(struct device *dev)
+{
+   struct host1x *host1x = dev_get_drvdata(dev);
+   return host1x-drm_data;
+}
 
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
 {
@@ -150,6 +163,8 @@ static int host1x_probe(struct platform_device *pdev)
 
host1x_debug_init(host);
 
+   host1x_drm_alloc(pdev);
+
return 0;
 
 fail_deinit_syncpt:
@@ -168,7 +183,7 @@ static int __exit host1x_remove(struct platform_device 
*pdev)
return 0;
 }
 
-static struct platform_driver platform_driver = {
+static struct platform_driver tegra_host1x_driver = {
.probe = host1x_probe,
.remove = __exit_p(host1x_remove),
.driver = {
@@ -178,8 +193,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_DRM_TEGRA
+   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_DRM_TEGRA
+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_DRM_TEGRA
+   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 thierry.red...@avionic-design.de);
 MODULE_AUTHOR(Terje Bergstrom tbergst...@nvidia.com);
 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 4d16fe9..a1607d6 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -124,6 +124,8 @@ struct host1x {
unsigned int num_allocated_channels;
 
struct dentry *debugfs;
+
+   void *drm_data;
 };
 
 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -299,4 +301,8 @@ static inline void host1x_hw_show_mlocks(struct host1x 
*host, struct output *o)
host-debug_op-show_mlocks(host, o);
 }
 
+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 

Re: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Daniel Vetter
On Thu, Mar 21, 2013 at 10:42 PM, Dylan Semler dylan.sem...@gmail.com wrote:
 Oops.  I neglected to preface this with my motivation:  I have a new monitor
 that doesn't report its native resolution in its EDID block.  It seemed to
 me
 this calls for an EDID quirk, but the current quirk infrastructure doesn't
 allow explicitly creating new modes.  So I set out to make a simple
 enhancement
 to allow specifying a new mode and then setting it as preferred.



 On Thu, Mar 21, 2013 at 5:36 PM, Dylan Semler dylan.sem...@gmail.com
 wrote:

 The idea is setup a new quirk list with width, height, and refresh rates
 for
 each monitor that needs this quirk.  If a monitor is attached that matches
 one
 in this list, the full modeline is calculated with drm_gtf_mode, the
 DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added to the
 connector.

 The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit
 needs
 to be set for the new quirk list discribed above to be checked.

 The first patch enhances the quirk logic as described above.  The second
 one
 adds my new monitor to the quirk lists.

I think it'd be good to shovel these text blocks into the (currently
rather empty) commit messages of the patches. Since when reading old
commits with e.g. git blame that's what people will read.
-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


[PATCH 1/3] drm/exynos: hdmi: Fix incorrect usage of IS_ERR_OR_NULL

2013-03-22 Thread Sachin Kamat
Use IS_ERR instead of IS_ERR_OR_NULL on clk_get results.

Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
---
 drivers/gpu/drm/exynos/exynos_hdmi.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 2c5f266..10757b6 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -2023,27 +2023,27 @@ static int hdmi_resources_init(struct hdmi_context 
*hdata)
 
/* get clocks, power */
res-hdmi = devm_clk_get(dev, hdmi);
-   if (IS_ERR_OR_NULL(res-hdmi)) {
+   if (IS_ERR(res-hdmi)) {
DRM_ERROR(failed to get clock 'hdmi'\n);
goto fail;
}
res-sclk_hdmi = devm_clk_get(dev, sclk_hdmi);
-   if (IS_ERR_OR_NULL(res-sclk_hdmi)) {
+   if (IS_ERR(res-sclk_hdmi)) {
DRM_ERROR(failed to get clock 'sclk_hdmi'\n);
goto fail;
}
res-sclk_pixel = devm_clk_get(dev, sclk_pixel);
-   if (IS_ERR_OR_NULL(res-sclk_pixel)) {
+   if (IS_ERR(res-sclk_pixel)) {
DRM_ERROR(failed to get clock 'sclk_pixel'\n);
goto fail;
}
res-sclk_hdmiphy = devm_clk_get(dev, sclk_hdmiphy);
-   if (IS_ERR_OR_NULL(res-sclk_hdmiphy)) {
+   if (IS_ERR(res-sclk_hdmiphy)) {
DRM_ERROR(failed to get clock 'sclk_hdmiphy'\n);
goto fail;
}
res-hdmiphy = devm_clk_get(dev, hdmiphy);
-   if (IS_ERR_OR_NULL(res-hdmiphy)) {
+   if (IS_ERR(res-hdmiphy)) {
DRM_ERROR(failed to get clock 'hdmiphy'\n);
goto fail;
}
-- 
1.7.4.1

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


[PATCH 2/3] drm/exynos: mixer: Fix incorrect usage of IS_ERR_OR_NULL

2013-03-22 Thread Sachin Kamat
Use IS_ERR instead of IS_ERR_OR_NULL on clk_get results.

Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
---
 drivers/gpu/drm/exynos/exynos_mixer.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 2f4f72f..2bd85c8 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -1047,13 +1047,13 @@ static int mixer_resources_init(struct 
exynos_drm_hdmi_context *ctx,
spin_lock_init(mixer_res-reg_slock);
 
mixer_res-mixer = devm_clk_get(dev, mixer);
-   if (IS_ERR_OR_NULL(mixer_res-mixer)) {
+   if (IS_ERR(mixer_res-mixer)) {
dev_err(dev, failed to get clock 'mixer'\n);
return -ENODEV;
}
 
mixer_res-sclk_hdmi = devm_clk_get(dev, sclk_hdmi);
-   if (IS_ERR_OR_NULL(mixer_res-sclk_hdmi)) {
+   if (IS_ERR(mixer_res-sclk_hdmi)) {
dev_err(dev, failed to get clock 'sclk_hdmi'\n);
return -ENODEV;
}
@@ -1096,17 +1096,17 @@ static int vp_resources_init(struct 
exynos_drm_hdmi_context *ctx,
struct resource *res;
 
mixer_res-vp = devm_clk_get(dev, vp);
-   if (IS_ERR_OR_NULL(mixer_res-vp)) {
+   if (IS_ERR(mixer_res-vp)) {
dev_err(dev, failed to get clock 'vp'\n);
return -ENODEV;
}
mixer_res-sclk_mixer = devm_clk_get(dev, sclk_mixer);
-   if (IS_ERR_OR_NULL(mixer_res-sclk_mixer)) {
+   if (IS_ERR(mixer_res-sclk_mixer)) {
dev_err(dev, failed to get clock 'sclk_mixer'\n);
return -ENODEV;
}
mixer_res-sclk_dac = devm_clk_get(dev, sclk_dac);
-   if (IS_ERR_OR_NULL(mixer_res-sclk_dac)) {
+   if (IS_ERR(mixer_res-sclk_dac)) {
dev_err(dev, failed to get clock 'sclk_dac'\n);
return -ENODEV;
}
-- 
1.7.4.1

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


[PATCH 3/3] drm/exynos: drm_rotator: Fix incorrect usage of IS_ERR_OR_NULL

2013-03-22 Thread Sachin Kamat
Use IS_ERR instead of IS_ERR_OR_NULL on clk_get results.

Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
---
 drivers/gpu/drm/exynos/exynos_drm_rotator.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c 
b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
index a40b9fb..947f09f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -674,7 +674,7 @@ static int rotator_probe(struct platform_device *pdev)
}
 
rot-clock = devm_clk_get(dev, rotator);
-   if (IS_ERR_OR_NULL(rot-clock)) {
+   if (IS_ERR(rot-clock)) {
dev_err(dev, failed to get clock\n);
ret = PTR_ERR(rot-clock);
goto err_clk_get;
-- 
1.7.4.1

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


[PATCH] nouveau: Fix unconditional return waiting on memory

2013-03-22 Thread Calvin Owens
Typo in nv50_display_flip_wait allows page flipping to run ahead before
memory has time to settle.

Signed-off-by: Calvin Owens jcalvinow...@gmail.com
---
 drivers/gpu/drm/nouveau/nv50_display.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nv50_display.c 
b/drivers/gpu/drm/nouveau/nv50_display.c
index 2db5799..96bc2f3 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -479,7 +479,7 @@ nv50_display_flip_wait(void *data)
 {
struct nv50_display_flip *flip = data;
if (nouveau_bo_rd32(flip-disp-sync, flip-chan-addr / 4) ==
- flip-chan-data);
+ flip-chan-data)
return true;
usleep_range(1, 2);
return false;
-- 
1.7.3.4
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 45641] Screen goes black randomly

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=45641

--- Comment #16 from Jan Papež (honyczek) honyc...@centrum.cz ---
(Additional info to comment #12)
 Interesting: If I connect only one monitor (either on cable 1 or 2), it works 
 well.
It is not working well, but in only blinks in longer intervals. After resuming
from hibernation, it started blinking more.
(In reply to comment #13)
 2. Disable acceleration (Option NoAccel True in the device section of 
 your xorg.conf)

After starting Xorg with NoAccel option, it is not blinking. But:
1. why don't use acceleration on accelerated graphic card?
2. I can't use rotated monitor, because it requires acceleration enabled.

-- 
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


Re: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 4:48 AM, Daniel Vetter dan...@ffwll.ch wrote:

 I think it'd be good to shovel these text blocks into the (currently
rather
 empty) commit messages of the patches. Since when reading old commits with
 e.g. git blame that's what people will read.

Yeah, I just noticed that.  For some reason my git format-patch didn't place
the commit messages above the signoff.  Here comes v2.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Alex Deucher
On Thu, Mar 21, 2013 at 5:42 PM, Dylan Semler dylan.sem...@gmail.com wrote:
 Oops.  I neglected to preface this with my motivation:  I have a new monitor
 that doesn't report its native resolution in its EDID block.  It seemed to
 me
 this calls for an EDID quirk, but the current quirk infrastructure doesn't
 allow explicitly creating new modes.  So I set out to make a simple
 enhancement
 to allow specifying a new mode and then setting it as preferred.


That's odd.  Maybe it's actually in an extension block or something like that?



 On Thu, Mar 21, 2013 at 5:36 PM, Dylan Semler dylan.sem...@gmail.com
 wrote:

 The idea is setup a new quirk list with width, height, and refresh rates
 for
 each monitor that needs this quirk.  If a monitor is attached that matches
 one
 in this list, the full modeline is calculated with drm_gtf_mode, the
 DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added to the
 connector.

 The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit
 needs
 to be set for the new quirk list discribed above to be checked.

 The first patch enhances the quirk logic as described above.  The second
 one
 adds my new monitor to the quirk lists.



 ___
 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


[PATCH v2 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
Changes in this version
 * Fix missing commit messages in patch emails

These patches offer a fix for a monitor that doesn't report its native
resolution in its EDID.  The idea is setup a new quirk list with width, height,
and refresh rates for each monitor that needs this quirk.  If a monitor is
attached that matches one in this list, the full modeline is calculated with
drm_gtf_mode, the DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added
to the connector.

The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit needs
to be set for the new quirk list discribed above to be checked.

Dylan Semler (2):
  Enhances EDID quirks to allow for specifying and preferring a mode
not reported in the EDID block.
  Adds EDID force mode quirk for MMT Monitor2Go HD+.

 drivers/gpu/drm/drm_edid.c | 77 ++
 1 file changed, 77 insertions(+)

-- 
1.7.11.7

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


[PATCH v2 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.

2013-03-22 Thread Dylan Semler
Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 72 ++
 1 file changed, 72 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..b1036b5 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1  6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1  7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1  8)
 
 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,15 @@ static struct edid_quirk {
{ VSC, 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };
 
+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }
 
+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh)
+{
+   struct drm_display_mode *mode;
+   struct drm_device *dev = connector-dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay  0)
+   return 0;
+   if (vdisplay  0)
+   return 0;
+   if (vrefresh  0)
+   return 0;
+
+   mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);
+
+   if (mode) {
+   mode-type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i  ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = edid_quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode-vendor) 
+   (EDID_PRODUCT_ID(edid) == quirk_mode-product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode-hdisplay,
+   quirk_mode-vdisplay,
+   quirk_mode-vrefresh);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)
 
if (quirks  (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks  EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);
 
drm_add_display_info(edid, connector-display_info);
 
-- 
1.7.11.7

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


[PATCH v2 2/2] Adds EDID force mode quirk for MMT Monitor2Go HD+.

2013-03-22 Thread Dylan Semler
Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b1036b5..b400971 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ FCM, 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },
 
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { LLP, 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ LPL, 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ LPL, 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -136,6 +139,8 @@ static struct edid_quirk_force_mode {
int vdisplay;
int vrefresh;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { LLP, 0x4c54, 1600, 900, 60 },
 };
 
 /*
-- 
1.7.11.7

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


Re: [PATCH 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.

2013-03-22 Thread Alex Deucher
On Thu, Mar 21, 2013 at 5:36 PM, Dylan Semler dylan.sem...@gmail.com wrote:

 Signed-off-by: Dylan Semler dylan.sem...@gmail.com
 ---
  drivers/gpu/drm/drm_edid.c | 72 
 ++
  1 file changed, 72 insertions(+)

 diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
 index c194f4e..b1036b5 100644
 --- a/drivers/gpu/drm/drm_edid.c
 +++ b/drivers/gpu/drm/drm_edid.c
 @@ -68,6 +68,8 @@
  #define EDID_QUIRK_DETAILED_SYNC_PP(1  6)
  /* Force reduced-blanking timings for detailed modes */
  #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1  7)
 +/* Force specific mode for monitors that don't report correct EDIDs */
 +#define EDID_QUIRK_FORCE_MODE  (1  8)

  struct detailed_mode_closure {
 struct drm_connector *connector;
 @@ -127,6 +129,15 @@ static struct edid_quirk {
 { VSC, 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
  };

 +static struct edid_quirk_force_mode {
 +   char vendor[4];
 +   int product_id;
 +   int hdisplay;
 +   int vdisplay;
 +   int vrefresh;
 +} edid_quirk_force_mode_list[] = {
 +};
 +
  /*
   * Autogenerated from the DMT spec.
   * This table is copied from xfree86/modes/xf86EdidModes.c.
 @@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, 
 struct edid *edid,
 return closure.modes;
  }

 +/* Add an explicit mode based on a quirk
 + */
 +static int
 +do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
 +int vdisplay, int vrefresh)
 +{
 +   struct drm_display_mode *mode;
 +   struct drm_device *dev = connector-dev;
 +   int num_modes = 0;
 +
 +   /* sanity check display parameters */
 +   if (hdisplay  0)
 +   return 0;
 +   if (vdisplay  0)
 +   return 0;
 +   if (vrefresh  0)
 +   return 0;
 +
 +   mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);

I would suggest using drm_cvt_mode() here since most modern monitors
prefer cvt timing and usually reduced blanking.  A lot of LCD monitors
don't like gtf timing.  You might also want to add a reduced blanking
field to the edid_quirk_force_mode struct so that you can specify on a
quirk by quirk basis.

Alex

 +
 +   if (mode) {
 +   mode-type |= DRM_MODE_TYPE_PREFERRED;
 +   drm_mode_probed_add(connector, mode);
 +   num_modes++;
 +   }
 +   return num_modes;
 +}
 +
 +/*
 + * add_force_quirk_modes - Add modes based on monitor's EDID quirks
 + * @connector: attached connector
 + * @edid: EDID block to scan
 + * @quirks: quirks to apply
 + *
 + * At least one monitor doesn't report its native resolution in its EDID 
 block.
 + * Here we add the native mode according to this quirk
 + */
 +static int
 +add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
 + u32 quirks)
 +{
 +   struct edid_quirk_force_mode *quirk_mode;
 +   int i, num_modes = 0;
 +
 +   for (i = 0; i  ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
 +   quirk_mode = edid_quirk_force_mode_list[i];
 +
 +   if (edid_vendor(edid, quirk_mode-vendor) 
 +   (EDID_PRODUCT_ID(edid) == quirk_mode-product_id)) {
 +   num_modes = do_force_quirk_modes(connector,
 +   quirk_mode-hdisplay,
 +   quirk_mode-vdisplay,
 +   quirk_mode-vrefresh);
 +   }
 +   }
 +   return num_modes;
 +
 +}
 +
  #define HDMI_IDENTIFIER 0x000C03
  #define AUDIO_BLOCK0x01
  #define VIDEO_BLOCK 0x02
 @@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
 struct edid *edid)

 if (quirks  (EDID_QUIRK_PREFER_LARGE_60 | 
 EDID_QUIRK_PREFER_LARGE_75))
 edid_fixup_preferred(connector, quirks);
 +   if (quirks  EDID_QUIRK_FORCE_MODE)
 +   num_modes += add_force_quirk_modes(connector, edid, quirks);

 drm_add_display_info(edid, connector-display_info);

 --
 1.7.11.7

 ___
 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: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher alexdeuc...@gmail.com wrote:

 On Thu, Mar 21, 2013 at 5:42 PM, Dylan Semler dylan.sem...@gmail.com
wrote:
  Oops.  I neglected to preface this with my motivation:  I have a new
  monitor that doesn't report its native resolution in its EDID block.  It
  seemed to me this calls for an EDID quirk, but the current quirk
  infrastructure doesn't allow explicitly creating new modes.  So I set
out
  to make a simple enhancement to allow specifying a new mode and then
  setting it as preferred.
 

 That's odd.  Maybe it's actually in an extension block or something like
 that?

Yeah, I agree.  According to edid-decode /sys/class/drm/card0-HDMI-A-1/edid
there's one extension block, but none of those modes are the native
resolution
either.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 62012] Intermittent black geometry

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=62012

Michel Dänzer mic...@daenzer.net changed:

   What|Removed |Added

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

--- Comment #1 from Michel Dänzer mic...@daenzer.net ---
commit c446baa0be1ed2a3bf157519f89a65d348aad17c
Author: Michel Danzer michel.daen...@amd.com
Date:   Fri Mar 22 14:09:10 2013 +

R600: Use legacy (0 * anything = 0) MUL instructions for pow intrinsics

Fixes wrong lighting in some corner cases with r600g and radeonsi, e.g.
manifested by failure of two piglit/glean tests and intermittent black
patches in many apps.

Tested on SI and RS880.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62012 [radeonsi]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58150 [r600g]

NOTE: This is a candidate for the Mesa stable branch.

Reviewed-by: Christian König christian.koe...@amd.com

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177730
91177308-0d34-0410-b5e6-96231b3b80d8

-- 
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 58150] LLVM regression on 4890 since r600g: Use default mul/mad function for tgsi-to-llvm

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=58150

Michel Dänzer mic...@daenzer.net changed:

   What|Removed |Added

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

--- Comment #3 from Michel Dänzer mic...@daenzer.net ---
commit c446baa0be1ed2a3bf157519f89a65d348aad17c
Author: Michel Danzer michel.daen...@amd.com
Date:   Fri Mar 22 14:09:10 2013 +

R600: Use legacy (0 * anything = 0) MUL instructions for pow intrinsics

Fixes wrong lighting in some corner cases with r600g and radeonsi, e.g.
manifested by failure of two piglit/glean tests and intermittent black
patches in many apps.

Tested on SI and RS880.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62012 [radeonsi]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58150 [r600g]

NOTE: This is a candidate for the Mesa stable branch.

Reviewed-by: Christian König christian.koe...@amd.com

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177730
91177308-0d34-0410-b5e6-96231b3b80d8

-- 
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 45641] Screen goes black randomly

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=45641

--- Comment #17 from Alex Deucher ag...@yahoo.com ---
Created attachment 76907
  -- https://bugs.freedesktop.org/attachment.cgi?id=76907action=edit
possible fix

Does the attached kernel patch 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 37696] [RADEON:KMS:PLL] frequent colored lines appear on screen

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=37696

--- Comment #4 from Alex Deucher ag...@yahoo.com ---
Created attachment 76913
  -- https://bugs.freedesktop.org/attachment.cgi?id=76913action=edit
possible fix

Does the attached patch 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


[PATCHv9 0/9] Support Tegra 2D hardware

2013-03-22 Thread Terje Bergstrom
This set of patches adds support for Tegra20 and Tegra30 host1x and
2D. It is based on linux-next-20130322 with RTC fixes applied.

Changes in this version:
 * Renaming in drivers/gpu/host1x/drm/drm.c to shorten function names
 * Whitespace and function order fixes
 * An extra struct (host1x_addr_reg) removed
 * Added uapi Kbuild entry

Changes in version 8:
 * Own version of framebuffer driver due to move to own allocator
   * Thanks to Thierry Reding for help
 * Miscellaneous variable name, whitespace and IOCTL interface cleanups
 * Bug fixes:
   * Validator enabled again
   * Added new class 2D strechblit
 * Dropped patch Support CMA object preallocation

Changes in version 7:
 * host1x memory data structures refactored
 * Some nvhost leftovers renamed to host1x

Changes in version 6:
 * Rebased on latest tegradrm
 * Renamed tegradrm's host1x to host1x_drm
 * Indentation and line split fixed to follow tegradrm convention
 * Pointers to platform_device replaced with pointers to device
 * Added host1x allocator, and wired it in
 * Debug spew code fixed to access mem handles from host1x_job
 * CDMA code doesn't keep the mem handles anymore
 * Push buffer ops have been made generic code
 * Removed the pin_array optimization in host1x_job to simplify code
 * Large number of smaller changes

The driver implements an allocator using the dma mapping API. Each buffer is
assigned an ops structure to operate on it.

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 http://http.download.nvidia.com/tegra-public-appnotes/host1x.html
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.

The changes to add support to libdrm are in
g...@gitorious.org:linux-host1x/libdrm-host1x.git

Arto Merilainen (2):
  gpu: host1x: drm: Rename host1x to host1x_drm
  gpu: host1x: drm: Add memory manager and fb

Terje Bergstrom (7):
  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
  drm: tegra: Add gr2d device

 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|  217 
 drivers/gpu/drm/tegra/fb.c |   52 --
 drivers/gpu/drm/tegra/host1x.c |  327 
 drivers/gpu/host1x/Kconfig |   23 +
 drivers/gpu/host1x/Makefile|   20 +
 drivers/gpu/host1x/cdma.c  |  491 ++
 drivers/gpu/host1x/cdma.h  |  100 
 drivers/gpu/host1x/channel.c   |  126 +
 drivers/gpu/host1x/channel.h   |   52 ++
 drivers/gpu/host1x/debug.c |  210 
 drivers/gpu/host1x/debug.h |   51 ++
 drivers/gpu/host1x/dev.c   |  246 +
 drivers/gpu/host1x/dev.h   |  308 
 drivers/gpu/{drm/tegra = host1x/drm}/Kconfig  |   19 +-
 drivers/gpu/{drm/tegra = host1x/drm}/dc.c |   26 +-
 drivers/gpu/{drm/tegra = host1x/drm}/dc.h |0
 drivers/gpu/host1x/drm/drm.c   |  640 
 drivers/gpu/{drm/tegra = host1x/drm}/drm.h|   68 ++-
 drivers/gpu/host1x/drm/fb.c|  372 ++
 drivers/gpu/host1x/drm/gem.c   |  270 ++
 drivers/gpu/host1x/drm/gem.h   |   59 +++
 drivers/gpu/host1x/drm/gr2d.c  |  339 +
 drivers/gpu/{drm/tegra = host1x/drm}/hdmi.c   |5 +-
 drivers/gpu/{drm/tegra = host1x/drm}/hdmi.h   |0
 drivers/gpu/{drm/tegra = host1x/drm}/output.c |0
 drivers/gpu/{drm/tegra = host1x/drm}/rgb.c|0
 drivers/gpu/host1x/host1x.h|   30 ++
 drivers/gpu/host1x/host1x_bo.h |   87 
 drivers/gpu/host1x/host1x_client.h |   35 ++
 drivers/gpu/host1x/hw/Makefile |6 +
 drivers/gpu/host1x/hw/cdma_hw.c|  326 
 drivers/gpu/host1x/hw/channel_hw.c |  168 +++
 drivers/gpu/host1x/hw/debug_hw.c   |  322 
 drivers/gpu/host1x/hw/host1x01.c   |   42 ++
 drivers/gpu/host1x/hw/host1x01.h

[PATCHv9 1/9] gpu: host1x: Add host1x driver

2013-03-22 Thread Terje Bergstrom
Add host1x, the driver for host1x and its client unit 2D. The Tegra
host1x module is the DMA engine for register access to Tegra's
graphics- and multimedia-related modules. The modules served by
host1x are referred to as clients. host1x includes some other
functionality, such as synchronization.

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/Makefile  |1 +
 drivers/gpu/host1x/Kconfig|9 ++
 drivers/gpu/host1x/Makefile   |8 ++
 drivers/gpu/host1x/dev.c  |  153 +
 drivers/gpu/host1x/dev.h  |   96 +
 drivers/gpu/host1x/hw/Makefile|6 +
 drivers/gpu/host1x/hw/host1x01.c  |   33 +
 drivers/gpu/host1x/hw/host1x01.h  |   25 
 drivers/gpu/host1x/hw/host1x01_hardware.h |   27 
 drivers/gpu/host1x/hw/hw_host1x01_sync.h  |   74 ++
 drivers/gpu/host1x/hw/syncpt_hw.c |  102 ++
 drivers/gpu/host1x/syncpt.c   |  212 +
 drivers/gpu/host1x/syncpt.h   |  147 
 drivers/video/Kconfig |2 +
 include/trace/events/host1x.h |   61 +
 15 files changed, 956 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 30879df..d8a22c2 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1 +1,2 @@
 obj-y  += drm/ vga/
+obj-$(CONFIG_TEGRA_HOST1X) += host1x/
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
new file mode 100644
index 000..c01c450
--- /dev/null
+++ b/drivers/gpu/host1x/Kconfig
@@ -0,0 +1,9 @@
+config TEGRA_HOST1X
+   tristate NVIDIA Tegra host1x driver
+   help
+ Driver for the NVIDIA Tegra host1x hardware.
+
+ The Tegra host1x module is the DMA engine for register access to
+ Tegra's graphics- and multimedia-related modules. The modules served
+ by host1x are referred to as clients. host1x includes some other
+ functionality, such as synchronization.
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..0d6002c
--- /dev/null
+++ b/drivers/gpu/host1x/dev.c
@@ -0,0 +1,153 @@
+/*
+ * 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 http://www.gnu.org/licenses/.
+ */
+
+#include linux/module.h
+#include linux/list.h
+#include linux/slab.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/clk.h
+#include linux/io.h
+
+#define CREATE_TRACE_POINTS
+#include trace/events/host1x.h
+
+#include dev.h
+#include hw/host1x01.h
+
+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 const struct host1x_info host1x01_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_of_match[] = {
+   { .compatible = 

[PATCHv9 2/9] gpu: host1x: Add syncpoint wait and interrupts

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

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/Makefile  |1 +
 drivers/gpu/host1x/dev.c |   12 ++
 drivers/gpu/host1x/dev.h |   51 +
 drivers/gpu/host1x/hw/host1x01.c |2 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h |   42 
 drivers/gpu/host1x/hw/intr_hw.c  |  143 +
 drivers/gpu/host1x/intr.c|  328 ++
 drivers/gpu/host1x/intr.h|   96 +
 drivers/gpu/host1x/syncpt.c  |  159 +++
 drivers/gpu/host1x/syncpt.h  |   12 ++
 10 files changed, 846 insertions(+)
 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 0d6002c..b967f6e 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -28,6 +28,7 @@
 #include trace/events/host1x.h
 
 #include dev.h
+#include intr.h
 #include hw/host1x01.h
 
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
@@ -123,13 +124,24 @@ static int host1x_probe(struct platform_device *pdev)
return err;
}
 
+   err = host1x_intr_init(host, syncpt_irq);
+   if (err) {
+   dev_err(pdev-dev, failed to initialize interrupts\n);
+   goto fail_deinit_syncpt;
+   }
+
return 0;
+
+fail_deinit_syncpt:
+   host1x_syncpt_deinit(host);
+   return err;
 }
 
 static int __exit host1x_remove(struct platform_device *pdev)
 {
struct host1x *host = platform_get_drvdata(pdev);
 
+   host1x_intr_deinit(host);
host1x_syncpt_deinit(host);
clk_disable_unprepare(host-clk);
 
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index eaf6026..caf9cc6 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -21,6 +21,7 @@
 #include linux/device.h
 
 #include syncpt.h
+#include intr.h
 
 struct host1x_syncpt;
 
@@ -33,6 +34,17 @@ struct host1x_syncpt_ops {
int (*patch_wait)(struct host1x_syncpt *syncpt, void *patch_addr);
 };
 
+struct host1x_intr_ops {
+   int (*init_host_sync)(struct host1x *host, u32 cpm,
+   void (*syncpt_thresh_work)(struct work_struct *work));
+   void (*set_syncpt_threshold)(
+   struct host1x *host, u32 id, u32 thresh);
+   void (*enable_syncpt_intr)(struct host1x *host, u32 id);
+   void (*disable_syncpt_intr)(struct host1x *host, u32 id);
+   void (*disable_all_syncpt_intrs)(struct host1x *host);
+   int (*free_syncpt_irq)(struct host1x *host);
+};
+
 struct host1x_info {
int nb_channels;/* host1x: num channels supported */
int nb_pts; /* host1x: num syncpoints supported */
@@ -50,7 +62,13 @@ struct host1x {
struct device *dev;
struct clk *clk;
 
+   struct mutex intr_mutex;
+   struct workqueue_struct *intr_wq;
+   int intr_syncpt_irq;
+
const struct host1x_syncpt_ops *syncpt_op;
+   const struct host1x_intr_ops *intr_op;
+
 };
 
 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -93,4 +111,37 @@ static inline int host1x_hw_syncpt_patch_wait(struct host1x 
*host,
return host-syncpt_op-patch_wait(sp, patch_addr);
 }
 
+static inline int host1x_hw_intr_init_host_sync(struct host1x *host, u32 cpm,
+   void (*syncpt_thresh_work)(struct work_struct *))
+{
+   return host-intr_op-init_host_sync(host, cpm, syncpt_thresh_work);
+}
+
+static inline void host1x_hw_intr_set_syncpt_threshold(struct host1x *host,
+  u32 id, u32 thresh)
+{
+   host-intr_op-set_syncpt_threshold(host, id, thresh);
+}
+
+static inline void host1x_hw_intr_enable_syncpt_intr(struct host1x *host,
+u32 id)
+{
+   host-intr_op-enable_syncpt_intr(host, id);
+}
+
+static inline void host1x_hw_intr_disable_syncpt_intr(struct host1x *host,
+ u32 id)
+{
+   host-intr_op-disable_syncpt_intr(host, id);
+}
+
+static inline void host1x_hw_intr_disable_all_syncpt_intrs(struct host1x *host)
+{
+   host-intr_op-disable_all_syncpt_intrs(host);
+}
+
+static inline int host1x_hw_intr_free_syncpt_irq(struct host1x *host)
+{
+   return 

[PATCHv9 6/9] gpu: host1x: drm: Rename host1x to host1x_drm

2013-03-22 Thread Terje Bergstrom
From: Arto Merilainen amerilai...@nvidia.com

Both host1x and drm drivers have host1x structures. This patch
renames the host1x structure under drm to follow name host1x_drm.

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/drm/dc.c |4 ++--
 drivers/gpu/host1x/drm/drm.c|4 ++--
 drivers/gpu/host1x/drm/drm.h|   14 +++---
 drivers/gpu/host1x/drm/fb.c |6 +++---
 drivers/gpu/host1x/drm/hdmi.c   |4 ++--
 drivers/gpu/host1x/drm/host1x.c |   22 --
 6 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index de94707..d1f6609 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -1097,7 +1097,7 @@ static const struct host1x_client_ops dc_client_ops = {
 
 static int tegra_dc_probe(struct platform_device *pdev)
 {
-   struct host1x *host1x = dev_get_drvdata(pdev-dev.parent);
+   struct host1x_drm *host1x = dev_get_drvdata(pdev-dev.parent);
struct resource *regs;
struct tegra_dc *dc;
int err;
@@ -1160,7 +1160,7 @@ static int tegra_dc_probe(struct platform_device *pdev)
 
 static int tegra_dc_remove(struct platform_device *pdev)
 {
-   struct host1x *host1x = dev_get_drvdata(pdev-dev.parent);
+   struct host1x_drm *host1x = dev_get_drvdata(pdev-dev.parent);
struct tegra_dc *dc = platform_get_drvdata(pdev);
int err;
 
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index 9d452df..6c59bcd 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -26,7 +26,7 @@
 static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 {
struct device *dev = drm-dev;
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
int err;
 
host1x = dev_get_drvdata(dev);
@@ -69,7 +69,7 @@ static int tegra_drm_open(struct drm_device *drm, struct 
drm_file *filp)
 
 static void tegra_drm_lastclose(struct drm_device *drm)
 {
-   struct host1x *host1x = drm-dev_private;
+   struct host1x_drm *host1x = drm-dev_private;
 
drm_fbdev_cma_restore_mode(host1x-fbdev);
 }
diff --git a/drivers/gpu/host1x/drm/drm.h b/drivers/gpu/host1x/drm/drm.h
index a6c011d..7fedb6c 100644
--- a/drivers/gpu/host1x/drm/drm.h
+++ b/drivers/gpu/host1x/drm/drm.h
@@ -18,7 +18,7 @@
 #include drm/drm_fb_cma_helper.h
 #include drm/drm_fixed.h
 
-struct host1x {
+struct host1x_drm {
struct drm_device *drm;
struct device *dev;
void __iomem *regs;
@@ -44,7 +44,7 @@ struct host1x_client_ops {
 };
 
 struct host1x_client {
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
struct device *dev;
 
const struct host1x_client_ops *ops;
@@ -52,12 +52,12 @@ struct host1x_client {
struct list_head list;
 };
 
-extern int host1x_drm_init(struct host1x *host1x, struct drm_device *drm);
-extern int host1x_drm_exit(struct host1x *host1x);
+extern int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm);
+extern int host1x_drm_exit(struct host1x_drm *host1x);
 
-extern int host1x_register_client(struct host1x *host1x,
+extern int host1x_register_client(struct host1x_drm *host1x,
  struct host1x_client *client);
-extern int host1x_unregister_client(struct host1x *host1x,
+extern int host1x_unregister_client(struct host1x_drm *host1x,
struct host1x_client *client);
 
 struct tegra_output;
@@ -66,7 +66,7 @@ struct tegra_dc {
struct host1x_client client;
spinlock_t lock;
 
-   struct host1x *host1x;
+   struct host1x_drm *host1x;
struct device *dev;
 
struct drm_crtc base;
diff --git a/drivers/gpu/host1x/drm/fb.c b/drivers/gpu/host1x/drm/fb.c
index 0391495..6ed885a 100644
--- a/drivers/gpu/host1x/drm/fb.c
+++ b/drivers/gpu/host1x/drm/fb.c
@@ -11,7 +11,7 @@
 
 static void tegra_drm_fb_output_poll_changed(struct drm_device *drm)
 {
-   struct host1x *host1x = drm-dev_private;
+   struct host1x_drm *host1x = drm-dev_private;
 
drm_fbdev_cma_hotplug_event(host1x-fbdev);
 }
@@ -23,7 +23,7 @@ static const struct drm_mode_config_funcs 
tegra_drm_mode_funcs = {
 
 int tegra_drm_fb_init(struct drm_device *drm)
 {
-   struct host1x *host1x = drm-dev_private;
+   struct host1x_drm *host1x = drm-dev_private;
struct drm_fbdev_cma *fbdev;
 
drm-mode_config.min_width = 0;
@@ -46,7 +46,7 @@ int tegra_drm_fb_init(struct drm_device *drm)
 
 void tegra_drm_fb_exit(struct drm_device *drm)
 {
-   struct host1x *host1x = drm-dev_private;
+   struct host1x_drm *host1x = drm-dev_private;
 
drm_fbdev_cma_fini(host1x-fbdev);
 }
diff --git a/drivers/gpu/host1x/drm/hdmi.c b/drivers/gpu/host1x/drm/hdmi.c
index bb747f6..f438f80 100644
--- a/drivers/gpu/host1x/drm/hdmi.c
+++ 

[PATCHv9 5/9] drm: tegra: Move drm to live under host1x

2013-03-22 Thread Terje Bergstrom
Make drm part of host1x driver.

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/drm/Kconfig|2 --
 drivers/gpu/drm/Makefile   |1 -
 drivers/gpu/drm/tegra/Makefile |7 ---
 drivers/gpu/host1x/Kconfig |2 ++
 drivers/gpu/host1x/Makefile|5 +
 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
 16 files changed, 10 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%)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 1e82882..9031bb7 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -215,8 +215,6 @@ source drivers/gpu/drm/cirrus/Kconfig
 
 source drivers/gpu/drm/shmobile/Kconfig
 
-source drivers/gpu/drm/tegra/Kconfig
-
 source drivers/gpu/drm/omapdrm/Kconfig
 
 source drivers/gpu/drm/tilcdc/Kconfig
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 0d59b24..847b830 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -49,7 +49,6 @@ 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-$(CONFIG_DRM_OMAP) += omapdrm/
 obj-$(CONFIG_DRM_TILCDC)   += tilcdc/
 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 00f0859..ee3af1e 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -18,4 +18,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 49fd580..4761e8a 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -10,4 +10,9 @@ host1x-y = \
debug.o \
hw/host1x01.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 6dd75a2..a6c011d 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.
  */
 
-#ifndef TEGRA_DRM_H
-#define TEGRA_DRM_H 1
+#ifndef HOST1X_DRM_H
+#define HOST1X_DRM_H 1
 
 #include drm/drmP.h
 #include drm/drm_crtc_helper.h
@@ -234,4 

[PATCHv9 8/9] gpu: host1x: drm: Add memory manager and fb

2013-03-22 Thread Terje Bergstrom
From: Arto Merilainen amerilai...@nvidia.com

This patch introduces a memory manager for tegra drm and moves
existing parts to use it. As cma framebuffer helpers can no more
be used, this patch adds also a separate framebuffer driver for
tegra.

Signed-off-by: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/Makefile|1 +
 drivers/gpu/host1x/drm/Kconfig |8 +-
 drivers/gpu/host1x/drm/dc.c|   23 +--
 drivers/gpu/host1x/drm/drm.c   |   17 +-
 drivers/gpu/host1x/drm/drm.h   |   18 ++-
 drivers/gpu/host1x/drm/fb.c|  336 +++-
 drivers/gpu/host1x/drm/gem.c   |  270 
 drivers/gpu/host1x/drm/gem.h   |   59 +++
 8 files changed, 698 insertions(+), 34 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gem.c
 create mode 100644 drivers/gpu/host1x/drm/gem.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 9a6fc76..3768dbc 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -15,4 +15,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/gem.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/drm/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index 7db9b3a..f743540 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -2,11 +2,9 @@ config DRM_TEGRA
bool 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
+   select FB_SYS_FILLRECT
+   select FB_SYS_COPYAREA
+   select FB_SYS_IMAGEBLIT
help
  Choose this option if you have an NVIDIA Tegra SoC.
 
diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
index 29a79b6..85ea616 100644
--- a/drivers/gpu/host1x/drm/dc.c
+++ b/drivers/gpu/host1x/drm/dc.c
@@ -14,9 +14,10 @@
 #include linux/platform_device.h
 #include linux/clk/tegra.h
 
-#include drm.h
-#include dc.h
 #include host1x_client.h
+#include dc.h
+#include drm.h
+#include gem.h
 
 struct tegra_plane {
struct drm_plane base;
@@ -52,9 +53,9 @@ static int tegra_plane_update(struct drm_plane *plane, struct 
drm_crtc *crtc,
window.bits_per_pixel = fb-bits_per_pixel;
 
for (i = 0; i  drm_format_num_planes(fb-pixel_format); i++) {
-   struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, i);
+   struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
 
-   window.base[i] = gem-paddr + fb-offsets[i];
+   window.base[i] = bo-paddr + fb-offsets[i];
 
/*
 * Tegra doesn't support different strides for U and V planes
@@ -137,7 +138,7 @@ static int tegra_dc_add_planes(struct drm_device *drm, 
struct tegra_dc *dc)
 static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
 struct drm_framebuffer *fb)
 {
-   struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, 0);
+   struct tegra_bo *bo = tegra_fb_get_plane(fb, 0);
unsigned long value;
 
tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER);
@@ -145,7 +146,7 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, 
int y,
value = fb-offsets[0] + y * fb-pitches[0] +
x * fb-bits_per_pixel / 8;
 
-   tegra_dc_writel(dc, gem-paddr + value, DC_WINBUF_START_ADDR);
+   tegra_dc_writel(dc, bo-paddr + value, DC_WINBUF_START_ADDR);
tegra_dc_writel(dc, fb-pitches[0], DC_WIN_LINE_STRIDE);
 
value = GENERAL_UPDATE | WIN_A_UPDATE;
@@ -187,20 +188,20 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
 {
struct drm_device *drm = dc-base.dev;
struct drm_crtc *crtc = dc-base;
-   struct drm_gem_cma_object *gem;
unsigned long flags, base;
+   struct tegra_bo *bo;
 
if (!dc-event)
return;
 
-   gem = drm_fb_cma_get_gem_obj(crtc-fb, 0);
+   bo = tegra_fb_get_plane(crtc-fb, 0);
 
/* check if new start address has been latched */
tegra_dc_writel(dc, READ_MUX, DC_CMD_STATE_ACCESS);
base = tegra_dc_readl(dc, DC_WINBUF_START_ADDR);
tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);
 
-   if (base == gem-paddr + crtc-fb-offsets[0]) {
+   if (base == bo-paddr + crtc-fb-offsets[0]) {
spin_lock_irqsave(drm-event_lock, flags);
drm_send_vblank_event(drm, dc-pipe, dc-event);
drm_vblank_put(drm, dc-pipe);
@@ -570,7 +571,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
   struct drm_display_mode *adjusted,
   int x, 

[PATCHv9 4/9] gpu: host1x: Add debug support

2013-03-22 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: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/Makefile |1 +
 drivers/gpu/host1x/cdma.c   |4 +
 drivers/gpu/host1x/debug.c  |  210 +
 drivers/gpu/host1x/debug.h  |   51 +
 drivers/gpu/host1x/dev.c|3 +
 drivers/gpu/host1x/dev.h|   42 
 drivers/gpu/host1x/hw/cdma_hw.c |2 +
 drivers/gpu/host1x/hw/channel_hw.c  |   25 +++
 drivers/gpu/host1x/hw/debug_hw.c|  322 +++
 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/hw_host1x01_uclass.h  |6 +
 drivers/gpu/host1x/hw/syncpt_hw.c   |1 +
 drivers/gpu/host1x/syncpt.c |5 +
 15 files changed, 807 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 06a995b..49fd580 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 \
hw/host1x01.o
 
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index 33935de..de72172 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -439,6 +439,10 @@ void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, 
u32 op2)
struct push_buffer *pb = cdma-push_buffer;
u32 slots_free = cdma-slots_free;
 
+   if (host1x_debug_trace_cmdbuf)
+   trace_host1x_cdma_push(dev_name(cdma_to_channel(cdma)-dev),
+  op1, op2);
+
if (slots_free == 0) {
host1x_hw_cdma_flush(host1x, 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..3ec7d77
--- /dev/null
+++ b/drivers/gpu/host1x/debug.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ * Author: Erik Gilling konk...@android.com
+ *
+ * Copyright (C) 2011-2013 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 linux/debugfs.h
+#include linux/seq_file.h
+#include linux/uaccess.h
+
+#include linux/io.h
+
+#include dev.h
+#include debug.h
+#include channel.h
+
+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, bool show_fifo)
+{
+   struct host1x *m = dev_get_drvdata(ch-dev-parent);
+   struct output *o = data;
+
+   mutex_lock(ch-reflock);
+   if (ch-refcount) {
+   mutex_lock(ch-cdma.lock);
+   if (show_fifo)
+   host1x_hw_show_channel_fifo(m, ch, o);
+   host1x_hw_show_channel_cdma(m, ch, o);
+   mutex_unlock(ch-cdma.lock);
+   }
+   mutex_unlock(ch-reflock);
+
+   return 0;
+}
+
+static void show_syncpts(struct host1x *m, struct output *o)
+{
+   int i;
+   host1x_debug_output(o,  syncpts \n);
+   for (i = 0; i  host1x_syncpt_nb_pts(m); i++) {
+   u32 max = host1x_syncpt_read_max(m-syncpt + i);
+   u32 min = host1x_syncpt_load(m-syncpt + i);
+   if (!min  !max)
+   continue;
+   host1x_debug_output(o, id %d (%s) min %d max %d\n,
+   i, m-syncpt[i].name, min, max);
+   }
+
+   for (i = 0; i  host1x_syncpt_nb_bases(m); i++) {
+   u32 base_val;
+   base_val = host1x_syncpt_load_wait_base(m-syncpt + i);
+   if (base_val)
+   host1x_debug_output(o, waitbase id %d val %d\n, i,
+ 

[PATCHv9 9/9] drm: tegra: Add gr2d device

2013-03-22 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: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 drivers/gpu/host1x/Makefile|1 +
 drivers/gpu/host1x/dev.c   |7 +
 drivers/gpu/host1x/drm/Kconfig |9 ++
 drivers/gpu/host1x/drm/drm.c   |  212 -
 drivers/gpu/host1x/drm/drm.h   |   27 +++-
 drivers/gpu/host1x/drm/gr2d.c  |  339 
 drivers/gpu/host1x/host1x.h|4 +-
 include/uapi/drm/Kbuild|1 +
 include/uapi/drm/tegra_drm.h   |  136 
 9 files changed, 733 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/uapi/drm/tegra_drm.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 3768dbc..3b037b6 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -16,4 +16,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/gem.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 8ce9889..28e28a2 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -209,11 +209,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_DRM_TEGRA
+unregister_hdmi:
+   platform_driver_unregister(tegra_hdmi_driver);
 unregister_dc:
platform_driver_unregister(tegra_dc_driver);
 unregister_host1x:
@@ -226,6 +232,7 @@ module_init(tegra_host1x_init);
 static void __exit tegra_host1x_exit(void)
 {
 #ifdef CONFIG_DRM_TEGRA
+   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/Kconfig b/drivers/gpu/host1x/drm/Kconfig
index f743540..6e3f567 100644
--- a/drivers/gpu/host1x/drm/Kconfig
+++ b/drivers/gpu/host1x/drm/Kconfig
@@ -13,6 +13,15 @@ config DRM_TEGRA
 
 if DRM_TEGRA
 
+config DRM_TEGRA_STAGING
+   bool Enable HOST1X interface
+   depends on STAGING
+   default n
+   help
+ Say yes if HOST1X should be available for userspace DRM users.
+
+ If unsure, choose N.
+
 config DRM_TEGRA_DEBUG
bool NVIDIA Tegra DRM debug support
help
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index c4e45c1..2b561c9 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2012 Avionic Design GmbH
- * Copyright (C) 2012 NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (C) 2012-2013 NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -14,6 +14,9 @@
 #include linux/dma-mapping.h
 #include asm/dma-iommu.h
 
+#include drm/drm.h
+#include drm/drmP.h
+
 #include host1x_client.h
 #include dev.h
 #include drm.h
@@ -81,8 +84,10 @@ static int host1x_parse_dt(struct host1x_drm *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;
@@ -277,9 +282,24 @@ static int tegra_drm_unload(struct drm_device *drm)
 
 static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
 {
+   struct host1x_drm_file *fpriv;
+
+   fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
+   if (!fpriv)
+   return -ENOMEM;
+
+   INIT_LIST_HEAD(fpriv-contexts);
+   filp-driver_priv = fpriv;
+
return 0;
 }
 
+static void host1x_drm_context_free(struct host1x_drm_context *context)
+{
+   context-client-ops-close_channel(context);
+   kfree(context);
+}
+
 static void tegra_drm_lastclose(struct drm_device *drm)
 {
struct host1x_drm *host1x = drm-dev_private;
@@ -287,7 +307,190 @@ static void tegra_drm_lastclose(struct drm_device *drm)
tegra_fbdev_restore_mode(host1x-fbdev);
 }
 
+#ifdef CONFIG_DRM_TEGRA_STAGING
+static bool host1x_drm_file_owns_context(struct host1x_drm_file *file,
+struct host1x_drm_context *context)
+{
+   struct host1x_drm_context *ctx;
+
+   

[PATCHv9 7/9] gpu: host1x: Remove second host1x driver

2013-03-22 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: Arto Merilainen amerilai...@nvidia.com
Signed-off-by: Terje Bergstrom tbergst...@nvidia.com
---
 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|5 +-
 drivers/gpu/host1x/drm/drm.c   |  214 ++-
 drivers/gpu/host1x/drm/drm.h   |3 -
 drivers/gpu/host1x/drm/hdmi.c  |5 +-
 drivers/gpu/host1x/drm/host1x.c|  329 
 drivers/gpu/host1x/host1x_client.h |   35 
 10 files changed, 317 insertions(+), 342 deletions(-)
 delete mode 100644 drivers/gpu/host1x/drm/host1x.c
 create mode 100644 drivers/gpu/host1x/host1x_client.h

diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 4761e8a..9a6fc76 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -13,6 +13,6 @@ host1x-y = \
 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 9689724..8ce9889 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -32,6 +32,19 @@
 #include channel.h
 #include debug.h
 #include hw/host1x01.h
+#include host1x_client.h
+
+void host1x_set_drm_data(struct device *dev, void *data)
+{
+   struct host1x *host1x = dev_get_drvdata(dev);
+   host1x-drm_data = data;
+}
+
+void *host1x_get_drm_data(struct device *dev)
+{
+   struct host1x *host1x = dev_get_drvdata(dev);
+   return host1x-drm_data;
+}
 
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
 {
@@ -150,6 +163,8 @@ static int host1x_probe(struct platform_device *pdev)
 
host1x_debug_init(host);
 
+   host1x_drm_alloc(pdev);
+
return 0;
 
 fail_deinit_syncpt:
@@ -168,7 +183,7 @@ static int __exit host1x_remove(struct platform_device 
*pdev)
return 0;
 }
 
-static struct platform_driver platform_driver = {
+static struct platform_driver tegra_host1x_driver = {
.probe = host1x_probe,
.remove = __exit_p(host1x_remove),
.driver = {
@@ -178,8 +193,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_DRM_TEGRA
+   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_DRM_TEGRA
+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_DRM_TEGRA
+   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 thierry.red...@avionic-design.de);
 MODULE_AUTHOR(Terje Bergstrom tbergst...@nvidia.com);
 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 4d16fe9..a1607d6 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -124,6 +124,8 @@ struct host1x {
unsigned int num_allocated_channels;
 
struct dentry *debugfs;
+
+   void *drm_data;
 };
 
 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -299,4 +301,8 @@ static inline void host1x_hw_show_mlocks(struct host1x 
*host, struct output *o)
host-debug_op-show_mlocks(host, o);
 }
 
+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 

Re: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Daniel Vetter
On Fri, Mar 22, 2013 at 3:02 PM, Dylan Semler dylan.sem...@gmail.com wrote:
 On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher alexdeuc...@gmail.com wrote:

 On Thu, Mar 21, 2013 at 5:42 PM, Dylan Semler dylan.sem...@gmail.com
 wrote:
  Oops.  I neglected to preface this with my motivation:  I have a new
  monitor that doesn't report its native resolution in its EDID block.  It
  seemed to me this calls for an EDID quirk, but the current quirk
  infrastructure doesn't allow explicitly creating new modes.  So I set
  out
  to make a simple enhancement to allow specifying a new mode and then
  setting it as preferred.
 

 That's odd.  Maybe it's actually in an extension block or something like
 that?

 Yeah, I agree.  According to edid-decode /sys/class/drm/card0-HDMI-A-1/edid
 there's one extension block, but none of those modes are the native
 resolution
 either.

Hm, we only recently added support for E-EDID (i.e. more than 1
extension block). Have you checked whether latest kernels fare better?
-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


Re: [PATCHv9 0/9] Support Tegra 2D hardware

2013-03-22 Thread Thierry Reding
On Fri, Mar 22, 2013 at 04:34:00PM +0200, Terje Bergstrom wrote:
 This set of patches adds support for Tegra20 and Tegra30 host1x and
 2D. It is based on linux-next-20130322 with RTC fixes applied.
 
 Changes in this version:
  * Renaming in drivers/gpu/host1x/drm/drm.c to shorten function names
  * Whitespace and function order fixes
  * An extra struct (host1x_addr_reg) removed
  * Added uapi Kbuild entry
 
 Changes in version 8:
  * Own version of framebuffer driver due to move to own allocator
* Thanks to Thierry Reding for help
  * Miscellaneous variable name, whitespace and IOCTL interface cleanups
  * Bug fixes:
* Validator enabled again
* Added new class 2D strechblit
  * Dropped patch Support CMA object preallocation
 
 Changes in version 7:
  * host1x memory data structures refactored
  * Some nvhost leftovers renamed to host1x
 
 Changes in version 6:
  * Rebased on latest tegradrm
  * Renamed tegradrm's host1x to host1x_drm
  * Indentation and line split fixed to follow tegradrm convention
  * Pointers to platform_device replaced with pointers to device
  * Added host1x allocator, and wired it in
  * Debug spew code fixed to access mem handles from host1x_job
  * CDMA code doesn't keep the mem handles anymore
  * Push buffer ops have been made generic code
  * Removed the pin_array optimization in host1x_job to simplify code
  * Large number of smaller changes
 
 The driver implements an allocator using the dma mapping API. Each buffer is
 assigned an ops structure to operate on it.
 
 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 http://http.download.nvidia.com/tegra-public-appnotes/host1x.html
 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.
 
 The changes to add support to libdrm are in
 g...@gitorious.org:linux-host1x/libdrm-host1x.git
 
 Arto Merilainen (2):
   gpu: host1x: drm: Rename host1x to host1x_drm
   gpu: host1x: drm: Add memory manager and fb
 
 Terje Bergstrom (7):
   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
   drm: tegra: Add gr2d device
 
  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|  217 
  drivers/gpu/drm/tegra/fb.c |   52 --
  drivers/gpu/drm/tegra/host1x.c |  327 
  drivers/gpu/host1x/Kconfig |   23 +
  drivers/gpu/host1x/Makefile|   20 +
  drivers/gpu/host1x/cdma.c  |  491 ++
  drivers/gpu/host1x/cdma.h  |  100 
  drivers/gpu/host1x/channel.c   |  126 +
  drivers/gpu/host1x/channel.h   |   52 ++
  drivers/gpu/host1x/debug.c |  210 
  drivers/gpu/host1x/debug.h |   51 ++
  drivers/gpu/host1x/dev.c   |  246 +
  drivers/gpu/host1x/dev.h   |  308 
  drivers/gpu/{drm/tegra = host1x/drm}/Kconfig  |   19 +-
  drivers/gpu/{drm/tegra = host1x/drm}/dc.c |   26 +-
  drivers/gpu/{drm/tegra = host1x/drm}/dc.h |0
  drivers/gpu/host1x/drm/drm.c   |  640 
 
  drivers/gpu/{drm/tegra = host1x/drm}/drm.h|   68 ++-
  drivers/gpu/host1x/drm/fb.c|  372 ++
  drivers/gpu/host1x/drm/gem.c   |  270 ++
  drivers/gpu/host1x/drm/gem.h   |   59 +++
  drivers/gpu/host1x/drm/gr2d.c  |  339 +
  drivers/gpu/{drm/tegra = host1x/drm}/hdmi.c   |5 +-
  drivers/gpu/{drm/tegra = host1x/drm}/hdmi.h   |0
  drivers/gpu/{drm/tegra = host1x/drm}/output.c |0
  drivers/gpu/{drm/tegra = host1x/drm}/rgb.c|0
  drivers/gpu/host1x/host1x.h|   30 ++
  drivers/gpu/host1x/host1x_bo.h |   87 
  drivers/gpu/host1x/host1x_client.h |   35 ++
  drivers/gpu/host1x/hw/Makefile |6 +
  drivers/gpu/host1x/hw/cdma_hw.c|  326 
  drivers/gpu/host1x/hw/channel_hw.c |  168

Re: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 10:41 AM, Daniel Vetter dan...@ffwll.ch wrote:

 On Fri, Mar 22, 2013 at 3:02 PM, Dylan Semler dylan.sem...@gmail.com
wrote:
  On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher alexdeuc...@gmail.com
  wrote:
 
  That's odd.  Maybe it's actually in an extension block or something
like
  that?
 
  Yeah, I agree.  According to edid-decode
/sys/class/drm/card0-HDMI-A-1/edid
  there's one extension block, but none of those modes are the native
  resolution either.

 Hm, we only recently added support for E-EDID (i.e. more than 1 extension
 block). Have you checked whether latest kernels fare better?

I just tried booting with 3.9rc3 and my distro's latest package of
xorg-utils;
I get the same results.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: nouveau shuts the machine down with v3.9-rc1 (temperature (72 C) hit the 'shutdown' threshold).

2013-03-22 Thread Rafał Miłecki
2013/3/15 Martin Peres martin.pe...@free.fr
 As a follow up, Konrad sent me in private his vbios and the issue turned out 
 to be trivial.
 The reason why it behaved this way was that his vbios didn't have sensor 
 calibration values.
 The fix is available here: 
 http://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commit/59b4006b5b30828bbd094dffe3937333b43d1e12

 This fix is part of a pull request I sent to Ben.

 Thanks again Konrad for reporting and testing the patches, I'll add you as a 
 tester to this patch :)

Thanks guys for debugging analyzing and fixing this. I got the same problem on
00:05.0 VGA compatible controller [0300]: NVIDIA Corporation C51G
[GeForce 6100] [10de:0242] (rev a2)
and now it's fixed.

It seems it wasn't just a one single BIOS like that in the world ;)

--
Rafał
8698080ee092bdbd6ee2cd5e7f707ceea2812bd8
Merge branch 'drm-nouveau-fixes-3.9' of 
git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-next
Regression fixes and oops fixes for nouveau.
[   76.082597] nouveau  [  DEVICE][:00:05.0] BOOT0  : 0x04e000a2
[   76.082605] nouveau  [  DEVICE][:00:05.0] Chipset: C51 (NV4E)
[   76.082609] nouveau  [  DEVICE][:00:05.0] Family : NV40
[   76.084534] nouveau  [   VBIOS][:00:05.0] checking PRAMIN for image...
[   76.125409] nouveau  [   VBIOS][:00:05.0] ... appears to be valid
[   76.125418] nouveau  [   VBIOS][:00:05.0] using image from PRAMIN
[   76.125658] nouveau  [   VBIOS][:00:05.0] BIT signature found
[   76.125663] nouveau  [   VBIOS][:00:05.0] version 05.51.22.28.10
[   76.128699] nouveau  [ PFB][:00:05.0] RAM type: stolen system memory
[   76.128708] nouveau  [ PFB][:00:05.0] RAM size: 64 MiB
[   76.128711] nouveau  [ PFB][:00:05.0]ZCOMP: 0 tags
[   76.781036] nouveau  [  PTHERM][:00:05.0] FAN control: none / external
[   76.781053] nouveau  [  PTHERM][:00:05.0] Thermal management: disabled
[   76.781057] nouveau  [  PTHERM][:00:05.0] internal sensor: yes
[   76.791261] nouveau  [  PTHERM][:00:05.0] programmed thresholds [ 90(2), 
95(3), 145(2), 135(5) ]
[   76.791267] nouveau  [  PTHERM][:00:05.0] temperature (154 C) hit the 
'fanboost' threshold
[   76.791271] nouveau  [  PTHERM][:00:05.0] Thermal management: automatic
[   76.791277] nouveau  [  PTHERM][:00:05.0] temperature (154 C) hit the 
'downclock' threshold
[   76.791281] nouveau  [  PTHERM][:00:05.0] temperature (154 C) hit the 
'critical' threshold
[   76.791285] nouveau  [  PTHERM][:00:05.0] temperature (154 C) hit the 
'shutdown' threshold

cf9a625fae3d0ce8dffab53b2758d7c0cf4a5ad4
Merge branch 'drm-nouveau-fixes-3.9' of 
git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-next
Lots of thermal fixes and fix a lockdep warning we've been seeing.
[   55.668598] nouveau  [  DEVICE][:00:05.0] BOOT0  : 0x04e000a2
[   55.668606] nouveau  [  DEVICE][:00:05.0] Chipset: C51 (NV4E)
[   55.668609] nouveau  [  DEVICE][:00:05.0] Family : NV40
[   55.670533] nouveau  [   VBIOS][:00:05.0] checking PRAMIN for image...
[   55.711390] nouveau  [   VBIOS][:00:05.0] ... appears to be valid
[   55.711399] nouveau  [   VBIOS][:00:05.0] using image from PRAMIN
[   55.711639] nouveau  [   VBIOS][:00:05.0] BIT signature found
[   55.711644] nouveau  [   VBIOS][:00:05.0] version 05.51.22.28.10
[   55.714712] nouveau  [ PFB][:00:05.0] RAM type: stolen system memory
[   55.714721] nouveau  [ PFB][:00:05.0] RAM size: 64 MiB
[   55.714724] nouveau  [ PFB][:00:05.0]ZCOMP: 0 tags
[   56.367033] nouveau  [  PTHERM][:00:05.0] FAN control: none / external
[   56.367052] nouveau  [  PTHERM][:00:05.0] fan management: disabled
[   56.367056] nouveau  [  PTHERM][:00:05.0] internal sensor: no
[   56.387298] nouveau  [  PTHERM][:00:05.0] programmed thresholds [ 90(2), 
95(3), 145(2), 135(5) ]
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 62573] [bisected] Half-Life 2: Deathmatch native version crashes

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=62573

--- Comment #20 from Tom neatno...@gmail.com ---
It fixes this issue for me too, thanks.

-- 
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 61182] r600g causes KWin crashes with kernel 3.8

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=61182

--- Comment #16 from Jürg Billeter j...@bitron.ch ---
No gnome-shell crashes since I've upgraded to Mesa 9.1.1. Will post an update
in a few days whether it remains stable or I was just lucky today.

-- 
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 60879] X11 can't start with acceleration enabled

2013-03-22 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=60879

--- Comment #15 from Hristo Venev mustrum...@gmail.com ---
Now egl{tri,gears}_screen work. However they don't render properly. Square
pixel blocks seem to be misplaced. I will test with Xorg and attach a
screenshot.

-- 
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


  1   2   >