Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/riastradh-drm2]: src/sys/external/bsd/drm2 Move OS-independent cruft fro...
details: https://anonhg.NetBSD.org/src/rev/68f21fc9ebb0
branches: riastradh-drm2
changeset: 788119:68f21fc9ebb0
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 24 02:19:53 2013 +0000
description:
Move OS-independent cruft from drm_drv.c to a new drm_fops.c.
diffstat:
sys/external/bsd/drm2/dist/include/drm/drmP.h | 10 +-
sys/external/bsd/drm2/drm/drm_drv.c | 405 +-----------------------
sys/external/bsd/drm2/drm/drm_fops.c | 438 ++++++++++++++++++++++++++
3 files changed, 449 insertions(+), 404 deletions(-)
diffs (truncated from 909 to 300 lines):
diff -r fff23cd579fb -r 68f21fc9ebb0 sys/external/bsd/drm2/dist/include/drm/drmP.h
--- a/sys/external/bsd/drm2/dist/include/drm/drmP.h Wed Jul 24 02:19:30 2013 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drmP.h Wed Jul 24 02:19:53 2013 +0000
@@ -1369,14 +1369,22 @@
/* Device support (drm_fops.h) */
extern struct mutex drm_global_mutex;
-#ifndef __NetBSD__
+#ifdef __NetBSD__
+extern int drm_open_file(struct drm_file *, void *, struct drm_minor *);
+extern int drm_close_file(struct drm_file *);
+# if 0 /* XXX */
+extern struct drm_pending_event *drm_dequeue_event(struct drm_file *, size_t);
+# endif
+#else
extern int drm_open(struct inode *inode, struct file *filp);
extern int drm_stub_open(struct inode *inode, struct file *filp);
extern int drm_fasync(int fd, struct file *filp, int on);
extern ssize_t drm_read(struct file *filp, char __user *buffer,
size_t count, loff_t *offset);
extern int drm_release(struct inode *inode, struct file *filp);
+#endif
+#ifndef __NetBSD__
/* Mapping support (drm_vm.h) */
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
diff -r fff23cd579fb -r 68f21fc9ebb0 sys/external/bsd/drm2/drm/drm_drv.c
--- a/sys/external/bsd/drm2/drm/drm_drv.c Wed Jul 24 02:19:30 2013 +0000
+++ b/sys/external/bsd/drm2/drm/drm_drv.c Wed Jul 24 02:19:53 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_drv.c,v 1.1.2.1 2013/07/24 02:18:42 riastradh Exp $ */
+/* $NetBSD: drm_drv.c,v 1.1.2.2 2013/07/24 02:19:53 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.1.2.1 2013/07/24 02:18:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.1.2.2 2013/07/24 02:19:53 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -55,20 +55,6 @@
static dev_type_open(drm_open);
-static int drm_open_file(struct drm_file *, struct file *,
- struct drm_minor *);
-static int drm_open_file_master(struct drm_file *);
-
-static int drm_close_file(struct drm_file *);
-static void drm_master_release(struct drm_file *);
-static void drm_events_release(struct drm_file *);
-static void drm_close_file_contexts(struct drm_file *);
-static void drm_close_file_master(struct drm_file *);
-
-static void drm_lastclose(struct drm_device *);
-static void drm_lastclose_agp(struct drm_device *);
-static void drm_lastclose_vma(struct drm_device *);
-
static int drm_close(struct file *);
static int drm_read(struct file *, off_t *, struct uio *, kauth_cred_t,
int);
@@ -339,371 +325,6 @@
return error;
}
-/*
- * XXX BEGIN MISPLACED OS-INDEPENDENT CODE
- */
-
-static int
-drm_open_file(struct drm_file *file, struct file *fp, struct drm_minor *minor)
-{
- struct drm_device *const dev = minor->dev;
- int error;
-
- atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
- if ((dev->open_count++ == 0) && (dev->driver->firstopen != NULL)) {
- error = (*dev->driver->firstopen)(dev);
- if (error)
- goto fail0;
- }
-
- file->authenticated = DRM_SUSER(); /* XXX */
- file->magic = 0;
- file->ioctl_count = 0;
- INIT_LIST_HEAD(&file->lhead);
- file->minor = minor;
- file->lock_count = 0;
- /* file->object_idr is initialized by drm_gem_open. */
- /* file->table_lock is initialized by drm_gem_open. */
- file->filp = fp;
- file->driver_priv = NULL;
- file->is_master = 0;
- file->master = NULL;
- INIT_LIST_HEAD(&file->fbs);
- DRM_INIT_WAITQUEUE(&file->event_wait, "drmevent");
- INIT_LIST_HEAD(&file->event_list);
- file->event_space = 0x1000; /* XXX cargo-culted from Linux */
-
- if (drm_core_check_feature(dev, DRIVER_GEM))
- drm_gem_open(dev, file);
-
- if (drm_core_check_feature(dev, DRIVER_PRIME))
- drm_prime_init_file_private(&file->prime);
-
- if (dev->driver->open) {
- error = (*dev->driver->open)(dev, file);
- if (error)
- goto fail1;
- }
-
- error = drm_open_file_master(file);
- if (error)
- goto fail2;
-
- /* Success! */
- return 0;
-
-fail2:
- /*
- * XXX This error branch needs scrutiny, but Linux's error
- * branches are incomprehensible and look wronger.
- */
- if (dev->driver->preclose)
- (*dev->driver->preclose)(dev, file);
- if (dev->driver->postclose)
- (*dev->driver->postclose)(dev, file);
-
-fail1:
- if (drm_core_check_feature(dev, DRIVER_PRIME))
- drm_prime_destroy_file_private(&file->prime);
-
- if (drm_core_check_feature(dev, DRIVER_GEM))
- drm_gem_release(dev, file);
-
- if (--dev->open_count == 0)
- drm_lastclose(dev);
-
-fail0:
- return error;
-}
-
-static int
-drm_open_file_master(struct drm_file *file)
-{
- struct drm_device *const dev = file->minor->dev;
- int error;
-
- mutex_lock(&dev->struct_mutex);
-
- if (file->minor->master != NULL) {
- file->master = drm_master_get(file->minor->master);
- } else {
- file->minor->master = drm_master_create(file->minor);
- if (file->minor->master == NULL) {
- error = -ENOMEM;
- goto fail0;
- }
-
- file->is_master = 1;
- file->master = drm_master_get(file->minor->master);
- file->authenticated = 1;
-
- if (dev->driver->master_create) {
- mutex_unlock(&dev->struct_mutex);
- error = (*dev->driver->master_create)(dev,
- file->minor->master);
- mutex_lock(&dev->struct_mutex);
- if (error)
- goto fail1;
- }
-
- if (dev->driver->master_set) {
- error = (*dev->driver->master_set)(dev, file, true);
- if (error)
- goto fail1;
- }
- }
- mutex_unlock(&dev->struct_mutex);
-
- /* Success! */
- return 0;
-
-fail1:
- /* drm_master_put handles calling master_destroy for us. */
- drm_master_put(&file->minor->master);
- drm_master_put(&file->master);
-fail0:
- mutex_unlock(&dev->struct_mutex);
- return error;
-}
-
-static int
-drm_close_file(struct drm_file *file)
-{
- struct drm_minor *const minor = file->minor;
- struct drm_device *const dev = minor->dev;
- int error;
-
- mutex_lock(&drm_global_mutex);
-
- /* XXX Not all users of ioctl_count take the global mutex! */
- if ((dev->open_count == 1) && (atomic_read(&dev->ioctl_count) != 0)) {
- error = -EBUSY;
- goto out;
- }
-
- if (dev->driver->preclose)
- (*dev->driver->preclose)(dev, file);
-
- if (file->magic)
- (void)drm_remove_magic(file->master, file->magic);
-
- if (file->minor->master)
- drm_master_release(file);
-
- if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
- drm_core_reclaim_buffers(dev, file);
-
- drm_events_release(file);
-
- if (drm_core_check_feature(dev, DRIVER_MODESET))
- drm_fb_release(file);
-
- if (drm_core_check_feature(dev, DRIVER_GEM))
- drm_gem_release(dev, file);
-
- drm_close_file_contexts(file);
- drm_close_file_master(file);
-
- mutex_lock(&dev->struct_mutex);
- list_del(&file->lhead);
- mutex_unlock(&dev->struct_mutex);
-
- if (dev->driver->postclose)
- (*dev->driver->postclose)(dev, file);
-
- if (drm_core_check_feature(dev, DRIVER_PRIME))
- drm_prime_destroy_file_private(&file->prime);
-
- atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
- if (--dev->open_count == 0) {
- KASSERT(atomic_read(&dev->ioctl_count) == 0);
- drm_lastclose(dev);
- }
-
- /* Success! */
- error = 0;
-
-out:
- mutex_unlock(&drm_global_mutex);
- return error;
-}
-
-static void
-drm_master_release(struct drm_file *file)
-{
-
- if (drm_i_have_hw_lock(file->minor->dev, file))
- drm_lock_free(&file->master->lock,
- _DRM_LOCKING_CONTEXT(file->master->lock.hw_lock->lock));
-}
-
-static void
-drm_events_release(struct drm_file *file)
-{
- struct drm_device *const dev = file->minor->dev;
- struct drm_pending_vblank_event *vblank, *vblank_next;
- struct drm_pending_event *event, *event_next;
- unsigned long flags;
-
- spin_lock_irqsave(&dev->event_lock, flags);
-
- list_for_each_entry_safe(vblank, vblank_next, &dev->vblank_event_list,
- base.link) {
- if (vblank->base.file_priv == file) {
- list_del(&vblank->base.link);
- drm_vblank_put(dev, vblank->pipe);
- (*vblank->base.destroy)(&vblank->base);
- }
- }
-
- list_for_each_entry_safe(event, event_next, &file->event_list, link) {
- (*event->destroy)(event);
- }
-
- spin_unlock_irqrestore(&dev->event_lock, flags);
-}
-
-static void
-drm_close_file_contexts(struct drm_file *file)
-{
- struct drm_device *const dev = file->minor->dev;
-
- mutex_lock(&dev->ctxlist_mutex);
Home |
Main Index |
Thread Index |
Old Index