* [PATCH] drm/amdgpu: Do a basic health check before reset
@ 2024-03-13 9:41 Lijo Lazar
2024-03-13 9:48 ` Kamal, Asad
2024-03-13 19:49 ` Felix Kuehling
0 siblings, 2 replies; 4+ messages in thread
From: Lijo Lazar @ 2024-03-13 9:41 UTC (permalink / raw)
To: amd-gfx; +Cc: Hawking.Zhang, Alexander.Deucher, Asad.Kamal
Check if the device is present in the bus before trying to recover. It
could be that device itself is lost from the bus in some hang
situations.
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 1e9454e6e4cb..b37113b79483 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5536,6 +5536,23 @@ static inline void amdgpu_device_stop_pending_resets(struct amdgpu_device *adev)
}
+static int amdgpu_device_health_check(struct list_head *device_list_handle)
+{
+ struct amdgpu_device *tmp_adev;
+ int ret = 0;
+ u32 status;
+
+ list_for_each_entry(tmp_adev, device_list_handle, reset_list) {
+ pci_read_config_dword(tmp_adev->pdev, PCI_COMMAND, &status);
+ if (PCI_POSSIBLE_ERROR(status)) {
+ dev_err(tmp_adev->dev, "device lost from bus!");
+ ret = -ENODEV;
+ }
+ }
+
+ return ret;
+}
+
/**
* amdgpu_device_gpu_recover - reset the asic and recover scheduler
*
@@ -5607,6 +5624,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
device_list_handle = &device_list;
}
+ if (!amdgpu_sriov_vf(adev)) {
+ r = amdgpu_device_health_check(device_list_handle);
+ if (r)
+ goto end_reset;
+ }
+
/* We need to lock reset domain only once both for XGMI and single device */
tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device,
reset_list);
@@ -5772,6 +5795,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
reset_list);
amdgpu_device_unlock_reset_domain(tmp_adev->reset_domain);
+end_reset:
if (hive) {
mutex_unlock(&hive->hive_lock);
amdgpu_put_xgmi_hive(hive);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* RE: [PATCH] drm/amdgpu: Do a basic health check before reset
2024-03-13 9:41 [PATCH] drm/amdgpu: Do a basic health check before reset Lijo Lazar
@ 2024-03-13 9:48 ` Kamal, Asad
2024-03-13 19:49 ` Felix Kuehling
1 sibling, 0 replies; 4+ messages in thread
From: Kamal, Asad @ 2024-03-13 9:48 UTC (permalink / raw)
To: Lazar, Lijo, amd-gfx@lists.freedesktop.org
Cc: Zhang, Hawking, Deucher, Alexander
[AMD Official Use Only - General]
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Thanks & Regards
Asad
-----Original Message-----
From: Lazar, Lijo <Lijo.Lazar@amd.com>
Sent: Wednesday, March 13, 2024 3:12 PM
To: amd-gfx@lists.freedesktop.org
Cc: Zhang, Hawking <Hawking.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Kamal, Asad <Asad.Kamal@amd.com>
Subject: [PATCH] drm/amdgpu: Do a basic health check before reset
Check if the device is present in the bus before trying to recover. It could be that device itself is lost from the bus in some hang situations.
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 1e9454e6e4cb..b37113b79483 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5536,6 +5536,23 @@ static inline void amdgpu_device_stop_pending_resets(struct amdgpu_device *adev)
}
+static int amdgpu_device_health_check(struct list_head
+*device_list_handle) {
+ struct amdgpu_device *tmp_adev;
+ int ret = 0;
+ u32 status;
+
+ list_for_each_entry(tmp_adev, device_list_handle, reset_list) {
+ pci_read_config_dword(tmp_adev->pdev, PCI_COMMAND, &status);
+ if (PCI_POSSIBLE_ERROR(status)) {
+ dev_err(tmp_adev->dev, "device lost from bus!");
+ ret = -ENODEV;
+ }
+ }
+
+ return ret;
+}
+
/**
* amdgpu_device_gpu_recover - reset the asic and recover scheduler
*
@@ -5607,6 +5624,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
device_list_handle = &device_list;
}
+ if (!amdgpu_sriov_vf(adev)) {
+ r = amdgpu_device_health_check(device_list_handle);
+ if (r)
+ goto end_reset;
+ }
+
/* We need to lock reset domain only once both for XGMI and single device */
tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device,
reset_list);
@@ -5772,6 +5795,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
reset_list);
amdgpu_device_unlock_reset_domain(tmp_adev->reset_domain);
+end_reset:
if (hive) {
mutex_unlock(&hive->hive_lock);
amdgpu_put_xgmi_hive(hive);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] drm/amdgpu: Do a basic health check before reset
2024-03-13 9:41 [PATCH] drm/amdgpu: Do a basic health check before reset Lijo Lazar
2024-03-13 9:48 ` Kamal, Asad
@ 2024-03-13 19:49 ` Felix Kuehling
2024-03-14 4:41 ` Lazar, Lijo
1 sibling, 1 reply; 4+ messages in thread
From: Felix Kuehling @ 2024-03-13 19:49 UTC (permalink / raw)
To: Lijo Lazar, amd-gfx; +Cc: Hawking.Zhang, Alexander.Deucher, Asad.Kamal
On 2024-03-13 5:41, Lijo Lazar wrote:
> Check if the device is present in the bus before trying to recover. It
> could be that device itself is lost from the bus in some hang
> situations.
>
> Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 24 ++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 1e9454e6e4cb..b37113b79483 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -5536,6 +5536,23 @@ static inline void amdgpu_device_stop_pending_resets(struct amdgpu_device *adev)
>
> }
>
> +static int amdgpu_device_health_check(struct list_head *device_list_handle)
> +{
> + struct amdgpu_device *tmp_adev;
> + int ret = 0;
> + u32 status;
> +
> + list_for_each_entry(tmp_adev, device_list_handle, reset_list) {
> + pci_read_config_dword(tmp_adev->pdev, PCI_COMMAND, &status);
> + if (PCI_POSSIBLE_ERROR(status)) {
> + dev_err(tmp_adev->dev, "device lost from bus!");
> + ret = -ENODEV;
You could just return here. What's the point of looking for other
devices if you're going to return an error anyway?
Regards,
Felix
> + }
> + }
> +
> + return ret;
> +}
> +
> /**
> * amdgpu_device_gpu_recover - reset the asic and recover scheduler
> *
> @@ -5607,6 +5624,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
> device_list_handle = &device_list;
> }
>
> + if (!amdgpu_sriov_vf(adev)) {
> + r = amdgpu_device_health_check(device_list_handle);
> + if (r)
> + goto end_reset;
> + }
> +
> /* We need to lock reset domain only once both for XGMI and single device */
> tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device,
> reset_list);
> @@ -5772,6 +5795,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
> reset_list);
> amdgpu_device_unlock_reset_domain(tmp_adev->reset_domain);
>
> +end_reset:
> if (hive) {
> mutex_unlock(&hive->hive_lock);
> amdgpu_put_xgmi_hive(hive);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drm/amdgpu: Do a basic health check before reset
2024-03-13 19:49 ` Felix Kuehling
@ 2024-03-14 4:41 ` Lazar, Lijo
0 siblings, 0 replies; 4+ messages in thread
From: Lazar, Lijo @ 2024-03-14 4:41 UTC (permalink / raw)
To: Felix Kuehling, amd-gfx; +Cc: Hawking.Zhang, Alexander.Deucher, Asad.Kamal
On 3/14/2024 1:19 AM, Felix Kuehling wrote:
>
> On 2024-03-13 5:41, Lijo Lazar wrote:
>> Check if the device is present in the bus before trying to recover. It
>> could be that device itself is lost from the bus in some hang
>> situations.
>>
>> Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 24 ++++++++++++++++++++++
>> 1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> index 1e9454e6e4cb..b37113b79483 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> @@ -5536,6 +5536,23 @@ static inline void
>> amdgpu_device_stop_pending_resets(struct amdgpu_device *adev)
>> }
>> +static int amdgpu_device_health_check(struct list_head
>> *device_list_handle)
>> +{
>> + struct amdgpu_device *tmp_adev;
>> + int ret = 0;
>> + u32 status;
>> +
>> + list_for_each_entry(tmp_adev, device_list_handle, reset_list) {
>> + pci_read_config_dword(tmp_adev->pdev, PCI_COMMAND, &status);
>> + if (PCI_POSSIBLE_ERROR(status)) {
>> + dev_err(tmp_adev->dev, "device lost from bus!");
>> + ret = -ENODEV;
>
> You could just return here. What's the point of looking for other
> devices if you're going to return an error anyway?
>
This for XGMI case; the error is primarily for informational purpose to
know which all devices in the hive got into a bad state.
Thanks,
Lijo
> Regards,
> Felix
>
>
>> + }
>> + }
>> +
>> + return ret;
>> +}
>> +
>> /**
>> * amdgpu_device_gpu_recover - reset the asic and recover scheduler
>> *
>> @@ -5607,6 +5624,12 @@ int amdgpu_device_gpu_recover(struct
>> amdgpu_device *adev,
>> device_list_handle = &device_list;
>> }
>> + if (!amdgpu_sriov_vf(adev)) {
>> + r = amdgpu_device_health_check(device_list_handle);
>> + if (r)
>> + goto end_reset;
>> + }
>> +
>> /* We need to lock reset domain only once both for XGMI and
>> single device */
>> tmp_adev = list_first_entry(device_list_handle, struct
>> amdgpu_device,
>> reset_list);
>> @@ -5772,6 +5795,7 @@ int amdgpu_device_gpu_recover(struct
>> amdgpu_device *adev,
>> reset_list);
>> amdgpu_device_unlock_reset_domain(tmp_adev->reset_domain);
>> +end_reset:
>> if (hive) {
>> mutex_unlock(&hive->hive_lock);
>> amdgpu_put_xgmi_hive(hive);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-14 4:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-13 9:41 [PATCH] drm/amdgpu: Do a basic health check before reset Lijo Lazar
2024-03-13 9:48 ` Kamal, Asad
2024-03-13 19:49 ` Felix Kuehling
2024-03-14 4:41 ` Lazar, Lijo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox