[PATCH 2/5] drm/nouveau/kms: Implement KDB debug hooks for nouveau KMS.

Previous thread: [PATCH 3/5] drm,kdb,kms: Add an enter argument to mode_set_base_atomic() API by Jason Wessel on Tuesday, October 12, 2010 - 11:15 am. (1 message)

Next thread: Re: 2.6.36-rc7: NULL pointer dereference in ehci_clear_tt_buffer_complete by Alan Stern on Tuesday, October 12, 2010 - 11:23 am. (1 message)
From: Jason Wessel
Date: Tuesday, October 12, 2010 - 11:15 am

What is new in patch set v3

  * Patch 3 - Per comment from Jesse Barnes change enter arg for
    mode_set_base_atomic() to be an enum
  * Patch 4 - Fixed a defect in the LUT save/restore where it should
    have used ctrc->gamma_size instead of the local size variable
  * Patch 5 - Context changes from the prior versions

---

What is new in patch set v2

  * patch 4 which was previously radeon specific was replaced with a
    generic patch to save and restore the LUT data for all drivers
  * minor white space cleanup vs checkpatch.pl in patches

---

The goal of this patch set is to add atomic kernel mode setting hooks
for the radeon and nouveau cards for the purpose of using kdb (the
kernel debug shell).

David Airlie had asked for more research into the gamma data
corruption after initially reviewing the patch that attempts to solve
the visible palette corruption after an atomic mode set operation.
The final conclusion was that other types of pallet corruption are
possible with the gamma data when using atomic mode setting so the
problem should be solved generically.

The mode_set_base_atomic() now receives and additional parameter to
note of the atomic mode set operation is an enter or exit such that a
driver can appropriately enable or disable hardware that will not work
in the polling context.

These patches have now passed the kgdb/kdb regression tests and are
deemed stable and ready for further integration and comment with the
hope of integrating the patches upstream.

Many thanks to Chris Ball for the contribution of the radeon and
nouveau hooks, as well as the time he spent helping debug the initial
LUT save and restore.

Thanks,
Jason.

---
The following changes since commit 29979aa8bd69becd94cbad59093807a417ce2a9e:
  Linus Torvalds (1):
        Merge branch 'rc-fixes' of git://git.kernel.org/.../mmarek/kbuild-2.6

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb.git for_dri

Chris ...
From: Jason Wessel
Date: Tuesday, October 12, 2010 - 11:15 am

When changing VTs non-atomically the kernel works in conjunction with
the Xserver in user space and receives the LUT information from the
Xserver via a system call.  When changing modes atomically for kdb,
this information must be saved and restored without disturbing user
space as if nothing ever happened.

There is a short cut used by this patch where gamma_store is used as
the save space.  If this turns out to be a problem in the future a
pre-allocated chunk of memory will be required for each crtc to save
and restore the LUT information.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
CC: Jesse Barnes <jbarnes@virtuousgeek.org>
CC: David Airlie <airlied@linux.ie>
CC: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/drm_fb_helper.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 74bac82..5c8fbfa 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -242,6 +242,34 @@ static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper)
 	return 0;
 }
 
+static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct drm_fb_helper *helper)
+{
+	int size;
+	uint16_t *r_base, *g_base, *b_base;
+	int i;
+
+	size = crtc->gamma_size * (sizeof(uint16_t));
+	r_base = crtc->gamma_store;
+	g_base = r_base + size;
+	b_base = g_base + size;
+
+	for (i = 0; i < crtc->gamma_size; i++)
+		helper->funcs->gamma_get(crtc, &r_base[i], &g_base[i], &b_base[i], i);
+}
+
+static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
+{
+	int size;
+	uint16_t *r_base, *g_base, *b_base;
+
+	size = crtc->gamma_size * (sizeof(uint16_t));
+	r_base = crtc->gamma_store;
+	g_base = r_base + size;
+	b_base = g_base + size;
+
+	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, size);
+}
+
 int drm_fb_helper_debug_enter(struct fb_info *info)
 {
 	struct drm_fb_helper *helper = ...
From: Jason Wessel
Date: Tuesday, October 12, 2010 - 11:15 am

From: Chris Ball <cjb@laptop.org>

Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
CC: Jesse Barnes <jbarnes@virtuousgeek.org>
CC: David Airlie <airlied@linux.ie>
CC: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/radeon/atombios_crtc.c      |  117 +++++++++++++++++++--------
 drivers/gpu/drm/radeon/radeon_fb.c          |    2 +
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |   44 ++++++++---
 drivers/gpu/drm/radeon/radeon_mode.h        |   10 ++-
 4 files changed, 126 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index cd0290f..58f7b15 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -854,13 +854,15 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
 
 }
 
-static int evergreen_crtc_set_base(struct drm_crtc *crtc, int x, int y,
-				   struct drm_framebuffer *old_fb)
+static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
+				      struct drm_framebuffer *fb,
+				      int x, int y, int atomic)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_framebuffer *radeon_fb;
+	struct drm_framebuffer *target_fb;
 	struct drm_gem_object *obj;
 	struct radeon_bo *rbo;
 	uint64_t fb_location;
@@ -868,28 +870,42 @@ static int evergreen_crtc_set_base(struct drm_crtc *crtc, int x, int y,
 	int r;
 
 	/* no fb bound */
-	if (!crtc->fb) {
+	if (!atomic && !crtc->fb) {
 		DRM_DEBUG_KMS("No FB bound\n");
 		return 0;
 	}
 
-	radeon_fb = to_radeon_framebuffer(crtc->fb);
+	if (atomic) {
+		radeon_fb = to_radeon_framebuffer(fb);
+		target_fb = fb;
+	} else {
+		radeon_fb = to_radeon_framebuffer(crtc->fb);
+		target_fb = crtc->fb;
+	}
 
-	/* Pin framebuffer & get tilling informations */
+	/* If atomic, assume fb object is pinned & idle & ...
From: Jason Wessel
Date: Tuesday, October 12, 2010 - 11:15 am

From: Chris Ball <cjb@laptop.org>

Francisco Jerez advises that pre-nv20 cards would hang if we entered
kdb with accel on and IRQs disabled, so we now disable accel before
entering kdb and re-enable it on the way back out.

Reported-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
 drivers/gpu/drm/nouveau/nv04_crtc.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c
index dc44ccc..aa6b82f 100644
--- a/drivers/gpu/drm/nouveau/nv04_crtc.c
+++ b/drivers/gpu/drm/nouveau/nv04_crtc.c
@@ -33,6 +33,7 @@
 #include "nouveau_fb.h"
 #include "nouveau_hw.h"
 #include "nvreg.h"
+#include "nouveau_fbcon.h"
 
 static int
 nv04_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
@@ -859,6 +860,14 @@ nv04_crtc_mode_set_base_atomic(struct drm_crtc *crtc,
 			       struct drm_framebuffer *fb,
 			       int x, int y, enum mode_set_atomic state)
 {
+	struct drm_nouveau_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = dev_priv->dev;
+
+	if (state == ENTER_ATOMIC_MODE_SET)
+		nouveau_fbcon_save_disable_accel(dev);
+	else
+		nouveau_fbcon_restore_accel(dev);
+
 	return nv04_crtc_do_mode_set_base(crtc, fb, x, y, true);
 }
 
-- 
1.6.3.3

--

From: Jason Wessel
Date: Tuesday, October 12, 2010 - 11:15 am

From: Chris Ball <cjb@laptop.org>

Tested on nv50 and nv04 HW.

Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
CC: Jesse Barnes <jbarnes@virtuousgeek.org>
CC: David Airlie <airlied@linux.ie>
CC: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |    6 ++++
 drivers/gpu/drm/nouveau/nv04_crtc.c     |   45 +++++++++++++++++++++++-----
 drivers/gpu/drm/nouveau/nv50_crtc.c     |   48 ++++++++++++++++++++++--------
 3 files changed, 78 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index dbd30b2..02a4d1f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -104,6 +104,8 @@ static struct fb_ops nouveau_fbcon_ops = {
 	.fb_pan_display = drm_fb_helper_pan_display,
 	.fb_blank = drm_fb_helper_blank,
 	.fb_setcmap = drm_fb_helper_setcmap,
+	.fb_debug_enter = drm_fb_helper_debug_enter,
+	.fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
 static struct fb_ops nv04_fbcon_ops = {
@@ -117,6 +119,8 @@ static struct fb_ops nv04_fbcon_ops = {
 	.fb_pan_display = drm_fb_helper_pan_display,
 	.fb_blank = drm_fb_helper_blank,
 	.fb_setcmap = drm_fb_helper_setcmap,
+	.fb_debug_enter = drm_fb_helper_debug_enter,
+	.fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
 static struct fb_ops nv50_fbcon_ops = {
@@ -130,6 +134,8 @@ static struct fb_ops nv50_fbcon_ops = {
 	.fb_pan_display = drm_fb_helper_pan_display,
 	.fb_blank = drm_fb_helper_blank,
 	.fb_setcmap = drm_fb_helper_setcmap,
+	.fb_debug_enter = drm_fb_helper_debug_enter,
+	.fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
 static void nouveau_fbcon_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c
index 497df87..9d214f5 100644
--- a/drivers/gpu/drm/nouveau/nv04_crtc.c
+++ b/drivers/gpu/drm/nouveau/nv04_crtc.c
@@ -768,8 +768,9 @@ ...
Previous thread: [PATCH 3/5] drm,kdb,kms: Add an enter argument to mode_set_base_atomic() API by Jason Wessel on Tuesday, October 12, 2010 - 11:15 am. (1 message)

Next thread: Re: 2.6.36-rc7: NULL pointer dereference in ehci_clear_tt_buffer_complete by Alan Stern on Tuesday, October 12, 2010 - 11:23 am. (1 message)