Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sunxi-6.13: Add all patches #7705

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

The-going
Copy link
Contributor

@The-going The-going commented Jan 15, 2025

Description

  • Add megous patches
  • Add armbian patches
  • H6/H616: Add a power domain driver for the Mali GPU
  • Switching to v6.13.6

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

  • Test build sunxi64
  • Test work on bananapi-m4-berry

@github-actions github-actions bot added size/large PR with 250 lines or more Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Jan 15, 2025
@igorpecovnik igorpecovnik added 02 Milestone: First quarter release 05 Milestone: Second quarter release labels Feb 5, 2025
@The-going The-going requested a review from igorpecovnik as a code owner March 12, 2025 20:02
@The-going The-going changed the title WIP: sunxi-6.13: Add all patches sunxi-6.13: Add all patches Mar 12, 2025
@The-going
Copy link
Contributor Author

The-going commented Mar 14, 2025

In order for the power domain to work, we need to add to the configuration:

diff --git a/config/kernel/linux-sunxi64-edge.config b/config/kernel/linux-sunxi64-edge.config
index 4f347164..f35b0063 100644
--- a/config/kernel/linux-sunxi64-edge.config
+++ b/config/kernel/linux-sunxi64-edge.config
@@ -2383,6 +2383,7 @@ CONFIG_ARM_MHU_V2=m
 CONFIG_SUN50I_IOMMU=y
 CONFIG_ARM_SMMU=y
 CONFIG_LITEX_SOC_CONTROLLER=m
+CONFIG_SUN50I_H6_PRCM_PPU=m
 CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y
 CONFIG_DEVFREQ_GOV_PERFORMANCE=y
 CONFIG_DEVFREQ_GOV_POWERSAVE=y

@The-going
Copy link
Contributor Author

At this stage, for GNOME, I get the following:

root@bananapim4berry:~# [  211.321228] Unable to handle kernel NULL pointer dereference at virtual address 000000000000000c
[  211.330056] Mem abort info:
[  211.332878]   ESR = 0x0000000096000004
[  211.336642]   EC = 0x25: DABT (current EL), IL = 32 bits
[  211.341969]   SET = 0, FnV = 0
[  211.345033]   EA = 0, S1PTW = 0
[  211.348189]   FSC = 0x04: level 0 translation fault
[  211.353093] Data abort info:
[  211.355981]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[  211.361487]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[  211.366569]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[  211.371905] user pgtable: 4k pages, 48-bit VAs, pgdp=000000004b3b4000
[  211.378367] [000000000000000c] pgd=0000000000000000, p4d=0000000000000000
[  211.385173] Internal error: Oops: 0000000096000004 [#1] SMP

Message from[  211.390744] Modules linked in: algif_hash algif_skcipher af_alg bnep sunrpc 8821cu rtw88_8821cu rtw88_8821c rtw88_usb rtw88_core btusbr
 syslogd@bananap[  211.451711] CPU: 2 UID: 109 PID: 3051 Comm: pulseaudio Tainted: G         C         6.13.6-edge-sunxi64 #6
im4berry at Mar [  211.462738] Tainted: [C]=CRAP
[  211.467082] Hardware name: BananaPi M4 Berry (DT)

 kernel:[  211[  211.473172] pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
.385173] Interna[  211.481498] pc : dmaengine_pcm_open+0x110/0x1f8
l error: Oops: 0[  211.487405] lr : dmaengine_pcm_open+0xf8/0x1f8
000000096000004 [  211.493224] sp : ffff800085a43840
[#1] SMP
[  211.497913] x29: ffff800085a43840 x28: ffff800085a43c78 x27: 0000000000000000
[  211.505985] x26: 0000000000000001 x25: ffff800080db58c8 x24: ffff00000392c880
[  211.513130] x23: 0000000000000000 x22: ffff000003b11810 x21: ffff000005380350
[  211.520282] x20: ffff0000033c1000 x19: ffff0000033c2e00 x18: 0000000000000000
[  211.527430] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
[  211.534574] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
[  211.541715] x11: 0000000000000000 x10: 0000000000000000 x9 : ffff800080ddc95c
[  211.548855] x8 : ffff800085a438d8 x7 : 0000000000000000 x6 : ffff000008569bac
[  211.556000] x5 : ffff000003b174f4 x4 : 0000000000000008 x3 : 0000000000000103
[  211.563137] x2 : 0000000000000100 x1 : ffff000003b11b00 x0 : ffffffff00000002
[  211.570274] Call trace:
[  211.572721]  dmaengine_pcm_open+0x110/0x1f8 (P)
[  211.577258]  snd_soc_component_open+0x34/0xb8
[  211.581617]  __soc_pcm_open+0xa4/0x5a0
[  211.585369]  soc_pcm_open+0x38/0x68
[  211.588858]  snd_pcm_open_substream+0x5a4/0x8d0
[  211.593391]  snd_pcm_open.part.0+0xe4/0x210
[  211.597575]  snd_pcm_playback_open+0x6c/0xa8
[  211.601844]  snd_open+0xac/0x1c0
[  211.605079]  chrdev_open+0xcc/0x2c8
[  211.608574]  do_dentry_open+0x22c/0x640
[  211.612416]  vfs_open+0x34/0xf8
[  211.615559]  path_openat+0x2b8/0xe78
[  211.619139]  do_filp_open+0x94/0x158
[  211.622721]  do_sys_openat2+0xbc/0xf0
[  211.626396]  __arm64_sys_openat+0x68/0xb8
[  211.630411]  invoke_syscall+0x50/0x120
[  211.634171]  el0_svc_common.constprop.0+0xd0/0xf8
[  211.638877]  do_el0_svc+0x28/0x40
[  211.642194]  el0_svc+0x30/0xd0
[  211.645253]  el0t_64_sync_handler+0x144/0x168
[  211.649609]  el0t_64_sync+0x198/0x1a0
[  211.653280] Code: f2a00000 f90047e0 f9412ac1 52802063 (b9400ee0) 
[  211.659370] ---[ end trace 0000000000000000 ]---

@igorpecovnik
Copy link
Member

for GNOME

Interesting. XFCE? Gnome uses Mali / Lima / Panfrost by default.

@The-going
Copy link
Contributor Author

for GNOME

Interesting. XFCE? Gnome uses Mali / Lima / Panfrost by default.

h616, h618 -> Panfrost

There have been significant changes in the sound subsystem in the core.
And it looks like I haven't fully fixed our patches.
That is, the fixes have been made to the level of "the code is assembled without errors".

@The-going
Copy link
Contributor Author

The same core works on a minimal image.
GPU starts without freezes.
The power domain is working correctly.

leo@bananapim4berry:~$ dmesg | grep -E 'hdmi|gpu|drm|video'
[    0.080362] /soc/hdmi@6000000: Fixed dependency cycle(s) with /soc/tcon-top@6510000
[    0.080424] /soc/tcon-top@6510000: Fixed dependency cycle(s) with /soc/hdmi@6000000
[    0.085564] /soc/hdmi@6000000: Fixed dependency cycle(s) with /soc/tcon-top@6510000
[    0.085933] /soc/hdmi@6000000: Fixed dependency cycle(s) with /soc/tcon-top@6510000
[    0.086102] /soc/tcon-top@6510000: Fixed dependency cycle(s) with /soc/hdmi@6000000
[    0.088857] /soc/hdmi@6000000: Fixed dependency cycle(s) with /connector
[    0.088940] /connector: Fixed dependency cycle(s) with /soc/hdmi@6000000
[    1.595067] sun4i-drm display-engine: bound 1100000.mixer (ops 0xffff8000811bd460)
[    1.605997] sun4i-drm display-engine: bound 6510000.tcon-top (ops 0xffff8000811c2200)
[    1.608641] sun4i-drm display-engine: bound 6515000.lcd-controller (ops 0xffff8000811ba228)
[    1.614824] sun8i-dw-hdmi 6000000.hdmi: Detected HDMI TX controller v2.12a with HDCP (DWC HDMI 2.0 TX PHY)
[    1.620851] sun8i-dw-hdmi 6000000.hdmi: registered DesignWare HDMI I2C bus driver
[    1.624642] sun8i-dw-hdmi 6000000.hdmi: EVENT=plugin
[    1.628463] sun4i-drm display-engine: bound 6000000.hdmi (ops 0xffff8000811bc528)
[    1.641245] [drm] Initialized sun4i-drm 1.0.0 for display-engine on minor 0
[    3.489669] sun8i-dw-hdmi 6000000.hdmi: read_hpd result: 1
[    3.739128] sun4i-drm display-engine: [drm] fb0: sun4i-drmdrmfb frame buffer device
[    9.520055] systemd[1]: Starting modprobe@drm.service - Load Kernel Module drm...
[   10.638005] systemd[1]: modprobe@drm.service: Deactivated successfully.
[   10.664101] systemd[1]: Finished modprobe@drm.service - Load Kernel Module drm.
[   12.875140] panfrost 1800000.gpu: clock rate = 432000000
[   12.875184] panfrost 1800000.gpu: bus_clock rate = 200000000
[   12.876200] panfrost 1800000.gpu: mali-g31 id 0x7093 major 0x0 minor 0x0 status 0x0
[   12.876224] panfrost 1800000.gpu: features: 00000000,000027f7, issues: 00000000,00000400
[   12.876235] panfrost 1800000.gpu: Features: L2:0x07100206 Shader:0x00000000 Tiler:0x00000209 Mem:0x1 MMU:0x00002821 AS:0xff JS:0x7
[   12.876247] panfrost 1800000.gpu: shader_present=0x1 l2_present=0x1
[   12.882720] [drm] Initialized panfrost 1.3.0 for 1800000.gpu on minor 1
[   13.014349] videodev: Linux video capture interface: v2.00
[   13.610654] cedrus 1c0e000.video-codec: Device registered as /dev/video0
[   44.620794] sun8i-dw-hdmi 6000000.hdmi: EVENT=plugin
[   45.514342] sun8i-dw-hdmi 6000000.hdmi: EVENT=plugin

The sound is not used, so there is no panic.

@pyavitz
Copy link
Collaborator

pyavitz commented Mar 15, 2025

May be useful.

Reparent GPU clock during frequency changes
https://patchwork.kernel.org/project/linux-clk/patch/20250220113808.1122414-2-simons.philippe@gmail.com/#26254912

ASoC: add Allwinner H616 audio codec support (NO HDMI SUPPORT YET)
https://lore.kernel.org/linux-arm-kernel/20241023075917.186835-1-ryan@testtoast.com/T/

@The-going
Copy link
Contributor Author

May be useful.

Oh my God! Patrick, you're on time as always.

@pyavitz
Copy link
Collaborator

pyavitz commented Mar 15, 2025

As an aside, I would like to recommend we adjust the thermal zone in the sun50i-h616.dtsi. In doing so its possible to easily add if there is a pwm header pin a pwm fan.

From ef39ef0191687bc86a2a5a752c3b995dfca5950d Mon Sep 17 00:00:00 2001
From: Patrick Yavitz <pyavitz@gmail.com>
Date: Sun, 9 Mar 2025 00:28:34 -0500
Subject: [PATCH] allwinner: sun50i-h616: correct thermal zones node

Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
---
 arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi
index 73a0fd2d14ec..f5a80dc7fcab 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi
@@ -1292,9 +1292,9 @@ r_rsb: rsb@7083000 {
 	};
 
 	thermal-zones {
-		cpu-thermal {
-			polling-delay-passive = <500>;
+		cpu_thermal: cpu-thermal {
 			polling-delay = <1000>;
+			polling-delay-passive = <500>;
 			thermal-sensors = <&ths 2>;
 			sustainable-power = <1000>;
 
@@ -1317,9 +1317,9 @@ cpu_critical: cpu-trip-2 {
 			};
 		};
 
-		gpu-thermal {
-			polling-delay-passive = <500>;
+		gpu_thermal: gpu-thermal {
 			polling-delay = <1000>;
+			polling-delay-passive = <500>;
 			thermal-sensors = <&ths 0>;
 			sustainable-power = <1100>;
 
@@ -1332,9 +1332,9 @@ gpu_temp_critical: gpu-trip-0 {
 			};
 		};
 
-		ve-thermal {
-			polling-delay-passive = <0>;
+		ve_thermal: ve-thermal {
 			polling-delay = <0>;
+			polling-delay-passive = <0>;
 			thermal-sensors = <&ths 1>;
 
 			trips {
@@ -1346,9 +1346,9 @@ ve_temp_critical: ve-trip-0 {
 			};
 		};
 
-		ddr-thermal {
-			polling-delay-passive = <0>;
+		ddr_thermal: ddr-thermal {
 			polling-delay = <0>;
+			polling-delay-passive = <0>;
 			thermal-sensors = <&ths 3>;
 
 			trips {
-- 
2.39.5


We can then create the needed overlays for such.

sunxi-h618-bananapi-m4-pwm1-fan.dtso

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/thermal/thermal.h>

/ {
	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h618";

	fragment@0 {
		target-path = "/";
		__overlay__ {
			fan: gpio-fan {
				compatible = "gpio-fan";
				gpios = <&pio 6 19 GPIO_ACTIVE_HIGH>; /* PG19 */
				gpio-fan,speed-map = <0 0>, <5000 1>;
				#cooling-cells = <2>;
			};
		};
	};

	fragment@1 {
		target = <&cpu_thermal>;
		polling-delay = <1500>;
		__overlay__ {
			trips {
				cpu_active: cpu-active {
					temperature = <61000>; /* 55°C */
					hysteresis = <4000>;
					type = "active";
				};
			};

			cooling-maps {
				map {
					trip = <&cpu_active>;
					cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
				};
			};
		};
	};

	fragment@2 {
		target = <&ddr_thermal>;
		__overlay__ {
			trips {
				ddr_active: ddr-active {
					temperature = <61000>;
					hysteresis = <4000>;
					type = "active";
				};
			};

			cooling-maps {
				map {
					trip = <&ddr_active>;
					cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
				};
			};
		};
	};
};

sunxi-h618-bananapi-m4-pwm2-fan.dtso

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/thermal/thermal.h>

/ {
	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h618";

	fragment@0 {
		target-path = "/";
		__overlay__ {
			fan: gpio-fan {
				compatible = "gpio-fan";
				gpios = <&pio 8 12 GPIO_ACTIVE_HIGH>; /* PI12 */
				gpio-fan,speed-map = <0 0>, <5000 1>;
				#cooling-cells = <2>;
			};
		};
	};

	fragment@1 {
		target = <&cpu_thermal>;
		polling-delay = <1500>;
		__overlay__ {
			trips {
				cpu_active: cpu-active {
					temperature = <61000>; /* 55°C */
					hysteresis = <4000>;
					type = "active";
				};
			};

			cooling-maps {
				map {
					trip = <&cpu_active>;
					cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
				};
			};
		};
	};

	fragment@2 {
		target = <&ddr_thermal>;
		__overlay__ {
			trips {
				ddr_active: ddr-active {
					temperature = <61000>;
					hysteresis = <4000>;
					type = "active";
				};
			};

			cooling-maps {
				map {
					trip = <&ddr_active>;
					cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
				};
			};
		};
	};
};

The overlays are still a WIP as the thermals don't seem to trip exactly when you think they should. I have two diff M4-Zeros, a 2GB and 4GB and both seem to trip the fan at diff times. One at 55*C and the other slightly higher. But they both have diff heatsink arrangements, so this could be why. Either way, I think it might be a good inclusion at some point, unless someone disagrees? The Zeros get really hot when doing anything that involves a HEAD, which is why I started messing with the idea.

@The-going
Copy link
Contributor Author

The overlays are still a WIP as the thermals don't seem to trip exactly when you think they should. I have two diff M4-Zeros, a 2GB and 4GB and both seem to trip the fan at diff times. One at 55*C and the other slightly higher. But they both have diff heatsink arrangements, so this could be why. Either way, I think it might be a good inclusion at some point, unless someone disagrees? The Zeros get really hot when doing anything that involves a HEAD, which is why I started messing with the idea.

Perhaps the reason may be that we cannot correctly configure the internal blocks of the chip (frequency, supply voltage).
I mean AC200, AC300.
This is an assumption.
I'm reading the h616 documentation and looking at what the driver does and I see some kind of discrepancy.

@The-going
Copy link
Contributor Author

The-going commented Mar 17, 2025

The GNOME works well.
Снимок экрана от 2025-03-16 21-49-30

@igorpecovnik I will test XFCE tomorrow.
But I think it can be taken so that other users can test the work on other platforms.

@The-going
Copy link
Contributor Author

@chraac Unfortunately, I was unable to adapt the
patches.armbian/arm64-dts-sun50i-h618-orangepi-zero2w-Add-missing-nodes.patch
to the new kernel version.
Please do it yourself so that it takes into account the current changes.
The kernel with the patches already applied is here:
sunxi-6.13-rebase

@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels Mar 17, 2025
Copy link
Member

@igorpecovnik igorpecovnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge at will.

@The-going
Copy link
Contributor Author

Interesting. XFCE?

I checked it out.
The localization is excellent.
The monitor is detected correctly, I mean the resolution.
But the desktop scale is 100%, I see very large letters, as if the scale was set to 150-200%.
The GNOME displays the scale correctly.

The sound on the BPI-m4-berry does not work.
And I know the reason:

[    0.919065] sun4i-codec 5096000.codec: Failed to get the module clock
[    0.919107] sun4i-codec 5096000.codec: probe with driver sun4i-codec failed with error -2
....
[   12.102140] it's ac300, skip the ac200 init!
[   12.102180] ac200-sunxi 2-0010: probe with driver ac200-sunxi failed with error -22
...
[  185.598782] hdmi-audio-codec hdmi-audio-codec.5.auto: Only one simultaneous stream supported!
[  185.598812] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -22
[  185.598831]  ahub_plat-i2s-hifi: ASoC: error at __soc_pcm_open on ahub_plat-i2s-hifi: -22

I used the user manual for the h616, but apparently there are differences for the h618.

@The-going
Copy link
Contributor Author

The-going commented Mar 18, 2025

One at 55*C and the other slightly higher.

On my BPI-m4-berry, the temperature does not rise above 45C when running on GNOME, XFCE.
The chip has a radiator of 15x15x7 mm.
There is no fan.
The temperature in the room is 22C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
02 Milestone: First quarter release 05 Milestone: Second quarter release Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/large PR with 250 lines or more
Development

Successfully merging this pull request may close these issues.

3 participants