Re: [PATCH RFCv1 3/3] iommu/arm-smmu-v3: Allow ATS to be always on

Robin Murphy
2026-01-26T18:49:12Z

On 2026-01-26 5:20 pm, Jason Gunthorpe wrote:
> On Mon, Jan 26, 2026 at 12:39:50PM +0000, Will Deacon wrote:
>>> + ret = arm_smmu_alloc_cd_tables(master);
>>> + if (ret)
>>> + return ret;
>>
>> Were do you allocate the second level entry for ssid 0 if we're using
>> 2-level cd tables?
>
> I don't think we need to. The entire design here has a non-valid CD entry
> for SSID 0.
>
> The spec is really weird here, on one hand it explicitly says that with
> S1DSS the CD entry is ignored.
>
> On the other hand, you are also required to have a CD table pointer of
> at least size one for some reason.

Because it is not possible to enable 0 SubStreams, since that wouldn't
make any sense, hence S1CDMax also acts as the "enable SubStreams"
control (assuming SSIDSIZE > 0 and it does anything at all - note that
strictly we cannot assume this bypass trick is *always* possible, since
an SMMU is permitted to support ATS without supporting SubStreams).

> So, I think a CD table pointer to a fully invalid L1 table of at least
> size 1 should be OK?
>
> Or stated another way, why would ie be OK to have a 1 level table with
> an non-valid CD table entry for SSID0 but not OK to have a 2 level
> table that returns non-valid at the first walk?

S1ContextPtr itself is reachable since S1 is enabled, so it cannot point
to nonsense. But the S1DSS==Bypass behaviour does state:

"Note: Such a transaction does not fetch a CD, and therefore does not
report F_CD_FETCH, C_BAD_CD or a stage 2 Translation-related fault with
CLASS == CD."

So if we're not intending to actually allow traffic on the SubStream(s),
then it should be fine to use either a 1-level table of invalid CDs, or
a 2-level format with an empty L1CD table to gracefully terminate any
config prefetches.

Thanks,
Robin.