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

drm/amdgpu/display: navi1x copy dcn watermark clock settings to smu resume from s3 (v2)

This interface is for dGPU Navi1x. Linux dc-pplib interface depends
on window driver dc implementation.

For Navi1x, clock settings of dcn watermarks are fixed. the settings
should be passed to smu during boot up and resume from s3.
boot up: dc calculate dcn watermark clock settings within dc_create,
dcn20_resource_construct, then call pplib functions below to pass
the settings to smu:
smu_set_watermarks_for_clock_ranges
smu_set_watermarks_table
navi10_set_watermarks_table
smu_write_watermarks_table

For Renoir, clock settings of dcn watermark are also fixed values.
dc has implemented different flow for window driver:
dc_hardware_init / dc_set_power_state
dcn10_init_hw
notify_wm_ranges
set_wm_ranges

For Linux
smu_set_watermarks_for_clock_ranges
renoir_set_watermarks_table
smu_write_watermarks_table

dc_hardware_init -> amdgpu_dm_init
dc_set_power_state --> dm_resume

therefore, linux dc-pplib interface of navi10/12/14 is different
from that of Renoir.

v2: add missing unlock in error case

Signed-off-by: Hersen Wu <hersenxs.wu@amd.com>
Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Hersen Wu and committed by
Alex Deucher
9340dfd3 6863d607

+69
+69
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 1435 1435 drm_kms_helper_hotplug_event(dev); 1436 1436 } 1437 1437 1438 + static int amdgpu_dm_smu_write_watermarks_table(struct amdgpu_device *adev) 1439 + { 1440 + struct smu_context *smu = &adev->smu; 1441 + int ret = 0; 1442 + 1443 + if (!is_support_sw_smu(adev)) 1444 + return 0; 1445 + 1446 + /* This interface is for dGPU Navi1x.Linux dc-pplib interface depends 1447 + * on window driver dc implementation. 1448 + * For Navi1x, clock settings of dcn watermarks are fixed. the settings 1449 + * should be passed to smu during boot up and resume from s3. 1450 + * boot up: dc calculate dcn watermark clock settings within dc_create, 1451 + * dcn20_resource_construct 1452 + * then call pplib functions below to pass the settings to smu: 1453 + * smu_set_watermarks_for_clock_ranges 1454 + * smu_set_watermarks_table 1455 + * navi10_set_watermarks_table 1456 + * smu_write_watermarks_table 1457 + * 1458 + * For Renoir, clock settings of dcn watermark are also fixed values. 1459 + * dc has implemented different flow for window driver: 1460 + * dc_hardware_init / dc_set_power_state 1461 + * dcn10_init_hw 1462 + * notify_wm_ranges 1463 + * set_wm_ranges 1464 + * -- Linux 1465 + * smu_set_watermarks_for_clock_ranges 1466 + * renoir_set_watermarks_table 1467 + * smu_write_watermarks_table 1468 + * 1469 + * For Linux, 1470 + * dc_hardware_init -> amdgpu_dm_init 1471 + * dc_set_power_state --> dm_resume 1472 + * 1473 + * therefore, this function apply to navi10/12/14 but not Renoir 1474 + * * 1475 + */ 1476 + switch(adev->asic_type) { 1477 + case CHIP_NAVI10: 1478 + case CHIP_NAVI14: 1479 + case CHIP_NAVI12: 1480 + break; 1481 + default: 1482 + return 0; 1483 + } 1484 + 1485 + mutex_lock(&smu->mutex); 1486 + 1487 + /* pass data to smu controller */ 1488 + if ((smu->watermarks_bitmap & WATERMARKS_EXIST) && 1489 + !(smu->watermarks_bitmap & WATERMARKS_LOADED)) { 1490 + ret = smu_write_watermarks_table(smu); 1491 + 1492 + if (ret) { 1493 + mutex_unlock(&smu->mutex); 1494 + DRM_ERROR("Failed to update WMTABLE!\n"); 1495 + return ret; 1496 + } 1497 + smu->watermarks_bitmap |= WATERMARKS_LOADED; 1498 + } 1499 + 1500 + mutex_unlock(&smu->mutex); 1501 + 1502 + return 0; 1503 + } 1504 + 1438 1505 /** 1439 1506 * dm_hw_init() - Initialize DC device 1440 1507 * @handle: The base driver device containing the amdgpu_dm device. ··· 1779 1712 dm->cached_state = NULL; 1780 1713 1781 1714 amdgpu_dm_irq_resume_late(adev); 1715 + 1716 + amdgpu_dm_smu_write_watermarks_table(adev); 1782 1717 1783 1718 return 0; 1784 1719 }