Skip to content

Commit c6e27bd

Browse files
Enable prepatcher DirectSubmission WA
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent 79fedd5 commit c6e27bd

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ HWTEST_F(BcsTests, givenBlitterDirectSubmissionEnabledWhenProgrammingBlitterThen
14051405
MI_BATCH_BUFFER_START *bbStart = hwParser.getCommand<MI_BATCH_BUFFER_START>();
14061406
ASSERT_NE(nullptr, bbStart);
14071407
EXPECT_EQ(csr.latestFlushedBatchBuffer.endCmdPtr, bbStart);
1408-
EXPECT_EQ(0ull, bbStart->getBatchBufferStartAddress());
1408+
EXPECT_NE(0ull, bbStart->getBatchBufferStartAddress());
14091409
}
14101410

14111411
HWTEST_F(BcsTests, givenBlitterDirectSubmissionEnabledWhenFlushTagUpdateThenBatchBufferStartIsProgrammed) {

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ inline void CommandStreamReceiverHw<GfxFamily>::addBatchBufferEnd(LinearStream &
9494
template <typename GfxFamily>
9595
inline void CommandStreamReceiverHw<GfxFamily>::programEndingCmd(LinearStream &commandStream, Device &device, void **patchLocation, bool directSubmissionEnabled) {
9696
if (directSubmissionEnabled) {
97-
uint64_t startAddress = 0;
98-
if (DebugManager.flags.BatchBufferStartPrepatchingWaEnabled.get() == 1) {
99-
startAddress = commandStream.getGraphicsAllocation()->getGpuAddress() + commandStream.getUsed();
97+
uint64_t startAddress = commandStream.getGraphicsAllocation()->getGpuAddress() + commandStream.getUsed();
98+
if (DebugManager.flags.BatchBufferStartPrepatchingWaEnabled.get() == 0) {
99+
startAddress = 0;
100100
}
101101

102102
*patchLocation = commandStream.getSpace(sizeof(MI_BATCH_BUFFER_START));

shared/test/unit_test/direct_submission/direct_submission_tests_1.cpp

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,12 @@ HWTEST_F(DirectSubmissionTest, givenDirectSubmissionAvailableWhenProgrammingEndi
602602
bool ret = mockCsr->isDirectSubmissionEnabled();
603603
EXPECT_TRUE(ret);
604604

605+
MockGraphicsAllocation mockAllocation;
606+
605607
void *location = nullptr;
606608
uint8_t buffer[128];
607609
mockCsr->commandStream.replaceBuffer(&buffer[0], 128u);
610+
mockCsr->commandStream.replaceGraphicsAllocation(&mockAllocation);
608611
auto &device = *pDevice;
609612
mockCsr->programEndingCmd(mockCsr->commandStream, device, &location, ret);
610613
EXPECT_EQ(sizeof(MI_BATCH_BUFFER_START), mockCsr->commandStream.getUsed());
@@ -615,18 +618,17 @@ HWTEST_F(DirectSubmissionTest, givenDirectSubmissionAvailableWhenProgrammingEndi
615618
mockCsr->getCmdSizeForEpilogueCommands(dispatchFlags);
616619
expectedSize = alignUp(expectedSize, MemoryConstants::cacheLineSize);
617620
EXPECT_EQ(expectedSize, mockCsr->getCmdSizeForEpilogue(dispatchFlags));
621+
622+
mockCsr->commandStream.replaceGraphicsAllocation(nullptr);
618623
}
619624

620-
HWTEST_F(DirectSubmissionTest, givenDebugFlagSetWhenProgrammingEndingCommandThenUseNonZeroBatchBufferStart) {
625+
HWTEST_F(DirectSubmissionTest, givenDebugFlagSetWhenProgrammingEndingCommandThenUseCorrectBatchBufferStartValue) {
621626
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
622627

623628
DebugManagerStateRestore restorer;
624-
625-
DebugManager.flags.BatchBufferStartPrepatchingWaEnabled.set(1);
626-
627629
MockGraphicsAllocation mockAllocation;
628-
629630
int32_t executionStamp = 0;
631+
630632
std::unique_ptr<MockCsr<FamilyType>> mockCsr = std::make_unique<MockCsr<FamilyType>>(executionStamp, *pDevice->executionEnvironment,
631633
pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
632634

@@ -636,25 +638,30 @@ HWTEST_F(DirectSubmissionTest, givenDebugFlagSetWhenProgrammingEndingCommandThen
636638
EXPECT_TRUE(ret);
637639

638640
void *location = nullptr;
639-
uint8_t buffer[128];
640-
mockCsr->commandStream.replaceBuffer(&buffer[0], 128u);
641-
mockCsr->commandStream.replaceGraphicsAllocation(&mockAllocation);
641+
642+
uint8_t buffer[256] = {};
643+
auto &cmdStream = mockCsr->commandStream;
644+
cmdStream.replaceBuffer(&buffer[0], 256);
645+
cmdStream.replaceGraphicsAllocation(&mockAllocation);
642646
auto &device = *pDevice;
643-
mockCsr->programEndingCmd(mockCsr->commandStream, device, &location, ret);
644-
EXPECT_EQ(sizeof(MI_BATCH_BUFFER_START), mockCsr->commandStream.getUsed());
645647

646-
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
647-
dispatchFlags.epilogueRequired = true;
648-
size_t expectedSize = sizeof(MI_BATCH_BUFFER_START) +
649-
mockCsr->getCmdSizeForEpilogueCommands(dispatchFlags);
650-
expectedSize = alignUp(expectedSize, MemoryConstants::cacheLineSize);
651-
EXPECT_EQ(expectedSize, mockCsr->getCmdSizeForEpilogue(dispatchFlags));
648+
for (int32_t value : {-1, 0, 1}) {
649+
DebugManager.flags.BatchBufferStartPrepatchingWaEnabled.set(value);
652650

653-
auto bbStartCmd = reinterpret_cast<MI_BATCH_BUFFER_START *>(mockCsr->commandStream.getCpuBase());
651+
auto currectBbStartCmd = reinterpret_cast<MI_BATCH_BUFFER_START *>(cmdStream.getSpace(0));
652+
uint64_t expectedGpuVa = cmdStream.getGraphicsAllocation()->getGpuAddress() + cmdStream.getUsed();
654653

655-
EXPECT_EQ(mockCsr->commandStream.getGraphicsAllocation()->getGpuAddress(), bbStartCmd->getBatchBufferStartAddress());
654+
mockCsr->programEndingCmd(cmdStream, device, &location, ret);
655+
EncodeNoop<FamilyType>::alignToCacheLine(cmdStream);
656656

657-
mockCsr->commandStream.replaceGraphicsAllocation(nullptr);
657+
if (value == 0) {
658+
EXPECT_EQ(0u, currectBbStartCmd->getBatchBufferStartAddress());
659+
} else {
660+
EXPECT_EQ(expectedGpuVa, currectBbStartCmd->getBatchBufferStartAddress());
661+
}
662+
}
663+
664+
cmdStream.replaceGraphicsAllocation(nullptr);
658665
}
659666

660667
HWTEST_F(DirectSubmissionTest,

0 commit comments

Comments
 (0)