From: Francisco Munoz Ruiz <francisco.ruiz@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
Francisco Munoz Ruiz <francisco.ruiz@oss.qualcomm.com>,
Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: [PATCH 2/2] soc: qcom: llcc: Use guards for mutex handling
Date: Thu, 05 Mar 2026 19:12:06 -0800 [thread overview]
Message-ID: <20260305-external_llcc_changes1set-v1-2-6347e52e648e@oss.qualcomm.com> (raw)
In-Reply-To: <20260305-external_llcc_changes1set-v1-0-6347e52e648e@oss.qualcomm.com>
From: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com>
Replacing manual lock/unlock pairs with guard() removes the need to
think about unlocking entirely and keeps the function trivially
structured.
Signed-off-by: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com>
Signed-off-by: Francisco Munoz Ruiz <francisco.ruiz@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
drivers/soc/qcom/llcc-qcom.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c
index 2e7f05df93a6..f859d91460c6 100644
--- a/drivers/soc/qcom/llcc-qcom.c
+++ b/drivers/soc/qcom/llcc-qcom.c
@@ -4531,27 +4531,21 @@ int llcc_slice_activate(struct llcc_slice_desc *desc)
if (IS_ERR_OR_NULL(desc))
return -EINVAL;
- mutex_lock(&drv_data->lock);
+ guard(mutex)(&drv_data->lock);
/* Already active; try to take another reference. */
- if (refcount_inc_not_zero(&desc->refcount)) {
- mutex_unlock(&drv_data->lock);
+ if (refcount_inc_not_zero(&desc->refcount))
return 0;
- }
act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE << ACT_CTRL_OPCODE_SHIFT;
-
ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
DEACTIVATE);
- if (ret) {
- mutex_unlock(&drv_data->lock);
+ if (ret)
return ret;
- }
/* Set first reference */
refcount_set(&desc->refcount, 1);
- mutex_unlock(&drv_data->lock);
- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(llcc_slice_activate);
@@ -4573,27 +4567,21 @@ int llcc_slice_deactivate(struct llcc_slice_desc *desc)
if (IS_ERR_OR_NULL(desc))
return -EINVAL;
- mutex_lock(&drv_data->lock);
+ guard(mutex)(&drv_data->lock);
/* refcount > 1, drop one ref and we’re done. */
- if (refcount_dec_not_one(&desc->refcount)) {
- mutex_unlock(&drv_data->lock);
+ if (refcount_dec_not_one(&desc->refcount))
return 0;
- }
act_ctrl_val = ACT_CTRL_OPCODE_DEACTIVATE << ACT_CTRL_OPCODE_SHIFT;
-
ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
ACTIVATE);
- if (ret) {
- mutex_unlock(&drv_data->lock);
+ if (ret)
return ret;
- }
/* Finalize: atomically transition 1 -> 0 */
WARN_ON_ONCE(!refcount_dec_if_one(&desc->refcount));
- mutex_unlock(&drv_data->lock);
- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(llcc_slice_deactivate);
--
2.34.1
next prev parent reply other threads:[~2026-03-06 3:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 3:12 [PATCH 0/2] Fix slice accounting and simplify descriptor and locking logic Francisco Munoz Ruiz
2026-03-06 3:12 ` [PATCH 1/2] soc: qcom: llcc: Add per-slice counter and common llcc slice descriptor Francisco Munoz Ruiz
2026-03-06 3:12 ` Francisco Munoz Ruiz [this message]
2026-03-16 2:02 ` [PATCH 0/2] Fix slice accounting and simplify descriptor and locking logic Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260305-external_llcc_changes1set-v1-2-6347e52e648e@oss.qualcomm.com \
--to=francisco.ruiz@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=unnathi.chalicheemala@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox