Closed z3ntu closed 6 months ago
I think this hack is just so Mesa treats the GPU as supported. We just need to add A506 here https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/freedreno/common/freedreno_devices.py#L180
You'll probably also need something like https://github.com/sdm660-mainline/linux/commit/43eb92b8babf14da947f9056e11205961a9066c6 (but I'm not 100% sure)?
You'll probably also need something like sdm660-mainline@43eb92b (but I'm not 100% sure)?
MODULE_FIRMWARE("qcom/a506_zap.b00");
MODULE_FIRMWARE("qcom/a506_zap.b01");
MODULE_FIRMWARE("qcom/a506_zap.b02");
MODULE_FIRMWARE("qcom/a506_zap.mdt");
a530_pm4.fw and a530_pfp.fw already present
FTR from matrix: https://matrix.to/#/!znmHDDTlttuCQhhnWN:matrix.org/$VEBnGhxv-tJrpZEAq17C3eeCGK5QQIX7wdOfeI6b9L8?via=z3ntu.xyz&via=matrix.org
vladly bare minimum for GPU to work is:
just GPU IOMMU and GPU nodes.
iommu/qcom: defer probe until scm is available
iommu/qcom: restore IOMMU state if needed
iommu/qcom: Use the asid read from device-tree if specified
oriommu/qcom: Index contexts by asid number to allow asid 0
alikates (he/they) The last one was already merged Author: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com Date: Tue Nov 15 11:11:20 2022 +0100
iommu/qcom: Index contexts by asid number to allow asid 0
Seems IOMMU patches are still pending, so we're blocked on the kernel part on that.
But in the meantime I've submitted mesa MR which makes GPU work without the A530 hack linked in the top message https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22647
A506 patch is also now present in Alpine edge: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/46345
So we can start trying to drop the 3c181c25e8355d641a711dc5da4ab35b1b5a64fb commit I believe, worked fine in my testing.
I just cherry-picked the iommu patches (starting with 8f2410192ef7255e0bc2cec6b29d33412002854) on top of kernel.org linux-next-20230602. To get drm to initialize one also needs drivers/interconnect/qcom/msm8953.c, otherwise the booting process seems to crash (on fairphone-fp3). Now only the display fails to initialize:
[ 3.179743] msm_mdp 1a01000.display-controller: bound 1c00000.gpu (ops 0xffff800008d2a190)
[ 3.179941] msm_mdp 1a01000.display-controller: [drm:mdp5_kms_init] MDP5 version v1.16
[ 3.205728] [drm] Initialized msm 1.10.0 20130625 for 1a01000.display-controller on minor 0
[ 3.206002] msm_mdp 1a01000.display-controller: [drm:adreno_request_fw] loaded qcom/a530_pm4.fw3 from legacy location
[ 3.213653] msm_mdp 1a01000.display-controller: [drm:adreno_request_fw] loaded qcom/a530_pfp.fw from legacy location
[ 3.307622] msm_mdp 1a01000.display-controller: pp done time out, lm=0
[ 3.340772] panel-djn-hx83112b 1a94000.dsi.0: Failed to initialize panel: -22
Almost there ...
Edit: panel initalization fails because djn_hx83112b_prepare is called before msm_dsi_host_power_on Edit2: This seems to be caused by the removal of dsi_mgr_power_on_early in linux-next-20230522. Edit3: Success! Display is up and running.
These are the patches that make the gpu and display work for the fairphone-fp3 for linux-next-20230602 from kernel.org. I've not yet tried how well these work with the current linux-next/master. 0001-iommu-qcom-Use-the-asid-read-from-device-tree-if-spe.patch.txt 0002-iommu-qcom-Properly-reset-the-IOMMU-context.patch.txt 0003-iommu-qcom-Index-contexts-by-asid-number-to-allow-as.patch.txt 0004-iommu-qcom-Add-support-for-QSMMUv2-and-QSMMU-500-sec.patch.txt 0005-iommu-qcom-Add-support-for-AArch64-IOMMU-pagetables.patch.txt 0006-fixup-iommu-qcom-Add-support-for-AArch64-IOMMU-paget.patch.txt 0007-iommu-qcom-avoid-bouncing-power-domain.patch.txt 0008-iommu-qcom-implement-adreno_priv-interface.patch.txt 0009-iommu-qcom-emulate-IDENTITY-domain-for-display-durin.patch.txt 0010-iommu-qcom-restore-IOMMU-state-if-needed.patch.txt 0011-iommu-qcom-defer-probe-until-scm-is-available.patch.txt 0012-MSM8953-drm-panel-Generate-using-linux-mdss-dsi-pane.patch.txt 0013-squash-MSM8953-drm-panel-Generate-using-linux-mdss-d.patch.txt 0014-drm-panel-fairphone-fp3-hx83112b-Swab-brightness-val.patch.txt 0015-squash-MSM8953-drm-panel-Generate-using-linux-mdss-d.patch.txt 0016-arm64-dts-qcom-msm8953-add-IOMMUs.patch.txt 0017-arm64-dts-qcom-msm8953-add-GPU.patch.txt 0018-arm64-dts-qcom-msm8953-add-GPU-operating-points.patch.txt 0019-arm64-dts-qcom-msm8953-enable-cpu-frequency-scaling.patch.txt 0020-arm64-dts-qcom-msm8953-add-cci-adapter.patch.txt 0021-arm64-dts-qcom-msm8953-add-camss-subsystem.patch.txt 0022-arm64-dts-qcom-msm8953-add-cpu-idle-states.patch.txt 0023-arm64-dts-qcom-sdm632-enable-cpu-frequency-scaling.patch.txt 0024-arm64-dts-qcom-msm8953-add-modem-remoteproc.patch.txt 0025-arm64-dts-qcom-sdm632-fairphone-fp3-add-display.patch.txt 0026-fixup-arm64-dts-qcom-sdm632-fairphone-fp3-add-displa.patch.txt 0027-HACK-drm-msm-a5xx-present-A506-as-A530.patch.txt I'm not really sure if the clock patches are necessary: 0028-clk-qcom-gcc-msm8953-don-t-cache-rate-for-dsi-clocks.patch.txt 0029-clk-qcom-rcg2-round-parent-rate-when-SET_RATE_PARENT.patch.txt 0030-clk-qcom-improve-regmap-mux-div-clock-ops-v2.patch.txt 0031-clk-qcom-Add-single-Alpha-PLL-driver.patch.txt 0032-clk-qcom-Add-muliplexer-divider-clock-for-CPUs.patch.txt The interconnect patches ARE necessary: 0033-interconnect-icc-rpm-Add-option-to-get-regmap-from-p.patch.txt 0034-dt-bindings-interconnect-Add-bindings-for-Qualcomm-M.patch.txt 0035-arm64-dts-qcom-msm8953-add-interconnect.patch.txt 0036-interconnect-qcom-Add-MSM8953-interconnect-provider-.patch.txt This is needed for proper display init on the fairphone-fp3: 0037-Revert-drm-msm-dsi-Stop-unconditionally-powering-up-.patch.txt
Rebasing this to linux-next-20230609 worked fine but there is stilll one warning:
2.989910] ------------[ cut here ]------------
[ 2.989913] msm_mdp 1a01000.display-controller: drm_WARN_ON_ONCE(!helper->funcs->fb_dirty)
[ 2.989965] WARNING: CPU: 5 PID: 39 at drivers/gpu/drm/drm_fb_helper.c:381 drm_fb_helper_damage_work+0x15c/0x168
[ 2.989992] Modules linked in:
[ 2.990001] CPU: 5 PID: 39 Comm: kworker/5:0 Not tainted 6.4.0-rc5-next-20230609-debian-github-msm8953+ #643
[ 2.990011] Hardware name: Fairphone 3 (DT)
[ 2.990015] Workqueue: events drm_fb_helper_damage_work
[ 2.990028] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 2.990036] pc : drm_fb_helper_damage_work+0x15c/0x168
[ 2.990046] lr : drm_fb_helper_damage_work+0x15c/0x168
[ 2.990055] sp : ffff800082443d80
[ 2.990058] x29: ffff800082443d80 x28: 0000000000000000 x27: 0000000000000000
[ 2.990070] x26: ffff0000f9bce6c0 x25: 00000000fffffef7 x24: ffff000014997ee0
[ 2.990081] x23: ffff0000f9bd2605 x22: ffff0000f9bce6c0 x21: ffff0000153b3000
[ 2.990091] x20: ffff000014997e00 x19: ffff000014997ed8 x18: fffffffffffe5670
[ 2.990101] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000058
[ 2.990112] x14: 0000000000000001 x13: fffffffffffc56c7 x12: ffffffffffffffff
[ 2.990122] x11: fffffffffffe0000 x10: 0000000000000020 x9 : ffff800082443d80
[ 2.990132] x8 : 0000000000000020 x7 : 00000000ffffffff x6 : 0000000000000000
[ 2.990142] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff
[ 2.990152] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000125c8000
[ 2.990162] Call trace:
[ 2.990165] drm_fb_helper_damage_work+0x15c/0x168
[ 2.990174] process_one_work+0x1e0/0x340
[ 2.990184] worker_thread+0x68/0x428
[ 2.990190] kthread+0x100/0x10c
[ 2.990201] ret_from_fork+0x10/0x20
[ 2.990211] ---[ end trace 0000000000000000 ]---
I was able to trim it down a little. These are the patches necessary to have working GPU and display on the fairphone-fp3, patches are on top of linux-next-20230616 from kernel.org (commit f7efed9f38f886edb450041b82a6f15d663c98f8): 0001-iommu-qcom-Use-the-asid-read-from-device-tree-if-spe.patch.txt 0002-iommu-qcom-Properly-reset-the-IOMMU-context.patch.txt 0003-iommu-qcom-Index-contexts-by-asid-number-to-allow-as.patch.txt 0004-iommu-qcom-Add-support-for-QSMMUv2-and-QSMMU-500-sec.patch.txt 0005-iommu-qcom-Add-support-for-AArch64-IOMMU-pagetables.patch.txt 0006-fixup-iommu-qcom-Add-support-for-AArch64-IOMMU-paget.patch.txt 0007-iommu-qcom-avoid-bouncing-power-domain.patch.txt 0008-iommu-qcom-implement-adreno_priv-interface.patch.txt 0009-iommu-qcom-emulate-IDENTITY-domain-for-display-durin.patch.txt 0010-iommu-qcom-restore-IOMMU-state-if-needed.patch.txt 0011-iommu-qcom-defer-probe-until-scm-is-available.patch.txt 0012-MSM8953-drm-panel-Generate-using-linux-mdss-dsi-pane.patch.txt 0013-squash-MSM8953-drm-panel-Generate-using-linux-mdss-d.patch.txt 0014-drm-panel-fairphone-fp3-hx83112b-Swab-brightness-val.patch.txt 0015-squash-MSM8953-drm-panel-Generate-using-linux-mdss-d.patch.txt 0016-arm64-dts-qcom-msm8953-add-IOMMUs.patch.txt 0017-arm64-dts-qcom-msm8953-add-GPU.patch.txt 0018-arm64-dts-qcom-sdm632-fairphone-fp3-add-display.patch.txt 0019-fixup-arm64-dts-qcom-sdm632-fairphone-fp3-add-displa.patch.txt 0020-interconnect-icc-rpm-Add-option-to-get-regmap-from-p.patch.txt 0021-dt-bindings-interconnect-Add-bindings-for-Qualcomm-M.patch.txt 0022-arm64-dts-qcom-msm8953-add-interconnect.patch.txt 0023-interconnect-qcom-Add-MSM8953-interconnect-provider-.patch.txt 0024-Revert-drm-msm-dsi-Stop-unconditionally-powering-up-.patch.txt 0025-arm64-dts-qcom-msm8953-add-GPU-operating-points.patch.txt 0026-clk-qcom-gcc-msm8953-don-t-cache-rate-for-dsi-clocks.patch.txt 0027-clk-qcom-rcg2-round-parent-rate-when-SET_RATE_PARENT.patch.txt
A warning from drm_fb_helper_damage work does not occur here.
Edit: My userspace is standard debian stable (12.0, bookworm) with the added 506 patch from here (which took ages (~1h) to compile within a chroot with qemu, dpkg-buildpackage crashed the fairphone-fp3, most likely because of memory usage):
A506 patch is also now present in Alpine edge: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/46345
So we can start trying to drop the 3c181c2 commit I believe, worked fine in my testing.
FYI some of the iommu patches appear to have been merged https://lore.kernel.org/linux-arm-msm/169158176438.300170.11135849217509321045.b4-ty@kernel.org/
Hopefully will be part of v6.5 v6.6 kernel.
Worked on this recently, preparing some commits for upstream... Also posted the last missing IOMMU patch yesterday: https://lore.kernel.org/linux-arm-msm/20231011-msm8953-iommu-restore-v1-1-48a0c93809a2@z3ntu.xyz/T/
If everything goes well I should be able to send the GPU patches upstream soon :)
@z3ntu Is there anything left? If i know correctly it is in 6.9.
Required getting rid of some hacks like 3bc402701599342e2780e13d68f4ffcf378c119f and probably some IOMMU things.
@vldly Can you share any details why these hacks exist right now and a possible way to not need them anymore?