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 liwei391@huawei.com --- 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 5286fc024494..e781f6ef56da 100644 --- a/arch/arm64/kernel/mpam/mpam_device.c +++ b/arch/arm64/kernel/mpam/mpam_device.c @@ -568,6 +568,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); @@ -582,7 +583,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);