/* * Determine if we have hit the "timeout" limit for the test if we * have then report it as an error, otherwise we wil sleep for the * required amount of time and then report completion.
*/ if (atomic_read(&timeout)) {
dev_err(dev, "async probe took too long\n");
atomic_inc(&errors);
} else {
dev_dbg(&pdev->dev, "sleeping for %d msecs in probe\n",
TEST_PROBE_DELAY);
msleep(TEST_PROBE_DELAY);
dev_dbg(&pdev->dev, "done sleeping\n");
}
/* * Report NUMA mismatch if device node is set and we are not * performing an async init on that node.
*/ if (dev->driver->probe_type == PROBE_PREFER_ASYNCHRONOUS) { if (IS_ENABLED(CONFIG_NUMA) &&
dev_to_node(dev) != numa_node_id()) {
dev_warn(dev, "NUMA node mismatch %d != %d\n",
dev_to_node(dev), numa_node_id());
atomic_inc(&warnings);
}
duration = (unsignedlonglong)ktime_ms_delta(ktime_get(), calltime);
pr_info("registration took %lld msecs\n", duration); if (duration > TEST_PROBE_THRESHOLD) {
pr_err("test failed: probe took too long\n");
err = -ETIMEDOUT; goto err_unregister_async_driver;
}
pr_info("registering second set of asynchronous devices...\n");
calltime = ktime_get();
for_each_online_cpu(cpu) {
nid = cpu_to_node(cpu);
pdev = &async_dev[async_id];
duration = (unsignedlonglong)ktime_ms_delta(ktime_get(), calltime);
dev_info(&(*pdev)->dev, "registration took %lld msecs\n", duration); if (duration < TEST_PROBE_THRESHOLD) {
dev_err(&(*pdev)->dev, "test failed: probe was too quick\n");
err = -ETIMEDOUT; goto err_unregister_sync_driver;
}
/* * The async events should have completed while we were taking care * of the synchronous events. We will now terminate any outstanding * asynchronous probe calls remaining by forcing timeout and remove * the driver before we return which should force the flush of the * pending asynchronous probe calls. * * Otherwise if they completed without errors or warnings then * report successful completion.
*/ if (atomic_read(&async_completed) != async_id) {
pr_err("async events still pending, forcing timeout\n");
atomic_inc(&timeout);
err = -ETIMEDOUT;
} elseif (!atomic_read(&errors) && !atomic_read(&warnings)) {
pr_info("completed successfully\n"); return 0;
}
err_unregister_sync_driver:
platform_driver_unregister(&sync_driver);
err_unregister_sync_devs: while (sync_id--)
platform_device_unregister(sync_dev[sync_id]);
err_unregister_async_driver:
platform_driver_unregister(&async_driver);
err_unregister_async_devs: while (async_id--)
platform_device_unregister(async_dev[async_id]);
/* * If err is already set then count that as an additional error for * the test. Otherwise we will report an invalid argument error and * not count that as we should have reached here as a result of * errors or warnings being reported by the probe routine.
*/ if (err)
atomic_inc(&errors); else
err = -EINVAL;
pr_err("Test failed with %d errors and %d warnings\n",
atomic_read(&errors), atomic_read(&warnings));
return err;
}
module_init(test_async_probe_init);
staticvoid __exit test_async_probe_exit(void)
{ int id = 2;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.