Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15510195 authored by Eric Huang's avatar Eric Huang Committed by Alex Deucher
Browse files

drm/amd/powerplay: revise caching the soft pptable and add it's size



This fixes a bug in the pptable access interface that could lead to
a crash.  Check the pointer before using it.

Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarEric Huang <JinHuiEric.Huang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 5632708f
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -138,12 +138,15 @@ const void *get_powerplay_table(struct pp_hwmgr *hwmgr)

	u16 size;
	u8 frev, crev;
	void *table_address;
	void *table_address = (void *)hwmgr->soft_pp_table;

	if (!table_address) {
		table_address = (ATOM_Tonga_POWERPLAYTABLE *)
		cgs_atom_get_data_table(hwmgr->device, index, &size, &frev, &crev);

				cgs_atom_get_data_table(hwmgr->device,
						index, &size, &frev, &crev);
		hwmgr->soft_pp_table = table_address;	/*Cache the result in RAM.*/
		hwmgr->soft_pp_table_size = size;
	}

	return table_address;
}
+1 −0
Original line number Diff line number Diff line
@@ -577,6 +577,7 @@ struct pp_hwmgr {
	void *device;
	struct pp_smumgr *smumgr;
	const void *soft_pp_table;
	uint32_t soft_pp_table_size;
	bool need_pp_table_upload;
	enum amd_dpm_forced_level dpm_level;
	bool block_hw_access;