Correct the logic to find supported NPS modes from firmware.

Signed-off-by: Lijo Lazar <lijo.la...@amd.com>
Reported-by: Ava Zhang <niandong.zh...@amd.com>

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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index ccb31e724b55..49630f838d45 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -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

Reply via email to