Skip to contentSkip to conversation

drm/msm: kick out firmware framebuffer

PATCH In review Rob Clark 2 participants 3 messages Jul 3, 2017

Subsystems (3)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm/msm: kick out firmware framebuffer

Fixes a problem with console not appearing when booting with EFI that has GOP support, because fb0 would end up being efifb, even after drm has taken over the display.

---
 drivers/gpu/drm/msm/msm_drv.c   | 20 ++++++++++++++++++++
 drivers/gpu/drm/msm/msm_drv.h   |  1 +
 drivers/gpu/drm/msm/msm_fbdev.c |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +20 -0
index 9d498eb..0650b2b 100644
@@ -372,6 +372,24 @@ static int msm_init_vram(struct drm_device *dev)
 	return ret;
 }
 
+static void msm_kick_out_firmware_fb(void)
+{
+	struct apertures_struct *ap;
+
+	ap = alloc_apertures(1);
+	if (!ap)
+		return;
+
+	/* Since msm is a UMA device, the simplefb or efifb node may
+	 * have been located anywhere in memory.
+	 */
+	ap->ranges[0].base = 0;
+	ap->ranges[0].size = MAX_RESOURCE;
+
+	drm_fb_helper_remove_conflicting_framebuffers(ap, FB_NAME, false);
+	kfree(ap);
+}
+
 static int msm_drm_init(struct device *dev, struct drm_driver *drv)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -424,6 +442,8 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
 		return ret;
 	}
 
+	msm_kick_out_firmware_fb();
+
 	ret = msm_init_vram(ddev);
 	if (ret)
 		goto fail;
drivers/gpu/drm/msm/msm_drv.h +1 -0
index 1b26ca6..18c5457 100644
@@ -56,6 +56,7 @@ struct msm_gem_address_space;
 struct msm_gem_vma;
 
 #define NUM_DOMAINS 2    /* one for KMS, then one per gpu core (?) */
+#define FB_NAME "msm"
 
 struct msm_file_private {
 	/* currently we don't do anything useful with this.. but when
drivers/gpu/drm/msm/msm_fbdev.c +1 -1
index 951e40f..b23a191 100644
@@ -146,7 +146,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 	fbi->flags = FBINFO_DEFAULT;
 	fbi->fbops = &msm_fb_ops;
 
-	strcpy(fbi->fix.id, "msm");
+	strcpy(fbi->fix.id, FB_NAME);
 
 	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
Signature · 1 line
2.9.4
#1 lore raw
Quoted 5 lines · Rob Clark

Fixes a problem with console not appearing when booting with EFI that has GOP support, because fb0 would end up being efifb, even after drm has taken over the display.

So I have no idea, but I thought DT would be standardized enough (register ranges seem to be) that we could write a DT helper for this. Not possible?

Quoted 19 lines
---
 drivers/gpu/drm/msm/msm_drv.c   | 20 ++++++++++++++++++++
 drivers/gpu/drm/msm/msm_drv.h   |  1 +
 drivers/gpu/drm/msm/msm_fbdev.c |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +5 -0
index 9d498eb..0650b2b 100644
@@ -372,6 +372,24 @@ static int msm_init_vram(struct drm_device *dev)
 	return ret;
 }
 
+static void msm_kick_out_firmware_fb(void)
+{
+	struct apertures_struct *ap;
+
+	ap = alloc_apertures(1);

drivers/gpu/drm/msm/msm_drv.c static int msm_init_vram(struct drm_device *dev) · line 389

Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +10 -0
+	if (!ap)
+		return;
+
+	/* Since msm is a UMA device, the simplefb or efifb node may
+	 * have been located anywhere in memory.
+	 */
+	ap->ranges[0].base = 0;
+	ap->ranges[0].size = MAX_RESOURCE;
+
+	drm_fb_helper_remove_conflicting_framebuffers(ap, FB_NAME, false);

Hm, can we do better? Is there no link in DT between the simplefb and the real DT node?
-Daniel

Quoted 47 lines
drivers/gpu/drm/msm/msm_drv.c +5 -0
+	kfree(ap);
+}
+
 static int msm_drm_init(struct device *dev, struct drm_driver *drv)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -424,6 +442,8 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
 		return ret;
 	}
 
