drm/msm/gem: Protect pin_count/madv by LRU lock
authorRob Clark <robdclark@chromium.org>
Mon, 20 Mar 2023 14:43:30 +0000 (07:43 -0700)
committerRob Clark <robdclark@chromium.org>
Sat, 25 Mar 2023 23:31:44 +0000 (16:31 -0700)
commit6c7c8fb863f7c3137ce5fc4b435af3891083abeb
treebd9d2960eac290a05d57e67ac84c0b6ef894937f
parent4a02a376cbc839b89bbd1109f98b461e26337236
drm/msm/gem: Protect pin_count/madv by LRU lock

Since the LRU lock is already acquired when moving an obj between LRUs,
we can use it to protect pin_count and madv, without any significant
change in locking (ie. it just expands the scope of the lock by a hand-
ful of instructions).  This prepares the way to decrement the pin_count
in the job_run() path without needing to hold the obj lock, to avoid a
potential deadlock (or rather stall) caused by the fence-signaling path
(job_run()) blocking on shrinker/reclaim.  (Only a stall because the
wait for fence signaling wait_for_idle() is not infinite.)

Signed-off-by: Rob Clark <robdclark@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/527843/
Link: https://lore.kernel.org/r/20230320144356.803762-9-robdclark@gmail.com
drivers/gpu/drm/msm/msm_gem.c
drivers/gpu/drm/msm/msm_gem.h