Skip to contentSkip to conversation

drm/amdkfd: Fix MEC pipe interrupt enablement

PATCH In review Lijo Lazar 3 participants 3 messages May 29, 2023 – May 31, 2023

Subsystems (3)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/1 drm/amdkfd: Fix MEC pipe interrupt enablement

for_each_inst modifies xcc_mask and therefore the loop doesn't initialize properly interrupts on all pipes. Keep looping through xcc as the outer loop to fix this issue.

Fixes 7b04c90a48b1 ("drm/amdkfd: Use xcc mask for identifying xcc")
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4 -3
index 493b4b66f180..80cddb46657f 100644
@@ -1274,11 +1274,12 @@ static void init_interrupts(struct device_queue_manager *dqm)
 	uint32_t xcc_mask = dqm->dev->xcc_mask;
 	unsigned int i, xcc_id;
 
-	for (i = 0 ; i < get_pipes_per_mec(dqm) ; i++) {
-		if (is_pipe_enabled(dqm, 0, i)) {
-			for_each_inst(xcc_id, xcc_mask)
+	for_each_inst(xcc_id, xcc_mask) {
+		for (i = 0 ; i < get_pipes_per_mec(dqm) ; i++) {
+			if (is_pipe_enabled(dqm, 0, i)) {
 				dqm->dev->kfd2kgd->init_interrupts(
 					dqm->dev->adev, i, xcc_id);
+			}
 		}
 	}
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Monday, May 29, 2023 21:58
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Joshi, Mukul <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH] drm/amdkfd: Fix MEC pipe interrupt enablement

for_each_inst modifies xcc_mask and therefore the loop doesn't initialize properly interrupts on all pipes. Keep looping through xcc as the outer loop to fix this issue.

Fixes 7b04c90a48b1 ("drm/amdkfd: Use xcc mask for identifying xcc")
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4 -3
index 493b4b66f180..80cddb46657f 100644
@@ -1274,11 +1274,12 @@ static void init_interrupts(struct device_queue_manager *dqm)
        uint32_t xcc_mask = dqm->dev->xcc_mask;
        unsigned int i, xcc_id;
 
-       for (i = 0 ; i < get_pipes_per_mec(dqm) ; i++) {
-               if (is_pipe_enabled(dqm, 0, i)) {
-                       for_each_inst(xcc_id, xcc_mask)
+       for_each_inst(xcc_id, xcc_mask) {
+               for (i = 0 ; i < get_pipes_per_mec(dqm) ; i++) {
+                       if (is_pipe_enabled(dqm, 0, i)) {
                                dqm->dev->kfd2kgd->init_interrupts(
                                        dqm->dev->adev, i, xcc_id);
+                       }
                }
        }
 }

--
2.25.1

maintainer
#2 lore raw
In reply to Lijo Lazar

This quirk of for_each_inst has caused problems more than once. Why not use for_each_set_bit to implement it? That one doesn't have side effects.

Regards,
  Felix

Am 2023-05-29 um 09:58 schrieb Lijo Lazar:

Quoted 31 lines

for_each_inst modifies xcc_mask and therefore the loop doesn't initialize properly interrupts on all pipes. Keep looping through xcc as the outer loop to fix this issue.

Fixes 7b04c90a48b1 ("drm/amdkfd: Use xcc mask for identifying xcc")
---
  drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4 -3
index 493b4b66f180..80cddb46657f 100644
@@ -1274,11 +1274,12 @@ static void init_interrupts(struct device_queue_manager *dqm)
  	uint32_t xcc_mask = dqm->dev->xcc_mask;
  	unsigned int i, xcc_id;
 
-	for (i = 0 ; i < get_pipes_per_mec(dqm) ; i++) {
-		if (is_pipe_enabled(dqm, 0, i)) {
-			for_each_inst(xcc_id, xcc_mask)
+	for_each_inst(xcc_id, xcc_mask) {
+		for (i = 0 ; i < get_pipes_per_mec(dqm) ; i++) {
+			if (is_pipe_enabled(dqm, 0, i)) {
  				dqm->dev->kfd2kgd->init_interrupts(
  					dqm->dev->adev, i, xcc_id);
+			}
  		}
  	}
  }