<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1257">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Please use C style comments rather than C++.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Alex</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Thomas Zimmermann <tzimmermann@suse.de><br>
<b>Sent:</b> Wednesday, September 4, 2019 7:56 AM<br>
<b>To:</b> daniel@ffwll.ch <daniel@ffwll.ch>; noralf@tronnes.org <noralf@tronnes.org>; airlied@linux.ie <airlied@linux.ie>; rong.a.chen@intel.com <rong.a.chen@intel.com>; feng.tang@intel.com <feng.tang@intel.com>; ying.huang@intel.com <ying.huang@intel.com>;
sean@poorly.run <sean@poorly.run>; maxime.ripard@bootlin.com <maxime.ripard@bootlin.com>; maarten.lankhorst@linux.intel.com <maarten.lankhorst@linux.intel.com>; dave@stgolabs.net <dave@stgolabs.net><br>
<b>Cc:</b> dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org>; Thomas Zimmermann <tzimmermann@suse.de>; Dave Airlie <airlied@redhat.com>; Greg Kroah-Hartman <gregkh@linuxfoundation.org>; Thomas Gleixner <tglx@linutronix.de>; Gerd Hoffmann <kraxel@redhat.com>;
Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Sam Ravnborg <sam@ravnborg.org>; Daniel Vetter <daniel.vetter@ffwll.ch>; Huang, Ray <Ray.Huang@amd.com>; Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>; Michał
Mirosław <mirq-linux@rere.qmqm.pl>; Armijn Hemel <armijn@tjaldur.nl><br>
<b>Subject:</b> [PATCH v2 3/3] drm/mgag200: Map fbdev framebuffer while it's being displayed</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">The generic fbdev emulation will map and unmap the framebuffer's memory<br>
if required. As consoles are most often updated while being on screen,<br>
we map the fbdev buffer while it's being displayed. This avoids frequent<br>
map/unmap operations in the fbdev code. The original fbdev code in mgag200<br>
used the same trick to improve performance.<br>
<br>
v2:<br>
* fix typo in comment<br>
<br>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de><br>
Fixes: 90f479ae51af ("drm/mgag200: Replace struct mga_fbdev with generic framebuffer emulation")<br>
Cc: Thomas Zimmermann <tzimmermann@suse.de><br>
Cc: Noralf Trønnes <noralf@tronnes.org><br>
Cc: Dave Airlie <airlied@redhat.com><br>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org><br>
Cc: Thomas Gleixner <tglx@linutronix.de><br>
Cc: Gerd Hoffmann <kraxel@redhat.com><br>
Cc: Alex Deucher <alexander.deucher@amd.com><br>
Cc: "Christian König" <christian.koenig@amd.com><br>
Cc: Sam Ravnborg <sam@ravnborg.org><br>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch><br>
Cc: Huang Rui <ray.huang@amd.com><br>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com><br>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl><br>
Cc: Armijn Hemel <armijn@tjaldur.nl><br>
Cc: Rong Chen <rong.a.chen@intel.com><br>
Cc: Feng Tang <feng.tang@intel.com><br>
Cc: Huang Ying <ying.huang@intel.com><br>
Cc: Davidlohr Bueso <dave@stgolabs.net><br>
---<br>
drivers/gpu/drm/mgag200/mgag200_mode.c | 20 ++++++++++++++++++++<br>
1 file changed, 20 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c<br>
index 5e778b5f1a10..7b95c59341f5 100644<br>
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c<br>
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c<br>
@@ -860,13 +860,20 @@ static int mga_crtc_do_set_base(struct drm_crtc *crtc,<br>
struct drm_framebuffer *fb,<br>
int x, int y, int atomic)<br>
{<br>
+ struct drm_fb_helper *fb_helper = crtc->dev->fb_helper;<br>
struct drm_gem_vram_object *gbo;<br>
int ret;<br>
s64 gpu_addr;<br>
+ void *base;<br>
<br>
if (!atomic && fb) {<br>
gbo = drm_gem_vram_of_gem(fb->obj[0]);<br>
drm_gem_vram_unpin(gbo);<br>
+<br>
+ // Unmap fbdev FB if it's not being displayed<br>
+ // any longer.<br>
+ if (fb == fb_helper->buffer->fb)<br>
+ drm_gem_vram_kunmap(gbo);<br>
}<br>
<br>
gbo = drm_gem_vram_of_gem(crtc->primary->fb->obj[0]);<br>
@@ -882,6 +889,14 @@ static int mga_crtc_do_set_base(struct drm_crtc *crtc,<br>
<br>
mga_set_start_address(crtc, (u32)gpu_addr);<br>
<br>
+ // Map fbdev FB while it's being displayed. This avoids frequent<br>
+ // mapping and unmapping within the fbdev code.<br>
+ if (crtc->primary->fb == fb_helper->buffer->fb) {<br>
+ base = drm_gem_vram_kmap(gbo, true, NULL);<br>
+ if (IS_ERR(base))<br>
+ DRM_ERROR("failed to kmap fbcon\n");<br>
+ }<br>
+<br>
return 0;<br>
<br>
err_drm_gem_vram_unpin:<br>
@@ -1403,9 +1418,14 @@ static void mga_crtc_disable(struct drm_crtc *crtc)<br>
DRM_DEBUG_KMS("\n");<br>
mga_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);<br>
if (crtc->primary->fb) {<br>
+ struct drm_fb_helper *fb_helper = crtc->dev->fb_helper;<br>
struct drm_framebuffer *fb = crtc->primary->fb;<br>
struct drm_gem_vram_object *gbo =<br>
drm_gem_vram_of_gem(fb->obj[0]);<br>
+<br>
+ // Unmap if it's the fbdev FB.<br>
+ if (fb == fb_helper->buffer->fb)<br>
+ drm_gem_vram_kunmap(gbo);<br>
drm_gem_vram_unpin(gbo);<br>
}<br>
crtc->primary->fb = NULL;<br>
-- <br>
2.23.0<br>
<br>
</div>
</span></font></div>
</body>
</html>