> From: Christoph Hellwig <hch@xxxxxx> > Sent: Thursday, August 26, 2021 12:19 AM > > IS_IOMMU_CAP_DOMAIN_IN_CONTAINER just obsfucated the checks being > performed, so open code it in the callers. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx> > --- > drivers/vfio/vfio_iommu_type1.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/drivers/vfio/vfio_iommu_type1.c > b/drivers/vfio/vfio_iommu_type1.c > index 871cd2867999cb..7ecf5ca01764a5 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -140,9 +140,6 @@ struct vfio_regions { > size_t len; > }; > > -#define IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu) \ > - (!list_empty(&iommu->domain_list)) > - > #define DIRTY_BITMAP_BYTES(n) (ALIGN(n, BITS_PER_TYPE(u64)) / > BITS_PER_BYTE) > > /* > @@ -880,7 +877,7 @@ static int vfio_iommu_type1_pin_pages(void > *iommu_data, > * already pinned and accounted. Accounting should be done if there > is no > * iommu capable domain in the container. > */ > - do_accounting = !IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu); > + do_accounting = list_empty(&iommu->domain_list); > > for (i = 0; i < npage; i++) { > struct vfio_pfn *vpfn; > @@ -969,7 +966,7 @@ static int vfio_iommu_type1_unpin_pages(void > *iommu_data, > > mutex_lock(&iommu->lock); > > - do_accounting = !IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu); > + do_accounting = list_empty(&iommu->domain_list); > for (i = 0; i < npage; i++) { > struct vfio_dma *dma; > dma_addr_t iova; > @@ -1090,7 +1087,7 @@ static long vfio_unmap_unpin(struct vfio_iommu > *iommu, struct vfio_dma *dma, > if (!dma->size) > return 0; > > - if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu)) > + if (list_empty(&iommu->domain_list)) > return 0; > > /* > @@ -1667,7 +1664,7 @@ static int vfio_dma_do_map(struct vfio_iommu > *iommu, > vfio_link_dma(iommu, dma); > > /* Don't pin and map if container doesn't contain IOMMU capable > domain*/ > - if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu)) > + if (list_empty(&iommu->domain_list)) > dma->size = size; > else > ret = vfio_pin_map_dma(iommu, dma, size); > @@ -2473,7 +2470,7 @@ static void vfio_iommu_type1_detach_group(void > *iommu_data, > kfree(group); > > if (list_empty(&iommu->emulated_iommu_groups) && > - !IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu)) { > + list_empty(&iommu->domain_list)) { > WARN_ON(iommu->notifier.head); > vfio_iommu_unmap_unpin_all(iommu); > } > -- > 2.30.2