Skip to contentSkip to conversation

drm/amd: Add helper to get partition config modes

PATCH In review Asad Kamal 3 participants 6 messages Sep 24, 2024

Subsystems (2)
lore
Share & tools
lore

Asad Kamal

author
#0 lore raw

PATCH v2 1/4 drm/amd: Add helper to get partition config modes

From: Lijo Lazar <[email protected]>

Add helper to get supported/available partition config modes

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 40 ++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h    |  2 +
 drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 54 ++++++++++++++++++++++
 3 files changed, 76 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +20 -20
index 83e54697f0ee..2d3fdb6c3161 100644
@@ -1363,35 +1363,35 @@ static ssize_t amdgpu_gfx_set_compute_partition(struct device *dev,
 	return count;
 }
 
+static const char *xcp_desc[] = {
+	[AMDGPU_SPX_PARTITION_MODE] = "SPX",
+	[AMDGPU_DPX_PARTITION_MODE] = "DPX",
+	[AMDGPU_TPX_PARTITION_MODE] = "TPX",
+	[AMDGPU_QPX_PARTITION_MODE] = "QPX",
+	[AMDGPU_CPX_PARTITION_MODE] = "CPX",
+};
+
 static ssize_t amdgpu_gfx_get_available_compute_partition(struct device *dev,
 						struct device_attribute *addr,
 						char *buf)
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(ddev);
-	char *supported_partition;
+	struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr;
+	int size = 0, mode;
+	char *sep = "";
 
-	/* TBD */
-	switch (NUM_XCC(adev->gfx.xcc_mask)) {
-	case 8:
-		supported_partition = "SPX, DPX, QPX, CPX";
-		break;
-	case 6:
-		supported_partition = "SPX, TPX, CPX";
-		break;
-	case 4:
-		supported_partition = "SPX, DPX, CPX";
-		break;
-	/* this seems only existing in emulation phase */
-	case 2:
-		supported_partition = "SPX, CPX";
-		break;
-	default:
-		supported_partition = "Not supported";
-		break;
+	if (!xcp_mgr || !xcp_mgr->avail_xcp_modes)
+		return sysfs_emit(buf, "Not supported\n");
+
+	for_each_inst(mode, xcp_mgr->avail_xcp_modes) {
+		size += sysfs_emit_at(buf, size, "%s%s", sep, xcp_desc[mode]);
+		sep = ", ";
 	}
 
-	return sysfs_emit(buf, "%s\n", supported_partition);
+	size += sysfs_emit_at(buf, size, "\n");
+
+	return size;
 }
 
 static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h +2 -0
index 32775260556f..2c54c05f2c16 100644
@@ -97,6 +97,8 @@ struct amdgpu_xcp_mgr {
 
 	 /* Used to determine KFD memory size limits per XCP */
 	unsigned int num_xcp_per_mem_partition;
+	uint32_t supp_xcp_modes;
+	uint32_t avail_xcp_modes;
 };
 
 struct amdgpu_xcp_mgr_funcs {
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +54 -0

72 lines not on this page · raw message

Signature · 1 line
2.46.0
author
#1 lore raw

PATCH v2 2/4 drm/amdgpu: Add callback get xcp resource info

From: Lijo Lazar <[email protected]>

Add a callback interface to get the resource information of a partition mode. Presently the information has number of resources and number of entities sharing the resource.

Add the implementation for aquavanjaram SOCs.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h    | 26 +++++++++-
 drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 59 +++++++++++++++++++++-
 2 files changed, 83 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h +25 -1
index 2c54c05f2c16..648237f27d1c 100644
@@ -56,6 +56,27 @@ enum AMDGPU_XCP_STATE {
 	AMDGPU_XCP_RESUME,
 };
 
+enum amdgpu_xcp_res_id {
+	AMDGPU_XCP_RES_XCC,
+	AMDGPU_XCP_RES_DMA,
+	AMDGPU_XCP_RES_DEC,
+	AMDGPU_XCP_RES_JPEG,
+	AMDGPU_XCP_RES_MAX,
+};
+
+struct amdgpu_xcp_res_details {
+	enum amdgpu_xcp_res_id id;
+	u8 num_inst;
+	u8 num_shared;
+};
+
+struct amdgpu_xcp_cfg {
+	u8 mode;
+	struct amdgpu_xcp_res_details xcp_res[AMDGPU_XCP_RES_MAX];
+	u8 num_res;
+	struct amdgpu_xcp_mgr *xcp_mgr;
+};
+
 struct amdgpu_xcp_ip_funcs {
 	int (*prepare_suspend)(void *handle, uint32_t inst_mask);
 	int (*suspend)(void *handle, uint32_t inst_mask);
@@ -97,6 +118,7 @@ struct amdgpu_xcp_mgr {
 
 	 /* Used to determine KFD memory size limits per XCP */
 	unsigned int num_xcp_per_mem_partition;
+	struct amdgpu_xcp_cfg *xcp_cfg;
 	uint32_t supp_xcp_modes;
 	uint32_t avail_xcp_modes;
 };
@@ -110,7 +132,9 @@ struct amdgpu_xcp_mgr_funcs {
 			      struct amdgpu_xcp_ip *ip);
 	int (*get_xcp_mem_id)(struct amdgpu_xcp_mgr *xcp_mgr,
 			      struct amdgpu_xcp *xcp, uint8_t *mem_id);
-
+	int (*get_xcp_res_info)(struct amdgpu_xcp_mgr *xcp_mgr,
+				int mode,
+				struct amdgpu_xcp_cfg *xcp_cfg);
 	int (*prepare_suspend)(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id);
 	int (*suspend)(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id);
 	int (*prepare_resume)(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id);
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +58 -1

73 lines not on this page · raw message

Signature · 1 line
2.46.0
author
#2 lore raw

PATCH v2 3/4 drm/amdgpu: Add sysfs nodes to get xcp details

In reply to Asad Kamal

From: Lijo Lazar <[email protected]>

Add partition config nodes in sysfs to get resource instance details for a particular partition mode. A resource could be anything like an xcc, vcn decoder, system dma units etc.

Details of various resource instances are available under /sys/bus/pci/devices/.../compute_partition_config/

Select a partition configuration:
/sys/bus/pci/devices/.../compute_partition_config/xcp_config

Number of instances of a resource:
/sys/bus/pci/devices/.../compute_partition_config/<rsrc_name>/num_inst

Total partitions sharing the resource:
/sys/bus/pci/devices/.../compute_partition_config/<rsrc_name>/num_shared

v2: Update node name as per spec

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c    | 201 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h    |   5 +
 3 files changed, 208 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index dee57f15719e..0de81262ec7c 100644
@@ -4505,6 +4505,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
 	amdgpu_fru_sysfs_init(adev);
 	amdgpu_reg_state_sysfs_init(adev);
+	amdgpu_xcp_cfg_sysfs_init(adev);
 
 	if (IS_ENABLED(CONFIG_PERF_EVENTS))
 		r = amdgpu_pmu_init(adev);
@@ -4628,6 +4629,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
 	amdgpu_fru_sysfs_fini(adev);
 
 	amdgpu_reg_state_sysfs_fini(adev);
+	amdgpu_xcp_cfg_sysfs_fini(adev);
 
 	/* disable ras feature must before hw fini */
 	amdgpu_ras_pre_fini(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +201 -0

204 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h +5 -0
index 648237f27d1c..7ac89d78a5bf 100644
@@ -68,6 +68,7 @@ struct amdgpu_xcp_res_details {
 	enum amdgpu_xcp_res_id id;
 	u8 num_inst;
 	u8 num_shared;
+	struct kobject kobj;
 };
 
 struct amdgpu_xcp_cfg {
@@ -75,6 +76,7 @@ struct amdgpu_xcp_cfg {
 	struct amdgpu_xcp_res_details xcp_res[AMDGPU_XCP_RES_MAX];
 	u8 num_res;
 	struct amdgpu_xcp_mgr *xcp_mgr;
+	struct kobject kobj;
 };
 
 struct amdgpu_xcp_ip_funcs {
@@ -172,6 +174,9 @@ int amdgpu_xcp_open_device(struct amdgpu_device *adev,
 void amdgpu_xcp_release_sched(struct amdgpu_device *adev,
 			      struct amdgpu_ctx_entity *entity);
 
+void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev);
+void amdgpu_xcp_cfg_sysfs_fini(struct amdgpu_device *adev);
+
 #define amdgpu_xcp_select_scheds(adev, e, c, d, x, y) \
 	((adev)->xcp_mgr && (adev)->xcp_mgr->funcs && \
 	(adev)->xcp_mgr->funcs->select_scheds ? \
Signature · 1 line
2.46.0
author
#3 lore raw

PATCH v2 4/4 drm/amdgpu: Add supported partition mode node

In reply to Asad Kamal

Add sysfs node to show supoorted partition modes across all NPS modes

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 48 +++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +45 -3
index fc4ab1d8c7c9..10daa6a15e5e 100644
@@ -463,6 +463,14 @@ static struct attribute *xcp_cfg_res_sysfs_attrs[] = {
 	&XCP_CFG_SYSFS_RES_ATTR_PTR(num_shared), NULL
 };
 
+static const char *xcp_desc[] = {
+	[AMDGPU_SPX_PARTITION_MODE] = "SPX",
+	[AMDGPU_DPX_PARTITION_MODE] = "DPX",
+	[AMDGPU_TPX_PARTITION_MODE] = "TPX",
+	[AMDGPU_QPX_PARTITION_MODE] = "QPX",
+	[AMDGPU_CPX_PARTITION_MODE] = "CPX",
+};
+
 ATTRIBUTE_GROUPS(xcp_cfg_res_sysfs);
 
 #define to_xcp_attr(x) \
@@ -511,6 +519,27 @@ static int amdgpu_xcp_get_res_info(struct amdgpu_xcp_mgr *xcp_mgr,
 }
 
 #define to_xcp_cfg(x) container_of(x, struct amdgpu_xcp_cfg, kobj)
+static ssize_t supported_xcp_configs_show(struct kobject *kobj,
+					  struct kobj_attribute *attr, char *buf)
+{
+	struct amdgpu_xcp_cfg *xcp_cfg = to_xcp_cfg(kobj);
+	struct amdgpu_xcp_mgr *xcp_mgr = xcp_cfg->xcp_mgr;
+	int size = 0, mode;
+	char *sep = "";
+
+	if (!xcp_mgr || !xcp_mgr->supp_xcp_modes)
+		return sysfs_emit(buf, "Not supported\n");
+
+	for_each_inst(mode, xcp_mgr->supp_xcp_modes) {
+		size += sysfs_emit_at(buf, size, "%s%s", sep, xcp_desc[mode]);
+		sep = ", ";
+	}
+
+	size += sysfs_emit_at(buf, size, "\n");
+
+	return size;
+}
+
 static ssize_t xcp_config_show(struct kobject *kobj,
 			       struct kobj_attribute *attr, char *buf)
 {
@@ -564,6 +593,19 @@ static const struct kobj_type xcp_cfg_sysfs_ktype = {
 	.sysfs_ops = &kobj_sysfs_ops,
 };
 
+static struct kobj_attribute supp_part_sysfs_mode =
+	__ATTR_RO(supported_xcp_configs);
+
+static const struct kobj_type supp_part_sysfs_ktype = {
+	.sysfs_ops = &kobj_sysfs_ops,
+};
+
+static const struct attribute *xcp_attrs[] = {
+	&supp_part_sysfs_mode.attr,
+	&xcp_cfg_sysfs_mode.attr,
+	NULL,
+};
+
 void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
 {
 	struct amdgpu_xcp_res_details *xcp_res;
@@ -583,7 +625,7 @@ void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
 	if (r)
 		goto err1;
 
-	r = sysfs_create_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
+	r = sysfs_create_files(&xcp_cfg->kobj, xcp_attrs);
 	if (r)
 		goto err1;
 
@@ -611,7 +653,7 @@ void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
 		kobject_put(&xcp_res->kobj);
 	}
 
-	sysfs_remove_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
+	sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs);
 err1:
 	kobject_put(&xcp_cfg->kobj);
 }
@@ -631,6 +673,6 @@ void amdgpu_xcp_cfg_sysfs_fini(struct amdgpu_device *adev)
 		kobject_put(&xcp_res->kobj);
 	}
 
-	sysfs_remove_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
+	sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs);
 	kobject_put(&xcp_cfg->kobj);
 }
Signature · 1 line
2.46.0
Reviewed-by on v2 4/4
#4 lore raw

RE: [PATCH v2 4/4] drm/amdgpu: Add supported partition mode node

[AMD Official Use Only - AMD Internal Distribution Only]

Series is

Regards,
Hawking
-----Original Message-----
From: Kamal, Asad <[email protected]>
Sent: Tuesday, September 24, 2024 22:16
To: [email protected]; Lazar, Lijo <[email protected]>
Cc: Ma, Le <[email protected]>; Zhang, Hawking <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Poag, Charis <[email protected]>; Cheung, Donald <[email protected]>; Khatir, Sepehr <[email protected]>; Oliveira, Daniel <[email protected]>
Subject: [PATCH v2 4/4] drm/amdgpu: Add supported partition mode node

Add sysfs node to show supoorted partition modes across all NPS modes

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 48 +++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +28 -0
index fc4ab1d8c7c9..10daa6a15e5e 100644
@@ -463,6 +463,14 @@ static struct attribute *xcp_cfg_res_sysfs_attrs[] = {
        &XCP_CFG_SYSFS_RES_ATTR_PTR(num_shared), NULL  };
 
+static const char *xcp_desc[] = {
+       [AMDGPU_SPX_PARTITION_MODE] = "SPX",
+       [AMDGPU_DPX_PARTITION_MODE] = "DPX",
+       [AMDGPU_TPX_PARTITION_MODE] = "TPX",
+       [AMDGPU_QPX_PARTITION_MODE] = "QPX",
+       [AMDGPU_CPX_PARTITION_MODE] = "CPX",
+};
+
 ATTRIBUTE_GROUPS(xcp_cfg_res_sysfs);
 
 #define to_xcp_attr(x) \
@@ -511,6 +519,27 @@ static int amdgpu_xcp_get_res_info(struct amdgpu_xcp_mgr *xcp_mgr,  }
 
 #define to_xcp_cfg(x) container_of(x, struct amdgpu_xcp_cfg, kobj)
+static ssize_t supported_xcp_configs_show(struct kobject *kobj,
+                                         struct kobj_attribute *attr, char *buf) {
+       struct amdgpu_xcp_cfg *xcp_cfg = to_xcp_cfg(kobj);
+       struct amdgpu_xcp_mgr *xcp_mgr = xcp_cfg->xcp_mgr;
+       int size = 0, mode;
+       char *sep = "";
+
+       if (!xcp_mgr || !xcp_mgr->supp_xcp_modes)
+               return sysfs_emit(buf, "Not supported\n");
+
+       for_each_inst(mode, xcp_mgr->supp_xcp_modes) {
+               size += sysfs_emit_at(buf, size, "%s%s", sep, xcp_desc[mode]);
+               sep = ", ";
+       }
+
+       size += sysfs_emit_at(buf, size, "\n");
+
+       return size;
+}
+
 static ssize_t xcp_config_show(struct kobject *kobj,
                               struct kobj_attribute *attr, char *buf)  { @@ -564,6 +593,19 @@ static const struct kobj_type xcp_cfg_sysfs_ktype = {
        .sysfs_ops = &kobj_sysfs_ops,
 };

+static struct kobj_attribute supp_part_sysfs_mode =
+ __ATTR_RO(supported_xcp_configs);
+
+static const struct kobj_type supp_part_sysfs_ktype = {
+ .sysfs_ops = &kobj_sysfs_ops,
+};
+
+static const struct attribute *xcp_attrs[] = {

+       &supp_part_sysfs_mode.attr,
+       &xcp_cfg_sysfs_mode.attr,
+       NULL,
+};
+
 void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)  {
        struct amdgpu_xcp_res_details *xcp_res; @@ -583,7 +625,7 @@ void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
        if (r)
                goto err1;

- r = sysfs_create_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);

+       r = sysfs_create_files(&xcp_cfg->kobj, xcp_attrs);
        if (r)
                goto err1;

@@ -611,7 +653,7 @@ void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)

                kobject_put(&xcp_res->kobj);
        }

- sysfs_remove_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
+ sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs);
err1:

        kobject_put(&xcp_cfg->kobj);
 }
@@ -631,6 +673,6 @@ void amdgpu_xcp_cfg_sysfs_fini(struct amdgpu_device *adev)
                kobject_put(&xcp_res->kobj);
        }

- sysfs_remove_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);

+       sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs);
        kobject_put(&xcp_cfg->kobj);

}
--
2.46.0

Reviewed-by on v2 4/4
#5 lore raw

Re: [PATCH v2 4/4] drm/amdgpu: Add supported partition mode node

In reply to Asad Kamal
Quoted 55 lines · Asad Kamal

Add sysfs node to show supoorted partition modes across all NPS modes

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 48 +++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +29 -0
index fc4ab1d8c7c9..10daa6a15e5e 100644
@@ -463,6 +463,14 @@ static struct attribute *xcp_cfg_res_sysfs_attrs[] = {
 	&XCP_CFG_SYSFS_RES_ATTR_PTR(num_shared), NULL
 };
 
+static const char *xcp_desc[] = {
+	[AMDGPU_SPX_PARTITION_MODE] = "SPX",
+	[AMDGPU_DPX_PARTITION_MODE] = "DPX",
+	[AMDGPU_TPX_PARTITION_MODE] = "TPX",
+	[AMDGPU_QPX_PARTITION_MODE] = "QPX",
+	[AMDGPU_CPX_PARTITION_MODE] = "CPX",
+};
+
 ATTRIBUTE_GROUPS(xcp_cfg_res_sysfs);
 
 #define to_xcp_attr(x) \
