forked from Mirrors/opensbi
sbi: tlb: Simplify to tlb_process_count/tlb_process function
tlb_process_count is only used when count=1, so refactor to tlb_process_once and add the return value to be reused in tlb_process Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org> Tested-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -229,30 +229,23 @@ static void tlb_entry_process(struct sbi_tlb_info *tinfo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tlb_process_count(struct sbi_scratch *scratch, int count)
|
static bool tlb_process_once(struct sbi_scratch *scratch)
|
||||||
{
|
{
|
||||||
struct sbi_tlb_info tinfo;
|
struct sbi_tlb_info tinfo;
|
||||||
unsigned int deq_count = 0;
|
|
||||||
struct sbi_fifo *tlb_fifo =
|
struct sbi_fifo *tlb_fifo =
|
||||||
sbi_scratch_offset_ptr(scratch, tlb_fifo_off);
|
sbi_scratch_offset_ptr(scratch, tlb_fifo_off);
|
||||||
|
|
||||||
while (!sbi_fifo_dequeue(tlb_fifo, &tinfo)) {
|
if (!sbi_fifo_dequeue(tlb_fifo, &tinfo)) {
|
||||||
tlb_entry_process(&tinfo);
|
tlb_entry_process(&tinfo);
|
||||||
deq_count++;
|
return true;
|
||||||
if (deq_count > count)
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tlb_process(struct sbi_scratch *scratch)
|
static void tlb_process(struct sbi_scratch *scratch)
|
||||||
{
|
{
|
||||||
struct sbi_tlb_info tinfo;
|
while (tlb_process_once(scratch));
|
||||||
struct sbi_fifo *tlb_fifo =
|
|
||||||
sbi_scratch_offset_ptr(scratch, tlb_fifo_off);
|
|
||||||
|
|
||||||
while (!sbi_fifo_dequeue(tlb_fifo, &tinfo))
|
|
||||||
tlb_entry_process(&tinfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tlb_sync(struct sbi_scratch *scratch)
|
static void tlb_sync(struct sbi_scratch *scratch)
|
||||||
@@ -265,7 +258,7 @@ static void tlb_sync(struct sbi_scratch *scratch)
|
|||||||
* While we are waiting for remote hart to set the sync,
|
* While we are waiting for remote hart to set the sync,
|
||||||
* consume fifo requests to avoid deadlock.
|
* consume fifo requests to avoid deadlock.
|
||||||
*/
|
*/
|
||||||
tlb_process_count(scratch, 1);
|
tlb_process_once(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -380,7 +373,7 @@ static int tlb_update(struct sbi_scratch *scratch,
|
|||||||
* TODO: Introduce a wait/wakeup event mechanism to handle
|
* TODO: Introduce a wait/wakeup event mechanism to handle
|
||||||
* this properly.
|
* this properly.
|
||||||
*/
|
*/
|
||||||
tlb_process_count(scratch, 1);
|
tlb_process_once(scratch);
|
||||||
sbi_dprintf("hart%d: hart%d tlb fifo full\n",
|
sbi_dprintf("hart%d: hart%d tlb fifo full\n",
|
||||||
curr_hartid, remote_hartid);
|
curr_hartid, remote_hartid);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user