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: 20240228012313.5934-1-yaolu@kylinos.cn Closes: https://lore.kernel.org/dri-devel/20240228012313.5934-1-yaolu@kylinos.cn Link: https://lore.kernel.org/dri-devel/20240228012313.5934-1-yaolu@kylinos.cn Fixes: 927f3e0 ("drm/imagination: Implement MIPS firmware processor and MMU support") Cc: stable@vger.kernel.org Signed-off-by: Matt Coster <matt.coster@imgtec.com> Reviewed-by: Frank Binns <frank.binns@imgtec.com>
1 parent 27906e5 commit e4236b1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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)