Re: [PATCH v2 22/31] iommu/vt-d: Export a helper to do function for each dmar_drhd_unit

From: Xu Yilun

Date: Wed Apr 22 2026 - 02:58:38 EST


On Thu, Apr 09, 2026 at 07:49:46AM +0000, Tian, Kevin wrote:
> > From: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>
> > Sent: Saturday, March 28, 2026 12:01 AM
> >
> > @@ -86,6 +86,8 @@ extern struct list_head dmar_drhd_units;
> > dmar_rcu_check()) \
> > if (i=drhd->iommu, 0) {} else
> >
> > +int do_for_each_drhd_unit(int (*fn)(struct dmar_drhd_unit *));
> > +
> > static inline bool dmar_rcu_check(void)
>
> It's a bit weird to insert it here. Move it to follow for_each_iommu().

Sorry, it is following for_each_iommu(), is it?

>
> > +
> > +int do_for_each_drhd_unit(int (*fn)(struct dmar_drhd_unit *))
> > +{
> > + struct dmar_drhd_unit *drhd;
> > + int ret;
> > +
> > + guard(rwsem_read)(&dmar_global_lock);
> > +
> > + for_each_drhd_unit(drhd) {
> > + ret = fn(drhd);
> > + if (ret)
> > + return ret;
> > + }
> > + return 0;
> > +}
>
> use for_each_active_drhd_unit(). or is there need to setup the trusted
> configuration even on ignored iommu?

No, for_each_active_drhd_unit() is good.