Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Ben Horgan <ben.horgan@arm.com>, Zeng Heng <zengheng4@huawei.com>,
	xry111@xry111.site, catalin.marinas@arm.com, maz@kernel.org,
	ardb@kernel.org, yang@os.amperecomputing.com,
	ryan.roberts@arm.com, kevin.brodsky@arm.com,
	reinette.chatre@intel.com, miko.lenczewski@arm.com,
	will@kernel.org, suzuki.poulose@arm.com, thuth@redhat.com,
	james.clark@linaro.org, lpieralisi@kernel.org,
	broonie@kernel.org, oupton@kernel.org, anshuman.khandual@arm.com,
	yeoreum.yun@arm.com, leo.yan@arm.com,
	mrigendra.chaubey@gmail.com, fenghuay@nvidia.com,
	ahmed.genidi@arm.com, mark.rutland@arm.com
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, wangkefeng.wang@huawei.com
Subject: Re: [PATCH v2 2/2] arm_mpam: Update architecture version check for MPAM MSC
Date: Fri, 8 May 2026 17:07:25 +0100	[thread overview]
Message-ID: <15208746-9521-4e04-a208-15600e96e7e1@arm.com> (raw)
In-Reply-To: <7b9d69df-8086-472d-b0c3-8d46e1b5399e@arm.com>

Hi Ben,

On 08/05/2026 10:56, Ben Horgan wrote:
> On 5/8/26 10:37, Ben Horgan wrote:
>> On 5/8/26 04:47, Zeng Heng wrote:
>>> On 2026/5/8 10:26, Zeng Heng wrote:
>>>
>>>>> I think its simpler to rule out the unsupported combinations, something like:
>>>>> | static bool mpam_msc_check_aidr(struct mpam_msc *msc)
>>>>> | {
>>>>> |     u32 rev;
>>>>> |
>>>>> |     rev = __mpam_read_reg(msc, MPAMF_AIDR) & MPAMF_AIDR_ARCH_REV;
>>>>> |
>>>>> |      /*
>>>>> |      * v0.0 and >v2.x aren't supported, but anything else should be backward
>>>>> |     * compatible to v0.1 or v1.0.
>>>>> |     */
>>>>> |     if (!rev)
>>>>> |         return false;
>>>>> |     if (rev & MPAMF_AIDR_ARCH_MAJOR_REV > MPAM_ARCHITECTURE_V1)
>>>>> |         return false;
>>>>> |
>>>
>>> Oops, after more complete version number testing, I found there's an
>>> operator precedence issue here. The correct fix is:
>>>
>>>     if ((rev & MPAMF_AIDR_ARCH_MAJOR_REV) > MPAM_ARCHITECTURE_V1)
>>>         return false;
>>>
>>> Note that '>' has higher precedence than '&'.

(yeah, the compiler winged at me. I should have said I didn't even build the hunk above
 before suggesting it!)


>> Isn't it better to use FIELD_GET()?

Always!


>> We could also avoid creating MPAMF_AIDR_ARCH_REV and use MPAMF_AIDR_ARCH_MAJOR_REV
>> and MPAMF_AIDR_ARCH_MINOR_REV directly to stop splitting the logic over two files. mpam_msc_check_aidr() could become:
>>
>> static bool mpam_msc_check_aidr(struct mpam_msc *msc)
>> {
>> 	u32 aidr = __mpam_read_reg(msc, MPAMF_AIDR);
>> 	u32 major = FIELD_GET(MPAMF_AIDR_ARCH_MAJOR_REV, aidr);
>> 	u32 minor = FIELD_GET(MPAMF_AIDR_ARCH_MINOR_REV, aidr);
>>
>> 	/*
>> 	 * v0.0 and >v2.x aren't supported, but anything else should be backward
>> 	 * compatible to v0.1 or v1.0.
>> 	 */
>> 	if (!major && !minor)
>> 		return false;
>> 	if (major > MPAM_ARCHITECTURE_V1)
> 
> This isn't correct. I missed that MPAM_ARCHITECTURE_V1 is 0x10 (which matches MPAMF_AIDR_ARCH_REV) and not 1.

Done locally. Thanks!

I also ran over two bugs with v0.1 MSC causing mpam_disable() to be called before
mpam_enable().


Thanks,

James


  reply	other threads:[~2026-05-08 16:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03  9:54 [PATCH v2 0/2] arm_mpam: Add support for the MPAM v0.1 architecture version Zeng Heng
2026-02-03  9:54 ` [PATCH v2 1/2] arm64: cpufeature: " Zeng Heng
2026-05-07 14:09   ` James Morse
2026-05-08  6:04     ` Zeng Heng
2026-02-03  9:54 ` [PATCH v2 2/2] arm_mpam: Update architecture version check for MPAM MSC Zeng Heng
2026-05-07 16:03   ` James Morse
2026-05-08  2:26     ` Zeng Heng
2026-05-08  3:47       ` Zeng Heng
2026-05-08  9:37         ` Ben Horgan
2026-05-08  9:56           ` Ben Horgan
2026-05-08 16:07             ` James Morse [this message]
2026-03-07  8:50 ` [PATCH v2 0/2] arm_mpam: Add support for the MPAM v0.1 architecture version Zeng Heng

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=15208746-9521-4e04-a208-15600e96e7e1@arm.com \
    --to=james.morse@arm.com \
    --cc=ahmed.genidi@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=ben.horgan@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=fenghuay@nvidia.com \
    --cc=james.clark@linaro.org \
    --cc=kevin.brodsky@arm.com \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=miko.lenczewski@arm.com \
    --cc=mrigendra.chaubey@gmail.com \
    --cc=oupton@kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=ryan.roberts@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=thuth@redhat.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=will@kernel.org \
    --cc=xry111@xry111.site \
    --cc=yang@os.amperecomputing.com \
    --cc=yeoreum.yun@arm.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