From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V9 00/11] IOMMU probe deferral support
Date: Mon, 27 Mar 2017 18:33:14 +0100 [thread overview]
Message-ID: <20170327173314.GA17035@red-moon> (raw)
In-Reply-To: <f67fb561-4238-6933-04f3-0f910f9232d1@arm.com>
On Mon, Mar 27, 2017 at 05:18:15PM +0100, Robin Murphy wrote:
[...]
> >> [ 145.212351] iommu: Adding device 0000:81:10.0 to group 5
> >> [ 145.212367] ixgbevf 0000:81:10.0: 0x0 0x100000000, 0x0 0xffffffffffff,
> >> 0xffffffff 0xffffffff
> >> [ 145.213261] ixgbevf 0000:81:10.0: enabling device (0000 -> 0002)
> >> [ 145.213394] ixgbe 0000:81:00.0 eth0: VF Reset msg received from vf 0
> >> [ 145.214272] ixgbe 0000:81:00.0: VF 0 has no MAC address assigned, you
> >> may have to assign one manually
> >> [ 145.224379] ixgbevf 0000:81:10.0: MAC address not assigned by
> >> administrator.
> >> [ 145.224384] ixgbevf 0000:81:10.0: Assigning random MAC address
> >> [ 145.225941] ixgbevf 0000:81:10.0: 1a:85:06:48:a7:19
> >> [ 145.225944] ixgbevf 0000:81:10.0: MAC: 1
> >> [ 145.225946] ixgbevf 0000:81:10.0: Intel(R) 82599 Virtual Function
> >> [ 145.299961] ixgbe 0000:81:00.0 eth0: NIC Link is Up 1 Gbps, Flow Control:
> >> None
> >> [ 154.947742] nfs: server 172.18.45.166 not responding, still trying
> >> [ 191.025780] nfs: server 172.18.45.166 not responding, still trying
> >> [ 191.026122] nfs: server 172.18.45.166 OK
> >> [ 191.026317] nfs: server 172.18.45.166 OK
> >> [ 263.706402] VFIO - User Level meta-driver version: 0.3
> >> [ 269.757613] vfio-pci 0000:81:10.0: 0x0 0x0, 0x0 0xffffffffffff, 0xffffffffffffffff
> >> 0xffffffffffffffff
> >> [ 269.757617] specified DMA range outside IOMMU capability
> >> [ 269.757618] Failed to set up IOMMU for device 0000:81:10.0; retaining
> >> platform DMA ops
> >>
> >> From the logs its clear that when ixgbevf driver originally probes and adds
> >> the device
> >> to smmu the dma mask is 32, but when it binds to vfio-pci, it becomes 64 bit.
> >
> > Just to add to that, the mask is set to 64 bit in the ixgebvf driver probe[1]
>
> Aha, but of course it's still the same struct device getting bound to
> VFIO later, so whatever mask the first driver set is still in there when
> we go through of_dma_configure() the second time (and the fact that we
> go through more than once being the new behaviour). So yes, this is a
> legitimate problem and we really do need to be robust against size
> overflow. I reckon the below tweak of your fix is probably the way to
> go; cleaning up the arch_setup_dma_ops() interface can happen later.
Yes. On ACPI the additional issue is, given that we now call
*_dma_configure multiple times, we end up adding the _same_ stream
id to an existing fwspec ids array which triggers the SMMUv3 driver bug,
because we try to configure the same id twice (it does not happen
in DT since you have a check similar to the one I added below).
ACPI fix(es) below please let me know if it actually fixes the issues:
-- >8 --
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 36a9abf..e7b1940 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -543,6 +543,14 @@ static const struct iommu_ops *iort_iommu_xlate(struct device *dev,
const struct iommu_ops *ops = NULL;
int ret = -ENODEV;
struct fwnode_handle *iort_fwnode;
+ struct iommu_fwspec *fwspec = dev->iommu_fwspec;
+
+ /*
+ * If we already translated the fwspec there
+ * is nothing left to do, return the iommu_ops.
+ */
+ if (fwspec && fwspec->ops)
+ return fwspec->ops;
if (node) {
iort_fwnode = iort_get_fwnode(node);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 823b005..2a513cc 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1376,18 +1376,20 @@ enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
int acpi_dma_configure(struct device *dev, enum dev_dma_attr attr)
{
const struct iommu_ops *iommu;
+ u64 size;
iort_set_dma_mask(dev);
iommu = iort_iommu_configure(dev);
if (IS_ERR(iommu))
return PTR_ERR(iommu);
+
+ size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1);
/*
* Assume dma valid range starts at 0 and covers the whole
* coherent_dma_mask.
*/
- arch_setup_dma_ops(dev, 0, dev->coherent_dma_mask + 1, iommu,
- attr == DEV_DMA_COHERENT);
+ arch_setup_dma_ops(dev, 0, size, iommu, attr == DEV_DMA_COHERENT);
return 0;
}
next prev parent reply other threads:[~2017-03-27 17:33 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 19:00 [PATCH V9 00/11] IOMMU probe deferral support Sricharan R
2017-03-09 19:00 ` [PATCH V9 01/11] iommu/of: Refactor of_iommu_configure() for error handling Sricharan R
2017-03-09 19:00 ` [PATCH V9 02/11] iommu/of: Prepare for deferred IOMMU configuration Sricharan R
2017-03-09 19:00 ` [PATCH V9 03/11] of: dma: Move range size workaround to of_dma_get_range() Sricharan R
2017-03-09 19:00 ` [PATCH V9 04/11] of: dma: Make of_dma_deconfigure() public Sricharan R
2017-03-09 19:00 ` [PATCH V9 05/11] ACPI/IORT: Add function to check SMMUs drivers presence Sricharan R
2017-03-09 19:00 ` [PATCH V9 06/11] of/acpi: Configure dma operations at probe time for platform/amba/pci bus devices Sricharan R
2017-03-09 19:00 ` [PATCH V9 07/11] iommu: of: Handle IOMMU lookup failure with deferred probing or error Sricharan R
2017-03-28 15:00 ` [V9, " Rob Herring
2017-03-28 15:11 ` Robin Murphy
2017-03-28 16:06 ` Sricharan R
2017-03-09 19:00 ` [PATCH V9 08/11] drivers: acpi: " Sricharan R
2017-03-09 19:00 ` [PATCH V9 09/11] arm64: dma-mapping: Remove the notifier trick to handle early setting of dma_ops Sricharan R
2017-03-09 19:01 ` [PATCH V9 10/11] iommu/arm-smmu: Clean up early-probing workarounds Sricharan R
2017-03-09 19:01 ` [PATCH V9 11/11] ACPI/IORT: Remove linker section for IORT entries probing Sricharan R
2017-03-24 3:53 ` [PATCH V9 00/11] IOMMU probe deferral support Zhou Wang
2017-03-24 7:09 ` Sricharan R
2017-03-24 9:27 ` Shameerali Kolothum Thodi
2017-03-24 12:50 ` Sricharan R
2017-03-24 14:43 ` Lorenzo Pieralisi
2017-03-24 15:09 ` Shameerali Kolothum Thodi
2017-03-24 18:38 ` Robin Murphy
2017-03-27 15:58 ` Shameerali Kolothum Thodi
2017-03-27 16:18 ` Robin Murphy
2017-03-27 17:33 ` Lorenzo Pieralisi [this message]
2017-03-28 4:53 ` Sricharan R
2017-03-28 14:15 ` Shameerali Kolothum Thodi
2017-03-28 16:07 ` Sricharan R
2017-04-04 10:18 ` [PATCH V10 00/12] " Sricharan R
2017-04-04 10:18 ` [PATCH V10 01/12] iommu/of: Refactor of_iommu_configure() for error handling Sricharan R
2017-04-04 10:18 ` [PATCH V10 02/12] iommu/of: Prepare for deferred IOMMU configuration Sricharan R
2017-04-04 10:18 ` [PATCH V10 03/12] of: dma: Move range size workaround to of_dma_get_range() Sricharan R
2017-04-04 10:46 ` Robin Murphy
2017-04-06 6:24 ` Frank Rowand
2017-04-06 9:35 ` Sricharan R
2017-04-06 10:03 ` Robin Murphy
2017-04-04 10:18 ` [PATCH V10 04/12] of: dma: Make of_dma_deconfigure() public Sricharan R
2017-04-04 10:47 ` Robin Murphy
2017-04-04 10:18 ` [PATCH V10 05/12] ACPI/IORT: Add function to check SMMUs drivers presence Sricharan R
2017-04-04 11:04 ` Robin Murphy
2017-04-04 10:18 ` [PATCH V10 06/12] of: device: Fix overflow of coherent_dma_mask Sricharan R
2017-04-04 11:10 ` Robin Murphy
2017-04-06 7:01 ` Frank Rowand
2017-04-06 10:24 ` Robin Murphy
2017-04-06 13:56 ` Rob Herring
2017-04-06 14:45 ` Robin Murphy
2017-04-06 19:24 ` Frank Rowand
2017-04-06 11:01 ` Sricharan R
2017-04-06 19:34 ` Frank Rowand
2017-04-07 4:12 ` Sricharan R
2017-04-07 14:46 ` Robin Murphy
2017-04-07 23:13 ` Frank Rowand
2017-04-10 13:25 ` Robin Murphy
2017-04-07 23:10 ` Frank Rowand
2017-04-04 10:18 ` [PATCH V10 07/12] of/acpi: Configure dma operations at probe time for platform/amba/pci bus devices Sricharan R
2017-04-04 12:17 ` Robin Murphy
2017-04-04 12:30 ` Sricharan R
2017-04-04 10:18 ` [PATCH V10 08/12] iommu: of: Handle IOMMU lookup failure with deferred probing or error Sricharan R
2017-04-04 11:24 ` Robin Murphy
2017-04-04 10:18 ` [PATCH V10 09/12] drivers: acpi: " Sricharan R
2017-04-04 11:31 ` Robin Murphy
2017-04-04 10:18 ` [PATCH V10 10/12] arm64: dma-mapping: Remove the notifier trick to handle early setting of dma_ops Sricharan R
2017-04-04 10:18 ` [PATCH V10 11/12] iommu/arm-smmu: Clean up early-probing workarounds Sricharan R
2017-04-04 10:18 ` [PATCH V10 12/12] ACPI/IORT: Remove linker section for IORT entries probing Sricharan R
2017-04-04 11:33 ` Robin Murphy
2017-04-04 12:49 ` [PATCH V10 00/12] IOMMU probe deferral support Robin Murphy
2017-04-05 10:04 ` Lorenzo Pieralisi
2017-04-05 1:23 ` Rob Herring
2017-04-06 18:46 ` Frank Rowand
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=20170327173314.GA17035@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 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).