drm/amdgpu: Add gfx v12 pte/pde format change
Subsystems (2)
Alex Deucher
maintainerPATCH 1/5 drm/amdgpu: Add gfx v12 pte/pde format change
From: Hawking Zhang <[email protected]>
Add gfx v12 pte/pde format change.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +13 -0
@@ -111,6 +111,19 @@ struct amdgpu_mem_stats;#define AMDGPU_PTE_MTYPE_NV10 (a) ((uint64_t)(a) << 48)#define AMDGPU_PTE_MTYPE_NV10_MASK AMDGPU_PTE_MTYPE_NV10(7ULL) +/* gfx12 */ +#define AMDGPU_PTE_PRT_GFX12 (1ULL << 56) + +#define AMDGPU_PTE_MTYPE_GFX12 (a) ((uint64_t)(a) << 54) +#define AMDGPU_PTE_MTYPE_GFX12_MASK AMDGPU_PTE_MTYPE_GFX12(3ULL) + +#define AMDGPU_PTE_IS_PTE (1ULL << 63) + +/* PDE Block Fragment Size for gfx v12 */ +#define AMDGPU_PDE_BFS_GFX12 (a) ((uint64_t)((a) & 0x1fULL) << 58) +/* PDE is handled as PTE for gfx v12 */ +#define AMDGPU_PDE_PTE_GFX12 (1ULL << 63) +/* How to program VM fault handling */ #define AMDGPU_VM_FAULT_STOP_NEVER 0#define AMDGPU_VM_FAULT_STOP_FIRST 1
Signature · 1 line
2.44.0
Alex Deucher
maintainerPATCH 2/5 drm/amdgpu: Add gmc v12_0 ip block support (v7)
From: Hawking Zhang <[email protected]>
Add initial support for GMC v12.
v1: Add gmc v12_0 ip block support.
v2: Switch to gfx.kiq array.
v3: Switch to vmhubs_mask.
v4: Switch to AMDGPU_MMHUB0(0) and AMDGPU_GFXHUB(0)
v5: Rebase (Alex)
v6: Squash in fixes for AGP handling, gfxhub init order,
vmhub index (Alex)
v7: Rebase (Alex)
v8: squash in ecc fix (Alex)
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 1000 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gmc_v12_0.h | 30 + 3 files changed, 1031 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c create mode 100644 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -116,7 +116,7 @@ amdgpu-y += \ gfxhub_v2_0.o mmhub_v2_0.o gmc_v10_0.o gfxhub_v2_1.o mmhub_v2_3.o \ mmhub_v1_7.o gfxhub_v3_0.o mmhub_v3_0.o mmhub_v3_0_2.o gmc_v11_0.o \ mmhub_v3_0_1.o gfxhub_v3_0_3.o gfxhub_v1_2.o mmhub_v1_8.o mmhub_v3_3.o \ - gfxhub_v11_5_0.o mmhub_v4_1_0.o gfxhub_v12_0.o + gfxhub_v11_5_0.o mmhub_v4_1_0.o gfxhub_v12_0.o gmc_v12_0.o # add UMC block amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c new file +1000 -0
1,000 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Copyright 2023 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef __GMC_V12_0_H__ +#define __GMC_V12_0_H__ + +extern const struct amd_ip_funcs gmc_v12_0_ip_funcs; +extern const struct amdgpu_ip_block_version gmc_v12_0_ip_block; + +#endif
Signature · 1 line
2.44.0
Alex Deucher
maintainerPATCH 3/5 drm/amdgpu: Set pte_is_pte flag in gmc v12 gart
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
pte_is_pte is new flag introduced in gmc v12 that needs to be set by default for pte.
--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +2 -1
@@ -686,7 +686,8 @@ static int gmc_v12_0_gart_init(struct amdgpu_device *adev) adev->gart.table_size = adev->gart.num_gpu_pages *8 ; adev->gart.gart_pte_flags =AMDGPU_PTE_MTYPE_GFX12 (MTYPE_UC ) | -AMDGPU_PTE_EXECUTABLE ; +AMDGPU_PTE_EXECUTABLE | +AMDGPU_PTE_IS_PTE ;return amdgpu_gart_table_vram_alloc (adev); }
Signature · 1 line
2.44.0
Alex Deucher
maintainerPATCH 4/5 drm/amdgpu: support gfx v12 specific pte/pde fields
In reply to Alex DeucherFrom: Hawking Zhang <[email protected]>
Add gfx v12 pte/pde support to gmc common helper.
v2: squash in fixes (Alex)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 ++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 6 +++--- 5 files changed, 18 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -1
@@ -683,7 +683,7 @@ uint64_t amdgpu_gem_va_map_flags(struct amdgpu_device *adev, uint32_t flags)if (flags &AMDGPU_VM_PAGE_WRITEABLE ) pte_flag |=AMDGPU_PTE_WRITEABLE ;if (flags &AMDGPU_VM_PAGE_PRT ) - pte_flag |=AMDGPU_PTE_PRT ; + pte_flag |=AMDGPU_PTE_PRT_FLAG (adev);if (flags &AMDGPU_VM_PAGE_NOALLOC ) pte_flag |=AMDGPU_PTE_NOALLOC ;
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +2 -2
@@ -1015,7 +1015,7 @@ void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev) flags |=AMDGPU_PTE_WRITEABLE ; flags |=AMDGPU_PTE_SNOOPED ; flags |=AMDGPU_PTE_FRAG ((adev->gmc.vmid0_page_table_block_size +9 *1 )); - flags |=AMDGPU_PDE_PTE ; + flags |=AMDGPU_PDE_PTE_FLAG (adev);/* The first n PDE0 entries are used as PTE, * pointing to vram
@@ -1028,7 +1028,7 @@ void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev)* pointing to a 4K system page */ flags =AMDGPU_PTE_VALID ; - flags |=AMDGPU_PDE_BFS (0 ) |AMDGPU_PTE_SNOOPED ; + flags |=AMDGPU_PTE_SNOOPED |AMDGPU_PDE_BFS_FLAG (adev,0 );/* Requires gart_ptb_gpu_pa to be 4K aligned */ amdgpu_gmc_set_pte_pde (adev, adev->gmc.ptr_pdb0, i, gart_ptb_gpu_pa, flags);drm_dev_exit (idx);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -6
@@ -1055,7 +1055,7 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, params.pages_addr =NULL ; } - }else if (flags & (AMDGPU_PTE_VALID |AMDGPU_PTE_PRT )) { + }else if (flags & (AMDGPU_PTE_VALID |AMDGPU_PTE_PRT_FLAG (adev))) { addr = vram_base + cursor.start; }else { addr =0 ;
@@ -1369,7 +1369,7 @@ static void amdgpu_vm_free_mapping(struct amdgpu_device *adev, struct amdgpu_bo_va_mapping *mapping, struct dma_fence *fence) { -if (mapping->flags &AMDGPU_PTE_PRT ) +if (mapping->flags &AMDGPU_PTE_PRT_FLAG (adev))amdgpu_vm_add_prt_cb (adev, fence);kfree (mapping); }
@@ -1637,7 +1637,7 @@ static void amdgpu_vm_bo_insert_map(struct amdgpu_device *adev,list_add (&mapping->list, &bo_va->invalids);amdgpu_vm_it_insert (mapping, &vm->va); -if (mapping->flags &AMDGPU_PTE_PRT ) +if (mapping->flags &AMDGPU_PTE_PRT_FLAG (adev))amdgpu_vm_prt_get (adev); if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv &&
@@ -1939,7 +1939,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,struct amdgpu_bo *bo = before->bo_va->base.bo;amdgpu_vm_it_insert (before, &vm->va); -if (before->flags &AMDGPU_PTE_PRT ) +if (before->flags &AMDGPU_PTE_PRT_FLAG (adev))amdgpu_vm_prt_get (adev); if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv &&
@@ -1954,7 +1954,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,struct amdgpu_bo *bo = after->bo_va->base.bo;amdgpu_vm_it_insert (after, &vm->va); -if (after->flags &AMDGPU_PTE_PRT ) +if (after->flags &AMDGPU_PTE_PRT_FLAG (adev))amdgpu_vm_prt_get (adev); if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv &&
@@ -2605,7 +2605,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)dma_fence_put (vm->last_tlb_flush);list_for_each_entry_safe (mapping, tmp, &vm->freed, list) { -if (mapping->flags &AMDGPU_PTE_PRT && prt_fini_needed) { +if (mapping->flags &AMDGPU_PTE_PRT_FLAG (adev) && prt_fini_needed) {amdgpu_vm_prt_fini (adev, vm); prt_fini_needed = false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +6 -0
@@ -113,6 +113,8 @@ struct amdgpu_mem_stats;/* gfx12 */ #define AMDGPU_PTE_PRT_GFX12 (1ULL << 56) +#define AMDGPU_PTE_PRT_FLAG (adev) \ + ((amdgpu_ip_version((adev), GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) ? AMDGPU_PTE_PRT_GFX12 : AMDGPU_PTE_PRT)#define AMDGPU_PTE_MTYPE_GFX12 (a) ((uint64_t)(a) << 54)#define AMDGPU_PTE_MTYPE_GFX12_MASK AMDGPU_PTE_MTYPE_GFX12(3ULL)
@@ -121,8 +123,12 @@ struct amdgpu_mem_stats;/* PDE Block Fragment Size for gfx v12 */ #define AMDGPU_PDE_BFS_GFX12 (a) ((uint64_t)((a) & 0x1fULL) << 58) +#define AMDGPU_PDE_BFS_FLAG (adev, a) \ + ((amdgpu_ip_version((adev), GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) ? AMDGPU_PDE_BFS_GFX12(a) : AMDGPU_PDE_BFS(a))/* PDE is handled as PTE for gfx v12 */ #define AMDGPU_PDE_PTE_GFX12 (1ULL << 63) +#define AMDGPU_PDE_PTE_FLAG (adev) \ + ((amdgpu_ip_version((adev), GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) ? AMDGPU_PDE_PTE_GFX12: AMDGPU_PDE_PTE)/* How to program VM fault handling */ #define AMDGPU_VM_FAULT_STOP_NEVER 0
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +3 -3
@@ -413,7 +413,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (adev->asic_type >=CHIP_VEGA10 ) {if (level !=AMDGPU_VM_PTB ) {/* Handle leaf PDEs as PTEs */ - flags |=AMDGPU_PDE_PTE ; + flags |=AMDGPU_PDE_PTE_FLAG (adev);amdgpu_gmc_get_vm_pde (adev, level, &value, &flags); }else {
@@ -757,12 +757,12 @@ static void amdgpu_vm_pte_update_flags(struct amdgpu_vm_update_params *params,struct amdgpu_device *adev = params->adev;if (level !=AMDGPU_VM_PTB ) { - flags |=AMDGPU_PDE_PTE ; + flags |=AMDGPU_PDE_PTE_FLAG (params->adev);amdgpu_gmc_get_vm_pde (adev, level, &addr, &flags); }else if (adev->asic_type >=CHIP_VEGA10 && !(flags &AMDGPU_PTE_VALID ) && - !(flags &AMDGPU_PTE_PRT )) { + !(flags &AMDGPU_PTE_PRT_FLAG (params->adev))) {/* Workaround for fault priority problem on GMC9 */ flags |=AMDGPU_PTE_EXECUTABLE ;
Signature · 1 line
2.44.0
Alex Deucher
maintainerPATCH 5/5 drm/amdgpu/discovery: Add gmc v12_0 ip block
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Add gmc v12_0 ip block.
v2: Squash in updates (Alex)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +5 -0
@@ -55,6 +55,7 @@#include "smuio_v9_0.h" #include "gmc_v10_0.h" #include "gmc_v11_0.h" +#include "gmc_v12_0.h" #include "gfxhub_v2_0.h" #include "mmhub_v2_0.h" #include "nbio_v2_3.h"
@@ -1753,6 +1754,10 @@ static int amdgpu_discovery_set_gmc_ip_blocks(struct amdgpu_device *adev)case IP_VERSION (11 ,5 ,1 ):amdgpu_device_ip_block_add (adev, &gmc_v11_0_ip_block);break ; +case IP_VERSION (12 ,0 ,0 ): +case IP_VERSION (12 ,0 ,1 ): +amdgpu_device_ip_block_add (adev, &gmc_v12_0_ip_block); +break ;default :dev_err (adev->dev,"Failed to add gmc ip block(GC_HWIP:0x%x)\n" ,amdgpu_ip_version (adev,GC_HWIP ,0 ));
Signature · 1 line
2.44.0