From 828ae6b8bc7169d13a3c9a04ebb6c124fa2bbd45 Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Wed, 7 Nov 2018 20:49:44 +0100 Subject: [PATCH] arch: arm: mpu: force outstanding transactions before MPU disabling The ARMv8-M Memory Protection Unit document indicates that a DMB instruction must be used before disabling the MPU in order to force outstanding memory transactions. The ARMv7-M documentation is less clear about that, and only specifies that a DSB instruction followed by a ISB instruction must be used before enabling the MPU, which is already the case. The ARMv7-M and ARMv8-M MPU are relatively similar to believe the same sequence should be used for disabling it. This patch therefore adds a DMB instruction before disabling the MPU. Signed-off-by: Aurelien Jarno --- arch/arm/core/cortex_m/mpu/arm_mpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/core/cortex_m/mpu/arm_mpu.c b/arch/arm/core/cortex_m/mpu/arm_mpu.c index 9bafd6bec54..1e36220e7ea 100644 --- a/arch/arm/core/cortex_m/mpu/arm_mpu.c +++ b/arch/arm/core/cortex_m/mpu/arm_mpu.c @@ -72,6 +72,9 @@ void arm_core_mpu_enable(void) */ void arm_core_mpu_disable(void) { + /* Force any outstanding transfers to complete before disabling MPU */ + __DMB(); + /* Disable MPU */ MPU->CTRL = 0; }