Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Sep 2016 18:53:17 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305485 - head/sys/amd64/vmm/io
Message-ID:  <201609061853.u86IrHdU076294@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Tue Sep  6 18:53:17 2016
New Revision: 305485
URL: https://svnweb.freebsd.org/changeset/base/305485

Log:
  Leave ppt devices in the host domain when they are not attached to a VM.
  
  This allows a pass through device to be reset to a normal device driver
  on the host and reused on the host.  ppt devices are now always active in
  some I/O MMU domain when the I/O MMU is active, either the host domain
  or the domain of a VM they are attached to.
  
  Sponsored by:	Chelsio Communications
  Differential Revision:	https://reviews.freebsd.org/D7666

Modified:
  head/sys/amd64/vmm/io/iommu.c
  head/sys/amd64/vmm/io/ppt.c

Modified: head/sys/amd64/vmm/io/iommu.c
==============================================================================
--- head/sys/amd64/vmm/io/iommu.c	Tue Sep  6 17:58:58 2016	(r305484)
+++ head/sys/amd64/vmm/io/iommu.c	Tue Sep  6 18:53:17 2016	(r305485)
@@ -158,7 +158,6 @@ iommu_init(void)
 {
 	int error, bus, slot, func;
 	vm_paddr_t maxaddr;
-	const char *name;
 	device_t dev;
 
 	if (!iommu_enable)
@@ -203,12 +202,7 @@ iommu_init(void)
 				if (dev == NULL)
 					continue;
 
-				/* skip passthrough devices */
-				name = device_get_name(dev);
-				if (name != NULL && strcmp(name, "ppt") == 0)
-					continue;
-
-				/* everything else belongs to the host domain */
+				/* Everything belongs to the host domain. */
 				iommu_add_device(host_domain,
 				    pci_get_rid(dev));
 			}

Modified: head/sys/amd64/vmm/io/ppt.c
==============================================================================
--- head/sys/amd64/vmm/io/ppt.c	Tue Sep  6 17:58:58 2016	(r305484)
+++ head/sys/amd64/vmm/io/ppt.c	Tue Sep  6 18:53:17 2016	(r305485)
@@ -363,6 +363,7 @@ ppt_assign_device(struct vm *vm, int bus
 			return (EBUSY);
 
 		ppt->vm = vm;
+		iommu_remove_device(iommu_host_domain(), pci_get_rid(ppt->dev));
 		iommu_add_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev));
 		return (0);
 	}
@@ -385,6 +386,7 @@ ppt_unassign_device(struct vm *vm, int b
 		ppt_teardown_msi(ppt);
 		ppt_teardown_msix(ppt);
 		iommu_remove_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev));
+		iommu_add_device(iommu_host_domain(), pci_get_rid(ppt->dev));
 		ppt->vm = NULL;
 		return (0);
 	}



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