Skip to contentSkip to conversation

drm/amdkfd: Move queue fs deletion after destroy check

PATCH In review Kent Russell 3 participants 5 messages Sep 10, 2024 – Sep 11, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdkfd: Move queue fs deletion after destroy check

We were removing the kernfs entry for queue info before checking if the queue could be destroyed. If it failed to get destroyed (e.g. during some GPU resets), then we would try to delete it later during pqm teardown, but the file was already removed. This led to a kernel WARN trying to remove size, gpuid and type. Move the remove to after the destroy check.

---
 drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -1
index b439d4d0bd84..01b960b15274 100644
@@ -517,7 +517,6 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
 		if (retval)
 			goto err_destroy_queue;
 
-		kfd_procfs_del_queue(pqn->q);
 		dqm = pqn->q->device->dqm;
 		retval = dqm->ops.destroy_queue(dqm, &pdd->qpd, pqn->q);
 		if (retval) {
@@ -527,6 +526,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
 			if (retval != -ETIME)
 				goto err_destroy_queue;
 		}
+		kfd_procfs_del_queue(pqn->q);
 		kfd_queue_release_buffers(pdd, &pqn->q->properties);
 		pqm_clean_queue_resource(pqm, pqn);
 		uninit_queue(pqn->q);
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 drm/amdgpu: Retry i2c transfer once if it fails

During init, there can be some collisions on the i2c bus that result in the EEPROM read failing. This has been mitigated in the PMFW to a degree, but there is still a small chance that the bus will be busy. When the read fails during RAS init, that disables page retirement altogether, which is obviously not ideal. To try to avoid that situation, set the eeprom_read function to retry once if the first read fails.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +7 -1
index 35fee3e8cde2..32755a37dcef 100644
@@ -227,8 +227,14 @@ int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap,
 		       u32 eeprom_addr, u8 *eeprom_buf,
 		       u32 bytes)
 {
-	return amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,
+	int ret;
+
+	ret = amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,
+				  true);
+	if (ret)
+		ret = amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,
 				  true);
+	return ret;
 }
 
 int amdgpu_eeprom_write(struct i2c_adapter *i2c_adap,
Signature · 1 line
2.34.1
#2 lore raw

RE: [PATCH 2/2] drm/amdgpu: Retry i2c transfer once if it fails

[AMD Official Use Only - AMD Internal Distribution Only]

The ideal place is -

        smu_v13_0_6_request_i2c_xfer

Restricts the change to specific SOCs with collision problem. Gives a bit more survival chance with a retry on every chunk requested.

Thanks,
Lijo
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kent Russell
Sent: Tuesday, September 10, 2024 7:07 PM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Retry i2c transfer once if it fails

During init, there can be some collisions on the i2c bus that result in the EEPROM read failing. This has been mitigated in the PMFW to a degree, but there is still a small chance that the bus will be busy. When the read fails during RAS init, that disables page retirement altogether, which is obviously not ideal. To try to avoid that situation, set the eeprom_read function to retry once if the first read fails.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +7 -1
index 35fee3e8cde2..32755a37dcef 100644
@@ -227,8 +227,14 @@ int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap,
                       u32 eeprom_addr, u8 *eeprom_buf,
                       u32 bytes)
 {
-       return amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,
+       int ret;
+
+       ret = amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,
+                                 true);
+       if (ret)
+               ret = amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,
                                  true);
+       return ret;
 }
 
 int amdgpu_eeprom_write(struct i2c_adapter *i2c_adap,

--
2.34.1

#3 lore raw

RE: [PATCH 2/2] drm/amdgpu: Retry i2c transfer once if it fails

[AMD Official Use Only - AMD Internal Distribution Only]

Sounds good, thanks for the input Lijo! I'll get that tested and verify that it works too.

Kent

Quoted 63 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, September 10, 2024 10:06 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Russell, Kent <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: Retry i2c transfer once if it fails

[AMD Official Use Only - AMD Internal Distribution Only]

The ideal place is -

        smu_v13_0_6_request_i2c_xfer

Restricts the change to specific SOCs with collision problem. Gives a bit more survival chance with a retry on every chunk requested.

Thanks,
Lijo
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kent Russell
Sent: Tuesday, September 10, 2024 7:07 PM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Retry i2c transfer once if it fails

During init, there can be some collisions on the i2c bus that result in the EEPROM read failing. This has been mitigated in the PMFW to a degree, but there is still a small chance that the bus will be busy.
When the read fails during RAS init, that disables page retirement altogether, which is obviously not ideal. To try to avoid that situation, set the eeprom_read function to retry once if the first read fails.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +7 -1
index 35fee3e8cde2..32755a37dcef 100644
@@ -227,8 +227,14 @@ int amdgpu_eeprom_read(struct i2c_adapter
 *i2c_adap,
                       u32 eeprom_addr, u8 *eeprom_buf,
                       u32 bytes)
 {
-       return amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,
+       int ret;
+
+       ret = amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,
+                                 true);
+       if (ret)
+               ret = amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf,
 bytes,
                                  true);
+       return ret;
 }

int amdgpu_eeprom_write(struct i2c_adapter *i2c_adap,
--
2.34.1

Reviewed-by on v1 1/2
#4 lore raw
In reply to Kent Russell

[Public]

Quoted 12 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kent Russell
Sent: Tuesday, September 10, 2024 9:37 AM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 1/2] drm/amdkfd: Move queue fs deletion after destroy check

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 8 lines

We were removing the kernfs entry for queue info before checking if the queue could be destroyed. If it failed to get destroyed (e.g. during some GPU resets), then we would try to delete it later during pqm teardown, but the file was already removed. This led to a kernel WARN trying to remove size, gpuid and type. Move the remove to after the destroy check.

This patch is:

Quoted 29 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +0 -1
index b439d4d0bd84..01b960b15274 100644
@@ -517,7 +517,6 @@ int pqm_destroy_queue(struct process_queue_manager
 *pqm, unsigned int qid)
                if (retval)
                        goto err_destroy_queue;
 
-               kfd_procfs_del_queue(pqn->q);
                dqm = pqn->q->device->dqm;
                retval = dqm->ops.destroy_queue(dqm, &pdd->qpd, pqn->q);
                if (retval) {
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -0
@@ -527,6 +526,7 @@ int pqm_destroy_queue(struct process_queue_manager
 *pqm, unsigned int qid)
                        if (retval != -ETIME)
                                goto err_destroy_queue;
                }
+               kfd_procfs_del_queue(pqn->q);
                kfd_queue_release_buffers(pdd, &pqn->q->properties);
                pqm_clean_queue_resource(pqm, pqn);
                uninit_queue(pqn->q);

--
2.34.1