mirror of
				https://github.com/riscv-software-src/opensbi
				synced 2025-11-04 05:50:22 +00:00 
			
		
		
		
	lib: utils: Make sure that hartid and the scratch are aligned
Harts associated with an ACLINT_MSWI need not have sequential hartids. It is insufficient to use first_hartid and hart_count. To account for non-sequential hart ids, include the empty hart-ids' generate hart-count. Signed-off-by: Raj Vishwanathan <Raj.Vishwanathan@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
		
							parent
							
								
									949c83a799
								
							
						
					
					
						commit
						321ca8063b
					
				@ -962,7 +962,7 @@ int fdt_parse_aclint_node(const void *fdt, int nodeoffset,
 | 
			
		||||
{
 | 
			
		||||
	const fdt32_t *val;
 | 
			
		||||
	int i, rc, count, cpu_offset, cpu_intc_offset;
 | 
			
		||||
	u32 phandle, hwirq, hartid, first_hartid, last_hartid, hart_count;
 | 
			
		||||
	u32 phandle, hwirq, hartid, first_hartid, last_hartid;
 | 
			
		||||
	u32 match_hwirq = (for_timer) ? IRQ_M_TIMER : IRQ_M_SOFT;
 | 
			
		||||
 | 
			
		||||
	if (nodeoffset < 0 || !fdt ||
 | 
			
		||||
@ -991,7 +991,7 @@ int fdt_parse_aclint_node(const void *fdt, int nodeoffset,
 | 
			
		||||
	count = count / sizeof(fdt32_t);
 | 
			
		||||
 | 
			
		||||
	first_hartid = -1U;
 | 
			
		||||
	hart_count = last_hartid = 0;
 | 
			
		||||
	last_hartid = 0;
 | 
			
		||||
	for (i = 0; i < (count / 2); i++) {
 | 
			
		||||
		phandle = fdt32_to_cpu(val[2 * i]);
 | 
			
		||||
		hwirq = fdt32_to_cpu(val[(2 * i) + 1]);
 | 
			
		||||
@ -1016,16 +1016,13 @@ int fdt_parse_aclint_node(const void *fdt, int nodeoffset,
 | 
			
		||||
				first_hartid = hartid;
 | 
			
		||||
			if (hartid > last_hartid)
 | 
			
		||||
				last_hartid = hartid;
 | 
			
		||||
			hart_count++;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((last_hartid >= first_hartid) && first_hartid != -1U) {
 | 
			
		||||
		*out_first_hartid = first_hartid;
 | 
			
		||||
		count = last_hartid - first_hartid + 1;
 | 
			
		||||
		*out_hart_count = (hart_count < count) ? hart_count : count;
 | 
			
		||||
		*out_hart_count = last_hartid - first_hartid + 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user