Potentially fix race condition nvGpfifoCreate by waiting on the fence returned by nvioctlChannel_AllocGpfifoEx2

This commit is contained in:
fincs 2018-09-05 14:00:28 +02:00
parent d718a8dd28
commit 7f4001bec2
2 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,6 @@
typedef struct {
NvChannel* parent;
nvioctl_fence fifo_fence;
} NvGpfifo;
Result nvGpfifoCreate(NvGpfifo* f, NvChannel* parent);

View File

@ -24,8 +24,11 @@ Result nvGpfifoCreate(NvGpfifo* f, NvChannel* parent)
{
f->parent = parent;
return nvioctlChannel_AllocGpfifoEx2(
parent->fd, DEFAULT_FIFO_ENTRIES, 1, 0, 0, 0, 0, &f->fifo_fence);
NvFence fence;
Result res = nvioctlChannel_AllocGpfifoEx2(parent->fd, DEFAULT_FIFO_ENTRIES, 1, 0, 0, 0, 0, &fence);
if (R_SUCCEEDED(res) && (s32)fence.id >= 0)
nvFenceWait(&fence, -1);
return res;
}
void nvGpfifoClose(NvGpfifo* f) {