write to GRBM_GFX_INDEX without lock

Tom St Denis tom.stdenis at amd.com
Tue Sep 12 14:18:23 UTC 2017


In the file smu7_powertune.c we have

int smu7_enable_didt_config(struct pp_hwmgr *hwmgr)
{
	int result;
	uint32_t num_se = 0;
	uint32_t count, value, value2;
	struct cgs_system_info sys_info = {0};

	sys_info.size = sizeof(struct cgs_system_info);
	sys_info.info_id = CGS_SYSTEM_INFO_GFX_SE_INFO;
	result = cgs_query_system_info(hwmgr->device, &sys_info);

	if (result == 0)
		num_se = sys_info.value;

	if (PP_CAP(PHM_PlatformCaps_SQRamping) ||
	    PP_CAP(PHM_PlatformCaps_DBRamping) ||
	    PP_CAP(PHM_PlatformCaps_TDRamping) ||
	    PP_CAP(PHM_PlatformCaps_TCPRamping)) {

		cgs_enter_safe_mode(hwmgr->device, true);
		value = 0;
		value2 = cgs_read_register(hwmgr->device, mmGRBM_GFX_INDEX);
		for (count = 0; count < num_se; count++) {
			value = SYS_GRBM_GFX_INDEX_DATA__INSTANCE_BROADCAST_WRITES_MASK
				| SYS_GRBM_GFX_INDEX_DATA__SH_BROADCAST_WRITES_MASK
				| (count << SYS_GRBM_GFX_INDEX_DATA__SE_INDEX__SHIFT);
			cgs_write_register(hwmgr->device, mmGRBM_GFX_INDEX, value);


The call to "enter safe mode" doesn't hold the lock which means that 
this could in theory occur while other things are going on.  Granted 
this function is likely called during init it should have a lock no?

Cheers,
Tom


More information about the amd-gfx mailing list