public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: greg@kroah.com, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Subject: [PATCH 09/15] gma500: Do sane FB cleanup
Date: Wed, 08 Jun 2011 11:13:54 +0100	[thread overview]
Message-ID: <20110608101334.9478.58564.stgit@localhost.localdomain> (raw)
In-Reply-To: <20110608100411.9478.86672.stgit@localhost.localdomain>

From: Alan Cox <alan@linux.intel.com>

If we get a user frame buffer destroyed which is being displayed then clean
up the mess nicely. We can now run a slightly modified modetest including setting
modes, and handling crashes.

Modetest still blows up but this is because libdrm 2.4.25 is busted.


Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/gma500/psb_fb.c            |   24 +++++++++++++++++++++++-
 drivers/staging/gma500/psb_intel_display.c |   22 +++++++++++++---------
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/gma500/psb_fb.c b/drivers/staging/gma500/psb_fb.c
index 5977add..d005025 100644
--- a/drivers/staging/gma500/psb_fb.c
+++ b/drivers/staging/gma500/psb_fb.c
@@ -719,16 +719,38 @@ static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
 	struct psb_framebuffer *psbfb = to_psb_fb(fb);
 	struct gtt_range *r = psbfb->gtt;
+	struct drm_device *dev = fb->dev;
+	struct drm_psb_private *dev_priv = dev->dev_private;
+	struct psb_fbdev *fbdev = dev_priv->fbdev;
+	struct drm_crtc *crtc;
+	int reset = 0;
 
 	/* Should never get stolen memory for a user fb */
 	WARN_ON(r->stolen);
 	pr_err("user framebuffer destroy %p, fbdev %p\n",
 						psbfb, psbfb->fbdev);
+	/* Check if we are erroneously live */
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
+		if (crtc->fb == fb)
+			reset = 1;
+
+	if (reset)
+		pr_err("DRM: gma500, forcing reset\n");
+
+	if (reset)
+		/* 
+		 * Now force a sane response before we permit the DRM crc layer to
+		 * do stupid things like blank the display. Instead we reset this
+		 * framebuffer as if the user had forced a reset. We must do this
+		 * before the cleanup so that the DRM layer doesn't get a chance
+		 * to stick its oar in where it isn't wanted.
+		 */
+		drm_fb_helper_restore_fbdev_mode(&fbdev->psb_fb_helper);
+
         /* Let DRM do its clean up */
 	drm_framebuffer_cleanup(fb);
 	/*  We are no longer using the resource in GEM */
 	drm_gem_object_unreference_unlocked(&r->gem);
-
 	kfree(fb);
 }
 
