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

Merge tag 'amd-drm-fixes-6.4-2023-05-11' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes

amdgpu:
- VCN3 fixes
- APUs always support PCI atomics
- Legacy power management fixes
- DCN 3.1.4 fix
- DCFCLK fix
- Fix several RAS irq refcount mismatches
- GPU Reset fix
- GFX 11.0.4 fix

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230511141755.7896-1-alexander.deucher@amd.com

+131 -71
+11 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 3757 3757 adev->have_atomics_support = ((struct amd_sriov_msg_pf2vf_info *) 3758 3758 adev->virt.fw_reserve.p_pf2vf)->pcie_atomic_ops_support_flags == 3759 3759 (PCI_EXP_DEVCAP2_ATOMIC_COMP32 | PCI_EXP_DEVCAP2_ATOMIC_COMP64); 3760 + /* APUs w/ gfx9 onwards doesn't reply on PCIe atomics, rather it is a 3761 + * internal path natively support atomics, set have_atomics_support to true. 3762 + */ 3763 + else if ((adev->flags & AMD_IS_APU) && 3764 + (adev->ip_versions[GC_HWIP][0] > IP_VERSION(9, 0, 0))) 3765 + adev->have_atomics_support = true; 3760 3766 else 3761 3767 adev->have_atomics_support = 3762 3768 !pci_enable_atomic_ops_to_root(adev->pdev, ··· 4512 4506 dev_info(adev->dev, "recover vram bo from shadow start\n"); 4513 4507 mutex_lock(&adev->shadow_list_lock); 4514 4508 list_for_each_entry(vmbo, &adev->shadow_list, shadow_list) { 4515 - shadow = &vmbo->bo; 4509 + /* If vm is compute context or adev is APU, shadow will be NULL */ 4510 + if (!vmbo->shadow) 4511 + continue; 4512 + shadow = vmbo->shadow; 4513 + 4516 4514 /* No need to recover an evicted BO */ 4517 4515 if (shadow->tbo.resource->mem_type != TTM_PL_TT || 4518 4516 shadow->tbo.resource->start == AMDGPU_BO_INVALID_OFFSET ||
+5 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
··· 687 687 if (r) 688 688 return r; 689 689 690 - r = amdgpu_irq_get(adev, &adev->gfx.cp_ecc_error_irq, 0); 691 - if (r) 692 - goto late_fini; 690 + if (adev->gfx.cp_ecc_error_irq.funcs) { 691 + r = amdgpu_irq_get(adev, &adev->gfx.cp_ecc_error_irq, 0); 692 + if (r) 693 + goto late_fini; 694 + } 693 695 } else { 694 696 amdgpu_ras_feature_enable_on_boot(adev, ras_block, 0); 695 697 }
-46
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
··· 1315 1315 if (r) 1316 1316 return r; 1317 1317 1318 - /* ECC error */ 1319 - r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP, 1320 - GFX_11_0_0__SRCID__CP_ECC_ERROR, 1321 - &adev->gfx.cp_ecc_error_irq); 1322 - if (r) 1323 - return r; 1324 - 1325 1318 /* FED error */ 1326 1319 r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX, 1327 1320 GFX_11_0_0__SRCID__RLC_GC_FED_INTERRUPT, ··· 4437 4444 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 4438 4445 int r; 4439 4446 4440 - amdgpu_irq_put(adev, &adev->gfx.cp_ecc_error_irq, 0); 4441 4447 amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0); 4442 4448 amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0); 4443 4449 ··· 5889 5897 } 5890 5898 } 5891 5899 5892 - #define CP_ME1_PIPE_INST_ADDR_INTERVAL 0x1 5893 - #define SET_ECC_ME_PIPE_STATE(reg_addr, state) \ 5894 - do { \ 5895 - uint32_t tmp = RREG32_SOC15_IP(GC, reg_addr); \ 5896 - tmp = REG_SET_FIELD(tmp, CP_ME1_PIPE0_INT_CNTL, CP_ECC_ERROR_INT_ENABLE, state); \ 5897 - WREG32_SOC15_IP(GC, reg_addr, tmp); \ 5898 - } while (0) 5899 - 5900 - static int gfx_v11_0_set_cp_ecc_error_state(struct amdgpu_device *adev, 5901 - struct amdgpu_irq_src *source, 5902 - unsigned type, 5903 - enum amdgpu_interrupt_state state) 5904 - { 5905 - uint32_t ecc_irq_state = 0; 5906 - uint32_t pipe0_int_cntl_addr = 0; 5907 - int i = 0; 5908 - 5909 - ecc_irq_state = (state == AMDGPU_IRQ_STATE_ENABLE) ? 1 : 0; 5910 - 5911 - pipe0_int_cntl_addr = SOC15_REG_OFFSET(GC, 0, regCP_ME1_PIPE0_INT_CNTL); 5912 - 5913 - WREG32_FIELD15_PREREG(GC, 0, CP_INT_CNTL_RING0, CP_ECC_ERROR_INT_ENABLE, ecc_irq_state); 5914 - 5915 - for (i = 0; i < adev->gfx.mec.num_pipe_per_mec; i++) 5916 - SET_ECC_ME_PIPE_STATE(pipe0_int_cntl_addr + i * CP_ME1_PIPE_INST_ADDR_INTERVAL, 5917 - ecc_irq_state); 5918 - 5919 - return 0; 5920 - } 5921 - 5922 5900 static int gfx_v11_0_set_eop_interrupt_state(struct amdgpu_device *adev, 5923 5901 struct amdgpu_irq_src *src, 5924 5902 unsigned type, ··· 6303 6341 .process = gfx_v11_0_priv_inst_irq, 6304 6342 }; 6305 6343 6306 - static const struct amdgpu_irq_src_funcs gfx_v11_0_cp_ecc_error_irq_funcs = { 6307 - .set = gfx_v11_0_set_cp_ecc_error_state, 6308 - .process = amdgpu_gfx_cp_ecc_error_irq, 6309 - }; 6310 - 6311 6344 static const struct amdgpu_irq_src_funcs gfx_v11_0_rlc_gc_fed_irq_funcs = { 6312 6345 .process = gfx_v11_0_rlc_gc_fed_irq, 6313 6346 }; ··· 6317 6360 6318 6361 adev->gfx.priv_inst_irq.num_types = 1; 6319 6362 adev->gfx.priv_inst_irq.funcs = &gfx_v11_0_priv_inst_irq_funcs; 6320 - 6321 - adev->gfx.cp_ecc_error_irq.num_types = 1; /* CP ECC error */ 6322 - adev->gfx.cp_ecc_error_irq.funcs = &gfx_v11_0_cp_ecc_error_irq_funcs; 6323 6363 6324 6364 adev->gfx.rlc_gc_fed_irq.num_types = 1; /* 0x80 FED error */ 6325 6365 adev->gfx.rlc_gc_fed_irq.funcs = &gfx_v11_0_rlc_gc_fed_irq_funcs;
+2 -1
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
··· 3764 3764 { 3765 3765 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 3766 3766 3767 - amdgpu_irq_put(adev, &adev->gfx.cp_ecc_error_irq, 0); 3767 + if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__GFX)) 3768 + amdgpu_irq_put(adev, &adev->gfx.cp_ecc_error_irq, 0); 3768 3769 amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0); 3769 3770 amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0); 3770 3771
+1
drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
··· 54 54 55 55 switch (adev->ip_versions[UVD_HWIP][0]) { 56 56 case IP_VERSION(3, 1, 1): 57 + case IP_VERSION(3, 1, 2): 57 58 break; 58 59 default: 59 60 harvest = RREG32_SOC15(JPEG, 0, mmCC_UVD_HARVESTING);
+16 -6
drivers/gpu/drm/amd/amdgpu/nv.c
··· 98 98 }; 99 99 100 100 /* Sienna Cichlid */ 101 + static const struct amdgpu_video_codec_info sc_video_codecs_encode_array[] = { 102 + {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC, 4096, 2160, 0)}, 103 + {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC, 7680, 4352, 0)}, 104 + }; 105 + 106 + static const struct amdgpu_video_codecs sc_video_codecs_encode = { 107 + .codec_count = ARRAY_SIZE(sc_video_codecs_encode_array), 108 + .codec_array = sc_video_codecs_encode_array, 109 + }; 110 + 101 111 static const struct amdgpu_video_codec_info sc_video_codecs_decode_array_vcn0[] = 102 112 { 103 113 {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2, 4096, 4096, 3)}, ··· 146 136 /* SRIOV Sienna Cichlid, not const since data is controlled by host */ 147 137 static struct amdgpu_video_codec_info sriov_sc_video_codecs_encode_array[] = 148 138 { 149 - {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC, 4096, 2304, 0)}, 150 - {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC, 4096, 2304, 0)}, 139 + {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC, 4096, 2160, 0)}, 140 + {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC, 7680, 4352, 0)}, 151 141 }; 152 142 153 143 static struct amdgpu_video_codec_info sriov_sc_video_codecs_decode_array_vcn0[] = ··· 247 237 } else { 248 238 if (adev->vcn.harvest_config & AMDGPU_VCN_HARVEST_VCN0) { 249 239 if (encode) 250 - *codecs = &nv_video_codecs_encode; 240 + *codecs = &sc_video_codecs_encode; 251 241 else 252 242 *codecs = &sc_video_codecs_decode_vcn1; 253 243 } else { 254 244 if (encode) 255 - *codecs = &nv_video_codecs_encode; 245 + *codecs = &sc_video_codecs_encode; 256 246 else 257 247 *codecs = &sc_video_codecs_decode_vcn0; 258 248 } ··· 261 251 case IP_VERSION(3, 0, 16): 262 252 case IP_VERSION(3, 0, 2): 263 253 if (encode) 264 - *codecs = &nv_video_codecs_encode; 254 + *codecs = &sc_video_codecs_encode; 265 255 else 266 256 *codecs = &sc_video_codecs_decode_vcn0; 267 257 return 0; 268 258 case IP_VERSION(3, 1, 1): 269 259 case IP_VERSION(3, 1, 2): 270 260 if (encode) 271 - *codecs = &nv_video_codecs_encode; 261 + *codecs = &sc_video_codecs_encode; 272 262 else 273 263 *codecs = &yc_video_codecs_decode; 274 264 return 0;
+5 -3
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
··· 1917 1917 return 0; 1918 1918 } 1919 1919 1920 - for (i = 0; i < adev->sdma.num_instances; i++) { 1921 - amdgpu_irq_put(adev, &adev->sdma.ecc_irq, 1922 - AMDGPU_SDMA_IRQ_INSTANCE0 + i); 1920 + if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__SDMA)) { 1921 + for (i = 0; i < adev->sdma.num_instances; i++) { 1922 + amdgpu_irq_put(adev, &adev->sdma.ecc_irq, 1923 + AMDGPU_SDMA_IRQ_INSTANCE0 + i); 1924 + } 1923 1925 } 1924 1926 1925 1927 sdma_v4_0_ctx_switch_enable(adev, false);
+1 -1
drivers/gpu/drm/amd/amdgpu/soc21.c
··· 711 711 AMD_PG_SUPPORT_VCN_DPG | 712 712 AMD_PG_SUPPORT_GFX_PG | 713 713 AMD_PG_SUPPORT_JPEG; 714 - adev->external_rev_id = adev->rev_id + 0x1; 714 + adev->external_rev_id = adev->rev_id + 0x80; 715 715 break; 716 716 717 717 default:
+65
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_hwseq.c
··· 423 423 424 424 PERF_TRACE(); 425 425 } 426 + static void apply_symclk_on_tx_off_wa(struct dc_link *link) 427 + { 428 + /* There are use cases where SYMCLK is referenced by OTG. For instance 429 + * for TMDS signal, OTG relies SYMCLK even if TX video output is off. 430 + * However current link interface will power off PHY when disabling link 431 + * output. This will turn off SYMCLK generated by PHY. The workaround is 432 + * to identify such case where SYMCLK is still in use by OTG when we 433 + * power off PHY. When this is detected, we will temporarily power PHY 434 + * back on and move PHY's SYMCLK state to SYMCLK_ON_TX_OFF by calling 435 + * program_pix_clk interface. When OTG is disabled, we will then power 436 + * off PHY by calling disable link output again. 437 + * 438 + * In future dcn generations, we plan to rework transmitter control 439 + * interface so that we could have an option to set SYMCLK ON TX OFF 440 + * state in one step without this workaround 441 + */ 442 + 443 + struct dc *dc = link->ctx->dc; 444 + struct pipe_ctx *pipe_ctx = NULL; 445 + uint8_t i; 446 + 447 + if (link->phy_state.symclk_ref_cnts.otg > 0) { 448 + for (i = 0; i < MAX_PIPES; i++) { 449 + pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i]; 450 + if (pipe_ctx->stream && pipe_ctx->stream->link == link && pipe_ctx->top_pipe == NULL) { 451 + pipe_ctx->clock_source->funcs->program_pix_clk( 452 + pipe_ctx->clock_source, 453 + &pipe_ctx->stream_res.pix_clk_params, 454 + dc->link_srv->dp_get_encoding_format( 455 + &pipe_ctx->link_config.dp_link_settings), 456 + &pipe_ctx->pll_settings); 457 + link->phy_state.symclk_state = SYMCLK_ON_TX_OFF; 458 + break; 459 + } 460 + } 461 + } 462 + } 463 + 464 + void dcn314_disable_link_output(struct dc_link *link, 465 + const struct link_resource *link_res, 466 + enum signal_type signal) 467 + { 468 + struct dc *dc = link->ctx->dc; 469 + const struct link_hwss *link_hwss = get_link_hwss(link, link_res); 470 + struct dmcu *dmcu = dc->res_pool->dmcu; 471 + 472 + if (signal == SIGNAL_TYPE_EDP && 473 + link->dc->hwss.edp_backlight_control) 474 + link->dc->hwss.edp_backlight_control(link, false); 475 + else if (dmcu != NULL && dmcu->funcs->lock_phy) 476 + dmcu->funcs->lock_phy(dmcu); 477 + 478 + link_hwss->disable_link_output(link, link_res, signal); 479 + link->phy_state.symclk_state = SYMCLK_OFF_TX_OFF; 480 + /* 481 + * Add the logic to extract BOTH power up and power down sequences 482 + * from enable/disable link output and only call edp panel control 483 + * in enable_link_dp and disable_link_dp once. 484 + */ 485 + if (dmcu != NULL && dmcu->funcs->lock_phy) 486 + dmcu->funcs->unlock_phy(dmcu); 487 + dc->link_srv->dp_trace_source_sequence(link, DPCD_SOURCE_SEQ_AFTER_DISABLE_LINK_PHY); 488 + 489 + apply_symclk_on_tx_off_wa(link); 490 + }
+2
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_hwseq.h
··· 45 45 46 46 void dcn314_dpp_root_clock_control(struct dce_hwseq *hws, unsigned int dpp_inst, bool clock_on); 47 47 48 + void dcn314_disable_link_output(struct dc_link *link, const struct link_resource *link_res, enum signal_type signal); 49 + 48 50 #endif /* __DC_HWSS_DCN314_H__ */
+1 -1
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_init.c
··· 105 105 .enable_lvds_link_output = dce110_enable_lvds_link_output, 106 106 .enable_tmds_link_output = dce110_enable_tmds_link_output, 107 107 .enable_dp_link_output = dce110_enable_dp_link_output, 108 - .disable_link_output = dce110_disable_link_output, 108 + .disable_link_output = dcn314_disable_link_output, 109 109 .z10_restore = dcn31_z10_restore, 110 110 .z10_save_init = dcn31_z10_save_init, 111 111 .set_disp_pattern_generator = dcn30_set_disp_pattern_generator,
+3 -2
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c
··· 810 810 v->SwathHeightY[k], 811 811 v->SwathHeightC[k], 812 812 TWait, 813 - v->DRAMSpeedPerState[mode_lib->vba.VoltageLevel] <= MEM_STROBE_FREQ_MHZ ? 813 + (v->DRAMSpeedPerState[mode_lib->vba.VoltageLevel] <= MEM_STROBE_FREQ_MHZ || 814 + v->DCFCLKPerState[mode_lib->vba.VoltageLevel] <= MIN_DCFCLK_FREQ_MHZ) ? 814 815 mode_lib->vba.ip.min_prefetch_in_strobe_us : 0, 815 816 /* Output */ 816 817 &v->DSTXAfterScaler[k], ··· 3311 3310 v->swath_width_chroma_ub_this_state[k], 3312 3311 v->SwathHeightYThisState[k], 3313 3312 v->SwathHeightCThisState[k], v->TWait, 3314 - v->DRAMSpeedPerState[i] <= MEM_STROBE_FREQ_MHZ ? 3313 + (v->DRAMSpeedPerState[i] <= MEM_STROBE_FREQ_MHZ || v->DCFCLKState[i][j] <= MIN_DCFCLK_FREQ_MHZ) ? 3315 3314 mode_lib->vba.ip.min_prefetch_in_strobe_us : 0, 3316 3315 3317 3316 /* Output */
+1
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.h
··· 53 53 #define BPP_BLENDED_PIPE 0xffffffff 54 54 55 55 #define MEM_STROBE_FREQ_MHZ 1600 56 + #define MIN_DCFCLK_FREQ_MHZ 200 56 57 #define MEM_STROBE_MAX_DELIVERY_TIME_US 60.0 57 58 58 59 struct display_mode_lib;
+18 -7
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
··· 36 36 #define amdgpu_dpm_enable_bapm(adev, e) \ 37 37 ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e))) 38 38 39 + #define amdgpu_dpm_is_legacy_dpm(adev) ((adev)->powerplay.pp_handle == (adev)) 40 + 39 41 int amdgpu_dpm_get_sclk(struct amdgpu_device *adev, bool low) 40 42 { 41 43 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; ··· 1462 1460 1463 1461 int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev) 1464 1462 { 1465 - struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; 1466 - struct smu_context *smu = adev->powerplay.pp_handle; 1463 + if (is_support_sw_smu(adev)) { 1464 + struct smu_context *smu = adev->powerplay.pp_handle; 1467 1465 1468 - if ((is_support_sw_smu(adev) && smu->od_enabled) || 1469 - (is_support_sw_smu(adev) && smu->is_apu) || 1470 - (!is_support_sw_smu(adev) && hwmgr->od_enabled)) 1471 - return true; 1466 + return (smu->od_enabled || smu->is_apu); 1467 + } else { 1468 + struct pp_hwmgr *hwmgr; 1472 1469 1473 - return false; 1470 + /* 1471 + * dpm on some legacy asics don't carry od_enabled member 1472 + * as its pp_handle is casted directly from adev. 1473 + */ 1474 + if (amdgpu_dpm_is_legacy_dpm(adev)) 1475 + return false; 1476 + 1477 + hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle; 1478 + 1479 + return hwmgr->od_enabled; 1480 + } 1474 1481 } 1475 1482 1476 1483 int amdgpu_dpm_set_pp_table(struct amdgpu_device *adev,