Mali-450 support by lima

I’ve replaced lima driver in my 4.16-lima with one from mediatek tree - works and boots (with my config and original dts).

lima-4.16 mt.txt (45.9 КБ)

Idk why, but this driver tries to init lima twice:

[    1.218185] INFO@lima_mediatek_init 67 err = -517
[    1.222906] lima 13040000.gpu: soc init fail -517
[    1.227582] lima 13040000.gpu: Fatal error during GPU init
[    1.240971] loop: module loaded
[    1.244353] [WMT-DETECT][I]wmt_detect_driver_init:driver(major 154) installed success
[    1.252210] [SDIO-DETECT][I]sdio_detect_init:sdio_register_driver() ret=0
............................
[    2.730001] [drm] Initialized mediatek 1.0.0 20150513 for 14000000.dispsys on minor 0
[    2.738229] lima 13040000.gpu: Unbalanced pm_runtime_enable!
[    2.743989] INFO@lima_mediatek_init 67 err = 0
[    2.748443] lima 13040000.gpu: bus rate = 500500000
[    2.753315] lima 13040000.gpu: mod rate = 500500000
[    2.758517] lima 13040000.gpu: found 3 PPs
[    2.762648] lima 13040000.gpu: fail to get irq pmu
[    2.767410] lima 13040000.gpu: no PMU present
[    2.771761] lima 13040000.gpu: dlbu 0 0
[    2.775600] lima 13040000.gpu: bcast 0 0
[    2.779502] lima 13040000.gpu: l2 cache 8K, 4-way, 64byte cache line, 128bit external bus
[    2.787745] lima 13040000.gpu: gp - mali450 version major 0 minor 0
[    2.794218] lima 13040000.gpu: l2 cache 128K, 4-way, 64byte cache line, 128bit external bus
[    2.802650] lima 13040000.gpu: pp0 - mali450 version major 0 minor 0
[    2.809069] lima 13040000.gpu: pp1 - mali450 version major 0 minor 0
[    2.815513] lima 13040000.gpu: pp2 - mali450 version major 0 minor 0

First - failed, second successfull.

bpi-r2-gentoo ~ # ls -la /dev/dri/
итого 0
drwxr-xr-x  3 root root        120 дек 31 16:00 .
drwxr-xr-x 13 root root      13520 дек 31 16:00 ..
drwxr-xr-x  2 root root        100 дек 31 16:00 by-path
crw-rw----  1 root video  226,   0 дек 31 16:00 card0
crw-rw----  1 root video  226,   1 дек 31 16:00 card1
crw-rw-rw-  1 root render 226, 128 дек 31 16:00 renderD128
bpi-r2-gentoo ~ #

UPD: dmesg with original lima - just in case.lima-4.16 orig.txt (45.3 КБ)

UPD2: all chandes commited to https://github.com/d3adme4t/BPI-R2-4.14/tree/4.16-lima-mt hope didn’t miss anything.

dtsi is modified, but looks like it doesn’t affect on results, and my config.txt (145.8 КБ)

Looks like second time it inits right after DRM, may be some hook in driver? If so, i dont understand why it can’t init as module…

Some thoughts:

[    1.218185] INFO@lima_mediatek_init 67 err = -517
[    1.222906] lima 13040000.gpu: soc init fail -517
[    1.227582] lima 13040000.gpu: Fatal error during GPU init

Looks like here it fails on larb usage attempt

probably because iommu starts later(actually not iommu, but larbs) :

[    1.878880] mtk-iommu-v1 10205000.mmsys_iommu: bound 13010000.larb (ops mtk_smi_larb_component_ops)

But i can’t get from code how it attempts to init second time, and why rhight after mediatek-drm?

