linux-next: manual merge of the amdgpu tree with the drm tree
Mark Brown
maintainerHi all,
Today's linux-next merge of the amdgpu tree got conflicts in:
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
between commits:
6d8e709912753 ("drm/amd: Select the firmware signing scheme the PSP reports") 4da6437456f0c ("drm/amdgpu: keep the commit padding when re-emitting submissions") 1ff6e3264ea63 ("drm/amdgpu: fix cleared PDE/PTE flag generation") 851fb23c38be5 ("drm/amdgpu/gfx9: deactivate all compute HQDs before MODE2 on APUs") fff46a322847a ("drm/amd/display: Keep FreeSync flip timing across plane resets") 988ab04d773ac ("drm/amd/display: Add the AUX backlight minimum once on the custom curve")
from the drm tree and commits:
5f95ef2cfd208 ("drm/amd/display: Add the AUX backlight minimum once on the custom curve") 127b26805f62d ("drm/amd/display: Pass linear brightness percent to power module") 4acf82d2a2dcc ("drm/amd/display: Keep FreeSync flip timing across plane resets") e2830fb628915 ("drm/amd/display: Test FreeSync flip timing across plane resets") 09a756064844b ("drm/amd/display: Leave self-refresh before an ABM level update") af33373b09502 ("drm/amdgpu/gfx9: deactivate all compute HQDs before MODE2 on APUs") 20f26c255b826 ("drm/amdgpu/gfx9: deactivate the KIQ before MODE2 on APUs") 6250a83427847 ("drm/amdgpu: fix cleared PDE/PTE flag generation") 3f0d9a1209142 ("drm/amdgpu: keep the address of cleared PDEs with translate further") 4d5b42281bf89 ("drm/amdgpu: keep the commit padding when re-emitting submissions") b9347fa729b64 ("Revert "drm/amdgpu: reemit RLC SPM register in ring reemit"") 2fe41c5fb704e ("drm/amd: Select the firmware signing scheme the PSP reports") ea17a494b1311 ("drm/amdgpu: move tmz init into early_init()")
from the amdgpu tree.
I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@@ -81,6 -81,7 +81,7 @@@#include "amdgpu_reset.h" #include "amdgpu_virt.h" #include "amdgpu_dev_coredump.h" +#include "amdgpu_trap.h" #include <linux/suspend.h> #include <drm/task_barrier.h> break; } + if (amdgpu_is_spm_passthrough(adev)) { +r = amdgpu_psp_disable_fb_carveout(adev); +if (r) +return r; +} +/* Check for IP version 9.4.3 with A0 hardware */ if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) && !amdgpu_device_get_rev_id (adev)) {if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP )amdgpu_psp_init_fw_variant (adev); +/* Enable TMZ based on IP_VERSION */ +amdgpu_gmc_tmz_set (adev); + total = true;for (i =0 ; i < adev->num_ip_blocks; i++) { ip_block = &adev->ip_blocks[i];if (amdgpu_ip_member_of_hwini (adev,AMD_IP_BLOCK_TYPE_SDMA ))amdgpu_ttm_enable_buffer_funcs (adev); +/* KFD init flushes the GART TLB through SDMA on Navi 1x and waits +* for it, so the fence interrupts must already be enabled. +*/ +amdgpu_fence_driver_hw_init (adev); +/* Don't init kfd if whole hive need to be reset during init */ if (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) {amdgpu_amdkfd_device_init (adev);amdgpu_fru_get_product_info (adev); r =amdgpu_cper_init (adev); +if (r) + goto init_failed; + + r =amdgpu_trap_init (adev); +if (r == -EOPNOTSUPP ) + r =0 ; +else if (r) + goto init_failed; init_failed: {int i, r; +amdgpu_trap_fini (adev);amdgpu_cper_fini (adev);if (amdgpu_sriov_vf (adev) && adev->virt.ras_init_done) * Check if there is DC (new modesetting infrastructre) support for an asic. * returns true if DC has support, false if not. */ - bool amdgpu_device_asic_has_dc_support(struct pci_dev *pdev, - enum amd_asic_type asic_type) + static bool amdgpu_device_asic_has_dc_support(struct pci_dev *pdev, + enum amd_asic_type asic_type) { switch (asic_type) { #ifdef CONFIG_DRM_AMDGPU_SI case CHIP_PITCAIRN: case CHIP_VERDE: case CHIP_OLAND: - return amdgpu_dc != 0 && IS_ENABLED(CONFIG_DRM_AMD_DC_SI); + if (!IS_ENABLED(CONFIG_DRM_AMD_DC_SI)) + dev_warn_once(&pdev->dev, + "Driver built without SI display support!\n"); +return IS_ENABLED (CONFIG_DRM_AMD_DC_SI ); +case CHIP_BONAIRE : +case CHIP_KAVERI : +case CHIP_KABINI : +case CHIP_HAWAII : +case CHIP_MULLINS : +case CHIP_TONGA : +case CHIP_FIJI : +case CHIP_CARRIZO : +case CHIP_STONEY : +case CHIP_POLARIS10 : +case CHIP_POLARIS11 : +case CHIP_POLARIS12 : +case CHIP_VEGAM : +case CHIP_VEGA10 : +case CHIP_VEGA12 : +case CHIP_VEGA20 : +if (!IS_ENABLED (CONFIG_DRM_AMD_DC_DCE )) +dev_warn_once (&pdev->dev, +"Driver built without DCE display support!\n" ); +return IS_ENABLED (CONFIG_DRM_AMD_DC_DCE );default : -return amdgpu_dc !=0 ; +return true;#else default : -if (amdgpu_dc >0 ) -dev_info_once ( - &pdev->dev, -"Display Core has been requested via kernel parameter but isn't supported by ASIC, ignoring\n" ); +dev_info_once (&pdev->dev, +"Driver built without display support\n" );return false;#endif }return r; } -/* Enable TMZ based on IP_VERSION */ -amdgpu_gmc_tmz_set (adev); -if (amdgpu_sriov_vf (adev) &&amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (10 ,3 ,0 ))/* VF MMIO access (except mailbox range) from CPU goto release_ras_con; } - amdgpu_fence_driver_hw_init(adev); -dev_info(adev->dev, "SE %d, SH per SE %d, CU per SH %d, active_cu_number %d\n", adev->gfx.config.max_shader_engines, } } + static bool amdgpu_device_has_vkms_modeset(struct amdgpu_device *adev) +{ +return adev->enable_virtual_display && +adev->mode_info.mode_config_initialized; +} +/** * amdgpu_device_suspend - initiate device suspend * amdgpu_ras_suspend(adev); /* VKMS modeset state is saved here, never from the reset path */ -if (adev->enable_virtual_display) { +if (amdgpu_device_has_vkms_modeset (adev)) { r =drm_mode_config_helper_suspend (dev);if (r) goto unwind_smartshift; } unwind_vkms: -if (adev->enable_virtual_display) +if (amdgpu_device_has_vkms_modeset (adev))drm_mode_config_helper_resume (dev); unwind_smartshift: goto exit; } -if (adev->enable_virtual_display) { +if (amdgpu_device_has_vkms_modeset (adev)) { r =drm_mode_config_helper_resume (dev);if (r) goto exit;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +0 -0
@@@ -346,31 -346,26 +346,26 @@@ static void amdgpu_vm_pt_next_dfs(strucamdgpu_vm_pt_continue_dfs ((start), (entry)); \ (entry) = (cursor).entry, amdgpu_vm_pt_next_dfs((adev), &(cursor))) -/* Return the flags used for cleared PDEs/PTES */ -static uint64_t amdgpu_vm_pt_clear_flags (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -unsigned int level) +/* Set @addr and @flags for cleared PDEs/PTEs */ +static void amdgpu_vm_pt_clear_flags (struct amdgpu_device *adev, +struct amdgpu_vm *vm, +unsigned int level,uint64_t *addr, +uint64_t *flags) { -uint64_t flags; -if (adev->asic_type <CHIP_VEGA10 ) -return 0 ; +return ;if (level !=AMDGPU_VM_PTB ) { -uint64_t value =0 ; - - flags =AMDGPU_PDE_PTE_FLAG (adev); + *flags |=AMDGPU_PDE_PTE_FLAG (adev);if (vm->is_npa) - flags |= adev->gmc.noretry_flags; -amdgpu_gmc_get_vm_pde (adev, level, &value, &flags); + *flags |= adev->gmc.noretry_flags; +amdgpu_gmc_get_vm_pde (adev, level, addr, flags); }else if (vm->is_npa) { - flags = adev->gmc.noretry_flags; + *flags |= adev->gmc.noretry_flags; }else {/* Workaround for fault priority problem on GMC9 */ - flags =AMDGPU_PTE_EXECUTABLE | adev->gmc.init_pte_flags; + *flags |=AMDGPU_PTE_EXECUTABLE | adev->gmc.init_pte_flags; } - -return flags; }/** struct amdgpu_bo *ancestor = &vmbo->bo; struct amdgpu_bo *bo = &vmbo->bo; unsigned int entries; -uint64_t flags; +uint64_t value = 0, flags = 0; int r, idx; /* Figure out our place in the hierarchy */ if (r) goto exit; - flags =amdgpu_vm_pt_clear_flags (adev, vm, level); - r = vm->update_funcs->update (¶ms, vmbo,0 ,0 , entries,0 , flags); +amdgpu_vm_pt_clear_flags (adev, vm, level, &value, &flags); + r = vm->update_funcs->update (¶ms, vmbo,0 ,0 , entries, value, + flags);if (r) goto exit; }else if (!(flags &AMDGPU_PTE_VALID ) && !(flags &AMDGPU_PTE_PRT_FLAG (params->adev))) { - flags |=amdgpu_vm_pt_clear_flags (adev, params->vm, level); +amdgpu_vm_pt_clear_flags (adev, params->vm, level, &addr, &flags); }/*
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
@@@ -2191,7 -2191,7 +2191,7 @@@ static int gfx_v9_0_compute_ring_init(shw_prio = amdgpu_gfx_is_high_priority_compute_queue(adev, ring) ? AMDGPU_RING_PRIO_2 : AMDGPU_RING_PRIO_DEFAULT; /* type-2 packets are deprecated on MEC, use type-3 instead */ -return amdgpu_ring_init (adev, ring,1024 , &adev->gfx.eop_irq, irq_type, +return amdgpu_ring_init (adev, ring,2048 , &adev->gfx.eop_irq, irq_type, hw_prio,NULL ); } * active, because KFD cannot unmap/destroy them while the reset domain is * locked. After MODE2 the MEC then resumes with stale HQDs and the HWS no * longer answers (qcm fence timeout on the next KFD queue). Deactivate every - * active HQD of all MECs except the KIQ, which is reprogrammed on resume. + * active HQD of all MECs except the KIQ, which gfx_v9_0_hw_fini() deactivates + * separately with the CAIL deinitialize sequence. */ static void gfx_v9_0_deactivate_all_hqd(struct amdgpu_device *adev) {gfx_v9_0_deactivate_all_hqd (adev);/* Use deinitialize sequence from CAIL when unbinding device from driver, -* otherwise KIQ is hanging when binding back +* otherwise KIQ is hanging when binding back. MODE2 does not reset the +* HQD registers on APUs either, so do the same before MODE2: otherwise +* the KIQ HQD is still active after the reset, kiq_init_register() +* dequeues it while the MEC is halted, and the CPF stays busy, so GFX +* never goes idle again until reboot. */ -if (!amdgpu_in_reset (adev) && !adev->in_suspend) { +if ((!amdgpu_in_reset (adev) && !adev->in_suspend) || + ((adev->flags &AMD_IS_APU ) &&amdgpu_in_reset (adev) && +amdgpu_asic_reset_method (adev) ==AMD_RESET_METHOD_MODE2 )) {mutex_lock (&adev->srbm_mutex); soc15_grbm_select(adev, adev->gfx.kiq[0].ring.me, adev->gfx.kiq[0].ring.pipe, } static void gfx_v9_0_update_spm_vmid(struct amdgpu_device *adev, int xcc_id, - unsigned int vmid) + struct amdgpu_ring *ring, unsigned int vmid) { + if (ring) { + if ((ring->funcs->type == AMDGPU_RING_TYPE_GFX) || + (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE)) { + u32 reg = SOC15_REG_OFFSET(GC, 0, mmRLC_SPM_MC_CNTL); + u32 data = (vmid & RLC_SPM_MC_CNTL__RLC_SPM_VMID_MASK) << RLC_SPM_MC_CNTL__RLC_SPM_VMID__SHIFT; + amdgpu_ring_emit_wreg(ring, reg, data); + } + return; + } + amdgpu_gfx_off_ctrl(adev, false); gfx_v9_0_update_spm_vmid_internal(adev, vmid); .get_wptr = gfx_v9_0_ring_get_wptr_gfx, .set_wptr = gfx_v9_0_ring_set_wptr_gfx, .emit_frame_size = /* totally 242 maximum if 16 IBs */ + 5 + /* update_spm_vmid */ 5 + /* COND_EXEC */ 13 + /* PIPELINE_SYNC */ SOC15_FLUSH_GPU_TLB_NUM_WREG * 5 + .get_wptr = amdgpu_sw_ring_get_wptr_gfx, .set_wptr = amdgpu_sw_ring_set_wptr_gfx, .emit_frame_size = /* totally 242 maximum if 16 IBs */ + 5 + /* update_spm_vmid */ 5 + /* COND_EXEC */ 13 + /* PIPELINE_SYNC */ SOC15_FLUSH_GPU_TLB_NUM_WREG * 5 + .get_wptr = gfx_v9_0_ring_get_wptr_compute, .set_wptr = gfx_v9_0_ring_set_wptr_compute, .emit_frame_size = + 5 + /* update_spm_vmid */ 20 + /* gfx_v9_0_ring_emit_gds_switch */ 7 + /* gfx_v9_0_ring_emit_hdp_flush */ 5 + /* hdp invalidate */
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@@ -170,6 -170,7 +170,7 @@@ static inline void amdgpu_dm_exit_ips_fSTATIC_IFN_KUNIT u32 dm_vblank_get_counter(struct amdgpu_device *adev, int crtc) { struct amdgpu_crtc *acrtc = NULL; +struct amdgpu_display_manager *dm = &adev->dm; if (crtc >= adev->mode_info.num_crtc) return 0; return 0; } - return dc_stream_get_vblank_counter(acrtc->dm_irq_params.stream); +guard(spinlock_irqsave)(&adev->dm.sw_counter_lock); ++ if (acrtc->otg_inst < 0) { +drm_err(adev_to_drm(adev), "dm_vblank_get_counter: no otg_inst for crtc '%d'!\n", +crtc); +return 0; +} ++ if (dm->use_sw_vblank_counter) +return dm->otg_sw_counter[acrtc->otg_inst].frozen; ++ return (dc_stream_get_vblank_counter(acrtc->dm_irq_params.stream) + +dm->otg_sw_counter[acrtc->otg_inst].offset) & 0xffffff; } EXPORT_IF_KUNIT(dm_vblank_get_counter); u32 *vbl, u32 *position) { u32 v_blank_start = 0, v_blank_end = 0, h_position = 0, v_position = 0; +struct amdgpu_display_manager *dm = &adev->dm; struct amdgpu_crtc *acrtc = NULL; -struct dc *dc = adev->dm.dc; if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc)) return -EINVAL; return 0; } - if (dc && dc->caps.ips_support && dc->idle_optimizations_allowed) -dc_allow_idle_optimizations(dc, false); +guard(spinlock_irqsave)(&adev->dm.sw_counter_lock); ++ if (acrtc->otg_inst < 0) { +drm_err(adev_to_drm(adev), "dm_crtc_get_scanoutpos: no otg_inst for crtc '%d'!\n", +crtc); +return 0; +} ++ if (dm->use_sw_vblank_counter) { +*vbl = dm->otg_sw_counter[acrtc->otg_inst].vblank_start | +(dm->otg_sw_counter[acrtc->otg_inst].vblank_end << 16); +*position = dm->otg_sw_counter[acrtc->otg_inst].vblank_end; +return 0; +} /* * TODO rework base driver to use values directly. } EXPORT_IF_KUNIT(dm_crtc_get_scanoutpos); + /* active_vblank_irq_count must be 0 before calling this function */ +void amdgpu_dm_sw_counter_freeze (struct amdgpu_display_manager *dm) + { +struct dc *dc = dm->dc; + +lockdep_assert_held (&dm->dc_lock); + +if (!dc->caps.ips_support || dc->config.disable_ips ==DMUB_IPS_DISABLE_ALL ) +return ; + +guard (spinlock_irqsave)(&dm->sw_counter_lock); + +if (dm->use_sw_vblank_counter) +return ; + +for (int i =0 ; i <MAX_PIPES ; i++) { +u32 hw, h_position, v_position; + + hw =dc_otg_get_vblank_counter (dc, i); + dm->otg_sw_counter[i].frozen = (hw + dm->otg_sw_counter[i].offset +1 ) &0xffffff ; +dc_otg_get_scanoutpos (dc, i, + &dm->otg_sw_counter[i].vblank_start, + &dm->otg_sw_counter[i].vblank_end, + &h_position, &v_position); + } + + dm->use_sw_vblank_counter = true; + + } + +/* should only be called after IPS exit */ +void amdgpu_dm_sw_counter_resume (struct amdgpu_display_manager *dm) + { +struct dc *dc = dm->dc; + +lockdep_assert_held (&dm->dc_lock); + +if (!dc->caps.ips_support || dc->config.disable_ips ==DMUB_IPS_DISABLE_ALL ) +return ; + +guard (spinlock_irqsave)(&dm->sw_counter_lock); + +if (!dm->use_sw_vblank_counter) +return ; + +for (int i =0 ; i <MAX_PIPES ; i++) { +u32 hw; + + hw =dc_otg_get_vblank_counter (dc, i); + dm->otg_sw_counter[i].offset = (dm->otg_sw_counter[i].frozen - hw) &0xffffff ; + } + + dm->use_sw_vblank_counter = false; + } + STATIC_IFN_KUNIT int dm_wait_for_idle(struct amdgpu_ip_block *ip_block) {/* XXX todo */ }EXPORT_IF_KUNIT (mmhub_read_system_context); + STATIC_IFN_KUNIT void +amdgpu_dm_fill_power_nits_range (const struct amdgpu_dm_backlight_caps *caps, +struct mod_power_init_params *init_data) + { + init_data->use_nits_based_brightness = false; + init_data->panel_max_millinits =0 ; + init_data->panel_min_millinits =0 ; +if (caps->aux_support && + caps->aux_max_input_signal > caps->aux_min_input_signal) { + init_data->use_nits_based_brightness = true; + init_data->panel_max_millinits = caps->aux_max_input_signal *1000 ; + init_data->panel_min_millinits = caps->aux_min_input_signal *1000 ; + } + } +EXPORT_IF_KUNIT (amdgpu_dm_fill_power_nits_range); + STATIC_IFN_KUNIT int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm) {struct mod_power_init_params init_data[MAX_NUM_EDP ]; init_data[i].def_varibright_level =0 ; init_data[i].abm_config_setting =0 ; init_data[i].num_backlight_levels =101 ; - init_data[i].use_nits_based_brightness = false; - init_data[i].panel_max_millinits =0 ; - init_data[i].panel_min_millinits =0 ; +amdgpu_dm_fill_power_nits_range (&dm->backlight_caps[i], &init_data[i]); init_data[i].disable_fractional_pwm = !(amdgpu_dc_feature_mask &DC_DISABLE_FRACTIONAL_PWM_MASK ); init_data[i].use_custom_backlight_caps = false;mutex_init (&adev->dm.audio_lock);spin_lock_init (&adev->dm.dmub_lock); +spin_lock_init (&adev->dm.sw_counter_lock);if (amdgpu_dm_irq_init (adev)) {drm_err (adev_to_drm (adev),"failed to initialize DM IRQ support.\n" );if (adev->dm.dc->caps.max_links >0 ) { adev->dm.vblank_control_workqueue =create_singlethread_workqueue ("dm_vblank_control_workqueue" ); -if (!adev->dm.vblank_control_workqueue) +if (!adev->dm.vblank_control_workqueue) {drm_err (adev_to_drm (adev),"failed to initialize vblank_workqueue.\n" ); + goto error; + } }if (adev->dm.dc->caps.ips_support && } EXPORT_IF_KUNIT(dm_destroy_cached_state); +static void amdgpu_dm_apple_imac_unlatch (struct dc *dc) + { +const u8 zeros[3 ] = {0 }; + +for (int i =0 ; i < dc->link_count; i++) { +struct dc_link *link = dc->links[i]; + +if (link->apple_imac_peer) { +core_link_write_dpcd (link,DP_SOURCE_TABLE_REVISION , zeros,3 ); +core_link_write_dpcd (link,DP_EDP_CONFIGURATION_SET , zeros,1 ); +core_link_write_dpcd (link,0x4F1 , zeros,1 ); +core_link_write_dpcd (link->apple_imac_peer,0x4F1 , zeros,1 ); +break ; + } + } + } +static int dm_suspend (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev;amdgpu_dm_hpd_rx_irq_work_suspend (dm); +amdgpu_dm_apple_imac_unlatch (dm->dc); +dc_set_power_state (dm->dc,DC_ACPI_CM_POWER_STATE_D3 );if (dm->dc->caps.ips_support && adev->in_s0ix)drm_atomic_private_obj_init (adev_to_drm (adev), &adev->dm.atomic_obj, +"amdgpu_dc_state" , &dm_atomic_state_funcs); r =amdgpu_display_modeset_create_props (adev);static const struct amdgpu_display_funcs dm_display_funcs = { .bandwidth_update = dm_bandwidth_update,/* called unconditionally */ .vblank_get_counter = dm_vblank_get_counter,/* called unconditionally */ - .backlight_set_level =NULL ,/* never called for DC */ - .backlight_get_level =NULL ,/* never called for DC */ - .hpd_sense =NULL ,/* called unconditionally */ - .hpd_set_polarity =NULL ,/* called unconditionally */ - .hpd_get_gpio_reg =NULL ,/* VBIOS parsing. DAL does it. */ .page_flip_get_scanoutpos = dm_crtc_get_scanoutpos,/* called unconditionally */ - .add_encoder =NULL ,/* VBIOS parsing. DAL does it. */ - .add_connector =NULL ,/* VBIOS parsing. DAL does it. */ };#if defined(CONFIG_DEBUG_KERNEL_DC ) * this at commit time, not in atomic check: by then the previous commit * has finished writing it. */ -static void + STATIC_IFN_KUNIT voiddm_plane_inherit_flip_time (struct dc_plane_state *dc_plane_state,struct drm_plane_state *old_plane_state,struct drm_plane_state *new_plane_state) old_plane_state->crtc == new_plane_state->crtc) dc_plane_state->time = old_dc_plane_state->time; } +EXPORT_IF_KUNIT (dm_plane_inherit_flip_time); + + +struct dm_sr_hold { +bool psr; +bool replay; + }; + +/* +* DMUB can hang if an ABM level reaches it while the panel is in +* self-refresh. A commit that changes only the ABM level is a fast update and +* skips the hold in amdgpu_dm_mod_power_update_streams(), so hold PSR and +* Replay off around the DC update. Holds that something else already set stay +* as they are, for their owner to clear. dc_lock keeps the backlight path, +* amdgpu_dm_mod_power_update_streams() and the self-refresh code in +* amdgpu_dm_commit_planes() from changing them in between. +* amdgpu_dm_mod_power_setup_streams() sets them without dc_lock, but only for +* a modeset stream, earlier in the same commit tail +*/ +static struct dm_sr_hold dm_hold_self_refresh (struct amdgpu_display_manager *dm, +struct dc_stream_state *stream) + { +struct dm_sr_hold hold; + +lockdep_assert_held (&dm->dc_lock); + + hold.psr = !amdgpu_dm_psr_event_is_set (dm, stream, psr_event_hw_programming); + hold.replay = !amdgpu_dm_replay_event_is_set (dm, stream, replay_event_hw_programming); + +if (hold.psr) +amdgpu_dm_psr_set_event (dm, stream, true, psr_event_hw_programming, true); +if (hold.replay) +amdgpu_dm_replay_set_event (dm, stream, true, replay_event_hw_programming, true); + +return hold; + } + +/* +* Nothing else may commit on an idle desktop, so drop the hold right after the +* update rather than leaving it to amdgpu_dm_enable_self_refresh() +*/ +static void dm_release_self_refresh (struct amdgpu_display_manager *dm, +struct dc_stream_state *stream, +struct dm_sr_hold hold) + { +lockdep_assert_held (&dm->dc_lock); + +if (hold.psr) +amdgpu_dm_psr_set_event (dm, stream, false, psr_event_hw_programming, false); +if (hold.replay) +amdgpu_dm_replay_set_event (dm, stream, false, replay_event_hw_programming, false); + }static void amdgpu_dm_commit_planes (struct drm_atomic_commit *state,struct drm_device *dev,struct amdgpu_display_manager *dm,struct drm_crtc *pcrtc, -bool wait_for_vblank) +bool wait_for_vblank, +bool abm_sent) {u32 i;u64 timestamp_ns =ktime_get_ns ();bool dirty_rects_changed = false;bool updated_planes_and_streams = false;bool stream_update_needed = false; +struct dm_sr_hold sr_hold = {};struct {struct dc_surface_update surface_updates[MAX_SURFACES ];struct dc_plane_info plane_infos[MAX_SURFACES ]; } acrtc_state->stream->abm_level = acrtc_state->abm_level; -if (acrtc_state->abm_level != dm_old_crtc_state->abm_level) { +/* The connector loop in amdgpu_dm_atomic_commit_tail() may have sent it */ +if (!abm_sent && acrtc_state->abm_level != dm_old_crtc_state->abm_level) { bundle->stream_update.abm_level = &acrtc_state->abm_level; stream_update_needed = true; }amdgpu_dm_replay_set_event (dm, acrtc_state->stream, true, replay_event_immediate_flip, true); } +if (bundle->stream_update.abm_level) { +dc_exit_ips_for_hw_access (dm->dc); + sr_hold =dm_hold_self_refresh (dm, acrtc_state->stream); + }update_planes_and_stream_adapter (dm->dc, planes_count, acrtc_state->stream, stream_update_needed ? &bundle->stream_update :NULL , bundle->surface_updates); +dm_release_self_refresh (dm, acrtc_state->stream, sr_hold); updated_planes_and_streams = true;/** if (!pending) return false; - drm_writeback_signal_completion(acrtc->wb_conn, 0); + drm_writeback_signal_completion(drm_writeback_to_connector(acrtc->wb_conn), 0); drm_crtc_vblank_put(&acrtc->base); return true; struct drm_connector *connector, struct drm_connector_state *new_con_state) { - struct drm_writeback_connector *wb_conn = drm_connector_to_writeback(connector); + struct drm_writeback_connector *wb_conn = &connector->writeback; struct amdgpu_device *adev = dm->adev; struct amdgpu_crtc *acrtc; struct dc_writeback_info *wb_info; goto cleanup; } - acrtc = to_amdgpu_crtc(wb_conn->encoder.crtc); + acrtc = to_amdgpu_crtc(to_amdgpu_dm_wb_connector(connector)->encoder.crtc); if (!acrtc) { drm_err(adev_to_drm(adev), "no amdgpu_crtc found\n"); goto cleanup; dc_stream_add_writeback(dm->dc, crtc_state->stream, wb_info); acrtc->wb_conn = wb_conn; - drm_writeback_queue_job(wb_conn, new_con_state); + drm_writeback_queue_job(connector, new_con_state); /* * Writeback completion is detected in the CRTC vblank IRQ struct drm_connector_state *old_con_state = NULL, *new_con_state = NULL; struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state; int crtc_disable_count = 0; +u32 abm_sent = 0; trace_amdgpu_dm_atomic_commit_tail_begin(state); struct dc_info_packet hdr_packet; struct dc_stream_status *status = NULL; bool abm_changed, hdr_changed, scaling_changed, output_color_space_changed = false; +struct dm_sr_hold sr_hold = {}; +bool updated; memset(&stream_update, 0, sizeof(stream_update)); mutex_lock(&dm->dc_lock); dc_exit_ips_for_hw_access(dm->dc); -dc_update_planes_and_stream(dm->dc, -dummy_updates, -status->plane_count, -dm_new_crtc_state->stream, -&stream_update); +if (abm_changed) +sr_hold = dm_hold_self_refresh(dm, dm_new_crtc_state->stream); +updated = dc_update_planes_and_stream(dm->dc, +dummy_updates, +status->plane_count, +dm_new_crtc_state->stream, +&stream_update); +dm_release_self_refresh(dm, dm_new_crtc_state->stream, sr_hold); mutex_unlock(&dm->dc_lock); kfree(dummy_updates); +if (abm_changed && updated) +abm_sent |= drm_crtc_mask(&acrtc->base); drm_connector_update_privacy_screen(new_con_state); } dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); if (dm_new_crtc_state->stream) -amdgpu_dm_commit_planes(state, dev, dm, crtc, wait_for_vblank); +amdgpu_dm_commit_planes(state, dev, dm, crtc, wait_for_vblank, +abm_sent & drm_crtc_mask(crtc)); } /* Enable writeback */ goto fail; } -if (dm_old_con_state->abm_level != dm_new_con_state->abm_level || - dm_old_con_state->scaling != dm_new_con_state->scaling) +if (dm_old_con_state->scaling != dm_new_con_state->scaling) new_crtc_state->connectors_changed = true; + +/* +* With VRR active, the CRTC check adds only the primary plane, +* and DC would drop any other plane from the stream +*/ +if (dm_old_con_state->abm_level != dm_new_con_state->abm_level) { + ret =drm_atomic_add_affected_planes (state, new_con_state->crtc); +if (ret) { +drm_dbg_atomic (dev, +"drm_atomic_add_affected_planes() failed: %pe\n" , +ERR_PTR (ret)); + goto fail; + } + } }if (dc_resource_is_dsc_encoding_supported (dc)) {