Skip to content

Commit a807cb2

Browse files
suijingfenglynxeye-dev
authored andcommitted
drm/etnaviv: Improve VA, PA, SIZE alignment checking
Alignment checking is only needed to be done in the upper caller function. If those address and sizes are able to pass the check, it will certainly pass the same test in the etnaviv_context_unmap() function. We don't need examine it more than once. Remove redundant alignment tests, move the those useless to upper caller function. Signed-off-by: Sui Jingfeng <[email protected]> Signed-off-by: Lucas Stach <[email protected]>
1 parent 0078a6f commit a807cb2

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

drivers/gpu/drm/etnaviv/etnaviv_mmu.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ static void etnaviv_context_unmap(struct etnaviv_iommu_context *context,
1919
size_t unmapped_page, unmapped = 0;
2020
size_t pgsize = SZ_4K;
2121

22-
if (!IS_ALIGNED(iova | size, pgsize)) {
23-
pr_err("unaligned: iova 0x%lx size 0x%zx min_pagesz 0x%zx\n",
24-
iova, size, pgsize);
25-
return;
26-
}
27-
2822
while (unmapped < size) {
2923
unmapped_page = context->global->ops->unmap(context, iova,
3024
pgsize);
@@ -45,12 +39,6 @@ static int etnaviv_context_map(struct etnaviv_iommu_context *context,
4539
size_t orig_size = size;
4640
int ret = 0;
4741

48-
if (!IS_ALIGNED(iova | paddr | size, pgsize)) {
49-
pr_err("unaligned: iova 0x%lx pa %pa size 0x%zx min_pagesz 0x%zx\n",
50-
iova, &paddr, size, pgsize);
51-
return -EINVAL;
52-
}
53-
5442
while (size) {
5543
ret = context->global->ops->map(context, iova, paddr, pgsize,
5644
prot);
@@ -88,6 +76,14 @@ static int etnaviv_iommu_map(struct etnaviv_iommu_context *context,
8876

8977
VERB("map[%d]: %08x %pap(%x)", i, da, &pa, bytes);
9078

79+
if (!IS_ALIGNED(iova | pa | bytes, SZ_4K)) {
80+
dev_err(context->global->dev,
81+
"unaligned: iova 0x%x pa %pa size 0x%x\n",
82+
iova, &pa, bytes);
83+
ret = -EINVAL;
84+
goto fail;
85+
}
86+
9187
ret = etnaviv_context_map(context, da, pa, bytes, prot);
9288
if (ret)
9389
goto fail;

0 commit comments

Comments
 (0)