Sun Dec 19 12:32:01 2021 UTC ()
drm: mutex_init/destroy and spin_lock_init/destroy audit


(riastradh)
diff -r1.6 -r1.7 src/sys/external/bsd/drm2/dist/drm/drm_connector.c
diff -r1.14 -r1.15 src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.c
diff -r1.21 -r1.22 src/sys/external/bsd/drm2/dist/drm/drm_drv.c
diff -r1.5 -r1.6 src/sys/external/bsd/drm2/dist/drm/drm_flip_work.c
diff -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/drm_mode_config.c
diff -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/drm_syncobj.c
diff -r1.13 -r1.14 src/sys/external/bsd/drm2/dist/drm/drm_vblank.c

cvs diff -r1.6 -r1.7 src/sys/external/bsd/drm2/dist/drm/drm_connector.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/drm_connector.c 2021/12/19 11:06:54 1.6
+++ src/sys/external/bsd/drm2/dist/drm/drm_connector.c 2021/12/19 12:32:01 1.7
@@ -1,53 +1,55 @@ @@ -1,53 +1,55 @@
1/* $NetBSD: drm_connector.c,v 1.6 2021/12/19 11:06:54 riastradh Exp $ */ 1/* $NetBSD: drm_connector.c,v 1.7 2021/12/19 12:32:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2016 Intel Corporation 4 * Copyright (c) 2016 Intel Corporation
5 * 5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its 6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that 7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that copyright 8 * the above copyright notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting documentation, and 9 * notice and this permission notice appear in supporting documentation, and
10 * that the name of the copyright holders not be used in advertising or 10 * that the name of the copyright holders not be used in advertising or
11 * publicity pertaining to distribution of the software without specific, 11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. The copyright holders make no representations 12 * written prior permission. The copyright holders make no representations
13 * about the suitability of this software for any purpose. It is provided "as 13 * about the suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty. 14 * is" without express or implied warranty.
15 * 15 *
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE. 22 * OF THIS SOFTWARE.
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: drm_connector.c,v 1.6 2021/12/19 11:06:54 riastradh Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: drm_connector.c,v 1.7 2021/12/19 12:32:01 riastradh Exp $");
27 27
28#include <drm/drm_connector.h> 28#include <drm/drm_connector.h>
29#include <drm/drm_edid.h> 29#include <drm/drm_edid.h>
30#include <drm/drm_encoder.h> 30#include <drm/drm_encoder.h>
31#include <drm/drm_utils.h> 31#include <drm/drm_utils.h>
32#include <drm/drm_print.h> 32#include <drm/drm_print.h>
33#include <drm/drm_drv.h> 33#include <drm/drm_drv.h>
34#include <drm/drm_file.h> 34#include <drm/drm_file.h>
35 35
36#include <linux/uaccess.h> 36#include <linux/uaccess.h>
37 37
38#include "drm_crtc_internal.h" 38#include "drm_crtc_internal.h"
39#include "drm_internal.h" 39#include "drm_internal.h"
40 40
 41#include <linux/nbsd-namespace.h>
 42
41/** 43/**
42 * DOC: overview 44 * DOC: overview
43 * 45 *
44 * In DRM connectors are the general abstraction for display sinks, and include 46 * In DRM connectors are the general abstraction for display sinks, and include
45 * als fixed panels or anything else that can display pixels in some form. As 47 * als fixed panels or anything else that can display pixels in some form. As
46 * opposed to all other KMS objects representing hardware (like CRTC, encoder or 48 * opposed to all other KMS objects representing hardware (like CRTC, encoder or
47 * plane abstractions) connectors can be hotplugged and unplugged at runtime. 49 * plane abstractions) connectors can be hotplugged and unplugged at runtime.
48 * Hence they are reference-counted using drm_connector_get() and 50 * Hence they are reference-counted using drm_connector_get() and
49 * drm_connector_put(). 51 * drm_connector_put().
50 * 52 *
51 * KMS driver must create, initialize, register and attach at a &struct 53 * KMS driver must create, initialize, register and attach at a &struct
52 * drm_connector for each such sink. The instance is created as other KMS 54 * drm_connector for each such sink. The instance is created as other KMS
53 * objects and initialized by setting the following fields. The connector is 55 * objects and initialized by setting the following fields. The connector is
@@ -246,31 +248,27 @@ int drm_connector_init(struct drm_device @@ -246,31 +248,27 @@ int drm_connector_init(struct drm_device
246 goto out_put_id; 248 goto out_put_id;
247 } 249 }
248 connector->name = 250 connector->name =
249 kasprintf(GFP_KERNEL, "%s-%d", 251 kasprintf(GFP_KERNEL, "%s-%d",
250 drm_connector_enum_list[connector_type].name, 252 drm_connector_enum_list[connector_type].name,
251 connector->connector_type_id); 253 connector->connector_type_id);
252 if (!connector->name) { 254 if (!connector->name) {
253 ret = -ENOMEM; 255 ret = -ENOMEM;
254 goto out_put_type_id; 256 goto out_put_type_id;
255 } 257 }
256 258
257 INIT_LIST_HEAD(&connector->probed_modes); 259 INIT_LIST_HEAD(&connector->probed_modes);
258 INIT_LIST_HEAD(&connector->modes); 260 INIT_LIST_HEAD(&connector->modes);
259#ifdef __NetBSD__ 
260 linux_mutex_init(&connector->mutex); 
261#else 
262 mutex_init(&connector->mutex); 261 mutex_init(&connector->mutex);
263#endif 
264 connector->edid_blob_ptr = NULL; 262 connector->edid_blob_ptr = NULL;
265 connector->tile_blob_ptr = NULL; 263 connector->tile_blob_ptr = NULL;
266 connector->status = connector_status_unknown; 264 connector->status = connector_status_unknown;
267 connector->display_info.panel_orientation = 265 connector->display_info.panel_orientation =
268 DRM_MODE_PANEL_ORIENTATION_UNKNOWN; 266 DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
269 267
270 drm_connector_get_cmdline_mode(connector); 268 drm_connector_get_cmdline_mode(connector);
271 269
272 /* We should add connectors at the end to avoid upsetting the connector 270 /* We should add connectors at the end to avoid upsetting the connector
273 * index too much. */ 271 * index too much. */
274 spin_lock_irq(&config->connector_list_lock); 272 spin_lock_irq(&config->connector_list_lock);
275 list_add_tail(&connector->head, &config->connector_list); 273 list_add_tail(&connector->head, &config->connector_list);
276 config->num_connector++; 274 config->num_connector++;
@@ -463,31 +461,27 @@ void drm_connector_cleanup(struct drm_co @@ -463,31 +461,27 @@ void drm_connector_cleanup(struct drm_co
463 drm_mode_object_unregister(dev, &connector->base); 461 drm_mode_object_unregister(dev, &connector->base);
464 kfree(connector->name); 462 kfree(connector->name);
465 connector->name = NULL; 463 connector->name = NULL;
466 spin_lock_irq(&dev->mode_config.connector_list_lock); 464 spin_lock_irq(&dev->mode_config.connector_list_lock);
467 list_del(&connector->head); 465 list_del(&connector->head);
468 dev->mode_config.num_connector--; 466 dev->mode_config.num_connector--;
469 spin_unlock_irq(&dev->mode_config.connector_list_lock); 467 spin_unlock_irq(&dev->mode_config.connector_list_lock);
470 468
471 WARN_ON(connector->state && !connector->funcs->atomic_destroy_state); 469 WARN_ON(connector->state && !connector->funcs->atomic_destroy_state);
472 if (connector->state && connector->funcs->atomic_destroy_state) 470 if (connector->state && connector->funcs->atomic_destroy_state)
473 connector->funcs->atomic_destroy_state(connector, 471 connector->funcs->atomic_destroy_state(connector,
474 connector->state); 472 connector->state);
475 473
476#ifdef __NetBSD__ 
477 linux_mutex_destroy(&connector->mutex); 
478#else 
479 mutex_destroy(&connector->mutex); 474 mutex_destroy(&connector->mutex);
480#endif 
481 475
482 memset(connector, 0, sizeof(*connector)); 476 memset(connector, 0, sizeof(*connector));
483} 477}
484EXPORT_SYMBOL(drm_connector_cleanup); 478EXPORT_SYMBOL(drm_connector_cleanup);
485 479
486/** 480/**
487 * drm_connector_register - register a connector 481 * drm_connector_register - register a connector
488 * @connector: the connector to register 482 * @connector: the connector to register
489 * 483 *
490 * Register userspace interfaces for a connector. Only call this for connectors 484 * Register userspace interfaces for a connector. Only call this for connectors
491 * which can be hotplugged after drm_dev_register() has been called already, 485 * which can be hotplugged after drm_dev_register() has been called already,
492 * e.g. DP MST connectors. All other connectors will be registered automatically 486 * e.g. DP MST connectors. All other connectors will be registered automatically
493 * when calling drm_dev_register(). 487 * when calling drm_dev_register().

cvs diff -r1.14 -r1.15 src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.c 2021/12/19 00:56:40 1.14
+++ src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.c 2021/12/19 12:32:01 1.15
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $NetBSD: drm_dp_helper.c,v 1.14 2021/12/19 00:56:40 riastradh Exp $ */ 1/* $NetBSD: drm_dp_helper.c,v 1.15 2021/12/19 12:32:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright © 2009 Keith Packard 4 * Copyright © 2009 Keith Packard
5 * 5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its 6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that 7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that copyright 8 * the above copyright notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting documentation, and 9 * notice and this permission notice appear in supporting documentation, and
10 * that the name of the copyright holders not be used in advertising or 10 * that the name of the copyright holders not be used in advertising or
11 * publicity pertaining to distribution of the software without specific, 11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. The copyright holders make no representations 12 * written prior permission. The copyright holders make no representations
13 * about the suitability of this software for any purpose. It is provided "as 13 * about the suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty. 14 * is" without express or implied warranty.
15 * 15 *
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE. 22 * OF THIS SOFTWARE.
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: drm_dp_helper.c,v 1.14 2021/12/19 00:56:40 riastradh Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: drm_dp_helper.c,v 1.15 2021/12/19 12:32:01 riastradh Exp $");
27 27
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/seq_file.h> 35#include <linux/seq_file.h>
36 36
37#include <drm/drm_dp_helper.h> 37#include <drm/drm_dp_helper.h>
38#include <drm/drm_print.h> 38#include <drm/drm_print.h>
39#include <drm/drm_vblank.h> 39#include <drm/drm_vblank.h>
@@ -1065,26 +1065,27 @@ int drm_dp_aux_register(struct drm_dp_au @@ -1065,26 +1065,27 @@ int drm_dp_aux_register(struct drm_dp_au
1065 1065
1066 return 0; 1066 return 0;
1067} 1067}
1068EXPORT_SYMBOL(drm_dp_aux_register); 1068EXPORT_SYMBOL(drm_dp_aux_register);
1069 1069
1070/** 1070/**
1071 * drm_dp_aux_unregister() - unregister an AUX adapter 1071 * drm_dp_aux_unregister() - unregister an AUX adapter
1072 * @aux: DisplayPort AUX channel 1072 * @aux: DisplayPort AUX channel
1073 */ 1073 */
1074void drm_dp_aux_unregister(struct drm_dp_aux *aux) 1074void drm_dp_aux_unregister(struct drm_dp_aux *aux)
1075{ 1075{
1076 drm_dp_aux_unregister_devnode(aux); 1076 drm_dp_aux_unregister_devnode(aux);
1077 i2c_del_adapter(&aux->ddc); 1077 i2c_del_adapter(&aux->ddc);
 1078 mutex_destroy(&aux->cec.lock);
1078 mutex_destroy(&aux->hw_mutex); 1079 mutex_destroy(&aux->hw_mutex);
1079} 1080}
1080EXPORT_SYMBOL(drm_dp_aux_unregister); 1081EXPORT_SYMBOL(drm_dp_aux_unregister);
1081 1082
1082#define PSR_SETUP_TIME(x) [DP_PSR_SETUP_TIME_ ## x >> DP_PSR_SETUP_TIME_SHIFT] = (x) 1083#define PSR_SETUP_TIME(x) [DP_PSR_SETUP_TIME_ ## x >> DP_PSR_SETUP_TIME_SHIFT] = (x)
1083 1084
1084/** 1085/**
1085 * drm_dp_psr_setup_time() - PSR setup in time usec 1086 * drm_dp_psr_setup_time() - PSR setup in time usec
1086 * @psr_cap: PSR capabilities from DPCD 1087 * @psr_cap: PSR capabilities from DPCD
1087 * 1088 *
1088 * Returns: 1089 * Returns:
1089 * PSR setup time for the panel in microseconds, negative 1090 * PSR setup time for the panel in microseconds, negative
1090 * error code on failure. 1091 * error code on failure.

cvs diff -r1.21 -r1.22 src/sys/external/bsd/drm2/dist/drm/drm_drv.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/drm_drv.c 2021/12/19 11:10:09 1.21
+++ src/sys/external/bsd/drm2/dist/drm/drm_drv.c 2021/12/19 12:32:01 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: drm_drv.c,v 1.21 2021/12/19 11:10:09 riastradh Exp $ */ 1/* $NetBSD: drm_drv.c,v 1.22 2021/12/19 12:32:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Created: Fri Jan 19 10:48:35 2001 by faith@acm.org 4 * Created: Fri Jan 19 10:48:35 2001 by faith@acm.org
5 * 5 *
6 * Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California. 6 * Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California.
7 * All Rights Reserved. 7 * All Rights Reserved.
8 * 8 *
9 * Author Rickard E. (Rik) Faith <faith@valinux.com> 9 * Author Rickard E. (Rik) Faith <faith@valinux.com>
10 * 10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a 11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"), 12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation 13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * paragraph) shall be included in all copies or substantial portions of the 19 * paragraph) shall be included in all copies or substantial portions of the
20 * Software. 20 * Software.
21 * 21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE. 28 * DEALINGS IN THE SOFTWARE.
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.21 2021/12/19 11:10:09 riastradh Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.22 2021/12/19 12:32:01 riastradh Exp $");
33 33
34#include <linux/debugfs.h> 34#include <linux/debugfs.h>
35#include <linux/fs.h> 35#include <linux/fs.h>
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/moduleparam.h> 37#include <linux/moduleparam.h>
38#include <linux/mount.h> 38#include <linux/mount.h>
39#include <linux/pseudo_fs.h> 39#include <linux/pseudo_fs.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/srcu.h> 41#include <linux/srcu.h>
42 42
43#include <drm/drm_client.h> 43#include <drm/drm_client.h>
44#include <drm/drm_color_mgmt.h> 44#include <drm/drm_color_mgmt.h>
45#include <drm/drm_drv.h> 45#include <drm/drm_drv.h>
@@ -751,26 +751,27 @@ err_minors: @@ -751,26 +751,27 @@ err_minors:
751 drm_fs_inode_free(dev->anon_inode); 751 drm_fs_inode_free(dev->anon_inode);
752err_free: 752err_free:
753#ifdef __NetBSD__ 753#ifdef __NetBSD__
754 sysmon_pswitch_unregister(&dev->sc_monitor_hotplug); 754 sysmon_pswitch_unregister(&dev->sc_monitor_hotplug);
755err_pswitch: 755err_pswitch:
756#endif 756#endif
757#ifndef __NetBSD__ /* XXX drm sysfs */ 757#ifndef __NetBSD__ /* XXX drm sysfs */
758 put_device(dev->dev); 758 put_device(dev->dev);
759#endif 759#endif
760 mutex_destroy(&dev->master_mutex); 760 mutex_destroy(&dev->master_mutex);
761 mutex_destroy(&dev->clientlist_mutex); 761 mutex_destroy(&dev->clientlist_mutex);
762 mutex_destroy(&dev->filelist_mutex); 762 mutex_destroy(&dev->filelist_mutex);
763 mutex_destroy(&dev->struct_mutex); 763 mutex_destroy(&dev->struct_mutex);
 764 spin_lock_destroy(&dev->event_lock);
