Mali-450 support by lima

I’ll see if I can come up with a process but it’s quite convoluted - a linux system capable of cross compiling your kernel is a good starting place.

I can certainly post my meson script, xorg.conf etc and the changes needed to mesa - I’ll see if I can put together a little script that will apply the patches and build binaries but there were an awful lot of build dependencies for mesa and I didn’t keep track of what was needed - just installed on a per error basis.

really, now that lima is working on the R2? the changes should be put into MESA - I’m struggling with bandwidth atm but I’ll chase it up.

1 Like

This one would be useful please. The prereq of linux system with cross-toolchain that is able to compile the kernel for the target system IMHO is pretty much a bare minimum basic thing anyone would have to setup in order to be able to do anything related to things that are discussed in this thread.

Pleaae post your changes (patchfiles,scripts,conf).this should be not that big and we help to get it in better shape.

Currently we have no clue what needs to be changed. If you have a working base just make a diff to official code and post it

@JohnnyWednesday can you please post your code?

Hello I cloned Alex 4.16 lima sources & compiled but gpu dosn’t find. dmesg says:

[ 1.238101] lima 13040000.gpu: get core clk failed -517 [ 1.243393] lima 13040000.gpu: clk init fail -517 [ 1.248067] lima 13040000.gpu: Fatal error during GPU init

I tryed add two (missing?) irq lines to dtsi as Ryder suggest but that don’t help, lima dosn’t detect gpu. @DeadMeat what modifications are needed to your sources that lima detects gpu?? You send dmesg where gpu is detected:

[ 8.492918] lima 13040000.gpu: bus rate = 500500000 [ 8.492930] lima 13040000.gpu: mod rate = 500500000 [ 8.493292] [TTM] Zone kernel: Available graphics memory: 248738 kiB

Is this clip from your 4.16 lima sources or somewhere else?

Hi, ERos, as i remember it should be in my github repo. I can try to recompile and test it, but it doesn’t work.

As i remember it was an attempt to backport driver from 4.17-lima, and it wasn’t successfull.

P.S. I didn’t tried other branches, but if lima driver is in mailine kernel i suppose we shold dig into dts and/or these patchworks Mali-450 support by lima

also you can check CONFIG_COMMON_CLK_MT2701_G3DSYS in config, if i remember/find somthing else, i’ll let you know.

UPD, i see thereis no CONFIG_COMMON_CLK_MT2701_G3DSYS in my defconfig https://github.com/d3adme4t/BPI-R2-4.14/blob/4.16-lima/arch/arm/configs/mt7623n_evb_fwu_defconfig, but CONFIG_DRM_LIMA=y is present, so you can try to add G3DSYS

I’ve tried to add lima related dts notes to 5.5-merged branch, and got

bpi-r2-gentoo ~ # dmesg | grep lima
[    5.401118] lima 13040000.gpu: IRQ pmu not found
[    5.405833] lima 13040000.gpu: mmu gpmmu dte write test fail
[    5.452399] lima: probe of 13040000.gpu failed with error -5

Probably i’ve missed something obvious, did someone tried 5.3-lima?

this notes

with this changes:

Result is pretty same as in 5.3-lima dts

UPD: Found a pmu definition in dts in my 4.16-lima branch, I’ll try to merge it into 5.5 dts.

Hello I tryed add it your 4.16-hdmi-wlan branch (it was linked to your previous post so I used it). It + Ryder Lee dtsi lines helps lot:

[ 1.240235] lima 13040000.gpu: bus rate = 500500000 [ 1.245187] lima 13040000.gpu: mod rate = 500500000 [ 1.273238] lima 13040000.gpu: mmu gpmmu dte write test fail [ 1.299309] lima 13040000.gpu: ttm finalized [ 1.303579] lima 13040000.gpu: Fatal error during GPU init [ 1.309151] lima: probe of 13040000.gpu failed with error -5

I’ll go your 4.16-lima branch and check it. I compile on board so it take some hours…

In your 4.16-hdimi-wlan there is severe error: [ 2218.732011] print_req_error: I/O error, dev sda, sector 219166976 [ 2218.732013] print_req_error: I/O error, dev sda, sector 256491464 [ 2218.732019] EXT4-fs warning (device sda2): ext4_end_bio:323: I/O error 10 writing to inode 6579236 (offset 0 size 131072 starting block 27395904) [ 2218.732335] EXT4-fs error (device sda2): ext4_find_entry:1437: inode #7484437: comm make: reading directory lblock 0 [ 2218.732664] sd 0:0:0:0: [sda] tag#8 UNKNOWN(0x2003) Result: hostbyte=0x04 driverbyte=0x00 [ 2218.732683] Buffer I/O error on dev sda2, logical block 0, lost sync page write

need to boot 4.19 and do fsck & continue compiling

1 Like

As we are currently hang on dts you can use nodt kernel and separate dtb…then you need to compile dtb only and also only replace it.

here is my way of booting kernel+separate dtb (see bootall above):

you set “kernel” in uEnv.txt to your nodt-kernel and “fdt” to your dtb (in subfolder “dtb”). then call newboot2. if you use my uboot, newboot2 should exist. there is also an “askboot” which lists kernels and dtb’s and let you enter the one you want :slight_smile:

1 Like

Can you share it? I can’t find it in 4.16-lima or 4.16-hdmi-wlan branches. Where I should search and what?

I just noticed that I have apply only half of Ryder lines, adding only 178&179 irq’s is enough to generate some lima lines in dmesg can be also config g3dsys. When add irq-names 11pcs like Ryder suggest it dosn’t affect, same lima lines in dmesg. It seems still need some gpmmu data: lima 13040000.gpu: mmu gpmmu dte write test fail

btw your 4.16-lima have something issues in network. wan dosn’t work. I’ll do tests in your 4.16-hdmi-wlan branch. Both of your default branches missing Ryder patch lines & config_g3dsys. Them need to be add by hand… Maybe you can update your repo liitle??

Edit: Hmm, Ryder 11 irq-names in 4.16-hdmi-wlan make now some effect:

[ 1.241661] lima 13040000.gpu: bus rate = 500500000 [ 1.246613] lima 13040000.gpu: mod rate = 500500000 [ 1.295041] lima 13040000.gpu: ttm finalized [ 1.299297] lima 13040000.gpu: Fatal error during GPU init

Need some more debug parameters. It dosn’t tell what is wrong.

There is also this in 4.16-hdmi-wlan: FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

Edit2: pmu you mean these lines…?: https://patchwork.kernel.org/patch/10588759/

just what i had in 5.4…

root@bpi-r2:~# dmesg | grep lima
[    0.000000] Linux version 5.4.12-bpi-r2-lima (frank@frank-G5) (gcc version 80
[    5.299692] lima 13040000.gpu: IRQ pmu not found
[    5.304416] lima 13040000.gpu: mmu gpmmu dte write test fail
[    5.351019] lima: probe of 13040000.gpu failed with error -5

for irq pmu you have a fix?

Jep Ryder lines seems to fix it (2 irq add and change 11 irq names, look today Alex post)

Sorry read too fast for pmu it may need pmu lines here ( I don’t think it affects, but don’t hurt) https://elixir.bootlin.com/linux/latest/source/arch/arm/boot/dts/mt7623.dtsi

had already 11 interrupts (also 178 and 179), tried changing interupts names

 801                 interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_LOW>,
 802                              <GIC_SPI 171 IRQ_TYPE_LEVEL_LOW>,
 803                              <GIC_SPI 172 IRQ_TYPE_LEVEL_LOW>,
 804                              <GIC_SPI 173 IRQ_TYPE_LEVEL_LOW>,
 805                              <GIC_SPI 174 IRQ_TYPE_LEVEL_LOW>,
 806                              <GIC_SPI 175 IRQ_TYPE_LEVEL_LOW>,
 807                              <GIC_SPI 176 IRQ_TYPE_LEVEL_LOW>,
 808                              <GIC_SPI 177 IRQ_TYPE_LEVEL_LOW>,
 809                              <GIC_SPI 178 IRQ_TYPE_LEVEL_LOW>,
 810                              <GIC_SPI 179 IRQ_TYPE_LEVEL_LOW>,
 811                              <GIC_SPI 180 IRQ_TYPE_LEVEL_LOW>;
 812                 interrupt-names = "mfg_irq_gp_b", "mfg_irq_gpmmu_b",
 813                                   "mfg_irq_pp0_b", "mfg_irq_ppmmu0_b",
 814                                   "mfg_irq_pp1_b", "mfg_irq_ppmmu1_b",
 815                                   "mfg_irq_pp2_b", "mfg_irq_ppmmu2_b",
 816                                   "mfg_irq_pp3_b", "mfg_irq_ppmmu3_b",
 817                                   "mfg_irq_pp_b";

pmu error is still there and additional gpmmu, but i don’t see the probe-error/write-test fail

only these lines:

root@bpi-r2:~# dmesg | grep lima
[    0.000000] Linux version 5.4.12-bpi-r2-lima (frank@frank-G5) (gcc version 80
[    5.302612] lima 13040000.gpu: IRQ pmu not found
[    5.307253] lima 13040000.gpu: IRQ gpmmu not found

so i guess it’s probed successfully…how can i verify it is working?

As i’m on 5.4 i have pmu lines…

I think it is not functional. It should do /dev/mali (?not sure?) and drop lines from L1 cache, memory amount etc. See 4.th post in this thread…

In my compiled Alex 4.16-hdmi-wlan it give:

[    1.254974] lima 13040000.gpu: bus rate = 500500000
[    1.259835] lima 13040000.gpu: mod rate = 500500000
[    1.308294] lima 13040000.gpu: ttm finalized
[    1.312567] lima 13040000.gpu: Fatal error during GPU init

in mt7623.dtsi are pmu lines:

        pmu {
                compatible = "arm,cortex-a7-pmu";
                interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_LOW>,
                             <GIC_SPI 5 IRQ_TYPE_LEVEL_LOW>,
                             <GIC_SPI 6 IRQ_TYPE_LEVEL_LOW>,
                             <GIC_SPI 7 IRQ_TYPE_LEVEL_LOW>;
                interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
        };

So I need to increase lima debug or add some printk lines to get info after ttm finalization error. Now busy this evening. These may apply easilly to 4.19 tree 5.4 things may change lot??

For your error think there are irq names changed in 5.4 so need to rename them as 5.4 lima driver like…?

found this in my ./drivers/gpu/drm/lima/lima_device.c

 46 static struct lima_ip_desc lima_ip_desc[lima_ip_num] = {
 47         LIMA_IP_DESC(pmu,         false, false, 0x02000, 0x02000, pmu,      "pmu"),
 48         LIMA_IP_DESC(l2_cache0,   true,  true,  0x01000, 0x10000, l2_cache, NULL),
 49         LIMA_IP_DESC(l2_cache1,   false, true,  -1,      0x01000, l2_cache, NULL),
 50         LIMA_IP_DESC(l2_cache2,   false, false, -1,      0x11000, l2_cache, NULL),
 51         LIMA_IP_DESC(gp,          true,  true,  0x00000, 0x00000, gp,       "gp"),
 52         LIMA_IP_DESC(pp0,         true,  true,  0x08000, 0x08000, pp,       "pp0"),
 53         LIMA_IP_DESC(pp1,         false, false, 0x0A000, 0x0A000, pp,       "pp1"),
 54         LIMA_IP_DESC(pp2,         false, false, 0x0C000, 0x0C000, pp,       "pp2"),
 55         LIMA_IP_DESC(pp3,         false, false, 0x0E000, 0x0E000, pp,       "pp3"),
 56         LIMA_IP_DESC(pp4,         false, false, -1,      0x28000, pp,       "pp4"),
 57         LIMA_IP_DESC(pp5,         false, false, -1,      0x2A000, pp,       "pp5"),
 58         LIMA_IP_DESC(pp6,         false, false, -1,      0x2C000, pp,       "pp6"),
 59         LIMA_IP_DESC(pp7,         false, false, -1,      0x2E000, pp,       "pp7"),
 60         LIMA_IP_DESC(gpmmu,       true,  true,  0x03000, 0x03000, mmu,      "gpmmu"),
 61         LIMA_IP_DESC(ppmmu0,      true,  true,  0x04000, 0x04000, mmu,      "ppmmu0"),
 62         LIMA_IP_DESC(ppmmu1,      false, false, 0x05000, 0x05000, mmu,      "ppmmu1"),
 63         LIMA_IP_DESC(ppmmu2,      false, false, 0x06000, 0x06000, mmu,      "ppmmu2"),
 64         LIMA_IP_DESC(ppmmu3,      false, false, 0x07000, 0x07000, mmu,      "ppmmu3"),
 65         LIMA_IP_DESC(ppmmu4,      false, false, -1,      0x1C000, mmu,      "ppmmu4"),
 66         LIMA_IP_DESC(ppmmu5,      false, false, -1,      0x1D000, mmu,      "ppmmu5"),
 67         LIMA_IP_DESC(ppmmu6,      false, false, -1,      0x1E000, mmu,      "ppmmu6"),
 68         LIMA_IP_DESC(ppmmu7,      false, false, -1,      0x1F000, mmu,      "ppmmu7"),
 69         LIMA_IP_DESC(dlbu,        false, true,  -1,      0x14000, dlbu,     NULL),
 70         LIMA_IP_DESC(bcast,       false, true,  -1,      0x13000, bcast,    NULL),
 71         LIMA_IP_DESC(pp_bcast,    false, true,  -1,      0x16000, pp_bcast, "pp"),
 72         LIMA_IP_DESC(ppmmu_bcast, false, true,  -1,      0x15000, mmu,      NULL),
 73 };

where

 30 #define LIMA_IP_DESC(ipname, mst0, mst1, off0, off1, func, irq) \
 31         [lima_ip_##ipname] = { \
 32                 .name = #ipname, \
 33                 .irq_name = irq, \
 34                 .must_have = { \
 35                         [lima_gpu_mali400] = mst0, \
 36                         [lima_gpu_mali450] = mst1, \ //<<<<<<<<<<<<<<<
 37                 }, \

so my probe is exited because musthave (mst1) is set for gpmmu and pmu is optional

and my previous names were right

-               interrupt-names = "gp", "gpmmu", "pp0", "ppmmu0", "pp1",
-                                 "ppmmu1", "pp2", "ppmmu2", "pp3", "ppmmu3",
-                                 "pp";

but how to fix the mmu gpmmu dte write test fail ?

which is from here:

the error was mentioned in the thread (at least here), but i’ve found no fix for it (also not in the objelf-repo). how did you increased debug?

I added little debug in Alex 4.16-hdmi-wlan:

[    1.251963] lima 13040000.gpu: bus rate = 500500000
[    1.256824] lima 13040000.gpu: mod rate = 500500000
[    1.261772] lima 13040000.gpu: ttm_init start
[    1.288326] lima 13040000.gpu: ttm_init stop 0
[    1.292762] lima 13040000.gpu: vm_create start 
[    1.297849] lima 13040000.gpu: vm_create stop 
[    1.302288] lima 13040000.gpu: va_start start 
[    1.306704] lima 13040000.gpu: va_start stop id:1 , 1 
[    1.312056] lima 13040000.gpu: get_resources start 
[    1.316909] lima 13040000.gpu: get_resources stop 
[    1.321720] lima 13040000.gpu: iomem stop 
[    1.325790] lima 13040000.gpu: ip_num for start
[    1.330298] lima 13040000.gpu: init_ip stop 0
[    1.334648] lima 13040000.gpu: init_ip stop -6
[    1.359450] lima 13040000.gpu: ttm finalized
[    1.363725] lima 13040000.gpu: Fatal error during GPU init

So error come in second run of:

        dev_err(ldev->dev, "ip_num for start\n");
        for (i = 0; i < lima_ip_num; i++) {
                err = lima_init_ip(ldev, i);
                dev_err(ldev->dev, "init_ip stop %d\n",err);
                if (err)
                        goto err_out5;
        }

No idea yet what is wrong

Error -6 is no such device/address (ENXIO)…you need to debug lima_init_ip. Should it run twice? What is lima_ip_num?

My mistake: it’s present in 5.5, but absents in 4.16, so looking forward. All my current udates are in my repo. https://github.com/d3adme4t/BPI-R2-4.14/tree/5.5-merged

I’ll check, maybe up to ip_num whatever it is

Edit: It should run 26 times and look that string end comes from lima_ip_id. Used to search correct IRQ line if I understand correct (?) from debug dmesg:

[    1.321755] lima 13040000.gpu: iomem stop 
[    1.325844] lima 13040000.gpu: ip_num for start 26
[    1.330601] lima offset stop 8192 , 0 
[    1.334347] lima pdev desc pmu
[    1.337386] lima irq_byname -6
[    1.340420] lima 13040000.gpu: init_ip stop 0
[    1.344759] lima offset stop 12288 , 1 
[    1.348566] lima pdev desc gpmmu
[    1.351771] lima irq_byname -6
[    1.354818] lima 13040000.gpu: init_ip stop -6
[    1.379631] lima 13040000.gpu: ttm finalized
[    1.383902] lima 13040000.gpu: Fatal error during GPU init

Dosn’t look good, it don’t find correct IRQ names so maybe back dtsi to Ryder irq names. I think they are not correct for that lima driver. Need to look platform_get_irq_byname function it may give some help how to name irq’s…

Have not yet idea, it come from “enum” whatever it is…

enum lima_ip_id {
        lima_ip_pmu,
        lima_ip_gpmmu,
        lima_ip_ppmmu0,
        lima_ip_ppmmu1,
        lima_ip_ppmmu2,
        lima_ip_ppmmu3,
        lima_ip_ppmmu4,
        lima_ip_ppmmu5,
        lima_ip_ppmmu6,
        lima_ip_ppmmu7,
        lima_ip_gp,
        lima_ip_pp0,
        lima_ip_pp1,
        lima_ip_pp2,
        lima_ip_pp3,
        lima_ip_pp4,
        lima_ip_pp5,
        lima_ip_pp6,
        lima_ip_pp7,
        lima_ip_l2_cache0,
        lima_ip_l2_cache1,
        lima_ip_l2_cache2,
        lima_ip_dlbu,
        lima_ip_bcast,
        lima_ip_pp_bcast,
        lima_ip_ppmmu_bcast,
        lima_ip_num,
};

It may have some correlation about irq naming

Edit: It is intresting that lima is only occurence in whole kernel where: err = platform_get_irq_byname(dev->pdev, desc->irq_name);

Common way is to ask function like this: irq_de = platform_get_irq_byname(pdev, “DE”);

So what happens if dev->pdev is substituted to normal pdev…? Ok, it dosn’t compile…

I wipe out Ryder irq names and put your 11 irq names and now it go diffrent - to point where you were 5hrs ago… So it now got functional(?) irq but runs gpmmu test and fail it.

[    1.326091] lima 13040000.gpu: ip_num for start 26
[    1.330850] lima offset stop 8192 , 0 
[    1.334605] lima pdev desc pmu
[    1.337648] lima irq_byname -6
[    1.340687] lima 13040000.gpu: init_ip stop 0
[    1.345031] lima offset stop 12288 , 1 
[    1.348841] lima pdev desc gpmmu
[    1.352122] lima irq_byname 229
[    1.355251] lima 13040000.gpu: mmu gpmmu dte write test fail
[    1.360875] lima 13040000.gpu: init_ip stop -5
[    1.385847] lima 13040000.gpu: ttm finalized

Asked how increase debug. Simpy put printk(“lima: hello world”); lines or something…

I think it should normally run out first return 0 and newer to go CAFEBABE branch…

	if (ip->id == lima_ip_ppmmu_bcast)
		return 0;

	mmu_write(LIMA_MMU_DTE_ADDR, 0xCAFEBABE);
	if (mmu_read(LIMA_MMU_DTE_ADDR) != 0xCAFEB000) {
		dev_err(dev->dev, "mmu %s dte write test fail\n", lima_ip_name(ip));
		return -EIO;
	}

Maybe 0xCAFEB000 should be 0xCAFEBABE or both some save address to use? But untested situation I think, not to wise use that codepiece?