The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ben Horgan <ben.horgan@arm.com>
To: Zeng Heng <zengheng4@huawei.com>,
	James Morse <james.morse@arm.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 10:56:17 +0100	[thread overview]
Message-ID: <7b9d69df-8086-472d-b0c3-8d46e1b5399e@arm.com> (raw)
In-Reply-To: <ff95000d-d4ee-493a-b3cd-d573bd32abd0@arm.com>

Hi again James and Zeng,

On 5/8/26 10:37, Ben Horgan wrote:
> Hi James and Zeng,
> 
> On 5/8/26 04:47, Zeng Heng wrote:
>> Hi James,
>>
>> 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 '&'.
> 
> Isn't it better to use FIELD_GET()?  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.

Thanks,

Ben

> 		return false;
> 
> 	return true;
> }
> 
> 
> Thanks,
> 
> Ben
> 
>>
>>
>> With this fix included:
>> Tested-by: Zeng Heng <zengheng4@huawei.com>
>>
>>
>>>> |     return true;
>>>> | }
>>>>
>>>>> +    if (!mpam_msc_check_aidr(msc)) {
>>>>> +        dev_err_once(dev, "MSC does not match MPAM architecture\n");
>>>>>           return -EIO;
>>>>>       }
>>>>
>>>> I'd like to keep the 'v1.x' in this message - this should help folk with old stable
>>>> kernels running on new hardware work out why the feature isn't available.
>>>> (assuming they have some documentation that says v2.0 in it!)
>>>>
>>>> I've rebased this with the above changes, which I'll post shortly for fixes.
>>>>
>>>>
>>>
>>> Agreed. Keep the backward compatibility extension for versions
>>> (compatible with v0.x(x>0) and 1.x), and remove the redundant
>>> MPAM_ARCHITECTURE_Vx_x macro definitions.
>>>
>>> I've verified locally that everything works fine.
>>>
>>
>>
> 


  reply	other threads:[~2026-05-08  9:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260203095406.6437-1-zengheng4@huawei.com>
     [not found] ` <20260203095406.6437-2-zengheng4@huawei.com>
2026-05-07 14:09   ` [PATCH v2 1/2] arm64: cpufeature: Add support for the MPAM v0.1 architecture version James Morse
2026-05-08  6:04     ` Zeng Heng
     [not found] ` <20260203095406.6437-3-zengheng4@huawei.com>
2026-05-07 16:03   ` [PATCH v2 2/2] arm_mpam: Update architecture version check for MPAM MSC 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 [this message]
2026-05-08 16:07             ` James Morse

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=7b9d69df-8086-472d-b0c3-8d46e1b5399e@arm.com \
    --to=ben.horgan@arm.com \
    --cc=ahmed.genidi@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=fenghuay@nvidia.com \
    --cc=james.clark@linaro.org \
    --cc=james.morse@arm.com \
    --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