Commit d9426c3d authored by Le Ma's avatar Le Ma Committed by Alex Deucher

drm/amdgpu: add bitmask to iterate vmhubs

As the layout of VMHUB definition has been changed to cover multiple
XCD/AID case, the original num_vmhubs is not appropriate to do vmhub
iteration any more.

Drop num_vmhubs and introduce vmhubs_mask instead.

v2: switch to the new VMHUB layout
v3: use DECLARE_BITMAP to define vmhubs_mask
Signed-off-by: default avatarLe Ma <le.ma@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent b35ce49a
...@@ -829,7 +829,7 @@ struct amdgpu_device { ...@@ -829,7 +829,7 @@ struct amdgpu_device {
dma_addr_t dummy_page_addr; dma_addr_t dummy_page_addr;
struct amdgpu_vm_manager vm_manager; struct amdgpu_vm_manager vm_manager;
struct amdgpu_vmhub vmhub[AMDGPU_MAX_VMHUBS]; struct amdgpu_vmhub vmhub[AMDGPU_MAX_VMHUBS];
unsigned num_vmhubs; DECLARE_BITMAP(vmhubs_mask, AMDGPU_MAX_VMHUBS);
/* memory management */ /* memory management */
struct amdgpu_mman mman; struct amdgpu_mman mman;
......
...@@ -733,7 +733,7 @@ int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct amdgpu_device *adev, ...@@ -733,7 +733,7 @@ int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct amdgpu_device *adev,
if (adev->family == AMDGPU_FAMILY_AI) { if (adev->family == AMDGPU_FAMILY_AI) {
int i; int i;
for (i = 0; i < adev->num_vmhubs; i++) for_each_set_bit(i, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS)
amdgpu_gmc_flush_gpu_tlb(adev, vmid, i, 0); amdgpu_gmc_flush_gpu_tlb(adev, vmid, i, 0);
} else { } else {
amdgpu_gmc_flush_gpu_tlb(adev, vmid, AMDGPU_GFXHUB(0), 0); amdgpu_gmc_flush_gpu_tlb(adev, vmid, AMDGPU_GFXHUB(0), 0);
......
...@@ -182,7 +182,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, ...@@ -182,7 +182,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
} }
mb(); mb();
amdgpu_device_flush_hdp(adev, NULL); amdgpu_device_flush_hdp(adev, NULL);
for (i = 0; i < adev->num_vmhubs; i++) for_each_set_bit(i, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS)
amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0); amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
drm_dev_exit(idx); drm_dev_exit(idx);
...@@ -264,7 +264,7 @@ void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev) ...@@ -264,7 +264,7 @@ void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev)
mb(); mb();
amdgpu_device_flush_hdp(adev, NULL); amdgpu_device_flush_hdp(adev, NULL);
for (i = 0; i < adev->num_vmhubs; i++) for_each_set_bit(i, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS)
amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0); amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
} }
......
...@@ -460,7 +460,7 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ...@@ -460,7 +460,7 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
&queried_pasid); &queried_pasid);
if (ret && queried_pasid == pasid) { if (ret && queried_pasid == pasid) {
if (all_hub) { if (all_hub) {
for (i = 0; i < adev->num_vmhubs; i++) for_each_set_bit(i, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS)
gmc_v10_0_flush_gpu_tlb(adev, vmid, gmc_v10_0_flush_gpu_tlb(adev, vmid,
i, flush_type); i, flush_type);
} else { } else {
...@@ -928,7 +928,8 @@ static int gmc_v10_0_sw_init(void *handle) ...@@ -928,7 +928,8 @@ static int gmc_v10_0_sw_init(void *handle)
case IP_VERSION(10, 3, 6): case IP_VERSION(10, 3, 6):
case IP_VERSION(10, 3, 3): case IP_VERSION(10, 3, 3):
case IP_VERSION(10, 3, 7): case IP_VERSION(10, 3, 7):
adev->num_vmhubs = 2; set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
set_bit(AMDGPU_MMHUB0(0), adev->vmhubs_mask);
/* /*
* To fulfill 4-level page support, * To fulfill 4-level page support,
* vm size is 256TB (48bit), maximum size of Navi10/Navi14/Navi12, * vm size is 256TB (48bit), maximum size of Navi10/Navi14/Navi12,
......
...@@ -364,7 +364,7 @@ static int gmc_v11_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ...@@ -364,7 +364,7 @@ static int gmc_v11_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
&queried_pasid); &queried_pasid);
if (ret && queried_pasid == pasid) { if (ret && queried_pasid == pasid) {
if (all_hub) { if (all_hub) {
for (i = 0; i < adev->num_vmhubs; i++) for_each_set_bit(i, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS)
gmc_v11_0_flush_gpu_tlb(adev, vmid, gmc_v11_0_flush_gpu_tlb(adev, vmid,
i, flush_type); i, flush_type);
} else { } else {
...@@ -779,7 +779,8 @@ static int gmc_v11_0_sw_init(void *handle) ...@@ -779,7 +779,8 @@ static int gmc_v11_0_sw_init(void *handle)
case IP_VERSION(11, 0, 2): case IP_VERSION(11, 0, 2):
case IP_VERSION(11, 0, 3): case IP_VERSION(11, 0, 3):
case IP_VERSION(11, 0, 4): case IP_VERSION(11, 0, 4):
adev->num_vmhubs = 2; set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
set_bit(AMDGPU_MMHUB0(0), adev->vmhubs_mask);
/* /*
* To fulfill 4-level page support, * To fulfill 4-level page support,
* vm size is 256TB (48bit), maximum size, * vm size is 256TB (48bit), maximum size,
......
...@@ -808,7 +808,7 @@ static int gmc_v6_0_sw_init(void *handle) ...@@ -808,7 +808,7 @@ static int gmc_v6_0_sw_init(void *handle)
int r; int r;
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
adev->num_vmhubs = 1; set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
if (adev->flags & AMD_IS_APU) { if (adev->flags & AMD_IS_APU) {
adev->gmc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; adev->gmc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN;
......
...@@ -977,7 +977,7 @@ static int gmc_v7_0_sw_init(void *handle) ...@@ -977,7 +977,7 @@ static int gmc_v7_0_sw_init(void *handle)
int r; int r;
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
adev->num_vmhubs = 1; set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
if (adev->flags & AMD_IS_APU) { if (adev->flags & AMD_IS_APU) {
adev->gmc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; adev->gmc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN;
......
...@@ -1093,7 +1093,7 @@ static int gmc_v8_0_sw_init(void *handle) ...@@ -1093,7 +1093,7 @@ static int gmc_v8_0_sw_init(void *handle)
int r; int r;
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
adev->num_vmhubs = 1; set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
if (adev->flags & AMD_IS_APU) { if (adev->flags & AMD_IS_APU) {
adev->gmc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; adev->gmc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN;
......
...@@ -481,7 +481,7 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev, ...@@ -481,7 +481,7 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev,
switch (state) { switch (state) {
case AMDGPU_IRQ_STATE_DISABLE: case AMDGPU_IRQ_STATE_DISABLE:
for (j = 0; j < adev->num_vmhubs; j++) { for_each_set_bit(j, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS) {
hub = &adev->vmhub[j]; hub = &adev->vmhub[j];
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
reg = hub->vm_context0_cntl + i; reg = hub->vm_context0_cntl + i;
...@@ -509,7 +509,7 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev, ...@@ -509,7 +509,7 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev,
} }
break; break;
case AMDGPU_IRQ_STATE_ENABLE: case AMDGPU_IRQ_STATE_ENABLE:
for (j = 0; j < adev->num_vmhubs; j++) { for_each_set_bit(j, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS) {
hub = &adev->vmhub[j]; hub = &adev->vmhub[j];
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
reg = hub->vm_context0_cntl + i; reg = hub->vm_context0_cntl + i;
...@@ -803,7 +803,7 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, ...@@ -803,7 +803,7 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,
u32 j, inv_req, inv_req2, tmp; u32 j, inv_req, inv_req2, tmp;
struct amdgpu_vmhub *hub; struct amdgpu_vmhub *hub;
BUG_ON(vmhub >= adev->num_vmhubs); BUG_ON(vmhub >= AMDGPU_MAX_VMHUBS);
hub = &adev->vmhub[vmhub]; hub = &adev->vmhub[vmhub];
if (adev->gmc.xgmi.num_physical_nodes && if (adev->gmc.xgmi.num_physical_nodes &&
...@@ -987,7 +987,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ...@@ -987,7 +987,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
&queried_pasid); &queried_pasid);
if (ret && queried_pasid == pasid) { if (ret && queried_pasid == pasid) {
if (all_hub) { if (all_hub) {
for (i = 0; i < adev->num_vmhubs; i++) for_each_set_bit(i, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS)
gmc_v9_0_flush_gpu_tlb(adev, vmid, gmc_v9_0_flush_gpu_tlb(adev, vmid,
i, flush_type); i, flush_type);
} else { } else {
...@@ -1684,7 +1684,8 @@ static int gmc_v9_0_sw_init(void *handle) ...@@ -1684,7 +1684,8 @@ static int gmc_v9_0_sw_init(void *handle)
switch (adev->ip_versions[GC_HWIP][0]) { switch (adev->ip_versions[GC_HWIP][0]) {
case IP_VERSION(9, 1, 0): case IP_VERSION(9, 1, 0):
case IP_VERSION(9, 2, 2): case IP_VERSION(9, 2, 2):
adev->num_vmhubs = 2; set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
set_bit(AMDGPU_MMHUB0(0), adev->vmhubs_mask);
if (adev->rev_id == 0x0 || adev->rev_id == 0x1) { if (adev->rev_id == 0x0 || adev->rev_id == 0x1) {
amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48); amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48);
...@@ -1701,8 +1702,8 @@ static int gmc_v9_0_sw_init(void *handle) ...@@ -1701,8 +1702,8 @@ static int gmc_v9_0_sw_init(void *handle)
case IP_VERSION(9, 3, 0): case IP_VERSION(9, 3, 0):
case IP_VERSION(9, 4, 2): case IP_VERSION(9, 4, 2):
case IP_VERSION(9, 4, 3): case IP_VERSION(9, 4, 3):
adev->num_vmhubs = 2; set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
set_bit(AMDGPU_MMHUB0(0), adev->vmhubs_mask);
/* /*
* To fulfill 4-level page support, * To fulfill 4-level page support,
...@@ -1718,7 +1719,9 @@ static int gmc_v9_0_sw_init(void *handle) ...@@ -1718,7 +1719,9 @@ static int gmc_v9_0_sw_init(void *handle)
adev->gmc.translate_further = adev->vm_manager.num_level > 1; adev->gmc.translate_further = adev->vm_manager.num_level > 1;
break; break;
case IP_VERSION(9, 4, 1): case IP_VERSION(9, 4, 1):
adev->num_vmhubs = 3; set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
set_bit(AMDGPU_MMHUB0(0), adev->vmhubs_mask);
set_bit(AMDGPU_MMHUB1(0), adev->vmhubs_mask);
/* Keep the vm size same with Vega20 */ /* Keep the vm size same with Vega20 */
amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48); amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48);
...@@ -1944,7 +1947,7 @@ static int gmc_v9_0_hw_init(void *handle) ...@@ -1944,7 +1947,7 @@ static int gmc_v9_0_hw_init(void *handle)
adev->gfxhub.funcs->set_fault_enable_default(adev, value); adev->gfxhub.funcs->set_fault_enable_default(adev, value);
adev->mmhub.funcs->set_fault_enable_default(adev, value); adev->mmhub.funcs->set_fault_enable_default(adev, value);
} }
for (i = 0; i < adev->num_vmhubs; ++i) { for_each_set_bit(i, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS) {
if (adev->in_s0ix && (i == AMDGPU_GFXHUB(0))) if (adev->in_s0ix && (i == AMDGPU_GFXHUB(0)))
continue; continue;
gmc_v9_0_flush_gpu_tlb(adev, 0, i, 0); gmc_v9_0_flush_gpu_tlb(adev, 0, i, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment