[PATCH] drm/amdkfd: Add missing #if defined(CONFIG_HSA_AMD_P2P)

sunliming sunliming at kylinos.cn
Sun Jun 12 06:40:50 UTC 2022


The variable 'i' in function kfd_dev_create_p2p_links is only used in
codes that gaurded by '#if defined(CONFIG_HSA_AMD_P2P)' check. So adding
CONFIG_HSA_AMD_P2P #ifdef check around variable 'i' too.

Fixes the following w1 warning:

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

Reported-by: kernel test robot <lkp at intel.com>
Signed-off-by: sunliming <sunliming at kylinos.cn>
---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 304322ac39e6..4bfce71f7fa9 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -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;
+	uint32_t k;
+#if defined(CONFIG_HSA_AMD_P2P)
+	uint32_t i = 0;
+#endif
 	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);
-- 
2.25.1



More information about the amd-gfx mailing list