Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Sep 2017 19:45:37 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323326 - head/sys/x86/iommu
Message-ID:  <201709081945.v88JjbmQ098364@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Sep  8 19:45:37 2017
New Revision: 323326
URL: https://svnweb.freebsd.org/changeset/base/323326

Log:
  Use IOAPIC PCI rid as the interrupt TLP source id for DMAR interrupt
  remapping.
  
  VT-d specification requires use of PCI rid as source id for IOAPICs
  enumerated by PCI bus.  The values from the DMAR ACPI table should be
  only used when IOAPIC is not on PCI.
  
  Reviewed by:	jhb
  Sponsored by:	The FreeBSD Foundation
  Hardware provided by:	Intel
  MFC after:	2 weeks
  Differential revision:	https://reviews.freebsd.org/D12205

Modified:
  head/sys/x86/iommu/intel_drv.c

Modified: head/sys/x86/iommu/intel_drv.c
==============================================================================
--- head/sys/x86/iommu/intel_drv.c	Fri Sep  8 19:39:20 2017	(r323325)
+++ head/sys/x86/iommu/intel_drv.c	Fri Sep  8 19:45:37 2017	(r323326)
@@ -71,6 +71,9 @@ __FBSDID("$FreeBSD$");
 
 #ifdef DEV_APIC
 #include "pcib_if.h"
+#include <machine/intr_machdep.h>
+#include <x86/apicreg.h>
+#include <x86/apicvar.h>
 #endif
 
 #define	DMAR_FAULT_IRQ_RID	0
@@ -788,6 +791,9 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t 
 	ACPI_DMAR_DEVICE_SCOPE *devscope;
 	ACPI_DMAR_PCI_PATH *path;
 	char *ptr, *ptrend;
+#ifdef DEV_APIC
+	int error;
+#endif
 	int i;
 
 	for (i = 0; i < dmar_devcnt; i++) {
@@ -809,6 +815,17 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t 
 				continue;
 			if (devscope->EnumerationId != id)
 				continue;
+#ifdef DEV_APIC
+			if (entry_type == ACPI_DMAR_SCOPE_TYPE_IOAPIC) {
+				error = ioapic_get_rid(id, rid);
+				/*
+				 * If our IOAPIC has PCI bindings then
+				 * use the PCI device rid.
+				 */
+				if (error == 0)
+					return (unit);
+			}
+#endif
 			if (devscope->Length - sizeof(ACPI_DMAR_DEVICE_SCOPE)
 			    == 2) {
 				if (rid != NULL) {
@@ -818,12 +835,11 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t 
 					    path->Device, path->Function);
 				}
 				return (unit);
-			} else {
-				/* XXXKIB */
-				printf(
-		       "dmar_find_nonpci: id %d type %d path length != 2\n",
-				    id, entry_type);
 			}
+			printf(
+		           "dmar_find_nonpci: id %d type %d path length != 2\n",
+			    id, entry_type);
+			break;
 		}
 	}
 	return (NULL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709081945.v88JjbmQ098364>