Skip to content

Commit 73100de

Browse files
Richard Mainaandersson
authored andcommitted
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>
1 parent 7c327d5 commit 73100de

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/hwspinlock/qcom_hwspinlock.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,34 @@ static void qcom_hwspinlock_unlock(struct hwspinlock *lock)
6464
pr_err("%s: failed to unlock spinlock\n", __func__);
6565
}
6666

67+
static int qcom_hwspinlock_bust(struct hwspinlock *lock, unsigned int id)
68+
{
69+
struct regmap_field *field = lock->priv;
70+
u32 owner;
71+
int ret;
72+
73+
ret = regmap_field_read(field, &owner);
74+
if (ret) {
75+
dev_err(lock->bank->dev, "unable to query spinlock owner\n");
76+
return ret;
77+
}
78+
79+
if (owner != id)
80+
return 0;
81+
82+
ret = regmap_field_write(field, 0);
83+
if (ret) {
84+
dev_err(lock->bank->dev, "failed to bust spinlock\n");
85+
return ret;
86+
}
87+
88+
return 0;
89+
}
90+
6791
static const struct hwspinlock_ops qcom_hwspinlock_ops = {
6892
.trylock = qcom_hwspinlock_trylock,
6993
.unlock = qcom_hwspinlock_unlock,
94+
.bust = qcom_hwspinlock_bust,
7095
};
7196

7297
static const struct regmap_config sfpb_mutex_config = {

0 commit comments

Comments
 (0)