void CommOS_StopIO(void) { int cpu; if (running) { running = 0; if (aioWQ) { FlushWorkqueue(aioWQ); DestroyWorkqueue(aioWQ); aioWQ = NULL; } FlushWorkqueue(dispatchWQ); #ifdef CONFIG_HOTPLUG_CPU unregister_hotcpu_notifier(&CpuNotifier); #endif for_each_possible_cpu(cpu) { WaitForDelayedWork(&dispatchWorksNow[cpu]); WaitForDelayedWork(&dispatchWorks[cpu]); } DestroyWorkqueue(dispatchWQ); dispatchWQ = NULL; commos_info("%s: I/O tasks stopped.\n", __func__); } }
static int DefaultTranspListener(CommTranspInitArgs *transpArgs, void *probeData) { int rc = -1; const int inBH = 1; const CommImpl *impl; if (!transpArgs || !probeData) { commos_debug("%s: NULL args [0x%p, 0x%p].\n", __func__, transpArgs, probeData); goto out; } impl = probeData; commos_debug("%s: Received attach info [%u,%u,%u:%u].\n", __func__, transpArgs->capacity, transpArgs->type, transpArgs->id.d32[0], transpArgs->id.d32[1]); if (impl->checkArgs(transpArgs)) goto out; transpArgs->mode = COMM_TRANSP_INIT_ATTACH; /* Ensure we attach */ /* * We recognized it, so don't let others waste any time. * Even if we fail. */ rc = 0; if (Comm_Alloc(transpArgs, impl, inBH, NULL)) { impl->closeNtf(impl->closeNtfData, transpArgs, inBH); commos_info("%s: Can't allocate new channel!\n", __func__); } out: return rc; }
int CommOS_StartIO(const char *dispatchTaskName, CommOSDispatchFunc dispatchFunc, unsigned int intervalMillis, unsigned int maxCycles, const char *aioTaskName) { int cpu; if (running) { commos_debug("%s: I/O tasks already running.\n", __func__); return 0; } if (!dispatchFunc) { commos_info("%s: a NULL Dispatch handler was passed.\n", __func__); return -1; } dispatch = dispatchFunc; if (intervalMillis == 0) intervalMillis = 4; dispatchInterval = msecs_to_jiffies(intervalMillis); if (dispatchInterval < 1) dispatchInterval = 1; if (maxCycles > DISPATCH_MAX_CYCLES) dispatchMaxCycles = DISPATCH_MAX_CYCLES; else if (maxCycles > 0) dispatchMaxCycles = maxCycles; commos_debug("%s: Interval millis %u (jif:%u).\n", __func__, intervalMillis, dispatchInterval); commos_debug("%s: Max cycles %u.\n", __func__, dispatchMaxCycles); dispatchWQ = CreateWorkqueue(dispatchTaskName); if (!dispatchWQ) { commos_info("%s: Couldn't create %s task(s).\n", __func__, dispatchTaskName); return -1; } if (aioTaskName) { aioWQ = CreateWorkqueue(aioTaskName); if (!aioWQ) { commos_info("%s: Couldn't create %s task(s).\n", __func__, aioTaskName); DestroyWorkqueue(dispatchWQ); return -1; } } else { aioWQ = NULL; } running = 1; for_each_possible_cpu(cpu) { CommOS_InitWork(&dispatchWorksNow[cpu], DispatchWrapper); CommOS_InitWork(&dispatchWorks[cpu], DispatchWrapper); } #ifdef CONFIG_HOTPLUG_CPU register_hotcpu_notifier(&CpuNotifier); #endif get_online_cpus(); for_each_online_cpu(cpu) QueueDelayedWorkOn(cpu, dispatchWQ, &dispatchWorks[cpu], dispatchInterval); put_online_cpus(); commos_info("%s: Created I/O task(s) successfully.\n", __func__); return 0; }