lib: sbi: Rename map_range/unmap_range functions

*_map_range and *_unmap_range functions are required
in M-Mode to get the temporary access to S-Mode and U-Mode
regions. Thse functions only operate using the TYPE_MEMORY
memory protection mechanisms. Rename them to reflect the
actual usage of these functions and let generic map/unmap_range
names to implement generic functions

Signed-off-by: Rahul Pathak <rahul.pathak@oss.qualcomm.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260820121309.2551296-2-rahul.pathak@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Rahul Pathak
2026-09-05 12:52:39 +05:30
committed by Anup Patel
parent 7774b82e4a
commit 35af7c8c7e
8 changed files with 72 additions and 67 deletions
+26 -26
View File
@@ -657,8 +657,8 @@ int sbi_dbtr_read_trig(unsigned long smode,
shmem_base = hart_shmem_base(hs);
sbi_hart_protection_map_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_map_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
xmit = &entry->data;
trig = INDEX_TO_TRIGGER((_idx + trig_idx_base));
@@ -671,8 +671,8 @@ int sbi_dbtr_read_trig(unsigned long smode,
xmit->tdata2 = cpu_to_lle(trig->tdata2);
xmit->tdata3 = cpu_to_lle(trig->tdata3);
}
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
return SBI_SUCCESS;
}
@@ -699,8 +699,8 @@ int sbi_dbtr_install_trig(unsigned long smode,
return SBI_ERR_NO_SHMEM;
shmem_base = hart_shmem_base(hs);
sbi_hart_protection_map_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_map_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
/*
* SBI v3.0 sec 19.4 requires SBI_ERR_NOT_SUPPORTED when a trigger
@@ -720,23 +720,23 @@ int sbi_dbtr_install_trig(unsigned long smode,
if (!dbtr_trigger_supported(TDATA1_GET_TYPE(ctrl))) {
*out = _idx;
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
return SBI_ERR_FAILED;
}
if (!dbtr_trigger_valid(TDATA1_GET_TYPE(ctrl), ctrl)) {
*out = _idx;
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
return SBI_ERR_INVALID_PARAM;
}
if ((recv->tdata2 && !tdata2_impl) ||
(recv->tdata3 && !tdata3_impl)) {
*out = _idx;
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
return SBI_ERR_NOT_SUPPORTED;
}
@@ -745,16 +745,16 @@ int sbi_dbtr_install_trig(unsigned long smode,
lle_to_cpu(recv->tdata2),
lle_to_cpu(recv->tdata3))) {
*out = _idx;
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
return SBI_ERR_NOT_SUPPORTED;
}
}
if (hs->available_trigs < trig_count) {
*out = hs->available_trigs;
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
return SBI_ERR_FAILED;
}
@@ -771,8 +771,8 @@ int sbi_dbtr_install_trig(unsigned long smode,
lle_to_cpu(recv->tdata3));
if (slot < 0) {
*out = _idx;
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
return SBI_ERR_FAILED;
}
claimed |= BIT(slot);
@@ -798,8 +798,8 @@ int sbi_dbtr_install_trig(unsigned long smode,
}
sbi_hart_protection_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)shmem_base,
trig_count * sizeof(*entry));
return SBI_SUCCESS;
}
@@ -882,24 +882,24 @@ int sbi_dbtr_update_trig(unsigned long smode,
tdata3_impl = tdata_implemented(CSR_TDATA3);
for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
sbi_hart_protection_map_range((unsigned long)entry, sizeof(*entry));
sbi_hart_protection_temp_map_range((unsigned long)entry, sizeof(*entry));
trig_idx = entry->id.idx;
if (trig_idx >= hs->total_trigs) {
sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)entry, sizeof(*entry));
return SBI_ERR_INVALID_PARAM;
}
trig = INDEX_TO_TRIGGER(trig_idx);
if (!(trig->state & RV_DBTR_BIT_MASK(TS, MAPPED))) {
sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)entry, sizeof(*entry));
return SBI_ERR_FAILED;
}
if ((entry->data.tdata2 && !tdata2_impl) ||
(entry->data.tdata3 && !tdata3_impl)) {
sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)entry, sizeof(*entry));
return SBI_ERR_NOT_SUPPORTED;
}
@@ -907,12 +907,12 @@ int sbi_dbtr_update_trig(unsigned long smode,
lle_to_cpu(entry->data.tdata1),
lle_to_cpu(entry->data.tdata2),
lle_to_cpu(entry->data.tdata3))) {
sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)entry, sizeof(*entry));
return SBI_ERR_NOT_SUPPORTED;
}
dbtr_trigger_setup(trig, &entry->data);
sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
sbi_hart_protection_temp_unmap_range((unsigned long)entry, sizeof(*entry));
dbtr_trigger_enable(trig);
}