Skip to content

Commit

Permalink
powerpc: mpc8xxx: Extend find_law() to find_law_by_addr_id()
Browse files Browse the repository at this point in the history
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@kernel.org>
Signed-off-by: Marek Mojík <marek.mojik@nic.cz>
Reviewed-by: Marek Behún <kabel@kernel.org>
  • Loading branch information
pali authored and trini committed Jul 12, 2024
1 parent 07928d4 commit 89b009d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion arch/powerpc/cpu/mpc8xxx/law.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion arch/powerpc/include/asm/fsl_law.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 89b009d

Please sign in to comment.