2 Commits

Author SHA1 Message Date
Michal Simek
74434f2558 lib: sbi: Fix behavior on platform without HART protection
The commit 42139bb9b7 ("lib: sbi: Replace sbi_hart_pmp_xyz() and
sbi_hart_map/unmap_addr()") changed logic by calling
sbi_hart_protection_configure(). But when protection doesn't exist
the function is returning SBI_EINVAL.
But on systems without protection this is correct configuration
that's why do not hang when system don't have any HART protection.

Fixes: 42139bb9b7 ("lib: sbi: Replace sbi_hart_pmp_xyz() and sbi_hart_map/unmap_addr()")
Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/bb8641e5f82654e3989537cea85f165f67a7044e.1767801896.git.michal.simek@amd.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-01-08 14:18:14 +05:30
Leo Yu-Chi Liang
65fac65311 include: sbi_scratch: fix typo sbi_scratch -> HART id
Fix "sbi_scratch" to "HART id" to better reflect its purpose.

Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260107032602.1143819-1-ycliang@andestech.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-01-08 12:40:32 +05:30
2 changed files with 4 additions and 8 deletions

View File

@@ -186,7 +186,7 @@ extern u32 sbi_scratch_hart_count;
/** HART index to HART id table */
extern u32 hartindex_to_hartid_table[];
/** Get sbi_scratch from HART index */
/** Get HART id from HART index */
#define sbi_hartindex_to_hartid(__hartindex) \
({ \
((__hartindex) < SBI_HARTMASK_MAX_BITS) ? \

View File

@@ -54,7 +54,7 @@ int sbi_hart_protection_configure(struct sbi_scratch *scratch)
struct sbi_hart_protection *hprot = sbi_hart_protection_best();
if (!hprot)
return SBI_EINVAL;
return 0;
if (!hprot->configure)
return SBI_ENOSYS;
@@ -75,9 +75,7 @@ int sbi_hart_protection_map_range(unsigned long base, unsigned long size)
{
struct sbi_hart_protection *hprot = sbi_hart_protection_best();
if (!hprot)
return SBI_EINVAL;
if (!hprot->map_range)
if (!hprot || !hprot->map_range)
return 0;
return hprot->map_range(sbi_scratch_thishart_ptr(), base, size);
@@ -87,9 +85,7 @@ int sbi_hart_protection_unmap_range(unsigned long base, unsigned long size)
{
struct sbi_hart_protection *hprot = sbi_hart_protection_best();
if (!hprot)
return SBI_EINVAL;
if (!hprot->unmap_range)
if (!hprot || !hprot->unmap_range)
return 0;
return hprot->unmap_range(sbi_scratch_thishart_ptr(), base, size);