Skip to content

Commit 61a6920

Browse files
dougg3lynxeye-dev
authored andcommitted
drm/etnaviv: fix power register offset on GC300
Older GC300 revisions have their power registers at an offset of 0x200 rather than 0x100. Add new gpu_read_power and gpu_write_power functions to encapsulate accesses to the power addresses and fix the addresses. Signed-off-by: Doug Brown <[email protected]> Signed-off-by: Lucas Stach <[email protected]>
1 parent cc7d3fb commit 61a6920

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

drivers/gpu/drm/etnaviv/etnaviv_dump.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,15 @@ static void etnaviv_core_dump_registers(struct core_dump_iterator *iter,
8383
{
8484
struct etnaviv_dump_registers *reg = iter->data;
8585
unsigned int i;
86+
u32 read_addr;
8687

8788
for (i = 0; i < ARRAY_SIZE(etnaviv_dump_registers); i++, reg++) {
89+
read_addr = etnaviv_dump_registers[i];
90+
if (read_addr >= VIVS_PM_POWER_CONTROLS &&
91+
read_addr <= VIVS_PM_PULSE_EATER)
92+
read_addr = gpu_fix_power_address(gpu, read_addr);
8893
reg->reg = cpu_to_le32(etnaviv_dump_registers[i]);
89-
reg->value = cpu_to_le32(gpu_read(gpu, etnaviv_dump_registers[i]));
94+
reg->value = cpu_to_le32(gpu_read(gpu, read_addr));
9095
}
9196

9297
etnaviv_core_dump_header(iter, ETDUMP_BUF_REG, reg);

drivers/gpu/drm/etnaviv/etnaviv_gpu.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -590,17 +590,17 @@ static void etnaviv_gpu_enable_mlcg(struct etnaviv_gpu *gpu)
590590
u32 pmc, ppc;
591591

592592
/* enable clock gating */
593-
ppc = gpu_read(gpu, VIVS_PM_POWER_CONTROLS);
593+
ppc = gpu_read_power(gpu, VIVS_PM_POWER_CONTROLS);
594594
ppc |= VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
595595

596596
/* Disable stall module clock gating for 4.3.0.1 and 4.3.0.2 revs */
597597
if (gpu->identity.revision == 0x4301 ||
598598
gpu->identity.revision == 0x4302)
599599
ppc |= VIVS_PM_POWER_CONTROLS_DISABLE_STALL_MODULE_CLOCK_GATING;
600600

601-
gpu_write(gpu, VIVS_PM_POWER_CONTROLS, ppc);
601+
gpu_write_power(gpu, VIVS_PM_POWER_CONTROLS, ppc);
602602

603-
pmc = gpu_read(gpu, VIVS_PM_MODULE_CONTROLS);
603+
pmc = gpu_read_power(gpu, VIVS_PM_MODULE_CONTROLS);
604604

605605
/* Disable PA clock gating for GC400+ without bugfix except for GC420 */
606606
if (gpu->identity.model >= chipModel_GC400 &&
@@ -635,7 +635,7 @@ static void etnaviv_gpu_enable_mlcg(struct etnaviv_gpu *gpu)
635635
pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_HZ;
636636
pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_EZ;
637637

638-
gpu_write(gpu, VIVS_PM_MODULE_CONTROLS, pmc);
638+
gpu_write_power(gpu, VIVS_PM_MODULE_CONTROLS, pmc);
639639
}
640640

641641
void etnaviv_gpu_start_fe(struct etnaviv_gpu *gpu, u32 address, u16 prefetch)
@@ -695,11 +695,11 @@ static void etnaviv_gpu_setup_pulse_eater(struct etnaviv_gpu *gpu)
695695
(gpu->identity.features & chipFeatures_PIPE_3D))
696696
{
697697
/* Performance fix: disable internal DFS */
698-
pulse_eater = gpu_read(gpu, VIVS_PM_PULSE_EATER);
698+
pulse_eater = gpu_read_power(gpu, VIVS_PM_PULSE_EATER);
699699
pulse_eater |= BIT(18);
700700
}
701701

702-
gpu_write(gpu, VIVS_PM_PULSE_EATER, pulse_eater);
702+
gpu_write_power(gpu, VIVS_PM_PULSE_EATER, pulse_eater);
703703
}
704704

705705
static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu)
@@ -1317,9 +1317,9 @@ static void sync_point_perfmon_sample_pre(struct etnaviv_gpu *gpu,
13171317
u32 val;
13181318

13191319
/* disable clock gating */
1320-
val = gpu_read(gpu, VIVS_PM_POWER_CONTROLS);
1320+
val = gpu_read_power(gpu, VIVS_PM_POWER_CONTROLS);
13211321
val &= ~VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
1322-
gpu_write(gpu, VIVS_PM_POWER_CONTROLS, val);
1322+
gpu_write_power(gpu, VIVS_PM_POWER_CONTROLS, val);
13231323

13241324
/* enable debug register */
13251325
val = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
@@ -1350,9 +1350,9 @@ static void sync_point_perfmon_sample_post(struct etnaviv_gpu *gpu,
13501350
gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, val);
13511351

13521352
/* enable clock gating */
1353-
val = gpu_read(gpu, VIVS_PM_POWER_CONTROLS);
1353+
val = gpu_read_power(gpu, VIVS_PM_POWER_CONTROLS);
13541354
val |= VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
1355-
gpu_write(gpu, VIVS_PM_POWER_CONTROLS, val);
1355+
gpu_write_power(gpu, VIVS_PM_POWER_CONTROLS, val);
13561356
}
13571357

13581358

drivers/gpu/drm/etnaviv/etnaviv_gpu.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "etnaviv_gem.h"
1111
#include "etnaviv_mmu.h"
1212
#include "etnaviv_drv.h"
13+
#include "common.xml.h"
1314

1415
struct etnaviv_gem_submit;
1516
struct etnaviv_vram_mapping;
@@ -159,6 +160,26 @@ static inline u32 gpu_read(struct etnaviv_gpu *gpu, u32 reg)
159160
return readl(gpu->mmio + reg);
160161
}
161162

163+
static inline u32 gpu_fix_power_address(struct etnaviv_gpu *gpu, u32 reg)
164+
{
165+
/* Power registers in GC300 < 2.0 are offset by 0x100 */
166+
if (gpu->identity.model == chipModel_GC300 &&
167+
gpu->identity.revision < 0x2000)
168+
reg += 0x100;
169+
170+
return reg;
171+
}
172+
173+
static inline void gpu_write_power(struct etnaviv_gpu *gpu, u32 reg, u32 data)
174+
{
175+
writel(data, gpu->mmio + gpu_fix_power_address(gpu, reg));
176+
}
177+
178+
static inline u32 gpu_read_power(struct etnaviv_gpu *gpu, u32 reg)
179+
{
180+
return readl(gpu->mmio + gpu_fix_power_address(gpu, reg));
181+
}
182+
162183
int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value);
163184

164185
int etnaviv_gpu_init(struct etnaviv_gpu *gpu);

0 commit comments

Comments
 (0)