764 drm_legacy_destroy_members(dev); 765 drm_legacy_destroy_members(dev);
765 return ret; 766 return ret;
766} 767}
767EXPORT_SYMBOL(drm_dev_init); 768EXPORT_SYMBOL(drm_dev_init);
768 769
769static void devm_drm_dev_init_release(void *data) 770static void devm_drm_dev_init_release(void *data)
770{ 771{
771 drm_dev_put(data); 772 drm_dev_put(data);
772} 773}
773 774
774/** 775/**
775 * devm_drm_dev_init - Resource managed drm_dev_init() 776 * devm_drm_dev_init - Resource managed drm_dev_init()
776 * @parent: Parent device object 777 * @parent: Parent device object
@@ -833,26 +834,27 @@ void drm_dev_fini(struct drm_device *dev @@ -833,26 +834,27 @@ void drm_dev_fini(struct drm_device *dev
833 834
834#ifdef __NetBSD__ 835#ifdef __NetBSD__
835 sysmon_pswitch_unregister(&dev->sc_monitor_hotplug); 836 sysmon_pswitch_unregister(&dev->sc_monitor_hotplug);
836#endif 837#endif
837 838
838#ifndef __NetBSD__ /* XXX drm sysfs */ 839#ifndef __NetBSD__ /* XXX drm sysfs */
839 put_device(dev->dev); 840 put_device(dev->dev);
840#endif 841#endif
841 842
842 mutex_destroy(&dev->master_mutex); 843 mutex_destroy(&dev->master_mutex);
843 mutex_destroy(&dev->clientlist_mutex); 844 mutex_destroy(&dev->clientlist_mutex);
844 mutex_destroy(&dev->filelist_mutex); 845 mutex_destroy(&dev->filelist_mutex);
845 mutex_destroy(&dev->struct_mutex); 846 mutex_destroy(&dev->struct_mutex);
 847 spin_lock_destroy(&dev->event_lock);
846 drm_legacy_destroy_members(dev); 848 drm_legacy_destroy_members(dev);
847 kfree(dev->unique); 849 kfree(dev->unique);
848} 850}
849EXPORT_SYMBOL(drm_dev_fini); 851EXPORT_SYMBOL(drm_dev_fini);
850 852
851/** 853/**
852 * drm_dev_alloc - Allocate new DRM device 854 * drm_dev_alloc - Allocate new DRM device
853 * @driver: DRM driver to allocate device for 855 * @driver: DRM driver to allocate device for
854 * @parent: Parent device object 856 * @parent: Parent device object
855 * 857 *
856 * Allocate and initialize a new DRM device. No device registration is done. 858 * Allocate and initialize a new DRM device. No device registration is done.
857 * Call drm_dev_register() to advertice the device to user space and register it 859 * Call drm_dev_register() to advertice the device to user space and register it
858 * with other core subsystems. This should be done last in the device 860 * with other core subsystems. This should be done last in the device

cvs diff -r1.5 -r1.6 src/sys/external/bsd/drm2/dist/drm/drm_flip_work.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/drm_flip_work.c 2021/12/18 23:44:57 1.5
+++ src/sys/external/bsd/drm2/dist/drm/drm_flip_work.c 2021/12/19 12:32:01 1.6
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $NetBSD: drm_flip_work.c,v 1.5 2021/12/18 23:44:57 riastradh Exp $ */ 1/* $NetBSD: drm_flip_work.c,v 1.6 2021/12/19 12:32:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 2013 Red Hat 4 * Copyright (C) 2013 Red Hat
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a 6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"), 7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation 8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the 10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions: 11 * Software is furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice (including the next 13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the 14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software. 15 * Software.
16 * 16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE. 23 * SOFTWARE.
24 */ 24 */
25 25
26#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: drm_flip_work.c,v 1.5 2021/12/18 23:44:57 riastradh Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: drm_flip_work.c,v 1.6 2021/12/19 12:32:01 riastradh Exp $");
28 28
29#include <linux/slab.h> 29#include <linux/slab.h>
30 30
31#include <drm/drm_flip_work.h> 31#include <drm/drm_flip_work.h>
32#include <drm/drm_print.h> 32#include <drm/drm_print.h>
33#include <drm/drm_util.h> 33#include <drm/drm_util.h>
34 34
35/** 35/**
36 * drm_flip_work_allocate_task - allocate a flip-work task 36 * drm_flip_work_allocate_task - allocate a flip-work task
37 * @data: data associated to the task 37 * @data: data associated to the task
38 * @flags: allocator flags 38 * @flags: allocator flags
39 * 39 *
40 * Allocate a drm_flip_task object and attach private data to it. 40 * Allocate a drm_flip_task object and attach private data to it.
@@ -161,15 +161,16 @@ void drm_flip_work_init(struct drm_flip_ @@ -161,15 +161,16 @@ void drm_flip_work_init(struct drm_flip_
161 INIT_WORK(&work->worker, flip_worker); 161 INIT_WORK(&work->worker, flip_worker);
162} 162}
163EXPORT_SYMBOL(drm_flip_work_init); 163EXPORT_SYMBOL(drm_flip_work_init);
164 164
165/** 165/**
166 * drm_flip_work_cleanup - cleans up flip-work 166 * drm_flip_work_cleanup - cleans up flip-work
167 * @work: the flip-work to cleanup 167 * @work: the flip-work to cleanup
168 * 168 *
169 * Destroy resources allocated for the flip-work 169 * Destroy resources allocated for the flip-work
170 */ 170 */
171void drm_flip_work_cleanup(struct drm_flip_work *work) 171void drm_flip_work_cleanup(struct drm_flip_work *work)
172{ 172{
173 WARN_ON(!list_empty(&work->queued) || !list_empty(&work->commited)); 173 WARN_ON(!list_empty(&work->queued) || !list_empty(&work->commited));
 174 spin_lock_destroy(&work->lock);
174} 175}
175EXPORT_SYMBOL(drm_flip_work_cleanup); 176EXPORT_SYMBOL(drm_flip_work_cleanup);

