mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Drake <dan@reactivated.net>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Joerg Roedel (AMD)" <joro@8bytes.org>,
	Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	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 5/6] iommu: Add Broadcom BCM2712 IOMMU driver
Date: Sat, 18 Jul 2026 09:39:48 +0100	[thread overview]
Message-ID: <57f5675c-8bcd-4022-978b-9f7933bb0032@reactivated.net> (raw)
In-Reply-To: <20260712221125.GD1835788@ziepe.ca>

Hi,

On 12/07/2026 23:11, Jason Gunthorpe wrote:
>> +static int bcm2712_iommu_map_pages(struct iommu_domain *domain,
>> +				   unsigned long iova, phys_addr_t paddr,
>> +				   size_t pgsize, size_t pgcount, int prot,
>> +				   gfp_t gfp, size_t *mapped)
>> +{
>> +	struct bcm2712_iommu_domain *mydomain = to_bcm2712_domain(domain);
>> +	struct pt_iommu *pt = &mydomain->pt.iommu;
>> +
>> +	return pt->ops->map_range(pt, bcm2712_iova_to_offset(mydomain, iova),
>> +				  paddr, pgsize * pgcount, prot, gfp, mapped);
>> +}
> 
> These ops should not be present, the iommpt provides the ops directly
> through a macro;
> 
>> +static const struct iommu_ops bcm2712_iommu_ops = {
>> +	.identity_domain = &bcm2712_identity_domain,
>> +	.domain_alloc_paging = bcm2712_iommu_domain_alloc,
>> +	.probe_device = bcm2712_iommu_probe_device,
>> +	.device_group = generic_single_device_group,
>> +	.of_xlate = bcm2712_iommu_of_xlate,
>> +	.default_domain_ops = &(const struct iommu_domain_ops) {
>> +		.attach_dev	 = bcm2712_iommu_attach_dev,
>> +		.iotlb_sync      = bcm2712_iommu_sync,
>> +		.iotlb_sync_map  = bcm2712_iommu_sync_map,
>> +		.flush_iotlb_all = bcm2712_iommu_sync_all,
>> +		.free		 = bcm2712_iommu_domain_free,
>> +		.map_pages       = bcm2712_iommu_map_pages,
>> +		.unmap_pages     = bcm2712_iommu_unmap_pages,
>> +		.iova_to_phys    = bcm2712_iova_to_phys,
>> +	},
> 
> Then use something like:
> 
> 		IOMMU_PT_DOMAIN_OPS(bcm2712),
> 
> To define all the page table related ops automatically.
I don't think I can use that because this setup uses an IOVA aperture at 
base 0xA00000000, whereas generic_pt assumes it is managing a 0-indexed 
virtual address space. So the driver has to intercept every incoming 
IOVA and translate for the aperture, see how map_pages calls:

  static inline unsigned long
  bcm2712_iova_to_offset(struct bcm2712_iommu_domain *domain, unsigned 
long iova)
  {
  	return iova - domain->mmu->aperture_start;
  }

That's why I also set is_iommupt=false. I will add a comment to make 
this clear. Let me know if you see a better approach. I was wondering 
about making iommupt understand apertures and translate accordingly, but 
I imagine you would want to keep that kind of thing out of the generic 
fast path?

Thanks for all the other feedback too - working on it!

Daniel


  reply	other threads:[~2026-07-18  8:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 21:18 [PATCH 0/6] Add support for Broadcom BCM2712 IOMMU driver (Raspberry Pi 5) Daniel Drake
2026-07-12 21:18 ` [PATCH 1/6] generic_pt: allow missing sw bit in DMA_INCOHERENT case Daniel Drake
2026-07-12 22:00   ` Jason Gunthorpe
2026-07-12 21:18 ` [PATCH 2/6] iommupt: allow full-table contiguous leaves in unit tests Daniel Drake
2026-07-12 22:02   ` Jason Gunthorpe
2026-07-12 21:18 ` [PATCH 3/6] dt-bindings: iommu: Add Broadcom BCM2712 IOMMU Daniel Drake
2026-07-13  9:16   ` Krzysztof Kozlowski
2026-07-12 21:18 ` [PATCH 4/6] iommu/generic_pt: Add Broadcom BCM2712 page table format Daniel Drake
2026-07-12 22:05   ` Jason Gunthorpe
2026-07-13 10:02   ` Nick Hollinghurst
2026-07-13 12:00     ` Jason Gunthorpe
2026-07-12 21:18 ` [PATCH 5/6] iommu: Add Broadcom BCM2712 IOMMU driver Daniel Drake
2026-07-12 22:11   ` Jason Gunthorpe
2026-07-18  8:39     ` Daniel Drake [this message]
2026-07-18 14:32       ` Jason Gunthorpe
2026-07-12 21:18 ` [PATCH 6/6] arm64: dts: broadcom: bcm2712: Add GPU IOMMU and IOMMU cache nodes Daniel Drake
2026-07-13  9:17   ` Krzysztof Kozlowski
2026-07-27 23:13 ` [PATCH 0/6] Add support for Broadcom BCM2712 IOMMU driver (Raspberry Pi 5) Jim Quinlan

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=57f5675c-8bcd-4022-978b-9f7933bb0032@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®