[Nouveau] [PATCH 1/2] glamor: fix build without glamor.h

2014-06-21 Thread Marcin Slusarz
xorg-server can be built without glamor, which leads to:

  CC   nouveau_xv.lo
In file included from nouveau_xv.c:41:0:
nouveau_glamor.h:12:20: fatal error: glamor.h: No such file or directory
compilation terminated.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 configure.ac | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index c34e575..92e047a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,7 +128,13 @@ XORG_MANPAGE_SECTIONS
 XORG_RELEASE_VERSION
 
 AC_MSG_CHECKING([whether to include GLAMOR support])
-if pkg-config --exists xorg-server = 1.15.99.901
+
+AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
+[[
+  #include glamor.h
+]],[[]]),[found_glamor_header=yes],[found_glamor_header=no])
+
+if test $found_glamor_header = yes  pkg-config --exists xorg-server = 
1.15.99.901
 then
AC_DEFINE(HAVE_GLAMOR, 1, [Build support for glamor acceleration])
AC_MSG_RESULT([yes])
-- 
2.0.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH 2/2] present: build only when glamor is enabled

2014-06-21 Thread Marcin Slusarz
nouveau_present_flip_exec references glamor_fd_from_pixmap,
which do not exist when glamor is disabled

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 src/nouveau_present.c | 2 +-
 src/nouveau_present.h | 6 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/nouveau_present.c b/src/nouveau_present.c
index b294bbe..38f2cac 100644
--- a/src/nouveau_present.c
+++ b/src/nouveau_present.c
@@ -23,7 +23,7 @@
  */
 
 #include nouveau_present.h
-#ifdef DRI3
+#if defined(DRI3)  defined(HAVE_GLAMOR)
 #include nv_include.h
 #include nouveau_glamor.h
 #include xf86drmMode.h
diff --git a/src/nouveau_present.h b/src/nouveau_present.h
index dea19ce..958c2f7 100644
--- a/src/nouveau_present.h
+++ b/src/nouveau_present.h
@@ -4,7 +4,11 @@
 #include xorg-server.h
 #include scrnintstr.h
 
-#ifdef DRI3
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#if defined(DRI3)  defined(HAVE_GLAMOR)
 #include present.h
 Bool nouveau_present_init(ScreenPtr pScreen);
 void nouveau_present_fini(ScreenPtr pScreen);
-- 
2.0.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: Ack interrupts for some fuc engines

2013-03-26 Thread Marcin Slusarz
On Tue, Mar 26, 2013 at 07:29:24AM +0100, Maarten Lankhorst wrote:
 Op 25-03-13 19:14, Marcin Slusarz schreef:
  On Mon, Mar 25, 2013 at 10:22:37AM +0100, Maarten Lankhorst wrote:
  Fixes 100% cpu usage when the exit interrupt never got acked.
 
  Signed-off-by: Maarten Lankhorst m.b.lankho...@gmail.com
  ---
  diff --git a/drivers/gpu/drm/nouveau/core/core/falcon.c 
  b/drivers/gpu/drm/nouveau/core/core/falcon.c
  index e05c157..b11c5f3 100644
  --- a/drivers/gpu/drm/nouveau/core/core/falcon.c
  +++ b/drivers/gpu/drm/nouveau/core/core/falcon.c
  @@ -229,6 +229,24 @@ _nouveau_falcon_fini(struct nouveau_object *object, 
  bool suspend)
 return nouveau_engine_fini(falcon-base, suspend);
   }
   
  +void
  +nouveau_falcon_intr(struct nouveau_subdev *subdev)
  +{
  +  struct nouveau_falcon *falcon = (void*)subdev;
  +  u32 intr = nv_ro32(falcon, 0x008);
  +
  +  nv_wo32(falcon, 0x004, intr);
  +
  +  if (intr  0x10) {
  +  intr = ~0x10;
  +
  +  nv_info(falcon, Exit interrupt called\n);
  Do you really want to print it at info level? How frequent it is?
 It shouldn't be often, I want it to run at the error level since that usually
 means the firmware exited prematurely/crashed and things go bad, but it
 happens with the secret scrubber finishing on initialization too. That one
 is harmless though.

Maybe it should say:
nv_error(falcon, firmware exited prematurely\n);
?

  +  }
  +
  +  if (intr)
  +  nv_error(falcon, Unhandled interrupt %08x\n, intr);
  +}
  +
   int
   nouveau_falcon_create_(struct nouveau_object *parent,
struct nouveau_object *engine,
  ___
  dri-devel mailing list
  dri-de...@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/dri-devel
 
 
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: Ack interrupts for some fuc engines

2013-03-25 Thread Marcin Slusarz
On Mon, Mar 25, 2013 at 10:22:37AM +0100, Maarten Lankhorst wrote:
 Fixes 100% cpu usage when the exit interrupt never got acked.
 
 Signed-off-by: Maarten Lankhorst m.b.lankho...@gmail.com
 ---
 diff --git a/drivers/gpu/drm/nouveau/core/core/falcon.c 
 b/drivers/gpu/drm/nouveau/core/core/falcon.c
 index e05c157..b11c5f3 100644
 --- a/drivers/gpu/drm/nouveau/core/core/falcon.c
 +++ b/drivers/gpu/drm/nouveau/core/core/falcon.c
 @@ -229,6 +229,24 @@ _nouveau_falcon_fini(struct nouveau_object *object, bool 
 suspend)
   return nouveau_engine_fini(falcon-base, suspend);
  }
  
 +void
 +nouveau_falcon_intr(struct nouveau_subdev *subdev)
 +{
 + struct nouveau_falcon *falcon = (void*)subdev;
 + u32 intr = nv_ro32(falcon, 0x008);
 +
 + nv_wo32(falcon, 0x004, intr);
 +
 + if (intr  0x10) {
 + intr = ~0x10;
 +
 + nv_info(falcon, Exit interrupt called\n);

Do you really want to print it at info level? How frequent it is?

 + }
 +
 + if (intr)
 + nv_error(falcon, Unhandled interrupt %08x\n, intr);
 +}
 +
  int
  nouveau_falcon_create_(struct nouveau_object *parent,
  struct nouveau_object *engine,
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [libdrm PATCH 1/2] nouveau: return error from pushbuf_validate

2013-03-19 Thread Marcin Slusarz
On Tue, Mar 05, 2013 at 09:14:53PM +0100, Marcin Slusarz wrote:
 Without it, libdrm_nouveau user cannot know when validation failed.
 
 Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
 ---

If there are no objections, I'll push both patches soon.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [RFC PATCH] drm/nouveau: use vmalloc for pgt allocation

2013-03-19 Thread Marcin Slusarz
On Tue, Mar 05, 2013 at 07:57:08PM +0100, Marcin Slusarz wrote:
 Page tables on nv50 take 48kB, which can be hard to allocate in one piece.
 Let's use vmalloc.
 
 Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
 Cc: sta...@vger.kernel.org [3.7+]
 ---
  drivers/gpu/drm/nouveau/core/subdev/vm/base.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c 
 b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
 index 77c67fc..e66fb77 100644
 --- a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
 +++ b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
 @@ -362,7 +362,7 @@ nouveau_vm_create(struct nouveau_vmmgr *vmm, u64 offset, 
 u64 length,
   vm-fpde = offset  (vmm-pgt_bits + 12);
   vm-lpde = (offset + length - 1)  (vmm-pgt_bits + 12);
  
 - vm-pgt  = kcalloc(vm-lpde - vm-fpde + 1, sizeof(*vm-pgt), 
 GFP_KERNEL);
 + vm-pgt  = vzalloc((vm-lpde - vm-fpde + 1) * sizeof(*vm-pgt));
   if (!vm-pgt) {
   kfree(vm);
   return -ENOMEM;
 @@ -371,7 +371,7 @@ nouveau_vm_create(struct nouveau_vmmgr *vmm, u64 offset, 
 u64 length,
   ret = nouveau_mm_init(vm-mm, mm_offset  12, mm_length  12,
 block  12);
   if (ret) {
 - kfree(vm-pgt);
 + vfree(vm-pgt);
   kfree(vm);
   return ret;
   }
 @@ -446,7 +446,7 @@ nouveau_vm_del(struct nouveau_vm *vm)
   }
  
   nouveau_mm_fini(vm-mm);
 - kfree(vm-pgt);
 + vfree(vm-pgt);
   kfree(vm);
  }
  
 -- 

What's up with this patch?

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Fwd: [bisected] nouveau failure with 3.9-rc1 and ongoing

2013-03-14 Thread Marcin Slusarz
On Thu, Mar 14, 2013 at 07:56:03PM +0100, Sune Mølgaard wrote:
 Marcin Slusarz wrote:
  I think it may be already fixed by commit 
  94f54f5336aac6801f2a14dcb12467e41b35456a
  drm/nv50: encoder creation failure doesn't mean full init failure (post 
  3.9-rc2)
 
 With the latest 3.9-rc2+ git, I got past the KMS init blackout and into 
 X, but I got a panic shortly after.
 
 Unfortunately, the trace was too lengthy to see in which module, and 
 since it wasn't captured /var/log/syslog, I have no idea whether it has 
 anything to do with nouveau or something else.
 
 tl;dr: It would seem that the commit fixes the specific bug I reported, 
 but my system isn't functional.

If you have another machine in the same network, you could try to catch this
panic with netconsole. See
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/netconsole.txt

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Fwd: [bisected] nouveau failure with 3.9-rc1 and ongoing

2013-03-13 Thread Marcin Slusarz
On Wed, Mar 13, 2013 at 06:22:38PM +0100, Sune Mølgaard wrote:
 Hiya,
 
 I sent the enclosed email to linux-kernel before realizing that it 
 would, perhaps, be more proper to send it here, which I hereby do.
 
 I shall be happy to try out any and all patches.
 
 Best regards,
 
 Sune Mølgaard
 
  Original Message 
 Subject: [bisected] nouveau failure with 3.9-rc1 and ongoing
 Date: Tue, 12 Mar 2013 19:57:55 +0100
 From: Sune Mølgaard s...@molgaard.org
 To: linux-ker...@vger.kernel.org
 
 Hiya,
 
 Between 3.8 and 3.9-rc1, the following occurs:
 
 Upon boot, when KMS kicks in, I get a blank screen. Keyboard responds
 correctly to Num Lock on/off, but machine is unreachable on the network.
 
 Git bisection says:
 
 eb6313add6dddf07ea3e50c4caa33a9c3b2379f1 is the first bad commit
 commit eb6313add6dddf07ea3e50c4caa33a9c3b2379f1
 Author: Ben Skeggs bske...@redhat.com
 Date:   Mon Feb 11 09:52:58 2013 +1000
 
  drm/nv50: initial kms support for off-chip TMDS/DP encoders
 
  Signed-off-by: Ben Skeggs bske...@redhat.com
 
 :04 04 41f69d26a80082e19d3c76e6556ad5ef9eb2677d
 216d501e053e9d05136929593e90259c2e59dff0 Mdrivers

I think it may be already fixed by commit 
94f54f5336aac6801f2a14dcb12467e41b35456a
drm/nv50: encoder creation failure doesn't mean full init failure (post 
3.9-rc2)

 But even though I marked that last bisection kernel good (since it
 didn't cause a black-out), it does have problems, namely that GTK themes
 are reset, and xrandr seems non-functional, inasmuch as my left-ward,
 secondary screen now seems to be treated as being situated to the right.
 No previous kernel in the bisection exercise caused anything of the like.

Not sure about this one...


Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Fix unaligned accesses for SPARC

2013-03-13 Thread Marcin Slusarz
On Tue, Mar 12, 2013 at 10:18:41PM -0500, Patrick Baggett wrote:
The nouveau driver makes a number of unaligned accesses via the
ROM16(), ROM32() and ROM64() macros which fault on SPARC (but would be
transparently handled by x86 hardware). Making use of get_unaligned()
macro fixes the problem for me.
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.h
b/drivers/gpu/drm/nouveau/nouveau_bios.h
index 7ccd28f..92031f6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.h
@@ -26,6 +26,8 @@
 #include nvreg.h
+#include asm/unaligned.h
+
 #define DCB_MAX_NUM_ENTRIES 16
 #define DCB_MAX_NUM_I2C_ENTRIES 16
 #define DCB_MAX_NUM_GPIO_ENTRIES 32
@@ -33,10 +35,10 @@
 #define DCB_LOC_ON_CHIP 0
-#define ROM16(x) le16_to_cpu(*(u16 *)(x))
-#define ROM32(x) le32_to_cpu(*(u32 *)(x))
+#define ROM16(x) le16_to_cpu(get_unaligned((u16 *)(x)))
+#define ROM32(x) le32_to_cpu(get_unaligned((u32 *)(x)))
 #define ROM48(x) ({ u8 *p = (x); (u64)ROM16(p[4])  32 |
ROM32(p[0]); })
-#define ROM64(x) le64_to_cpu(*(u64 *)(x))
+#define ROM64(x) le64_to_cpu(get_unaligned((u64 *)(x)))
 #define ROMPTR(d,x) ({\
struct nouveau_drm *drm = nouveau_drm((d)); \
ROM16(x) ? drm-vbios.data[ROM16(x)] : NULL; \

Please take a look at Documentation/SubmittingPatches and resubmit after
adapting.

IMHO, I think you should submit this patch only once you figure out how to
correctly boot and use at least basic accelerated operations, because I'm not
100% sure this is correct - 1. you have other severe issues with nouveau which
may or may not be connected to this code, 2. sparc defines get_unaligned to
__get_unaligned_be, so maybe you need to use _le variant? or maybe use
get_unaligned_le* without le*_to_cpu?.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] nouveau lockdep splat

2013-03-06 Thread Marcin Slusarz
On Wed, Mar 06, 2013 at 01:04:29AM +0100, Borislav Petkov wrote:
 On Tue, Mar 05, 2013 at 05:30:52PM +0100, Lucas Stach wrote:
  Dropping Tegra ML, it's not the place where Nouveau mails should go.
 
 $ ./scripts/get_maintainer.pl -f drivers/gpu/drm/nouveau/nv50_display.c
 ...
 linux-te...@vger.kernel.org (open list:TEGRA SUPPORT)
 
 Maybe get_maintainer.pl patterns need correction...

That's new feature (introduced in commit eb90d0855b75f8 get_maintainer: allow
keywords to match filenames) of get_maintainer.pl which now can look at file
contents...

TEGRA SUPPORT
M:  Stephen Warren swar...@wwwdotorg.org
L:  linux-te...@vger.kernel.org
Q:  http://patchwork.ozlabs.org/project/linux-tegra/list/
T:  git 
git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra.git
S:  Supported
K:  (?i)[^a-z]tegra

Note the last line and this:

$ grep tegra drivers/gpu/drm/nouveau/nv50_display.c
u32 rekey = 56; /* binary driver, and tegra constant */
max_ac_packet -= 18; /* constant from tegra */

Fun.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: fix regression in vblanking

2013-03-05 Thread Marcin Slusarz
On Tue, Mar 05, 2013 at 02:59:26PM +0100, Maarten Lankhorst wrote:
 nv50_vblank_enable/disable got switched from 
 NV50_PDISPLAY_INTR_EN_1_VBLANK_CRTC_0 (4)  head to 1  head, which is 
 wrong.
 
 4  head is the correct value.
 
 Fixes regression with vblanking since 1d7c71a3e2f77 drm/nouveau/disp: port 
 vblank handling to event interface
 
 Signed-off-by: Maarten Lankhorst maarten.lankho...@canonical.com
 ---
 diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c 
 b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
 index 5fa1326..02e369f 100644
 --- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
 +++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
 @@ -544,13 +544,13 @@ nv50_disp_curs_ofuncs = {
  static void
  nv50_disp_base_vblank_enable(struct nouveau_event *event, int head)
  {
 - nv_mask(event-priv, 0x61002c, (1  head), (1  head));
 + nv_mask(event-priv, 0x61002c, (4  head), (4  head));
  }
  
  static void
  nv50_disp_base_vblank_disable(struct nouveau_event *event, int head)
  {
 - nv_mask(event-priv, 0x61002c, (1  head), (0  head));
 + nv_mask(event-priv, 0x61002c, (4  head), 0);
  }
  
  static int
 

It fixes vblank on my NVA8, thanks.

Tested-by: Marcin Slusarz marcin.slus...@gmail.com
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [RFC PATCH] drm/nouveau: use vmalloc for pgt allocation

2013-03-05 Thread Marcin Slusarz
Page tables on nv50 take 48kB, which can be hard to allocate in one piece.
Let's use vmalloc.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
Cc: sta...@vger.kernel.org [3.7+]
---
 drivers/gpu/drm/nouveau/core/subdev/vm/base.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c 
b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
index 77c67fc..e66fb77 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
@@ -362,7 +362,7 @@ nouveau_vm_create(struct nouveau_vmmgr *vmm, u64 offset, 
u64 length,
vm-fpde = offset  (vmm-pgt_bits + 12);
vm-lpde = (offset + length - 1)  (vmm-pgt_bits + 12);
 
-   vm-pgt  = kcalloc(vm-lpde - vm-fpde + 1, sizeof(*vm-pgt), 
GFP_KERNEL);
+   vm-pgt  = vzalloc((vm-lpde - vm-fpde + 1) * sizeof(*vm-pgt));
if (!vm-pgt) {
kfree(vm);
return -ENOMEM;
@@ -371,7 +371,7 @@ nouveau_vm_create(struct nouveau_vmmgr *vmm, u64 offset, 
u64 length,
ret = nouveau_mm_init(vm-mm, mm_offset  12, mm_length  12,
  block  12);
if (ret) {
-   kfree(vm-pgt);
+   vfree(vm-pgt);
kfree(vm);
return ret;
}
@@ -446,7 +446,7 @@ nouveau_vm_del(struct nouveau_vm *vm)
}
 
nouveau_mm_fini(vm-mm);
-   kfree(vm-pgt);
+   vfree(vm-pgt);
kfree(vm);
 }
 
-- 
1.8.1.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: fix crash in vram manager debug callback

2013-03-05 Thread Marcin Slusarz
It's probably impossible to hit it now on mainline kernel.
I only noticed it because one of my debugging patches uses it.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c 
b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 9be9cb5..9c60ef6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -35,14 +35,16 @@
 static int
 nouveau_vram_manager_init(struct ttm_mem_type_manager *man, unsigned long 
psize)
 {
-   /* nothing to do */
+   struct nouveau_drm *drm = nouveau_bdev(man-bdev);
+   struct nouveau_fb *pfb = nouveau_fb(drm-device);
+   man-priv = pfb;
return 0;
 }
 
 static int
 nouveau_vram_manager_fini(struct ttm_mem_type_manager *man)
 {
-   /* nothing to do */
+   man-priv = NULL;
return 0;
 }
 
@@ -104,7 +106,8 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
 static void
 nouveau_vram_manager_debug(struct ttm_mem_type_manager *man, const char 
*prefix)
 {
-   struct nouveau_mm *mm = man-priv;
+   struct nouveau_fb *pfb = man-priv;
+   struct nouveau_mm *mm = pfb-vram;
struct nouveau_mm_node *r;
u32 total = 0, free = 0;
 
-- 
1.8.1.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: drop redundant channel handle and owner info from nv_channel_idle

2013-03-05 Thread Marcin Slusarz
before: nouveau E[X[3162]] failed to idle channel 0x [X[3162]]
after:  nouveau E[X[3162]] failed to idle channel: -16

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nouveau_chan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c 
b/drivers/gpu/drm/nouveau/nouveau_chan.c
index eaa80a2..c8be059 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -58,8 +58,7 @@ nouveau_channel_idle(struct nouveau_channel *chan)
}
 
if (ret)
-   NV_ERROR(cli, failed to idle channel 0x%08x [%s]\n,
-chan-handle, cli-base.name);
+   NV_ERROR(cli, failed to idle channel: %d\n, ret);
return ret;
 }
 
-- 
1.8.1.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau/nv50: use correct tiling methods for m2mf buffer moves

2013-03-05 Thread Marcin Slusarz
Currently used only on original nv50, nvaa and nvac.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
Note: it would be catched much faster (probably even by author, and not after
2 years) if this code would use (known!) register names...
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 11ca821..7ff1071 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -801,7 +801,7 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct 
ttm_buffer_object *bo,
stride  = 16 * 4;
height  = amount / stride;
 
-   if (new_mem-mem_type == TTM_PL_VRAM 
+   if (old_mem-mem_type == TTM_PL_VRAM 
nouveau_bo_tile_layout(nvbo)) {
ret = RING_SPACE(chan, 8);
if (ret)
@@ -823,7 +823,7 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct 
ttm_buffer_object *bo,
BEGIN_NV04(chan, NvSubCopy, 0x0200, 1);
OUT_RING  (chan, 1);
}
-   if (old_mem-mem_type == TTM_PL_VRAM 
+   if (new_mem-mem_type == TTM_PL_VRAM 
nouveau_bo_tile_layout(nvbo)) {
ret = RING_SPACE(chan, 8);
if (ret)
-- 
1.8.1.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: idle channel before releasing notify object

2013-03-05 Thread Marcin Slusarz
Unmapping it while it's still in use (e.g. by M2MF) can lead to page faults
and a lot of TRAP_M2MF spam in dmesg.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c 
b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 4124192..3b6dc88 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -116,6 +116,11 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
 {
struct nouveau_abi16_ntfy *ntfy, *temp;
 
+   /* wait for all activity to stop before releasing notify object, which
+* may be still in use */
+   if (chan-chan  chan-ntfy)
+   nouveau_channel_idle(chan-chan);
+
/* cleanup notifier state */
list_for_each_entry_safe(ntfy, temp, chan-notifiers, head) {
nouveau_abi16_ntfy_fini(chan, ntfy);
-- 
1.8.1.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv50/disp: ignore encoder initialization failures

2013-03-05 Thread Marcin Slusarz
Nouveau does not support all encoder types, so failure to handle one should
not stop module initialization. And because of other bug, it lead to oops
in nv50_crtc_destroy (nv50_display_destroy sets nouveau_display-priv to NULL,
which is used by nv50_crtc_destroy).

Fixes regression from eb6313add6dddf07ea3e50c4caa33a9c3b2379f1
(drm/nv50: initial kms support for off-chip TMDS/DP encoders).

Reported-by: Richard Yao r...@gentoo.org
Tested-by: Richard Yao r...@gentoo.org
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nv50_display.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/nouveau/nv50_display.c 
b/drivers/gpu/drm/nouveau/nv50_display.c
index 87a5a56..2db5799 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -2276,6 +2276,7 @@ nv50_display_create(struct drm_device *dev)
NV_WARN(drm, failed to create encoder %d/%d/%d: %d\n,
 dcbe-location, dcbe-type,
 ffs(dcbe-or) - 1, ret);
+   ret = 0;
}
}
 
-- 
1.8.1.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [libdrm PATCH 1/2] nouveau: return error from pushbuf_validate

2013-03-05 Thread Marcin Slusarz
Without it, libdrm_nouveau user cannot know when validation failed.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 nouveau/pushbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nouveau/pushbuf.c b/nouveau/pushbuf.c
index ff8e125..e720a08 100644
--- a/nouveau/pushbuf.c
+++ b/nouveau/pushbuf.c
@@ -524,7 +524,7 @@ pushbuf_validate(struct nouveau_pushbuf *push, bool retry)
}
}
 
-   return 0;
+   return ret;
 }
 
 int
-- 
1.8.1.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [libdrm PATCH 2/2] nouveau: add a way to override single pushbuffer vram/gart limits

2013-03-05 Thread Marcin Slusarz
Add environment variables:
NOUVEAU_LIBDRM_VRAM_LIMIT_PERCENT
NOUVEAU_LIBDRM_GART_LIMIT_PERCENT
which will allow override how much VRAM/GART single pushbuffer can take.
Default to 80.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 nouveau/nouveau.c | 18 --
 nouveau/private.h |  1 +
 nouveau/pushbuf.c |  6 --
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
index 9b32e31..ee7893b 100644
--- a/nouveau/nouveau.c
+++ b/nouveau/nouveau.c
@@ -77,6 +77,7 @@ nouveau_device_wrap(int fd, int close, struct nouveau_device 
**pdev)
uint64_t chipset, vram, gart, bousage;
drmVersionPtr ver;
int ret;
+   char *tmp;
 
 #ifdef DEBUG
debug_init(getenv(NOUVEAU_LIBDRM_DEBUG));
@@ -114,14 +115,27 @@ nouveau_device_wrap(int fd, int close, struct 
nouveau_device **pdev)
nvdev-have_bo_usage = (bousage != 0);
 
nvdev-close = close;
+
+   tmp = getenv(NOUVEAU_LIBDRM_VRAM_LIMIT_PERCENT);
+   if (tmp)
+   nvdev-vram_limit_percent = atoi(tmp);
+   else
+   nvdev-vram_limit_percent = 80;
+   tmp = getenv(NOUVEAU_LIBDRM_GART_LIMIT_PERCENT);
+   if (tmp)
+   nvdev-gart_limit_percent = atoi(tmp);
+   else
+   nvdev-gart_limit_percent = 80;
DRMINITLISTHEAD(nvdev-bo_list);
nvdev-base.object.oclass = NOUVEAU_DEVICE_CLASS;
nvdev-base.lib_version = 0x0100;
nvdev-base.chipset = chipset;
nvdev-base.vram_size = vram;
nvdev-base.gart_size = gart;
-   nvdev-base.vram_limit = (nvdev-base.vram_size * 80) / 100;
-   nvdev-base.gart_limit = (nvdev-base.gart_size * 80) / 100;
+   nvdev-base.vram_limit =
+   (nvdev-base.vram_size * nvdev-vram_limit_percent) / 100;
+   nvdev-base.gart_limit =
+   (nvdev-base.gart_size * nvdev-gart_limit_percent) / 100;
 
*pdev = nvdev-base;
return 0;
diff --git a/nouveau/private.h b/nouveau/private.h
index 8a5cb26..60714b8 100644
--- a/nouveau/private.h
+++ b/nouveau/private.h
@@ -99,6 +99,7 @@ struct nouveau_device_priv {
uint32_t *client;
int nr_client;
bool have_bo_usage;
+   int gart_limit_percent, vram_limit_percent;
 };
 
 static inline struct nouveau_device_priv *
diff --git a/nouveau/pushbuf.c b/nouveau/pushbuf.c
index e720a08..0fd0c47 100644
--- a/nouveau/pushbuf.c
+++ b/nouveau/pushbuf.c
@@ -347,8 +347,10 @@ pushbuf_submit(struct nouveau_pushbuf *push, struct 
nouveau_object *chan)
  req, sizeof(req));
nvpb-suffix0 = req.suffix0;
nvpb-suffix1 = req.suffix1;
-   dev-vram_limit = (req.vram_available * 80) / 100;
-   dev-gart_limit = (req.gart_available * 80) / 100;
+   dev-vram_limit = (req.vram_available *
+   nouveau_device(dev)-vram_limit_percent) / 100;
+   dev-gart_limit = (req.gart_available *
+   nouveau_device(dev)-gart_limit_percent) / 100;
 #else
if (dbg_on(31))
ret = -EINVAL;
-- 
1.8.1.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: fix suspend bug in nvc0 fence implementation

2013-02-19 Thread Marcin Slusarz
On Tue, Feb 19, 2013 at 10:20:55AM +, Maarten Lankhorst wrote:
 Everywhere else the constant is multiplied by 16/4, so it looks like
 nvc0_fence_suspend/resume is buggy here.
 
 Signed-off-by: Maarten Lankhorst m.b.lankho...@gmail.com
 Cc: sta...@vger.kernel.org [3.7+]