[    2.711818] [drm:drm_minor_register] new minor registered 0
[    2.717484] [drm:drm_sysfs_connector_add] adding "HDMI-A-1" to sysfs
[    2.723823] [drm:drm_sysfs_hotplug_event] generating hotplug event
[    2.730001] [drm] Initialized mediatek 1.0.0 20150513 for 14000000.dispsys on minor 0
[    2.738229] lima 13040000.gpu:  
[    2.743989] INFO@lima_mediatek_init 67 err = 0
[    2.748443] lima 13040000.gpu: bus rate = 500500000
[    2.753315] lima 13040000.gpu: mod rate = 500500000
[    2.758517] lima 13040000.gpu: found 3 PPs
[    2.762648] lima 13040000.gpu: fail to get irq pmu
[    2.767410] lima 13040000.gpu: no PMU present
[    2.771761] lima 13040000.gpu: dlbu 0 0
[    2.775600] lima 13040000.gpu: bcast 0 0
[    2.779502] lima 13040000.gpu: l2 cache 8K, 4-way, 64byte cache line, 128bit external bus
[    2.787745] lima 13040000.gpu: gp - mali450 version major 0 minor 0
[    2.794218] lima 13040000.gpu: l2 cache 128K, 4-way, 64byte cache line, 128bit external bus
[    2.802650] lima 13040000.gpu: pp0 - mali450 version major 0 minor 0
[    2.809069] lima 13040000.gpu: pp1 - mali450 version major 0 minor 0
[    2.815513] lima 13040000.gpu: pp2 - mali450 version major 0 minor 0
[    2.822016] [drm:drm_minor_register] 
[    2.825662] [drm:drm_minor_register] 
[    2.829539] [drm:drm_minor_register] new minor registered 128
[    2.835284] [drm:drm_minor_register] 
[    2.839120] [drm:drm_minor_register] new minor registered 1
[    2.844692] [drm] Initialized lima 1.0.0 20170325 for 13040000.gpu on minor 1

@moore is it your code? Could you please explain this moment, or to point the place where it gets 2nd attempt? Thank You!

Why? it’s literally the same, but with some pulls from mainstream.

Oh, 4.16-hdmi-wlan have working ethernet (same config as Frank 4.19-main). I use ssh to access board…

Btw low priority question: what is “larb”. I found only thai food…

Larb is “local arbiter”…somewhere described in mtk docs…

Maybe hotplug event affect or is it only for HDMI?

HDMI probe can write wakeup_register somewhere and enable GPU at same?

Can you try in 5.5-merged (or somewhere) execute read “devmem 0x1000301C”? I have not currently board at hands… It should read status bits from wakeup register.

Found this:

So wlan enable tweaks power_register. Your dmesg was 1s. before wmt init before lima success.

If it is needed, then I have not it enabled (yet)

Thanks found something from 2016:

+	/* Enable the smi-common's power and clocks */
+	ret = mtk_smi_enable(common);
+	if (ret)
+		return ret;
+
+	/* Enable the larb's power and clocks */
+	ret = mtk_smi_enable(&larb->smi);

So there is some power enable/disable framework in mtk chips. It needs to check if GPU is power down. And find correct mtk_smi_enable for GPU…

File is mtk-smi.c. SMI seems to be related ethernet(?). Not:

SMI(Smart Multimedia Interface) driver. This driver is responsible to enable/disable iommu and control the power domain and clocks of each local arbiter. Yong Wu / Mediatek

GPU is in AXI bus but peripheral controller (=power_register) is in some other bus.

extern int wmt_detect_ext_chip_pwr_on(void); extern int wmt_detect_ext_chip_pwr_off(void);

wmt_detect_chip_pwr_on (void)

COMBO_PMU_PIN, \
COMBO_RST_PIN, \
COMBO_WIFI_EINT_PIN);

some init logs:
_wmt_detect_set_output_mode(COMBO_PMU_PIN);
_wmt_detect_output_low(COMBO_PMU_PIN);
_wmt_detect_set_output_mode(COMBO_RST_PIN);
_wmt_detect_output_low(COMBO_RST_PIN);

GPIO_COMBO_PMU_EN_PIN
hmm.. in  hiteq8735a_tb_n.dts
gpio_combo_pmu_en_pin = <&pio 21 0>; /* 2) GPIO_COMBO_PMU_EN_PIN */

