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

Sam Ravnborg sam at ravnborg.org
Thu Jul 18 15:37:36 UTC 2019


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

Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
Cc: Kevin Brace <kevinbrace at gmx.com>
Cc: Thomas Hellstrom <thellstrom at vmware.com>
Cc: "Gustavo A. R. Silva" <gustavo at embeddedor.com>
Cc: Mike Marshall <hubcap at omnibond.com>
Cc: Ira Weiny <ira.weiny at intel.com>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Emil Velikov <emil.velikov at collabora.com>
---
 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



More information about the dri-devel mailing list