Yay. It will probably fix https://bugs.freedesktop.org/show_bug.cgi?id=59168.
(note: it doesn't apply on top of nouveau/master)

Reviewed-by: Marcin Slusarz marcin.slus...@gmail.com

 ---
 
 diff --git a/drivers/gpu/drm/nouveau/nvc0_fence.c
 b/drivers/gpu/drm/nouveau/nvc0_fence.c
 index 85a0e78..4f46d8b 100644
 --- a/drivers/gpu/drm/nouveau/nvc0_fence.c
 +++ b/drivers/gpu/drm/nouveau/nvc0_fence.c
 @@ -161,11 +161,12 @@ nvc0_fence_suspend(struct nouveau_drm *drm)
   struct nouveau_fifo *pfifo = nouveau_fifo(drm-device);
   struct nvc0_fence_priv *priv = drm-fence;
   int i;
 + u32 chan = pfifo-max + 1;
 
 - priv-suspend = vmalloc((pfifo-max + 1) * sizeof(u32));
 + priv-suspend = vmalloc(chan * sizeof(u32));
   if (priv-suspend) {
 - for (i = 0; i = pfifo-max; i++)
 - priv-suspend[i] = nouveau_bo_rd32(priv-bo, i);
 + for (i = 0; i  chan; i++)
 + priv-suspend[i] = nouveau_bo_rd32(priv-bo, i * 16/4);
   }
 
   return priv-suspend != NULL;
 @@ -177,10 +178,11 @@ nvc0_fence_resume(struct nouveau_drm *drm)
   struct nouveau_fifo *pfifo = nouveau_fifo(drm-device);
   struct nvc0_fence_priv *priv = drm-fence;
   int i;
 + u32 chan = pfifo-max + 1;
 
   if (priv-suspend) {
 - for (i = 0; i = pfifo-max; i++)
 - nouveau_bo_wr32(priv-bo, i, priv-suspend[i]);
 + for (i = 0; i  chan; i++)
 + nouveau_bo_wr32(priv-bo, i * 16/4, priv-suspend[i]);
   vfree(priv-suspend);
   priv-suspend = NULL;
   }
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: fix suspend bug in nvc0 fence implementation

2013-02-19 Thread Marcin Slusarz
On Tue, Feb 19, 2013 at 10:09:12PM +0100, Michael Weirauch wrote:
 2013/2/19 Marcin Slusarz marcin.slus...@gmail.com:
  Yay. It will probably fix 
  https://bugs.freedesktop.org/show_bug.cgi?id=59168.
  (note: it doesn't apply on top of nouveau/master)
 
 Please correct me if I am wrong, but doesn't nv84_fence_[resume,suspend]
 on current nouveau-3.8.0_rc7 (master) which is used by nvc0_fence.c
 identical to what this patch does?
 
 nvc0_fence_create-
 nv84_fence_create sets up:
   priv-base.suspend = nv84_fence_suspend;
   priv-base.resume = nv84_fence_resume;
 
 There is no dedicated nvc0_fence_[resume,suspend] impl from what I grasped.
 
 c.f.:
 http://cgit.freedesktop.org/nouveau/linux-2.6/tree/drivers/gpu/drm/nouveau/nv84_fence.c#n178

This patch is only for 3.7 and 3.8 kernels. Nouveau/master contains refactored
fence code which will be submitted for 3.9.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Monitor with corrupted EDID

2013-02-07 Thread Marcin Slusarz
On Thu, Feb 07, 2013 at 04:16:54PM +0100, Flavio Castelli wrote:
 For an unknown reason both my monitors ended up with a corrupted EDID.
 They both provide VGA and DVI input. The VGA input works fine, while
 DVI is broken because of the EDID issue.
 
 Using these [1] instructions I have been able to read the EDID and fix
 it. Unfortunately I'm not able to write it back to the eeprom.
 I always get this message:
   i2c i2c-1: sendbytes: NAK bailout.
 
 This is what I usually see in /var/log/message
 [dump of the EDID]
 nouveau :01:00.0: DVI-D-1: EDID block 0 invalid.
 [drm] nouveau :01:00.0: DDC responded, but no EDID for DVI-D-1
 
 Do you know why writing to the monitor does not work? I suspect the
 eeprom is write protected
 
 Googling a bit I noticed the nvidia driver allows to ignore the EDID
 returned by the monitor and use a custom one. I looks like the nouveau
 drivers do not offer this feature. Am I wrong?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=Documentation/EDID/HOWTO.txt

 
 These are my specs:
   * kernel: 3.4.11-2.16-desktop
   * architecture: x86_64
   * distribution: openSUSE 12.2
   * xorg-x11-driver-video-nouveau-0.0.16_20120321_ab7291d-3.5.1.x86_64
   * X.Org X Server 1.12.3
   * NVIDIA Corporation G84M [Quadro FX 570M]
   * Monitor 1: lenovo l220x wide
   * Monitor 2: lenovo l2440p
 
 
 What should I do?
 
 Thanks in advance
 Flavio
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: add lockdep annotations

2013-02-04 Thread Marcin Slusarz
1) Lockdep thinks all nouveau subdevs belong to the same class and can be
locked in arbitrary order, which is not true (at least in general case).
Tell it to distinguish subdevs by (o)class type.
2) DRM client can be locked under user client lock - tell lockdep to put DRM
client lock in a separate class.

Reported-by: Arend van Spriel ar...@broadcom.com
Reported-by: Peter Hurley pe...@hurleysoftware.com
Reported-by: Maarten Lankhorst maarten.lankho...@canonical.com
Reported-by: Daniel J Blueman dan...@quora.org
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
Cc: sta...@vger.kernel.org [3.7, but needs s/const ofuncs/ofuncs/ to build]
---
Lightly tested, only on NV4B and NVC1.
---
 drivers/gpu/drm/nouveau/core/core/subdev.c | 2 +-
 drivers/gpu/drm/nouveau/core/include/core/object.h | 7 +--
 drivers/gpu/drm/nouveau/nouveau_drm.c  | 3 +++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/subdev.c 
b/drivers/gpu/drm/nouveau/core/core/subdev.c
index f74c30a..48f0637 100644
--- a/drivers/gpu/drm/nouveau/core/core/subdev.c
+++ b/drivers/gpu/drm/nouveau/core/core/subdev.c
@@ -99,7 +99,7 @@ nouveau_subdev_create_(struct nouveau_object *parent,
if (ret)
return ret;
 
-   mutex_init(subdev-mutex);
+   __mutex_init(subdev-mutex, subname, oclass-lock_class_key);
subdev-name = subname;
 
if (parent) {
diff --git a/drivers/gpu/drm/nouveau/core/include/core/object.h 
b/drivers/gpu/drm/nouveau/core/include/core/object.h
index 6a90267..62e68ba 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/object.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/object.h
@@ -50,10 +50,13 @@ int  nouveau_object_fini(struct nouveau_object *, bool 
suspend);
 
 extern struct nouveau_ofuncs nouveau_object_ofuncs;
 
+/* Don't allocate dynamically, because lockdep needs lock_class_keys to be in
+ * .data. */
 struct nouveau_oclass {
u32 handle;
-   struct nouveau_ofuncs *ofuncs;
-   struct nouveau_omthds *omthds;
+   struct nouveau_ofuncs * const ofuncs;
+   struct nouveau_omthds * const omthds;
+   struct lock_class_key lock_class_key;
 };
 
 #define nv_oclass(o)nv_object(o)-oclass
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index ef1ad21..bc00587 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -245,6 +245,8 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
return 0;
 }
 
+static struct lock_class_key drm_client_lock_class_key;
+
 static int
 nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 {
@@ -256,6 +258,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long 
flags)
ret = nouveau_cli_create(pdev, DRM, sizeof(*drm), (void**)drm);
if (ret)
return ret;
+   lockdep_set_class(drm-client.mutex, drm_client_lock_class_key);
 
dev-dev_private = drm;
drm-dev = dev;
-- 
1.8.1

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH 1/3] drm/nouveau/therm: turn on a fan only when crossing threshold in positive direction

2013-02-03 Thread Marcin Slusarz
+ the same for shutdown threshold - seems impossible, but shutdown can fail.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/subdev/therm/temp.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c 
b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c
index bf9b3ce..8f27b44 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c
@@ -105,7 +105,7 @@ void nouveau_therm_sensor_event(struct nouveau_therm *therm,
return;
 
if (dir == NOUVEAU_THERM_THRS_FALLING)
-   nv_info(therm, temperature (%u C) went bellow the '%s' 
threshold\n,
+   nv_info(therm, temperature (%u C) went below the '%s' 
threshold\n,
temperature, thresolds[thrs]);
else
nv_info(therm, temperature (%u C) hit the '%s' threshold\n,
@@ -114,8 +114,10 @@ void nouveau_therm_sensor_event(struct nouveau_therm 
*therm,
active = (dir == NOUVEAU_THERM_THRS_RISING);
switch (thrs) {
case NOUVEAU_THERM_THRS_FANBOOST:
-   nouveau_therm_fan_set(therm, true, 100);
-   nouveau_therm_mode(therm, NOUVEAU_THERM_CTRL_AUTO);
+   if (active) {
+   nouveau_therm_fan_set(therm, true, 100);
+   nouveau_therm_mode(therm, NOUVEAU_THERM_CTRL_AUTO);
+   }
break;
case NOUVEAU_THERM_THRS_DOWNCLOCK:
if (priv-emergency.downclock)
@@ -126,7 +128,8 @@ void nouveau_therm_sensor_event(struct nouveau_therm *therm,
priv-emergency.pause(therm, active);
break;
case NOUVEAU_THERM_THRS_SHUTDOWN:
-   orderly_poweroff(true);
+   if (active)
+   orderly_poweroff(true);
break;
case NOUVEAU_THERM_THRS_NR:
break;
-- 
1.8.1

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH 2/3] drm/nv40/therm: reset temperature sensor on init

2013-02-03 Thread Marcin Slusarz
Current uninitialized sensor detection does not work for me on nv4b and
sensor returns crazy values (190°C). It stabilises later, but it's too
late - therm code shutdowns the machine...

Let's just reset it on init.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c 
b/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c
index accc628..7d90844 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c
@@ -173,13 +173,23 @@ nv40_therm_ctor(struct nouveau_object *parent,
return nouveau_therm_preinit(priv-base.base);
 }
 
+int
+nv40_therm_init(struct nouveau_object *object)
+{
+   struct nouveau_therm *therm = (void *)object;
+
+   nv40_sensor_setup(therm);
+
+   return _nouveau_therm_init(object);
+}
+
 struct nouveau_oclass
 nv40_therm_oclass = {
.handle = NV_SUBDEV(THERM, 0x40),
.ofuncs = (struct nouveau_ofuncs) {
.ctor = nv40_therm_ctor,
.dtor = _nouveau_therm_dtor,
-   .init = _nouveau_therm_init,
+   .init = nv40_therm_init,
.fini = _nouveau_therm_fini,
},
 };
-- 
1.8.1

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH 3/3] drm/nouveau/therm: use workqueue to shutdown the machine

2013-02-03 Thread Marcin Slusarz
orderly_poweroff cannot be called from atomic context.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/subdev/therm/temp.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c 
b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c
index 8f27b44..b37624a 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c
@@ -90,6 +90,13 @@ nouveau_therm_sensor_get_threshold_state(struct 
nouveau_therm *therm,
return priv-sensor.alarm_state[thrs];
 }
 
+static void
+nv_poweroff_work(struct work_struct *work)
+{
+   orderly_poweroff(true);
+   kfree(work);
+}
+
 void nouveau_therm_sensor_event(struct nouveau_therm *therm,
enum nouveau_therm_thrs thrs,
enum nouveau_therm_thrs_direction dir)
@@ -128,8 +135,15 @@ void nouveau_therm_sensor_event(struct nouveau_therm 
*therm,
priv-emergency.pause(therm, active);
break;
case NOUVEAU_THERM_THRS_SHUTDOWN:
-   if (active)
-   orderly_poweroff(true);
+   if (active) {
+   struct work_struct *work;
+
+   work = kmalloc(sizeof(*work), GFP_ATOMIC);
+   if (work) {
+   INIT_WORK(work, nv_poweroff_work);
+   schedule_work(work);
+   }
+   }
break;
case NOUVEAU_THERM_THRS_NR:
break;
-- 
1.8.1

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] nv30/exa: fix shaders on big-endian machines

2013-02-03 Thread Marcin Slusarz
Direct port of commit d1bc38b6673c54af61196056c489383fba8dced8
nv40/exa: fix shaders on big-endian machines to nv30.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=60050
---
 src/nv30_exa.c | 272 -
 1 file changed, 136 insertions(+), 136 deletions(-)

diff --git a/src/nv30_exa.c b/src/nv30_exa.c
index 95509bc..21586e9 100644
--- a/src/nv30_exa.c
+++ b/src/nv30_exa.c
@@ -820,146 +820,146 @@ NVAccelInitNV30TCL(ScrnInfoPtr pScrn)
PUSH_DATA (push, 409616);
 
PUSH_DATAu(push, pNv-scratch, PFP_PASS, 2 * 4);
-   PUSH_DATA (push, 0x18009e80); /* txph r0, a[tex0], t[0] */
-   PUSH_DATA (push, 0x1c9dc801);
-   PUSH_DATA (push, 0x0001c800);
-   PUSH_DATA (push, 0x3fe1c800);
-   PUSH_DATA (push, 0x1802be83); /* txph r1, a[tex1], t[1] */
-   PUSH_DATA (push, 0x1c9dc801); /* exit */
-   PUSH_DATA (push, 0x0001c800);
-   PUSH_DATA (push, 0x3fe1c800);
+   PUSH_DATAs(push, 0x18009e80); /* txph r0, a[tex0], t[0] */
+   PUSH_DATAs(push, 0x1c9dc801);
+   PUSH_DATAs(push, 0x0001c800);
+   PUSH_DATAs(push, 0x3fe1c800);
+   PUSH_DATAs(push, 0x1802be83); /* txph r1, a[tex1], t[1] */
+   PUSH_DATAs(push, 0x1c9dc801); /* exit */
+   PUSH_DATAs(push, 0x0001c800);
+   PUSH_DATAs(push, 0x3fe1c800);
 
PUSH_DATAu(push, pNv-scratch, PFP_NV12_BILINEAR, 8 * 4);
-   PUSH_DATA (push, 0x17028200); /* texr r0.x, a[tex0], t[1] */
-   PUSH_DATA (push, 0x1c9dc801);
-   PUSH_DATA (push, 0x0001c800);
-   PUSH_DATA (push, 0x3fe1c800);
-   PUSH_DATA (push, 0x04000e02); /* madr r1.xyz, r0.x, imm.x, imm.yzww */
-   PUSH_DATA (push, 0x1c9c);
-   PUSH_DATA (push, 0x0002);
-   PUSH_DATA (push, 0x0001f202);
-   PUSH_DATA (push, 0x3f9507c8); /* { 1.16, -0.87, 0.53, -1.08 } */
-   PUSH_DATA (push, 0xbf5ee393);
-   PUSH_DATA (push, 0x3f078fef);
-   PUSH_DATA (push, 0xbf8a6762);
-   PUSH_DATA (push, 0x1704ac80); /* texr r0.yz, a[tex1], t[2] */
-   PUSH_DATA (push, 0x1c9dc801);
-   PUSH_DATA (push, 0x0001c800);
-   PUSH_DATA (push, 0x3fe1c800);
-   PUSH_DATA (push, 0x04000e02); /* madr r1.xyz, r0.y, imm, r1 */
-   PUSH_DATA (push, 0x1c9cab00);
-   PUSH_DATA (push, 0x0001c802);
-   PUSH_DATA (push, 0x0001c804);
-   PUSH_DATA (push, 0x); /* { 0.00, -0.39, 2.02, 0.00 } */
-   PUSH_DATA (push, 0xbec890d6);
-   PUSH_DATA (push, 0x40011687);
-   PUSH_DATA (push, 0x);
-   PUSH_DATA (push, 0x04000e81); /* madr r0.xyz, r0.z, imm, r1 */
-   PUSH_DATA (push, 0x1c9d5500);
-   PUSH_DATA (push, 0x0001c802);
-   PUSH_DATA (push, 0x0001c804);
-   PUSH_DATA (push, 0x3fcc432d); /* { 1.60, -0.81, 0.00, 0.00 } */
-   PUSH_DATA (push, 0xbf501a37);
-   PUSH_DATA (push, 0x);
-   PUSH_DATA (push, 0x);
+   PUSH_DATAs(push, 0x17028200); /* texr r0.x, a[tex0], t[1] */
+   PUSH_DATAs(push, 0x1c9dc801);
+   PUSH_DATAs(push, 0x0001c800);
+   PUSH_DATAs(push, 0x3fe1c800);
+   PUSH_DATAs(push, 0x04000e02); /* madr r1.xyz, r0.x, imm.x, imm.yzww */
+   PUSH_DATAs(push, 0x1c9c);
+   PUSH_DATAs(push, 0x0002);
+   PUSH_DATAs(push, 0x0001f202);
+   PUSH_DATAs(push, 0x3f9507c8); /* { 1.16, -0.87, 0.53, -1.08 } */
+   PUSH_DATAs(push, 0xbf5ee393);
+   PUSH_DATAs(push, 0x3f078fef);
+   PUSH_DATAs(push, 0xbf8a6762);
+   PUSH_DATAs(push, 0x1704ac80); /* texr r0.yz, a[tex1], t[2] */
+   PUSH_DATAs(push, 0x1c9dc801);
+   PUSH_DATAs(push, 0x0001c800);
+   PUSH_DATAs(push, 0x3fe1c800);
+   PUSH_DATAs(push, 0x04000e02); /* madr r1.xyz, r0.y, imm, r1 */
+   PUSH_DATAs(push, 0x1c9cab00);
+   PUSH_DATAs(push, 0x0001c802);
+   PUSH_DATAs(push, 0x0001c804);
+   PUSH_DATAs(push, 0x); /* { 0.00, -0.39, 2.02, 0.00 } */
+   PUSH_DATAs(push, 0xbec890d6);
+   PUSH_DATAs(push, 0x40011687);
+   PUSH_DATAs(push, 0x);
+   PUSH_DATAs(push, 0x04000e81); /* madr r0.xyz, r0.z, imm, r1 */
+   PUSH_DATAs(push, 0x1c9d5500);
+   PUSH_DATAs(push, 0x0001c802);
+   PUSH_DATAs(push, 0x0001c804);
+   PUSH_DATAs(push, 0x3fcc432d); /* { 1.60, -0.81, 0.00, 0.00 } */
+   PUSH_DATAs(push, 0xbf501a37);
+   PUSH_DATAs(push, 0x);
+   PUSH_DATAs(push, 0x);
 
PUSH_DATAu(push, pNv-scratch, PFP_NV12_BICUBIC, 24 * 4);
-   PUSH_DATA (push, 0x01008604); /* movr r2.xy, a[tex0] */
-   PUSH_DATA (push, 0x1c9dc801);
-   PUSH_DATA (push, 0x0001c800);
-   PUSH_DATA (push, 0x0001c800);
-   PUSH_DATA (push, 0x03000600); /* addr r0.xy, r2, imm.x */
-   PUSH_DATA (push, 0x1c9dc808);
-   PUSH_DATA (push, 0x0002);
-   PUSH_DATA (push, 0x0001c800);
-   PUSH_DATA (push, 0x3f00); /* { 0.50, 0.00, 0.00, 0.00 } */
-   PUSH_DATA (push, 0x);
-   PUSH_DATA (push, 0x);
-   PUSH_DATA (push, 0x);
-   

Re: [Nouveau] [PATCH 2/3] drm/nv40/therm: reset temperature sensor on init

2013-02-03 Thread Marcin Slusarz
On Sun, Feb 03, 2013 at 09:07:56PM +0100, Marcin Slusarz wrote:
 Current uninitialized sensor detection does not work for me on nv4b and
 sensor returns crazy values (190°C). It stabilises later, but it's too
 late - therm code shutdowns the machine...
 
 Let's just reset it on init.
 
 Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
 ---
  drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c | 12 +++-
  1 file changed, 11 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c 
 b/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c
 index accc628..7d90844 100644
 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c
 +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c
 @@ -173,13 +173,23 @@ nv40_therm_ctor(struct nouveau_object *parent,
   return nouveau_therm_preinit(priv-base.base);
  }
  
 +int
 +nv40_therm_init(struct nouveau_object *object)

Tiny issue: this function should be static.

 +{
 + struct nouveau_therm *therm = (void *)object;
 +
 + nv40_sensor_setup(therm);
 +
 + return _nouveau_therm_init(object);
 +}
 +
  struct nouveau_oclass
  nv40_therm_oclass = {
   .handle = NV_SUBDEV(THERM, 0x40),
   .ofuncs = (struct nouveau_ofuncs) {
   .ctor = nv40_therm_ctor,
   .dtor = _nouveau_therm_dtor,
 - .init = _nouveau_therm_init,
 + .init = nv40_therm_init,
   .fini = _nouveau_therm_fini,
   },
  };
 -- 
 1.8.1
 
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Resume regression with nouveau 3.8rc1 (bisected)

2013-01-05 Thread Marcin Slusarz
On Sat, Jan 05, 2013 at 10:10:06AM +0100, Pontus Fuchs wrote:
 On 01/03/2013 08:12 PM, Marcin Slusarz wrote:
  On Thu, Jan 03, 2013 at 01:58:10PM +0100, Marcin Slusarz wrote:
  I bisected the problem down to this commit:
 
  186ecad21: drm/nv50/disp: move remaining interrupt handling into core
 
  Hardware is 8400M GS (10de:0427) in a Dell XPS M1330.
  There's already open bug report for that:
  https://bugs.freedesktop.org/show_bug.cgi?id=58729
  Yay, a bug fix was just posted there ;).
 
 Hi, I tried that patch but it didn't help :(
 
 I see this in my kernel log after resume:
 
 nouveau E[ PFB][:01:00.0] trapped read at 0x002001a020 on 
 channel 0x7b23 SEMAPHORE_BG/PFIFO_READ/00 reason: PAGE_NOT_PRESENT
 nouveau E[1177] failed to idle channel 0x
 [TTM] Failed to expire sync object before buffer eviction
 [TTM] Failed to expire sync object before buffer eviction
 [TTM] Failed to expire sync object before buffer eviction

Sigh, this seems to be another issue :/
Please follow http://nouveau.freedesktop.org/wiki/Bugs and open new bug report.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Resume regression with nouveau 3.8rc1 (bisected)

2013-01-03 Thread Marcin Slusarz
On Wed, Jan 02, 2013 at 04:19:35PM +0100, Pontus Fuchs wrote:
 Hi,
 
 Starting with 3.8rc1 I get a black screen when resuming after suspend. 
 The kernel is alive because I can switch to VT1 and reboot with 
 ctrl-alt-delete.
 
 I bisected the problem down to this commit:
 
 186ecad21: drm/nv50/disp: move remaining interrupt handling into core
 
 Hardware is 8400M GS (10de:0427) in a Dell XPS M1330.

There's already open bug report for that:
https://bugs.freedesktop.org/show_bug.cgi?id=58729

And my nv92 does not resume too, with similar symptoms, since nouveau display
rework hit the tree.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Resume regression with nouveau 3.8rc1 (bisected)

2013-01-03 Thread Marcin Slusarz
On Thu, Jan 03, 2013 at 01:58:10PM +0100, Marcin Slusarz wrote:
 On Wed, Jan 02, 2013 at 04:19:35PM +0100, Pontus Fuchs wrote:
  Hi,
  
  Starting with 3.8rc1 I get a black screen when resuming after suspend. 
  The kernel is alive because I can switch to VT1 and reboot with 
  ctrl-alt-delete.
  
  I bisected the problem down to this commit:
  
  186ecad21: drm/nv50/disp: move remaining interrupt handling into core
  
  Hardware is 8400M GS (10de:0427) in a Dell XPS M1330.
 
 There's already open bug report for that:
 https://bugs.freedesktop.org/show_bug.cgi?id=58729

Yay, a bug fix was just posted there ;).

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv17-50: restore fence buffer on resume

2012-12-26 Thread Marcin Slusarz
Since commit 5e120f6e4b3f35b741c5445dfc755f50128c3c44 drm/nouveau/fence:
convert to exec engine, and improve channel sync nouveau fence sync
implementation for nv17-50 and nvc0+ started to rely on state of fence buffer
left by previous sync operation. But as pinned bo's (where fence state is
stored) are not saved+restored across suspend/resume, we need to do it
manually.

nvc0+ was fixed by commit d6ba6d215a538a58f0f0026f0961b0b9125e8042
drm/nvc0/fence: restore pre-suspend fence buffer context on resume.

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

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
Cc: sta...@vger.kernel.org
---
 drivers/gpu/drm/nouveau/nouveau_fence.h | 1 +
 drivers/gpu/drm/nouveau/nv10_fence.c| 9 +
 drivers/gpu/drm/nouveau/nv50_fence.c| 2 ++
 3 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h 
b/drivers/gpu/drm/nouveau/nouveau_fence.h
index bedafd1..cdb83ac 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.h
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
@@ -60,6 +60,7 @@ u32  nv10_fence_read(struct nouveau_channel *);
 void nv10_fence_context_del(struct nouveau_channel *);
 void nv10_fence_destroy(struct nouveau_drm *);
 int  nv10_fence_create(struct nouveau_drm *);
+void nv17_fence_resume(struct nouveau_drm *drm);
 
 int nv50_fence_create(struct nouveau_drm *);
 int nv84_fence_create(struct nouveau_drm *);
diff --git a/drivers/gpu/drm/nouveau/nv10_fence.c 
b/drivers/gpu/drm/nouveau/nv10_fence.c
index 7ae7f97..0619c02 100644
--- a/drivers/gpu/drm/nouveau/nv10_fence.c
+++ b/drivers/gpu/drm/nouveau/nv10_fence.c
@@ -162,6 +162,13 @@ nv10_fence_destroy(struct nouveau_drm *drm)
kfree(priv);
 }
 
+void nv17_fence_resume(struct nouveau_drm *drm)
+{
+   struct nv10_fence_priv *priv = drm-fence;
+
+   nouveau_bo_wr32(priv-bo, 0, priv-sequence);
+}
+
 int
 nv10_fence_create(struct nouveau_drm *drm)
 {
@@ -197,6 +204,8 @@ nv10_fence_create(struct nouveau_drm *drm)
if (ret == 0) {
nouveau_bo_wr32(priv-bo, 0x000, 0x);
priv-base.sync = nv17_fence_sync;
+
+   priv-base.resume = nv17_fence_resume;
}
}
 
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c 
b/drivers/gpu/drm/nouveau/nv50_fence.c
index c20f272..4cc0ce6 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -122,6 +122,8 @@ nv50_fence_create(struct nouveau_drm *drm)
if (ret == 0) {
nouveau_bo_wr32(priv-bo, 0x000, 0x);
priv-base.sync = nv17_fence_sync;
+
+   priv-base.resume = nv17_fence_resume;
}
 
if (ret)
-- 
1.8.0.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: share fence structures between nv10+ and nv50 implementations

2012-12-26 Thread Marcin Slusarz
We already rely on them having the same fields and layout.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nv10_fence.c | 13 +
 drivers/gpu/drm/nouveau/nv10_fence.h | 19 +++
 drivers/gpu/drm/nouveau/nv50_fence.c | 19 ---
 3 files changed, 24 insertions(+), 27 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nv10_fence.h

diff --git a/drivers/gpu/drm/nouveau/nv10_fence.c 
b/drivers/gpu/drm/nouveau/nv10_fence.c
index 0619c02..2ad4cd5 100644
--- a/drivers/gpu/drm/nouveau/nv10_fence.c
+++ b/drivers/gpu/drm/nouveau/nv10_fence.c
@@ -27,18 +27,7 @@
 
 #include nouveau_drm.h
 #include nouveau_dma.h
-#include nouveau_fence.h
-
-struct nv10_fence_chan {
-   struct nouveau_fence_chan base;
-};
-
-struct nv10_fence_priv {
-   struct nouveau_fence_priv base;
-   struct nouveau_bo *bo;
-   spinlock_t lock;
-   u32 sequence;
-};
+#include nv10_fence.h
 
 int
 nv10_fence_emit(struct nouveau_fence *fence)
diff --git a/drivers/gpu/drm/nouveau/nv10_fence.h 
b/drivers/gpu/drm/nouveau/nv10_fence.h
new file mode 100644
index 000..e5d9204
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nv10_fence.h
@@ -0,0 +1,19 @@
+#ifndef __NV10_FENCE_H_
+#define __NV10_FENCE_H_
+
+#include core/os.h
+#include nouveau_fence.h
+#include nouveau_bo.h
+
+struct nv10_fence_chan {
+   struct nouveau_fence_chan base;
+};
+
+struct nv10_fence_priv {
+   struct nouveau_fence_priv base;
+   struct nouveau_bo *bo;
+   spinlock_t lock;
+   u32 sequence;
+};
+
+#endif
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c 
b/drivers/gpu/drm/nouveau/nv50_fence.c
index 4cc0ce6..4bef67c 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -27,27 +27,16 @@
 
 #include nouveau_drm.h
 #include nouveau_dma.h
-#include nouveau_fence.h
+#include nv10_fence.h
 
 #include nv50_display.h
 
-struct nv50_fence_chan {
-   struct nouveau_fence_chan base;
-};
-
-struct nv50_fence_priv {
-   struct nouveau_fence_priv base;
-   struct nouveau_bo *bo;
-   spinlock_t lock;
-   u32 sequence;
-};
-
 static int
 nv50_fence_context_new(struct nouveau_channel *chan)
 {
struct drm_device *dev = chan-drm-dev;
-   struct nv50_fence_priv *priv = chan-drm-fence;
-   struct nv50_fence_chan *fctx;
+   struct nv10_fence_priv *priv = chan-drm-fence;
+   struct nv10_fence_chan *fctx;
struct ttm_mem_reg *mem = priv-bo-bo.mem;
struct nouveau_object *object;
int ret, i;
@@ -91,7 +80,7 @@ nv50_fence_context_new(struct nouveau_channel *chan)
 int
 nv50_fence_create(struct nouveau_drm *drm)
 {
-   struct nv50_fence_priv *priv;
+   struct nv10_fence_priv *priv;
int ret = 0;
 
priv = drm-fence = kzalloc(sizeof(*priv), GFP_KERNEL);
-- 
1.8.0.2


___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] G4 Snowball DPMS 1 fix

2012-12-22 Thread Marcin Slusarz
On Sat, Dec 22, 2012 at 06:25:21PM +0100, Stefan de Konink wrote:
 Hi,
 
 Since I am a proud owner of a G4 Snowball, and the screen did some
 strange things in DPMS 1 (blanking), I thought it was a good idea to fix
 it. With some help from IRC I made the attached patch.
 
 Stefan

 commit 4e2b7e05ceb5afb2f1a0b9e5bfd405bbef11a723
 Author: Stefan de Konink ste...@konink.de
 Date:   Sat Dec 22 18:04:37 2012 +0100
 
 drm/nouveau: Fix DPMS 1 on G4 Snowball, from snow white to coal black.
 
 This fixes bug https://bugs.freedesktop.org/show_bug.cgi?id=40275
 
 Signed-off-by: Stefan de Konink ste...@konink.de
 
 diff --git a/drivers/gpu/drm/nouveau/nv04_dfp.c 
 b/drivers/gpu/drm/nouveau/nv04_dfp.c
 index 184cdf8..eb76b69 100644
 --- a/drivers/gpu/drm/nouveau/nv04_dfp.c
 +++ b/drivers/gpu/drm/nouveau/nv04_dfp.c
 @@ -490,8 +490,8 @@ static void nv04_dfp_update_backlight(struct drm_encoder 
 *encoder, int mode)
   /* BIOS scripts usually take care of the backlight, thanks
* Apple for your consistency.
*/
 - if (dev-pci_device == 0x0179 || dev-pci_device == 0x0189 ||
 - dev-pci_device == 0x0329) {
 + if (dev-pci_device == 0x0174 || dev-pci_device == 0x0179 ||
 + dev-pci_device == 0x0189 || dev-pci_device == 0x0329) {
   if (mode == DRM_MODE_DPMS_ON) {
   nv_mask(device, NV_PBUS_DEBUG_DUALHEAD_CTL, 0, 1  31);
   nv_mask(device, NV_PCRTC_GPIO_EXT, 3, 1);

Reviewed-by: Marcin Slusarz marcin.slus...@gmail.com
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: fix ramht wraparound

2012-12-21 Thread Marcin Slusarz
On Fri, Dec 21, 2012 at 10:15:48AM +1000, Ben Skeggs wrote:
 On Thu, Dec 20, 2012 at 11:37:12PM +0100, Marcin Slusarz wrote:
  When hash collision occurs and it's near ramht object boundary, we could
  read and possibly overwrite some memory after ramht object.
  
  Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
  Cc: sta...@vger.kernel.org
  ---
   drivers/gpu/drm/nouveau/core/core/ramht.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/drivers/gpu/drm/nouveau/core/core/ramht.c 
  b/drivers/gpu/drm/nouveau/core/core/ramht.c
  index 86a6404..6da314c 100644
  --- a/drivers/gpu/drm/nouveau/core/core/ramht.c
  +++ b/drivers/gpu/drm/nouveau/core/core/ramht.c
  @@ -59,7 +59,7 @@ nouveau_ramht_insert(struct nouveau_ramht *ramht, int 
  chid,
  }
   
  co += 8;
  -   if (co = nv_gpuobj(ramht)-size)
  +   if (co + 8  nv_gpuobj(ramht)-size)
 I might just be really tired, but, how exactly is the original wrong?
 The original could even just be (co == size) and still work correctly as
 far as I can tell.

Ah, crap, I didn't see that both hash value and ramht-size are divisible by 8.
So original code is correct (although it relies on the above) and my version
does not really fix anything.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH RESEND] drm/nouveau: add locking around instobj list operations

2012-12-20 Thread Marcin Slusarz
Fixes memory corruptions, oopses, etc. when multiple gpuobjs are
simultaneously created or destroyed.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
Cc: sta...@vger.kernel.org
---
 drivers/gpu/drm/nouveau/core/subdev/instmem/base.c | 35 +-
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c 
b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
index 1188227..6565f3d 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
@@ -40,15 +40,21 @@ nouveau_instobj_create_(struct nouveau_object *parent,
if (ret)
return ret;
 
+   mutex_lock(imem-base.mutex);
list_add(iobj-head, imem-list);
+   mutex_unlock(imem-base.mutex);
return 0;
 }
 
 void
 nouveau_instobj_destroy(struct nouveau_instobj *iobj)
 {
-   if (iobj-head.prev)
-   list_del(iobj-head);
+   struct nouveau_subdev *subdev = nv_subdev(iobj-base.engine);
+
+   mutex_lock(subdev-mutex);
+   list_del(iobj-head);
+   mutex_unlock(subdev-mutex);
+
return nouveau_object_destroy(iobj-base);
 }
 
@@ -88,6 +94,8 @@ nouveau_instmem_init(struct nouveau_instmem *imem)
if (ret)
return ret;
 
+   mutex_lock(imem-base.mutex);
+
list_for_each_entry(iobj, imem-list, head) {
if (iobj-suspend) {
for (i = 0; i  iobj-size; i += 4)
@@ -97,6 +105,8 @@ nouveau_instmem_init(struct nouveau_instmem *imem)
}
}
 
+   mutex_unlock(imem-base.mutex);
+
return 0;
 }
 
@@ -104,17 +114,26 @@ int
 nouveau_instmem_fini(struct nouveau_instmem *imem, bool suspend)
 {
struct nouveau_instobj *iobj;
-   int i;
+   int i, ret = 0;
 
if (suspend) {
+   mutex_lock(imem-base.mutex);
+
list_for_each_entry(iobj, imem-list, head) {
iobj-suspend = vmalloc(iobj-size);
-   if (iobj-suspend) {
-   for (i = 0; i  iobj-size; i += 4)
-   iobj-suspend[i / 4] = nv_ro32(iobj, i);
-   } else
-   return -ENOMEM;
+   if (!iobj-suspend) {
+   ret = -ENOMEM;
+   break;
+   }
+
+   for (i = 0; i  iobj-size; i += 4)
+   iobj-suspend[i / 4] = nv_ro32(iobj, i);
}
+
+   mutex_unlock(imem-base.mutex);
+
+   if (ret)
+   return ret;
}
 
return nouveau_subdev_fini(imem-base, suspend);
-- 
1.8.0.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau/vm: fix memory corruption when pgt allocation fails

2012-12-20 Thread Marcin Slusarz
If we return freed vm, nouveau_drm_open will happily call nouveau_cli_destroy,
which will try to free it again.

Reported-by: Peter Hurley pe...@hurleysoftware.com
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/subdev/vm/base.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c 
b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
index 082c11b..77c67fc 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
@@ -352,7 +352,7 @@ nouveau_vm_create(struct nouveau_vmmgr *vmm, u64 offset, 
u64 length,
u64 mm_length = (offset + length) - mm_offset;
int ret;
 
-   vm = *pvm = kzalloc(sizeof(*vm), GFP_KERNEL);
+   vm = kzalloc(sizeof(*vm), GFP_KERNEL);
if (!vm)
return -ENOMEM;
 
@@ -376,6 +376,8 @@ nouveau_vm_create(struct nouveau_vmmgr *vmm, u64 offset, 
u64 length,
return ret;
}
 
+   *pvm = vm;
+
return 0;
 }
 
-- 
1.8.0.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: don't return freed object from nouveau_handle_create

2012-12-20 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/handle.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/handle.c 
b/drivers/gpu/drm/nouveau/core/core/handle.c
index b8d2cbf..264c2b3 100644
--- a/drivers/gpu/drm/nouveau/core/core/handle.c
+++ b/drivers/gpu/drm/nouveau/core/core/handle.c
@@ -109,7 +109,7 @@ nouveau_handle_create(struct nouveau_object *parent, u32 
_parent, u32 _handle,
while (!nv_iclass(namedb, NV_NAMEDB_CLASS))
namedb = namedb-parent;
 
-   handle = *phandle = kzalloc(sizeof(*handle), GFP_KERNEL);
+   handle = kzalloc(sizeof(*handle), GFP_KERNEL);
if (!handle)
return -ENOMEM;
 
@@ -146,6 +146,9 @@ nouveau_handle_create(struct nouveau_object *parent, u32 
_parent, u32 _handle,
}
 
hprintk(handle, TRACE, created\n);
+
+   *phandle = handle;
+
return 0;
 }
 
-- 
1.8.0.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: fix nouveau_client allocation failure path

2012-12-20 Thread Marcin Slusarz
Depending on the point of failure, freed object would be returned
or memory leak would happen.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/client.c | 4 +---
 drivers/gpu/drm/nouveau/core/include/core/client.h | 3 +++
 drivers/gpu/drm/nouveau/nouveau_drm.c  | 7 ++-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/client.c 
b/drivers/gpu/drm/nouveau/core/core/client.c
index 762e4fc..295c221 100644
--- a/drivers/gpu/drm/nouveau/core/core/client.c
+++ b/drivers/gpu/drm/nouveau/core/core/client.c
@@ -66,10 +66,8 @@ nouveau_client_create_(const char *name, u64 devname, const 
char *cfg,
 
ret = nouveau_handle_create(nv_object(client), ~0, ~0,
nv_object(client), client-root);
-   if (ret) {
-   nouveau_namedb_destroy(client-base);
+   if (ret)
return ret;
-   }
 
/* prevent init/fini being called, os in in charge of this */
atomic_set(nv_object(client)-usecount, 2);
diff --git a/drivers/gpu/drm/nouveau/core/include/core/client.h 
b/drivers/gpu/drm/nouveau/core/include/core/client.h
index b8d0457..c66eac5 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/client.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/client.h
@@ -36,6 +36,9 @@ nouveau_client(void *obj)
 
 int  nouveau_client_create_(const char *name, u64 device, const char *cfg,
const char *dbg, int, void **);
+#define nouveau_client_destroy(p)  
\
+   nouveau_namedb_destroy((p)-base)
+
 int  nouveau_client_init(struct nouveau_client *);
 int  nouveau_client_fini(struct nouveau_client *, bool suspend);
 const char *nouveau_client_name(void *obj);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index ab85a89..83a38d8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -84,11 +84,16 @@ nouveau_cli_create(struct pci_dev *pdev, const char *name,
struct nouveau_cli *cli;
int ret;
 
+   *pcli = NULL;
ret = nouveau_client_create_(name, nouveau_name(pdev), nouveau_config,
 nouveau_debug, size, pcli);
cli = *pcli;
-   if (ret)
+   if (ret) {
+   if (cli)
+   nouveau_client_destroy(cli-base);
+   *pcli = NULL;
return ret;
+   }
 
mutex_init(cli-mutex);
return 0;
-- 
1.8.0.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: fix ramht wraparound

2012-12-20 Thread Marcin Slusarz
When hash collision occurs and it's near ramht object boundary, we could
read and possibly overwrite some memory after ramht object.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
Cc: sta...@vger.kernel.org
---
 drivers/gpu/drm/nouveau/core/core/ramht.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/ramht.c 
b/drivers/gpu/drm/nouveau/core/core/ramht.c
index 86a6404..6da314c 100644
--- a/drivers/gpu/drm/nouveau/core/core/ramht.c
+++ b/drivers/gpu/drm/nouveau/core/core/ramht.c
@@ -59,7 +59,7 @@ nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid,
}
 
co += 8;
-   if (co = nv_gpuobj(ramht)-size)
+   if (co + 8  nv_gpuobj(ramht)-size)
co = 0;
} while (co != ho);
 
-- 
1.8.0.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: fix blank LVDS screen regression on pre-nv50 cards

2012-12-20 Thread Marcin Slusarz
Commit 2a44e499 (drm/nouveau/disp: introduce proper init/fini, separate
from create/destroy) started to call display init routines on pre-nv50
hardware on module load. But LVDS init code sets driver state in a way
which prevents modesetting code from operating properly.

nv04_display_init calls nv04_dfp_restore, which sets encoder-last_dpms to
NV_DPMS_CLEARED.

drm_crtc_helper_set_mode
  nv04_dfp_prepare
nv04_lvds_dpms(DRM_MODE_DPMS_OFF)

nv04_lvds_dpms checks last_dpms mode (which is NV_DPMS_CLEARED) and wrongly
assumes it's a powersaving mode, the new one (DRM_MODE_DPMS_OFF) is too,
so it skips calling some crucial lvds scripts.

Reported-by: Chris Paulson-Ellis ch...@edesix.com
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
Cc: sta...@vger.kernel.org
---
 drivers/gpu/drm/nouveau/nv04_dfp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nv04_dfp.c 
b/drivers/gpu/drm/nouveau/nv04_dfp.c
index 184cdf8..39ffc07 100644
--- a/drivers/gpu/drm/nouveau/nv04_dfp.c
+++ b/drivers/gpu/drm/nouveau/nv04_dfp.c
@@ -505,7 +505,7 @@ static void nv04_dfp_update_backlight(struct drm_encoder 
*encoder, int mode)
 
 static inline bool is_powersaving_dpms(int mode)
 {
-   return (mode != DRM_MODE_DPMS_ON);
+   return mode != DRM_MODE_DPMS_ON  mode != NV_DPMS_CLEARED;
 }
 
 static void nv04_lvds_dpms(struct drm_encoder *encoder, int mode)
-- 
1.8.0.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: improve reporting of fifo errors

2012-12-20 Thread Marcin Slusarz
Note: bar faults and semaphore errors were previously silently acked.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c | 142 ++--
 drivers/gpu/drm/nouveau/core/engine/fifo/nv04.h |   5 +-
 2 files changed, 139 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
index e34ab40..9c73bc1 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
@@ -25,6 +25,7 @@
 #include core/os.h
 #include core/class.h
 #include core/engctx.h
+#include core/enum.h
 #include core/namedb.h
 #include core/handle.h
 #include core/ramht.h
@@ -398,6 +399,73 @@ out:
return handled;
 }
 
+static struct nouveau_bitfield
+nv04_cache1_pull0_bits[] = {
+   {0x0001, ACCESS},
+   {0x0010, HASH_FAILED},
+   {0x0100, DEVICE_SOFTWARE},
+   {0x1000, HASH_BUSY},
+   {0x0001, ACQUIRE_BUSY},
+   {}
+};
+
+static struct nouveau_bitfield
+nv50_cache1_pull0_bits[] = {
+   {0x0001, ACCESS},
+   {0x0010, HASH_FAILED},
+   {0x0100, DEVICE_SOFTWARE},
+   {0x1000, HASH_BUSY},
+   {0x0001, ACQUIRE_BUSY},
+   {0x0100, INVALID_ENGINE},
+   {}
+};
+
+static const char * const
+nv11_sem_error_codes[] = {
+   NONE, INVALID_OPERAND, INVALID_STATE
+};
+
+static const char * const
+nv50_sem_error_codes[] = {
+   NONE, ADDRESS_UNALIGNED, INVALID_STATE,
+   ADDRESS_TOO_LARGE, MEM_FAULT
+};
+
+static void
+nv_decode_cache1_pull0(struct nouveau_device *device, u32 reg)
+{
+   const char * const *sem_error_codes;
+   int error_codes_size;
+   struct nouveau_bitfield *pull0_bits;
+   u8 sem_error;
+
+   pr_cont( cache1_pull0 0x%08x, reg);
+
+   sem_error = (reg  0x00F0)  20;
+   reg = ~0x00F0;
+
+   if (device-card_type == NV_50) {
+   pull0_bits = nv50_cache1_pull0_bits;
+   sem_error_codes = nv50_sem_error_codes;
+   error_codes_size = ARRAY_SIZE(nv50_sem_error_codes);
+   } else {
+   pull0_bits = nv04_cache1_pull0_bits;
+   sem_error_codes = nv11_sem_error_codes;
+   error_codes_size = ARRAY_SIZE(nv11_sem_error_codes);
+   }
+
+   nouveau_bitfield_print(pull0_bits, reg);
+
+   if (sem_error) {
+   pr_cont( SEMAPHORE_ERROR=);
+
+   if (sem_error  error_codes_size)
+   pr_cont(%s, sem_error_codes[sem_error]);
+   else
+   pr_cont(UNK%d, sem_error);
+   }
+}
+
 static void
 nv04_fifo_cache_error(struct nouveau_device *device,
struct nv04_fifo_priv *priv, u32 chid, u32 get)
@@ -423,10 +491,16 @@ nv04_fifo_cache_error(struct nouveau_device *device,
if (!nv04_fifo_swmthd(priv, chid, mthd, data)) {
const char *client_name =
nouveau_client_name_for_fifo_chid(priv-base, chid);
+   u32 c1p0 = nv_rd32(priv, NV04_PFIFO_CACHE1_PULL0);
nv_error(priv,
-CACHE_ERROR - ch %d [%s] subc %d mthd 0x%04x data 
0x%08x\n,
+CACHE_ERROR - ch %d [%s] subc %d mthd 0x%04x data 
0x%08x,
 chid, client_name, (mthd  13)  7, mthd  0x1ffc,
 data);
+   nv_decode_cache1_pull0(device, c1p0);
+   if (c1p0  0x0010) /* HASH_FAILED */
+   pr_cont( cache1_hash 0x%08x,
+   nv_rd32(priv, NV04_PFIFO_CACHE1_HASH));
+   pr_cont(\n);
}
 
nv_wr32(priv, NV04_PFIFO_CACHE1_DMA_PUSH, 0);
@@ -496,6 +570,7 @@ nv04_fifo_intr(struct nouveau_subdev *subdev)
struct nouveau_device *device = nv_device(subdev);
struct nv04_fifo_priv *priv = (void *)subdev;
uint32_t status, reassign;
+   const char *client_name = NULL;
int cnt = 0;
 
reassign = nv_rd32(priv, NV03_PFIFO_CACHES)  1;
@@ -517,9 +592,19 @@ nv04_fifo_intr(struct nouveau_subdev *subdev)
status = ~NV_PFIFO_INTR_DMA_PUSHER;
}
 
+   if (status)
+   client_name = nouveau_client_name_for_fifo_chid(
+   priv-base, chid);
+
if (status  NV_PFIFO_INTR_SEMAPHORE) {
uint32_t sem;
 
+   nv_error(priv, SEM_ERROR - ch %d [%s], chid,
+client_name);
+   nv_decode_cache1_pull0(device,
+   nv_rd32(priv, NV04_PFIFO_CACHE1_PULL0));
+   pr_cont(\n);
+
status = ~NV_PFIFO_INTR_SEMAPHORE;
nv_wr32(priv, NV03_PFIFO_INTR_0,
NV_PFIFO_INTR_SEMAPHORE);
@@ -532,15 +617,56

[Nouveau] reproducible CACHE_ERRORS

2012-12-20 Thread Marcin Slusarz
Hi

I found a way to reliably reproduce PFIFO CACHE_ERRORS, but I don't see why.

How to reproduce them:
1) Run a couple of glxinfo loops - 3 is usually enough.
   while [ true ]; do nvgl glxinfo /dev/null 2/dev/null; done
2) Run glxgears.
3) If you can't see it now, resize glxgears window or add more glxinfos.
Note: you need at least 2 CPUs.

Usually the error looks like this (with a bit improved logging):
nouveau E[   PFIFO][:02:00.0] CACHE_ERROR - ch 6 [glxgears[15559]] subc 0 
mthd 0x0060 data 0x800f c1p0 0x2010 HASH_FAILED (unknown bits 
0x2000) c1_hash 0x0436

What I found so far:
1) It's triggered by setting of NV11_SUBCHAN_DMA_SEMAPHORE to NvSema
   (0x800f) in nv84_fence_emit. Hw tells us it cannot find ramht entry
   for NvSema object (NV04_PFIFO_CACHE1_PULL0 == HASH_FAILED, frequently
   unknown 30th bit is set)
2) In 95% cases CACHE_ERRORs are triggered on glxgears channel.
3) RAMHT entry was definitely created and used many times before reporting
   an error. Next use of NvSema usually does NOT trigger another CACHE_ERROR.
4) NV04_PFIFO_CACHE1_HASH has the same value as was written to ramht.
5) I can replace glxinfo loops with application which creates and destroys
   PGRAPH objects. PCRYPT, PMPEG and SW objects do NOT provoke this bug.
   (program attached)
6) There are no interrupts between CACHE_ERRORs, so it's not caused by race in
   cache_error/software method handling.

Any ideas how to debug it?

Marcin


test_objects.tar.gz
Description: Binary data
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] libdrm_nouveau.pc: don't include I${includedir}/nouveau

2012-12-20 Thread Marcin Slusarz
Nouveau related headers are installed in I${includedir}/libdrm now.
---
 nouveau/libdrm_nouveau.pc.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nouveau/libdrm_nouveau.pc.in b/nouveau/libdrm_nouveau.pc.in
index 6170613..454fc87 100644
--- a/nouveau/libdrm_nouveau.pc.in
+++ b/nouveau/libdrm_nouveau.pc.in
@@ -7,5 +7,5 @@ Name: libdrm_nouveau
 Description: Userspace interface to nouveau kernel DRM services
 Version: 2.4.33
 Libs: -L${libdir} -ldrm_nouveau
-Cflags: -I${includedir} -I${includedir}/libdrm -I${includedir}/nouveau
+Cflags: -I${includedir} -I${includedir}/libdrm
 Requires.private: libdrm
-- 
1.8.0.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [RFC PATCH] drm/nouveau: report channel owner in error messages

2012-12-10 Thread Marcin Slusarz
On Mon, Dec 10, 2012 at 06:47:41PM +1000, Ben Skeggs wrote:
 On Sun, Dec 09, 2012 at 12:04:54PM +0100, Marcin Slusarz wrote:
  On Sun, Dec 09, 2012 at 02:48:49PM +1000, Ben Skeggs wrote:
  diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c 
  b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
  index 487cb8c..d1120fc 100644
  --- a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
  +++ b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
  @@ -22,8 +22,13 @@
* Authors: Ben Skeggs
*/
   
  -#include core/object.h
  +#include core/client.h
   #include core/enum.h
  +#include core/engctx.h
  +#include core/object.h
  +
  +#include engine/fifo.h
  +#include engine/graph.h
   
   #include subdev/fb.h
   #include subdev/bios.h
  @@ -317,6 +322,19 @@ static const struct nouveau_enum vm_engine[] = 
  {
  {}
   };
   
  +static const struct nouveau_engine_map {
  +   u32 value;
  +   int engines[3];
  +} nvdev_engine_for_vm_engine[] = {
  +   { 0x, {NVDEV_ENGINE_GR, 0} },
  +   { 0x0001, {NVDEV_ENGINE_VP, 0} },
  +   { 0x0005, {NVDEV_ENGINE_FIFO, 0} },
  +   { 0x0008, {NVDEV_ENGINE_PPP, NVDEV_ENGINE_MPEG, 0} },
 I think it may actually be a good idea to go (in core/device.h):
 
   NVDEV_ENGINE_MPEG,
 + NVDEV_ENGINE_PPP = NVDEV_ENGINE_MPEG,
   NVDEV_ENGINE_ME,
 
 PPP got introduced when MPEG disappeared.  There's likely a few other
 engines we can create as aliases for each other too.  What do you 
 think?

I'm not sure it's such a good idea. Suddenly 
nouveau_engctx_get(NVDEV_ENGINE_PPP, chan)
can return nouveau_mpeg_chan and device-subdev[NVDEV_ENGINE_PPP] can 
point
to nouveau_mpeg, etc. So in generic code you can't rely on 
device-subdev[X]
being NULL on cards which don't have X engine...
   This is true for non-engine subdevs, yes.  But, the engines themselves
   should *never* *ever* be accessed from anything other than the object
   interface, from which it's impossible for a mix-up to happen.
  
  what does this code (in this patch) do then? For me, it does exactly what 
  you
  want to be forbidden.
 I probably wasn't very clear on what I meant, sorry about that.  What I
 meant is that there should never be any need to access anything specific
 to a certain engine type from code that doesn't belong to that engine,
 *except* for what's exposed by the object interface.

 So, accessing the nouveau_object/subdev/engine data is OK, accessing the
 nouveau_graph/copy/whatever should only be done by that module.

Thanks, I see your point now (and I agree it's valuable goal).

 Really,
 I should probably consider moving all the relevant structure definitions
 to a priv.h within the engine modules themselves.
 
  
  What are we going to do when we'll need to look up something in engine 
  specific
  data (e.g. nouveau_mpeg) to improve error reporting? We'll be screwed if
  NVDEV_ENGINE_PPP == NVDEV_ENGINE_MPEG.
 What will we possibly need to do here?  The error data we get is
 signalled via an interrupt directly to the specific module, which will
 indeed be able to access its own private information.

Here, interrupts triggered by various engines are delivered to fb subdev, so
if we'll ever need to e.g. dump registers related to one of those engines
(or look up something in all contexts of said engine, or...), it will be much
harder. Sure, we can add another function pointer to nouveau_engine (or abuse
one of nouveau_ofuncs ;), but it feels a bit hacky...

For now it's only theoretical problem (we don't need engine specific data here),
but I think it's better to leave it as an option if possible. And I don't see
what can be improved by aliasing PPP to MPEG...

  
   If we do the aliasing this point should probably be documented in the
   enum list, and the nouveau_whatever() accessors removed.
  
  But what's the point of all of this? Removal of one line from above list
  is pretty weak upside when there are so many downsides. Maybe I'm missing
  something obvious...
  

 
 I can handle the aliasing if you like, but feel free :)
 
  +   { 0x0009, {NVDEV_ENGINE_BSP, 0} },
  +   { 0x000a, {NVDEV_ENGINE_CRYPT, 0} },
  +   { 0x000d, {NVDEV_ENGINE_COPY0, NVDEV_ENGINE_COPY1, 0} },
 COPY1 doesn't exist on NV50.  NVC0 has its own VM engine for the
 additional copy engines.

OK.

  +};
  +
   static const struct nouveau_enum vm_fault[] = {
  { 0x, PT_NOT_PRESENT, NULL },
  { 0x0001, PT_TOO_SHORT, NULL },
  @@ -334,8 +352,12 @@ static void
   nv50_fb_intr(struct nouveau_subdev *subdev)
   {
  struct nouveau_device *device = nv_device(subdev);
  +   struct nouveau_engine *engine = NULL;
  struct nv50_fb_priv *priv = (void *)subdev;
  const struct nouveau_enum *en

Re: [Nouveau] [RFC PATCH] drm/nouveau: report channel owner in error messages

2012-12-09 Thread Marcin Slusarz
On Sun, Dec 09, 2012 at 02:48:49PM +1000, Ben Skeggs wrote:
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c 
b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
index 487cb8c..d1120fc 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
@@ -22,8 +22,13 @@
  * Authors: Ben Skeggs
  */
 
-#include core/object.h
+#include core/client.h
 #include core/enum.h
+#include core/engctx.h
+#include core/object.h
+
+#include engine/fifo.h
+#include engine/graph.h
 
 #include subdev/fb.h
 #include subdev/bios.h
@@ -317,6 +322,19 @@ static const struct nouveau_enum vm_engine[] = {
{}
 };
 
+static const struct nouveau_engine_map {
+   u32 value;
+   int engines[3];
+} nvdev_engine_for_vm_engine[] = {
+   { 0x, {NVDEV_ENGINE_GR, 0} },
+   { 0x0001, {NVDEV_ENGINE_VP, 0} },
+   { 0x0005, {NVDEV_ENGINE_FIFO, 0} },
+   { 0x0008, {NVDEV_ENGINE_PPP, NVDEV_ENGINE_MPEG, 0} },
   I think it may actually be a good idea to go (in core/device.h):
   
 NVDEV_ENGINE_MPEG,
   + NVDEV_ENGINE_PPP = NVDEV_ENGINE_MPEG,
 NVDEV_ENGINE_ME,
   
   PPP got introduced when MPEG disappeared.  There's likely a few other
   engines we can create as aliases for each other too.  What do you think?
  
  I'm not sure it's such a good idea. Suddenly 
  nouveau_engctx_get(NVDEV_ENGINE_PPP, chan)
  can return nouveau_mpeg_chan and device-subdev[NVDEV_ENGINE_PPP] can point
  to nouveau_mpeg, etc. So in generic code you can't rely on device-subdev[X]
  being NULL on cards which don't have X engine...
 This is true for non-engine subdevs, yes.  But, the engines themselves
 should *never* *ever* be accessed from anything other than the object
 interface, from which it's impossible for a mix-up to happen.

what does this code (in this patch) do then? For me, it does exactly what you
want to be forbidden.

What are we going to do when we'll need to look up something in engine specific
data (e.g. nouveau_mpeg) to improve error reporting? We'll be screwed if
NVDEV_ENGINE_PPP == NVDEV_ENGINE_MPEG.

 If we do the aliasing this point should probably be documented in the
 enum list, and the nouveau_whatever() accessors removed.

But what's the point of all of this? Removal of one line from above list
is pretty weak upside when there are so many downsides. Maybe I'm missing
something obvious...

  
   
   I can handle the aliasing if you like, but feel free :)
   
+   { 0x0009, {NVDEV_ENGINE_BSP, 0} },
+   { 0x000a, {NVDEV_ENGINE_CRYPT, 0} },
+   { 0x000d, {NVDEV_ENGINE_COPY0, NVDEV_ENGINE_COPY1, 0} },
   COPY1 doesn't exist on NV50.  NVC0 has its own VM engine for the
   additional copy engines.
  
  OK.
  
+};
+
 static const struct nouveau_enum vm_fault[] = {
{ 0x, PT_NOT_PRESENT, NULL },
{ 0x0001, PT_TOO_SHORT, NULL },
@@ -334,8 +352,12 @@ static void
 nv50_fb_intr(struct nouveau_subdev *subdev)
 {
struct nouveau_device *device = nv_device(subdev);
+   struct nouveau_engine *engine = NULL;
struct nv50_fb_priv *priv = (void *)subdev;
const struct nouveau_enum *en, *cl;
+   struct nouveau_object *engctx = NULL;
+   const int *poss_engines = NULL;
+   const char *client_name = unk;
u32 trap[6], idx, chan;
u8 st0, st1, st2, st3;
int i;
@@ -366,9 +388,34 @@ nv50_fb_intr(struct nouveau_subdev *subdev)
}
chan = (trap[2]  16) | trap[1];
 
-   nv_error(priv, trapped %s at 0x%02x%04x%04x on channel 0x%08x 
,
+   for (i = 0; i  ARRAY_SIZE(nvdev_engine_for_vm_engine); ++i) {
+   if (nvdev_engine_for_vm_engine[i].value == st0) {
+   poss_engines = 
nvdev_engine_for_vm_engine[i].engines;
+   break;
+   }
+   }
+
+   for (i = 0; poss_engines  poss_engines[i]; ++i) {
+   engine = nv_engine(device-subdev[poss_engines[i]]);
   engine = nouveau_engine(device, poss_engines[i]);
  
  OK.
  
   Perhaps you can even append another field to nouveau_enum to store the
   subdev index in too, rather than having to look it up?
  
  Good idea. Thanks.
  
+   if (engine) {
+   engctx = nouveau_engctx_get(engine, chan);
+   if (engctx)
+   break;
+   }
+   }
+
+   if (engctx) {
+   struct nouveau_client *client = nouveau_client(engctx);
+   if (client)
+   client_name = client-name;
+   }
+
+   nv_error(priv, trapped %s at 0x%02x%04x%04x on channel 0x%08x 
[%s] ,
  

[Nouveau] [PATCH 1/4] drm/nouveau: split fifo interrupt handler

2012-12-09 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c | 174 
 1 file changed, 88 insertions(+), 86 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
index 2fe14da3..76944c4 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
@@ -398,6 +398,92 @@ out:
return handled;
 }
 
+static void
+nv04_fifo_cache_error(struct nouveau_device *device,
+   struct nv04_fifo_priv *priv, u32 chid, u32 get)
+{
+   u32 mthd, data;
+   int ptr;
+
+   /* NV_PFIFO_CACHE1_GET actually goes to 0xffc before wrapping on my
+* G80 chips, but CACHE1 isn't big enough for this much data.. Tests
+* show that it wraps around to the start at GET=0x800.. No clue as to
+* why..
+*/
+   ptr = (get  0x7ff)  2;
+
+   if (device-card_type  NV_40) {
+   mthd = nv_rd32(priv, NV04_PFIFO_CACHE1_METHOD(ptr));
+   data = nv_rd32(priv, NV04_PFIFO_CACHE1_DATA(ptr));
+   } else {
+   mthd = nv_rd32(priv, NV40_PFIFO_CACHE1_METHOD(ptr));
+   data = nv_rd32(priv, NV40_PFIFO_CACHE1_DATA(ptr));
+   }
+
+   if (!nv04_fifo_swmthd(priv, chid, mthd, data)) {
+   nv_error(priv,
+CACHE_ERROR - Ch %d/%d Mthd 0x%04x Data 0x%08x\n,
+chid, (mthd  13)  7, mthd  0x1ffc, data);
+   }
+
+   nv_wr32(priv, NV04_PFIFO_CACHE1_DMA_PUSH, 0);
+   nv_wr32(priv, NV03_PFIFO_INTR_0, NV_PFIFO_INTR_CACHE_ERROR);
+
+   nv_wr32(priv, NV03_PFIFO_CACHE1_PUSH0,
+   nv_rd32(priv, NV03_PFIFO_CACHE1_PUSH0)  ~1);
+   nv_wr32(priv, NV03_PFIFO_CACHE1_GET, get + 4);
+   nv_wr32(priv, NV03_PFIFO_CACHE1_PUSH0,
+   nv_rd32(priv, NV03_PFIFO_CACHE1_PUSH0) | 1);
+   nv_wr32(priv, NV04_PFIFO_CACHE1_HASH, 0);
+
+   nv_wr32(priv, NV04_PFIFO_CACHE1_DMA_PUSH,
+   nv_rd32(priv, NV04_PFIFO_CACHE1_DMA_PUSH) | 1);
+   nv_wr32(priv, NV04_PFIFO_CACHE1_PULL0, 1);
+}
+
+static void
+nv04_fifo_dma_pusher(struct nouveau_device *device, struct nv04_fifo_priv 
*priv,
+   u32 chid)
+{
+   u32 dma_get = nv_rd32(priv, 0x003244);
+   u32 dma_put = nv_rd32(priv, 0x003240);
+   u32 push = nv_rd32(priv, 0x003220);
+   u32 state = nv_rd32(priv, 0x003228);
+
+   if (device-card_type == NV_50) {
+   u32 ho_get = nv_rd32(priv, 0x003328);
+   u32 ho_put = nv_rd32(priv, 0x003320);
+   u32 ib_get = nv_rd32(priv, 0x003334);
+   u32 ib_put = nv_rd32(priv, 0x003330);
+
+   nv_error(priv,
+DMA_PUSHER - Ch %d Get 0x%02x%08x Put 0x%02x%08x 
IbGet 0x%08x IbPut 0x%08x State 0x%08x (err: %s) Push 0x%08x\n,
+chid, ho_get, dma_get, ho_put, dma_put, ib_get, ib_put,
+state, nv_dma_state_err(state), push);
+
+   /* METHOD_COUNT, in DMA_STATE on earlier chipsets */
+   nv_wr32(priv, 0x003364, 0x);
+   if (dma_get != dma_put || ho_get != ho_put) {
+   nv_wr32(priv, 0x003244, dma_put);
+   nv_wr32(priv, 0x003328, ho_put);
+   } else
+   if (ib_get != ib_put)
+   nv_wr32(priv, 0x003334, ib_put);
+   } else {
+   nv_error(priv,
+DMA_PUSHER - Ch %d Get 0x%08x Put 0x%08x State 0x%08x 
(err: %s) Push 0x%08x\n,
+chid, dma_get, dma_put, state, nv_dma_state_err(state),
+push);
+
+   if (dma_get != dma_put)
+   nv_wr32(priv, 0x003244, dma_put);
+   }
+
+   nv_wr32(priv, 0x003228, 0x);
+   nv_wr32(priv, 0x003220, 0x0001);
+   nv_wr32(priv, 0x002100, NV_PFIFO_INTR_DMA_PUSHER);
+}
+
 void
 nv04_fifo_intr(struct nouveau_subdev *subdev)
 {
@@ -416,96 +502,12 @@ nv04_fifo_intr(struct nouveau_subdev *subdev)
get  = nv_rd32(priv, NV03_PFIFO_CACHE1_GET);
 
if (status  NV_PFIFO_INTR_CACHE_ERROR) {
-   uint32_t mthd, data;
-   int ptr;
-
-   /* NV_PFIFO_CACHE1_GET actually goes to 0xffc before
-* wrapping on my G80 chips, but CACHE1 isn't big
-* enough for this much data.. Tests show that it
-* wraps around to the start at GET=0x800.. No clue
-* as to why..
-*/
-   ptr = (get  0x7ff)  2;
-
-   if (device-card_type  NV_40) {
-   mthd = nv_rd32(priv,
-   NV04_PFIFO_CACHE1_METHOD(ptr));
-   data = nv_rd32(priv

[Nouveau] [PATCH 2/4] drm/nouveau: use pr_cont

2012-12-09 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/enum.c |  8 
 drivers/gpu/drm/nouveau/core/engine/copy/nva3.c  |  2 +-
 drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c |  2 +-
 drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c |  2 +-
 drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c  | 10 +-
 drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c  | 10 +-
 drivers/gpu/drm/nouveau/core/engine/graph/nv04.c |  6 +++---
 drivers/gpu/drm/nouveau/core/engine/graph/nv10.c |  6 +++---
 drivers/gpu/drm/nouveau/core/engine/graph/nv20.c |  6 +++---
 drivers/gpu/drm/nouveau/core/engine/graph/nv40.c |  6 +++---
 drivers/gpu/drm/nouveau/core/engine/graph/nv50.c | 14 +++---
 drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c |  2 +-
 drivers/gpu/drm/nouveau/core/engine/graph/nve0.c |  2 +-
 drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c| 18 +-
 drivers/gpu/drm/nouveau/core/subdev/mxm/mxms.c   |  8 
 drivers/gpu/drm/nouveau/nouveau_bios.c   |  4 ++--
 16 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/enum.c 
b/drivers/gpu/drm/nouveau/core/core/enum.c
index 7cc7133..148f91f 100644
--- a/drivers/gpu/drm/nouveau/core/core/enum.c
+++ b/drivers/gpu/drm/nouveau/core/core/enum.c
@@ -45,9 +45,9 @@ nouveau_enum_print(const struct nouveau_enum *en, u32 value)
 {
en = nouveau_enum_find(en, value);
if (en)
-   printk(%s, en-name);
+   pr_cont(%s, en-name);
else
-   printk((unknown enum 0x%08x), value);
+   pr_cont((unknown enum 0x%08x), value);
 }
 
 void
@@ -55,7 +55,7 @@ nouveau_bitfield_print(const struct nouveau_bitfield *bf, u32 
value)
 {
while (bf-name) {
if (value  bf-mask) {
-   printk( %s, bf-name);
+   pr_cont( %s, bf-name);
value = ~bf-mask;
}
 
@@ -63,5 +63,5 @@ nouveau_bitfield_print(const struct nouveau_bitfield *bf, u32 
value)
}
 
if (value)
-   printk( (unknown bits 0x%08x), value);
+   pr_cont( (unknown bits 0x%08x), value);
 }
diff --git a/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c 
b/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
index 283248c..6068f5f 100644
--- a/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
+++ b/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
@@ -100,7 +100,7 @@ nva3_copy_intr(struct nouveau_subdev *subdev)
if (stat  0x0040) {
nv_error(falcon, DISPATCH_ERROR [);
nouveau_enum_print(nva3_copy_isr_error_name, ssta);
-   printk(] ch %d [0x%010llx] subc %d mthd 0x%04x data 0x%08x\n,
+   pr_cont(] ch %d [0x%010llx] subc %d mthd 0x%04x data 0x%08x\n,
   chid, inst  12, subc, mthd, data);
nv_wo32(falcon, 0x004, 0x0040);
stat = ~0x0040;
diff --git a/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c 
b/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
index b974905..8d0a440 100644
--- a/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
+++ b/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
@@ -128,7 +128,7 @@ nv84_crypt_intr(struct nouveau_subdev *subdev)
if (stat) {
nv_error(priv, );
nouveau_bitfield_print(nv84_crypt_intr_mask, stat);
-   printk( ch %d [0x%010llx] mthd 0x%04x data 0x%08x\n,
+   pr_cont( ch %d [0x%010llx] mthd 0x%04x data 0x%08x\n,
   chid, (u64)inst  12, mthd, data);
}
 
diff --git a/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c 
b/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
index 21986f3..1b33c20 100644
--- a/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
+++ b/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
@@ -102,7 +102,7 @@ nv98_crypt_intr(struct nouveau_subdev *subdev)
if (stat  0x0040) {
nv_error(priv, DISPATCH_ERROR [);
nouveau_enum_print(nv98_crypt_isr_error_name, ssta);
-   printk(] ch %d [0x%010llx] subc %d mthd 0x%04x data 0x%08x\n,
+   pr_cont(] ch %d [0x%010llx] subc %d mthd 0x%04x data 0x%08x\n,
   chid, (u64)inst  12, subc, mthd, data);
nv_wr32(priv, 0x087004, 0x0040);
stat = ~0x0040;
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c
index ec60bc1..151706b 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c
@@ -421,16 +421,16 @@ nvc0_fifo_isr_vm_fault(struct nvc0_fifo_priv *priv, int 
unit)
nv_error(priv, %s fault at 0x%010llx [, (stat  0x0080) ?
 write : read, (u64)vahi  32 | valo);
nouveau_enum_print(nvc0_fifo_fault_reason, stat  0x000f);
-   printk(] from

[Nouveau] [PATCH 3/4] drm/nouveau: prepare for reporting channel owner

2012-12-09 Thread Marcin Slusarz
- record channel owner process name
- add some helpers for accessing this information
- let nouveau_enum hold additional value (will be needed in the next patch)

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/client.c | 10 ++
 drivers/gpu/drm/nouveau/core/core/enum.c   |  3 ++-
 drivers/gpu/drm/nouveau/core/engine/fifo/base.c| 15 +++
 drivers/gpu/drm/nouveau/core/include/core/client.h |  3 ++-
 drivers/gpu/drm/nouveau/core/include/core/enum.h   |  3 ++-
 drivers/gpu/drm/nouveau/core/include/engine/fifo.h |  2 ++
 drivers/gpu/drm/nouveau/nouveau_drm.c  |  5 +++--
 7 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/client.c 
b/drivers/gpu/drm/nouveau/core/core/client.c
index c617f04..0d15696 100644
--- a/drivers/gpu/drm/nouveau/core/core/client.c
+++ b/drivers/gpu/drm/nouveau/core/core/client.c
@@ -101,3 +101,13 @@ nouveau_client_fini(struct nouveau_client *client, bool 
suspend)
nv_debug(client, %s completed with %d\n, name[suspend], ret);
return ret;
 }
+
+const char *
+nouveau_client_name(void *obj)
+{
+   const char *client_name = unk;
+   struct nouveau_client *client = nouveau_client(obj);
+   if (client)
+   client_name = client-name;
+   return client_name;
+}
diff --git a/drivers/gpu/drm/nouveau/core/core/enum.c 
b/drivers/gpu/drm/nouveau/core/core/enum.c
index 148f91f..dd43479 100644
--- a/drivers/gpu/drm/nouveau/core/core/enum.c
+++ b/drivers/gpu/drm/nouveau/core/core/enum.c
@@ -40,7 +40,7 @@ nouveau_enum_find(const struct nouveau_enum *en, u32 value)
return NULL;
 }
 
-void
+const struct nouveau_enum *
 nouveau_enum_print(const struct nouveau_enum *en, u32 value)
 {
en = nouveau_enum_find(en, value);
@@ -48,6 +48,7 @@ nouveau_enum_print(const struct nouveau_enum *en, u32 value)
pr_cont(%s, en-name);
else
pr_cont((unknown enum 0x%08x), value);
+   return en;
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/base.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/base.c
index a7f41f8..6ea18e4 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/base.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/base.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 
+#include core/client.h
 #include core/object.h
 #include core/handle.h
 #include core/class.h
@@ -146,6 +147,20 @@ nouveau_fifo_chid(struct nouveau_fifo *priv, struct 
nouveau_object *object)
return -1;
 }
 
+const char *
+nouveau_client_name_for_fifo_chid(struct nouveau_fifo *fifo, u32 chid)
+{
+   struct nouveau_fifo_chan *chan = NULL;
+   unsigned long flags;
+
+   spin_lock_irqsave(fifo-lock, flags);
+   if (chid = fifo-min  chid = fifo-max)
+   chan = (void *)fifo-channel[chid];
+   spin_unlock_irqrestore(fifo-lock, flags);
+
+   return nouveau_client_name(chan);
+}
+
 void
 nouveau_fifo_destroy(struct nouveau_fifo *priv)
 {
diff --git a/drivers/gpu/drm/nouveau/core/include/core/client.h 
b/drivers/gpu/drm/nouveau/core/include/core/client.h
index 0193532..b8d0457 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/client.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/client.h
@@ -7,7 +7,7 @@ struct nouveau_client {
struct nouveau_namedb base;
struct nouveau_handle *root;
struct nouveau_object *device;
-   char name[16];
+   char name[32];
u32 debug;
struct nouveau_vm *vm;
 };
@@ -38,5 +38,6 @@ int  nouveau_client_create_(const char *name, u64 device, 
const char *cfg,
const char *dbg, int, void **);
 int  nouveau_client_init(struct nouveau_client *);
 int  nouveau_client_fini(struct nouveau_client *, bool suspend);
+const char *nouveau_client_name(void *obj);
 
 #endif
diff --git a/drivers/gpu/drm/nouveau/core/include/core/enum.h 
b/drivers/gpu/drm/nouveau/core/include/core/enum.h
index e7b1e18..4fc62bb 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/enum.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/enum.h
@@ -5,12 +5,13 @@ struct nouveau_enum {
u32 value;
const char *name;
const void *data;
+   u32 data2;
 };
 
 const struct nouveau_enum *
 nouveau_enum_find(const struct nouveau_enum *, u32 value);
 
-void
+const struct nouveau_enum *
 nouveau_enum_print(const struct nouveau_enum *en, u32 value);
 
 struct nouveau_bitfield {
diff --git a/drivers/gpu/drm/nouveau/core/include/engine/fifo.h 
b/drivers/gpu/drm/nouveau/core/include/engine/fifo.h
index 039bd19..f4f4149 100644
--- a/drivers/gpu/drm/nouveau/core/include/engine/fifo.h
+++ b/drivers/gpu/drm/nouveau/core/include/engine/fifo.h
@@ -92,6 +92,8 @@ int nouveau_fifo_create_(struct nouveau_object *, struct 
nouveau_object *,
 struct nouveau_oclass *, int min, int max,
 int size, void **);
 void nouveau_fifo_destroy(struct

[Nouveau] [PATCHv2 4/4] drm/nouveau: report channel owner in error messages

2012-12-09 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/engine/copy/nva3.c  |  6 ++--
 drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c |  6 ++--
 drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c |  6 ++--
 drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c  | 22 +++-
 drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c  |  3 +-
 drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c  |  3 +-
 drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c  | 42 +++---
 drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c  | 29 +++
 drivers/gpu/drm/nouveau/core/engine/graph/nv04.c |  8 +++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv10.c |  8 +++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv20.c |  7 ++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv40.c |  8 +++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv50.c | 34 +-
 drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c | 24 +++--
 drivers/gpu/drm/nouveau/core/engine/graph/nve0.c | 44 ---
 drivers/gpu/drm/nouveau/core/engine/mpeg/nv31.c  |  7 ++--
 drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c| 45 ++--
 drivers/gpu/drm/nouveau/nouveau_chan.c   |  3 +-
 18 files changed, 198 insertions(+), 107 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c 
b/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
index 6068f5f..d6dc2a6 100644
--- a/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
+++ b/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 
+#include core/client.h
 #include core/falcon.h
 #include core/class.h
 #include core/enum.h
@@ -100,8 +101,9 @@ nva3_copy_intr(struct nouveau_subdev *subdev)
if (stat  0x0040) {
nv_error(falcon, DISPATCH_ERROR [);
nouveau_enum_print(nva3_copy_isr_error_name, ssta);
-   pr_cont(] ch %d [0x%010llx] subc %d mthd 0x%04x data 0x%08x\n,
-  chid, inst  12, subc, mthd, data);
+   pr_cont(] ch %d [0x%010llx %s] subc %d mthd 0x%04x data 
0x%08x\n,
+  chid, inst  12, nouveau_client_name(engctx), subc,
+  mthd, data);
nv_wo32(falcon, 0x004, 0x0040);
stat = ~0x0040;
}
diff --git a/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c 
b/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
index 8d0a440..f431759 100644
--- a/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
+++ b/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 
+#include core/client.h
 #include core/os.h
 #include core/enum.h
 #include core/class.h
@@ -128,8 +129,9 @@ nv84_crypt_intr(struct nouveau_subdev *subdev)
if (stat) {
nv_error(priv, );
nouveau_bitfield_print(nv84_crypt_intr_mask, stat);
-   pr_cont( ch %d [0x%010llx] mthd 0x%04x data 0x%08x\n,
-  chid, (u64)inst  12, mthd, data);
+   pr_cont( ch %d [0x%010llx %s] mthd 0x%04x data 0x%08x\n,
+  chid, (u64)inst  12, nouveau_client_name(engctx),
+  mthd, data);
}
 
nv_wr32(priv, 0x102130, stat);
diff --git a/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c 
b/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
index 1b33c20..8bf8955 100644
--- a/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
+++ b/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 
+#include core/client.h
 #include core/os.h
 #include core/enum.h
 #include core/class.h
@@ -102,8 +103,9 @@ nv98_crypt_intr(struct nouveau_subdev *subdev)
if (stat  0x0040) {
nv_error(priv, DISPATCH_ERROR [);
nouveau_enum_print(nv98_crypt_isr_error_name, ssta);
-   pr_cont(] ch %d [0x%010llx] subc %d mthd 0x%04x data 0x%08x\n,
-  chid, (u64)inst  12, subc, mthd, data);
+   pr_cont(] ch %d [0x%010llx %s] subc %d mthd 0x%04x data 
0x%08x\n,
+  chid, (u64)inst  12, nouveau_client_name(engctx),
+  subc, mthd, data);
nv_wr32(priv, 0x087004, 0x0040);
stat = ~0x0040;
}
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
index 76944c4..874fa9a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
@@ -421,9 +421,12 @@ nv04_fifo_cache_error(struct nouveau_device *device,
}
 
if (!nv04_fifo_swmthd(priv, chid, mthd, data)) {
+   const char *client_name =
+   nouveau_client_name_for_fifo_chid(priv-base, chid);
nv_error(priv,
-CACHE_ERROR - Ch %d/%d Mthd 0x%04x Data 0x%08x\n,
-chid, (mthd  13)  7, mthd  0x1ffc

[Nouveau] [PATCHv3 4/4] drm/nouveau: report channel owner in error messages

2012-12-09 Thread Marcin Slusarz

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---

v2: finish, fixes after initial review
v3: fix reporting of vm_engine when client already went away

---
 drivers/gpu/drm/nouveau/core/engine/copy/nva3.c  |  6 ++--
 drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c |  6 ++--
 drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c |  6 ++--
 drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c  | 22 +++-
 drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c  |  3 +-
 drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c  |  3 +-
 drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c  | 42 +++---
 drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c  | 29 +++
 drivers/gpu/drm/nouveau/core/engine/graph/nv04.c |  8 +++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv10.c |  8 +++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv20.c |  7 ++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv40.c |  8 +++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv50.c | 34 +-
 drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c | 24 +++--
 drivers/gpu/drm/nouveau/core/engine/graph/nve0.c | 44 ---
 drivers/gpu/drm/nouveau/core/engine/mpeg/nv31.c  |  7 ++--
 drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c| 46 ++--
 drivers/gpu/drm/nouveau/nouveau_chan.c   |  3 +-
 18 files changed, 199 insertions(+), 107 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c 
b/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
index 6068f5f..d6dc2a6 100644
--- a/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
+++ b/drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 
+#include core/client.h
 #include core/falcon.h
 #include core/class.h
 #include core/enum.h
@@ -100,8 +101,9 @@ nva3_copy_intr(struct nouveau_subdev *subdev)
if (stat  0x0040) {
nv_error(falcon, DISPATCH_ERROR [);
nouveau_enum_print(nva3_copy_isr_error_name, ssta);
-   pr_cont(] ch %d [0x%010llx] subc %d mthd 0x%04x data 0x%08x\n,
-  chid, inst  12, subc, mthd, data);
+   pr_cont(] ch %d [0x%010llx %s] subc %d mthd 0x%04x data 
0x%08x\n,
+  chid, inst  12, nouveau_client_name(engctx), subc,
+  mthd, data);
nv_wo32(falcon, 0x004, 0x0040);
stat = ~0x0040;
}
diff --git a/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c 
b/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
index 8d0a440..f431759 100644
--- a/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
+++ b/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 
+#include core/client.h
 #include core/os.h
 #include core/enum.h
 #include core/class.h
@@ -128,8 +129,9 @@ nv84_crypt_intr(struct nouveau_subdev *subdev)
if (stat) {
nv_error(priv, );
nouveau_bitfield_print(nv84_crypt_intr_mask, stat);
-   pr_cont( ch %d [0x%010llx] mthd 0x%04x data 0x%08x\n,
-  chid, (u64)inst  12, mthd, data);
+   pr_cont( ch %d [0x%010llx %s] mthd 0x%04x data 0x%08x\n,
+  chid, (u64)inst  12, nouveau_client_name(engctx),
+  mthd, data);
}
 
nv_wr32(priv, 0x102130, stat);
diff --git a/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c 
b/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
index 1b33c20..8bf8955 100644
--- a/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
+++ b/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 
+#include core/client.h
 #include core/os.h
 #include core/enum.h
 #include core/class.h
@@ -102,8 +103,9 @@ nv98_crypt_intr(struct nouveau_subdev *subdev)
if (stat  0x0040) {
nv_error(priv, DISPATCH_ERROR [);
nouveau_enum_print(nv98_crypt_isr_error_name, ssta);
-   pr_cont(] ch %d [0x%010llx] subc %d mthd 0x%04x data 0x%08x\n,
-  chid, (u64)inst  12, subc, mthd, data);
+   pr_cont(] ch %d [0x%010llx %s] subc %d mthd 0x%04x data 
0x%08x\n,
+  chid, (u64)inst  12, nouveau_client_name(engctx),
+  subc, mthd, data);
nv_wr32(priv, 0x087004, 0x0040);
stat = ~0x0040;
}
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
index 76944c4..874fa9a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
@@ -421,9 +421,12 @@ nv04_fifo_cache_error(struct nouveau_device *device,
}
 
if (!nv04_fifo_swmthd(priv, chid, mthd, data)) {
+   const char *client_name =
+   nouveau_client_name_for_fifo_chid(priv-base, chid);
nv_error(priv

Re: [Nouveau] [RFC PATCH] drm/nouveau: report channel owner in error messages

2012-12-08 Thread Marcin Slusarz
On Fri, Dec 07, 2012 at 02:46:53PM +1000, Ben Skeggs wrote:
 On Wed, Dec 05, 2012 at 11:56:22PM +0100, Marcin Slusarz wrote:
  Full piglit run with this patch:
  http://people.freedesktop.org/~mslusarz/chan_owners.txt
  
  This patch covers only a small subset of all error messages, so:
  Not-yet-signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
  
  Comments? Ideas?
 Very nice idea.  I'll put a little bit of thought into it, but I think
 it's looking good.  More comments where appropriate inline.

Thanks.

  
  (This commit depends on this one:
  http://people.freedesktop.org/~mslusarz/0001-drm-nouveau-split-fifo-interrupt-handler.patch
   )
  ---
   core/engine/fifo/nv04.c|   43 +---
   core/engine/graph/nv50.c   |   14 +--
   core/include/core/client.h |2 -
   core/subdev/fb/nv50.c  |   53 
  ++---
   nouveau_drm.c  |5 ++--
   5 files changed, 100 insertions(+), 17 deletions(-)
  
  diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c 
  b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
  index 76944c4..f5d4d28 100644
  --- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
  +++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
  @@ -24,6 +24,7 @@
   
   #include core/os.h
   #include core/class.h
  +#include core/client.h
   #include core/engctx.h
   #include core/namedb.h
   #include core/handle.h
  @@ -398,10 +399,29 @@ out:
  return handled;
   }
   
  +static struct nouveau_client *
  +nv04_fifo_client_for_chid(struct nv04_fifo_priv *priv, u32 chid)
  +{
  +   struct nouveau_fifo_chan *chan;
  +   struct nouveau_client *client = NULL;
  +   unsigned long flags;
  +
  +   spin_lock_irqsave(priv-base.lock, flags);
  +   if (chid = priv-base.min 
  +   chid = priv-base.max) {
  +   chan = (void *)priv-base.channel[chid];
  +   client = nouveau_client(chan);
  +   }
  +   spin_unlock_irqrestore(priv-base.lock, flags);
  +
  +   return client;
  +}
  +
   static void
   nv04_fifo_cache_error(struct nouveau_device *device,
  struct nv04_fifo_priv *priv, u32 chid, u32 get)
   {
  +   struct nouveau_client *client;
  u32 mthd, data;
  int ptr;
   
  @@ -421,9 +441,12 @@ nv04_fifo_cache_error(struct nouveau_device *device,
  }
   
  if (!nv04_fifo_swmthd(priv, chid, mthd, data)) {
  +   client = nv04_fifo_client_for_chid(priv, chid);
  +
  nv_error(priv,
  -CACHE_ERROR - Ch %d/%d Mthd 0x%04x Data 0x%08x\n,
  -chid, (mthd  13)  7, mthd  0x1ffc, data);
  +CACHE_ERROR - Ch %d/%d [%s] Mthd 0x%04x Data 
  0x%08x\n,
  +chid, (mthd  13)  7, client ? client-name : unk,
  +mthd  0x1ffc, data);
  }
   
  nv_wr32(priv, NV04_PFIFO_CACHE1_DMA_PUSH, 0);
  @@ -445,11 +468,14 @@ static void
   nv04_fifo_dma_pusher(struct nouveau_device *device, struct nv04_fifo_priv 
  *priv,
  u32 chid)
   {
  +   struct nouveau_client *client;
  u32 dma_get = nv_rd32(priv, 0x003244);
  u32 dma_put = nv_rd32(priv, 0x003240);
  u32 push = nv_rd32(priv, 0x003220);
  u32 state = nv_rd32(priv, 0x003228);
   
  +   client = nv04_fifo_client_for_chid(priv, chid);
  +
  if (device-card_type == NV_50) {
  u32 ho_get = nv_rd32(priv, 0x003328);
  u32 ho_put = nv_rd32(priv, 0x003320);
  @@ -457,9 +483,10 @@ nv04_fifo_dma_pusher(struct nouveau_device *device, 
  struct nv04_fifo_priv *priv,
  u32 ib_put = nv_rd32(priv, 0x003330);
   
  nv_error(priv,
  -DMA_PUSHER - Ch %d Get 0x%02x%08x Put 0x%02x%08x 
  IbGet 0x%08x IbPut 0x%08x State 0x%08x (err: %s) Push 0x%08x\n,
  -chid, ho_get, dma_get, ho_put, dma_put, ib_get, ib_put,
  -state, nv_dma_state_err(state), push);
  +DMA_PUSHER - Ch %d [%s] Get 0x%02x%08x Put 0x%02x%08x 
  IbGet 0x%08x IbPut 0x%08x State 0x%08x (err: %s) Push 0x%08x\n,
  +chid, client ? client-name : unk, ho_get, dma_get,
  +ho_put, dma_put, ib_get, ib_put, state,
  +nv_dma_state_err(state), push);
   
  /* METHOD_COUNT, in DMA_STATE on earlier chipsets */
  nv_wr32(priv, 0x003364, 0x);
  @@ -471,9 +498,9 @@ nv04_fifo_dma_pusher(struct nouveau_device *device, 
  struct nv04_fifo_priv *priv,
  nv_wr32(priv, 0x003334, ib_put);
  } else {
  nv_error(priv,
  -DMA_PUSHER - Ch %d Get 0x%08x Put 0x%08x State 0x%08x 
  (err: %s) Push 0x%08x\n,
  -chid, dma_get, dma_put, state, nv_dma_state_err(state),
  -push);
  +DMA_PUSHER - Ch %d [%s] Get 0x%08x Put 0x%08x State 
  0x%08x (err: %s) Push 0x%08x\n,
  +chid, client ? client-name : unk, dma_get

[Nouveau] [RFC PATCH] drm/nouveau: report channel owner in error messages

2012-12-06 Thread Marcin Slusarz
Full piglit run with this patch:
http://people.freedesktop.org/~mslusarz/chan_owners.txt

This patch covers only a small subset of all error messages, so:
Not-yet-signed-off-by: Marcin Slusarz marcin.slus...@gmail.com

Comments? Ideas?

(This commit depends on this one:
http://people.freedesktop.org/~mslusarz/0001-drm-nouveau-split-fifo-interrupt-handler.patch
 )
---
 core/engine/fifo/nv04.c|   43 +---
 core/engine/graph/nv50.c   |   14 +--
 core/include/core/client.h |2 -
 core/subdev/fb/nv50.c  |   53 ++---
 nouveau_drm.c  |5 ++--
 5 files changed, 100 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
index 76944c4..f5d4d28 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
@@ -24,6 +24,7 @@
 
 #include core/os.h
 #include core/class.h
+#include core/client.h
 #include core/engctx.h
 #include core/namedb.h
 #include core/handle.h
@@ -398,10 +399,29 @@ out:
return handled;
 }
 
+static struct nouveau_client *
+nv04_fifo_client_for_chid(struct nv04_fifo_priv *priv, u32 chid)
+{
+   struct nouveau_fifo_chan *chan;
+   struct nouveau_client *client = NULL;
+   unsigned long flags;
+
+   spin_lock_irqsave(priv-base.lock, flags);
+   if (chid = priv-base.min 
+   chid = priv-base.max) {
+   chan = (void *)priv-base.channel[chid];
+   client = nouveau_client(chan);
+   }
+   spin_unlock_irqrestore(priv-base.lock, flags);
+
+   return client;
+}
+
 static void
 nv04_fifo_cache_error(struct nouveau_device *device,
struct nv04_fifo_priv *priv, u32 chid, u32 get)
 {
+   struct nouveau_client *client;
u32 mthd, data;
int ptr;
 
@@ -421,9 +441,12 @@ nv04_fifo_cache_error(struct nouveau_device *device,
}
 
if (!nv04_fifo_swmthd(priv, chid, mthd, data)) {
+   client = nv04_fifo_client_for_chid(priv, chid);
+
nv_error(priv,
-CACHE_ERROR - Ch %d/%d Mthd 0x%04x Data 0x%08x\n,
-chid, (mthd  13)  7, mthd  0x1ffc, data);
+CACHE_ERROR - Ch %d/%d [%s] Mthd 0x%04x Data 
0x%08x\n,
+chid, (mthd  13)  7, client ? client-name : unk,
+mthd  0x1ffc, data);
}
 
nv_wr32(priv, NV04_PFIFO_CACHE1_DMA_PUSH, 0);
@@ -445,11 +468,14 @@ static void
 nv04_fifo_dma_pusher(struct nouveau_device *device, struct nv04_fifo_priv 
*priv,
u32 chid)
 {
+   struct nouveau_client *client;
u32 dma_get = nv_rd32(priv, 0x003244);
u32 dma_put = nv_rd32(priv, 0x003240);
u32 push = nv_rd32(priv, 0x003220);
u32 state = nv_rd32(priv, 0x003228);
 
+   client = nv04_fifo_client_for_chid(priv, chid);
+
if (device-card_type == NV_50) {
u32 ho_get = nv_rd32(priv, 0x003328);
u32 ho_put = nv_rd32(priv, 0x003320);
@@ -457,9 +483,10 @@ nv04_fifo_dma_pusher(struct nouveau_device *device, struct 
nv04_fifo_priv *priv,
u32 ib_put = nv_rd32(priv, 0x003330);
 
nv_error(priv,
-DMA_PUSHER - Ch %d Get 0x%02x%08x Put 0x%02x%08x 
IbGet 0x%08x IbPut 0x%08x State 0x%08x (err: %s) Push 0x%08x\n,
-chid, ho_get, dma_get, ho_put, dma_put, ib_get, ib_put,
-state, nv_dma_state_err(state), push);
+DMA_PUSHER - Ch %d [%s] Get 0x%02x%08x Put 0x%02x%08x 
IbGet 0x%08x IbPut 0x%08x State 0x%08x (err: %s) Push 0x%08x\n,
+chid, client ? client-name : unk, ho_get, dma_get,
+ho_put, dma_put, ib_get, ib_put, state,
+nv_dma_state_err(state), push);
 
/* METHOD_COUNT, in DMA_STATE on earlier chipsets */
nv_wr32(priv, 0x003364, 0x);
@@ -471,9 +498,9 @@ nv04_fifo_dma_pusher(struct nouveau_device *device, struct 
nv04_fifo_priv *priv,
nv_wr32(priv, 0x003334, ib_put);
} else {
nv_error(priv,
-DMA_PUSHER - Ch %d Get 0x%08x Put 0x%08x State 0x%08x 
(err: %s) Push 0x%08x\n,
-chid, dma_get, dma_put, state, nv_dma_state_err(state),
-push);
+DMA_PUSHER - Ch %d [%s] Get 0x%08x Put 0x%08x State 
0x%08x (err: %s) Push 0x%08x\n,
+chid, client ? client-name : unk, dma_get, dma_put,
+state, nv_dma_state_err(state), push);
 
if (dma_get != dma_put)
nv_wr32(priv, 0x003244, dma_put);
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c 
b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
index

Re: [Nouveau] [PATCH] drm/nouveau: unpin pushbuffer bo before destroying it

2012-12-02 Thread Marcin Slusarz
On Sun, Nov 25, 2012 at 11:02:28PM +0100, Marcin Slusarz wrote:
 Fixes GART leak (as accounted by nouveau_drm.gem.gart_available).
 
 Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
 ---
 
 Running glxinfo in a loop is enough to trigger it - after several thousand
 runs (depending on GART size), X server crashes and does not come back in
 a correct state (corruptions and crashes).
 
 With this patch applied, it's possible again to do full piglit run (with
 concurrency disabled) without crashes or lockups.
 
 ---

Please consider applying this patch for 3.7/3.7.x. This bug is easily
reproducible and has fatal consequences (gpu is unusuable after 1st crash).

  drivers/gpu/drm/nouveau/nouveau_chan.c | 2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c 
 b/drivers/gpu/drm/nouveau/nouveau_chan.c
 index 1363578..174300b 100644
 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c
 +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
 @@ -76,6 +76,8 @@ nouveau_channel_del(struct nouveau_channel **pchan)
   nouveau_object_del(client, NVDRM_DEVICE, chan-push.handle);
   nouveau_bo_vma_del(chan-push.buffer, chan-push.vma);
   nouveau_bo_unmap(chan-push.buffer);
 + if (chan-push.buffer  chan-push.buffer-pin_refcnt)
 + nouveau_bo_unpin(chan-push.buffer);
   nouveau_bo_ref(NULL, chan-push.buffer);
   kfree(chan);
   }
 -- 
 1.7.12
 
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: add locking around instobj list operations

2012-12-02 Thread Marcin Slusarz
Fixes memory corruptions (unrelated to nouveau!), oopses, gpu lockups and
xserver crashes when multiple gpuobjs are simultaneously created / destroyed.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
Piglit, with concurrency enabled, can finally finish without crashes or lockups
(most of the time :).

---
 drivers/gpu/drm/nouveau/core/subdev/instmem/base.c | 35 +-
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c 
b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
index 1188227..6565f3d 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
@@ -40,15 +40,21 @@ nouveau_instobj_create_(struct nouveau_object *parent,
if (ret)
return ret;
 
+   mutex_lock(imem-base.mutex);
list_add(iobj-head, imem-list);
+   mutex_unlock(imem-base.mutex);
return 0;
 }
 
 void
 nouveau_instobj_destroy(struct nouveau_instobj *iobj)
 {
-   if (iobj-head.prev)
-   list_del(iobj-head);
+   struct nouveau_subdev *subdev = nv_subdev(iobj-base.engine);
+
+   mutex_lock(subdev-mutex);
+   list_del(iobj-head);
+   mutex_unlock(subdev-mutex);
+
return nouveau_object_destroy(iobj-base);
 }
 
@@ -88,6 +94,8 @@ nouveau_instmem_init(struct nouveau_instmem *imem)
if (ret)
return ret;
 
+   mutex_lock(imem-base.mutex);
+
list_for_each_entry(iobj, imem-list, head) {
if (iobj-suspend) {
for (i = 0; i  iobj-size; i += 4)
@@ -97,6 +105,8 @@ nouveau_instmem_init(struct nouveau_instmem *imem)
}
}
 
+   mutex_unlock(imem-base.mutex);
+
return 0;
 }
 
@@ -104,17 +114,26 @@ int
 nouveau_instmem_fini(struct nouveau_instmem *imem, bool suspend)
 {
struct nouveau_instobj *iobj;
-   int i;
+   int i, ret = 0;
 
if (suspend) {
+   mutex_lock(imem-base.mutex);
+
list_for_each_entry(iobj, imem-list, head) {
iobj-suspend = vmalloc(iobj-size);
-   if (iobj-suspend) {
-   for (i = 0; i  iobj-size; i += 4)
-   iobj-suspend[i / 4] = nv_ro32(iobj, i);
-   } else
-   return -ENOMEM;
+   if (!iobj-suspend) {
+   ret = -ENOMEM;
+   break;
+   }
+
+   for (i = 0; i  iobj-size; i += 4)
+   iobj-suspend[i / 4] = nv_ro32(iobj, i);
}
+
+   mutex_unlock(imem-base.mutex);
+
+   if (ret)
+   return ret;
}
 
return nouveau_subdev_fini(imem-base, suspend);
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: add locking around instobj list operations

2012-12-02 Thread Marcin Slusarz
On Sun, Dec 02, 2012 at 02:53:01PM +0100, Marcin Slusarz wrote:
 Fixes memory corruptions (unrelated to nouveau!), oopses, gpu lockups and
 xserver crashes when multiple gpuobjs are simultaneously created / destroyed.
 
 Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
 ---
 Piglit, with concurrency enabled, can finally finish without crashes or 
 lockups
 (most of the time :).

It would be awesome to have this in 3.7/3.7.x ;).

 ---
  drivers/gpu/drm/nouveau/core/subdev/instmem/base.c | 35 
 +-
  1 file changed, 27 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c 
 b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
 index 1188227..6565f3d 100644
 --- a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
 +++ b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
 @@ -40,15 +40,21 @@ nouveau_instobj_create_(struct nouveau_object *parent,
   if (ret)
   return ret;
  
 + mutex_lock(imem-base.mutex);
   list_add(iobj-head, imem-list);
 + mutex_unlock(imem-base.mutex);
   return 0;
  }
  
  void
  nouveau_instobj_destroy(struct nouveau_instobj *iobj)
  {
 - if (iobj-head.prev)
 - list_del(iobj-head);
 + struct nouveau_subdev *subdev = nv_subdev(iobj-base.engine);
 +
 + mutex_lock(subdev-mutex);
 + list_del(iobj-head);
 + mutex_unlock(subdev-mutex);
 +
   return nouveau_object_destroy(iobj-base);
  }
  
 @@ -88,6 +94,8 @@ nouveau_instmem_init(struct nouveau_instmem *imem)
   if (ret)
   return ret;
  
 + mutex_lock(imem-base.mutex);
 +
   list_for_each_entry(iobj, imem-list, head) {
   if (iobj-suspend) {
   for (i = 0; i  iobj-size; i += 4)
 @@ -97,6 +105,8 @@ nouveau_instmem_init(struct nouveau_instmem *imem)
   }
   }
  
 + mutex_unlock(imem-base.mutex);
 +
   return 0;
  }
  
 @@ -104,17 +114,26 @@ int
  nouveau_instmem_fini(struct nouveau_instmem *imem, bool suspend)
  {
   struct nouveau_instobj *iobj;
 - int i;
 + int i, ret = 0;
  
   if (suspend) {
 + mutex_lock(imem-base.mutex);
 +
   list_for_each_entry(iobj, imem-list, head) {
   iobj-suspend = vmalloc(iobj-size);
 - if (iobj-suspend) {
 - for (i = 0; i  iobj-size; i += 4)
 - iobj-suspend[i / 4] = nv_ro32(iobj, i);
 - } else
 - return -ENOMEM;
 + if (!iobj-suspend) {
 + ret = -ENOMEM;
 + break;
 + }
 +
 + for (i = 0; i  iobj-size; i += 4)
 + iobj-suspend[i / 4] = nv_ro32(iobj, i);
   }
 +
 + mutex_unlock(imem-base.mutex);
 +
 + if (ret)
 + return ret;
   }
  
   return nouveau_subdev_fini(imem-base, suspend);
 -- 
 1.7.12
 
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] GTX-560 in v3.6

2012-12-01 Thread Marcin Slusarz
On Thu, Nov 29, 2012 at 11:56:54AM +0100, Javier Domingo wrote:
 Hi,
 
 I am running a GTX-560 with nouveau driver, or at least I try to, and
 I dont get it working... I have seen that in the Xorg.log.0 appears
 the chipset family, but I don't know why it isn't working.
 
 I attach the Xorg.log.0 and the dmesg output,

http://nouveau.freedesktop.org/wiki/TroubleShooting#Xorg_fails_to_start_with_.22.28EE.29_.5Bdrm.5D_failed_to_open_device.22
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [ddx PATCH] add some missing newlines in error messages

2012-11-26 Thread Marcin Slusarz

---
 src/drmmode_display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 803785d..4d2d09d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -357,7 +357,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr 
mode,
 
if (ret) {
xf86DrvMsg(crtc-scrn-scrnIndex, X_ERROR,
-  failed to set mode: %s, strerror(-ret));
+  failed to set mode: %s\n, strerror(-ret));
return FALSE;
}
 
@@ -532,7 +532,7 @@ drmmode_gamma_set(xf86CrtcPtr crtc, CARD16 *red, CARD16 
*green, CARD16 *blue,
  size, red, green, blue);
if (ret != 0) {
xf86DrvMsg(crtc-scrn-scrnIndex, X_ERROR,
-  failed to set gamma: %s, strerror(-ret));
+  failed to set gamma: %s\n, strerror(-ret));
}
 }
 
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: raise reporting levels of some messages

2012-11-26 Thread Marcin Slusarz

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c  | 10 +-
 drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c  |  2 +-
 drivers/gpu/drm/nouveau/core/engine/graph/nv20.c |  4 ++--
 drivers/gpu/drm/nouveau/core/engine/graph/nv40.c |  2 +-
 drivers/gpu/drm/nouveau/core/engine/graph/nv50.c |  6 +++---
 drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c |  2 +-
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
index 1147aec..2fe14da3 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv04.c
@@ -440,7 +440,7 @@ nv04_fifo_intr(struct nouveau_subdev *subdev)
}
 
if (!nv04_fifo_swmthd(priv, chid, mthd, data)) {
-   nv_info(priv, CACHE_ERROR - Ch %d/%d 
+   nv_error(priv, CACHE_ERROR - Ch %d/%d 
  Mthd 0x%04x Data 0x%08x\n,
chid, (mthd  13)  7, mthd  0x1ffc,
data);
@@ -476,7 +476,7 @@ nv04_fifo_intr(struct nouveau_subdev *subdev)
u32 ib_get = nv_rd32(priv, 0x003334);
u32 ib_put = nv_rd32(priv, 0x003330);
 
-   nv_info(priv, DMA_PUSHER - Ch %d Get 
0x%02x%08x 
+   nv_error(priv, DMA_PUSHER - Ch %d Get 
0x%02x%08x 
 Put 0x%02x%08x IbGet 0x%08x IbPut 0x%08x 
 State 0x%08x (err: %s) Push 0x%08x\n,
chid, ho_get, dma_get, ho_put,
@@ -494,7 +494,7 @@ nv04_fifo_intr(struct nouveau_subdev *subdev)
nv_wr32(priv, 0x003334, ib_put);
}
} else {
-   nv_info(priv, DMA_PUSHER - Ch %d Get 0x%08x 
+   nv_error(priv, DMA_PUSHER - Ch %d Get 0x%08x 
 Put 0x%08x State 0x%08x (err: %s) 
Push 0x%08x\n,
chid, dma_get, dma_put, state,
nv_dma_state_err(state), push);
@@ -531,7 +531,7 @@ nv04_fifo_intr(struct nouveau_subdev *subdev)
}
 
if (status) {
-   nv_info(priv, unknown intr 0x%08x, ch %d\n,
+   nv_warn(priv, unknown intr 0x%08x, ch %d\n,
status, chid);
nv_wr32(priv, NV03_PFIFO_INTR_0, status);
status = 0;
@@ -541,7 +541,7 @@ nv04_fifo_intr(struct nouveau_subdev *subdev)
}
 
if (status) {
-   nv_info(priv, still angry after %d spins, halt\n, cnt);
+   nv_error(priv, still angry after %d spins, halt\n, cnt);
nv_wr32(priv, 0x002140, 0);
nv_wr32(priv, 0x000140, 0);
}
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c 
b/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c
index d7c3f3e..ec60bc1 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c
@@ -503,7 +503,7 @@ nvc0_fifo_intr(struct nouveau_subdev *subdev)
u32 stat = nv_rd32(priv, 0x002100)  mask;
 
if (stat  0x0100) {
-   nv_info(priv, unknown status 0x0100\n);
+   nv_warn(priv, unknown status 0x0100\n);
nv_wr32(priv, 0x002100, 0x0100);
stat = ~0x0100;
}
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv20.c 
b/drivers/gpu/drm/nouveau/core/engine/graph/nv20.c
index e45eded..5b20401 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv20.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv20.c
@@ -224,14 +224,14 @@ nv20_graph_intr(struct nouveau_subdev *subdev)
nv_wr32(priv, NV04_PGRAPH_FIFO, 0x0001);
 
if (show) {
-   nv_info(priv, );
+   nv_error(priv, );
nouveau_bitfield_print(nv10_graph_intr_name, show);
printk( nsource:);
nouveau_bitfield_print(nv04_graph_nsource, nsource);
printk( nstatus:);
nouveau_bitfield_print(nv10_graph_nstatus, nstatus);
printk(\n);
-   nv_info(priv, ch %d/%d class 0x%04x mthd 0x%04x data 0x%08x\n,
+   nv_error(priv, ch %d/%d class 0x%04x mthd 0x%04x data 
0x%08x\n,
chid, subc, class, mthd, data);
}
 
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c 
b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
index 0052f09..0b36dd3 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
+++ b/drivers

[Nouveau] [PATCH] drm/nouveau: remove misleading comment from nouveau_prime_new

2012-11-26 Thread Marcin Slusarz
Copy/pasted from nouveau_gem_new.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nouveau_prime.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c 
b/drivers/gpu/drm/nouveau/nouveau_prime.c
index 366462c..3543fec 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -155,10 +155,6 @@ nouveau_prime_new(struct drm_device *dev,
return ret;
nvbo = *pnvbo;
 
-   /* we restrict allowed domains on nv50+ to only the types
-* that were requested at creation time.  not possibly on
-* earlier chips without busting the ABI.
-*/
nvbo-valid_domains = NOUVEAU_GEM_DOMAIN_GART;
nvbo-gem = drm_gem_object_alloc(dev, nvbo-bo.mem.size);
if (!nvbo-gem) {
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: unpin pushbuffer bo before destroying it

2012-11-26 Thread Marcin Slusarz
Fixes GART leak (as accounted by nouveau_drm.gem.gart_available).

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---

Running glxinfo in a loop is enough to trigger it - after several thousand
runs (depending on GART size), X server crashes and does not come back in
a correct state (corruptions and crashes).

With this patch applied, it's possible again to do full piglit run (with
concurrency disabled) without crashes or lockups.

---
 drivers/gpu/drm/nouveau/nouveau_chan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c 
b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 1363578..174300b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -76,6 +76,8 @@ nouveau_channel_del(struct nouveau_channel **pchan)
nouveau_object_del(client, NVDRM_DEVICE, chan-push.handle);
nouveau_bo_vma_del(chan-push.buffer, chan-push.vma);
nouveau_bo_unmap(chan-push.buffer);
+   if (chan-push.buffer  chan-push.buffer-pin_refcnt)
+   nouveau_bo_unpin(chan-push.buffer);
nouveau_bo_ref(NULL, chan-push.buffer);
kfree(chan);
}
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: unpin various bo's before destroying

2012-11-26 Thread Marcin Slusarz
These objects leak VRAM - but only on module unload.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nv04_crtc.c|  6 +-
 drivers/gpu/drm/nouveau/nv10_fence.c   |  7 ++-
 drivers/gpu/drm/nouveau/nv50_display.c | 21 ++---
 drivers/gpu/drm/nouveau/nv50_fence.c   |  5 -
 drivers/gpu/drm/nouveau/nvc0_fence.c   |  7 ++-
 5 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c 
b/drivers/gpu/drm/nouveau/nv04_crtc.c
index 82a0d9c..6578cd2 100644
--- a/drivers/gpu/drm/nouveau/nv04_crtc.c
+++ b/drivers/gpu/drm/nouveau/nv04_crtc.c
@@ -730,6 +730,7 @@ static void nv_crtc_destroy(struct drm_crtc *crtc)
drm_crtc_cleanup(crtc);
 
nouveau_bo_unmap(nv_crtc-cursor.nvbo);
+   nouveau_bo_unpin(nv_crtc-cursor.nvbo);
nouveau_bo_ref(NULL, nv_crtc-cursor.nvbo);
kfree(nv_crtc);
 }
@@ -1056,8 +1057,11 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
 0, 0x, NULL, nv_crtc-cursor.nvbo);
if (!ret) {
ret = nouveau_bo_pin(nv_crtc-cursor.nvbo, TTM_PL_FLAG_VRAM);
-   if (!ret)
+   if (!ret) {
ret = nouveau_bo_map(nv_crtc-cursor.nvbo);
+   if (ret)
+   nouveau_bo_unpin(nv_crtc-cursor.nvbo);
+   }
if (ret)
nouveau_bo_ref(NULL, nv_crtc-cursor.nvbo);
}
diff --git a/drivers/gpu/drm/nouveau/nv10_fence.c 
b/drivers/gpu/drm/nouveau/nv10_fence.c
index ce752bf..7ae7f97 100644
--- a/drivers/gpu/drm/nouveau/nv10_fence.c
+++ b/drivers/gpu/drm/nouveau/nv10_fence.c
@@ -155,6 +155,8 @@ nv10_fence_destroy(struct nouveau_drm *drm)
 {
struct nv10_fence_priv *priv = drm-fence;
nouveau_bo_unmap(priv-bo);
+   if (priv-bo)
+   nouveau_bo_unpin(priv-bo);
nouveau_bo_ref(NULL, priv-bo);
drm-fence = NULL;
kfree(priv);
@@ -183,8 +185,11 @@ nv10_fence_create(struct nouveau_drm *drm)
 0, 0x, NULL, priv-bo);
if (!ret) {
ret = nouveau_bo_pin(priv-bo, TTM_PL_FLAG_VRAM);
-   if (!ret)
+   if (!ret) {
ret = nouveau_bo_map(priv-bo);
+   if (ret)
+   nouveau_bo_unpin(priv-bo);
+   }
if (ret)
nouveau_bo_ref(NULL, priv-bo);
}
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c 
b/drivers/gpu/drm/nouveau/nv50_display.c
index b252dbe..3587408 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -1228,8 +1228,12 @@ nv50_crtc_destroy(struct drm_crtc *crtc)
nv50_dmac_destroy(disp-core, head-sync.base);
nv50_pioc_destroy(disp-core, head-curs.base);
nouveau_bo_unmap(nv_crtc-cursor.nvbo);
+   if (nv_crtc-cursor.nvbo)
+   nouveau_bo_unpin(nv_crtc-cursor.nvbo);
nouveau_bo_ref(NULL, nv_crtc-cursor.nvbo);
nouveau_bo_unmap(nv_crtc-lut.nvbo);
+   if (nv_crtc-lut.nvbo)
+   nouveau_bo_unpin(nv_crtc-lut.nvbo);
nouveau_bo_ref(NULL, nv_crtc-lut.nvbo);
drm_crtc_cleanup(crtc);
kfree(crtc);
@@ -1300,8 +1304,11 @@ nv50_crtc_create(struct drm_device *dev, struct 
nouveau_object *core, int index)
 0, 0x, NULL, head-base.lut.nvbo);
if (!ret) {
ret = nouveau_bo_pin(head-base.lut.nvbo, TTM_PL_FLAG_VRAM);
-   if (!ret)
+   if (!ret) {
ret = nouveau_bo_map(head-base.lut.nvbo);
+   if (ret)
+   nouveau_bo_unpin(head-base.lut.nvbo);
+   }
if (ret)
nouveau_bo_ref(NULL, head-base.lut.nvbo);
}
@@ -1324,8 +1331,11 @@ nv50_crtc_create(struct drm_device *dev, struct 
nouveau_object *core, int index)
 0, 0x, NULL, head-base.cursor.nvbo);
if (!ret) {
ret = nouveau_bo_pin(head-base.cursor.nvbo, TTM_PL_FLAG_VRAM);
-   if (!ret)
+   if (!ret) {
ret = nouveau_bo_map(head-base.cursor.nvbo);
+   if (ret)
+   nouveau_bo_unpin(head-base.lut.nvbo);
+   }
if (ret)
nouveau_bo_ref(NULL, head-base.cursor.nvbo);
}
@@ -1917,6 +1927,8 @@ nv50_display_destroy(struct drm_device *dev)
nv50_dmac_destroy(disp-core, disp-mast.base);
 
nouveau_bo_unmap(disp-sync);
+   if (disp-sync)
+   nouveau_bo_unpin(disp-sync);
nouveau_bo_ref(NULL, disp-sync);
 
nouveau_display(dev)-priv = NULL;
@@ -1957,8 +1969,11

Re: [Nouveau] Reproducible PGRAPH TLB flush timeout hang on NV96

2012-11-26 Thread Marcin Slusarz
On Sun, Nov 25, 2012 at 11:50:50PM +0100, Maarten Maathuis wrote:
 Hi everyone,
 
 I was wondering what to do to dig into this problem further.The kernel
 is several weeks old (nouveau tree), it's at commit
 000463f13fba6b2f94a5bfcb0d615751ae9c34a0.
 
 As you can see from the mesages below the problem is reproducable to
 the point of getting exactly the same error.

You missed the most important information - how do you reproduce it?
:)

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Reproducible PGRAPH TLB flush timeout hang on NV96

2012-11-26 Thread Marcin Slusarz
On Mon, Nov 26, 2012 at 08:16:17PM +0100, Maarten Maathuis wrote:
 On Mon, Nov 26, 2012 at 7:04 PM, Marcin Slusarz
 marcin.slus...@gmail.com wrote:
  On Sun, Nov 25, 2012 at 11:50:50PM +0100, Maarten Maathuis wrote:
  Hi everyone,
 
  I was wondering what to do to dig into this problem further.The kernel
  is several weeks old (nouveau tree), it's at commit
  000463f13fba6b2f94a5bfcb0d615751ae9c34a0.
 
  As you can see from the mesages below the problem is reproducable to
  the point of getting exactly the same error.
 
  You missed the most important information - how do you reproduce it?
  :)
 
  Marcin
 
 A specific savegame for a game called freeorion which causes the
 problem within one turn typically, if you are interested in it i can
 dig it up.

Apitrace log could be useful - if you can reproduce hang with retrace.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau/bios: fix DCB v1.5 parsing

2012-11-17 Thread Marcin Slusarz
On Fri, Nov 16, 2012 at 09:36:56PM +1000, Dave Airlie wrote:
 On Fri, Nov 16, 2012 at 7:09 AM, Marcin Slusarz
 marcin.slus...@gmail.com wrote:
  memcmp-nv_strncmp conversion should have inverted the return value.
 
  Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
  ---
  See 
  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/nouveau_bios.c;h=a0a3fe3c016be86665db1369c44bef832f829a1a;hb=a0d271cbfed1dd50278c6b06bead3d00ba0a88f9#l5652
   (3.6)
  and 
  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/core/include/core/object.h;h=818feabbf4a0969f090f897852fe4476a422b1b6;hb=77b67063bb6bce6d475e910d3b886a606d0d91f7#l179
   (nv_strncmp definition)
 
 Christ fix that nv_strncmp to act like the C one, or give it a very
 different name!

Please don't kill the messenger.

---
From: Marcin Slusarz marcin.slus...@gmail.com
Subject: [PATCH v2] drm/nouveau/bios: fix DCB v1.5 parsing

memcmp-nv_strncmp conversion, in addition to name change, should have
inverted the return value.

But nv_strncmp does not act like strncmp - it does not check for string
terminator, returns true/false instead of -1/0/1 and has different
parameters order.
Let's rename it to nv_memcmp and let it act like memcmp.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/include/core/object.h | 14 +-
 drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c |  2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/include/core/object.h 
b/drivers/gpu/drm/nouveau/core/include/core/object.h
index 818feab..486f1a9 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/object.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/object.h
@@ -175,14 +175,18 @@ nv_mo32(void *obj, u32 addr, u32 mask, u32 data)
return temp;
 }
 
-static inline bool
-nv_strncmp(void *obj, u32 addr, u32 len, const char *str)
+static inline int
+nv_memcmp(void *obj, u32 addr, const char *str, u32 len)
 {
+   unsigned char c1, c2;
+
while (len--) {
-   if (nv_ro08(obj, addr++) != *(str++))
-   return false;
+   c1 = nv_ro08(obj, addr++);
+   c2 = *(str++);
+   if (c1 != c2)
+   return c1 - c2;
}
-   return true;
+   return 0;
 }
 
 #endif
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c 
b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
index 7d75038..c511971 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
@@ -64,7 +64,7 @@ dcb_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 
*cnt, u8 *len)
}
} else
if (*ver = 0x15) {
-   if (!nv_strncmp(bios, dcb - 7, 7, DEV_REC)) {
+   if (!nv_memcmp(bios, dcb - 7, DEV_REC, 7)) {
u16 i2c = nv_ro16(bios, dcb + 2);
*hdr = 4;
*cnt = (i2c - dcb) / 10;
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau/bios: fix DCB v1.5 parsing

2012-11-15 Thread Marcin Slusarz
memcmp-nv_strncmp conversion should have inverted the return value.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
See 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/nouveau_bios.c;h=a0a3fe3c016be86665db1369c44bef832f829a1a;hb=a0d271cbfed1dd50278c6b06bead3d00ba0a88f9#l5652
 (3.6)
and 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/core/include/core/object.h;h=818feabbf4a0969f090f897852fe4476a422b1b6;hb=77b67063bb6bce6d475e910d3b886a606d0d91f7#l179
 (nv_strncmp definition)
---
 drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c 
b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
index 7d75038..acb6936 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
@@ -64,7 +64,7 @@ dcb_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 
*cnt, u8 *len)
}
} else
if (*ver = 0x15) {
-   if (!nv_strncmp(bios, dcb - 7, 7, DEV_REC)) {
+   if (nv_strncmp(bios, dcb - 7, 7, DEV_REC)) {
u16 i2c = nv_ro16(bios, dcb + 2);
*hdr = 4;
*cnt = (i2c - dcb) / 10;
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Fix for vblank on nvc0

2012-11-12 Thread Marcin Slusarz
On Mon, Nov 12, 2012 at 06:14:05AM -0600, Kelly Doran wrote:
 Okay I have added two patches, one of them should fix the problem...
 

vblank-fix1.patch works, thanks.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Fix for vblank on nvc0

2012-11-11 Thread Marcin Slusarz
On Tue, Nov 06, 2012 at 07:30:00PM +0100, Maarten Lankhorst wrote:
 
 
 Op 06-11-12 15:48, Kelly Doran schreef:
  The vblank on nvc0 was not working correctly and would freeze X, I managed
  to track it down and fix it with some help from m.b.lankhorst, see
  https://bugs.freedesktop.org/show_bug.cgi?id=56692 for details.
 
 Reviewed-by: Maarten Lankhorst maarten.lankho...@canonical.com
 
 I recommended the bar flush since nvd0 does as well, and there might be a 
 small race
 otherwise.
 
 Can this still get in before final 3.7 release?

This patch breaks vblank here (nv92) completely.

[ 6879.200427] Console: switching to colour VGA+ 80x25
[ 6879.202884] drm: unregistered panic notifier
[ 6879.334278] [TTM] Finalizing pool allocator
[ 6879.334518] [TTM] Finalizing DMA pool allocator
[ 6879.334765] [TTM] Zone  kernel: Used memory at exit: 0 kiB
[ 6879.335004] [TTM] Zone   dma32: Used memory at exit: 0 kiB
[ 6879.340472] [drm] Module unloaded
[ 6879.397744] [drm] Initialized drm 1.1.0 20060810
[ 6879.408149] nouveau  [  DEVICE][:02:00.0] BOOT0  : 0x092a00a2
[ 6879.408401] nouveau  [  DEVICE][:02:00.0] Chipset: G92 (NV92)
[ 6879.408641] nouveau  [  DEVICE][:02:00.0] Family : NV50
[ 6879.409752] nouveau  [   VBIOS][:02:00.0] checking PRAMIN for image...
[ 6879.409997] nouveau  [   VBIOS][:02:00.0] ... signature not found
[ 6879.410236] nouveau  [   VBIOS][:02:00.0] checking PROM for image...
[ 6879.549018] nouveau  [   VBIOS][:02:00.0] ... appears to be valid
[ 6879.549259] nouveau  [   VBIOS][:02:00.0] using image from PROM
[ 6879.549640] nouveau  [   VBIOS][:02:00.0] BIT signature found
[ 6879.549879] nouveau  [   VBIOS][:02:00.0] version 62.92.63.00
[ 6879.570275] nouveau  [ MXM][:02:00.0] no VBIOS data, nothing to do
[ 6879.572488] nouveau  [ PFB][:02:00.0] RAM type: GDDR3
[ 6879.572726] nouveau  [ PFB][:02:00.0] RAM size: 512 MiB
[ 6879.572964] nouveau  [ PFB][:02:00.0]ZCOMP: 4032 tags
[ 6879.597652] [TTM] Zone  kernel: Available graphics memory: 3047140 kiB
[ 6879.597892] [TTM] Zone   dma32: Available graphics memory: 2097152 kiB
[ 6879.598130] [TTM] Initializing pool allocator
[ 6879.598367] [TTM] Initializing DMA pool allocator
[ 6879.602860] nouveau  [ DRM] VRAM: 512 MiB
[ 6879.603102] nouveau  [ DRM] GART: 512 MiB
[ 6879.603339] nouveau  [ DRM] BIT BIOS found
[ 6879.603575] nouveau  [ DRM] Bios version 62.92.63.00
[ 6879.603813] nouveau  [ DRM] TMDS table version 2.0
[ 6879.604050] nouveau  [ DRM] DCB version 4.0
[ 6879.604287] nouveau  [ DRM] DCB outp 00: 02000300 0028
[ 6879.604524] nouveau  [ DRM] DCB outp 01: 01000302 00020030
[ 6879.604763] nouveau  [ DRM] DCB outp 02: 04011310 0028
[ 6879.605000] nouveau  [ DRM] DCB outp 03: 02011312 00020030
[ 6879.605238] nouveau  [ DRM] DCB conn 00: 1030
[ 6879.605516] nouveau  [ DRM] DCB conn 01: 2130
[ 6879.648012] [drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
[ 6879.648257] [drm] No driver support for vblank timestamp query.
[ 6879.648708] nouveau  [ DRM] 1 available performance level(s)
[ 6879.648953] nouveau  [ DRM] 3: core 650MHz shader 1625MHz memory 1000MHz 
voltage 1050mV fanspeed 100%
[ 6879.649391] nouveau  [ DRM] c: core 399MHz shader 810MHz memory 399MHz 
voltage 1050mV fanspeed 34%
[ 6879.693947] nouveau  [ DRM] MM: using CRYPT for buffer copies
[ 6879.791680] nouveau  [ DRM] allocated 1920x1080 fb: 0x7, bo 
880018f20800
[ 6879.792175] fbcon: nouveaufb (fb0) is primary device
[ 6879.850216] Console: switching to colour frame buffer device 240x67
[ 6879.897075] fb0: nouveaufb frame buffer device
[ 6879.897075] drm: registered panic notifier
[ 6879.897078] [drm] Initialized nouveau 1.1.0 20120801 for :02:00.0 on 
minor 0
I'm starting glxgears here
xorg hangs, with occasional mouse movement
[ 6907.054696] nouveau  [   PFIFO][:02:00.0] unknown intr 0x0040, ch 2
pkill glxgears from fbcon
[ 6963.987969] nouveau E[   15318] failed to idle channel 0x
xorg still hangs
[ 7034.713069] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_2D - TP 0 - Unknown 
fault at address 002006
[ 7034.713167] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_2D - TP 0 - e0c: 
, e18: , e1c: , e20: 0037, e24: 0c03
[ 7034.713286] nouveau  [  PGRAPH][:02:00.0]  TRAP
[ 7034.713353] nouveau E[  PGRAPH][:02:00.0] ch 2 [0x001faf9000] subc 2 
class 0x502d mthd 0x060c data 0x000b
[ 7034.713454] nouveau E[ PFB][:02:00.0] trapped write at 0x00 
on channel 0x0001fea0 PEEPHOLE/PFIFO_WRITE/00 reason: NULL_DMAOBJ
[ 7034.713624] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_RT - TP 0 - Unknown 
fault at address 002006
[ 7034.713713] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_RT - TP 0 - e0c: 
, e18: , e1c: 0002, e20: 3b00, e24: 0003
[ 7034.713834] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_RT - TP 1 - 

Re: [Nouveau] Fix for vblank on nvc0

2012-11-11 Thread Marcin Slusarz
On Sun, Nov 11, 2012 at 07:26:17PM +0100, Marcin Slusarz wrote:
 On Tue, Nov 06, 2012 at 07:30:00PM +0100, Maarten Lankhorst wrote:
  
  
  Op 06-11-12 15:48, Kelly Doran schreef:
   The vblank on nvc0 was not working correctly and would freeze X, I managed
   to track it down and fix it with some help from m.b.lankhorst, see
   https://bugs.freedesktop.org/show_bug.cgi?id=56692 for details.
  
  Reviewed-by: Maarten Lankhorst maarten.lankho...@canonical.com
  
  I recommended the bar flush since nvd0 does as well, and there might be a 
  small race
  otherwise.
  
  Can this still get in before final 3.7 release?
 
 This patch breaks vblank here (nv92) completely.
 
 [ 6879.200427] Console: switching to colour VGA+ 80x25
 [ 6879.202884] drm: unregistered panic notifier
 [ 6879.334278] [TTM] Finalizing pool allocator
 [ 6879.334518] [TTM] Finalizing DMA pool allocator
 [ 6879.334765] [TTM] Zone  kernel: Used memory at exit: 0 kiB
 [ 6879.335004] [TTM] Zone   dma32: Used memory at exit: 0 kiB
 [ 6879.340472] [drm] Module unloaded
 [ 6879.397744] [drm] Initialized drm 1.1.0 20060810
 [ 6879.408149] nouveau  [  DEVICE][:02:00.0] BOOT0  : 0x092a00a2
 [ 6879.408401] nouveau  [  DEVICE][:02:00.0] Chipset: G92 (NV92)
 [ 6879.408641] nouveau  [  DEVICE][:02:00.0] Family : NV50
 [ 6879.409752] nouveau  [   VBIOS][:02:00.0] checking PRAMIN for image...
 [ 6879.409997] nouveau  [   VBIOS][:02:00.0] ... signature not found
 [ 6879.410236] nouveau  [   VBIOS][:02:00.0] checking PROM for image...
 [ 6879.549018] nouveau  [   VBIOS][:02:00.0] ... appears to be valid
 [ 6879.549259] nouveau  [   VBIOS][:02:00.0] using image from PROM
 [ 6879.549640] nouveau  [   VBIOS][:02:00.0] BIT signature found
 [ 6879.549879] nouveau  [   VBIOS][:02:00.0] version 62.92.63.00
 [ 6879.570275] nouveau  [ MXM][:02:00.0] no VBIOS data, nothing to do
 [ 6879.572488] nouveau  [ PFB][:02:00.0] RAM type: GDDR3
 [ 6879.572726] nouveau  [ PFB][:02:00.0] RAM size: 512 MiB
 [ 6879.572964] nouveau  [ PFB][:02:00.0]ZCOMP: 4032 tags
 [ 6879.597652] [TTM] Zone  kernel: Available graphics memory: 3047140 kiB
 [ 6879.597892] [TTM] Zone   dma32: Available graphics memory: 2097152 kiB
 [ 6879.598130] [TTM] Initializing pool allocator
 [ 6879.598367] [TTM] Initializing DMA pool allocator
 [ 6879.602860] nouveau  [ DRM] VRAM: 512 MiB
 [ 6879.603102] nouveau  [ DRM] GART: 512 MiB
 [ 6879.603339] nouveau  [ DRM] BIT BIOS found
 [ 6879.603575] nouveau  [ DRM] Bios version 62.92.63.00
 [ 6879.603813] nouveau  [ DRM] TMDS table version 2.0
 [ 6879.604050] nouveau  [ DRM] DCB version 4.0
 [ 6879.604287] nouveau  [ DRM] DCB outp 00: 02000300 0028
 [ 6879.604524] nouveau  [ DRM] DCB outp 01: 01000302 00020030
 [ 6879.604763] nouveau  [ DRM] DCB outp 02: 04011310 0028
 [ 6879.605000] nouveau  [ DRM] DCB outp 03: 02011312 00020030
 [ 6879.605238] nouveau  [ DRM] DCB conn 00: 1030
 [ 6879.605516] nouveau  [ DRM] DCB conn 01: 2130
 [ 6879.648012] [drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
 [ 6879.648257] [drm] No driver support for vblank timestamp query.
 [ 6879.648708] nouveau  [ DRM] 1 available performance level(s)
 [ 6879.648953] nouveau  [ DRM] 3: core 650MHz shader 1625MHz memory 
 1000MHz voltage 1050mV fanspeed 100%
 [ 6879.649391] nouveau  [ DRM] c: core 399MHz shader 810MHz memory 399MHz 
 voltage 1050mV fanspeed 34%
 [ 6879.693947] nouveau  [ DRM] MM: using CRYPT for buffer copies
 [ 6879.791680] nouveau  [ DRM] allocated 1920x1080 fb: 0x7, bo 
 880018f20800
 [ 6879.792175] fbcon: nouveaufb (fb0) is primary device
 [ 6879.850216] Console: switching to colour frame buffer device 240x67
 [ 6879.897075] fb0: nouveaufb frame buffer device
 [ 6879.897075] drm: registered panic notifier
 [ 6879.897078] [drm] Initialized nouveau 1.1.0 20120801 for :02:00.0 on 
 minor 0
 I'm starting glxgears here
 xorg hangs, with occasional mouse movement
 [ 6907.054696] nouveau  [   PFIFO][:02:00.0] unknown intr 0x0040, ch 2
 pkill glxgears from fbcon
 [ 6963.987969] nouveau E[   15318] failed to idle channel 0x
 xorg still hangs
 [ 7034.713069] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_2D - TP 0 - 
 Unknown fault at address 002006
 [ 7034.713167] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_2D - TP 0 - e0c: 
 , e18: , e1c: , e20: 0037, e24: 0c03
 [ 7034.713286] nouveau  [  PGRAPH][:02:00.0]  TRAP
 [ 7034.713353] nouveau E[  PGRAPH][:02:00.0] ch 2 [0x001faf9000] subc 2 
 class 0x502d mthd 0x060c data 0x000b
 [ 7034.713454] nouveau E[ PFB][:02:00.0] trapped write at 
 0x00 on channel 0x0001fea0 PEEPHOLE/PFIFO_WRITE/00 reason: NULL_DMAOBJ
 [ 7034.713624] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_RT - TP 0 - 
 Unknown fault at address 002006
 [ 7034.713713] nouveau E[  PGRAPH][:02:00.0] TRAP_TPDMA_RT

Re: [Nouveau] [PATCH] drm/nv50: decode PGRAPH status registers on TLB flush fail

2012-11-11 Thread Marcin Slusarz
On Wed, Nov 07, 2012 at 08:04:41PM +0100, Marcin Slusarz wrote:
 On Wed, Nov 07, 2012 at 10:08:47AM +1000, Ben Skeggs wrote:
  On Tue, Nov 06, 2012 at 10:48:52PM +0100, Marcin Slusarz wrote:
   Now it outputs:
   nouveau E[  PGRAPH][:02:00.0] PGRAPH TLB flush idle timeout fail
   nouveau E[  PGRAPH][:02:00.0] PGRAPH_STATUS: BUSY DISPATCH VFETCH 
   CCACHE_UNK4 STRMOUT_GSCHED_UNK5 UNK14XX UNK1CXX CLIPID ZCULL ENG2D 
   UNK34XX TPRAST TPROP ROP (0x011fde03)
   nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS: CCACHE (0x00145b4d) 
   (0x002d) ENG2D ROP (0x0034db40)
  
  How about this instead?
  
  PGRAPH_STATUS  : 0x011fde03 [BUSY DISPATCH VFETCH CCACHE_UNK4 
  STRMOUT_GSCHED_UNK5 UNK14XX UNK1CXX CLIPID ZCULL ENG2D UNK34XX TPRAST TPROP 
  ROP]
  PGRAPH_VSTATUS0: 0x00145b4d [CCACHE]
  PGRAPH_VSTATUS1: 0x002d []
  PGRAPH_VSTATUS2: 0x0034db40 [ENG2D ROP]
 
 Looks good too. I'll post updated patch tomorrow.

I removed square brackets to make this code as simple as possible (think about
last space before ]).
---
From: Marcin Slusarz marcin.slus...@gmail.com
Subject: [PATCH] drm/nv50: decode PGRAPH status registers on TLB flush fail

Now it prints:
nouveau E[  PGRAPH][:02:00.0] PGRAPH TLB flush idle timeout fail
nouveau E[  PGRAPH][:02:00.0] PGRAPH_STATUS  : 0x011fde03 BUSY DISPATCH 
VFETCH CCACHE_UNK4 STRMOUT_GSCHED_UNK5 UNK14XX UNK1CXX CLIPID ZCULL ENG2D 
UNK34XX TPRAST TPROP ROP
nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS0: 0x00145b4d CCACHE
nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS0: 0x002d
nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS0: 0x0034db40 ENG2D ROP

instead of:
[drm] nouveau :02:00.0: PGRAPH TLB flush idle timeout fail: 0x011fde03 
0x00145b4d 0x002d 0x0034db40

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/engine/graph/nv50.c | 76 ++--
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c 
b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
index ab3b9dc..0d67e86 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
@@ -184,6 +184,65 @@ nv50_graph_tlb_flush(struct nouveau_engine *engine)
return 0;
 }
 
+static const struct nouveau_bitfield nv50_pgraph_status[] = {
+   { 0x0001, BUSY }, /* set when any bit is set */
+   { 0x0002, DISPATCH },
+   { 0x0004, UNK2 },
+   { 0x0008, UNK3 },
+   { 0x0010, UNK4 },
+   { 0x0020, UNK5 },
+   { 0x0040, M2MF },
+   { 0x0080, UNK7 },
+   { 0x0100, CTXPROG },
+   { 0x0200, VFETCH },
+   { 0x0400, CCACHE_UNK4 },
+   { 0x0800, STRMOUT_GSCHED_UNK5 },
+   { 0x1000, UNK14XX },
+   { 0x2000, UNK24XX_CSCHED },
+   { 0x4000, UNK1CXX },
+   { 0x8000, CLIPID },
+   { 0x0001, ZCULL },
+   { 0x0002, ENG2D },
+   { 0x0004, UNK34XX },
+   { 0x0008, TPRAST },
+   { 0x0010, TPROP },
+   { 0x0020, TEX },
+   { 0x0040, TPVP },
+   { 0x0080, MP },
+   { 0x0100, ROP },
+   {}
+};
+
+static const char *const nv50_pgraph_vstatus_0[] = {
+   VFETCH, CCACHE, UNK4, UNK5, GSCHED, STRMOUT, UNK14XX, NULL
+};
+
+static const char *const nv50_pgraph_vstatus_1[] = {
+   TPRAST, TPROP, TEXTURE, TPVP, MP, NULL
+};
+
+static const char *const nv50_pgraph_vstatus_2[] = {
+   UNK24XX, CSCHED, UNK1CXX, CLIPID, ZCULL, ENG2D, UNK34XX,
+   ROP, NULL
+};
+
+static void nouveau_pgraph_vstatus_print(struct nv50_graph_priv *priv, int r,
+   const char *const units[], u32 status)
+{
+   int i;
+
+   nv_error(priv, PGRAPH_VSTATUS%d: 0x%08x, r, status);
+
+   for (i = 0; units[i]  status; i++) {
+   if ((status  7) == 1)
+   pr_cont( %s, units[i]);
+   status = 3;
+   }
+   if (status)
+   pr_cont( (invalid: 0x%x), status);
+   pr_cont(\n);
+}
+
 static int
 nv84_graph_tlb_flush(struct nouveau_engine *engine)
 {
@@ -219,10 +278,19 @@ nv84_graph_tlb_flush(struct nouveau_engine *engine)
 !(timeout = ptimer-read(ptimer) - start  20));
 
if (timeout) {
-   nv_error(priv, PGRAPH TLB flush idle timeout fail: 
- 0x%08x 0x%08x 0x%08x 0x%08x\n,
-nv_rd32(priv, 0x400700), nv_rd32(priv, 0x400380),
-nv_rd32(priv, 0x400384), nv_rd32(priv, 0x400388));
+   nv_error(priv, PGRAPH TLB flush idle timeout fail\n);
+
+   tmp = nv_rd32(priv, 0x400700);
+   nv_error(priv, PGRAPH_STATUS  : 0x%08x, tmp);
+   nouveau_bitfield_print(nv50_pgraph_status, tmp);
+   pr_cont(\n);
+
+   nouveau_pgraph_vstatus_print(priv, 0, nv50_pgraph_vstatus_0,
+   nv_rd32(priv, 0x400380

[Nouveau] [PATCH] drm/nouveau: remove unused variable from nouveau_bios_shadow_of

2012-11-11 Thread Marcin Slusarz
drivers/gpu/drm/nouveau/core/subdev/bios/base.c: warning: unused variable 'i'

Reported-by: Geert Uytterhoeven ge...@linux-m68k.org
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---

It's powerpc only code, so this wasn't compile tested.

---
 drivers/gpu/drm/nouveau/core/subdev/bios/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c 
b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
index 1cf818d..8963e36 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
@@ -63,7 +63,7 @@ nouveau_bios_shadow_of(struct nouveau_bios *bios)
struct pci_dev *pdev = nv_device(bios)-pdev;
struct device_node *dn;
const u32 *data;
-   int size, i;
+   int size;
 
dn = pci_device_to_OF_node(pdev);
if (!dn) {
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] kms: Let the server know if we got more than 1 EDID block

2012-11-11 Thread Marcin Slusarz
On Sun, Nov 11, 2012 at 08:09:08PM +, Emil Velikov wrote:
 On 04/11/12 18:06, Emil Velikov wrote:
  Verbatim copy from xf86-video-radeon commit 809cacb

s/radeon/ati/

Here's direct link: 
http://cgit.freedesktop.org/xorg/driver/xf86-video-ati/commit/?id=809cacb

  
  Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=32341
  Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
  ---
   src/drmmode_display.c | 5 -
   1 file changed, 4 insertions(+), 1 deletion(-)
  
  diff --git a/src/drmmode_display.c b/src/drmmode_display.c
  index 803785d..8ec69f5 100644
  --- a/src/drmmode_display.c
  +++ b/src/drmmode_display.c
  @@ -640,9 +640,12 @@ drmmode_output_get_modes(xf86OutputPtr output)
  drmModeFreeProperty(props);
  }
   
  -   if (drmmode_output-edid_blob)
  +   if (drmmode_output-edid_blob) {
  ddc_mon = xf86InterpretEDID(output-scrn-scrnIndex,
  drmmode_output-edid_blob-data);
  +   if (ddc_mon  drmmode_output-edid_blob-length  128)
  +   ddc_mon-flags |= MONITOR_EDID_COMPLETE_RAWDATA;
  +   }
  xf86OutputSetEDID(output, ddc_mon);
   
  /* modes should already be available */
  
 ping

Cc'ing Adam.

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] nouveau: Fix crash after D3

2012-11-07 Thread Marcin Slusarz
On Tue, Nov 06, 2012 at 10:03:40PM +0800, Daniel J Blueman wrote:
 In 3.7-rc4, when starting X with the integrated GPU and suspending the 
 discrete GPU,
 after one or more 32-bit applications are used (eg Skype) and X is stopped,
 we hit a panic.
 
 Prevent this by testing if the fini function is valid.

It's a bit weird. Can you explain better what is going on?
Why do we try to destroy this object (with NULL fini) only when GPU is
suspended? Maybe it means we are leaking this object on normal close/destroy?
Did you test what happens when you resume nv GPU after stopping X?

 Full panic bootlog is at: http://quora.org/2012/nouveau/dmesg-crash.txt
 Xorg.log is at: http://quora.org/2012/nouveau/Xorg.0.log-crash.txt
 Kernel log after fix is at: http://quora.org/2012/nouveau/dmesg-fix.txt
 
 Signed-off-by: Daniel J Blueman dan...@quora.org
 ---
  drivers/gpu/drm/nouveau/core/core/object.c |   10 +++---
  1 file changed, 7 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/gpu/drm/nouveau/core/core/object.c 
 b/drivers/gpu/drm/nouveau/core/core/object.c
 index 0daab62..3da3525 100644
 --- a/drivers/gpu/drm/nouveau/core/core/object.c
 +++ b/drivers/gpu/drm/nouveau/core/core/object.c
 @@ -354,12 +354,16 @@ static int
  nouveau_object_decf(struct nouveau_object *object)
  {
   int ret;
 + struct nouveau_ofuncs *pfuncs;
  
   nv_trace(object, stopping...\n);
  
 - ret = nv_ofuncs(object)-fini(object, false);
 - if (ret)
 - nv_warn(object, failed fini, %d\n, ret);
 + pfuncs = nv_ofuncs(object);
 + if (pfuncs-fini) {
 + ret = nv_ofuncs(object)-fini(object, false);
 + if (ret)
 + nv_warn(object, failed fini, %d\n, ret);
 + }
  
   if (object-engine) {
   mutex_lock(nv_subdev(object-engine)-mutex);
 -- 
 1.7.10.4
 
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nv50: decode PGRAPH status registers on TLB flush fail

2012-11-07 Thread Marcin Slusarz
On Wed, Nov 07, 2012 at 10:08:47AM +1000, Ben Skeggs wrote:
 On Tue, Nov 06, 2012 at 10:48:52PM +0100, Marcin Slusarz wrote:
  Now it outputs:
  nouveau E[  PGRAPH][:02:00.0] PGRAPH TLB flush idle timeout fail
  nouveau E[  PGRAPH][:02:00.0] PGRAPH_STATUS: BUSY DISPATCH VFETCH 
  CCACHE_UNK4 STRMOUT_GSCHED_UNK5 UNK14XX UNK1CXX CLIPID ZCULL ENG2D UNK34XX 
  TPRAST TPROP ROP (0x011fde03)
  nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS: CCACHE (0x00145b4d) 
  (0x002d) ENG2D ROP (0x0034db40)
 
 How about this instead?
 
 PGRAPH_STATUS  : 0x011fde03 [BUSY DISPATCH VFETCH CCACHE_UNK4 
 STRMOUT_GSCHED_UNK5 UNK14XX UNK1CXX CLIPID ZCULL ENG2D UNK34XX TPRAST TPROP 
 ROP]
 PGRAPH_VSTATUS0: 0x00145b4d [CCACHE]
 PGRAPH_VSTATUS1: 0x002d []
 PGRAPH_VSTATUS2: 0x0034db40 [ENG2D ROP]

Looks good too. I'll post updated patch tomorrow.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v2] drm/nv41/vm: fix typo in type name

2012-11-06 Thread Marcin Slusarz
It's a miracle it compiles at all - nv04_vm_priv does not exist
anywhere in the tree.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
v2: rebased on top of nouveau/master
---
 drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c 
b/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
index 49050d9..9474cfc 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
@@ -67,7 +67,7 @@ nv41_vm_unmap(struct nouveau_gpuobj *pgt, u32 pte, u32 cnt)
 static void
 nv41_vm_flush(struct nouveau_vm *vm)
 {
-   struct nv04_vm_priv *priv = (void *)vm-vmm;
+   struct nv04_vmmgr_priv *priv = (void *)vm-vmm;
 
mutex_lock(nv_subdev(priv)-mutex);
nv_wr32(priv, 0x100810, 0x0022);
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv40/graph: fix typo in type names

2012-11-06 Thread Marcin Slusarz
nv04_graph_priv / nv04_graph_chan are not defined in this context...

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/engine/graph/nv40.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c 
b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
index b076678..a3742db 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
@@ -156,8 +156,8 @@ nv40_graph_context_ctor(struct nouveau_object *parent,
 static int
 nv40_graph_context_fini(struct nouveau_object *object, bool suspend)
 {
-   struct nv04_graph_priv *priv = (void *)object-engine;
-   struct nv04_graph_chan *chan = (void *)object;
+   struct nv40_graph_priv *priv = (void *)object-engine;
+   struct nv40_graph_chan *chan = (void *)object;
u32 inst = 0x0100 | nv_gpuobj(chan)-addr  4;
int ret = 0;
 
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv40/mpeg: fix context handling

2012-11-06 Thread Marcin Slusarz
It slipped in thanks to typeless API.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c 
b/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c
index 1241857..f7c581a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c
+++ b/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c
@@ -38,7 +38,7 @@ struct nv40_mpeg_priv {
 };
 
 struct nv40_mpeg_chan {
-   struct nouveau_mpeg base;
+   struct nouveau_mpeg_chan base;
 };
 
 
/***
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv50: decode PGRAPH status registers on TLB flush fail

2012-11-06 Thread Marcin Slusarz
Now it outputs:
nouveau E[  PGRAPH][:02:00.0] PGRAPH TLB flush idle timeout fail
nouveau E[  PGRAPH][:02:00.0] PGRAPH_STATUS: BUSY DISPATCH VFETCH 
CCACHE_UNK4 STRMOUT_GSCHED_UNK5 UNK14XX UNK1CXX CLIPID ZCULL ENG2D UNK34XX 
TPRAST TPROP ROP (0x011fde03)
nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS: CCACHE (0x00145b4d) 
(0x002d) ENG2D ROP (0x0034db40)

instead of:
[drm] nouveau :02:00.0: PGRAPH TLB flush idle timeout fail: 0x011fde03 
0x00145b4d 0x002d 0x0034db40

Based on envytools docs.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/engine/graph/nv50.c | 75 ++--
 1 file changed, 71 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c 
b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
index ab3b9dc..5f1adca 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
@@ -184,6 +184,62 @@ nv50_graph_tlb_flush(struct nouveau_engine *engine)
return 0;
 }
 
+static const struct nouveau_bitfield nv50_pgraph_status[] = {
+   { 0x0001, BUSY }, /* set when any bit is set */
+   { 0x0002, DISPATCH },
+   { 0x0004, UNK2 },
+   { 0x0008, UNK3 },
+   { 0x0010, UNK4 },
+   { 0x0020, UNK5 },
+   { 0x0040, M2MF },
+   { 0x0080, UNK7 },
+   { 0x0100, CTXPROG },
+   { 0x0200, VFETCH },
+   { 0x0400, CCACHE_UNK4 },
+   { 0x0800, STRMOUT_GSCHED_UNK5 },
+   { 0x1000, UNK14XX },
+   { 0x2000, UNK24XX_CSCHED },
+   { 0x4000, UNK1CXX },
+   { 0x8000, CLIPID },
+   { 0x0001, ZCULL },
+   { 0x0002, ENG2D },
+   { 0x0004, UNK34XX },
+   { 0x0008, TPRAST },
+   { 0x0010, TPROP },
+   { 0x0020, TEX },
+   { 0x0040, TPVP },
+   { 0x0080, MP },
+   { 0x0100, ROP },
+   {}
+};
+
+static const char *const nv50_pgraph_vstatus_0[] = {
+   VFETCH, CCACHE, UNK4, UNK5, GSCHED, STRMOUT, UNK14XX, NULL
+};
+
+static const char *const nv50_pgraph_vstatus_1[] = {
+   TPRAST, TPROP, TEXTURE, TPVP, MP, NULL
+};
+
+static const char *const nv50_pgraph_vstatus_2[] = {
+   UNK24XX, CSCHED, UNK1CXX, CLIPID, ZCULL, ENG2D, UNK34XX,
+   ROP, NULL
+};
+
+static void nouveau_pgraph_vstatus_print(const char *const units[], u32 status)
+{
+   int i;
+   u32 tmp = status;
+   for (i = 0; units[i]  tmp; i++) {
+   if ((tmp  7) == 1)
+   pr_cont(%s , units[i]);
+   tmp = 3;
+   }
+   if (tmp)
+   pr_cont(invalid: %x , tmp);
+   pr_cont((0x%08x) , status);
+}
+
 static int
 nv84_graph_tlb_flush(struct nouveau_engine *engine)
 {
@@ -219,10 +275,21 @@ nv84_graph_tlb_flush(struct nouveau_engine *engine)
 !(timeout = ptimer-read(ptimer) - start  20));
 
if (timeout) {
-   nv_error(priv, PGRAPH TLB flush idle timeout fail: 
- 0x%08x 0x%08x 0x%08x 0x%08x\n,
-nv_rd32(priv, 0x400700), nv_rd32(priv, 0x400380),
-nv_rd32(priv, 0x400384), nv_rd32(priv, 0x400388));
+   nv_error(priv, PGRAPH TLB flush idle timeout fail\n);
+
+   nv_error(priv, PGRAPH_STATUS: );
+   tmp = nv_rd32(priv, 0x400700);
+   nouveau_bitfield_print(nv50_pgraph_status, tmp);
+   pr_cont( (0x%08x)\n, tmp);
+
+   nv_error(priv, PGRAPH_VSTATUS: );
+   nouveau_pgraph_vstatus_print(nv50_pgraph_vstatus_0,
+   nv_rd32(priv, 0x400380));
+   nouveau_pgraph_vstatus_print(nv50_pgraph_vstatus_1,
+   nv_rd32(priv, 0x400384));
+   nouveau_pgraph_vstatus_print(nv50_pgraph_vstatus_2,
+   nv_rd32(priv, 0x400388));
+   pr_cont(\n);
}
 
nv50_vm_flush_engine(engine-base, 0x00);
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv50/evo: store iomem pointer in properly typed field

2012-11-06 Thread Marcin Slusarz
Abuse of function pointer was noticed by sparse.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nv50_evo.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nv50_evo.c 
b/drivers/gpu/drm/nouveau/nv50_evo.c
index 9f6f55c..ba497fb 100644
--- a/drivers/gpu/drm/nouveau/nv50_evo.c
+++ b/drivers/gpu/drm/nouveau/nv50_evo.c
@@ -33,17 +33,22 @@
 #include subdev/timer.h
 #include subdev/fb.h
 
+struct evo_object {
+   struct nouveau_object parent;
+   void __iomem *iomem;
+};
+
 static u32
 nv50_evo_rd32(struct nouveau_object *object, u32 addr)
 {
-   void __iomem *iomem = object-oclass-ofuncs-rd08;
+   void __iomem *iomem = ((struct evo_object *)object)-iomem;
return ioread32_native(iomem + addr);
 }
 
 static void
 nv50_evo_wr32(struct nouveau_object *object, u32 addr, u32 data)
 {
-   void __iomem *iomem = object-oclass-ofuncs-rd08;
+   void __iomem *iomem = ((struct evo_object *)object)-iomem;
iowrite32_native(data, iomem + addr);
 }
 
@@ -60,7 +65,7 @@ nv50_evo_channel_del(struct nouveau_channel **pevo)
nouveau_bo_ref(NULL, evo-push.buffer);
 
if (evo-object)
-   iounmap(evo-object-oclass-ofuncs);
+   iounmap(((struct evo_object *)evo-object)-iomem);
 
kfree(evo);
 }
@@ -112,6 +117,7 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
struct nouveau_drm *drm = nouveau_drm(dev);
struct nv50_display *disp = nv50_display(dev);
struct nouveau_channel *evo;
+   struct evo_object *evo_object;
int ret;
 
evo = kzalloc(sizeof(struct nouveau_channel), GFP_KERNEL);
@@ -142,7 +148,8 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
return ret;
}
 
-   evo-object = kzalloc(sizeof(*evo-object), GFP_KERNEL);
+   evo_object = kzalloc(sizeof(*evo_object), GFP_KERNEL);
+   evo-object = evo_object-parent;
 #ifdef NOUVEAU_OBJECT_MAGIC
evo-object-_magic = NOUVEAU_OBJECT_MAGIC;
 #endif
@@ -154,8 +161,7 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
kzalloc(sizeof(*evo-object-oclass-ofuncs), GFP_KERNEL);
evo-object-oclass-ofuncs-rd32 = nv50_evo_rd32;
evo-object-oclass-ofuncs-wr32 = nv50_evo_wr32;
-   evo-object-oclass-ofuncs-rd08 =
-   ioremap(pci_resource_start(dev-pdev, 0) +
+   evo_object-iomem = ioremap(pci_resource_start(dev-pdev, 0) +
NV50_PDISPLAY_USER(evo-handle), PAGE_SIZE);
return 0;
 }
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Nouveau soft lockup after switcheroo'd...

2012-11-01 Thread Marcin Slusarz
On Mon, Oct 29, 2012 at 10:09:07PM +0800, Daniel J Blueman wrote:
 On 25 October 2012 02:07, Marcin Slusarz marcin.slus...@gmail.com wrote:
  On Wed, Oct 24, 2012 at 01:54:43PM +0800, Daniel J Blueman wrote:
  On 13 October 2012 15:12, Daniel J Blueman dan...@quora.org wrote:
 [...]
  echo IGD /sys/kernel/debug/vgaswitcheroo/switch
  echo OFF /sys/kernel/debug/vgaswitcheroo/switch
 
  after boot+40s:
 
  BUG: soft lockup - CPU#0 stuck for 22s! [Xorg:1703]
 [...]\
   [a037c538] nv04_timer_read+0x28/0x70 [nouveau]
   [a037bfec] nouveau_timer_wait_eq+0x7c/0xe0 [nouveau]
   [a03f4f4e] nvd0_sor_dpms+0xde/0x1a0 [nouveau]
   [813871d9] ? fb_set_var+0xe9/0x3a0
   [811554a9] ? __pte_alloc+0xa9/0x160
   [a03f4e70] ? nvd0_sor_dp_link_set+0x2c0/0x2c0 [nouveau]
   [a00b2a5c] drm_helper_connector_dpms+0xbc/0x100 [drm_kms_helper]
   [a00b1665] drm_fb_helper_dpms.isra.13+0xa5/0xf0 [drm_kms_helper]
   [a00b16f9] drm_fb_helper_blank+0x49/0x80 [drm_kms_helper]
   [81386e16] fb_blank+0x56/0xc0
   [813887bb] do_fb_ioctl+0x59b/0x5f0
   [81152883] ? vma_interval_tree_insert+0x83/0x90
   [81388af5] fb_ioctl+0x45/0x50
   [8119adda] do_vfs_ioctl+0x8a/0x340
   [8119b121] sys_ioctl+0x91/0xb0
   [81189862] ? sys_read+0x52/0xa0
 
  In case it's not obvious: Xorg tries to blank monitor connected to nvidia
  card, but hangs because card is already powered down.
 
  Did it ever work? If yes, can you bisect it?
  Does it work if you power down nvidia card while X is not running?
 
 Thanks for your reply Marcin! I wasn't able to boot kernels earlier
 than 3.6 on this Macbook Pro retina due to various issues, and it
 occurs on kernels between and including 3.6 and 3.7-rc3.
 
 As we see read being called, I've taken the lsof output [1].
 
 Should the DPMS functions be deregistered prior the hardware being
 placed in D3, or is it more that the functions should check if the
 card was put into D3 and just return?

I'm not sure, but I would bet on adding a check(s). The question is: at which
layer (nouveau? drm? fb?)? Another is: are there any other code paths which
need to be protected from calling when suspended?
(Currently, I don't have answers to these questions and not much time to look
into them, sorry.)

If no one will figure it out in a few days, please open new bug report - see
http://nouveau.freedesktop.org/wiki/Bugs for description how to do this.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Virtualbox 3D accel broken in xf86-video-nouveau 1.0.3

2012-11-01 Thread Marcin Slusarz
On Thu, Nov 01, 2012 at 11:13:03AM -0500, Pouar wrote:
On 2012/10/31 17:27, Marcin Slusarz wrote:
 
 On Tue, Oct 30, 2012 at 01:30:53PM -0500, Pouar wrote:
 
On 10/30/2012 01:28 PM, Pouar wrote:
 
On 10/28/2012 01:21 PM, Pouar wrote:
 
On 10/28/2012 01:18 PM, Emil Velikov wrote:
 
  On Sun, 28 Oct 2012 01:15:54 -, Pouar wrote:
 
  there's a regression in the xf86-video-nouveau driver that came up
  in
  1.0.3 that causes the desktop to bounce around in virtualbox
  whenever
  using HW acceleration in cinnamon and gnome 3, but not in fallback
  or
  cinnamon 2d, only happens in virtualbox and not the host, I've
  confirmed
  it was the graphics driver on the host because it happened with the
  1.0.3 driver but not the 1.0.2.
  anyone else having this problem? I'm using GeForce GTX 560 Ti
 
  Hi Pouar
  Can you open a bug, following these instructions [1]
  Ideally you can try bisecting the issue - there are only 10 changes
  that may have caused the issue
  Cheers
  Emil
  [1] [1][1]http://nouveau.freedesktop.org/wiki/Bugs
 
  I just did
 
--
Pouar
 
  by I just did I meant the bug report, not the bisecting, I have zero
  experience with driver programming, much less graphics driver
  programming, so I wouldn't know what to look for, I signed up for
  this mailing list to keep track of the different driver issues and
  bugs and their progress
 
 You don't need to have any experience in driver programming to bisect this 
 bug.
 
 git clone git://anongit.freedesktop.org/git/nouveau/xf86-video-nouveau/
 cd xf86-video-nouveau/
 ./autogen.sh
 make
 
 If you can compile successfully, do:
 
 1) git bisect start xf86-video-nouveau-1.0.3 xf86-video-nouveau-1.0.2
 2) make  sudo rm /usr/lib/xorg/modules/drivers/nouveau_drv.so  sudo cp 
 src/.
 libs/nouveau_drv.so /usr/lib/xorg/modules/drivers
 3) Restart X. Try to reproduce the bug.
 4) If you can't reproduce it - do git bisect good, if you can - do git 
 bisect
  bad.
 5) Go to 2). After ~4 compiles it will tell you about first bad commit - this
 is what we want to see.
 
 Marcin
 
Did the bisect today. Here's what I got:
297fd0d0755bda698be1d0b30cc60a41d7673c0b is the first bad commit
commit 297fd0d0755bda698be1d0b30cc60a41d7673c0b
Author: Dave Airlie [2]airl...@redhat.com
Date:   Tue Oct 16 16:15:16 2012 +1000
nouveau/dri2: fix pixmap/window offset calcs.
 
This should fix prime rendering under kwin, and not break it under
the
others.
 
Signed-off-by: Dave Airlie [3]airl...@redhat.com
:04 04 10860842c2d9ff579e3e0b46b1edfc332d40b311
886ca8b5c05779ee410c6d14575b4805016b71af Msrc
 
--

Thanks!
Cc'ing Dave.

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Virtualbox 3D accel broken in xf86-video-nouveau 1.0.3

2012-10-31 Thread Marcin Slusarz
On Tue, Oct 30, 2012 at 01:30:53PM -0500, Pouar wrote:
On 10/30/2012 01:28 PM, Pouar wrote:
 
On 10/28/2012 01:21 PM, Pouar wrote:
 
On 10/28/2012 01:18 PM, Emil Velikov wrote:
 
  On Sun, 28 Oct 2012 01:15:54 -, Pouar wrote:
 
  there's a regression in the xf86-video-nouveau driver that came up
  in
  1.0.3 that causes the desktop to bounce around in virtualbox
  whenever
  using HW acceleration in cinnamon and gnome 3, but not in fallback
  or
  cinnamon 2d, only happens in virtualbox and not the host, I've
  confirmed
  it was the graphics driver on the host because it happened with the
  1.0.3 driver but not the 1.0.2.
  anyone else having this problem? I'm using GeForce GTX 560 Ti
 
  Hi Pouar
  Can you open a bug, following these instructions [1]
  Ideally you can try bisecting the issue - there are only 10 changes
  that may have caused the issue
  Cheers
  Emil
  [1] [1]http://nouveau.freedesktop.org/wiki/Bugs
 
  I just did
 
--
Pouar
 
  by I just did I meant the bug report, not the bisecting, I have zero
  experience with driver programming, much less graphics driver
  programming, so I wouldn't know what to look for, I signed up for
  this mailing list to keep track of the different driver issues and
  bugs and their progress

You don't need to have any experience in driver programming to bisect this bug.

git clone git://anongit.freedesktop.org/git/nouveau/xf86-video-nouveau/
cd xf86-video-nouveau/
./autogen.sh
make

If you can compile successfully, do:

1) git bisect start xf86-video-nouveau-1.0.3 xf86-video-nouveau-1.0.2
2) make  sudo rm /usr/lib/xorg/modules/drivers/nouveau_drv.so  sudo cp 
src/.libs/nouveau_drv.so /usr/lib/xorg/modules/drivers
3) Restart X. Try to reproduce the bug.
4) If you can't reproduce it - do git bisect good, if you can - do git 
bisect bad.
5) Go to 2). After ~4 compiles it will tell you about first bad commit - this
is what we want to see.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Nouveau soft lockup after switcheroo'd...

