On Wed, Apr 09, 2025 at 07:19:25PM +0530, Lazar, Lijo wrote: > > > On 4/9/2025 7:09 PM, Ce Sun wrote: > > Checking hive is more readable. > > > > The following 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") > > Reported-by: Dan Carpenter <dan.carpen...@linaro.org> > > Signed-off-by: Ce Sun <cesun...@amd.com> > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > index 60269fba5745..6fb234832ff3 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > @@ -6784,8 +6784,8 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev > > *pdev) > > struct drm_device *dev = pci_get_drvdata(pdev); > > struct amdgpu_device *adev = drm_to_adev(dev); > > struct amdgpu_reset_context reset_context; > > - struct amdgpu_device *tmp_adev = NULL; > > - struct amdgpu_hive_info *hive = NULL; > > + struct amdgpu_device *tmp_adev; > > + struct amdgpu_hive_info *hive; > > struct list_head device_list; > > int r = 0, i; > > u32 memsize; > > @@ -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) { > > This doesn't look correct. I think the original logic is to have a > single device list or multi-device list when there is a hive. Now this > skips the step for single device case. >
I don't know what the original intentions were, but what I know is that this code will behave exactly the same as the original code. regards, dan carpenter