Re: [PATCH v5 3/7] iommu/arm-smmu-v3: Introduce a per-domain arm_smmu_invs array

Nicolin Chen
2025-11-25T04:14:55Z

On Mon, Nov 24, 2025 at 09:42:31PM +0000, Will Deacon wrote:
> On Sat, Nov 08, 2025 at 12:08:04AM -0800, Nicolin Chen wrote:
> > +VISIBLE_IF_KUNIT
> > +struct arm_smmu_invs *arm_smmu_invs_merge(struct arm_smmu_invs *invs,
> > + struct arm_smmu_invs *to_merge)
> > +{
> > + struct arm_smmu_invs *new_invs;
> > + struct arm_smmu_inv *new;
> > + size_t num_trashes = 0;
> > + size_t num_adds = 0;
> > + size_t i, j;
> > +
> > + for (i = j = 0; i < invs->num_invs || j < to_merge->num_invs;) {
>
> Maybe worth having a simple iterator macro for this?

I added two macros:

+#define arm_smmu_invs_for_each_inv(invs, idx, inv) \
+ for (idx = 0, inv = &invs->inv[0]; idx < invs->num_invs; \
+ inv = &invs->inv[++idx])
+#define arm_smmu_invs_for_each_idx_dual(invs1, idx1, invs2, idx2) \
+ for (idx1 = idx2 = 0; idx1 < invs1->num_invs || idx2 < invs2->num_invs;)

Thanks
Nicolin