gk7205v500: CMA-allocated MMZ no longer panics the kernel on VPSS-to-VENC bind - #238
Merged
Merged
Conversation
…VENC bind With mmz_allocator=cma, a GK7205V510 panicked as soon as a bound VPSS channel delivered its first frame to VENC. The console showed nothing, because the panic is printed at a loglevel the image silences, and the camera rebooted panic= seconds later. With printk raised: Alignment trap: not handling instruction f8d31045 at VENC_VpssSend+0x10f Unhandled fault: alignment exception (0x001) at 0xc99b6045 *pte=42008043, *ppte=42008012 VENC_VpssSend <- VpssFakeSend <- VPSS_ProcSendPic <- ... VpssOnLineSendFrame The closed venc object reads its bind descriptors with an unaligned ldr.w. The CMA allocator mapped non-cached MMBs with pgprot_noncached(), which is strongly-ordered on ARM, and an unaligned load from strongly-ordered memory faults whatever SCTLR.A says. The carve-out allocator maps the same buffers with ioremap_wc(), Normal non-cacheable, where the load is legal. That is why mmz_allocator=xmedia streams and cma did not, and why a user-space GetChnFrame/SendFrame relay (which never reaches VENC_VpssSend) was stable. arch_kern_pgprot() now returns pgprot_writecombine() for the non-cached case. The same header called the kernel's three-argument __dma_clear_buffer() with two. Its coherent flag, which decides whether the zeroed pages are flushed out of the cache, was whatever cma_alloc() had left in r2. It is now passed explicitly as NORMAL. Measured on a GK7205V510 (MIS2008), mem=128M mmz_allocator=cma: the vendor sample (VI -> VPSS -> bound VENC) and majestic both stream with no alignment trap; before, both panicked within a second of the first frame.
PR Summary by QodoPrevent CMA MMZ alignment panic on GK7205V500 VPSS-to-VENC binds
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships |
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
mmz_allocator=cma(the gk7205v500 family default since #236), a GK7205V510 panicked the kernel as soon as a bound VPSS channel delivered its first frame to VENC. The image runs with the console loglevel at 0, so nothing was printed, and the board rebootedpanic=seconds later. That looked like a hardware reset. Withprintkraised:The closed venc object reads its bind descriptors with an unaligned
ldr.w. The CMA allocator mapped non-cached MMBs withpgprot_noncached(), which is strongly-ordered on ARM, and an unaligned load from strongly-ordered memory always faults. The carve-out allocator maps the same buffers withioremap_wc()(Normal non-cacheable), where the load is legal. That is whymmz_allocator=xmediastreams andcmadid not.Change
kernel/osal/gk7205v500/mmz_arm.h, ARM branch only:arch_kern_pgprot()returnspgprot_writecombine()for the non-cached case, matching the carve-out allocator.__dma_clear_buffer()is declared and called with the OpenIPC 4.9 kernel's three arguments. With two, itscoherent_flag, which decides whether the zeroed pages are flushed out of the cache, was whatevercma_alloc()left inr2.The other families'
mmz_arm.hcopies (hi3516cv500, hi3519v101, linux) also usepgprot_noncached(). They are left alone: no fault has been observed there.Tested on
GK7205V510, Zenointel SD-2N-4G, MIS2008, OpenIPC
gk7205v500_ultimateNAND image,mem=128M mmz_allocator=cma mmz=anonymous,0,0x42000000,96M. The rebuiltopen_osal.kowas loaded in place of the image's.Isolation, with the same image and modules:
sample_viomode 0 (VI → VPSS → bound VENC)mmz_allocator=xmedia(mem=32Mormem=64M)dmesg | grep -c alignment