Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 10:46:44 UTC 2021

Modified Files:
        src/sys/external/bsd/drm2/dist/drm: drm_fb_helper.c
        src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_fb.c
        src/sys/external/bsd/drm2/dist/drm/i915/display: intel_fbdev.c
        src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c
        src/sys/external/bsd/drm2/dist/drm/radeon: radeon_fb.c
        src/sys/external/bsd/drm2/dist/include/drm: drm_fb_helper.h

Log Message:
Narrow scope of exclusions in drm_fb_helper.c; reduce diffs.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c
cvs rdiff -u -r1.8 -r1.9 \
    src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c
cvs rdiff -u -r1.2 -r1.3 \
    src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c
cvs rdiff -u -r1.12 -r1.13 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c
cvs rdiff -u -r1.13 -r1.14 \
    src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c
cvs rdiff -u -r1.13 -r1.14 \
    src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.23 src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.24
--- src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.23	Sun Dec 19 09:52:24 2021
+++ src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c	Sun Dec 19 10:46:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_fb_helper.c,v 1.23 2021/12/19 09:52:24 riastradh Exp $	*/
+/*	$NetBSD: drm_fb_helper.c,v 1.24 2021/12/19 10:46:43 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2006-2009 Red Hat Inc.
@@ -30,7 +30,7 @@
  *      Jesse Barnes <jesse.bar...@intel.com>
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_fb_helper.c,v 1.23 2021/12/19 09:52:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_fb_helper.c,v 1.24 2021/12/19 10:46:43 riastradh Exp $");
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
@@ -54,6 +54,8 @@ __KERNEL_RCSID(0, "$NetBSD: drm_fb_helpe
 #include "drm_crtc_helper_internal.h"
 #include "drm_internal.h"
 
+#include <linux/nbsd-namespace.h>
+
 static bool drm_fbdev_emulation = true;
 module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
 MODULE_PARM_DESC(fbdev_emulation,
@@ -395,10 +397,10 @@ static void drm_fb_helper_resume_worker(
 #endif
 }
 
-#ifndef __NetBSD__		/* XXX fb dirty */
 static void drm_fb_helper_dirty_blit_real(struct drm_fb_helper *fb_helper,
 					  struct drm_clip_rect *clip)
 {
+#ifndef __NetBSD__		/* XXX fb dirty */
 	struct drm_framebuffer *fb = fb_helper->fb;
 	unsigned int cpp = fb->format->cpp[0];
 	size_t offset = clip->y1 * fb->pitches[0] + clip->x1 * cpp;
@@ -412,6 +414,7 @@ static void drm_fb_helper_dirty_blit_rea
 		src = (char *)src + fb->pitches[0];
 		dst = (char *)dst + fb->pitches[0];
 	}
+#endif
 }
 
 static void drm_fb_helper_dirty_work(struct work_struct *work)
@@ -447,7 +450,6 @@ static void drm_fb_helper_dirty_work(str
 			drm_client_buffer_vunmap(helper->buffer);
 	}
 }
-#endif	/* __NetBSD__ */
 
 /**
  * drm_fb_helper_prepare - setup a drm_fb_helper structure
@@ -462,19 +464,11 @@ void drm_fb_helper_prepare(struct drm_de
 			   const struct drm_fb_helper_funcs *funcs)
 {
 	INIT_LIST_HEAD(&helper->kernel_fb_list);
-#ifndef __NetBSD__		/* XXX fb dirty */
 	spin_lock_init(&helper->dirty_lock);
-#endif
 	INIT_WORK(&helper->resume_work, drm_fb_helper_resume_worker);
-#ifndef __NetBSD__		/* XXX fb dirty */
 	INIT_WORK(&helper->dirty_work, drm_fb_helper_dirty_work);
 	helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0;
-#endif
-#ifdef __NetBSD__
-	linux_mutex_init(&helper->lock);
-#else
 	mutex_init(&helper->lock);
