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);
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)
uint32_t i;
ioat = DEVICE2SOFTC(device);
+
+ ioat_test_detach();
callout_drain(&ioat->timer);
pci_disable_busmaster(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;
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);
}
.d_name = "ioat_test",
};
+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)
{
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);
+}