Skip to content

Commit a77b588

Browse files
Alyssa RosenzweigSteven Price
authored andcommitted
drm/panfrost: Use u64 for size in lock_region
Mali virtual addresses are 48-bit. Use a u64 instead of size_t to ensure we can express the "lock everything" condition as ~0ULL without overflow. This code was silently broken on any platform where a size_t is less than 48-bits; in particular, it was broken on 32-bit armv7 platforms which remain in use with panfrost. (Mainly RK3288) Signed-off-by: Alyssa Rosenzweig <[email protected]> Suggested-by: Rob Herring <[email protected]> Tested-by: Chris Morgan <[email protected]> Reviewed-by: Steven Price <[email protected]> Reviewed-by: Rob Herring <[email protected]> Fixes: f3ba912 ("drm/panfrost: Add initial panfrost driver") Cc: <[email protected]> Signed-off-by: Steven Price <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent b5fab34 commit a77b588

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/gpu/drm/panfrost/panfrost_mmu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd)
5858
}
5959

6060
static void lock_region(struct panfrost_device *pfdev, u32 as_nr,
61-
u64 iova, size_t size)
61+
u64 iova, u64 size)
6262
{
6363
u8 region_width;
6464
u64 region = iova & PAGE_MASK;
@@ -78,7 +78,7 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr,
7878

7979

8080
static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr,
81-
u64 iova, size_t size, u32 op)
81+
u64 iova, u64 size, u32 op)
8282
{
8383
if (as_nr < 0)
8484
return 0;
@@ -95,7 +95,7 @@ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr,
9595

9696
static int mmu_hw_do_operation(struct panfrost_device *pfdev,
9797
struct panfrost_mmu *mmu,
98-
u64 iova, size_t size, u32 op)
98+
u64 iova, u64 size, u32 op)
9999
{
100100
int ret;
101101

@@ -112,7 +112,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m
112112
u64 transtab = cfg->arm_mali_lpae_cfg.transtab;
113113
u64 memattr = cfg->arm_mali_lpae_cfg.memattr;
114114

115-
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM);
115+
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
116116

117117
mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL);
118118
mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), transtab >> 32);
@@ -128,7 +128,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m
128128

129129
static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr)
130130
{
131-
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM);
131+
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
132132

133133
mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0);
134134
mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0);
@@ -242,7 +242,7 @@ static size_t get_pgsize(u64 addr, size_t size)
242242

243243
static void panfrost_mmu_flush_range(struct panfrost_device *pfdev,
244244
struct panfrost_mmu *mmu,
245-
u64 iova, size_t size)
245+
u64 iova, u64 size)
246246
{
247247
if (mmu->as < 0)
248248
return;

0 commit comments

Comments
 (0)