Skip to contentSkip to conversation

drm/amdgpu: Fix logic to fetch supported NPS modes

PATCH In review Lijo Lazar 2 participants 2 messages Feb 25, 2025

Subsystems (2)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix logic to fetch supported NPS modes

Correct the logic to find supported NPS modes from firmware.

Fixes cdb41537812f ("drm/amdgpu: Use firmware supported NPS modes")
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -3
index ccb31e724b55..49630f838d45 100644
@@ -1607,9 +1607,8 @@ static void gmc_v9_0_init_nps_details(struct amdgpu_device *adev)
 
 	/* Mode detected by hardware and supported modes available */
 	if ((mode != UNKNOWN_MEMORY_PARTITION_MODE) && supp_modes) {
-		for (i = AMDGPU_NPS1_PARTITION_MODE;
-		     supp_modes && i <= AMDGPU_NPS8_PARTITION_MODE; i++) {
-			if (supp_modes & BIT(i - 1))
+		while (i = ffs(supp_modes)) {
+			if (AMDGPU_ALL_NPS_MASK & BIT(i))
 				adev->gmc.supported_nps_modes |= BIT(i);
 			supp_modes &= supp_modes - 1;
 		}
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Regards,
Hawking
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, February 25, 2025 19:03
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Lin, Amber <[email protected]>; Zhang, Ava <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix logic to fetch supported NPS modes

Correct the logic to find supported NPS modes from firmware.

Fixes cdb41537812f ("drm/amdgpu: Use firmware supported NPS modes")
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -3
index ccb31e724b55..49630f838d45 100644
@@ -1607,9 +1607,8 @@ static void gmc_v9_0_init_nps_details(struct amdgpu_device *adev)
 
        /* Mode detected by hardware and supported modes available */
        if ((mode != UNKNOWN_MEMORY_PARTITION_MODE) && supp_modes) {
-               for (i = AMDGPU_NPS1_PARTITION_MODE;
-                    supp_modes && i <= AMDGPU_NPS8_PARTITION_MODE; i++) {
-                       if (supp_modes & BIT(i - 1))
+               while (i = ffs(supp_modes)) {
+                       if (AMDGPU_ALL_NPS_MASK & BIT(i))
                                adev->gmc.supported_nps_modes |= BIT(i);
                        supp_modes &= supp_modes - 1;
                }

--
2.25.1