Skip to contentSkip to conversation

write to GRBM_GFX_INDEX without lock

DISCUSSION Tom St Denis 2 participants 2 messages Sep 12, 2017 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

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
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 5d433b5e-855f-dd03-df0e-629a798d749f-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 40 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Tom St Denis
Sent: Tuesday, September 12, 2017 10:18 AM
To: amd-gfx mailing list
Subject: write to GRBM_GFX_INDEX without lock

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,
Quoted 6 lines

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?

Yes, it should. I think there is a cgs function to handle the locking.

Alex

Quoted 7 lines

Cheers,
Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx