Skip to contentSkip to conversation

drm/amdgpu: move dpm related definitions to amdgpu_dpm.h

PATCH In review Alex Deucher 4 participants 15 messages Oct 7, 2016 – Oct 12, 2016 9 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 drm/amdgpu: move dpm related definitions to amdgpu_dpm.h

No intended functional change.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 449 +-------------------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 447 +++++++++++++++++++++++++++++++
 2 files changed, 448 insertions(+), 448 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -448
index 7d30a8e..a6db3dd 100644
@@ -57,6 +57,7 @@
 #include "amdgpu_ring.h"
 #include "amdgpu_vm.h"
 #include "amd_powerplay.h"
+#include "amdgpu_dpm.h"
 #include "amdgpu_acp.h"
 
 #include "gpu_scheduler.h"
@@ -961,354 +962,6 @@ struct amdgpu_wb {
 int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb);
 void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb);
 
-
-
-enum amdgpu_int_thermal_type {
-	THERMAL_TYPE_NONE,
-	THERMAL_TYPE_EXTERNAL,
-	THERMAL_TYPE_EXTERNAL_GPIO,
-	THERMAL_TYPE_RV6XX,
-	THERMAL_TYPE_RV770,
-	THERMAL_TYPE_ADT7473_WITH_INTERNAL,
-	THERMAL_TYPE_EVERGREEN,
-	THERMAL_TYPE_SUMO,
-	THERMAL_TYPE_NI,
-	THERMAL_TYPE_SI,
-	THERMAL_TYPE_EMC2103_WITH_INTERNAL,
-	THERMAL_TYPE_CI,
-	THERMAL_TYPE_KV,
-};
-
-enum amdgpu_dpm_auto_throttle_src {
-	AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL,
-	AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL
-};
-
-enum amdgpu_dpm_event_src {
-	AMDGPU_DPM_EVENT_SRC_ANALOG = 0,
-	AMDGPU_DPM_EVENT_SRC_EXTERNAL = 1,
-	AMDGPU_DPM_EVENT_SRC_DIGITAL = 2,
-	AMDGPU_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL = 3,
-	AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4
-};
-
-#define AMDGPU_MAX_VCE_LEVELS 6
-
-enum amdgpu_vce_level {
-	AMDGPU_VCE_LEVEL_AC_ALL = 0,     /* AC, All cases */
-	AMDGPU_VCE_LEVEL_DC_EE = 1,      /* DC, entropy encoding */
-	AMDGPU_VCE_LEVEL_DC_LL_LOW = 2,  /* DC, low latency queue, res <= 720 */
-	AMDGPU_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
-	AMDGPU_VCE_LEVEL_DC_GP_LOW = 4,  /* DC, general purpose queue, res <= 720 */
-	AMDGPU_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
-};
-
-struct amdgpu_ps {
-	u32 caps; /* vbios flags */
-	u32 class; /* vbios flags */
-	u32 class2; /* vbios flags */
-	/* UVD clocks */
-	u32 vclk;
-	u32 dclk;
-	/* VCE clocks */
-	u32 evclk;
-	u32 ecclk;
-	bool vce_active;
-	enum amdgpu_vce_level vce_level;
-	/* asic priv */
-	void *ps_priv;
-};
-
-struct amdgpu_dpm_thermal {
-	/* thermal interrupt work */
-	struct work_struct work;
-	/* low temperature threshold */
-	int                min_temp;
-	/* high temperature threshold */
-	int                max_temp;
-	/* was last interrupt low to high or high to low */
-	bool               high_to_low;
-	/* interrupt source */
-	struct amdgpu_irq_src	irq;
-};
-
-enum amdgpu_clk_action
-{
-	AMDGPU_SCLK_UP = 1,
-	AMDGPU_SCLK_DOWN
-};
-
-struct amdgpu_blacklist_clocks
-{
-	u32 sclk;
-	u32 mclk;
-	enum amdgpu_clk_action action;
-};
-
-struct amdgpu_clock_and_voltage_limits {
-	u32 sclk;
-	u32 mclk;
-	u16 vddc;
-	u16 vddci;
-};
-
-struct amdgpu_clock_array {
-	u32 count;
-	u32 *values;
-};
-
-struct amdgpu_clock_voltage_dependency_entry {
-	u32 clk;
-	u16 v;
-};
-
-struct amdgpu_clock_voltage_dependency_table {
-	u32 count;
-	struct amdgpu_clock_voltage_dependency_entry *entries;
-};
-
-union amdgpu_cac_leakage_entry {
-	struct {
-		u16 vddc;
-		u32 leakage;
-	};
-	struct {
-		u16 vddc1;
-		u16 vddc2;
-		u16 vddc3;
-	};
-};
-
-struct amdgpu_cac_leakage_table {
-	u32 count;
-	union amdgpu_cac_leakage_entry *entries;
-};
-
-struct amdgpu_phase_shedding_limits_entry {
-	u16 voltage;
-	u32 sclk;
-	u32 mclk;
-};
-
-struct amdgpu_phase_shedding_limits_table {
-	u32 count;
-	struct amdgpu_phase_shedding_limits_entry *entries;
-};
-
-struct amdgpu_uvd_clock_voltage_dependency_entry {
-	u32 vclk;
-	u32 dclk;
-	u16 v;
-};
-
-struct amdgpu_uvd_clock_voltage_dependency_table {
-	u8 count;
-	struct amdgpu_uvd_clock_voltage_dependency_entry *entries;
-};
-
-struct amdgpu_vce_clock_voltage_dependency_entry {
-	u32 ecclk;
-	u32 evclk;
-	u16 v;
-};
-
-struct amdgpu_vce_clock_voltage_dependency_table {
-	u8 count;
-	struct amdgpu_vce_clock_voltage_dependency_entry *entries;
-};
-
-struct amdgpu_ppm_table {
-	u8 ppm_design;
-	u16 cpu_core_number;
-	u32 platform_tdp;
-	u32 small_ac_platform_tdp;
-	u32 platform_tdc;
-	u32 small_ac_platform_tdc;
-	u32 apu_tdp;
-	u32 dgpu_tdp;
-	u32 dgpu_ulv_power;
-	u32 tj_max;
-};
-
-struct amdgpu_cac_tdp_table {
-	u16 tdp;
-	u16 configurable_tdp;
-	u16 tdc;
-	u16 battery_power_limit;
-	u16 small_power_limit;
-	u16 low_cac_leakage;
-	u16 high_cac_leakage;
-	u16 maximum_power_delivery_limit;
-};
-
-struct amdgpu_dpm_dynamic_state {
-	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_sclk;
-	struct amdgpu_clock_voltage_dependency_table vddci_dependency_on_mclk;
-	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_mclk;
-	struct amdgpu_clock_voltage_dependency_table mvdd_dependency_on_mclk;
-	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_dispclk;
-	struct amdgpu_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table;
-	struct amdgpu_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table;
-	struct amdgpu_clock_voltage_dependency_table samu_clock_voltage_dependency_table;
-	struct amdgpu_clock_voltage_dependency_table acp_clock_voltage_dependency_table;
-	struct amdgpu_clock_voltage_dependency_table vddgfx_dependency_on_sclk;
-	struct amdgpu_clock_array valid_sclk_values;
-	struct amdgpu_clock_array valid_mclk_values;
-	struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_dc;
-	struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_ac;
-	u32 mclk_sclk_ratio;
-	u32 sclk_mclk_delta;
-	u16 vddc_vddci_delta;
-	u16 min_vddc_for_pcie_gen2;
-	struct amdgpu_cac_leakage_table cac_leakage_table;
-	struct amdgpu_phase_shedding_limits_table phase_shedding_limits_table;
-	struct amdgpu_ppm_table *ppm_table;
-	struct amdgpu_cac_tdp_table *cac_tdp_table;
-};
-
-struct amdgpu_dpm_fan {
-	u16 t_min;
-	u16 t_med;
-	u16 t_high;
-	u16 pwm_min;
-	u16 pwm_med;
-	u16 pwm_high;
-	u8 t_hyst;
-	u32 cycle_delay;
-	u16 t_max;
-	u8 control_mode;
-	u16 default_max_fan_pwm;
-	u16 default_fan_output_sensitivity;
-	u16 fan_output_sensitivity;
-	bool ucode_fan_control;
-};
-
-enum amdgpu_pcie_gen {
-	AMDGPU_PCIE_GEN1 = 0,
-	AMDGPU_PCIE_GEN2 = 1,
-	AMDGPU_PCIE_GEN3 = 2,
-	AMDGPU_PCIE_GEN_INVALID = 0xffff
-};
-
-enum amdgpu_dpm_forced_level {
-	AMDGPU_DPM_FORCED_LEVEL_AUTO = 0,
-	AMDGPU_DPM_FORCED_LEVEL_LOW = 1,
-	AMDGPU_DPM_FORCED_LEVEL_HIGH = 2,
-	AMDGPU_DPM_FORCED_LEVEL_MANUAL = 3,
-};
-
-struct amdgpu_vce_state {
-	/* vce clocks */
-	u32 evclk;
-	u32 ecclk;
-	/* gpu clocks */
-	u32 sclk;
-	u32 mclk;
-	u8 clk_idx;
-	u8 pstate;
-};
-
-struct amdgpu_dpm_funcs {
-	int (*get_temperature)(struct amdgpu_device *adev);
-	int (*pre_set_power_state)(struct amdgpu_device *adev);
-	int (*set_power_state)(struct amdgpu_device *adev);
-	void (*post_set_power_state)(struct amdgpu_device *adev);
-	void (*display_configuration_changed)(struct amdgpu_device *adev);
-	u32 (*get_sclk)(struct amdgpu_device *adev, bool low);
-	u32 (*get_mclk)(struct amdgpu_device *adev, bool low);
-	void (*print_power_state)(struct amdgpu_device *adev, struct amdgpu_ps *ps);
-	void (*debugfs_print_current_performance_level)(struct amdgpu_device *adev, struct seq_file *m);
-	int (*force_performance_level)(struct amdgpu_device *adev, enum amdgpu_dpm_forced_level level);
-	bool (*vblank_too_short)(struct amdgpu_device *adev);
-	void (*powergate_uvd)(struct amdgpu_device *adev, bool gate);
-	void (*powergate_vce)(struct amdgpu_device *adev, bool gate);
-	void (*enable_bapm)(struct amdgpu_device *adev, bool enable);
-	void (*set_fan_control_mode)(struct amdgpu_device *adev, u32 mode);
-	u32 (*get_fan_control_mode)(struct amdgpu_device *adev);
-	int (*set_fan_speed_percent)(struct amdgpu_device *adev, u32 speed);
-	int (*get_fan_speed_percent)(struct amdgpu_device *adev, u32 *speed);
-	int (*force_clock_level)(struct amdgpu_device *adev, enum pp_clock_type type, uint32_t mask);
-	int (*print_clock_levels)(struct amdgpu_device *adev, enum pp_clock_type type, char *buf);
-	int (*get_sclk_od)(struct amdgpu_device *adev);
-	int (*set_sclk_od)(struct amdgpu_device *adev, uint32_t value);
-	int (*get_mclk_od)(struct amdgpu_device *adev);
-	int (*set_mclk_od)(struct amdgpu_device *adev, uint32_t value);
-};
-
-struct amdgpu_dpm {
-	struct amdgpu_ps        *ps;
-	/* number of valid power states */
-	int                     num_ps;
-	/* current power state that is active */
-	struct amdgpu_ps        *current_ps;
-	/* requested power state */
-	struct amdgpu_ps        *requested_ps;
-	/* boot up power state */
-	struct amdgpu_ps        *boot_ps;
-	/* default uvd power state */
-	struct amdgpu_ps        *uvd_ps;
-	/* vce requirements */
-	struct amdgpu_vce_state vce_states[AMDGPU_MAX_VCE_LEVELS];
-	enum amdgpu_vce_level vce_level;
-	enum amd_pm_state_type state;
-	enum amd_pm_state_type user_state;
-	u32                     platform_caps;
-	u32                     voltage_response_time;
-	u32                     backbias_response_time;
-	void                    *priv;
-	u32			new_active_crtcs;
-	int			new_active_crtc_count;
-	u32			current_active_crtcs;
-	int			current_active_crtc_count;
-	struct amdgpu_dpm_dynamic_state dyn_state;
-	struct amdgpu_dpm_fan fan;
-	u32 tdp_limit;
-	u32 near_tdp_limit;
-	u32 near_tdp_limit_adjusted;
-	u32 sq_ramping_threshold;
-	u32 cac_leakage;
-	u16 tdp_od_limit;
-	u32 tdp_adjustment;
-	u16 load_line_slope;
-	bool power_control;
-	bool ac_power;
-	/* special states active */
-	bool                    thermal_active;
-	bool                    uvd_active;
-	bool                    vce_active;
-	/* thermal handling */
-	struct amdgpu_dpm_thermal thermal;
-	/* forced levels */
-	enum amdgpu_dpm_forced_level forced_level;
-};
-
-struct amdgpu_pm {
-	struct mutex		mutex;
-	u32                     current_sclk;
-	u32                     current_mclk;
-	u32                     default_sclk;
-	u32                     default_mclk;
-	struct amdgpu_i2c_chan *i2c_bus;
-	/* internal thermal controller on rv6xx+ */
-	enum amdgpu_int_thermal_type int_thermal_type;
-	struct device	        *int_hwmon_dev;
-	/* fan control parameters */
-	bool                    no_fan;
-	u8                      fan_pulses_per_revolution;
-	u8                      fan_min_rpm;
-	u8                      fan_max_rpm;
-	/* dpm */
-	bool                    dpm_enabled;
-	bool                    sysfs_initialized;
-	struct amdgpu_dpm       dpm;
-	const struct firmware	*fw;	/* SMC firmware */
-	uint32_t                fw_version;
-	const struct amdgpu_dpm_funcs *funcs;
-	uint32_t                pcie_gen_mask;
-	uint32_t                pcie_mlw_mask;
-	struct amd_pp_display_configuration pm_display_cfg;/* set by DAL */
-};
-
 void amdgpu_get_pcie_info(struct amdgpu_device *adev);
 
 /*
@@ -1973,108 +1626,8 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 #define amdgpu_display_resume_mc_access(adev, s) (adev)->mode_info.funcs->resume_mc_access((adev), (s))
 #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib),  (s), (d), (b))
 #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b))
-#define amdgpu_dpm_pre_set_power_state(adev) (adev)->pm.funcs->pre_set_power_state((adev))
-#define amdgpu_dpm_set_power_state(adev) (adev)->pm.funcs->set_power_state((adev))
-#define amdgpu_dpm_post_set_power_state(adev) (adev)->pm.funcs->post_set_power_state((adev))
-#define amdgpu_dpm_display_configuration_changed(adev) (adev)->pm.funcs->display_configuration_changed((adev))
-#define amdgpu_dpm_print_power_state(adev, ps) (adev)->pm.funcs->print_power_state((adev), (ps))
-#define amdgpu_dpm_vblank_too_short(adev) (adev)->pm.funcs->vblank_too_short((adev))
-#define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e))
 #define amdgpu_gfx_get_gpu_clock_counter(adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev))
 #define amdgpu_gfx_select_se_sh(adev, se, sh, instance) (adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance))
-
-#define amdgpu_dpm_read_sensor(adev, idx, value) \
-	((adev)->pp_enabled ? \
-		(adev)->powerplay.pp_funcs->read_sensor(adev->powerplay.pp_handle, (idx), (value)) : \
-		-EINVAL)
-
-#define amdgpu_dpm_get_temperature(adev) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \
-	      (adev)->pm.funcs->get_temperature((adev)))
-
-#define amdgpu_dpm_set_fan_control_mode(adev, m) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \
-	      (adev)->pm.funcs->set_fan_control_mode((adev), (m)))
-
-#define amdgpu_dpm_get_fan_control_mode(adev) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \
-	      (adev)->pm.funcs->get_fan_control_mode((adev)))
-
-#define amdgpu_dpm_set_fan_speed_percent(adev, s) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
-	      (adev)->pm.funcs->set_fan_speed_percent((adev), (s)))
-
-#define amdgpu_dpm_get_fan_speed_percent(adev, s) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
-	      (adev)->pm.funcs->get_fan_speed_percent((adev), (s)))
-
-#define amdgpu_dpm_get_sclk(adev, l) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \
-		(adev)->pm.funcs->get_sclk((adev), (l)))
-
-#define amdgpu_dpm_get_mclk(adev, l)  \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \
-	      (adev)->pm.funcs->get_mclk((adev), (l)))
-
-
-#define amdgpu_dpm_force_performance_level(adev, l) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \
-	      (adev)->pm.funcs->force_performance_level((adev), (l)))
-
-#define amdgpu_dpm_powergate_uvd(adev, g) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \
-	      (adev)->pm.funcs->powergate_uvd((adev), (g)))
-
-#define amdgpu_dpm_powergate_vce(adev, g) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \
-	      (adev)->pm.funcs->powergate_vce((adev), (g)))
-
-#define amdgpu_dpm_get_current_power_state(adev) \
-	(adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle)
-
-#define amdgpu_dpm_get_performance_level(adev) \
-	(adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle)
-
-#define amdgpu_dpm_get_pp_num_states(adev, data) \
-	(adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data)
-
-#define amdgpu_dpm_get_pp_table(adev, table) \
-	(adev)->powerplay.pp_funcs->get_pp_table((adev)->powerplay.pp_handle, table)
-
-#define amdgpu_dpm_set_pp_table(adev, buf, size) \
-	(adev)->powerplay.pp_funcs->set_pp_table((adev)->powerplay.pp_handle, buf, size)
-
-#define amdgpu_dpm_print_clock_levels(adev, type, buf) \
-	(adev)->powerplay.pp_funcs->print_clock_levels((adev)->powerplay.pp_handle, type, buf)
-
-#define amdgpu_dpm_force_clock_level(adev, type, level) \
-		(adev)->powerplay.pp_funcs->force_clock_level((adev)->powerplay.pp_handle, type, level)
-
-#define amdgpu_dpm_get_sclk_od(adev) \
-	(adev)->powerplay.pp_funcs->get_sclk_od((adev)->powerplay.pp_handle)
-
-#define amdgpu_dpm_set_sclk_od(adev, value) \
-	(adev)->powerplay.pp_funcs->set_sclk_od((adev)->powerplay.pp_handle, value)
-
-#define amdgpu_dpm_get_mclk_od(adev) \
-	((adev)->powerplay.pp_funcs->get_mclk_od((adev)->powerplay.pp_handle))
-
-#define amdgpu_dpm_set_mclk_od(adev, value) \
-	((adev)->powerplay.pp_funcs->set_mclk_od((adev)->powerplay.pp_handle, value))
-
-#define amdgpu_dpm_dispatch_task(adev, event_id, input, output)		\
-	(adev)->powerplay.pp_funcs->dispatch_tasks((adev)->powerplay.pp_handle, (event_id), (input), (output))
-
 #define amdgpu_gds_switch(adev, r, v, d, w, a) (adev)->gds.funcs->patch_gds_switch((r), (v), (d), (w), (a))
 
 /* Common functions */
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +447 -0

453 lines not on this page · raw message

Signature · 6 lines
2.5.5

_______________________________________________
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): 1475864905-21269-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/6 drm/amdgpu: add info ioctl query for vce clock info

This is needed to set up the vce clock table in userspace for proper VCE DPM.

---
 include/uapi/drm/amdgpu_drm.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/uapi/drm/amdgpu_drm.h +18 -0
index b6a04d4..7cb71f8 100644
@@ -491,6 +491,8 @@ struct drm_amdgpu_cs_chunk_data {
 #define AMDGPU_INFO_NUM_EVICTIONS		0x18
 /* Query memory about VRAM and GTT domains */
 #define AMDGPU_INFO_MEMORY			0x19
+/* Query memory about VRAM and GTT domains */
+#define AMDGPU_INFO_VCE_CLOCK_TABLE		0x1A
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT	0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK	0xff
@@ -677,6 +679,22 @@ struct drm_amdgpu_info_hw_ip {
 	__u32  _pad;
 };
 
+#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES		6
+
+struct drm_amdgpu_info_vce_clock_table_entry {
+	/** System clock */
+	__u32 sclk;
+	/** Memory clock */
+	__u32 mclk;
+	/** VCE clock */
+	__u32 eclk;
+	__u32 pad;
+};
+
+struct drm_amdgpu_info_vce_clock_table {
+	struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
+};
+
 /*
  * Supported GPU families
  */
Signature · 6 lines
2.5.5

_______________________________________________
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): 1475864905-21269-2-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/6] drm/amdgpu: add info ioctl query for vce clock info

Shouldn't there be a version bump if you're adding a new command to the ioctl?

Tom

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Alex Deucher <[email protected]>
Sent: Friday, October 7, 2016 14:28
To: [email protected]; Fang, Peter; Zhang, Boyuan
Cc: Deucher, Alexander
Subject: [PATCH 2/6] drm/amdgpu: add info ioctl query for vce clock info

This is needed to set up the vce clock table in userspace for proper VCE DPM.

---
 include/uapi/drm/amdgpu_drm.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/uapi/drm/amdgpu_drm.h +18 -0
index b6a04d4..7cb71f8 100644
@@ -491,6 +491,8 @@ struct drm_amdgpu_cs_chunk_data {
 #define AMDGPU_INFO_NUM_EVICTIONS               0x18
 /* Query memory about VRAM and GTT domains */
 #define AMDGPU_INFO_MEMORY                      0x19
+/* Query memory about VRAM and GTT domains */
+#define AMDGPU_INFO_VCE_CLOCK_TABLE            0x1A
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT  0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK   0xff
@@ -677,6 +679,22 @@ struct drm_amdgpu_info_hw_ip {
         __u32  _pad;
 };
 
+#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES         6
+
+struct drm_amdgpu_info_vce_clock_table_entry {
+       /** System clock */
+       __u32 sclk;
+       /** Memory clock */
+       __u32 mclk;
+       /** VCE clock */
+       __u32 eclk;
+       __u32 pad;
+};
+
+struct drm_amdgpu_info_vce_clock_table {
+       struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
+};
+
 /*
  * Supported GPU families
  */

--
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - lists.freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives. Using amd-gfx: To post a message to all the list members, send email ...

_______________________________________________
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): BN6PR12MB1764E581BC7A01B74C850D83F7C60-/b2+HYfkarS51p+Siuid1wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#6 lore raw

Re: [PATCH 2/6] drm/amdgpu: add info ioctl query for vce clock info

No, you can just check if it fails or not (i.e., the ioctl will return -EINVAL if the query is not supported).

Alex

Quoted 63 lines · Tom

Shouldn't there be a version bump if you're adding a new command to the ioctl?

Tom

------------------------------
*From:* amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Alex Deucher <[email protected]>
*Sent:* Friday, October 7, 2016 14:28
*To:* [email protected]; Fang, Peter; Zhang, Boyuan *Cc:* Deucher, Alexander
*Subject:* [PATCH 2/6] drm/amdgpu: add info ioctl query for vce clock info

This is needed to set up the vce clock table in userspace for proper VCE DPM.

---
 include/uapi/drm/amdgpu_drm.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/uapi/drm/amdgpu_drm.h +18 -0
