On Sat, Dec 21, 2019 at 03:03:53PM +0000, Tom Murphy wrote:
> In the intel iommu driver devices which only support 32bit DMA can't be
> direct mapped. The implementation of this is weird. Currently we assign
> it a direct mapped domain and then remove the domain later and replace
> it with a domain of type IOMMU_DOMAIN_IDENTITY. We should just assign it
> a domain of type IOMMU_DOMAIN_IDENTITY from the begging rather than
> needlessly swapping domains.
> 
> Signed-off-by: Tom Murphy <murph...@tcd.ie>
> ---
>  drivers/iommu/intel-iommu.c | 88 +++++++++++++------------------------
>  1 file changed, 31 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 0c8d81f56a30..c1ea66467918 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -5640,7 +5609,12 @@ static int intel_iommu_add_device(struct device *dev)
>       domain = iommu_get_domain_for_dev(dev);
>       dmar_domain = to_dmar_domain(domain);
>       if (domain->type == IOMMU_DOMAIN_DMA) {
> -             if (device_def_domain_type(dev) == IOMMU_DOMAIN_IDENTITY) {
> +             /*
> +              * We check dma_mask >= dma_get_required_mask(dev) because
> +              * 32 bit DMA falls back to non-identity mapping.
> +              */
> +             if (device_def_domain_type(dev) == IOMMU_DOMAIN_IDENTITY &&
> +                             dma_mask >= dma_get_required_mask(dev)) {
>                       ret = iommu_request_dm_for_dev(dev);
>                       if (ret) {
>                               dmar_remove_one_dev_info(dev);
> -- 
> 2.20.1
> 

Should this be dma_direct_get_required_mask? dma_get_required_mask may
return DMA_BIT_MASK(32) -- it callbacks into intel_get_required_mask,
but I'm not sure what iommu_no_mapping(dev) will do at this point?
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to