All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, aacraid@adaptec.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: quirks: DMA alias quirk for Adaptec 3405
Date: Fri, 23 Jan 2015 15:30:41 -0700	[thread overview]
Message-ID: <1422052241.4048.14.camel@redhat.com> (raw)
In-Reply-To: <20150123215058.GM29776@google.com>

On Fri, 2015-01-23 at 15:50 -0600, Bjorn Helgaas wrote:
> On Tue, Jan 13, 2015 at 11:26:50AM -0700, Alex Williamson wrote:
> > As noted in the added comment, this device is actually an Intel 80333
> > I/O processor where the exposed device at 0e.0 is actually the address
> > translation unit of the I/O processor and a hidden, private device at
> > 01.0 masters the DMA for the device.  In order to enable the IOMMU, we
> > therefore need to create a fixed alias between the exposed and hidden
> > devfn.
> > 
> > Scenarios like this are potentially likely for any device incorporating
> > this I/O processor, so this little bit of abstraction with the fixed
> > alias table should make future additions trivial.
> 
> This sounds like the result of some serious debugging :)  Do you have a
> pointer to a bugzilla or some email discussion?  I'd like to make the fix
> discoverable starting with a failure symptom.

Sorry, this one comes from a private bugzilla.  The symptom is simply a
slew of IOMMU faults when trying to boot the system with the IOMMU
enabled.  For example, with the Adaptec 3405 showing up at 02:0e.0 on an
Intel system, the log is filled with:

dmar: DRHD: handling fault status reg 3
dmar: DMAR:[DMA Write] Request device [02:01.0] fault addr ffbff000 
DMAR:[fault reason 02] Present bit in context entry is clear
dmar: DRHD: handling fault status reg 3
dmar: DMAR:[DMA Write] Request device [02:01.0] fault addr ffbfe000 
DMAR:[fault reason 02] Present bit in context entry is clear

As expected, the device is non-functional.  In the log I have there are
only DMA write faults and the addresses are all ffbxxxxx, which falls
into a reserved memory area on the system and owned by a PNP0c02 device
according to iomem.  With the change here the device, of course, works
without any issues with VT-d enabled.  Thanks,

Alex

> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > Cc: Adaptec OEM Raid Solutions <aacraid@adaptec.com>
> > ---
> > 
> >  drivers/pci/quirks.c |   37 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 37 insertions(+)
> > 
> > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> > index ed6f89b..19bdb17 100644
> > --- a/drivers/pci/quirks.c
> > +++ b/drivers/pci/quirks.c
> > @@ -3528,6 +3528,43 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON,
> >  			 quirk_dma_func1_alias);
> >  
> >  /*
> > + * Some devices DMA with the wrong devfn, not just the wrong function.
> > + * quirk_fixed_dma_alias() uses this table to create fixed aliass, where
> > + * the alias is "fixed" and independent of the device devfn.
> > + *
> > + * For example, the Adaptec 3405 is a PCIe card making use of an Intel 80333
> > + * I/O processor.  To software, this appears as a straightforward PCIe-to-PCI/X
> > + * bridge with a single device on the subordinate bus.  In reality, the exposed
> > + * device at 0e.0 is the Address Translation Unit (ATU) of the controller that
> > + * provides a bridge to the internal bus of the I/O processor.  The controller
> > + * supports private devices, which can be hidden from PCI config space.  In the
> > + * case of the Adaptec 3405, a private device at 01.0 appears to be the DMA
> > + * engine, which therefore needs to become a DMA alias for the device.
> > + */
> > +static const struct pci_device_id fixed_dma_alias_tbl[] = {
> > +	{ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x0285,
> > +			 PCI_VENDOR_ID_ADAPTEC2, 0x02bb), /* Adaptec 3405 */
> > +	  .driver_data = PCI_DEVFN(1, 0) },
> > +	{ 0 }
> > +};
> > +
> > +static void quirk_fixed_dma_alias(struct pci_dev *dev)
> > +{
> > +	const struct pci_device_id *id;
> > +
> > +	id = pci_match_id(fixed_dma_alias_tbl, dev);
> > +	if (id) {
> > +		dev->dma_alias_devfn = id->driver_data;
> > +		dev->dev_flags |= PCI_DEV_FLAGS_DMA_ALIAS_DEVFN;
> > +		dev_info(&dev->dev, "Enabling fixed DMA alias to %02x.%d\n",
> > +			 PCI_SLOT(dev->dma_alias_devfn),
> > +			 PCI_FUNC(dev->dma_alias_devfn));
> > +	}
> > +}
> > +
> > +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ADAPTEC2, 0x0285, quirk_fixed_dma_alias);
> > +
> > +/*
> >   * A few PCIe-to-PCI bridges fail to expose a PCIe capability, resulting in
> >   * using the wrong DMA alias for the device.  Some of these devices can be
> >   * used as either forward or reverse bridges, so we need to test whether the
> > 
> --
> 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




  reply	other threads:[~2015-01-23 22:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 18:26 [PATCH] PCI: quirks: DMA alias quirk for Adaptec 3405 Alex Williamson
2015-01-23 21:50 ` Bjorn Helgaas
2015-01-23 22:30   ` Alex Williamson [this message]
2015-01-23 22:53     ` Bjorn Helgaas
2015-01-23 22:46 ` Bjorn Helgaas

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=1422052241.4048.14.camel@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=aacraid@adaptec.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.