mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Jason Wessel <jason.wessel@windriver.com>
Cc: linux-kernel@vger.kernel.org,
	kgdb-bugreport@lists.sourceforge.net, kdb@oss.sgi.com,
	mingo@elte.hu
Subject: Re: [PATCH 33/37] drm: add KGDB/KDB support Add support for KDB entry/exit.
Date: Mon, 4 Jan 2010 09:23:35 -0800	[thread overview]
Message-ID: <20100104092335.7c52f249@jbarnes-piketon> (raw)
In-Reply-To: <1261604584-5796-1-git-send-email-jason.wessel@windriver.com>

Can you send this one over to Dave Airlie <airlied@linux.ie>?  At KS he
indicated he'd be happy to just apply it, since other drivers will need
it too (along with the driver specific code of course).

Jesse

On Wed, 23 Dec 2009 15:43:00 -0600
Jason Wessel <jason.wessel@windriver.com> wrote:

> From: Jesse Barnes <jbarnes@virtuousgeek.org>
> 
> ---
>  drivers/gpu/drm/drm_fb_helper.c      |   83
> ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_display.c
> |   93 ++++++++++++++++++++++++++++++++++
> include/drm/drm_crtc_helper.h        |    2 +
> include/drm/drm_fb_helper.h          |    4 ++ 4 files changed, 182
> insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c
> b/drivers/gpu/drm/drm_fb_helper.c index 1b49fa0..80aab3c 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -29,6 +29,7 @@
>   */
>  #include <linux/sysrq.h>
>  #include <linux/fb.h>
> +#include <linux/kgdb.h>
>  #include "drmP.h"
>  #include "drm_crtc.h"
>  #include "drm_fb_helper.h"
> @@ -233,6 +234,84 @@ int drm_fb_helper_parse_command_line(struct
> drm_device *dev) return 0;
>  }
>  
> +#define to_fb_helper(ops) (container_of((ops), struct drm_fb_helper,
> kdb_ops)) +
> +static int drm_fb_kdb_enter(struct dbg_kms_console_ops *ops)
> +{
> +	struct drm_fb_helper *helper = to_fb_helper(ops);
> +	struct drm_crtc_helper_funcs *funcs;
> +	int i;
> +
> +	if (atomic_read(&kgdb_active))
> +		goto out; /* already in KDB, don't reset mode */
> +
> +	if (list_empty(&kernel_fb_helper_list))
> +		return false;
> +
> +	list_for_each_entry(helper, &kernel_fb_helper_list,
> kernel_fb_list) {
> +		for (i = 0; i < helper->crtc_count; i++) {
> +			struct drm_mode_set *mode_set =
> +				&helper->crtc_info[i].mode_set;
> +
> +			if (!mode_set->crtc->enabled)
> +				continue;
> +
> +			funcs =
> mode_set->crtc->helper_private;
> +			funcs->mode_set_base_atomic(mode_set->crtc,
> +						    mode_set->fb,
> +						    mode_set->x,
> +						    mode_set->y);
> +
> +		}
> +	}
> +
> +out:
> +	return 0;
> +}
> +
> +/* Find the real fb for a given fb helper CRTC */
> +static struct drm_framebuffer *drm_mode_config_fb(struct drm_crtc
> *crtc) +{
> +	struct drm_device *dev = crtc->dev;
> +	struct drm_crtc *c;
> +
> +	list_for_each_entry(c, &dev->mode_config.crtc_list, head) {
> +		if (crtc->base.id == c->base.id)
> +			return c->fb;
> +	}
> +
> +	return NULL;
> +}
> +
> +static int drm_fb_kdb_exit(struct dbg_kms_console_ops *ops)
> +{
> +	struct drm_fb_helper *helper = to_fb_helper(ops);
> +	struct drm_crtc *crtc;
> +	struct drm_crtc_helper_funcs *funcs;
> +	struct drm_framebuffer *fb;
> +	int i;
> +
> +	for (i = 0; i < helper->crtc_count; i++) {
> +		struct drm_mode_set *mode_set =
> &helper->crtc_info[i].mode_set;
> +		crtc = mode_set->crtc;
> +		funcs = crtc->helper_private;
> +		fb = drm_mode_config_fb(crtc);
> +
> +		if (!crtc->enabled)
> +			continue;
> +
> +		if (!fb) {
> +			DRM_ERROR("no fb to restore??\n");
> +			continue;
> +		}
> +
> +		funcs->mode_set_base_atomic(mode_set->crtc, fb,
> crtc->x,
> +					    crtc->y);
> +	}
> +
> +	return 0;
> +}
> +
>  bool drm_fb_helper_force_kernel_mode(void)
>  {
>  	int i = 0;
> @@ -924,6 +1003,9 @@ int drm_fb_helper_single_fb_probe(struct
> drm_device *dev, /* Switch back to kernel console on panic */
>  	/* multi card linked list maybe */
>  	if (list_empty(&kernel_fb_helper_list)) {
> +		fb_helper->kdb_ops.activate_console =
> drm_fb_kdb_enter;
> +		fb_helper->kdb_ops.restore_console = drm_fb_kdb_exit;
> +		dbg_kms_console_ops_register(&fb_helper->kdb_ops);
>  		printk(KERN_INFO "registered panic notifier\n");
>  		atomic_notifier_chain_register(&panic_notifier_list,
>  					       &paniced);
> @@ -938,6 +1020,7 @@ void drm_fb_helper_free(struct drm_fb_helper
> *helper) {
>  	list_del(&helper->kernel_fb_list);
>  	if (list_empty(&kernel_fb_helper_list)) {
> +		dbg_kms_console_ops_unregister(&helper->kdb_ops);
>  		printk(KERN_INFO "unregistered panic notifier\n");
>  		atomic_notifier_chain_unregister(&panic_notifier_list,
>  						 &paniced);
> diff --git a/drivers/gpu/drm/i915/intel_display.c
> b/drivers/gpu/drm/i915/intel_display.c index 52cd9b0..e134a81 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -1234,6 +1234,98 @@ intel_pin_and_fence_fb_obj(struct drm_device
> *dev, struct drm_gem_object *obj) return 0;
>  }
>  
> +/* Assume fb object is pinned & idle & fenced and just update base
> pointers */ +static int
> +intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct
> drm_framebuffer *fb,
> +			   int x, int y)
> +{
> +	struct drm_device *dev = crtc->dev;
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> +	struct intel_framebuffer *intel_fb;
> +	struct drm_i915_gem_object *obj_priv;
> +	struct drm_gem_object *obj;
> +	int plane = intel_crtc->plane;
> +	unsigned long Start, Offset;
> +	int dspbase = (plane == 0 ? DSPAADDR : DSPBADDR);
> +	int dspsurf = (plane == 0 ? DSPASURF : DSPBSURF);
> +	int dspstride = (plane == 0) ? DSPASTRIDE : DSPBSTRIDE;
> +	int dsptileoff = (plane == 0 ? DSPATILEOFF : DSPBTILEOFF);
> +	int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR;
> +	u32 dspcntr;
> +
> +	switch (plane) {
> +	case 0:
> +	case 1:
> +		break;
> +	default:
> +		DRM_ERROR("Can't update plane %d in SAREA\n", plane);
> +		return -EINVAL;
> +	}
> +
> +	intel_fb = to_intel_framebuffer(fb);
> +	obj = intel_fb->obj;
> +	obj_priv = obj->driver_private;
> +
> +	dspcntr = I915_READ(dspcntr_reg);
> +	/* Mask out pixel format bits in case we change it */
> +	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
> +	switch (fb->bits_per_pixel) {
> +	case 8:
> +		dspcntr |= DISPPLANE_8BPP;
> +		break;
> +	case 16:
> +		if (fb->depth == 15)
> +			dspcntr |= DISPPLANE_15_16BPP;
> +		else
> +			dspcntr |= DISPPLANE_16BPP;
> +		break;
> +	case 24:
> +	case 32:
> +		dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
> +		break;
> +	default:
> +		DRM_ERROR("Unknown color depth\n");
> +		return -EINVAL;
> +	}
> +	if (IS_I965G(dev)) {
> +		if (obj_priv->tiling_mode != I915_TILING_NONE)
> +			dspcntr |= DISPPLANE_TILED;
> +		else
> +			dspcntr &= ~DISPPLANE_TILED;
> +	}
> +
> +	if (IS_IRONLAKE(dev))
> +		/* must disable */
> +		dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
> +
> +	I915_WRITE(dspcntr_reg, dspcntr);
> +
> +	Start = obj_priv->gtt_offset;
> +	Offset = y * fb->pitch + x * (fb->bits_per_pixel / 8);
> +
> +	DRM_DEBUG("Writing base %08lX %08lX %d %d\n", Start, Offset,
> x, y);
> +	I915_WRITE(dspstride, fb->pitch);
> +	if (IS_I965G(dev)) {
> +		I915_WRITE(dspbase, Offset);
> +		I915_READ(dspbase);
> +		I915_WRITE(dspsurf, Start);
> +		I915_READ(dspsurf);
> +		I915_WRITE(dsptileoff, (y << 16) | x);
> +	} else {
> +		I915_WRITE(dspbase, Start + Offset);
> +		I915_READ(dspbase);
> +	}
> +
> +	if ((IS_I965G(dev) || plane == 0))
> +		intel_update_fbc(crtc, &crtc->mode);
> +
> +	intel_wait_for_vblank(dev);
> +	intel_increase_pllclock(crtc, true);
> +
> +	return 0;
> +}
> +
>  static int
>  intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
>  		    struct drm_framebuffer *old_fb)
> @@ -4243,6 +4335,7 @@ static const struct drm_crtc_helper_funcs
> intel_helper_funcs = { .mode_fixup = intel_crtc_mode_fixup,
>  	.mode_set = intel_crtc_mode_set,
>  	.mode_set_base = intel_pipe_set_base,
> +	.mode_set_base_atomic = intel_pipe_set_base_atomic,
>  	.prepare = intel_crtc_prepare,
>  	.commit = intel_crtc_commit,
>  	.load_lut = intel_crtc_load_lut,
> diff --git a/include/drm/drm_crtc_helper.h
> b/include/drm/drm_crtc_helper.h index b29e201..4c12319 100644
> --- a/include/drm/drm_crtc_helper.h
> +++ b/include/drm/drm_crtc_helper.h
> @@ -61,6 +61,8 @@ struct drm_crtc_helper_funcs {
>  	/* Move the crtc on the current fb to the given position
> *optional* */ int (*mode_set_base)(struct drm_crtc *crtc, int x, int
> y, struct drm_framebuffer *old_fb);
> +	int (*mode_set_base_atomic)(struct drm_crtc *crtc,
> +				    struct drm_framebuffer *fb, int
> x, int y); 
>  	/* reload the current crtc LUT */
>  	void (*load_lut)(struct drm_crtc *crtc);
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index 58c892a..c4f87a5 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -30,6 +30,8 @@
>  #ifndef DRM_FB_HELPER_H
>  #define DRM_FB_HELPER_H
>  
> +#include <linux/kgdb.h>
> +
>  struct drm_fb_helper_crtc {
>  	uint32_t crtc_id;
>  	struct drm_mode_set mode_set;
> @@ -63,8 +65,10 @@ struct drm_fb_helper_connector {
>  
>  struct drm_fb_helper {
>  	struct drm_framebuffer *fb;
> +	struct drm_framebuffer *saved_fb;
>  	struct drm_device *dev;
>  	struct drm_display_mode *mode;
> +	struct dbg_kms_console_ops kdb_ops;
>  	int crtc_count;
>  	struct drm_fb_helper_crtc *crtc_info;
>  	struct drm_fb_helper_funcs *funcs;


-- 
Jesse Barnes, Intel Open Source Technology Center

  parent reply	other threads:[~2010-01-04 17:23 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-23 21:19 [PATCH 0/37] kgdb, kdb and atomic kernel modesetting series Jason Wessel
2009-12-23 21:19 ` [PATCH 01/37] softlockup: add sched_clock_tick() to avoid kernel warning on kgdb resume Jason Wessel
2009-12-23 21:19   ` [PATCH 02/37] x86,hw_breakpoint,kgdb: kgdb to use hw_breakpoint API Jason Wessel
2009-12-23 21:19     ` [PATCH 03/37] Move kernel/kgdb.c to kernel/debug/debug_core.c Jason Wessel
2009-12-23 21:19       ` [PATCH 04/37] Separate the gdbstub from the debug core Jason Wessel
2009-12-23 21:19         ` [PATCH 05/37] kdb: core for kgdb back end Jason Wessel
2009-12-23 21:19           ` [PATCH 06/37] kgdb: eliminate kgdb_wait(), all cpus enter the same way Jason Wessel
2009-12-23 21:19             ` [PATCH 07/37] kgdb,sparc: Add in kgdb_arch_set_pc for sparc Jason Wessel
2009-12-23 21:19               ` [PATCH 08/37] kgdb,sh: update superh kgdb exception handling Jason Wessel
2009-12-23 21:19                 ` [PATCH 09/37] kgdb,blackfin: Add in kgdb_arch_set_pc for blackfin Jason Wessel
2009-12-23 21:19                   ` [PATCH 10/37] kgdb: Make mem access function weak in kgdb.c and kgdb.h Jason Wessel
2009-12-23 21:19                     ` [PATCH 11/37] kgdb: Fix kernel-doc format error in kgdb.h Jason Wessel
2009-12-23 21:19                       ` [PATCH 12/37] kgdb: core changes to support kdb Jason Wessel
2009-12-23 21:19                         ` [PATCH 13/37] kgdb,8250,pl011: Return immediately from console poll Jason Wessel
2009-12-23 21:19                           ` [PATCH 14/37] sh,sh-sci: Use NO_POLL_CHAR in the SCIF polled console code Jason Wessel
2009-12-23 21:19                             ` [PATCH 15/37] sparc,sunzilog: Add console polling support for sunzilog serial driver Jason Wessel
2009-12-23 21:19                               ` [PATCH 16/37] kgdb: gdb "monitor" -> kdb passthrough Jason Wessel
2009-12-23 21:19                                 ` [PATCH 17/37] kgdboc,keyboard: Keyboard driver for kdb with kgdb Jason Wessel
2009-12-23 21:19                                   ` [PATCH 18/37] kgdb: remove post_primary_code references Jason Wessel
2009-12-23 21:19                                     ` [PATCH 19/37] x86,kgdb: Add low level debug hook Jason Wessel
2009-12-23 21:19                                       ` [PATCH 20/37] arm,kgdb: Add hook to catch an oops with debugger Jason Wessel
2009-12-23 21:19                                         ` [PATCH 21/37] powerpc,kgdb: Introduce low level trap catching Jason Wessel
2009-12-23 21:19                                           ` [PATCH 22/37] mips,kgdb: kdb low level trap catch and stack trace Jason Wessel
2009-12-23 21:19                                             ` [PATCH 23/37] kgdb: Add the ability to schedule a breakpoint via a tasklet Jason Wessel
2009-12-23 21:19                                               ` [PATCH 24/37] kgdboc,kdb: Allow kdb to work on a non open console port Jason Wessel
2009-12-23 21:19                                                 ` [PATCH 25/37] printk,kdb: capture printk() when in kdb shell Jason Wessel
2009-12-23 21:19                                                   ` [PATCH 26/37] keyboard, input: Add hook to input to allow low level event clear Jason Wessel
2009-12-23 21:19                                                     ` [PATCH 27/37] debug_core,kdb: Allow the debug core to process a recursive debug entry Jason Wessel
2009-12-23 21:19                                                       ` [PATCH 28/37] kdb,panic,debug_core: Allow the debug core to receive a panic before smp_send_stop() Jason Wessel
2009-12-23 21:19                                                         ` [PATCH 29/37] MAINTAINERS: update kgdb, kdb, and debug_core info Jason Wessel
2009-12-23 21:19                                                           ` [PATCH 30/37] kgdboc,debug_core: Add call backs to allow kernel mode switching Jason Wessel
2009-12-23 21:19                                                             ` [PATCH 31/37] kgdb: add ops arg to kgdb console active & restore hooks Jason Wessel
2009-12-23 21:19                                                               ` [PATCH 32/37] kms,kdb: Force unblank a console device Jason Wessel
2009-12-23 21:43                                                                 ` [PATCH 33/37] drm: add KGDB/KDB support Add support for KDB entry/exit Jason Wessel
2009-12-23 21:43                                                                   ` [PATCH 34/37] i915: when kgdb is active display compression should be off Jason Wessel
2009-12-23 21:43                                                                     ` [PATCH 35/37] drm_fb_helper: Preserve capability to use atomic kms Jason Wessel
2009-12-23 21:43                                                                       ` [PATCH 36/37] drm,i915 - atomic mutex hacks Jason Wessel
2009-12-23 21:43                                                                         ` [PATCH 37/37] kgdbts,sh: Add in breakpoint pc offset for superh Jason Wessel
2009-12-24  3:58                                                                           ` Paul Mundt
2010-01-04 17:23                                                                   ` Jesse Barnes [this message]
2009-12-23 21:50                               ` [PATCH 15/37] sparc,sunzilog: Add console polling support for sunzilog serial driver David Miller
2009-12-23 21:54                                 ` Jason Wessel
2009-12-23 22:00                                   ` David Miller
2009-12-24  6:08                             ` [PATCH 14/37] sh,sh-sci: Use NO_POLL_CHAR in the SCIF polled console code Paul Mundt
2009-12-26 21:07                     ` [PATCH 10/37] kgdb: Make mem access function weak in kgdb.c and kgdb.h Mike Frysinger
2009-12-26 21:12                   ` [PATCH 09/37] kgdb,blackfin: Add in kgdb_arch_set_pc for blackfin Mike Frysinger
2009-12-28  9:49                     ` Zhang, Sonic
2009-12-28  9:57                     ` Zhang, Sonic
2009-12-28 10:17                     ` Zhang, Sonic
2009-12-31  2:45                       ` Sonic Zhang
2010-01-06 19:43                         ` [Kgdb-bugreport] " Jason Wessel
2010-01-06 20:08                           ` Mike Frysinger
2010-01-06 20:34                             ` Jason Wessel
2010-01-06 20:39                               ` Mike Frysinger
2010-01-06 22:40                                 ` Jason Wessel
2010-01-07  6:27                                   ` Mike Frysinger
2010-01-07  3:50                           ` Zhang, Sonic
2009-12-24  6:07                 ` [PATCH 08/37] kgdb,sh: update superh kgdb exception handling Paul Mundt
2009-12-23 21:48               ` [PATCH 07/37] kgdb,sparc: Add in kgdb_arch_set_pc for sparc David Miller
2009-12-23 23:04                 ` Jason Wessel
2009-12-24  4:42                   ` David Miller
2009-12-24  1:28           ` [PATCH 05/37] kdb: core for kgdb back end Andi Kleen
2009-12-28 22:36             ` Jason Wessel
2009-12-28 23:37               ` Andi Kleen
2009-12-24 11:01           ` Peter Zijlstra
2009-12-24 11:16             ` Peter Zijlstra
2009-12-24 15:57               ` Jason Wessel
2009-12-26 21:34                 ` Mike Frysinger
2009-12-24 11:55             ` Jason Wessel
2009-12-24 12:01               ` Peter Zijlstra
2009-12-24 11:04           ` Peter Zijlstra
2009-12-28 16:33             ` Jason Wessel
2009-12-28 16:55               ` Peter Zijlstra
2009-12-28 17:15                 ` Jason Wessel
2009-12-24  0:56 ` [PATCH 0/37] kgdb, kdb and atomic kernel modesetting series Greg KH
2009-12-24  3:55   ` [Kgdb-bugreport] [PATCH 0/37] kgdb,kdb " Jason Wessel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100104092335.7c52f249@jbarnes-piketon \
    --to=jbarnes@virtuousgeek.org \
    --cc=jason.wessel@windriver.com \
    --cc=kdb@oss.sgi.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome