diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ioat/ioat.c | 20 | ||||
-rw-r--r-- | sys/dev/ioat/ioat_internal.h | 3 | ||||
-rw-r--r-- | sys/dev/ioat/ioat_test.c | 47 |
3 files changed, 55 insertions, 15 deletions
diff --git a/sys/dev/ioat/ioat.c b/sys/dev/ioat/ioat.c index decd0a93418f..bb71243094f5 100644 --- a/sys/dev/ioat/ioat.c +++ b/sys/dev/ioat/ioat.c @@ -56,6 +56,7 @@ static int ioat_detach(device_t device); static int ioat_setup_intr(struct ioat_softc *ioat); static int ioat_teardown_intr(struct ioat_softc *ioat); static int ioat3_attach(device_t device); +static int ioat3_selftest(struct ioat_softc *ioat); static int ioat_map_pci_bar(struct ioat_softc *ioat); static void ioat_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error); @@ -239,7 +240,15 @@ ioat_attach(device_t device) if (error != 0) goto err; + error = ioat3_selftest(ioat); + if (error != 0) + return (error); + + ioat_process_events(ioat); + ioat_setup_sysctl(device); + ioat_channel[ioat_channel_index++] = ioat; + ioat_test_attach(); err: if (error != 0) @@ -254,6 +263,8 @@ ioat_detach(device_t device) uint32_t i; ioat = DEVICE2SOFTC(device); + + ioat_test_detach(); callout_drain(&ioat->timer); pci_disable_busmaster(device); @@ -347,7 +358,7 @@ ioat3_attach(device_t device) mtx_init(&ioat->submit_lock, "ioat_submit", NULL, MTX_DEF); mtx_init(&ioat->cleanup_lock, "ioat_process_events", NULL, MTX_DEF); - callout_init(&ioat->timer, CALLOUT_MPSAFE); + callout_init(&ioat->timer, 1); ioat->is_resize_pending = FALSE; ioat->is_completion_pending = FALSE; @@ -415,13 +426,6 @@ ioat3_attach(device_t device) ioat_write_chanctrl(ioat, IOAT_CHANCTRL_RUN); ioat_write_chancmp(ioat, ioat->comp_update_bus_addr); ioat_write_chainaddr(ioat, ring[0]->hw_desc_bus_addr); - - error = ioat3_selftest(ioat); - if (error != 0) - return (error); - - ioat_process_events(ioat); - ioat_setup_sysctl(device); return (0); } diff --git a/sys/dev/ioat/ioat_internal.h b/sys/dev/ioat/ioat_internal.h index 7420c82892e0..9bc6040b27dd 100644 --- a/sys/dev/ioat/ioat_internal.h +++ b/sys/dev/ioat/ioat_internal.h @@ -366,6 +366,9 @@ struct ioat_softc { struct mtx cleanup_lock; }; +void ioat_test_attach(void); +void ioat_test_detach(void); + static inline uint64_t ioat_get_chansts(struct ioat_softc *ioat) { 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); +} |