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

Commit ab5cf3a5 authored by Rex Zhu's avatar Rex Zhu Committed by Alex Deucher
Browse files

drm/amd/powerplay: add avfs fuse overdriver func.



Add a function to look up the AVFS fuse values for vega10
These are used to populate the avfs fuse table in the smu.

Signed-off-by: default avatarRex Zhu <Rex.Zhu@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d6c025d2
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -9,8 +9,7 @@ HARDWARE_MGR = hwmgr.o processpptables.o functiontables.o \
		smu7_hwmgr.o smu7_powertune.o smu7_thermal.o \
		smu7_clockpowergating.o \
		vega10_processpptables.o vega10_hwmgr.o vega10_powertune.o \
		vega10_thermal.o

		vega10_thermal.o pp_overdriver.o

AMD_PP_HWMGR = $(addprefix $(AMD_PP_PATH)/hwmgr/,$(HARDWARE_MGR))

+1276 −0

File added.

Preview size limit exceeded, changes collapsed.

+48 −0
Original line number Diff line number Diff line
/*
 * Copyright 2015 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#ifndef _PP_OVERDRIVER_H_
#define _PP_OVERDRIVER_H_

#include <linux/types.h>
#include <linux/kernel.h>

struct phm_fuses_default {
	const char *key;
	uint32_t VFT2_m1;
	uint32_t VFT2_m2;
	uint32_t VFT2_b;
	uint32_t VFT1_m1;
	uint32_t VFT1_m2;
	uint32_t VFT1_b;
	uint32_t VFT0_m1;
	uint32_t VFT0_m2;
	uint32_t VFT0_b;
};

extern struct phm_fuses_default vega10_fuses_default[];
extern int pp_override_get_default_fuse_value(uint64_t key,
			struct phm_fuses_default list[],
			struct phm_fuses_default *result);

#endif
 No newline at end of file
+42 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@
#include "amd_pcie_helpers.h"
#include "cgs_linux.h"
#include "ppinterrupt.h"

#include "pp_overdriver.h"

#define VOLTAGE_SCALE  4
#define VOLTAGE_VID_OFFSET_SCALE1   625
@@ -2286,6 +2286,45 @@ static int vega10_avfs_enable(struct pp_hwmgr *hwmgr, bool enable)
	return 0;
}

static int vega10_populate_and_upload_avfs_fuse_override(struct pp_hwmgr *hwmgr)
{
	int result = 0;

	uint64_t serial_number = 0;
	uint32_t top32, bottom32;
	struct phm_fuses_default fuse;

	struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
	AvfsFuseOverride_t *avfs_fuse_table = &(data->smc_state_table.avfs_fuse_override_table);

	smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_ReadSerialNumTop32);
	vega10_read_arg_from_smc(hwmgr->smumgr, &top32);

	smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_ReadSerialNumBottom32);
	vega10_read_arg_from_smc(hwmgr->smumgr, &bottom32);

	serial_number = ((uint64_t)bottom32 << 32) | top32;

	if (pp_override_get_default_fuse_value(serial_number, vega10_fuses_default, &fuse) == 0) {
		avfs_fuse_table->VFT0_b  = fuse.VFT0_b;
		avfs_fuse_table->VFT0_m1 = fuse.VFT0_m1;
		avfs_fuse_table->VFT0_m2 = fuse.VFT0_m2;
		avfs_fuse_table->VFT1_b  = fuse.VFT1_b;
		avfs_fuse_table->VFT1_m1 = fuse.VFT1_m1;
		avfs_fuse_table->VFT1_m2 = fuse.VFT1_m2;
		avfs_fuse_table->VFT2_b  = fuse.VFT2_b;
		avfs_fuse_table->VFT2_m1 = fuse.VFT2_m1;
		avfs_fuse_table->VFT2_m2 = fuse.VFT2_m2;
		result = vega10_copy_table_to_smc(hwmgr->smumgr,
			(uint8_t *)avfs_fuse_table, AVFSFUSETABLE);
		PP_ASSERT_WITH_CODE(!result,
			"Failed to upload FuseOVerride!",
			);
	}

	return result;
}

static int vega10_save_default_power_profile(struct pp_hwmgr *hwmgr)
{
	struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
@@ -2439,6 +2478,8 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr)
	pp_table->GfxActivityAverageAlpha = (uint8_t)
			(data->gfx_activity_average_alpha);

	vega10_populate_and_upload_avfs_fuse_override(hwmgr);

	result = vega10_copy_table_to_smc(hwmgr->smumgr,
			(uint8_t *)pp_table, PPTABLE);
	PP_ASSERT_WITH_CODE(!result,
+1 −0
Original line number Diff line number Diff line
@@ -210,6 +210,7 @@ struct vega10_smc_state_table {
	PPTable_t       pp_table;
	Watermarks_t    water_marks_table;
	AvfsTable_t     avfs_table;
	AvfsFuseOverride_t avfs_fuse_override_table;
};

struct vega10_mclk_latency_entries {