From cdb316ee878150ab9835601913f7b33b6ea1ff31 Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 25 Nov 2016 04:35:40 +0000 Subject: [PATCH] hyperv/vmbus,pcib: unbreak build in case NEW_PCIB is undefined vmbus_pcib requires NEW_PCIB, but in case that's not defined, we at least shouldn't break build. Reviewed by: sephe Approved by: sephe (mentor) MFC after: 3 days Sponsored by: Microsoft --- sys/dev/hyperv/pcib/vmbus_pcib.c | 4 ++++ sys/dev/hyperv/vmbus/vmbus.c | 21 ++++++++++++++++----- sys/dev/hyperv/vmbus/vmbus_var.h | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c index 2fb2c0259d53..0e8170848a31 100644 --- a/sys/dev/hyperv/pcib/vmbus_pcib.c +++ b/sys/dev/hyperv/pcib/vmbus_pcib.c @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD$"); +#ifdef NEW_PCIB + #include #include #include @@ -1789,3 +1791,5 @@ DEFINE_CLASS_0(pcib, vmbus_pcib_driver, vmbus_pcib_methods, DRIVER_MODULE(vmbus_pcib, vmbus, vmbus_pcib_driver, pcib_devclass, 0, 0); MODULE_DEPEND(vmbus_pcib, vmbus, 1, 1, 1); MODULE_DEPEND(vmbus_pcib, pci, 1, 1, 1); + +#endif /* NEW_PCIB */ diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index 4695d9572574..a6315025cb43 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -1020,16 +1020,21 @@ static struct resource * vmbus_alloc_resource(device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) { - struct vmbus_softc *sc = device_get_softc(dev); device_t parent = device_get_parent(dev); struct resource *res; - if (type != SYS_RES_MEMORY) - res = BUS_ALLOC_RESOURCE(parent, child, type, rid, start, - end, count, flags); - else +#ifdef NEW_PCIB + if (type == SYS_RES_MEMORY) { + struct vmbus_softc *sc = device_get_softc(dev); + res = pcib_host_res_alloc(&sc->vmbus_mmio_res, child, type, rid, start, end, count, flags); + } else +#endif + { + res = BUS_ALLOC_RESOURCE(parent, child, type, rid, start, + end, count, flags); + } return (res); } @@ -1100,6 +1105,7 @@ vmbus_get_vcpu_id_method(device_t bus, device_t dev, int cpu) return (VMBUS_PCPU_GET(sc, vcpuid, cpu)); } +#ifdef NEW_PCIB #define VTPM_BASE_ADDR 0xfed40000 #define FOUR_GB (1ULL << 32) @@ -1231,6 +1237,7 @@ vmbus_free_mmio_res(device_t dev) pcib_host_res_free(dev, &sc->vmbus_mmio_res); } +#endif /* NEW_PCIB */ static int vmbus_probe(device_t dev) @@ -1269,7 +1276,9 @@ vmbus_doattach(struct vmbus_softc *sc) if (sc->vmbus_flags & VMBUS_FLAG_ATTACHED) return (0); +#ifdef NEW_PCIB vmbus_get_mmio_res(sc->vmbus_dev); +#endif sc->vmbus_flags |= VMBUS_FLAG_ATTACHED; @@ -1417,7 +1426,9 @@ vmbus_detach(device_t dev) mtx_destroy(&sc->vmbus_prichan_lock); mtx_destroy(&sc->vmbus_chan_lock); +#ifdef NEW_PCIB vmbus_free_mmio_res(dev); +#endif return (0); } diff --git a/sys/dev/hyperv/vmbus/vmbus_var.h b/sys/dev/hyperv/vmbus/vmbus_var.h index 7aa035f94d85..a5f4db554c93 100644 --- a/sys/dev/hyperv/vmbus/vmbus_var.h +++ b/sys/dev/hyperv/vmbus/vmbus_var.h @@ -128,8 +128,10 @@ struct vmbus_softc { struct mtx vmbus_chan_lock; TAILQ_HEAD(, vmbus_channel) vmbus_chans; +#ifdef NEW_PCIB /* The list of usable MMIO ranges for PCIe pass-through */ struct pcib_host_resources vmbus_mmio_res; +#endif }; #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */