hyperv/vmbus: Set a mark on the revoked channel.

This will be used to fix device detach DEVMETHOD for revoked primary
channel.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8522
This commit is contained in:
Sepherosa Ziehau 2016-11-23 05:03:44 +00:00
parent 5e2be2f660
commit fb6216bd43
3 changed files with 19 additions and 3 deletions

View File

@ -172,6 +172,7 @@ int vmbus_chan_send_prplist(struct vmbus_channel *chan,
uint32_t vmbus_chan_id(const struct vmbus_channel *chan);
uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan);
bool vmbus_chan_is_primary(const struct vmbus_channel *chan);
bool vmbus_chan_is_revoked(const struct vmbus_channel *chan);
const struct hyperv_guid *
vmbus_chan_guid_inst(const struct vmbus_channel *chan);
int vmbus_chan_prplist_nelem(int br_size, int prpcnt_max,

View File

@ -1220,7 +1220,7 @@ vmbus_chan_add(struct vmbus_channel *newchan)
wakeup(prichan);
done:
/*
* Hook this channel up for later rescind.
* Hook this channel up for later revocation.
*/
mtx_lock(&sc->vmbus_chan_lock);
vmbus_chan_ins_list(sc, newchan);
@ -1368,7 +1368,7 @@ vmbus_chan_msgproc_chrescind(struct vmbus_softc *sc,
note = (const struct vmbus_chanmsg_chrescind *)msg->msg_data;
if (note->chm_chanid > VMBUS_CHAN_MAX) {
device_printf(sc->vmbus_dev, "invalid rescinded chan%u\n",
device_printf(sc->vmbus_dev, "invalid revoked chan%u\n",
note->chm_chanid);
return;
}
@ -1403,8 +1403,12 @@ vmbus_chan_msgproc_chrescind(struct vmbus_softc *sc,
mtx_unlock(&sc->vmbus_prichan_lock);
}
if (atomic_testandset_int(&chan->ch_stflags,
VMBUS_CHAN_ST_REVOKED_SHIFT))
panic("channel has already been revoked");
if (bootverbose)
vmbus_chan_printf(chan, "chan%u rescinded\n", note->chm_chanid);
vmbus_chan_printf(chan, "chan%u revoked\n", note->chm_chanid);
/* Detach the target channel. */
taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_detach_task);
@ -1695,3 +1699,12 @@ vmbus_chan_mgmt_tq(const struct vmbus_channel *chan)
return (chan->ch_mgmt_tq);
}
bool
vmbus_chan_is_revoked(const struct vmbus_channel *chan)
{
if (chan->ch_stflags & VMBUS_CHAN_ST_REVOKED)
return (true);
return (false);
}

View File

@ -159,10 +159,12 @@ struct vmbus_channel {
#define VMBUS_CHAN_ST_ONPRIL_SHIFT 1
#define VMBUS_CHAN_ST_ONSUBL_SHIFT 2
#define VMBUS_CHAN_ST_ONLIST_SHIFT 3
#define VMBUS_CHAN_ST_REVOKED_SHIFT 4 /* sticky */
#define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT)
#define VMBUS_CHAN_ST_ONPRIL (1 << VMBUS_CHAN_ST_ONPRIL_SHIFT)
#define VMBUS_CHAN_ST_ONSUBL (1 << VMBUS_CHAN_ST_ONSUBL_SHIFT)
#define VMBUS_CHAN_ST_ONLIST (1 << VMBUS_CHAN_ST_ONLIST_SHIFT)
#define VMBUS_CHAN_ST_REVOKED (1 << VMBUS_CHAN_ST_REVOKED_SHIFT)
struct vmbus_softc;
struct vmbus_message;