From: Robin Murphy <robin.murphy@arm.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
iommu@lists.linux.dev, "Joerg Roedel (AMD)" <joro@8bytes.org>,
Jean-Philippe Brucker <jpb@kernel.org>,
linux-arm-kernel@lists.infradead.org,
Will Deacon <will@kernel.org>
Cc: David Matlack <dmatlack@google.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
patches@lists.linux.dev, Pranjal Shrivastava <praan@google.com>,
Samiullah Khawaja <skhawaja@google.com>,
Mostafa Saleh <smostafa@google.com>
Subject: Re: [PATCH v2 7/8] iommu/arm-smmu-v3: Change how the tlbi describes the invalidation
Date: Mon, 6 Jul 2026 19:00:15 +0100 [thread overview]
Message-ID: <f351b3ce-6488-4b8c-a28a-a3cb0b827750@arm.com> (raw)
In-Reply-To: <7-v2-43074a57a53a+fb95-smmu_tlbi_jgg@nvidia.com>
On 2026-07-06 5:26 pm, Jason Gunthorpe wrote:
[...]
> /*
> - * Generate a single range TLBI command covering [iova, iova+size). Sets
> + * Compute the TTL hint from leaf/table level bitmaps. 0 ttlt means no hint
> + * invalidate all levels.
> + */
> +static unsigned int arm_smmu_compute_ttl(u8 leaf_bitmap, u8 table_bitmap,
> + unsigned int tg)
> +{
> + int ttl;
> +
> + if (leaf_bitmap) {
> + if (is_power_of_2(leaf_bitmap))
> + ttl = 3 - (int)__ffs(leaf_bitmap);
> + else
> + ttl = 0;
> +
> + if (table_bitmap) {
> + int table_ttl = 3 - (int)__ffs(table_bitmap) + 1;
> +
> + /*
> + * A RIL invalidation with !leaf_only clears out all
> + * table levels above the leaf level ttl only.
> + */
> + if (table_ttl > ttl)
> + ttl = 0;
> + }
> + } else if (table_bitmap) {
> + ttl = 3 - (int)__ffs(table_bitmap) + 1;
Maybe I'm misunderstanding what table_bitmap represents, but whichever way:
- if this case means purely changes to table (i.e. non-leaf) PTEs
themselves, then calculating any leaf level is pretty pointless.
- conversely if it means to an invalidate an entire table worth of leaf
PTEs at once, then L1 tables could contain a mix of both L2 and L3
leaves, so a single level is not necessarily sufficient.
- at best, if it's the latter but you'd be generating separate
invalidations for each individual sub-table from the bottom up, such
that there would only be exactly one table_bitmap level per
invalidation, isn't that pretty inefficient?
> + } else {
> + /* Both bitmaps zero is not allowed */
> + return 0;
> + }
> +
> + /* 16K granule, ARM TTL=1 is reserved (SMMUv3 F.b Section 4.4.1) */
> + if (tg == 14 && ttl == 1)
> + return 0;
It's reserved in the absence of LPA2, i.e. when DS=0 (side note, please
refer to an up-to-date version of the architecture - F.b is pretty old
by now) because the 16K format can only have L1 block entries when using
52-bit VA. If between the caller and the code above we can calculate
that a block entry exists where it cannot, then something is wrong and
needs fixing properly.
> + /* ARM levels -1 and 0 cannot be hinted */
> + if (ttl <= 0 || ttl > 3)
> + return 0;
Similarly, no format allows blocks at level -1, so again if that check
ever did anything we'd already have bigger problems. In the remaining
case, 4KB with 52-bit VA *does* permit blocks at level 0, but it should
hopefully be obvious why that doesn't need special treatment here either...
Thanks,
Robin.
> + return ttl;
> +}
next prev parent reply other threads:[~2026-07-06 18:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 16:26 [PATCH v2 0/8] Organize the SMMUv3 invalidation flow so iommupt can use it Jason Gunthorpe
2026-07-06 16:26 ` [PATCH v2 1/8] iommu/arm-smmu-v3: Pass the parameters for the invalidation in a struct Jason Gunthorpe
2026-07-07 3:04 ` Nicolin Chen
2026-07-06 16:26 ` [PATCH v2 2/8] iommu/arm-smmu-v3: Move pgsize out of arm_smmu_inv Jason Gunthorpe
2026-07-07 3:57 ` Nicolin Chen
2026-07-06 16:26 ` [PATCH v2 3/8] iommu/arm-smmu-v3: Optimize range invalidation for latency Jason Gunthorpe
2026-07-07 7:27 ` Nicolin Chen
2026-07-06 16:26 ` [PATCH v2 4/8] iommu/arm-smmu-v3: Keep track in the arm_smmu_invs if RIL is used Jason Gunthorpe
2026-07-07 7:27 ` Nicolin Chen
2026-07-06 16:26 ` [PATCH v2 5/8] iommu/arm-smmu-v3: Precompute the invalidation commands Jason Gunthorpe
2026-07-06 16:26 ` [PATCH v2 6/8] iommu/arm-smmu-v3: Populate the tlbi at the top of the call chain Jason Gunthorpe
2026-07-06 16:26 ` [PATCH v2 7/8] iommu/arm-smmu-v3: Change how the tlbi describes the invalidation Jason Gunthorpe
2026-07-06 18:00 ` Robin Murphy [this message]
2026-07-06 19:45 ` Jason Gunthorpe
2026-07-06 16:26 ` [PATCH v2 8/8] iommu/arm-smmu-v3: Support the DS expansion of RIL's SCALE Jason Gunthorpe
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=f351b3ce-6488-4b8c-a28a-a3cb0b827750@arm.com \
--to=robin.murphy@arm.com \
--cc=dmatlack@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=jpb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=pasha.tatashin@soleen.com \
--cc=patches@lists.linux.dev \
--cc=praan@google.com \
--cc=skhawaja@google.com \
--cc=smostafa@google.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