ret = 0; if (!i915_sw_fence_done(C)) {
pr_err("fence C not done\n");
ret = -EINVAL;
} if (!i915_sw_fence_done(B)) {
pr_err("fence B not done\n");
ret = -EINVAL;
} if (!i915_sw_fence_done(A)) {
pr_err("fence A not done\n");
ret = -EINVAL;
}
err_C:
free_fence(C);
err_B:
free_fence(B);
err_A:
free_fence(A); return ret;
}
staticint test_AB(void *arg)
{ struct i915_sw_fence *A, *B; int ret;
/* Test i915_sw_fence (A) waiting on an event source (B) */
A = alloc_fence(); if (!A) return -ENOMEM;
B = alloc_fence(); if (!B) {
ret = -ENOMEM; goto err_A;
}
ret = i915_sw_fence_await_sw_fence_gfp(A, B, GFP_KERNEL); if (ret < 0) goto err_B; if (ret == 0) {
pr_err("Incorrectly reported fence A was complete before await\n");
ret = -EINVAL; goto err_B;
}
ret = -EINVAL;
i915_sw_fence_commit(A); if (i915_sw_fence_done(A)) goto err_B;
i915_sw_fence_commit(B); if (!i915_sw_fence_done(B)) {
pr_err("Fence B is not done\n"); goto err_B;
}
if (!i915_sw_fence_done(A)) {
pr_err("Fence A is not done\n"); goto err_B;
}
ret = 0;
err_B:
free_fence(B);
err_A:
free_fence(A); return ret;
}
/* Test a chain of fences, A waits on B who waits on C */
A = alloc_fence(); if (!A) return -ENOMEM;
B = alloc_fence(); if (!B) {
ret = -ENOMEM; goto err_A;
}
C = alloc_fence(); if (!C) {
ret = -ENOMEM; goto err_B;
}
ret = i915_sw_fence_await_sw_fence_gfp(A, B, GFP_KERNEL); if (ret < 0) goto err_C; if (ret == 0) {
pr_err("Incorrectly reported fence B was complete before await\n"); goto err_C;
}
ret = i915_sw_fence_await_sw_fence_gfp(B, C, GFP_KERNEL); if (ret < 0) goto err_C; if (ret == 0) {
pr_err("Incorrectly reported fence C was complete before await\n"); goto err_C;
}
ret = -EINVAL;
i915_sw_fence_commit(A); if (i915_sw_fence_done(A)) {
pr_err("Fence A completed early\n"); goto err_C;
}
i915_sw_fence_commit(B); if (i915_sw_fence_done(B)) {
pr_err("Fence B completed early\n"); goto err_C;
}
if (i915_sw_fence_done(A)) {
pr_err("Fence A completed early (after signaling B)\n"); goto err_C;
}
i915_sw_fence_commit(C);
ret = 0; if (!i915_sw_fence_done(C)) {
pr_err("Fence C not done\n");
ret = -EINVAL;
} if (!i915_sw_fence_done(B)) {
pr_err("Fence B not done\n");
ret = -EINVAL;
} if (!i915_sw_fence_done(A)) {
pr_err("Fence A not done\n");
ret = -EINVAL;
}
err_C:
free_fence(C);
err_B:
free_fence(B);
err_A:
free_fence(A); return ret;
}
staticint test_AB_C(void *arg)
{ struct i915_sw_fence *A, *B, *C; int ret = -EINVAL;
/* Test multiple fences (AB) waiting on a single event (C) */
A = alloc_fence(); if (!A) return -ENOMEM;
B = alloc_fence(); if (!B) {
ret = -ENOMEM; goto err_A;
}
C = alloc_fence(); if (!C) {
ret = -ENOMEM; goto err_B;
}
ret = i915_sw_fence_await_sw_fence_gfp(A, C, GFP_KERNEL); if (ret < 0) goto err_C; if (ret == 0) {
ret = -EINVAL; goto err_C;
}
ret = i915_sw_fence_await_sw_fence_gfp(B, C, GFP_KERNEL); if (ret < 0) goto err_C; if (ret == 0) {
ret = -EINVAL; goto err_C;
}
i915_sw_fence_commit(A);
i915_sw_fence_commit(B);
ret = 0; if (i915_sw_fence_done(A)) {
pr_err("Fence A completed early\n");
ret = -EINVAL;
}
if (i915_sw_fence_done(B)) {
pr_err("Fence B completed early\n");
ret = -EINVAL;
}
i915_sw_fence_commit(C); if (!i915_sw_fence_done(C)) {
pr_err("Fence C not done\n");
ret = -EINVAL;
}
if (!i915_sw_fence_done(B)) {
pr_err("Fence B not done\n");
ret = -EINVAL;
}
if (!i915_sw_fence_done(A)) {
pr_err("Fence A not done\n");
ret = -EINVAL;
}
staticint test_chain(void *arg)
{ int nfences = 4096; struct i915_sw_fence **fences; int ret, i;
/* Test a long chain of fences */
fences = kmalloc_array(nfences, sizeof(*fences), GFP_KERNEL); if (!fences) return -ENOMEM;
for (i = 0; i < nfences; i++) {
fences[i] = alloc_fence(); if (!fences[i]) {
nfences = i;
ret = -ENOMEM; goto err;
}
if (i > 0) {
ret = i915_sw_fence_await_sw_fence_gfp(fences[i],
fences[i - 1],
GFP_KERNEL); if (ret < 0) {
nfences = i + 1; goto err;
}
i915_sw_fence_commit(fences[i]);
}
}
ret = 0; for (i = nfences; --i; ) { if (i915_sw_fence_done(fences[i])) { if (ret == 0)
pr_err("Fence[%d] completed early\n", i);
ret = -EINVAL;
}
}
i915_sw_fence_commit(fences[0]); for (i = 0; ret == 0 && i < nfences; i++) { if (!i915_sw_fence_done(fences[i])) {
pr_err("Fence[%d] is not done\n", i);
ret = -EINVAL;
}
}
err: for (i = 0; i < nfences; i++)
free_fence(fences[i]);
kfree(fences); return ret;
}
/* Test use of i915_sw_fence as an interprocess signaling mechanism */
ipc.in = alloc_fence(); if (!ipc.in) {
ret = -ENOMEM; goto err_work;
}
ipc.out = alloc_fence(); if (!ipc.out) {
ret = -ENOMEM; goto err_in;
}
/* use a completion to avoid chicken-and-egg testing */
init_completion(&ipc.started);
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.