Skip to content

Commit 2f4129a

Browse files
committed
GPU OC: cleanUp old fake UI OC
Time for real ECT oc. so no ui mods are required anymore
1 parent acf230c commit 2f4129a

4 files changed

Lines changed: 10 additions & 491 deletions

File tree

drivers/soc/samsung/cal-if/cal-if.c

Lines changed: 8 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "ra.h"
1818
#include "acpm_dvfs.h"
1919
#include "fvmap.h"
20-
#include "gpu_dvfs_overrides.h"
2120
#include "asv.h"
2221

2322
#include "pmucal_system.h"
@@ -32,39 +31,14 @@
3231

3332
static DEFINE_SPINLOCK(pmucal_cpu_lock);
3433

35-
static bool cal_is_gpu_dvfs_id(unsigned int id)
36-
{
37-
struct vclk *vclk;
38-
39-
vclk = cmucal_get_node(id);
40-
if (!vclk || !vclk->name)
41-
return false;
42-
43-
return !strcmp(vclk->name, "dvfs_g3d");
44-
}
45-
4634
unsigned int cal_clk_is_enabled(unsigned int id)
4735
{
48-
return 0;
36+
return 0;
4937
}
5038

5139
unsigned long cal_dfs_get_max_freq(unsigned int id)
5240
{
53-
struct vclk *vclk;
54-
unsigned long highest_override;
55-
56-
if (!cal_is_gpu_dvfs_id(id))
57-
return vclk_get_max_freq(id);
58-
59-
if (!gpu_dvfs_has_overrides())
60-
return vclk_get_max_freq(id);
61-
62-
highest_override = gpu_dvfs_override_highest_rate();
63-
vclk = cmucal_get_node(id);
64-
if (vclk && vclk->lut && highest_override > vclk->max_freq)
65-
vclk->max_freq = highest_override;
66-
67-
return highest_override ? highest_override : vclk_get_max_freq(id);
41+
return vclk_get_max_freq(id);
6842
}
6943

7044
unsigned long cal_dfs_get_min_freq(unsigned int id)
@@ -145,65 +119,11 @@ unsigned long cal_dfs_get_rate(unsigned int id)
145119

146120
int cal_dfs_get_rate_table(unsigned int id, unsigned long *table)
147121
{
148-
int ret;
149-
struct vclk *vclk;
150-
size_t override_idx;
151-
152-
ret = vclk_get_rate_table(id, table);
153-
154-
if (!cal_is_gpu_dvfs_id(id) || ret <= 0 || !gpu_dvfs_has_overrides())
155-
return ret;
156-
157-
vclk = cmucal_get_node(id);
158-
if (!vclk || !vclk->lut)
159-
return ret;
160-
161-
if (ret > vclk->num_rates)
162-
ret = vclk->num_rates;
122+
int ret;
163123

164-
for (override_idx = 0; override_idx < gpu_dvfs_override_count(); override_idx++) {
165-
const struct gpu_dvfs_override_entry *entry;
166-
bool found = false;
167-
int insert_idx = vclk->num_rates;
168-
int idx;
124+
ret = vclk_get_rate_table(id, table);
169125

170-
entry = gpu_dvfs_override_get(override_idx);
171-
if (!entry)
172-
continue;
173-
174-
for (idx = 0; idx < ret; idx++) {
175-
if (table[idx] == entry->rate_khz) {
176-
found = true;
177-
break;
178-
}
179-
}
180-
181-
if (found)
182-
continue;
183-
184-
for (idx = 0; idx < vclk->num_rates; idx++) {
185-
if (vclk->lut[idx].rate == entry->rate_khz) {
186-
insert_idx = idx;
187-
break;
188-
}
189-
190-
if (insert_idx == vclk->num_rates && vclk->lut[idx].rate < entry->rate_khz)
191-
insert_idx = idx;
192-
}
193-
194-
if (insert_idx > ret)
195-
insert_idx = ret;
196-
197-
if (ret < vclk->num_rates) {
198-
for (idx = ret; idx > insert_idx; idx--)
199-
table[idx] = table[idx - 1];
200-
ret++;
201-
}
202-
203-
table[insert_idx] = entry->rate_khz;
204-
}
205-
206-
return ret;
126+
return ret;
207127
}
208128

209129
int cal_clk_setrate(unsigned int id, unsigned long rate)
@@ -421,99 +341,11 @@ extern int cal_is_lastcore_detecting(unsigned int cpu)
421341

422342
int cal_dfs_get_asv_table(unsigned int id, unsigned int *table)
423343
{
424-
int entries;
425-
struct vclk *vclk;
426-
size_t override_count = 0;
427-
size_t override_idx;
428-
struct gpu_override_plan {
429-
const struct gpu_dvfs_override_entry *entry;
430-
int index;
431-
} *plans = NULL;
432-
433-
entries = fvmap_get_voltage_table(id, table);
434-
435-
if (!cal_is_gpu_dvfs_id(id) || entries <= 0 || !gpu_dvfs_has_overrides())
436-
return entries;
437-
438-
vclk = cmucal_get_node(id);
439-
if (!vclk || !vclk->lut)
440-
return entries;
441-
442-
if (entries > vclk->num_rates)
443-
entries = vclk->num_rates;
444-
445-
override_count = gpu_dvfs_override_count();
446-
plans = kcalloc(override_count, sizeof(*plans), GFP_KERNEL);
447-
if (!plans)
448-
return entries;
449-
450-
for (override_idx = 0; override_idx < override_count; override_idx++) {
451-
const struct gpu_dvfs_override_entry *entry;
452-
int idx;
453-
454-
entry = gpu_dvfs_override_get(override_idx);
455-
if (!entry)
456-
continue;
457-
458-
for (idx = 0; idx < vclk->num_rates; idx++) {
459-
if (vclk->lut[idx].rate == entry->rate_khz) {
460-
plans[override_idx].entry = entry;
461-
plans[override_idx].index = idx;
462-
break;
463-
}
464-
}
465-
}
466-
467-
/* sort overrides by target index descending to keep shifts safe */
468-
for (override_idx = 0; override_idx < override_count; override_idx++) {
469-
size_t other;
470-
471-
if (!plans[override_idx].entry)
472-
continue;
473-
474-
for (other = override_idx + 1; other < override_count; other++) {
475-
if (!plans[other].entry)
476-
continue;
477-
478-
if (plans[other].index > plans[override_idx].index) {
479-
struct gpu_override_plan tmp = plans[override_idx];
480-
plans[override_idx] = plans[other];
481-
plans[other] = tmp;
482-
}
483-
}
484-
}
485-
486-
for (override_idx = 0; override_idx < override_count; override_idx++) {
487-
const struct gpu_dvfs_override_entry *entry = plans[override_idx].entry;
488-
int idx = plans[override_idx].index;
489-
int shift;
490-
491-
if (!entry)
492-
continue;
493-
494-
if (idx > entries)
495-
idx = entries;
496-
497-
if (idx >= entries) {
498-
if (entries < vclk->num_rates) {
499-
table[entries] = entry->volt_uv;
500-
entries++;
501-
}
502-
continue;
503-
}
504-
505-
if (entries < vclk->num_rates) {
506-
for (shift = entries; shift > idx; shift--)
507-
table[shift] = table[shift - 1];
508-
entries++;
509-
}
510-
511-
table[idx] = entry->volt_uv;
512-
}
344+
int entries;
513345

514-
kfree(plans);
346+
entries = fvmap_get_voltage_table(id, table);
515347

516-
return entries;
348+
return entries;
517349
}
518350

519351
void cal_dfs_set_volt_margin(unsigned int id, int volt)

drivers/soc/samsung/cal-if/fvmap.c

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include "cmucal.h"
1515
#include "fvmap.h"
16-
#include "gpu_dvfs_overrides.h"
1716
#include "ra.h"
1817
#include "vclk.h"
1918

@@ -27,41 +26,6 @@ static int init_margin_table[MAX_MARGIN_ID];
2726
static int volt_offset_percent = 0;
2827
static int percent_margin_table[MAX_MARGIN_ID];
2928

30-
#define G3D_MANUAL_RATE(_mhz, _uv) {.rate = (_mhz) * 1000U, .volt = (_uv)}
31-
32-
static const struct rate_volt g3d_manual_ratevolt[] = {
33-
G3D_MANUAL_RATE(1222, 900000),
34-
G3D_MANUAL_RATE(1066, 875000),
35-
G3D_MANUAL_RATE(962, 850000),
36-
G3D_MANUAL_RATE(845, 825000),
37-
G3D_MANUAL_RATE(754, 800000),
38-
G3D_MANUAL_RATE(702, 775000),
39-
G3D_MANUAL_RATE(650, 750000),
40-
G3D_MANUAL_RATE(572, 725000),
41-
G3D_MANUAL_RATE(433, 700000),
42-
G3D_MANUAL_RATE(377, 675000),
43-
G3D_MANUAL_RATE(325, 650000),
44-
G3D_MANUAL_RATE(260, 625000),
45-
G3D_MANUAL_RATE(200, 600000),
46-
G3D_MANUAL_RATE(156, 575000),
47-
G3D_MANUAL_RATE(100, 550000),
48-
};
49-
50-
static size_t
51-
fvmap_ratevolt_capacity(const volatile struct fvmap_header *header) {
52-
size_t capacity = header->num_of_lv;
53-
54-
if (header->o_tables > header->o_ratevolt) {
55-
size_t ratevolt_capacity =
56-
(header->o_tables - header->o_ratevolt) / sizeof(struct rate_volt);
57-
58-
if (ratevolt_capacity && ratevolt_capacity < capacity)
59-
capacity = ratevolt_capacity;
60-
}
61-
62-
return capacity;
63-
}
64-
6529
static size_t
6630
fvmap_calculate_initial_usage(const volatile struct fvmap_header *header,
6731
int num_of_vclks) {
@@ -86,35 +50,6 @@ fvmap_calculate_initial_usage(const volatile struct fvmap_header *header,
8650
return ALIGN(max_offset, sizeof(u32));
8751
}
8852

89-
static void fvmap_apply_gpu_manual_table(volatile struct fvmap_header *header,
90-
struct rate_volt_header *rate_table,
91-
struct vclk *vclk) {
92-
size_t manual_count = ARRAY_SIZE(g3d_manual_ratevolt);
93-
size_t capacity = fvmap_ratevolt_capacity(header);
94-
size_t idx;
95-
96-
if (capacity < manual_count) {
97-
pr_warn(" G3D manual table truncated to %zu entries (capacity %zu)\n",
98-
capacity, manual_count);
99-
manual_count = capacity;
100-
}
101-
102-
if (!manual_count)
103-
return;
104-
105-
memcpy(rate_table->table, g3d_manual_ratevolt,
106-
manual_count * sizeof(struct rate_volt));
107-
header->num_of_lv = manual_count;
108-
109-
if (vclk && vclk->lut && vclk->num_rates < manual_count)
110-
vclk->num_rates = manual_count;
111-
112-
if (vclk && vclk->lut) {
113-
for (idx = 0; idx < manual_count && idx < vclk->num_rates; idx++)
114-
vclk->lut[idx].rate = g3d_manual_ratevolt[idx].rate;
115-
}
116-
}
117-
11853
static int __init get_mif_volt(char *str) {
11954
int volt;
12055

@@ -516,60 +451,11 @@ static void fvmap_copy_from_sram(void __iomem *map_base,
516451

517452
fw_lv = header[i].num_of_lv;
518453

519-
if (!strcmp(vclk->name, "dvfs_g3d")) {
520-
size_t manual_lv = ARRAY_SIZE(g3d_manual_ratevolt);
521-
size_t capacity = fvmap_ratevolt_capacity(&header[i]);
522-
523-
if (manual_lv > capacity) {
524-
size_t ratevolt_bytes = manual_lv * sizeof(struct rate_volt);
525-
size_t table_bytes = manual_lv * fvmap_header[i].num_of_members;
526-
size_t new_ratevolt_offset =
527-
ALIGN(next_free_offset, sizeof(struct rate_volt));
528-
size_t new_tables_offset =
529-
ALIGN(new_ratevolt_offset + ratevolt_bytes, sizeof(u32));
530-
size_t new_end = new_tables_offset + table_bytes;
531-
532-
if (new_end > FVMAP_SIZE) {
533-
pr_err(" G3D: unable to extend manual table, "
534-
"need %zu bytes, limit %lu – truncating\n",
535-
new_end, FVMAP_SIZE);
536-
manual_lv = capacity;
537-
} else {
538-
pr_info(" G3D: relocating rate/volt tables to 0x%zx "
539-
"to fit %zu entries\n",
540-
new_ratevolt_offset, manual_lv);
541-
fvmap_header[i].o_ratevolt = new_ratevolt_offset;
542-
fvmap_header[i].o_tables = new_tables_offset;
543-
next_free_offset = new_end;
544-
capacity = manual_lv;
545-
}
546-
}
547-
548-
if (manual_lv > capacity) {
549-
pr_warn(" G3D: manual table has %zu entries, "
550-
"FW/capacity only %zu – truncating!\n",
551-
manual_lv, capacity);
552-
manual_lv = capacity;
553-
}
554-
555-
pr_info(" G3D: using %zu levels from manual table "
556-
"(FW advertised %u)\n",
557-
manual_lv, fw_lv);
558-
559-
fvmap_header[i].num_of_lv = manual_lv;
560-
}
561-
562454
pr_info("dvfs_type : %s - id : %x\n", vclk->name,
563455
fvmap_header[i].dvfs_type);
564456
pr_info(" num_of_lv : %d\n", fvmap_header[i].num_of_lv);
565457
pr_info(" num_of_members : %d\n", fvmap_header[i].num_of_members);
566458

567-
if (!strcmp(vclk->name, "dvfs_g3d")) {
568-
pr_info(" G3D init level : %d\n", fvmap_header[i].init_lv);
569-
pr_info(" G3D volt_offset_percent : %d\n", volt_offset_percent);
570-
pr_info(" Using manual G3D rate/volt table\n");
571-
}
572-
573459
old = sram_base + header[i].o_ratevolt;
574460
new = map_base + fvmap_header[i].o_ratevolt;
575461

@@ -618,10 +504,6 @@ static void fvmap_copy_from_sram(void __iomem *map_base,
618504
new->table[j].volt, volt_offset_percent);
619505
}
620506

621-
if (!strcmp(vclk->name, "dvfs_g3d")) {
622-
fvmap_apply_gpu_manual_table(&fvmap_header[i], new, vclk);
623-
}
624-
625507
for (j = 0; j < fvmap_header[i].num_of_lv; j++) {
626508
pr_info(" lv : [%7d], volt = %d uV (%d %%) \n", new->table[j].rate,
627509
new->table[j].volt, volt_offset_percent);
@@ -644,18 +526,6 @@ static void fvmap_copy_from_sram(void __iomem *map_base,
644526
}
645527
}
646528

647-
if (!strcmp(vclk->name, "dvfs_g3d")) {
648-
size_t manual_lv = fvmap_header[i].num_of_lv;
649-
650-
if (manual_lv > fw_lv && fw_lv) {
651-
size_t stride = fvmap_header[i].num_of_members;
652-
653-
for (j = fw_lv; j < manual_lv; j++) {
654-
memcpy(&new_param->val[stride * j],
655-
&new_param->val[stride * (fw_lv - 1)], stride);
656-
}
657-
}
658-
}
659529
}
660530
}
661531

0 commit comments

Comments
 (0)