git: b7fde5e82bd5 - stable/13 - ioat(4): Remove Giant from ioat_test enable/disable.
Alexander Motin
mav at FreeBSD.org
Mon Oct 4 01:14:28 UTC 2021
The branch stable/13 has been updated by mav:
URL: https://cgit.FreeBSD.org/src/commit/?id=b7fde5e82bd54242d4f8c1801ab6487711e7532b
commit b7fde5e82bd54242d4f8c1801ab6487711e7532b
Author: Alexander Motin <mav at FreeBSD.org>
AuthorDate: 2021-09-04 19:53:28 +0000
Commit: Alexander Motin <mav at FreeBSD.org>
CommitDate: 2021-10-04 01:14:25 +0000
ioat(4): Remove Giant from ioat_test enable/disable.
MFC after: 1 month
(cherry picked from commit 71bf3900b7827643830dfd9aa1db81bc2926eadb)
---
sys/dev/ioat/ioat.c | 25 +++++++++++++++++++++++--
sys/dev/ioat/ioat_test.c | 26 ++++++++++++--------------
2 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/sys/dev/ioat/ioat.c b/sys/dev/ioat/ioat.c
index 45a6c273822d..2badfedb7488 100644
--- a/sys/dev/ioat/ioat.c
+++ b/sys/dev/ioat/ioat.c
@@ -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);
diff --git a/sys/dev/ioat/ioat_test.c b/sys/dev/ioat/ioat_test.c
index 0bd6a3377bea..3a42ba5fb54c 100644
--- a/sys/dev/ioat/ioat_test.c
+++ b/sys/dev/ioat/ioat_test.c
@@ -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
More information about the dev-commits-src-all
mailing list