[Intel-gfx] [PATCH 3/3] drm/i915: userspace interface to the forcewake

Ben Widawsky ben at bwidawsk.net
Sun Apr 17 18:55:12 CEST 2011


On Sat, Apr 16, 2011 at 08:05:42AM +0100, Chris Wilson wrote:
> On Thu, 14 Apr 2011 21:56:02 +0200, Paul Menzel <paulepanter at users.sourceforge.net> wrote:

> But Ben... I seemed to have missed the real reason why we need the
> spinlock. You have to remind me or else I will keep whining on like a
> broken record. ;-)
> -Chris
> 

The reason rests on 1 major conclusion, we must make sure FORCEAWAKE
(FORCEWAKE_ACK in the code) is set prior to reading any register in the
range 0-0x3ffff. If I've misunderstood the way this works, and that is
not correct, then you can stop reading now.

The simplest case which shows why we need a spinlock is in reading IIR
(as discussed previously, including my theory why we probably don't
actually have an issue today) in the interrupt handler. We can't get
struct_mutex there, so we're forced to either bump up struct_mutex to a
spinlock, or introduce a new one.

There were one or two cases which got uncovered with the warning, which
I can't find from code inspection right now, where we write to these
registers with just config.mutex. In those cases, we could just acquire
struct_mutex after config.mutex, and that should fix those problems.

Now assuming access is synchronized, here is how I believe it should
work:

/*
 * Sorry for using the register names from the doc, which differ from
 * our code, but I'm writing this while reading the docs, not our code.
 */
u32 reg = IIR; // As an example
if (reg < 0x40000) {
	while(!I915_READ(GTFORCEAWAKE)) {
		I915_WRITE(FORCEWAKE, FWAKE2)
		I915_POSTING_READ(FORCEWAKE);
		gen6_gt_drain_write_fifo(); // ;)
	}
}

I would honestly prefer being wrong about this :-)
Ben



More information about the Intel-gfx mailing list