Re: [RFC 6/7] iommu/vt-d: convert the intel iommu driver to the dma-iommu ops api

From
Lu Baolu <baolu.lu@linux.intel.com>
Date
2019-05-06 01:41:31
Also in
kvm, linux-arm-msm, linux-iommu, linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc, linux-tegra, lkml
Reply to
Tom Murphy, 2019-05-05
Hi,

On 5/6/19 1:03 AM, Tom Murphy wrote:
On Sun, May 5, 2019 at 3:44 AM Lu Baolu[off-list ref]  wrote:
quoted
Hi,

On 5/4/19 9:23 PM, Tom Murphy wrote:
quoted
static int intel_iommu_add_device(struct device *dev)
   {
+     struct dmar_domain *dmar_domain;
+     struct iommu_domain *domain;
       struct intel_iommu *iommu;
       struct iommu_group *group;
-     struct iommu_domain *domain;
+     dma_addr_t base;
       u8 bus, devfn;

       iommu = device_to_iommu(dev, &bus, &devfn);
@@ -4871,9 +4514,12 @@ static int intel_iommu_add_device(struct device *dev)
       if (IS_ERR(group))
               return PTR_ERR(group);

+     base = IOVA_START_PFN << VTD_PAGE_SHIFT;
       domain = iommu_get_domain_for_dev(dev);
+     dmar_domain = to_dmar_domain(domain);
       if (domain->type == IOMMU_DOMAIN_DMA)
-             dev->dma_ops = &intel_dma_ops;
+             iommu_setup_dma_ops(dev, base,
+                             __DOMAIN_MAX_ADDR(dmar_domain->gaw) - base);
I didn't find the implementation of iommu_setup_dma_ops() in this
series. Will the iova resource be initialized in this function?
Ah sorry, I should've mentioned this is based on the
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma-iommu-ops.3
branch with the "iommu/vt-d: Delegate DMA domain to generic iommu" and
"iommu/amd: Convert the AMD iommu driver to the dma-iommu api" patch
sets applied.
quoted
If so, will this block iommu_group_create_direct_mappings() which
reserves and maps the reserved iova ranges.
The reserved regions will be reserved by the
iova_reserve_iommu_regions function instead:
(https://github.com/torvalds/linux/blob/6203838dec05352bc357625b1e9ba0a10d3bca35/drivers/iommu/dma-iommu.c#L238
)
iommu_setup_dma_ops calls iommu_dma_init_domain which calls
iova_reserve_iommu_regions.
iommu_group_create_direct_mappings will still execute normally but it
won't be able to call the intel_iommu_apply_resv_region function
because it's been removed in this patchset.
This shouldn't change any behavior and the same regions should be reserved.
Okay, I understand it now. Thanks for the explanation.

Best regards,
Lu Baolu

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (15 messages) 15 messages, 2 authors, last reply 2019-05-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help