2012-10-24 Thread Marcin Slusarz
On Wed, Oct 24, 2012 at 01:54:43PM +0800, Daniel J Blueman wrote:
 On 13 October 2012 15:12, Daniel J Blueman dan...@quora.org wrote:
  On my Macbook Retina, when switching to the integrated GPU, we see a
  ioread32 issued to the discrete GPU, which hangs as it is in D3 [1]
  (drm.debug is set to 14 here).
 
  Full kernel 3.6.2 boot logs with drm.debug=5 are at:
  http://quora.org/2012/mbp-i915-panel.txt
 
  What additional information will help debug this?
 
 I'm seeing this on 3.7-rc2 also:
 
 cat /sys/kernel/debug/vgaswitcheroo/switch
 0:DIS:+:Pwr::01:00.0
 1:IGD: :Pwr::00:02.0
 2:DIS-Audio: :Pwr::01:00.1
 
 echo IGD /sys/kernel/debug/vgaswitcheroo/switch
 echo OFF /sys/kernel/debug/vgaswitcheroo/switch
 
 after boot+40s:
 
 BUG: soft lockup - CPU#0 stuck for 22s! [Xorg:1703]
 Modules linked in: dm_crypt snd_hda_codec_hdmi bnep rfcomm parport_pc
 ppdev nfsd nfs_acl auth_rpcgss nfs binfmt_misc fscache lockd sunrpc
 joydev arc4 coretemp kvm_intel b43 kvm mac80211 cfg80211 ssb btusb
 snd_hda_codec_cirrus applesmc input_polldev microcode bluetooth
 bcm5974 snd_hda_intel snd_hda_codec nouveau snd_seq_midi snd_rawmidi
 snd_hwdep bcma lpc_ich snd_seq_midi_event snd_pcm mei snd_seq
 snd_timer snd_seq_device ttm mxm_wmi wmi snd soundcore snd_page_alloc
 nls_iso8859_1 apple_gmux mac_hid apple_bl lp parport hid_generic
 hid_apple usbhid hid btrfs zlib_deflate libcrc32c ghash_clmulni_intel
 aesni_intel ablk_helper cryptd lrw aes_x86_64 xts gf128mul i915
 drm_kms_helper sdhci_pci sdhci drm i2c_algo_bit tg3 video
 CPU 0
 Pid: 1703, comm: Xorg Not tainted 3.7.0-030700rc2-generic
 #201210201535 Apple Inc. MacBookPro10,1/Mac-C3EC7CD22292981F
 RIP: 0010:[813469fa] [813469fa] ioread32+0x3a/0x40
 RSP: 0018:880260577b28 EFLAGS: 0296
 RAX:  RBX: 880260577b90 RCX: 8000
 RDX: 1000 RSI: 77359400 RDI: c9001d909410
 RBP: 880260577b28 R08:  R09: 880263d63798
 R10:  R11: 0246 R12: 88026f3d0968
 R13:  R14: 81049dc0 R15: 880260577ac8
 FS: 7f912f03e880() GS:88026f20() knlGS:
 CS: 0010 DS:  ES:  CR0: 80050033
 CR2: 7f9131bf7d00 CR3: 000264192000 CR4: 001407f0
 DR0:  DR1:  DR2: 
 DR3:  DR6: 0ff0 DR7: 0400
 Process Xorg (pid: 1703, threadinfo 880260576000, task 8802605bc4a0)
 Stack:
  880260577b58 a037c538 0296 8802612a3000
  77359400 0061d004 880260577bb8 a037bfec
  8802605bc4a0 0061d004  81172756
 Call Trace:
  [a037c538] nv04_timer_read+0x28/0x70 [nouveau]
  [a037bfec] nouveau_timer_wait_eq+0x7c/0xe0 [nouveau]
  [a03f4f4e] nvd0_sor_dpms+0xde/0x1a0 [nouveau]
  [813871d9] ? fb_set_var+0xe9/0x3a0
  [811554a9] ? __pte_alloc+0xa9/0x160
  [a03f4e70] ? nvd0_sor_dp_link_set+0x2c0/0x2c0 [nouveau]
  [a00b2a5c] drm_helper_connector_dpms+0xbc/0x100 [drm_kms_helper]
  [a00b1665] drm_fb_helper_dpms.isra.13+0xa5/0xf0 [drm_kms_helper]
  [a00b16f9] drm_fb_helper_blank+0x49/0x80 [drm_kms_helper]
  [81386e16] fb_blank+0x56/0xc0
  [813887bb] do_fb_ioctl+0x59b/0x5f0
  [81152883] ? vma_interval_tree_insert+0x83/0x90
  [81388af5] fb_ioctl+0x45/0x50
  [8119adda] do_vfs_ioctl+0x8a/0x340
  [8119b121] sys_ioctl+0x91/0xb0
  [81189862] ? sys_read+0x52/0xa0
  [816b9899] system_call_fastpath+0x16/0x1b
 Code: ff 00 00 01 00 76 0a 0f b7 d7 ed 5d c3 0f 1f 40 00 48 c7 c6 81
 4b a5 81 e8 24 fe ff ff b8 ff ff ff ff 5d c3 0f 1f 44 00 00 8b 07 5d
 c3 0f 1f 40 00 55 48 81 ff ff ff 03 00 48 89 e5 77 2b 48 81
 -- 

