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 Fix up drm_read and drm_poll ...



details:   https://anonhg.NetBSD.org/src/rev/403840adbe9b
branches:  riastradh-drm2
changeset: 788125:403840adbe9b
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 24 02:21:22 2013 +0000

description:
Fix up drm_read and drm_poll a little.

Still #ifdef'd out because it needs some selnotify calls to actually
work, but the #ifdef'd code now compiles and looks more plausible --
doesn't hold onto spin locks during loops and uiomoves.

diffstat:

 sys/external/bsd/drm2/dist/include/drm/drmP.h |  13 ++++++-
 sys/external/bsd/drm2/drm/drm_drv.c           |  41 ++++++++++++++------------
 2 files changed, 32 insertions(+), 22 deletions(-)

diffs (131 lines):

diff -r a74b9b095463 -r 403840adbe9b sys/external/bsd/drm2/dist/include/drm/drmP.h
--- a/sys/external/bsd/drm2/dist/include/drm/drmP.h     Wed Jul 24 02:21:05 2013 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drmP.h     Wed Jul 24 02:21:22 2013 +0000
@@ -485,6 +485,12 @@
        struct list_head event_list;
        int event_space;
 
+#ifdef __NetBSD__
+#if 0                          /* XXX drm event poll */
+       struct selinfo event_sel;
+#endif
+#endif
+
        struct drm_prime_file_private prime;
 };
 
@@ -1372,9 +1378,10 @@
 #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
+#if 0                          /* XXX drm event poll */
+extern int drm_dequeue_event(struct drm_file *, size_t,
+    struct drm_pending_event **);
+#endif
 #else
 extern int drm_open(struct inode *inode, struct file *filp);
 extern int drm_stub_open(struct inode *inode, struct file *filp);
diff -r a74b9b095463 -r 403840adbe9b sys/external/bsd/drm2/drm/drm_drv.c
--- a/sys/external/bsd/drm2/drm/drm_drv.c       Wed Jul 24 02:21:05 2013 +0000
+++ b/sys/external/bsd/drm2/drm/drm_drv.c       Wed Jul 24 02:21:22 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_drv.c,v 1.1.2.4 2013/07/24 02:21:05 riastradh Exp $        */
+/*     $NetBSD: drm_drv.c,v 1.1.2.5 2013/07/24 02:21:22 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.4 2013/07/24 02:21:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.1.2.5 2013/07/24 02:21:22 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -40,6 +40,10 @@
 #include <sys/filedesc.h>
 #include <sys/ioccom.h>
 #include <sys/kauth.h>
+#if 0                          /* XXX drm event poll */
+#include <sys/poll.h>
+#include <sys/select.h>
+#endif
 
 #include <drm/drmP.h>
 
@@ -58,9 +62,6 @@
 static int     drm_close(struct file *);
 static int     drm_read(struct file *, off_t *, struct uio *, kauth_cred_t,
                    int);
-#if 0                          /* XXX */
-static int     drm_dequeue_event(struct drm_file *, size_t);
-#endif
 static int     drm_poll(struct file *, int);
 static int     drm_stat(struct file *, struct stat *);
 static int     drm_ioctl(struct file *, unsigned long, void *);
@@ -350,28 +351,29 @@
 #else
        /* XXX How do flags figure into this?  */
        struct drm_file *const file = fp->f_data;
-       size_t transferred, limit;
        struct drm_pending_event *event;
        int error;
 
        if (off != 0)
                return EINVAL;
 
-       mutex_lock(&dev->event_lock);
-       DRM_WAIT_ON(error, &file->event_wait, &dev->event_lock,
-           !list_empty(&file->event_list));
-       if (error)
-               goto out;
+       for (;;) {
+               error = drm_dequeue_event(file, uio->uio_resid, &event);
+               if (error) {
+                       /* XXX errno Linux->NetBSD */
+                       return -error;
+               }
 
-       while ((event = drm_dequeue_event(file, uio->uio_resid)) != NULL) {
+               if (event == NULL)
+                       break;
+
                error = uiomove(event->event, event->event->length, uio);
-               if (error)
-                       goto out;
+               if (error)      /* XXX Requeue the event?  */
+                       return error;
        }
 
-out:
-       mutex_unlock(&drm_global_mutex);
-       return error;
+       /* Success!  */
+       return 0;
 #endif
 }
 
@@ -387,8 +389,9 @@
 #else
        struct drm_file *const file = fp->f_data;
        int revents = 0;
+       unsigned long flags;
 
-       mutex_lock(&file->event_list);
+       spin_lock_irqsave(&file->minor->dev->event_lock, flags);
 
        if (events & (POLLIN | POLLRDNORM)) {
                if (!list_empty(&file->event_list))
@@ -400,7 +403,7 @@
                        selrecord(curlwp, &file->event_sel);
        }
 
-       mutex_unlock(&file->event_list);
+       spin_unlock_irqrestore(&file->minor->dev->event_lock, flags);
 
        return revents;
 #endif



Home | Main Index | Thread Index | Old Index