Mali-450 support by lima

thanks,so adding this regulator fixes all our problems on init? Did you add any of the mtk specific quirks in driver?

No, only debug messages. Also Iā€™ve tested it across reboot - same result.

Yep :slight_smile:

P.S. Iā€™m still not sure which way is more correct, power-on device on init by driver, or power-on by voltage regulator on boot. 1st is more likely on gpu-less configuration e.g. as router. 2nd letā€™s use unified driver.

Anyway its a discussion for times when weā€™ll test both :slight_smile:

thank you tried in 4.19, here it seems not enough (still ā€œmmu gpmmu dte write test failā€ at boottime), but i can activate it via devmem2ā€¦maybe before i had not waited enough time (made now a 15 s delay)

https://github.com/frank-w/BPI-R2-4.14/commits/4.19-lima

will try on 5.4

Ok, Iā€™ll commit all changes to not miss something.

How is g3dsys defined?

BTW, itā€™s my another change.

after i unload mali, run devmem2 and load lima again (after waiting 15s) lima gets initialized

root@bpi-r2:~# dmesg | grep lima                                                
[    0.000000] Linux version 4.19.92-bpi-r2-lima (frank@frank-G5) (gcc version 0
[   10.361897] lima 13040000.gpu: bus rate = 500500000                          
[   10.371909] lima 13040000.gpu: mod rate = 500500000                          
[   10.436896] lima 13040000.gpu: mmu gpmmu dte write test fail                 
[   10.488376] lima 13040000.gpu: ttm finalized                                 
[   10.497105] lima 13040000.gpu: Fatal error during GPU init                   
[   10.507339] lima: probe of 13040000.gpu failed with error -5                 

root@bpi-r2:~# modprobe -r lima                                                 
root@bpi-r2:~# ./devmem2 0x1000301C                                             
/dev/mem opened.                                                                
Memory mapped at address 0xb6f71000.                                            
Value at address 0x1000301C (0xb6f7101c): 0xFFF                                 
root@bpi-r2:~# ./devmem2 0x10003014 w 0x00000001                                
/dev/mem opened.                                                                
Memory mapped at address 0xb6f04000.                                            
Value at address 0x10003014 (0xb6f04014): 0x0                                   
Written 0x1; readback 0x0                                                       
root@bpi-r2:~# modprobe lima

[   77.822367] lima 13040000.gpu: bus rate = 500500000                          
[   77.827282] lima 13040000.gpu: mod rate = 500500000                          
[   77.851617] lima 13040000.gpu: gp - mali450 version major 0 minor 0          
[   77.857983] lima 13040000.gpu: pp0 - mali450 version major 0 minor 0         
[   77.864502] lima 13040000.gpu: pp1 - mali450 version major 0 minor 0         
[   77.870865] lima 13040000.gpu: pp2 - mali450 version major 0 minor 0         
[   77.877264] lima 13040000.gpu: pp3 - mali450 version major 0 minor 0         
[   77.883708] lima 13040000.gpu: l2 cache 8K, 4-way, 64byte cache line, 128bits
[   77.891831] lima 13040000.gpu: l2 cache 128K, 4-way, 64byte cache line, 128bs
[   77.903240] [drm] Initialized lima 1.0.0 20170325 for 13040000.gpu on minor 1

edit:

5.4-lima same (and lima built-in so i cannot unload/load atm)

root@bpi-r2:~# dmesg | grep lima                                                
[    0.000000] Linux version 5.4.12-bpi-r2-lima (frank@frank-G5) (gcc version 80
[    5.346493] DEBUG: Passed lima_pdev_probe 284 (probe start)                  
[    5.352154] DEBUG: Passed lima_pdev_probe 288 (slab init)                    
[    5.357686] DEBUG: Passed lima_pdev_probe 308 (alloc)                        
[    5.363172] DEBUG: Passed lima_init_ip 178                                   
[    5.367368] DEBUG: Passed lima_init_ip 181                                   
[    5.371601] lima 13040000.gpu: IRQ pmu not found                             
[    5.376221] DEBUG: Passed lima_init_ip 178                                   
[    5.380424] DEBUG: Passed lima_init_ip 181                                   
[    5.384639] DEBUG: Passed lima_init_ip 191                                   
[    5.388842] lima 13040000.gpu: mmu gpmmu dte write test fail                 
[    5.394502] DEBUG: Passed lima_init_ip 197                                   
[    5.438415] lima: probe of 13040000.gpu failed with error -5

https://github.com/d3adme4t/BPI-R2-4.14/tree/5.5-merged-lima-testing all my changes, w/o cleaning

btw, thera are changes in drivers/gpu/drm/lima/lima_pmu.c that i alredy forgot.

looks like pmu-patch works (have not changed syscon-node)ā€¦

root@bpi-r2:~# dmesg | grep lima                                                
[    0.000000] Linux version 5.4.12-bpi-r2-lima (frank@frank-G5) (gcc version 80
[   11.316340] DEBUG: Passed lima_pdev_probe 284 (probe start)                  
[   11.326717] DEBUG: Passed lima_pdev_probe 288 (slab init)                    
[   11.336732] DEBUG: Passed lima_pdev_probe 308 (alloc)                        
[   11.346355] LIMA_INIT: lima_clk_init                                         
[   11.354306] LIMA_INIT: lima_clk_init_err:0                                   
[   11.362677] LIMA_INIT: lima_regulator_init_err:0                             
[   11.471228] LIMA_INIT: lima_dlbu_cpu no err:0                                
[   11.480124] DEBUG: Passed lima_init_ip 178                                   
[   11.488373] DEBUG: Passed lima_init_ip 181                                   
[   11.496536] lima 13040000.gpu: IRQ pmu not found                             
[   11.505096] lima 13040000.gpu: Lima_init_ip: ip:0, err:0                     
[   11.514308] DEBUG: Passed lima_init_ip 178                                   
[   11.522328] DEBUG: Passed lima_init_ip 181                                   
[   11.530381] DEBUG: Passed lima_init_ip 191                                   
[   11.538484] lima 13040000.gpu: mmu gpmmu dte write: ADDR:0,val:cafebabe      
[   11.549170] lima 13040000.gpu: mmu gpmmu dte read: ADDR:0,val:cafeb000       
[   11.559775] lima 13040000.gpu: Lima_init_ip: ip:1, err:0                     
[   11.568958] DEBUG: Passed lima_init_ip 178                                   
[   11.577026] DEBUG: Passed lima_init_ip 181                                   
[   11.584926] DEBUG: Passed lima_init_ip 191                                   
[   11.592708] lima 13040000.gpu: mmu ppmmu0 dte write: ADDR:0,val:cafebabe     
[   11.602987] lima 13040000.gpu: mmu ppmmu0 dte read: ADDR:0,val:cafeb000      
[   11.613148] lima 13040000.gpu: Lima_init_ip: ip:2, err:0                     
[   11.621797] DEBUG: Passed lima_init_ip 178                                   
[   11.629256] DEBUG: Passed lima_init_ip 181                                   
[   11.636610] DEBUG: Passed lima_init_ip 191                                   
[   11.643825] lima 13040000.gpu: mmu ppmmu1 dte write: ADDR:0,val:cafebabe     
[   11.653612] lima 13040000.gpu: mmu ppmmu1 dte read: ADDR:0,val:cafeb000      
[   11.663275] lima 13040000.gpu: Lima_init_ip: ip:3, err:0                     
[   11.671492] DEBUG: Passed lima_init_ip 178                                   
[   11.678404] DEBUG: Passed lima_init_ip 181                                   
[   11.685293] DEBUG: Passed lima_init_ip 191                                   
[   11.692091] lima 13040000.gpu: mmu ppmmu2 dte write: ADDR:0,val:cafebabe     
[   11.701419] lima 13040000.gpu: mmu ppmmu2 dte read: ADDR:0,val:cafeb000      
[   11.710672] lima 13040000.gpu: Lima_init_ip: ip:4, err:0                     
[   11.718416] DEBUG: Passed lima_init_ip 178                                   
[   11.725017] DEBUG: Passed lima_init_ip 181                                   
[   11.731498] DEBUG: Passed lima_init_ip 191                                   
[   11.737878] lima 13040000.gpu: mmu ppmmu3 dte write: ADDR:0,val:cafebabe     
[   11.746949] lima 13040000.gpu: mmu ppmmu3 dte read: ADDR:0,val:cafeb000      
[   11.756004] lima 13040000.gpu: Lima_init_ip: ip:5, err:0                     
[   11.763649] DEBUG: Passed lima_init_ip 178                                   
[   11.770116] DEBUG: Passed lima_init_ip 181                                   
[   11.776503] lima 13040000.gpu: IRQ ppmmu4 not found                          
[   11.783665] lima 13040000.gpu: Lima_init_ip: ip:6, err:0                     
[   11.791321] DEBUG: Passed lima_init_ip 178                                   
[   11.797754] DEBUG: Passed lima_init_ip 181                                   
[   11.804219] lima 13040000.gpu: IRQ ppmmu5 not found                          
[   11.811434] lima 13040000.gpu: Lima_init_ip: ip:7, err:0                     
[   11.819095] DEBUG: Passed lima_init_ip 178                                   
[   11.825605] DEBUG: Passed lima_init_ip 181                                   
[   11.832063] lima 13040000.gpu: IRQ ppmmu6 not found                          
[   11.839260] lima 13040000.gpu: Lima_init_ip: ip:8, err:0                     
[   11.846818] DEBUG: Passed lima_init_ip 178                                   
[   11.853262] DEBUG: Passed lima_init_ip 181                                   
[   11.859728] lima 13040000.gpu: IRQ ppmmu7 not found                          
[   11.866908] lima 13040000.gpu: Lima_init_ip: ip:9, err:0                     
[   11.874521] DEBUG: Passed lima_init_ip 178                                   
[   11.881020] DEBUG: Passed lima_init_ip 181                                   
[   11.887427] DEBUG: Passed lima_init_ip 191                                   
[   11.893797] lima 13040000.gpu: gp - mali450 version major 0 minor 0          
[   11.902446] lima 13040000.gpu: Lima_init_ip: ip:10, err:0                    
[   11.910205] DEBUG: Passed lima_init_ip 178                                   
[   11.916620] DEBUG: Passed lima_init_ip 181                                   
[   11.923084] DEBUG: Passed lima_init_ip 191                                   
[   11.929473] lima 13040000.gpu: pp0 - mali450 version major 0 minor 0         
[   11.938133] lima 13040000.gpu: Lima_init_ip: ip:11, err:0                    
[   11.945861] DEBUG: Passed lima_init_ip 178                                   
[   11.952394] DEBUG: Passed lima_init_ip 181                                   
[   11.958845] DEBUG: Passed lima_init_ip 191                                   
[   11.965177] lima 13040000.gpu: pp1 - mali450 version major 0 minor 0         
[   11.973875] lima 13040000.gpu: Lima_init_ip: ip:12, err:0                    
[   11.981528] DEBUG: Passed lima_init_ip 178                                   
[   11.987929] DEBUG: Passed lima_init_ip 181                                   
[   11.994424] DEBUG: Passed lima_init_ip 191                                   
[   12.000809] lima 13040000.gpu: pp2 - mali450 version major 0 minor 0         
[   12.009537] lima 13040000.gpu: Lima_init_ip: ip:13, err:0                    
[   12.017142] DEBUG: Passed lima_init_ip 178                                   
[   12.023556] DEBUG: Passed lima_init_ip 181                                   
[   12.030013] DEBUG: Passed lima_init_ip 191                                   
[   12.036334] lima 13040000.gpu: pp3 - mali450 version major 0 minor 0         
[   12.045031] lima 13040000.gpu: Lima_init_ip: ip:14, err:0                    
[   12.052680] DEBUG: Passed lima_init_ip 178                                   
[   12.059139] DEBUG: Passed lima_init_ip 181                                   
[   12.065494] lima 13040000.gpu: IRQ pp4 not found                             
[   12.072360] lima 13040000.gpu: Lima_init_ip: ip:15, err:0                    
[   12.079983] DEBUG: Passed lima_init_ip 178                                   
[   12.079995] DEBUG: Passed lima_init_ip 181                                   
[   12.092780] lima 13040000.gpu: IRQ pp5 not found                             
[   12.100252] lima 13040000.gpu: Lima_init_ip: ip:16, err:0                    
[   12.108273] DEBUG: Passed lima_init_ip 178                                   
[   12.114702] DEBUG: Passed lima_init_ip 181                                   
[   12.121103] lima 13040000.gpu: IRQ pp6 not found                             
[   12.127904] lima 13040000.gpu: Lima_init_ip: ip:17, err:0                    
[   12.135514] DEBUG: Passed lima_init_ip 178                                   
[   12.141962] DEBUG: Passed lima_init_ip 181                                   
[   12.148367] lima 13040000.gpu: IRQ pp7 not found                             
[   12.155237] lima 13040000.gpu: Lima_init_ip: ip:18, err:0                    
[   12.162886] DEBUG: Passed lima_init_ip 178                                   
[   12.169302] DEBUG: Passed lima_init_ip 181                                   
[   12.175648] DEBUG: Passed lima_init_ip 191                                   
[   12.182065] lima 13040000.gpu: l2 cache 8K, 4-way, 64byte cache line, 128bits
[   12.192586] lima 13040000.gpu: Lima_init_ip: ip:19, err:0                    
[   12.200297] DEBUG: Passed lima_init_ip 178                                   
[   12.206709] DEBUG: Passed lima_init_ip 181                                   
[   12.213160] DEBUG: Passed lima_init_ip 191                                   
[   12.219643] lima 13040000.gpu: l2 cache 128K, 4-way, 64byte cache line, 128bs
[   12.230400] lima 13040000.gpu: Lima_init_ip: ip:20, err:0                    
[   12.238160] DEBUG: Passed lima_init_ip 178                                   
[   12.244685] DEBUG: Passed lima_init_ip 181                                   
[   12.251201] DEBUG: Passed lima_init_ip 191                                   
[   12.257668] DEBUG: Passed lima_init_ip 197                                   
[   12.264087] lima 13040000.gpu: Lima_init_ip: ip:21, err:0                    
[   12.271778] DEBUG: Passed lima_init_ip 178                                   
[   12.278173] DEBUG: Passed lima_init_ip 181                                   
[   12.284595] DEBUG: Passed lima_init_ip 191                                   
[   12.291036] lima 13040000.gpu: Lima_init_ip: ip:22, err:0                    
[   12.298681] DEBUG: Passed lima_init_ip 178                                   
[   12.305067] DEBUG: Passed lima_init_ip 181                                   
[   12.311421] DEBUG: Passed lima_init_ip 191                                   
[   12.317749] lima 13040000.gpu: Lima_init_ip: ip:23, err:0                    
[   12.325364] DEBUG: Passed lima_init_ip 178                                   
[   12.331768] DEBUG: Passed lima_init_ip 181                                   
[   12.338106] DEBUG: Passed lima_init_ip 191                                   
[   12.344528] lima 13040000.gpu: Lima_init_ip: ip:24, err:0                    
[   12.352146] DEBUG: Passed lima_init_ip 178                                   
[   12.358488] DEBUG: Passed lima_init_ip 181                                   
[   12.364795] DEBUG: Passed lima_init_ip 191                                   
[   12.371135] lima 13040000.gpu: Lima_init_ip: ip:25, err:0                    
[   12.381101] lima 13040000.gpu: bus rate = 500500000                          
[   12.388160] lima 13040000.gpu: mod rate = 500500000                          
[   12.395427] DEBUG: Passed lima_pdev_probe 312 (dev init)                     
[   12.403638] [drm] Initialized lima 1.0.0 20190217 for 13040000.gpu on minor 1
[   12.420272] DEBUG: Passed lima_pdev_probe 320 (probe_finish)                 
root@bpi-r2:~#

btw. stripped some whitespaces before commitā€¦how can we test if lima is working?

root@bpi-r2:~# ls -la /dev/dri/                                                 
total 0                                                                         
drwxr-xr-x  3 root root        120 Jan 22 09:28 .                               
drwxr-xr-x 15 root root      13480 Jan 22 09:28 ..                              
drwxr-xr-x  2 root root        100 Jan 22 09:28 by-path                         
crw-rw----  1 root video  226,   0 Jan 22 09:28 card0                           
crw-rw----  1 root video  226,   1 Jan 22 09:28 card1                           
crw-rw----  1 root render 226, 128 Jan 22 09:28 renderD128                      
root@bpi-r2:~#

mhm, looks like 4.19-lima does already have the pmu-patchā€¦

Hey based "writel(0x00000010 ", this time it is global reset register.

After write wakup_register (pointer) it is 100% sure it wakeup GPU. It is not needed to check. Ofcourse posible, be free to add.

Better idea is to first check 0x1000301C and if it have 0th bit 1 then do write to wakup_register. Anyway it saves to code if only force wakeup. It dosnā€™t hurt to do it even GPU active.

Ah you mean that you find 4.16-mt tree some powermanagement lines and want to check are them effective?? So put two printkā€™s and readl( 0x1000301C-pointer) before and after pm-lines. Is it what you think? And do that in 4.16-mt. It is intresting to know result.

I use config_mtk_combo because it was first line where 7623 and =y. Have better idea to check in compilation that we are in 7623 chipā€¦?

Devmem calls: atleast first is needed. Second reset seems to be ineffective, it can drop out. And delays posible to ripe out.

Alex find some power management lines from 4.16-mt tree. Need to check are them enough.

Tryed rmmod lima && modprobe lima? Based timelines you be very fast or didnā€™t do reload.

ah, ok, you only searched for any way to check for mt7623 :slight_smile:

in 5.4, i do not need any of the devmem-callsā€¦it goes up on bootime :wink: so i try it with 4.19 which still failes on boottimeā€¦

if i unload+load after boot (no devmem), it works on 4.19 tooā€¦seems like only timing issue

dmesg_4.19.log (31,3 KB)

lima init is very late, but maybe drm core is not ready yet

imho the best way will be defining regulator in dts, but disabled and switch on in driver (if possible).

I added it in 4.19-main and got one new unbalanced line in dmesg:

[   14.197263] lima: unknown parameter 'debug' ignored
[   14.198572] lima 13040000.gpu: bus rate = 500500000
[   14.198588] lima 13040000.gpu: mod rate = 500500000
[   14.225870] lima 13040000.gpu: mmu gpmmu dte write test fail
[   14.229008] lima 13040000.gpu: ttm finalized
[   14.229046] lima 13040000.gpu: Fatal error during GPU init
[   14.229225] lima: probe of 13040000.gpu failed with error -5
[  101.794467] lima: unknown parameter 'debug' ignored
[  101.795680] lima 13040000.gpu: Unbalanced pm_runtime_enable!
[  101.795746] lima 13040000.gpu: bus rate = 500500000
[  101.795754] lima 13040000.gpu: mod rate = 500500000
[  101.798139] lima 13040000.gpu: gp - mali450 version major 0 minor 0
[  101.798195] lima 13040000.gpu: pp0 - mali450 version major 0 minor 0
[  101.798252] lima 13040000.gpu: pp1 - mali450 version major 0 minor 0
[  101.798300] lima 13040000.gpu: pp2 - mali450 version major 0 minor 0
[  101.798347] lima 13040000.gpu: pp3 - mali450 version major 0 minor 0
[  101.798390] lima 13040000.gpu: l2 cache 8K, 4-way, 64byte cache line, 128bit external bus
[  101.798398] lima 13040000.gpu: l2 cache 128K, 4-way, 64byte cache line, 128bit external bus
[  101.801073] [drm] Initialized lima 1.0.0 20170325 for 13040000.gpu on minor 1

Still needs rmmod lima && modprobe lima

Edit: Ok unbalanced line comes that it dosnā€™t deactivate powermanagement when unloading module. It needs to add somewhere module unloadingā€¦ (minor bug)

Can you devmem2 0x1000301C between tests so we get data can it poweron GPU alone. If its read FFF then it is sure that GPU is inactive.

root@bpi-r2:~# ./devmem2 0x1000301C                                             
/dev/mem opened.                                                                
Memory mapped at address 0xb6f8f000.                                            
Value at address 0x1000301C (0xb6f8f01c): 0xFFF                                 
root@bpi-r2:~# modprobe -r lima                                                 
root@bpi-r2:~# ./devmem2 0x1000301C                                             
/dev/mem opened.                                                                
Memory mapped at address 0xb6ff2000.                                            
Value at address 0x1000301C (0xb6ff201c): 0xFFF                                 
root@bpi-r2:~# modprobe lima                                                    
[   70.541999] LIMA_INIT: lima_clk_init                                         
[   70.545644] lima 13040000.gpu: bus rate = 500500000                          
[   70.550489] lima 13040000.gpu: mod rate = 500500000                          
[   70.555397] LIMA_INIT: lima_clk_init_err:0                                   
[   70.559504] LIMA_INIT: lima_regulator_init_err:0                             
[   70.564439] [TTM] Zone  kernel: Available graphics memory: 247594 kiB        
[   70.570836] [TTM] Zone highmem: Available graphics memory: 1029416 kiB       
[   70.577374] [TTM] Initializing pool allocator                                
[   70.583331] LIMA_INIT: lima_dlbu_cpu no err:0                                
[   70.587703] lima 13040000.gpu: Lima_init_ip: ip:0, err:0                     
[   70.593068] lima 13040000.gpu: Lima_init_ip: ip:1, err:0                     
[   70.598444] lima 13040000.gpu: Lima_init_ip: ip:2, err:0                     
[   70.603951] lima 13040000.gpu: Lima_init_ip: ip:3, err:0                     
[   70.609284] lima 13040000.gpu: Lima_init_ip: ip:4, err:0                     
[   70.614657] lima 13040000.gpu: Lima_init_ip: ip:5, err:0                     
[   70.619940] lima 13040000.gpu: Lima_init_ip: ip:6, err:0                     
[   70.625267] lima 13040000.gpu: Lima_init_ip: ip:7, err:0                     
[   70.630548] lima 13040000.gpu: Lima_init_ip: ip:8, err:0                     
[   70.635865] lima 13040000.gpu: Lima_init_ip: ip:9, err:0                     
[   70.641173] lima 13040000.gpu: gp - mali450 version major 0 minor 0          
[   70.647511] lima 13040000.gpu: Lima_init_ip: ip:10, err:0                    
[   70.652905] lima 13040000.gpu: pp0 - mali450 version major 0 minor 0         
[   70.659305] lima 13040000.gpu: Lima_init_ip: ip:11, err:0                    
[   70.664747] lima 13040000.gpu: pp1 - mali450 version major 0 minor 0         
[   70.671111] lima 13040000.gpu: Lima_init_ip: ip:12, err:0                    
[   70.676514] lima 13040000.gpu: pp2 - mali450 version major 0 minor 0         
[   70.682883] lima 13040000.gpu: Lima_init_ip: ip:13, err:0                    
[   70.688319] lima 13040000.gpu: pp3 - mali450 version major 0 minor 0         
[   70.694732] lima 13040000.gpu: Lima_init_ip: ip:14, err:0                    
[   70.700096] lima 13040000.gpu: Lima_init_ip: ip:15, err:0                    
[   70.705494] lima 13040000.gpu: Lima_init_ip: ip:16, err:0                    
[   70.710859] lima 13040000.gpu: Lima_init_ip: ip:17, err:0                    
[   70.716258] lima 13040000.gpu: Lima_init_ip: ip:18, err:0                    
[   70.721624] lima 13040000.gpu: l2 cache 8K, 4-way, 64byte cache line, 128bit 
external bus                                                                    
[   70.729782] lima 13040000.gpu: Lima_init_ip: ip:19, err:0                    
[   70.735176] lima 13040000.gpu: l2 cache 128K, 4-way, 64byte cache line, 128bi
t external bus                                                                  
[   70.743507] lima 13040000.gpu: Lima_init_ip: ip:20, err:0                    
[   70.748877] lima 13040000.gpu: Lima_init_ip: ip:21, err:0                    
[   70.754274] lima 13040000.gpu: Lima_init_ip: ip:22, err:0                    
[   70.759637] lima 13040000.gpu: Lima_init_ip: ip:23, err:0                    
[   70.765128] lima 13040000.gpu: Lima_init_ip: ip:24, err:0                    
[   70.770492] lima 13040000.gpu: Lima_init_ip: ip:25, err:0                    
[   70.777934] [drm] Initialized lima 1.0.0 20170325 for 13040000.gpu on minor 1
root@bpi-r2:~# ./devmem2 0x1000301C                                             
/dev/mem opened.                                                                
Memory mapped at address 0xb6f9e000.                                            
Value at address 0x1000301C (0xb6f9e01c): 0xFFF                                 
root@bpi-r2:~#

also after successful lima init it is 0xFFF :stuck_out_tongue: i guess this is not the right power-line

compared power-consumption on 5.4 (otg branch = without lima and lima-branch with initialized lima).

  • without lima: 5.2w
  • with lima: 9.4w (no matter if i unload lima afterwards)

so at least lima should switch power on/off on load/unload to have good state. we have a lima_regulator_init callā€¦why not use it to power on the new regulator too??

It is documented by Mediatek. It sure right and if its read 0xFFF then GPU is power off. Have you measured power when it is 0xFFE??? I donā€™t know is powermanagement able to toggle it running kernel fast frequency. If it works right it can toggle off when GPU have no work to do.

How you measure power consumption? Is is posible onboard or need it some external instruments?

You mean what? Codepiece orā€¦? You mean ā€¦bpi.dts regulator line?

use this to switch on/off regulator defined in dts (vdd_g3d-supply = <&vdd_fixed_vgpu_reg>;):

drivers/gpu/drm/lima/lima_device.c:141:static int lima_regulator_init(struct lima_device *dev)

it seems that the regulator is not referenced in code by nameā€¦so i guess itā€™s on only by definition and does not change the register you try to loadā€¦but how does kernel know where to supply the voltage defined (so it goes to mali chip)

145         dev->regulator = devm_regulator_get_optional(dev->dev, "mali");
146         if (IS_ERR(dev->regulator)) {
147                 ret = PTR_ERR(dev->regulator);
148                 dev->regulator = NULL;
149                 if (ret == -ENODEV)
150                         return 0;
151                 if (ret != -EPROBE_DEFER)
152                         dev_err(dev->dev, "failed to get regulator: %d\n", $
153                 return ret;
154         }
155
156         ret = regulator_enable(dev->regulator);

should the regulator named also mali??? or how is it found in dts? name mali will conflict with the gpu-node itselfā€¦maybe itā€™s enough to change ā€œmaliā€ to ā€œvdd_g3d-supplyā€

i use a basic external wattmeter on power-supply of the board

after 5.4-lima bootup (lima initialized): 9.3w (0xFFF state), and same consumption after i executed the devmem-write

root@bpi-r2:~# ./devmem2 0x10003014 w 0x00000001                                
/dev/mem opened.                                                                
Memory mapped at address 0xb6f90000.                                            
Value at address 0x10003014 (0xb6f90014): 0x0                                   
Written 0x1; readback 0x0                                                       
root@bpi-r2:~# ./devmem2 0x1000301C                                             
/dev/mem opened.                                                                
Memory mapped at address 0xb6f26000.                                            
Value at address 0x1000301C (0xb6f2601c): 0xFFE                                 
root@bpi-r2:~#

Well I added in 4.19-main: lima_device.c

#include <linux/pm_runtime.h>

int lima_device_init(struct lima_device *ldev)
{
        int err, i;
        struct resource *res;

        #ifdef CONFIG_MTK_COMBO_CHIP_CONSYS_7623
        void __iomem *wakeup_register;
        wakeup_register = ioremap(0x10003014 , 0x04);
        writel(0x00000001,wakeup_register); // this may be wrong, may need bitbang 0th bit to 1
        iounmap(wakeup_register);

        pm_runtime_enable(ldev->dev);
        pm_runtime_set_active(ldev->dev);
        pm_runtime_get_sync(ldev->dev);
        #endif

void lima_device_fini(struct lima_device *ldev)
{
        int i;
        #ifdef CONFIG_MTK_COMBO_CHIP_CONSYS_7623
        void __iomem *powerdown_register;
        #endif

--clip--
        lima_ttm_fini(ldev);

        #ifdef CONFIG_MTK_COMBO_CHIP_CONSYS_7623
        pm_runtime_set_suspended(ldev->dev);
        pm_runtime_put_noidle(ldev->dev);
        pm_runtime_disable(ldev->dev);

        powerdown_register = ioremap(0x1000300C , 0x04); // powerdown register
        writel(0x00000001,powerdown_register); // this may be wrong, may need bitbang 0th bit to 1
        iounmap(powerdown_register);
        #endif

And after rmmod lima it reads 0xFFF so can you test it in your powermeter?? It still have unbalanced powermanagemet error. But it is minor bug

in my 5.4-tree there is no change in power-consumption after unloading limaā€¦but i have your patches not appliedā€¦imho it is very specific hardcoded register-write which should be defined in dts and executed in code (lima_regulator_*). good for testing, but unable to put to mainline

changing regulator-name in lima_device.c does not power off it on unloadā€¦no change in logsā€¦

No broblem, but you are sure they like .dtsi changes in upstream? Mediatek do lot inside kernel without .dtsi documentation. Who supplies patches to upstream?

ok, find that reset is defined here:

#define MT2701_PERI_GCPU_SW_RST                 5

Find also why 3dgsys may affect:
#define MT2701_G3DSYS_CORE_RST                  0

But mt2701-power.h is very incomplete and grepping GCPU from include gives very little hits. So I assume we need GCPU; power_status, power_on and power_off registers to define somewhere. Maybe .dtsi but it can be wrong place.

Ok, it seems to be ok define io in .dtsi so we need atleast lines:

MT7623_PERI_PWR_STATUS  0x1000301C 
MT7623_PERI_PWR_ON 0x10003014
MT7623_PERI_PWR_DOWN 0x1000300C
maybe:
MT7623_PERI_RST 0x10003000
Then can use (incomplete) bits from mt2701-resets.h

found:

mt7623.dtsi:	
       pericfg: syscon@10003000 {
                compatible =  "mediatek,mt7623-pericfg",
                              "mediatek,mt2701-pericfg",
                              "syscon";
                reg = <0 0x10003000 0 0x1000>;
                #clock-cells = <1>;
                #reset-cells = <1>;
        };
I understand correct it may need to add:
                pericfg0 {
                        reg = <0x10003000 0x00000004>,
                                <0x1000300C 0x00000004>,
                                <0x10003014 0x00000004>,
                                <0x1000301C 0x00000004>
                        reg-names = "peri_reset", "peri_powerdown", "peri_poweron", "peri_powerstatus";
                };

Not test it yetā€¦

i can also send it if we get it working with dynamic on/off of regulator

isnā€™t it possible to define a regulator which is by default powered off and setting it on with driver-code? have not done much with regulators yetā€¦