mbox series

[0/7] Add support for hwspinlock bust

Message ID 20240516-hwspinlock-bust-v1-0-47a90a859238@quicinc.com
Headers show
Series Add support for hwspinlock bust | expand

Message

Chris Lew May 16, 2024, 10:58 p.m. UTC
hwspinlocks can be acquired by many devices on the SoC. If any of these
devices go into a bad state before the device releases the hwspinlock,
then that hwspinlock may end up in an unusable state.

In the case of smem, each remoteproc takes a hwspinlock before trying to
allocate an smem item. If the remoteproc were to suddenly crash without
releasing this, it would be impossible for other remoteprocs to allocate
any smem items.

We propose a new api to bust a hwspinlock. This functionality is meant
for drivers that manage the lifecycle of a device. The driver can use
the bust api if it detects the device has gone into an error state, thus
allowing other entities in the system to use the hwspinlock.

The bust API implies multiple devices in linux can get a reference to a
hwspinlock. We add the ability for multiple devices to get a reference
to a hwspinlock via hwspin_lock_request_specific().
hwspin_lock_request() will continue to provide the next unused lock.

For the smem example, the hwspinlock will now be referenced by remoteproc
and the smem driver.

These patches were tested on an sm8650 mtp using engineering cdsp
firmware that triggers a watchdog with the smem hwspinlock acquired.

Checked for error in dt-bindings with below.
 - make DT_CHECKER_FLAGS=-m DT_SCHEMA_FILES=remoteproc/qcom,pas-common.yaml dt_binding_check
 - make qcom/sm8650-mtp.dtb CHECK_DTBS=1

Signed-off-by: Chris Lew <quic_clew@quicinc.com>
---
Chris Lew (2):
      dt-bindings: remoteproc: qcom,pas: Add hwlocks
      arm64: dts: qcom: sm8650: Add hwlock to remoteproc

Richard Maina (5):
      hwspinlock: Introduce refcount
      hwspinlock: Enable hwspinlock sharing
      hwspinlock: Introduce hwspin_lock_bust()
      hwspinlock: qcom: implement bust operation
      remoteproc: qcom_q6v5_pas: Add hwspinlock bust on stop

 .../bindings/remoteproc/qcom,pas-common.yaml       |  3 ++
 Documentation/locking/hwspinlock.rst               | 19 ++++++--
 arch/arm64/boot/dts/qcom/sm8650.dtsi               |  3 ++
 drivers/hwspinlock/hwspinlock_core.c               | 52 ++++++++++++++++------
 drivers/hwspinlock/hwspinlock_internal.h           |  5 +++
 drivers/hwspinlock/qcom_hwspinlock.c               | 25 +++++++++++
 drivers/remoteproc/qcom_q6v5_pas.c                 | 28 ++++++++++++
 include/linux/hwspinlock.h                         |  6 +++
 8 files changed, 123 insertions(+), 18 deletions(-)
---
base-commit: e7b4ef8fffaca247809337bb78daceb406659f2d
change-id: 20240509-hwspinlock-bust-d497a70c1a3a

Best regards,