* [PATCH] iommu/vt-d: Don't reject NTB devices due to scope mismatch
@ 2016-06-03 0:46 Roland Dreier
2016-06-15 13:24 ` Joerg Roedel
0 siblings, 1 reply; 2+ messages in thread
From: Roland Dreier @ 2016-06-03 0:46 UTC (permalink / raw)
To: Joerg Roedel; +Cc: linux-kernel, iommu, David Woodhouse
From: Roland Dreier <roland@purestorage.com>
On a system with an Intel PCIe port configured as an NTB device, iommu
initialization fails with
DMAR: Device scope type does not match for 0000:80:03.0
This is because the DMAR table reports this device as having scope 2
(ACPI_DMAR_SCOPE_TYPE_BRIDGE):
[0A0h 0160 1] Device Scope Entry Type : 02
[0A1h 0161 1] Entry Length : 08
[0A2h 0162 2] Reserved : 0000
[0A4h 0164 1] Enumeration ID : 00
[0A5h 0165 1] PCI Bus Number : 80
[0A6h 0166 2] PCI Path : 03,00
but the device has a type 0 PCI header:
80:03.0 Bridge [0680]: Intel Corporation Device [8086:2f0d] (rev 02)
00: 86 80 0d 2f 00 00 10 00 02 00 80 06 10 00 80 00
10: 0c 00 c0 00 c0 38 00 00 0c 00 00 00 80 38 00 00
20: 00 00 00 c8 00 00 10 c8 00 00 00 00 86 80 00 00
30: 00 00 00 00 60 00 00 00 00 00 00 00 ff 01 00 00
VT-d works perfectly on this system, so there's no reason to bail out
on initialization due to this apparent scope mismatch. Use the class
0x0680 ("Other bridge device") as a heuristic for allowing DMAR
initialization for non-bridge PCI devices listed with scope bridge.
Signed-off-by: Roland Dreier <roland@purestorage.com>
---
drivers/iommu/dmar.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 6a86b5d1defa..2eff7b6c6c98 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -241,8 +241,20 @@ int dmar_insert_dev_scope(struct dmar_pci_notify_info *info,
if (!dmar_match_pci_path(info, scope->bus, path, level))
continue;
- if ((scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT) ^
- (info->dev->hdr_type == PCI_HEADER_TYPE_NORMAL)) {
+ /*
+ * We expect devices with endpoint scope to have normal PCI
+ * headers, and devices with bridge scope to have bridge PCI
+ * headers. However PCI NTB devices may be listed in the
+ * DMAR table with bridge scope, even though they have a
+ * normal PCI header. NTB devices are identified by class
+ * "BRIDGE_OTHER" (0680h) - we don't declare a socpe mismatch
+ * for this special case.
+ */
+ if ((scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT &&
+ info->dev->hdr_type != PCI_HEADER_TYPE_NORMAL) ||
+ (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE &&
+ (info->dev->hdr_type == PCI_HEADER_TYPE_NORMAL &&
+ info->dev->class >> 8 != PCI_CLASS_BRIDGE_OTHER))) {
pr_warn("Device scope type does not match for %s\n",
pci_name(info->dev));
return -EINVAL;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iommu/vt-d: Don't reject NTB devices due to scope mismatch
2016-06-03 0:46 [PATCH] iommu/vt-d: Don't reject NTB devices due to scope mismatch Roland Dreier
@ 2016-06-15 13:24 ` Joerg Roedel
0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2016-06-15 13:24 UTC (permalink / raw)
To: Roland Dreier; +Cc: linux-kernel, iommu, David Woodhouse
On Thu, Jun 02, 2016 at 05:46:10PM -0700, Roland Dreier wrote:
> From: Roland Dreier <roland@purestorage.com>
>
> On a system with an Intel PCIe port configured as an NTB device, iommu
> initialization fails with
>
> DMAR: Device scope type does not match for 0000:80:03.0
>
> This is because the DMAR table reports this device as having scope 2
> (ACPI_DMAR_SCOPE_TYPE_BRIDGE):
>
> [0A0h 0160 1] Device Scope Entry Type : 02
> [0A1h 0161 1] Entry Length : 08
> [0A2h 0162 2] Reserved : 0000
> [0A4h 0164 1] Enumeration ID : 00
> [0A5h 0165 1] PCI Bus Number : 80
>
> [0A6h 0166 2] PCI Path : 03,00
>
> but the device has a type 0 PCI header:
>
> 80:03.0 Bridge [0680]: Intel Corporation Device [8086:2f0d] (rev 02)
> 00: 86 80 0d 2f 00 00 10 00 02 00 80 06 10 00 80 00
> 10: 0c 00 c0 00 c0 38 00 00 0c 00 00 00 80 38 00 00
> 20: 00 00 00 c8 00 00 10 c8 00 00 00 00 86 80 00 00
> 30: 00 00 00 00 60 00 00 00 00 00 00 00 ff 01 00 00
>
> VT-d works perfectly on this system, so there's no reason to bail out
> on initialization due to this apparent scope mismatch. Use the class
> 0x0680 ("Other bridge device") as a heuristic for allowing DMAR
> initialization for non-bridge PCI devices listed with scope bridge.
>
> Signed-off-by: Roland Dreier <roland@purestorage.com>
> ---
> drivers/iommu/dmar.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-15 13:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-03 0:46 [PATCH] iommu/vt-d: Don't reject NTB devices due to scope mismatch Roland Dreier
2016-06-15 13:24 ` Joerg Roedel
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).