Convert ndis_set_info() and ndis_get_info() from using msleep()
to KeSetEvent()/KeWaitForSingleObject(). Also make object argument of KeWaitForSingleObject() a void * like it's supposed to be.
This commit is contained in:
parent
06cb0fb4c0
commit
0ce580e541
@ -99,9 +99,7 @@ static image_patch_table kernndis_functbl[] = {
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
struct nd_head ndis_devhead;
|
||||
|
||||
static struct mtx ndis_req_mtx;
|
||||
static struct nd_head ndis_devhead;
|
||||
|
||||
/*
|
||||
* This allows us to export our symbols to other modules.
|
||||
@ -135,9 +133,6 @@ ndis_modevent(module_t mod, int cmd, void *arg)
|
||||
|
||||
TAILQ_INIT(&ndis_devhead);
|
||||
|
||||
mtx_init(&ndis_req_mtx, "NDIS request lock",
|
||||
MTX_NDIS_LOCK, MTX_DEF);
|
||||
|
||||
break;
|
||||
case MOD_SHUTDOWN:
|
||||
if (TAILQ_FIRST(&ndis_devhead) == NULL) {
|
||||
@ -153,7 +148,6 @@ ndis_modevent(module_t mod, int cmd, void *arg)
|
||||
windrv_unwrap(patch->ipt_wrap);
|
||||
patch++;
|
||||
}
|
||||
mtx_destroy(&ndis_req_mtx);
|
||||
}
|
||||
break;
|
||||
case MOD_UNLOAD:
|
||||
@ -170,8 +164,6 @@ ndis_modevent(module_t mod, int cmd, void *arg)
|
||||
patch++;
|
||||
}
|
||||
|
||||
mtx_destroy(&ndis_req_mtx);
|
||||
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
@ -234,7 +226,7 @@ ndis_setdone_func(adapter, status)
|
||||
block = adapter;
|
||||
|
||||
block->nmb_setstat = status;
|
||||
wakeup(&block->nmb_setstat);
|
||||
KeSetEvent(&block->nmb_setevent, IO_NO_INCREMENT, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -247,7 +239,7 @@ ndis_getdone_func(adapter, status)
|
||||
block = adapter;
|
||||
|
||||
block->nmb_getstat = status;
|
||||
wakeup(&block->nmb_getstat);
|
||||
KeSetEvent(&block->nmb_getevent, IO_NO_INCREMENT, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -267,7 +259,8 @@ ndis_resetdone_func(adapter, status, addressingreset)
|
||||
|
||||
if (ifp->if_flags & IFF_DEBUG)
|
||||
device_printf (sc->ndis_dev, "reset done...\n");
|
||||
wakeup(sc);
|
||||
KeSetEvent(&block->nmb_resetevent, IO_NO_INCREMENT, FALSE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -832,8 +825,8 @@ ndis_set_info(arg, oid, buf, buflen)
|
||||
ndis_handle adapter;
|
||||
ndis_setinfo_handler setfunc;
|
||||
uint32_t byteswritten = 0, bytesneeded = 0;
|
||||
int error;
|
||||
uint8_t irql;
|
||||
uint64_t duetime;
|
||||
|
||||
/*
|
||||
* According to the NDIS spec, MiniportQueryInformation()
|
||||
@ -846,25 +839,22 @@ ndis_set_info(arg, oid, buf, buflen)
|
||||
|
||||
KeAcquireSpinLock(&sc->ndis_block->nmb_lock, &irql);
|
||||
|
||||
if (sc->ndis_block->nmb_pendingreq != NULL)
|
||||
if (sc->ndis_block->nmb_pendingreq != NULL) {
|
||||
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
|
||||
panic("ndis_set_info() called while other request pending");
|
||||
else
|
||||
} else
|
||||
sc->ndis_block->nmb_pendingreq = (ndis_request *)sc;
|
||||
|
||||
NDIS_LOCK(sc);
|
||||
setfunc = sc->ndis_chars->nmc_setinfo_func;
|
||||
adapter = sc->ndis_block->nmb_miniportadapterctx;
|
||||
|
||||
if (adapter == NULL || setfunc == NULL ||
|
||||
sc->ndis_block->nmb_devicectx == NULL) {
|
||||
sc->ndis_block->nmb_pendingreq = NULL;
|
||||
NDIS_UNLOCK(sc);
|
||||
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
|
||||
return(ENXIO);
|
||||
}
|
||||
|
||||
NDIS_UNLOCK(sc);
|
||||
|
||||
rval = MSCALL6(setfunc, adapter, oid, buf, *buflen,
|
||||
&byteswritten, &bytesneeded);
|
||||
|
||||
@ -873,11 +863,11 @@ ndis_set_info(arg, oid, buf, buflen)
|
||||
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
|
||||
|
||||
if (rval == NDIS_STATUS_PENDING) {
|
||||
mtx_lock(&ndis_req_mtx);
|
||||
error = msleep(&sc->ndis_block->nmb_setstat,
|
||||
&ndis_req_mtx,
|
||||
curthread->td_priority|PDROP,
|
||||
"ndisset", 5 * hz);
|
||||
/* Wait up to 5 seconds. */
|
||||
duetime = (5 * 1000000) * -10;
|
||||
KeResetEvent(&sc->ndis_block->nmb_setevent);
|
||||
KeWaitForSingleObject(&sc->ndis_block->nmb_setevent,
|
||||
0, 0, FALSE, &duetime);
|
||||
rval = sc->ndis_block->nmb_setstat;
|
||||
}
|
||||
|
||||
@ -1077,9 +1067,9 @@ ndis_reset_nic(arg)
|
||||
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
|
||||
|
||||
if (rval == NDIS_STATUS_PENDING) {
|
||||
mtx_lock(&ndis_req_mtx);
|
||||
msleep(sc, &ndis_req_mtx,
|
||||
curthread->td_priority|PDROP, "ndisrst", 0);
|
||||
KeResetEvent(&sc->ndis_block->nmb_resetevent);
|
||||
KeWaitForSingleObject(&sc->ndis_block->nmb_resetevent,
|
||||
0, 0, FALSE, NULL);
|
||||
}
|
||||
|
||||
return(0);
|
||||
@ -1336,32 +1326,29 @@ ndis_get_info(arg, oid, buf, buflen)
|
||||
ndis_handle adapter;
|
||||
ndis_queryinfo_handler queryfunc;
|
||||
uint32_t byteswritten = 0, bytesneeded = 0;
|
||||
int error;
|
||||
uint8_t irql;
|
||||
uint64_t duetime;
|
||||
|
||||
sc = arg;
|
||||
|
||||
KeAcquireSpinLock(&sc->ndis_block->nmb_lock, &irql);
|
||||
|
||||
if (sc->ndis_block->nmb_pendingreq != NULL)
|
||||
if (sc->ndis_block->nmb_pendingreq != NULL) {
|
||||
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
|
||||
panic("ndis_get_info() called while other request pending");
|
||||
else
|
||||
} else
|
||||
sc->ndis_block->nmb_pendingreq = (ndis_request *)sc;
|
||||
|
||||
NDIS_LOCK(sc);
|
||||
queryfunc = sc->ndis_chars->nmc_queryinfo_func;
|
||||
adapter = sc->ndis_block->nmb_miniportadapterctx;
|
||||
|
||||
if (adapter == NULL || queryfunc == NULL ||
|
||||
sc->ndis_block->nmb_devicectx == NULL) {
|
||||
sc->ndis_block->nmb_pendingreq = NULL;
|
||||
NDIS_UNLOCK(sc);
|
||||
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
|
||||
return(ENXIO);
|
||||
}
|
||||
|
||||
NDIS_UNLOCK(sc);
|
||||
|
||||
rval = MSCALL6(queryfunc, adapter, oid, buf, *buflen,
|
||||
&byteswritten, &bytesneeded);
|
||||
|
||||
@ -1372,11 +1359,11 @@ ndis_get_info(arg, oid, buf, buflen)
|
||||
/* Wait for requests that block. */
|
||||
|
||||
if (rval == NDIS_STATUS_PENDING) {
|
||||
mtx_lock(&ndis_req_mtx);
|
||||
error = msleep(&sc->ndis_block->nmb_getstat,
|
||||
&ndis_req_mtx,
|
||||
curthread->td_priority|PDROP,
|
||||
"ndisget", 5 * hz);
|
||||
/* Wait up to 5 seconds. */
|
||||
duetime = (5 * 1000000) * -10;
|
||||
KeResetEvent(&sc->ndis_block->nmb_getevent);
|
||||
KeWaitForSingleObject(&sc->ndis_block->nmb_getevent,
|
||||
0, 0, FALSE, &duetime);
|
||||
rval = sc->ndis_block->nmb_getstat;
|
||||
}
|
||||
|
||||
@ -1426,6 +1413,9 @@ NdisAddDevice(drv, pdo)
|
||||
block->nmb_nextdeviceobj = IoAttachDeviceToDeviceStack(fdo, pdo);
|
||||
KeInitializeSpinLock(&block->nmb_lock);
|
||||
InitializeListHead(&block->nmb_parmlist);
|
||||
KeInitializeEvent(&block->nmb_getevent, EVENT_TYPE_NOTIFY, TRUE);
|
||||
KeInitializeEvent(&block->nmb_setevent, EVENT_TYPE_NOTIFY, TRUE);
|
||||
KeInitializeEvent(&block->nmb_resetevent, EVENT_TYPE_NOTIFY, TRUE);
|
||||
|
||||
/*
|
||||
* Stash pointers to the miniport block and miniport
|
||||
|
@ -1613,7 +1613,10 @@ struct ndis_miniport_block {
|
||||
list_entry nmb_parmlist;
|
||||
ndis_resource_list *nmb_rlist;
|
||||
ndis_status nmb_getstat;
|
||||
nt_kevent nmb_getevent;
|
||||
ndis_status nmb_setstat;
|
||||
nt_kevent nmb_setevent;
|
||||
nt_kevent nmb_resetevent;
|
||||
ndis_miniport_timer *nmb_timerlist;
|
||||
ndis_handle nmb_rxpool;
|
||||
TAILQ_ENTRY(ndis_miniport_block) link;
|
||||
|
@ -1326,7 +1326,7 @@ extern uint8_t KeSetTimer(ktimer *, int64_t, kdpc *);
|
||||
extern uint8_t KeSetTimerEx(ktimer *, int64_t, uint32_t, kdpc *);
|
||||
extern uint8_t KeCancelTimer(ktimer *);
|
||||
extern uint8_t KeReadStateTimer(ktimer *);
|
||||
extern uint32_t KeWaitForSingleObject(nt_dispatch_header *, uint32_t,
|
||||
extern uint32_t KeWaitForSingleObject(void *, uint32_t,
|
||||
uint32_t, uint8_t, int64_t *);
|
||||
extern void KeInitializeEvent(nt_kevent *, uint32_t, uint8_t);
|
||||
extern void KeClearEvent(nt_kevent *);
|
||||
|
@ -1609,8 +1609,8 @@ ntoskrnl_time(tval)
|
||||
*/
|
||||
|
||||
uint32_t
|
||||
KeWaitForSingleObject(obj, reason, mode, alertable, duetime)
|
||||
nt_dispatch_header *obj;
|
||||
KeWaitForSingleObject(arg, reason, mode, alertable, duetime)
|
||||
void *arg;
|
||||
uint32_t reason;
|
||||
uint32_t mode;
|
||||
uint8_t alertable;
|
||||
@ -1622,6 +1622,9 @@ KeWaitForSingleObject(obj, reason, mode, alertable, duetime)
|
||||
int error = 0;
|
||||
uint64_t curtime;
|
||||
wb_ext we;
|
||||
nt_dispatch_header *obj;
|
||||
|
||||
obj = arg;
|
||||
|
||||
if (obj == NULL)
|
||||
return(STATUS_INVALID_PARAMETER);
|
||||
@ -2587,8 +2590,7 @@ ntoskrnl_workitem_thread(arg)
|
||||
KeInitializeEvent(&kq->kq_dead, EVENT_TYPE_SYNC, FALSE);
|
||||
|
||||
while (1) {
|
||||
KeWaitForSingleObject((nt_dispatch_header *)&kq->kq_proc,
|
||||
0, 0, TRUE, NULL);
|
||||
KeWaitForSingleObject(&kq->kq_proc, 0, 0, TRUE, NULL);
|
||||
|
||||
mtx_lock_spin(&kq->kq_lock);
|
||||
|
||||
@ -2632,8 +2634,7 @@ ntoskrnl_destroy_workitem_threads(void)
|
||||
kq = wq_queues + i;
|
||||
kq->kq_exit = 1;
|
||||
KeSetEvent(&kq->kq_proc, IO_NO_INCREMENT, FALSE);
|
||||
KeWaitForSingleObject((nt_dispatch_header *)&kq->kq_dead,
|
||||
0, 0, TRUE, NULL);
|
||||
KeWaitForSingleObject(&kq->kq_dead, 0, 0, TRUE, NULL);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -3490,8 +3491,7 @@ ntoskrnl_dpc_thread(arg)
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
while (1) {
|
||||
KeWaitForSingleObject((nt_dispatch_header *)&kq->kq_proc,
|
||||
0, 0, TRUE, NULL);
|
||||
KeWaitForSingleObject(&kq->kq_proc, 0, 0, TRUE, NULL);
|
||||
|
||||
mtx_lock_spin(&kq->kq_lock);
|
||||
|
||||
@ -3567,8 +3567,7 @@ ntoskrnl_destroy_dpc_threads(void)
|
||||
KeInitializeDpc(&dpc, NULL, NULL);
|
||||
KeSetTargetProcessorDpc(&dpc, i);
|
||||
KeInsertQueueDpc(&dpc, NULL, NULL);
|
||||
KeWaitForSingleObject((nt_dispatch_header *)&kq->kq_dead,
|
||||
0, 0, TRUE, NULL);
|
||||
KeWaitForSingleObject(&kq->kq_dead, 0, 0, TRUE, NULL);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -3735,8 +3734,7 @@ KeFlushQueuedDpcs(void)
|
||||
for (i = 0; i < mp_ncpus; i++) {
|
||||
kq = kq_queues + i;
|
||||
KeSetEvent(&kq->kq_proc, IO_NO_INCREMENT, FALSE);
|
||||
KeWaitForSingleObject((nt_dispatch_header *)&kq->kq_done,
|
||||
0, 0, TRUE, NULL);
|
||||
KeWaitForSingleObject(&kq->kq_done, 0, 0, TRUE, NULL);
|
||||
}
|
||||
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user