cvs diff -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/drm_mode_config.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/drm_mode_config.c 2021/12/19 10:47:29 1.4
+++ src/sys/external/bsd/drm2/dist/drm/drm_mode_config.c 2021/12/19 12:32:01 1.5
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $NetBSD: drm_mode_config.c,v 1.4 2021/12/19 10:47:29 riastradh Exp $ */ 1/* $NetBSD: drm_mode_config.c,v 1.5 2021/12/19 12:32:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2016 Intel Corporation 4 * Copyright (c) 2016 Intel Corporation
5 * 5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its 6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that 7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that copyright 8 * the above copyright notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting documentation, and 9 * notice and this permission notice appear in supporting documentation, and
10 * that the name of the copyright holders not be used in advertising or 10 * that the name of the copyright holders not be used in advertising or
11 * publicity pertaining to distribution of the software without specific, 11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. The copyright holders make no representations 12 * written prior permission. The copyright holders make no representations
13 * about the suitability of this software for any purpose. It is provided "as 13 * about the suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty. 14 * is" without express or implied warranty.
15 * 15 *
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE. 22 * OF THIS SOFTWARE.
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: drm_mode_config.c,v 1.4 2021/12/19 10:47:29 riastradh Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: drm_mode_config.c,v 1.5 2021/12/19 12:32:01 riastradh Exp $");
27 27
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29 29
30#include <drm/drm_drv.h> 30#include <drm/drm_drv.h>
31#include <drm/drm_encoder.h> 31#include <drm/drm_encoder.h>
32#include <drm/drm_file.h> 32#include <drm/drm_file.h>
33#include <drm/drm_mode_config.h> 33#include <drm/drm_mode_config.h>
34#include <drm/drm_print.h> 34#include <drm/drm_print.h>
35#include <linux/dma-resv.h> 35#include <linux/dma-resv.h>
36 36
37#include "drm_crtc_internal.h" 37#include "drm_crtc_internal.h"
38#include "drm_internal.h" 38#include "drm_internal.h"
39 39
@@ -523,19 +523,24 @@ void drm_mode_config_cleanup(struct drm_ @@ -523,19 +523,24 @@ void drm_mode_config_cleanup(struct drm_
523 * would actually deadlock with the drm_framebuffer_cleanup function. 523 * would actually deadlock with the drm_framebuffer_cleanup function.
524 * 524 *
525 * Also, if there are any framebuffers left, that's a driver leak now, 525 * Also, if there are any framebuffers left, that's a driver leak now,
526 * so politely WARN about this. 526 * so politely WARN about this.
527 */ 527 */
528 WARN_ON(!list_empty(&dev->mode_config.fb_list)); 528 WARN_ON(!list_empty(&dev->mode_config.fb_list));
529 list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) { 529 list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) {
530 struct drm_printer p = drm_debug_printer("[leaked fb]"); 530 struct drm_printer p = drm_debug_printer("[leaked fb]");
531 drm_printf(&p, "framebuffer[%u]:\n", fb->base.id); 531 drm_printf(&p, "framebuffer[%u]:\n", fb->base.id);
532 drm_framebuffer_print_info(&p, 1, fb); 532 drm_framebuffer_print_info(&p, 1, fb);
533 drm_framebuffer_free(&fb->base.refcount); 533 drm_framebuffer_free(&fb->base.refcount);
534 } 534 }
535 535
 536 spin_lock_destroy(&dev->mode_config.connector_list_lock);
