efi: Replace runtime services spinlock with semaphore
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 15 Jul 2016 19:36:31 +0000 (21:36 +0200)
committerMatt Fleming <matt@codeblueprint.co.uk>
Fri, 9 Sep 2016 15:08:43 +0000 (16:08 +0100)
commitdce48e351c0d42014e5fb16ac3eb099e11b7e716
tree97ec1bf70a8269d40598b5d1ed12f60d51ec18b4
parent21b3ddd39feecd2f4d6c52bcd30f0a4fa14f125a
efi: Replace runtime services spinlock with semaphore

The purpose of the efi_runtime_lock is to prevent concurrent calls into
the firmware. There is no need to use spinlocks here, as long as we ensure
that runtime service invocations from an atomic context (i.e., EFI pstore)
cannot block.

So use a semaphore instead, and use down_trylock() in the nonblocking case.
We don't use a mutex here because the mutex_trylock() function must not
be called from interrupt context, whereas the down_trylock() can.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Sylvain Chouleur <sylvain.chouleur@gmail.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
drivers/firmware/efi/efi.c
drivers/firmware/efi/runtime-wrappers.c
include/linux/efi.h