diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2019-07-23 23:09:42 +0300 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2019-07-25 18:35:11 +0300 |
commit | 9154e60c4e057296983ef08d96ab5db76c1574c2 (patch) | |
tree | 3d88b525991f6e8b52e94fcec1ab8337fa45861b /drivers/gpu/drm/via/via_drv.h | |
parent | 3bf2a06e3612575284202c63de4f584006a85146 (diff) | |
download | linux-9154e60c4e057296983ef08d96ab5db76c1574c2.tar.xz |
drm/via: copy DRM_WAIT_ON as VIA_WAIT_ON and use it
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 <sam@ravnborg.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Cc: Kevin Brace <kevinbrace@gmx.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Mike Marshall <hubcap@omnibond.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Michel Dänzer <michel@daenzer.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20190723200944.17285-3-sam@ravnborg.org
Diffstat (limited to 'drivers/gpu/drm/via/via_drv.h')
-rw-r--r-- | drivers/gpu/drm/via/via_drv.h | 42 |
1 files changed, 41 insertions, 1 deletions
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 <drm/drm_mm.h> +#include <linux/jiffies.h> +#include <linux/sched.h> +#include <linux/sched/signal.h> +#include <linux/wait.h> + #include <drm/drm_legacy.h> +#include <drm/drm_mm.h> #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; |