From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 988BC606A322 for ; Sat, 5 Dec 2026 04:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=UMXs5ORk; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.a=rsa-sha256 header.s=default header.b=ZKuIupGf DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=eto3VWOmORBLJ4mYHNG0mJsQLd/KQsch/HEJgAy7xvM=; b=UMXs5ORkiOdr36 Ot1Us8TXb0K7mHZH7b23W6YmkaoWO3r5BDfRMqIz47WWo41BDrxFd25/rNK58jt8dHM+a9vV+hYQA h0RcNhfpAQzub3bAqV6FhGDBbZOQdq47zfBStV6qDQ1X+oYB+FTnlOqwb9Re55FJOJ8fHTaVyEsB/ BG7mYuNj93wq8e17ctPodGafLTOkItz2C4ckdTkIaZmGvGZC9AgnHrLyo2kl8g91aHnsDaHCZvGX7 4+at1RTy5txciFOW7Ql+1rdqIGdkWuSZEFhUBVNJyYGrpGU3EROFpVi+JG+5IMklL3AQV3iYKs2Tz WyZZvosbEs8lzyCYNznA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZhZg-000000020l7-3Zlm; Sat, 05 Dec 2026 04:40:40 +0000 Received: from mail-m16023652138.xmail.ntesmail.com ([160.236.52.138]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZhZc-000000020kc-1K1r; Sat, 05 Dec 2026 04:40:39 +0000 Received: from [172.16.12.90] (unknown [61.154.14.86]) by smtp.qiye.163.com (Hmail) with ESMTP id 6fd05f4da; Sat, 5 Dec 2026 12:40:28 +0800 (GMT+08:00) Message-ID: <6c9cea64-a491-48ca-84da-ad4db2fb0833@rock-chips.com> Date: Sat, 5 Dec 2026 12:40:26 +0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain To: Sebastian Reichel Cc: Robin Murphy , Francesco Saverio Pavone , Joerg Roedel , Will Deacon , Sandy Huang , Heiko Stuebner , Andy Yan , Damon Ding , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jiaxing Hu , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org References: <20261204153227.7794-1-pavone.lawyer@gmail.com> <480259ce-4971-45d4-b34e-e8b5a8e6ee29@rock-chips.com> Content-Language: en-US From: Chaoyi Chen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-HM-Tid: 0aa24480e9a903a7kunm6289fd472129b5 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkaHx9JVk1LT0xOQkxJHUNOHlYVFA kWGhdVEwETFhoSFyQUDg9ZV1kYEgtZQVlNSlVKTk9VSk9VQ01ZV1kWGg8SFR0UWUFZT0tIVUJCSU 5LVUpLS1VKQktCWQY+ DKIM-Signature: a=rsa-sha256; b=ZKuIupGfnZ5ieDMygn5EvCc/qcbxaNNm0haXKX0eSXlfs9d21lkA+hu7Jw0W2XixDEHjYUzosA/vID00Mk6a+dHDf6/7V7PSs4f+TmNsMD7yqpG7o9jT0nEwrKYNi4D/5Hwk1zFCiOYvraVBybO6LQtWOlYpa1L6Ktp2eX00D7c=; s=default; c=relaxed/relaxed; d=rock-chips.com; v=1; bh=eto3VWOmORBLJ4mYHNG0mJsQLd/KQsch/HEJgAy7xvM=; h=date:mime-version:subject:message-id:from; X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_204037_005193_57AC3CB8 X-CRM114-Status: GOOD ( 24.97 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-7.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Sebastian, On 12/5/2026 12:06 PM, Sebastian Reichel wrote: > Hi, > > On Sat, Dec 05, 2026 at 10:19:07AM +0800, Chaoyi Chen wrote: >> Hi, >> >> On 12/5/2026 1:14 AM, Robin Murphy wrote: >>> On 04/12/2026 3:32 pm, Francesco Saverio Pavone wrote: >>>> Hi Robin, >>>> >>>> On 2026-12-04 12:00, Robin Murphy wrote: >>>>> If you reach the point of creating private abstractions of entire >>>>> IOMMU API concepts inside a DRM driver, you should probably stop and >>>>> think "Why aren't other drivers doing this?" >>>> >>>> Thank you. That was blunt, and it was right. I went and looked: no >>>> driver outside drivers/iommu walks the reserved regions the way my >>>> patch does. >>> >>> Heh, sometimes it's hard to see the wood for the trees when you're working backwards from one very specific symptom of a larger issue. >>> >>>> I am withdrawing the series. >>>> >>>> The driver already does the standard takeover. I think the real gap >>>> is smaller: the VOP2 is not stopped before it is attached to the >>>> IOMMU domain, while the older VOP driver resets itself first. I will >>>> look at that instead, and only send something if it removes the >>>> faults on my board. >>> >>> I don't doubt that both the IOMMU driver and the VOP drivers might need a bit of smoothing out to make this properly work, it's just one of those scenarios where I'm almost certain that taking a step back to do things the "right" way will end up being easier. >>> >>> And that's not to say that this "minimal glitch" approach of pre-mapping the initial framebuffer prior to attaching the domain (and ideally unmapping it again as soon as we're sure it's out of use) isn't still potentially worth exploring, just that I'd hope we could pull the relevant config straight out of the VOP registers, or at worst add a DRM-appropriate way to query any existing sysfb aperture. But yeah, if just stopping the thing for the duration of driver registration is good enough for now, even simpler! >>> >> >> Yes, this depends largely on what we are trying to achieve. >> >> If we merely want to eliminate the IOMMU warnings, then resetting the >> hardware before attach, or stopping the DMA, would easily accomplish that. >> >> But if we want the display to remain completely continuous throughout the >> entire boot process and to transition smoothly from IOMMU disabled to >> IOMMU enabled, then it may require more effort. >> >> I saw some interesting examples: >> >> - Exynos uses a default domain. >> - Msm mdp4/mdp5 disable display before attaching IOMMU. >> - i915 wraps the reserved region as a GEM object (DRM framebuffer) >> and displays it. >> >> If we adopt an i915-style takeover, perhaps we need to do the following: >> >> { >> rockchip_gem_alloc_object() /* alloc object */ >> drm_mm_reserve_node() /* optional? reserve old iova */ >> iommu_map_sgtable() /* map old iova to new GEM */ >> /* copy old fb data to new GEM */ >> } >> >> /* Now iova is in private domain */ >> >> rockchip_drm_dma_attach_device() /* IOMMU take over! */ >> >> /* after userspace take over */ >> { >> iommu_unmap(); >> drm_mm_remove_node(); >> drm_gem_object_put(); >> } >> >> This looks more like something done in the DRM world. >> Robin, what do you think of this? Thank you. > > FYI there is some ongoing work for generic DRM helpers regarding DRM > state readout from prior boot stages (I haven't found the time to > look at this closer myself, so not sure how much they help with the > IOMMU specifically): > > https://lore.kernel.org/dri-devel/20261127-drm-state-readout-v10-0-0259582d45a8@kernel.org/ > Yes, I noticed this series earlier, but I think its benefit for the IOMMU is limited. It is intended to establish the initial state by reading hardware registers. In my view, this can help us maintain resources such as clocks and power domains during the boot process, and without needing to repeatedly perform enable and similar operations on the PHY. And once the IOMMU operations described above are justified, the two could perhaps be combined in some way. > Greetings, > > -- Sebastian -- Best, Chaoyi