From owner-svn-src-head@FreeBSD.ORG Sat Aug 24 15:47:16 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 1AC9E90D; Sat, 24 Aug 2013 15:47:16 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id EB93324A5; Sat, 24 Aug 2013 15:47:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7OFlFYc095272; Sat, 24 Aug 2013 15:47:15 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7OFlFv0095270; Sat, 24 Aug 2013 15:47:15 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201308241547.r7OFlFv0095270@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Sat, 24 Aug 2013 15:47:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254792 - head/sys/dev/drm2 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Aug 2013 15:47:16 -0000 Author: dumbbell Date: Sat Aug 24 15:47:15 2013 New Revision: 254792 URL: http://svnweb.freebsd.org/changeset/base/254792 Log: drm: Call drm_global_init() & drm_global_release() at module load/unload Added: head/sys/dev/drm2/drm_core.h (contents, props changed) Modified: head/sys/dev/drm2/drm_drv.c Added: head/sys/dev/drm2/drm_core.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/drm2/drm_core.h Sat Aug 24 15:47:15 2013 (r254792) @@ -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 Modified: head/sys/dev/drm2/drm_drv.c ============================================================================== --- head/sys/dev/drm2/drm_drv.c Sat Aug 24 15:41:36 2013 (r254791) +++ head/sys/dev/drm2/drm_drv.c Sat Aug 24 15:47:15 2013 (r254792) @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -78,7 +80,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); @@ -210,7 +212,7 @@ static struct drm_msi_blacklist_entry dr 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)) { @@ -349,7 +351,7 @@ drm_pci_id_list_t *drm_find_description( 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) || @@ -746,7 +748,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 @@ -809,7 +811,7 @@ extern drm_ioctl_desc_t drm_compat_ioctl /* 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); @@ -984,14 +986,9 @@ MODULE_DEPEND(DRIVER_NAME, linux, 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 @@ -1007,13 +1004,45 @@ drm_linux_ioctl(DRM_STRUCTPROC *p, struc 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) { @@ -1021,4 +1050,3 @@ dmi_check_system(const struct dmi_system /* XXXKIB */ return (false); } -