Skip to content

Commit f352262

Browse files
rmurphy-armSteven Price
authored andcommitted
drm/panfrost: Split io-pgtable requests properly
Although we don't use 1GB block mappings, we still need to split map/unmap requests at 1GB boundaries to match what io-pgtable expects. Fix that, and add some explanation to make sense of it all. Fixes: 3740b08 ("drm/panfrost: Update io-pgtable API") Reported-by: Dmitry Osipenko <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Tested-by: Dmitry Osipenko <[email protected]> Reviewed-by: Steven Price <[email protected]> Signed-off-by: Steven Price <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/49e54bb4019cd06e01549b106d7ac37c3d182cd3.1667927179.git.robin.murphy@arm.com
1 parent e0b26b9 commit f352262

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/gpu/drm/panfrost/panfrost_mmu.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,22 @@ void panfrost_mmu_reset(struct panfrost_device *pfdev)
250250

251251
static size_t get_pgsize(u64 addr, size_t size, size_t *count)
252252
{
253+
/*
254+
* io-pgtable only operates on multiple pages within a single table
255+
* entry, so we need to split at boundaries of the table size, i.e.
256+
* the next block size up. The distance from address A to the next
257+
* boundary of block size B is logically B - A % B, but in unsigned
258+
* two's complement where B is a power of two we get the equivalence
259+
* B - A % B == (B - A) % B == (n * B - A) % B, and choose n = 0 :)
260+
*/
253261
size_t blk_offset = -addr % SZ_2M;
254262

255263
if (blk_offset || size < SZ_2M) {
256264
*count = min_not_zero(blk_offset, size) / SZ_4K;
257265
return SZ_4K;
258266
}
259-
*count = size / SZ_2M;
267+
blk_offset = -addr % SZ_1G ?: SZ_1G;
268+
*count = min(blk_offset, size) / SZ_2M;
260269
return SZ_2M;
261270
}
262271

0 commit comments

Comments
 (0)