[PATCH v1 5/6] drm/via: drop DRM_WAIT_ON() in via_irq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace DRM_WAIT_ON() with wait_event_interruptible().
While replacing be careful to keep same return value semantics.

Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx>
Cc: Kevin Brace <kevinbrace@xxxxxxx>
Cc: Thomas Hellstrom <thellstrom@xxxxxxxxxx>
Cc: "Gustavo A. R. Silva" <gustavo@xxxxxxxxxxxxxx>
Cc: Mike Marshall <hubcap@xxxxxxxxxxxx>
Cc: Ira Weiny <ira.weiny@xxxxxxxxx>
Cc: Daniel Vetter <daniel.vetter@xxxxxxxx>
Cc: Emil Velikov <emil.velikov@xxxxxxxxxxxxx>
---
 drivers/gpu/drm/via/via_irq.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index 9d47feb367d8..6de15065a3c0 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -36,7 +36,6 @@
  */
 
 #include <drm/drm_device.h>
-#include <drm/drm_os_linux.h>
 #include <drm/drm_vblank.h>
 #include <drm/via_drm.h>
 
@@ -201,6 +200,12 @@ void via_disable_vblank(struct drm_device *dev, unsigned int pipe)
 		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
 }
 
+/*
+ * Returns:
+ * 0 if interrupt occured within 3 secs
+ * -EBUSY if timeout happended
+ * -EINTR if interrupted by a signal
+ */
 static int
 via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence,
 		    unsigned int *sequence)
@@ -208,7 +213,7 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
 	drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
 	unsigned int cur_irq_sequence;
 	drm_via_irq_t *cur_irq;
-	int ret = 0;
+	int ret;
 	maskarray_t *masks;
 	int real_irq;
 
@@ -236,18 +241,27 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
 	cur_irq = dev_priv->via_irqs + real_irq;
 
 	if (masks[real_irq][2] && !force_sequence) {
-		DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
-			    ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
-			     masks[irq][4]));
+		ret = wait_event_interruptible_timeout(cur_irq->irq_queue,
+			((VIA_READ(masks[irq][2]) & masks[irq][3]) == masks[irq][4]),
+			msecs_to_jiffies(3000));
 		cur_irq_sequence = atomic_read(&cur_irq->irq_received);
 	} else {
-		DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
-			    (((cur_irq_sequence =
-			       atomic_read(&cur_irq->irq_received)) -
-			      *sequence) <= (1 << 23)));
+		ret = wait_event_interruptible_timeout(cur_irq->irq_queue,
+			(((cur_irq_sequence = atomic_read(&cur_irq->irq_received)) - *sequence) <= (1 << 23)),
+			msecs_to_jiffies(3000));
 	}
 	*sequence = cur_irq_sequence;
-	return ret;
+
+	switch (ret) {
+	case 0:
+		/* timeout */
+		return -EBUSY;
+	case -ERESTARTSYS:
+		/* interrupted by signal */
+		return -EINTR;
+	default:
+		return 0;
+	}
 }
 
 
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux