Skip to content

Commit 44cbbbb

Browse files
committed
fvMap: expand to locate more luts
1 parent 4326adc commit 44cbbbb

1 file changed

Lines changed: 41 additions & 18 deletions

File tree

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

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,31 @@ static void fvmap_apply_gpu_manual_table(volatile struct fvmap_header *header,
100100
if (!manual_count)
101101
return;
102102

103+
if (vclk && vclk->num_rates < manual_count) {
104+
struct vclk_lut *new_lut;
105+
size_t old_count = vclk->num_rates;
106+
107+
new_lut = krealloc_array(vclk->lut, manual_count, sizeof(*new_lut),
108+
GFP_KERNEL);
109+
if (!new_lut) {
110+
pr_err(" G3D: failed to grow LUT to %zu entries\n", manual_count);
111+
manual_count = min_t(size_t, manual_count, old_count);
112+
} else {
113+
vclk->lut = new_lut;
114+
for (idx = old_count; idx < manual_count; idx++) {
115+
vclk->lut[idx].params = kcalloc(vclk->num_list,
116+
sizeof(*vclk->lut[idx].params),
117+
GFP_KERNEL);
118+
if (!vclk->lut[idx].params) {
119+
pr_err(" G3D: failed to allocate params for LUT[%zu]\n",
120+
idx);
121+
manual_count = idx;
122+
break;
123+
}
124+
}
125+
}
126+
}
127+
103128
memcpy(rate_table->table, g3d_manual_ratevolt,
104129
manual_count * sizeof(struct rate_volt));
105130
header->num_of_lv = manual_count;
@@ -625,29 +650,27 @@ static void fvmap_copy_from_sram(void __iomem *map_base,
625650
old_param = sram_base + header[i].o_tables;
626651
new_param = map_base + fvmap_header[i].o_tables;
627652

628-
for (j = 0; j < fw_lv; j++) {
653+
for (j = 0; j < fvmap_header[i].num_of_lv; j++) {
654+
size_t src_lv = (fw_lv && j >= fw_lv) ? (fw_lv - 1) : j;
655+
629656
for (k = 0; k < fvmap_header[i].num_of_members; k++) {
657+
size_t src_param_idx =
658+
fvmap_header[i].num_of_members * src_lv + k;
630659
param_idx = fvmap_header[i].num_of_members * j + k;
631660

632-
new_param->val[param_idx] = old_param->val[param_idx];
633-
if (vclk->lut[j].params[k] != new_param->val[param_idx]) {
634-
vclk->lut[j].params[k] = new_param->val[param_idx];
635-
636-
pr_info("Mis-match %s[%d][%d] : %d %d\n", vclk->name, j, k,
637-
vclk->lut[j].params[k], new_param->val[param_idx]);
638-
}
639-
}
640-
}
641-
642-
if (!strcmp(vclk->name, "dvfs_g3d")) {
643-
size_t manual_lv = fvmap_header[i].num_of_lv;
661+
if (j < fw_lv)
662+
new_param->val[param_idx] = old_param->val[param_idx];
663+
else
664+
new_param->val[param_idx] = new_param->val[src_param_idx];
644665

645-
if (manual_lv > fw_lv && fw_lv) {
646-
size_t stride = fvmap_header[i].num_of_members;
666+
if (vclk->lut && vclk->lut[j].params) {
667+
if (vclk->lut[j].params[k] != new_param->val[param_idx]) {
668+
vclk->lut[j].params[k] = new_param->val[param_idx];
647669

648-
for (j = fw_lv; j < manual_lv; j++) {
649-
memcpy(&new_param->val[stride * j],
650-
&new_param->val[stride * (fw_lv - 1)], stride);
670+
pr_info("Mis-match %s[%d][%d] : %d %d\n", vclk->name, j,
671+
k, vclk->lut[j].params[k],
672+
new_param->val[param_idx]);
673+
}
651674
}
652675
}
653676
}

0 commit comments

Comments
 (0)