Skip to contentSkip to conversation

drm/amdkfd: fix warning when CONFIG_HSA_AMD_P2P is not set

PATCH In review Alex Deucher 3 participants 3 messages Jun 10, 2022 – Jun 13, 2022

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH v2 1/1 drm/amdkfd: fix warning when CONFIG_HSA_AMD_P2P is not set

drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1542:11:
warning: variable 'i' set but not used [-Wunused-but-set-variable]

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +5 -2
index 3e240b22ec91..411447357196 100644
@@ -1539,7 +1539,10 @@ static int kfd_dev_create_p2p_links(void)
 {
 	struct kfd_topology_device *dev;
 	struct kfd_topology_device *new_dev;
-	uint32_t i, k;
+#if defined(CONFIG_HSA_AMD_P2P)
+	uint32_t i;
+#endif
+	uint32_t k;
 	int ret = 0;
 
 	k = 0;
@@ -1553,7 +1556,6 @@ static int kfd_dev_create_p2p_links(void)
 		return 0;
 
 	k--;
-	i = 0;
 
 	/* create in-direct links */
 	ret = kfd_create_indirect_link_prop(new_dev, k);
@@ -1562,6 +1564,7 @@ static int kfd_dev_create_p2p_links(void)
 
 	/* create p2p links */
 #if defined(CONFIG_HSA_AMD_P2P)
+	i = 0;
 	list_for_each_entry(dev, &topology_device_list, list) {
 		if (dev == new_dev)
 			break;
Signature · 1 line
2.35.3
maintainer Reviewed-by on v2 1/1
#1 lore raw

Am 2022-06-10 um 11:46 schrieb Alex Deucher:

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1542:11:
warning: variable 'i' set but not used [-Wunused-but-set-variable]

Thank you for taking care of this.

Quoted 36 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +5 -2
index 3e240b22ec91..411447357196 100644
@@ -1539,7 +1539,10 @@ static int kfd_dev_create_p2p_links(void)
  {
  	struct kfd_topology_device *dev;
  	struct kfd_topology_device *new_dev;
-	uint32_t i, k;
+#if defined(CONFIG_HSA_AMD_P2P)
+	uint32_t i;
+#endif
+	uint32_t k;
  	int ret = 0;
 
  	k = 0;
@@ -1553,7 +1556,6 @@ static int kfd_dev_create_p2p_links(void)
  		return 0;
 
  	k--;
-	i = 0;
 
  	/* create in-direct links */
  	ret = kfd_create_indirect_link_prop(new_dev, k);
@@ -1562,6 +1564,7 @@ static int kfd_dev_create_p2p_links(void)
 
  	/* create p2p links */
  #if defined(CONFIG_HSA_AMD_P2P)
+	i = 0;
  	list_for_each_entry(dev, &topology_device_list, list) {
  		if (dev == new_dev)
  			break;
#2 lore raw
In reply to Alex Deucher

Am 10.06.22 um 17:46 schrieb Alex Deucher:

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1542:11:
warning: variable 'i' set but not used [-Wunused-but-set-variable]

Ideally we should put the code for this into a separate function and then guard the decleration of the function with #ifdefs.

But not code that I'm deeply involved with so Acked-by: Christian König <[email protected]> anyway.

Christian.

Quoted 36 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +5 -2
index 3e240b22ec91..411447357196 100644
@@ -1539,7 +1539,10 @@ static int kfd_dev_create_p2p_links(void)
  {
  	struct kfd_topology_device *dev;
  	struct kfd_topology_device *new_dev;
-	uint32_t i, k;
+#if defined(CONFIG_HSA_AMD_P2P)
+	uint32_t i;
+#endif
+	uint32_t k;
  	int ret = 0;
 
  	k = 0;
@@ -1553,7 +1556,6 @@ static int kfd_dev_create_p2p_links(void)
  		return 0;
 
  	k--;
-	i = 0;
 
  	/* create in-direct links */
  	ret = kfd_create_indirect_link_prop(new_dev, k);
@@ -1562,6 +1564,7 @@ static int kfd_dev_create_p2p_links(void)
 
  	/* create p2p links */
  #if defined(CONFIG_HSA_AMD_P2P)
+	i = 0;
  	list_for_each_entry(dev, &topology_device_list, list) {
  		if (dev == new_dev)
  			break;