From 6f729193201b59713eb42417a2c57489746b77aa Mon Sep 17 00:00:00 2001 From: dumbbell Date: Sat, 8 Feb 2014 09:50:02 +0000 Subject: [PATCH] MFC r254792: drm: Call drm_global_init() & drm_global_release() at module load/unload git-svn-id: svn://svn.freebsd.org/base/stable/9@261626 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/drm2/drm_core.h | 38 +++++++++++++++++++++++++++++ sys/dev/drm2/drm_drv.c | 54 +++++++++++++++++++++++++++++++---------- 2 files changed, 79 insertions(+), 13 deletions(-) create mode 100644 sys/dev/drm2/drm_core.h diff --git a/sys/dev/drm2/drm_core.h b/sys/dev/drm2/drm_core.h new file mode 100644 index 000000000..4cccb7b4d --- /dev/null +++ b/sys/dev/drm2/drm_core.h @@ -0,0 +1,38 @@ +/* + * Copyright 2004 Jon Smirl + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#define CORE_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl" + +#define CORE_NAME "drm" +#define CORE_DESC "DRM shared core routines" +#define CORE_DATE "20060810" + +#define DRM_IF_MAJOR 1 +#define DRM_IF_MINOR 4 + +#define CORE_MAJOR 1 +#define CORE_MINOR 1 +#define CORE_PATCHLEVEL 0 diff --git a/sys/dev/drm2/drm_drv.c b/sys/dev/drm2/drm_drv.c index 483aff543..d43c583fd 100644 --- a/sys/dev/drm2/drm_drv.c +++ b/sys/dev/drm2/drm_drv.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -76,7 +78,7 @@ static moduledata_t drm_mod = { "drmn", drm_modevent, 0 -}; +}; DECLARE_MODULE(drmn, drm_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); MODULE_VERSION(drmn, 1); MODULE_DEPEND(drmn, agp, 1, 1, 1); @@ -208,7 +210,7 @@ static struct drm_msi_blacklist_entry drm_msi_blacklist[] = { static int drm_msi_is_blacklisted(int vendor, int device) { int i = 0; - + for (i = 0; drm_msi_blacklist[i].vendor != 0; i++) { if ((drm_msi_blacklist[i].vendor == vendor) && (drm_msi_blacklist[i].device == device)) { @@ -347,7 +349,7 @@ drm_pci_id_list_t *drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist) { int i = 0; - + for (i = 0; idlist[i].vendor != 0; i++) { if ((idlist[i].vendor == vendor) && ((idlist[i].device == device) || @@ -744,7 +746,7 @@ void drm_close(void *data) drm_lock_free(&dev->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - + /* FIXME: may require heavy-handed reset of hardware at this point, possibly processed via a callback to the X @@ -807,7 +809,7 @@ extern drm_ioctl_desc_t drm_compat_ioctls[]; /* drm_ioctl is called whenever a process performs an ioctl on /dev/drm. */ -int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, +int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p) { struct drm_device *dev = drm_get_device_from_kdev(kdev); @@ -965,14 +967,9 @@ MODULE_DEPEND(DRIVER_NAME, linux, 1, 1, 1); #define LINUX_IOCTL_DRM_MAX 0x64ff static linux_ioctl_function_t drm_linux_ioctl; -static struct linux_ioctl_handler drm_handler = {drm_linux_ioctl, +static struct linux_ioctl_handler drm_handler = {drm_linux_ioctl, LINUX_IOCTL_DRM_MIN, LINUX_IOCTL_DRM_MAX}; -SYSINIT(drm_register, SI_SUB_KLD, SI_ORDER_MIDDLE, - linux_ioctl_register_handler, &drm_handler); -SYSUNINIT(drm_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE, - linux_ioctl_unregister_handler, &drm_handler); - /* The bits for in/out are switched on Linux */ #define LINUX_IOC_IN IOC_OUT #define LINUX_IOC_OUT IOC_IN @@ -988,13 +985,45 @@ drm_linux_ioctl(DRM_STRUCTPROC *p, struct linux_ioctl_args* args) args->cmd |= IOC_IN; if (cmd & LINUX_IOC_OUT) args->cmd |= IOC_OUT; - + error = ioctl(p, (struct ioctl_args *)args); return error; } #endif /* DRM_LINUX */ + +static int +drm_core_init(void *arg) +{ + + drm_global_init(); + +#if DRM_LINUX + linux_ioctl_register_handler(&drm_handler); +#endif /* DRM_LINUX */ + + DRM_INFO("Initialized %s %d.%d.%d %s\n", + CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); + return 0; +} + +static void +drm_core_exit(void *arg) +{ + +#if DRM_LINUX + linux_ioctl_unregister_handler(&drm_handler); +#endif /* DRM_LINUX */ + + drm_global_release(); +} + +SYSINIT(drm_register, SI_SUB_KLD, SI_ORDER_MIDDLE, + drm_core_init, NULL); +SYSUNINIT(drm_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE, + drm_core_exit, NULL); + bool dmi_check_system(const struct dmi_system_id *sysid) { @@ -1002,4 +1031,3 @@ dmi_check_system(const struct dmi_system_id *sysid) /* XXXKIB */ return (false); } - -- 2.45.0