2005-04-17 06:20:36 +08:00
|
|
|
/**
|
2005-09-25 12:28:13 +08:00
|
|
|
* \file drm_drv.c
|
2005-04-17 06:20:36 +08:00
|
|
|
* Generic driver template
|
|
|
|
*
|
|
|
|
* \author Rickard E. (Rik) Faith <faith@valinux.com>
|
|
|
|
* \author Gareth Hughes <gareth@valinux.com>
|
|
|
|
*
|
|
|
|
* To use this template, you must at least define the following (samples
|
|
|
|
* given for the MGA driver):
|
|
|
|
*
|
|
|
|
* \code
|
|
|
|
* #define DRIVER_AUTHOR "VA Linux Systems, Inc."
|
|
|
|
*
|
|
|
|
* #define DRIVER_NAME "mga"
|
|
|
|
* #define DRIVER_DESC "Matrox G200/G400"
|
|
|
|
* #define DRIVER_DATE "20001127"
|
|
|
|
*
|
|
|
|
* #define drm_x mga_##x
|
|
|
|
* \endcode
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
|
|
|
|
*
|
|
|
|
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
|
|
|
|
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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, sublicense,
|
|
|
|
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* VA LINUX SYSTEMS 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.
|
|
|
|
*/
|
|
|
|
|
2009-02-18 09:08:49 +08:00
|
|
|
#include <linux/debugfs.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "drmP.h"
|
|
|
|
#include "drm_core.h"
|
|
|
|
|
2009-02-18 09:08:49 +08:00
|
|
|
|
2007-09-03 10:06:45 +08:00
|
|
|
static int drm_version(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2005-07-07 19:03:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/** Ioctl table */
|
2007-09-03 10:06:45 +08:00
|
|
|
static struct drm_ioctl_desc drm_ioctls[] = {
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, 0),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, 0),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, 0),
|
2009-08-19 13:51:55 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion, DRM_MASTER),
|
2007-09-03 10:06:45 +08:00
|
|
|
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
2009-08-19 13:51:55 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_AUTH|DRM_MASTER),
|
2007-09-03 10:06:45 +08:00
|
|
|
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH),
|
|
|
|
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH),
|
|
|
|
|
2008-11-28 12:22:24 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_DROP_MASTER, drm_dropmaster_ioctl, DRM_ROOT_ONLY),
|
|
|
|
|
2007-09-03 10:06:45 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH),
|
|
|
|
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH),
|
|
|
|
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
|
|
|
|
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
|
2005-04-17 06:20:36 +08:00
|
|
|
/* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
|
2007-09-03 10:06:45 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_DMA, NULL, DRM_AUTH),
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-09-03 10:06:45 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#if __OS_HAS_AGP
|
2007-09-03 10:06:45 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_agp_info_ioctl, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2007-09-03 10:06:45 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-09-03 10:06:45 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0),
|
2006-10-24 21:04:19 +08:00
|
|
|
|
2008-10-01 03:14:26 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0),
|
|
|
|
|
2007-09-03 10:06:45 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
2008-07-31 03:06:12 +08:00
|
|
|
|
2010-02-03 17:14:35 +08:00
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GEM_FLINK, drm_gem_flink_ioctl, DRM_AUTH|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH|DRM_UNLOCKED),
|
|
|
|
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR, drm_mode_cursor_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETGAMMA, drm_mode_gamma_get_ioctl, DRM_MASTER|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETGAMMA, drm_mode_gamma_set_ioctl, DRM_MASTER|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETENCODER, drm_mode_getencoder, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCONNECTOR, drm_mode_getconnector, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_mode_attachmode_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_mode_detachmode_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPERTY, drm_mode_getproperty_ioctl, DRM_MASTER | DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPROPERTY, drm_mode_connector_property_set_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_PAGE_FLIP, drm_mode_page_flip_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
|
|
|
|
DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED)
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2007-05-08 13:28:15 +08:00
|
|
|
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Take down the DRM device.
|
|
|
|
*
|
|
|
|
* \param dev DRM device structure.
|
|
|
|
*
|
|
|
|
* Frees every resource in \p dev.
|
|
|
|
*
|
2005-07-10 14:58:40 +08:00
|
|
|
* \sa drm_device
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2007-07-11 13:53:27 +08:00
|
|
|
int drm_lastclose(struct drm_device * dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-07-11 14:21:47 +08:00
|
|
|
struct drm_vma_entry *vma, *vma_temp;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
DRM_DEBUG("\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-10 19:16:34 +08:00
|
|
|
if (dev->driver->lastclose)
|
|
|
|
dev->driver->lastclose(dev);
|
|
|
|
DRM_DEBUG("driver lastclose completed\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-11-08 06:05:41 +08:00
|
|
|
if (dev->irq_enabled && !drm_core_check_feature(dev, DRIVER_MODESET))
|
2005-09-25 12:28:13 +08:00
|
|
|
drm_irq_uninstall(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-02-02 16:37:46 +08:00
|
|
|
mutex_lock(&dev->struct_mutex);
|
2007-07-17 08:55:47 +08:00
|
|
|
|
|
|
|
/* Free drawable information memory */
|
|
|
|
drm_drawable_free_all(dev);
|
2005-09-25 12:28:13 +08:00
|
|
|
del_timer(&dev->timer);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
/* Clear AGP information */
|
2008-11-08 06:05:41 +08:00
|
|
|
if (drm_core_has_AGP(dev) && dev->agp &&
|
2009-02-18 09:08:49 +08:00
|
|
|
!drm_core_check_feature(dev, DRIVER_MODESET)) {
|
2007-07-11 14:53:40 +08:00
|
|
|
struct drm_agp_mem *entry, *tempe;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
/* Remove AGP resources, but leave dev->agp
|
|
|
|
intact until drv_cleanup is called. */
|
2007-05-26 03:01:51 +08:00
|
|
|
list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
|
2005-09-25 12:28:13 +08:00
|
|
|
if (entry->bound)
|
|
|
|
drm_unbind_agp(entry->memory);
|
|
|
|
drm_free_agp(entry->memory, entry->pages);
|
2009-03-25 03:23:04 +08:00
|
|
|
kfree(entry);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-05-26 03:01:51 +08:00
|
|
|
INIT_LIST_HEAD(&dev->agp->memory);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-07-10 14:56:52 +08:00
|
|
|
if (dev->agp->acquired)
|
2005-09-25 12:28:13 +08:00
|
|
|
drm_agp_release(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dev->agp->acquired = 0;
|
2005-09-25 12:28:13 +08:00
|
|
|
dev->agp->enabled = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-11-08 06:05:41 +08:00
|
|
|
if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
|
|
|
|
!drm_core_check_feature(dev, DRIVER_MODESET)) {
|
2005-07-10 17:27:04 +08:00
|
|
|
drm_sg_cleanup(dev->sg);
|
|
|
|
dev->sg = NULL;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
/* Clear vma list (only built for debugging) */
|
2007-05-26 03:01:51 +08:00
|
|
|
list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
|
|
|
|
list_del(&vma->head);
|
2009-03-25 03:23:04 +08:00
|
|
|
kfree(vma);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
|
|
|
|
for (i = 0; i < dev->queue_count; i++) {
|
2009-03-25 03:23:04 +08:00
|
|
|
kfree(dev->queuelist[i]);
|
|
|
|
dev->queuelist[i] = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-03-25 03:23:04 +08:00
|
|
|
kfree(dev->queuelist);
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->queuelist = NULL;
|
|
|
|
}
|
|
|
|
dev->queue_count = 0;
|
|
|
|
|
2008-11-08 06:05:41 +08:00
|
|
|
if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
|
|
|
|
!drm_core_check_feature(dev, DRIVER_MODESET))
|
2005-09-25 12:28:13 +08:00
|
|
|
drm_dma_takedown(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-11-06 02:31:53 +08:00
|
|
|
dev->dev_mapping = NULL;
|
2006-02-02 16:37:46 +08:00
|
|
|
mutex_unlock(&dev->struct_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-10 19:16:34 +08:00
|
|
|
DRM_DEBUG("lastclose completed\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module initialization. Called via init_module at module load time, or via
|
|
|
|
* linux/init/main.c (this is not currently supported).
|
|
|
|
*
|
|
|
|
* \return zero on success or a negative number on failure.
|
|
|
|
*
|
|
|
|
* Initializes an array of drm_device structures, and attempts to
|
|
|
|
* initialize all available devices, using consecutive minors, registering the
|
|
|
|
* stubs and initializing the AGP device.
|
2005-09-25 12:28:13 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
|
|
|
|
* after the initialization for driver customization.
|
|
|
|
*/
|
2005-09-25 12:28:13 +08:00
|
|
|
int drm_init(struct drm_driver *driver)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct pci_dev *pdev = NULL;
|
2009-01-05 05:55:33 +08:00
|
|
|
const struct pci_device_id *pid;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
DRM_DEBUG("\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-11-28 11:43:47 +08:00
|
|
|
INIT_LIST_HEAD(&driver->device_list);
|
|
|
|
|
2009-01-05 05:55:33 +08:00
|
|
|
if (driver->driver_features & DRIVER_MODESET)
|
|
|
|
return pci_register_driver(&driver->pci_driver);
|
|
|
|
|
|
|
|
/* If not using KMS, fall back to stealth mode manual scanning. */
|
2005-09-25 12:28:13 +08:00
|
|
|
for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
|
2009-01-05 05:55:33 +08:00
|
|
|
pid = &driver->pci_driver.id_table[i];
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2008-11-11 16:02:12 +08:00
|
|
|
/* Loop around setting up a DRM device for each PCI device
|
|
|
|
* matching our ID and device class. If we had the internal
|
|
|
|
* function that pci_get_subsys and pci_get_class used, we'd
|
|
|
|
* be able to just pass pid in instead of doing a two-stage
|
|
|
|
* thing.
|
|
|
|
*/
|
2005-09-25 12:28:13 +08:00
|
|
|
pdev = NULL;
|
|
|
|
while ((pdev =
|
|
|
|
pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
|
|
|
|
pid->subdevice, pdev)) != NULL) {
|
2008-11-11 16:02:12 +08:00
|
|
|
if ((pdev->class & pid->class_mask) != pid->class)
|
|
|
|
continue;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* stealth mode requires a manual probe */
|
|
|
|
pci_dev_get(pdev);
|
|
|
|
drm_get_dev(pdev, pid, driver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
EXPORT_SYMBOL(drm_init);
|
|
|
|
|
2008-04-21 14:47:32 +08:00
|
|
|
void drm_exit(struct drm_driver *driver)
|
|
|
|
{
|
2008-11-28 11:43:47 +08:00
|
|
|
struct drm_device *dev, *tmp;
|
2005-09-25 12:28:13 +08:00
|
|
|
DRM_DEBUG("\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-05 05:55:33 +08:00
|
|
|
if (driver->driver_features & DRIVER_MODESET) {
|
|
|
|
pci_unregister_driver(&driver->pci_driver);
|
|
|
|
} else {
|
|
|
|
list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item)
|
|
|
|
drm_put_dev(dev);
|
|
|
|
}
|
2008-04-21 14:47:32 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
DRM_INFO("Module unloaded\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
EXPORT_SYMBOL(drm_exit);
|
|
|
|
|
|
|
|
/** File operations structure */
|
2007-02-12 16:55:32 +08:00
|
|
|
static const struct file_operations drm_stub_fops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.owner = THIS_MODULE,
|
2005-09-25 12:28:13 +08:00
|
|
|
.open = drm_stub_open
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init drm_core_init(void)
|
|
|
|
{
|
|
|
|
int ret = -ENOMEM;
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2008-04-21 14:47:32 +08:00
|
|
|
idr_init(&drm_minors_idr);
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops))
|
|
|
|
goto err_p1;
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
drm_class = drm_sysfs_create(THIS_MODULE, "drm");
|
|
|
|
if (IS_ERR(drm_class)) {
|
2005-09-25 12:28:13 +08:00
|
|
|
printk(KERN_ERR "DRM: Error creating drm class.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
ret = PTR_ERR(drm_class);
|
|
|
|
goto err_p2;
|
|
|
|
}
|
|
|
|
|
2005-09-29 05:32:57 +08:00
|
|
|
drm_proc_root = proc_mkdir("dri", NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!drm_proc_root) {
|
|
|
|
DRM_ERROR("Cannot create /proc/dri\n");
|
|
|
|
ret = -1;
|
|
|
|
goto err_p3;
|
|
|
|
}
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2009-02-18 09:08:49 +08:00
|
|
|
drm_debugfs_root = debugfs_create_dir("dri", NULL);
|
|
|
|
if (!drm_debugfs_root) {
|
2009-06-02 14:01:37 +08:00
|
|
|
DRM_ERROR("Cannot create /sys/kernel/debug/dri\n");
|
2009-02-18 09:08:49 +08:00
|
|
|
ret = -1;
|
|
|
|
goto err_p3;
|
|
|
|
}
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
DRM_INFO("Initialized %s %d.%d.%d %s\n",
|
|
|
|
CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
2007-11-22 12:02:38 +08:00
|
|
|
err_p3:
|
|
|
|
drm_sysfs_destroy();
|
|
|
|
err_p2:
|
2005-04-17 06:20:36 +08:00
|
|
|
unregister_chrdev(DRM_MAJOR, "drm");
|
2008-04-21 14:47:32 +08:00
|
|
|
|
|
|
|
idr_destroy(&drm_minors_idr);
|
2007-11-22 12:02:38 +08:00
|
|
|
err_p1:
|
2005-04-17 06:20:36 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
static void __exit drm_core_exit(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
remove_proc_entry("dri", NULL);
|
2009-02-18 09:08:49 +08:00
|
|
|
debugfs_remove(drm_debugfs_root);
|
2007-11-22 12:02:38 +08:00
|
|
|
drm_sysfs_destroy();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
unregister_chrdev(DRM_MAJOR, "drm");
|
|
|
|
|
2008-04-21 14:47:32 +08:00
|
|
|
idr_destroy(&drm_minors_idr);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
module_init(drm_core_init);
|
|
|
|
module_exit(drm_core_exit);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-11-18 06:41:23 +08:00
|
|
|
/**
|
|
|
|
* Copy and IOCTL return string to user space
|
|
|
|
*/
|
2009-11-18 06:41:24 +08:00
|
|
|
static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* don't overflow userbuf */
|
|
|
|
len = strlen(value);
|
|
|
|
if (len > *buf_len)
|
|
|
|
len = *buf_len;
|
|
|
|
|
|
|
|
/* let userspace know exact length of driver value (which could be
|
|
|
|
* larger than the userspace-supplied buffer) */
|
|
|
|
*buf_len = strlen(value);
|
|
|
|
|
|
|
|
/* finally, try filling in the userbuf */
|
|
|
|
if (len && buf)
|
|
|
|
if (copy_to_user(buf, value, len))
|
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-11-18 06:41:23 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* Get version information
|
|
|
|
*
|
|
|
|
* \param inode device inode.
|
|
|
|
* \param filp file pointer.
|
|
|
|
* \param cmd command.
|
|
|
|
* \param arg user argument, pointing to a drm_version structure.
|
|
|
|
* \return zero on success or negative number on failure.
|
|
|
|
*
|
|
|
|
* Fills in the version information in \p arg.
|
|
|
|
*/
|
2007-09-03 10:06:45 +08:00
|
|
|
static int drm_version(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-09-03 10:06:45 +08:00
|
|
|
struct drm_version *version = data;
|
2009-11-18 06:41:25 +08:00
|
|
|
int err;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-09-03 10:06:45 +08:00
|
|
|
version->version_major = dev->driver->major;
|
|
|
|
version->version_minor = dev->driver->minor;
|
|
|
|
version->version_patchlevel = dev->driver->patchlevel;
|
2009-11-18 06:41:25 +08:00
|
|
|
err = drm_copy_field(version->name, &version->name_len,
|
|
|
|
dev->driver->name);
|
|
|
|
if (!err)
|
|
|
|
err = drm_copy_field(version->date, &version->date_len,
|
|
|
|
dev->driver->date);
|
|
|
|
if (!err)
|
|
|
|
err = drm_copy_field(version->desc, &version->desc_len,
|
|
|
|
dev->driver->desc);
|
|
|
|
|
|
|
|
return err;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
/**
|
2005-04-17 06:20:36 +08:00
|
|
|
* Called whenever a process performs an ioctl on /dev/drm.
|
|
|
|
*
|
|
|
|
* \param inode device inode.
|
2007-08-25 18:23:09 +08:00
|
|
|
* \param file_priv DRM file private.
|
2005-04-17 06:20:36 +08:00
|
|
|
* \param cmd command.
|
|
|
|
* \param arg user argument.
|
|
|
|
* \return zero on success or negative number on failure.
|
|
|
|
*
|
|
|
|
* Looks up the ioctl function in the ::ioctls table, checking for root
|
|
|
|
* previleges if so required, and dispatches to the respective function.
|
|
|
|
*/
|
2009-12-17 06:17:09 +08:00
|
|
|
long drm_ioctl(struct file *filp,
|
2005-09-25 12:28:13 +08:00
|
|
|
unsigned int cmd, unsigned long arg)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-08-25 18:23:09 +08:00
|
|
|
struct drm_file *file_priv = filp->private_data;
|
2009-12-17 06:17:09 +08:00
|
|
|
struct drm_device *dev;
|
2007-09-03 10:06:45 +08:00
|
|
|
struct drm_ioctl_desc *ioctl;
|
2005-04-17 06:20:36 +08:00
|
|
|
drm_ioctl_t *func;
|
|
|
|
unsigned int nr = DRM_IOCTL_NR(cmd);
|
|
|
|
int retcode = -EINVAL;
|
2009-03-20 09:56:14 +08:00
|
|
|
char stack_kdata[128];
|
2007-09-03 10:06:45 +08:00
|
|
|
char *kdata = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-12-17 06:17:09 +08:00
|
|
|
dev = file_priv->minor->dev;
|
2005-09-25 12:28:13 +08:00
|
|
|
atomic_inc(&dev->ioctl_count);
|
|
|
|
atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
|
2007-08-25 18:23:09 +08:00
|
|
|
++file_priv->ioctl_count;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
|
2007-10-19 14:40:40 +08:00
|
|
|
task_pid_nr(current), cmd, nr,
|
2008-04-21 14:47:32 +08:00
|
|
|
(long)old_encode_dev(file_priv->minor->device),
|
2007-08-25 18:23:09 +08:00
|
|
|
file_priv->authenticated);
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2007-05-08 13:28:15 +08:00
|
|
|
if ((nr >= DRM_CORE_IOCTL_COUNT) &&
|
2007-03-19 05:52:17 +08:00
|
|
|
((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END)))
|
|
|
|
goto err_i1;
|
2007-05-08 13:28:15 +08:00
|
|
|
if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END) &&
|
|
|
|
(nr < DRM_COMMAND_BASE + dev->driver->num_ioctls))
|
2005-04-17 06:20:36 +08:00
|
|
|
ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE];
|
2008-06-20 13:42:38 +08:00
|
|
|
else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) {
|
2007-03-19 05:52:17 +08:00
|
|
|
ioctl = &drm_ioctls[nr];
|
2008-06-20 13:42:38 +08:00
|
|
|
cmd = ioctl->cmd;
|
|
|
|
} else
|
2005-04-17 06:20:36 +08:00
|
|
|
goto err_i1;
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2008-06-13 13:04:40 +08:00
|
|
|
/* Do not trust userspace, use our own definition */
|
2005-04-17 06:20:36 +08:00
|
|
|
func = ioctl->func;
|
|
|
|
/* is there a local override? */
|
|
|
|
if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl)
|
|
|
|
func = dev->driver->dma_ioctl;
|
2005-09-25 12:28:13 +08:00
|
|
|
|
|
|
|
if (!func) {
|
|
|
|
DRM_DEBUG("no function\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
retcode = -EINVAL;
|
2006-01-02 10:54:04 +08:00
|
|
|
} else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) ||
|
2007-08-25 18:23:09 +08:00
|
|
|
((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) ||
|
2009-04-24 13:05:02 +08:00
|
|
|
((ioctl->flags & DRM_MASTER) && !file_priv->is_master) ||
|
|
|
|
(!(ioctl->flags & DRM_CONTROL_ALLOW) && (file_priv->minor->type == DRM_MINOR_CONTROL))) {
|
2005-04-17 06:20:36 +08:00
|
|
|
retcode = -EACCES;
|
|
|
|
} else {
|
2007-09-03 10:06:45 +08:00
|
|
|
if (cmd & (IOC_IN | IOC_OUT)) {
|
2009-03-20 09:56:14 +08:00
|
|
|
if (_IOC_SIZE(cmd) <= sizeof(stack_kdata)) {
|
|
|
|
kdata = stack_kdata;
|
|
|
|
} else {
|
|
|
|
kdata = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
|
|
|
|
if (!kdata) {
|
|
|
|
retcode = -ENOMEM;
|
|
|
|
goto err_i1;
|
|
|
|
}
|
2008-02-07 12:51:32 +08:00
|
|
|
}
|
2007-09-03 10:06:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd & IOC_IN) {
|
|
|
|
if (copy_from_user(kdata, (void __user *)arg,
|
|
|
|
_IOC_SIZE(cmd)) != 0) {
|
2008-02-07 12:51:32 +08:00
|
|
|
retcode = -EFAULT;
|
2007-09-03 10:06:45 +08:00
|
|
|
goto err_i1;
|
|
|
|
}
|
|
|
|
}
|
2009-12-17 06:17:09 +08:00
|
|
|
if (ioctl->flags & DRM_UNLOCKED)
|
|
|
|
retcode = func(dev, kdata, file_priv);
|
|
|
|
else {
|
|
|
|
lock_kernel();
|
|
|
|
retcode = func(dev, kdata, file_priv);
|
|
|
|
unlock_kernel();
|
|
|
|
}
|
2007-09-03 10:06:45 +08:00
|
|
|
|
2009-05-20 19:32:00 +08:00
|
|
|
if (cmd & IOC_OUT) {
|
2007-09-03 10:06:45 +08:00
|
|
|
if (copy_to_user((void __user *)arg, kdata,
|
|
|
|
_IOC_SIZE(cmd)) != 0)
|
2008-02-07 12:51:32 +08:00
|
|
|
retcode = -EFAULT;
|
2007-09-03 10:06:45 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-09-25 12:28:13 +08:00
|
|
|
|
|
|
|
err_i1:
|
2009-03-20 09:56:14 +08:00
|
|
|
if (kdata != stack_kdata)
|
2007-09-03 10:06:45 +08:00
|
|
|
kfree(kdata);
|
2005-09-25 12:28:13 +08:00
|
|
|
atomic_dec(&dev->ioctl_count);
|
|
|
|
if (retcode)
|
|
|
|
DRM_DEBUG("ret = %x\n", retcode);
|
2005-04-17 06:20:36 +08:00
|
|
|
return retcode;
|
|
|
|
}
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
EXPORT_SYMBOL(drm_ioctl);
|
2007-05-26 03:04:51 +08:00
|
|
|
|
2009-02-02 13:55:46 +08:00
|
|
|
struct drm_local_map *drm_getsarea(struct drm_device *dev)
|
2007-05-26 03:04:51 +08:00
|
|
|
{
|
2007-07-11 14:53:40 +08:00
|
|
|
struct drm_map_list *entry;
|
2007-05-26 03:04:51 +08:00
|
|
|
|
2007-05-28 17:41:35 +08:00
|
|
|
list_for_each_entry(entry, &dev->maplist, head) {
|
2007-05-26 03:04:51 +08:00
|
|
|
if (entry->map && entry->map->type == _DRM_SHM &&
|
|
|
|
(entry->map->flags & _DRM_CONTAINS_LOCK)) {
|
|
|
|
return entry->map;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_getsarea);
|