Skip to content

Commit e4236b1

Browse files
committed
drm/imagination: Ensure PVR_MIPS_PT_PAGE_COUNT is never zero
When the host page size was more than 4 times larger than the FW page size, this macro evaluated to zero resulting in zero-sized arrays. Use DIV_ROUND_UP() to ensure the correct behavior. Reported-by: [email protected] Closes: https://lore.kernel.org/dri-devel/[email protected] Link: https://lore.kernel.org/dri-devel/[email protected] Fixes: 927f3e0 ("drm/imagination: Implement MIPS firmware processor and MMU support") Cc: [email protected] Signed-off-by: Matt Coster <[email protected]> Reviewed-by: Frank Binns <[email protected]>
1 parent 27906e5 commit e4236b1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpu/drm/imagination/pvr_fw_mips.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
#include "pvr_rogue_mips.h"
88

99
#include <asm/page.h>
10+
#include <linux/math.h>
1011
#include <linux/types.h>
1112

1213
/* Forward declaration from pvr_gem.h. */
1314
struct pvr_gem_object;
1415

15-
#define PVR_MIPS_PT_PAGE_COUNT ((ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K) \
16-
>> PAGE_SHIFT)
16+
#define PVR_MIPS_PT_PAGE_COUNT DIV_ROUND_UP(ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K, PAGE_SIZE)
17+
1718
/**
1819
* struct pvr_fw_mips_data - MIPS-specific data
1920
*/

0 commit comments

Comments
 (0)