Skip to content

Commit f38bb9b

Browse files
amd-pvishwakalexdeucher
authored andcommitted
drm/amd/swsmu: Move IP specific functions
Move SMU v15_0_0 specific functions to IP file - smu_v15_0_0_set_default_dpm_tables and - smu_v15_0_0_update_table Signed-off-by: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent b18fc0a commit f38bb9b

3 files changed

Lines changed: 67 additions & 74 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/inc/smu_v15_0.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ int smu_v15_0_deep_sleep_control(struct smu_context *smu,
226226

227227
int smu_v15_0_set_gfx_power_up_by_imu(struct smu_context *smu);
228228

229-
int smu_v15_0_set_default_dpm_tables(struct smu_context *smu);
230-
231229
int smu_v15_0_get_pptable_from_firmware(struct smu_context *smu,
232230
void **table,
233231
uint32_t *size,
@@ -241,10 +239,5 @@ int smu_v15_0_enable_thermal_alert(struct smu_context *smu);
241239

242240
int smu_v15_0_disable_thermal_alert(struct smu_context *smu);
243241

244-
int smu_v15_0_0_update_table(struct smu_context *smu,
245-
enum smu_table_id table_index,
246-
int argument, void *table_data,
247-
bool drv2smu);
248-
249242
#endif
250243
#endif

drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,72 +1726,6 @@ int smu_v15_0_set_gfx_power_up_by_imu(struct smu_context *smu)
17261726
return ret;
17271727
}
17281728

1729-
int smu_v15_0_0_update_table(struct smu_context *smu,
1730-
enum smu_table_id table_index,
1731-
int argument,
1732-
void *table_data,
1733-
bool drv2smu)
1734-
{
1735-
struct smu_table_context *smu_table = &smu->smu_table;
1736-
struct amdgpu_device *adev = smu->adev;
1737-
struct smu_table *table = &smu_table->driver_table;
1738-
int table_id = smu_cmn_to_asic_specific_index(smu,
1739-
CMN2ASIC_MAPPING_TABLE,
1740-
table_index);
1741-
uint64_t address;
1742-
uint32_t table_size;
1743-
int ret;
1744-
struct smu_msg_ctl *ctl = &smu->msg_ctl;
1745-
1746-
if (!table_data || table_index >= SMU_TABLE_COUNT || table_id < 0)
1747-
return -EINVAL;
1748-
1749-
table_size = smu_table->tables[table_index].size;
1750-
1751-
if (drv2smu) {
1752-
memcpy(table->cpu_addr, table_data, table_size);
1753-
/*
1754-
* Flush hdp cache: to guard the content seen by
1755-
* GPU is consitent with CPU.
1756-
*/
1757-
amdgpu_hdp_flush(adev, NULL);
1758-
}
1759-
1760-
address = table->mc_address;
1761-
1762-
struct smu_msg_args args = {
1763-
.msg = drv2smu ?
1764-
SMU_MSG_TransferTableDram2Smu :
1765-
SMU_MSG_TransferTableSmu2Dram,
1766-
.num_args = 3,
1767-
.num_out_args = 0,
1768-
};
1769-
1770-
args.args[0] = table_id;
1771-
args.args[1] = (uint32_t)lower_32_bits(address);
1772-
args.args[2] = (uint32_t)upper_32_bits(address);
1773-
1774-
ret = ctl->ops->send_msg(ctl, &args);
1775-
1776-
if (ret)
1777-
return ret;
1778-
1779-
if (!drv2smu) {
1780-
amdgpu_hdp_invalidate(adev, NULL);
1781-
memcpy(table_data, table->cpu_addr, table_size);
1782-
}
1783-
1784-
return 0;
1785-
}
1786-
1787-
int smu_v15_0_set_default_dpm_tables(struct smu_context *smu)
1788-
{
1789-
struct smu_table_context *smu_table = &smu->smu_table;
1790-
1791-
return smu_v15_0_0_update_table(smu, SMU_TABLE_DPMCLOCKS, 0,
1792-
smu_table->clocks_table, false);
1793-
}
1794-
17951729
int smu_v15_0_od_edit_dpm_table(struct smu_context *smu,
17961730
enum PP_OD_DPM_TABLE_COMMAND type,
17971731
long input[], uint32_t size)

drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,72 @@ static int smu_v15_0_0_system_features_control(struct smu_context *smu, bool en)
233233
return ret;
234234
}
235235

