All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] drm/amdkfd: mark GFX12 system and peer GPU memory mappings as MTYPE_NC
@ 2024-05-04 19:35 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2024-05-04 19:35 UTC (permalink / raw
  To: sreekant.somasekharan; +Cc: amd-gfx

Hello Sreekant Somasekharan,

This is a semi-automatic email about new static checker warnings.

Commit 628e1ace2379 ("drm/amdkfd: mark GFX12 system and peer GPU
memory mappings as MTYPE_NC") from Mar 26, 2024, leads to the
following Smatch complaint:

    drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c:518 gmc_v12_0_get_vm_pte()
    warn: variable dereferenced before check 'bo' (see line 500)

drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
   499		struct amdgpu_bo *bo = mapping->bo_va->base.bo;
   500		struct amdgpu_device *bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
                                                                ^^^^
   501		bool coherent = bo->flags & AMDGPU_GEM_CREATE_COHERENT;
                                ^^^^^^^^^
   502		bool is_system = bo->tbo.resource->mem_type == TTM_PL_SYSTEM;
                                 ^^^^^^^
The patch adds unchecked dereferences.

   503	
   504	
   505		*flags &= ~AMDGPU_PTE_EXECUTABLE;
   506		*flags |= mapping->flags & AMDGPU_PTE_EXECUTABLE;
   507	
   508		*flags &= ~AMDGPU_PTE_MTYPE_GFX12_MASK;
   509		*flags |= (mapping->flags & AMDGPU_PTE_MTYPE_GFX12_MASK);
   510	
   511		if (mapping->flags & AMDGPU_PTE_PRT_GFX12) {
   512			*flags |= AMDGPU_PTE_PRT_GFX12;
   513			*flags |= AMDGPU_PTE_SNOOPED;
   514			*flags |= AMDGPU_PTE_SYSTEM;
   515			*flags &= ~AMDGPU_PTE_VALID;
   516		}
   517	
   518		if (bo && bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
                    ^^
But previously we assumed bo could be NULL.

   519				       AMDGPU_GEM_CREATE_UNCACHED))
   520			*flags = (*flags & ~AMDGPU_PTE_MTYPE_GFX12_MASK) |

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-06 10:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-04 19:35 [bug report] drm/amdkfd: mark GFX12 system and peer GPU memory mappings as MTYPE_NC Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.