File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -250,13 +250,22 @@ void panfrost_mmu_reset(struct panfrost_device *pfdev)
250
250
251
251
static size_t get_pgsize (u64 addr , size_t size , size_t * count )
252
252
{
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
+ */
253
261
size_t blk_offset = - addr % SZ_2M ;
254
262
255
263
if (blk_offset || size < SZ_2M ) {
256
264
* count = min_not_zero (blk_offset , size ) / SZ_4K ;
257
265
return SZ_4K ;
258
266
}
259
- * count = size / SZ_2M ;
267
+ blk_offset = - addr % SZ_1G ?: SZ_1G ;
268
+ * count = min (blk_offset , size ) / SZ_2M ;
260
269
return SZ_2M ;
261
270
}
262
271
You can’t perform that action at this time.
0 commit comments