Skip to contentSkip to conversation

drm/amdkfd: Fix getting unique_id in topology

PATCH In review Kent Russell 2 participants 8 messages Oct 28, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdkfd: Fix getting unique_id in topology

Since the unique_id is now obtained in amdgpu in smu_late_init, topology's device addition is now happening before the unique_id is saved, thus topology misses it. To work around this, we use the amdgpu_amdkfd_get_unique_id to get the unique_id at read time.

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
index 3f2aa055c32c..a3fc23873819 100644
@@ -1340,7 +1340,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
 		dev->gpu->dqm->sched_policy != KFD_SCHED_POLICY_NO_HWS) ?
 		amdgpu_amdkfd_get_num_gws(dev->gpu->kgd) : 0;
 	dev->node_props.num_cp_queues = get_cp_queues_num(dev->gpu->dqm);
-	dev->node_props.unique_id = gpu->unique_id;
+	dev->node_props.unique_id = amdgpu_amdkfd_get_unique_id(dev->gpu->kgd);
 
 	kfd_fill_mem_clk_max_info(dev);
 	kfd_fill_iolink_non_crat_info(dev);
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

PATCH 2/2 drm/amdkfd: Change unique_id to print hex format

amdgpu's unique_id prints in hex format, so change topology's printout to hex by adding a new sysfs_print macro specifically for hex output, and use it for unique_id

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +3 -1
index a3fc23873819..d13c68c52bbc 100644
@@ -217,6 +217,8 @@ struct kfd_topology_device *kfd_create_topology_device(
 		sysfs_show_gen_prop(buffer, offs, "%s %u\n", name, value)
 #define sysfs_show_64bit_prop(buffer, offs, name, value) \
 		sysfs_show_gen_prop(buffer, offs, "%s %llu\n", name, value)
+#define sysfs_show_64bit_prop_hex(buffer, offs, name, value) \
+		sysfs_show_gen_prop(buffer, offs, "%s %llx\n", name, value)
 #define sysfs_show_32bit_val(buffer, offs, value) \
 		sysfs_show_gen_prop(buffer, offs, "%u\n", value)
 #define sysfs_show_str_val(buffer, offs, value) \
@@ -497,7 +499,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
 			      dev->node_props.num_sdma_queues_per_engine);
 	sysfs_show_32bit_prop(buffer, offs, "num_cp_queues",
 			      dev->node_props.num_cp_queues);
-	sysfs_show_64bit_prop(buffer, offs, "unique_id",
+	sysfs_show_64bit_prop_hex(buffer, offs, "unique_id",
 			      dev->node_props.unique_id);
 
 	if (dev->gpu) {
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#2 lore raw

Re: [PATCH 2/2] drm/amdkfd: Change unique_id to print hex format

This is an ABI-breaking change. Is any user mode code using this already?

Regards,
  Felix

Am 2020-10-28 um 11:22 a.m. schrieb Kent Russell:

Quoted 23 lines

amdgpu's unique_id prints in hex format, so change topology's printout to hex by adding a new sysfs_print macro specifically for hex output, and use it for unique_id

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +2 -0
index a3fc23873819..d13c68c52bbc 100644
@@ -217,6 +217,8 @@ struct kfd_topology_device *kfd_create_topology_device(
 		sysfs_show_gen_prop(buffer, offs, "%s %u\n", name, value)
 #define sysfs_show_64bit_prop(buffer, offs, name, value) \
 		sysfs_show_gen_prop(buffer, offs, "%s %llu\n", name, value)
+#define sysfs_show_64bit_prop_hex(buffer, offs, name, value) \
+		sysfs_show_gen_prop(buffer, offs, "%s %llx\n", name, value)
 #define sysfs_show_32bit_val(buffer, offs, value) \
 		sysfs_show_gen_prop(buffer, offs, "%u\n", value)
 #define sysfs_show_str_val(buffer, offs, value) \

drivers/gpu/drm/amd/amdkfd/kfd_topology.c static ssize_t node_show(struct kobject *kobj, struct attribute *attr, · line 505

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
@@ -497,7 +499,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
 			      dev->node_props.num_sdma_queues_per_engine);
 	sysfs_show_32bit_prop(buffer, offs, "num_cp_queues",
 			      dev->node_props.num_cp_queues);
-	sysfs_show_64bit_prop(buffer, offs, "unique_id",
+	sysfs_show_64bit_prop_hex(buffer, offs, "unique_id",
 			      dev->node_props.unique_id);
 
 	if (dev->gpu) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw

RE: [PATCH 2/2] drm/amdkfd: Change unique_id to print hex format

[AMD Public Use]

rocminfo uses it, but that's all that I am aware of. I can drop this though and stick with patch1, I just didn't know if we'd end up getting complaints of:
"Well, rocm-smi (amdgpu) says that the unique_id is F, while rocminfo (amdkfd) says that the unique_id is 16" . Probably too late to try to change it now though, as you pointed out.

Kent

Quoted 37 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Wednesday, October 28, 2020 11:55 AM
To: [email protected]; Russell, Kent <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdkfd: Change unique_id to print hex format

This is an ABI-breaking change. Is any user mode code using this already?

Regards,
  Felix

Am 2020-10-28 um 11:22 a.m. schrieb Kent Russell:

Review

Quoted 10 lines

amdgpu's unique_id prints in hex format, so change topology's printout to hex by adding a new sysfs_print macro specifically for hex output, and use it for unique_id

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c

drivers/gpu/drm/amd/amdkfd/kfd_topology.c static ssize_t node_show(struct kobject *kobj, struct attribute

Quoted 13 lines

index a3fc23873819..d13c68c52bbc 100644

drivers/gpu/drm/amd/amdkfd/kfd_topology.c +2 -0
@@ -217,6 +217,8 @@ struct kfd_topology_device *kfd_create_topology_device(
 		sysfs_show_gen_prop(buffer, offs, "%s %u\n", name, value)
 #define sysfs_show_64bit_prop(buffer, offs, name, value) \
 		sysfs_show_gen_prop(buffer, offs, "%s %llu\n", name, value)
+#define sysfs_show_64bit_prop_hex(buffer, offs, name, value) \
+		sysfs_show_gen_prop(buffer, offs, "%s %llx\n", name, value)
 #define sysfs_show_32bit_val(buffer, offs, value) \
 		sysfs_show_gen_prop(buffer, offs, "%u\n", value)
 #define sysfs_show_str_val(buffer, offs, value) \
@@ -497,7 +499,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute

*attr,

Quoted 8 lines

drivers/gpu/drm/amd/amdkfd/kfd_topology.c static ssize_t node_show(struct kobject *kobj, struct attribute *attr, · line 505

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
 			      dev->node_props.num_sdma_queues_per_engine);
 	sysfs_show_32bit_prop(buffer, offs, "num_cp_queues",
 			      dev->node_props.num_cp_queues);
-	sysfs_show_64bit_prop(buffer, offs, "unique_id",
+	sysfs_show_64bit_prop_hex(buffer, offs, "unique_id",
 			      dev->node_props.unique_id);
 
 	if (dev->gpu) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#4 lore raw

Re: [PATCH 2/2] drm/amdkfd: Change unique_id to print hex format

So rocm-smi reads the decimal and converts it to hex? Then changing KFD will break rocm-smi. If you want to fix rocminfo, you'll need to fix it in the rocminfo code to do the conversion to hex.

Regards,
  Felix

Am 2020-10-28 um 12:02 p.m. schrieb Russell, Kent:

Quoted 44 lines

[AMD Public Use]

rocminfo uses it, but that's all that I am aware of. I can drop this though and stick with patch1, I just didn't know if we'd end up getting complaints of:
"Well, rocm-smi (amdgpu) says that the unique_id is F, while rocminfo (amdkfd) says that the unique_id is 16" . Probably too late to try to change it now though, as you pointed out.

Kent

Quoted 37 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Wednesday, October 28, 2020 11:55 AM
To: [email protected]; Russell, Kent <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdkfd: Change unique_id to print hex format

This is an ABI-breaking change. Is any user mode code using this already?

Regards,
  Felix

Am 2020-10-28 um 11:22 a.m. schrieb Kent Russell:

Review

Quoted 10 lines

amdgpu's unique_id prints in hex format, so change topology's printout to hex by adding a new sysfs_print macro specifically for hex output, and use it for unique_id

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c

drivers/gpu/drm/amd/amdkfd/kfd_topology.c static ssize_t node_show(struct kobject *kobj, struct attribute

Quoted 13 lines

index a3fc23873819..d13c68c52bbc 100644

drivers/gpu/drm/amd/amdkfd/kfd_topology.c +2 -0
@@ -217,6 +217,8 @@ struct kfd_topology_device *kfd_create_topology_device(
 		sysfs_show_gen_prop(buffer, offs, "%s %u\n", name, value)
 #define sysfs_show_64bit_prop(buffer, offs, name, value) \
 		sysfs_show_gen_prop(buffer, offs, "%s %llu\n", name, value)
+#define sysfs_show_64bit_prop_hex(buffer, offs, name, value) \
+		sysfs_show_gen_prop(buffer, offs, "%s %llx\n", name, value)
 #define sysfs_show_32bit_val(buffer, offs, value) \
 		sysfs_show_gen_prop(buffer, offs, "%u\n", value)
 #define sysfs_show_str_val(buffer, offs, value) \
@@ -497,7 +499,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute

*attr,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdkfd/kfd_topology.c static ssize_t node_show(struct kobject *kobj, struct attribute *attr, · line 505

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
 			      dev->node_props.num_sdma_queues_per_engine);
 	sysfs_show_32bit_prop(buffer, offs, "num_cp_queues",
 			      dev->node_props.num_cp_queues);
-	sysfs_show_64bit_prop(buffer, offs, "unique_id",
+	sysfs_show_64bit_prop_hex(buffer, offs, "unique_id",
 			      dev->node_props.unique_id);
 
 	if (dev->gpu) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw

RE: [PATCH 2/2] drm/amdkfd: Change unique_id to print hex format

[AMD Public Use]

amdgpu actually prints it as hex:
return snprintf(buf, PAGE_SIZE, "%016llx\n", adev->unique_id);

But either way, we can address it in rocminfo if anyone complains. Thanks for the review!

Kent

Quoted 60 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Wednesday, October 28, 2020 12:11 PM
To: Russell, Kent <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] drm/amdkfd: Change unique_id to print hex format

So rocm-smi reads the decimal and converts it to hex? Then changing KFD will break rocm-smi. If you want to fix rocminfo, you'll need to fix it in the rocminfo code to do the conversion to hex.

Regards,
  Felix

Am 2020-10-28 um 12:02 p.m. schrieb Russell, Kent:

Quoted 3 lines

[AMD Public Use]

rocminfo uses it, but that's all that I am aware of. I can drop this though and stick with

patch1, I just didn't know if we'd end up getting complaints of:

Quoted 1 line

"Well, rocm-smi (amdgpu) says that the unique_id is F, while rocminfo (amdkfd) says that

the unique_id is 16" . Probably too late to try to change it now though, as you pointed out.

Quoted 40 lines

Kent

Quoted 37 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Wednesday, October 28, 2020 11:55 AM
To: [email protected]; Russell, Kent <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdkfd: Change unique_id to print hex format

This is an ABI-breaking change. Is any user mode code using this already?

Regards,
  Felix

Am 2020-10-28 um 11:22 a.m. schrieb Kent Russell:

Review

Quoted 10 lines

amdgpu's unique_id prints in hex format, so change topology's printout to hex by adding a new sysfs_print macro specifically for hex output, and use it for unique_id

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c

drivers/gpu/drm/amd/amdkfd/kfd_topology.c static ssize_t node_show(struct kobject *kobj, struct attribute

Quoted 13 lines

index a3fc23873819..d13c68c52bbc 100644

drivers/gpu/drm/amd/amdkfd/kfd_topology.c +2 -0
@@ -217,6 +217,8 @@ struct kfd_topology_device *kfd_create_topology_device(
 		sysfs_show_gen_prop(buffer, offs, "%s %u\n", name, value)
 #define sysfs_show_64bit_prop(buffer, offs, name, value) \
 		sysfs_show_gen_prop(buffer, offs, "%s %llu\n", name, value)
+#define sysfs_show_64bit_prop_hex(buffer, offs, name, value) \
+		sysfs_show_gen_prop(buffer, offs, "%s %llx\n", name, value)
 #define sysfs_show_32bit_val(buffer, offs, value) \
 		sysfs_show_gen_prop(buffer, offs, "%u\n", value)
 #define sysfs_show_str_val(buffer, offs, value) \
@@ -497,7 +499,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute

*attr,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdkfd/kfd_topology.c static ssize_t node_show(struct kobject *kobj, struct attribute *attr, · line 505

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
 			      dev->node_props.num_sdma_queues_per_engine);
 	sysfs_show_32bit_prop(buffer, offs, "num_cp_queues",
 			      dev->node_props.num_cp_queues);
-	sysfs_show_64bit_prop(buffer, offs, "unique_id",
+	sysfs_show_64bit_prop_hex(buffer, offs, "unique_id",
 			      dev->node_props.unique_id);
 
 	if (dev->gpu) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#6 lore raw
In reply to Kent Russell

Please also remove the broken code that initializes gpu->unique_id and remove the unique_id field from the structure.

Regards,
  Felix

Am 2020-10-28 um 11:22 a.m. schrieb Kent Russell:

Quoted 15 lines

Since the unique_id is now obtained in amdgpu in smu_late_init, topology's device addition is now happening before the unique_id is saved, thus topology misses it. To work around this, we use the amdgpu_amdkfd_get_unique_id to get the unique_id at read time.

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +0 -0
index 3f2aa055c32c..a3fc23873819 100644

drivers/gpu/drm/amd/amdkfd/kfd_topology.c int kfd_topology_add_device(struct kfd_dev *gpu) · line 1346

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
@@ -1340,7 +1340,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
 		dev->gpu->dqm->sched_policy != KFD_SCHED_POLICY_NO_HWS) ?
 		amdgpu_amdkfd_get_num_gws(dev->gpu->kgd) : 0;
 	dev->node_props.num_cp_queues = get_cp_queues_num(dev->gpu->dqm);
-	dev->node_props.unique_id = gpu->unique_id;
+	dev->node_props.unique_id = amdgpu_amdkfd_get_unique_id(dev->gpu->kgd);
 
 	kfd_fill_mem_clk_max_info(dev);
 	kfd_fill_iolink_non_crat_info(dev);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw

[AMD Public Use]

Right, will do!

Kent

Quoted 35 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Wednesday, October 28, 2020 12:16 PM
To: Russell, Kent <[email protected]>; [email protected]
Subject: Re: [PATCH 1/2] drm/amdkfd: Fix getting unique_id in topology

Please also remove the broken code that initializes gpu->unique_id and remove the unique_id field from the structure.

Regards,
  Felix

Am 2020-10-28 um 11:22 a.m. schrieb Kent Russell:

Review

Quoted 11 lines

Since the unique_id is now obtained in amdgpu in smu_late_init, topology's device addition is now happening before the unique_id is saved, thus topology misses it. To work around this, we use the amdgpu_amdkfd_get_unique_id to get the unique_id at read time.

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c

Quoted 10 lines

index 3f2aa055c32c..a3fc23873819 100644

drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
@@ -1340,7 +1340,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
 		dev->gpu->dqm->sched_policy != KFD_SCHED_POLICY_NO_HWS) ?
 		amdgpu_amdkfd_get_num_gws(dev->gpu->kgd) : 0;
 	dev->node_props.num_cp_queues = get_cp_queues_num(dev->gpu->dqm);
-	dev->node_props.unique_id = gpu->unique_id;
+	dev->node_props.unique_id = amdgpu_amdkfd_get_unique_id(dev->gpu->kgd);
 
Quoted 2 lines

drivers/gpu/drm/amd/amdkfd/kfd_topology.c int kfd_topology_add_device(struct kfd_dev *gpu) · line 1346

Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +0 -0
 	kfd_fill_mem_clk_max_info(dev);
 	kfd_fill_iolink_non_crat_info(dev);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx