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

Merge branch 'drm-next-3.9' of git://people.freedesktop.org/~agd5f/linux into drm-next

More drm-next bits for radeon. Just bug fixes.

* 'drm-next-3.9' of git://people.freedesktop.org/~agd5f/linux:
drm/radeon: properly validate the atpx interface
drm/radeon: switch get_gpu_clock() to a callback (v2)
drm/radeon: add a asic callback to get the xclk
drm/radeon: Avoid NULL pointer dereference from atom_index_iio() allocation failure
drm/radeon: remove overzealous warning in hdmi handling
drm/radeon: fix multi-head power profile stability on BTC+ asics

+212 -19
+7 -2
drivers/gpu/drm/radeon/atom.c
··· 1238 1238 static void atom_index_iio(struct atom_context *ctx, int base) 1239 1239 { 1240 1240 ctx->iio = kzalloc(2 * 256, GFP_KERNEL); 1241 + if (!ctx->iio) 1242 + return; 1241 1243 while (CU8(base) == ATOM_IIO_START) { 1242 1244 ctx->iio[CU8(base + 1)] = base + 2; 1243 1245 base += 2; ··· 1289 1287 ctx->cmd_table = CU16(base + ATOM_ROM_CMD_PTR); 1290 1288 ctx->data_table = CU16(base + ATOM_ROM_DATA_PTR); 1291 1289 atom_index_iio(ctx, CU16(ctx->data_table + ATOM_DATA_IIO_PTR) + 4); 1290 + if (!ctx->iio) { 1291 + atom_destroy(ctx); 1292 + return NULL; 1293 + } 1292 1294 1293 1295 str = CSTR(CU16(base + ATOM_ROM_MSG_PTR)); 1294 1296 while (*str && ((*str == '\n') || (*str == '\r'))) ··· 1341 1335 1342 1336 void atom_destroy(struct atom_context *ctx) 1343 1337 { 1344 - if (ctx->iio) 1345 - kfree(ctx->iio); 1338 + kfree(ctx->iio); 1346 1339 kfree(ctx); 1347 1340 } 1348 1341
+13
drivers/gpu/drm/radeon/evergreen.c
··· 403 403 rdev->pm.current_vddc = voltage->voltage; 404 404 DRM_DEBUG("Setting: vddc: %d\n", voltage->voltage); 405 405 } 406 + 407 + /* starting with BTC, there is one state that is used for both 408 + * MH and SH. Difference is that we always use the high clock index for 409 + * mclk and vddci. 410 + */ 411 + if ((rdev->pm.pm_method == PM_METHOD_PROFILE) && 412 + (rdev->family >= CHIP_BARTS) && 413 + rdev->pm.active_crtc_count && 414 + ((rdev->pm.profile_index == PM_PROFILE_MID_MH_IDX) || 415 + (rdev->pm.profile_index == PM_PROFILE_LOW_MH_IDX))) 416 + voltage = &rdev->pm.power_state[req_ps_idx]. 417 + clock_info[rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx].voltage; 418 + 406 419 /* 0xff01 is a flag rather then an actual voltage */ 407 420 if (voltage->vddci == 0xff01) 408 421 return;
+15 -2
drivers/gpu/drm/radeon/r600.c
··· 109 109 void r600_irq_disable(struct radeon_device *rdev); 110 110 static void r600_pcie_gen2_enable(struct radeon_device *rdev); 111 111 112 + /** 113 + * r600_get_xclk - get the xclk 114 + * 115 + * @rdev: radeon_device pointer 116 + * 117 + * Returns the reference clock used by the gfx engine 118 + * (r6xx, IGPs, APUs). 119 + */ 120 + u32 r600_get_xclk(struct radeon_device *rdev) 121 + { 122 + return rdev->clock.spll.reference_freq; 123 + } 124 + 112 125 /* get temperature in millidegrees */ 113 126 int rv6xx_get_temp(struct radeon_device *rdev) 114 127 { ··· 4461 4448 } 4462 4449 4463 4450 /** 4464 - * r600_get_gpu_clock - return GPU clock counter snapshot 4451 + * r600_get_gpu_clock_counter - return GPU clock counter snapshot 4465 4452 * 4466 4453 * @rdev: radeon_device pointer 4467 4454 * 4468 4455 * Fetches a GPU clock counter snapshot (R6xx-cayman). 4469 4456 * Returns the 64 bit clock counter snapshot. 4470 4457 */ 4471 - uint64_t r600_get_gpu_clock(struct radeon_device *rdev) 4458 + uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev) 4472 4459 { 4473 4460 uint64_t clock; 4474 4461
-1
drivers/gpu/drm/radeon/r600_hdmi.c
··· 544 544 545 545 /* Called for ATOM_ENCODER_MODE_HDMI only */ 546 546 if (!dig || !dig->afmt) { 547 - WARN_ON(1); 548 547 return; 549 548 } 550 549 if (!dig->afmt->enabled)
+6
drivers/gpu/drm/radeon/radeon.h
··· 1178 1178 bool (*gui_idle)(struct radeon_device *rdev); 1179 1179 /* wait for mc_idle */ 1180 1180 int (*mc_wait_for_idle)(struct radeon_device *rdev); 1181 + /* get the reference clock */ 1182 + u32 (*get_xclk)(struct radeon_device *rdev); 1183 + /* get the gpu clock counter */ 1184 + uint64_t (*get_gpu_clock_counter)(struct radeon_device *rdev); 1181 1185 /* gart */ 1182 1186 struct { 1183 1187 void (*tlb_flush)(struct radeon_device *rdev); ··· 1863 1859 #define radeon_post_page_flip(rdev, crtc) (rdev)->asic->pflip.post_page_flip((rdev), (crtc)) 1864 1860 #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc)) 1865 1861 #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev)) 1862 + #define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev)) 1863 + #define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev)) 1866 1864 1867 1865 /* Common functions */ 1868 1866 /* AGP */
+18
drivers/gpu/drm/radeon/radeon_asic.c
··· 934 934 .ioctl_wait_idle = r600_ioctl_wait_idle, 935 935 .gui_idle = &r600_gui_idle, 936 936 .mc_wait_for_idle = &r600_mc_wait_for_idle, 937 + .get_xclk = &r600_get_xclk, 938 + .get_gpu_clock_counter = &r600_get_gpu_clock_counter, 937 939 .gart = { 938 940 .tlb_flush = &r600_pcie_gart_tlb_flush, 939 941 .set_page = &rs600_gart_set_page, ··· 1020 1018 .ioctl_wait_idle = r600_ioctl_wait_idle, 1021 1019 .gui_idle = &r600_gui_idle, 1022 1020 .mc_wait_for_idle = &r600_mc_wait_for_idle, 1021 + .get_xclk = &r600_get_xclk, 1022 + .get_gpu_clock_counter = &r600_get_gpu_clock_counter, 1023 1023 .gart = { 1024 1024 .tlb_flush = &r600_pcie_gart_tlb_flush, 1025 1025 .set_page = &rs600_gart_set_page, ··· 1106 1102 .ioctl_wait_idle = r600_ioctl_wait_idle, 1107 1103 .gui_idle = &r600_gui_idle, 1108 1104 .mc_wait_for_idle = &r600_mc_wait_for_idle, 1105 + .get_xclk = &rv770_get_xclk, 1106 + .get_gpu_clock_counter = &r600_get_gpu_clock_counter, 1109 1107 .gart = { 1110 1108 .tlb_flush = &r600_pcie_gart_tlb_flush, 1111 1109 .set_page = &rs600_gart_set_page, ··· 1192 1186 .ioctl_wait_idle = r600_ioctl_wait_idle, 1193 1187 .gui_idle = &r600_gui_idle, 1194 1188 .mc_wait_for_idle = &evergreen_mc_wait_for_idle, 1189 + .get_xclk = &rv770_get_xclk, 1190 + .get_gpu_clock_counter = &r600_get_gpu_clock_counter, 1195 1191 .gart = { 1196 1192 .tlb_flush = &evergreen_pcie_gart_tlb_flush, 1197 1193 .set_page = &rs600_gart_set_page, ··· 1278 1270 .ioctl_wait_idle = r600_ioctl_wait_idle, 1279 1271 .gui_idle = &r600_gui_idle, 1280 1272 .mc_wait_for_idle = &evergreen_mc_wait_for_idle, 1273 + .get_xclk = &r600_get_xclk, 1274 + .get_gpu_clock_counter = &r600_get_gpu_clock_counter, 1281 1275 .gart = { 1282 1276 .tlb_flush = &evergreen_pcie_gart_tlb_flush, 1283 1277 .set_page = &rs600_gart_set_page, ··· 1364 1354 .ioctl_wait_idle = r600_ioctl_wait_idle, 1365 1355 .gui_idle = &r600_gui_idle, 1366 1356 .mc_wait_for_idle = &evergreen_mc_wait_for_idle, 1357 + .get_xclk = &rv770_get_xclk, 1358 + .get_gpu_clock_counter = &r600_get_gpu_clock_counter, 1367 1359 .gart = { 1368 1360 .tlb_flush = &evergreen_pcie_gart_tlb_flush, 1369 1361 .set_page = &rs600_gart_set_page, ··· 1450 1438 .ioctl_wait_idle = r600_ioctl_wait_idle, 1451 1439 .gui_idle = &r600_gui_idle, 1452 1440 .mc_wait_for_idle = &evergreen_mc_wait_for_idle, 1441 + .get_xclk = &rv770_get_xclk, 1442 + .get_gpu_clock_counter = &r600_get_gpu_clock_counter, 1453 1443 .gart = { 1454 1444 .tlb_flush = &cayman_pcie_gart_tlb_flush, 1455 1445 .set_page = &rs600_gart_set_page, ··· 1579 1565 .ioctl_wait_idle = r600_ioctl_wait_idle, 1580 1566 .gui_idle = &r600_gui_idle, 1581 1567 .mc_wait_for_idle = &evergreen_mc_wait_for_idle, 1568 + .get_xclk = &r600_get_xclk, 1569 + .get_gpu_clock_counter = &r600_get_gpu_clock_counter, 1582 1570 .gart = { 1583 1571 .tlb_flush = &cayman_pcie_gart_tlb_flush, 1584 1572 .set_page = &rs600_gart_set_page, ··· 1708 1692 .ioctl_wait_idle = r600_ioctl_wait_idle, 1709 1693 .gui_idle = &r600_gui_idle, 1710 1694 .mc_wait_for_idle = &evergreen_mc_wait_for_idle, 1695 + .get_xclk = &si_get_xclk, 1696 + .get_gpu_clock_counter = &si_get_gpu_clock_counter, 1711 1697 .gart = { 1712 1698 .tlb_flush = &si_pcie_gart_tlb_flush, 1713 1699 .set_page = &rs600_gart_set_page,
+5 -2
drivers/gpu/drm/radeon/radeon_asic.h
··· 389 389 unsigned num_gpu_pages, 390 390 struct radeon_sa_bo *vb); 391 391 int r600_mc_wait_for_idle(struct radeon_device *rdev); 392 - uint64_t r600_get_gpu_clock(struct radeon_device *rdev); 392 + u32 r600_get_xclk(struct radeon_device *rdev); 393 + uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev); 393 394 394 395 /* 395 396 * rv770,rv730,rv710,rv740 ··· 408 407 uint64_t src_offset, uint64_t dst_offset, 409 408 unsigned num_gpu_pages, 410 409 struct radeon_fence **fence); 410 + u32 rv770_get_xclk(struct radeon_device *rdev); 411 411 412 412 /* 413 413 * evergreen ··· 517 515 uint32_t incr, uint32_t flags); 518 516 void si_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); 519 517 int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib); 520 - uint64_t si_get_gpu_clock(struct radeon_device *rdev); 521 518 int si_copy_dma(struct radeon_device *rdev, 522 519 uint64_t src_offset, uint64_t dst_offset, 523 520 unsigned num_gpu_pages, 524 521 struct radeon_fence **fence); 525 522 void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); 523 + u32 si_get_xclk(struct radeon_device *rdev); 524 + uint64_t si_get_gpu_clock_counter(struct radeon_device *rdev); 526 525 527 526 #endif
+71 -2
drivers/gpu/drm/radeon/radeon_atpx_handler.c
··· 43 43 u32 function_bits; /* supported functions bit vector */ 44 44 } __packed; 45 45 46 + struct atpx_px_params { 47 + u16 size; /* structure size in bytes (includes size field) */ 48 + u32 valid_flags; /* which flags are valid */ 49 + u32 flags; /* flags */ 50 + } __packed; 51 + 46 52 struct atpx_power_control { 47 53 u16 size; 48 54 u8 dgpu_state; ··· 129 123 } 130 124 131 125 /** 126 + * radeon_atpx_validate_functions - validate ATPX functions 127 + * 128 + * @atpx: radeon atpx struct 129 + * 130 + * Validate that required functions are enabled (all asics). 131 + * returns 0 on success, error on failure. 132 + */ 133 + static int radeon_atpx_validate(struct radeon_atpx *atpx) 134 + { 135 + /* make sure required functions are enabled */ 136 + /* dGPU power control is required */ 137 + atpx->functions.power_cntl = true; 138 + 139 + if (atpx->functions.px_params) { 140 + union acpi_object *info; 141 + struct atpx_px_params output; 142 + size_t size; 143 + u32 valid_bits; 144 + 145 + info = radeon_atpx_call(atpx->handle, ATPX_FUNCTION_GET_PX_PARAMETERS, NULL); 146 + if (!info) 147 + return -EIO; 148 + 149 + memset(&output, 0, sizeof(output)); 150 + 151 + size = *(u16 *) info->buffer.pointer; 152 + if (size < 10) { 153 + printk("ATPX buffer is too small: %zu\n", size); 154 + kfree(info); 155 + return -EINVAL; 156 + } 157 + size = min(sizeof(output), size); 158 + 159 + memcpy(&output, info->buffer.pointer, size); 160 + 161 + valid_bits = output.flags & output.valid_flags; 162 + /* if separate mux flag is set, mux controls are required */ 163 + if (valid_bits & ATPX_SEPARATE_MUX_FOR_I2C) { 164 + atpx->functions.i2c_mux_cntl = true; 165 + atpx->functions.disp_mux_cntl = true; 166 + } 167 + /* if any outputs are muxed, mux controls are required */ 168 + if (valid_bits & (ATPX_CRT1_RGB_SIGNAL_MUXED | 169 + ATPX_TV_SIGNAL_MUXED | 170 + ATPX_DFP_SIGNAL_MUXED)) 171 + atpx->functions.disp_mux_cntl = true; 172 + 173 + kfree(info); 174 + } 175 + return 0; 176 + } 177 + 178 + /** 132 179 * radeon_atpx_verify_interface - verify ATPX 133 180 * 134 - * @handle: acpi handle 135 181 * @atpx: radeon atpx struct 136 182 * 137 183 * Execute the ATPX_FUNCTION_VERIFY_INTERFACE ATPX function ··· 464 406 */ 465 407 static int radeon_atpx_init(void) 466 408 { 409 + int r; 410 + 467 411 /* set up the ATPX handle */ 468 - return radeon_atpx_verify_interface(&radeon_atpx_priv.atpx); 412 + r = radeon_atpx_verify_interface(&radeon_atpx_priv.atpx); 413 + if (r) 414 + return r; 415 + 416 + /* validate the atpx setup */ 417 + r = radeon_atpx_validate(&radeon_atpx_priv.atpx); 418 + if (r) 419 + return r; 420 + 421 + return 0; 469 422 } 470 423 471 424 /**
+8 -1
drivers/gpu/drm/radeon/radeon_device.c
··· 759 759 atom_card_info->pll_write = cail_pll_write; 760 760 761 761 rdev->mode_info.atom_context = atom_parse(atom_card_info, rdev->bios); 762 + if (!rdev->mode_info.atom_context) { 763 + radeon_atombios_fini(rdev); 764 + return -ENOMEM; 765 + } 766 + 762 767 mutex_init(&rdev->mode_info.atom_context->mutex); 763 768 radeon_atom_initialize_bios_scratch_regs(rdev->ddev); 764 769 atom_allocate_fb_scratch(rdev->mode_info.atom_context); ··· 783 778 { 784 779 if (rdev->mode_info.atom_context) { 785 780 kfree(rdev->mode_info.atom_context->scratch); 786 - kfree(rdev->mode_info.atom_context); 787 781 } 782 + kfree(rdev->mode_info.atom_context); 783 + rdev->mode_info.atom_context = NULL; 788 784 kfree(rdev->mode_info.atom_card_info); 785 + rdev->mode_info.atom_card_info = NULL; 789 786 } 790 787 791 788 /* COMBIOS */
+5 -6
drivers/gpu/drm/radeon/radeon_kms.c
··· 185 185 if (info->request == RADEON_INFO_TIMESTAMP) { 186 186 if (rdev->family >= CHIP_R600) { 187 187 value_ptr64 = (uint64_t*)((unsigned long)info->value); 188 - if (rdev->family >= CHIP_TAHITI) { 189 - value64 = si_get_gpu_clock(rdev); 190 - } else { 191 - value64 = r600_get_gpu_clock(rdev); 192 - } 188 + value64 = radeon_get_gpu_clock_counter(rdev); 193 189 194 190 if (DRM_COPY_TO_USER(value_ptr64, &value64, sizeof(value64))) { 195 191 DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); ··· 278 282 break; 279 283 case RADEON_INFO_CLOCK_CRYSTAL_FREQ: 280 284 /* return clock value in KHz */ 281 - value = rdev->clock.spll.reference_freq * 10; 285 + if (rdev->asic->get_xclk) 286 + value = radeon_get_xclk(rdev) * 10; 287 + else 288 + value = rdev->clock.spll.reference_freq * 10; 282 289 break; 283 290 case RADEON_INFO_NUM_BACKENDS: 284 291 if (rdev->family >= CHIP_TAHITI)
+1 -1
drivers/gpu/drm/radeon/radeon_pm.c
··· 169 169 170 170 /* starting with BTC, there is one state that is used for both 171 171 * MH and SH. Difference is that we always use the high clock index for 172 - * mclk. 172 + * mclk and vddci. 173 173 */ 174 174 if ((rdev->pm.pm_method == PM_METHOD_PROFILE) && 175 175 (rdev->family >= CHIP_BARTS) &&
+25
drivers/gpu/drm/radeon/rv770.c
··· 43 43 void rv770_fini(struct radeon_device *rdev); 44 44 static void rv770_pcie_gen2_enable(struct radeon_device *rdev); 45 45 46 + #define PCIE_BUS_CLK 10000 47 + #define TCLK (PCIE_BUS_CLK / 10) 48 + 49 + /** 50 + * rv770_get_xclk - get the xclk 51 + * 52 + * @rdev: radeon_device pointer 53 + * 54 + * Returns the reference clock used by the gfx engine 55 + * (r7xx-cayman). 56 + */ 57 + u32 rv770_get_xclk(struct radeon_device *rdev) 58 + { 59 + u32 reference_clock = rdev->clock.spll.reference_freq; 60 + u32 tmp = RREG32(CG_CLKPIN_CNTL); 61 + 62 + if (tmp & MUX_TCLK_TO_XCLK) 63 + return TCLK; 64 + 65 + if (tmp & XTALIN_DIVIDE) 66 + return reference_clock / 4; 67 + 68 + return reference_clock; 69 + } 70 + 46 71 u32 rv770_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base) 47 72 { 48 73 struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
+4
drivers/gpu/drm/radeon/rv770d.h
··· 128 128 #define GUI_ACTIVE (1<<31) 129 129 #define GRBM_STATUS2 0x8014 130 130 131 + #define CG_CLKPIN_CNTL 0x660 132 + # define MUX_TCLK_TO_XCLK (1 << 8) 133 + # define XTALIN_DIVIDE (1 << 9) 134 + 131 135 #define CG_MULT_THERMAL_STATUS 0x740 132 136 #define ASIC_T(x) ((x) << 16) 133 137 #define ASIC_T_MASK 0x3FF0000
+29 -2
drivers/gpu/drm/radeon/si.c
··· 70 70 extern void evergreen_print_gpu_status_regs(struct radeon_device *rdev); 71 71 extern bool evergreen_is_display_hung(struct radeon_device *rdev); 72 72 73 + #define PCIE_BUS_CLK 10000 74 + #define TCLK (PCIE_BUS_CLK / 10) 75 + 76 + /** 77 + * si_get_xclk - get the xclk 78 + * 79 + * @rdev: radeon_device pointer 80 + * 81 + * Returns the reference clock used by the gfx engine 82 + * (SI). 83 + */ 84 + u32 si_get_xclk(struct radeon_device *rdev) 85 + { 86 + u32 reference_clock = rdev->clock.spll.reference_freq; 87 + u32 tmp; 88 + 89 + tmp = RREG32(CG_CLKPIN_CNTL_2); 90 + if (tmp & MUX_TCLK_TO_XCLK) 91 + return TCLK; 92 + 93 + tmp = RREG32(CG_CLKPIN_CNTL); 94 + if (tmp & XTALIN_DIVIDE) 95 + return reference_clock / 4; 96 + 97 + return reference_clock; 98 + } 99 + 73 100 /* get temperature in millidegrees */ 74 101 int si_get_temp(struct radeon_device *rdev) 75 102 { ··· 4609 4582 } 4610 4583 4611 4584 /** 4612 - * si_get_gpu_clock - return GPU clock counter snapshot 4585 + * si_get_gpu_clock_counter - return GPU clock counter snapshot 4613 4586 * 4614 4587 * @rdev: radeon_device pointer 4615 4588 * 4616 4589 * Fetches a GPU clock counter snapshot (SI). 4617 4590 * Returns the 64 bit clock counter snapshot. 4618 4591 */ 4619 - uint64_t si_get_gpu_clock(struct radeon_device *rdev) 4592 + uint64_t si_get_gpu_clock_counter(struct radeon_device *rdev) 4620 4593 { 4621 4594 uint64_t clock; 4622 4595
+5
drivers/gpu/drm/radeon/sid.h
··· 58 58 #define VGA_HDP_CONTROL 0x328 59 59 #define VGA_MEMORY_DISABLE (1 << 4) 60 60 61 + #define CG_CLKPIN_CNTL 0x660 62 + # define XTALIN_DIVIDE (1 << 1) 63 + #define CG_CLKPIN_CNTL_2 0x664 64 + # define MUX_TCLK_TO_XCLK (1 << 8) 65 + 61 66 #define DMIF_ADDR_CONFIG 0xBD4 62 67 63 68 #define SRBM_STATUS 0xE50