firmware: arm_sdei: fix double-lock on hibernate with shared events
authorJames Morse <james.morse@arm.com>
Fri, 21 Feb 2020 16:35:06 +0000 (16:35 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 27 Feb 2020 17:14:12 +0000 (17:14 +0000)
commit6ded0b61cf638bf9f8efe60ab8ba23db60ea9763
tree5786bb7b077bb3c4ec9573a24863d28d69305a09
parentf8788d86ab28f61f7b46eb6be375f8a726783636
firmware: arm_sdei: fix double-lock on hibernate with shared events

SDEI has private events that must be registered on each CPU. When
CPUs come and go they must re-register and re-enable their private
events. Each event has flags to indicate whether this should happen
to protect against an event being registered on a CPU coming online,
while all the others are unregistering the event.

These flags are protected by the sdei_list_lock spinlock, because
the cpuhp callbacks can't take the mutex.

Hibernate needs to unregister all events, but keep the in-memory
re-register and re-enable as they are. sdei_unregister_shared()
takes the spinlock to walk the list, then calls _sdei_event_unregister()
on each shared event. _sdei_event_unregister() tries to take the
same spinlock to update re-register and re-enable. This doesn't go
so well.

Push the re-register and re-enable updates out to their callers.
sdei_unregister_shared() doesn't want these values updated, so
doesn't need to do anything.

This also fixes shared events getting lost over hibernate as this
path made them look unregistered.

Fixes: da351827240e ("firmware: arm_sdei: Add support for CPU and system power states")
Reported-by: Liguang Zhang <zhangliguang@linux.alibaba.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
drivers/firmware/arm_sdei.c