In case it's not obvious: Xorg tries to blank monitor connected to nvidia
card, but hangs because card is already powered down.

Did it ever work? If yes, can you bisect it?
Does it work if you power down nvidia card while X is not running?

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv41/vm: fix typo in struct name

2012-10-22 Thread Marcin Slusarz
It's a miracle it compiles at all - nv04_vm_priv does not exist
anywhere in the tree.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
Noticed when adding types to Nouveau APIs.
---
 drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c 
b/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
index 4545b0c..e41ce9b 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
@@ -67,7 +67,7 @@ nv41_vm_unmap(struct nouveau_gpuobj *pgt, u32 pte, u32 cnt)
 static int
 nv41_vm_flush(struct nouveau_vm *vm)
 {
-   struct nv04_vm_priv *priv = (void *)vm-vmm;
+   struct nv04_vmmgr_priv *priv = (void *)vm-vmm;
int ret = 0;
 
mutex_lock(nv_subdev(priv)-mutex);
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau/bios: use size provided by _ROM method

2012-10-21 Thread Marcin Slusarz
On Sun, Oct 21, 2012 at 12:53:15PM +0200, Lekensteyn wrote:
 From: Peter Wu lekenst...@gmail.com
 
 Since commit drm/nouveau/bios: attempt to fetch entire acpi rom image in one
 shot, the ACPI spec is broken in order to gain speed. In theory, since the
 _ROM method is supposed to return 4 KiB only, the returned buffer size could 
 be
 less than the requested length. This could lead to reading past the buffer
 boundaries which could make worse thing happen. To fix that, do not read more
 than the buffer contains. As an extra side-effect, the function returns the
 bytes that have really been read which is more natural.
 
 Signed-off-by: Peter Wu lekenst...@gmail.com
 ---
  drivers/gpu/drm/nouveau/nouveau_acpi.c |1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c 
 b/drivers/gpu/drm/nouveau/nouveau_acpi.c
 index 48783e1..368e45c 100644
 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
 +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
 @@ -356,6 +356,7 @@ static int nouveau_rom_call(acpi_handle rom_handle, 
 uint8_t *bios,
   return -ENODEV;
   }
   obj = (union acpi_object *)buffer.pointer;
 + len = min(len, (int)obj-buffer.size);
   memcpy(bios+offset, obj-buffer.pointer, len);
   kfree(buffer.pointer);
   return len;
 -- 

BTW, _ROM method from https://lkml.org/lkml/2012/10/21/11 multiplies length
by 8, so maybe we can read 32kB in one batch?

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak

2012-10-21 Thread Marcin Slusarz
On Fri, Oct 19, 2012 at 04:05:14PM +1000, Ben Skeggs wrote:
 On Thu, Oct 11, 2012 at 11:53:09PM +0200, Marcin Slusarz wrote:
  Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
  ---
   drivers/gpu/drm/nouveau/core/core/gpuobj.c | 6 +-
   drivers/gpu/drm/nouveau/core/include/core/gpuobj.h | 3 +++
   2 files changed, 8 insertions(+), 1 deletion(-)
  
  diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c 
  b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
  index c2a7608..48121d2 100644
  --- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
  +++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
  @@ -39,8 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
  nv_wo32(gpuobj, i, 0x);
  }
   
  +   if (gpuobj-node)
  +   nouveau_mm_free(gpuobj-node_heap, gpuobj-node);
  +
 if (gpuobj-node) {
   nouveau_mm_free(nv_gpuobj(gpuobj-parent)-heap,
   gpuobj-node);
 }
 
 Or something to that effect, instead of having to store the heap
 pointer again.

