Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Richard Maina and committed by
Bjorn Andersson
73100deb 7c327d56

+25
+25
drivers/hwspinlock/qcom_hwspinlock.c
··· 64 64 pr_err("%s: failed to unlock spinlock\n", __func__); 65 65 } 66 66 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 + 67 91 static const struct hwspinlock_ops qcom_hwspinlock_ops = { 68 92 .trylock = qcom_hwspinlock_trylock, 69 93 .unlock = qcom_hwspinlock_unlock, 94 + .bust = qcom_hwspinlock_bust, 70 95 }; 71 96 72 97 static const struct regmap_config sfpb_mutex_config = {