summaryrefslogtreecommitdiff
path: root/drivers/hwspinlock/qcom_hwspinlock.c
diff options
context:
space:
mode:
authorRichard Maina <quic_rmaina@quicinc.com>2024-05-29 11:09:56 -0700
committerBjorn Andersson <andersson@kernel.org>2024-05-29 12:52:26 -0700
commit73100deb59c3892e280234fcc0171a5376c71788 (patch)
treec7969c714c3867e713619bce748961a5bfdd5b33 /drivers/hwspinlock/qcom_hwspinlock.c
parent7c327d56597d8de1680cf24e956b704270d3d84a (diff)
downloadlwn-73100deb59c3892e280234fcc0171a5376c71788.tar.gz
lwn-73100deb59c3892e280234fcc0171a5376c71788.zip
hwspinlock: qcom: implement bust operation
Implement a new operation qcom_hwspinlock_bust() which can be invoked to bust any locks that are in use when a remoteproc is stopped or crashed. Signed-off-by: Richard Maina <quic_rmaina@quicinc.com> Reviewed-by: Bjorn Andersson <andersson@kernel.org> Signed-off-by: Chris Lew <quic_clew@quicinc.com> Link: https://lore.kernel.org/r/20240529-hwspinlock-bust-v3-2-c8b924ffa5a2@quicinc.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Diffstat (limited to 'drivers/hwspinlock/qcom_hwspinlock.c')
-rw-r--r--drivers/hwspinlock/qcom_hwspinlock.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
index 814dfe8697bf..0390979fd765 100644
--- a/drivers/hwspinlock/qcom_hwspinlock.c
+++ b/drivers/hwspinlock/qcom_hwspinlock.c
@@ -64,9 +64,34 @@ static void qcom_hwspinlock_unlock(struct hwspinlock *lock)
pr_err("%s: failed to unlock spinlock\n", __func__);
}
+static int qcom_hwspinlock_bust(struct hwspinlock *lock, unsigned int id)
+{
+ struct regmap_field *field = lock->priv;
+ u32 owner;
+ int ret;
+
+ ret = regmap_field_read(field, &owner);
+ if (ret) {
+ dev_err(lock->bank->dev, "unable to query spinlock owner\n");
+ return ret;
+ }
+
+ if (owner != id)
+ return 0;
+
+ ret = regmap_field_write(field, 0);
+ if (ret) {
+ dev_err(lock->bank->dev, "failed to bust spinlock\n");
+ return ret;
+ }
+
+ return 0;
+}
+
static const struct hwspinlock_ops qcom_hwspinlock_ops = {
.trylock = qcom_hwspinlock_trylock,
.unlock = qcom_hwspinlock_unlock,
+ .bust = qcom_hwspinlock_bust,
};
static const struct regmap_config sfpb_mutex_config = {