File drivers/gpu/alga/amd/atombios/pp.c changed (mode: 100644) (index e386e85..05e3a0d) |
... |
... |
unlock_mutex: |
498 |
498 |
return r; |
return r; |
499 |
499 |
} |
} |
500 |
500 |
EXPORT_SYMBOL_GPL(atb_pp_tdp_limits_get); |
EXPORT_SYMBOL_GPL(atb_pp_tdp_limits_get); |
|
501 |
|
|
|
502 |
|
long atb_pp_sq_ramping_threshold_get(struct atombios *atb, |
|
503 |
|
u32 *sq_ramping_threshold) |
|
504 |
|
{ |
|
505 |
|
u16 of; |
|
506 |
|
struct master_data_tbl *data_tbl; |
|
507 |
|
union pp *pp; |
|
508 |
|
u16 tbl_sz; |
|
509 |
|
long r; |
|
510 |
|
|
|
511 |
|
mutex_lock(&atb->mutex); |
|
512 |
|
|
|
513 |
|
of = get_unaligned_le16(&atb->hdr->master_data_tbl_of); |
|
514 |
|
data_tbl = atb->adev.rom + of; |
|
515 |
|
|
|
516 |
|
of = get_unaligned_le16(&data_tbl->list.pp_info); |
|
517 |
|
pp = atb->adev.rom + of; |
|
518 |
|
|
|
519 |
|
dev_info(atb->adev.dev, "atombios:pp_info (0x%04x) revision %u.%u\n", |
|
520 |
|
of, pp->pp0.hdr.tbl_fmt_rev, pp->pp0.hdr.tbl_content_rev); |
|
521 |
|
|
|
522 |
|
if (pp->pp0.hdr.tbl_fmt_rev != 6 && pp->pp0.hdr.tbl_content_rev != 1) { |
|
523 |
|
dev_err(atb->adev.dev, "atombios:pp_info (0x%04x) revision %u.%u not supported\n", |
|
524 |
|
of, pp->pp0.hdr.tbl_fmt_rev, |
|
525 |
|
pp->pp0.hdr.tbl_content_rev); |
|
526 |
|
r = -ATB_ERR; |
|
527 |
|
goto unlock_mutex; |
|
528 |
|
} |
|
529 |
|
|
|
530 |
|
tbl_sz = get_unaligned_le16(&pp->pp0.tbl_sz); |
|
531 |
|
if (tbl_sz < sizeof(struct pp4)) { |
|
532 |
|
dev_err(atb->adev.dev, "atombios:missing powerplay 4 table\n"); |
|
533 |
|
r = -ATB_ERR; |
|
534 |
|
goto unlock_mutex; |
|
535 |
|
} |
|
536 |
|
|
|
537 |
|
*sq_ramping_threshold = get_unaligned_le32( |
|
538 |
|
&pp->pp4.sq_ramping_threshold); |
|
539 |
|
|
|
540 |
|
r = 0; |
|
541 |
|
|
|
542 |
|
unlock_mutex: |
|
543 |
|
mutex_unlock(&atb->mutex); |
|
544 |
|
return r; |
|
545 |
|
} |
|
546 |
|
EXPORT_SYMBOL_GPL(atb_pp_sq_ramping_threshold_get); |
File drivers/gpu/alga/amd/si/dyn_pm/ctx.c changed (mode: 100644) (index 8931550..fac74ea) |
... |
... |
long ctx_init(struct pci_dev *dev, struct ctx *ctx) |
677 |
677 |
dev_err(&dev->dev, "dyn_pm:unable to fetch the voltage time\n"); |
dev_err(&dev->dev, "dyn_pm:unable to fetch the voltage time\n"); |
678 |
678 |
goto err_free_cac_lkge_tbl_entries; |
goto err_free_cac_lkge_tbl_entries; |
679 |
679 |
} |
} |
|
680 |
|
|
|
681 |
|
r = atb_pp_sq_ramping_threshold_get(dd->atb, |
|
682 |
|
&ctx->atb_sq_ramping_threshold); |
|
683 |
|
if (r == -ATB_ERR) { |
|
684 |
|
dev_err(&dev->dev, "dyn_pm:unable to fetch the sequencer block ramping threshold\n"); |
|
685 |
|
goto err_free_cac_lkge_tbl_entries; |
|
686 |
|
} |
680 |
687 |
return 0; |
return 0; |
681 |
688 |
|
|
682 |
689 |
err_free_cac_lkge_tbl_entries: |
err_free_cac_lkge_tbl_entries: |
File drivers/gpu/alga/amd/si/dyn_pm/driver.c changed (mode: 100644) (index 6d19e77..1721e29) |
... |
... |
static void smc_sw_state_init(struct ctx *ctx, struct smc_sw_state *state) |
44 |
44 |
state->lvls_n = ctx->atb_performance.lvls_n; |
state->lvls_n = ctx->atb_performance.lvls_n; |
45 |
45 |
} |
} |
46 |
46 |
|
|
|
47 |
|
#define PWR_EFFICIENCY_RATIO_MARGIN 10 |
47 |
48 |
static u16 pwr_efficiency_ratio_compute(struct ctx *ctx, |
static u16 pwr_efficiency_ratio_compute(struct ctx *ctx, |
48 |
49 |
struct smc_volt *prev_std_vddc, struct smc_volt *cur_std_vddc) |
struct smc_volt *prev_std_vddc, struct smc_volt *cur_std_vddc) |
49 |
50 |
{ |
{ |
50 |
|
//TODO |
|
51 |
|
return 0; |
|
|
51 |
|
u64 prev_std_vddc_mv; |
|
52 |
|
u64 cur_std_vddc_mv; |
|
53 |
|
u64 n; |
|
54 |
|
u64 d; |
|
55 |
|
u64 pwr_efficiency_ratio; |
|
56 |
|
|
|
57 |
|
prev_std_vddc_mv = (u64)get_unaligned_be16(&prev_std_vddc->val); |
|
58 |
|
cur_std_vddc_mv = (u64)get_unaligned_be16(&cur_std_vddc->val); |
|
59 |
|
|
|
60 |
|
n = div64_u64(1024 * cur_std_vddc_mv * cur_std_vddc_mv |
|
61 |
|
* (1000 + PWR_EFFICIENCY_RATIO_MARGIN), 1000); |
|
62 |
|
d = prev_std_vddc_mv * prev_std_vddc_mv; |
|
63 |
|
|
|
64 |
|
pwr_efficiency_ratio = div64_u64(n, d); |
|
65 |
|
return (u16)pwr_efficiency_ratio; |
52 |
66 |
} |
} |
53 |
67 |
|
|
54 |
68 |
#define NEAR_TDP_DEC 10 |
#define NEAR_TDP_DEC 10 |
|
... |
... |
static long smc_pp_dpm_to_perf_lvl_init(struct ctx *ctx, u8 lvl_idx, |
111 |
125 |
return 0; |
return 0; |
112 |
126 |
} |
} |
113 |
127 |
|
|
|
128 |
|
#define SQ_RAMPING_PWR_MAX 0x3fff |
|
129 |
|
#define SQ_RAMPING_PWR_MIN 0x12 |
|
130 |
|
#define SQ_RAMPING_PWR_DELTA_MAX 0x15 |
|
131 |
|
#define SQ_RAMPING_STI_SZ 0x1e |
|
132 |
|
#define SQ_RAMPING_LTI_RATIO 0xf |
|
133 |
|
static void sq_ramping_threshold_init(struct ctx *ctx, u8 lvl_idx, |
|
134 |
|
struct smc_lvl *lvl) |
|
135 |
|
{ |
|
136 |
|
u32 sq_pwr_throttle_0; |
|
137 |
|
u32 sq_pwr_throttle_1; |
|
138 |
|
|
|
139 |
|
if (ctx->atb_performance.lvls[lvl_idx].eng_clk >= |
|
140 |
|
ctx->atb_sq_ramping_threshold) { |
|
141 |
|
sq_pwr_throttle_0 = set(SPT0_PWR_MAX, SQ_RAMPING_PWR_MAX); |
|
142 |
|
sq_pwr_throttle_0 |= set(SPT0_PWR_MIN, SQ_RAMPING_PWR_MIN); |
|
143 |
|
|
|
144 |
|
sq_pwr_throttle_1 = set(SPT1_PWR_DELTA_MAX, |
|
145 |
|
SQ_RAMPING_PWR_DELTA_MAX); |
|
146 |
|
sq_pwr_throttle_1 |= set(SPT1_STI_SZ, SQ_RAMPING_STI_SZ); |
|
147 |
|
sq_pwr_throttle_1 |= set(SPT1_LTI_RATIO, SQ_RAMPING_LTI_RATIO); |
|
148 |
|
} else { |
|
149 |
|
sq_pwr_throttle_0 = SPT0_PWR_MIN | SPT0_PWR_MAX; |
|
150 |
|
sq_pwr_throttle_1 = SPT1_PWR_DELTA_MAX | SPT1_STI_SZ |
|
151 |
|
| SPT1_LTI_RATIO; |
|
152 |
|
} |
|
153 |
|
|
|
154 |
|
put_unaligned_be32(sq_pwr_throttle_0, &lvl->sq_pwr_throttle_0); |
|
155 |
|
put_unaligned_be32(sq_pwr_throttle_1, &lvl->sq_pwr_throttle_1); |
|
156 |
|
} |
|
157 |
|
|
114 |
158 |
static long smc_lvls_init(struct ctx *ctx, struct smc_lvl *lvls) |
static long smc_lvls_init(struct ctx *ctx, struct smc_lvl *lvls) |
115 |
159 |
{ |
{ |
116 |
160 |
u8 lvl_idx; |
u8 lvl_idx; |
|
... |
... |
static long smc_lvls_init(struct ctx *ctx, struct smc_lvl *lvls) |
149 |
193 |
|
|
150 |
194 |
smc_pp_dpm_to_perf_lvl_init(ctx, lvl_idx, |
smc_pp_dpm_to_perf_lvl_init(ctx, lvl_idx, |
151 |
195 |
&lvl->dpm_to_perf_lvl); |
&lvl->dpm_to_perf_lvl); |
|
196 |
|
sq_ramping_threshold_init(ctx, lvl_idx, lvl); |
152 |
197 |
//TODO |
//TODO |
153 |
198 |
} |
} |
154 |
199 |
return 0; |
return 0; |
File drivers/gpu/alga/amd/si/dyn_pm/emergency.c changed (mode: 100644) (index e651a0f..dc3306a) |
... |
... |
long smc_state_tbl_emergency_init(struct ctx *ctx, struct smc_state_tbl *tbl) |
231 |
231 |
lvl->dpm_to_perf_lvl.pwr_efficiency_ratio = 0; |
lvl->dpm_to_perf_lvl.pwr_efficiency_ratio = 0; |
232 |
232 |
|
|
233 |
233 |
/* set everything to the max value, namely all bits to 1 */ |
/* set everything to the max value, namely all bits to 1 */ |
234 |
|
put_unaligned_be32(SPT0_MIN_PWR | SPT0_MAX_PWR, |
|
|
234 |
|
put_unaligned_be32(SPT0_PWR_MIN | SPT0_PWR_MAX, |
235 |
235 |
&lvl->sq_pwr_throttle_0); |
&lvl->sq_pwr_throttle_0); |
236 |
236 |
|
|
237 |
|
put_unaligned_be32(SPT1_MAX_PWR_DELTA | SPT1_STI_SZ | SPT1_LTI_RATIO, |
|
|
237 |
|
put_unaligned_be32(SPT1_PWR_DELTA_MAX | SPT1_STI_SZ | SPT1_LTI_RATIO, |
238 |
238 |
&lvl->sq_pwr_throttle_1); |
&lvl->sq_pwr_throttle_1); |
239 |
239 |
return 0; |
return 0; |
240 |
240 |
} |
} |
File drivers/gpu/alga/amd/si/dyn_pm/initial.c changed (mode: 100644) (index 291f8ab..229d921) |
... |
... |
void smc_state_tbl_initial_init(struct ctx *ctx, struct smc_state_tbl *tbl) |
148 |
148 |
lvl->dpm_to_perf_lvl.pwr_efficiency_ratio = 0; |
lvl->dpm_to_perf_lvl.pwr_efficiency_ratio = 0; |
149 |
149 |
|
|
150 |
150 |
/* set everything to the max value, namely all bits to 1 */ |
/* set everything to the max value, namely all bits to 1 */ |
151 |
|
put_unaligned_be32(SPT0_MIN_PWR | SPT0_MAX_PWR, |
|
|
151 |
|
put_unaligned_be32(SPT0_PWR_MIN | SPT0_PWR_MAX, |
152 |
152 |
&lvl->sq_pwr_throttle_0); |
&lvl->sq_pwr_throttle_0); |
153 |
153 |
|
|
154 |
|
put_unaligned_be32(SPT1_MAX_PWR_DELTA | SPT1_STI_SZ | SPT1_LTI_RATIO, |
|
|
154 |
|
put_unaligned_be32(SPT1_PWR_DELTA_MAX | SPT1_STI_SZ | SPT1_LTI_RATIO, |
155 |
155 |
&lvl->sq_pwr_throttle_1); |
&lvl->sq_pwr_throttle_1); |
156 |
156 |
} |
} |
File drivers/gpu/alga/amd/si/regs.h changed (mode: 100644) (index 1e59658..e2ee383) |
... |
... |
static inline u32 get(u32 mask, u32 v) |
589 |
589 |
#define SCRATCH_ADDR 0x8544 |
#define SCRATCH_ADDR 0x8544 |
590 |
590 |
|
|
591 |
591 |
#define SQ_PWR_THROTTLE_0 0x8e58 |
#define SQ_PWR_THROTTLE_0 0x8e58 |
592 |
|
#define SPT0_MIN_PWR 0x00003fff |
|
593 |
|
#define SPT0_MAX_PWR 0x3fff0000 |
|
|
592 |
|
#define SPT0_PWR_MIN 0x00003fff |
|
593 |
|
#define SPT0_PWR_MAX 0x3fff0000 |
594 |
594 |
#define SQ_PWR_THROTTLE_1 0x8e5c |
#define SQ_PWR_THROTTLE_1 0x8e5c |
595 |
|
#define SPT1_MAX_PWR_DELTA 0x00003fff |
|
|
595 |
|
#define SPT1_PWR_DELTA_MAX 0x00003fff |
596 |
596 |
#define SPT1_STI_SZ 0x03ff0000 |
#define SPT1_STI_SZ 0x03ff0000 |
597 |
597 |
#define SPT1_LTI_RATIO 0x78000000 |
#define SPT1_LTI_RATIO 0x78000000 |
598 |
598 |
/* end of configuration register area: 0x8000-0xb000--------------------------*/ |
/* end of configuration register area: 0x8000-0xb000--------------------------*/ |