Oh, right.
(Somehow I assumed pargpu to be different object than parent when
I first read it.)

  if (gpuobj-heap.block_size)
  -   nouveau_mm_fini(gpuobj-heap);
  +   WARN_ON(nouveau_mm_fini(gpuobj-heap));
 Alright, I get this.  However, perhaps we should go the full hog here
 and make nouveau_mm_fini() directly do the WARN_ON() in this situation?
 
 There was, once upon a time, reasons for it not doing this, I don't
 believe they're valid anymore though.

OK.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v2] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak

2012-10-21 Thread Marcin Slusarz
v2: use already existing parent

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/gpuobj.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c 
b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
index c2a7608..18b3f5c 100644
--- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
+++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
@@ -39,6 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
nv_wo32(gpuobj, i, 0x);
}
 
+   if (gpuobj-node) {
+   nouveau_mm_free(nv_gpuobj(gpuobj-parent)-heap,
+   gpuobj-node);
+   }
+
if (gpuobj-heap.block_size)
nouveau_mm_fini(gpuobj-heap);
 
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: warn when trying to free mm which is still in use

2012-10-21 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/mm.c 
b/drivers/gpu/drm/nouveau/core/core/mm.c
index bfddf87..4d62064 100644
--- a/drivers/gpu/drm/nouveau/core/core/mm.c
+++ b/drivers/gpu/drm/nouveau/core/core/mm.c
@@ -236,7 +236,7 @@ nouveau_mm_fini(struct nouveau_mm *mm)
int nodes = 0;
 
