Skip to content

Commit ce75767

Browse files
Add AUB registry key to override MMIO offset value
Change-Id: Iac3bf9074e544a03e38fc437d7b21ea478d9cc5d
1 parent 0867682 commit ce75767

23 files changed

+206
-81
lines changed

runtime/aub_mem_dump/aub_mem_dump.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "aub_mem_dump.h"
99
#include "runtime/helpers/ptr_math.h"
1010
#include "runtime/helpers/debug_helpers.h"
11+
#include "runtime/os_interface/debug_settings_manager.h"
1112

1213
namespace AubMemDump {
1314

@@ -173,4 +174,15 @@ void LrcaHelper::initialize(void *pLRCIn) const {
173174
setPDP2(pLRCIn, 0);
174175
setPDP3(pLRCIn, 0);
175176
}
177+
178+
void AubStream::writeMMIO(uint32_t offset, uint32_t value) {
179+
auto dbgOffset = OCLRT::DebugManager.flags.AubDumpOverrideMmioRegister.get();
180+
if (dbgOffset > 0) {
181+
if (offset == static_cast<uint32_t>(dbgOffset)) {
182+
offset = static_cast<uint32_t>(dbgOffset);
183+
value = static_cast<uint32_t>(OCLRT::DebugManager.flags.AubDumpOverrideMmioRegisterValue.get());
184+
}
185+
}
186+
writeMMIOImpl(offset, value);
187+
}
176188
} // namespace AubMemDump

runtime/aub_mem_dump/aub_mem_dump.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ struct AubStream {
106106
}
107107
virtual void writePTE(uint64_t physAddress, uint64_t entry) = 0;
108108
virtual void writeGTT(uint32_t offset, uint64_t entry) = 0;
109-
virtual void writeMMIO(uint32_t offset, uint32_t value) = 0;
109+
void writeMMIO(uint32_t offset, uint32_t value);
110110
virtual void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) = 0;
111111
virtual ~AubStream() = default;
112+
113+
protected:
114+
virtual void writeMMIOImpl(uint32_t offset, uint32_t value) = 0;
112115
};
113116