some else:
+#define GPIO_COMBO_PMU_EN_PIN         GPIOEXT13
+#define GPIO_COMBO_PMU_EN_PIN_M_GPIO  GPIO_MODE_00
+#define GPIO_COMBO_PMU_EN_PIN_M_EINT  GPIO_MODE_02 

So no yet get definition in mt7623. It maybe posible it tweak GPU on, but also posible it dosn’t do that.

1 Like
devmemX/devmem2 0x1000301C
00000FFF

So GPU is offline for sure.

devmem2 0x10003014 w 0x00000001

devmem2 0x1000301C             
00000FFE

So GPU is posible to put online… Need modularize lima to test if this trick is effective.

After hot boot:
devmem2 0x1000301C
00000FFF

devmem2 0x10003014 w 0x00000001

modprobe lima

[  599.901524] lima 13040000.gpu: IRQ ppmmu4 not found
[  599.901532] lima 13040000.gpu: IRQ ppmmu5 not found
[  599.901540] lima 13040000.gpu: IRQ ppmmu6 not found
[  599.901547] lima 13040000.gpu: IRQ ppmmu7 not found
[  599.901581] lima 13040000.gpu: gp - mali450 version major 0 minor 0
[  599.901636] lima 13040000.gpu: pp0 - mali450 version major 0 minor 0
[  599.901691] lima 13040000.gpu: pp1 - mali450 version major 0 minor 0
[  599.901738] lima 13040000.gpu: pp2 - mali450 version major 0 minor 0
[  599.901790] lima 13040000.gpu: pp3 - mali450 version major 0 minor 0
[  599.901832] lima 13040000.gpu: IRQ pp4 not found
[  599.901839] lima 13040000.gpu: IRQ pp5 not found
[  599.901846] lima 13040000.gpu: IRQ pp6 not found
[  599.901853] lima 13040000.gpu: IRQ pp7 not found
[  599.901861] lima 13040000.gpu: l2 cache 8K, 4-way, 64byte cache line, 128bit external bus
[  599.901869] lima 13040000.gpu: l2 cache 128K, 4-way, 64byte cache line, 128bit external bus
[  599.901917] lima: ip-id: 25 ppmmu: 25 
[  599.902568] lima 13040000.gpu: bus rate = 500500000
[  599.902578] lima 13040000.gpu: mod rate = 500500000
[  599.903197] [drm] Initialized lima 1.0.0 20190217 for 13040000.gpu on minor 1

This is 5.5-merged

2 Likes

Do i understand it right,you check status and switch on power for mali?

If yes you can try adding the regulator from 4.4 i’ve posted here

Yep I read first status register. As you can see 0th bit is 1 so mali is power off. Writing it to 1 power_on register is effective and mali stay on. Can check it from status register after writing. After boot it is powered off.

I booted 4.19-main and there is also GPU power off by default. So I think you can apply 4.19 lima patches to 4.19-main and do power on before load lima module…?

Is it GCPU_PDN flag?

devmem2 is it a userspace tool?

UPD, found devmem and tested.

bpi-r2-gentoo /lib/modules # dmesg -C  
bpi-r2-gentoo /lib/modules # devmem 0x10003014 w 0x00000001
/dev/mem opened.
Memory mapped at address 0xb6f2b000.
Value at address 0x10003014 (0xb6f2b014): 0x0
Written 0x1; readback 0x0
bpi-r2-gentoo /lib/modules # devmem 0x1000301C
/dev/mem opened.
Memory mapped at address 0xb6f69000.
Value at address 0x1000301C (0xb6f6901c): 0xFFE
bpi-r2-gentoo /lib/modules # modprobe lima
bpi-r2-gentoo /lib/modules # dmesg
[45599.640115] LIMA_INIT: lima_clk_init
[45599.640191] LIMA_INIT: lima_clk_init_err:0
[45599.640245] LIMA_INIT: lima_regulator_init_err:0
[45599.642151] LIMA_INIT: lima_dlbu_cpu no err:0
[45599.642230] lima 13040000.gpu: IRQ pmu not found
[45599.642248] lima 13040000.gpu: Lima_init_ip: ip:0, err:0
[45599.642327] lima 13040000.gpu: mmu gpmmu dte write: ADDR:0,val:cafebabe
[45599.642345] lima 13040000.gpu: mmu gpmmu dte read: ADDR:0,val:0
[45599.642356] lima 13040000.gpu: mmu gpmmu dte write test fail
[45599.642366] lima 13040000.gpu: Lima_init_ip: ip:1, err:-5
[45599.681835] lima: probe of 13040000.gpu failed with error -5
bpi-r2-gentoo /lib/modules #
bpi-r2-gentoo /lib/modules # uname -r
5.5.0-rc5-bpi-r2-merged