+	msm_kick_out_firmware_fb();
+
 	ret = msm_init_vram(ddev);
 	if (ret)
 		goto fail;
drivers/gpu/drm/msm/msm_drv.h +1 -0
index 1b26ca6..18c5457 100644
@@ -56,6 +56,7 @@ struct msm_gem_address_space;
 struct msm_gem_vma;
 
 #define NUM_DOMAINS 2    /* one for KMS, then one per gpu core (?) */
+#define FB_NAME "msm"
 
 struct msm_file_private {
 	/* currently we don't do anything useful with this.. but when
drivers/gpu/drm/msm/msm_fbdev.c +1 -1
index 951e40f..b23a191 100644
@@ -146,7 +146,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 	fbi->flags = FBINFO_DEFAULT;
 	fbi->fbops = &msm_fb_ops;
 
-	strcpy(fbi->fix.id, "msm");
+	strcpy(fbi->fix.id, FB_NAME);
 
 	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
Signature · 6 lines
2.9.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
author
#2 lore raw
Quoted 9 lines · Daniel Vetter
Quoted 5 lines · Rob Clark

Fixes a problem with console not appearing when booting with EFI that has GOP support, because fb0 would end up being efifb, even after drm has taken over the display.

So I have no idea, but I thought DT would be standardized enough (register ranges seem to be) that we could write a DT helper for this. Not possible?

no, see below

Quoted 24 lines
Quoted 24 lines
---
 drivers/gpu/drm/msm/msm_drv.c   | 20 ++++++++++++++++++++
 drivers/gpu/drm/msm/msm_drv.h   |  1 +
 drivers/gpu/drm/msm/msm_fbdev.c |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +10 -0
index 9d498eb..0650b2b 100644
@@ -372,6 +372,24 @@ static int msm_init_vram(struct drm_device *dev)
      return ret;
 }
 
+static void msm_kick_out_firmware_fb(void)
+{
+     struct apertures_struct *ap;
+
+     ap = alloc_apertures(1);
+     if (!ap)
+             return;
+
+     /* Since msm is a UMA device, the simplefb or efifb node may
+      * have been located anywhere in memory.
Quoted 8 lines

drivers/gpu/drm/msm/msm_drv.c static int msm_init_vram(struct drm_device *dev) · line 389

Quoted 5 lines
drivers/gpu/drm/msm/msm_drv.c +5 -0
+      */
+     ap->ranges[0].base = 0;
+     ap->ranges[0].size = MAX_RESOURCE;
+
+     drm_fb_helper_remove_conflicting_framebuffers(ap, FB_NAME, false);

Hm, can we do better? Is there no link in DT between the simplefb and the real DT node?

umm, well it could be efifb (ie. not in DT).. although I suppose we could create a small helper for UMA devices to avoid duplicating 5 lines of code in several drivers. Not something I'm going to do for a patch planned for -fixes, but possibly a later patch for 4.14.

BR,
-R

Quoted 45 lines

-Daniel

Quoted 43 lines
drivers/gpu/drm/msm/msm_drv.c +5 -0
+     kfree(ap);
+}
+
 static int msm_drm_init(struct device *dev, struct drm_driver *drv)
 {
      struct platform_device *pdev = to_platform_device(dev);
@@ -424,6 +442,8 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
              return ret;
      }
 
+     msm_kick_out_firmware_fb();
+
      ret = msm_init_vram(ddev);
      if (ret)
              goto fail;
drivers/gpu/drm/msm/msm_drv.h +1 -0
index 1b26ca6..18c5457 100644
@@ -56,6 +56,7 @@ struct msm_gem_address_space;
 struct msm_gem_vma;
 
 #define NUM_DOMAINS 2    /* one for KMS, then one per gpu core (?) */
+#define FB_NAME "msm"
 
 struct msm_file_private {
      /* currently we don't do anything useful with this.. but when
drivers/gpu/drm/msm/msm_fbdev.c +1 -2
index 951e40f..b23a191 100644
@@ -146,7 +146,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
      fbi->flags = FBINFO_DEFAULT;
      fbi->fbops = &msm_fb_ops;
 
-     strcpy(fbi->fix.id, "msm");
+     strcpy(fbi->fix.id, FB_NAME);
 
      drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
      drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
--

2.9.4

Quoted 9 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel