[v2,3/3] drm/mgag200: Map fbdev framebuffer while it's being displayed

Submitted by Deucher, Alexander on Sept. 11, 2019, 4:13 p.m.

Details

Message ID BN6PR12MB18091DC5B7F11840145F6910F7B10@BN6PR12MB1809.namprd12.prod.outlook.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in DRI devel

Not browsing as part of any series.

Commit Message

Deucher, Alexander Sept. 11, 2019, 4:13 p.m.
Please use C style comments rather than C++.

Alex

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 5e778b5f1a10..7b95c59341f5 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,14 @@  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 within 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 +1418,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;