hyperv/vmbus: Field renaming to reflect reality
MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7111
This commit is contained in:
parent
1d5eeebc86
commit
632673c3cb
@ -326,7 +326,7 @@ typedef struct hv_vmbus_channel {
|
||||
void *hv_chan_priv3;
|
||||
|
||||
struct task ch_detach_task;
|
||||
TAILQ_ENTRY(hv_vmbus_channel) ch_link;
|
||||
TAILQ_ENTRY(hv_vmbus_channel) ch_prilink; /* primary chan link */
|
||||
uint32_t ch_subidx; /* subchan index */
|
||||
volatile uint32_t ch_stflags; /* atomic-op */
|
||||
/* VMBUS_CHAN_ST_ */
|
||||
|
@ -134,8 +134,8 @@ vmbus_chan_add(struct hv_vmbus_channel *newchan)
|
||||
newchan->ch_id, newchan->ch_subidx);
|
||||
}
|
||||
|
||||
mtx_lock(&sc->vmbus_chlist_lock);
|
||||
TAILQ_FOREACH(prichan, &sc->vmbus_chlist, ch_link) {
|
||||
mtx_lock(&sc->vmbus_prichan_lock);
|
||||
TAILQ_FOREACH(prichan, &sc->vmbus_prichans, ch_prilink) {
|
||||
if (memcmp(&prichan->ch_guid_type, &newchan->ch_guid_type,
|
||||
sizeof(struct hyperv_guid)) == 0 &&
|
||||
memcmp(&prichan->ch_guid_inst, &newchan->ch_guid_inst,
|
||||
@ -145,18 +145,19 @@ vmbus_chan_add(struct hv_vmbus_channel *newchan)
|
||||
if (VMBUS_CHAN_ISPRIMARY(newchan)) {
|
||||
if (prichan == NULL) {
|
||||
/* Install the new primary channel */
|
||||
TAILQ_INSERT_TAIL(&sc->vmbus_chlist, newchan, ch_link);
|
||||
mtx_unlock(&sc->vmbus_chlist_lock);
|
||||
TAILQ_INSERT_TAIL(&sc->vmbus_prichans, newchan,
|
||||
ch_prilink);
|
||||
mtx_unlock(&sc->vmbus_prichan_lock);
|
||||
return 0;
|
||||
} else {
|
||||
mtx_unlock(&sc->vmbus_chlist_lock);
|
||||
mtx_unlock(&sc->vmbus_prichan_lock);
|
||||
device_printf(sc->vmbus_dev, "duplicated primary "
|
||||
"chan%u\n", newchan->ch_id);
|
||||
return EINVAL;
|
||||
}
|
||||
} else { /* Sub-channel */
|
||||
if (prichan == NULL) {
|
||||
mtx_unlock(&sc->vmbus_chlist_lock);
|
||||
mtx_unlock(&sc->vmbus_prichan_lock);
|
||||
device_printf(sc->vmbus_dev, "no primary chan for "
|
||||
"chan%u\n", newchan->ch_id);
|
||||
return EINVAL;
|
||||
@ -168,7 +169,7 @@ vmbus_chan_add(struct hv_vmbus_channel *newchan)
|
||||
* XXX refcnt prichan
|
||||
*/
|
||||
}
|
||||
mtx_unlock(&sc->vmbus_chlist_lock);
|
||||
mtx_unlock(&sc->vmbus_prichan_lock);
|
||||
|
||||
/*
|
||||
* This is a sub-channel; link it with the primary channel.
|
||||
@ -406,20 +407,20 @@ vmbus_chan_destroy_all(struct vmbus_softc *sc)
|
||||
{
|
||||
struct hv_vmbus_channel *chan;
|
||||
|
||||
mtx_lock(&sc->vmbus_chlist_lock);
|
||||
while ((chan = TAILQ_FIRST(&sc->vmbus_chlist)) != NULL) {
|
||||
mtx_lock(&sc->vmbus_prichan_lock);
|
||||
while ((chan = TAILQ_FIRST(&sc->vmbus_prichans)) != NULL) {
|
||||
KASSERT(VMBUS_CHAN_ISPRIMARY(chan), ("not primary channel"));
|
||||
TAILQ_REMOVE(&sc->vmbus_chlist, chan, ch_link);
|
||||
mtx_unlock(&sc->vmbus_chlist_lock);
|
||||
TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink);
|
||||
mtx_unlock(&sc->vmbus_prichan_lock);
|
||||
|
||||
hv_vmbus_child_device_unregister(chan);
|
||||
vmbus_chan_free(chan);
|
||||
|
||||
mtx_lock(&sc->vmbus_chlist_lock);
|
||||
mtx_lock(&sc->vmbus_prichan_lock);
|
||||
}
|
||||
bzero(sc->vmbus_chmap,
|
||||
sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX);
|
||||
mtx_unlock(&sc->vmbus_chlist_lock);
|
||||
mtx_unlock(&sc->vmbus_prichan_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1104,8 +1104,8 @@ vmbus_doattach(struct vmbus_softc *sc)
|
||||
|
||||
mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF);
|
||||
sc->vmbus_gpadl = VMBUS_GPADL_START;
|
||||
mtx_init(&sc->vmbus_chlist_lock, "vmbus chlist", NULL, MTX_DEF);
|
||||
TAILQ_INIT(&sc->vmbus_chlist);
|
||||
mtx_init(&sc->vmbus_prichan_lock, "vmbus prichan", NULL, MTX_DEF);
|
||||
TAILQ_INIT(&sc->vmbus_prichans);
|
||||
sc->vmbus_chmap = malloc(
|
||||
sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF,
|
||||
M_WAITOK | M_ZERO);
|
||||
@ -1176,7 +1176,7 @@ vmbus_doattach(struct vmbus_softc *sc)
|
||||
}
|
||||
free(sc->vmbus_chmap, M_DEVBUF);
|
||||
mtx_destroy(&sc->vmbus_scan_lock);
|
||||
mtx_destroy(&sc->vmbus_chlist_lock);
|
||||
mtx_destroy(&sc->vmbus_prichan_lock);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
@ -1258,7 +1258,7 @@ vmbus_detach(device_t dev)
|
||||
|
||||
free(sc->vmbus_chmap, M_DEVBUF);
|
||||
mtx_destroy(&sc->vmbus_scan_lock);
|
||||
mtx_destroy(&sc->vmbus_chlist_lock);
|
||||
mtx_destroy(&sc->vmbus_prichan_lock);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -102,8 +102,9 @@ struct vmbus_softc {
|
||||
#define VMBUS_SCAN_CHCNT_DONE 0x80000000
|
||||
uint32_t vmbus_scan_devcnt;
|
||||
|
||||
struct mtx vmbus_chlist_lock;
|
||||
TAILQ_HEAD(, hv_vmbus_channel) vmbus_chlist;
|
||||
/* Primary channels */
|
||||
struct mtx vmbus_prichan_lock;
|
||||
TAILQ_HEAD(, hv_vmbus_channel) vmbus_prichans;
|
||||
};
|
||||
|
||||
#define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */
|
||||
|
Loading…
Reference in New Issue
Block a user