Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux

Pull radeon drm fixes from Dave Airlie:
"This is just radeon fixes, primarily the two pll fix and the aux fix,
it also disables dpm on rv770 gpus, fixes driver reloading, and fixes
two issues with runtime PM on some GPUS"

* 'drm-fixes' of git://people.freedesktop.org/~airlied/linux:
drm/radeon: don't allow runpm=1 on systems with out ATPX
drm/radeon: fix ATPX detection on non-VGA GPUs
drm/radeon/pm: don't walk the crtc list before it has been initialized (v2)
drm/radeon: properly unregister hwmon interface (v2)
drm/radeon: fix count in cik_sdma_ring_test()
drm/radeon/aux: fix hpd assignment for aux bus
drm/radeon: improve PLL limit handling in post div calculation
drm/radeon: use fixed PPL ref divider if needed
drm/radeon: disable dpm on rv770 by default

+120 -68
+1
drivers/gpu/drm/radeon/atombios_dp.c
··· 209 209 { 210 210 int ret; 211 211 212 + radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd; 212 213 radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; 213 214 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer; 214 215 ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux);
+1 -1
drivers/gpu/drm/radeon/cik_sdma.c
··· 597 597 tmp = 0xCAFEDEAD; 598 598 writel(tmp, ptr); 599 599 600 - r = radeon_ring_lock(rdev, ring, 4); 600 + r = radeon_ring_lock(rdev, ring, 5); 601 601 if (r) { 602 602 DRM_ERROR("radeon: dma failed to lock ring %d (%d).\n", ring->idx, r); 603 603 return r;
+19 -16
drivers/gpu/drm/radeon/r600_dpm.c
··· 158 158 u32 line_time_us, vblank_lines; 159 159 u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ 160 160 161 - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 162 - radeon_crtc = to_radeon_crtc(crtc); 163 - if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { 164 - line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) / 165 - radeon_crtc->hw_mode.clock; 166 - vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end - 167 - radeon_crtc->hw_mode.crtc_vdisplay + 168 - (radeon_crtc->v_border * 2); 169 - vblank_time_us = vblank_lines * line_time_us; 170 - break; 161 + if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { 162 + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 163 + radeon_crtc = to_radeon_crtc(crtc); 164 + if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { 165 + line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) / 166 + radeon_crtc->hw_mode.clock; 167 + vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end - 168 + radeon_crtc->hw_mode.crtc_vdisplay + 169 + (radeon_crtc->v_border * 2); 170 + vblank_time_us = vblank_lines * line_time_us; 171 + break; 172 + } 171 173 } 172 174 } 173 175 ··· 183 181 struct radeon_crtc *radeon_crtc; 184 182 u32 vrefresh = 0; 185 183 186 - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 187 - radeon_crtc = to_radeon_crtc(crtc); 188 - if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { 189 - vrefresh = radeon_crtc->hw_mode.vrefresh; 190 - break; 184 + if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { 185 + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 186 + radeon_crtc = to_radeon_crtc(crtc); 187 + if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { 188 + vrefresh = radeon_crtc->hw_mode.vrefresh; 189 + break; 190 + } 191 191 } 192 192 } 193 - 194 193 return vrefresh; 195 194 } 196 195
+7
drivers/gpu/drm/radeon/radeon_atpx_handler.c
··· 528 528 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); 529 529 } 530 530 531 + /* some newer PX laptops mark the dGPU as a non-VGA display device */ 532 + while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { 533 + vga_count++; 534 + 535 + has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); 536 + } 537 + 531 538 if (has_atpx && vga_count == 2) { 532 539 acpi_get_name(radeon_atpx_priv.atpx.handle, ACPI_FULL_PATHNAME, &buffer); 533 540 printk(KERN_INFO "VGA switcheroo: detected switching method %s handle\n",
+57 -27
drivers/gpu/drm/radeon/radeon_display.c
··· 840 840 } 841 841 842 842 /** 843 + * avivo_get_fb_ref_div - feedback and ref divider calculation 844 + * 845 + * @nom: nominator 846 + * @den: denominator 847 + * @post_div: post divider 848 + * @fb_div_max: feedback divider maximum 849 + * @ref_div_max: reference divider maximum 850 + * @fb_div: resulting feedback divider 851 + * @ref_div: resulting reference divider 852 + * 853 + * Calculate feedback and reference divider for a given post divider. Makes 854 + * sure we stay within the limits. 855 + */ 856 + static void avivo_get_fb_ref_div(unsigned nom, unsigned den, unsigned post_div, 857 + unsigned fb_div_max, unsigned ref_div_max, 858 + unsigned *fb_div, unsigned *ref_div) 859 + { 860 + /* limit reference * post divider to a maximum */ 861 + ref_div_max = min(210 / post_div, ref_div_max); 862 + 863 + /* get matching reference and feedback divider */ 864 + *ref_div = min(max(DIV_ROUND_CLOSEST(den, post_div), 1u), ref_div_max); 865 + *fb_div = DIV_ROUND_CLOSEST(nom * *ref_div * post_div, den); 866 + 867 + /* limit fb divider to its maximum */ 868 + if (*fb_div > fb_div_max) { 869 + *ref_div = DIV_ROUND_CLOSEST(*ref_div * fb_div_max, *fb_div); 870 + *fb_div = fb_div_max; 871 + } 872 + } 873 + 874 + /** 843 875 * radeon_compute_pll_avivo - compute PLL paramaters 844 876 * 845 877 * @pll: information about the PLL ··· 892 860 u32 *ref_div_p, 893 861 u32 *post_div_p) 894 862 { 863 + unsigned target_clock = pll->flags & RADEON_PLL_USE_FRAC_FB_DIV ? 864 + freq : freq / 10; 865 + 895 866 unsigned fb_div_min, fb_div_max, fb_div; 896 867 unsigned post_div_min, post_div_max, post_div; 897 868 unsigned ref_div_min, ref_div_max, ref_div; ··· 915 880 ref_div_min = pll->reference_div; 916 881 else 917 882 ref_div_min = pll->min_ref_div; 918 - ref_div_max = pll->max_ref_div; 883 + 884 + if (pll->flags & RADEON_PLL_USE_FRAC_FB_DIV && 885 + pll->flags & RADEON_PLL_USE_REF_DIV) 886 + ref_div_max = pll->reference_div; 887 + else 888 + ref_div_max = pll->max_ref_div; 919 889 920 890 /* determine allowed post divider range */ 921 891 if (pll->flags & RADEON_PLL_USE_POST_DIV) { 922 892 post_div_min = pll->post_div; 923 893 post_div_max = pll->post_div; 924 894 } else { 925 - unsigned target_clock = freq / 10; 926 895 unsigned vco_min, vco_max; 927 896 928 897 if (pll->flags & RADEON_PLL_IS_LCD) { ··· 935 896 } else { 936 897 vco_min = pll->pll_out_min; 937 898 vco_max = pll->pll_out_max; 899 + } 900 + 901 + if (pll->flags & RADEON_PLL_USE_FRAC_FB_DIV) { 902 + vco_min *= 10; 903 + vco_max *= 10; 938 904 } 939 905 940 906 post_div_min = vco_min / target_clock; ··· 956 912 } 957 913 958 914 /* represent the searched ratio as fractional number */ 959 - nom = pll->flags & RADEON_PLL_USE_FRAC_FB_DIV ? freq : freq / 10; 915 + nom = target_clock; 960 916 den = pll->reference_freq; 961 917 962 918 /* reduce the numbers to a simpler ratio */ ··· 970 926 diff_best = ~0; 971 927 972 928 for (post_div = post_div_min; post_div <= post_div_max; ++post_div) { 973 - unsigned diff = abs(den - den / post_div * post_div); 929 + unsigned diff; 930 + avivo_get_fb_ref_div(nom, den, post_div, fb_div_max, 931 + ref_div_max, &fb_div, &ref_div); 932 + diff = abs(target_clock - (pll->reference_freq * fb_div) / 933 + (ref_div * post_div)); 934 + 974 935 if (diff < diff_best || (diff == diff_best && 975 936 !(pll->flags & RADEON_PLL_PREFER_MINM_OVER_MAXP))) { 976 937 ··· 985 936 } 986 937 post_div = post_div_best; 987 938 988 - /* limit reference * post divider to a maximum */ 989 - ref_div_max = min(210 / post_div, ref_div_max); 990 - 991 - /* get matching reference and feedback divider */ 992 - ref_div = max(DIV_ROUND_CLOSEST(den, post_div), 1u); 993 - fb_div = DIV_ROUND_CLOSEST(nom * ref_div * post_div, den); 994 - 995 - /* we're almost done, but reference and feedback 996 - divider might be to large now */ 997 - 998 - nom = fb_div; 999 - den = ref_div; 1000 - 1001 - if (fb_div > fb_div_max) { 1002 - ref_div = DIV_ROUND_CLOSEST(den * fb_div_max, nom); 1003 - fb_div = fb_div_max; 1004 - } 1005 - 1006 - if (ref_div > ref_div_max) { 1007 - ref_div = ref_div_max; 1008 - fb_div = DIV_ROUND_CLOSEST(nom * ref_div_max, den); 1009 - } 939 + /* get the feedback and reference divider for the optimal value */ 940 + avivo_get_fb_ref_div(nom, den, post_div, fb_div_max, ref_div_max, 941 + &fb_div, &ref_div); 1010 942 1011 943 /* reduce the numbers to a simpler ratio once more */ 1012 944 /* this also makes sure that the reference divider is large enough */ ··· 1009 979 *post_div_p = post_div; 1010 980 1011 981 DRM_DEBUG_KMS("%d - %d, pll dividers - fb: %d.%d ref: %d, post %d\n", 1012 - freq, *dot_clock_p, *fb_div_p, *frac_fb_div_p, 982 + freq, *dot_clock_p * 10, *fb_div_p, *frac_fb_div_p, 1013 983 ref_div, post_div); 1014 984 } 1015 985
+3 -5
drivers/gpu/drm/radeon/radeon_kms.c
··· 107 107 flags |= RADEON_IS_PCI; 108 108 } 109 109 110 - if (radeon_runtime_pm == 1) 111 - flags |= RADEON_IS_PX; 112 - else if ((radeon_runtime_pm == -1) && 113 - radeon_has_atpx() && 114 - ((flags & RADEON_IS_IGP) == 0)) 110 + if ((radeon_runtime_pm != 0) && 111 + radeon_has_atpx() && 112 + ((flags & RADEON_IS_IGP) == 0)) 115 113 flags |= RADEON_IS_PX; 116 114 117 115 /* radeon_device_init should report only fatal error
+32 -19
drivers/gpu/drm/radeon/radeon_pm.c
··· 603 603 static int radeon_hwmon_init(struct radeon_device *rdev) 604 604 { 605 605 int err = 0; 606 - struct device *hwmon_dev; 607 606 608 607 switch (rdev->pm.int_thermal_type) { 609 608 case THERMAL_TYPE_RV6XX: ··· 615 616 case THERMAL_TYPE_KV: 616 617 if (rdev->asic->pm.get_temperature == NULL) 617 618 return err; 618 - hwmon_dev = hwmon_device_register_with_groups(rdev->dev, 619 - "radeon", rdev, 620 - hwmon_groups); 621 - if (IS_ERR(hwmon_dev)) { 622 - err = PTR_ERR(hwmon_dev); 619 + rdev->pm.int_hwmon_dev = hwmon_device_register_with_groups(rdev->dev, 620 + "radeon", rdev, 621 + hwmon_groups); 622 + if (IS_ERR(rdev->pm.int_hwmon_dev)) { 623 + err = PTR_ERR(rdev->pm.int_hwmon_dev); 623 624 dev_err(rdev->dev, 624 625 "Unable to register hwmon device: %d\n", err); 625 626 } ··· 629 630 } 630 631 631 632 return err; 633 + } 634 + 635 + static void radeon_hwmon_fini(struct radeon_device *rdev) 636 + { 637 + if (rdev->pm.int_hwmon_dev) 638 + hwmon_device_unregister(rdev->pm.int_hwmon_dev); 632 639 } 633 640 634 641 static void radeon_dpm_thermal_work_handler(struct work_struct *work) ··· 1262 1257 case CHIP_RV670: 1263 1258 case CHIP_RS780: 1264 1259 case CHIP_RS880: 1260 + case CHIP_RV770: 1265 1261 case CHIP_BARTS: 1266 1262 case CHIP_TURKS: 1267 1263 case CHIP_CAICOS: ··· 1279 1273 else 1280 1274 rdev->pm.pm_method = PM_METHOD_PROFILE; 1281 1275 break; 1282 - case CHIP_RV770: 1283 1276 case CHIP_RV730: 1284 1277 case CHIP_RV710: 1285 1278 case CHIP_RV740: ··· 1358 1353 device_remove_file(rdev->dev, &dev_attr_power_method); 1359 1354 } 1360 1355 1356 + radeon_hwmon_fini(rdev); 1357 + 1361 1358 if (rdev->pm.power_state) 1362 1359 kfree(rdev->pm.power_state); 1363 1360 } ··· 1378 1371 device_remove_file(rdev->dev, &dev_attr_power_method); 1379 1372 } 1380 1373 radeon_dpm_fini(rdev); 1374 + 1375 + radeon_hwmon_fini(rdev); 1381 1376 1382 1377 if (rdev->pm.power_state) 1383 1378 kfree(rdev->pm.power_state); ··· 1406 1397 1407 1398 rdev->pm.active_crtcs = 0; 1408 1399 rdev->pm.active_crtc_count = 0; 1409 - list_for_each_entry(crtc, 1410 - &ddev->mode_config.crtc_list, head) { 1411 - radeon_crtc = to_radeon_crtc(crtc); 1412 - if (radeon_crtc->enabled) { 1413 - rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id); 1414 - rdev->pm.active_crtc_count++; 1400 + if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { 1401 + list_for_each_entry(crtc, 1402 + &ddev->mode_config.crtc_list, head) { 1403 + radeon_crtc = to_radeon_crtc(crtc); 1404 + if (radeon_crtc->enabled) { 1405 + rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id); 1406 + rdev->pm.active_crtc_count++; 1407 + } 1415 1408 } 1416 1409 } 1417 1410 ··· 1480 1469 /* update active crtc counts */ 1481 1470 rdev->pm.dpm.new_active_crtcs = 0; 1482 1471 rdev->pm.dpm.new_active_crtc_count = 0; 1483 - list_for_each_entry(crtc, 1484 - &ddev->mode_config.crtc_list, head) { 1485 - radeon_crtc = to_radeon_crtc(crtc); 1486 - if (crtc->enabled) { 1487 - rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id); 1488 - rdev->pm.dpm.new_active_crtc_count++; 1472 + if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { 1473 + list_for_each_entry(crtc, 1474 + &ddev->mode_config.crtc_list, head) { 1475 + radeon_crtc = to_radeon_crtc(crtc); 1476 + if (crtc->enabled) { 1477 + rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id); 1478 + rdev->pm.dpm.new_active_crtc_count++; 1479 + } 1489 1480 } 1490 1481 } 1491 1482