lkml.org 
[lkml]   [2023]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 02/10] iommu: Introduce a new iommu_group_replace_domain() API
On Wed, Feb 15, 2023 at 06:10:47AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc@nvidia.com>
> > Sent: Wednesday, February 8, 2023 5:18 AM
> >
> > +int iommu_group_replace_domain(struct iommu_group *group,
> > + struct iommu_domain *new_domain)
> > +{
> > + int ret;
> > +
> > + if (!new_domain)
> > + return -EINVAL;
> > +
> > + mutex_lock(&group->mutex);
> > + ret = __iommu_group_set_domain(group, new_domain);
> > + if (ret)
> > + __iommu_group_set_domain(group, group->domain);
>
> Just realize the error unwind is a nop given below:
>
> __iommu_group_set_domain()
> {
> if (group->domain == new_domain)
> return 0;
>
> ...
>
> There was an attempt [1] to fix error unwind in iommu_attach_group(), by
> temporarily set group->domain to NULL before calling set_domain().
>
> Jason, I wonder why this recovering cannot be done in
> __iommu_group_set_domain() directly, e.g.:
>
> ret = __iommu_group_for_each_dev(group, new_domain,
> iommu_group_do_attach_device);
> if (ret) {
> __iommu_group_for_each_dev(group, group->domain,
> iommu_group_do_attach_device);
> return ret;
> }
> group->domain = new_domain;

We talked about this already, some times this is not the correct
recovery case, eg if we are going to a blocking domain we need to drop
all references to the prior domain, not put them back.

Failures are WARN_ON events not error recovery.

Jason

\
 
 \ /
  Last update: 2023-03-27 00:24    [W:0.206 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site