Date: Tue, 21 Jan 2014 18:09:24 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 1190242 for review Message-ID: <201401211809.s0LI9OjL010215@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@1190242?ac=10 Change 1190242 by jhb@jhb_jhbbsd on 2014/01/21 18:08:58 IFC @1190241 Affected files ... .. //depot/projects/pci/sys/amd64/vmm/io/iommu.c#2 integrate .. //depot/projects/pci/sys/amd64/vmm/io/ppt.c#6 integrate .. //depot/projects/pci/sys/amd64/vmm/io/ppt.h#4 integrate .. //depot/projects/pci/sys/amd64/vmm/vmm.c#9 integrate .. //depot/projects/pci/sys/boot/i386/libi386/comconsole.c#5 integrate .. //depot/projects/pci/sys/boot/pc98/libpc98/comconsole.c#5 integrate .. //depot/projects/pci/sys/dev/vt/hw/fb/vt_fb.c#3 integrate .. //depot/projects/pci/sys/kern/vfs_bio.c#14 integrate .. //depot/projects/pci/sys/vm/vm_pageout.c#12 integrate .. //depot/projects/pci/sys/x86/include/legacyvar.h#4 integrate .. //depot/projects/pci/sys/x86/pci/pci_bus.c#7 integrate .. //depot/projects/pci/sys/x86/pci/qpi.c#7 integrate .. //depot/projects/pci/sys/x86/x86/mptable_pci.c#19 integrate Differences ... ==== //depot/projects/pci/sys/amd64/vmm/io/iommu.c#2 (text+ko) ==== @@ -23,16 +23,17 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/io/iommu.c 245678 2013-01-20 03:42:49Z neel $ + * $FreeBSD: head/sys/amd64/vmm/io/iommu.c 260972 2014-01-21 03:01:34Z neel $ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/amd64/vmm/io/iommu.c 245678 2013-01-20 03:42:49Z neel $"); +__FBSDID("$FreeBSD: head/sys/amd64/vmm/io/iommu.c 260972 2014-01-21 03:01:34Z neel $"); #include <sys/param.h> #include <sys/types.h> #include <sys/systm.h> #include <sys/bus.h> +#include <sys/sysctl.h> #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> @@ -43,7 +44,13 @@ #include "vmm_mem.h" #include "iommu.h" -static boolean_t iommu_avail; +SYSCTL_DECL(_hw_vmm); +SYSCTL_NODE(_hw_vmm, OID_AUTO, iommu, CTLFLAG_RW, 0, "bhyve iommu parameters"); + +static int iommu_avail; +SYSCTL_INT(_hw_vmm_iommu, OID_AUTO, initialized, CTLFLAG_RD, &iommu_avail, + 0, "bhyve iommu initialized?"); + static struct iommu_ops *ops; static void *host_domain; @@ -160,7 +167,7 @@ if (error) return; - iommu_avail = TRUE; + iommu_avail = 1; /* * Create a domain for the devices owned by the host ==== //depot/projects/pci/sys/amd64/vmm/io/ppt.c#6 (text+ko) ==== @@ -23,11 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/io/ppt.c 259482 2013-12-16 19:59:31Z neel $ + * $FreeBSD: head/sys/amd64/vmm/io/ppt.c 260972 2014-01-21 03:01:34Z neel $ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/amd64/vmm/io/ppt.c 259482 2013-12-16 19:59:31Z neel $"); +__FBSDID("$FreeBSD: head/sys/amd64/vmm/io/ppt.c 260972 2014-01-21 03:01:34Z neel $"); #include <sys/param.h> #include <sys/systm.h> @@ -38,6 +38,7 @@ #include <sys/pciio.h> #include <sys/rman.h> #include <sys/smp.h> +#include <sys/sysctl.h> #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> @@ -100,7 +101,12 @@ } msix; } pptdevs[64]; +SYSCTL_DECL(_hw_vmm); +SYSCTL_NODE(_hw_vmm, OID_AUTO, ppt, CTLFLAG_RW, 0, "bhyve passthru devices"); + static int num_pptdevs; +SYSCTL_INT(_hw_vmm_ppt, OID_AUTO, devices, CTLFLAG_RD, &num_pptdevs, 0, + "number of pci passthru devices"); static int ppt_probe(device_t dev) @@ -282,7 +288,14 @@ } int -ppt_num_devices(struct vm *vm) +ppt_avail_devices(void) +{ + + return (num_pptdevs); +} + +int +ppt_assigned_devices(struct vm *vm) { int i, num; ==== //depot/projects/pci/sys/amd64/vmm/io/ppt.h#4 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/io/ppt.h 259482 2013-12-16 19:59:31Z neel $ + * $FreeBSD: head/sys/amd64/vmm/io/ppt.h 260972 2014-01-21 03:01:34Z neel $ */ #ifndef _IO_PPT_H_ @@ -36,10 +36,16 @@ uint64_t addr, uint64_t msg, int numvec); int ppt_setup_msix(struct vm *vm, int vcpu, int bus, int slot, int func, int idx, uint64_t addr, uint64_t msg, uint32_t vector_control); -int ppt_num_devices(struct vm *vm); +int ppt_assigned_devices(struct vm *vm); boolean_t ppt_is_mmio(struct vm *vm, vm_paddr_t gpa); /* + * Returns the number of devices sequestered by the ppt driver for assignment + * to virtual machines. + */ +int ppt_avail_devices(void); + +/* * The following functions should never be called directly. * Use 'vm_assign_pptdev()' and 'vm_unassign_pptdev()' instead. */ ==== //depot/projects/pci/sys/amd64/vmm/vmm.c#9 (text+ko) ==== @@ -23,11 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/vmm.c 260619 2014-01-14 01:55:58Z neel $ + * $FreeBSD: head/sys/amd64/vmm/vmm.c 260972 2014-01-21 03:01:34Z neel $ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm.c 260619 2014-01-14 01:55:58Z neel $"); +__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm.c 260972 2014-01-21 03:01:34Z neel $"); #include <sys/param.h> #include <sys/systm.h> @@ -266,7 +266,8 @@ switch (what) { case MOD_LOAD: vmmdev_init(); - iommu_init(); + if (ppt_avail_devices() > 0) + iommu_init(); error = vmm_init(); if (error == 0) vmm_initialized = 1; @@ -604,7 +605,7 @@ if (error) return (error); - if (ppt_num_devices(vm) == 0) { + if (ppt_assigned_devices(vm) == 0) { vm_iommu_unmap(vm); vm_gpa_unwire(vm); } @@ -624,7 +625,7 @@ * * We need to do this before the first pci passthru device is attached. */ - if (ppt_num_devices(vm) == 0) { + if (ppt_assigned_devices(vm) == 0) { KASSERT(vm->iommu == NULL, ("vm_assign_pptdev: iommu must be NULL")); maxaddr = vmm_mem_maxaddr(); ==== //depot/projects/pci/sys/boot/i386/libi386/comconsole.c#5 (text+ko) ==== @@ -24,7 +24,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/boot/i386/libi386/comconsole.c 245848 2013-01-23 18:34:21Z jhb $"); +__FBSDID("$FreeBSD: head/sys/boot/i386/libi386/comconsole.c 260949 2014-01-20 23:27:05Z mav $"); #include <stand.h> #include <bootstrap.h> @@ -181,8 +181,7 @@ return (CMD_ERROR); } - if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) != 0 && - comc_curspeed != speed) + if (comc_curspeed != speed) comc_setup(speed, comc_port); env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); @@ -200,8 +199,7 @@ return (CMD_ERROR); } - if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) != 0 && - comc_port != port) + if (comc_port != port) comc_setup(comc_curspeed, port); env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); @@ -309,6 +307,8 @@ unsetenv("hw.uart.console"); comc_curspeed = speed; comc_port = port; + if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0) + return; outb(comc_port + com_cfcr, CFCR_DLAB | COMC_FMT); outb(comc_port + com_dlbl, COMC_BPS(speed) & 0xff); ==== //depot/projects/pci/sys/boot/pc98/libpc98/comconsole.c#5 (text+ko) ==== @@ -24,7 +24,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/boot/pc98/libpc98/comconsole.c 251223 2013-06-01 12:27:48Z nyan $"); +__FBSDID("$FreeBSD: head/sys/boot/pc98/libpc98/comconsole.c 260949 2014-01-20 23:27:05Z mav $"); #include <stand.h> #include <bootstrap.h> @@ -181,8 +181,7 @@ return (CMD_ERROR); } - if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) != 0 && - comc_curspeed != speed) + if (comc_curspeed != speed) comc_setup(speed, comc_port); env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); @@ -200,8 +199,7 @@ return (CMD_ERROR); } - if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) != 0 && - comc_port != port) + if (comc_port != port) comc_setup(comc_curspeed, port); env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); @@ -309,6 +307,8 @@ unsetenv("hw.uart.console"); comc_curspeed = speed; comc_port = port; + if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0) + return; outb(comc_port + com_cfcr, CFCR_DLAB | COMC_FMT); outb(comc_port + com_dlbl, COMC_BPS(speed) & 0xff); ==== //depot/projects/pci/sys/dev/vt/hw/fb/vt_fb.c#3 (text+ko) ==== @@ -26,11 +26,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/dev/vt/hw/fb/vt_fb.c 259777 2013-12-23 18:09:10Z ray $ + * $FreeBSD: head/sys/dev/vt/hw/fb/vt_fb.c 260953 2014-01-20 23:36:16Z ray $ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/dev/vt/hw/fb/vt_fb.c 259777 2013-12-23 18:09:10Z ray $"); +__FBSDID("$FreeBSD: head/sys/dev/vt/hw/fb/vt_fb.c 260953 2014-01-20 23:36:16Z ray $"); #include <sys/param.h> #include <sys/systm.h> @@ -69,8 +69,9 @@ return (info->fb_ioctl(info->fb_cdev, cmd, data, 0, td)); } -static int vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, - vm_paddr_t *paddr, int prot, vm_memattr_t *memattr) +static int +vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, vm_paddr_t *paddr, + int prot, vm_memattr_t *memattr) { struct fb_info *info; ==== //depot/projects/pci/sys/kern/vfs_bio.c#14 (text+ko) ==== @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/kern/vfs_bio.c 259952 2013-12-27 17:04:51Z kib $"); +__FBSDID("$FreeBSD: head/sys/kern/vfs_bio.c 260974 2014-01-21 03:24:52Z jhb $"); #include <sys/param.h> #include <sys/systm.h> @@ -715,7 +715,7 @@ } /* - * Ideal allocation size for the transient bio submap if 10% + * Ideal allocation size for the transient bio submap is 10% * of the maximal space buffer map. This roughly corresponds * to the amount of the buffer mapped for typical UFS load. * ==== //depot/projects/pci/sys/vm/vm_pageout.c#12 (text+ko) ==== @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/vm/vm_pageout.c 260859 2014-01-18 20:02:59Z alc $"); +__FBSDID("$FreeBSD: head/sys/vm/vm_pageout.c 260975 2014-01-21 03:27:47Z jhb $"); #include "opt_vm.h" #include <sys/param.h> @@ -1121,7 +1121,7 @@ } else if ((m->flags & PG_WINATCFLS) == 0 && pass < 2) { /* * Dirty pages need to be paged out, but flushing - * a page is extremely expensive verses freeing + * a page is extremely expensive versus freeing * a clean page. Rather then artificially limiting * the number of pages we can flush, we instead give * dirty pages extra priority on the inactive queue @@ -1183,7 +1183,7 @@ * to be freed and dirty pages to be moved to the end * of the queue. Since dirty pages are also moved to * the end of the queue once-cleaned, this gives - * way too large a weighting to defering the freeing + * way too large a weighting to deferring the freeing * of dirty pages. * * We can't wait forever for the vnode lock, we might ==== //depot/projects/pci/sys/x86/include/legacyvar.h#4 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/x86/include/legacyvar.h 233707 2012-03-30 19:10:14Z jhb $ + * $FreeBSD: head/sys/x86/include/legacyvar.h 260973 2014-01-21 03:14:19Z jhb $ */ #ifndef _X86_LEGACYVAR_H_ @@ -61,6 +61,9 @@ struct resource *r, u_long start, u_long end); int legacy_pcib_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r); +int legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, + int maxcount, int *irqs); +int legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq); int legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data); ==== //depot/projects/pci/sys/x86/pci/pci_bus.c#7 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/x86/pci/pci_bus.c 234153 2012-04-11 21:00:33Z jhb $"); +__FBSDID("$FreeBSD: head/sys/x86/pci/pci_bus.c 260973 2014-01-21 03:14:19Z jhb $"); #include "opt_cpu.h" @@ -92,7 +92,7 @@ /* Pass MSI requests up to the nexus. */ -static int +int legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs) { @@ -103,7 +103,7 @@ irqs)); } -static int +int legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) { device_t bus; ==== //depot/projects/pci/sys/x86/pci/qpi.c#7 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/x86/pci/qpi.c 227843 2011-11-22 21:28:20Z marius $"); +__FBSDID("$FreeBSD: head/sys/x86/pci/qpi.c 260973 2014-01-21 03:14:19Z jhb $"); #include <sys/param.h> #include <sys/bus.h> @@ -253,26 +253,6 @@ #endif static int -qpi_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, - int *irqs) -{ - device_t bus; - - bus = device_get_parent(pcib); - return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, - irqs)); -} - -static int -qpi_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) -{ - device_t bus; - - bus = device_get_parent(pcib); - return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); -} - -static int qpi_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data) { @@ -309,9 +289,9 @@ DEVMETHOD(pcib_maxslots, pcib_maxslots), DEVMETHOD(pcib_read_config, legacy_pcib_read_config), DEVMETHOD(pcib_write_config, legacy_pcib_write_config), - DEVMETHOD(pcib_alloc_msi, qpi_pcib_alloc_msi), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), DEVMETHOD(pcib_release_msi, pcib_release_msi), - DEVMETHOD(pcib_alloc_msix, qpi_pcib_alloc_msix), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), DEVMETHOD(pcib_release_msix, pcib_release_msix), DEVMETHOD(pcib_map_msi, qpi_pcib_map_msi), ==== //depot/projects/pci/sys/x86/x86/mptable_pci.c#19 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/x86/x86/mptable_pci.c 233707 2012-03-30 19:10:14Z jhb $"); +__FBSDID("$FreeBSD: head/sys/x86/x86/mptable_pci.c 260973 2014-01-21 03:14:19Z jhb $"); #include <sys/param.h> #include <sys/systm.h> @@ -76,27 +76,6 @@ return (bus_generic_attach(dev)); } -/* Pass MSI requests up to the nexus. */ -static int -mptable_hostb_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, - int *irqs) -{ - device_t bus; - - bus = device_get_parent(pcib); - return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, - irqs)); -} - -static int -mptable_hostb_alloc_msix(device_t pcib, device_t dev, int *irq) -{ - device_t bus; - - bus = device_get_parent(pcib); - return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); -} - #ifdef NEW_PCIB static int mptable_is_isa_range(u_long start, u_long end) @@ -213,9 +192,9 @@ DEVMETHOD(pcib_read_config, legacy_pcib_read_config), DEVMETHOD(pcib_write_config, legacy_pcib_write_config), DEVMETHOD(pcib_route_interrupt, mptable_pci_route_interrupt), - DEVMETHOD(pcib_alloc_msi, mptable_hostb_alloc_msi), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), DEVMETHOD(pcib_release_msi, pcib_release_msi), - DEVMETHOD(pcib_alloc_msix, mptable_hostb_alloc_msix), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), DEVMETHOD(pcib_release_msix, pcib_release_msix), DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi),
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401211809.s0LI9OjL010215>