drm/amdgpu: correct the vmhub index when page fault occurs
authorLe Ma <le.ma@amd.com>
Fri, 9 Dec 2022 11:44:05 +0000 (19:44 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 13:50:30 +0000 (09:50 -0400)
The AMDGPU_GFXHUB was bind to each xcc in the logical order.
Thus convert the node_id to logical xcc_id to index the
correct AMDGPU_GFXHUB. And "node_id / 4" can get the correct
AMDGPU_MMHUB0 index.

Signed-off-by: Le Ma <le.ma@amd.com>
Tested-by: Asad kamal <asad.kamal@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c

index 2287768ed141aebe2d52a8f136654c2766123d2f..81b4c7e684af2962e6085df0befa59eb7f468067 100644 (file)
@@ -280,6 +280,7 @@ struct amdgpu_gfx_funcs {
                        (*query_mem_partition_mode)(struct amdgpu_device *adev);
        int (*switch_partition_mode)(struct amdgpu_device *adev,
                                     int num_xccs_per_xcp);
+       int (*ih_node_to_logical_xcc)(struct amdgpu_device *adev, int ih_node);
 };
 
 struct sq_work {
index ef552c9b19b552a388d565d539d00f2261485c49..6aaa810ea04466ff9169110f533fbd224efeef27 100644 (file)
@@ -637,6 +637,19 @@ static int gfx_v9_4_3_switch_compute_partition(struct amdgpu_device *adev,
        return 0;
 }
 
+static int gfx_v9_4_3_ih_to_xcc_inst(struct amdgpu_device *adev, int ih_node)
+{
+       int xcc;
+
+       xcc = hweight8(adev->gfx.xcc_mask & GENMASK(ih_node / 2, 0));
+       if (!xcc) {
+               dev_err(adev->dev, "Couldn't find xcc mapping from IH node");
+               return -EINVAL;
+       }
+
+       return xcc - 1;
+}
+
 static const struct amdgpu_gfx_funcs gfx_v9_4_3_gfx_funcs = {
        .get_gpu_clock_counter = &gfx_v9_4_3_get_gpu_clock_counter,
        .select_se_sh = &gfx_v9_4_3_xcc_select_se_sh,
@@ -646,6 +659,7 @@ static const struct amdgpu_gfx_funcs gfx_v9_4_3_gfx_funcs = {
        .select_me_pipe_q = &gfx_v9_4_3_select_me_pipe_q,
        .switch_partition_mode = &gfx_v9_4_3_switch_compute_partition,
        .query_mem_partition_mode = &gfx_v9_4_3_query_memory_partition,
+       .ih_node_to_logical_xcc = &gfx_v9_4_3_ih_to_xcc_inst,
 };
 
 static int gfx_v9_4_3_gpu_early_init(struct amdgpu_device *adev)
@@ -2754,19 +2768,6 @@ static int gfx_v9_4_3_set_eop_interrupt_state(struct amdgpu_device *adev,
        return 0;
 }
 
-static int gfx_v9_4_3_ih_to_xcc_inst(struct amdgpu_device *adev, int ih_node)
-{
-       int xcc;
-
-       xcc = hweight8(adev->gfx.xcc_mask & GENMASK(ih_node / 2, 0));
-       if (!xcc) {
-               dev_err(adev->dev, "Couldn't find xcc mapping from IH node");
-               return -EINVAL;
-       }
-
-       return xcc - 1;
-}
-
 static int gfx_v9_4_3_eop_irq(struct amdgpu_device *adev,
                            struct amdgpu_irq_src *source,
                            struct amdgpu_iv_entry *entry)
index 3765178e6fc5294e50163f139a4490c748fa65d7..841333148610ec1bcee50487305497acee1e9b39 100644 (file)
@@ -557,22 +557,28 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
        u64 addr;
        uint32_t cam_index = 0;
        int ret;
-       uint32_t node_id;
+       uint32_t node_id, xcc_id = 0;
 
-       node_id = (adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 3)) ? entry->node_id : 0;
+       node_id = entry->node_id;
 
        addr = (u64)entry->src_data[0] << 12;
        addr |= ((u64)entry->src_data[1] & 0xf) << 44;
 
        if (entry->client_id == SOC15_IH_CLIENTID_VMC) {
                hub_name = "mmhub0";
-               hub = &adev->vmhub[AMDGPU_MMHUB0(0)];
+               hub = &adev->vmhub[AMDGPU_MMHUB0(node_id / 4)];
        } else if (entry->client_id == SOC15_IH_CLIENTID_VMC1) {
                hub_name = "mmhub1";
                hub = &adev->vmhub[AMDGPU_MMHUB1(0)];
        } else {
                hub_name = "gfxhub0";
-               hub = &adev->vmhub[node_id/2];
+               if (adev->gfx.funcs->ih_node_to_logical_xcc) {
+                       xcc_id = adev->gfx.funcs->ih_node_to_logical_xcc(adev,
+                               node_id);
+                       if (xcc_id < 0)
+                               xcc_id = 0;
+               }
+               hub = &adev->vmhub[xcc_id];
        }
 
        if (retry_fault) {