From 9154e60c4e057296983ef08d96ab5db76c1574c2 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 23 Jul 2019 22:09:42 +0200 Subject: drm/via: copy DRM_WAIT_ON as VIA_WAIT_ON and use it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VIA_WAIT_ON() is a direct copy of DRM_WAIT_ON() from drm_os_linux.h. The copy is made so we can avoid the dependency on the legacy header. A more involved approach had been to introduce wait_event_* but for this legacy driver the simpler and more safe approach with a copy of the macro was selected. Added the relevant header files for the functions used in VIA_WAIT_ON. v3: - Updated users of DRM_WAIT_ON => VIA_WAIT_ON (Emil) - Updated $subject (Emil) Signed-off-by: Sam Ravnborg Reviewed-by: Emil Velikov Cc: Kevin Brace Cc: Thomas Hellstrom Cc: "Gustavo A. R. Silva" Cc: Mike Marshall Cc: Ira Weiny Cc: Daniel Vetter Cc: Michel Dänzer Link: https://patchwork.freedesktop.org/patch/msgid/20190723200944.17285-3-sam@ravnborg.org --- drivers/gpu/drm/via/via_drv.h | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/via/via_drv.h') diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h index 368185b80184..9e6a0c5f316c 100644 --- a/drivers/gpu/drm/via/via_drv.h +++ b/drivers/gpu/drm/via/via_drv.h @@ -24,8 +24,13 @@ #ifndef _VIA_DRV_H_ #define _VIA_DRV_H_ -#include +#include +#include +#include +#include + #include +#include #define DRIVER_AUTHOR "Various" @@ -140,6 +145,41 @@ static inline void via_write8_mask(struct drm_via_private *dev_priv, writeb(tmp, (void __iomem *)(dev_priv->mmio->handle + reg)); } +/* + * Poll in a loop waiting for 'contidition' to be true. + * Note: A direct replacement with wait_event_interruptible_timeout() + * will not work unless driver is updated to emit wake_up() + * in relevant places that can impact the 'condition' + * + * Returns: + * ret keeps current value if 'condition' becomes true + * ret = -BUSY if timeout happens + * ret = -EINTR if a signal interrupted the waiting period + */ +#define VIA_WAIT_ON( ret, queue, timeout, condition ) \ +do { \ + DECLARE_WAITQUEUE(entry, current); \ + unsigned long end = jiffies + (timeout); \ + add_wait_queue(&(queue), &entry); \ + \ + for (;;) { \ + __set_current_state(TASK_INTERRUPTIBLE); \ + if (condition) \ + break; \ + if (time_after_eq(jiffies, end)) { \ + ret = -EBUSY; \ + break; \ + } \ + schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \ + if (signal_pending(current)) { \ + ret = -EINTR; \ + break; \ + } \ + } \ + __set_current_state(TASK_RUNNING); \ + remove_wait_queue(&(queue), &entry); \ +} while (0) + extern const struct drm_ioctl_desc via_ioctls[]; extern int via_max_ioctl; -- cgit v1.2.3