Re: [PATCH 1/8] iommu: Lift and generalize the STE/CD update code from SMMUv3

From: Samiullah Khawaja

Date: Mon Mar 30 2026 - 11:30:35 EST


On Mon, Mar 30, 2026 at 10:00:24AM -0300, Jason Gunthorpe wrote:
On Mon, Mar 09, 2026 at 11:33:23PM +0000, Samiullah Khawaja wrote:
> + for (i = 0; i != writer->num_quantas; i++) {
> + /*
> + * Check that masks are up to date, the make functions are not

nit: "the make functions" looks like a typo.

the smmu drivers called all the functions that build STE and CD
structs 'arm_smmu_make_xxx' So they are the 'make functions'

Interesting... Thanks for the context.

> + } else if (used_qword_diff) {
> + /*
> + * At least two quantas need their inuse bits to be changed.
> + * This requires a breaking update, zero the V bit, write all
> + * qwords but 0, then set qword 0
> + */
> + unused_update[writer->vbit_quanta] = 0;
> + NS(entry_set)(writer, entry, unused_update, writer->vbit_quanta, 1);
> +
> + if (writer->vbit_quanta != 0)
> + NS(entry_set)(writer, entry, target, 0,
> + writer->vbit_quanta - 1);

Looking at the definition of the entry_set below, the last argument is
length. So if vbit_quanta 1 then it would write zero len. Shouldn't it
be writing quantas before the vbit_quanta?
> + if (writer->vbit_quanta != writer->num_quantas)
> + NS(entry_set)(writer, entry, target,
> + writer->vbit_quanta,
> + writer->num_quantas - 1);

Sami here, the last argument should not have "- 1".

Yeah, I probably botched this when I quickly drafted it

Jason

Thanks,
Sami