From a8b4b83b7fef84b0491f5a897651a30f98d75a9a Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Wed, 15 Jan 2020 11:42:51 +0530 Subject: [PATCH] lib: Introduce sbi_tlb_fifo_request() API Instead of directly calling sbi_ipi_send_many(), we introduce sbi_tlb_fifo_request() for halting a set of HARTs. This way in future we can assign any IPI event number for remote FENCE within sbi_tlb.c only. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi/sbi_scratch.h | 1 - include/sbi/sbi_tlb.h | 7 ++++-- lib/sbi/sbi_ecall.c | 53 +++++++++++++++------------------------ lib/sbi/sbi_tlb.c | 8 ++++++ 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h index 2e6fd5a6..d70c80d4 100644 --- a/include/sbi/sbi_scratch.h +++ b/include/sbi/sbi_scratch.h @@ -44,7 +44,6 @@ #ifndef __ASSEMBLY__ #include -#include /** Representation of per-HART scratch space */ struct sbi_scratch { diff --git a/include/sbi/sbi_tlb.h b/include/sbi/sbi_tlb.h index 83f94587..38a9418e 100644 --- a/include/sbi/sbi_tlb.h +++ b/include/sbi/sbi_tlb.h @@ -47,8 +47,11 @@ int sbi_tlb_fifo_update(struct sbi_scratch *scratch, u32 hartid, void *data); 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); +int sbi_tlb_fifo_request(struct sbi_scratch *scratch, ulong hmask, + ulong hbase, struct sbi_tlb_info *tinfo); + +int sbi_tlb_fifo_init(struct sbi_scratch *scratch, bool cold_boot); + #endif diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c index 6bf33ad3..29df26bc 100644 --- a/lib/sbi/sbi_ecall.c +++ b/lib/sbi/sbi_ecall.c @@ -180,17 +180,16 @@ int sbi_ecall_rfence_handler(struct sbi_scratch *scratch, unsigned long funcid, tlb_info.size = 0; tlb_info.type = SBI_ITLB_FLUSH; tlb_info.shart_mask = 1UL << source_hart; - ret = sbi_ipi_send_many(scratch, args[0], args[1], - SBI_IPI_EVENT_FENCE, &tlb_info); + ret = sbi_tlb_fifo_request(scratch, args[0], args[1], + &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA: tlb_info.start = (unsigned long)args[2]; tlb_info.size = (unsigned long)args[3]; tlb_info.type = SBI_TLB_FLUSH_GVMA; tlb_info.shart_mask = 1UL << source_hart; - - ret = sbi_ipi_send_many(scratch, args[0], args[1], - SBI_IPI_EVENT_FENCE, &tlb_info); + ret = sbi_tlb_fifo_request(scratch, args[0], args[1], + &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID: tlb_info.start = (unsigned long)args[2]; @@ -198,19 +197,16 @@ int sbi_ecall_rfence_handler(struct sbi_scratch *scratch, unsigned long funcid, tlb_info.asid = (unsigned long)args[4]; tlb_info.type = SBI_TLB_FLUSH_GVMA_VMID; tlb_info.shart_mask = 1UL << source_hart; - - ret = sbi_ipi_send_many(scratch, args[0], args[1], - SBI_IPI_EVENT_FENCE, - &tlb_info); + ret = sbi_tlb_fifo_request(scratch, args[0], args[1], + &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA: tlb_info.start = (unsigned long)args[2]; tlb_info.size = (unsigned long)args[3]; tlb_info.type = SBI_TLB_FLUSH_VVMA; tlb_info.shart_mask = 1UL << source_hart; - - ret = sbi_ipi_send_many(scratch, args[0], args[1], - SBI_IPI_EVENT_FENCE, &tlb_info); + ret = sbi_tlb_fifo_request(scratch, args[0], args[1], + &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID: tlb_info.start = (unsigned long)args[2]; @@ -218,19 +214,16 @@ int sbi_ecall_rfence_handler(struct sbi_scratch *scratch, unsigned long funcid, tlb_info.asid = (unsigned long)args[4]; tlb_info.type = SBI_TLB_FLUSH_VVMA_ASID; tlb_info.shart_mask = 1UL << source_hart; - - ret = sbi_ipi_send_many(scratch, args[0], args[1], - SBI_IPI_EVENT_FENCE, - &tlb_info); + ret = sbi_tlb_fifo_request(scratch, args[0], args[1], + &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA: tlb_info.start = (unsigned long)args[2]; tlb_info.size = (unsigned long)args[3]; tlb_info.type = SBI_TLB_FLUSH_VMA; tlb_info.shart_mask = 1UL << source_hart; - - ret = sbi_ipi_send_many(scratch, args[0], args[1], - SBI_IPI_EVENT_FENCE, &tlb_info); + ret = sbi_tlb_fifo_request(scratch, args[0], args[1], + &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID: tlb_info.start = (unsigned long)args[2]; @@ -238,10 +231,8 @@ int sbi_ecall_rfence_handler(struct sbi_scratch *scratch, unsigned long funcid, tlb_info.asid = (unsigned long)args[4]; tlb_info.type = SBI_TLB_FLUSH_VMA_ASID; tlb_info.shart_mask = 1UL << source_hart; - - ret = sbi_ipi_send_many(scratch, args[0], args[1], - SBI_IPI_EVENT_FENCE, - &tlb_info); + ret = sbi_tlb_fifo_request(scratch, args[0], args[1], + &tlb_info); break; default: @@ -291,9 +282,8 @@ int sbi_ecall_0_1_handler(struct sbi_scratch *scratch, unsigned long extid, ret = sbi_load_hart_mask_unpriv(scratch, (ulong *)args[0], &hmask, out_trap); if (ret != SBI_ETRAP) - ret = sbi_ipi_send_many(scratch, hmask, 0, - SBI_IPI_EVENT_FENCE, - &tlb_info); + ret = sbi_tlb_fifo_request(scratch, hmask, 0, + &tlb_info); break; case SBI_EXT_0_1_REMOTE_SFENCE_VMA: tlb_info.start = (unsigned long)args[1]; @@ -303,9 +293,8 @@ int sbi_ecall_0_1_handler(struct sbi_scratch *scratch, unsigned long extid, ret = sbi_load_hart_mask_unpriv(scratch, (ulong *)args[0], &hmask, out_trap); if (ret != SBI_ETRAP) - ret = sbi_ipi_send_many(scratch, hmask, 0, - SBI_IPI_EVENT_FENCE, - &tlb_info); + ret = sbi_tlb_fifo_request(scratch, hmask, 0, + &tlb_info); break; case SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID: tlb_info.start = (unsigned long)args[1]; @@ -313,13 +302,11 @@ int sbi_ecall_0_1_handler(struct sbi_scratch *scratch, unsigned long extid, tlb_info.asid = (unsigned long)args[3]; tlb_info.type = SBI_TLB_FLUSH_VMA_ASID; tlb_info.shart_mask = 1UL << source_hart; - ret = sbi_load_hart_mask_unpriv(scratch, (ulong *)args[0], &hmask, out_trap); if (ret != SBI_ETRAP) - ret = sbi_ipi_send_many(scratch, hmask, 0, - SBI_IPI_EVENT_FENCE, - &tlb_info); + ret = sbi_tlb_fifo_request(scratch, hmask, 0, + &tlb_info); break; case SBI_EXT_0_1_SHUTDOWN: sbi_system_shutdown(scratch, 0); diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index d8215168..c07f4a49 100644 --- a/lib/sbi/sbi_tlb.c +++ b/lib/sbi/sbi_tlb.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -366,6 +367,13 @@ int sbi_tlb_fifo_update(struct sbi_scratch *rscratch, u32 hartid, void *data) return 0; } +int sbi_tlb_fifo_request(struct sbi_scratch *scratch, ulong hmask, + ulong hbase, struct sbi_tlb_info *tinfo) +{ + return sbi_ipi_send_many(scratch, hmask, hbase, + SBI_IPI_EVENT_FENCE, tinfo); +} + int sbi_tlb_fifo_init(struct sbi_scratch *scratch, bool cold_boot) { void *tlb_mem;