From: Fenghua Yu <fenghuay@nvidia.com>
To: Ben Horgan <ben.horgan@arm.com>, james.morse@arm.com
Cc: amitsinght@marvell.com, baisheng.gao@unisoc.com,
baolin.wang@linux.alibaba.com, bobo.shaobowang@huawei.com,
carl@os.amperecomputing.com, catalin.marinas@arm.com,
dakr@kernel.org, dave.martin@arm.com, david@redhat.com,
dfustini@baylibre.com, gregkh@linuxfoundation.org,
gshan@redhat.com, guohanjun@huawei.com, jeremy.linton@arm.com,
jonathan.cameron@huawei.com, kobak@nvidia.com,
lcherian@marvell.com, lenb@kernel.org,
linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, lpieralisi@kernel.org,
peternewman@google.com, quic_jiles@quicinc.com,
rafael@kernel.org, robh@kernel.org, rohit.mathew@arm.com,
scott@os.amperecomputing.com, sdonthineni@nvidia.com,
sudeep.holla@arm.com, tan.shaopeng@fujitsu.com, will@kernel.org,
xhao@linux.alibaba.com,
Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>,
Zeng Heng <zengheng4@huawei.com>
Subject: Re: [PATCH v5 15/34] arm_mpam: Add helpers for managing the locking around the mon_sel registers
Date: Tue, 18 Nov 2025 20:13:59 -0800 [thread overview]
Message-ID: <bb238bdc-1870-4888-874e-b3fa466d264b@nvidia.com> (raw)
In-Reply-To: <20251117170014.4113754-16-ben.horgan@arm.com>
Hi, Ben,
On 11/17/25 08:59, Ben Horgan wrote:
> From: James Morse <james.morse@arm.com>
>
> The MSC MON_SEL register needs to be accessed from hardirq for the overflow
> interrupt, and when taking an IPI to access these registers on platforms
> where MSC are not accessible from every CPU. This makes an irqsave
> spinlock the obvious lock to protect these registers. On systems with SCMI
> or PCC mailboxes it must be able to sleep, meaning a mutex must be used.
> The SCMI or PCC platforms can't support an overflow interrupt, and
> can't access the registers from hardirq context.
>
> Clearly these two can't exist for one MSC at the same time.
>
> Add helpers for the MON_SEL locking. For now, use a irqsave spinlock and
> only support 'real' MMIO platforms.
>
> In the future this lock will be split in two allowing SCMI/PCC platforms
> to take a mutex. Because there are contexts where the SCMI/PCC platforms
> can't make an access, mpam_mon_sel_lock() needs to be able to fail. Do
> this now, so that all the error handling on these paths is present. This
> allows the relevant paths to fail if they are needed on a platform where
> this isn't possible, instead of having to make explicit checks of the
> interface type.
>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Reviewed-by: Gavin Shan <gshan@redhat.com>
> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
> Tested-by: Fenghua Yu <fenghuay@nvidia.com>
> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
> Tested-by: Peter Newman <peternewman@google.com>
> Tested-by: Carl Worth <carl@os.amperecomputing.com>
> Tested-by: Gavin Shan <gshan@redhat.com>
> Tested-by: Zeng Heng <zengheng4@huawei.com>
> Signed-off-by: James Morse <james.morse@arm.com>
> Signed-off-by: Ben Horgan <ben.horgan@arm.com
[SNIP]
> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
> index 768a58a3ab27..b62ee55e1ed5 100644
> --- a/drivers/resctrl/mpam_internal.h
> +++ b/drivers/resctrl/mpam_internal.h
[SNIP]
> +/* Returning false here means accesses to mon_sel must fail and report an error. */
> +static inline bool __must_check mpam_mon_sel_lock(struct mpam_msc *msc)
> +{
> + WARN_ON_ONCE(msc->iface != MPAM_IFACE_MMIO);
> +
> + raw_spin_lock_irqsave(&msc->_mon_sel_lock, msc->_mon_sel_flags);
> + return true;
> +}
This helper always returns true, never false. And this may cause issue
later.
On the bottom line, this causes confusion in the comment and when later
its return value is always checked by callers.
It's better to improve this helper?
Option 1: warn and return false when ris->iface is not MMIO. No changes
in other patches which call the helper. Seems this is a better fix.
Option 2: warn on non MMIO iface but no return value. Other patches need
to be changed when calling the helper.
Thanks.
-Fenghua
next prev parent reply other threads:[~2025-11-19 4:14 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 16:59 [PATCH v5 00/34] arm_mpam: Add basic mpam driver Ben Horgan
2025-11-17 16:59 ` [PATCH v5 01/34] ACPI / PPTT: Add a helper to fill a cpumask from a processor container Ben Horgan
2025-11-18 8:37 ` Hanjun Guo
2025-11-19 3:35 ` Gavin Shan
2025-11-19 10:00 ` Ben Horgan
2025-11-19 16:22 ` Jeremy Linton
2025-11-17 16:59 ` [PATCH v5 02/34] ACPI / PPTT: Stop acpi_count_levels() expecting callers to clear levels Ben Horgan
2025-11-19 4:50 ` Hanjun Guo
2025-11-19 16:25 ` Jeremy Linton
2025-11-17 16:59 ` [PATCH v5 03/34] ACPI / PPTT: Add acpi_pptt_cache_v1_full to use pptt cache as one structure Ben Horgan
2025-11-18 4:03 ` Fenghua Yu
2025-11-18 10:57 ` Ben Horgan
2025-11-18 16:30 ` Fenghua Yu
2025-11-18 14:40 ` Jonathan Cameron
2025-11-19 3:44 ` Gavin Shan
2025-11-19 5:13 ` Hanjun Guo
2025-11-19 16:28 ` Jeremy Linton
2025-11-17 16:59 ` [PATCH v5 04/34] ACPI / PPTT: Find cache level by cache-id Ben Horgan
2025-11-18 15:32 ` Jonathan Cameron
2025-11-19 16:29 ` Jeremy Linton
2025-11-17 16:59 ` [PATCH v5 05/34] ACPI / PPTT: Add a helper to fill a cpumask from a cache_id Ben Horgan
2025-11-18 15:33 ` Jonathan Cameron
2025-11-19 16:37 ` Jeremy Linton
2025-11-17 16:59 ` [PATCH v5 06/34] arm64: kconfig: Add Kconfig entry for MPAM Ben Horgan
2025-11-17 16:59 ` [PATCH v5 07/34] platform: Define platform_device_put cleanup handler Ben Horgan
2025-11-17 16:59 ` [PATCH v5 08/34] ACPI: Define acpi_put_table cleanup handler and acpi_get_table_ret() helper Ben Horgan
2025-11-17 19:46 ` Rafael J. Wysocki
2025-11-18 11:07 ` Ben Horgan
2025-11-18 16:13 ` Catalin Marinas
2025-11-18 16:21 ` Rafael J. Wysocki
2025-11-18 16:45 ` Catalin Marinas
2025-11-17 16:59 ` [PATCH v5 09/34] ACPI / MPAM: Parse the MPAM table Ben Horgan
2025-11-18 3:31 ` Fenghua Yu
2025-11-17 16:59 ` [PATCH v5 10/34] arm_mpam: Add probe/remove for mpam msc driver and kbuild boiler plate Ben Horgan
2025-11-17 19:50 ` Markus Elfring
2025-11-18 10:44 ` Ben Horgan
2025-11-18 11:28 ` [v5 " Markus Elfring
2025-11-18 5:19 ` [PATCH v5 " Shaopeng Tan (Fujitsu)
2025-11-17 16:59 ` [PATCH v5 11/34] arm_mpam: Add the class and component structures for firmware described ris Ben Horgan
2025-11-18 4:11 ` Fenghua Yu
2025-11-17 16:59 ` [PATCH v5 12/34] arm_mpam: Add MPAM MSC register layout definitions Ben Horgan
2025-11-17 16:59 ` [PATCH v5 13/34] arm_mpam: Add cpuhp callbacks to probe MSC hardware Ben Horgan
2025-11-17 16:59 ` [PATCH v5 14/34] arm_mpam: Probe hardware to find the supported partid/pmg values Ben Horgan
2025-11-18 16:23 ` Fenghua Yu
2025-11-17 16:59 ` [PATCH v5 15/34] arm_mpam: Add helpers for managing the locking around the mon_sel registers Ben Horgan
2025-11-19 4:13 ` Fenghua Yu [this message]
2025-11-19 10:12 ` Ben Horgan
2025-11-17 16:59 ` [PATCH v5 16/34] arm_mpam: Probe the hardware features resctrl supports Ben Horgan
2025-11-17 16:59 ` [PATCH v5 17/34] arm_mpam: Merge supported features during mpam_enable() into mpam_class Ben Horgan
2025-11-17 16:59 ` [PATCH v5 18/34] arm_mpam: Reset MSC controls from cpuhp callbacks Ben Horgan
2025-11-17 16:59 ` [PATCH v5 19/34] arm_mpam: Add a helper to touch an MSC from any CPU Ben Horgan
2025-11-17 16:59 ` [PATCH v5 20/34] arm_mpam: Extend reset logic to allow devices to be reset any time Ben Horgan
2025-11-17 17:00 ` [PATCH v5 21/34] arm_mpam: Register and enable IRQs Ben Horgan
2025-11-18 5:30 ` Fenghua Yu
2025-11-17 17:00 ` [PATCH v5 22/34] arm_mpam: Use a static key to indicate when mpam is enabled Ben Horgan
2025-11-17 17:00 ` [PATCH v5 23/34] arm_mpam: Allow configuration to be applied and restored during cpu online Ben Horgan
2025-11-18 5:21 ` Shaopeng Tan (Fujitsu)
2025-11-18 15:39 ` Jonathan Cameron
2025-11-19 4:53 ` Fenghua Yu
2025-11-17 17:00 ` [PATCH v5 24/34] arm_mpam: Probe and reset the rest of the features Ben Horgan
2025-11-18 16:54 ` Fenghua Yu
2025-11-17 17:00 ` [PATCH v5 25/34] arm_mpam: Add helpers to allocate monitors Ben Horgan
2025-11-18 20:44 ` Fenghua Yu
2025-11-17 17:00 ` [PATCH v5 26/34] arm_mpam: Add mpam_msmon_read() to read monitor value Ben Horgan
2025-11-19 5:03 ` Fenghua Yu
2025-11-17 17:00 ` [PATCH v5 27/34] arm_mpam: Track bandwidth counter state for power management Ben Horgan
2025-11-19 4:43 ` Fenghua Yu
2025-11-17 17:00 ` [PATCH v5 28/34] arm_mpam: Consider overflow in bandwidth counter state Ben Horgan
2025-11-19 4:27 ` Fenghua Yu
2025-11-17 17:00 ` [PATCH v5 29/34] arm_mpam: Probe for long/lwd mbwu counters Ben Horgan
2025-11-19 4:57 ` Fenghua Yu
2025-11-17 17:00 ` [PATCH v5 30/34] arm_mpam: Use long MBWU counters if supported Ben Horgan
2025-11-17 17:00 ` [PATCH v5 31/34] arm_mpam: Add helper to reset saved mbwu state Ben Horgan
2025-11-17 17:00 ` [PATCH v5 32/34] arm_mpam: Add kunit test for bitmap reset Ben Horgan
2025-11-17 17:00 ` [PATCH v5 33/34] arm_mpam: Add kunit tests for props_mismatch() Ben Horgan
2025-11-17 17:00 ` [PATCH v5 34/34] MAINTAINERS: new entry for MPAM Driver Ben Horgan
2025-11-17 20:02 ` Catalin Marinas
2025-11-17 22:08 ` Reinette Chatre
2025-11-18 15:41 ` Jonathan Cameron
2025-11-19 4:06 ` Gavin Shan
2025-11-18 3:29 ` [PATCH v5 00/34] arm_mpam: Add basic mpam driver Fenghua Yu
2025-11-18 6:54 ` Shaopeng Tan (Fujitsu)
2025-11-18 7:45 ` Hanjun Guo
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=bb238bdc-1870-4888-874e-b3fa466d264b@nvidia.com \
--to=fenghuay@nvidia.com \
--cc=amitsinght@marvell.com \
--cc=baisheng.gao@unisoc.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=ben.horgan@arm.com \
--cc=bobo.shaobowang@huawei.com \
--cc=carl@os.amperecomputing.com \
--cc=catalin.marinas@arm.com \
--cc=dakr@kernel.org \
--cc=dave.martin@arm.com \
--cc=david@redhat.com \
--cc=dfustini@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=gshan@redhat.com \
--cc=guohanjun@huawei.com \
--cc=james.morse@arm.com \
--cc=jeremy.linton@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=kobak@nvidia.com \
--cc=lcherian@marvell.com \
--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=peternewman@google.com \
--cc=quic_jiles@quicinc.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rohit.mathew@arm.com \
--cc=scott@os.amperecomputing.com \
--cc=sdonthineni@nvidia.com \
--cc=sudeep.holla@arm.com \
--cc=tan.shaopeng@fujitsu.com \
--cc=tan.shaopeng@jp.fujitsu.com \
--cc=will@kernel.org \
--cc=xhao@linux.alibaba.com \
--cc=zengheng4@huawei.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