lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240529-hwspinlock-bust-v3-2-c8b924ffa5a2@quicinc.com>
Date: Wed, 29 May 2024 11:09:56 -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 v3 2/4] hwspinlock: qcom: implement bust operation

From: Richard Maina <quic_rmaina@...cinc.com>

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@...cinc.com>
Reviewed-by: Bjorn Andersson <andersson@...nel.org>
Signed-off-by: Chris Lew <quic_clew@...cinc.com>
---
 drivers/hwspinlock/qcom_hwspinlock.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

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 = {

-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