diff --git a/drivers/staging/gma500/psb_intel_display.c b/drivers/staging/gma500/psb_intel_display.c
index a99271d..c7c55b1 100644
--- a/drivers/staging/gma500/psb_intel_display.c
+++ b/drivers/staging/gma500/psb_intel_display.c
@@ -352,15 +352,15 @@ int psb_intel_pipe_set_base(struct drm_crtc *crtc,
 
 	PSB_DEBUG_ENTRY("\n");
 
+	if (!gma_power_begin(dev, true))
+		return 0;
+
 	/* no fb bound */
 	if (!crtc->fb) {
 		DRM_DEBUG("No FB bound\n");
-		return 0;
+		goto psb_intel_pipe_cleaner;
 	}
 
-	if (!gma_power_begin(dev, true))
-		return 0;
-
 	/* We are displaying this buffer, make sure it is actually loaded
 	   into the GTT */
 	ret = psb_gtt_pin(psbfb->gtt);
@@ -409,6 +409,7 @@ int psb_intel_pipe_set_base(struct drm_crtc *crtc,
 		REG_READ(dspbase);
 	}
 
+psb_intel_pipe_cleaner:
 	/* If there was a previous display we can now unpin it */
 	if (old_fb)
 		psb_gtt_unpin(to_psb_fb(old_fb)->gtt);
@@ -588,6 +589,7 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
 {
 	struct drm_device *dev = crtc->dev;
 	struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
+	struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
 	int pipe = psb_intel_crtc->pipe;
 	int fp_reg = (pipe == 0) ? FPA0 : FPB0;
 	int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
@@ -610,6 +612,12 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
 	struct drm_mode_config *mode_config = &dev->mode_config;
 	struct drm_connector *connector;
 
+	/* No scan out no play */
+	if (crtc->fb == NULL) {
+	        crtc_funcs->mode_set_base(crtc, x, y, old_fb);
+                return 0;
+        }
+
 	list_for_each_entry(connector, &mode_config->connector_list, head) {
 		struct psb_intel_output *psb_intel_output =
 		    to_psb_intel_output(connector);
@@ -786,11 +794,7 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
 	REG_WRITE(dspcntr_reg, dspcntr);
 
 	/* Flush the plane changes */
-	{
-		struct drm_crtc_helper_funcs *crtc_funcs =
-		    crtc->helper_private;
-		crtc_funcs->mode_set_base(crtc, x, y, old_fb);
-	}
+	crtc_funcs->mode_set_base(crtc, x, y, old_fb);
 
 	psb_intel_wait_for_vblank(dev);
 


  parent reply	other threads:[~2011-06-08 10:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08 10:10 [PATCH 00/15] GMA500 KMS and GEM Alan Cox
2011-06-08 10:11 ` [PATCH 01/15] gma500: fix warnings Alan Cox
2011-06-08 10:11 ` [PATCH 02/15] gma500: Skip bogus LVDS VBT mode and check for LVDS before adding backlight Alan Cox
2011-06-08 10:11 ` [PATCH 03/15] gma500: Make GTT pages uncached Alan Cox
2011-06-08 10:12 ` [PATCH 04/15] gma500: Ensure the frame buffer has a linear virtual mapping Alan Cox
2011-06-08 10:12 ` [PATCH 05/15] gma500: Set the correct bits according to the pipe Alan Cox
2011-06-08 10:12 ` [PATCH 06/15] staging/gma500: get control from firmware framebuffer if conflicts Alan Cox
2011-06-08 10:13 ` [PATCH 07/15] gma500: Fix uninitialized variable and style issues Alan Cox
2011-06-08 10:13 ` [PATCH 08/15] gma500: revamp frame buffer creation and handling Alan Cox
2011-06-08 10:13 ` Alan Cox [this message]
2011-06-08 10:14 ` [PATCH 10/15] gma500: trim some of the debug Alan Cox
2011-06-08 10:14 ` [PATCH 11/15] gma500: polish for completion of this phase Alan Cox
2011-06-08 10:14 ` [PATCH 12/15] gma500: 2D acceleration tidying Alan Cox
2011-06-08 10:15 ` [PATCH 13/15] gma500: nuke the last bits of TTM code Alan Cox
2011-06-08 10:15 ` [PATCH 14/15] gma500: nuke the PSB debug stuff Alan Cox
2011-06-09  1:10   ` Patrik Jakobsson
2011-06-09  8:11     ` Alan Cox
2011-06-09 10:36       ` Dave Airlie
2011-06-09 11:45         ` Patrik Jakobsson
2011-06-09 12:04           ` Alan Cox
2011-06-12 19:02             ` Daniel Vetter
2011-06-13 15:44               ` Alan Cox
2011-06-13 19:35                 ` Daniel Vetter
2011-06-09 11:55         ` Alan Cox
2011-06-08 10:15 ` [PATCH 15/15] gma500: Kill spare kref Alan Cox
2011-06-08 11:15 ` [OT] Re: [PATCH 00/15] GMA500 KMS and GEM Lukasz
2011-06-08 12:24   ` Alan Cox
2011-06-14  9:24     ` Pasi Kärkkäinen

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=20110608101334.9478.58564.stgit@localhost.localdomain \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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