diff options
author | Colin Xu <[email protected]> | 2021-04-16 16:33:55 +0800 |
---|---|---|
committer | Zhenyu Wang <[email protected]> | 2021-04-29 17:00:09 +0800 |
commit | d385c16173f28a18866abf54c764200c276dace0 (patch) | |
tree | c75d5bf58c139bbb52fdbc87008fd9dbd3b7b5d8 /lib | |
parent | e65a4d378480101f222e8f6978c22e590c1fb7b5 (diff) |
drm/i915/gvt: Prevent divided by zero when calculating refresh rate
To get refresh rate as vblank timer period and keep the precision, the
calculation of rate is multiplied by 1000. However old logic was using:
rate = pixel clock / (h * v / 1000). When the h/v total is invalid, like
all 0, h * v / 1000 will be rounded to 0, which leads to a divided by 0
fault.
0 H/V are already checked above. Instead of divide after divide, refine
the calculation to divide after multiply: "pixel clock * 1000 / (h * v)"
Guest driver should guarantee the correctness of the timing regs' value.
Fixes: 6a4500c7b83f ("drm/i915/gvt: Get accurate vGPU virtual display refresh rate from vreg")
Reported-by: Zhenyu Wang <[email protected]>
Signed-off-by: Colin Xu <[email protected]>
Signed-off-by: Zhenyu Wang <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
Reviewed-by: Zhenyu Wang <[email protected]>
Diffstat (limited to 'lib')
0 files changed, 0 insertions, 0 deletions