diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2015-10-22 16:46:21 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2015-10-22 16:46:21 +0000 |
commit | 7afbb2638e18a1b80c15f8f8c88d80b5bfee26c7 (patch) | |
tree | 297b0fd243af558ee50c438f1e290adc3bdadf3f /sys/dev/ioat/ioat_test.c | |
parent | 0820c78e9343773b3ba52f9d2fb55212764e41e5 (diff) | |
download | src-7afbb2638e18a1b80c15f8f8c88d80b5bfee26c7.tar.gz src-7afbb2638e18a1b80c15f8f8c88d80b5bfee26c7.zip |
ioat: Fix some attach/detach issues
Don't run the selftest until after we've enabled bus mastering, or the
DMA engine can't copy anything for our test.
Create the ioat_test device on attach, if so tuned. Destroy the
ioat_test device on teardown.
Replace deprecated 'CALLOUT_MPSAFE' with correct '1' in callout_init().
Sponsored by: EMC / Isilon Storage Division
Notes
Notes:
svn path=/head/; revision=289760
Diffstat (limited to 'sys/dev/ioat/ioat_test.c')
-rw-r--r-- | sys/dev/ioat/ioat_test.c | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/sys/dev/ioat/ioat_test.c b/sys/dev/ioat/ioat_test.c index 8ac6a9bd4e68..6bb924dc2082 100644 --- a/sys/dev/ioat/ioat_test.c +++ b/sys/dev/ioat/ioat_test.c @@ -367,6 +367,22 @@ static struct cdevsw ioat_cdevsw = { }; static int +enable_ioat_test(bool enable) +{ + + mtx_assert(&Giant, MA_OWNED); + + if (enable && g_ioat_cdev == NULL) { + g_ioat_cdev = make_dev(&ioat_cdevsw, 0, UID_ROOT, GID_WHEEL, + 0600, "ioat_test"); + } else if (!enable && g_ioat_cdev != NULL) { + destroy_dev(g_ioat_cdev); + g_ioat_cdev = NULL; + } + return (0); +} + +static int sysctl_enable_ioat_test(SYSCTL_HANDLER_ARGS) { int error, enabled; @@ -376,15 +392,32 @@ sysctl_enable_ioat_test(SYSCTL_HANDLER_ARGS) if (error != 0 || req->newptr == NULL) return (error); - if (enabled != 0 && g_ioat_cdev == NULL) { - g_ioat_cdev = make_dev(&ioat_cdevsw, 0, UID_ROOT, GID_WHEEL, - 0600, "ioat_test"); - } else if (enabled == 0 && g_ioat_cdev != NULL) { - destroy_dev(g_ioat_cdev); - g_ioat_cdev = NULL; - } + enable_ioat_test(enabled); return (0); } SYSCTL_PROC(_hw_ioat, OID_AUTO, enable_ioat_test, CTLTYPE_INT | CTLFLAG_RW, 0, 0, sysctl_enable_ioat_test, "I", "Non-zero: Enable the /dev/ioat_test device"); + +void +ioat_test_attach(void) +{ + char *val; + + val = kern_getenv("hw.ioat.enable_ioat_test"); + if (val != NULL && strcmp(val, "0") != 0) { + mtx_lock(&Giant); + enable_ioat_test(true); + mtx_unlock(&Giant); + } + freeenv(val); +} + +void +ioat_test_detach(void) +{ + + mtx_lock(&Giant); + enable_ioat_test(false); + mtx_unlock(&Giant); +} |