drm/amdgpu: add SRAT lookup for GPU-local memory
Subsystems (3)
PATCH 1/6 drm/amdgpu: add SRAT lookup for GPU-local memory
On A+A the GPU HBM is exposed as specific-purpose memory described by SRAT, and the GPU reaches it at a system physical address over the internal link, so the driver needs a way to discover that range.
Add amdgpu_acpi_find_gpu_memory_in_srat(), which resolves the GPU proximity domain from the SRAT GENERIC_AFFINITY entry matching the PCI device handle, then returns the enabled, non-hotpluggable memory range of that domain.
No caller yet, the users follow.
v2:
- A+A VF/passthrough is identified later by missing FB BAR0 (AMDGPU_VIRT_VRAM_IS_SPM), not by xgmi.connected_to_cpu.
v3:
- Rename best_base/best_len to mem_base/mem_len; first match, not a comparison.
- Drop the unused legacy packed-BDF PCI handle format.
- Log "no acpi generic initiator found" without extra PCI BDF.
- Use dev_err for error-return logs.
v4:
- Reverse Christmas-tree local declarations, one per line.
- Reject NULL base_addr/length with -EINVAL.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 136 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.h | 7 ++ 2 files changed, 143 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +136 -0
@@ -28,6 +28,7 @@#include <linux/slab.h> #include <linux/xarray.h> #include <linux/power_supply.h> +#include <linux/numa.h> #include <linux/pm_runtime.h> #include <linux/suspend.h> #include <acpi/video.h>
@@ -1445,6 +1446,141 @@ bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev)#endif } +#ifdef HAVE_ACPI_SRAT_GENERIC_AFFINITY +static bool amdgpu_acpi_srat_pci_handle_match (struct pci_dev *pdev, +struct acpi_srat_generic_affinity *gi) +{ +u16 segment = *(u16 *)&gi->device_handle[0 ]; +u8 bus = gi->device_handle[2 ]; +u8 devfn = gi->device_handle[3 ]; + +/* Only PCI device handles (ACPI 6.3: type 1; some firmware used 0) */ +if (gi->device_handle_type !=0 && gi->device_handle_type !=1 ) +return false; + +if (!(gi->flags &ACPI_SRAT_GENERIC_AFFINITY_ENABLED )) +return false; + +/* ACPI 6.3 Table 5-80: segment + bus + devfn bytes */ +return segment ==pci_domain_nr (pdev->bus) && + bus == pdev->bus->number && + devfn == pdev->devfn; +} + +int amdgpu_acpi_find_gpu_memory_in_srat (struct amdgpu_device *adev, +uint64_t *base_addr,uint64_t *length) +{ +struct acpi_srat_generic_affinity *gpu; +struct acpi_subtable_header *sub_header; +struct acpi_table_header *table_header; +struct acpi_srat_mem_affinity *mem; +struct pci_dev *pdev = adev->pdev; +unsigned long subtable_len; +unsigned long table_end; +acpi_status status; +bool pxm_found = false; +bool mem_found = false; +u64 mem_base =0 ; +u64 mem_len =0 ; +u32 gpu_pxm =0 ; + +if (!base_addr || !length) +return -EINVAL ; + + status =acpi_get_table (ACPI_SIG_SRAT ,0 , &table_header); +if (ACPI_FAILURE (status)) +return -ENOENT ; + + table_end = (unsigned long )table_header + table_header->length; + +/* Pass 1: find GPU PXM from GENERIC_AFFINITY */ + sub_header = (struct acpi_subtable_header *) + ((unsigned long )table_header +sizeof (struct acpi_table_srat )); + subtable_len = sub_header->length; + +while (((unsigned long )sub_header) + subtable_len <= table_end) { +if (subtable_len ==0 ) +break ; + +if (sub_header->type ==ACPI_SRAT_TYPE_GENERIC_AFFINITY ) { + gpu = (struct acpi_srat_generic_affinity *)sub_header; +if (amdgpu_acpi_srat_pci_handle_match (pdev, gpu)) { + gpu_pxm = gpu->proximity_domain; + pxm_found = true; +break ; + } + } + + sub_header = (struct acpi_subtable_header *) + ((unsigned long )sub_header + subtable_len); + subtable_len = sub_header->length; + } + +if (!pxm_found) { +acpi_put_table (table_header); +dev_err (adev->dev,"SRAT: no acpi generic initiator found\n" ); +return -ENOENT ; + } + +/* Pass 2: find SPM memory for gpu_pxm */ + sub_header = (struct acpi_subtable_header *) + ((unsigned long )table_header +sizeof (struct acpi_table_srat )); + subtable_len = sub_header->length; + +while (((unsigned long )sub_header) + subtable_len <= table_end) { +if (subtable_len ==0 ) +break ; + +if (sub_header->type ==ACPI_SRAT_TYPE_MEMORY_AFFINITY ) { +bool enabled, hotplug; + + mem = (struct acpi_srat_mem_affinity *)sub_header; + enabled = mem->flags &ACPI_SRAT_MEM_ENABLED ; + hotplug = mem->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE ; + +/* MUST filter ENABLED && !HOTPLUGGABLE */ +if (enabled && !hotplug && + mem->proximity_domain == gpu_pxm) { +/* [mem->base_address, mem->length] is the SPM range */ + mem_base = mem->base_address; + mem_len = mem->length; + mem_found = true; +break ; + } + } + + sub_header = (struct acpi_subtable_header *) + ((unsigned long )sub_header + subtable_len); + subtable_len = sub_header->length; + } + +acpi_put_table (table_header); + +if (!mem_found) { +dev_err (adev->dev,"SRAT: no memory affinity for pxm %u\n" , + gpu_pxm); +return -ENOENT ; + } + +dev_info (adev->dev,"SRAT: gpu pxm=%u base=%llx length=%llx\n" , + gpu_pxm, mem_base, mem_len); + + *base_addr = mem_base; + *length = mem_len; + +return 0 ; +} +#else +int amdgpu_acpi_find_gpu_memory_in_srat (struct amdgpu_device *adev, +uint64_t *base_addr,uint64_t *length) +{ +if (!base_addr || !length) +return -EINVAL ; + +return -ENOENT ; +} +#endif +/* * amdgpu_acpi_detect - detect ACPI ATIF/ATCS methods *
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.h +7 -0
@@ -102,6 +102,8 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,void amdgpu_acpi_get_backlight_caps (struct amdgpu_dm_backlight_caps *caps);bool amdgpu_acpi_should_gpu_reset (struct amdgpu_device *adev); +int amdgpu_acpi_find_gpu_memory_in_srat (struct amdgpu_device *adev, +uint64_t *base_addr,uint64_t *length);void amdgpu_acpi_detect (void );void amdgpu_acpi_release (void );#else
@@ -117,6 +119,11 @@ static inline int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, {return -EINVAL ; } +static inline int amdgpu_acpi_find_gpu_memory_in_srat (struct amdgpu_device *adev, +uint64_t *base_addr,uint64_t *length) +{ +return -EINVAL ; +}static inline void amdgpu_acpi_fini (struct amdgpu_device *adev) { }static inline bool amdgpu_acpi_should_gpu_reset (struct amdgpu_device *adev) {return false; }static inline void amdgpu_acpi_detect (void ) { }
Signature · 1 line
2.43.0
PATCH 2/6 drm/amdgpu: add helper for VRAM in system physical memory
On A+A, HBM is reached at a host physical address, so VRAM mappings need the system-memory path. That is true for both an SR-IOV VF and a passthrough VM; native PF A+A keeps the mmhub/sysvm path.
Add AMDGPU_VIRT_VRAM_IS_SPM and amdgpu_virt_vram_is_spm() so later patches can identify SPM-backed VRAM without repeating the cap test.
v2:
- Rename the helper to amdgpu_virt_vram_is_spm(); it only tests AMDGPU_VIRT_VRAM_IS_SPM.
- Set the cap in ip_early_init when an SR-IOV VF or passthrough dGPU has no FB BAR0, after AMD_IS_APU is known.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 4 ++++ 2 files changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
@@ -2085,6 +2085,10 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)if (!(adev->flags &AMD_IS_APU )) { parent =amdgpu_device_find_parent (adev); adev->has_pr3 = parent ?pci_pr3_present (parent) : false; + +if ((amdgpu_sriov_vf (adev) ||amdgpu_passthrough (adev)) && + !pci_resource_len (adev->pdev,0 )) + adev->virt.caps |=AMDGPU_VIRT_VRAM_IS_SPM ; } adev->pm.pp_feature = amdgpu_pp_feature_mask;
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +4 -0
@@ -32,6 +32,7 @@#define AMDGPU_PASSTHROUGH_MODE (1 << 3)/* thw whole GPU is pass through for VM */ #define AMDGPU_SRIOV_CAPS_RUNTIME (1 << 4)/* is out of full access mode */ #define AMDGPU_VF_MMIO_ACCESS_PROTECT (1 << 5)/* MMIO write access is not allowed in sriov runtime */ +#define AMDGPU_VIRT_VRAM_IS_SPM (1 << 6)/* FB BAR0 is absent; VRAM is SPM */ /* flags for indirect register access path supported by rlcg for sriov */ #define AMDGPU_RLCG_GC_WRITE_LEGACY (0x8 << 28)
@@ -406,6 +407,9 @@ struct amdgpu_video_codec_info;#define amdgpu_passthrough (adev) \ ((adev)->virt.caps & AMDGPU_PASSTHROUGH_MODE) +#define amdgpu_virt_vram_is_spm (adev) \ +((adev)->virt.caps & AMDGPU_VIRT_VRAM_IS_SPM) +#define amdgpu_sriov_vf_mmio_access_protection (adev) \ ((adev)->virt.caps & AMDGPU_VF_MMIO_ACCESS_PROTECT)
Signature · 1 line
2.43.0
PATCH 3/6 drm/amdgpu: fetch the A+A VF VBIOS from the SRAT HBM range
In reply to Zhigang LuoOn A+A the VF has no usable FB BAR, so the VBIOS copy cannot be read through BAR 0. It lives in HBM, which the SRAT describes as specific-purpose memory reachable at a system physical address.
Add a dedicated amdgpu_read_bios_from_spm() path that resolves the HBM range from SRAT and maps it as write-back system memory. Keep the existing SR-IOV dynamic critical region path when it is enabled, matching the VRAM reader.
v2:
- Use a separate amdgpu_read_bios_from_spm() helper and leave amdgpu_read_bios_from_vram() unchanged.
- Keep the SR-IOV dynamic critical region path for SPM-backed VBIOS.
- Fetch VBIOS after the COMMON block and make it optional for SPM-backed SR-IOV VF and passthrough configurations.
v3:
- Keep the SRAT range local to the VBIOS path; GMC owns aper_base and aper_size.
- Map SPM with memremap(), memcpy(), and memunmap().
- Rely on amdgpu_virt_vram_is_spm() without redundant VF/passthrough checks.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 55 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++ 2 files changed, 58 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +55 -0
@@ -152,6 +152,56 @@ static bool amdgpu_read_bios_from_vram(struct amdgpu_device *adev)return true; } +static bool amdgpu_read_bios_from_spm (struct amdgpu_device *adev) +{ +u64 spm_base, spm_size; +void *bios =NULL ; +u32 size =256U *1024U ;/* ??? */ +int r; + +if (!amdgpu_virt_vram_is_spm (adev)) +return false; + + r =amdgpu_acpi_find_gpu_memory_in_srat (adev, &spm_base, &spm_size); +if (r) +return false; + + adev->bios =kmalloc (size,GFP_KERNEL ); +if (!adev->bios) +return false; + +/* For SRIOV with dynamic critical region is enabled, +* the vbios image is put at a dynamic offset of VRAM in the VF. +* If dynamic critical region is disabled, read it from SPM. +*/ +if (amdgpu_sriov_vf (adev) && adev->virt.is_dynamic_crit_regn_enabled) { +if (amdgpu_virt_get_dynamic_data_info (adev, +AMD_SRIOV_MSG_VBIOS_IMG_TABLE_ID , + adev->bios, &size)) { +amdgpu_bios_release (adev); +return false; + } + }else { + bios =memremap (spm_base, size,MEMREMAP_WB ); +if (!bios) { +amdgpu_bios_release (adev); +return false; + } + +memcpy (adev->bios, bios, size); +memunmap (bios); + } + + adev->bios_size = size; + +if (!check_atom_bios (adev, size)) { +amdgpu_bios_release (adev); +return false; + } + +return true; +} +bool amdgpu_read_bios (struct amdgpu_device *adev) {uint8_t __iomem *bios;
@@ -530,6 +580,11 @@ static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev) goto success; } +if (amdgpu_read_bios_from_spm (adev)) { +dev_info (adev->dev,"Fetched VBIOS from SPM\n" ); + goto success; + } +/* this is required for SR-IOV */ if (amdgpu_read_bios_from_vram (adev)) {dev_info (adev->dev,"Fetched VBIOS from VRAM BAR\n" );
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -944,6 +944,9 @@ u32 amdgpu_device_get_rev_id(struct amdgpu_device *adev)static uint32_t amdgpu_device_get_vbios_flags (struct amdgpu_device *adev) { +if (amdgpu_virt_vram_is_spm (adev)) +return AMDGPU_VBIOS_OPTIONAL ; +if (hweight32 (adev->aid_mask) && (adev->flags &AMD_IS_APU ))return AMDGPU_VBIOS_SKIP ;
Signature · 1 line
2.43.0
PATCH 4/6 drm/amdgpu: take the A+A VF GMC aperture from SRAT
In reply to Zhigang LuoThe A+A VF FB BAR is not usable, so resolve its aperture from SRAT in GMC early_init. Skip later aperture assignment for SPM-backed devices, and restrict the existing mmhub-based override to native A+A and APU.
The GPU reaches its HBM at a system physical address, so vram_base_offset becomes aper_base as well, which makes PDB0 map GPU address 0 onto that address.
The XGMI node segment size comes from the same place: once early_init has resolved the aperture, use its size rather than the value derived from the register, which does not describe the VF partition.
v2:
- Use (sriov_vf || passthrough) and amdgpu_virt_vram_is_spm() instead of connected_to_cpu for the SRAT aperture and node segment size.
v3:
- Resolve the SRAT aperture in GMC early_init and skip later aperture assignment in mc_init for SPM-backed devices.
- Rely on amdgpu_virt_vram_is_spm() without redundant VF/passthrough checks.
--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 53 ++++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c | 5 ++- 2 files changed, 45 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +41 -12
@@ -638,6 +638,7 @@ static void gmc_v12_0_set_gfxhub_funcs(struct amdgpu_device *adev)static int gmc_v12_0_early_init (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; +int r;if (adev->smuio.funcs && adev->smuio.funcs->is_host_gpu_xgmi_supported)
@@ -660,6 +661,14 @@ static int gmc_v12_0_early_init(struct amdgpu_ip_block *ip_block)gmc_v12_0_set_mmhub_funcs (adev);gmc_v12_0_set_umc_funcs (adev); +if (amdgpu_virt_vram_is_spm (adev)) { + r =amdgpu_acpi_find_gpu_memory_in_srat (adev, + &adev->gmc.aper_base, + &adev->gmc.aper_size); +if (r) +return r; + } + adev->gmc.shared_aperture_start =0x2000000000000000ULL ; adev->gmc.shared_aperture_end = adev->gmc.shared_aperture_start + (4ULL <<30 ) -1 ;
@@ -706,10 +715,19 @@ static void gmc_v12_0_vram_gtt_location(struct amdgpu_device *adev,amdgpu_gmc_agp_location (adev, mc); }/* base offset of vram pages */ -if (amdgpu_sriov_vf (adev)) +if (amdgpu_virt_vram_is_spm (adev)) { +/* +* For SPM-backed VRAM, PDB0 entries use PTE_SYSTEM, so the +* address is a system physical address. vram_base_offset must +* be aper_base so PDB0 maps GPU address 0 onto the HBM system +* physical address. +*/ + adev->vm_manager.vram_base_offset = adev->gmc.aper_base; + }else if (amdgpu_sriov_vf (adev)) { adev->vm_manager.vram_base_offset =0 ; -else + }else { adev->vm_manager.vram_base_offset = adev->mmhub.funcs->get_mc_fb_offset (adev); + } adev->vm_manager.vram_base_offset += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size;
@@ -746,17 +764,28 @@ static int gmc_v12_0_mc_init(struct amdgpu_device *adev)return r; } - adev->gmc.aper_base =pci_resource_start (adev->pdev,0 ); - adev->gmc.aper_size =pci_resource_len (adev->pdev,0 ); -#ifdef CONFIG_X86_64 -if (((adev->flags &AMD_IS_APU ) && !amdgpu_passthrough (adev)) || - (adev->gmc.xgmi.connected_to_cpu)) { - adev->gmc.aper_base = - adev->mmhub.funcs->get_mc_fb_offset (adev) + - adev->gmc.xgmi.physical_node_id * - adev->gmc.xgmi.node_segment_size; - adev->gmc.aper_size = adev->gmc.real_vram_size; +/* +* SPM-backed devices resolve the aperture from SRAT during early_init. +* For native A+A (non-VF) or APU, override aper_base using mmhub +* offset. Otherwise derive the aperture from BAR 0. +*/ +if (!amdgpu_virt_vram_is_spm (adev)) { +if (!amdgpu_sriov_vf (adev) && + (((adev->flags &AMD_IS_APU ) && + !amdgpu_passthrough (adev)) || + adev->gmc.xgmi.connected_to_cpu)) { + adev->gmc.aper_base = + adev->mmhub.funcs->get_mc_fb_offset (adev) + + adev->gmc.xgmi.physical_node_id * + adev->gmc.xgmi.node_segment_size; + adev->gmc.aper_size = adev->gmc.real_vram_size; + }else { + adev->gmc.aper_base = +pci_resource_start (adev->pdev,0 ); + adev->gmc.aper_size = +pci_resource_len (adev->pdev,0 ); + } }#endif /* In case the PCI BAR is larger than the actual amount of vram */
drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c +4 -1
@@ -154,7 +154,10 @@ static int mmhub_v4_2_0_get_xgmi_info(struct amdgpu_device *adev)if (adev->gmc.xgmi.physical_node_id > max_physical_node_id)return -EINVAL ; - adev->gmc.xgmi.node_segment_size = seg_size; +if (amdgpu_virt_vram_is_spm (adev) && adev->gmc.aper_size) + adev->gmc.xgmi.node_segment_size = adev->gmc.aper_size; +else + adev->gmc.xgmi.node_segment_size = seg_size;return 0 ; }
Signature · 1 line
2.43.0
PATCH 5/6 drm/amdgpu: mark A+A VF VRAM mappings as system memory
In reply to Zhigang LuoOn the A+A VF the GPU reaches its HBM over the system memory path at a system physical address, so page table entries covering VRAM have to carry AMDGPU_PTE_SYSTEM and the addresses they hold have to be physical rather than MC addresses.
Set the SYSTEM bit in the PDB0 entries and in amdgpu_ttm_tt_pde_flags(), and convert the VRAM address in amdgpu_gmc_get_pde_for_bo() with amdgpu_gmc_vram_mc2pa().
NPA mappings still require VSCT=0011 (PTE.S=0). Clear SYSTEM in gmc_v12_1_get_npa_flags() and amdgpu_ualink_peer_remote_init() so NPA PTEs do not inherit the VRAM SYSTEM bit.
v2:
- Use (sriov_vf || passthrough) and amdgpu_virt_vram_is_spm() for PDB0/TTM SYSTEM bits and mc2pa.
v3:
- Rely on amdgpu_virt_vram_is_spm() without redundant VF/passthrough checks.
v4:
- Explicitly clear AMDGPU_PTE_SYSTEM for NPA (VSCT=0011).
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 +++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 1 + 4 files changed, 22 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +9 -0
@@ -120,6 +120,11 @@ void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level,break ;case TTM_PL_VRAM : *addr =amdgpu_bo_gpu_offset (bo); +/* For SPM-backed VRAM, convert the MC address to a physical +* address for system memory path access. +*/ +if (amdgpu_virt_vram_is_spm (adev)) + *addr =amdgpu_gmc_vram_mc2pa (adev, *addr);break ;default : *addr =0 ;
@@ -1159,6 +1164,8 @@ void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev) flags |=AMDGPU_PTE_VALID |AMDGPU_PTE_READABLE ; flags |=AMDGPU_PTE_WRITEABLE ; flags |=AMDGPU_PTE_SNOOPED ; +if (amdgpu_virt_vram_is_spm (adev)) + flags |=AMDGPU_PTE_SYSTEM ; flags |=AMDGPU_PTE_FRAG ((adev->gmc.vmid0_page_table_block_size +9 *1 )); flags |=AMDGPU_PDE_PTE_FLAG (adev);
@@ -1178,6 +1185,8 @@ void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev)* pointing to a 4K system page */ flags =AMDGPU_PTE_VALID ; +if (amdgpu_virt_vram_is_spm (adev)) + flags |=AMDGPU_PTE_SYSTEM ; 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);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +11 -3
@@ -1460,9 +1460,17 @@ uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem) flags |=AMDGPU_PTE_SNOOPED ; } -if (mem && mem->mem_type ==TTM_PL_VRAM && - mem->bus.caching == ttm_cached) - flags |=AMDGPU_PTE_SNOOPED ; +if (mem && mem->mem_type ==TTM_PL_VRAM ) { +if (mem->bo) { +struct amdgpu_device *adev =amdgpu_ttm_adev (mem->bo->bdev); + +if (amdgpu_virt_vram_is_spm (adev)) + flags |=AMDGPU_PTE_SYSTEM ; + } + +if (mem->bus.caching == ttm_cached) + flags |=AMDGPU_PTE_SNOOPED ; + }return flags; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +1 -0
@@ -5876,6 +5876,7 @@ static int amdgpu_ualink_peer_remote_init(struct amdgpu_device *adev) flags =amdgpu_ttm_tt_pte_flags (adev, bo->tbo.ttm, bo->tbo.resource); flags |=AMDGPU_PTE_SNOOPED |AMDGPU_PTE_PRT_GFX12 |AMDGPU_PTE_BUS_ATOMICS ; flags &= ~AMDGPU_PTE_VALID ; + flags &= ~AMDGPU_PTE_SYSTEM ;/* PTE.X=0 turn off RPC checks for RBs, wptr and doorbell NPA address */ flags &= ~AMDGPU_PTE_EXECUTABLE ;
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +1 -0
@@ -616,6 +616,7 @@ static void gmc_v12_1_get_npa_flags(struct amdgpu_device *adev, *flags |=AMDGPU_PTE_SNOOPED |AMDGPU_PTE_PRT_GFX12 |AMDGPU_PTE_BUS_ATOMICS ; *flags &= ~AMDGPU_PTE_VALID ; + *flags &= ~AMDGPU_PTE_SYSTEM ; *flags &= ~AMDGPU_PTE_EXECUTABLE ; }
Signature · 1 line
2.43.0
PATCH 6/6 drm/amdkfd: mark A+A VF VRAM PTEs as system memory
In reply to Zhigang LuoOn the A+A VF, VRAM is accessed through the system memory path, so SVM range PTEs that point at VRAM need AMDGPU_PTE_SYSTEM set, matching what the graphics paths already do.
v2:
- Use (sriov_vf || passthrough) and amdgpu_virt_vram_is_spm() for SVM VRAM PTE_SYSTEM.
v3:
- Rely on amdgpu_virt_vram_is_spm() without redundant VF/passthrough checks.
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +7 -1
@@ -1374,7 +1374,13 @@ svm_range_get_pte_flags(struct kfd_node *node, struct amdgpu_vm *vm, mapping_flags |=AMDGPU_VM_PAGE_EXECUTABLE ; pte_flags =AMDGPU_PTE_VALID ; - pte_flags |= (domain ==SVM_RANGE_VRAM_DOMAIN ) ?0 :AMDGPU_PTE_SYSTEM ; +/* SPM-backed VRAM is accessed through the system memory path and +* requires the SYSTEM bit. +*/ +if (amdgpu_virt_vram_is_spm (node->adev)) + pte_flags |=AMDGPU_PTE_SYSTEM ; +else + pte_flags |= (domain ==SVM_RANGE_VRAM_DOMAIN ) ?0 :AMDGPU_PTE_SYSTEM ; pte_flags |= snoop ?AMDGPU_PTE_SNOOPED :0 ;if (gc_ip_version >=IP_VERSION (12 ,0 ,0 )) pte_flags |=AMDGPU_PTE_IS_PTE ;
Signature · 1 line
2.43.0