236+
static int smu_v15_0_0_update_table(struct smu_context *smu,
237+
enum smu_table_id table_index,
238+
int argument,
239+
void *table_data,
240+
bool drv2smu)
241+
{
242+
struct smu_table_context *smu_table = &smu->smu_table;
243+
struct amdgpu_device *adev = smu->adev;
244+
struct smu_table *table = &smu_table->driver_table;
245+
int table_id = smu_cmn_to_asic_specific_index(smu,
246+
CMN2ASIC_MAPPING_TABLE,
247+
table_index);
248+
uint64_t address;
249+
uint32_t table_size;
250+
int ret;
251+
struct smu_msg_ctl *ctl = &smu->msg_ctl;
252+
253+
if (!table_data || table_index >= SMU_TABLE_COUNT || table_id < 0)
254+
return -EINVAL;
255+
256+
table_size = smu_table->tables[table_index].size;
257+
258+
if (drv2smu) {
259+
memcpy(table->cpu_addr, table_data, table_size);
260+
/*
261+
* Flush hdp cache: to guard the content seen by
262+
* GPU is consitent with CPU.
263+
*/
264+
amdgpu_hdp_flush(adev, NULL);
265+
}
266+
267+
address = table->mc_address;
268+
269+
struct smu_msg_args args = {
270+
.msg = drv2smu ?
271+
SMU_MSG_TransferTableDram2Smu :
272+
SMU_MSG_TransferTableSmu2Dram,
273+
.num_args = 3,
274+
.num_out_args = 0,
275+
};
276+
277+
args.args[0] = table_id;
278+
args.args[1] = (uint32_t)lower_32_bits(address);
279+
args.args[2] = (uint32_t)upper_32_bits(address);
280+
281+
ret = ctl->ops->send_msg(ctl, &args);
282+
283+
if (ret)
284+
return ret;
285+
286+
if (!drv2smu) {
287+
amdgpu_hdp_invalidate(adev, NULL);
288+
memcpy(table_data, table->cpu_addr, table_size);
289+
}
290+
291+
return 0;
292+
}
293+
294+
static int smu_v15_0_0_set_default_dpm_tables(struct smu_context *smu)
295+
{
296+
struct smu_table_context *smu_table = &smu->smu_table;
297+
298+
return smu_v15_0_0_update_table(smu, SMU_TABLE_DPMCLOCKS, 0,
299+
smu_table->clocks_table, false);
300+
}
301+
236302
static int smu_v15_0_0_get_metrics_table(struct smu_context *smu,
237303
void *metrics_table,
238304
bool bypass_cache)
@@ -1357,7 +1423,7 @@ static const struct pptable_funcs smu_v15_0_0_ppt_funcs = {
13571423
.system_features_control = smu_v15_0_0_system_features_control,
13581424
.dpm_set_vcn_enable = smu_v15_0_set_vcn_enable,
13591425
.dpm_set_jpeg_enable = smu_v15_0_set_jpeg_enable,
1360-
.set_default_dpm_table = smu_v15_0_set_default_dpm_tables,
1426+
.set_default_dpm_table = smu_v15_0_0_set_default_dpm_tables,
13611427
.read_sensor = smu_v15_0_0_read_sensor,
13621428
.is_dpm_running = smu_v15_0_0_is_dpm_running,
13631429
.set_watermarks_table = smu_v15_0_0_set_watermarks_table,

0 commit comments

Comments
 (0)