diff options
author | rnoland <rnoland@FreeBSD.org> | 2008-10-03 16:59:11 +0000 |
---|---|---|
committer | rnoland <rnoland@FreeBSD.org> | 2008-10-03 16:59:11 +0000 |
commit | bbc754f502e8dc966e5d05fc4fd4d91d4c136d83 (patch) | |
tree | 2d4185c3ec896efd0d1b2735041e6ddeb6a750f1 /sys/dev/drm/drm_vm.c | |
parent | bbe0e181656adf606748968f5803bb8cbc7d83c8 (diff) | |
download | FreeBSD-src-bbc754f502e8dc966e5d05fc4fd4d91d4c136d83.zip FreeBSD-src-bbc754f502e8dc966e5d05fc4fd4d91d4c136d83.tar.gz |
resync to git master
This reverts a private patch which is causing issues with many Intel chipsets.
I will review that patch and see what we need to do to fix it up later, but
for the time being, we will just get these chips working again.
This update contains a lot of code cleanup and is post gem merge
(no, we don't have gem support). It should prove much easier to read the
code now. A lot of thanks goes to vehemens for that work. I have adapted
the code to use cdevpriv for tracking per open file data. That alleviates
the old ugly hack that we used to try and accomplish the task and helped to
clean up the open / close behavior a good bit. This also replaces the hack
that was put in place a year or so ago to prevent radeons from locking up
with AIGLX enabled. I have had a couple of radeon testers report that it
still works as expected, though I no longer have radeon hardware to test with
myself. Other various fixes from the linux crew and Intel, many of
which are muddled in with the gem merge.
Approved by: jhb (mentor)
Obtained from: mesa/drm git master
MFC after: 2 weeks
Diffstat (limited to 'sys/dev/drm/drm_vm.c')
-rw-r--r-- | sys/dev/drm/drm_vm.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/sys/dev/drm/drm_vm.c b/sys/dev/drm/drm_vm.c index c602eec..e00684b 100644 --- a/sys/dev/drm/drm_vm.c +++ b/sys/dev/drm/drm_vm.c @@ -31,34 +31,27 @@ __FBSDID("$FreeBSD$"); #include "dev/drm/drmP.h" #include "dev/drm/drm.h" -#if defined(__FreeBSD__) && __FreeBSD_version >= 500102 int drm_mmap(struct cdev *kdev, vm_offset_t offset, vm_paddr_t *paddr, int prot) -#elif defined(__FreeBSD__) -int drm_mmap(dev_t kdev, vm_offset_t offset, int prot) -#elif defined(__NetBSD__) || defined(__OpenBSD__) -paddr_t drm_mmap(dev_t kdev, off_t offset, int prot) -#endif { struct drm_device *dev = drm_get_device_from_kdev(kdev); + struct drm_file *file_priv = NULL; drm_local_map_t *map; - drm_file_t *priv; - drm_map_type_t type; -#ifdef __FreeBSD__ + enum drm_map_type type; vm_paddr_t phys; -#else - paddr_t phys; -#endif + int error; - DRM_LOCK(); - priv = drm_find_file_by_proc(dev, DRM_CURPROC); - DRM_UNLOCK(); - if (priv == NULL) { - DRM_ERROR("can't find authenticator\n"); + /* d_mmap gets called twice, we can only reference file_priv during + * the first call. We need to assume that if error is EBADF the + * call was succesful and the client is authenticated. + */ + error = devfs_get_cdevpriv((void **)&file_priv); + if (error == ENOENT) { + DRM_ERROR("Could not find authenticator!\n"); return EINVAL; } - if (!priv->authenticated) + if (file_priv && !file_priv->authenticated) return EACCES; if (dev->dma && offset >= 0 && offset < ptoa(dev->dma->page_count)) { @@ -71,12 +64,8 @@ paddr_t drm_mmap(dev_t kdev, off_t offset, int prot) unsigned long phys = dma->pagelist[page]; DRM_SPINUNLOCK(&dev->dma_lock); -#if defined(__FreeBSD__) && __FreeBSD_version >= 500102 *paddr = phys; return 0; -#else - return atop(phys); -#endif } else { DRM_SPINUNLOCK(&dev->dma_lock); return -1; @@ -127,11 +116,7 @@ paddr_t drm_mmap(dev_t kdev, off_t offset, int prot) return -1; /* This should never happen. */ } -#if defined(__FreeBSD__) && __FreeBSD_version >= 500102 *paddr = phys; return 0; -#else - return atop(phys); -#endif } |