Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: ee52489d1210 ("drm/amdgpu: Place NPS mode request on unload")
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
d37bc6a4 b6890efb

+16 -12
+16 -12
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
··· 1586 1586 * devices don't request anymore. 1587 1587 */ 1588 1588 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 + } 1589 1595 list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { 1590 1596 r = adev->gmc.gmc_funcs->request_mem_partition_mode( 1591 1597 tmp_adev, req_nps_mode); 1592 1598 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); 1594 1609 } 1595 1610 /* Set to UNKNOWN so that other devices don't request anymore */ 1596 1611 atomic_set(&hive->requested_nps_mode, UNKNOWN_MEMORY_PARTITION_MODE); 1597 - 1598 1612 mutex_unlock(&hive->hive_lock); 1599 - 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 1613 1610 1614 return r; 1611 1615 }