All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, noralf@tronnes.org, airlied@linux.ie,
	rong.a.chen@intel.com, feng.tang@intel.com, ying.huang@intel.com,
	sean@poorly.run, maxime.ripard@bootlin.com,
	maarten.lankhorst@linux.intel.com
Cc: "Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	dri-devel@lists.freedesktop.org,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	"Armijn Hemel" <armijn@tjaldur.nl>,
	"Huang Rui" <ray.huang@amd.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Dave Airlie" <airlied@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Sam Ravnborg" <sam@ravnborg.org>,
	"Christian König" <christian.koenig@amd.com>
Subject: [PATCH 3/3] drm/mgag200: Map fbdev framebuffer while it's being displayed
Date: Thu,  1 Aug 2019 13:56:42 +0200	[thread overview]
Message-ID: <20190801115642.21231-4-tzimmermann@suse.de> (raw)
In-Reply-To: <20190801115642.21231-1-tzimmermann@suse.de>

The generic fbdev emulation will map and unmap the framebuffer's memory
if required. As consoles are most often updated while being on screen,
we map the fbdev buffer while it's being displayed. This avoids frequent
map/unmap operations in the fbdev code. The original fbdev code in mgag200
used the same trick to improve performance.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 90f479ae51af ("drm/mgag200: Replace struct mga_fbdev with generic framebuffer emulation")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Armijn Hemel <armijn@tjaldur.nl>
Cc: Rong Chen <rong.a.chen@intel.com>
Cc: Feng Tang <feng.tang@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 822f2a13748f..a6391144feb5 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -860,13 +860,20 @@ static int mga_crtc_do_set_base(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
 				int x, int y, int atomic)
 {
+	struct drm_fb_helper *fb_helper = crtc->dev->fb_helper;
 	struct drm_gem_vram_object *gbo;
 	int ret;
 	s64 gpu_addr;
+	void *base;
 
 	if (!atomic && fb) {
 		gbo = drm_gem_vram_of_gem(fb->obj[0]);
 		drm_gem_vram_unpin(gbo);
+
+		// Unmap fbdev FB if it's not being displayed
+		// any longer.
+		if (fb == fb_helper->buffer->fb)
+			drm_gem_vram_kunmap(gbo);
 	}
 
 	gbo = drm_gem_vram_of_gem(crtc->primary->fb->obj[0]);
@@ -882,6 +889,15 @@ static int mga_crtc_do_set_base(struct drm_crtc *crtc,
 
 	mga_set_start_address(crtc, (u32)gpu_addr);
 
+	// Map fbdev FB while it's being displayed. This
+	// avoids frequent mapping and unmapping withing the
+	// fbdev code.
+	if (crtc->primary->fb == fb_helper->buffer->fb) {
+		base = drm_gem_vram_kmap(gbo, true, NULL);
+		if (IS_ERR(base))
+			DRM_ERROR("failed to kmap fbcon\n");
+	}
+
 	return 0;
 
 err_drm_gem_vram_unpin:
@@ -1403,9 +1419,14 @@ static void mga_crtc_disable(struct drm_crtc *crtc)
 	DRM_DEBUG_KMS("\n");
 	mga_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 	if (crtc->primary->fb) {
+		struct drm_fb_helper *fb_helper = crtc->dev->fb_helper;
 		struct drm_framebuffer *fb = crtc->primary->fb;
 		struct drm_gem_vram_object *gbo =
 			drm_gem_vram_of_gem(fb->obj[0]);
+
+		// Unmap if it's the fbdev FB.
+		if (fb == fb_helper->buffer->fb)
+			drm_gem_vram_kunmap(gbo);
 		drm_gem_vram_unpin(gbo);
 	}
 	crtc->primary->fb = NULL;
-- 
2.22.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2019-08-01 11:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 11:56 [PATCH 0/3] drm/vram-helper: Fix performance regression in fbdev Thomas Zimmermann
2019-08-01 11:56 ` [PATCH 1/3] drm/vram-helpers: Add kmap ref-counting to GEM VRAM objects Thomas Zimmermann
2019-08-01 11:56 ` [PATCH 2/3] drm/ast: Map fbdev framebuffer while it's being displayed Thomas Zimmermann
2019-08-01 11:56 ` Thomas Zimmermann [this message]

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=20190801115642.21231-4-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=alexander.deucher@amd.com \
    --cc=armijn@tjaldur.nl \
    --cc=b.zolnierkie@samsung.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=feng.tang@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kraxel@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=noralf@tronnes.org \
    --cc=ray.huang@amd.com \
    --cc=rong.a.chen@intel.com \
    --cc=sam@ravnborg.org \
    --cc=sean@poorly.run \
    --cc=tglx@linutronix.de \
    --cc=ying.huang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.