[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240516-hwspinlock-bust-v1-2-47a90a859238@quicinc.com>
Date: Thu, 16 May 2024 15:58:20 -0700
From: Chris Lew <quic_clew@...cinc.com>
To: Bjorn Andersson <andersson@...nel.org>,
Baolin Wang
<baolin.wang@...ux.alibaba.com>,
Peter Zijlstra <peterz@...radead.org>,
"Ingo
Molnar" <mingo@...hat.com>, Will Deacon <will@...nel.org>,
Waiman Long
<longman@...hat.com>, Boqun Feng <boqun.feng@...il.com>,
Jonathan Corbet
<corbet@....net>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Rob Herring
<robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley
<conor+dt@...nel.org>,
Manivannan Sadhasivam
<manivannan.sadhasivam@...aro.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>
CC: <linux-remoteproc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-doc@...r.kernel.org>, <linux-arm-msm@...r.kernel.org>,
<devicetree@...r.kernel.org>, Chris Lew <quic_clew@...cinc.com>,
"Richard
Maina" <quic_rmaina@...cinc.com>
Subject: [PATCH 2/7] hwspinlock: Enable hwspinlock sharing
From: Richard Maina <quic_rmaina@...cinc.com>
The hwspinlock used by qcom,smem is used to synchronize smem access
between the cpu and other remoteprocs in the soc. If one of these
remoteprocs crashes while holding the hwspinlock, then the remoteproc
driver should try to release the lock on behalf of the rproc. This
would require rproc and smem drivers to share access to a hwspinlock
handle.
With the introduction of reference counting this is now achievable,
therefore, remove the code in hwspin_lock_request_specific() preventing
this.
The single owner condition is retained in the hwspin_lock_request()
function, as this is specifically intended for requesting an unused
hwspinlock and should not have any shared references.
Signed-off-by: Richard Maina <quic_rmaina@...cinc.com>
Signed-off-by: Chris Lew <quic_clew@...cinc.com>
---
Documentation/locking/hwspinlock.rst | 8 ++++----
drivers/hwspinlock/hwspinlock_core.c | 8 --------
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/Documentation/locking/hwspinlock.rst b/Documentation/locking/hwspinlock.rst
index 6f03713b7003..c1c2c827b575 100644
--- a/Documentation/locking/hwspinlock.rst
+++ b/Documentation/locking/hwspinlock.rst
@@ -53,10 +53,10 @@ Should be called from a process context (might sleep).
struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
-Assign a specific hwspinlock id and return its address, or NULL
-if that hwspinlock is already in use. Usually board code will
-be calling this function in order to reserve specific hwspinlock
-ids for predefined purposes.
+Assign a specific hwspinlock id or increment the reference count if the
+hwspinlock is already in use. Return NULL if unable to request the
+hwspinlock. Usually board code will be calling this function in order
+to reserve specific hwspinlock ids for predefined purposes.
Should be called from a process context (might sleep).
diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
index 29b33072ff57..73a6dff5cbac 100644
--- a/drivers/hwspinlock/hwspinlock_core.c
+++ b/drivers/hwspinlock/hwspinlock_core.c
@@ -774,14 +774,6 @@ struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
/* sanity check (this shouldn't happen) */
WARN_ON(hwlock_to_id(hwlock) != id);
- /* make sure this hwspinlock is unused */
- ret = radix_tree_tag_get(&hwspinlock_tree, id, HWSPINLOCK_UNUSED);
- if (ret == 0) {
- pr_warn("hwspinlock %u is already in use\n", id);
- hwlock = NULL;
- goto out;
- }
-
/* mark as used and power up */
ret = __hwspin_lock_request(hwlock);
if (ret < 0)
--
2.25.1
Powered by blists - more mailing lists