P.S. after reboot:

bpi-r2-gentoo ~ # devmem 0x1000301C
/dev/mem opened.
Memory mapped at address 0xb6f03000.
Value at address 0x1000301C (0xb6f0301c): 0xFFF

Do you have any additional changes in code or dts? Can you show ‘git diff’?

I changed only lima, added debug in 5.5-merged.

I can show git diff after someone give more exact commandline parameters to run…

Now compiling Frank newest 4.19-main where added lima driver. Don’t know yet compiles it ok…

Btw I used:

1 Like

Ok, after i chanded mt7623,dtsi

g3dsys: syscon@13000000 {

to

g3dsys: clock-controller@13000000 {

Your method worked.

[  120.071693] LIMA_INIT: lima_clk_init
[  120.071752] LIMA_INIT: lima_clk_init_err:0
[  120.071799] LIMA_INIT: lima_regulator_init_err:0
[  120.073328] LIMA_INIT: lima_dlbu_cpu no err:0
[  120.073383] lima 13040000.gpu: IRQ pmu not found
[  120.073391] lima 13040000.gpu: Lima_init_ip: ip:0, err:0
[  120.073446] lima 13040000.gpu: mmu gpmmu dte write: ADDR:0,val:cafebabe
[  120.073458] lima 13040000.gpu: mmu gpmmu dte read: ADDR:0,val:cafeb000
[  120.073540] lima 13040000.gpu: Lima_init_ip: ip:1, err:0
[  120.073578] lima 13040000.gpu: mmu ppmmu0 dte write: ADDR:0,val:cafebabe
[  120.073588] lima 13040000.gpu: mmu ppmmu0 dte read: ADDR:0,val:cafeb000
[  120.073641] lima 13040000.gpu: Lima_init_ip: ip:2, err:0
[  120.073674] lima 13040000.gpu: mmu ppmmu1 dte write: ADDR:0,val:cafebabe
[  120.073693] lima 13040000.gpu: mmu ppmmu1 dte read: ADDR:0,val:cafeb000
[  120.073746] lima 13040000.gpu: Lima_init_ip: ip:3, err:0
[  120.073773] lima 13040000.gpu: mmu ppmmu2 dte write: ADDR:0,val:cafebabe
[  120.073781] lima 13040000.gpu: mmu ppmmu2 dte read: ADDR:0,val:cafeb000
[  120.073855] lima 13040000.gpu: Lima_init_ip: ip:4, err:0
[  120.073882] lima 13040000.gpu: mmu ppmmu3 dte write: ADDR:0,val:cafebabe
[  120.073890] lima 13040000.gpu: mmu ppmmu3 dte read: ADDR:0,val:cafeb000
[  120.073946] lima 13040000.gpu: Lima_init_ip: ip:5, err:0
[  120.073958] lima 13040000.gpu: IRQ ppmmu4 not found
[  120.073964] lima 13040000.gpu: Lima_init_ip: ip:6, err:0
[  120.073973] lima 13040000.gpu: IRQ ppmmu5 not found
[  120.073979] lima 13040000.gpu: Lima_init_ip: ip:7, err:0
[  120.073988] lima 13040000.gpu: IRQ ppmmu6 not found
[  120.073994] lima 13040000.gpu: Lima_init_ip: ip:8, err:0
[  120.074002] lima 13040000.gpu: IRQ ppmmu7 not found
[  120.074008] lima 13040000.gpu: Lima_init_ip: ip:9, err:0
[  120.074034] lima 13040000.gpu: gp - mali450 version major 0 minor 0
[  120.074091] lima 13040000.gpu: Lima_init_ip: ip:10, err:0
[  120.074117] lima 13040000.gpu: pp0 - mali450 version major 0 minor 0
[  120.074180] lima 13040000.gpu: Lima_init_ip: ip:11, err:0
[  120.074208] lima 13040000.gpu: pp1 - mali450 version major 0 minor 0
[  120.074261] lima 13040000.gpu: Lima_init_ip: ip:12, err:0
[  120.074287] lima 13040000.gpu: pp2 - mali450 version major 0 minor 0
[  120.074338] lima 13040000.gpu: Lima_init_ip: ip:13, err:0
[  120.074362] lima 13040000.gpu: pp3 - mali450 version major 0 minor 0
[  120.074416] lima 13040000.gpu: Lima_init_ip: ip:14, err:0
[  120.074426] lima 13040000.gpu: IRQ pp4 not found
[  120.074433] lima 13040000.gpu: Lima_init_ip: ip:15, err:0
[  120.074441] lima 13040000.gpu: IRQ pp5 not found
[  120.074448] lima 13040000.gpu: Lima_init_ip: ip:16, err:0
[  120.074456] lima 13040000.gpu: IRQ pp6 not found
[  120.074463] lima 13040000.gpu: Lima_init_ip: ip:17, err:0
[  120.074471] lima 13040000.gpu: IRQ pp7 not found
[  120.074477] lima 13040000.gpu: Lima_init_ip: ip:18, err:0
[  120.074488] lima 13040000.gpu: l2 cache 8K, 4-way, 64byte cache line, 128bit external bus
[  120.074496] lima 13040000.gpu: Lima_init_ip: ip:19, err:0
[  120.074504] lima 13040000.gpu: l2 cache 128K, 4-way, 64byte cache line, 128bit external bus
[  120.074511] lima 13040000.gpu: Lima_init_ip: ip:20, err:0
[  120.074519] lima 13040000.gpu: Lima_init_ip: ip:21, err:0
[  120.074526] lima 13040000.gpu: Lima_init_ip: ip:22, err:0
[  120.074533] lima 13040000.gpu: Lima_init_ip: ip:23, err:0
[  120.074628] lima 13040000.gpu: Lima_init_ip: ip:24, err:0
[  120.074637] lima 13040000.gpu: Lima_init_ip: ip:25, err:0
[  120.075470] lima 13040000.gpu: bus rate = 500500000
[  120.075484] lima 13040000.gpu: mod rate = 500500000
[  120.076419] [drm] Initialized lima 1.0.0 20190217 for 13040000.gpu on minor 1

Atleast it looks like a light in the end of a tunnel :smiley:

I’ll tty to check devmem 0x1000301C in working 4.16-mt

i found https://bootlin.com/pub/mirror/ - works fine for me :slight_smile:

Could you please check g3dsys?

Yep, but next to find why only 1/2 of GPU is activated…

Hmm, I don’t modified it:

        g3dsys: syscon@13000000 {
                compatible = "mediatek,mt7623-g3dsys",
                             "mediatek,mt2701-g3dsys",
                             "syscon";
                reg = <0 0x13000000 0 0x200>;
                #clock-cells = <1>;
                #reset-cells = <1>;
        };

That is intresting to know. Lima driver says it don’t handle powermanagement yet.

1 Like

As i know mt7632n’s mali450 has 1 GP and 4 PPs so everything seems ok

http://wiki.banana-pi.org/Banana_Pi_router_Comparison - bpi-r2 has mali450 MP4 i.e. 4 PPs

Strange… probably it’s unstable result. We need more tests and testers.:thinking:

This says 8:

This picture says 8:

This says 1-8:

So I’m quite sure there is 8 PP.

You mean that Mali450 MP4 means 4PP…!!!

MP4 is the version with four cores (so called fragment processors).