@@ -511,6 +519,27 @@ static int amdgpu_xcp_get_res_info(struct amdgpu_xcp_mgr *xcp_mgr,
 }
 
 #define to_xcp_cfg(x) container_of(x, struct amdgpu_xcp_cfg, kobj)
+static ssize_t supported_xcp_configs_show(struct kobject *kobj,
+					  struct kobj_attribute *attr, char *buf)
+{
+	struct amdgpu_xcp_cfg *xcp_cfg = to_xcp_cfg(kobj);
+	struct amdgpu_xcp_mgr *xcp_mgr = xcp_cfg->xcp_mgr;
+	int size = 0, mode;
+	char *sep = "";
+
+	if (!xcp_mgr || !xcp_mgr->supp_xcp_modes)
+		return sysfs_emit(buf, "Not supported\n");
+
+	for_each_inst(mode, xcp_mgr->supp_xcp_modes) {
+		size += sysfs_emit_at(buf, size, "%s%s", sep, xcp_desc[mode]);
+		sep = ", ";
+	}
+
+	size += sysfs_emit_at(buf, size, "\n");
+
+	return size;
+}
+
 static ssize_t xcp_config_show(struct kobject *kobj,
 			       struct kobj_attribute *attr, char *buf)
 {

drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c static const struct kobj_type xcp_cfg_sysfs_ktype = { · line 602

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +7 -0
@@ -564,6 +593,19 @@ static const struct kobj_type xcp_cfg_sysfs_ktype = {
 	.sysfs_ops = &kobj_sysfs_ops,
 };
 
+static struct kobj_attribute supp_part_sysfs_mode =
+	__ATTR_RO(supported_xcp_configs);
+
+static const struct kobj_type supp_part_sysfs_ktype = {
+	.sysfs_ops = &kobj_sysfs_ops,
+};
+

I think this is not required. Other than that, this looks good.

Thanks,
Lijo

Quoted 35 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +9 -3
+static const struct attribute *xcp_attrs[] = {
+	&supp_part_sysfs_mode.attr,
+	&xcp_cfg_sysfs_mode.attr,
+	NULL,
+};
+
 void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
 {
 	struct amdgpu_xcp_res_details *xcp_res;
@@ -583,7 +625,7 @@ void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
 	if (r)
 		goto err1;
 
-	r = sysfs_create_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
+	r = sysfs_create_files(&xcp_cfg->kobj, xcp_attrs);
 	if (r)
 		goto err1;
 
@@ -611,7 +653,7 @@ void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
 		kobject_put(&xcp_res->kobj);
 	}
 
-	sysfs_remove_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
+	sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs);
 err1:
 	kobject_put(&xcp_cfg->kobj);
 }
@@ -631,6 +673,6 @@ void amdgpu_xcp_cfg_sysfs_fini(struct amdgpu_device *adev)
 		kobject_put(&xcp_res->kobj);
 	}
 
-	sysfs_remove_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
+	sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs);
 	kobject_put(&xcp_cfg->kobj);
 }