Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=210.118.77.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796338233; b=b7xntQBio5QwDsQ3zKcbuXHWwEDWZpkh9w/Jud7N8lcKYarjE4lZkWCgj5YlmNsQDaPJ qYewQmQ1tMyAjXC9rJPjA5dMGS4lzjhrINdnp8dBZnKth7650gDgnw4013Ef9E5v2e+pP 9hN7MYh4G6ERiN/0cnuOPgXYrMq5/ScwA1FG++b2fnGrxz0A171O3YFaPPVOjiIeY99k4 8BDdU3PBh3J0iNfYPsYMI/RDhdROFOYM5zTx/wsWQsppovVA5Kk/nc2whl2UDZLEK+0Tw 4p0hO405dJK6I2rA6D56xB63X9KoCrE+Hh6eDhyYapu8XIloG4NR0kYulhvvPX0PtSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796338233; h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:MIME-Version: Content-Transfer-Encoding:X-CMS-MailID:X-Msg-Generator:Content-Type: X-RootMTR:X-EPHeader:X-CMS-RootMailID:References; bh=AB8G7cboe2eaTRr9+rFdnymR6B72df4mpYHS48lfXGI=; b=bweTZtp+WhR2K/ltscxQFsEZpFWjj7cI3X0ZCbpSedkKTOf2VA4cMUapK1OjRbAOj56B WLOmexDyBlMSJFNvQgdUHy6k2CfzSdjXhhRU1b3llRnEh4e/3U7BP4j5kGeLIzid62EdH hsK8NUaSpMHrFkjTJL5N4QyHABRRD2gWg1gjuMSCwmOZ5l4CEOZANNzBKiOPnffZ4HKZs nIwdzodgmaTz+2oDaLdrLPgPnZL6SKdrr84yI+5LpXsvz8ZWSS6NkZKlcrW1jEv1X7x8s GeFV7qe5jBK7dw/n9Dn9JEvINwYMQ5og/bppaCohZ987UwIkLnNW+uRJt66j3NoZpPw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass header.d=samsung.com header.i=@samsung.com header.a=rsa-sha256 header.s=mail20170921 header.b=DZPJbUpm; arc=none smtp.remote-ip=210.118.77.11 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2D21606A322 for ; Thu, 3 Dec 2026 22:50:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B2D21606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.a=rsa-sha256 header.s=mail20170921 header.b=DZPJbUpm Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20261203225030euoutp0165af00b0928a1403879c72a985f2e274~t4BplTFEY2846628466euoutp01J for ; Thu, 3 Dec 2026 22:50:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20261203225030euoutp0165af00b0928a1403879c72a985f2e274~t4BplTFEY2846628466euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1796338230; bh=AB8G7cboe2eaTRr9+rFdnymR6B72df4mpYHS48lfXGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DZPJbUpmqSklk191U49560PCti1CuS7UuAgqRkLSZU15gjWQhnYrQr8P8dQNNrw40 AIsqqYJuqma/9rsHgTwVA7Nc3Ph3KZZ+hWHvsl0ebwhM+9lZ6OCIZ4trEiQxTfT9Qp TbQYuPGy+rTuqBgjAeZgG3CjNhKoNo0NTN/T7etU= Received: from eusmtip1.samsung.com (unknown [203.254.199.221]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20261203225029eucas1p2c4b355b547fc9e2970f706534d5ce858~t4Bo7GJfg2576425764eucas1p2d; Thu, 3 Dec 2026 22:50:29 +0000 (GMT) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20261203225029eusmtip1018c78a6f9b946acd1a3f2b5fd759d2f~t4BoVLk-P3226132261eusmtip1_; Thu, 3 Dec 2026 22:50:28 +0000 (GMT) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org Cc: Marek Szyprowski , Krzysztof Kozlowski , Peter Griffin , Alim Akhtar , Daniel Lezcano , "Rafael J. Wysocki" , Bartlomiej Zolnierkiewicz , Ingo Molnar , Frederic Weisbecker , Ulf Hansson , Peter Zijlstra Subject: [PATCH v2 1/4] ARM: exynos: Exit coherency before powering down CPU1 in coupled AFTR Date: Thu, 3 Dec 2026 23:50:08 +0100 Message-ID: <20261203225013.4186872-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261203225013.4186872-1-m.szyprowski@samsung.com> X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMS-MailID: 20261203225029eucas1p2c4b355b547fc9e2970f706534d5ce858 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20261203225029eucas1p2c4b355b547fc9e2970f706534d5ce858 X-EPHeader: CA X-CMS-RootMailID: 20261203225029eucas1p2c4b355b547fc9e2970f706534d5ce858 References: <20261203225013.4186872-1-m.szyprowski@samsung.com> In the coupled AFTR mode, CPU1 is powered down from exynos_wfi_finisher() with the data cache and the SMP coherency still enabled. Between the cache flush and the actual power down, dirty cache lines might be migrated from CPU0 to the CPU1 L1 cache by the coherency logic. Those lines are then lost together with the CPU1 power, what leads to random memory corruption, like the following crash observed on Exynos3250 based Rinato board during a cpuidle stress test: Unable to handle kernel NULL pointer dereference at virtual address 00000010 when read ... PC is at __lock_acquire+0x4c/0x2a14 LR is at lock_acquire+0x140/0x3d8 ... lock_acquire from _raw_spin_lock+0x38/0x48 _raw_spin_lock from pte_offset_map_lock+0x74/0x134 pte_offset_map_lock from filemap_map_pages+0x1d4/0xa1c ... Fix this by disabling the data cache, flushing it and exiting coherency with v7_exit_coherency_flush() before entering WFI, like it is already done in the CPU hotplug code. Flush all cache levels on Exynos3250 like before, while on Exynos4210 flushing L1 is enough, as its L2 is the outer PL310 cache. Restore the coherency and data cache if the power down is aborted. Fixes: 712eddf70225 ("cpuidle: exynos: add coupled cpuidle support for exynos4210") Signed-off-by: Marek Szyprowski --- arch/arm/mach-exynos/pm.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c index 0019d21bff90..6806af6fcb0b 100644 --- a/arch/arm/mach-exynos/pm.c +++ b/arch/arm/mach-exynos/pm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "common.h" @@ -278,10 +279,33 @@ static int exynos_cpu0_enter_aftr(void) static int exynos_wfi_finisher(unsigned long flags) { + unsigned int v; + + /* + * Disable D-cache and exit coherency before powering down, otherwise + * dirty cache lines migrated from the other cpu might get lost. + */ if (soc_is_exynos3250()) - flush_cache_all(); + v7_exit_coherency_flush(all); + else + v7_exit_coherency_flush(louis); + cpu_do_idle(); + /* Power down has been aborted, restore coherency and D-cache */ + asm volatile( + " mrc p15, 0, %0, c1, c0, 1\n" + " orr %0, %0, %2\n" + " mcr p15, 0, %0, c1, c0, 1\n" + " isb\n" + " mrc p15, 0, %0, c1, c0, 0\n" + " orr %0, %0, %1\n" + " mcr p15, 0, %0, c1, c0, 0\n" + " isb\n" + : "=&r" (v) + : "Ir" (CR_C), "Ir" (0x40) + : "cc"); + return -1; } -- 2.43.0