[openchrome-devel] drm-openchrome: Branch 'drm-next-5.10' - 4 commits - drivers/gpu/drm

Kevin Brace kevinbrace at kemper.freedesktop.org
Mon Sep 14 22:03:34 UTC 2020


 drivers/gpu/drm/openchrome/openchrome_drv.h |    2 
 drivers/gpu/drm/openchrome/openchrome_fb.c  |  116 +++++++++++++++-------------
 2 files changed, 66 insertions(+), 52 deletions(-)

New commits:
commit 455bc1584794c6ca3aa2f363f38008821838c5a5
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Sep 14 15:02:41 2020 -0700

    drm/openchrome: Version bumped to 3.3.6
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h
index 6e43547127df..641166eed88b 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -61,7 +61,7 @@
 
 #define DRIVER_MAJOR		3
 #define DRIVER_MINOR		3
-#define DRIVER_PATCHLEVEL	5
+#define DRIVER_PATCHLEVEL	6
 #define DRIVER_NAME		"openchrome"
 #define DRIVER_DESC		"OpenChrome DRM for VIA Technologies Chrome IGP"
 #define DRIVER_DATE		"20200914"
commit 28b7dd7ad2527fb8cad5bf666146f11f644d51ce
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Sep 14 15:02:04 2020 -0700

    drm/openchrome: Add openchrome_framebuffer_init()
    
    Move frame buffer initialization code into
    openchrome_framebuffer_init().
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c b/drivers/gpu/drm/openchrome/openchrome_fb.c
index 223ff643d1e9..cc6e3a918a32 100644
--- a/drivers/gpu/drm/openchrome/openchrome_fb.c
+++ b/drivers/gpu/drm/openchrome/openchrome_fb.c
@@ -39,15 +39,48 @@ openchrome_drm_framebuffer_funcs = {
 	.destroy	= drm_gem_fb_destroy,
 };
 
+static int openchrome_framebuffer_init(
+			struct drm_device *dev,
+			struct drm_gem_object *gem,
+			const struct drm_mode_fb_cmd2 *mode_cmd,
+			struct drm_framebuffer **pfb)
+{
+	struct drm_framebuffer *fb;
+	int ret = 0;
+
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+	fb = kzalloc(sizeof(struct drm_framebuffer), GFP_KERNEL);
+	if (!fb) {
+		ret = -ENOMEM;
+		goto exit;
+	}
+
+	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
+	fb->obj[0] = gem;
+	ret = drm_framebuffer_init(dev, fb,
+				&openchrome_drm_framebuffer_funcs);
+	if (ret) {
+		kfree(fb);
+	}
+exit:
+	*pfb = fb;
+
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+	return ret;
+}
+
 static struct drm_framebuffer *
