Re: [PATCH v4 4/7] iommu/vt-d: Use pci_real_dma_dev() for mapping
Good catch. Thanks Baolu. Will do v5 fixing this and Christoph's nit On Tue, 2020-01-21 at 09:06 +0800, Lu Baolu wrote: > Hi, > > On 1/18/20 12:27 AM, Jon Derrick wrote: > > The PCI device may have a DMA requester on another bus, such as VMD > > subdevices needing to use the VMD endpoint. This case requires the real > > DMA device when mapping to IOMMU. > > > > Signed-off-by: Jon Derrick > > --- > > drivers/iommu/intel-iommu.c | 9 + > > 1 file changed, 9 insertions(+) > > > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > > index 0c8d81f..01a1b0f 100644 > > --- a/drivers/iommu/intel-iommu.c > > +++ b/drivers/iommu/intel-iommu.c > > @@ -782,6 +782,8 @@ static struct intel_iommu *device_to_iommu(struct > > device *dev, u8 *bus, u8 *devf > > return NULL; > > #endif > > > > + pdev = pci_real_dma_dev(dev); > > This isn't correct. It will result in a compiling error when bisect. > > Best regards, > baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v4 4/7] iommu/vt-d: Use pci_real_dma_dev() for mapping
Hi, On 1/18/20 12:27 AM, Jon Derrick wrote: The PCI device may have a DMA requester on another bus, such as VMD subdevices needing to use the VMD endpoint. This case requires the real DMA device when mapping to IOMMU. Signed-off-by: Jon Derrick --- drivers/iommu/intel-iommu.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 0c8d81f..01a1b0f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -782,6 +782,8 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf return NULL; #endif + pdev = pci_real_dma_dev(dev); This isn't correct. It will result in a compiling error when bisect. Best regards, baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v4 4/7] iommu/vt-d: Use pci_real_dma_dev() for mapping
On Fri, Jan 17, 2020 at 09:27:26AM -0700, Jon Derrick wrote: > + if (dev_is_pci(dev)) { > + struct pci_dev *pdev; > + > + pdev = pci_real_dma_dev(to_pci_dev(dev)); > + dev = >dev; I think this could be simplified to if (dev_is_pci(dev)) dev = _real_dma_dev(to_pci_dev(dev)->dev; ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v4 4/7] iommu/vt-d: Use pci_real_dma_dev() for mapping
The PCI device may have a DMA requester on another bus, such as VMD subdevices needing to use the VMD endpoint. This case requires the real DMA device when mapping to IOMMU. Signed-off-by: Jon Derrick --- drivers/iommu/intel-iommu.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 0c8d81f..01a1b0f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -782,6 +782,8 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf return NULL; #endif + pdev = pci_real_dma_dev(dev); + /* VFs aren't listed in scope tables; we need to look up * the PF instead to find the IOMMU. */ pf_pdev = pci_physfn(pdev); @@ -2428,6 +2430,13 @@ static struct dmar_domain *find_domain(struct device *dev) dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)) return NULL; + if (dev_is_pci(dev)) { + struct pci_dev *pdev; + + pdev = pci_real_dma_dev(to_pci_dev(dev)); + dev = >dev; + } + /* No lock here, assumes no domain exit in normal case */ info = dev->archdata.iommu; if (likely(info)) -- 1.8.3.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu