[PATCH] drm/panfrost: Update io-pgtable API

Alyssa Rosenzweig alyssa at collabora.com
Wed Aug 31 12:49:16 UTC 2022


On Tue, Aug 23, 2022 at 11:42:33AM +0100, Robin Murphy wrote:
> On 2022-08-23 03:51, Alyssa Rosenzweig wrote:
> > > -static size_t get_pgsize(u64 addr, size_t size)
> > > +static size_t get_pgsize(u64 addr, size_t size, size_t *count)
> > >   {
> > > -	if (addr & (SZ_2M - 1) || size < SZ_2M)
> > > -		return SZ_4K;
> > > +	size_t blk_offset = -addr % SZ_2M;
> > 
> > addr is unsigned. if this is correct, it's magic.
> 
> Eh, it's just well-defined unsigned integer overflow. Take "SZ_2M - (addr %
> SZ_2M)", realise the first term can be anything that's zero modulo SZ_2M,
> including zero, then also that the operations can be done in either order to
> give the same result, and there you go.

Shrug. It still seems voodoo to me but if this is normal kernel style
I'm not going to complain, Acked-by for the patch regardless.


More information about the dri-devel mailing list