list_for_each_entry(node, mm-nodes, nl_entry) {
-   if (nodes++ == mm-heap_nodes)
+   if (WARN_ON(nodes++ == mm-heap_nodes))
return -EBUSY;
}
 
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH 01/10] drm/nv50: decode PGRAPH status registers on TLB flush fail

2012-10-16 Thread Marcin Slusarz
On Thu, Oct 04, 2012 at 01:43:15PM +0200, Marcin Slusarz wrote:
 On Thu, Sep 13, 2012 at 12:47:53AM +0200, Marcin Slusarz wrote:
  On Tue, Aug 21, 2012 at 12:08:32AM +0200, Marcin Slusarz wrote:
   On Mon, Aug 20, 2012 at 07:02:46PM +0200, Marcin Slusarz wrote:
On Mon, Aug 20, 2012 at 04:27:18PM +1000, Ben Skeggs wrote:
 On Sun, Aug 19, 2012 at 10:59:56PM +0200, Marcin Slusarz wrote:
  Now it outputs:
  nouveau E[  PGRAPH][:02:00.0] PGRAPH TLB flush idle timeout fail
  nouveau E[  PGRAPH][:02:00.0] PGRAPH_STATUS: BUSY DISPATCH 
  VFETCH CCACHE_UNK4 STRMOUT_GSCHED_UNK5 UNK14XX UNK1CXX CLIPID ZCULL 
  ENG2D UNK34XX TPRAST TPROP ROP (0x011fde03)
  nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS_0: CCACHE 
  (0x00145b4d)
  nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS_1: (0x002d)
  nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS_2: ENG2D ROP 
  (0x0034db40)
  
  instead of:
  [drm] nouveau :02:00.0: PGRAPH TLB flush idle timeout fail: 
  0x011fde03 0x00145b4d 0x002d 0x0034db40
 
 I didn't push these first few patches yet as I have a couple of 
 thoughts on it.
 
 Mostly I was thinking we should probably have a:
 
 nv_printf(obj, lvl, fmt, args...)
 
 to replace the printk's which just does a continued print while still 
 obeying
 the debug level?

Well, this patch does not use nv_printk_enabled, so these concerns 
should
not apply to it, right? I'll fix up bitfield list and resend it.
  
  New version, which prints VSTATUS regs on one line.
  
  PS: I pushed this and some other patches to my github repo.
   ( https://github.com/mslusarz/linux )
  ---
  From: Marcin Slusarz marcin.slus...@gmail.com
  Subject: [PATCH 01/11] drm/nv50: decode PGRAPH status registers on TLB 
  flush fail
  
  Now it outputs:
  nouveau E[  PGRAPH][:02:00.0] PGRAPH TLB flush idle timeout fail
  nouveau E[  PGRAPH][:02:00.0] PGRAPH_STATUS: BUSY DISPATCH VFETCH 
  CCACHE_UNK4 STRMOUT_GSCHED_UNK5 UNK14XX UNK1CXX CLIPID ZCULL ENG2D UNK34XX 
  TPRAST TPROP ROP (0x011fde03)
  nouveau E[  PGRAPH][:02:00.0] PGRAPH_VSTATUS: CCACHE (0x00145b4d) 
  (0x002d) ENG2D ROP (0x0034db40)
  
  instead of:
  [drm] nouveau :02:00.0: PGRAPH TLB flush idle timeout fail: 0x011fde03 
  0x00145b4d 0x002d 0x0034db40
  
  Based on envytools docs.
  
  Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
  ---
   drivers/gpu/drm/nouveau/core/engine/graph/nv50.c | 75 
  ++--
   1 file changed, 71 insertions(+), 4 deletions(-)
  
  diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c 
  b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
  index ab3b9dc..5f1adca 100644
  --- a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
  +++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
  @@ -184,6 +184,62 @@ nv50_graph_tlb_flush(struct nouveau_engine *engine)
  return 0;
   }
   
  +static const struct nouveau_bitfield nv50_pgraph_status[] = {
  +   { 0x0001, BUSY }, /* set when any bit is set */
  +   { 0x0002, DISPATCH },
  +   { 0x0004, UNK2 },
  +   { 0x0008, UNK3 },
  +   { 0x0010, UNK4 },
  +   { 0x0020, UNK5 },
  +   { 0x0040, M2MF },
  +   { 0x0080, UNK7 },
  +   { 0x0100, CTXPROG },
  +   { 0x0200, VFETCH },
  +   { 0x0400, CCACHE_UNK4 },
  +   { 0x0800, STRMOUT_GSCHED_UNK5 },
  +   { 0x1000, UNK14XX },
  +   { 0x2000, UNK24XX_CSCHED },
  +   { 0x4000, UNK1CXX },
  +   { 0x8000, CLIPID },
  +   { 0x0001, ZCULL },
  +   { 0x0002, ENG2D },
  +   { 0x0004, UNK34XX },
  +   { 0x0008, TPRAST },
  +   { 0x0010, TPROP },
  +   { 0x0020, TEX },
  +   { 0x0040, TPVP },
  +   { 0x0080, MP },
  +   { 0x0100, ROP },
  +   {}
  +};
  +
  +static const char *const nv50_pgraph_vstatus_0[] = {
  +   VFETCH, CCACHE, UNK4, UNK5, GSCHED, STRMOUT, UNK14XX, NULL
  +};
  +
  +static const char *const nv50_pgraph_vstatus_1[] = {
  +   TPRAST, TPROP, TEXTURE, TPVP, MP, NULL
  +};
  +
  +static const char *const nv50_pgraph_vstatus_2[] = {
  +   UNK24XX, CSCHED, UNK1CXX, CLIPID, ZCULL, ENG2D, UNK34XX,
  +   ROP, NULL
  +};
  +
  +static void nouveau_pgraph_vstatus_print(const char *const units[], u32 
  status)
  +{
  +   int i;
  +   u32 tmp = status;
  +   for (i = 0; units[i]  tmp; i++) {
  +   if ((tmp  7) == 1)
  +   pr_cont(%s , units[i]);
  +   tmp = 3;
  +   }
  +   if (tmp)
  +   pr_cont(invalid: %x , tmp);
  +   pr_cont((0x%08x) , status);
  +}
  +
   static int
   nv84_graph_tlb_flush(struct nouveau_engine *engine)
   {
  @@ -219,10 +275,21 @@ nv84_graph_tlb_flush(struct nouveau_engine *engine)
   !(timeout = ptimer-read(ptimer) - start  20));
   
  if (timeout) {
  -   nv_error(priv, PGRAPH TLB flush idle timeout fail: 
  - 0x%08x 0x%08x 0x%08x 0x%08x\n

Re: [Nouveau] [PATCH] drm/nouveau: handle same-fb page flips

2012-10-16 Thread Marcin Slusarz
On Fri, Oct 05, 2012 at 09:37:59PM +0200, Marcin Slusarz wrote:
 It's questionable use case, but weston/wayland already relies on this 
 behaviour,
 and other drivers don't care about it, so it's a matter of compatibility.
 Without it, process invoking such page flip hangs in unkillable state, trying
 to reserve the same buffer twice.
 
 Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
 ---
  drivers/gpu/drm/nouveau/nouveau_display.c | 20 +++-
  1 file changed, 15 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
 b/drivers/gpu/drm/nouveau/nouveau_display.c
 index 61f370d..a52cfd3 100644
 --- a/drivers/gpu/drm/nouveau/nouveau_display.c
 +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
 @@ -530,9 +530,11 @@ nouveau_page_flip_reserve(struct nouveau_bo *old_bo,
   if (ret)
   goto fail;
  
 - ret = ttm_bo_reserve(old_bo-bo, false, false, false, 0);
 - if (ret)
 - goto fail_unreserve;
 + if (likely(old_bo != new_bo)) {
 + ret = ttm_bo_reserve(old_bo-bo, false, false, false, 0);
 + if (ret)
 + goto fail_unreserve;
 + }
  
   return 0;
  
 @@ -551,8 +553,10 @@ nouveau_page_flip_unreserve(struct nouveau_bo *old_bo,
   nouveau_bo_fence(new_bo, fence);
   ttm_bo_unreserve(new_bo-bo);
  
 - nouveau_bo_fence(old_bo, fence);
 - ttm_bo_unreserve(old_bo-bo);
 + if (likely(old_bo != new_bo)) {
 + nouveau_bo_fence(old_bo, fence);
 + ttm_bo_unreserve(old_bo-bo);
 + }
  
   nouveau_bo_unpin(old_bo);
  }
 @@ -624,6 +628,12 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct 
 drm_framebuffer *fb,
   if (!drm-channel)
   return -ENODEV;
  
 + if (unlikely(old_bo == new_bo)) {
 + char name[sizeof(current-comm)];
 + pr_debug_ratelimited('%s': useless page flip invoked\n,
 + get_task_comm(name, current));
 + }
 +
   s = kzalloc(sizeof(*s), GFP_KERNEL);
   if (!s)
   return -ENOMEM;
 -- 

ping
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak

2012-10-16 Thread Marcin Slusarz
On Thu, Oct 11, 2012 at 11:53:09PM +0200, Marcin Slusarz wrote:
 Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
 ---
  drivers/gpu/drm/nouveau/core/core/gpuobj.c | 6 +-
  drivers/gpu/drm/nouveau/core/include/core/gpuobj.h | 3 +++
  2 files changed, 8 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c 
 b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
 index c2a7608..48121d2 100644
 --- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
 +++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
 @@ -39,8 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
   nv_wo32(gpuobj, i, 0x);
   }
  
 + if (gpuobj-node)
 + nouveau_mm_free(gpuobj-node_heap, gpuobj-node);
 +
   if (gpuobj-heap.block_size)
 - nouveau_mm_fini(gpuobj-heap);
 + WARN_ON(nouveau_mm_fini(gpuobj-heap));
  
   nouveau_object_destroy(gpuobj-base);
  }
 @@ -114,6 +117,7 @@ nouveau_gpuobj_create_(struct nouveau_object *parent,
 max(align, (u32)1), gpuobj-node);
   if (ret)
   return ret;
 + gpuobj-node_heap = heap;
  
   gpuobj-addr += gpuobj-node-offset;
   }
 diff --git a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h 
 b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
 index d09adf1..f65bf5b 100644
 --- a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
 +++ b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
 @@ -16,7 +16,10 @@ struct nouveau_vm;
  struct nouveau_gpuobj {
   struct nouveau_object base;
   struct nouveau_object *parent;
 +
 + struct nouveau_mm *node_heap;
   struct nouveau_mm_node *node;
 +
   struct nouveau_mm heap;
  
   u32 flags;
 -- 

What's wrong with this patch?
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: remove redundant comments listing classes

2012-10-16 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/include/core/class.h | 31 +++
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/include/core/class.h 
b/drivers/gpu/drm/nouveau/core/include/core/class.h
index 6180ae9..5b739de 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/class.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/class.h
@@ -1,10 +1,7 @@
 #ifndef __NOUVEAU_CLASS_H__
 #define __NOUVEAU_CLASS_H__
 
-/* Device class
- *
- * 0080: NV_DEVICE
- */
+/* Device class */
 #define NV_DEVICE_CLASS  0x0080
 
 #define NV_DEVICE_DISABLE_IDENTIFY0x0001ULL
@@ -30,12 +27,7 @@ struct nv_device_class {
u64 debug0; /* as above, but *internal* ids, and *NOT* ABI */
 };
 
-/* DMA object classes
- *
- * 0002: NV_DMA_FROM_MEMORY
- * 0003: NV_DMA_TO_MEMORY
- * 003d: NV_DMA_IN_MEMORY
- */
+/* DMA object classes */
 #define NV_DMA_FROM_MEMORY_CLASS 0x0002
 #define NV_DMA_TO_MEMORY_CLASS   0x0003
 #define NV_DMA_IN_MEMORY_CLASS   0x003d
@@ -59,15 +51,7 @@ struct nv_dma_class {
u64 limit;
 };
 
-/* DMA FIFO channel classes
- *
- * 006b: NV03_CHANNEL_DMA
- * 006e: NV10_CHANNEL_DMA
- * 176e: NV17_CHANNEL_DMA
- * 406e: NV40_CHANNEL_DMA
- * 506e: NV50_CHANNEL_DMA
- * 826e: NV84_CHANNEL_DMA
- */
+/* DMA FIFO channel classes */
 #define NV03_CHANNEL_DMA_CLASS   0x006b
 #define NV10_CHANNEL_DMA_CLASS   0x006e
 #define NV17_CHANNEL_DMA_CLASS   0x176e
@@ -81,14 +65,7 @@ struct nv03_channel_dma_class {
u64 offset;
 };
 
-/* Indirect FIFO channel classes
- *
- * 506f: NV50_CHANNEL_IND
- * 826f: NV84_CHANNEL_IND
- * 906f: NVC0_CHANNEL_IND
- * a06f: NVE0_CHANNEL_IND
- */
-
+/* Indirect FIFO channel classes */
 #define NV50_CHANNEL_IND_CLASS   0x506f
 #define NV84_CHANNEL_IND_CLASS   0x826f
 #define NVC0_CHANNEL_IND_CLASS   0x906f
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nv50: wire up pll_calc hook

2012-10-11 Thread Marcin Slusarz
On Mon, Oct 08, 2012 at 12:49:27AM +0200, Marcin Slusarz wrote:
 Fixes crash during reclocking.
 Call Trace:
  pll_calc == NULL
  calc_pll
  calc_mclk
  nv50_pm_clocks_pre
  nouveau_pm_perflvl_set
  nouveau_pm_trigger
  nouveau_pm_profile_set
  nouveau_pm_set_perflvl
  dev_attr_store
  sysfs_write_file
  vfs_write
  sys_write
  system_call_fastpath
 
 Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
 ---
 
 It's weird nobody noticed this... nva3+ code does not set this hook either,
 but there's no existing function to wire up...
 
And it seems to crash in the same way, see:
http://www.phoronix.com/image-viewer.php?id=ubuntu_1210_nouvreimage=ubuntu_nouveau_pointer_lrg

BTW, reclocking crashes without this patch:
https://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commit/f3ed9b23ee611891166da9bac792a22844217c7a

Applying this patch:
https://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commit/abdd905d2bf362d48c125fd7c556c54c7ae1cbb9
would be good too, because perflvl module option is useless without it.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv50/fb: fix double free of vram mm

2012-10-11 Thread Marcin Slusarz
nouveau_fb_destroy already calls nouveau_mm_fini on vram mm.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c 
b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
index 767d9c4..275e062 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
@@ -277,7 +277,6 @@ nv50_fb_dtor(struct nouveau_object *object)
__free_page(priv-r100c08_page);
}
 
-   nouveau_mm_fini(priv-base.vram);
nouveau_fb_destroy(priv-base);
 }
 
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak

2012-10-11 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/gpuobj.c | 6 +-
 drivers/gpu/drm/nouveau/core/include/core/gpuobj.h | 3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c 
b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
index c2a7608..48121d2 100644
--- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
+++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
@@ -39,8 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
nv_wo32(gpuobj, i, 0x);
}
 
+   if (gpuobj-node)
+   nouveau_mm_free(gpuobj-node_heap, gpuobj-node);
+
if (gpuobj-heap.block_size)
-   nouveau_mm_fini(gpuobj-heap);
+   WARN_ON(nouveau_mm_fini(gpuobj-heap));
 
nouveau_object_destroy(gpuobj-base);
 }
@@ -114,6 +117,7 @@ nouveau_gpuobj_create_(struct nouveau_object *parent,
  max(align, (u32)1), gpuobj-node);
if (ret)
return ret;
+   gpuobj-node_heap = heap;
 
gpuobj-addr += gpuobj-node-offset;
}
diff --git a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h 
b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
index d09adf1..f65bf5b 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
@@ -16,7 +16,10 @@ struct nouveau_vm;
 struct nouveau_gpuobj {
struct nouveau_object base;
struct nouveau_object *parent;
+
+   struct nouveau_mm *node_heap;
struct nouveau_mm_node *node;
+
struct nouveau_mm heap;
 
u32 flags;
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: comment out unused _nouveau_parent_ctor

2012-10-08 Thread Marcin Slusarz
On Mon, Oct 08, 2012 at 11:07:34AM +1000, Ben Skeggs wrote:
 On Mon, Oct 08, 2012 at 12:49:28AM +0200, Marcin Slusarz wrote:
  Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
  ---
   drivers/gpu/drm/nouveau/core/core/parent.c | 2 ++
   drivers/gpu/drm/nouveau/core/include/core/parent.h | 3 +++
   2 files changed, 5 insertions(+)
 Feel free to just kill it completely.  There's a few bits and pieces
 of left-overs like this around the place, I'll be killing them as
 I run across them too.

OK.

---
From: Marcin Slusarz marcin.slus...@gmail.com
Subject: [PATCH] drm/nouveau: remove unused _nouveau_parent_ctor

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/parent.c | 17 -
 drivers/gpu/drm/nouveau/core/include/core/parent.h |  3 ---
 2 files changed, 20 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/parent.c 
b/drivers/gpu/drm/nouveau/core/core/parent.c
index a1ea034..db7c549 100644
--- a/drivers/gpu/drm/nouveau/core/core/parent.c
+++ b/drivers/gpu/drm/nouveau/core/core/parent.c
@@ -101,23 +101,6 @@ nouveau_parent_create_(struct nouveau_object *parent,
return 0;
 }
 
-int
-_nouveau_parent_ctor(struct nouveau_object *parent,
-struct nouveau_object *engine,
-struct nouveau_oclass *oclass, void *data, u32 size,
-struct nouveau_object **pobject)
-{
-   struct nouveau_parent *object;
-   int ret;
-
-   ret = nouveau_parent_create(parent, engine, oclass, 0, NULL, 0, 
object);
-   *pobject = nv_object(object);
-   if (ret)
-   return ret;
-
-   return 0;
-}
-
 void
 nouveau_parent_destroy(struct nouveau_parent *parent)
 {
diff --git a/drivers/gpu/drm/nouveau/core/include/core/parent.h 
b/drivers/gpu/drm/nouveau/core/include/core/parent.h
index d3aa251..3c2e940 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/parent.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/parent.h
@@ -50,9 +50,6 @@ int  nouveau_parent_create_(struct nouveau_object *, struct 
nouveau_object *,
int size, void **);
 void nouveau_parent_destroy(struct nouveau_parent *);
 
-int  _nouveau_parent_ctor(struct nouveau_object *, struct nouveau_object *,
- struct nouveau_oclass *, void *, u32,
- struct nouveau_object **);
 void _nouveau_parent_dtor(struct nouveau_object *);
 #define _nouveau_parent_init _nouveau_object_init
 #define _nouveau_parent_fini _nouveau_object_fini
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau: remove 1 sclass support from nouveau_parent_create_

2012-10-08 Thread Marcin Slusarz
On Mon, Oct 08, 2012 at 11:06:46AM +1000, Ben Skeggs wrote:
 On Mon, Oct 08, 2012 at 12:49:30AM +0200, Marcin Slusarz wrote:
  It's unused (only one codepath passes sclass at all and it's always one),
  broken (overwrites the same field, leaking previous one) and confusing.
 It's only *currently* unused, I have WIP code in branches that uses it,
 otherwise it wouldn't still exist :)

Yeah, like _nouveau_parent_ctor :P

 I will take a look today at the claims it's broken, it wasn't at some
 point but may have got busted along the way somehow.

Oh, it chains them in list...

/me hides.

Marcin
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nv50: wire up pll_calc hook

2012-10-07 Thread Marcin Slusarz
Fixes crash during reclocking.
Call Trace:
 pll_calc == NULL
 calc_pll
 calc_mclk
 nv50_pm_clocks_pre
 nouveau_pm_perflvl_set
 nouveau_pm_trigger
 nouveau_pm_profile_set
 nouveau_pm_set_perflvl
 dev_attr_store
 sysfs_write_file
 vfs_write
 sys_write
 system_call_fastpath

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---

It's weird nobody noticed this... nva3+ code does not set this hook either,
but there's no existing function to wire up...

---
 drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c 
b/drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c
index fd181fb..f4147f6 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c
@@ -90,6 +90,7 @@ nv50_clock_ctor(struct nouveau_object *parent, struct 
nouveau_object *engine,
return ret;
 
priv-base.pll_set = nv50_clock_pll_set;
+   priv-base.pll_calc = nv04_clock_pll_calc;
return 0;
 }
 
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: comment out unused _nouveau_parent_ctor

2012-10-07 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/core/parent.c | 2 ++
 drivers/gpu/drm/nouveau/core/include/core/parent.h | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/core/core/parent.c 
b/drivers/gpu/drm/nouveau/core/core/parent.c
index a1ea034..0e7733c 100644
--- a/drivers/gpu/drm/nouveau/core/core/parent.c
+++ b/drivers/gpu/drm/nouveau/core/core/parent.c
@@ -101,6 +101,7 @@ nouveau_parent_create_(struct nouveau_object *parent,
return 0;
 }
 
+#if 0
 int
 _nouveau_parent_ctor(struct nouveau_object *parent,
 struct nouveau_object *engine,
@@ -117,6 +118,7 @@ _nouveau_parent_ctor(struct nouveau_object *parent,
 
return 0;
 }
+#endif
 
 void
 nouveau_parent_destroy(struct nouveau_parent *parent)
diff --git a/drivers/gpu/drm/nouveau/core/include/core/parent.h 
b/drivers/gpu/drm/nouveau/core/include/core/parent.h
index d3aa251..58bf6b5 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/parent.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/parent.h
@@ -50,9 +50,12 @@ int  nouveau_parent_create_(struct nouveau_object *, struct 
nouveau_object *,
int size, void **);
 void nouveau_parent_destroy(struct nouveau_parent *);
 
+#if 0
 int  _nouveau_parent_ctor(struct nouveau_object *, struct nouveau_object *,
  struct nouveau_oclass *, void *, u32,
  struct nouveau_object **);
+#endif
+
 void _nouveau_parent_dtor(struct nouveau_object *);
 #define _nouveau_parent_init _nouveau_object_init
 #define _nouveau_parent_fini _nouveau_object_fini
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH] drm/nouveau: add some comments about class fields

2012-10-07 Thread Marcin Slusarz
Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/core/include/core/engine.h | 4 
 drivers/gpu/drm/nouveau/core/include/core/parent.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/core/include/core/engine.h 
b/drivers/gpu/drm/nouveau/core/include/core/engine.h
index 666d06d..09b2828 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/engine.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/engine.h
@@ -9,7 +9,11 @@
 
 struct nouveau_engine {
struct nouveau_subdev base;
+
+   /* context class */
struct nouveau_oclass *cclass;
+
+   /* array of possible subclasses */
struct nouveau_oclass *sclass;
 
struct list_head contexts;
diff --git a/drivers/gpu/drm/nouveau/core/include/core/parent.h 
b/drivers/gpu/drm/nouveau/core/include/core/parent.h
index 58bf6b5..31a32b0 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/parent.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/parent.h
@@ -13,6 +13,7 @@ struct nouveau_sclass {
 struct nouveau_parent {
struct nouveau_object base;
 
+   /* subclass */
struct nouveau_sclass *sclass;
u32 engine;
 
-- 
1.7.12

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


  1   2   3   4   >