Add debug flag to read back command buffer pointer

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2022-03-29 11:51:44 +00:00
committed by Compute-Runtime-Automation
parent 88c16542a1
commit 68351249d1
7 changed files with 62 additions and 3 deletions

View File

@@ -169,6 +169,42 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenCommandStreamWithDuplicate
mm->freeGraphicsMemory(commandBuffer);
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDebugFlagSetWhenFlushingThenReadBackCommandBufferPointerIfRequired) {
auto commandBuffer = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
LinearStream cs(commandBuffer);
auto testedCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
{
DebugManager.flags.ReadBackCommandBufferAllocation.set(1);
csr->flush(batchBuffer, csr->getResidencyAllocations());
if (commandBuffer->isAllocatedInLocalMemoryPool()) {
EXPECT_EQ(commandBuffer->getUnderlyingBuffer(), testedCsr->latestReadBackAddress);
} else {
EXPECT_EQ(nullptr, testedCsr->latestReadBackAddress);
}
testedCsr->latestReadBackAddress = nullptr;
}
{
DebugManager.flags.ReadBackCommandBufferAllocation.set(2);
csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(commandBuffer->getUnderlyingBuffer(), testedCsr->latestReadBackAddress);
}
mm->freeGraphicsMemory(commandBuffer);
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmCsrCreatedWithInactiveGemCloseWorkerPolicyThenThreadIsNotCreated) {
TestedDrmCommandStreamReceiver<FamilyType> testedCsr(gemCloseWorkerMode::gemCloseWorkerInactive,
*this->executionEnvironment,

View File

@@ -407,3 +407,4 @@ DirectSubmissionForceLocalMemoryStorageMode = -1
EnableRingSwitchTagUpdateWa = -1
DirectSubmissionReadBackCommandBuffer = -1
DirectSubmissionReadBackRingBuffer = -1
ReadBackCommandBufferAllocation = -1

View File

@@ -197,6 +197,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideTimestampEvents, -1, "-1: default (based
DECLARE_DEBUG_VARIABLE(int32_t, ForcePreParserEnabledForMiArbCheck, -1, "-1: default , 0: PreParser disabled, 1: PreParser enabled")
DECLARE_DEBUG_VARIABLE(int32_t, BatchBufferStartPrepatchingWaEnabled, -1, "-1: default , 0: disabled, 1: enabled. WA applies valid VA pointing to 'self' instead of 0x0. This mitigates incorrect VA preparsing.")
DECLARE_DEBUG_VARIABLE(int32_t, SetVmAdviseAtomicAttribute, -1, "-1: default - atomic system, 0: atomic none, 1: atomic device, 2: atomic system)")
DECLARE_DEBUG_VARIABLE(int32_t, ReadBackCommandBufferAllocation, -1, "Read command buffer allocation back on the host side. -1: default, 0 - disabled, 1 - local memory only, 2 - local and system memory")
DECLARE_DEBUG_VARIABLE(bool, DisableScratchPages, false, "Disable scratch pages during VM creations")
/*LOGGING FLAGS*/
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")

View File

@@ -153,7 +153,7 @@ class DirectSubmissionHw {
uint32_t workloadModeOneExpectedValue = 0u;
uint32_t activeTiles = 1u;
uint32_t postSyncOffset = 0u;
uint32_t reserved = 0u;
volatile uint32_t reserved = 0u;
bool ringStart = false;
bool disableCpuCacheFlush = true;

View File

@@ -70,6 +70,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
MOCKABLE_VIRTUAL int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency);
MOCKABLE_VIRTUAL int exec(const BatchBuffer &batchBuffer, uint32_t vmHandleId, uint32_t drmContextId, uint32_t index);
MOCKABLE_VIRTUAL int waitUserFence(uint32_t waitValue);
MOCKABLE_VIRTUAL void readBackAllocation(void *source);
bool isUserFenceWaitActive();
std::vector<BufferObject *> residency;
@@ -77,6 +78,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
Drm *drm;
gemCloseWorkerMode gemCloseWorkerOperationMode;
volatile uint32_t reserved = 0;
int32_t kmdWaitTimeout = -1;
bool useUserFenceWait = true;

View File

@@ -153,6 +153,14 @@ SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBu
} else {
this->flushStamp->setStamp(bb->peekHandle());
}
auto readBackMode = DebugManager.flags.ReadBackCommandBufferAllocation.get();
bool readBackAllowed = ((batchBuffer.commandBufferAllocation->isAllocatedInLocalMemoryPool() && readBackMode == 1) || readBackMode == 2);
if (readBackAllowed) {
readBackAllocation(ptrOffset(batchBuffer.commandBufferAllocation->getUnderlyingBuffer(), batchBuffer.startOffset));
}
auto ret = this->flushInternal(batchBuffer, allocationsForResidency);
if (this->gemCloseWorkerOperationMode == gemCloseWorkerMode::gemCloseWorkerActive) {
@@ -167,6 +175,11 @@ SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBu
return SubmissionStatus::SUCCESS;
}
template <typename GfxFamily>
void DrmCommandStreamReceiver<GfxFamily>::readBackAllocation(void *source) {
reserved = *reinterpret_cast<volatile uint32_t *>(source);
}
template <typename GfxFamily>
void DrmCommandStreamReceiver<GfxFamily>::printBOsForSubmit(ResidencyContainer &allocationsForResidency, GraphicsAllocation &cmdBufferAllocation) {
if (DebugManager.flags.PrintBOsForSubmit.get()) {

View File

@@ -106,14 +106,20 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
}
}
bool callHwFlush = true;
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
if (callHwFlush) {
return DrmCommandStreamReceiver<GfxFamily>::flushInternal(batchBuffer, allocationsForResidency);
}
return 0;
}
void readBackAllocation(void *source) override {
latestReadBackAddress = source;
DrmCommandStreamReceiver<GfxFamily>::readBackAllocation(source);
}
void *latestReadBackAddress = nullptr;
bool callHwFlush = true;
};
template <typename GfxFamily>