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

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.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

+32 -7
+2
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 1122 1122 bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type); 1123 1123 bool amdgpu_device_has_dc_support(struct amdgpu_device *adev); 1124 1124 1125 + void amdgpu_device_set_sriov_virtual_display(struct amdgpu_device *adev); 1126 + 1125 1127 int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, 1126 1128 struct amdgpu_reset_context *reset_context); 1127 1129
+11 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 1915 1915 } 1916 1916 } 1917 1917 1918 + void amdgpu_device_set_sriov_virtual_display(struct amdgpu_device *adev) 1919 + { 1920 + if (amdgpu_sriov_vf(adev) && !adev->enable_virtual_display) { 1921 + adev->mode_info.num_crtc = 1; 1922 + adev->enable_virtual_display = true; 1923 + DRM_INFO("virtual_display:%d, num_crtc:%d\n", 1924 + adev->enable_virtual_display, adev->mode_info.num_crtc); 1925 + } 1926 + } 1927 + 1918 1928 /** 1919 1929 * amdgpu_device_parse_gpu_info_fw - parse gpu info firmware 1920 1930 * ··· 3357 3347 */ 3358 3348 bool amdgpu_device_has_dc_support(struct amdgpu_device *adev) 3359 3349 { 3360 - if (amdgpu_sriov_vf(adev) || 3361 - adev->enable_virtual_display || 3350 + if (adev->enable_virtual_display || 3362 3351 (adev->harvest_ip_mask & AMD_HARVEST_IP_DMU_MASK)) 3363 3352 return false; 3364 3353
+15 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
··· 1702 1702 return 0; 1703 1703 } 1704 1704 1705 + static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev) 1706 + { 1707 + amdgpu_device_set_sriov_virtual_display(adev); 1708 + amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); 1709 + } 1710 + 1705 1711 static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev) 1706 1712 { 1707 - if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) { 1713 + if (adev->enable_virtual_display) { 1708 1714 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); 1709 1715 return 0; 1710 1716 } ··· 1738 1732 case IP_VERSION(3, 1, 6): 1739 1733 case IP_VERSION(3, 2, 0): 1740 1734 case IP_VERSION(3, 2, 1): 1741 - amdgpu_device_ip_block_add(adev, &dm_ip_block); 1735 + if (amdgpu_sriov_vf(adev)) 1736 + amdgpu_discovery_set_sriov_display(adev); 1737 + else 1738 + amdgpu_device_ip_block_add(adev, &dm_ip_block); 1742 1739 break; 1743 1740 default: 1744 1741 dev_err(adev->dev, ··· 1754 1745 case IP_VERSION(12, 0, 0): 1755 1746 case IP_VERSION(12, 0, 1): 1756 1747 case IP_VERSION(12, 1, 0): 1757 - amdgpu_device_ip_block_add(adev, &dm_ip_block); 1748 + if (amdgpu_sriov_vf(adev)) 1749 + amdgpu_discovery_set_sriov_display(adev); 1750 + else 1751 + amdgpu_device_ip_block_add(adev, &dm_ip_block); 1758 1752 break; 1759 1753 default: 1760 1754 dev_err(adev->dev,
+4 -2
drivers/gpu/drm/amd/amdgpu/vi.c
··· 2111 2111 2112 2112 int vi_set_ip_blocks(struct amdgpu_device *adev) 2113 2113 { 2114 + amdgpu_device_set_sriov_virtual_display(adev); 2115 + 2114 2116 switch (adev->asic_type) { 2115 2117 case CHIP_TOPAZ: 2116 2118 /* topaz has no DCE, UVD, VCE */ ··· 2132 2130 amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 2133 2131 amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 2134 2132 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 2135 - if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 2133 + if (adev->enable_virtual_display) 2136 2134 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); 2137 2135 #if defined(CONFIG_DRM_AMD_DC) 2138 2136 else if (amdgpu_device_has_dc_support(adev)) ··· 2152 2150 amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 2153 2151 amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 2154 2152 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 2155 - if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 2153 + if (adev->enable_virtual_display) 2156 2154 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); 2157 2155 #if defined(CONFIG_DRM_AMD_DC) 2158 2156 else if (amdgpu_device_has_dc_support(adev))