diff options
author | Dave Airlie <airlied@gmail.com> | 2012-08-09 01:00:15 -0400 |
---|---|---|
committer | Dave Airlie <airlied@gmail.com> | 2012-08-10 06:31:37 -0400 |
commit | 9830605d4c070b16ec5c24a75503877cc7698409 (patch) | |
tree | e99385fa8c9d9c1ab16bcb8a996959de9f4aa05d /drivers | |
parent | f7b83b908fbecadefa73c0d76b9c719d09c1d96d (diff) |
drm/mgag200: fix G200ER pll picking algorithm
The original code was misported from the X driver,
a) an int went to unsigned int, breaking the downward counting testm code
b) the port did the vco/computed clock bits completely wrong.
This fixes an infinite loop on modprobe on some Dell servers with the G200ER
chipset variant.
Found in internal testing.
Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/mgag200/mgag200_mode.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index a4d7c500c97b..b69642d5d850 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c | |||
@@ -468,10 +468,11 @@ static int mga_g200er_set_plls(struct mga_device *mdev, long clock) | |||
468 | { | 468 | { |
469 | unsigned int vcomax, vcomin, pllreffreq; | 469 | unsigned int vcomax, vcomin, pllreffreq; |
470 | unsigned int delta, tmpdelta; | 470 | unsigned int delta, tmpdelta; |
471 | unsigned int testr, testn, testm, testo; | 471 | int testr, testn, testm, testo; |
472 | unsigned int p, m, n; | 472 | unsigned int p, m, n; |
473 | unsigned int computed; | 473 | unsigned int computed, vco; |
474 | int tmp; | 474 | int tmp; |
475 | const unsigned int m_div_val[] = { 1, 2, 4, 8 }; | ||
475 | 476 | ||
476 | m = n = p = 0; | 477 | m = n = p = 0; |
477 | vcomax = 1488000; | 478 | vcomax = 1488000; |
@@ -490,12 +491,13 @@ static int mga_g200er_set_plls(struct mga_device *mdev, long clock) | |||
490 | if (delta == 0) | 491 | if (delta == 0) |
491 | break; | 492 | break; |
492 | for (testo = 5; testo < 33; testo++) { | 493 | for (testo = 5; testo < 33; testo++) { |
493 | computed = pllreffreq * (testn + 1) / | 494 | vco = pllreffreq * (testn + 1) / |
494 | (testr + 1); | 495 | (testr + 1); |
495 | if (computed < vcomin) | 496 | if (vco < vcomin) |
496 | continue; | 497 | continue; |
497 | if (computed > vcomax) | 498 | if (vco > vcomax) |
498 | continue; | 499 | continue; |
500 | computed = vco / (m_div_val[testm] * (testo + 1)); | ||
499 | if (computed > clock) | 501 | if (computed > clock) |
500 | tmpdelta = computed - clock; | 502 | tmpdelta = computed - clock; |
501 | else | 503 | else |