* [PATCH V3 2/5] drm/amdgpu: Add sysfs interface for sdma reset mask
2024-10-24 7:39 [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset mask Jesse.zhang@amd.com
@ 2024-10-24 7:39 ` Jesse.zhang@amd.com
2024-10-24 7:39 ` [PATCH V3 3/5] drm/amdgpu: Add sysfs interface for vcn " Jesse.zhang@amd.com
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jesse.zhang@amd.com @ 2024-10-24 7:39 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Jesse.zhang@amd.com,
Jesse Zhang
From: "Jesse.zhang@amd.com" <Jesse.zhang@amd.com>
Add the sysfs interface for sdma:
sdma_reset_mask
The interface is read-only and show the resets supported by the IP.
For example, full adapter reset (mode1/mode2/BACO/etc),
soft reset, queue reset, and pipe reset.
V2: the sysfs node returns a text string instead of some flags (Christian)
v3: add a generic helper which takes the ring as parameter
and print the strings in the order they are applied (Christian)
check amdgpu_gpu_recovery before creating sysfs file itself,
and initialize supported_reset_types in IP version files (Lijo)
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by:Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 41 ++++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 3 ++
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 18 +++++++++++
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 23 +++++++++++++
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 17 ++++++++++
5 files changed, 102 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
index 183a976ba29d..7edcd989afce 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
@@ -343,3 +343,44 @@ int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev)
return 0;
}
+
+static ssize_t amdgpu_get_sdma_reset_mask(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_device *ddev = dev_get_drvdata(dev);
+ struct amdgpu_device *adev = drm_to_adev(ddev);
+
+ if (!adev)
+ return -ENODEV;
+
+ return amdgpu_show_reset_mask(buf, adev->sdma.supported_reset);
+}
+
+static DEVICE_ATTR(sdma_reset_mask, 0444,
+ amdgpu_get_sdma_reset_mask, NULL);
+
+int amdgpu_sdma_sysfs_reset_mask_init(struct amdgpu_device *adev)
+{
+ int r = 0;
+
+ if (!amdgpu_gpu_recovery)
+ return r;
+
+ if (adev->sdma.num_instances) {
+ r = device_create_file(adev->dev, &dev_attr_sdma_reset_mask);
+ if (r)
+ return r;
+ }
+
+ return r;
+}
+
+void amdgpu_sdma_sysfs_reset_mask_fini(struct amdgpu_device *adev)
+{
+ if (!amdgpu_gpu_recovery)
+ return;
+
+ if (adev->sdma.num_instances)
+ device_remove_file(adev->dev, &dev_attr_sdma_reset_mask);
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
index 087ce0f6fa07..7ce613de7ee0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
@@ -116,6 +116,7 @@ struct amdgpu_sdma {
struct ras_common_if *ras_if;
struct amdgpu_sdma_ras *ras;
uint32_t *ip_dump;
+ uint32_t supported_reset;
};
/*
@@ -175,5 +176,7 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev, u32 instance,
void amdgpu_sdma_destroy_inst_ctx(struct amdgpu_device *adev,
bool duplicate);
int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev);
+int amdgpu_sdma_sysfs_reset_mask_init(struct amdgpu_device *adev);
+void amdgpu_sdma_sysfs_reset_mask_fini(struct amdgpu_device *adev);
#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
index 6a675daf5620..728643efe203 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
@@ -1452,6 +1452,19 @@ static int sdma_v5_0_sw_init(struct amdgpu_ip_block *ip_block)
return r;
}
+ switch (amdgpu_ip_version(adev, SDMA0_HWIP, 0)) {
+ case IP_VERSION(5, 0, 0):
+ case IP_VERSION(5, 0, 2):
+ case IP_VERSION(5, 0, 5):
+ if (adev->sdma.instance[i].fw_version >= 35)
+ adev->sdma.supported_reset = AMDGPU_RESET_TYPE_PER_QUEUE;
+ break;
+ default:
+ break;
+ }
+ adev->sdma.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->sdma.instance[0].ring);
+
/* Allocate memory for SDMA IP Dump buffer */
ptr = kcalloc(adev->sdma.num_instances * reg_count, sizeof(uint32_t), GFP_KERNEL);
if (ptr)
@@ -1459,6 +1472,10 @@ static int sdma_v5_0_sw_init(struct amdgpu_ip_block *ip_block)
else
DRM_ERROR("Failed to allocated memory for SDMA IP Dump\n");
+ r = amdgpu_sdma_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
+
return r;
}
@@ -1470,6 +1487,7 @@ static int sdma_v5_0_sw_fini(struct amdgpu_ip_block *ip_block)
for (i = 0; i < adev->sdma.num_instances; i++)
amdgpu_ring_fini(&adev->sdma.instance[i].ring);
+ amdgpu_sdma_sysfs_reset_mask_fini(adev);
amdgpu_sdma_destroy_inst_ctx(adev, false);
kfree(adev->sdma.ip_dump);
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
index e1413ccaf7e4..38cb5ebe1b7b 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
@@ -1357,6 +1357,24 @@ static int sdma_v5_2_sw_init(struct amdgpu_ip_block *ip_block)
return r;
}
+ switch (amdgpu_ip_version(adev, SDMA0_HWIP, 0)) {
+ case IP_VERSION(5, 2, 0):
+ case IP_VERSION(5, 2, 2):
+ case IP_VERSION(5, 2, 3):
+ case IP_VERSION(5, 2, 4):
+ if (adev->sdma.instance[i].fw_version >= 76)
+ adev->sdma.supported_reset = AMDGPU_RESET_TYPE_PER_QUEUE;
+ break;
+ case IP_VERSION(5, 2, 5):
+ if (adev->sdma.instance[i].fw_version >= 34)
+ adev->sdma.supported_reset = AMDGPU_RESET_TYPE_PER_QUEUE;
+ break;
+ default:
+ break;
+ }
+ adev->sdma.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->sdma.instance[0].ring);
+
/* Allocate memory for SDMA IP Dump buffer */
ptr = kcalloc(adev->sdma.num_instances * reg_count, sizeof(uint32_t), GFP_KERNEL);
if (ptr)
@@ -1364,6 +1382,10 @@ static int sdma_v5_2_sw_init(struct amdgpu_ip_block *ip_block)
else
DRM_ERROR("Failed to allocated memory for SDMA IP Dump\n");
+ r = amdgpu_sdma_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
+
return r;
}
@@ -1375,6 +1397,7 @@ static int sdma_v5_2_sw_fini(struct amdgpu_ip_block *ip_block)
for (i = 0; i < adev->sdma.num_instances; i++)
amdgpu_ring_fini(&adev->sdma.instance[i].ring);
+ amdgpu_sdma_sysfs_reset_mask_fini(adev);
amdgpu_sdma_destroy_inst_ctx(adev, true);
kfree(adev->sdma.ip_dump);
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
index 4856a093e23f..97c837dbb135 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
@@ -1351,6 +1351,19 @@ static int sdma_v6_0_sw_init(struct amdgpu_ip_block *ip_block)
return r;
}
+ switch (amdgpu_ip_version(adev, SDMA0_HWIP, 0)) {
+ case IP_VERSION(6, 0, 0):
+ case IP_VERSION(6, 0, 2):
+ case IP_VERSION(6, 0, 3):
+ if (adev->sdma.instance[i].fw_version >= 21)
+ adev->sdma.supported_reset = AMDGPU_RESET_TYPE_PER_QUEUE;
+ break;
+ default:
+ break;
+ }
+ adev->sdma.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->sdma.instance[0].ring);
+
if (amdgpu_sdma_ras_sw_init(adev)) {
dev_err(adev->dev, "Failed to initialize sdma ras block!\n");
return -EINVAL;
@@ -1366,6 +1379,9 @@ static int sdma_v6_0_sw_init(struct amdgpu_ip_block *ip_block)
#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ
adev->userq_funcs[AMDGPU_HW_IP_DMA] = &userq_mes_v11_0_funcs;
#endif
+ r = amdgpu_sdma_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
return r;
}
@@ -1378,6 +1394,7 @@ static int sdma_v6_0_sw_fini(struct amdgpu_ip_block *ip_block)
for (i = 0; i < adev->sdma.num_instances; i++)
amdgpu_ring_fini(&adev->sdma.instance[i].ring);
+ amdgpu_sdma_sysfs_reset_mask_fini(adev);
amdgpu_sdma_destroy_inst_ctx(adev, true);
kfree(adev->sdma.ip_dump);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH V3 3/5] drm/amdgpu: Add sysfs interface for vcn reset mask
2024-10-24 7:39 [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset mask Jesse.zhang@amd.com
2024-10-24 7:39 ` [PATCH V3 2/5] drm/amdgpu: Add sysfs interface for sdma " Jesse.zhang@amd.com
@ 2024-10-24 7:39 ` Jesse.zhang@amd.com
2024-10-24 7:39 ` [PATCH V3 4/5] drm/amdgpu: Add sysfs interface for vpe " Jesse.zhang@amd.com
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jesse.zhang@amd.com @ 2024-10-24 7:39 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Jesse.zhang@amd.com,
Jesse Zhang
From: "Jesse.zhang@amd.com" <Jesse.zhang@amd.com>
Add the sysfs interface for vcn:
vcn_reset_mask
The interface is read-only and show the resets supported by the IP.
For example, full adapter reset (mode1/mode2/BACO/etc),
soft reset, queue reset, and pipe reset.
V2: the sysfs node returns a text string instead of some flags (Christian)
V2: the sysfs node returns a text string instead of some flags (Christian)
v3: add a generic helper which takes the ring as parameter
and print the strings in the order they are applied (Christian)
check amdgpu_gpu_recovery before creating sysfs file itself,
and initialize supported_reset_types in IP version files (Lijo)
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by:Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 35 +++++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 4 +++
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 9 +++++++
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 8 ++++++
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 9 +++++++
5 files changed, 65 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 43f44cc201cb..9bbae298189a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -1277,3 +1277,38 @@ int amdgpu_vcn_psp_update_sram(struct amdgpu_device *adev, int inst_idx,
return psp_execute_ip_fw_load(&adev->psp, &ucode);
}
+
+static ssize_t amdgpu_get_vcn_reset_mask(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_device *ddev = dev_get_drvdata(dev);
+ struct amdgpu_device *adev = drm_to_adev(ddev);
+
+ if (!adev)
+ return -ENODEV;
+
+ return amdgpu_show_reset_mask(buf, adev->vcn.supported_reset);
+}
+
+static DEVICE_ATTR(vcn_reset_mask, 0444,
+ amdgpu_get_vcn_reset_mask, NULL);
+
+int amdgpu_vcn_sysfs_reset_mask_init(struct amdgpu_device *adev)
+{
+ int r = 0;
+
+ if (adev->vcn.num_vcn_inst) {
+ r = device_create_file(adev->dev, &dev_attr_vcn_reset_mask);
+ if (r)
+ return r;
+ }
+
+ return r;
+}
+
+void amdgpu_vcn_sysfs_reset_mask_fini(struct amdgpu_device *adev)
+{
+ if (adev->vcn.num_vcn_inst)
+ device_remove_file(adev->dev, &dev_attr_vcn_reset_mask);
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
index 2a1f3dbb14d3..904336ff0b39 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
@@ -333,6 +333,8 @@ struct amdgpu_vcn {
/* IP reg dump */
uint32_t *ip_dump;
+
+ uint32_t supported_reset;
};
struct amdgpu_fw_shared_rb_ptrs_struct {
@@ -518,5 +520,7 @@ int amdgpu_vcn_ras_sw_init(struct amdgpu_device *adev);
int amdgpu_vcn_psp_update_sram(struct amdgpu_device *adev, int inst_idx,
enum AMDGPU_UCODE_ID ucode_id);
+int amdgpu_vcn_sysfs_reset_mask_init(struct amdgpu_device *adev);
+void amdgpu_vcn_sysfs_reset_mask_fini(struct amdgpu_device *adev);
#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
index e7b7a8150ea7..9c84cfe9ea43 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
@@ -225,6 +225,10 @@ static int vcn_v4_0_sw_init(struct amdgpu_ip_block *ip_block)
vcn_v4_0_fw_shared_init(adev, i);
}
+ /* TODO: Check the version that supports queue reset */
+ adev->sdma.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->vcn.inst[0].ring_enc[0]);
+
if (amdgpu_sriov_vf(adev)) {
r = amdgpu_virt_alloc_mm_table(adev);
if (r)
@@ -247,6 +251,10 @@ static int vcn_v4_0_sw_init(struct amdgpu_ip_block *ip_block)
adev->vcn.ip_dump = ptr;
}
+ r = amdgpu_vcn_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
+
return 0;
}
@@ -284,6 +292,7 @@ static int vcn_v4_0_sw_fini(struct amdgpu_ip_block *ip_block)
if (r)
return r;
+ amdgpu_vcn_sysfs_reset_mask_fini(adev);
r = amdgpu_vcn_sw_fini(adev);
kfree(adev->vcn.ip_dump);
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
index 6dcae398b2dc..1887a15b7d69 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
@@ -180,6 +180,10 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
amdgpu_vcn_fwlog_init(&adev->vcn.inst[i]);
}
+ /* TODO: Check the version that supports queue reset ? */
+ adev->sdma.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->vcn.inst[0].ring_enc[0]);
+
if (amdgpu_sriov_vf(adev)) {
r = amdgpu_virt_alloc_mm_table(adev);
if (r)
@@ -206,6 +210,10 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
adev->vcn.ip_dump = ptr;
}
+ r = amdgpu_vcn_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
+
return 0;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
index 89bf29fa6f8d..a67a0b11027a 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
@@ -170,6 +170,9 @@ static int vcn_v5_0_0_sw_init(struct amdgpu_ip_block *ip_block)
amdgpu_vcn_fwlog_init(&adev->vcn.inst[i]);
}
+ /* TODO: check version which supported queue reset ? */
+ adev->sdma.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->vcn.inst[0].ring_enc[0]);
if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG)
adev->vcn.pause_dpg_mode = vcn_v5_0_0_pause_dpg_mode;
@@ -181,6 +184,11 @@ static int vcn_v5_0_0_sw_init(struct amdgpu_ip_block *ip_block)
} else {
adev->vcn.ip_dump = ptr;
}
+
+ r = amdgpu_vcn_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
+
return 0;
}
@@ -215,6 +223,7 @@ static int vcn_v5_0_0_sw_fini(struct amdgpu_ip_block *ip_block)
if (r)
return r;
+ amdgpu_vcn_sysfs_reset_mask_fini(adev);
r = amdgpu_vcn_sw_fini(adev);
kfree(adev->vcn.ip_dump);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH V3 4/5] drm/amdgpu: Add sysfs interface for vpe reset mask
2024-10-24 7:39 [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset mask Jesse.zhang@amd.com
2024-10-24 7:39 ` [PATCH V3 2/5] drm/amdgpu: Add sysfs interface for sdma " Jesse.zhang@amd.com
2024-10-24 7:39 ` [PATCH V3 3/5] drm/amdgpu: Add sysfs interface for vcn " Jesse.zhang@amd.com
@ 2024-10-24 7:39 ` Jesse.zhang@amd.com
2024-10-24 7:39 ` [PATCH V3 5/5] drm/amdgpu: Add sysfs interface for jpeg " Jesse.zhang@amd.com
2024-10-29 4:21 ` [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc " Huang, Tim
4 siblings, 0 replies; 7+ messages in thread
From: Jesse.zhang@amd.com @ 2024-10-24 7:39 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Jesse.zhang@amd.com,
Jesse Zhang
From: "Jesse.zhang@amd.com" <Jesse.zhang@amd.com>
Add the sysfs interface for vpe:
vpe_reset_mask
The interface is read-only and show the resets supported by the IP.
For example, full adapter reset (mode1/mode2/BACO/etc),
soft reset, queue reset, and pipe reset.
V2: the sysfs node returns a text string instead of some flags (Christian)
v3: add a generic helper which takes the ring as parameter
and print the strings in the order they are applied (Christian)
check amdgpu_gpu_recovery before creating sysfs file itself,
and initialize supported_reset_types in IP version files (Lijo)
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by:Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c | 43 +++++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.h | 3 ++
2 files changed, 46 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
index 6d96e1f21e20..44213634e236 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
@@ -377,6 +377,13 @@ static int vpe_sw_init(struct amdgpu_ip_block *ip_block)
ret = vpe_init_microcode(vpe);
if (ret)
goto out;
+
+ /* TODO: Check the version that supports queue reset */
+ adev->vpe.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->vpe.ring);
+ ret = amdgpu_vpe_sysfs_reset_mask_init(adev);
+ if (ret)
+ goto out;
out:
return ret;
}
@@ -389,6 +396,7 @@ static int vpe_sw_fini(struct amdgpu_ip_block *ip_block)
release_firmware(vpe->fw);
vpe->fw = NULL;
+ amdgpu_vpe_sysfs_reset_mask_fini(adev);
vpe_ring_fini(vpe);
amdgpu_bo_free_kernel(&adev->vpe.cmdbuf_obj,
@@ -865,6 +873,41 @@ static void vpe_ring_end_use(struct amdgpu_ring *ring)
schedule_delayed_work(&adev->vpe.idle_work, VPE_IDLE_TIMEOUT);
}
+static ssize_t amdgpu_get_vpe_reset_mask(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_device *ddev = dev_get_drvdata(dev);
+ struct amdgpu_device *adev = drm_to_adev(ddev);
+
+ if (!adev)
+ return -ENODEV;
+
+ return amdgpu_show_reset_mask(buf, adev->vpe.supported_reset);
+}
+
+static DEVICE_ATTR(vpe_reset_mask, 0444,
+ amdgpu_get_vpe_reset_mask, NULL);
+
+int amdgpu_vpe_sysfs_reset_mask_init(struct amdgpu_device *adev)
+{
+ int r = 0;
+
+ if (adev->vpe.num_instances) {
+ r = device_create_file(adev->dev, &dev_attr_vpe_reset_mask);
+ if (r)
+ return r;
+ }
+
+ return r;
+}
+
+void amdgpu_vpe_sysfs_reset_mask_fini(struct amdgpu_device *adev)
+{
+ if (adev->vpe.num_instances)
+ device_remove_file(adev->dev, &dev_attr_vpe_reset_mask);
+}
+
static const struct amdgpu_ring_funcs vpe_ring_funcs = {
.type = AMDGPU_RING_TYPE_VPE,
.align_mask = 0xf,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.h
index 231d86d0953e..695da740a97e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.h
@@ -79,6 +79,7 @@ struct amdgpu_vpe {
uint32_t num_instances;
bool collaborate_mode;
+ uint32_t supported_reset;
};
int amdgpu_vpe_psp_update_sram(struct amdgpu_device *adev);
@@ -86,6 +87,8 @@ int amdgpu_vpe_init_microcode(struct amdgpu_vpe *vpe);
int amdgpu_vpe_ring_init(struct amdgpu_vpe *vpe);
int amdgpu_vpe_ring_fini(struct amdgpu_vpe *vpe);
int amdgpu_vpe_configure_dpm(struct amdgpu_vpe *vpe);
+void amdgpu_vpe_sysfs_reset_mask_fini(struct amdgpu_device *adev);
+int amdgpu_vpe_sysfs_reset_mask_init(struct amdgpu_device *adev);
#define vpe_ring_init(vpe) ((vpe)->funcs->ring_init ? (vpe)->funcs->ring_init((vpe)) : 0)
#define vpe_ring_start(vpe) ((vpe)->funcs->ring_start ? (vpe)->funcs->ring_start((vpe)) : 0)
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH V3 5/5] drm/amdgpu: Add sysfs interface for jpeg reset mask
2024-10-24 7:39 [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset mask Jesse.zhang@amd.com
` (2 preceding siblings ...)
2024-10-24 7:39 ` [PATCH V3 4/5] drm/amdgpu: Add sysfs interface for vpe " Jesse.zhang@amd.com
@ 2024-10-24 7:39 ` Jesse.zhang@amd.com
2024-10-29 4:21 ` [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc " Huang, Tim
4 siblings, 0 replies; 7+ messages in thread
From: Jesse.zhang@amd.com @ 2024-10-24 7:39 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Jesse.zhang@amd.com,
Jesse Zhang
From: "Jesse.zhang@amd.com" <Jesse.zhang@amd.com>
Add the sysfs interface for jpeg:
jpeg_reset_mask
The interface is read-only and show the resets supported by the IP.
For example, full adapter reset (mode1/mode2/BACO/etc),
soft reset, queue reset, and pipe reset.
V2: the sysfs node returns a text string instead of some flags (Christian)
v3: add a generic helper which takes the ring as parameter
and print the strings in the order they are applied (Christian)
check amdgpu_gpu_recovery before creating sysfs file itself,
and initialize supported_reset_types in IP version files (Lijo)
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by:Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 35 ++++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h | 3 ++
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 7 +++++
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 8 ++++++
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c | 8 ++++++
drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c | 7 +++++
6 files changed, 68 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
index 95e2796919fc..f971ffdffce9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
@@ -415,3 +415,38 @@ void amdgpu_debugfs_jpeg_sched_mask_init(struct amdgpu_device *adev)
&amdgpu_debugfs_jpeg_sched_mask_fops);
#endif
}
+
+static ssize_t amdgpu_get_jpeg_reset_mask(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_device *ddev = dev_get_drvdata(dev);
+ struct amdgpu_device *adev = drm_to_adev(ddev);
+
+ if (!adev)
+ return -ENODEV;
+
+ return amdgpu_show_reset_mask(buf, adev->jpeg.supported_reset);
+}
+
+static DEVICE_ATTR(jpeg_reset_mask, 0444,
+ amdgpu_get_jpeg_reset_mask, NULL);
+
+int amdgpu_jpeg_sysfs_reset_mask_init(struct amdgpu_device *adev)
+{
+ int r = 0;
+
+ if (adev->jpeg.num_jpeg_inst) {
+ r = device_create_file(adev->dev, &dev_attr_jpeg_reset_mask);
+ if (r)
+ return r;
+ }
+
+ return r;
+}
+
+void amdgpu_jpeg_sysfs_reset_mask_fini(struct amdgpu_device *adev)
+{
+ if (adev->jpeg.num_jpeg_inst)
+ device_remove_file(adev->dev, &dev_attr_jpeg_reset_mask);
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h
index 819dc7a0af99..3eb4a4653fce 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h
@@ -128,6 +128,7 @@ struct amdgpu_jpeg {
uint16_t inst_mask;
uint8_t num_inst_per_aid;
bool indirect_sram;
+ uint32_t supported_reset;
};
int amdgpu_jpeg_sw_init(struct amdgpu_device *adev);
@@ -150,5 +151,7 @@ int amdgpu_jpeg_ras_sw_init(struct amdgpu_device *adev);
int amdgpu_jpeg_psp_update_sram(struct amdgpu_device *adev, int inst_idx,
enum AMDGPU_UCODE_ID ucode_id);
void amdgpu_debugfs_jpeg_sched_mask_init(struct amdgpu_device *adev);
+int amdgpu_jpeg_sysfs_reset_mask_init(struct amdgpu_device *adev);
+void amdgpu_jpeg_sysfs_reset_mask_fini(struct amdgpu_device *adev);
#endif /*__AMDGPU_JPEG_H__*/
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
index 20e1fe89c463..d1ee342d91e7 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
@@ -121,6 +121,12 @@ static int jpeg_v4_0_sw_init(struct amdgpu_ip_block *ip_block)
adev->jpeg.inst->external.jpeg_pitch[0] = SOC15_REG_OFFSET(JPEG, 0, regUVD_JPEG_PITCH);
r = amdgpu_jpeg_ras_sw_init(adev);
+ if (r)
+ return r;
+ /* TODO: Check the version that supports queue reset */
+ adev->jpeg.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->jpeg.inst[0].ring_dec[0]);
+ r = amdgpu_jpeg_sysfs_reset_mask_init(adev);
if (r)
return r;
@@ -143,6 +149,7 @@ static int jpeg_v4_0_sw_fini(struct amdgpu_ip_block *ip_block)
if (r)
return r;
+ amdgpu_jpeg_sysfs_reset_mask_fini(adev);
r = amdgpu_jpeg_sw_fini(adev);
return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c
index 2a53537db135..8c673fe71e5b 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c
@@ -159,6 +159,13 @@ static int jpeg_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
}
}
+ /* TODO: Check the version that supports queue reset */
+ adev->jpeg.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->jpeg.inst[0].ring_dec[0]);
+ r = amdgpu_jpeg_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
+
return 0;
}
@@ -178,6 +185,7 @@ static int jpeg_v4_0_3_sw_fini(struct amdgpu_ip_block *ip_block)
if (r)
return r;
+ amdgpu_jpeg_sysfs_reset_mask_fini(adev);
r = amdgpu_jpeg_sw_fini(adev);
return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
index ef2d4237925b..fc60b1e29f3e 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
@@ -153,6 +153,13 @@ static int jpeg_v4_0_5_sw_init(struct amdgpu_ip_block *ip_block)
adev->jpeg.inst[i].external.jpeg_pitch[0] = SOC15_REG_OFFSET(JPEG, i, regUVD_JPEG_PITCH);
}
+ /* TODO: Check the version that supports queue reset */
+ adev->jpeg.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->jpeg.inst[0].ring_dec[0]);
+ r = amdgpu_jpeg_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
+
return 0;
}
@@ -172,6 +179,7 @@ static int jpeg_v4_0_5_sw_fini(struct amdgpu_ip_block *ip_block)
if (r)
return r;
+ amdgpu_jpeg_sysfs_reset_mask_fini(adev);
r = amdgpu_jpeg_sw_fini(adev);
return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c
index 7954a6fae464..7ef4389ea03e 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c
@@ -100,6 +100,12 @@ static int jpeg_v5_0_0_sw_init(struct amdgpu_ip_block *ip_block)
adev->jpeg.internal.jpeg_pitch[0] = regUVD_JPEG_PITCH_INTERNAL_OFFSET;
adev->jpeg.inst->external.jpeg_pitch[0] = SOC15_REG_OFFSET(JPEG, 0, regUVD_JPEG_PITCH);
+ /* TODO: Check the version that supports queue reset */
+ adev->jpeg.supported_reset |=
+ amdgpu_get_soft_full_reset_mask(&adev->jpeg.inst[0].ring_dec[0]);
+ r = amdgpu_jpeg_sysfs_reset_mask_init(adev);
+ if (r)
+ return r;
return 0;
}
@@ -119,6 +125,7 @@ static int jpeg_v5_0_0_sw_fini(struct amdgpu_ip_block *ip_block)
if (r)
return r;
+ amdgpu_jpeg_sysfs_reset_mask_fini(adev);
r = amdgpu_jpeg_sw_fini(adev);
return r;
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* RE: [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset mask
2024-10-24 7:39 [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset mask Jesse.zhang@amd.com
` (3 preceding siblings ...)
2024-10-24 7:39 ` [PATCH V3 5/5] drm/amdgpu: Add sysfs interface for jpeg " Jesse.zhang@amd.com
@ 2024-10-29 4:21 ` Huang, Tim
2024-10-29 4:50 ` Huang, Tim
4 siblings, 1 reply; 7+ messages in thread
From: Huang, Tim @ 2024-10-29 4:21 UTC (permalink / raw)
To: Zhang, Jesse(Jie), amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander, Koenig, Christian, Zhang, Jesse(Jie),
Zhang, Jesse(Jie)
[Public]
Hi Jesse,
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
> Jesse.zhang@amd.com
> Sent: Thursday, October 24, 2024 3:39 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>;
> Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>
> Subject: [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset mask
>
> Add two sysfs interfaces for gfx and compute:
> gfx_reset_mask
> compute_reset_mask
>
> These interfaces are read-only and show the resets supported by the IP.
> For example, full adapter reset (mode1/mode2/BACO/etc), soft reset, queue
> reset, and pipe reset.
>
> V2: the sysfs node returns a text string instead of some flags (Christian)
> v3: add a generic helper which takes the ring as parameter
> and print the strings in the order they are applied (Christian)
>
> check amdgpu_gpu_recovery before creating sysfs file itself,
> and initialize supported_reset_types in IP version files (Lijo)
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com> Suggested-by:Alex
> Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 8 +++
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 37 ++++++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 66
> ++++++++++++++++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 4 ++
> drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 6 ++
> drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 14 +++++
> drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 12 ++++
> 7 files changed, 147 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 48c9b9b06905..aea1031d7b84 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -300,6 +300,12 @@ extern int amdgpu_wbrf;
> #define AMDGPU_RESET_VCE (1 << 13)
> #define AMDGPU_RESET_VCE1 (1 << 14)
>
> +/* reset mask */
> +#define AMDGPU_RESET_TYPE_FULL (1 << 0) /* full adapter reset,
> +mode1/mode2/BACO/etc. */ #define AMDGPU_RESET_TYPE_SOFT_RESET (1
> << 1)
> +/* IP level soft reset */ #define AMDGPU_RESET_TYPE_PER_QUEUE (1 << 2)
> +/* per queue */ #define AMDGPU_RESET_TYPE_PER_PIPE (1 << 3) /* per pipe
> +*/
> +
> /* max cursor sizes (in pixels) */
> #define CIK_CURSOR_WIDTH 128
> #define CIK_CURSOR_HEIGHT 128
> @@ -1466,6 +1472,8 @@ struct dma_fence
> *amdgpu_device_get_gang(struct amdgpu_device *adev); struct dma_fence
> *amdgpu_device_switch_gang(struct amdgpu_device *adev,
> struct dma_fence *gang);
> bool amdgpu_device_has_display_hardware(struct amdgpu_device *adev);
> +ssize_t amdgpu_get_soft_full_reset_mask(struct amdgpu_ring *ring);
> +ssize_t amdgpu_show_reset_mask(char *buf, uint32_t supported_reset);
>
> /* atpx handler */
> #if defined(CONFIG_VGA_SWITCHEROO)
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index ef715b2bbcdb..cd1e3f018893 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -6684,3 +6684,40 @@ uint32_t amdgpu_device_wait_on_rreg(struct
> amdgpu_device *adev,
> }
> return ret;
> }
> +
> +ssize_t amdgpu_get_soft_full_reset_mask(struct amdgpu_ring *ring) {
> + ssize_t size = 0;
> +
> + if (!ring)
> + return size;
> +
> + if (amdgpu_device_should_recover_gpu(ring->adev))
> + size |= AMDGPU_RESET_TYPE_FULL;
> +
> + if (unlikely(!ring->adev->debug_disable_soft_recovery) &&
> + !amdgpu_sriov_vf(ring->adev) && ring->funcs->soft_recovery)
> + size |= AMDGPU_RESET_TYPE_SOFT_RESET;
> +
> + return size;
> +}
> +
> +ssize_t amdgpu_show_reset_mask(char *buf, uint32_t supported_reset) {
> + ssize_t size = 0;
> +
> + if (supported_reset & AMDGPU_RESET_TYPE_SOFT_RESET)
> + size += sysfs_emit_at(buf, size, "soft ");
> +
> + if (supported_reset & AMDGPU_RESET_TYPE_PER_QUEUE)
> + size += sysfs_emit_at(buf, size, "queue ");
> +
> + if (supported_reset & AMDGPU_RESET_TYPE_PER_PIPE)
> + size += sysfs_emit_at(buf, size, "pipe ");
> +
> + if (supported_reset & AMDGPU_RESET_TYPE_FULL)
> + size += sysfs_emit_at(buf, size, "full ");
> +
> + size += sysfs_emit_at(buf, size, "\n");
> + return size;
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> index e96984c53e72..6de1f3bf6863 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> @@ -1588,6 +1588,32 @@ static ssize_t
> amdgpu_gfx_set_enforce_isolation(struct device *dev,
> return count;
> }
>
> +static ssize_t amdgpu_gfx_get_gfx_reset_mask(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct drm_device *ddev = dev_get_drvdata(dev);
> + struct amdgpu_device *adev = drm_to_adev(ddev);
> +
> + if (!adev)
> + return -ENODEV;
> +
> + return amdgpu_show_reset_mask(buf, adev->gfx.gfx_supported_reset); }
> +
> +static ssize_t amdgpu_gfx_get_compute_reset_mask(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct drm_device *ddev = dev_get_drvdata(dev);
> + struct amdgpu_device *adev = drm_to_adev(ddev);
> +
> + if (!adev)
> + return -ENODEV;
> +
> + return amdgpu_show_reset_mask(buf,
> adev->gfx.compute_supported_reset);
> +}
> +
> static DEVICE_ATTR(run_cleaner_shader, 0200,
> NULL, amdgpu_gfx_set_run_cleaner_shader);
>
> @@ -1602,6 +1628,12 @@ static DEVICE_ATTR(current_compute_partition,
> 0644, static DEVICE_ATTR(available_compute_partition, 0444,
> amdgpu_gfx_get_available_compute_partition, NULL);
>
> +static DEVICE_ATTR(gfx_reset_mask, 0444,
> + amdgpu_gfx_get_gfx_reset_mask, NULL);
> +
> +static DEVICE_ATTR(compute_reset_mask, 0444,
> + amdgpu_gfx_get_compute_reset_mask, NULL);
> +
> int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev) {
> struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr; @@ -1702,6
> +1734,40 @@ void amdgpu_gfx_cleaner_shader_init(struct amdgpu_device
> *adev,
> cleaner_shader_size);
> }
>
> +int amdgpu_gfx_sysfs_reset_mask_init(struct amdgpu_device *adev) {
> + int r = 0;
> +
> + if (!amdgpu_gpu_recovery)
> + return r;
> +
> + if (adev->gfx.num_gfx_rings) {
> + r = device_create_file(adev->dev, &dev_attr_gfx_reset_mask);
> + if (r)
> + return r;
> + }
> +
> + if (adev->gfx.num_compute_rings) {
> + r = device_create_file(adev->dev, &dev_attr_compute_reset_mask);
> + if (r)
> + return r;
> + }
> +
> + return r;
> +}
> +
> +void amdgpu_gfx_sysfs_reset_mask_fini(struct amdgpu_device *adev) {
> + if (!amdgpu_gpu_recovery)
> + return;
> +
> + if (adev->gfx.num_gfx_rings)
> + device_remove_file(adev->dev, &dev_attr_gfx_reset_mask);
> +
> + if (adev->gfx.num_compute_rings)
> + device_remove_file(adev->dev, &dev_attr_compute_reset_mask); }
> +
> /**
> * amdgpu_gfx_kfd_sch_ctrl - Control the KFD scheduler from the KGD
> (Graphics Driver)
> * @adev: amdgpu_device pointer
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> index f710178a21bc..fb0e1adf6766 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> @@ -424,6 +424,8 @@ struct amdgpu_gfx {
> /* reset mask */
> uint32_t grbm_soft_reset;
> uint32_t srbm_soft_reset;
> + uint32_t gfx_supported_reset;
> + uint32_t compute_supported_reset;
>
> /* gfx off */
> bool gfx_off_state; /* true:
> enabled, false: disabled */
> @@ -582,6 +584,8 @@ void amdgpu_gfx_sysfs_isolation_shader_fini(struct
> amdgpu_device *adev); void amdgpu_gfx_enforce_isolation_handler(struct
> work_struct *work); void
> amdgpu_gfx_enforce_isolation_ring_begin_use(struct amdgpu_ring *ring);
> void amdgpu_gfx_enforce_isolation_ring_end_use(struct amdgpu_ring *ring);
> +int amdgpu_gfx_sysfs_reset_mask_init(struct amdgpu_device *adev); void
> +amdgpu_gfx_sysfs_reset_mask_fini(struct amdgpu_device *adev);
>
> static inline const char *amdgpu_gfx_compute_mode_desc(int mode) { diff
> --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> index 9da95b25e158..446e37768397 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
Here may miss the reset_mask_int and reset_mask_fini for gfx_v10.
Best Regards
Tim
> @@ -4806,6 +4806,9 @@ static int gfx_v10_0_sw_init(struct
> amdgpu_ip_block *ip_block)
> }
> }
> }
> + /* TODO: Check the version that supports fully queue reset */
> + adev->gfx.gfx_supported_reset |=
> + amdgpu_get_soft_full_reset_mask(&adev->gfx.gfx_ring[0]);
>
> ring_id = 0;
> /* set up the compute queues - allocate horizontally across pipes */ @@
> -4825,6 +4828,9 @@ static int gfx_v10_0_sw_init(struct amdgpu_ip_block
> *ip_block)
> }
> }
> }
> + /* TODO: Check the version that supports fully queue reset */
> + adev->gfx.compute_supported_reset |=
> + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]);
>
> r = amdgpu_gfx_kiq_init(adev, GFX10_MEC_HPD_SIZE, 0);
> if (r) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 5aff8f72de9c..3b23402dfb47 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -1560,6 +1560,11 @@ static int gfx_v11_0_sw_init(struct
> amdgpu_ip_block *ip_block)
> adev->userq_funcs[AMDGPU_HW_IP_GFX] =
> &userq_mes_v11_0_funcs;
> adev->userq_funcs[AMDGPU_HW_IP_COMPUTE] =
> &userq_mes_v11_0_funcs; #endif
> + if ((adev->gfx.me_fw_version >= 2280) &&
> + (adev->gfx.mec_fw_version >= 2410)) {
> + adev->gfx.compute_supported_reset =
> AMDGPU_RESET_TYPE_PER_QUEUE;
> + adev->gfx.gfx_supported_reset =
> AMDGPU_RESET_TYPE_PER_QUEUE;
> + }
> break;
> case IP_VERSION(11, 0, 1):
> case IP_VERSION(11, 0, 4):
> @@ -1663,6 +1668,8 @@ static int gfx_v11_0_sw_init(struct
> amdgpu_ip_block *ip_block)
> }
> }
> }
> + adev->gfx.gfx_supported_reset |=
> + amdgpu_get_soft_full_reset_mask(&adev->gfx.gfx_ring[0]);
>
> ring_id = 0;
> /* set up the compute queues - allocate horizontally across pipes */ @@
> -1682,6 +1689,8 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block
> *ip_block)
> }
> }
> }
> + adev->gfx.compute_supported_reset |=
> + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]);
>
> if (!adev->enable_mes_kiq) {
> r = amdgpu_gfx_kiq_init(adev, GFX11_MEC_HPD_SIZE, 0); @@
> -1721,6 +1730,10 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block
> *ip_block)
> if (r)
> return r;
>
> + r = amdgpu_gfx_sysfs_reset_mask_init (adev);
> + if (r)
> + return r;
> +
> return 0;
> }
>
> @@ -1783,6 +1796,7 @@ static int gfx_v11_0_sw_fini(struct
> amdgpu_ip_block *ip_block)
> gfx_v11_0_free_microcode(adev);
>
> amdgpu_gfx_sysfs_isolation_shader_fini(adev);
> + amdgpu_gfx_sysfs_reset_mask_fini(adev);
>
> kfree(adev->gfx.ip_dump_core);
> kfree(adev->gfx.ip_dump_compute_queues);
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> index 016290f00592..b9d5a79ba85c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> @@ -1067,6 +1067,11 @@ static int gfx_v9_4_3_sw_init(struct
> amdgpu_ip_block *ip_block)
> dev_err(adev->dev, "Failed to initialize cleaner shader\n");
> }
> }
> +
> + if (adev->gfx.mec_fw_version >= 155) {
> + adev->gfx.compute_supported_reset =
> AMDGPU_RESET_TYPE_PER_QUEUE;
> + adev->gfx.compute_supported_reset |=
> AMDGPU_RESET_TYPE_PER_PIPE;
> + }
> break;
> default:
> adev->gfx.enable_cleaner_shader = false; @@ -1157,6 +1162,9 @@
> static int gfx_v9_4_3_sw_init(struct amdgpu_ip_block *ip_block)
> return r;
> }
>
> + adev->gfx.compute_supported_reset |=
> + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]);
> +
> r = gfx_v9_4_3_gpu_early_init(adev);
> if (r)
> return r;
> @@ -1175,6 +1183,9 @@ static int gfx_v9_4_3_sw_init(struct
> amdgpu_ip_block *ip_block)
> if (r)
> return r;
>
> + r = amdgpu_gfx_sysfs_reset_mask_init(adev);
> + if (r)
> + return r;
> return 0;
> }
>
> @@ -1200,6 +1211,7 @@ static int gfx_v9_4_3_sw_fini(struct
> amdgpu_ip_block *ip_block)
> gfx_v9_4_3_free_microcode(adev);
> amdgpu_gfx_sysfs_fini(adev);
> amdgpu_gfx_sysfs_isolation_shader_fini(adev);
> + amdgpu_gfx_sysfs_reset_mask_fini(adev);
>
> kfree(adev->gfx.ip_dump_core);
> kfree(adev->gfx.ip_dump_compute_queues);
> --
> 2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread* RE: [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset mask
2024-10-29 4:21 ` [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc " Huang, Tim
@ 2024-10-29 4:50 ` Huang, Tim
0 siblings, 0 replies; 7+ messages in thread
From: Huang, Tim @ 2024-10-29 4:50 UTC (permalink / raw)
To: Huang, Tim, Zhang, Jesse(Jie), amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander, Koenig, Christian, Zhang, Jesse(Jie),
Zhang, Jesse(Jie)
[Public]
Hi Jesse,
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Huang,
> Tim
> Sent: Tuesday, October 29, 2024 12:21 PM
> To: Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>; amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>;
> Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>
> Subject: RE: [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset
> mask
>
> [Public]
>
> [Public]
>
> Hi Jesse,
>
> > -----Original Message-----
> > From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
> > Jesse.zhang@amd.com
> > Sent: Thursday, October 24, 2024 3:39 PM
> > To: amd-gfx@lists.freedesktop.org
> > Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> > <Christian.Koenig@amd.com>; Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>;
> > Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>
> > Subject: [PATCH V3 1/5] drm/amdgpu: Add sysfs interface for gc reset
> > mask
> >
> > Add two sysfs interfaces for gfx and compute:
> > gfx_reset_mask
> > compute_reset_mask
> >
> > These interfaces are read-only and show the resets supported by the IP.
> > For example, full adapter reset (mode1/mode2/BACO/etc), soft reset,
> > queue reset, and pipe reset.
> >
> > V2: the sysfs node returns a text string instead of some flags
> > (Christian)
> > v3: add a generic helper which takes the ring as parameter
> > and print the strings in the order they are applied (Christian)
> >
> > check amdgpu_gpu_recovery before creating sysfs file itself,
> > and initialize supported_reset_types in IP version files (Lijo)
> >
> > Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com> Suggested-by:Alex
> > Deucher <alexander.deucher@amd.com>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu.h | 8 +++
> > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 37 ++++++++++++
> > drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 66
> > ++++++++++++++++++++++
> > drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 4 ++
> > drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 6 ++
> > drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 14 +++++
> > drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 12 ++++
> > 7 files changed, 147 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > index 48c9b9b06905..aea1031d7b84 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > @@ -300,6 +300,12 @@ extern int amdgpu_wbrf;
> > #define AMDGPU_RESET_VCE (1 << 13)
> > #define AMDGPU_RESET_VCE1 (1 << 14)
> >
> > +/* reset mask */
> > +#define AMDGPU_RESET_TYPE_FULL (1 << 0) /* full adapter reset,
> > +mode1/mode2/BACO/etc. */ #define AMDGPU_RESET_TYPE_SOFT_RESET
> (1
> > << 1)
> > +/* IP level soft reset */ #define AMDGPU_RESET_TYPE_PER_QUEUE (1 <<
> > +2)
> > +/* per queue */ #define AMDGPU_RESET_TYPE_PER_PIPE (1 << 3) /* per
> > +pipe */
> > +
> > /* max cursor sizes (in pixels) */
> > #define CIK_CURSOR_WIDTH 128
> > #define CIK_CURSOR_HEIGHT 128
> > @@ -1466,6 +1472,8 @@ struct dma_fence
> *amdgpu_device_get_gang(struct
> > amdgpu_device *adev); struct dma_fence
> > *amdgpu_device_switch_gang(struct amdgpu_device *adev,
> > struct dma_fence *gang);
> > bool amdgpu_device_has_display_hardware(struct amdgpu_device *adev);
> > +ssize_t amdgpu_get_soft_full_reset_mask(struct amdgpu_ring *ring);
> > +ssize_t amdgpu_show_reset_mask(char *buf, uint32_t supported_reset);
> >
> > /* atpx handler */
> > #if defined(CONFIG_VGA_SWITCHEROO)
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > index ef715b2bbcdb..cd1e3f018893 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -6684,3 +6684,40 @@ uint32_t amdgpu_device_wait_on_rreg(struct
> > amdgpu_device *adev,
> > }
> > return ret;
> > }
> > +
> > +ssize_t amdgpu_get_soft_full_reset_mask(struct amdgpu_ring *ring) {
> > + ssize_t size = 0;
> > +
> > + if (!ring)
> > + return size;
> > +
> > + if (amdgpu_device_should_recover_gpu(ring->adev))
> > + size |= AMDGPU_RESET_TYPE_FULL;
> > +
> > + if (unlikely(!ring->adev->debug_disable_soft_recovery) &&
> > + !amdgpu_sriov_vf(ring->adev) && ring->funcs->soft_recovery)
> > + size |= AMDGPU_RESET_TYPE_SOFT_RESET;
> > +
> > + return size;
> > +}
> > +
> > +ssize_t amdgpu_show_reset_mask(char *buf, uint32_t supported_reset) {
> > + ssize_t size = 0;
> > +
> > + if (supported_reset & AMDGPU_RESET_TYPE_SOFT_RESET)
> > + size += sysfs_emit_at(buf, size, "soft ");
> > +
> > + if (supported_reset & AMDGPU_RESET_TYPE_PER_QUEUE)
> > + size += sysfs_emit_at(buf, size, "queue ");
> > +
> > + if (supported_reset & AMDGPU_RESET_TYPE_PER_PIPE)
> > + size += sysfs_emit_at(buf, size, "pipe ");
> > +
> > + if (supported_reset & AMDGPU_RESET_TYPE_FULL)
> > + size += sysfs_emit_at(buf, size, "full ");
> > +
> > + size += sysfs_emit_at(buf, size, "\n");
> > + return size;
> > +}
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> > index e96984c53e72..6de1f3bf6863 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> > @@ -1588,6 +1588,32 @@ static ssize_t
> > amdgpu_gfx_set_enforce_isolation(struct device *dev,
> > return count;
> > }
> >
> > +static ssize_t amdgpu_gfx_get_gfx_reset_mask(struct device *dev,
> > + struct
> device_attribute *attr,
> > + char *buf) {
> > + struct drm_device *ddev = dev_get_drvdata(dev);
> > + struct amdgpu_device *adev = drm_to_adev(ddev);
> > +
> > + if (!adev)
> > + return -ENODEV;
> > +
> > + return amdgpu_show_reset_mask(buf,
> > + adev->gfx.gfx_supported_reset); }
> > +
> > +static ssize_t amdgpu_gfx_get_compute_reset_mask(struct device *dev,
> > + struct
> device_attribute *attr,
> > + char *buf) {
> > + struct drm_device *ddev = dev_get_drvdata(dev);
> > + struct amdgpu_device *adev = drm_to_adev(ddev);
> > +
> > + if (!adev)
> > + return -ENODEV;
> > +
> > + return amdgpu_show_reset_mask(buf,
> > adev->gfx.compute_supported_reset);
> > +}
> > +
> > static DEVICE_ATTR(run_cleaner_shader, 0200,
> > NULL, amdgpu_gfx_set_run_cleaner_shader);
> >
> > @@ -1602,6 +1628,12 @@ static DEVICE_ATTR(current_compute_partition,
> > 0644, static DEVICE_ATTR(available_compute_partition, 0444,
> > amdgpu_gfx_get_available_compute_partition, NULL);
> >
> > +static DEVICE_ATTR(gfx_reset_mask, 0444,
> > + amdgpu_gfx_get_gfx_reset_mask, NULL);
> > +
> > +static DEVICE_ATTR(compute_reset_mask, 0444,
> > + amdgpu_gfx_get_compute_reset_mask, NULL);
> > +
> > int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev) {
> > struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr; @@ -1702,6
> > +1734,40 @@ void amdgpu_gfx_cleaner_shader_init(struct amdgpu_device
> > *adev,
> > cleaner_shader_size); }
> >
> > +int amdgpu_gfx_sysfs_reset_mask_init(struct amdgpu_device *adev) {
> > + int r = 0;
> > +
> > + if (!amdgpu_gpu_recovery)
> > + return r;
> > +
> > + if (adev->gfx.num_gfx_rings) {
> > + r = device_create_file(adev->dev,
> &dev_attr_gfx_reset_mask);
> > + if (r)
> > + return r;
> > + }
> > +
> > + if (adev->gfx.num_compute_rings) {
> > + r = device_create_file(adev->dev,
> &dev_attr_compute_reset_mask);
> > + if (r)
> > + return r;
> > + }
> > +
> > + return r;
> > +}
> > +
> > +void amdgpu_gfx_sysfs_reset_mask_fini(struct amdgpu_device *adev) {
> > + if (!amdgpu_gpu_recovery)
> > + return;
> > +
> > + if (adev->gfx.num_gfx_rings)
> > + device_remove_file(adev->dev, &dev_attr_gfx_reset_mask);
> > +
> > + if (adev->gfx.num_compute_rings)
> > + device_remove_file(adev->dev,
> > + &dev_attr_compute_reset_mask); }
> > +
> > /**
> > * amdgpu_gfx_kfd_sch_ctrl - Control the KFD scheduler from the KGD
> > (Graphics Driver)
> > * @adev: amdgpu_device pointer
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> > index f710178a21bc..fb0e1adf6766 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> > @@ -424,6 +424,8 @@ struct amdgpu_gfx {
> > /* reset mask */
> > uint32_t grbm_soft_reset;
> > uint32_t srbm_soft_reset;
> > + uint32_t gfx_supported_reset;
> > + uint32_t compute_supported_reset;
> >
> > /* gfx off */
> > bool gfx_off_state; /* true:
> > enabled, false: disabled */
> > @@ -582,6 +584,8 @@ void amdgpu_gfx_sysfs_isolation_shader_fini(struct
> > amdgpu_device *adev); void
> > amdgpu_gfx_enforce_isolation_handler(struct
> > work_struct *work); void
> > amdgpu_gfx_enforce_isolation_ring_begin_use(struct amdgpu_ring *ring);
> > void amdgpu_gfx_enforce_isolation_ring_end_use(struct amdgpu_ring
> > *ring);
> > +int amdgpu_gfx_sysfs_reset_mask_init(struct amdgpu_device *adev);
> > +void amdgpu_gfx_sysfs_reset_mask_fini(struct amdgpu_device *adev);
> >
> > static inline const char *amdgpu_gfx_compute_mode_desc(int mode) {
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> > b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> > index 9da95b25e158..446e37768397 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
>
> Here may miss the reset_mask_int and reset_mask_fini for gfx_v10.
>
>
> Best Regards
> Tim
>
> > @@ -4806,6 +4806,9 @@ static int gfx_v10_0_sw_init(struct
> > amdgpu_ip_block *ip_block)
> > }
> > }
> > }
> > + /* TODO: Check the version that supports fully queue reset */
> > + adev->gfx.gfx_supported_reset |=
> > + amdgpu_get_soft_full_reset_mask(&adev->gfx.gfx_ring[0]);
> >
> > ring_id = 0;
> > /* set up the compute queues - allocate horizontally across
> > pipes */ @@
> > -4825,6 +4828,9 @@ static int gfx_v10_0_sw_init(struct amdgpu_ip_block
> > *ip_block)
> > }
> > }
> > }
> > + /* TODO: Check the version that supports fully queue reset */
> > + adev->gfx.compute_supported_reset |=
> > +
> > + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]);
> >
> > r = amdgpu_gfx_kiq_init(adev, GFX10_MEC_HPD_SIZE, 0);
> > if (r) {
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> > b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> > index 5aff8f72de9c..3b23402dfb47 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> > @@ -1560,6 +1560,11 @@ static int gfx_v11_0_sw_init(struct
> > amdgpu_ip_block *ip_block)
> > adev->userq_funcs[AMDGPU_HW_IP_GFX] =
> > &userq_mes_v11_0_funcs;
> > adev->userq_funcs[AMDGPU_HW_IP_COMPUTE] =
> > &userq_mes_v11_0_funcs; #endif
> > + if ((adev->gfx.me_fw_version >= 2280) &&
> > + (adev->gfx.mec_fw_version >= 2410)) {
> > + adev->gfx.compute_supported_reset =
> > AMDGPU_RESET_TYPE_PER_QUEUE;
> > + adev->gfx.gfx_supported_reset =
> > AMDGPU_RESET_TYPE_PER_QUEUE;
> > + }
> > break;
> > case IP_VERSION(11, 0, 1):
> > case IP_VERSION(11, 0, 4):
> > @@ -1663,6 +1668,8 @@ static int gfx_v11_0_sw_init(struct
> > amdgpu_ip_block *ip_block)
> > }
> > }
> > }
> > + adev->gfx.gfx_supported_reset |=
> > + amdgpu_get_soft_full_reset_mask(&adev->gfx.gfx_ring[0]);
> >
> > ring_id = 0;
> > /* set up the compute queues - allocate horizontally across
> > pipes */ @@
> > -1682,6 +1689,8 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block
> > *ip_block)
> > }
> > }
> > }
> > + adev->gfx.compute_supported_reset |=
> > +
> > + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]);
> >
> > if (!adev->enable_mes_kiq) {
> > r = amdgpu_gfx_kiq_init(adev, GFX11_MEC_HPD_SIZE, 0);
> @@
> > -1721,6 +1730,10 @@ static int gfx_v11_0_sw_init(struct
> > amdgpu_ip_block
> > *ip_block)
> > if (r)
> > return r;
> >
> > + r = amdgpu_gfx_sysfs_reset_mask_init (adev);
> > + if (r)
> > + return r;
> > +
> > return 0;
> > }
> >
> > @@ -1783,6 +1796,7 @@ static int gfx_v11_0_sw_fini(struct
> > amdgpu_ip_block *ip_block)
> > gfx_v11_0_free_microcode(adev);
> >
> > amdgpu_gfx_sysfs_isolation_shader_fini(adev);
> > + amdgpu_gfx_sysfs_reset_mask_fini(adev);
> >
> > kfree(adev->gfx.ip_dump_core);
> > kfree(adev->gfx.ip_dump_compute_queues);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> > b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> > index 016290f00592..b9d5a79ba85c 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> > @@ -1067,6 +1067,11 @@ static int gfx_v9_4_3_sw_init(struct
> > amdgpu_ip_block *ip_block)
> > dev_err(adev->dev, "Failed to initialize
> cleaner shader\n");
> > }
> > }
> > +
> > + if (adev->gfx.mec_fw_version >= 155) {
> > + adev->gfx.compute_supported_reset =
> > AMDGPU_RESET_TYPE_PER_QUEUE;
> > + adev->gfx.compute_supported_reset |=
> > AMDGPU_RESET_TYPE_PER_PIPE;
> > + }
> > break;
> > default:
> > adev->gfx.enable_cleaner_shader = false; @@ -1157,6
> > +1162,9 @@ static int gfx_v9_4_3_sw_init(struct amdgpu_ip_block
> *ip_block)
> > return r;
> > }
> >
> > + adev->gfx.compute_supported_reset |=
> > +
> > + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]);
May careful handling is required for the initialization of `adev->gfx.gfx_supported_reset` and `adev->gfx.compute_supported_reset`. For instance, in `gfx_v9`, `adev->gfx.gfx_supported_reset` is not initialized, yet the sysfs file should be created by `amdgpu_gfx_sysfs_reset_mask_init`. Additionally, `adev->gfx.compute_supported_reset` may perform a bitwise OR operation with an uninitialized value when adev->gfx.mec_fw_version < 155.
Best Regards
Tim Huang
> > +
> > r = gfx_v9_4_3_gpu_early_init(adev);
> > if (r)
> > return r;
> > @@ -1175,6 +1183,9 @@ static int gfx_v9_4_3_sw_init(struct
> > amdgpu_ip_block *ip_block)
> > if (r)
> > return r;
> >
> > + r = amdgpu_gfx_sysfs_reset_mask_init(adev);
> > + if (r)
> > + return r;
> > return 0;
> > }
> >
> > @@ -1200,6 +1211,7 @@ static int gfx_v9_4_3_sw_fini(struct
> > amdgpu_ip_block *ip_block)
> > gfx_v9_4_3_free_microcode(adev);
> > amdgpu_gfx_sysfs_fini(adev);
> > amdgpu_gfx_sysfs_isolation_shader_fini(adev);
> > + amdgpu_gfx_sysfs_reset_mask_fini(adev);
> >
> > kfree(adev->gfx.ip_dump_core);
> > kfree(adev->gfx.ip_dump_compute_queues);
> > --
> > 2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread