[PATCH 3/6] powerpc: mpc8xxx: Extend find_law() to find_law_by_addr_id()
Marek Mojík
marek.mojik at nic.cz
Thu Jun 6 18:33:23 CEST 2024
From: Pali Rohár <pali at kernel.org>
The find_law() function searches for LAW just by physical address. This
is unsuitable for cases with overlapping LAWs. Extend it to
find_law_by_addr_id(), which searches for LAW by physical address and
target id.
Add a static inline definition of the original find_law() into fsl_law.h
header.
Signed-off-by: Pali Rohár <pali at kernel.org>
Signed-off-by: Marek Mojík <marek.mojik at nic.cz>
---
arch/powerpc/cpu/mpc8xxx/law.c | 5 ++++-
arch/powerpc/include/asm/fsl_law.h | 8 +++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/cpu/mpc8xxx/law.c b/arch/powerpc/cpu/mpc8xxx/law.c
index f16bc19966..f3a9749625 100644
--- a/arch/powerpc/cpu/mpc8xxx/law.c
+++ b/arch/powerpc/cpu/mpc8xxx/law.c
@@ -130,7 +130,7 @@ int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
return idx;
}
-struct law_entry find_law(phys_addr_t addr)
+struct law_entry find_law_by_addr_id(phys_addr_t addr, enum law_trgt_if id)
{
struct law_entry entry;
int i;
@@ -146,6 +146,9 @@ struct law_entry find_law(phys_addr_t addr)
if (!get_law_entry(i, &entry))
continue;
+ if (id != -1 && id != entry.trgt_id)
+ continue;
+
upper = entry.addr + (2ull << entry.size);
if ((addr >= entry.addr) && (addr < upper)) {
entry.index = i;
diff --git a/arch/powerpc/include/asm/fsl_law.h b/arch/powerpc/include/asm/fsl_law.h
index 9e2f2d5370..d1cd728397 100644
--- a/arch/powerpc/include/asm/fsl_law.h
+++ b/arch/powerpc/include/asm/fsl_law.h
@@ -130,7 +130,13 @@ extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if
extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
extern int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
extern int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id);
-extern struct law_entry find_law(phys_addr_t addr);
+extern struct law_entry find_law_by_addr_id(phys_addr_t addr, enum law_trgt_if id);
+
+static inline struct law_entry find_law(phys_addr_t addr)
+{
+ return find_law_by_addr_id(addr, -1);
+}
+
extern void disable_law(u8 idx);
extern void init_laws(void);
extern void print_laws(void);
--
2.45.1
More information about the U-Boot
mailing list