Message ID | 20210820213117.13050-3-alyssa.rosenzweig@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/panfrost: Bug fixes for lock_region | expand |
On 20/08/2021 22:31, Alyssa Rosenzweig wrote: > 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 relying > on platform-specific behaviour. 'platform-specific behaviour' makes it sound like this is something to do with a particular board. This is 32bit/64bit - it's going to be broken on 32bit: large lock regions are not going to work. > Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> > Suggested-by: Rob Herring <robh@kernel.org> > Tested-by: Chris Morgan <macromorgan@hotmail.com> Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver") Reviewed-by: Steven Price <steven.price@arm.com> Steve > --- > drivers/gpu/drm/panfrost/panfrost_mmu.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c > index f6e02d0392f4..3a795273e505 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c > +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c > @@ -58,7 +58,7 @@ static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd) > } > > static void lock_region(struct panfrost_device *pfdev, u32 as_nr, > - u64 iova, size_t size) > + u64 iova, u64 size) > { > u8 region_width; > u64 region = iova & PAGE_MASK; > @@ -78,7 +78,7 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr, > > > static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, > - u64 iova, size_t size, u32 op) > + u64 iova, u64 size, u32 op) > { > if (as_nr < 0) > return 0; > @@ -95,7 +95,7 @@ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, > > static int mmu_hw_do_operation(struct panfrost_device *pfdev, > struct panfrost_mmu *mmu, > - u64 iova, size_t size, u32 op) > + u64 iova, u64 size, u32 op) > { > int ret; > > @@ -112,7 +112,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m > u64 transtab = cfg->arm_mali_lpae_cfg.transtab; > u64 memattr = cfg->arm_mali_lpae_cfg.memattr; > > - mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); > + mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM); > > mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL); > 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 > > static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr) > { > - mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); > + mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM); > > mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0); > mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0); > @@ -242,7 +242,7 @@ static size_t get_pgsize(u64 addr, size_t size) > > static void panfrost_mmu_flush_range(struct panfrost_device *pfdev, > struct panfrost_mmu *mmu, > - u64 iova, size_t size) > + u64 iova, u64 size) > { > if (mmu->as < 0) > return; >
> > 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 relying > > on platform-specific behaviour. > > 'platform-specific behaviour' makes it sound like this is something to > do with a particular board. This is 32bit/64bit - it's going to be > broken on 32bit: large lock regions are not going to work. Oh, my. I used the term as a weasel word since the spec is loose on how big a size_t actually is. But if this is causing actual breakage on armv7 we're in trouble. I'll add a Cc stable tag on v2, unless the Fixes implies that? Thanks for pointing this out.
On 23 August 2021 22:11:09 BST, Alyssa Rosenzweig <alyssa@collabora.com> wrote: >> > 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 relying >> > on platform-specific behaviour. >> >> 'platform-specific behaviour' makes it sound like this is something to >> do with a particular board. This is 32bit/64bit - it's going to be >> broken on 32bit: large lock regions are not going to work. > >Oh, my. I used the term as a weasel word since the spec is loose on how >big a size_t actually is. But if this is causing actual breakage on >armv7 we're in trouble. I'll add a Cc stable tag on v2, unless the Fixes >implies that? The usual practice is to put CC: stable in the commit message or the fixes tag (no need to actually CC the stable email address). So just Fixes: should work >Thanks for pointing this out. It's not actually quite so bad as it could be as >4GB regions are unlikely (especially on 32bit), but the GPU does of course support such a thing. Thanks, Steve
diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index f6e02d0392f4..3a795273e505 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -58,7 +58,7 @@ static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd) } static void lock_region(struct panfrost_device *pfdev, u32 as_nr, - u64 iova, size_t size) + u64 iova, u64 size) { u8 region_width; u64 region = iova & PAGE_MASK; @@ -78,7 +78,7 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr, static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, - u64 iova, size_t size, u32 op) + u64 iova, u64 size, u32 op) { if (as_nr < 0) return 0; @@ -95,7 +95,7 @@ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, static int mmu_hw_do_operation(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, - u64 iova, size_t size, u32 op) + u64 iova, u64 size, u32 op) { int ret; @@ -112,7 +112,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m u64 transtab = cfg->arm_mali_lpae_cfg.transtab; u64 memattr = cfg->arm_mali_lpae_cfg.memattr; - mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); + mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM); mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL); 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 static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr) { - mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); + mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM); mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0); mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0); @@ -242,7 +242,7 @@ static size_t get_pgsize(u64 addr, size_t size) static void panfrost_mmu_flush_range(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, - u64 iova, size_t size) + u64 iova, u64 size) { if (mmu->as < 0) return;