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

drm/amdgpu: Fix amdgpu_display_supported_domains logic.

Add restriction to dissallow GTT domain if the relevant BO
doesn't have USWC flag set to avoid the APU hang scenario.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Andrey Grodzovsky and committed by
Alex Deucher
f2bd8a0e 354e6e14

+22 -15
+11 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
··· 191 191 } 192 192 193 193 if (!adev->enable_virtual_display) { 194 - r = amdgpu_bo_pin(new_abo, amdgpu_display_supported_domains(adev)); 194 + r = amdgpu_bo_pin(new_abo, 195 + amdgpu_display_supported_domains(adev, new_abo->flags)); 195 196 if (unlikely(r != 0)) { 196 197 DRM_ERROR("failed to pin new abo buffer before flip\n"); 197 198 goto unreserve; ··· 496 495 .create_handle = drm_gem_fb_create_handle, 497 496 }; 498 497 499 - uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev) 498 + uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev, 499 + uint64_t bo_flags) 500 500 { 501 501 uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM; 502 502 503 503 #if defined(CONFIG_DRM_AMD_DC) 504 504 /* 505 - * if amdgpu_bo_validate_uswc returns false it means that USWC mappings 505 + * if amdgpu_bo_support_uswc returns false it means that USWC mappings 506 506 * is not supported for this board. But this mapping is required 507 507 * to avoid hang caused by placement of scanout BO in GTT on certain 508 508 * APUs. So force the BO placement to VRAM in case this architecture 509 509 * will not allow USWC mappings. 510 + * Also, don't allow GTT domain if the BO doens't have USWC falg set. 510 511 */ 511 - if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type <= CHIP_RAVEN && 512 - adev->flags & AMD_IS_APU && amdgpu_bo_support_uswc(0) && 512 + if (adev->asic_type >= CHIP_CARRIZO && 513 + adev->asic_type <= CHIP_RAVEN && 514 + (adev->flags & AMD_IS_APU) && 515 + (bo_flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) && 516 + amdgpu_bo_support_uswc(bo_flags) && 513 517 amdgpu_device_asic_has_dc_support(adev->asic_type)) 514 518 domain |= AMDGPU_GEM_DOMAIN_GTT; 515 519 #endif
+2 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
··· 38 38 int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data, 39 39 struct drm_file *filp); 40 40 void amdgpu_display_update_priority(struct amdgpu_device *adev); 41 - uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev); 41 + uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev, 42 + uint64_t bo_flags); 42 43 struct drm_framebuffer * 43 44 amdgpu_display_user_framebuffer_create(struct drm_device *dev, 44 45 struct drm_file *file_priv,
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
··· 299 299 struct amdgpu_bo *bo = gem_to_amdgpu_bo(dma_buf->priv); 300 300 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 301 301 struct ttm_operation_ctx ctx = { true, false }; 302 - u32 domain = amdgpu_display_supported_domains(adev); 302 + u32 domain = amdgpu_display_supported_domains(adev, bo->flags); 303 303 int ret; 304 304 bool reads = (direction == DMA_BIDIRECTIONAL || 305 305 direction == DMA_FROM_DEVICE);
+6 -6
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
··· 131 131 int aligned_size, size; 132 132 int height = mode_cmd->height; 133 133 u32 cpp; 134 + u64 flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 135 + AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | 136 + AMDGPU_GEM_CREATE_VRAM_CLEARED | 137 + AMDGPU_GEM_CREATE_CPU_GTT_USWC; 134 138 135 139 info = drm_get_format_info(adev->ddev, mode_cmd); 136 140 cpp = info->cpp[0]; ··· 142 138 /* need to align pitch with crtc limits */ 143 139 mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp, 144 140 fb_tiled); 145 - domain = amdgpu_display_supported_domains(adev); 141 + domain = amdgpu_display_supported_domains(adev, flags); 146 142 height = ALIGN(mode_cmd->height, 8); 147 143 size = mode_cmd->pitches[0] * height; 148 144 aligned_size = ALIGN(size, PAGE_SIZE); 149 - ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, 150 - AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 151 - AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | 152 - AMDGPU_GEM_CREATE_VRAM_CLEARED | 153 - AMDGPU_GEM_CREATE_CPU_GTT_USWC, 145 + ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, flags, 154 146 ttm_bo_type_kernel, NULL, &gobj); 155 147 if (ret) { 156 148 pr_err("failed to allocate framebuffer (%d)\n", aligned_size);
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 765 765 args->size = (u64)args->pitch * args->height; 766 766 args->size = ALIGN(args->size, PAGE_SIZE); 767 767 domain = amdgpu_bo_get_preferred_pin_domain(adev, 768 - amdgpu_display_supported_domains(adev)); 768 + amdgpu_display_supported_domains(adev, flags)); 769 769 r = amdgpu_gem_object_create(adev, args->size, 0, domain, flags, 770 770 ttm_bo_type_device, NULL, &gobj); 771 771 if (r)
+1 -1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 4454 4454 } 4455 4455 4456 4456 if (plane->type != DRM_PLANE_TYPE_CURSOR) 4457 - domain = amdgpu_display_supported_domains(adev); 4457 + domain = amdgpu_display_supported_domains(adev, rbo->flags); 4458 4458 else 4459 4459 domain = AMDGPU_GEM_DOMAIN_VRAM; 4460 4460