Skip to contentSkip to conversation

drm/amdgpu: fix a smatch static checker warning in amdgpu_pci_slot_reset

PATCH In review Ce Sun 5 participants 5 messages Apr 9, 2025 – Apr 10, 2025 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ce Sun

author
#1 lore raw

PATCH 1/1 drm/amdgpu: fix a smatch static checker warning in amdgpu_pci_slot_reset

Fixes smatch warning:

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:6820 amdgpu_pci_slot_reset()
warn: iterator used outside loop: 'tmp_adev'

Fixes 8ba904f54148 ("drm/amdgpu: Multi-GPU DPC recovery support")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index 60269fba5745..eb0589a09a27 100644
@@ -6846,7 +6846,7 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)
 		dev_info(adev->dev, "PCIe error recovery succeeded\n");
 	} else {
 		dev_err(adev->dev, "PCIe error recovery failed, err:%d\n", r);
-		if (tmp_adev) {
+		if (hive) {
 			list_for_each_entry(tmp_adev, &device_list, reset_list)
 				amdgpu_device_unset_mp1_state(tmp_adev);
 			amdgpu_device_unlock_reset_domain(adev->reset_domain);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 37 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Ce Sun
Sent: Wednesday, April 9, 2025 8:10 PM
To: [email protected]
Cc: [email protected]; Sun, Ce(Overlord) <[email protected]>
Subject: [PATCH v1 1/1] drm/amdgpu: fix a smatch static checker warning in amdgpu_pci_slot_reset

Fixes smatch warning:

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:6820 amdgpu_pci_slot_reset()
warn: iterator used outside loop: 'tmp_adev'

Fixes 8ba904f54148 ("drm/amdgpu: Multi-GPU DPC recovery support")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index 60269fba5745..eb0589a09a27 100644
@@ -6846,7 +6846,7 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev
 *pdev)
              dev_info(adev->dev, "PCIe error recovery succeeded\n");
      } else {
              dev_err(adev->dev, "PCIe error recovery failed, err:%d\n", r);
-             if (tmp_adev) {
+             if (hive) {
                      list_for_each_entry(tmp_adev, &device_list, reset_list)
                              amdgpu_device_unset_mp1_state(tmp_adev);
                      amdgpu_device_unlock_reset_domain(adev->reset_domain);

--
2.34.1

#3 lore raw
In reply to Ce Sun
Quoted 17 lines · Ce Sun

Fixes smatch warning:

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:6820 amdgpu_pci_slot_reset()
warn: iterator used outside loop: 'tmp_adev'

Fixes 8ba904f54148 ("drm/amdgpu: Multi-GPU DPC recovery support")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 60269fba5745..eb0589a09a27 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev) · line 6849

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -6846,7 +6846,7 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)
 		dev_info(adev->dev, "PCIe error recovery succeeded\n");
 	} else {
 		dev_err(adev->dev, "PCIe error recovery failed, err:%d\n", r);
-		if (tmp_adev) {
+		if (hive) {

Hi Ce Sun,

Looks like your original patch broke single device handling path. That one will need a revisit.

Thanks,
Lijo

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
 			list_for_each_entry(tmp_adev, &device_list, reset_list)
 				amdgpu_device_unset_mp1_state(tmp_adev);
 			amdgpu_device_unlock_reset_domain(adev->reset_domain);
#4 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Lijo,
      There is indeed a single device issue, thank you very much

Thanks,
Sun,Ce

________________________________
From: Lazar, Lijo <[email protected]>
Sent: Thursday, April 10, 2025 4:11 PM
To: Sun, Ce(Overlord) <[email protected]>; [email protected] <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [PATCH v1 1/1] drm/amdgpu: fix a smatch static checker warning in amdgpu_pci_slot_reset

Quoted 17 lines · Ce Sun

Fixes smatch warning:

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:6820 amdgpu_pci_slot_reset()
warn: iterator used outside loop: 'tmp_adev'

Fixes 8ba904f54148 ("drm/amdgpu: Multi-GPU DPC recovery support")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 60269fba5745..eb0589a09a27 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev) · line 6849

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -6846,7 +6846,7 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)
               dev_info(adev->dev, "PCIe error recovery succeeded\n");
       } else {
               dev_err(adev->dev, "PCIe error recovery failed, err:%d\n", r);
-             if (tmp_adev) {
+             if (hive) {

Hi Ce Sun,

Looks like your original patch broke single device handling path. That one will need a revisit.

Thanks,
Lijo

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                       list_for_each_entry(tmp_adev, &device_list, reset_list)
                               amdgpu_device_unset_mp1_state(tmp_adev);
                       amdgpu_device_unlock_reset_domain(adev->reset_domain);
#5 lore raw
In reply to Ce Sun
Quoted 7 lines · Ce Sun

Fixes smatch warning:

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:6820 amdgpu_pci_slot_reset()
warn: iterator used outside loop: 'tmp_adev'

Fixes 8ba904f54148 ("drm/amdgpu: Multi-GPU DPC recovery support")

Thanks. This doesn't change how the code works so probably the Fixes tag isn't required. But it doesn't hurt anything either. Static checker warnings are a gray area.

regards,
dan carpenter