536 ida_destroy(&dev->mode_config.connector_ida); 537 ida_destroy(&dev->mode_config.connector_ida);
537 idr_destroy(&dev->mode_config.tile_idr); 538 idr_destroy(&dev->mode_config.tile_idr);
538 idr_destroy(&dev->mode_config.object_idr); 539 idr_destroy(&dev->mode_config.object_idr);
 540 mutex_destroy(&dev->mode_config.blob_lock);
 541 mutex_destroy(&dev->mode_config.fb_lock);
 542 mutex_destroy(&dev->mode_config.idr_mutex);
539 drm_modeset_lock_fini(&dev->mode_config.connection_mutex); 543 drm_modeset_lock_fini(&dev->mode_config.connection_mutex);
 544 mutex_destroy(&dev->mode_config.mutex);
540} 545}
541EXPORT_SYMBOL(drm_mode_config_cleanup); 546EXPORT_SYMBOL(drm_mode_config_cleanup);

cvs diff -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/drm_syncobj.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/drm_syncobj.c 2021/12/19 10:39:14 1.4
+++ src/sys/external/bsd/drm2/dist/drm/drm_syncobj.c 2021/12/19 12:32:01 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: drm_syncobj.c,v 1.4 2021/12/19 10:39:14 riastradh Exp $ */ 1/* $NetBSD: drm_syncobj.c,v 1.5 2021/12/19 12:32:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2017 Red Hat 4 * Copyright 2017 Red Hat
5 * Parts ported from amdgpu (fence wait code). 5 * Parts ported from amdgpu (fence wait code).
6 * Copyright 2016 Advanced Micro Devices, Inc. 6 * Copyright 2016 Advanced Micro Devices, Inc.
7 * 7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a 8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"), 9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation 10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the 12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions: 13 * Software is furnished to do so, subject to the following conditions:
14 * 14 *
@@ -115,27 +115,27 @@ @@ -115,27 +115,27 @@
115 * &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE lets the client 115 * &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE lets the client
116 * import/export the syncobj's current fence from/to a &sync_file. 116 * import/export the syncobj's current fence from/to a &sync_file.
117 * When a syncobj is exported to a sync file, that sync file wraps the 117 * When a syncobj is exported to a sync file, that sync file wraps the
118 * sycnobj's fence at the time of export and any later signal or reset 118 * sycnobj's fence at the time of export and any later signal or reset
119 * operations on the syncobj will not affect the exported sync file. 119 * operations on the syncobj will not affect the exported sync file.
120 * When a sync file is imported into a syncobj, the syncobj's fence is set 120 * When a sync file is imported into a syncobj, the syncobj's fence is set
121 * to the fence wrapped by that sync file. 121 * to the fence wrapped by that sync file.
122 * Because sync files are immutable, resetting or signaling the syncobj 122 * Because sync files are immutable, resetting or signaling the syncobj
123 * will not affect any sync files whose fences have been imported into the 123 * will not affect any sync files whose fences have been imported into the
124 * syncobj. 124 * syncobj.
125 */ 125 */
126 126
127#include <sys/cdefs.h> 127#include <sys/cdefs.h>
128__KERNEL_RCSID(0, "$NetBSD: drm_syncobj.c,v 1.4 2021/12/19 10:39:14 riastradh Exp $"); 128__KERNEL_RCSID(0, "$NetBSD: drm_syncobj.c,v 1.5 2021/12/19 12:32:01 riastradh Exp $");
129 129
130#include <linux/anon_inodes.h> 130#include <linux/anon_inodes.h>
131#include <linux/file.h> 131#include <linux/file.h>
132#include <linux/fs.h> 132#include <linux/fs.h>
133#include <linux/sched/signal.h> 133#include <linux/sched/signal.h>
134#include <linux/sync_file.h> 134#include <linux/sync_file.h>
135#include <linux/uaccess.h> 135#include <linux/uaccess.h>
136 136
137#include <drm/drm.h> 137#include <drm/drm.h>
138#include <drm/drm_drv.h> 138#include <drm/drm_drv.h>
139#include <drm/drm_file.h> 139#include <drm/drm_file.h>
140#include <drm/drm_gem.h> 140#include <drm/drm_gem.h>
141#include <drm/drm_print.h> 141#include <drm/drm_print.h>
@@ -455,26 +455,27 @@ EXPORT_SYMBOL(drm_syncobj_find_fence); @@ -455,26 +455,27 @@ EXPORT_SYMBOL(drm_syncobj_find_fence);
455 455
456/** 456/**
457 * drm_syncobj_free - free a sync object. 457 * drm_syncobj_free - free a sync object.
458 * @kref: kref to free. 458 * @kref: kref to free.
459 * 459 *
460 * Only to be called from kref_put in drm_syncobj_put. 460 * Only to be called from kref_put in drm_syncobj_put.
461 */ 461 */
462void drm_syncobj_free(struct kref *kref) 462void drm_syncobj_free(struct kref *kref)
463{ 463{
464 struct drm_syncobj *syncobj = container_of(kref, 464 struct drm_syncobj *syncobj = container_of(kref,
465 struct drm_syncobj, 465 struct drm_syncobj,
466 refcount); 466 refcount);
467 drm_syncobj_replace_fence(syncobj, NULL); 467 drm_syncobj_replace_fence(syncobj, NULL);
 468 spin_lock_destroy(&syncobj->lock);
468 kfree(syncobj); 469 kfree(syncobj);
469} 470}
470EXPORT_SYMBOL(drm_syncobj_free); 471EXPORT_SYMBOL(drm_syncobj_free);
471 472
472/** 473/**
473 * drm_syncobj_create - create a new syncobj 474 * drm_syncobj_create - create a new syncobj
474 * @out_syncobj: returned syncobj 475 * @out_syncobj: returned syncobj
475 * @flags: DRM_SYNCOBJ_* flags 476 * @flags: DRM_SYNCOBJ_* flags
476 * @fence: if non-NULL, the syncobj will represent this fence 477 * @fence: if non-NULL, the syncobj will represent this fence
477 * 478 *
478 * This is the first function to create a sync object. After creating, drivers 479 * This is the first function to create a sync object. After creating, drivers
479 * probably want to make it available to userspace, either through 480 * probably want to make it available to userspace, either through
480 * drm_syncobj_get_handle() or drm_syncobj_get_fd(). 481 * drm_syncobj_get_handle() or drm_syncobj_get_fd().

cvs diff -r1.13 -r1.14 src/sys/external/bsd/drm2/dist/drm/drm_vblank.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/drm_vblank.c 2021/12/19 12:24:57 1.13
+++ src/sys/external/bsd/drm2/dist/drm/drm_vblank.c 2021/12/19 12:32:01 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: drm_vblank.c,v 1.13 2021/12/19 12:24:57 riastradh Exp $ */ 1/* $NetBSD: drm_vblank.c,v 1.14 2021/12/19 12:32:01 riastradh Exp $ */
2 2
3/* 3/*
4 * drm_irq.c IRQ and vblank support 4 * drm_irq.c IRQ and vblank support
5 * 5 *
6 * \author Rickard E. (Rik) Faith <faith@valinux.com> 6 * \author Rickard E. (Rik) Faith <faith@valinux.com>
7 * \author Gareth Hughes <gareth@valinux.com> 7 * \author Gareth Hughes <gareth@valinux.com>
8 * 8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a 9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"), 10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation 11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the 13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions: 14 * Software is furnished to do so, subject to the following conditions:
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * paragraph) shall be included in all copies or substantial portions of the 17 * paragraph) shall be included in all copies or substantial portions of the
18 * Software. 18 * Software.
19 * 19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 23 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE. 26 * OTHER DEALINGS IN THE SOFTWARE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: drm_vblank.c,v 1.13 2021/12/19 12:24:57 riastradh Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: drm_vblank.c,v 1.14 2021/12/19 12:32:01 riastradh Exp $");
31 31
32#include <linux/export.h> 32#include <linux/export.h>
33#include <linux/moduleparam.h> 33#include <linux/moduleparam.h>
34#include <linux/math64.h> 34#include <linux/math64.h>
35 35
36#include <drm/drm_crtc.h> 36#include <drm/drm_crtc.h>
37#include <drm/drm_drv.h> 37#include <drm/drm_drv.h>
38#include <drm/drm_framebuffer.h> 38#include <drm/drm_framebuffer.h>
39#include <drm/drm_print.h> 39#include <drm/drm_print.h>
40#include <drm/drm_vblank.h> 40#include <drm/drm_vblank.h>
41 41
42#include "drm_internal.h" 42#include "drm_internal.h"
43#include "drm_trace.h" 43#include "drm_trace.h"
@@ -470,26 +470,28 @@ void drm_vblank_cleanup(struct drm_devic @@ -470,26 +470,28 @@ void drm_vblank_cleanup(struct drm_devic
470 for (pipe = 0; pipe < dev->num_crtcs; pipe++) { 470 for (pipe = 0; pipe < dev->num_crtcs; pipe++) {
471 struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; 471 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
472 472
473 WARN_ON(READ_ONCE(vblank->enabled) && 473 WARN_ON(READ_ONCE(vblank->enabled) &&
474 drm_core_check_feature(dev, DRIVER_MODESET)); 474 drm_core_check_feature(dev, DRIVER_MODESET));
475 475
476 del_timer_sync(&vblank->disable_timer); 476 del_timer_sync(&vblank->disable_timer);
477 seqlock_destroy(&vblank->seqlock); 477 seqlock_destroy(&vblank->seqlock);
478 } 478 }
479 479
480 kfree(dev->vblank); 480 kfree(dev->vblank);
481 481
482 dev->num_crtcs = 0; 482 dev->num_crtcs = 0;
 483
 484 spin_lock_destroy(&dev->vblank_time_lock);
483} 485}
484 486
485/** 487/**
486 * drm_vblank_init - initialize vblank support 488 * drm_vblank_init - initialize vblank support
487 * @dev: DRM device 489 * @dev: DRM device
488 * @num_crtcs: number of CRTCs supported by @dev 490 * @num_crtcs: number of CRTCs supported by @dev
489 * 491 *
490 * This function initializes vblank support for @num_crtcs display pipelines. 492 * This function initializes vblank support for @num_crtcs display pipelines.
491 * Cleanup is handled by the DRM core, or through calling drm_dev_fini() for 493 * Cleanup is handled by the DRM core, or through calling drm_dev_fini() for
492 * drivers with a &drm_driver.release callback. 494 * drivers with a &drm_driver.release callback.
493 * 495 *
494 * Returns: 496 * Returns:
495 * Zero on success or a negative error code on failure. 497 * Zero on success or a negative error code on failure.