Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc1f7194 authored by Dave Airlie's avatar Dave Airlie
Browse files

drm: introduce drm_can_sleep and use in intel/radeon drivers. (v2)

So we have a few places where the drm drivers would like to sleep to
be nice to the system, mainly in the modesetting paths, but we also
have two cases were atomic modesetting must take place, panic writing
and kernel debugger. So provide a central inline to determine if a
sleep or delay should be used and use this in the intel and radeon drivers.

v2: drop intel_drv.h MSLEEP macro, nobody uses it.

Based on patch from Michel Dänzer <michel.daenzer@amd.com>

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=43941



Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 3df96909
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@
			ret__ = -ETIMEDOUT;				\
			break;						\
		}							\
		if (W && !(in_atomic() || in_dbg_master())) msleep(W);	\
		if (W && drm_can_sleep()) msleep(W);	\
	}								\
	ret__;								\
})
@@ -48,13 +48,6 @@
#define wait_for(COND, MS) _wait_for(COND, MS, 1)
#define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)

#define MSLEEP(x) do { \
	if (in_dbg_master()) \
		mdelay(x); \
	else \
		msleep(x); \
} while (0)

#define KHz(x) (1000*x)
#define MHz(x) KHz(1000*x)

+2 −0
Original line number Diff line number Diff line
@@ -665,6 +665,8 @@ static void atom_op_delay(atom_exec_context *ctx, int *ptr, int arg)
	SDEBUG("   count: %d\n", count);
	if (arg == ATOM_UNIT_MICROSEC)
		udelay(count);
	else if (!drm_can_sleep())
		mdelay(count);
	else
		msleep(count);
}
+8 −0
Original line number Diff line number Diff line
@@ -1696,5 +1696,13 @@ extern void drm_platform_exit(struct drm_driver *driver, struct platform_device
extern int drm_get_platform_dev(struct platform_device *pdev,
				struct drm_driver *driver);

/* returns true if currently okay to sleep */
static __inline__ bool drm_can_sleep(void)
{
	if (in_atomic() || in_dbg_master() || irqs_disabled())
		return false;
	return true;
}

#endif				/* __KERNEL__ */
#endif