drm/i915/gtt: Serialise both updates to PDE and our shadow
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 17 Jun 2019 14:04:26 +0000 (15:04 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 17 Jun 2019 19:53:03 +0000 (20:53 +0100)
commit32a1963148277407f7af0160da2b7c0527afc8a4
tree4d077fc715d46755017e9d84634906f98e2c6cf5
parente93821146921efa9e8f6a83606145445f9a9cc3a
drm/i915/gtt: Serialise both updates to PDE and our shadow

Currently, we perform a locked update of the shadow entry when
allocating a page directory entry such that if two clients are
concurrently allocating neighbouring ranges we only insert one new entry
for the pair of them. However, we also need to serialise both clients
wrt to the actual entry in the HW table, or else we may allow one client
or even a third client to proceed ahead of the HW write. My handwave
before was that under the _pathological_ condition we would see the
scratch entry instead of the expected entry, causing a temporary
glitch. That starvation condition will eventually show up in practice, so
fix it.

The reason for the previous cheat was to avoid having to free the extra
allocation while under the spinlock. Now, we keep the extra entry
allocated until the end instead.

v2: Fix error paths for gen6

Fixes: 1d1b5490b91c ("drm/i915/gtt: Replace struct_mutex serialisation for allocation")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190617140426.7203-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_gtt.c