Skip to content

Commit cf7592c

Browse files
author
Lukas
committed
Bound the GPFIFO-space wait in nvWriteGpEntry()
1 parent 57130a2 commit cf7592c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/common/unix/nvidia-push/src/nvidia-push.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ static NvBool nvWriteGpEntry(
347347

348348
NvU32 nextGpPut;
349349
NvU32 *gpPointer;
350+
NvU64 baseTime, currentTime;
350351
const NvU32 entriesNeeded = NV_PUSH_NUM_GPFIFO_ENTRIES_PER_KICKOFF;
351352
NvPushDevicePtr pDevice = push_buffer->pDevice;
352353

@@ -359,11 +360,21 @@ static NvBool nvWriteGpEntry(
359360
nvAssert((nextGpPut % 2) == 0);
360361

361362
// Wait for a free entry in the buffer
362-
while (nextGpPut == ReadGpGetOffset(push_buffer)) {
363+
for (baseTime = currentTime = nvPushImportGetMilliSeconds(pDevice);
364+
nextGpPut == ReadGpGetOffset(push_buffer);
365+
currentTime = nvPushImportGetMilliSeconds(pDevice)) {
366+
363367
if (nvPushCheckChannelError(push_buffer)) {
364368
nvAssert(!"A channel error occurred in nvWriteGpEntry()");
365369
return FALSE;
366370
}
371+
372+
if (currentTime > (baseTime + NV_PUSH_NOTIFIER_SHORT_TIMEOUT) &&
373+
!push_buffer->noTimeout) {
374+
nvPushImportLogError(pDevice,
375+
"Timed out waiting for a free GPFIFO entry.");
376+
return FALSE;
377+
}
367378
}
368379
gpPointer[0] = gpEntry0;
369380
gpPointer[1] = gpEntry1;

0 commit comments

Comments
 (0)