-via_user_framebuffer_create(struct drm_device *dev,
-				struct drm_file *file_priv,
-				const struct drm_mode_fb_cmd2 *mode_cmd)
+openchrome_fb_create(struct drm_device *dev,
+			struct drm_file *file_priv,
+			const struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct drm_framebuffer *fb;
 	struct drm_gem_object *gem;
 	int ret;
 
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
 	gem = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
 	if (!gem) {
 		DRM_ERROR("No GEM object found for handle 0x%08X\n",
@@ -55,26 +88,19 @@ via_user_framebuffer_create(struct drm_device *dev,
 		return ERR_PTR(-ENOENT);
 	}
 
-	fb = kzalloc(sizeof(struct drm_framebuffer), GFP_KERNEL);
-	if (!fb) {
-		return ERR_PTR(-ENOMEM);
-	}
-
-	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
-	fb->obj[0] = gem;
-	ret = drm_framebuffer_init(dev, fb,
-				&openchrome_drm_framebuffer_funcs);
+	ret = openchrome_framebuffer_init(dev, gem, mode_cmd, &fb);
 	if (ret) {
 		drm_gem_object_put(gem);
-		kfree(fb);
+		DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 		return ERR_PTR(ret);
 	}
 
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 	return fb;
 }
 
-static const struct drm_mode_config_funcs via_mode_funcs = {
-	.fb_create		= via_user_framebuffer_create,
+static const struct drm_mode_config_funcs openchrome_drm_mode_config_funcs = {
+	.fb_create		= openchrome_fb_create,
 	.output_poll_changed	= drm_fb_helper_output_poll_changed
 };
 
@@ -92,7 +118,7 @@ void openchrome_mode_config_init(
 	dev->mode_config.max_width = 2044;
 	dev->mode_config.max_height = 4096;
 
-	dev->mode_config.funcs = &via_mode_funcs;
+	dev->mode_config.funcs = &openchrome_drm_mode_config_funcs;
 
 	dev->mode_config.preferred_depth = 24;
 
@@ -133,6 +159,7 @@ openchrome_fb_probe(struct drm_fb_helper *helper,
 	struct via_framebuffer_device *via_fbdev = container_of(helper,
 				struct via_framebuffer_device, helper);
 	struct drm_framebuffer *fb;
+	struct drm_gem_object *gem;
 	struct fb_info *info = helper->fbdev;
 	const struct drm_format_info *format_info;
 	struct drm_mode_fb_cmd2 mode_cmd;
@@ -164,18 +191,10 @@ openchrome_fb_probe(struct drm_fb_helper *helper,
 		goto exit;
 	}
 
-	fb = kzalloc(sizeof(struct drm_framebuffer), GFP_KERNEL);
-	if (!fb) {
-		ret = -ENOMEM;
-		goto free_bo;
-	}
-
-	drm_helper_mode_fill_fb_struct(dev, fb, &mode_cmd);
-	fb->obj[0] = &via_fbdev->bo->gem;
-	ret = drm_framebuffer_init(dev, fb,
-				&openchrome_drm_framebuffer_funcs);
+	gem = &via_fbdev->bo->gem;
+	ret = openchrome_framebuffer_init(dev, gem, &mode_cmd, &fb);
 	if (ret) {
-		goto free_fb;
+		goto free_bo;
 	}
 
 	info = drm_fb_helper_alloc_fbi(helper);
@@ -203,7 +222,12 @@ openchrome_fb_probe(struct drm_fb_helper *helper,
 	goto exit;
 cleanup_fb:
 	drm_framebuffer_cleanup(fb);
-free_fb:
+
+	/*
+	 * openchrome_framebuffer_init() allocates a drm_framebuffer
+	 * struct (in this case, fb pointer), so it needs to be
+	 * released if there was an error.
+	 */
 	kfree(fb);
 free_bo:
 	openchrome_bo_destroy(via_fbdev->bo, true);
commit 5081a0a32b3f5fb9acbe96911cfa1260303674d5
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Sep 14 15:01:49 2020 -0700

    drm/openchrome: Rely on drm_fb_helper_alloc_fbi() for FB initialization
    
    drm_fb_helper_alloc_fbi() framebuffer helper handles initialization of
    certain fields, so rely on that rather than doing it in
    openchrome_fb_probe().
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c b/drivers/gpu/drm/openchrome/openchrome_fb.c
index c575899379fb..223ff643d1e9 100644
--- a/drivers/gpu/drm/openchrome/openchrome_fb.c
+++ b/drivers/gpu/drm/openchrome/openchrome_fb.c
@@ -136,7 +136,6 @@ openchrome_fb_probe(struct drm_fb_helper *helper,
 	struct fb_info *info = helper->fbdev;
 	const struct drm_format_info *format_info;
 	struct drm_mode_fb_cmd2 mode_cmd;
-	struct apertures_struct *ap;
 	int size, cpp;
 	int ret = 0;
 
@@ -171,14 +170,6 @@ openchrome_fb_probe(struct drm_fb_helper *helper,
 		goto free_bo;
 	}
 
-	info = drm_fb_helper_alloc_fbi(helper);
-	if (IS_ERR(info)) {
-		ret = PTR_ERR(info);
-		goto free_fb;
-	}
-
-	info->skip_vt_switch = true;
-
 	drm_helper_mode_fill_fb_struct(dev, fb, &mode_cmd);
 	fb->obj[0] = &via_fbdev->bo->gem;
 	ret = drm_framebuffer_init(dev, fb,
@@ -187,6 +178,12 @@ openchrome_fb_probe(struct drm_fb_helper *helper,
 		goto free_fb;
 	}
 
+	info = drm_fb_helper_alloc_fbi(helper);
+	if (IS_ERR(info)) {
+		ret = PTR_ERR(info);
+		goto cleanup_fb;
+	}
+
 	via_fbdev->helper.fb = fb;
 	via_fbdev->helper.fbdev = info;
 
@@ -198,16 +195,9 @@ openchrome_fb_probe(struct drm_fb_helper *helper,
 	info->screen_base = via_fbdev->bo->kmap.virtual;
 	info->screen_size = size;
 
-	/* Setup aperture base / size for takeover (i.e., vesafb). */
-	ap = alloc_apertures(1);
-	if (!ap) {
-		goto cleanup_fb;
-	}
-
-	ap->ranges[0].size = via_fbdev->bo->kmap.bo->bdev->
+	info->apertures->ranges[0].size = via_fbdev->bo->kmap.bo->bdev->
 			man[via_fbdev->bo->kmap.bo->mem.mem_type].size;
-	ap->ranges[0].base = via_fbdev->bo->kmap.bo->mem.bus.base;
-	info->apertures = ap;
+	info->apertures->ranges[0].base = via_fbdev->bo->kmap.bo->mem.bus.base;
 
 	drm_fb_helper_fill_info(info, helper, sizes);
 	goto exit;
commit dfb06497f0a25d3715a306e47e614930c087ba56
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Sep 14 15:01:31 2020 -0700

    drm/openchrome: Fix and improve error handling of openchrome_fb_probe()
    
    via_fb_probe() was renamed to openchrome_fb_probe().
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c b/drivers/gpu/drm/openchrome/openchrome_fb.c
index 13a3945f8841..c575899379fb 100644
--- a/drivers/gpu/drm/openchrome/openchrome_fb.c
+++ b/drivers/gpu/drm/openchrome/openchrome_fb.c
@@ -124,7 +124,7 @@ static struct fb_ops via_fb_ops = {
 };
 
 static int
-via_fb_probe(struct drm_fb_helper *helper,
+openchrome_fb_probe(struct drm_fb_helper *helper,
 		struct drm_fb_helper_surface_size *sizes)
 {
 	struct drm_device *dev = helper->dev;
@@ -167,13 +167,14 @@ via_fb_probe(struct drm_fb_helper *helper,
 
 	fb = kzalloc(sizeof(struct drm_framebuffer), GFP_KERNEL);
 	if (!fb) {
-		return ret;
+		ret = -ENOMEM;
+		goto free_bo;
 	}
 
 	info = drm_fb_helper_alloc_fbi(helper);
 	if (IS_ERR(info)) {
 		ret = PTR_ERR(info);
-		goto out_err;
+		goto free_fb;
 	}
 
 	info->skip_vt_switch = true;
@@ -182,8 +183,8 @@ via_fb_probe(struct drm_fb_helper *helper,
 	fb->obj[0] = &via_fbdev->bo->gem;
 	ret = drm_framebuffer_init(dev, fb,
 				&openchrome_drm_framebuffer_funcs);
-	if (unlikely(ret)) {
-		goto out_err;
+	if (ret) {
+		goto free_fb;
 	}
 
 	via_fbdev->helper.fb = fb;
@@ -200,8 +201,7 @@ via_fb_probe(struct drm_fb_helper *helper,
 	/* Setup aperture base / size for takeover (i.e., vesafb). */
 	ap = alloc_apertures(1);
 	if (!ap) {
-		drm_framebuffer_cleanup(fb);
-		goto out_err;
+		goto cleanup_fb;
 	}
 
 	ap->ranges[0].size = via_fbdev->bo->kmap.bo->bdev->
@@ -211,20 +211,20 @@ via_fb_probe(struct drm_fb_helper *helper,
 
 	drm_fb_helper_fill_info(info, helper, sizes);
 	goto exit;
-out_err:
-	if (via_fbdev->bo) {
-		openchrome_bo_destroy(via_fbdev->bo, true);
-		via_fbdev->bo = NULL;
-	}
-
+cleanup_fb:
+	drm_framebuffer_cleanup(fb);
+free_fb:
 	kfree(fb);
+free_bo:
+	openchrome_bo_destroy(via_fbdev->bo, true);
+	via_fbdev->bo = NULL;
 exit:
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 	return ret;
 }
 
-static struct drm_fb_helper_funcs via_drm_fb_helper_funcs = {
-	.fb_probe = via_fb_probe,
+static struct drm_fb_helper_funcs openchrome_drm_fb_helper_funcs = {
+	.fb_probe = openchrome_fb_probe,
 };
 
 int via_fbdev_init(struct drm_device *dev)
@@ -246,7 +246,7 @@ int via_fbdev_init(struct drm_device *dev)
 	dev_private->via_fbdev = via_fbdev;
 
 	drm_fb_helper_prepare(dev, &via_fbdev->helper,
-				&via_drm_fb_helper_funcs);
+				&openchrome_drm_fb_helper_funcs);
 
 	ret = drm_fb_helper_init(dev, &via_fbdev->helper);
 	if (ret) {


More information about the openchrome-devel mailing list