ANDROID: iommu/io-pgtable-arm: Fix existing/missing mapping hooks

Fix one hook that is called in the wrong place and add 2 missing calls,
also remove the return from arm_lpae_unmap_empty() as it is not used.

Bug: 357781595
Bug: 384432312
Change-Id: I62cb848b0421c295a144660511bf4389f4e6ffd6
Signed-off-by: Mostafa Saleh <smostafa@google.com>
This commit is contained in:
Mostafa Saleh
2025-02-24 18:59:43 +00:00
committed by Treehugger Robot
parent 155a73725c
commit 004af73a3e
4 changed files with 10 additions and 8 deletions
@@ -25,9 +25,8 @@ int arm_lpae_map_exists(void)
return -EEXIST;
}
int arm_lpae_unmap_empty(void)
void arm_lpae_unmap_empty(void)
{
return -EEXIST;
}
void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp,
+7 -3
View File
@@ -231,7 +231,7 @@ static int __arm_lpae_map(struct arm_lpae_io_pgtable *data, unsigned long iova,
cptep = iopte_deref(pte, data);
} else if (iopte_valid(pte)) {
/* We require an unmap first */
return arm_lpae_unmap_empty();
return arm_lpae_map_exists();
}
/* Rinse, repeat */
@@ -428,8 +428,10 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
unmap_idx_start = ARM_LPAE_LVL_IDX(iova, lvl, data);
ptep += unmap_idx_start;
pte = READ_ONCE(*ptep);
if (WARN_ON(!iopte_valid(pte)))
if (!iopte_valid(pte)) {
arm_lpae_unmap_empty();
return 0;
}
/* If the size matches this level, we're in the right place */
if (size == ARM_LPAE_BLOCK_SIZE(lvl, data)) {
@@ -439,8 +441,10 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
/* Find and handle non-leaf entries */
for (i = 0; i < num_entries; i++) {
pte = READ_ONCE(ptep[i]);
if (WARN_ON(!iopte_valid(pte)))
if (!iopte_valid(pte)) {
arm_lpae_unmap_empty();
break;
}
if (!iopte_leaf(pte, lvl, iop->fmt)) {
__arm_lpae_clear_pte(&ptep[i], &iop->cfg, 1);
+1 -2
View File
@@ -31,10 +31,9 @@ int arm_lpae_map_exists(void)
return -EEXIST;
}
int arm_lpae_unmap_empty(void)
void arm_lpae_unmap_empty(void)
{
WARN_ON(!selftest_running);
return -EEXIST;
}
static dma_addr_t __arm_lpae_dma_addr(void *pages)
+1 -1
View File
@@ -233,5 +233,5 @@ void __arm_lpae_free_pages(void *pages, size_t size, struct io_pgtable_cfg *cfg,
void __arm_lpae_sync_pte(arm_lpae_iopte *ptep, int num_entries,
struct io_pgtable_cfg *cfg);
int arm_lpae_map_exists(void);
int arm_lpae_unmap_empty(void);
void arm_lpae_unmap_empty(void);
#endif /* IO_PGTABLE_H_ */