Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm_mpam: Disable preemption when making accesses to fake MSC in kunit test

Accesses to MSC must be made from a cpu that is affine to that MSC and the
driver checks this in __mpam_write_reg() using smp_processor_id(). A fake
in-memory MSC is used for testing. When using that, it doesn't matter which
cpu we access it from but calling smp_processor_id() from a preemptible
context gives warnings when running with CONFIG_DEBUG_PREEMPT.

Add a test helper that wraps mpam_reset_msc_bitmap() with preemption
disabled to ensure all (fake) MSC accesses are made with preemption
disabled.

Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: James Morse <james.morse@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Ben Horgan and committed by
Will Deacon
c1376f1f 4ad79c87

+13 -5
+13 -5
drivers/resctrl/test_mpam_devices.c
··· 322 322 mutex_unlock(&mpam_list_lock); 323 323 } 324 324 325 + static void __test_mpam_reset_msc_bitmap(struct mpam_msc *msc, u16 reg, u16 wd) 326 + { 327 + /* Avoid warnings when running with CONFIG_DEBUG_PREEMPT */ 328 + guard(preempt)(); 329 + 330 + mpam_reset_msc_bitmap(msc, reg, wd); 331 + } 332 + 325 333 static void test_mpam_reset_msc_bitmap(struct kunit *test) 326 334 { 327 335 char __iomem *buf = kunit_kzalloc(test, SZ_16K, GFP_KERNEL); ··· 349 341 350 342 test_result = (u32 *)(buf + MPAMCFG_CPBM); 351 343 352 - mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 0); 344 + __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 0); 353 345 KUNIT_EXPECT_EQ(test, test_result[0], 0); 354 346 KUNIT_EXPECT_EQ(test, test_result[1], 0); 355 347 test_result[0] = 0; 356 348 test_result[1] = 0; 357 349 358 - mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 1); 350 + __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 1); 359 351 KUNIT_EXPECT_EQ(test, test_result[0], 1); 360 352 KUNIT_EXPECT_EQ(test, test_result[1], 0); 361 353 test_result[0] = 0; 362 354 test_result[1] = 0; 363 355 364 - mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 16); 356 + __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 16); 365 357 KUNIT_EXPECT_EQ(test, test_result[0], 0xffff); 366 358 KUNIT_EXPECT_EQ(test, test_result[1], 0); 367 359 test_result[0] = 0; 368 360 test_result[1] = 0; 369 361 370 - mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 32); 362 + __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 32); 371 363 KUNIT_EXPECT_EQ(test, test_result[0], 0xffffffff); 372 364 KUNIT_EXPECT_EQ(test, test_result[1], 0); 373 365 test_result[0] = 0; 374 366 test_result[1] = 0; 375 367 376 - mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 33); 368 + __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 33); 377 369 KUNIT_EXPECT_EQ(test, test_result[0], 0xffffffff); 378 370 KUNIT_EXPECT_EQ(test, test_result[1], 1); 379 371 test_result[0] = 0;