Commit 5f38ac54 authored by Kenneth Feng's avatar Kenneth Feng Committed by Alex Deucher
Browse files

drm/amd/pm: fix the high voltage and temperature issue



fix the high voltage and temperature issue after the driver is unloaded on smu 13.0.0,
smu 13.0.7 and smu 13.0.10
v2 - fix the code format and make sure it is used on the unload case only.

Signed-off-by: default avatarKenneth Feng <kenneth.feng@amd.com>
Reviewed-by: default avatarYang Wang <kevinyang.wang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent a17f574a
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -3962,6 +3962,13 @@ int amdgpu_device_init(struct amdgpu_device *adev,
				}
			}
		} else {
			switch (amdgpu_ip_version(adev, MP1_HWIP, 0)) {
			case IP_VERSION(13, 0, 0):
			case IP_VERSION(13, 0, 7):
			case IP_VERSION(13, 0, 10):
				r = psp_gpu_reset(adev);
				break;
			default:
				tmp = amdgpu_reset_method;
				/* It should do a default reset when loading or reloading the driver,
				 * regardless of the module parameter reset_method.
@@ -3969,6 +3976,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
				amdgpu_reset_method = AMD_RESET_METHOD_NONE;
				r = amdgpu_asic_reset(adev);
				amdgpu_reset_method = tmp;
				break;
			}

			if (r) {
				dev_err(adev->dev, "asic reset on init failed\n");
				goto failed;
+31 −2
Original line number Diff line number Diff line
@@ -733,7 +733,7 @@ static int smu_early_init(void *handle)
	smu->adev = adev;
	smu->pm_enabled = !!amdgpu_dpm;
	smu->is_apu = false;
	smu->smu_baco.state = SMU_BACO_STATE_EXIT;
	smu->smu_baco.state = SMU_BACO_STATE_NONE;
	smu->smu_baco.platform_support = false;
	smu->user_dpm_profile.fan_mode = -1;

@@ -1742,10 +1742,31 @@ static int smu_smc_hw_cleanup(struct smu_context *smu)
	return 0;
}

static int smu_reset_mp1_state(struct smu_context *smu)
{
	struct amdgpu_device *adev = smu->adev;
	int ret = 0;

	if ((!adev->in_runpm) && (!adev->in_suspend) &&
		(!amdgpu_in_reset(adev)))
		switch (amdgpu_ip_version(adev, MP1_HWIP, 0)) {
		case IP_VERSION(13, 0, 0):
		case IP_VERSION(13, 0, 7):
		case IP_VERSION(13, 0, 10):
			ret = smu_set_mp1_state(smu, PP_MP1_STATE_UNLOAD);
			break;
		default:
			break;
		}

	return ret;
}

static int smu_hw_fini(void *handle)
{
	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
	struct smu_context *smu = adev->powerplay.pp_handle;
	int ret;

	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
		return 0;
@@ -1763,7 +1784,15 @@ static int smu_hw_fini(void *handle)

	adev->pm.dpm_enabled = false;

	return smu_smc_hw_cleanup(smu);
	ret = smu_smc_hw_cleanup(smu);
	if (ret)
		return ret;

	ret = smu_reset_mp1_state(smu);
	if (ret)
		return ret;

	return 0;
}

static void smu_late_fini(void *handle)
+1 −0
Original line number Diff line number Diff line
@@ -419,6 +419,7 @@ enum smu_reset_mode {
enum smu_baco_state {
	SMU_BACO_STATE_ENTER = 0,
	SMU_BACO_STATE_EXIT,
	SMU_BACO_STATE_NONE,
};

struct smu_baco_context {
+2 −0
Original line number Diff line number Diff line
@@ -299,5 +299,7 @@ int smu_v13_0_update_pcie_parameters(struct smu_context *smu,
				     uint8_t pcie_gen_cap,
				     uint8_t pcie_width_cap);

int smu_v13_0_disable_pmfw_state(struct smu_context *smu);

#endif
#endif
+13 −0
Original line number Diff line number Diff line
@@ -2477,3 +2477,16 @@ int smu_v13_0_update_pcie_parameters(struct smu_context *smu,

	return 0;
}

int smu_v13_0_disable_pmfw_state(struct smu_context *smu)
{
	int ret;
	struct amdgpu_device *adev = smu->adev;

	WREG32_PCIE(MP1_Public | (smnMP1_FIRMWARE_FLAGS & 0xffffffff), 0);

	ret = RREG32_PCIE(MP1_Public |
					   (smnMP1_FIRMWARE_FLAGS & 0xffffffff));

	return ret == 0 ? 0 : -EINVAL;
}
Loading