forked from Mirrors/opensbi
		
	lib: Drop _fifo from the name of various sbi_tlb_fifo_xyz() functions
This patch drops _fifo from the name of various sbi_tlb_fifo_xyz() functions because all these functions deal with remote TLB managment and FIFO is the per-HART data structure used internally by remote TLB implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
		@@ -180,16 +180,14 @@ 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_tlb_fifo_request(scratch, args[0], args[1],
 | 
			
		||||
					   &tlb_info);
 | 
			
		||||
		ret = sbi_tlb_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_tlb_fifo_request(scratch, args[0], args[1],
 | 
			
		||||
					   &tlb_info);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
@@ -197,16 +195,14 @@ 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_tlb_fifo_request(scratch, args[0], args[1],
 | 
			
		||||
					   &tlb_info);
 | 
			
		||||
		ret = sbi_tlb_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_tlb_fifo_request(scratch, args[0], args[1],
 | 
			
		||||
					   &tlb_info);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
@@ -214,16 +210,14 @@ 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_tlb_fifo_request(scratch, args[0], args[1],
 | 
			
		||||
					   &tlb_info);
 | 
			
		||||
		ret = sbi_tlb_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_tlb_fifo_request(scratch, args[0], args[1],
 | 
			
		||||
					   &tlb_info);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
@@ -231,8 +225,7 @@ 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_tlb_fifo_request(scratch, args[0], args[1],
 | 
			
		||||
					   &tlb_info);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
@@ -282,8 +275,7 @@ 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_tlb_fifo_request(scratch, hmask, 0,
 | 
			
		||||
						   &tlb_info);
 | 
			
		||||
			ret = sbi_tlb_request(scratch, hmask, 0, &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_0_1_REMOTE_SFENCE_VMA:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[1];
 | 
			
		||||
@@ -293,8 +285,7 @@ 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_tlb_fifo_request(scratch, hmask, 0,
 | 
			
		||||
						   &tlb_info);
 | 
			
		||||
			ret = sbi_tlb_request(scratch, hmask, 0, &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[1];
 | 
			
		||||
@@ -305,8 +296,7 @@ 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_tlb_fifo_request(scratch, hmask, 0,
 | 
			
		||||
						   &tlb_info);
 | 
			
		||||
			ret = sbi_tlb_request(scratch, hmask, 0, &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_0_1_SHUTDOWN:
 | 
			
		||||
		sbi_system_shutdown(scratch, 0);
 | 
			
		||||
 
 | 
			
		||||
@@ -232,7 +232,7 @@ int sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot)
 | 
			
		||||
	ipi_data = sbi_scratch_offset_ptr(scratch, ipi_data_off);
 | 
			
		||||
	ipi_data->ipi_type = 0x00;
 | 
			
		||||
 | 
			
		||||
	ret = sbi_tlb_fifo_init(scratch, cold_boot);
 | 
			
		||||
	ret = sbi_tlb_init(scratch, cold_boot);
 | 
			
		||||
	if (ret)
 | 
			
		||||
		return ret;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ static void sbi_tlb_flush_all(void)
 | 
			
		||||
	__asm__ __volatile("sfence.vma");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_hfence_vvma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
static void sbi_tlb_hfence_vvma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
{
 | 
			
		||||
	unsigned long start = tinfo->start;
 | 
			
		||||
	unsigned long size  = tinfo->size;
 | 
			
		||||
@@ -48,7 +48,7 @@ static void sbi_tlb_fifo_hfence_vvma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_hfence_gvma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
static void sbi_tlb_hfence_gvma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
{
 | 
			
		||||
	unsigned long start = tinfo->start;
 | 
			
		||||
	unsigned long size  = tinfo->size;
 | 
			
		||||
@@ -64,7 +64,7 @@ static void sbi_tlb_fifo_hfence_gvma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_sfence_vma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
static void sbi_tlb_sfence_vma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
{
 | 
			
		||||
	unsigned long start = tinfo->start;
 | 
			
		||||
	unsigned long size  = tinfo->size;
 | 
			
		||||
@@ -83,7 +83,7 @@ static void sbi_tlb_fifo_sfence_vma(struct sbi_tlb_info *tinfo)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_hfence_vvma_asid(struct sbi_tlb_info *tinfo)
 | 
			
		||||
static void sbi_tlb_hfence_vvma_asid(struct sbi_tlb_info *tinfo)
 | 
			
		||||
{
 | 
			
		||||
	unsigned long start = tinfo->start;
 | 
			
		||||
	unsigned long size  = tinfo->size;
 | 
			
		||||
@@ -105,7 +105,7 @@ static void sbi_tlb_fifo_hfence_vvma_asid(struct sbi_tlb_info *tinfo)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_hfence_gvma_vmid(struct sbi_tlb_info *tinfo)
 | 
			
		||||
static void sbi_tlb_hfence_gvma_vmid(struct sbi_tlb_info *tinfo)
 | 
			
		||||
{
 | 
			
		||||
	unsigned long start = tinfo->start;
 | 
			
		||||
	unsigned long size  = tinfo->size;
 | 
			
		||||
@@ -127,7 +127,7 @@ static void sbi_tlb_fifo_hfence_gvma_vmid(struct sbi_tlb_info *tinfo)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_sfence_vma_asid(struct sbi_tlb_info *tinfo)
 | 
			
		||||
static void sbi_tlb_sfence_vma_asid(struct sbi_tlb_info *tinfo)
 | 
			
		||||
{
 | 
			
		||||
	unsigned long start = tinfo->start;
 | 
			
		||||
	unsigned long size  = tinfo->size;
 | 
			
		||||
@@ -160,22 +160,22 @@ static void sbi_tlb_local_flush(struct sbi_tlb_info *tinfo)
 | 
			
		||||
{
 | 
			
		||||
	switch (tinfo->type) {
 | 
			
		||||
	case SBI_TLB_FLUSH_VMA:
 | 
			
		||||
		sbi_tlb_fifo_sfence_vma(tinfo);
 | 
			
		||||
		sbi_tlb_sfence_vma(tinfo);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_TLB_FLUSH_VMA_ASID:
 | 
			
		||||
		sbi_tlb_fifo_sfence_vma_asid(tinfo);
 | 
			
		||||
		sbi_tlb_sfence_vma_asid(tinfo);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_TLB_FLUSH_GVMA:
 | 
			
		||||
		sbi_tlb_fifo_hfence_gvma(tinfo);
 | 
			
		||||
		sbi_tlb_hfence_gvma(tinfo);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_TLB_FLUSH_GVMA_VMID:
 | 
			
		||||
		sbi_tlb_fifo_hfence_gvma_vmid(tinfo);
 | 
			
		||||
		sbi_tlb_hfence_gvma_vmid(tinfo);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_TLB_FLUSH_VVMA:
 | 
			
		||||
		sbi_tlb_fifo_hfence_vvma(tinfo);
 | 
			
		||||
		sbi_tlb_hfence_vvma(tinfo);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_TLB_FLUSH_VVMA_ASID:
 | 
			
		||||
		sbi_tlb_fifo_hfence_vvma_asid(tinfo);
 | 
			
		||||
		sbi_tlb_hfence_vvma_asid(tinfo);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_ITLB_FLUSH:
 | 
			
		||||
		__asm__ __volatile("fence.i");
 | 
			
		||||
@@ -206,7 +206,7 @@ static void sbi_tlb_entry_process(struct sbi_scratch *scratch,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_process_count(struct sbi_scratch *scratch, int count)
 | 
			
		||||
static void sbi_tlb_process_count(struct sbi_scratch *scratch, int count)
 | 
			
		||||
{
 | 
			
		||||
	struct sbi_tlb_info tinfo;
 | 
			
		||||
	u32 deq_count = 0;
 | 
			
		||||
@@ -222,7 +222,7 @@ static void sbi_tlb_fifo_process_count(struct sbi_scratch *scratch, int count)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_process(struct sbi_scratch *scratch)
 | 
			
		||||
static void sbi_tlb_process(struct sbi_scratch *scratch)
 | 
			
		||||
{
 | 
			
		||||
	struct sbi_tlb_info tinfo;
 | 
			
		||||
	struct sbi_fifo *tlb_fifo =
 | 
			
		||||
@@ -232,7 +232,7 @@ static void sbi_tlb_fifo_process(struct sbi_scratch *scratch)
 | 
			
		||||
		sbi_tlb_entry_process(scratch, &tinfo);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void sbi_tlb_fifo_sync(struct sbi_scratch *scratch)
 | 
			
		||||
static void sbi_tlb_sync(struct sbi_scratch *scratch)
 | 
			
		||||
{
 | 
			
		||||
	unsigned long *tlb_sync =
 | 
			
		||||
			sbi_scratch_offset_ptr(scratch, tlb_sync_off);
 | 
			
		||||
@@ -242,14 +242,14 @@ static void sbi_tlb_fifo_sync(struct sbi_scratch *scratch)
 | 
			
		||||
		 * While we are waiting for remote hart to set the sync,
 | 
			
		||||
		 * consume fifo requests to avoid deadlock.
 | 
			
		||||
		 */
 | 
			
		||||
		sbi_tlb_fifo_process_count(scratch, 1);
 | 
			
		||||
		sbi_tlb_process_count(scratch, 1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int __sbi_tlb_fifo_range_check(struct sbi_tlb_info *curr,
 | 
			
		||||
					     struct sbi_tlb_info *next)
 | 
			
		||||
static inline int __sbi_tlb_range_check(struct sbi_tlb_info *curr,
 | 
			
		||||
					struct sbi_tlb_info *next)
 | 
			
		||||
{
 | 
			
		||||
	unsigned long curr_end;
 | 
			
		||||
	unsigned long next_end;
 | 
			
		||||
@@ -291,7 +291,7 @@ static inline int __sbi_tlb_fifo_range_check(struct sbi_tlb_info *curr,
 | 
			
		||||
 *	before continuing the while loop. This method is preferred over wfi/ipi because
 | 
			
		||||
 *	of MMIO cost involved in later method.
 | 
			
		||||
 */
 | 
			
		||||
static int sbi_tlb_fifo_update_cb(void *in, void *data)
 | 
			
		||||
static int sbi_tlb_update_cb(void *in, void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct sbi_tlb_info *curr;
 | 
			
		||||
	struct sbi_tlb_info *next;
 | 
			
		||||
@@ -306,18 +306,18 @@ static int sbi_tlb_fifo_update_cb(void *in, void *data)
 | 
			
		||||
	if (next->type == SBI_TLB_FLUSH_VMA_ASID &&
 | 
			
		||||
	    curr->type == SBI_TLB_FLUSH_VMA_ASID) {
 | 
			
		||||
		if (next->asid == curr->asid)
 | 
			
		||||
			ret = __sbi_tlb_fifo_range_check(curr, next);
 | 
			
		||||
			ret = __sbi_tlb_range_check(curr, next);
 | 
			
		||||
	} else if (next->type == SBI_TLB_FLUSH_VMA &&
 | 
			
		||||
		   curr->type == SBI_TLB_FLUSH_VMA) {
 | 
			
		||||
			ret = __sbi_tlb_fifo_range_check(curr, next);
 | 
			
		||||
			ret = __sbi_tlb_range_check(curr, next);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int sbi_tlb_fifo_update(struct sbi_scratch *scratch,
 | 
			
		||||
			       struct sbi_scratch *remote_scratch,
 | 
			
		||||
			       u32 remote_hartid, void *data)
 | 
			
		||||
static int sbi_tlb_update(struct sbi_scratch *scratch,
 | 
			
		||||
			  struct sbi_scratch *remote_scratch,
 | 
			
		||||
			  u32 remote_hartid, void *data)
 | 
			
		||||
{
 | 
			
		||||
	int ret;
 | 
			
		||||
	struct sbi_fifo *tlb_fifo_r;
 | 
			
		||||
@@ -345,7 +345,7 @@ static int sbi_tlb_fifo_update(struct sbi_scratch *scratch,
 | 
			
		||||
 | 
			
		||||
	tlb_fifo_r = sbi_scratch_offset_ptr(remote_scratch, tlb_fifo_off);
 | 
			
		||||
 | 
			
		||||
	ret = sbi_fifo_inplace_update(tlb_fifo_r, data, sbi_tlb_fifo_update_cb);
 | 
			
		||||
	ret = sbi_fifo_inplace_update(tlb_fifo_r, data, sbi_tlb_update_cb);
 | 
			
		||||
	if (ret != SBI_FIFO_UNCHANGED) {
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
@@ -359,7 +359,7 @@ static int sbi_tlb_fifo_update(struct sbi_scratch *scratch,
 | 
			
		||||
		 * TODO: Introduce a wait/wakeup event mechanism to handle
 | 
			
		||||
		 * this properly.
 | 
			
		||||
		 */
 | 
			
		||||
		sbi_tlb_fifo_process_count(scratch, 1);
 | 
			
		||||
		sbi_tlb_process_count(scratch, 1);
 | 
			
		||||
		sbi_dprintf(remote_scratch, "hart%d: hart%d tlb fifo full\n",
 | 
			
		||||
			    curr_hartid, remote_hartid);
 | 
			
		||||
	}
 | 
			
		||||
@@ -369,20 +369,20 @@ static int sbi_tlb_fifo_update(struct sbi_scratch *scratch,
 | 
			
		||||
 | 
			
		||||
static struct sbi_ipi_event_ops tlb_ops = {
 | 
			
		||||
	.name = "IPI_TLB",
 | 
			
		||||
	.update = sbi_tlb_fifo_update,
 | 
			
		||||
	.sync = sbi_tlb_fifo_sync,
 | 
			
		||||
	.process = sbi_tlb_fifo_process,
 | 
			
		||||
	.update = sbi_tlb_update,
 | 
			
		||||
	.sync = sbi_tlb_sync,
 | 
			
		||||
	.process = sbi_tlb_process,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static u32 tlb_event = SBI_IPI_EVENT_MAX;
 | 
			
		||||
 | 
			
		||||
int sbi_tlb_fifo_request(struct sbi_scratch *scratch, ulong hmask,
 | 
			
		||||
			 ulong hbase, struct sbi_tlb_info *tinfo)
 | 
			
		||||
int sbi_tlb_request(struct sbi_scratch *scratch, ulong hmask,
 | 
			
		||||
		    ulong hbase, struct sbi_tlb_info *tinfo)
 | 
			
		||||
{
 | 
			
		||||
	return sbi_ipi_send_many(scratch, hmask, hbase, tlb_event, tinfo);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int sbi_tlb_fifo_init(struct sbi_scratch *scratch, bool cold_boot)
 | 
			
		||||
int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot)
 | 
			
		||||
{
 | 
			
		||||
	int ret;
 | 
			
		||||
	void *tlb_mem;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user