From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 1/3] ppc: implement sync_caches_for_execution
Date: Wed, 6 Aug 2025 15:24:53 +0200 [thread overview]
Message-ID: <20250806132455.2827813-1-a.fatoum@barebox.org> (raw)
Instead of opencoding flush_dcache followed by invalidate_icache,
implement sync_caches_for_execution().
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/powerpc/boards/freescale-p1010rdb/p1010rdb.c | 3 +--
arch/powerpc/boards/freescale-p1022ds/p1022ds.c | 3 +--
arch/powerpc/boards/freescale-p2020rdb/p2020rdb.c | 3 +--
arch/powerpc/boards/owc-da923rc/da923rc.c | 3 +--
arch/powerpc/cpu-85xx/Makefile | 1 +
arch/powerpc/cpu-85xx/cache.c | 9 +++++++++
arch/powerpc/cpu-85xx/mmu.c | 6 ++----
arch/powerpc/include/asm/cache.h | 2 ++
8 files changed, 18 insertions(+), 12 deletions(-)
create mode 100644 arch/powerpc/cpu-85xx/cache.c
diff --git a/arch/powerpc/boards/freescale-p1010rdb/p1010rdb.c b/arch/powerpc/boards/freescale-p1010rdb/p1010rdb.c
index c8f19bf2c147..023fb32bf3b1 100644
--- a/arch/powerpc/boards/freescale-p1010rdb/p1010rdb.c
+++ b/arch/powerpc/boards/freescale-p1010rdb/p1010rdb.c
@@ -164,8 +164,7 @@ static int p1010rdb_board_init_r(void)
const u8 flash_esel = e500_find_tlb_idx((void *)flashbase, 1);
/* Flush d-cache and invalidate i-cache of any FLASH data */
- flush_dcache();
- invalidate_icache();
+ sync_caches_for_execution();
/* invalidate existing TLB entry for flash */
e500_disable_tlb(flash_esel);
diff --git a/arch/powerpc/boards/freescale-p1022ds/p1022ds.c b/arch/powerpc/boards/freescale-p1022ds/p1022ds.c
index f46a0a20aee0..e3591454f831 100644
--- a/arch/powerpc/boards/freescale-p1022ds/p1022ds.c
+++ b/arch/powerpc/boards/freescale-p1022ds/p1022ds.c
@@ -165,8 +165,7 @@ static int p1022ds_board_init_r(void)
fsl_set_lbc_or(1, 0xffff8796);
/* Flush d-cache and invalidate i-cache of any FLASH data */
- flush_dcache();
- invalidate_icache();
+ sync_caches_for_execution();
/* invalidate existing TLB entry for flash */
e500_disable_tlb(flash_esel);
diff --git a/arch/powerpc/boards/freescale-p2020rdb/p2020rdb.c b/arch/powerpc/boards/freescale-p2020rdb/p2020rdb.c
index b1efee26f11e..ba4f58be10e7 100644
--- a/arch/powerpc/boards/freescale-p2020rdb/p2020rdb.c
+++ b/arch/powerpc/boards/freescale-p2020rdb/p2020rdb.c
@@ -246,8 +246,7 @@ static int board_init_r(void)
fsl_set_lbc_or(0, 0xff000ff7);
/* Flush d-cache and invalidate i-cache of any FLASH data */
- flush_dcache();
- invalidate_icache();
+ sync_caches_for_execution();
/* invalidate existing TLB entry for flash */
e500_disable_tlb(flash_esel);
diff --git a/arch/powerpc/boards/owc-da923rc/da923rc.c b/arch/powerpc/boards/owc-da923rc/da923rc.c
index b3e347794b49..baede439b15b 100644
--- a/arch/powerpc/boards/owc-da923rc/da923rc.c
+++ b/arch/powerpc/boards/owc-da923rc/da923rc.c
@@ -147,8 +147,7 @@ static int da923rc_board_init_r(void)
da923rc_boardinfo_get(&binfo);
- flush_dcache();
- invalidate_icache();
+ sync_caches_for_execution();
/* Clear LBC error interrupts */
out_be32(lbc + FSL_LBC_LTESR_OFFSET, 0xffffffff);
diff --git a/arch/powerpc/cpu-85xx/Makefile b/arch/powerpc/cpu-85xx/Makefile
index c7c5c8a00663..cc85eb759472 100644
--- a/arch/powerpc/cpu-85xx/Makefile
+++ b/arch/powerpc/cpu-85xx/Makefile
@@ -2,6 +2,7 @@
obj-y += traps.o
obj-y += tlb.o
+obj-y += cache.o
obj-$(CONFIG_MMU) += mmu.o
extra-y += start.o
extra-y += resetvec.o
diff --git a/arch/powerpc/cpu-85xx/cache.c b/arch/powerpc/cpu-85xx/cache.c
new file mode 100644
index 000000000000..fcd71b6f9b76
--- /dev/null
+++ b/arch/powerpc/cpu-85xx/cache.c
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <asm/cache.h>
+
+void sync_caches_for_execution(void)
+{
+ flush_dcache();
+ invalidate_icache();
+}
diff --git a/arch/powerpc/cpu-85xx/mmu.c b/arch/powerpc/cpu-85xx/mmu.c
index 3bd75281eb98..091873d966a3 100644
--- a/arch/powerpc/cpu-85xx/mmu.c
+++ b/arch/powerpc/cpu-85xx/mmu.c
@@ -47,10 +47,8 @@ int arch_remap_range(void *virt_addr, phys_addr_t phys_addr, size_t size, unsign
break;
e500_read_tlbcam_entry(esel, &valid, &tsize, &epn,
&rpn);
- if (pte_flags & MAS2_I) {
- flush_dcache();
- invalidate_icache();
- }
+ if (pte_flags & MAS2_I)
+ sync_caches_for_execution();
e500_set_tlb(1, epn, rpn, MAS3_SX|MAS3_SW|MAS3_SR,
(u8)wimge, 0, esel, tsize, 1);
/* convert tsize to bytes to increment address. */
diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
index c9066099ab6d..2edf11de2ef8 100644
--- a/arch/powerpc/include/asm/cache.h
+++ b/arch/powerpc/include/asm/cache.h
@@ -35,6 +35,8 @@ extern void clean_dcache_range(unsigned long start, unsigned long stop);
extern void invalidate_dcache_range(unsigned long start, unsigned long stop);
extern void flush_dcache(void);
extern void invalidate_icache(void);
+#define sync_caches_for_execution sync_caches_for_execution
+extern void sync_caches_for_execution(void);
#ifdef CFG_INIT_RAM_LOCK
extern void unlock_ram_in_cache(void);
#endif /* CFG_INIT_RAM_LOCK */
--
2.39.5
next reply other threads:[~2025-08-06 13:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 13:24 Ahmad Fatoum [this message]
2025-08-06 13:24 ` [PATCH 2/3] MIPS: " Ahmad Fatoum
2025-08-06 13:24 ` [PATCH 3/3] openrisc: " Ahmad Fatoum
2025-08-07 7:28 ` [PATCH 1/3] ppc: " Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250806132455.2827813-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox