Skip to content

Commit d37bc6a

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amdgpu: Fix the logic for NPS request failure
On a hive, NPS request is placed by the first one for all devices in the hive. If the request fails, mark the mode as UNKNOWN so that subsequent devices on unload don't request it. Also, fix the mutex double lock issue in error condition, should have been mutex_unlock. Fixes: ee52489 ("drm/amdgpu: Place NPS mode request on unload") Signed-off-by: Lijo Lazar <[email protected]> Reviewed-by: Rajneesh Bhardwaj <[email protected]> Acked-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b6890ef commit d37bc6a

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,26 +1586,30 @@ int amdgpu_xgmi_request_nps_change(struct amdgpu_device *adev,
15861586
* devices don't request anymore.
15871587
*/
15881588
mutex_lock(&hive->hive_lock);
1589+
if (atomic_read(&hive->requested_nps_mode) ==
1590+
UNKNOWN_MEMORY_PARTITION_MODE) {
1591+
dev_dbg(adev->dev, "Unexpected entry for hive NPS change");
1592+
mutex_unlock(&hive->hive_lock);
1593+
return 0;
1594+
}
15891595
list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) {
15901596
r = adev->gmc.gmc_funcs->request_mem_partition_mode(
15911597
tmp_adev, req_nps_mode);
15921598
if (r)
1593-
goto err;
1599+
break;
1600+
}
1601+
if (r) {
1602+
/* Request back current mode if one of the requests failed */
1603+
cur_nps_mode =
1604+
adev->gmc.gmc_funcs->query_mem_partition_mode(tmp_adev);
1605+
list_for_each_entry_continue_reverse(
1606+
tmp_adev, &hive->device_list, gmc.xgmi.head)
1607+
adev->gmc.gmc_funcs->request_mem_partition_mode(
1608+
tmp_adev, cur_nps_mode);
15941609
}
15951610
/* Set to UNKNOWN so that other devices don't request anymore */
15961611
atomic_set(&hive->requested_nps_mode, UNKNOWN_MEMORY_PARTITION_MODE);
1597-
15981612
mutex_unlock(&hive->hive_lock);
15991613

1600-
return 0;
1601-
err:
1602-
/* Request back current mode if one of the requests failed */
1603-
cur_nps_mode = adev->gmc.gmc_funcs->query_mem_partition_mode(tmp_adev);
1604-
list_for_each_entry_continue_reverse(tmp_adev, &hive->device_list,
1605-
gmc.xgmi.head)
1606-
adev->gmc.gmc_funcs->request_mem_partition_mode(tmp_adev,
1607-
cur_nps_mode);
1608-
mutex_lock(&hive->hive_lock);
1609-
16101614
return r;
16111615
}

0 commit comments

Comments
 (0)