Initialize kernel_fb_helper_lock in drm module load.diff -r1.18 -r1.19 src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c
(riastradh)
--- src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c 2021/12/19 00:29:02 1.18
+++ src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c 2021/12/19 01:03:22 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_fb_helper.c,v 1.18 2021/12/19 00:29:02 riastradh Exp $ */ | 1 | /* $NetBSD: drm_fb_helper.c,v 1.19 2021/12/19 01:03:22 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2006-2009 Red Hat Inc. | 4 | * Copyright (c) 2006-2009 Red Hat Inc. | |
5 | * Copyright (c) 2006-2008 Intel Corporation | 5 | * Copyright (c) 2006-2008 Intel Corporation | |
6 | * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> | 6 | * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> | |
7 | * | 7 | * | |
8 | * DRM framebuffer helper functions | 8 | * DRM framebuffer helper functions | |
9 | * | 9 | * | |
10 | * Permission to use, copy, modify, distribute, and sell this software and its | 10 | * Permission to use, copy, modify, distribute, and sell this software and its | |
11 | * documentation for any purpose is hereby granted without fee, provided that | 11 | * documentation for any purpose is hereby granted without fee, provided that | |
12 | * the above copyright notice appear in all copies and that both that copyright | 12 | * the above copyright notice appear in all copies and that both that copyright | |
13 | * notice and this permission notice appear in supporting documentation, and | 13 | * notice and this permission notice appear in supporting documentation, and | |
14 | * that the name of the copyright holders not be used in advertising or | 14 | * that the name of the copyright holders not be used in advertising or | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | 20 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
21 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | 21 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | |
22 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | 22 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | |
23 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | 23 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |
24 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | 24 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |
25 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | 25 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
26 | * OF THIS SOFTWARE. | 26 | * OF THIS SOFTWARE. | |
27 | * | 27 | * | |
28 | * Authors: | 28 | * Authors: | |
29 | * Dave Airlie <airlied@linux.ie> | 29 | * Dave Airlie <airlied@linux.ie> | |
30 | * Jesse Barnes <jesse.barnes@intel.com> | 30 | * Jesse Barnes <jesse.barnes@intel.com> | |
31 | */ | 31 | */ | |
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: drm_fb_helper.c,v 1.18 2021/12/19 00:29:02 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_fb_helper.c,v 1.19 2021/12/19 01:03:22 riastradh Exp $"); | |
34 | 34 | |||
35 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 35 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | |
36 | 36 | |||
37 | #include <linux/console.h> | 37 | #include <linux/console.h> | |
38 | #include <linux/dma-buf.h> | 38 | #include <linux/dma-buf.h> | |
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> | |
40 | #include <linux/module.h> | 40 | #include <linux/module.h> | |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> | |
42 | #include <linux/sysrq.h> | 42 | #include <linux/sysrq.h> | |
43 | #include <linux/vmalloc.h> | 43 | #include <linux/vmalloc.h> | |
44 | 44 | |||
45 | #include <drm/drm_atomic.h> | 45 | #include <drm/drm_atomic.h> | |
46 | #include <drm/drm_crtc.h> | 46 | #include <drm/drm_crtc.h> | |
@@ -77,30 +77,32 @@ MODULE_PARM_DESC(drm_fbdev_overalloc, | @@ -77,30 +77,32 @@ MODULE_PARM_DESC(drm_fbdev_overalloc, | |||
77 | * This module_param *should* be removed as soon as possible and be | 77 | * This module_param *should* be removed as soon as possible and be | |
78 | * considered as a broken and legacy behaviour from a modern fbdev device. | 78 | * considered as a broken and legacy behaviour from a modern fbdev device. | |
79 | */ | 79 | */ | |
80 | #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM) | 80 | #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM) | |
81 | static bool drm_leak_fbdev_smem = false; | 81 | static bool drm_leak_fbdev_smem = false; | |
82 | module_param_unsafe(drm_leak_fbdev_smem, bool, 0600); | 82 | module_param_unsafe(drm_leak_fbdev_smem, bool, 0600); | |
83 | MODULE_PARM_DESC(drm_leak_fbdev_smem, | 83 | MODULE_PARM_DESC(drm_leak_fbdev_smem, | |
84 | "Allow unsafe leaking fbdev physical smem address [default=false]"); | 84 | "Allow unsafe leaking fbdev physical smem address [default=false]"); | |
85 | #endif | 85 | #endif | |
86 | 86 | |||
87 | #ifdef __NetBSD__ /* XXX LIST_HEAD means something else */ | 87 | #ifdef __NetBSD__ /* XXX LIST_HEAD means something else */ | |
88 | static struct list_head kernel_fb_helper_list = | 88 | static struct list_head kernel_fb_helper_list = | |
89 | LIST_HEAD_INIT(kernel_fb_helper_list); | 89 | LIST_HEAD_INIT(kernel_fb_helper_list); | |
90 | #define kernel_fb_helper_lock drm_kernel_fb_helper_lock | |||
91 | struct mutex kernel_fb_helper_lock; | |||
90 | #else | 92 | #else | |
91 | static LIST_HEAD(kernel_fb_helper_list); | 93 | static LIST_HEAD(kernel_fb_helper_list); | |
92 | #endif | |||
93 | static DEFINE_MUTEX(kernel_fb_helper_lock); | 94 | static DEFINE_MUTEX(kernel_fb_helper_lock); | |
95 | #endif | |||
94 | 96 | |||
95 | /** | 97 | /** | |
96 | * DOC: fbdev helpers | 98 | * DOC: fbdev helpers | |
97 | * | 99 | * | |
98 | * The fb helper functions are useful to provide an fbdev on top of a drm kernel | 100 | * The fb helper functions are useful to provide an fbdev on top of a drm kernel | |
99 | * mode setting driver. They can be used mostly independently from the crtc | 101 | * mode setting driver. They can be used mostly independently from the crtc | |
100 | * helper functions used by many drivers to implement the kernel mode setting | 102 | * helper functions used by many drivers to implement the kernel mode setting | |
101 | * interfaces. | 103 | * interfaces. | |
102 | * | 104 | * | |
103 | * Drivers that support a dumb buffer with a virtual address and mmap support, | 105 | * Drivers that support a dumb buffer with a virtual address and mmap support, | |
104 | * should try out the generic fbdev emulation using drm_fbdev_generic_setup(). | 106 | * should try out the generic fbdev emulation using drm_fbdev_generic_setup(). | |
105 | * It will automatically set up deferred I/O if the driver requires a shadow | 107 | * It will automatically set up deferred I/O if the driver requires a shadow | |
106 | * buffer. | 108 | * buffer. |
--- src/sys/external/bsd/drm2/dist/drm/drm_internal.h 2021/12/19 00:58:30 1.8
+++ src/sys/external/bsd/drm2/dist/drm/drm_internal.h 2021/12/19 01:03:22 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_internal.h,v 1.8 2021/12/19 00:58:30 riastradh Exp $ */ | 1 | /* $NetBSD: drm_internal.h,v 1.9 2021/12/19 01:03:22 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright © 2014 Intel Corporation | 4 | * Copyright © 2014 Intel Corporation | |
5 | * Daniel Vetter <daniel.vetter@ffwll.ch> | 5 | * Daniel Vetter <daniel.vetter@ffwll.ch> | |
6 | * | 6 | * | |
7 | * Permission is hereby granted, free of charge, to any person obtaining a | 7 | * Permission is hereby granted, free of charge, to any person obtaining a | |
8 | * copy of this software and associated documentation files (the "Software"), | 8 | * copy of this software and associated documentation files (the "Software"), | |
9 | * to deal in the Software without restriction, including without limitation | 9 | * to deal in the Software without restriction, including without limitation | |
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
11 | * and/or sell copies of the Software, and to permit persons to whom the | 11 | * and/or sell copies of the Software, and to permit persons to whom the | |
12 | * Software is furnished to do so, subject to the following conditions: | 12 | * Software is furnished to do so, subject to the following conditions: | |
13 | * | 13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | 14 | * The above copyright notice and this permission notice shall be included in | |
@@ -237,13 +237,16 @@ int drm_syncobj_signal_ioctl(struct drm_ | @@ -237,13 +237,16 @@ int drm_syncobj_signal_ioctl(struct drm_ | |||
237 | int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, | 237 | int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, | |
238 | struct drm_file *file_private); | 238 | struct drm_file *file_private); | |
239 | int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, | 239 | int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, | |
240 | struct drm_file *file_private); | 240 | struct drm_file *file_private); | |
241 | 241 | |||
242 | /* drm_framebuffer.c */ | 242 | /* drm_framebuffer.c */ | |
243 | void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent, | 243 | void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent, | |
244 | const struct drm_framebuffer *fb); | 244 | const struct drm_framebuffer *fb); | |
245 | int drm_framebuffer_debugfs_init(struct drm_minor *minor); | 245 | int drm_framebuffer_debugfs_init(struct drm_minor *minor); | |
246 | 246 | |||
247 | /* drm_hdcp.c */ | 247 | /* drm_hdcp.c */ | |
248 | int drm_setup_hdcp_srm(struct class *drm_class); | 248 | int drm_setup_hdcp_srm(struct class *drm_class); | |
249 | void drm_teardown_hdcp_srm(struct class *drm_class); | 249 | void drm_teardown_hdcp_srm(struct class *drm_class); | |
250 | ||||
251 | /* drm_fb_helper.c */ | |||
252 | extern struct mutex drm_kernel_fb_helper_lock; |
--- src/sys/external/bsd/drm2/drm/drm_module.c 2021/12/19 00:58:31 1.20
+++ src/sys/external/bsd/drm2/drm/drm_module.c 2021/12/19 01:03:22 1.21
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_module.c,v 1.20 2021/12/19 00:58:31 riastradh Exp $ */ | 1 | /* $NetBSD: drm_module.c,v 1.21 2021/12/19 01:03:22 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: drm_module.c,v 1.20 2021/12/19 00:58:31 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_module.c,v 1.21 2021/12/19 01:03:22 riastradh Exp $"); | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/condvar.h> | 36 | #include <sys/condvar.h> | |
37 | #include <sys/conf.h> | 37 | #include <sys/conf.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | #include <sys/module.h> | 39 | #include <sys/module.h> | |
40 | #include <sys/mutex.h> | 40 | #include <sys/mutex.h> | |
41 | #include <sys/once.h> | 41 | #include <sys/once.h> | |
42 | #include <sys/reboot.h> | 42 | #include <sys/reboot.h> | |
43 | #include <sys/systm.h> | 43 | #include <sys/systm.h> | |
44 | 44 | |||
45 | #include <linux/mutex.h> | 45 | #include <linux/mutex.h> | |
46 | 46 | |||
@@ -114,26 +114,27 @@ drm_init(void) | @@ -114,26 +114,27 @@ drm_init(void) | |||
114 | if (error) { | 114 | if (error) { | |
115 | drm_agp_hooks_fini(); | 115 | drm_agp_hooks_fini(); | |
116 | return error; | 116 | return error; | |
117 | } | 117 | } | |
118 | #endif | 118 | #endif | |
119 | 119 | |||
120 | if (ISSET(boothowto, AB_DEBUG)) | 120 | if (ISSET(boothowto, AB_DEBUG)) | |
121 | drm_debug = DRM_UT_CORE | DRM_UT_DRIVER | DRM_UT_KMS; | 121 | drm_debug = DRM_UT_CORE | DRM_UT_DRIVER | DRM_UT_KMS; | |
122 | 122 | |||
123 | spin_lock_init(&drm_minor_lock); | 123 | spin_lock_init(&drm_minor_lock); | |
124 | idr_init(&drm_minors_idr); | 124 | idr_init(&drm_minors_idr); | |
125 | srcu_init(&drm_unplug_srcu, "drmunplg"); | 125 | srcu_init(&drm_unplug_srcu, "drmunplg"); | |
126 | linux_mutex_init(&drm_global_mutex); | 126 | linux_mutex_init(&drm_global_mutex); | |
127 | linux_mutex_init(&drm_kernel_fb_helper_lock); | |||
127 | drm_connector_ida_init(); | 128 | drm_connector_ida_init(); | |
128 | drm_global_init(); | 129 | drm_global_init(); | |
129 | drm_panel_init_lock(); | 130 | drm_panel_init_lock(); | |
130 | drm_bridge_init_lock(); | 131 | drm_bridge_init_lock(); | |
131 | drm_sysctl_init(&drm_def); | 132 | drm_sysctl_init(&drm_def); | |
132 | drm_i2c_encoders_init(); | 133 | drm_i2c_encoders_init(); | |
133 | 134 | |||
134 | return 0; | 135 | return 0; | |
135 | } | 136 | } | |
136 | 137 | |||
137 | int | 138 | int | |
138 | drm_guarantee_initialized(void) | 139 | drm_guarantee_initialized(void) | |
139 | { | 140 | { | |
@@ -146,26 +147,27 @@ drm_guarantee_initialized(void) | @@ -146,26 +147,27 @@ drm_guarantee_initialized(void) | |||
146 | #endif | 147 | #endif | |
147 | } | 148 | } | |
148 | 149 | |||
149 | static void | 150 | static void | |
150 | drm_fini(void) | 151 | drm_fini(void) | |
151 | { | 152 | { | |
152 | 153 | |||
153 | drm_i2c_encoders_fini(); | 154 | drm_i2c_encoders_fini(); | |
154 | drm_sysctl_fini(&drm_def); | 155 | drm_sysctl_fini(&drm_def); | |
155 | drm_bridge_fini_lock(); | 156 | drm_bridge_fini_lock(); | |
156 | drm_panel_fini_lock(); | 157 | drm_panel_fini_lock(); | |
157 | drm_global_release(); | 158 | drm_global_release(); | |
158 | drm_connector_ida_destroy(); | 159 | drm_connector_ida_destroy(); | |
160 | linux_mutex_destroy(&drm_kernel_fb_helper_lock); | |||
159 | linux_mutex_destroy(&drm_global_mutex); | 161 | linux_mutex_destroy(&drm_global_mutex); | |
160 | srcu_fini(&drm_unplug_srcu); | 162 | srcu_fini(&drm_unplug_srcu); | |
161 | idr_destroy(&drm_minors_idr); | 163 | idr_destroy(&drm_minors_idr); | |
162 | spin_lock_destroy(&drm_minor_lock); | 164 | spin_lock_destroy(&drm_minor_lock); | |
163 | drm_agp_hooks_fini(); | 165 | drm_agp_hooks_fini(); | |
164 | } | 166 | } | |
165 | 167 | |||
166 | int | 168 | int | |
167 | drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file) | 169 | drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file) | |
168 | { | 170 | { | |
169 | 171 | |||
170 | return -ENODEV; | 172 | return -ENODEV; | |
171 | } | 173 | } |