On Wed, May 03, 2023 at 04:54:28PM +0100, Robin Murphy wrote: > > On 2023-05-01 19:03, Jason Gunthorpe wrote: > > This brings back the ops->detach_dev() code that commit > > 1b932ceddd19 ("iommu: Remove detach_dev callbacks") deleted and turns it > > into an IDENTITY domain. > > > > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > > --- > > drivers/iommu/sun50i-iommu.c | 21 +++++++++++++++++++++ > > 1 file changed, 21 insertions(+) > > > > diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c > > index 74c5cb93e90027..15fd62d360778f 100644 > > --- a/drivers/iommu/sun50i-iommu.c > > +++ b/drivers/iommu/sun50i-iommu.c > > @@ -772,6 +772,26 @@ static void sun50i_iommu_detach_device(struct iommu_domain *domain, > > sun50i_iommu_detach_domain(iommu, sun50i_domain); > > } > > +static int sun50i_iommu_identity_attach(struct iommu_domain *identity_domain, > > + struct device *dev) > > +{ > > + struct sun50i_iommu *iommu = dev_iommu_priv_get(dev); > > + > > + if (iommu->domain == identity_domain || !iommu->domain) > > I don't think that first condition could ever be true. Oh yes, this needs more work.. I folded sun50i_iommu_detach_device() into sun50i_iommu_identity_attach() and made iommu->domain be set to identity immediately after allocation. Now it can't be NULL Thanks Jason