drm/imagination: Ensure PVR_MIPS_PT_PAGE_COUNT is never zero
Subsystems (3)
PATCH 1/1 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]
Fixes 927f3e0253c1 ("drm/imagination: Implement MIPS firmware processor and MMU support")
Signed-off-by Matt Coster <[email protected]>
--- drivers/gpu/drm/imagination/pvr_fw_mips.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/imagination/pvr_fw_mips.h +3 -2
@@ -7,13 +7,14 @@#include "pvr_rogue_mips.h" #include <asm/page.h> +#include <linux/math.h> #include <linux/types.h> /* Forward declaration from pvr_gem.h. */ struct pvr_gem_object ; -#define PVR_MIPS_PT_PAGE_COUNT ((ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K) \ - >> PAGE_SHIFT) +#define PVR_MIPS_PT_PAGE_COUNT DIV_ROUND_UP(ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K, PAGE_SIZE) +/** * struct pvr_fw_mips_data - MIPS-specific data */
base-commit: e95752752eaf06c860811ac5ddf9badf6c1b43ca
Signature · 1 line
2.44.0
Quoted 9 lines · Matt Coster
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]Fixes 927f3e0253c1 ("drm/imagination: Implement MIPS firmware processor and MMU support")Signed-off-by Matt Coster <[email protected]>
Reviewed-by Frank Binns <[email protected]>
Quoted 27 lines
--- drivers/gpu/drm/imagination/pvr_fw_mips.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/imagination/pvr_fw_mips.h +3
-2@@ -7,13 +7,14 @@#include "pvr_rogue_mips.h" #include <asm/page.h> +#include <linux/math.h> #include <linux/types.h> /* Forward declaration from pvr_gem.h. */ struct pvr_gem_object ; -#define PVR_MIPS_PT_PAGE_COUNT ((ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K) \ - >> PAGE_SHIFT) +#define PVR_MIPS_PT_PAGE_COUNT DIV_ROUND_UP(ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K, PAGE_SIZE) +/** * struct pvr_fw_mips_data - MIPS-specific data */ base-commit:
e95752752eaf06c860811ac5ddf9badf6c1b43ca