From: Philip Yang <[email protected]>

For GMC v12.1.0, the IH cookie NodeID spacing is 8 (MID0=0x0, MID1=0x8),
not 4. The wrong divisor caused NPA page faults (node_id=8) to select
mmhub2 instead of the correct mmhub1.

Fix the divisor from 4 to 8, and add a comment documenting the NodeID
to DIE mapping for reference.

Warn once if page fault from the vmhub but vmhub print fault status
function not initialized because not all hubs are initialized.

Signed-off-by: Philip Yang <[email protected]>
Reviewed-by: Felix Kuehling <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
index 5fe43f7eab29d..ecd17ee160194 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
@@ -100,6 +100,23 @@ static int gmc_v12_1_vm_fault_interrupt_state(struct 
amdgpu_device *adev,
        return 0;
 }
 
+/*
+ * NodeID definition in interrupt cookie for gmc v12.1.0
+ *
+ * DIE         IH Cookie NodeID
+ * MID0                0x0
+ * AID0                0x1
+ * AID0.XCD0   0x2
+ * AID0.XCD1   0x3
+ * AID0.XCD2   0x4
+ * AID0.XCD3   0x5
+ * MID1                0x8
+ * AID1                0x9
+ * AID1.XCD0   0xA
+ * AID1.XCD1   0xB
+ * AID1.XCD2   0xC
+ * AID1.XCD3   0xD
+ */
 static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
                                       struct amdgpu_irq_src *source,
                                       struct amdgpu_iv_entry *entry)
@@ -128,7 +145,7 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device 
*adev,
 
        if (entry->client_id == SOC_V1_0_IH_CLIENTID_VMC) {
                hub_name = "mmhub0";
-               vmhub = AMDGPU_MMHUB0(node_id / 4);
+               vmhub = AMDGPU_MMHUB0(node_id / 8);
        } else {
                hub_name = "gfxhub0";
                if (adev->gfx.funcs->ih_node_to_logical_xcc) {
@@ -237,6 +254,11 @@ static int gmc_v12_1_process_interrupt(struct 
amdgpu_device *adev,
 
        amdgpu_vm_update_fault_cache(adev, entry->pasid, addr, status, vmhub);
 
+       if (!hub->vmhub_funcs || 
!hub->vmhub_funcs->print_l2_protection_fault_status) {
+               dev_warn_once(adev->dev, "vmhub %d print fault status func not 
defined\n", vmhub);
+               return 0;
+       }
+
        hub->vmhub_funcs->print_l2_protection_fault_status(adev, status);
 
        return 0;
-- 
2.55.0

Reply via email to