From e4e46c59cd78bfc4c4b0a958510aa1b01aee7f25 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Mon, 25 Mar 2024 09:05:52 +0800 Subject: [PATCH] arm64/mpam: Fix repeated enabling in mpam_enable() hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9AZFU -------------------------------- In mpam_enable(), the enabling process is designed to be called once after all devices are probed. But if the kworker is parallel and delayed, it may be called multi times, add an atomic guard to avoid this situation. Fixes: e4173244bdfb ("arm64/mpam: Probe supported partid/pmg ranges from devices") Signed-off-by: Wei Li (cherry picked from commit 0376d22925d376939ebecf4febc648594af4e0db) --- arch/arm64/kernel/mpam/mpam_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/mpam/mpam_device.c b/arch/arm64/kernel/mpam/mpam_device.c index b77cea2673c0..c516b93eeb5f 100644 --- a/arch/arm64/kernel/mpam/mpam_device.c +++ b/arch/arm64/kernel/mpam/mpam_device.c @@ -543,6 +543,7 @@ static void mpam_enable(struct work_struct *work) unsigned long flags; struct mpam_device *dev; bool all_devices_probed = true; + static atomic_t once; /* Have we probed all the devices? */ mutex_lock(&mpam_devices_lock); @@ -557,7 +558,7 @@ static void mpam_enable(struct work_struct *work) } mutex_unlock(&mpam_devices_lock); - if (!all_devices_probed) + if (!(all_devices_probed && !atomic_fetch_inc(&once))) return; mutex_lock(&mpam_devices_lock); -- Gitee