114117
struct AubFileStream : public AubStream {
@@ -120,7 +123,7 @@ struct AubFileStream : public AubStream {
120123
void writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) override;
121124
void writePTE(uint64_t physAddress, uint64_t entry) override;
122125
void writeGTT(uint32_t offset, uint64_t entry) override;
123-
void writeMMIO(uint32_t offset, uint32_t value) override;
126+
void writeMMIOImpl(uint32_t offset, uint32_t value) override;
124127
void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override;
125128
bool isOpen() const { return fileHandle.is_open(); }
126129
const std::string &getFileName() const { return fileName; }

runtime/command_stream/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ set(RUNTIME_SRCS_COMMAND_STREAM
2626
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/command_stream_receiver_simulated_hw.h
2727
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/engine_node.h
2828
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_simulated_common_hw.h
29+
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_simulated_common_hw.inl
2930
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream.h
3031
${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.cpp
3132
${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.h

runtime/command_stream/aub_command_stream_receiver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void AubFileStream::writePTE(uint64_t physAddress, uint64_t entry) {
144144
write(reinterpret_cast<char *>(&entry), sizeof(entry));
145145
}
146146

147-
void AubFileStream::writeMMIO(uint32_t offset, uint32_t value) {
147+
void AubFileStream::writeMMIOImpl(uint32_t offset, uint32_t value) {
148148
CmdServicesMemTraceRegisterWrite header = {};
149149
header.setHeader();
150150
header.dwordCount = (sizeof(header) / sizeof(uint32_t)) - 1;

runtime/command_stream/aub_command_stream_receiver_hw.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
2828
using ExternalAllocationsContainer = std::vector<AllocationView>;
2929

3030
public:
31+
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
32+
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
33+
3134
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override;
3235
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
3336

@@ -36,6 +39,10 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
3639
void makeResidentExternal(AllocationView &allocationView);
3740
void makeNonResidentExternal(uint64_t gpuAddress);
3841

42+
AubMemDump::AubFileStream *getAubStream() const {
43+
return static_cast<AubMemDump::AubFileStream *>(this->stream);
44+
}
45+
3946
MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation);
4047
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
4148
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue);
@@ -90,7 +97,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
9097
} engineInfoTable[arrayCount(allEngineInstances)] = {};
9198
size_t gpgpuEngineIndex = arrayCount(gpgpuEngineInstances) - 1;
9299

93-
AUBCommandStreamReceiver::AubFileStream *stream;
94100
std::unique_ptr<AubSubCaptureManager> subCaptureManager;
95101
uint32_t aubDeviceId;
96102
bool standalone;

runtime/command_stream/aub_command_stream_receiver_hw.inl

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initEngineMMIO(EngineInstanceT engin
125125

126126
template <typename GfxFamily>
127127
void AUBCommandStreamReceiverHw<GfxFamily>::openFile(const std::string &fileName) {
128-
auto streamLocked = stream->lockStream();
128+
auto streamLocked = getAubStream()->lockStream();
129129
initFile(fileName);
130130
}
131131

132132
template <typename GfxFamily>
133133
bool AUBCommandStreamReceiverHw<GfxFamily>::reopenFile(const std::string &fileName) {
134-
auto streamLocked = stream->lockStream();
134+
auto streamLocked = getAubStream()->lockStream();
135135
if (isFileOpen()) {
136136
if (fileName != getFileName()) {
137137
closeFile();
@@ -147,11 +147,11 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::reopenFile(const std::string &fileNa
147147

148148
template <typename GfxFamily>
149149
void AUBCommandStreamReceiverHw<GfxFamily>::initFile(const std::string &fileName) {
150-
if (!stream->isOpen()) {
150+
if (!getAubStream()->isOpen()) {
151151
// Open our file
152152
stream->open(fileName.c_str());
153153

154-
if (!stream->isOpen()) {
154+
if (!getAubStream()->isOpen()) {
155155
// This DEBUG_BREAK_IF most probably means you are not executing aub tests with correct current directory (containing aub_out folder)
156156
// try adding <familycodename>_aub
157157
DEBUG_BREAK_IF(true);
@@ -168,12 +168,12 @@ void AUBCommandStreamReceiverHw<GfxFamily>::closeFile() {
168168

169169
template <typename GfxFamily>
170170
bool AUBCommandStreamReceiverHw<GfxFamily>::isFileOpen() const {
171-
return stream->isOpen();
171+
return getAubStream()->isOpen();
172172
}
173173

174174
template <typename GfxFamily>
175175
const std::string &AUBCommandStreamReceiverHw<GfxFamily>::getFileName() {
176-
return stream->getFileName();
176+
return getAubStream()->getFileName();
177177
}
178178

179179
template <typename GfxFamily>
@@ -184,6 +184,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex)
184184

185185
initGlobalMMIO();
186186
initEngineMMIO(engineInstance);
187+
this->initAdditionalMMIO();
187188

188189
// Global HW Status Page
189190
{
@@ -198,7 +199,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex)
198199
{
199200
std::ostringstream str;
200201
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttHWSP;
201-
stream->addComment(str.str().c_str());
202+
getAubStream()->addComment(str.str().c_str());
202203
}
203204

204205
AubGTTData data = {0};
@@ -228,7 +229,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex)
228229
{
229230
std::ostringstream str;
230231
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttRingBuffer;
231-
stream->addComment(str.str().c_str());
232+
getAubStream()->addComment(str.str().c_str());
232233
}
233234

234235
AubGTTData data = {0};
@@ -256,7 +257,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex)
256257
{
257258
std::ostringstream str;
258259
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttLRCA;
259-
stream->addComment(str.str().c_str());
260+
getAubStream()->addComment(str.str().c_str());
260261
}
261262

262263
AubGTTData data = {0};
@@ -315,7 +316,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
315316
}
316317
}
317318

318-
auto streamLocked = stream->lockStream();
319+
auto streamLocked = getAubStream()->lockStream();
319320
auto engineIndex = getEngineIndex(engineType);
320321
auto engineInstance = allEngineInstances[engineIndex];
321322
engineType = engineInstance.type;
@@ -349,7 +350,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
349350
{
350351
std::ostringstream str;
351352
str << "ppgtt: " << std::hex << std::showbase << pBatchBuffer;
352-
stream->addComment(str.str().c_str());
353+
getAubStream()->addComment(str.str().c_str());
353354
}
354355

355356
auto physBatchBuffer = ppgtt->map(static_cast<uintptr_t>(batchBufferGpuAddress), sizeBatchBuffer,
@@ -455,7 +456,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
455456
{
456457
std::ostringstream str;
457458
str << "ggtt: " << std::hex << std::showbase << ggttDumpStart;
458-
stream->addComment(str.str().c_str());
459+
getAubStream()->addComment(str.str().c_str());
459460
}
460461

461462
auto physDumpStart = ggtt->map(ggttDumpStart, dumpLength, this->getGTTBits(), getMemoryBankForGtt());
@@ -471,7 +472,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
471472
{
472473
std::ostringstream str;
473474
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttLRCA + 0x101c;
474-
stream->addComment(str.str().c_str());
475+
getAubStream()->addComment(str.str().c_str());
475476
}
476477

477478
auto physLRCA = ggtt->map(engineInfo.ggttLRCA, sizeof(engineInfo.tailRingBuffer), this->getGTTBits(), getMemoryBankForGtt());
@@ -513,7 +514,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
513514
subCaptureManager->disableSubCapture();
514515
}
515516

516-
stream->flush();
517+
getAubStream()->flush();
517518
return 0;
518519
}
519520

@@ -542,7 +543,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::addPatchInfoComments() {
542543
ppgtt->map(static_cast<uintptr_t>(patchInfoData.targetAllocation), 1, 0, MemoryBanks::MainBank)));
543544
}
544545
}
545-
bool result = stream->addComment(str.str().c_str());
546+
bool result = getAubStream()->addComment(str.str().c_str());
546547
this->flatBatchBufferHelper->getPatchInfoCollection().clear();
547548
if (!result) {
548549
return false;
@@ -553,7 +554,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::addPatchInfoComments() {
553554
for (auto &element : allocationsMap) {
554555
allocationStr << std::hex << element.first << ";" << element.second << std::endl;
555556
}
556-
result = stream->addComment(allocationStr.str().c_str());
557+
result = getAubStream()->addComment(allocationStr.str().c_str());
557558
if (!result) {
558559
return false;
559560
}
@@ -575,7 +576,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::pollForCompletion(EngineInstanceT en
575576

576577
auto mmioBase = getCsTraits(engineInstance).mmioBase;
577578
bool pollNotEqual = false;
578-
this->stream->registerPoll(
579+
stream->registerPoll(
579580
mmioBase + 0x2234, //EXECLIST_STATUS
580581
0x100,
581582
0x100,
@@ -613,7 +614,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
613614
{
614615
std::ostringstream str;
615616
str << "ppgtt: " << std::hex << std::showbase << gpuAddress << " end address: " << gpuAddress + size << " cpu address: " << cpuAddress << " device mask: " << gfxAllocation.devicesBitfield << " size: " << std::dec << size;
616-
stream->addComment(str.str().c_str());
617+
getAubStream()->addComment(str.str().c_str());
617618
}
618619

619620
if (cpuAddress == nullptr) {
@@ -664,18 +665,18 @@ void AUBCommandStreamReceiverHw<GfxFamily>::expectMMIO(uint32_t mmioRegister, ui
664665
header.readMaskHigh = 0xffffffff;
665666
header.dwordCount = (sizeof(header) / sizeof(uint32_t)) - 1;
666667

667-
this->stream->fileHandle.write(reinterpret_cast<char *>(&header), sizeof(header));
668+
this->getAubStream()->fileHandle.write(reinterpret_cast<char *>(&header), sizeof(header));
668669
}
669670

670671
template <typename GfxFamily>
671672
void AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(void *gfxAddress, const void *srcAddress, size_t length) {
672673
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset, uint64_t entryBits) {
673674
UNRECOVERABLE_IF(offset > length);
674675

675-
this->stream->expectMemory(physAddress,
676-
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(srcAddress) + offset),
677-
size,
678-
this->getAddressSpaceFromPTEBits(entryBits));
676+
this->getAubStream()->expectMemory(physAddress,
677+
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(srcAddress) + offset),
678+
size,
679+
this->getAddressSpaceFromPTEBits(entryBits));
679680
};
680681

681682
this->ppgtt->pageWalk(reinterpret_cast<uintptr_t>(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::BankNotSpecified);

runtime/command_stream/command_stream_receiver_simulated_common_hw.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include "runtime/memory_manager/memory_banks.h"
1111
#include "runtime/memory_manager/physical_address_allocator.h"
1212

13+
namespace AubMemDump {
14+
struct AubStream;
15+
}
16+
1317
namespace OCLRT {
1418
class GraphicsAllocation;
1519
template <typename GfxFamily>
@@ -20,6 +24,9 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
2024
uint64_t getGTTBits() const {
2125
return 0u;
2226
}
27+
void initAdditionalMMIO();
28+
29+
AubMemDump::AubStream *stream;
2330

2431
protected:
2532
PhysicalAddressAllocator *createPhysicalAddressAllocator();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (C) 2018 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.h"
9+
#include "runtime/os_interface/debug_settings_manager.h"
10+
namespace OCLRT {
11+
template <typename GfxFamily>
12+
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO() {
13+
auto newOffset = static_cast<uint32_t>(DebugManager.flags.AubDumpAddMmioRegister.get());
14+
if (newOffset > 0) {
15+
auto value = static_cast<uint32_t>(DebugManager.flags.AubDumpAddMmioRegisterValue.get());
16+
stream->writeMMIO(newOffset, value);
17+
}
18+
}
19+
} // namespace OCLRT

runtime/command_stream/tbx_command_stream_receiver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TbxStream : public AubMemDump::AubStream {
3838
void writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) override;
3939
void writeGTT(uint32_t gttOffset, uint64_t entry) override;
4040
void writePTE(uint64_t physAddress, uint64_t entry) override;
41-
void writeMMIO(uint32_t offset, uint32_t value) override;
41+
void writeMMIOImpl(uint32_t offset, uint32_t value) override;
4242
void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override;
4343
void readMemory(uint64_t physAddress, void *memory, size_t size);
4444
};

runtime/command_stream/tbx_command_stream_receiver_hw.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
namespace OCLRT {
1717

18+
class TbxStream;
19+
1820
class TbxMemoryManager : public OsAgnosticMemoryManager {
1921
public:
2022
TbxMemoryManager(bool enable64kbPages, bool enableLocalMemory, ExecutionEnvironment &executionEnvironment) : OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment) {}
@@ -30,6 +32,9 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
3032
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
3133

3234
public:
35+
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
36+
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
37+
3338
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override;
3439
void makeCoherent(GraphicsAllocation &gfxAllocation) override;
3540

@@ -73,7 +78,8 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
7378
void getGTTData(void *memory, AubGTTData &data);
7479
uint32_t getMemoryBankForGtt() const;
7580

76-
TbxCommandStreamReceiver::TbxStream stream;
81+
TbxStream tbxStream;
82+
7783
uint32_t aubDeviceId;
7884
bool streamInitialized = false;
7985

0 commit comments

Comments
 (0)