From: Daniel Drake <dan@reactivated.net>
To: Jason Gunthorpe <jgg@ziepe.ca>, Robin Murphy <robin.murphy@arm.com>
Cc: "Joerg Roedel (AMD)" <joro@8bytes.org>,
Will Deacon <will@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
nick.hollinghurst@raspberrypi.com
Subject: Re: [PATCH v2 4/5] iommu: Add Broadcom BCM2712 IOMMU driver
Date: Fri, 31 Jul 2026 21:22:42 +0100 [thread overview]
Message-ID: <d6bb859e-c1e7-428e-b765-7b471e1ce005@reactivated.net> (raw)
In-Reply-To: <amlE8rEgryPqrUZd@ziepe.ca>
On 29/07/2026 01:10, Jason Gunthorpe wrote:
> If paging is attached then it sets MMMU_CTRL_OPERATING_FLAGS and
> places the aperture at 40G. Based on the comments about blocking I
> wonder if the "bypass" even works when paging is on?
>
> If blocking is attached then it sets MMMU_CTRL_OPERATING_FLAGS with
> some 0 address cap which aborts everything?
The hardware lets two regions be configured:
1. Bypass window
Configured as BYPASS_START_OFFSET..BYPASS_END_OFFSET
Any device access to addresses in this range go straight through to the
same addresses in physical memory. There is no PT translation.
2. IOVA Aperture
Configured as BYPASS_END_OFFSET..ADDR_CAP_OFFSET
Any device access to addresses in this region go through page table
translation before reaching physical memory.
The bypass must come before the aperture.
Access to any address above ADDR_CAP_OFFSET will abort.
So the blocking domain is implemented by setting both of those ranges to
0, which means ADDR_CAP_OFFSET=0 as part of that. (I'm going with the
interpretation that a blocking domain is like a killswitch and should
abort all memory accesses.)
However, the blocking domain implementation should be removed (see below).
The bypass works fine when paging is on - did you spot something that
makes you suspect otherwise?
> It looks to me like some of those comments and choices don't reflect
> what the driver actually does. Since there is only ever one
> translation we never need to be worried about where the aperture is,
> it could be anything so long as the HW gives it priority to bypass.
>
> Could the aperture be placed at 0 with the bypass fully disabled? Then
> it would basically be a normal iommu.
Please let me know which comments/choices you are finding unclear, I
tried to make this driver readable and would like to fix that.
The aperture could be placed anywhere, but the key idea in the current
driver structure is that we deliberately place it above physical memory,
so that we can have the bypass window operational for all regular
physical addresses, meaning that iommu-unaware devices can operate as
normal.
Each of the 3-4 IOMMUs has around 5 devices hardwired into it. When the
IOMMU is switched on (effectively via setting CTRL_OPERATING_FLAGS),
*all* of the hardwired devices are subject to the IOMMU operation,
uniformly. There is no gating where you can have one of the devices in
standard passthrough mode and the rest using the IOMMU. Also there is no
Stream ID in the transactions, there is no way to configure per-device
page tables.
Among the devices hardwired to the IOMMUs we might have:
- Devices already set up by the firmware and relying on regular access
to physical memory
- Devices that don't require large contiguous DMA allocations and would
prefer not to have the translation overhead of the iommu
- Devices that handle scatter-gather natively and prefer not to have
the translation overhead of the iommu
- & devices that want to use the IOMMU :) so that they can work with
large contiguous allocations which are actually scattered in
underlying physical memory
So we have multiple needs to tend to, which is why the driver currently
sets up the bypass in the regular address space (serving the first 3
above), and the IOMMU aperture in a high, unused part of the address
space (for the devices that do want to take advantage of the IOMMU).
Are those good enough reasons to set up the driver in this way? Or are
there other approaches to consider?
Let's take an example where the aperture gets placed at address 0 (and
hence there is no bypass window). Now it is operating more like a
"normal" IOMMU (except without per-device configurable behaviour, stream
IDs, etc). The system boots and the firmware sets up the display
controller rendering some early boot screens. Then the kernel boots and
takes over the framebuffer using efifb or simpledrm. Then it loads a
device driver for, let's say, an image processor. This turns on one of
the iommus and puts it in paging mode. The aperture gets placed at
address 0, no bypass window. But, whoops, that iommu happened to *also*
have the display controller hardwared into it. Now we have a big visual
glitch and the display output has stopped. And maybe the kernel doesn't
even have the vc4 display driver available to correct that later,
because the expectation was just to use the simple fw-configured
framebuffer.
This is also why I think the blocking domain implementation should be
removed. It causes collateral damage to all the devices which might not
have had any idea they were influenced by an iommu.
Thanks for your help!
Daniel
next prev parent reply other threads:[~2026-07-31 20:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 20:43 [PATCH v2 0/5] Add support for Broadcom BCM2712 IOMMU driver (Raspberry Pi 5) Daniel Drake
2026-07-27 20:43 ` [PATCH v2 1/5] generic_pt: allow missing sw bit in DMA_INCOHERENT case Daniel Drake
2026-07-27 20:43 ` [PATCH v2 2/5] dt-bindings: iommu: Add Broadcom BCM2712 IOMMU Daniel Drake
2026-07-30 6:59 ` Krzysztof Kozlowski
2026-07-27 20:43 ` [PATCH v2 3/5] iommu/generic_pt: Add Broadcom BCM2712 page table format Daniel Drake
2026-07-27 20:43 ` [PATCH v2 4/5] iommu: Add Broadcom BCM2712 IOMMU driver Daniel Drake
2026-07-28 10:51 ` Robin Murphy
2026-07-29 0:10 ` Jason Gunthorpe
2026-07-29 11:21 ` Robin Murphy
2026-07-31 20:22 ` Daniel Drake [this message]
2026-08-16 12:50 ` Daniel Drake
2026-08-16 16:57 ` Jason Gunthorpe
2026-07-30 7:00 ` Krzysztof Kozlowski
2026-07-31 20:34 ` Daniel Drake
2026-08-01 9:15 ` Krzysztof Kozlowski
2026-08-03 10:53 ` Nick Hollinghurst
2026-07-27 20:44 ` [PATCH v2 5/5] arm64: dts: broadcom: bcm2712: Add GPU IOMMU and IOMMU cache nodes Daniel Drake
2026-07-28 22:57 ` [PATCH v2 4/5] iommu: Add Broadcom BCM2712 IOMMU driver Jim Quinlan
2026-08-19 19:22 ` Daniel Drake
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=d6bb859e-c1e7-428e-b765-7b471e1ce005@reactivated.net \
--to=dan@reactivated.net \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=nick.hollinghurst@raspberrypi.com \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.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
all inboxes | Powered by JetHome®