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
This commit is contained in:
Dexuan Cui 2016-11-25 04:35:40 +00:00
parent 28a116bab4
commit cdb316ee87
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=309127
3 changed files with 22 additions and 5 deletions

View File

@ -27,6 +27,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef NEW_PCIB
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/types.h>
@ -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 */

View File

@ -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);
}

View File

@ -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 */