drm/amdgpu: use proper DC check in amdgpu_display_supported_domains()
Alex Deucher
maintainerPATCH 1/4 drm/amdgpu: use proper DC check in amdgpu_display_supported_domains()
amdgpu_device_asic_has_dc_support() just checks the asic itself. amdgpu_device_has_dc_support() is a runtime check which not only checks the asic, but also other things in the driver like whether virtual display is enabled. We want the latter here.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
@@ -514,7 +514,7 @@ uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,*/ if ((bo_flags &AMDGPU_GEM_CREATE_CPU_GTT_USWC ) &&amdgpu_bo_support_uswc (bo_flags) && -amdgpu_device_asic_has_dc_support (adev->asic_type) && +amdgpu_device_has_dc_support (adev) && adev->mode_info.gpu_vm_support) domain |=AMDGPU_GEM_DOMAIN_GTT ;#endif
Signature · 1 line
2.37.2
Alex Deucher
maintainerPATCH 2/4 drm/amdgpu: rework SR-IOV virtual display handling
virtual display is enabled unconditionally in SR-IOV, but without specifying the virtual_display module, the number of crtcs defaults to 0. Set a single display by default for SR-IOV if the virtual_display parameter is not set. Only enable virtual display by default on SR-IOV on asics which actually have display hardware.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 13 +++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 18 +++++++++++++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 6 ++++-- 4 files changed, 32 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1123,6 +1123,8 @@ void amdgpu_device_indirect_wreg64(struct amdgpu_device *adev,bool amdgpu_device_asic_has_dc_support (enum amd_asic_type asic_type);bool amdgpu_device_has_dc_support (struct amdgpu_device *adev); +void amdgpu_device_set_sriov_virtual_display (struct amdgpu_device *adev); +int amdgpu_device_pre_asic_reset (struct amdgpu_device *adev,struct amdgpu_reset_context *reset_context);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11 -2
@@ -1915,6 +1915,16 @@ static void amdgpu_device_enable_virtual_display(struct amdgpu_device *adev) } } +void amdgpu_device_set_sriov_virtual_display (struct amdgpu_device *adev) +{ +if (amdgpu_sriov_vf (adev) && !adev->enable_virtual_display) { + adev->mode_info.num_crtc =1 ; + adev->enable_virtual_display = true; +DRM_INFO ("virtual_display:%d, num_crtc:%d\n" , + adev->enable_virtual_display, adev->mode_info.num_crtc); + } +} +/** * amdgpu_device_parse_gpu_info_fw - parse gpu info firmware *
@@ -3319,8 +3329,7 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)*/ bool amdgpu_device_has_dc_support (struct amdgpu_device *adev) { -if (amdgpu_sriov_vf (adev) || - adev->enable_virtual_display || +if (adev->enable_virtual_display || (adev->harvest_ip_mask &AMD_HARVEST_IP_DMU_MASK ))return false;
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +15 -3
@@ -1704,9 +1704,15 @@ static int amdgpu_discovery_set_smu_ip_blocks(struct amdgpu_device *adev)return 0 ; } +static void amdgpu_discovery_set_sriov_display (struct amdgpu_device *adev) +{ +amdgpu_device_set_sriov_virtual_display (adev); +amdgpu_device_ip_block_add (adev, &amdgpu_vkms_ip_block); +} +static int amdgpu_discovery_set_display_ip_blocks (struct amdgpu_device *adev) { -if (adev->enable_virtual_display ||amdgpu_sriov_vf (adev)) { +if (adev->enable_virtual_display) {amdgpu_device_ip_block_add (adev, &amdgpu_vkms_ip_block);return 0 ; }
@@ -1734,7 +1740,10 @@ static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)case IP_VERSION (3 ,1 ,6 ):case IP_VERSION (3 ,2 ,0 ):case IP_VERSION (3 ,2 ,1 ): -amdgpu_device_ip_block_add (adev, &dm_ip_block); +if (amdgpu_sriov_vf (adev)) +amdgpu_discovery_set_sriov_display (adev); +else +amdgpu_device_ip_block_add (adev, &dm_ip_block);break ;default : dev_err(adev->dev,
@@ -1747,7 +1756,10 @@ static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)case IP_VERSION (12 ,0 ,0 ):case IP_VERSION (12 ,0 ,1 ):case IP_VERSION (12 ,1 ,0 ): -amdgpu_device_ip_block_add (adev, &dm_ip_block); +if (amdgpu_sriov_vf (adev)) +amdgpu_discovery_set_sriov_display (adev); +else +amdgpu_device_ip_block_add (adev, &dm_ip_block);break ;default : dev_err(adev->dev,
drivers/gpu/drm/amd/amdgpu/vi.c +4 -2
@@ -2111,6 +2111,8 @@ void vi_set_virt_ops(struct amdgpu_device *adev)int vi_set_ip_blocks (struct amdgpu_device *adev) { +amdgpu_device_set_sriov_virtual_display (adev); +switch (adev->asic_type) {case CHIP_TOPAZ :/* topaz has no DCE, UVD, VCE */
@@ -2130,7 +2132,7 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)amdgpu_device_ip_block_add (adev, &gfx_v8_0_ip_block);amdgpu_device_ip_block_add (adev, &sdma_v3_0_ip_block);amdgpu_device_ip_block_add (adev, &pp_smu_ip_block); -if (adev->enable_virtual_display ||amdgpu_sriov_vf (adev)) +if (adev->enable_virtual_display)amdgpu_device_ip_block_add (adev, &amdgpu_vkms_ip_block);#if defined(CONFIG_DRM_AMD_DC ) else if (amdgpu_device_has_dc_support(adev))
@@ -2150,7 +2152,7 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)amdgpu_device_ip_block_add (adev, &gfx_v8_0_ip_block);amdgpu_device_ip_block_add (adev, &sdma_v3_0_ip_block);amdgpu_device_ip_block_add (adev, &pp_smu_ip_block); -if (adev->enable_virtual_display ||amdgpu_sriov_vf (adev)) +if (adev->enable_virtual_display)amdgpu_device_ip_block_add (adev, &amdgpu_vkms_ip_block);#if defined(CONFIG_DRM_AMD_DC ) else if (amdgpu_device_has_dc_support(adev))
Signature · 1 line
2.37.2
Alex Deucher
maintainerPATCH 3/4 drm/amdgpu: move non-DC vblank handling out of irq code
In reply to Alex DeucherMove it into the DCE code for each generation. This avoids confusion with the different display paths.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 35 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_display.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 58 +-------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 12 +++++ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 13 +++++ drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 13 +++++ drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 14 +++++ drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 14 +++++ 8 files changed, 103 insertions(+), 57 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +35 -0
@@ -44,6 +44,41 @@#include <drm/drm_fourcc.h> #include <drm/drm_vblank.h> +/** +* amdgpu_display_hotplug_work_func - work handler for display hotplug event +* +* @work: work struct pointer +* +* This is the hotplug event work handler (all ASICs). +* The work gets scheduled from the IRQ handler if there +* was a hotplug interrupt. It walks through the connector table +* and calls hotplug handler for each connector. After this, it sends +* a DRM hotplug event to alert userspace. +* +* This design approach is required in order to defer hotplug event handling +* from the IRQ handler to a work handler because hotplug handler has to use +* mutexes which cannot be locked in an IRQ handler (since &mutex_lock may +* sleep). +*/ +void amdgpu_display_hotplug_work_func (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + hotplug_work); +struct drm_device *dev =adev_to_drm (adev); +struct drm_mode_config *mode_config = &dev->mode_config; +struct drm_connector *connector; +struct drm_connector_list_iter iter; + +mutex_lock (&mode_config->mutex); +drm_connector_list_iter_begin (dev, &iter); +drm_for_each_connector_iter (connector, &iter) +amdgpu_connector_hotplug (connector); +drm_connector_list_iter_end (&iter); +mutex_unlock (&mode_config->mutex); +/* Just fire off a uevent and let userspace tell us what to do */ +drm_helper_hpd_irq_event (dev); +} + static int amdgpu_display_framebuffer_init(struct drm_device *dev, struct amdgpu_framebuffer *rfb, const struct drm_mode_fb_cmd2 *mode_cmd,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
@@ -35,6 +35,7 @@#define amdgpu_display_add_encoder (adev, e, s, c) (adev)->mode_info.funcs->add_encoder((adev), (e), (s), (c))#define amdgpu_display_add_connector (adev, ci, sd, ct, ib, coi, h, r) (adev)->mode_info.funcs->add_connector((adev), (ci), (sd), (ct), (ib), (coi), (h), (r)) +void amdgpu_display_hotplug_work_func (struct work_struct *work);void amdgpu_display_update_priority (struct amdgpu_device *adev);uint32_t amdgpu_display_supported_domains (struct amdgpu_device *adev,uint64_t bo_flags);
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +1 -57
83 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +12 -0
@@ -511,6 +511,15 @@ static int amdgpu_vkms_sw_init(void *handle)return r; } + + r =drm_vblank_init (adev_to_drm (adev), adev->mode_info.num_crtc); +if (r) +return r; + +/* Pre-DCE11 */ +INIT_WORK (&adev->hotplug_work, + amdgpu_display_hotplug_work_func); +drm_kms_helper_poll_init (adev_to_drm (adev)); adev->mode_info.mode_config_initialized = true;
@@ -583,6 +592,9 @@ static int amdgpu_vkms_hw_init(void *handle)static int amdgpu_vkms_hw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +flush_work (&adev->hotplug_work);return 0 ; }
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +13 -0
@@ -2830,6 +2830,17 @@ static int dce_v10_0_sw_init(void *handle)if (r)return r; +/* Disable vblank IRQs aggressively for power-saving */ +/* XXX: can this be enabled for DC? */ +adev_to_drm (adev)->vblank_disable_immediate = true; + + r =drm_vblank_init (adev_to_drm (adev), adev->mode_info.num_crtc); +if (r) +return r; + +INIT_WORK (&adev->hotplug_work, + amdgpu_display_hotplug_work_func); +drm_kms_helper_poll_init (adev_to_drm (adev)); adev->mode_info.mode_config_initialized = true;
@@ -2892,6 +2903,8 @@ static int dce_v10_0_hw_fini(void *handle)dce_v10_0_pageflip_interrupt_fini (adev); +flush_work (&adev->hotplug_work); +return 0 ; }
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +13 -0
@@ -2949,6 +2949,17 @@ static int dce_v11_0_sw_init(void *handle)if (r)return r; +/* Disable vblank IRQs aggressively for power-saving */ +/* XXX: can this be enabled for DC? */ +adev_to_drm (adev)->vblank_disable_immediate = true; + + r =drm_vblank_init (adev_to_drm (adev), adev->mode_info.num_crtc); +if (r) +return r; + +INIT_WORK (&adev->hotplug_work, + amdgpu_display_hotplug_work_func); +drm_kms_helper_poll_init (adev_to_drm (adev)); adev->mode_info.mode_config_initialized = true;
@@ -3022,6 +3033,8 @@ static int dce_v11_0_hw_fini(void *handle)dce_v11_0_pageflip_interrupt_fini (adev); +flush_work (&adev->hotplug_work); +return 0 ; }
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +14 -0
@@ -2706,6 +2706,18 @@ static int dce_v6_0_sw_init(void *handle)if (r)return r; +/* Disable vblank IRQs aggressively for power-saving */ +/* XXX: can this be enabled for DC? */ +adev_to_drm (adev)->vblank_disable_immediate = true; + + r =drm_vblank_init (adev_to_drm (adev), adev->mode_info.num_crtc); +if (r) +return r; + +/* Pre-DCE11 */ +INIT_WORK (&adev->hotplug_work, + amdgpu_display_hotplug_work_func); +drm_kms_helper_poll_init (adev_to_drm (adev));return r;
@@ -2764,6 +2776,8 @@ static int dce_v6_0_hw_fini(void *handle)dce_v6_0_pageflip_interrupt_fini (adev); +flush_work (&adev->hotplug_work); +return 0 ; }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +14 -0
@@ -2731,6 +2731,18 @@ static int dce_v8_0_sw_init(void *handle)if (r)return r; +/* Disable vblank IRQs aggressively for power-saving */ +/* XXX: can this be enabled for DC? */ +adev_to_drm (adev)->vblank_disable_immediate = true; + + r =drm_vblank_init (adev_to_drm (adev), adev->mode_info.num_crtc); +if (r) +return r; + +/* Pre-DCE11 */ +INIT_WORK (&adev->hotplug_work, + amdgpu_display_hotplug_work_func); +drm_kms_helper_poll_init (adev_to_drm (adev)); adev->mode_info.mode_config_initialized = true;
@@ -2791,6 +2803,8 @@ static int dce_v8_0_hw_fini(void *handle)dce_v8_0_pageflip_interrupt_fini (adev); +flush_work (&adev->hotplug_work); +return 0 ; }
Signature · 1 line
2.37.2
Alex Deucher
maintainerPATCH 4/4 drm/amdgpu: clarify DC checks
In reply to Alex DeucherThere are several places where we don't want to check if a particular asic could support DC, but rather, if DC is enabled. Set a flag if DC is enabled and check for that rather than if a device supports DC or not.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 32 ++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 + .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 2 +- 8 files changed, 25 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1066,6 +1066,7 @@ struct amdgpu_device {uint32_t amdgpu_reset_level_mask;bool job_hang; +bool dc_enabled; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +1 -1
@@ -846,7 +846,7 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)struct amdgpu_atif *atif = &amdgpu_acpi_priv.atif;if (atif->notifications.brightness_change) { -if (amdgpu_device_has_dc_support (adev)) { +if (adev->dc_enabled) {#if defined(CONFIG_DRM_AMD_DC )struct amdgpu_display_manager *dm = &adev->dm;if (dm->backlight_dev[0 ])
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
@@ -1971,7 +1971,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)amdgpu_ta_if_debugfs_init (adev);#if defined(CONFIG_DRM_AMD_DC ) -if (amdgpu_device_has_dc_support (adev)) +if (adev->dc_enabled)dtn_debugfs_init (adev);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +17 -15
@@ -4156,25 +4156,27 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)amdgpu_ras_resume (adev); -/* -* Most of the connector probing functions try to acquire runtime pm -* refs to ensure that the GPU is powered on when connector polling is -* performed. Since we're calling this from a runtime PM callback, -* trying to acquire rpm refs will cause us to deadlock. -* -* Since we're guaranteed to be holding the rpm lock, it's safe to -* temporarily disable the rpm helpers so this doesn't deadlock us. -*/ +if (adev->mode_info.num_crtc) { +/* +* Most of the connector probing functions try to acquire runtime pm +* refs to ensure that the GPU is powered on when connector polling is +* performed. Since we're calling this from a runtime PM callback, +* trying to acquire rpm refs will cause us to deadlock. +* +* Since we're guaranteed to be holding the rpm lock, it's safe to +* temporarily disable the rpm helpers so this doesn't deadlock us. +*/ #ifdef CONFIG_PM - dev->dev->power.disable_depth++; + dev->dev->power.disable_depth++;#endif -if (!amdgpu_device_has_dc_support (adev)) -drm_helper_hpd_irq_event (dev); -else -drm_kms_helper_hotplug_event (dev); +if (!adev->dc_enabled) +drm_helper_hpd_irq_event (dev); +else +drm_kms_helper_hotplug_event (dev);#ifdef CONFIG_PM - dev->dev->power.disable_depth--; + dev->dev->power.disable_depth--;#endif + } adev->in_suspend = false;if (amdgpu_acpi_smart_shift_update (dev,AMDGPU_SS_DEV_D0 ))
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -2
@@ -549,7 +549,7 @@ uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,*/ if ((bo_flags &AMDGPU_GEM_CREATE_CPU_GTT_USWC ) &&amdgpu_bo_support_uswc (bo_flags) && -amdgpu_device_has_dc_support (adev) && + adev->dc_enabled && adev->mode_info.gpu_vm_support) domain |=AMDGPU_GEM_DOMAIN_GTT ;#endif
@@ -1315,7 +1315,7 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)"dither" , amdgpu_dither_enum_list, sz); -if (amdgpu_device_has_dc_support (adev)) { +if (adev->dc_enabled) { adev->mode_info.abm_level_property =drm_property_create_range (adev_to_drm (adev),0 ,"abm level" ,0 ,4 );
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -2425,7 +2425,7 @@ static int amdgpu_runtime_idle_check_display(struct device *dev)if (ret)return ret; -if (amdgpu_device_has_dc_support (adev)) { +if (adev->dc_enabled) {struct drm_crtc *crtc;drm_for_each_crtc (crtc, drm_dev) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
@@ -4601,6 +4601,7 @@ static int dm_early_init(void *handle)adev_to_drm (adev)->dev, &dev_attr_s3_debug);#endif + adev->dc_enabled = true;return 0 ; }
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1 -1
@@ -1504,7 +1504,7 @@ static void pp_pm_compute_clocks(void *handle)struct pp_hwmgr *hwmgr = handle;struct amdgpu_device *adev = hwmgr->adev; -if (!amdgpu_device_has_dc_support (adev)) { +if (!adev->dc_enabled) {amdgpu_dpm_get_active_displays (adev); adev->pm.pm_display_cfg.num_display = adev->pm.dpm.new_active_crtc_count; adev->pm.pm_display_cfg.vrefresh =amdgpu_dpm_get_vrefresh (adev);
Signature · 1 line
2.37.2
Ping on this series?
Alex
Quoted 28 lines · Alex Deucher
amdgpu_device_asic_has_dc_support()just checks the asic itself.amdgpu_device_has_dc_support()is a runtime check which not only checks the asic, but also other things in the driver like whether virtual display is enabled. We want the latter here.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1
-2@@ -514,7 +514,7 @@ uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,*/ if ((bo_flags &AMDGPU_GEM_CREATE_CPU_GTT_USWC ) &&amdgpu_bo_support_uswc (bo_flags) && -amdgpu_device_asic_has_dc_support (adev->asic_type) && +amdgpu_device_has_dc_support (adev) && adev->mode_info.gpu_vm_support) domain |=AMDGPU_GEM_DOMAIN_GTT ;#endif --2.37.2
Feel free to add my acked-by, but that's really not my field of expertise.
Christian.
Am 29.09.22 um 15:15 schrieb Alex Deucher:
Quoted 32 lines
Ping on this series?
Alex
Quoted 27 lines · Alex Deucher
amdgpu_device_asic_has_dc_support()just checks the asic itself.amdgpu_device_has_dc_support()is a runtime check which not only checks the asic, but also other things in the driver like whether virtual display is enabled. We want the latter here.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1
-2@@ -514,7 +514,7 @@ uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,*/ if ((bo_flags &AMDGPU_GEM_CREATE_CPU_GTT_USWC ) &&amdgpu_bo_support_uswc (bo_flags) && -amdgpu_device_asic_has_dc_support (adev->asic_type) && +amdgpu_device_has_dc_support (adev) && adev->mode_info.gpu_vm_support) domain |=AMDGPU_GEM_DOMAIN_GTT ;#endif --2.37.2