diff options
author | Atish Patra <atish.patra@wdc.com> | 2019-08-14 18:02:14 -0700 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2019-08-16 08:42:55 +0530 |
commit | 897a97a6af31174eb2c6058c6ceb9d3ccc6c6e3c (patch) | |
tree | e667994b5a11efdef3a2b3be8a8bf27a32b018b0 /include/sbi/sbi_tlb.h | |
parent | f6e13e0dd30b164eb444bc08c70fa1b8576e0bca (diff) |
lib: Fix race conditions in tlb fifo access.
Linux kernel expects tlb flush SBI call to be completely synchronous i.e.
the SBI call should only return once corresponding *fence* instruction is
executed.
OpenSBI manages the outstanding TLB flush requests by keeping them in a
per hart based fifo. However, there are few corner cases that may lead to
race conditions while updating the fifo.
Currently, the caller hart waits for IPI acknowledgement via clint
address which is not a very good method as synchronization on MMIO may not
be supported in every platform. Moreover, the waiter doesn't have any way of
identifying if the IPI is received for specific tlb flush request or any
other IPI. This may lead to unpredictable behavior in supervisor/user space.
Fix this by waiting on individual fifo entries rather than MMIO address.
Currently, a relaxed loop is being used because wfi again involves MMIO write
which would be slower compared to relaxed loop. To avoid deadlock, fifo
is processed every time a hart loops for fifo enqueue or fifo sync to consume
the tlb flush requests sent by other harts.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'include/sbi/sbi_tlb.h')
-rw-r--r-- | include/sbi/sbi_tlb.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/include/sbi/sbi_tlb.h b/include/sbi/sbi_tlb.h index f3d93d4..af77f89 100644 --- a/include/sbi/sbi_tlb.h +++ b/include/sbi/sbi_tlb.h @@ -20,12 +20,13 @@ /* clang-format on */ -#define SBI_TLB_FIFO_NUM_ENTRIES 4 +#define SBI_TLB_FIFO_NUM_ENTRIES 8 enum sbi_tlb_info_types { SBI_TLB_FLUSH_VMA, SBI_TLB_FLUSH_VMA_ASID, - SBI_TLB_FLUSH_VMA_VMID + SBI_TLB_FLUSH_VMA_VMID, + SBI_ITLB_FLUSH }; struct sbi_scratch; @@ -35,14 +36,17 @@ struct sbi_tlb_info { unsigned long size; unsigned long asid; unsigned long type; + unsigned long shart_mask; }; #define SBI_TLB_INFO_SIZE sizeof(struct sbi_tlb_info) -int sbi_tlb_fifo_update(struct sbi_scratch *scratch, u32 event, void *data); +int sbi_tlb_fifo_update(struct sbi_scratch *scratch, u32 hartid, void *data); -void sbi_tlb_fifo_process(struct sbi_scratch *scratch, u32 event); +void sbi_tlb_fifo_process(struct sbi_scratch *scratch); int sbi_tlb_fifo_init(struct sbi_scratch *scratch, bool cold_boot); +void sbi_tlb_fifo_sync(struct sbi_scratch *scratch); + #endif |