From: Jonathan Cameron <jic23@kernel.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>,
Hanjun Guo <guohanjun@huawei.com>,
Sudeep Holla <sudeep.holla@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, James Morse <james.morse@arm.com>,
Ben Horgan <ben.horgan@arm.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Fenghua Yu <fenghuay@nvidia.com>,
Srivathsa L Rao <srivathsa.rao@oss.qualcomm.com>,
Ganapatrao Kulkarni <ganapatrao.kulkarni@oss.qualcomm.com>,
Trilok Soni <tsoni@quicinc.com>,
Srinivas Ramana <sramana@qti.qualcomm.com>,
Niyas Sait <niyas.sait@arm.com>, Lee Trager <lee@trager.us>,
linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 02/10] arm_mpam: propagate MSC access errors for hw_probe functions
Date: Mon, 27 Jul 2026 23:21:25 +0100 [thread overview]
Message-ID: <20260727232125.357fd22c@jic23-huawei> (raw)
In-Reply-To: <20260723155454.1760823-3-andre.przywara@arm.com>
On Thu, 23 Jul 2026 17:54:46 +0200
Andre Przywara <andre.przywara@arm.com> wrote:
> Allow the functions probing for MSC hardware and features to return an
> error, and propagate read and write errors from the lower level up.
> This uses some "scoped cleanup" functions like scoped_guard() and
> ACQUIRE() to avoid the complexity of error handling when a lock has been
> taken. Since the mon_sel_lock is a bit special (even more so in an
> upcoming patch), we define a new GUARD type for it.
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Hi Andre
A couple of whites space comments inline.
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> ---
> drivers/resctrl/mpam_devices.c | 127 +++++++++++++++++++++-----------
> drivers/resctrl/mpam_internal.h | 8 ++
> 2 files changed, 91 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
> index 912c21ce7f9f..ecd45a585942 100644
> --- a/drivers/resctrl/mpam_devices.c
> +++ b/drivers/resctrl/mpam_devices.c
>
> static int mpam_msc_hw_probe(struct mpam_msc *msc)
> {
> + int ret;
> u64 idr;
> u16 partid_max;
> u8 ris_idx, pmg_max;
> @@ -1021,11 +1047,14 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
> }
>
> /* Grab an IDR value to find out how many RIS there are */
> - mutex_lock(&msc->part_sel_lock);
> - mpam_msc_read_idr(msc, &idr);
> - mpam_read_partsel_reg(msc, IIDR, &msc->iidr);
> -
> - mutex_unlock(&msc->part_sel_lock);
> + scoped_guard(mutex, &msc->part_sel_lock) {
> + ret = mpam_msc_read_idr(msc, &idr);
> + if (ret)
> + return ret;
Aim for formatting consistency. I'd put a blank line here and
in similar locations to keep each read / error check block separate...
> + ret = mpam_read_partsel_reg(msc, IIDR, &msc->iidr);
> + if (ret)
> + return ret;
> + }
>
> mpam_enable_quirks(msc);
>
> @@ -1036,10 +1065,15 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
> msc->pmg_max = FIELD_GET(MPAMF_IDR_PMG_MAX, idr);
>
> for (ris_idx = 0; ris_idx <= msc->ris_max; ris_idx++) {
> - mutex_lock(&msc->part_sel_lock);
> - __mpam_part_sel(ris_idx, 0, msc);
> - mpam_msc_read_idr(msc, &idr);
> - mutex_unlock(&msc->part_sel_lock);
> + scoped_guard(mutex, &msc->part_sel_lock) {
> + ret = __mpam_part_sel(ris_idx, 0, msc);
> + if (ret)
> + return ret;
> +
Just like you have done here.
> + ret = mpam_msc_read_idr(msc, &idr);
> + if (ret)
> + return ret;
> + }
>
> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
> index 04d1a59f02af..0c3f6a040b20 100644
> --- a/drivers/resctrl/mpam_internal.h
> +++ b/drivers/resctrl/mpam_internal.h
> @@ -162,6 +162,14 @@ static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc)
> raw_spin_lock_init(&msc->_mon_sel_lock);
> }
>
> +DEFINE_GUARD(mon_sel,
> + struct mpam_msc *,
> + mpam_mon_sel_lock(_T),
> + mpam_mon_sel_unlock(_T));
Why wrap so much. Something like:
DEFINE_GUARD(mon_sel, struct mpam_msc *,
mpam_mon_sel_lock(_T), mpam_mon_sel_unlock(_T));
or all on one line seems fine to me.
> +DEFINE_GUARD_COND(mon_sel, _lock,
> + mpam_mon_sel_lock(_T),
> + _RET);
> +
Similar.
> /* Bits for mpam features bitmaps */
> enum mpam_device_features {
> mpam_feat_cpor_part,
next prev parent reply other threads:[~2026-07-27 22:21 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 15:54 [PATCH v4 00/10] arm_mpam: Add MPAM-Fb firmware support Andre Przywara
2026-07-23 15:54 ` [PATCH v4 01/10] arm_mpam: let low level MSC accessors return an error Andre Przywara
2026-07-27 22:12 ` Jonathan Cameron
2026-07-23 15:54 ` [PATCH v4 02/10] arm_mpam: propagate MSC access errors for hw_probe functions Andre Przywara
2026-07-27 22:21 ` Jonathan Cameron [this message]
2026-07-23 15:54 ` [PATCH v4 03/10] arm_mpam: propagate MSC access errors for MBWU counters Andre Przywara
2026-07-27 22:37 ` Jonathan Cameron
2026-07-23 15:54 ` [PATCH v4 04/10] arm_mpam: propagate MSC access errors for msmon helpers Andre Przywara
2026-07-27 22:41 ` Jonathan Cameron
2026-07-23 15:54 ` [PATCH v4 05/10] arm_mpam: propagate MSC access errors for __ris_msmon_read() Andre Przywara
2026-07-24 10:02 ` Sudeep Holla
2026-07-24 11:17 ` Andre Przywara
2026-07-24 12:19 ` Sudeep Holla
2026-07-27 22:44 ` Jonathan Cameron
2026-07-23 15:54 ` [PATCH v4 06/10] arm_mpam: propagate MSC access errors for state saving function Andre Przywara
2026-07-24 10:07 ` Sudeep Holla
2026-07-24 11:19 ` Andre Przywara
2026-07-24 12:27 ` Sudeep Holla
2026-07-24 16:43 ` Ben Horgan
2026-07-27 22:51 ` Jonathan Cameron
2026-07-27 22:46 ` Jonathan Cameron
2026-07-23 15:54 ` [PATCH v4 07/10] arm_mpam: prepare mon_sel locking for MPAM-Fb Andre Przywara
2026-07-24 16:56 ` Ben Horgan
2026-07-23 15:54 ` [PATCH v4 08/10] arm_mpam: add MPAM-Fb MSC firmware access support Andre Przywara
2026-07-24 9:55 ` Sudeep Holla
2026-07-24 11:17 ` Andre Przywara
2026-07-24 12:22 ` Sudeep Holla
2026-07-24 17:08 ` Ben Horgan
2026-07-24 18:03 ` Sudeep Holla
2026-07-27 23:22 ` Jonathan Cameron
2026-07-23 15:54 ` [PATCH v4 09/10] arm_mpam: prevent MPAM-Fb accesses inside IRQ handler Andre Przywara
2026-07-24 16:52 ` Ben Horgan
2026-07-23 15:54 ` [PATCH v4 10/10] arm_mpam: detect and enable MPAM-Fb PCC support Andre Przywara
2026-07-24 10:18 ` Sudeep Holla
2026-07-27 12:48 ` Lorenzo Pieralisi
2026-07-27 13:20 ` Sudeep Holla
2026-07-27 13:33 ` Lorenzo Pieralisi
2026-07-27 13:39 ` Sudeep Holla
2026-07-27 13:39 ` Andre Przywara
2026-07-27 16:27 ` Srivathsa L Rao
2026-07-27 23:36 ` Jonathan Cameron
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=20260727232125.357fd22c@jic23-huawei \
--to=jic23@kernel.org \
--cc=andre.przywara@arm.com \
--cc=ben.horgan@arm.com \
--cc=catalin.marinas@arm.com \
--cc=fenghuay@nvidia.com \
--cc=ganapatrao.kulkarni@oss.qualcomm.com \
--cc=guohanjun@huawei.com \
--cc=james.morse@arm.com \
--cc=lee@trager.us \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=niyas.sait@arm.com \
--cc=rafael@kernel.org \
--cc=reinette.chatre@intel.com \
--cc=sramana@qti.qualcomm.com \
--cc=srivathsa.rao@oss.qualcomm.com \
--cc=sudeep.holla@kernel.org \
--cc=tsoni@quicinc.com \
--cc=will@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.