From: Christoph Hellwig <hch@infradead.org> To: Lu Baolu <baolu.lu@linux.intel.com> Cc: David Woodhouse <dwmw2@infradead.org>, Joerg Roedel <joro@8bytes.org>, kevin.tian@intel.com, ashok.raj@intel.com, dima@arista.com, tmurphy@arista.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, jacob.jun.pan@intel.com Subject: Re: [PATCH v3 5/8] iommu/vt-d: Implement def_domain_type iommu ops entry Date: Mon, 29 Apr 2019 13:03:38 -0700 [thread overview] Message-ID: <20190429200338.GA8412@infradead.org> (raw) In-Reply-To: <20190429020925.18136-6-baolu.lu@linux.intel.com> > @@ -3631,35 +3607,30 @@ static int iommu_no_mapping(struct device *dev) > if (iommu_dummy(dev)) > return 1; > > - if (!iommu_identity_mapping) > - return 0; > - FYI, iommu_no_mapping has been refactored in for-next: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git/commit/?h=x86/vt-d&id=48b2c937ea37a3bece0094b46450ed5267525289 > found = identity_mapping(dev); > if (found) { > + /* > + * If the device's dma_mask is less than the system's memory > + * size then this is not a candidate for identity mapping. > + */ > + u64 dma_mask = *dev->dma_mask; > + > + if (dev->coherent_dma_mask && > + dev->coherent_dma_mask < dma_mask) > + dma_mask = dev->coherent_dma_mask; > + > + if (dma_mask < dma_get_required_mask(dev)) { I know this is mostly existing code moved around, but it really needs some fixing. For one dma_get_required_mask is supposed to return the required to not bounce mask for the given device. E.g. for a device behind an iommu it should always just return 32-bit. If you really want to check vs system memory please call dma_direct_get_required_mask without the dma_ops indirection. Second I don't even think we need to check the coherent_dma_mask, dma_direct is pretty good at always finding memory even without an iommu. Third this doesn't take take the bus_dma_mask into account. This probably should just be: if (min(*dev->dma_mask, dev->bus_dma_mask) < dma_direct_get_required_mask(dev)) {
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@infradead.org> To: Lu Baolu <baolu.lu@linux.intel.com> Cc: kevin.tian@intel.com, ashok.raj@intel.com, dima@arista.com, tmurphy@arista.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, jacob.jun.pan@intel.com, David Woodhouse <dwmw2@infradead.org> Subject: Re: [PATCH v3 5/8] iommu/vt-d: Implement def_domain_type iommu ops entry Date: Mon, 29 Apr 2019 13:03:38 -0700 [thread overview] Message-ID: <20190429200338.GA8412@infradead.org> (raw) Message-ID: <20190429200338.mxaBN8YdIdfAhrvlM2nq5SUqI2W6-qf5ip6xE9zChPk@z> (raw) In-Reply-To: <20190429020925.18136-6-baolu.lu@linux.intel.com> > @@ -3631,35 +3607,30 @@ static int iommu_no_mapping(struct device *dev) > if (iommu_dummy(dev)) > return 1; > > - if (!iommu_identity_mapping) > - return 0; > - FYI, iommu_no_mapping has been refactored in for-next: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git/commit/?h=x86/vt-d&id=48b2c937ea37a3bece0094b46450ed5267525289 > found = identity_mapping(dev); > if (found) { > + /* > + * If the device's dma_mask is less than the system's memory > + * size then this is not a candidate for identity mapping. > + */ > + u64 dma_mask = *dev->dma_mask; > + > + if (dev->coherent_dma_mask && > + dev->coherent_dma_mask < dma_mask) > + dma_mask = dev->coherent_dma_mask; > + > + if (dma_mask < dma_get_required_mask(dev)) { I know this is mostly existing code moved around, but it really needs some fixing. For one dma_get_required_mask is supposed to return the required to not bounce mask for the given device. E.g. for a device behind an iommu it should always just return 32-bit. If you really want to check vs system memory please call dma_direct_get_required_mask without the dma_ops indirection. Second I don't even think we need to check the coherent_dma_mask, dma_direct is pretty good at always finding memory even without an iommu. Third this doesn't take take the bus_dma_mask into account. This probably should just be: if (min(*dev->dma_mask, dev->bus_dma_mask) < dma_direct_get_required_mask(dev)) { _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2019-04-29 20:03 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-29 2:09 [PATCH v3 0/8] iommu/vt-d: Delegate DMA domain to generic iommu Lu Baolu 2019-04-29 2:09 ` Lu Baolu 2019-04-29 2:09 ` [PATCH v3 1/8] iommu: Add ops entry for supported default domain type Lu Baolu 2019-04-29 2:09 ` Lu Baolu 2019-05-06 15:32 ` Tom Murphy via iommu 2019-05-07 10:28 ` Robin Murphy 2019-05-09 2:30 ` Lu Baolu 2019-05-09 16:11 ` Robin Murphy 2019-05-10 5:29 ` Lu Baolu 2019-05-09 2:22 ` Lu Baolu 2019-04-29 2:09 ` [PATCH v3 2/8] iommu/vt-d: Implement apply_resv_region iommu ops entry Lu Baolu 2019-04-29 2:09 ` Lu Baolu 2019-04-29 2:09 ` [PATCH v3 3/8] iommu/vt-d: Expose ISA direct mapping region via iommu_get_resv_regions Lu Baolu 2019-04-29 2:09 ` Lu Baolu 2019-04-29 2:09 ` [PATCH v3 4/8] iommu/vt-d: Enable DMA remapping after rmrr mapped Lu Baolu 2019-04-29 2:09 ` Lu Baolu 2019-04-29 2:09 ` [PATCH v3 5/8] iommu/vt-d: Implement def_domain_type iommu ops entry Lu Baolu 2019-04-29 2:09 ` Lu Baolu 2019-04-29 20:03 ` Christoph Hellwig [this message] 2019-04-29 20:03 ` Christoph Hellwig 2019-04-30 2:11 ` Lu Baolu 2019-04-30 2:11 ` Lu Baolu 2019-05-06 15:25 ` Tom Murphy via iommu 2019-05-09 4:31 ` Lu Baolu 2019-04-29 2:09 ` [PATCH v3 6/8] iommu/vt-d: Allow DMA domains to be allocated by iommu ops Lu Baolu 2019-04-29 2:09 ` Lu Baolu 2019-04-29 2:09 ` [PATCH v3 7/8] iommu/vt-d: Remove lazy allocation of domains Lu Baolu 2019-04-29 2:09 ` Lu Baolu 2019-04-29 2:09 ` [PATCH v3 8/8] iommu/vt-d: Implement is_attach_deferred iommu ops entry Lu Baolu 2019-04-29 2:09 ` Lu Baolu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190429200338.GA8412@infradead.org \ --to=hch@infradead.org \ --cc=ashok.raj@intel.com \ --cc=baolu.lu@linux.intel.com \ --cc=dima@arista.com \ --cc=dwmw2@infradead.org \ --cc=iommu@lists.linux-foundation.org \ --cc=jacob.jun.pan@intel.com \ --cc=joro@8bytes.org \ --cc=kevin.tian@intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=tmurphy@arista.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).