Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jiaxing Hu <gahing@gahingwoo.com>
To: Chaoyi Chen <chaoyi.chen@rock-chips.com>
Cc: Francesco Saverio Pavone <pavone.lawyer@gmail.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Sandy Huang <hjc@rock-chips.com>, Andy Yan <andyshrk@163.com>,
	Damon Ding <damon.ding@rock-chips.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Lucas Tanure <tanure@linux.com>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Cristian Ciocaltea <cristian.ciocaltea@collabora.com>,
	iommu@lists.linux.dev, dri-devel@lists.freedesktop.org,
	linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: rk3588: VOP IOMMU faults at boot while the firmware window is on
Date: Mon, 30 Nov 2026 15:04:31 +1300	[thread overview]
Message-ID: <20261130020431.487169-1-gahing@gahingwoo.com> (raw)
In-Reply-To: <1c5a8286-d61f-4c7c-b2ff-33aac9018abe@rock-chips.com>

Hi Chaoyi,

On 11/30/2026 9:49 AM, Chaoyi Chen wrote:
> For clk_ignore_unused and pd_ignore_unused, see this series:
>
> https://lore.kernel.org/linux-clk/20260626-clk-sync-state-v1-0-4156d8196dc8@redhat.com/

Thanks, that explains why the module case only stays clean by luck of
timing.

> This looks more like some kind of hack.
> Why not just use iommu_map() to establish a 1:1 mapping?

That is actually what I ended up doing in my Windows display driver on
RK3576 [1]. Before enabling translation in the VOP's IOMMU, it maps the
firmware framebuffer pages 1:1 at their own physical addresses so the
active scanout window keeps hitting valid memory once paging turns on.
I've had this enabled by default since Nov 21.

Here is the relevant snippet from scanout.c [2]:

	/* at load: the firmware framebuffer at its own address */
	for (ULONG64 p = fb & ~0xFFFull; p < fb + A->FbSize; p += PAGE_SIZE)
		if (!Enter(A, (ULONG)p, p))
			goto fail;

	/* later, with the window still scanning: tables in, paging on */
	ULONG dte = Entry((ULONG64)A->ScanTablesPa.QuadPart, 1);
	for (ULONG m = VOP_MMU0; m <= VOP_MMU1; m += VOP_MMU1 - VOP_MMU0) {
		W(A, m + VMMU_DTE_ADDR, dte);
		W(A, m + VMMU_COMMAND, VMMU_CMD_ZAP_CACHE);
		W(A, m + VMMU_INT_MASK, 0);
		W(A, m + VMMU_AUTO_GATING,
		  R(A, m + VMMU_AUTO_GATING) | 0x80000000u);
	}
	W(A, VOP_MMU0 + VMMU_COMMAND, VMMU_CMD_ENABLE_PAGING);
	W(A, VOP_MMU1 + VMMU_COMMAND, VMMU_CMD_ENABLE_PAGING);

Looking at rockchip_drm_drv.c, the domain gets allocated in
rockchip_drm_init_iommu() and the VOP attaches to it during bind.
Calling iommu_map() for a 1:1 mapping of the firmware framebuffer right
before that first attach should keep the live window happy. On EFI
boots the address would have to come from screen_info, since there is
no simple-framebuffer node, and it would need checking against the
window the VOP is actually scanning before it is trusted.

One gotcha I ran into on the Windows side: the 1:1 mapping has to
outlive the initial modeset. The VOP keeps scanning out from the old
address until the next frame start, so tearing down the entries right
after programming the flip triggered the exact same 0x40b fault. Any
unmap on Linux would need to wait until the next vblank after the
window actually switches over; in my driver, I just leave the entries
mapped. Here is the note I left myself when debugging it [3]:

	/* The entries stay. The window moves at the next frame start, and
	 * until then the VOP2 is still reading this primary: with the entries
	 * cleared it faulted (IOMMU status 0x40b, seen when dwm.exe was ended
	 * a dozen times in a row). */

Francesco, thanks for running those module tests. Good to confirm it's
the power domain rather than the clocks.

In the meantime, I'll go ahead and quiesce the HDMI path in my firmware
the same way I did for DSI until a proper kernel-side fix lands.

Thanks,
Jiaxing

[1] https://github.com/gahingwoo/wddm-mali-g52
[2] https://github.com/gahingwoo/wddm-mali-g52/blob/906abc21eda0/drivers/maliwddm/scanout.c#L213-L216
    https://github.com/gahingwoo/wddm-mali-g52/blob/906abc21eda0/drivers/maliwddm/scanout.c#L636-L648
[3] https://github.com/gahingwoo/wddm-mali-g52/blob/906abc21eda0/drivers/maliwddm/scanout.c#L607-L612


      reply	other threads:[~2026-11-30  2:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  9:38 rk3588: VOP IOMMU faults at boot while the firmware window is on Francesco Saverio Pavone
2026-11-29 10:04 ` Jiaxing Hu
2026-11-29 16:40   ` Francesco Saverio Pavone
2026-11-30  1:48     ` Chaoyi Chen
2026-11-30  2:04       ` Jiaxing Hu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130020431.487169-1-gahing@gahingwoo.com \
    --to=gahing@gahingwoo.com \
    --cc=andyshrk@163.com \
    --cc=chaoyi.chen@rock-chips.com \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=damon.ding@rock-chips.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=iommu@lists.linux.dev \
    --cc=jagan@amarulasolutions.com \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=pavone.lawyer@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=sebastian.reichel@collabora.com \
    --cc=tanure@linux.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox