diff mbox

[v2,2/2] pci: Add DMA alias quirk for mic_x200_dma

Message ID 1453804310-12946-2-git-send-email-jacek.lawrynowicz@intel.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Jacek Lawrynowicz Jan. 26, 2016, 10:31 a.m. UTC
MIC x200 NTB forwards PCIe traffic using multiple alien RID. They have to
be added as aliases to the DMA device in order to allow buffer access
when IOMMU is enabled.

Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@intel.com>
---
 drivers/pci/quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Alex Williamson Jan. 26, 2016, 4:28 p.m. UTC | #1
On Tue, 2016-01-26 at 11:31 +0100, Jacek Lawrynowicz wrote:
> MIC x200 NTB forwards PCIe traffic using multiple alien RID. They have to
> be added as aliases to the DMA device in order to allow buffer access
> when IOMMU is enabled.
> 
> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@intel.com>
> ---
>  drivers/pci/quirks.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index b094061..bc23bc8 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -3703,6 +3703,21 @@ DECLARE_PCI_FIXUP_HEADER(0x1283, 0x8892, quirk_use_pcie_bridge_dma_alias);
>  DECLARE_PCI_FIXUP_HEADER(0x8086, 0x244e, quirk_use_pcie_bridge_dma_alias);
>  
>  /*
> + * MIC x200 NTB forwards PCIe traffic using multiple alien RID. They have to
> + * be added as aliases to the DMA device in order to allow buffer access
> + * when IOMMU is enabled.
> + */
> +static void quirk_mic_x200_dma_alias(struct pci_dev *pdev)
> +{
> +	if (iommu_present(pdev->dev.bus)) {

Why do we need this test?  The alias simply goes unused without an
IOMMU, right?

> +		pci_enable_dma_alias(pdev, PCI_DEVFN(0x10, 0x0));
> +		pci_enable_dma_alias(pdev, PCI_DEVFN(0x11, 0x0));
> +		pci_enable_dma_alias(pdev, PCI_DEVFN(0x12, 0x3));
> +	}
> +}
> +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2264, quirk_mic_x200_dma_alias);
> +
> +/*
>   * Intersil/Techwell TW686[4589]-based video capture cards have an empty (zero)
>   * class code.  Fix it.
>   */

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jacek Lawrynowicz Jan. 26, 2016, 5:20 p.m. UTC | #2
> -----Original Message-----

> From: linux-pci-owner@vger.kernel.org [mailto:linux-pci-

> owner@vger.kernel.org] On Behalf Of Alex Williamson

> Sent: Tuesday, January 26, 2016 5:28 PM

> To: Lawrynowicz, Jacek <jacek.lawrynowicz@intel.com>; linux-

> pci@vger.kernel.org

> Cc: bhelgaas@google.com; dwmw2@infradead.org; jroedel@suse.de

> Subject: Re: [PATCH v2 2/2] pci: Add DMA alias quirk for mic_x200_dma

> 

> On Tue, 2016-01-26 at 11:31 +0100, Jacek Lawrynowicz wrote:

> > MIC x200 NTB forwards PCIe traffic using multiple alien RID. They have

> > to be added as aliases to the DMA device in order to allow buffer

> > access when IOMMU is enabled.

> >

> > Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@intel.com>

> > ---

> >  drivers/pci/quirks.c | 15 +++++++++++++++

> >  1 file changed, 15 insertions(+)

> >

> > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index

> > b094061..bc23bc8 100644

> > --- a/drivers/pci/quirks.c

> > +++ b/drivers/pci/quirks.c

> > @@ -3703,6 +3703,21 @@ DECLARE_PCI_FIXUP_HEADER(0x1283, 0x8892,

> > quirk_use_pcie_bridge_dma_alias);

> >  DECLARE_PCI_FIXUP_HEADER(0x8086, 0x244e,

> > quirk_use_pcie_bridge_dma_alias);

> >

> >  /*

> > + * MIC x200 NTB forwards PCIe traffic using multiple alien RID. They

> > +have to

> > + * be added as aliases to the DMA device in order to allow buffer

> > +access

> > + * when IOMMU is enabled.

> > + */

> > +static void quirk_mic_x200_dma_alias(struct pci_dev *pdev) {

> > +	if (iommu_present(pdev->dev.bus)) {

> 

> Why do we need this test?  The alias simply goes unused without an IOMMU,

> right?


Right, I wanted to limit when the quirk is applied but it works without the check for iommu.
I guess that the code will be a bit simpler without this check. I will remove it.

--
Jacek Lawrynowicz
Intel Technology Poland sp. z o.o.
KRS 101882 - ul. Slowackiego 173, 80-298 Gdansk
diff mbox

Patch

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b094061..bc23bc8 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3703,6 +3703,21 @@  DECLARE_PCI_FIXUP_HEADER(0x1283, 0x8892, quirk_use_pcie_bridge_dma_alias);
 DECLARE_PCI_FIXUP_HEADER(0x8086, 0x244e, quirk_use_pcie_bridge_dma_alias);
 
 /*
+ * MIC x200 NTB forwards PCIe traffic using multiple alien RID. They have to
+ * be added as aliases to the DMA device in order to allow buffer access
+ * when IOMMU is enabled.
+ */
+static void quirk_mic_x200_dma_alias(struct pci_dev *pdev)
+{
+	if (iommu_present(pdev->dev.bus)) {
+		pci_enable_dma_alias(pdev, PCI_DEVFN(0x10, 0x0));
+		pci_enable_dma_alias(pdev, PCI_DEVFN(0x11, 0x0));
+		pci_enable_dma_alias(pdev, PCI_DEVFN(0x12, 0x3));
+	}
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2264, quirk_mic_x200_dma_alias);
+
+/*
  * Intersil/Techwell TW686[4589]-based video capture cards have an empty (zero)
  * class code.  Fix it.
  */