mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 07:41:42 +01:00
lib: sbi_tlb: Use sbi_hartmask in sbi_tlb_info
Instead of using single ulong as source mask for sbi_tlb_info, we use sbi_hartmask. This way sbi_tlb_info can easily scale for large number of HARTs. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#define __SBI_TLB_H__
|
#define __SBI_TLB_H__
|
||||||
|
|
||||||
#include <sbi/sbi_types.h>
|
#include <sbi/sbi_types.h>
|
||||||
|
#include <sbi/sbi_hartmask.h>
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ struct sbi_tlb_info {
|
|||||||
unsigned long size;
|
unsigned long size;
|
||||||
unsigned long asid;
|
unsigned long asid;
|
||||||
unsigned long type;
|
unsigned long type;
|
||||||
unsigned long shart_mask;
|
struct sbi_hartmask smask;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SBI_TLB_INFO_INIT(__ptr, __start, __size, __asid, __type, __src_hart) \
|
#define SBI_TLB_INFO_INIT(__ptr, __start, __size, __asid, __type, __src_hart) \
|
||||||
@@ -47,7 +48,7 @@ do { \
|
|||||||
(__ptr)->size = (__size); \
|
(__ptr)->size = (__size); \
|
||||||
(__ptr)->asid = (__asid); \
|
(__ptr)->asid = (__asid); \
|
||||||
(__ptr)->type = (__type); \
|
(__ptr)->type = (__type); \
|
||||||
(__ptr)->shart_mask = 1UL << (__src_hart); \
|
SBI_HARTMASK_INIT_EXCEPT(&(__ptr)->smask, (__src_hart)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SBI_TLB_INFO_SIZE sizeof(struct sbi_tlb_info)
|
#define SBI_TLB_INFO_SIZE sizeof(struct sbi_tlb_info)
|
||||||
|
@@ -190,17 +190,14 @@ static void sbi_tlb_local_flush(struct sbi_tlb_info *tinfo)
|
|||||||
static void sbi_tlb_entry_process(struct sbi_scratch *scratch,
|
static void sbi_tlb_entry_process(struct sbi_scratch *scratch,
|
||||||
struct sbi_tlb_info *tinfo)
|
struct sbi_tlb_info *tinfo)
|
||||||
{
|
{
|
||||||
u32 i;
|
u32 rhartid;
|
||||||
u64 m;
|
|
||||||
struct sbi_scratch *rscratch = NULL;
|
struct sbi_scratch *rscratch = NULL;
|
||||||
unsigned long *rtlb_sync = NULL;
|
unsigned long *rtlb_sync = NULL;
|
||||||
|
|
||||||
sbi_tlb_local_flush(tinfo);
|
sbi_tlb_local_flush(tinfo);
|
||||||
for (i = 0, m = tinfo->shart_mask; m; i++, m >>= 1) {
|
|
||||||
if (!(m & 1UL))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
rscratch = sbi_hart_id_to_scratch(scratch, i);
|
sbi_hartmask_for_each_hart(rhartid, &tinfo->smask) {
|
||||||
|
rscratch = sbi_hart_id_to_scratch(scratch, rhartid);
|
||||||
rtlb_sync = sbi_scratch_offset_ptr(rscratch, tlb_sync_off);
|
rtlb_sync = sbi_scratch_offset_ptr(rscratch, tlb_sync_off);
|
||||||
while (atomic_raw_xchg_ulong(rtlb_sync, 1)) ;
|
while (atomic_raw_xchg_ulong(rtlb_sync, 1)) ;
|
||||||
}
|
}
|
||||||
@@ -263,10 +260,10 @@ static inline int __sbi_tlb_range_check(struct sbi_tlb_info *curr,
|
|||||||
if (next->start <= curr->start && next_end > curr_end) {
|
if (next->start <= curr->start && next_end > curr_end) {
|
||||||
curr->start = next->start;
|
curr->start = next->start;
|
||||||
curr->size = next->size;
|
curr->size = next->size;
|
||||||
curr->shart_mask = curr->shart_mask | next->shart_mask;
|
sbi_hartmask_or(&curr->smask, &curr->smask, &next->smask);
|
||||||
ret = SBI_FIFO_UPDATED;
|
ret = SBI_FIFO_UPDATED;
|
||||||
} else if (next->start >= curr->start && next_end <= curr_end) {
|
} else if (next->start >= curr->start && next_end <= curr_end) {
|
||||||
curr->shart_mask = curr->shart_mask | next->shart_mask;
|
sbi_hartmask_or(&curr->smask, &curr->smask, &next->smask);
|
||||||
ret = SBI_FIFO_SKIP;
|
ret = SBI_FIFO_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user