Skip to content

Commit c6a3573

Browse files
committed
lib: utils: Fix sbi_hartid_to_scratch() usage in ACLINT drivers
The cold_init() functions of ACLINT drivers should skip the HART if sbi_hartid_to_scratch() returns NULL because we might be dealing with a HART that is disabled in the device tree. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Xiang W <wxjstz@126.com>
1 parent 7828eeb commit c6a3573

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/utils/ipi/aclint_mswi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@ int aclint_mswi_cold_init(struct aclint_mswi_data *mswi)
101101
/* Update MSWI pointer in scratch space */
102102
for (i = 0; i < mswi->hart_count; i++) {
103103
scratch = sbi_hartid_to_scratch(mswi->first_hartid + i);
104+
/*
105+
* We don't need to fail if scratch pointer is not available
106+
* because we might be dealing with hartid of a HART disabled
107+
* in the device tree.
108+
*/
104109
if (!scratch)
105-
return SBI_ENOENT;
110+
continue;
106111
mswi_set_hart_data_ptr(scratch, mswi);
107112
}
108113

lib/utils/timer/aclint_mtimer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,13 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
219219
/* Update MTIMER pointer in scratch space */
220220
for (i = 0; i < mt->hart_count; i++) {
221221
scratch = sbi_hartid_to_scratch(mt->first_hartid + i);
222+
/*
223+
* We don't need to fail if scratch pointer is not available
224+
* because we might be dealing with hartid of a HART disabled
225+
* in the device tree.
226+
*/
222227
if (!scratch)
223-
return SBI_ENOENT;
228+
continue;
224229
mtimer_set_hart_data_ptr(scratch, mt);
225230
}
226231

0 commit comments

Comments
 (0)