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

From
Robin Murphy <robin.murphy@arm.com>
Date
2022-08-23 10:43:50
Also in
dri-devel
Reply to
Alyssa Rosenzweig, 2022-08-23
On 2022-08-23 03:51, Alyssa Rosenzweig wrote:
quoted
-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.

Cheers,
Robin.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (10 messages) 10 messages, 4 authors, last reply 2022-11-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help