-#endif
 	helper->funcs = funcs;
 	helper->dev = dev;
 }
@@ -513,8 +507,16 @@ int drm_fb_helper_init(struct drm_device
 	 */
 	if (!fb_helper->client.funcs) {
 		ret = drm_client_init(dev, &fb_helper->client, "drm_fb_helper", NULL);
-		if (ret)
+		if (ret) {
+			/*
+			 * XXX Undo what drm_fb_helper_prepare did
+			 * since the caller will not be going through
+			 * drm_fb_helper_fini.
+			 */
+			mutex_destroy(&fb_helper->lock);
+			spin_lock_destroy(&fb_helper->dirty_lock);
 			return ret;
+		}
 	}
 
 	dev->fb_helper = fb_helper;
@@ -523,8 +525,6 @@ int drm_fb_helper_init(struct drm_device
 }
 EXPORT_SYMBOL(drm_fb_helper_init);
 
-#ifndef __NetBSD__		/* XXX fb info */
-
 /**
  * drm_fb_helper_alloc_fbi - allocate fb_info and some of its members
  * @fb_helper: driver-allocated fbdev helper
@@ -538,6 +538,7 @@ EXPORT_SYMBOL(drm_fb_helper_init);
  * fb_info pointer if things went okay, pointer containing error code
  * otherwise
  */
+#ifndef __NetBSD__		/* XXX fb info */
 struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper)
 {
 	struct device *dev = fb_helper->dev->dev;
@@ -570,6 +571,7 @@ err_release:
 	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
+#endif
 
 /**
  * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device
@@ -581,8 +583,15 @@ EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
  */
 void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
 {
+#ifdef __NetBSD__
+	/* XXX errno NetBSD->Linux */
+	int ret = -config_detach(fb_helper->fbdev, DETACH_FORCE);
+	if (ret)
+		DRM_ERROR("failed to detach drm framebuffer: %d\n", ret);
+#else
 	if (fb_helper && fb_helper->fbdev)
 		unregister_framebuffer(fb_helper->fbdev);
+#endif
 }
 EXPORT_SYMBOL(drm_fb_helper_unregister_fbi);
 
@@ -594,7 +603,9 @@ EXPORT_SYMBOL(drm_fb_helper_unregister_f
  */
 void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 {
+#ifndef __NetBSD__
 	struct fb_info *info;
+#endif
 
 	if (!fb_helper)
 		return;
@@ -607,12 +618,14 @@ void drm_fb_helper_fini(struct drm_fb_he
 	cancel_work_sync(&fb_helper->resume_work);
 	cancel_work_sync(&fb_helper->dirty_work);
 
+#ifndef __NetBSD__
 	info = fb_helper->fbdev;
 	if (info) {
 		if (info->cmap.len)
 			fb_dealloc_cmap(&info->cmap);
 		framebuffer_release(info);
 	}
+#endif
 	fb_helper->fbdev = NULL;
 
 	mutex_lock(&kernel_fb_helper_lock);
@@ -624,12 +637,15 @@ void drm_fb_helper_fini(struct drm_fb_he
 	mutex_unlock(&kernel_fb_helper_lock);
 
 	mutex_destroy(&fb_helper->lock);
+	spin_lock_destroy(&fb_helper->dirty_lock);
 
 	if (!fb_helper->client.funcs)
 		drm_client_release(&fb_helper->client);
 }
 EXPORT_SYMBOL(drm_fb_helper_fini);
 
+#ifndef __NetBSD__		/* XXX fb dirty */
+
 static bool drm_fbdev_use_shadow_fb(struct drm_fb_helper *fb_helper)
 {
 	struct drm_device *dev = fb_helper->dev;
@@ -660,6 +676,8 @@ static void drm_fb_helper_dirty(struct f
 	schedule_work(&helper->dirty_work);
 }
 
+#endif
+
 #ifndef __NetBSD__		/* XXX fb deferred */
 
 /**
@@ -832,7 +850,7 @@ EXPORT_SYMBOL(drm_fb_helper_cfb_imagebli
 #endif	/* __NetBSD__ */
 
 #ifdef __NetBSD__		/* XXX fb info */
-void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state)
+void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend)
 {
 }
 #else
@@ -878,6 +896,7 @@ void drm_fb_helper_set_suspend_unlocked(
 	/* make sure there's no pending/ongoing resume */
 	flush_work(&fb_helper->resume_work);
 
+#ifndef __NetBSD__		/* XXX fb suspend */
 	if (suspend) {
 		if (fb_helper->fbdev->state != FBINFO_STATE_RUNNING)
 			return;
@@ -896,9 +915,12 @@ void drm_fb_helper_set_suspend_unlocked(
 
 	fb_set_suspend(fb_helper->fbdev, suspend);
 	console_unlock();
+#endif
 }
 EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
 
+#ifndef __NetBSD__
+
 static int setcmap_pseudo_palette(struct fb_cmap *cmap, struct fb_info *info)
 {
 	u32 *palette = (u32 *)info->pseudo_palette;
@@ -1463,6 +1485,7 @@ unlock:
 	return ret;
 }
 EXPORT_SYMBOL(drm_fb_helper_pan_display);
+
 #endif
 
 /*

Index: src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c:1.8 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c:1.9
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c:1.8	Sat Dec 18 23:44:58 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c	Sun Dec 19 10:46:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_fb.c,v 1.8 2021/12/18 23:44:58 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_fb.c,v 1.9 2021/12/19 10:46:43 riastradh Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_fb.c,v 1.8 2021/12/18 23:44:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_fb.c,v 1.9 2021/12/19 10:46:43 riastradh Exp $");
 
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
@@ -336,21 +336,8 @@ out:
 static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev)
 {
 	struct amdgpu_framebuffer *rfb = &rfbdev->rfb;
-#ifdef __NetBSD__
-	int ret;
-#endif
 
-#ifdef __NetBSD__
-	/* XXX errno NetBSD->Linux */
-	ret = -config_detach(rfbdev->helper.fbdev, DETACH_FORCE);
-	if (ret) {
-		DRM_ERROR("failed to detach amdgpufb: %d\n", ret);
-		return ret;
-	}
-	rfbdev->helper.fbdev = NULL;
-#else
 	drm_fb_helper_unregister_fbi(&rfbdev->helper);
-#endif
 
 	if (rfb->base.obj[0]) {
 		amdgpufb_destroy_pinned_object(rfb->base.obj[0]);

Index: src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c:1.2 src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c:1.3
--- src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c:1.2	Sat Dec 18 23:45:30 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c	Sun Dec 19 10:46:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_fbdev.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $	*/
+/*	$NetBSD: intel_fbdev.c,v 1.3 2021/12/19 10:46:43 riastradh Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_fbdev.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_fbdev.c,v 1.3 2021/12/19 10:46:43 riastradh Exp $");
 
 #include <linux/async.h>
 #include <linux/console.h>
@@ -333,18 +333,7 @@ static void intel_fbdev_destroy(struct i
 	 * trying to rectify all the possible error paths leading here.
 	 */
 
-#ifdef __NetBSD__
-    {
-	int ret;
-	/* XXX errno NetBSD->Linux */
-	ret = -config_detach(ifbdev->helper.fbdev, DETACH_FORCE);
-	if (ret)
-		DRM_ERROR("failed to detach intelfb: %d\n", ret);
-	ifbdev->helper.fbdev = NULL;
-    }
-#else
 	drm_fb_helper_fini(&ifbdev->helper);
-#endif
 
 	if (ifbdev->vma)
 		intel_unpin_fb_vma(ifbdev->vma, ifbdev->vma_flags);

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.12 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.13
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.12	Sat Dec 18 23:45:32 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c	Sun Dec 19 10:46:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fbcon.c,v 1.12 2021/12/18 23:45:32 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fbcon.c,v 1.13 2021/12/19 10:46:43 riastradh Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.12 2021/12/18 23:45:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.13 2021/12/19 10:46:43 riastradh Exp $");
 
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -483,20 +483,8 @@ nouveau_fbcon_destroy(struct drm_device 
 {
 	struct nouveau_framebuffer *nouveau_fb = nouveau_framebuffer(fbcon->helper.fb);
 
-#ifdef __NetBSD__
-	if (fbcon->helper.fbdev) {
-		int ret;
-
-		/* XXX errno NetBSD->Linux */
-		ret = -config_detach(fbcon->helper.fbdev, DETACH_FORCE);
-		if (ret)
-			DRM_ERROR("failed to detach nouveaufb: %d\n", ret);
-		fbcon->helper.fbdev = NULL;
-	}
-#else
 	drm_fb_helper_unregister_fbi(&fbcon->helper);
 	drm_fb_helper_fini(&fbcon->helper);
-#endif
 
 	if (nouveau_fb && nouveau_fb->nvbo) {
 		nouveau_vma_del(&nouveau_fb->vma);

Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c:1.13 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c:1.14
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c:1.13	Sun Dec 19 09:55:48 2021
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c	Sun Dec 19 10:46:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_fb.c,v 1.13 2021/12/19 09:55:48 riastradh Exp $	*/
+/*	$NetBSD: radeon_fb.c,v 1.14 2021/12/19 10:46:44 riastradh Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeon_fb.c,v 1.13 2021/12/19 09:55:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_fb.c,v 1.14 2021/12/19 10:46:44 riastradh Exp $");
 
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -354,19 +354,8 @@ out:
 
 static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev)
 {
-#ifdef __NetBSD__
-	int ret;
-#else
 	struct drm_framebuffer *fb = &rfbdev->fb;
-#endif
 
-#ifdef __NetBSD__
-	/* XXX errno NetBSD->Linux */
-	ret = -config_detach(rfbdev->helper.fbdev, DETACH_FORCE);
-	if (ret)
-		DRM_ERROR("failed to detach radeonfb: %d\n", ret);
-	rfbdev->helper.fbdev = NULL;
-#else
 	drm_fb_helper_unregister_fbi(&rfbdev->helper);
 
 	if (fb->obj[0]) {
@@ -376,7 +365,6 @@ static int radeon_fbdev_destroy(struct d
 		drm_framebuffer_cleanup(fb);
 	}
 	drm_fb_helper_fini(&rfbdev->helper);
-#endif
 
 	return 0;
 }

Index: src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h:1.13 src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h:1.14
--- src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h:1.13	Sun Dec 19 09:52:25 2021
+++ src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h	Sun Dec 19 10:46:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_fb_helper.h,v 1.13 2021/12/19 09:52:25 riastradh Exp $	*/
+/*	$NetBSD: drm_fb_helper.h,v 1.14 2021/12/19 10:46:44 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2006-2009 Red Hat Inc.
@@ -142,11 +142,9 @@ struct drm_fb_helper {
 	struct fb_info *fbdev;
 #endif
 	u32 pseudo_palette[17];
-#ifndef __NetBSD__		/* XXX fb dirty */
 	struct drm_clip_rect dirty_clip;
 	spinlock_t dirty_lock;
 	struct work_struct dirty_work;
-#endif
 	struct work_struct resume_work;
 
 	/**
@@ -242,7 +240,9 @@ int drm_fb_helper_restore_fbdev_mode_unl
 
 #ifndef __NetBSD__		/* XXX fb info */
 struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper);
+#endif
 void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper);
+#ifndef __NetBSD__		/* XXX fb info */
 void drm_fb_helper_fill_info(struct fb_info *info,
 			     struct drm_fb_helper *fb_helper,
 			     struct drm_fb_helper_surface_size *sizes);

Reply via email to