diff --git a/drivers/gpu/drm/nouveau/nv50_pm.c b/drivers/gpu/drm/nouveau/nv50_pm.c index 64bc29c..e703ca1 100644 --- a/drivers/gpu/drm/nouveau/nv50_pm.c +++ b/drivers/gpu/drm/nouveau/nv50_pm.c @@ -56,6 +56,11 @@ nv50_pm_clock_get(struct drm_device *dev, u32 id) N = (reg1 & 0x0000ff00) >> 8; M = (reg1 & 0x000000ff); + if (N == 0 || M == 0) { + NV_ERROR(dev, "can't calc clock for id=%d, reg0:0x%x, reg1:0x%x\n", id, reg0, reg1); + return -EINVAL; + } + return ((pll.refclk * N / M) >> P); } @@ -63,6 +68,12 @@ nv50_pm_clock_get(struct drm_device *dev, u32 id) P = (reg0 & 0x003f0000) >> 16; N = (reg0 & 0x0000ff00) >> 8; M = (reg0 & 0x000000ff); + + if (N == 0 || M == 0 || P == 0) { + NV_ERROR(dev, "can't calc clock for id=%d, reg0:0x%x\n", id, reg0); + return -EINVAL; + } + return pll.refclk * N / M / P; }