On GFX IPs with multiple XCCs each XCC has an own GFXHUB, but the setup_vm_pt_regs gfxhub callback programs a VMID's page table base on every XCC. Callers which bind a VMID on a single VMHUB, like the SPM VMID binding, have no way to reach one GFXHUB through the callback interface.
Extend the callback with the mask of logical XCCs to program. gfxhub v1.2 and v12.1 already implement an XCC-masked variant internally, hook it up directly and drop their broadcast wrappers; the implementations for IPs with a single XCC ignore the mask. All callers pass the full mask, no functional change. Signed-off-by: James Zhu <[email protected]> Assisted-by: Claude:claude-fable-5 --- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 3 ++- .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c | 3 ++- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c | 3 ++- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 ++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfxhub_v11_5_0.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/gfxhub_v12_0.c | 5 +++-- drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c | 13 +------------ drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 5 +++-- drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c | 12 +----------- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c | 4 ++-- 17 files changed, 48 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c index 1550e275f0ee..762b3a53ebbd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c @@ -708,7 +708,8 @@ static void set_vm_context_page_table_base(struct amdgpu_device *adev, } /* SDMA is on gfxhub as well for Navi1* series */ - adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base, + amdgpu_gfx_logical_xcc_mask(adev)); } /* diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c index 50535563efa8..837a17dd03de 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c @@ -626,7 +626,8 @@ static void set_vm_context_page_table_base_v10_3(struct amdgpu_device *adev, uint32_t vmid, uint64_t page_table_base) { /* SDMA is on gfxhub as well for Navi1* series */ - adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base, + amdgpu_gfx_logical_xcc_mask(adev)); } static void program_trap_handler_settings_v10_3(struct amdgpu_device *adev, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c index 96a308b94646..0c8983b353f2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c @@ -606,7 +606,8 @@ static void set_vm_context_page_table_base_v11(struct amdgpu_device *adev, } /* SDMA is on gfxhub as well for gfx11 adapters */ - adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base, + amdgpu_gfx_logical_xcc_mask(adev)); } /* diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c index 0bc8d31081e6..475058562b75 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c @@ -923,7 +923,8 @@ void kgd_gfx_v9_set_vm_context_page_table_base(struct amdgpu_device *adev, adev->mmhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); - adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base, + amdgpu_gfx_logical_xcc_mask(adev)); } static void lock_spi_csq_mutexes(struct amdgpu_device *adev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c index c5a2dcff5058..f42fe3510f16 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c @@ -170,6 +170,24 @@ static bool amdgpu_gfx_is_compute_multipipe_capable(struct amdgpu_device *adev) return adev->gfx.mec.num_mec > 1; } +/** + * amdgpu_gfx_logical_xcc_mask - mask of the logical XCCs + * @adev: amdgpu device pointer + * + * The GFXHUBs, and everything else going through GET_INST(GC, ...), are + * indexed by logical XCC. adev->gfx.xcc_mask holds physical instances + * and can be sparse when an XCC is harvested, so it must not be used to + * iterate the GFXHUBs. + * + * Returns: the contiguous mask of the logical XCCs. + */ +uint32_t amdgpu_gfx_logical_xcc_mask(struct amdgpu_device *adev) +{ + int num_xcc = NUM_XCC(adev->gfx.xcc_mask); + + return num_xcc ? GENMASK(num_xcc - 1, 0) : 0; +} + bool amdgpu_gfx_is_high_priority_graphics_queue(struct amdgpu_device *adev, struct amdgpu_ring *ring) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h index 6529c395f5bc..b7354a7dce79 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h @@ -597,6 +597,7 @@ static inline u32 amdgpu_gfx_create_bitmask(u32 bit_width) return (u32)((1ULL << bit_width) - 1); } +uint32_t amdgpu_gfx_logical_xcc_mask(struct amdgpu_device *adev); void amdgpu_gfx_parse_disable_cu(struct amdgpu_device *adev, unsigned int *mask, unsigned int max_se, unsigned int max_sh); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h index c7b44aeb671b..65893a40c959 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h @@ -27,7 +27,7 @@ struct amdgpu_gfxhub_funcs { u64 (*get_fb_location)(struct amdgpu_device *adev); u64 (*get_mc_fb_offset)(struct amdgpu_device *adev); void (*setup_vm_pt_regs)(struct amdgpu_device *adev, uint32_t vmid, - uint64_t page_table_base); + uint64_t page_table_base, uint32_t xcc_mask); int (*gart_enable)(struct amdgpu_device *adev); void (*gart_disable)(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c index 08d3ff61edcc..c0efb90e1d2e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c @@ -806,7 +806,8 @@ void amdgpu_gmc_bind_vmid(struct amdgpu_device *adev, unsigned int vmhub, if (is_mmhub) adev->mmhub.funcs->setup_vm_pt_regs(adev, vmid, pd_addr); else - adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, pd_addr); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, pd_addr, + amdgpu_gfx_logical_xcc_mask(adev)); amdgpu_gmc_flush_gpu_tlb(adev, vmid, vmhub, TLB_FLUSH_LEGACY); } diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v11_5_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v11_5_0.c index 8be912d50601..0b7d89d04f4c 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v11_5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v11_5_0.c @@ -122,7 +122,7 @@ static u64 gfxhub_v11_5_0_get_mc_fb_offset(struct amdgpu_device *adev) } static void gfxhub_v11_5_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, - uint64_t page_table_base) + uint64_t page_table_base, uint32_t xcc_mask) { struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)]; @@ -139,7 +139,7 @@ static void gfxhub_v11_5_0_init_gart_aperture_regs(struct amdgpu_device *adev) { uint64_t pt_base = amdgpu_gmc_pd_addr(adev->gart.bo); - gfxhub_v11_5_0_setup_vm_pt_regs(adev, 0, pt_base); + gfxhub_v11_5_0_setup_vm_pt_regs(adev, 0, pt_base, BIT(0)); WREG32_SOC15(GC, 0, regGCVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, (u32)(adev->gmc.gart_start >> 12)); diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v12_0.c index 4144c1c2ee13..9bfd97671699 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v12_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v12_0.c @@ -125,7 +125,8 @@ static u64 gfxhub_v12_0_get_mc_fb_offset(struct amdgpu_device *adev) static void gfxhub_v12_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, - uint64_t page_table_base) + uint64_t page_table_base, + uint32_t xcc_mask) { struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)]; @@ -142,7 +143,7 @@ static void gfxhub_v12_0_init_gart_aperture_regs(struct amdgpu_device *adev) { uint64_t pt_base = amdgpu_gmc_pd_addr(adev->gart.bo); - gfxhub_v12_0_setup_vm_pt_regs(adev, 0, pt_base); + gfxhub_v12_0_setup_vm_pt_regs(adev, 0, pt_base, BIT(0)); WREG32_SOC15(GC, 0, regGCVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, (u32)(adev->gmc.gart_start >> 12)); diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c index b13967a1c8fb..afcf7a58cae4 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c @@ -79,17 +79,6 @@ static void gfxhub_v12_1_xcc_setup_vm_pt_regs(struct amdgpu_device *adev, } } -static void gfxhub_v12_1_setup_vm_pt_regs(struct amdgpu_device *adev, - uint32_t vmid, - uint64_t page_table_base) -{ - uint32_t xcc_mask; - - xcc_mask = GENMASK(NUM_XCC(adev->gfx.xcc_mask) - 1, 0); - gfxhub_v12_1_xcc_setup_vm_pt_regs(adev, vmid, page_table_base, - xcc_mask); -} - static void gfxhub_v12_1_xcc_init_gart_aperture_regs(struct amdgpu_device *adev, uint32_t xcc_mask) { @@ -808,7 +797,7 @@ static void gfxhub_v12_1_init(struct amdgpu_device *adev) const struct amdgpu_gfxhub_funcs gfxhub_v12_1_funcs = { .get_fb_location = gfxhub_v12_1_get_fb_location, .get_mc_fb_offset = gfxhub_v12_1_get_mc_fb_offset, - .setup_vm_pt_regs = gfxhub_v12_1_setup_vm_pt_regs, + .setup_vm_pt_regs = gfxhub_v12_1_xcc_setup_vm_pt_regs, .gart_enable = gfxhub_v12_1_gart_enable, .gart_disable = gfxhub_v12_1_gart_disable, .set_fault_enable_default = gfxhub_v12_1_set_fault_enable_default, diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c index c35856180c3c..a3ef12d6b20a 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c @@ -38,7 +38,8 @@ static u64 gfxhub_v1_0_get_mc_fb_offset(struct amdgpu_device *adev) static void gfxhub_v1_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, - uint64_t page_table_base) + uint64_t page_table_base, + uint32_t xcc_mask) { struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)]; @@ -60,7 +61,7 @@ static void gfxhub_v1_0_init_gart_aperture_regs(struct amdgpu_device *adev) else pt_base = amdgpu_gmc_pd_addr(adev->gart.bo); - gfxhub_v1_0_setup_vm_pt_regs(adev, 0, pt_base); + gfxhub_v1_0_setup_vm_pt_regs(adev, 0, pt_base, BIT(0)); /* If use GART for FB translation, vmid0 page table covers both * vram and system memory (gart) diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c index e89813590539..79653ffd42b6 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c @@ -62,16 +62,6 @@ static void gfxhub_v1_2_xcc_setup_vm_pt_regs(struct amdgpu_device *adev, } } -static void gfxhub_v1_2_setup_vm_pt_regs(struct amdgpu_device *adev, - uint32_t vmid, - uint64_t page_table_base) -{ - uint32_t xcc_mask; - - xcc_mask = GENMASK(NUM_XCC(adev->gfx.xcc_mask) - 1, 0); - gfxhub_v1_2_xcc_setup_vm_pt_regs(adev, vmid, page_table_base, xcc_mask); -} - static void gfxhub_v1_2_xcc_init_gart_aperture_regs(struct amdgpu_device *adev, uint32_t xcc_mask) { @@ -633,7 +623,7 @@ static int gfxhub_v1_2_get_xgmi_info(struct amdgpu_device *adev) const struct amdgpu_gfxhub_funcs gfxhub_v1_2_funcs = { .get_mc_fb_offset = gfxhub_v1_2_get_mc_fb_offset, - .setup_vm_pt_regs = gfxhub_v1_2_setup_vm_pt_regs, + .setup_vm_pt_regs = gfxhub_v1_2_xcc_setup_vm_pt_regs, .gart_enable = gfxhub_v1_2_gart_enable, .gart_disable = gfxhub_v1_2_gart_disable, .set_fault_enable_default = gfxhub_v1_2_set_fault_enable_default, diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c index 04778f9f95bd..0aabd25e1c71 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c @@ -118,7 +118,7 @@ static u64 gfxhub_v2_0_get_mc_fb_offset(struct amdgpu_device *adev) } static void gfxhub_v2_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, - uint64_t page_table_base) + uint64_t page_table_base, uint32_t xcc_mask) { struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)]; @@ -135,7 +135,7 @@ static void gfxhub_v2_0_init_gart_aperture_regs(struct amdgpu_device *adev) { uint64_t pt_base = amdgpu_gmc_pd_addr(adev->gart.bo); - gfxhub_v2_0_setup_vm_pt_regs(adev, 0, pt_base); + gfxhub_v2_0_setup_vm_pt_regs(adev, 0, pt_base, BIT(0)); WREG32_SOC15(GC, 0, mmGCVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, (u32)(adev->gmc.gart_start >> 12)); diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c index 6c77c17878f8..3f2661f8531e 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c @@ -121,7 +121,7 @@ static u64 gfxhub_v2_1_get_mc_fb_offset(struct amdgpu_device *adev) } static void gfxhub_v2_1_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, - uint64_t page_table_base) + uint64_t page_table_base, uint32_t xcc_mask) { struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)]; @@ -138,7 +138,7 @@ static void gfxhub_v2_1_init_gart_aperture_regs(struct amdgpu_device *adev) { uint64_t pt_base = amdgpu_gmc_pd_addr(adev->gart.bo); - gfxhub_v2_1_setup_vm_pt_regs(adev, 0, pt_base); + gfxhub_v2_1_setup_vm_pt_regs(adev, 0, pt_base, BIT(0)); WREG32_SOC15(GC, 0, mmGCVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, (u32)(adev->gmc.gart_start >> 12)); diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c index e2b9fd0c8af0..fdb47bf557c6 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c @@ -117,7 +117,7 @@ static u64 gfxhub_v3_0_get_mc_fb_offset(struct amdgpu_device *adev) } static void gfxhub_v3_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, - uint64_t page_table_base) + uint64_t page_table_base, uint32_t xcc_mask) { struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)]; @@ -134,7 +134,7 @@ static void gfxhub_v3_0_init_gart_aperture_regs(struct amdgpu_device *adev) { uint64_t pt_base = amdgpu_gmc_pd_addr(adev->gart.bo); - gfxhub_v3_0_setup_vm_pt_regs(adev, 0, pt_base); + gfxhub_v3_0_setup_vm_pt_regs(adev, 0, pt_base, BIT(0)); WREG32_SOC15(GC, 0, regGCVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, (u32)(adev->gmc.gart_start >> 12)); diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c index fa8b966b7ea1..4e6e35120b6c 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c @@ -120,7 +120,7 @@ static u64 gfxhub_v3_0_3_get_mc_fb_offset(struct amdgpu_device *adev) } static void gfxhub_v3_0_3_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, - uint64_t page_table_base) + uint64_t page_table_base, uint32_t xcc_mask) { struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)]; @@ -137,7 +137,7 @@ static void gfxhub_v3_0_3_init_gart_aperture_regs(struct amdgpu_device *adev) { uint64_t pt_base = amdgpu_gmc_pd_addr(adev->gart.bo); - gfxhub_v3_0_3_setup_vm_pt_regs(adev, 0, pt_base); + gfxhub_v3_0_3_setup_vm_pt_regs(adev, 0, pt_base, BIT(0)); WREG32_SOC15(GC, 0, regGCVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, (u32)(adev->gmc.gart_start >> 12)); -- 2.34.1
