summaryrefslogtreecommitdiffstats
path: root/sys/dev/drm/drm_fops.c
diff options
context:
space:
mode:
authorrnoland <rnoland@FreeBSD.org>2008-10-03 16:59:11 +0000
committerrnoland <rnoland@FreeBSD.org>2008-10-03 16:59:11 +0000
commitbbc754f502e8dc966e5d05fc4fd4d91d4c136d83 (patch)
tree2d4185c3ec896efd0d1b2735041e6ddeb6a750f1 /sys/dev/drm/drm_fops.c
parentbbe0e181656adf606748968f5803bb8cbc7d83c8 (diff)
downloadFreeBSD-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_fops.c')
-rw-r--r--sys/dev/drm/drm_fops.c91
1 files changed, 33 insertions, 58 deletions
diff --git a/sys/dev/drm/drm_fops.c b/sys/dev/drm/drm_fops.c
index f6eacd2..9b7bc40 100644
--- a/sys/dev/drm/drm_fops.c
+++ b/sys/dev/drm/drm_fops.c
@@ -39,31 +39,12 @@ __FBSDID("$FreeBSD$");
#include "dev/drm/drmP.h"
-drm_file_t *drm_find_file_by_proc(struct drm_device *dev, DRM_STRUCTPROC *p)
-{
-#if __FreeBSD_version >= 500021
- uid_t uid = p->td_ucred->cr_svuid;
- pid_t pid = p->td_proc->p_pid;
-#else
- uid_t uid = p->p_cred->p_svuid;
- pid_t pid = p->p_pid;
-#endif
- drm_file_t *priv;
-
- DRM_SPINLOCK_ASSERT(&dev->dev_lock);
-
- TAILQ_FOREACH(priv, &dev->files, link)
- if (priv->pid == pid && priv->uid == uid)
- return priv;
- return NULL;
-}
-
/* drm_open_helper is called whenever a process opens /dev/drm. */
int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
struct drm_device *dev)
{
- int m = dev2unit(kdev);
- drm_file_t *priv;
+ struct drm_file *priv;
+ int m = minor(kdev);
int retcode;
if (flags & O_EXCL)
@@ -72,50 +53,44 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
+ priv = malloc(sizeof(*priv), M_DRM, M_NOWAIT | M_ZERO);
+ if (priv == NULL) {
+ return ENOMEM;
+ }
+
+ retcode = devfs_set_cdevpriv(priv, drm_close);
+ if (retcode != 0) {
+ free(priv, M_DRM);
+ return retcode;
+ }
+
DRM_LOCK();
- priv = drm_find_file_by_proc(dev, p);
- if (priv) {
- priv->refs++;
- } else {
- priv = malloc(sizeof(*priv), M_DRM, M_NOWAIT | M_ZERO);
- if (priv == NULL) {
+ priv->dev = dev;
+ priv->uid = p->td_ucred->cr_svuid;
+ priv->pid = p->td_proc->p_pid;
+ priv->minor = m;
+ priv->ioctl_count = 0;
+
+ /* for compatibility root is always authenticated */
+ priv->authenticated = DRM_SUSER(p);
+
+ if (dev->driver->open) {
+ /* shared code returns -errno */
+ retcode = -dev->driver->open(dev, priv);
+ if (retcode != 0) {
+ devfs_clear_cdevpriv();
+ free(priv, M_DRM);
DRM_UNLOCK();
- return ENOMEM;
- }
-#if __FreeBSD_version >= 500000
- priv->uid = p->td_ucred->cr_svuid;
- priv->pid = p->td_proc->p_pid;
-#else
- priv->uid = p->p_cred->p_svuid;
- priv->pid = p->p_pid;
-#endif
-
- priv->refs = 1;
- priv->minor = m;
- priv->ioctl_count = 0;
-
- /* for compatibility root is always authenticated */
- priv->authenticated = DRM_SUSER(p);
-
- if (dev->driver.open) {
- /* shared code returns -errno */
- retcode = -dev->driver.open(dev, priv);
- if (retcode != 0) {
- free(priv, M_DRM);
- DRM_UNLOCK();
- return retcode;
- }
+ return retcode;
}
+ }
- /* first opener automatically becomes master */
- priv->master = TAILQ_EMPTY(&dev->files);
+ /* first opener automatically becomes master */
+ priv->master = TAILQ_EMPTY(&dev->files);
- TAILQ_INSERT_TAIL(&dev->files, priv, link);
- }
+ TAILQ_INSERT_TAIL(&dev->files, priv, link);
DRM_UNLOCK();
-#ifdef __FreeBSD__
kdev->si_drv1 = dev;
-#endif
return 0;
}
OpenPOWER on IntegriCloud