mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
ioat(4): Remove Giant from ioat_test enable/disable.
MFC after: 1 month
This commit is contained in:
parent
312f5f8a4f
commit
71bf3900b7
2 changed files with 35 additions and 16 deletions
|
|
@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
|
|||
#define BUS_SPACE_MAXADDR_46BIT MIN(BUS_SPACE_MAXADDR, 0x3FFFFFFFFFFFULL)
|
||||
#endif
|
||||
|
||||
static int ioat_modevent(module_t mod, int type, void *data);
|
||||
static int ioat_probe(device_t device);
|
||||
static int ioat_attach(device_t device);
|
||||
static int ioat_detach(device_t device);
|
||||
|
|
@ -147,7 +148,7 @@ static driver_t ioat_pci_driver = {
|
|||
};
|
||||
|
||||
static devclass_t ioat_devclass;
|
||||
DRIVER_MODULE(ioat, pci, ioat_pci_driver, ioat_devclass, 0, 0);
|
||||
DRIVER_MODULE(ioat, pci, ioat_pci_driver, ioat_devclass, ioat_modevent, NULL);
|
||||
MODULE_VERSION(ioat, 1);
|
||||
|
||||
/*
|
||||
|
|
@ -248,6 +249,27 @@ MODULE_PNP_INFO("W32:vendor/device;D:#", pci, ioat, pci_ids,
|
|||
/*
|
||||
* OS <-> Driver linkage functions
|
||||
*/
|
||||
static int
|
||||
ioat_modevent(module_t mod __unused, int type, void *data __unused)
|
||||
{
|
||||
switch(type) {
|
||||
case MOD_LOAD:
|
||||
break;
|
||||
|
||||
case MOD_UNLOAD:
|
||||
ioat_test_detach();
|
||||
break;
|
||||
|
||||
case MOD_SHUTDOWN:
|
||||
break;
|
||||
|
||||
default:
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ioat_probe(device_t device)
|
||||
{
|
||||
|
|
@ -362,7 +384,6 @@ ioat_detach(device_t device)
|
|||
ioat_channel_index--;
|
||||
mtx_unlock(&ioat_list_mtx);
|
||||
|
||||
ioat_test_detach();
|
||||
taskqueue_drain(taskqueue_thread, &ioat->reset_task);
|
||||
|
||||
mtx_lock(&ioat->submit_lock);
|
||||
|
|
|
|||
|
|
@ -550,17 +550,21 @@ static struct cdevsw ioat_cdevsw = {
|
|||
static int
|
||||
enable_ioat_test(bool enable)
|
||||
{
|
||||
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
struct make_dev_args devargs;
|
||||
int error = 0;
|
||||
|
||||
if (enable && g_ioat_cdev == NULL) {
|
||||
g_ioat_cdev = make_dev(&ioat_cdevsw, 0, UID_ROOT, GID_WHEEL,
|
||||
0600, "ioat_test");
|
||||
make_dev_args_init(&devargs);
|
||||
devargs.mda_devsw = &ioat_cdevsw;
|
||||
devargs.mda_uid = UID_ROOT;
|
||||
devargs.mda_gid = GID_WHEEL;
|
||||
devargs.mda_mode = 0600;
|
||||
error = make_dev_s(&devargs, &g_ioat_cdev, "ioat_test");
|
||||
} else if (!enable && g_ioat_cdev != NULL) {
|
||||
destroy_dev(g_ioat_cdev);
|
||||
g_ioat_cdev = NULL;
|
||||
}
|
||||
return (0);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -573,11 +577,10 @@ sysctl_enable_ioat_test(SYSCTL_HANDLER_ARGS)
|
|||
if (error != 0 || req->newptr == NULL)
|
||||
return (error);
|
||||
|
||||
enable_ioat_test(enabled);
|
||||
return (0);
|
||||
return (enable_ioat_test(enabled));
|
||||
}
|
||||
SYSCTL_PROC(_hw_ioat, OID_AUTO, enable_ioat_test,
|
||||
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, 0, 0,
|
||||
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0,
|
||||
sysctl_enable_ioat_test, "I",
|
||||
"Non-zero: Enable the /dev/ioat_test device");
|
||||
|
||||
|
|
@ -587,11 +590,8 @@ ioat_test_attach(void)
|
|||
char *val;
|
||||
|
||||
val = kern_getenv("hw.ioat.enable_ioat_test");
|
||||
if (val != NULL && strcmp(val, "0") != 0) {
|
||||
mtx_lock(&Giant);
|
||||
if (val != NULL && strcmp(val, "0") != 0)
|
||||
enable_ioat_test(true);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
freeenv(val);
|
||||
}
|
||||
|
||||
|
|
@ -599,9 +599,7 @@ void
|
|||
ioat_test_detach(void)
|
||||
{
|
||||
|
||||
mtx_lock(&Giant);
|
||||
enable_ioat_test(false);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Reference in a new issue