drm/etnaviv: GC300 fixes
Subsystems (2)
cover drm/etnaviv: GC300 fixes
This series contains a few special cases for supporting the GC300 properly. These were found in the drivers in the vivante_kernel_drivers repository. These changes were tested on a PXA168 with GC300 revision 0x2201 (date 0x20080814, time 0x12051100), which already has an existing special case in the driver to modify the revision to 0x1051.
I was a little unsure of the "correct" way to do the fixup to the power register offsets. I implemented the change in gpu_write and gpu_read, but if someone has a better idea I would be happy to do it differently.
Doug Brown (2):
drm/etnaviv: add missing quirks for GC300
drm/etnaviv: fix power register offset on GC300
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 11 +++++++++-- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 drm/etnaviv: add missing quirks for GC300
The GC300's features register doesn't specify that a 2D pipe is available, and like the GC600, its idle register reports zero bits where modules aren't present.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +9 -2
@@ -416,6 +416,12 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)if (gpu->identity.model == chipModel_GC700) gpu->identity.features &= ~chipFeatures_FAST_CLEAR; +/* These models/revisions don't have the 2D pipe bit */ +if ((gpu->identity.model == chipModel_GC500 && + gpu->identity.revision <=2 ) || + gpu->identity.model == chipModel_GC300) + gpu->identity.features |= chipFeatures_PIPE_2D; + if ((gpu->identity.model == chipModel_GC500 && gpu->identity.revision < 2) || (gpu->identity.model == chipModel_GC300 &&
@@ -449,8 +455,9 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)gpu_read (gpu,VIVS_HI_CHIP_MINOR_FEATURE_5 ); } -/* GC600 idle register reports zero bits where modules aren't present */ -if (gpu->identity.model == chipModel_GC600) +/* GC600/300 idle register reports zero bits where modules aren't present */ +if (gpu->identity.model == chipModel_GC600 || + gpu->identity.model == chipModel_GC300) gpu->idle_mask =VIVS_HI_IDLE_STATE_TX |VIVS_HI_IDLE_STATE_RA | VIVS_HI_IDLE_STATE_SE |
Signature · 1 line
2.25.1
Re: [PATCH 1/2] drm/etnaviv: add missing quirks for GC300
Quoted 6 lines
The GC300's features register doesn't specify that a 2D pipe is available, and like the GC600, its idle register reports zero bits where modules aren't present.
Signed-off-by Doug Brown <[email protected]>
Quoted 36 lines
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gpu.c +9
-3@@ -416,6 +416,12 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)if (gpu->identity.model == chipModel_GC700) gpu->identity.features &= ~chipFeatures_FAST_CLEAR; +/* These models/revisions don't have the 2D pipe bit */ +if ((gpu->identity.model == chipModel_GC500 && + gpu->identity.revision <=2 ) || + gpu->identity.model == chipModel_GC300) + gpu->identity.features |= chipFeatures_PIPE_2D; + if ((gpu->identity.model == chipModel_GC500 && gpu->identity.revision < 2) || (gpu->identity.model == chipModel_GC300 &&@@ -449,8 +455,9 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)gpu_read (gpu,VIVS_HI_CHIP_MINOR_FEATURE_5 ); } -/* GC600 idle register reports zero bits where modules aren't present */ -if (gpu->identity.model == chipModel_GC600) +/* GC600/300 idle register reports zero bits where modules aren't present */ +if (gpu->identity.model == chipModel_GC600 || + gpu->identity.model == chipModel_GC300) gpu->idle_mask =VIVS_HI_IDLE_STATE_TX |VIVS_HI_IDLE_STATE_RA | VIVS_HI_IDLE_STATE_SE | --2.25.1
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy
PATCH 2/2 drm/etnaviv: fix power register offset on GC300
In reply to Doug BrownOlder GC300 revisions have their power registers at an offset of 0x200 rather than 0x100.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.h +14 -2
@@ -10,6 +10,8 @@#include "etnaviv_gem.h" #include "etnaviv_mmu.h" #include "etnaviv_drv.h" +#include "common.xml.h" +#include "state_hi.xml.h" struct etnaviv_gem_submit ;struct etnaviv_vram_mapping ;
@@ -149,14 +151,24 @@ struct etnaviv_gpu {unsigned long base_rate_shader; }; +static inline u32 gpu_fix_reg_address (struct etnaviv_gpu *gpu,u32 reg) +{ +/* Power registers in GC300 < 2.0 are offset by 0x100 */ +if (reg >=VIVS_PM_POWER_CONTROLS && reg <=VIVS_PM_PULSE_EATER && + gpu->identity.model == chipModel_GC300 && + gpu->identity.revision <0x2000 ) + reg +=0x100 ; +return reg; +} +static inline void gpu_write (struct etnaviv_gpu *gpu,u32 reg,u32 data) { -writel (data, gpu->mmio + reg); +writel (data, gpu->mmio +gpu_fix_reg_address (gpu, reg)); }static inline u32 gpu_read (struct etnaviv_gpu *gpu,u32 reg) { -return readl (gpu->mmio + reg); +return readl (gpu->mmio +gpu_fix_reg_address (gpu, reg)); }int etnaviv_gpu_get_param (struct etnaviv_gpu *gpu,u32 param,u64 *value);
Signature · 1 line
2.25.1
Christian Gmeiner
reviewerRe: [PATCH 2/2] drm/etnaviv: fix power register offset on GC300
Hi
Quoted 38 lines
Older GC300 revisions have their power registers at an offset of
0x200rather than0x100.Signed-off-by Doug Brown <[email protected]>--- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gpu.h +12
-0@@ -10,6 +10,8 @@#include "etnaviv_gem.h" #include "etnaviv_mmu.h" #include "etnaviv_drv.h" +#include "common.xml.h" +#include "state_hi.xml.h" struct etnaviv_gem_submit ;struct etnaviv_vram_mapping ;@@ -149,14 +151,24 @@ struct etnaviv_gpu {unsigned long base_rate_shader; }; +static inline u32 gpu_fix_reg_address (struct etnaviv_gpu *gpu,u32 reg) +{ +/* Power registers in GC300 < 2.0 are offset by 0x100 */ +if (reg >=VIVS_PM_POWER_CONTROLS && reg <=VIVS_PM_PULSE_EATER && + gpu->identity.model == chipModel_GC300 && + gpu->identity.revision <0x2000 ) + reg +=0x100 ; +return reg; +} +static inline void gpu_write (struct etnaviv_gpu *gpu,u32 reg,u32 data) {
drivers/gpu/drm/etnaviv/etnaviv_gpu.h struct etnaviv_gpu { · line 173
Quoted 10 lines
drivers/gpu/drm/etnaviv/etnaviv_gpu.h +2
-2-writel (data, gpu->mmio + reg); +writel (data, gpu->mmio +gpu_fix_reg_address (gpu, reg)); }static inline u32 gpu_read (struct etnaviv_gpu *gpu,u32 reg) { -return readl (gpu->mmio + reg); +return readl (gpu->mmio +gpu_fix_reg_address (gpu, reg)); }
I had a quick look at what vivantes kernel driver did. It uses a per gpu instance variable powerBaseAddress
that gets set accordingly. I am not sure if I really like the gpu_fix_reg_address(..) idea, as it gets called on every register read and write. For me I see two other possible solutions:
1) Add two seperate helpers ala gpu_read_power() and gpu_write_power() where we do the if beast.
2) Add a power register offset variable to etnaviv_gpu and explicitly use it on for reads and writes - like the Vivante driver does.
But that's just my personal opinion. Can't wait to hear what Lucas thinks.
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy
Re: [PATCH 2/2] drm/etnaviv: fix power register offset on GC300
Hi Christian,
Quoted 6 lines · Christian Gmeiner
I had a quick look at what vivantes kernel driver did. It uses a per gpu instance variable powerBaseAddress
that gets set accordingly. I am not sure if I really like thegpu_fix_reg_address(..)idea, as it gets called on every register read and write. For me I see two other possible solutions:
Quoted 7 lines
1) Add two seperate helpers ala
gpu_read_power()andgpu_write_power()where we do the if beast.
2) Add a power register offset variable toetnaviv_gpuand explicitly use it on for reads and writes - like the Vivante driver does.But that's just my personal opinion. Can't wait to hear what Lucas thinks.
Thanks for reviewing so fast! I honestly agree. It felt kind of dirty modifying gpu_write and gpu_read. The reason I went for it is I was thinking that in most cases the compiler is going to optimize the ugly "if" out.
The two solutions listed above both sound good. They would need a special case in etnaviv_core_dump_registers, but that's probably much less nasty than modifying gpu_read and gpu_write. Any preferences from everyone on which of the other two options I should do? The gpu_read_power and gpu_write_power approach sounds pretty clean to me.
Also, dropping David Airlie from the chain -- his email address bounced on my original patch messages.
Doug
Lucas Stach
maintainerRe: [PATCH 2/2] drm/etnaviv: fix power register offset on GC300
Hi Doug,
Am Montag, dem 05.09.2022 um 14:05 -0700 schrieb Doug Brown:
Quoted 23 lines
Hi Christian,
Quoted 6 lines · Christian Gmeiner
I had a quick look at what vivantes kernel driver did. It uses a per gpu instance variable powerBaseAddress
that gets set accordingly. I am not sure if I really like thegpu_fix_reg_address(..)idea, as it gets called on every register read and write. For me I see two other possible solutions:Quoted 7 lines
1) Add two seperate helpers ala
gpu_read_power()andgpu_write_power()where we do the if beast.
2) Add a power register offset variable toetnaviv_gpuand explicitly use it on for reads and writes - like the Vivante driver does.But that's just my personal opinion. Can't wait to hear what Lucas thinks.
Thanks for reviewing so fast! I honestly agree. It felt kind of dirty modifying
gpu_writeandgpu_read. The reason I went for it is I was thinking that in most cases the compiler is going to optimize the ugly "if" out.
Quoted 5 lines
The two solutions listed above both sound good. They would need a special case in
etnaviv_core_dump_registers, but that's probably much less nasty than modifyinggpu_readandgpu_write. Any preferences from everyone on which of the other two options I should do? Thegpu_read_powerandgpu_write_powerapproach sounds pretty clean to me.
Yes, please add a specialized wrapper for the power register accesses.
Regards,
Lucas