Commit a141b4e3 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher
Browse files

drm/amd/powerplay: simplify the code around retrieving power limit



Use the cached max/current power limit for other cases except
.late_init.

Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1e239fdd
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -831,9 +831,9 @@ static int smu_late_init(void *handle)
		return ret;
	}

	ret = smu_get_power_limit(smu, &smu->default_power_limit, false, false);
	ret = smu_get_asic_power_limits(smu);
	if (ret) {
		dev_err(adev->dev, "Failed to get default power limit!\n");
		dev_err(adev->dev, "Failed to get asic power limits!\n");
		return ret;
	}

@@ -2222,8 +2222,7 @@ int smu_get_power_limit(struct smu_context *smu,
		mutex_lock(&smu->mutex);
	}

	if (smu->ppt_funcs->get_power_limit)
		ret = smu->ppt_funcs->get_power_limit(smu, limit, def);
	*limit = (def ? smu->max_power_limit : smu->current_power_limit);

	if (lock_needed)
		mutex_unlock(&smu->mutex);
+1 −5
Original line number Diff line number Diff line
@@ -1409,9 +1409,7 @@ arcturus_get_profiling_clk_mask(struct smu_context *smu,
	return 0;
}

static int arcturus_get_power_limit(struct smu_context *smu,
				     uint32_t *limit,
				     bool cap)
static int arcturus_get_power_limit(struct smu_context *smu)
{
	struct smu_11_0_powerplay_table *powerplay_table =
		(struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;
@@ -1439,8 +1437,6 @@ static int arcturus_get_power_limit(struct smu_context *smu,
	}
	smu->max_power_limit = power_limit;

	*limit = (cap ? smu->max_power_limit : smu->current_power_limit);

	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -487,7 +487,7 @@ struct pptable_funcs {
	int (*set_performance_level)(struct smu_context *smu, enum amd_dpm_forced_level level);
	int (*display_disable_memory_clock_switch)(struct smu_context *smu, bool disable_memory_clock_switch);
	void (*dump_pptable)(struct smu_context *smu);
	int (*get_power_limit)(struct smu_context *smu, uint32_t *limit, bool asic_default);
	int (*get_power_limit)(struct smu_context *smu);
	int (*get_dpm_clk_limited)(struct smu_context *smu, enum smu_clk_type clk_type,
				   uint32_t dpm_level, uint32_t *freq);
	int (*set_df_cstate)(struct smu_context *smu, enum pp_df_cstate state);
+1 −5
Original line number Diff line number Diff line
@@ -1922,9 +1922,7 @@ static uint32_t navi10_get_pptable_power_limit(struct smu_context *smu)
	return pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0];
}

static int navi10_get_power_limit(struct smu_context *smu,
				  uint32_t *limit,
				  bool cap)
static int navi10_get_power_limit(struct smu_context *smu)
{
	struct smu_11_0_powerplay_table *powerplay_table =
		(struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;
@@ -1952,8 +1950,6 @@ static int navi10_get_power_limit(struct smu_context *smu,
	}
	smu->max_power_limit = power_limit;

	*limit = (cap ? smu->max_power_limit : smu->current_power_limit);

	return 0;
}

+1 −5
Original line number Diff line number Diff line
@@ -1743,9 +1743,7 @@ static uint32_t sienna_cichlid_get_pptable_power_limit(struct smu_context *smu)
	return pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0];
}

static int sienna_cichlid_get_power_limit(struct smu_context *smu,
				     uint32_t *limit,
				     bool cap)
static int sienna_cichlid_get_power_limit(struct smu_context *smu)
{
	struct smu_11_0_7_powerplay_table *powerplay_table =
		(struct smu_11_0_7_powerplay_table *)smu->smu_table.power_play_table;
@@ -1773,8 +1771,6 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu,
	}
	smu->max_power_limit = power_limit;

	*limit = (cap ? smu->max_power_limit : smu->current_power_limit);

	return 0;
}

Loading