drm/i915/gtt: Avoid overflowing the WC stash
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 29 May 2019 09:34:07 +0000 (10:34 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 29 May 2019 15:42:38 +0000 (16:42 +0100)
commit7f5f228008e4d6f59212b0ee693cbc36212096ba
treea9900db9bb113fc573d38f04e7b524ec66619650
parenta10f361d176ce53c72d5b1b2e2913a1a222ee393
drm/i915/gtt: Avoid overflowing the WC stash

An interesting issue cropped with making the pagetables be allocated and
freed concurrently (i.e. removing their grandeous struct_mutex guard)
was that we would overflow the page stash. This happens when we have
multiple allocators grabbing WC pages such that we fill the vm's local
page stash and then when we free another page, the page stash is already
full and we overflow.

The fix is quite simple: to check for a full page stash before adding
another. This results in us keeping a vm local page stash around for
much longer, which is both a blessing and a curse.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190529093407.31697-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_gtt.c