forked from Mirrors/opensbi
		
	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 <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
		@@ -44,7 +44,6 @@
 | 
			
		||||
#ifndef __ASSEMBLY__
 | 
			
		||||
 | 
			
		||||
#include <sbi/sbi_types.h>
 | 
			
		||||
#include <sbi/sbi_ipi.h>
 | 
			
		||||
 | 
			
		||||
/** Representation of per-HART scratch space */
 | 
			
		||||
struct sbi_scratch {
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@
 | 
			
		||||
#include <sbi/sbi_error.h>
 | 
			
		||||
#include <sbi/sbi_fifo.h>
 | 
			
		||||
#include <sbi/sbi_hart.h>
 | 
			
		||||
#include <sbi/sbi_ipi.h>
 | 
			
		||||
#include <sbi/sbi_scratch.h>
 | 
			
		||||
#include <sbi/sbi_tlb.h>
 | 
			
		||||
#include <sbi/sbi_hfence.h>
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user