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

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: zero-initialize GART table on allocation

GART TLB is flushed after unmapping but not after mapping. Since
amdgpu_bo_create_kernel() does not zero-initialize the buffer, when a
single PTE is written the TLB may speculatively load other uninitialized
entries from the same cacheline. Those garbage entries can appear valid,
and a subsequent write to another PTE in the same cacheline may cause the
GPU to use a stale garbage PTE from the TLB.

Fix this by calling memset_io() to zero-initialize the GART table with
gart_pte_flags immediately after allocation.

Using AMDGPU_GEM_CREATE_VRAM_CLEARED, SDMA-based clear will not work
since SDMA needs GART to be initialized to work.

Suggested-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit d9af8263b82b6eaa60c5718e0c6631c5037e4b24)
Cc: stable@vger.kernel.org

authored by

Philip Yang and committed by
Alex Deucher
e6c2e6c2 78d2e624

+10 -3
+10 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
··· 262 262 */ 263 263 int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev) 264 264 { 265 + int r; 266 + 265 267 if (adev->gart.bo != NULL) 266 268 return 0; 267 269 268 - return amdgpu_bo_create_kernel(adev, adev->gart.table_size, PAGE_SIZE, 269 - AMDGPU_GEM_DOMAIN_VRAM, &adev->gart.bo, 270 - NULL, (void *)&adev->gart.ptr); 270 + r = amdgpu_bo_create_kernel(adev, adev->gart.table_size, PAGE_SIZE, 271 + AMDGPU_GEM_DOMAIN_VRAM, &adev->gart.bo, 272 + NULL, (void *)&adev->gart.ptr); 273 + if (r) 274 + return r; 275 + 276 + memset_io(adev->gart.ptr, adev->gart.gart_pte_flags, adev->gart.table_size); 277 + return 0; 271 278 } 272 279 273 280 /**