From: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
To: Ben Horgan <ben.horgan@arm.com>,
James Morse <james.morse@arm.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Fenghua Yu <fenghuay@nvidia.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/2] arm_mpam: Force __iomem casts
Date: Fri, 27 Feb 2026 15:51:13 +0100 [thread overview]
Message-ID: <18f3f73a-9bc6-4518-b3e4-730fa0793146@oss.qualcomm.com> (raw)
In-Reply-To: <7b5e4218-5961-4874-bbb1-89770cd2c744@arm.com>
On 27/02/2026 15:06, Ben Horgan wrote:
> Hi Krzysztof,
>
> On 2/16/26 11:02, Krzysztof Kozlowski wrote:
>> Code allocates standard kernel memory to pass to the MPAM, which expects
>> __iomem. The code is safe, because __iomem accessors should work fine
>> on kernel mapped memory, however leads to sparse warnings:
>>
>> test_mpam_devices.c:327:42: warning: incorrect type in initializer (different address spaces)
>> test_mpam_devices.c:327:42: expected char [noderef] __iomem *buf
>> test_mpam_devices.c:327:42: got void *
>> test_mpam_devices.c:342:24: warning: cast removes address space '__iomem' of expression
>>
>> Cast the pointer to memory via __force to silence them.
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
>> ---
>> drivers/resctrl/test_mpam_devices.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/resctrl/test_mpam_devices.c b/drivers/resctrl/test_mpam_devices.c
>> index 3e8d564a0c64..2de41b47c138 100644
>> --- a/drivers/resctrl/test_mpam_devices.c
>> +++ b/drivers/resctrl/test_mpam_devices.c
>> @@ -324,7 +324,7 @@ static void test_mpam_enable_merge_features(struct kunit *test)
>>
>> static void test_mpam_reset_msc_bitmap(struct kunit *test)
>> {
>> - char __iomem *buf = kunit_kzalloc(test, SZ_16K, GFP_KERNEL);
>> + char __iomem *buf = (__force char __iomem *)kunit_kzalloc(test, SZ_16K, GFP_KERNEL);
>> struct mpam_msc fake_msc = {};
>> u32 *test_result;
>>
>> @@ -339,7 +339,7 @@ static void test_mpam_reset_msc_bitmap(struct kunit *test)
>> mutex_init(&fake_msc.part_sel_lock);
>> mutex_lock(&fake_msc.part_sel_lock);
>>
>> - test_result = (u32 *)(buf + MPAMCFG_CPBM);
>> + test_result = (__force u32 *)(buf + MPAMCFG_CPBM);
>>
>> mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 0);
>> KUNIT_EXPECT_EQ(test, test_result[0], 0);
>
>
> This change looks good to me. As sparse is more broken I needed to use
> the patch from [1] to reproduce this. Copied here for convenience.
The branch from Al Viro was working fine at that time, now merged to master.
>
> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index 2b30a0529d48..90536b2bc42e 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -14,8 +14,8 @@ struct vm_area_struct;
> struct mempolicy;
>
> /* Helper macro to avoid gfp flags if they are the default one */
> -#define __default_gfp(a,...) a
> -#define default_gfp(...) __default_gfp(__VA_ARGS__ __VA_OPT__(,)
> GFP_KERNEL)
> +#define __default_gfp(a,b,...) b
> +#define default_gfp(...) __default_gfp(,##__VA_ARGS__,GFP_KERNEL)
>
> /* Convert GFP flags to their corresponding migrate type */
> #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE)
>
> There is a kernel test robot report [2] and that asks for these tags:
That I did not know. Anyone can run sparse, as I am doing every now and
then, and find issues.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes:
> https://lore.kernel.org/oe-kbuild-all/202512160133.eAzPdJv2-lkp@intel.com/
>
> Acked-by: Ben Horgan <ben.horgan@arm.com>
Best regards,
Krzysztof
next prev parent reply other threads:[~2026-02-27 14:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 11:02 Krzysztof Kozlowski
2026-02-16 11:02 ` [PATCH 2/2] arm64: MAINTAINERS: Include resctrl MPAM driver Krzysztof Kozlowski
2026-02-18 16:23 ` Catalin Marinas
2026-02-18 16:46 ` Krzysztof Kozlowski
2026-02-18 17:13 ` Catalin Marinas
2026-02-18 17:21 ` Krzysztof Kozlowski
2026-02-27 14:06 ` [PATCH 1/2] arm_mpam: Force __iomem casts Ben Horgan
2026-02-27 14:51 ` Krzysztof Kozlowski [this message]
2026-03-06 18:26 ` 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=18f3f73a-9bc6-4518-b3e4-730fa0793146@oss.qualcomm.com \
--to=krzysztof.kozlowski@oss.qualcomm.com \
--cc=ben.horgan@arm.com \
--cc=catalin.marinas@arm.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=reinette.chatre@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®