index b6a04d4..7cb71f8 100644
@@ -491,6 +491,8 @@ struct drm_amdgpu_cs_chunk_data {
 #define AMDGPU_INFO_NUM_EVICTIONS               0x18
 /* Query memory about VRAM and GTT domains */
 #define AMDGPU_INFO_MEMORY                      0x19
+/* Query memory about VRAM and GTT domains */
+#define AMDGPU_INFO_VCE_CLOCK_TABLE            0x1A
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT  0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK   0xff
@@ -677,6 +679,22 @@ struct drm_amdgpu_info_hw_ip {
         __u32  _pad;
 };
 
+#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES         6
+
+struct drm_amdgpu_info_vce_clock_table_entry {
+       /** System clock */
+       __u32 sclk;
+       /** Memory clock */
+       __u32 mclk;
+       /** VCE clock */
+       __u32 eclk;
+       __u32 pad;
+};
+
+struct drm_amdgpu_info_vce_clock_table {
+       struct drm_amdgpu_info_vce_clock_table_entry
 entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
+};
+
 /*
  * Supported GPU families

*/
--
2.5.5

Quoted 13 lines

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - lists.freedesktop.org
<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives. Using amd-gfx: To post a message to all the list members, send email ...

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

#7 lore raw

PATCH 3/6 drm/amdgpu/dpm: add new callback to fetch vce clock table

In reply to a message not in the archive

Will be used by the new info ioctl query.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h           | 5 +++++
 drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h | 1 +
 2 files changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +5 -0
index d06496d..b0c800d 100644
@@ -293,6 +293,7 @@ struct amdgpu_dpm_funcs {
 	int (*set_sclk_od)(struct amdgpu_device *adev, uint32_t value);
 	int (*get_mclk_od)(struct amdgpu_device *adev);
 	int (*set_mclk_od)(struct amdgpu_device *adev, uint32_t value);
+	struct drm_amdgpu_info_vce_clock_table (*get_vce_clock_table)(struct amdgpu_device *adev);
 };
 
 #define amdgpu_dpm_pre_set_power_state(adev) (adev)->pm.funcs->pre_set_power_state((adev))
@@ -395,6 +396,10 @@ struct amdgpu_dpm_funcs {
 #define amdgpu_dpm_dispatch_task(adev, event_id, input, output)		\
 	(adev)->powerplay.pp_funcs->dispatch_tasks((adev)->powerplay.pp_handle, (event_id), (input), (output))
 
+#define amdgpu_dpm_get_vce_clock_table(adev)  \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->get_vce_clock_table((adev)->powerplay.pp_handle) : \
+	      (adev)->pm.funcs->get_vce_clock_table((adev)))
 
 struct amdgpu_dpm {
 	struct amdgpu_ps        *ps;
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +1 -0
index 3fb5e57..057d3ca 100644
@@ -359,6 +359,7 @@ struct amd_powerplay_funcs {
 	int (*get_mclk_od)(void *handle);
 	int (*set_mclk_od)(void *handle, uint32_t value);
 	int (*read_sensor)(void *handle, int idx, int32_t *value);
+	struct drm_amdgpu_info_vce_clock_table (*get_vce_clock_table)(void *handle);
 };
 
 struct amd_powerplay {
Signature · 6 lines
2.5.5

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

PATCH 4/6 drm/amdgpu/dpm: add an implementation for get_vce_clock_table

In reply to a message not in the archive

Used by the non-powerplay dpm code.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c | 16 ++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h |  3 +++
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c     |  1 +
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c     |  1 +
 drivers/gpu/drm/amd/amdgpu/si_dpm.c     |  1 +
 5 files changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +16 -0
index fe36caf..a0ffd9b 100644
@@ -953,3 +953,19 @@ u8 amdgpu_encode_pci_lane_width(u32 lanes)
 
 	return encoded_lanes[lanes];
 }
+
+struct drm_amdgpu_info_vce_clock_table
+amdgpu_get_vce_clock_table(struct amdgpu_device *adev)
+{
+	struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};
+	unsigned i;
+
+	/* fill in the vce power states */
+	for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {
+		vce_clk_table.entries[i].sclk = adev->pm.dpm.vce_states[i].sclk;
+		vce_clk_table.entries[i].mclk = adev->pm.dpm.vce_states[i].mclk;
+		vce_clk_table.entries[i].eclk = adev->pm.dpm.vce_states[i].evclk;
+	}
+
+	return vce_clk_table;
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +3 -0
index b0c800d..933e58e 100644
@@ -534,4 +534,7 @@ u16 amdgpu_get_pcie_lane_support(struct amdgpu_device *adev,
 				 u16 default_lanes);
 u8 amdgpu_encode_pci_lane_width(u32 lanes);
 
+struct drm_amdgpu_info_vce_clock_table
+amdgpu_get_vce_clock_table(struct amdgpu_device *adev);
+
 #endif
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +1 -0
index 1d8c375..b5030d3 100644
@@ -6644,6 +6644,7 @@ static const struct amdgpu_dpm_funcs ci_dpm_funcs = {
 	.set_sclk_od = ci_dpm_set_sclk_od,
 	.get_mclk_od = ci_dpm_get_mclk_od,
 	.set_mclk_od = ci_dpm_set_mclk_od,
+	.get_vce_clock_table = amdgpu_get_vce_clock_table,
 };
 
 static void ci_dpm_set_dpm_funcs(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/kv_dpm.c +1 -0
index f8618a3..c4e869d 100644
@@ -3273,6 +3273,7 @@ static const struct amdgpu_dpm_funcs kv_dpm_funcs = {
 	.force_performance_level = &kv_dpm_force_performance_level,
 	.powergate_uvd = &kv_dpm_powergate_uvd,
 	.enable_bapm = &kv_dpm_enable_bapm,
+	.get_vce_clock_table = amdgpu_get_vce_clock_table,
 };
 
 static void kv_dpm_set_dpm_funcs(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/si_dpm.c +1 -0
index 8bd0892..e683980 100644
@@ -7985,6 +7985,7 @@ static const struct amdgpu_dpm_funcs si_dpm_funcs = {
 	.get_fan_control_mode = &si_dpm_get_fan_control_mode,
 	.set_fan_speed_percent = &si_dpm_set_fan_speed_percent,
 	.get_fan_speed_percent = &si_dpm_get_fan_speed_percent,
+	.get_vce_clock_table = amdgpu_get_vce_clock_table,
 };
 
 static void si_dpm_set_dpm_funcs(struct amdgpu_device *adev)
Signature · 6 lines
2.5.5

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

PATCH 5/6 drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

In reply to a message not in the archive

Used by the powerplay dpm code.

---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +24 -0
index bb8a345..8eee390 100644
@@ -30,6 +30,7 @@
 #include "power_state.h"
 #include "eventmanager.h"
 #include "pp_debug.h"
+#include "drm/amdgpu_drm.h"
 
 
 #define PP_CHECK(handle)						\
@@ -821,6 +822,28 @@ static int pp_dpm_read_sensor(void *handle, int idx, int32_t *value)
 	return hwmgr->hwmgr_func->read_sensor(hwmgr, idx, value);
 }
 
+static struct drm_amdgpu_info_vce_clock_table
+pp_dpm_get_vce_clock_table(void *handle)
+{
+	struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};
+	struct pp_hwmgr *hwmgr;
+	unsigned i;
+
+	if (handle) {
+		hwmgr = ((struct pp_instance *)handle)->hwmgr;
+
+		if (hwmgr) {
+			for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {
+				vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+				vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+				vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;
+			}
+		}
+	}
+
+	return vce_clk_table;
+}
+
 const struct amd_powerplay_funcs pp_dpm_funcs = {
 	.get_temperature = pp_dpm_get_temperature,
 	.load_firmware = pp_dpm_load_fw,
@@ -847,6 +870,7 @@ const struct amd_powerplay_funcs pp_dpm_funcs = {
 	.get_mclk_od = pp_dpm_get_mclk_od,
 	.set_mclk_od = pp_dpm_set_mclk_od,
 	.read_sensor = pp_dpm_read_sensor,
+	.get_vce_clock_table = pp_dpm_get_vce_clock_table,
 };
 
 static int amd_pp_instance_init(struct amd_pp_init *pp_init,
Signature · 6 lines
2.5.5

_______________________________________________
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): 1475864905-21269-5-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#11 lore raw

Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Rex what is your opinion on exposing the amdgpu drm structure through to powerplay? We could do an intermediate interface, but that just seems like extra hoops to jump through for pretty questionable gain.

Alex

Quoted 57 lines · Alex Deucher

Used by the powerplay dpm code.

---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +24 -1
index bb8a345..8eee390 100644
@@ -30,6 +30,7 @@
 #include "power_state.h"
 #include "eventmanager.h"
 #include "pp_debug.h"
+#include "drm/amdgpu_drm.h"
 
 
 #define PP_CHECK(handle)                                               \
@@ -821,6 +822,28 @@ static int pp_dpm_read_sensor(void *handle, int idx, int32_t *value)
        return hwmgr->hwmgr_func->read_sensor(hwmgr, idx, value);
 }
 
+static struct drm_amdgpu_info_vce_clock_table
+pp_dpm_get_vce_clock_table(void *handle)
+{
+       struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};
+       struct pp_hwmgr *hwmgr;
+       unsigned i;
+
+       if (handle) {
+               hwmgr = ((struct pp_instance *)handle)->hwmgr;
+
+               if (hwmgr) {
+                       for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {
+                               vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+                               vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+                               vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;
+                       }
+               }
+       }
+
+       return vce_clk_table;
+}
+
 const struct amd_powerplay_funcs pp_dpm_funcs = {
        .get_temperature = pp_dpm_get_temperature,
        .load_firmware = pp_dpm_load_fw,
@@ -847,6 +870,7 @@ const struct amd_powerplay_funcs pp_dpm_funcs = {
        .get_mclk_od = pp_dpm_get_mclk_od,
        .set_mclk_od = pp_dpm_set_mclk_od,
        .read_sensor = pp_dpm_read_sensor,
+       .get_vce_clock_table = pp_dpm_get_vce_clock_table,
 };
 
 static int amd_pp_instance_init(struct amd_pp_init *pp_init,
--
Quoted 2 lines

2.5.5

_______________________________________________
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): CADnq5_MFT8M8VRu17gOcZjjRCK9Z-c3mG7=V46BQhYZXMKMetA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#13 lore raw

RE: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Hi Alex,

In Patch1, I moved struct amdgpu_vce_states to amd_shared.h from amdgpu.h. So in powerplay, we used same vce state definition.

So the define of static struct drm_amdgpu_info_vce_clock_table pp_dpm_get_vce_clock_table(void *handle) Can change to
static struct amd_vce_state pp_dpm_get_vce_clock_table(void *handle, int num);

and can move those codes to Patch6.

Review

Quoted 3 lines
(quoted diff) +3 -0
+                               vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+                               vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+                               vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;

So in powerplay and dpm, we don't need to visit struct drm_amdgpu_info_vce_clock_table.

In Patch2, add numer of vce_states in struct dpm. If it is useful to UMD driver. We can notify UMD by add a member in struct drm_amdgpu_info_vce_clock_table.

Best Regards
Rex

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Wednesday, October 12, 2016 4:07 AM
To: amd-gfx list; Fang, Peter; Zhang, Boyuan; Zhu, Rex
Cc: Deucher, Alexander
Subject: Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Rex what is your opinion on exposing the amdgpu drm structure through to powerplay? We could do an intermediate interface, but that just seems like extra hoops to jump through for pretty questionable gain.

Alex

Quoted 57 lines · Alex Deucher

Used by the powerplay dpm code.

---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 24 
++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +23 -1
index bb8a345..8eee390 100644
@@ -30,6 +30,7 @@
 #include "power_state.h"
 #include "eventmanager.h"
 #include "pp_debug.h"
+#include "drm/amdgpu_drm.h"
 
 
 #define PP_CHECK(handle)                                               \
@@ -821,6 +822,28 @@ static int pp_dpm_read_sensor(void *handle, int idx, int32_t *value)
        return hwmgr->hwmgr_func->read_sensor(hwmgr, idx, value);  }
 
+static struct drm_amdgpu_info_vce_clock_table 
+pp_dpm_get_vce_clock_table(void *handle) {
+       struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};
+       struct pp_hwmgr *hwmgr;
+       unsigned i;
+
+       if (handle) {
+               hwmgr = ((struct pp_instance *)handle)->hwmgr;
+
+               if (hwmgr) {
+                       for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {
+                               vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+                               vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+                               vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;
+                       }
+               }
+       }
+
+       return vce_clk_table;
+}
+
 const struct amd_powerplay_funcs pp_dpm_funcs = {
        .get_temperature = pp_dpm_get_temperature,
        .load_firmware = pp_dpm_load_fw, @@ -847,6 +870,7 @@ const 
 struct amd_powerplay_funcs pp_dpm_funcs = {
        .get_mclk_od = pp_dpm_get_mclk_od,
        .set_mclk_od = pp_dpm_set_mclk_od,
        .read_sensor = pp_dpm_read_sensor,
+       .get_vce_clock_table = pp_dpm_get_vce_clock_table,
 };
 
 static int amd_pp_instance_init(struct amd_pp_init *pp_init,
--
Quoted 2 lines

2.5.5

From 534ca4d6789f3554e9b28038d2f7eae4e6d4e092 Mon Sep 17 00:00:00 2001
From: Rex Zhu <[email protected]>
Date: Wed, 12 Oct 2016 15:13:29 +0800
Subject: [PATCH 1/2] drm/amdgpu: use same vce state definition in dpm and
powerplay

Change-Id: I2f183f51df21407b7007366590bc692ca7ae8ca0

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h                | 28 +++-------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c            |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c             |  2 +-
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c                |  2 +-
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c                |  2 +-
 drivers/gpu/drm/amd/amdgpu/si_dpm.c                |  2 +-
 drivers/gpu/drm/amd/include/amd_shared.h           | 23 ++++++++++++++++++
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      |  3 ++-
 .../amd/powerplay/hwmgr/process_pptables_v1_0.c    |  4 ++--
 .../gpu/drm/amd/powerplay/hwmgr/processpptables.c  |  2 +-
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          | 16 ++-----------
 drivers/gpu/drm/amd/powerplay/inc/power_state.h    |  9 -------
 12 files changed, 38 insertions(+), 57 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -25
index 4cfd55c..2a414c8 100644
@@ -994,17 +994,6 @@ enum amdgpu_dpm_event_src {
 	AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4
 };
 
-#define AMDGPU_MAX_VCE_LEVELS 6
-
-enum amdgpu_vce_level {
-	AMDGPU_VCE_LEVEL_AC_ALL = 0,     /* AC, All cases */
-	AMDGPU_VCE_LEVEL_DC_EE = 1,      /* DC, entropy encoding */
-	AMDGPU_VCE_LEVEL_DC_LL_LOW = 2,  /* DC, low latency queue, res <= 720 */
-	AMDGPU_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
-	AMDGPU_VCE_LEVEL_DC_GP_LOW = 4,  /* DC, general purpose queue, res <= 720 */
-	AMDGPU_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
-};
-
 struct amdgpu_ps {
 	u32 caps; /* vbios flags */
 	u32 class; /* vbios flags */
@@ -1016,7 +1005,7 @@ struct amdgpu_ps {
 	u32 evclk;
 	u32 ecclk;
 	bool vce_active;
-	enum amdgpu_vce_level vce_level;
+	enum amd_vce_level vce_level;
 	/* asic priv */
 	void *ps_priv;
 };
@@ -1199,17 +1188,6 @@ enum amdgpu_dpm_forced_level {
 	AMDGPU_DPM_FORCED_LEVEL_MANUAL = 3,
 };
 
-struct amdgpu_vce_state {
-	/* vce clocks */
-	u32 evclk;
-	u32 ecclk;
-	/* gpu clocks */
-	u32 sclk;
-	u32 mclk;
-	u8 clk_idx;
-	u8 pstate;
-};
-
 struct amdgpu_dpm_funcs {
 	int (*get_temperature)(struct amdgpu_device *adev);
 	int (*pre_set_power_state)(struct amdgpu_device *adev);
@@ -1250,8 +1228,8 @@ struct amdgpu_dpm {
 	/* default uvd power state */
 	struct amdgpu_ps        *uvd_ps;
 	/* vce requirements */
-	struct amdgpu_vce_state vce_states[AMDGPU_MAX_VCE_LEVELS];
-	enum amdgpu_vce_level vce_level;
+	struct amd_vce_state vce_states[AMD_MAX_VCE_LEVELS];
+	enum amd_vce_level vce_level;
 	enum amd_pm_state_type state;
 	enum amd_pm_state_type user_state;
 	u32                     platform_caps;
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +1 -1
index 14f57d9..4f8d3a5 100644
@@ -554,7 +554,7 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev)
 					((u8 *)entry + sizeof(ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record));
 			}
 			for (i = 0; i < states->numEntries; i++) {
-				if (i >= AMDGPU_MAX_VCE_LEVELS)
+				if (i >= AMD_MAX_VCE_LEVELS)
 					break;
 				vce_clk = (VCEClockInfo *)
 					((u8 *)&array->entries[0] +
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -1
index 5307107..d253b01 100644
@@ -1134,7 +1134,7 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
 			mutex_lock(&adev->pm.mutex);
 			adev->pm.dpm.vce_active = true;
 			/* XXX select vce level based on ring/task */
-			adev->pm.dpm.vce_level = AMDGPU_VCE_LEVEL_AC_ALL;
+			adev->pm.dpm.vce_level = AMD_VCE_LEVEL_AC_ALL;
 			mutex_unlock(&adev->pm.mutex);
 		} else {
 			mutex_lock(&adev->pm.mutex);
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +1 -1
index 1d8c375..dc3196e 100644
@@ -5689,7 +5689,7 @@ static int ci_parse_power_table(struct amdgpu_device *adev)
 	adev->pm.dpm.num_ps = state_array->ucNumEntries;
 
 	/* fill in the vce power states */
-	for (i = 0; i < AMDGPU_MAX_VCE_LEVELS; i++) {
+	for (i = 0; i < AMD_MAX_VCE_LEVELS; i++) {
 		u32 sclk, mclk;
 		clock_array_index = adev->pm.dpm.vce_states[i].clk_idx;
 		clock_info = (union pplib_clock_info *)
drivers/gpu/drm/amd/amdgpu/kv_dpm.c +1 -1
index f8618a3..a03690a 100644
@@ -2796,7 +2796,7 @@ static int kv_parse_power_table(struct amdgpu_device *adev)
 	adev->pm.dpm.num_ps = state_array->ucNumEntries;
 
 	/* fill in the vce power states */
-	for (i = 0; i < AMDGPU_MAX_VCE_LEVELS; i++) {
+	for (i = 0; i < AMD_MAX_VCE_LEVELS; i++) {
 		u32 sclk;
 		clock_array_index = adev->pm.dpm.vce_states[i].clk_idx;
 		clock_info = (union pplib_clock_info *)
drivers/gpu/drm/amd/amdgpu/si_dpm.c +1 -1
index 8bd0892..1a909fa 100644
@@ -7314,7 +7314,7 @@ static int si_parse_power_table(struct amdgpu_device *adev)
 	adev->pm.dpm.num_ps = state_array->ucNumEntries;
 
 	/* fill in the vce power states */
-	for (i = 0; i < AMDGPU_MAX_VCE_LEVELS; i++) {
+	for (i = 0; i < AMD_MAX_VCE_LEVELS; i++) {
 		u32 sclk, mclk;
 		clock_array_index = adev->pm.dpm.vce_states[i].clk_idx;
 		clock_info = (union pplib_clock_info *)
drivers/gpu/drm/amd/include/amd_shared.h +23 -0
index c934b78c..94ebc32 100644
@@ -84,6 +84,29 @@ enum amd_powergating_state {
 	AMD_PG_STATE_UNGATE,
 };
 
+struct amd_vce_state {
+	/* vce clocks */
+	u32 evclk;
+	u32 ecclk;
+	/* gpu clocks */
+	u32 sclk;
+	u32 mclk;
+	u8 clk_idx;
+	u8 pstate;
+};
+
+
+#define AMD_MAX_VCE_LEVELS 6
+
+enum amd_vce_level {
+	AMD_VCE_LEVEL_AC_ALL = 0,     /* AC, All cases */
+	AMD_VCE_LEVEL_DC_EE = 1,      /* DC, entropy encoding */
+	AMD_VCE_LEVEL_DC_LL_LOW = 2,  /* DC, low latency queue, res <= 720 */
+	AMD_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
+	AMD_VCE_LEVEL_DC_GP_LOW = 4,  /* DC, general purpose queue, res <= 720 */
+	AMD_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
+};
+
 /* CG flags */
 #define AMD_CG_SUPPORT_GFX_MGCG			(1 << 0)
 #define AMD_CG_SUPPORT_GFX_MGLS			(1 << 1)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +2 -1
index bb8a345..29af13a 100644
@@ -20,6 +20,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/gfp.h>
@@ -30,7 +31,7 @@
 #include "power_state.h"
 #include "eventmanager.h"
 #include "pp_debug.h"
-
+#include "drm/amdgpu_drm.h"
 
 #define PP_CHECK(handle)						\
 	do {								\
drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c +2 -2
index 19361ad..b0b5f3a 100644
@@ -1212,7 +1212,7 @@ static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr)
 }
 
 static int ppt_get_vce_state_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t i,
-		struct pp_vce_state *vce_state, void **clock_info, uint32_t *flag)
+		struct amd_vce_state *vce_state, void **clock_info, uint32_t *flag)
 {
 	const ATOM_Tonga_VCE_State_Record *vce_state_record;
 	ATOM_Tonga_SCLK_Dependency_Record *sclk_dep_record;
@@ -1316,7 +1316,7 @@ int get_powerplay_table_entry_v1_0(struct pp_hwmgr *hwmgr,
 
 	hwmgr->num_vce_state_tables = i = ppt_get_num_of_vce_state_table_entries_v1_0(hwmgr);
 
-	if ((i != 0) && (i <= PP_MAX_VCE_LEVELS)) {
+	if ((i != 0) && (i <= AMD_MAX_VCE_LEVELS)) {
 		for (j = 0; j < i; j++)
 			ppt_get_vce_state_table_entry_v1_0(hwmgr, j, &(hwmgr->vce_states[j]), NULL, &flags);
 	}
drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c +1 -1
index bd1f190..a4e9cf4 100644
@@ -1523,7 +1523,7 @@ static int get_number_of_vce_state_table_entries(
 
 static int get_vce_state_table_entry(struct pp_hwmgr *hwmgr,
 							unsigned long i,
-							struct pp_vce_state *vce_state,
+							struct amd_vce_state *vce_state,
 							void **clock_info,
 							unsigned long *flag)
 {
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +2 -14
index 4f0fedd..e38b999 100644
@@ -367,7 +367,7 @@ struct pp_table_func {
 	int (*pptable_get_vce_state_table_entry)(
 						struct pp_hwmgr *hwmgr,
 						unsigned long i,
-						struct pp_vce_state *vce_state,
+						struct amd_vce_state *vce_state,
 						void **clock_info,
 						unsigned long *flag);
 };
@@ -586,18 +586,6 @@ struct phm_microcode_version_info {
 	uint32_t NB;
 };
 
-#define PP_MAX_VCE_LEVELS 6
-
-enum PP_VCE_LEVEL {
-	PP_VCE_LEVEL_AC_ALL = 0,     /* AC, All cases */
-	PP_VCE_LEVEL_DC_EE = 1,      /* DC, entropy encoding */
-	PP_VCE_LEVEL_DC_LL_LOW = 2,  /* DC, low latency queue, res <= 720 */
-	PP_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
-	PP_VCE_LEVEL_DC_GP_LOW = 4,  /* DC, general purpose queue, res <= 720 */
-	PP_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
-};
-
-
 enum PP_TABLE_VERSION {
 	PP_TABLE_V0 = 0,
 	PP_TABLE_V1,
@@ -620,7 +608,7 @@ struct pp_hwmgr {
 	void *hardcode_pp_table;
 	bool need_pp_table_upload;
 
-	struct pp_vce_state vce_states[PP_MAX_VCE_LEVELS];
+	struct amd_vce_state vce_states[AMD_MAX_VCE_LEVELS];
 	uint32_t num_vce_state_tables;
 
 	enum amd_dpm_forced_level dpm_level;
drivers/gpu/drm/amd/powerplay/inc/power_state.h +0 -9
index 9ceaed9..827860f 100644
@@ -156,15 +156,6 @@ struct pp_power_state {
 	struct pp_hw_power_state  hardware;
 };
 
-
-/*Structure to hold a VCE state entry*/
-struct pp_vce_state {
-	uint32_t evclk;
-	uint32_t ecclk;
-	uint32_t sclk;
-	uint32_t mclk;
-};
-
 enum PP_MMProfilingState {
 	PP_MMProfilingState_NA = 0,
 	PP_MMProfilingState_Started,
Signature · 1 line
1.9.1

From 6d81b620fac52d7c526984132a97646dcad52943 Mon Sep 17 00:00:00 2001
From: Rex Zhu <[email protected]>
Date: Wed, 12 Oct 2016 15:38:56 +0800
Subject: [PATCH 2/2] drm/amdgpu: save number of vce states in dpm struct.

Change-Id: I8b3ee9c53bfccdc7b823d97ddd66b1351105cf75

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c | 7 ++++---
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c     | 2 +-
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c     | 2 +-
 drivers/gpu/drm/amd/amdgpu/si_dpm.c     | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 2a414c8..9bbaf96 100644
@@ -1228,6 +1228,7 @@ struct amdgpu_dpm {
 	/* default uvd power state */
 	struct amdgpu_ps        *uvd_ps;
 	/* vce requirements */
+	u32                  num_of_vce_states;
 	struct amd_vce_state vce_states[AMD_MAX_VCE_LEVELS];
 	enum amd_vce_level vce_level;
 	enum amd_pm_state_type state;
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +4 -3
index 4f8d3a5..009ccb9 100644
@@ -553,9 +553,10 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev)
 				entry = (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record *)
 					((u8 *)entry + sizeof(ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record));
 			}
-			for (i = 0; i < states->numEntries; i++) {
-				if (i >= AMD_MAX_VCE_LEVELS)
-					break;
+			adev->pm.dpm.num_of_vce_states =
+					states->numEntries > AMD_MAX_VCE_LEVELS ?
+					AMD_MAX_VCE_LEVELS : states->numEntries;
+			for (i = 0; i < adev->pm.dpm.num_of_vce_states; i++) {
 				vce_clk = (VCEClockInfo *)
 					((u8 *)&array->entries[0] +
 					 (state_entry->ucVCEClockInfoIndex * sizeof(VCEClockInfo)));
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +1 -1
index dc3196e..fa939df 100644
@@ -5689,7 +5689,7 @@ static int ci_parse_power_table(struct amdgpu_device *adev)
 	adev->pm.dpm.num_ps = state_array->ucNumEntries;
 
 	/* fill in the vce power states */
-	for (i = 0; i < AMD_MAX_VCE_LEVELS; i++) {
+	for (i = 0; i < adev->pm.dpm.num_of_vce_states; i++) {
 		u32 sclk, mclk;
 		clock_array_index = adev->pm.dpm.vce_states[i].clk_idx;
 		clock_info = (union pplib_clock_info *)
drivers/gpu/drm/amd/amdgpu/kv_dpm.c +1 -1
index a03690a..b23f643 100644
@@ -2796,7 +2796,7 @@ static int kv_parse_power_table(struct amdgpu_device *adev)
 	adev->pm.dpm.num_ps = state_array->ucNumEntries;
 
 	/* fill in the vce power states */
-	for (i = 0; i < AMD_MAX_VCE_LEVELS; i++) {
+	for (i = 0; i < adev->pm.dpm.num_of_vce_states; i++) {
 		u32 sclk;
 		clock_array_index = adev->pm.dpm.vce_states[i].clk_idx;
 		clock_info = (union pplib_clock_info *)
drivers/gpu/drm/amd/amdgpu/si_dpm.c +1 -1
index 1a909fa..a76a856 100644
@@ -7314,7 +7314,7 @@ static int si_parse_power_table(struct amdgpu_device *adev)
 	adev->pm.dpm.num_ps = state_array->ucNumEntries;
 
 	/* fill in the vce power states */
-	for (i = 0; i < AMD_MAX_VCE_LEVELS; i++) {
+	for (i = 0; i < adev->pm.dpm.num_of_vce_states; i++) {
 		u32 sclk, mclk;
 		clock_array_index = adev->pm.dpm.vce_states[i].clk_idx;
 		clock_info = (union pplib_clock_info *)
Signature · 1 line
1.9.1

_______________________________________________
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): CY4PR12MB16871A098341B047DBA0DEADFBDD0-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#15 lore raw

Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Hi Rex,

the problem with this approach is that you need to copy the entries from one structure to another, like we have below:

Review

Quoted 3 lines
(quoted diff) +3 -0
+                               vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+                               vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+                               vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;

This is not seen as good coding practice and usually isn't allowed upstream because it creates two representations in the kernel for the same thing.

Regards,
Christian.

Am 12.10.2016 um 10:34 schrieb Zhu, Rex:

Quoted 93 lines

Hi Alex,

In Patch1, I moved struct amdgpu_vce_states to amd_shared.h from amdgpu.h. So in powerplay, we used same vce state definition.

So the define of static struct drm_amdgpu_info_vce_clock_table pp_dpm_get_vce_clock_table(void *handle) Can change to
static struct amd_vce_state pp_dpm_get_vce_clock_table(void *handle, int num);

and can move those codes to Patch6.

Review

Quoted 3 lines
(quoted diff) +3 -0
+                               vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+                               vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+                               vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;

So in powerplay and dpm, we don't need to visit struct drm_amdgpu_info_vce_clock_table.

In Patch2, add numer of vce_states in struct dpm. If it is useful to UMD driver. We can notify UMD by add a member in struct drm_amdgpu_info_vce_clock_table.

Best Regards
Rex

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Wednesday, October 12, 2016 4:07 AM
To: amd-gfx list; Fang, Peter; Zhang, Boyuan; Zhu, Rex
Cc: Deucher, Alexander
Subject: Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Rex what is your opinion on exposing the amdgpu drm structure through to powerplay? We could do an intermediate interface, but that just seems like extra hoops to jump through for pretty questionable gain.

Alex

Quoted 61 lines · Alex Deucher

Used by the powerplay dpm code.

---
  drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 24
++++++++++++++++++++++++
  1 file changed, 24 insertions(+)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +23 -1
index bb8a345..8eee390 100644
@@ -30,6 +30,7 @@
  #include "power_state.h"
  #include "eventmanager.h"
  #include "pp_debug.h"
+#include "drm/amdgpu_drm.h"
 
 
  #define PP_CHECK(handle)                                               \
@@ -821,6 +822,28 @@ static int pp_dpm_read_sensor(void *handle, int idx, int32_t *value)
         return hwmgr->hwmgr_func->read_sensor(hwmgr, idx, value);  }
 
+static struct drm_amdgpu_info_vce_clock_table
+pp_dpm_get_vce_clock_table(void *handle) {
+       struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};
+       struct pp_hwmgr *hwmgr;
+       unsigned i;
+
+       if (handle) {
+               hwmgr = ((struct pp_instance *)handle)->hwmgr;
+
+               if (hwmgr) {
+                       for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {
+                               vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+                               vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+                               vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;
+                       }
+               }
+       }
+
+       return vce_clk_table;
+}
+
  const struct amd_powerplay_funcs pp_dpm_funcs = {
         .get_temperature = pp_dpm_get_temperature,
         .load_firmware = pp_dpm_load_fw, @@ -847,6 +870,7 @@ const
 struct amd_powerplay_funcs pp_dpm_funcs = {
         .get_mclk_od = pp_dpm_get_mclk_od,
         .set_mclk_od = pp_dpm_set_mclk_od,
         .read_sensor = pp_dpm_read_sensor,
+       .get_vce_clock_table = pp_dpm_get_vce_clock_table,
  };
 
  static int amd_pp_instance_init(struct amd_pp_init *pp_init,
--

2.5.5

Quoted 4 lines
Quoted 4 lines

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): e8cdcd80-3df3-940f-32b5-9116e5d15fa6-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#17 lore raw

RE: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Hi Christian,

I mean patch 5 can be changed as

static struct amd_vce_state* pp_dpm_get_vce_clock_table(void *handle, int num)

{
    PP_CHECK((struct pp_instance *)handle);
    hwmgr = ((struct pp_instance *)handle)->hwmgr;

if (hwmgr && num < hwmgr->num_vce_state_tables)

     return &hwmgr->vce_states[i];

    Return NULL;
}

And in Patch6.

+ case AMDGPU_INFO_VCE_CLOCK_TABLE: {

+ struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};

                 struct amd_vce_state*  vce_state;

+ for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {

                 vce_state = amdgpu_dpm_get_vce_clock_table(adev, i);

                         If (vce_state) {

                                      vce_clk_table.entries[i].sclk = vce_state->sclk;
             vce_clk_table.entries[i].mclk = vce_state->mclk;
            vce_clk_table.entries[i].eclk = vce_state->evclk;

                        } else {

                               vce_clk_table.num_of_entries = i;         //if UMD driver need to check number of vce state.

                               break;

                      }

              }

+ return copy_to_user(out, &vce_clk_table,

+ min((size_t)size, sizeof(vce_clk_table))) ? -EFAULT : 0;

+ }

Best Regards
Rex
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Wednesday, October 12, 2016 4:53 PM
To: Zhu, Rex; Alex Deucher; amd-gfx list; Fang, Peter; Zhang, Boyuan
Cc: Deucher, Alexander
Subject: Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Hi Rex,

the problem with this approach is that you need to copy the entries from one structure to another, like we have below:

Review

Quoted 3 lines
(quoted diff) +3 -0
+                               vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+                               vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+                               vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;

This is not seen as good coding practice and usually isn't allowed upstream because it creates two representations in the kernel for the same thing.

Regards,
Christian.

Am 12.10.2016 um 10:34 schrieb Zhu, Rex:

Hi Alex,

In Patch1, I moved struct amdgpu_vce_states to amd_shared.h from amdgpu.h. So in powerplay, we used same vce state definition.

So the define of static struct drm_amdgpu_info_vce_clock_table pp_dpm_get_vce_clock_table(void *handle)

Can change to

static struct amd_vce_state pp_dpm_get_vce_clock_table(void *handle, int num);

and can move those codes to Patch6.

+ vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;

+ vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;

+ vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;

So in powerplay and dpm, we don't need to visit struct drm_amdgpu_info_vce_clock_table.

In Patch2, add numer of vce_states in struct dpm. If it is useful to UMD driver. We can notify UMD by add a member in struct drm_amdgpu_info_vce_clock_table.

Best Regards

Rex

-----Original Message-----

From: Alex Deucher [mailto:[email protected]]

Sent: Wednesday, October 12, 2016 4:07 AM

To: amd-gfx list; Fang, Peter; Zhang, Boyuan; Zhu, Rex

Cc Deucher, Alexander

Subject: Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Rex what is your opinion on exposing the amdgpu drm structure through to powerplay? We could do an intermediate interface, but that just seems like extra hoops to jump through for pretty questionable gain.

Alex

On Fri, Oct 7, 2016 at 2:28 PM, Alex Deucher <[email protected]><mailto:[email protected]> wrote:

Used by the powerplay dpm code.

---

 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 24

++++++++++++++++++++++++

 1 file changed, 24 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

index bb8a345..8eee390 100644

--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

@@ -30,6 +30,7 @@

#include "power_state.h"

#include "eventmanager.h"

#include "pp_debug.h"

+#include "drm/amdgpu_drm.h"

#define PP_CHECK(handle) \

@@ -821,6 +822,28 @@ static int pp_dpm_read_sensor(void *handle, int idx, int32_t *value)

        return hwmgr->hwmgr_func->read_sensor(hwmgr, idx, value);  }

+static struct drm_amdgpu_info_vce_clock_table

+pp_dpm_get_vce_clock_table(void *handle) {

+ struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};

+ struct pp_hwmgr *hwmgr;

+ unsigned i;

+

+ if (handle) {

+ hwmgr = ((struct pp_instance *)handle)->hwmgr;

+

+ if (hwmgr) {

+ for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {

+ vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;

+ vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;

+ vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;

+ }

+ }

+ }

+

+ return vce_clk_table;

+}

+

const struct amd_powerplay_funcs pp_dpm_funcs = {

.get_temperature = pp_dpm_get_temperature,

.load_firmware = pp_dpm_load_fw, @@ -847,6 +870,7 @@ const

struct amd_powerplay_funcs pp_dpm_funcs = {

        .get_mclk_od = pp_dpm_get_mclk_od,

        .set_mclk_od = pp_dpm_set_mclk_od,

        .read_sensor = pp_dpm_read_sensor,

+ .get_vce_clock_table = pp_dpm_get_vce_clock_table,

};

static int amd_pp_instance_init(struct amd_pp_init *pp_init,

--

2.5.5

_______________________________________________

amd-gfx mailing list

[email protected]<mailto:[email protected]>

https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
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): CY4PR12MB168795F3CD0C3B58ED38828DFBDD0-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#19 lore raw

Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Hi Rex,

So amd_vce_state is our hardware representation and drm_amdgpu_info_vce_clock_table is the IOCTL interface structure? Is there a reason for not using drm_amdgpu_info_vce_clock_table directly in the hw manager, except that we don't want to include the IOCTL interface here?

Cause that would at least be a bit awkward, this is an extra abstraction layer we usually try to avoid upstream.

I'm fine with this approach for this use case, but when we get more and more power management exposed to userspace this could raise objections cause this essentially means we need to duplicate all internal power management structures for the public interface again.

Regards,
Christian.

Am 12.10.2016 um 11:40 schrieb Zhu, Rex:

Quoted 262 lines

Hi Christian,

I mean patch 5 can be changed as

static struct amd_vce_state* pp_dpm_get_vce_clock_table(void *handle, int num)

{

    PP_CHECK((struct pp_instance *)handle);

    hwmgr = ((struct pp_instance *)handle)->hwmgr;

if (hwmgr && num < hwmgr->num_vce_state_tables)

     return &hwmgr->vce_states[i];

    Return NULL;

}

And in Patch6.

(quoted diff) +3 -0
+       case AMDGPU_INFO_VCE_CLOCK_TABLE: {
 
+ struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};
 
 struct amd_vce_state*  vce_state;
 
+      for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {

vce_state = amdgpu_dpm_get_vce_clock_table(adev, i);

If (vce_state) {

vce_clk_table.entries[i].sclk =
vce_state->sclk;
vce_clk_table.entries[i].mclk = vce_state->mclk; vce_clk_table.entries[i].eclk = vce_state->evclk;

} else {

vce_clk_table.num_of_entries = i; //if UMD driver need
to check number of vce state.

break;

             }

              }

+ return copy_to_user(out, &vce_clk_table,

(quoted diff) +2 -0
+     min((size_t)size, sizeof(vce_clk_table))) ? -EFAULT : 0;
 
+       }

Best Regards

Rex

*From:*amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] *On Behalf Of *Christian König *Sent:* Wednesday, October 12, 2016 4:53 PM
*To:* Zhu, Rex; Alex Deucher; amd-gfx list; Fang, Peter; Zhang, Boyuan
*Cc:* Deucher, Alexander
*Subject:* Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Hi Rex,

the problem with this approach is that you need to copy the entries from one structure to another, like we have below:

Quoted 3 lines

+ vce_clk_table.entries[i].sclk = hwmgr->vce_states[i].sclk;
+ vce_clk_table.entries[i].mclk = hwmgr->vce_states[i].mclk;
+ vce_clk_table.entries[i].eclk = hwmgr->vce_states[i].evclk;

This is not seen as good coding practice and usually isn't allowed upstream because it creates two representations in the kernel for the same thing.

Regards,
Christian.

Am 12.10.2016 um 10:34 schrieb Zhu, Rex:

Hi Alex,

In Patch1, I moved struct amdgpu_vce_states to amd_shared.h from amdgpu.h. So in powerplay, we used same vce state definition.

So the define of static struct drm_amdgpu_info_vce_clock_table pp_dpm_get_vce_clock_table(void *handle)

Can change to

static struct amd_vce_state pp_dpm_get_vce_clock_table(void *handle, int num);

and can move those codes to Patch6.

+ vce_clk_table.entries[i].sclk
= hwmgr->vce_states[i].sclk;

+ vce_clk_table.entries[i].mclk
= hwmgr->vce_states[i].mclk;

+ vce_clk_table.entries[i].eclk
= hwmgr->vce_states[i].evclk;

So in powerplay and dpm, we don't need to visit struct drm_amdgpu_info_vce_clock_table.

In Patch2, add numer of vce_states in struct dpm. If it is useful to UMD driver. We can notify UMD by add a member in struct drm_amdgpu_info_vce_clock_table.

Best Regards

Rex

-----Original Message-----

From: Alex Deucher [mailto:[email protected]]

Sent: Wednesday, October 12, 2016 4:07 AM

To: amd-gfx list; Fang, Peter; Zhang, Boyuan; Zhu, Rex

Cc Deucher, Alexander

Subject: Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Rex what is your opinion on exposing the amdgpu drm structure through to powerplay? We could do an intermediate interface, but that just seems like extra hoops to jump through for pretty questionable gain.

Alex

On Fri, Oct 7, 2016 at 2:28 PM, Alex Deucher
<[email protected]> <mailto:[email protected]> wrote:

Used by the powerplay dpm code.

<mailto:[email protected]>

---

drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 24

++++++++++++++++++++++++

1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

index bb8a345..8eee390 100644

--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

@@ -30,6 +30,7 @@

#include "power_state.h"

#include "eventmanager.h"

#include "pp_debug.h"

+#include "drm/amdgpu_drm.h"

#define
PP_CHECK(handle) \

@@ -821,6 +822,28 @@ static int pp_dpm_read_sensor(void *handle, int idx, int32_t *value)

return hwmgr->hwmgr_func->read_sensor(hwmgr, idx,
value); }

+static struct drm_amdgpu_info_vce_clock_table

+pp_dpm_get_vce_clock_table(void *handle) {

+ struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};

+ struct pp_hwmgr *hwmgr;

+ unsigned i;

+

+ if (handle) {

+ hwmgr = ((struct pp_instance *)handle)->hwmgr;

+

+ if (hwmgr) {

+ for (i = 0; i <
AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {

+ vce_clk_table.entries[i].sclk
= hwmgr->vce_states[i].sclk;

+ vce_clk_table.entries[i].mclk
= hwmgr->vce_states[i].mclk;

+ vce_clk_table.entries[i].eclk
= hwmgr->vce_states[i].evclk;

+ }

+ }

+ }

+

+ return vce_clk_table;

+}

+

const struct amd_powerplay_funcs pp_dpm_funcs = {

.get_temperature = pp_dpm_get_temperature,

.load_firmware = pp_dpm_load_fw, @@ -847,6 +870,7 @@
const

struct amd_powerplay_funcs pp_dpm_funcs = {

.get_mclk_od = pp_dpm_get_mclk_od,

.set_mclk_od = pp_dpm_set_mclk_od,

.read_sensor = pp_dpm_read_sensor,

+ .get_vce_clock_table = pp_dpm_get_vce_clock_table,

};

static int amd_pp_instance_init(struct amd_pp_init *pp_init,

--

2.5.5

_______________________________________________

amd-gfx mailing list

[email protected] <mailto:[email protected]>

Quoted 8 lines

https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): 4117134e-ff2f-808d-4354-3e51c2410724-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#21 lore raw

Re: [PATCH 5/6] drm/amdgpu/powerplay: add an implementation for get_vce_clock_table

Quoted 7 lines · Christian König

Hi Rex,

So amd_vce_state is our hardware representation and drm_amdgpu_info_vce_clock_table is the IOCTL interface structure? Is there a reason for not using drm_amdgpu_info_vce_clock_table directly in the hw manager, except that we don't want to include the IOCTL interface here?

Quoted 7 lines

Cause that would at least be a bit awkward, this is an extra abstraction layer we usually try to avoid upstream.

I'm fine with this approach for this use case, but when we get more and more power management exposed to userspace this could raise objections cause this essentially means we need to duplicate all internal power management structures for the public interface again.

It's only needed for a subset of asics (some CI and VI parts). Everything else gets handled in the firmware similar to UVD DPM.

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

#22 lore raw

PATCH 6/6 drm/amdgpu: fill in vce clock info ioctl query

In reply to a message not in the archive

Returns the vce clock table for the user mode driver. The user mode driver can fill this data into vce clock data packet for optimal VCE DPM.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +8 -0
index 1ecfe9a..07493b6 100644
@@ -524,6 +524,14 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 		return copy_to_user(out, &dev_info,
 				    min((size_t)size, sizeof(dev_info))) ? -EFAULT : 0;
 	}
+	case AMDGPU_INFO_VCE_CLOCK_TABLE: {
+		struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};
+
+		vce_clk_table = amdgpu_dpm_get_vce_clock_table(adev);
+
+		return copy_to_user(out, &vce_clk_table,
+				    min((size_t)size, sizeof(vce_clk_table))) ? -EFAULT : 0;
+	}
 	default:
 		DRM_DEBUG_KMS("Invalid request %d\n", info->query);
 		return -EINVAL;
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#23 lore raw
In reply to a message not in the archive

Am 07.10.2016 um 20:28 schrieb Alex Deucher:

Quoted 3 lines

No intended functional change.

Patches #1-#4 and #6 are Reviewed-by: Christian König <[email protected]>.

Patch #5 is fine with me, but I think Rex is going to object because it pulls the amdgpu IOCTL definitions into the powerplay code (but might be that I'm wrong on this).

I'm not sure if we can keep this separation in the long term, cause it's an extra abstraction layer for the upstream code. Which is essentially unnecessary from an upstream perspective.

Regards,
Christian.

Quoted 929 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 449 +-------------------------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 447 +++++++++++++++++++++++++++++++
  2 files changed, 448 insertions(+), 448 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -448
index 7d30a8e..a6db3dd 100644
@@ -57,6 +57,7 @@
  #include "amdgpu_ring.h"
  #include "amdgpu_vm.h"
  #include "amd_powerplay.h"
+#include "amdgpu_dpm.h"
  #include "amdgpu_acp.h"
 
  #include "gpu_scheduler.h"
@@ -961,354 +962,6 @@ struct amdgpu_wb {
  int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb);
  void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb);
 
-
-
-enum amdgpu_int_thermal_type {
-	THERMAL_TYPE_NONE,
-	THERMAL_TYPE_EXTERNAL,
-	THERMAL_TYPE_EXTERNAL_GPIO,
-	THERMAL_TYPE_RV6XX,
-	THERMAL_TYPE_RV770,
-	THERMAL_TYPE_ADT7473_WITH_INTERNAL,
-	THERMAL_TYPE_EVERGREEN,
-	THERMAL_TYPE_SUMO,
-	THERMAL_TYPE_NI,
-	THERMAL_TYPE_SI,
-	THERMAL_TYPE_EMC2103_WITH_INTERNAL,
-	THERMAL_TYPE_CI,
-	THERMAL_TYPE_KV,
-};
-
-enum amdgpu_dpm_auto_throttle_src {
-	AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL,
-	AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL
-};
-
-enum amdgpu_dpm_event_src {
-	AMDGPU_DPM_EVENT_SRC_ANALOG = 0,
-	AMDGPU_DPM_EVENT_SRC_EXTERNAL = 1,
-	AMDGPU_DPM_EVENT_SRC_DIGITAL = 2,
-	AMDGPU_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL = 3,
-	AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4
-};
-
-#define AMDGPU_MAX_VCE_LEVELS 6
-
-enum amdgpu_vce_level {
-	AMDGPU_VCE_LEVEL_AC_ALL = 0,     /* AC, All cases */
-	AMDGPU_VCE_LEVEL_DC_EE = 1,      /* DC, entropy encoding */
-	AMDGPU_VCE_LEVEL_DC_LL_LOW = 2,  /* DC, low latency queue, res <= 720 */
-	AMDGPU_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
-	AMDGPU_VCE_LEVEL_DC_GP_LOW = 4,  /* DC, general purpose queue, res <= 720 */
-	AMDGPU_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
-};
-
-struct amdgpu_ps {
-	u32 caps; /* vbios flags */
-	u32 class; /* vbios flags */
-	u32 class2; /* vbios flags */
-	/* UVD clocks */
-	u32 vclk;
-	u32 dclk;
-	/* VCE clocks */
-	u32 evclk;
-	u32 ecclk;
-	bool vce_active;
-	enum amdgpu_vce_level vce_level;
-	/* asic priv */
-	void *ps_priv;
-};
-
-struct amdgpu_dpm_thermal {
-	/* thermal interrupt work */
-	struct work_struct work;
-	/* low temperature threshold */
-	int                min_temp;
-	/* high temperature threshold */
-	int                max_temp;
-	/* was last interrupt low to high or high to low */
-	bool               high_to_low;
-	/* interrupt source */
-	struct amdgpu_irq_src	irq;
-};
-
-enum amdgpu_clk_action
-{
-	AMDGPU_SCLK_UP = 1,
-	AMDGPU_SCLK_DOWN
-};
-
-struct amdgpu_blacklist_clocks
-{
-	u32 sclk;
-	u32 mclk;
-	enum amdgpu_clk_action action;
-};
-
-struct amdgpu_clock_and_voltage_limits {
-	u32 sclk;
-	u32 mclk;
-	u16 vddc;
-	u16 vddci;
-};
-
-struct amdgpu_clock_array {
-	u32 count;
-	u32 *values;
-};
-
-struct amdgpu_clock_voltage_dependency_entry {
-	u32 clk;
-	u16 v;
-};
-
-struct amdgpu_clock_voltage_dependency_table {
-	u32 count;
-	struct amdgpu_clock_voltage_dependency_entry *entries;
-};
-
-union amdgpu_cac_leakage_entry {
-	struct {
-		u16 vddc;
-		u32 leakage;
-	};
-	struct {
-		u16 vddc1;
-		u16 vddc2;
-		u16 vddc3;
-	};
-};
-
-struct amdgpu_cac_leakage_table {
-	u32 count;
-	union amdgpu_cac_leakage_entry *entries;
-};
-
-struct amdgpu_phase_shedding_limits_entry {
-	u16 voltage;
-	u32 sclk;
-	u32 mclk;
-};
-
-struct amdgpu_phase_shedding_limits_table {
-	u32 count;
-	struct amdgpu_phase_shedding_limits_entry *entries;
-};
-
-struct amdgpu_uvd_clock_voltage_dependency_entry {
-	u32 vclk;
-	u32 dclk;
-	u16 v;
-};
-
-struct amdgpu_uvd_clock_voltage_dependency_table {
-	u8 count;
-	struct amdgpu_uvd_clock_voltage_dependency_entry *entries;
-};
-
-struct amdgpu_vce_clock_voltage_dependency_entry {
-	u32 ecclk;
-	u32 evclk;
-	u16 v;
-};
-
-struct amdgpu_vce_clock_voltage_dependency_table {
-	u8 count;
-	struct amdgpu_vce_clock_voltage_dependency_entry *entries;
-};
-
-struct amdgpu_ppm_table {
-	u8 ppm_design;
-	u16 cpu_core_number;
-	u32 platform_tdp;
-	u32 small_ac_platform_tdp;
-	u32 platform_tdc;
-	u32 small_ac_platform_tdc;
-	u32 apu_tdp;
-	u32 dgpu_tdp;
-	u32 dgpu_ulv_power;
-	u32 tj_max;
-};
-
-struct amdgpu_cac_tdp_table {
-	u16 tdp;
-	u16 configurable_tdp;
-	u16 tdc;
-	u16 battery_power_limit;
-	u16 small_power_limit;
-	u16 low_cac_leakage;
-	u16 high_cac_leakage;
-	u16 maximum_power_delivery_limit;
-};
-
-struct amdgpu_dpm_dynamic_state {
-	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_sclk;
-	struct amdgpu_clock_voltage_dependency_table vddci_dependency_on_mclk;
-	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_mclk;
-	struct amdgpu_clock_voltage_dependency_table mvdd_dependency_on_mclk;
-	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_dispclk;
-	struct amdgpu_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table;
-	struct amdgpu_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table;
-	struct amdgpu_clock_voltage_dependency_table samu_clock_voltage_dependency_table;
-	struct amdgpu_clock_voltage_dependency_table acp_clock_voltage_dependency_table;
-	struct amdgpu_clock_voltage_dependency_table vddgfx_dependency_on_sclk;
-	struct amdgpu_clock_array valid_sclk_values;
-	struct amdgpu_clock_array valid_mclk_values;
-	struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_dc;
-	struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_ac;
-	u32 mclk_sclk_ratio;
-	u32 sclk_mclk_delta;
-	u16 vddc_vddci_delta;
-	u16 min_vddc_for_pcie_gen2;
-	struct amdgpu_cac_leakage_table cac_leakage_table;
-	struct amdgpu_phase_shedding_limits_table phase_shedding_limits_table;
-	struct amdgpu_ppm_table *ppm_table;
-	struct amdgpu_cac_tdp_table *cac_tdp_table;
-};
-
-struct amdgpu_dpm_fan {
-	u16 t_min;
-	u16 t_med;
-	u16 t_high;
-	u16 pwm_min;
-	u16 pwm_med;
-	u16 pwm_high;
-	u8 t_hyst;
-	u32 cycle_delay;
-	u16 t_max;
-	u8 control_mode;
-	u16 default_max_fan_pwm;
-	u16 default_fan_output_sensitivity;
-	u16 fan_output_sensitivity;
-	bool ucode_fan_control;
-};
-
-enum amdgpu_pcie_gen {
-	AMDGPU_PCIE_GEN1 = 0,
-	AMDGPU_PCIE_GEN2 = 1,
-	AMDGPU_PCIE_GEN3 = 2,
-	AMDGPU_PCIE_GEN_INVALID = 0xffff
-};
-
-enum amdgpu_dpm_forced_level {
-	AMDGPU_DPM_FORCED_LEVEL_AUTO = 0,
-	AMDGPU_DPM_FORCED_LEVEL_LOW = 1,
-	AMDGPU_DPM_FORCED_LEVEL_HIGH = 2,
-	AMDGPU_DPM_FORCED_LEVEL_MANUAL = 3,
-};
-
-struct amdgpu_vce_state {
-	/* vce clocks */
-	u32 evclk;
-	u32 ecclk;
-	/* gpu clocks */
-	u32 sclk;
-	u32 mclk;
-	u8 clk_idx;
-	u8 pstate;
-};
-
-struct amdgpu_dpm_funcs {
-	int (*get_temperature)(struct amdgpu_device *adev);
-	int (*pre_set_power_state)(struct amdgpu_device *adev);
-	int (*set_power_state)(struct amdgpu_device *adev);
-	void (*post_set_power_state)(struct amdgpu_device *adev);
-	void (*display_configuration_changed)(struct amdgpu_device *adev);
-	u32 (*get_sclk)(struct amdgpu_device *adev, bool low);
-	u32 (*get_mclk)(struct amdgpu_device *adev, bool low);
-	void (*print_power_state)(struct amdgpu_device *adev, struct amdgpu_ps *ps);
-	void (*debugfs_print_current_performance_level)(struct amdgpu_device *adev, struct seq_file *m);
-	int (*force_performance_level)(struct amdgpu_device *adev, enum amdgpu_dpm_forced_level level);
-	bool (*vblank_too_short)(struct amdgpu_device *adev);
-	void (*powergate_uvd)(struct amdgpu_device *adev, bool gate);
-	void (*powergate_vce)(struct amdgpu_device *adev, bool gate);
-	void (*enable_bapm)(struct amdgpu_device *adev, bool enable);
-	void (*set_fan_control_mode)(struct amdgpu_device *adev, u32 mode);
-	u32 (*get_fan_control_mode)(struct amdgpu_device *adev);
-	int (*set_fan_speed_percent)(struct amdgpu_device *adev, u32 speed);
-	int (*get_fan_speed_percent)(struct amdgpu_device *adev, u32 *speed);
-	int (*force_clock_level)(struct amdgpu_device *adev, enum pp_clock_type type, uint32_t mask);
-	int (*print_clock_levels)(struct amdgpu_device *adev, enum pp_clock_type type, char *buf);
-	int (*get_sclk_od)(struct amdgpu_device *adev);
-	int (*set_sclk_od)(struct amdgpu_device *adev, uint32_t value);
-	int (*get_mclk_od)(struct amdgpu_device *adev);
-	int (*set_mclk_od)(struct amdgpu_device *adev, uint32_t value);
-};
-
-struct amdgpu_dpm {
-	struct amdgpu_ps        *ps;
-	/* number of valid power states */
-	int                     num_ps;
-	/* current power state that is active */
-	struct amdgpu_ps        *current_ps;
-	/* requested power state */
-	struct amdgpu_ps        *requested_ps;
-	/* boot up power state */
-	struct amdgpu_ps        *boot_ps;
-	/* default uvd power state */
-	struct amdgpu_ps        *uvd_ps;
-	/* vce requirements */
-	struct amdgpu_vce_state vce_states[AMDGPU_MAX_VCE_LEVELS];
-	enum amdgpu_vce_level vce_level;
-	enum amd_pm_state_type state;
-	enum amd_pm_state_type user_state;
-	u32                     platform_caps;
-	u32                     voltage_response_time;
-	u32                     backbias_response_time;
-	void                    *priv;
-	u32			new_active_crtcs;
-	int			new_active_crtc_count;
-	u32			current_active_crtcs;
-	int			current_active_crtc_count;
-	struct amdgpu_dpm_dynamic_state dyn_state;
-	struct amdgpu_dpm_fan fan;
-	u32 tdp_limit;
-	u32 near_tdp_limit;
-	u32 near_tdp_limit_adjusted;
-	u32 sq_ramping_threshold;
-	u32 cac_leakage;
-	u16 tdp_od_limit;
-	u32 tdp_adjustment;
-	u16 load_line_slope;
-	bool power_control;
-	bool ac_power;
-	/* special states active */
-	bool                    thermal_active;
-	bool                    uvd_active;
-	bool                    vce_active;
-	/* thermal handling */
-	struct amdgpu_dpm_thermal thermal;
-	/* forced levels */
-	enum amdgpu_dpm_forced_level forced_level;
-};
-
-struct amdgpu_pm {
-	struct mutex		mutex;
-	u32                     current_sclk;
-	u32                     current_mclk;
-	u32                     default_sclk;
-	u32                     default_mclk;
-	struct amdgpu_i2c_chan *i2c_bus;
-	/* internal thermal controller on rv6xx+ */
-	enum amdgpu_int_thermal_type int_thermal_type;
-	struct device	        *int_hwmon_dev;
-	/* fan control parameters */
-	bool                    no_fan;
-	u8                      fan_pulses_per_revolution;
-	u8                      fan_min_rpm;
-	u8                      fan_max_rpm;
-	/* dpm */
-	bool                    dpm_enabled;
-	bool                    sysfs_initialized;
-	struct amdgpu_dpm       dpm;
-	const struct firmware	*fw;	/* SMC firmware */
-	uint32_t                fw_version;
-	const struct amdgpu_dpm_funcs *funcs;
-	uint32_t                pcie_gen_mask;
-	uint32_t                pcie_mlw_mask;
-	struct amd_pp_display_configuration pm_display_cfg;/* set by DAL */
-};
-
  void amdgpu_get_pcie_info(struct amdgpu_device *adev);
 
  /*
@@ -1973,108 +1626,8 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
  #define amdgpu_display_resume_mc_access(adev, s) (adev)->mode_info.funcs->resume_mc_access((adev), (s))
  #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib),  (s), (d), (b))
  #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b))
-#define amdgpu_dpm_pre_set_power_state(adev) (adev)->pm.funcs->pre_set_power_state((adev))
-#define amdgpu_dpm_set_power_state(adev) (adev)->pm.funcs->set_power_state((adev))
-#define amdgpu_dpm_post_set_power_state(adev) (adev)->pm.funcs->post_set_power_state((adev))
-#define amdgpu_dpm_display_configuration_changed(adev) (adev)->pm.funcs->display_configuration_changed((adev))
-#define amdgpu_dpm_print_power_state(adev, ps) (adev)->pm.funcs->print_power_state((adev), (ps))
-#define amdgpu_dpm_vblank_too_short(adev) (adev)->pm.funcs->vblank_too_short((adev))
-#define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e))
  #define amdgpu_gfx_get_gpu_clock_counter(adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev))
  #define amdgpu_gfx_select_se_sh(adev, se, sh, instance) (adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance))
-
-#define amdgpu_dpm_read_sensor(adev, idx, value) \
-	((adev)->pp_enabled ? \
-		(adev)->powerplay.pp_funcs->read_sensor(adev->powerplay.pp_handle, (idx), (value)) : \
-		-EINVAL)
-
-#define amdgpu_dpm_get_temperature(adev) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \
-	      (adev)->pm.funcs->get_temperature((adev)))
-
-#define amdgpu_dpm_set_fan_control_mode(adev, m) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \
-	      (adev)->pm.funcs->set_fan_control_mode((adev), (m)))
-
-#define amdgpu_dpm_get_fan_control_mode(adev) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \
-	      (adev)->pm.funcs->get_fan_control_mode((adev)))
-
-#define amdgpu_dpm_set_fan_speed_percent(adev, s) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
-	      (adev)->pm.funcs->set_fan_speed_percent((adev), (s)))
-
-#define amdgpu_dpm_get_fan_speed_percent(adev, s) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
-	      (adev)->pm.funcs->get_fan_speed_percent((adev), (s)))
-
-#define amdgpu_dpm_get_sclk(adev, l) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \
-		(adev)->pm.funcs->get_sclk((adev), (l)))
-
-#define amdgpu_dpm_get_mclk(adev, l)  \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \
-	      (adev)->pm.funcs->get_mclk((adev), (l)))
-
-
-#define amdgpu_dpm_force_performance_level(adev, l) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \
-	      (adev)->pm.funcs->force_performance_level((adev), (l)))
-
-#define amdgpu_dpm_powergate_uvd(adev, g) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \
-	      (adev)->pm.funcs->powergate_uvd((adev), (g)))
-
-#define amdgpu_dpm_powergate_vce(adev, g) \
-	((adev)->pp_enabled ?						\
-	      (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \
-	      (adev)->pm.funcs->powergate_vce((adev), (g)))
-
-#define amdgpu_dpm_get_current_power_state(adev) \
-	(adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle)
-
-#define amdgpu_dpm_get_performance_level(adev) \
-	(adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle)
-
-#define amdgpu_dpm_get_pp_num_states(adev, data) \
-	(adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data)
-
-#define amdgpu_dpm_get_pp_table(adev, table) \
-	(adev)->powerplay.pp_funcs->get_pp_table((adev)->powerplay.pp_handle, table)
-
-#define amdgpu_dpm_set_pp_table(adev, buf, size) \
-	(adev)->powerplay.pp_funcs->set_pp_table((adev)->powerplay.pp_handle, buf, size)
-
-#define amdgpu_dpm_print_clock_levels(adev, type, buf) \
-	(adev)->powerplay.pp_funcs->print_clock_levels((adev)->powerplay.pp_handle, type, buf)
-
-#define amdgpu_dpm_force_clock_level(adev, type, level) \
-		(adev)->powerplay.pp_funcs->force_clock_level((adev)->powerplay.pp_handle, type, level)
-
-#define amdgpu_dpm_get_sclk_od(adev) \
-	(adev)->powerplay.pp_funcs->get_sclk_od((adev)->powerplay.pp_handle)
-
-#define amdgpu_dpm_set_sclk_od(adev, value) \
-	(adev)->powerplay.pp_funcs->set_sclk_od((adev)->powerplay.pp_handle, value)
-
-#define amdgpu_dpm_get_mclk_od(adev) \
-	((adev)->powerplay.pp_funcs->get_mclk_od((adev)->powerplay.pp_handle))
-
-#define amdgpu_dpm_set_mclk_od(adev, value) \
-	((adev)->powerplay.pp_funcs->set_mclk_od((adev)->powerplay.pp_handle, value))
-
-#define amdgpu_dpm_dispatch_task(adev, event_id, input, output)		\
-	(adev)->powerplay.pp_funcs->dispatch_tasks((adev)->powerplay.pp_handle, (event_id), (input), (output))
-
  #define amdgpu_gds_switch(adev, r, v, d, w, a) (adev)->gds.funcs->patch_gds_switch((r), (v), (d), (w), (a))
 
  /* Common functions */
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +440 -0
index 3738a96..d06496d 100644
@@ -23,6 +23,453 @@
  #ifndef __AMDGPU_DPM_H__
  #define __AMDGPU_DPM_H__
 
+enum amdgpu_int_thermal_type {
+	THERMAL_TYPE_NONE,
+	THERMAL_TYPE_EXTERNAL,
+	THERMAL_TYPE_EXTERNAL_GPIO,
+	THERMAL_TYPE_RV6XX,
+	THERMAL_TYPE_RV770,
+	THERMAL_TYPE_ADT7473_WITH_INTERNAL,
+	THERMAL_TYPE_EVERGREEN,
+	THERMAL_TYPE_SUMO,
+	THERMAL_TYPE_NI,
+	THERMAL_TYPE_SI,
+	THERMAL_TYPE_EMC2103_WITH_INTERNAL,
+	THERMAL_TYPE_CI,
+	THERMAL_TYPE_KV,
+};
+
+enum amdgpu_dpm_auto_throttle_src {
+	AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL,
+	AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL
+};
+
+enum amdgpu_dpm_event_src {
+	AMDGPU_DPM_EVENT_SRC_ANALOG = 0,
+	AMDGPU_DPM_EVENT_SRC_EXTERNAL = 1,
+	AMDGPU_DPM_EVENT_SRC_DIGITAL = 2,
+	AMDGPU_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL = 3,
+	AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4
+};
+
+#define AMDGPU_MAX_VCE_LEVELS 6
+
+enum amdgpu_vce_level {
+	AMDGPU_VCE_LEVEL_AC_ALL = 0,     /* AC, All cases */
+	AMDGPU_VCE_LEVEL_DC_EE = 1,      /* DC, entropy encoding */
+	AMDGPU_VCE_LEVEL_DC_LL_LOW = 2,  /* DC, low latency queue, res <= 720 */
+	AMDGPU_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
+	AMDGPU_VCE_LEVEL_DC_GP_LOW = 4,  /* DC, general purpose queue, res <= 720 */
+	AMDGPU_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
+};
+
+struct amdgpu_ps {
+	u32 caps; /* vbios flags */
+	u32 class; /* vbios flags */
+	u32 class2; /* vbios flags */
+	/* UVD clocks */
+	u32 vclk;
+	u32 dclk;
+	/* VCE clocks */
+	u32 evclk;
+	u32 ecclk;
+	bool vce_active;
+	enum amdgpu_vce_level vce_level;
+	/* asic priv */
+	void *ps_priv;
+};
+
+struct amdgpu_dpm_thermal {
+	/* thermal interrupt work */
+	struct work_struct work;
+	/* low temperature threshold */
+	int                min_temp;
+	/* high temperature threshold */
+	int                max_temp;
+	/* was last interrupt low to high or high to low */
+	bool               high_to_low;
+	/* interrupt source */
+	struct amdgpu_irq_src	irq;
+};
+
+enum amdgpu_clk_action
+{
+	AMDGPU_SCLK_UP = 1,
+	AMDGPU_SCLK_DOWN
+};
+
+struct amdgpu_blacklist_clocks
+{
+	u32 sclk;
+	u32 mclk;
+	enum amdgpu_clk_action action;
+};
+
+struct amdgpu_clock_and_voltage_limits {
+	u32 sclk;
+	u32 mclk;
+	u16 vddc;
+	u16 vddci;
+};
+
+struct amdgpu_clock_array {
+	u32 count;
+	u32 *values;
+};
+
+struct amdgpu_clock_voltage_dependency_entry {
+	u32 clk;
+	u16 v;
+};
+
+struct amdgpu_clock_voltage_dependency_table {
+	u32 count;
+	struct amdgpu_clock_voltage_dependency_entry *entries;
+};
+
+union amdgpu_cac_leakage_entry {
+	struct {
+		u16 vddc;
+		u32 leakage;
+	};
+	struct {
+		u16 vddc1;
+		u16 vddc2;
+		u16 vddc3;
+	};
+};
+
+struct amdgpu_cac_leakage_table {
+	u32 count;
+	union amdgpu_cac_leakage_entry *entries;
+};
+
+struct amdgpu_phase_shedding_limits_entry {
+	u16 voltage;
+	u32 sclk;
+	u32 mclk;
+};
+
+struct amdgpu_phase_shedding_limits_table {
+	u32 count;
+	struct amdgpu_phase_shedding_limits_entry *entries;
+};
+
+struct amdgpu_uvd_clock_voltage_dependency_entry {
+	u32 vclk;
+	u32 dclk;
+	u16 v;
+};
+
+struct amdgpu_uvd_clock_voltage_dependency_table {
+	u8 count;
+	struct amdgpu_uvd_clock_voltage_dependency_entry *entries;
+};
+
+struct amdgpu_vce_clock_voltage_dependency_entry {
+	u32 ecclk;
+	u32 evclk;
+	u16 v;
+};
+
+struct amdgpu_vce_clock_voltage_dependency_table {
+	u8 count;
+	struct amdgpu_vce_clock_voltage_dependency_entry *entries;
+};
+
+struct amdgpu_ppm_table {
+	u8 ppm_design;
+	u16 cpu_core_number;
+	u32 platform_tdp;
+	u32 small_ac_platform_tdp;
+	u32 platform_tdc;
+	u32 small_ac_platform_tdc;
+	u32 apu_tdp;
+	u32 dgpu_tdp;
+	u32 dgpu_ulv_power;
+	u32 tj_max;
+};
+
+struct amdgpu_cac_tdp_table {
+	u16 tdp;
+	u16 configurable_tdp;
+	u16 tdc;
+	u16 battery_power_limit;
+	u16 small_power_limit;
+	u16 low_cac_leakage;
+	u16 high_cac_leakage;
+	u16 maximum_power_delivery_limit;
+};
+
+struct amdgpu_dpm_dynamic_state {
+	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_sclk;
+	struct amdgpu_clock_voltage_dependency_table vddci_dependency_on_mclk;
+	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_mclk;
+	struct amdgpu_clock_voltage_dependency_table mvdd_dependency_on_mclk;
+	struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_dispclk;
+	struct amdgpu_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table;
+	struct amdgpu_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table;
+	struct amdgpu_clock_voltage_dependency_table samu_clock_voltage_dependency_table;
+	struct amdgpu_clock_voltage_dependency_table acp_clock_voltage_dependency_table;
+	struct amdgpu_clock_voltage_dependency_table vddgfx_dependency_on_sclk;
+	struct amdgpu_clock_array valid_sclk_values;
+	struct amdgpu_clock_array valid_mclk_values;
+	struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_dc;
+	struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_ac;
+	u32 mclk_sclk_ratio;
+	u32 sclk_mclk_delta;
+	u16 vddc_vddci_delta;
+	u16 min_vddc_for_pcie_gen2;
+	struct amdgpu_cac_leakage_table cac_leakage_table;
+	struct amdgpu_phase_shedding_limits_table phase_shedding_limits_table;
+	struct amdgpu_ppm_table *ppm_table;
+	struct amdgpu_cac_tdp_table *cac_tdp_table;
+};
+
+struct amdgpu_dpm_fan {
+	u16 t_min;
+	u16 t_med;
+	u16 t_high;
+	u16 pwm_min;
+	u16 pwm_med;
+	u16 pwm_high;
+	u8 t_hyst;
+	u32 cycle_delay;
+	u16 t_max;
+	u8 control_mode;
+	u16 default_max_fan_pwm;
+	u16 default_fan_output_sensitivity;
+	u16 fan_output_sensitivity;
+	bool ucode_fan_control;
+};
+
+enum amdgpu_pcie_gen {
+	AMDGPU_PCIE_GEN1 = 0,
+	AMDGPU_PCIE_GEN2 = 1,
+	AMDGPU_PCIE_GEN3 = 2,
+	AMDGPU_PCIE_GEN_INVALID = 0xffff
+};
+
+enum amdgpu_dpm_forced_level {
+	AMDGPU_DPM_FORCED_LEVEL_AUTO = 0,
+	AMDGPU_DPM_FORCED_LEVEL_LOW = 1,
+	AMDGPU_DPM_FORCED_LEVEL_HIGH = 2,
+	AMDGPU_DPM_FORCED_LEVEL_MANUAL = 3,
+};
+
+struct amdgpu_vce_state {
+	/* vce clocks */
+	u32 evclk;
+	u32 ecclk;
+	/* gpu clocks */
+	u32 sclk;
+	u32 mclk;
+	u8 clk_idx;
+	u8 pstate;
+};
+
+struct amdgpu_dpm_funcs {
+	int (*get_temperature)(struct amdgpu_device *adev);
+	int (*pre_set_power_state)(struct amdgpu_device *adev);
+	int (*set_power_state)(struct amdgpu_device *adev);
+	void (*post_set_power_state)(struct amdgpu_device *adev);
+	void (*display_configuration_changed)(struct amdgpu_device *adev);
+	u32 (*get_sclk)(struct amdgpu_device *adev, bool low);
+	u32 (*get_mclk)(struct amdgpu_device *adev, bool low);
+	void (*print_power_state)(struct amdgpu_device *adev, struct amdgpu_ps *ps);
+	void (*debugfs_print_current_performance_level)(struct amdgpu_device *adev, struct seq_file *m);
+	int (*force_performance_level)(struct amdgpu_device *adev, enum amdgpu_dpm_forced_level level);
+	bool (*vblank_too_short)(struct amdgpu_device *adev);
+	void (*powergate_uvd)(struct amdgpu_device *adev, bool gate);
+	void (*powergate_vce)(struct amdgpu_device *adev, bool gate);
+	void (*enable_bapm)(struct amdgpu_device *adev, bool enable);
+	void (*set_fan_control_mode)(struct amdgpu_device *adev, u32 mode);
+	u32 (*get_fan_control_mode)(struct amdgpu_device *adev);
+	int (*set_fan_speed_percent)(struct amdgpu_device *adev, u32 speed);
+	int (*get_fan_speed_percent)(struct amdgpu_device *adev, u32 *speed);
+	int (*force_clock_level)(struct amdgpu_device *adev, enum pp_clock_type type, uint32_t mask);
+	int (*print_clock_levels)(struct amdgpu_device *adev, enum pp_clock_type type, char *buf);
+	int (*get_sclk_od)(struct amdgpu_device *adev);
+	int (*set_sclk_od)(struct amdgpu_device *adev, uint32_t value);
+	int (*get_mclk_od)(struct amdgpu_device *adev);
+	int (*set_mclk_od)(struct amdgpu_device *adev, uint32_t value);
+};
+
+#define amdgpu_dpm_pre_set_power_state(adev) (adev)->pm.funcs->pre_set_power_state((adev))
+#define amdgpu_dpm_set_power_state(adev) (adev)->pm.funcs->set_power_state((adev))
+#define amdgpu_dpm_post_set_power_state(adev) (adev)->pm.funcs->post_set_power_state((adev))
+#define amdgpu_dpm_display_configuration_changed(adev) (adev)->pm.funcs->display_configuration_changed((adev))
+#define amdgpu_dpm_print_power_state(adev, ps) (adev)->pm.funcs->print_power_state((adev), (ps))
+#define amdgpu_dpm_vblank_too_short(adev) (adev)->pm.funcs->vblank_too_short((adev))
+#define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e))
+
+#define amdgpu_dpm_read_sensor(adev, idx, value) \
+	((adev)->pp_enabled ? \
+		(adev)->powerplay.pp_funcs->read_sensor(adev->powerplay.pp_handle, (idx), (value)) : \
+		-EINVAL)
+
+#define amdgpu_dpm_get_temperature(adev) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \
+	      (adev)->pm.funcs->get_temperature((adev)))
+
+#define amdgpu_dpm_set_fan_control_mode(adev, m) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \
+	      (adev)->pm.funcs->set_fan_control_mode((adev), (m)))
+
+#define amdgpu_dpm_get_fan_control_mode(adev) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \
+	      (adev)->pm.funcs->get_fan_control_mode((adev)))
+
+#define amdgpu_dpm_set_fan_speed_percent(adev, s) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
+	      (adev)->pm.funcs->set_fan_speed_percent((adev), (s)))
+
+#define amdgpu_dpm_get_fan_speed_percent(adev, s) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
+	      (adev)->pm.funcs->get_fan_speed_percent((adev), (s)))
+
+#define amdgpu_dpm_get_sclk(adev, l) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \
+		(adev)->pm.funcs->get_sclk((adev), (l)))
+
+#define amdgpu_dpm_get_mclk(adev, l)  \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \
+	      (adev)->pm.funcs->get_mclk((adev), (l)))
+
+
+#define amdgpu_dpm_force_performance_level(adev, l) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \
+	      (adev)->pm.funcs->force_performance_level((adev), (l)))
+
+#define amdgpu_dpm_powergate_uvd(adev, g) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \
+	      (adev)->pm.funcs->powergate_uvd((adev), (g)))
+
+#define amdgpu_dpm_powergate_vce(adev, g) \
+	((adev)->pp_enabled ?						\
+	      (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \
+	      (adev)->pm.funcs->powergate_vce((adev), (g)))
+
+#define amdgpu_dpm_get_current_power_state(adev) \
+	(adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle)
+
+#define amdgpu_dpm_get_performance_level(adev) \
+	(adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle)
+
+#define amdgpu_dpm_get_pp_num_states(adev, data) \
+	(adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data)
+
+#define amdgpu_dpm_get_pp_table(adev, table) \
+	(adev)->powerplay.pp_funcs->get_pp_table((adev)->powerplay.pp_handle, table)
+
+#define amdgpu_dpm_set_pp_table(adev, buf, size) \
+	(adev)->powerplay.pp_funcs->set_pp_table((adev)->powerplay.pp_handle, buf, size)
+
+#define amdgpu_dpm_print_clock_levels(adev, type, buf) \
+	(adev)->powerplay.pp_funcs->print_clock_levels((adev)->powerplay.pp_handle, type, buf)
+
+#define amdgpu_dpm_force_clock_level(adev, type, level) \
+		(adev)->powerplay.pp_funcs->force_clock_level((adev)->powerplay.pp_handle, type, level)
+
+#define amdgpu_dpm_get_sclk_od(adev) \
+	(adev)->powerplay.pp_funcs->get_sclk_od((adev)->powerplay.pp_handle)
+
+#define amdgpu_dpm_set_sclk_od(adev, value) \
+	(adev)->powerplay.pp_funcs->set_sclk_od((adev)->powerplay.pp_handle, value)
+
+#define amdgpu_dpm_get_mclk_od(adev) \
+	((adev)->powerplay.pp_funcs->get_mclk_od((adev)->powerplay.pp_handle))
+
+#define amdgpu_dpm_set_mclk_od(adev, value) \
+	((adev)->powerplay.pp_funcs->set_mclk_od((adev)->powerplay.pp_handle, value))
+
+#define amdgpu_dpm_dispatch_task(adev, event_id, input, output)		\
+	(adev)->powerplay.pp_funcs->dispatch_tasks((adev)->powerplay.pp_handle, (event_id), (input), (output))
+
+
+struct amdgpu_dpm {
+	struct amdgpu_ps        *ps;
+	/* number of valid power states */
+	int                     num_ps;
+	/* current power state that is active */
+	struct amdgpu_ps        *current_ps;
+	/* requested power state */
+	struct amdgpu_ps        *requested_ps;
+	/* boot up power state */
+	struct amdgpu_ps        *boot_ps;
+	/* default uvd power state */
+	struct amdgpu_ps        *uvd_ps;
+	/* vce requirements */
+	struct amdgpu_vce_state vce_states[AMDGPU_MAX_VCE_LEVELS];
+	enum amdgpu_vce_level vce_level;
+	enum amd_pm_state_type state;
+	enum amd_pm_state_type user_state;
+	u32                     platform_caps;
+	u32                     voltage_response_time;
+	u32                     backbias_response_time;
+	void                    *priv;
+	u32			new_active_crtcs;
+	int			new_active_crtc_count;
+	u32			current_active_crtcs;
+	int			current_active_crtc_count;
+	struct amdgpu_dpm_dynamic_state dyn_state;
+	struct amdgpu_dpm_fan fan;
+	u32 tdp_limit;
+	u32 near_tdp_limit;
+	u32 near_tdp_limit_adjusted;
+	u32 sq_ramping_threshold;
+	u32 cac_leakage;
+	u16 tdp_od_limit;
+	u32 tdp_adjustment;
+	u16 load_line_slope;
+	bool power_control;
+	bool ac_power;
+	/* special states active */
+	bool                    thermal_active;
+	bool                    uvd_active;
+	bool                    vce_active;
+	/* thermal handling */
+	struct amdgpu_dpm_thermal thermal;
+	/* forced levels */
+	enum amdgpu_dpm_forced_level forced_level;
+};
+
+struct amdgpu_pm {
+	struct mutex		mutex;
+	u32                     current_sclk;
+	u32                     current_mclk;
+	u32                     default_sclk;
+	u32                     default_mclk;
+	struct amdgpu_i2c_chan *i2c_bus;
+	/* internal thermal controller on rv6xx+ */
+	enum amdgpu_int_thermal_type int_thermal_type;
+	struct device	        *int_hwmon_dev;
+	/* fan control parameters */
+	bool                    no_fan;
+	u8                      fan_pulses_per_revolution;
+	u8                      fan_min_rpm;
+	u8                      fan_max_rpm;
+	/* dpm */
+	bool                    dpm_enabled;
+	bool                    sysfs_initialized;
+	struct amdgpu_dpm       dpm;
+	const struct firmware	*fw;	/* SMC firmware */

drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h line 475

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +7 -0
+	uint32_t                fw_version;
+	const struct amdgpu_dpm_funcs *funcs;
+	uint32_t                pcie_gen_mask;
+	uint32_t                pcie_mlw_mask;
+	struct amd_pp_display_configuration pm_display_cfg;/* set by DAL */
+};
+
  #define R600_SSTU_DFLT                               0
  #define R600_SST_DFLT                                0x00C8
 

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