Add AUB registry key to override MMIO offset value

Change-Id: Iac3bf9074e544a03e38fc437d7b21ea478d9cc5d
This commit is contained in:
Zdanowicz, Zbigniew
2018-11-01 22:28:20 -07:00
committed by sys_ocldev
parent 08676826c6
commit ce75767ca3
23 changed files with 206 additions and 81 deletions

View File

@ -8,6 +8,7 @@
#include "aub_mem_dump.h"
#include "runtime/helpers/ptr_math.h"
#include "runtime/helpers/debug_helpers.h"
#include "runtime/os_interface/debug_settings_manager.h"
namespace AubMemDump {
@ -173,4 +174,15 @@ void LrcaHelper::initialize(void *pLRCIn) const {
setPDP2(pLRCIn, 0);
setPDP3(pLRCIn, 0);
}
void AubStream::writeMMIO(uint32_t offset, uint32_t value) {
auto dbgOffset = OCLRT::DebugManager.flags.AubDumpOverrideMmioRegister.get();
if (dbgOffset > 0) {
if (offset == static_cast<uint32_t>(dbgOffset)) {
offset = static_cast<uint32_t>(dbgOffset);
value = static_cast<uint32_t>(OCLRT::DebugManager.flags.AubDumpOverrideMmioRegisterValue.get());
}
}
writeMMIOImpl(offset, value);
}
} // namespace AubMemDump

View File

@ -106,9 +106,12 @@ struct AubStream {
}
virtual void writePTE(uint64_t physAddress, uint64_t entry) = 0;
virtual void writeGTT(uint32_t offset, uint64_t entry) = 0;
virtual void writeMMIO(uint32_t offset, uint32_t value) = 0;
void writeMMIO(uint32_t offset, uint32_t value);
virtual void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) = 0;
virtual ~AubStream() = default;
protected:
virtual void writeMMIOImpl(uint32_t offset, uint32_t value) = 0;
};
struct AubFileStream : public AubStream {
@ -120,7 +123,7 @@ struct AubFileStream : public AubStream {
void writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) override;
void writePTE(uint64_t physAddress, uint64_t entry) override;
void writeGTT(uint32_t offset, uint64_t entry) override;
void writeMMIO(uint32_t offset, uint32_t value) override;
void writeMMIOImpl(uint32_t offset, uint32_t value) override;
void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override;
bool isOpen() const { return fileHandle.is_open(); }
const std::string &getFileName() const { return fileName; }

View File

@ -26,6 +26,7 @@ set(RUNTIME_SRCS_COMMAND_STREAM
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/command_stream_receiver_simulated_hw.h
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/engine_node.h
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_simulated_common_hw.h
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_simulated_common_hw.inl
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream.h
${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.h

View File

@ -144,7 +144,7 @@ void AubFileStream::writePTE(uint64_t physAddress, uint64_t entry) {
write(reinterpret_cast<char *>(&entry), sizeof(entry));
}
void AubFileStream::writeMMIO(uint32_t offset, uint32_t value) {
void AubFileStream::writeMMIOImpl(uint32_t offset, uint32_t value) {
CmdServicesMemTraceRegisterWrite header = {};
header.setHeader();
header.dwordCount = (sizeof(header) / sizeof(uint32_t)) - 1;

View File

@ -28,6 +28,9 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
using ExternalAllocationsContainer = std::vector<AllocationView>;
public:
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override;
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
@ -36,6 +39,10 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
void makeResidentExternal(AllocationView &allocationView);
void makeNonResidentExternal(uint64_t gpuAddress);
AubMemDump::AubFileStream *getAubStream() const {
return static_cast<AubMemDump::AubFileStream *>(this->stream);
}
MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation);
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue);
@ -90,7 +97,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
} engineInfoTable[arrayCount(allEngineInstances)] = {};
size_t gpgpuEngineIndex = arrayCount(gpgpuEngineInstances) - 1;
AUBCommandStreamReceiver::AubFileStream *stream;
std::unique_ptr<AubSubCaptureManager> subCaptureManager;
uint32_t aubDeviceId;
bool standalone;

View File

@ -125,13 +125,13 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initEngineMMIO(EngineInstanceT engin
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::openFile(const std::string &fileName) {
auto streamLocked = stream->lockStream();
auto streamLocked = getAubStream()->lockStream();
initFile(fileName);
}
template <typename GfxFamily>
bool AUBCommandStreamReceiverHw<GfxFamily>::reopenFile(const std::string &fileName) {
auto streamLocked = stream->lockStream();
auto streamLocked = getAubStream()->lockStream();
if (isFileOpen()) {
if (fileName != getFileName()) {
closeFile();
@ -147,11 +147,11 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::reopenFile(const std::string &fileNa
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::initFile(const std::string &fileName) {
if (!stream->isOpen()) {
if (!getAubStream()->isOpen()) {
// Open our file
stream->open(fileName.c_str());
if (!stream->isOpen()) {
if (!getAubStream()->isOpen()) {
// This DEBUG_BREAK_IF most probably means you are not executing aub tests with correct current directory (containing aub_out folder)
// try adding <familycodename>_aub
DEBUG_BREAK_IF(true);
@ -168,12 +168,12 @@ void AUBCommandStreamReceiverHw<GfxFamily>::closeFile() {
template <typename GfxFamily>
bool AUBCommandStreamReceiverHw<GfxFamily>::isFileOpen() const {
return stream->isOpen();
return getAubStream()->isOpen();
}
template <typename GfxFamily>
const std::string &AUBCommandStreamReceiverHw<GfxFamily>::getFileName() {
return stream->getFileName();
return getAubStream()->getFileName();
}
template <typename GfxFamily>
@ -184,6 +184,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex)
initGlobalMMIO();
initEngineMMIO(engineInstance);
this->initAdditionalMMIO();
// Global HW Status Page
{
@ -198,7 +199,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex)
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttHWSP;
stream->addComment(str.str().c_str());
getAubStream()->addComment(str.str().c_str());
}
AubGTTData data = {0};
@ -228,7 +229,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex)
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttRingBuffer;
stream->addComment(str.str().c_str());
getAubStream()->addComment(str.str().c_str());
}
AubGTTData data = {0};
@ -256,7 +257,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex)
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttLRCA;
stream->addComment(str.str().c_str());
getAubStream()->addComment(str.str().c_str());
}
AubGTTData data = {0};
@ -315,7 +316,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
}
}
auto streamLocked = stream->lockStream();
auto streamLocked = getAubStream()->lockStream();
auto engineIndex = getEngineIndex(engineType);
auto engineInstance = allEngineInstances[engineIndex];
engineType = engineInstance.type;
@ -349,7 +350,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
{
std::ostringstream str;
str << "ppgtt: " << std::hex << std::showbase << pBatchBuffer;
stream->addComment(str.str().c_str());
getAubStream()->addComment(str.str().c_str());
}
auto physBatchBuffer = ppgtt->map(static_cast<uintptr_t>(batchBufferGpuAddress), sizeBatchBuffer,
@ -455,7 +456,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << ggttDumpStart;
stream->addComment(str.str().c_str());
getAubStream()->addComment(str.str().c_str());
}
auto physDumpStart = ggtt->map(ggttDumpStart, dumpLength, this->getGTTBits(), getMemoryBankForGtt());
@ -471,7 +472,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttLRCA + 0x101c;
stream->addComment(str.str().c_str());
getAubStream()->addComment(str.str().c_str());
}
auto physLRCA = ggtt->map(engineInfo.ggttLRCA, sizeof(engineInfo.tailRingBuffer), this->getGTTBits(), getMemoryBankForGtt());
@ -513,7 +514,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
subCaptureManager->disableSubCapture();
}
stream->flush();
getAubStream()->flush();
return 0;
}
@ -542,7 +543,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::addPatchInfoComments() {
ppgtt->map(static_cast<uintptr_t>(patchInfoData.targetAllocation), 1, 0, MemoryBanks::MainBank)));
}
}
bool result = stream->addComment(str.str().c_str());
bool result = getAubStream()->addComment(str.str().c_str());
this->flatBatchBufferHelper->getPatchInfoCollection().clear();
if (!result) {
return false;
@ -553,7 +554,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::addPatchInfoComments() {
for (auto &element : allocationsMap) {
allocationStr << std::hex << element.first << ";" << element.second << std::endl;
}
result = stream->addComment(allocationStr.str().c_str());
result = getAubStream()->addComment(allocationStr.str().c_str());
if (!result) {
return false;
}
@ -575,7 +576,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::pollForCompletion(EngineInstanceT en
auto mmioBase = getCsTraits(engineInstance).mmioBase;
bool pollNotEqual = false;
this->stream->registerPoll(
stream->registerPoll(
mmioBase + 0x2234, //EXECLIST_STATUS
0x100,
0x100,
@ -613,7 +614,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
{
std::ostringstream str;
str << "ppgtt: " << std::hex << std::showbase << gpuAddress << " end address: " << gpuAddress + size << " cpu address: " << cpuAddress << " device mask: " << gfxAllocation.devicesBitfield << " size: " << std::dec << size;
stream->addComment(str.str().c_str());
getAubStream()->addComment(str.str().c_str());
}
if (cpuAddress == nullptr) {
@ -664,7 +665,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::expectMMIO(uint32_t mmioRegister, ui
header.readMaskHigh = 0xffffffff;
header.dwordCount = (sizeof(header) / sizeof(uint32_t)) - 1;
this->stream->fileHandle.write(reinterpret_cast<char *>(&header), sizeof(header));
this->getAubStream()->fileHandle.write(reinterpret_cast<char *>(&header), sizeof(header));
}
template <typename GfxFamily>
@ -672,10 +673,10 @@ void AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(void *gfxAddress, const
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset, uint64_t entryBits) {
UNRECOVERABLE_IF(offset > length);
this->stream->expectMemory(physAddress,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(srcAddress) + offset),
size,
this->getAddressSpaceFromPTEBits(entryBits));
this->getAubStream()->expectMemory(physAddress,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(srcAddress) + offset),
size,
this->getAddressSpaceFromPTEBits(entryBits));
};
this->ppgtt->pageWalk(reinterpret_cast<uintptr_t>(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::BankNotSpecified);

View File

@ -10,6 +10,10 @@
#include "runtime/memory_manager/memory_banks.h"
#include "runtime/memory_manager/physical_address_allocator.h"
namespace AubMemDump {
struct AubStream;
}
namespace OCLRT {
class GraphicsAllocation;
template <typename GfxFamily>
@ -20,6 +24,9 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
uint64_t getGTTBits() const {
return 0u;
}
void initAdditionalMMIO();
AubMemDump::AubStream *stream;
protected:
PhysicalAddressAllocator *createPhysicalAddressAllocator();

View File

@ -0,0 +1,19 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.h"
#include "runtime/os_interface/debug_settings_manager.h"
namespace OCLRT {
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO() {
auto newOffset = static_cast<uint32_t>(DebugManager.flags.AubDumpAddMmioRegister.get());
if (newOffset > 0) {
auto value = static_cast<uint32_t>(DebugManager.flags.AubDumpAddMmioRegisterValue.get());
stream->writeMMIO(newOffset, value);
}
}
} // namespace OCLRT

View File

@ -38,7 +38,7 @@ class TbxStream : public AubMemDump::AubStream {
void writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) override;
void writeGTT(uint32_t gttOffset, uint64_t entry) override;
void writePTE(uint64_t physAddress, uint64_t entry) override;
void writeMMIO(uint32_t offset, uint32_t value) override;
void writeMMIOImpl(uint32_t offset, uint32_t value) override;
void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override;
void readMemory(uint64_t physAddress, void *memory, size_t size);
};

View File

@ -15,6 +15,8 @@
namespace OCLRT {
class TbxStream;
class TbxMemoryManager : public OsAgnosticMemoryManager {
public:
TbxMemoryManager(bool enable64kbPages, bool enableLocalMemory, ExecutionEnvironment &executionEnvironment) : OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment) {}
@ -30,6 +32,9 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
public:
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override;
void makeCoherent(GraphicsAllocation &gfxAllocation) override;
@ -73,7 +78,8 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
void getGTTData(void *memory, AubGTTData &data);
uint32_t getMemoryBankForGtt() const;
TbxCommandStreamReceiver::TbxStream stream;
TbxStream tbxStream;
uint32_t aubDeviceId;
bool streamInitialized = false;

View File

@ -45,12 +45,13 @@ TbxCommandStreamReceiverHw<GfxFamily>::TbxCommandStreamReceiverHw(const Hardware
this->aubDeviceId = debugDeviceId == -1
? hwInfoIn.capabilityTable.aubDeviceId
: static_cast<uint32_t>(debugDeviceId);
this->stream = &tbxStream;
}
template <typename GfxFamily>
TbxCommandStreamReceiverHw<GfxFamily>::~TbxCommandStreamReceiverHw() {
if (streamInitialized) {
stream.close();
tbxStream.close();
}
for (auto &engineInfo : engineInfoTable) {
@ -76,7 +77,7 @@ const AubMemDump::LrcaHelper &TbxCommandStreamReceiverHw<GfxFamily>::getCsTraits
template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::initGlobalMMIO() {
for (auto &mmioPair : AUBFamilyMapper<GfxFamily>::globalMMIO) {
stream.writeMMIO(mmioPair.first, mmioPair.second);
tbxStream.writeMMIO(mmioPair.first, mmioPair.second);
}
}
@ -86,7 +87,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initEngineMMIO(EngineType engineType
DEBUG_BREAK_IF(!mmioList);
for (auto &mmioPair : *mmioList) {
stream.writeMMIO(mmioPair.first, mmioPair.second);
tbxStream.writeMMIO(mmioPair.first, mmioPair.second);
}
}
@ -97,6 +98,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineTy
initGlobalMMIO();
initEngineMMIO(engineType);
this->initAdditionalMMIO();
// Global HW Status Page
{
@ -109,8 +111,8 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineTy
// Write our GHWSP
AubGTTData data = {0};
getGTTData(reinterpret_cast<void *>(physHWSP), data);
AUB::reserveAddressGGTT(stream, engineInfo.ggttHWSP, sizeHWSP, physHWSP, data);
stream.writeMMIO(mmioBase + 0x2080, engineInfo.ggttHWSP);
AUB::reserveAddressGGTT(tbxStream, engineInfo.ggttHWSP, sizeHWSP, physHWSP, data);
tbxStream.writeMMIO(mmioBase + 0x2080, engineInfo.ggttHWSP);
}
// Allocate the LRCA
@ -133,7 +135,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineTy
AubGTTData data = {0};
getGTTData(reinterpret_cast<void *>(physRCS), data);
AUB::reserveAddressGGTT(stream, engineInfo.ggttRCS, engineInfo.sizeRCS, physRCS, data);
AUB::reserveAddressGGTT(tbxStream, engineInfo.ggttRCS, engineInfo.sizeRCS, physRCS, data);
}
// Initialize the ring MMIO registers
@ -155,9 +157,9 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineTy
AubGTTData data = {0};
getGTTData(reinterpret_cast<void *>(lrcAddressPhys), data);
AUB::reserveAddressGGTT(stream, engineInfo.ggttLRCA, sizeLRCA, lrcAddressPhys, data);
AUB::reserveAddressGGTT(tbxStream, engineInfo.ggttLRCA, sizeLRCA, lrcAddressPhys, data);
AUB::addMemoryWrite(
stream,
tbxStream,
lrcAddressPhys,
pLRCABase,
sizeLRCA,
@ -176,10 +178,10 @@ CommandStreamReceiver *TbxCommandStreamReceiverHw<GfxFamily>::create(const Hardw
}
// Open our stream
csr->stream.open(nullptr);
csr->stream->open(nullptr);
// Add the file header.
bool streamInitialized = csr->stream.init(AubMemDump::SteppingValues::A, csr->aubDeviceId);
bool streamInitialized = csr->stream->init(AubMemDump::SteppingValues::A, csr->aubDeviceId);
csr->streamInitialized = streamInitialized;
return csr;
@ -206,12 +208,12 @@ FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
this->getMemoryBank(batchBuffer.commandBufferAllocation));
AubHelperHw<GfxFamily> aubHelperHw(this->localMemoryEnabled);
AUB::reserveAddressPPGTT(stream, reinterpret_cast<uintptr_t>(pBatchBuffer), sizeBatchBuffer, physBatchBuffer,
AUB::reserveAddressPPGTT(tbxStream, reinterpret_cast<uintptr_t>(pBatchBuffer), sizeBatchBuffer, physBatchBuffer,
getPPGTTAdditionalBits(batchBuffer.commandBufferAllocation),
aubHelperHw);
AUB::addMemoryWrite(
stream,
tbxStream,
physBatchBuffer,
pBatchBuffer,
sizeBatchBuffer,
@ -243,7 +245,7 @@ FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
// write remaining ring
auto physDumpStart = ggtt->map(ggttTail, sizeToWrap, this->getGTTBits(), getMemoryBankForGtt());
AUB::addMemoryWrite(
stream,
tbxStream,
physDumpStart,
pTail,
sizeToWrap,
@ -283,7 +285,7 @@ FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
// write RCS
auto physDumpStart = ggtt->map(ggttDumpStart, dumpLength, this->getGTTBits(), getMemoryBankForGtt());
AUB::addMemoryWrite(
stream,
tbxStream,
physDumpStart,
dumpStart,
dumpLength,
@ -293,7 +295,7 @@ FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
// update the RCS mmio tail in the LRCA
auto physLRCA = ggtt->map(engineInfo.ggttLRCA, sizeof(engineInfo.tailRCS), this->getGTTBits(), getMemoryBankForGtt());
AUB::addMemoryWrite(
stream,
tbxStream,
physLRCA + 0x101c,
&engineInfo.tailRCS,
sizeof(engineInfo.tailRCS),
@ -328,10 +330,10 @@ FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::submitLRCA(EngineType engineType, const MiContextDescriptorReg &contextDescriptor) {
auto mmioBase = getCsTraits(engineType).mmioBase;
stream.writeMMIO(mmioBase + 0x2230, 0);
stream.writeMMIO(mmioBase + 0x2230, 0);
stream.writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[1]);
stream.writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[0]);
tbxStream.writeMMIO(mmioBase + 0x2230, 0);
tbxStream.writeMMIO(mmioBase + 0x2230, 0);
tbxStream.writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[1]);
tbxStream.writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[0]);
}
template <typename GfxFamily>
@ -340,7 +342,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::pollForCompletion(EngineType engineT
auto mmioBase = getCsTraits(engineType).mmioBase;
bool pollNotEqual = false;
stream.registerPoll(
tbxStream.registerPoll(
mmioBase + 0x2234, //EXECLIST_STATUS
0x100,
0x100,
@ -360,7 +362,7 @@ bool TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
AubHelperHw<GfxFamily> aubHelperHw(this->localMemoryEnabled);
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset, uint64_t entryBits) {
AUB::reserveAddressGGTTAndWriteMmeory(stream, static_cast<uintptr_t>(gpuAddress), cpuAddress, physAddress, size, offset, getPPGTTAdditionalBits(&gfxAllocation),
AUB::reserveAddressGGTTAndWriteMmeory(tbxStream, static_cast<uintptr_t>(gpuAddress), cpuAddress, physAddress, size, offset, getPPGTTAdditionalBits(&gfxAllocation),
aubHelperHw);
};
@ -387,7 +389,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::makeCoherent(GraphicsAllocation &gfx
if (length) {
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset, uint64_t entryBits) {
DEBUG_BREAK_IF(offset > length);
stream.readMemory(physAddress, ptrOffset(cpuAddress, offset), size);
tbxStream.readMemory(physAddress, ptrOffset(cpuAddress, offset), size);
};
ppgtt->pageWalk(static_cast<uintptr_t>(gpuAddress), length, 0, 0, walker, this->getMemoryBank(&gfxAllocation));
}

View File

@ -1,23 +1,8 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (C) 2017-2018 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* SPDX-License-Identifier: MIT
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/command_stream/tbx_command_stream_receiver.h"
@ -65,7 +50,7 @@ void TbxStream::writePTE(uint64_t physAddress, uint64_t entry) {
void TbxStream::writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) {
}
void TbxStream::writeMMIO(uint32_t offset, uint32_t value) {
void TbxStream::writeMMIOImpl(uint32_t offset, uint32_t value) {
socket->writeMMIO(offset, value);
}

View File

@ -7,6 +7,7 @@
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
#include "runtime/command_stream/aub_command_stream_receiver_hw.inl"
#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl"
#include "runtime/helpers/base_object.h"
#include "runtime/helpers/array_count.h"

View File

@ -7,6 +7,7 @@
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
#include "runtime/command_stream/aub_command_stream_receiver_hw.inl"
#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl"
#include "runtime/helpers/base_object.h"
#include "runtime/helpers/array_count.h"

View File

@ -7,6 +7,7 @@
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
#include "runtime/command_stream/aub_command_stream_receiver_hw.inl"
#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl"
#include "runtime/helpers/base_object.h"
#include "runtime/helpers/array_count.h"

View File

@ -19,6 +19,10 @@ DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpSubCaptureMode, 0, "AUB dump subcapture m
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterKernelStartIdx, 0, "Start index of kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterKernelEndIdx, -1, "End index of kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpToggleCaptureOnOff, 0, "Toggle AUB capture on/off")
DECLARE_DEBUG_VARIABLE(int32_t, AubDumpOverrideMmioRegister, 0, "Override mmio offset from list with new value from AubDumpOverrideMmioRegisterValue")
DECLARE_DEBUG_VARIABLE(int32_t, AubDumpOverrideMmioRegisterValue, 0, "Value to override mmio offset from AubDumpOverrideMmioRegister")
DECLARE_DEBUG_VARIABLE(int32_t, AubDumpAddMmioRegister, 0, "Program mmio offset that is not on default mmio list wtih value AubDumpAddMmioRegisterValue")
DECLARE_DEBUG_VARIABLE(int32_t, AubDumpAddMmioRegisterValue, 0, "Value to add new mmio offset from AubDumpAddMmioRegister")
DECLARE_DEBUG_VARIABLE(int32_t, SetCommandStreamReceiver, 0, "Set command stream receiver to: 0 - HW, 1 - AUB, 2 - TBX, 3 - HW & AUB, 4 - TBX & AUB")
DECLARE_DEBUG_VARIABLE(int32_t, TbxPort, 4321, "TCP-IP port of TBX server")
DECLARE_DEBUG_VARIABLE(bool, FlattenBatchBufferForAUBDump, false, "Dump multi-level batch buffers to AUB as single, flat batch buffer")
@ -105,6 +109,6 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForcePreemptionMode, -1, "Keep this variable in
DECLARE_DEBUG_VARIABLE(int32_t, NodeOrdinal, -1, "-1: default do not override, 0: ENGINE_RCS")
DECLARE_DEBUG_VARIABLE(int32_t, OverrideThreadArbitrationPolicy, -1, "-1 (dont override) or any valid config (0: Age Based, 1: Round Robin)")
DECLARE_DEBUG_VARIABLE(int32_t, OverrideAubDeviceId, -1, "-1 dont override, any other: use this value for AUB generation device id")
DECLARE_DEBUG_VARIABLE(bool, UseMaxSimdSizeToDeduceMaxWorkgroupSize, false, "With this flag on, max workgroup size is deduced using SIMD32 instead of SIMD8, this causes the max wkg size to be 4 times bigger")
DECLARE_DEBUG_VARIABLE(int32_t, EnableTimestampPacket, -1, "-1: default, 0: disable, 1:enable. Write Timestamp Packet for each set of gpu walkers")
DECLARE_DEBUG_VARIABLE(bool, UseMaxSimdSizeToDeduceMaxWorkgroupSize, false, "With this flag on, max workgroup size is deduced using SIMD32 instead of SIMD8, this causes the max wkg size to be 4 times bigger")
DECLARE_DEBUG_VARIABLE(bool, ReturnRawGpuTimestamps, false, "Driver returns raw GPU tiemstamps instead of calculated ones.")

View File

@ -49,7 +49,7 @@ class AUBCommandStreamFixture : public CommandStreamFixture {
// Write our pseudo-op to the AUB file
auto aubCsr = reinterpret_cast<AUBCommandStreamReceiverHw<FamilyType> *>(csr);
aubCsr->stream->fileHandle.write(reinterpret_cast<char *>(&header), sizeof(header));
aubCsr->getAubStream()->fileHandle.write(reinterpret_cast<char *>(&header), sizeof(header));
}
template <typename FamilyType>
@ -64,10 +64,10 @@ class AUBCommandStreamFixture : public CommandStreamFixture {
if (offset > length)
abort();
aubCsr->stream->expectMemory(physAddress,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(srcAddress) + offset),
size,
aubCsr->getAddressSpaceFromPTEBits(entryBits));
aubCsr->getAubStream()->expectMemory(physAddress,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(srcAddress) + offset),
size,
aubCsr->getAddressSpaceFromPTEBits(entryBits));
};
aubCsr->ppgtt->pageWalk(reinterpret_cast<uintptr_t>(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::BankNotSpecified);

View File

@ -9,6 +9,8 @@
#include "runtime/aub/aub_helper.h"
#include "runtime/helpers/hw_helper.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/mocks/mock_aub_csr.h"
using OCLRT::AUBCommandStreamReceiver;
using OCLRT::AUBCommandStreamReceiverHw;
@ -193,3 +195,39 @@ HWTEST_F(AubMemDumpTests, simpleVCS) {
HWTEST_F(AubMemDumpTests, simpleVECS) {
setupAUB<FamilyType>(pDevice, EngineType::ENGINE_VECS);
}
TEST(AubMemDumpBasic, givenDebugOverrideMmioWhenMmioNotMatchThenDoNotAlterValue) {
DebugManagerStateRestore dbgRestore;
uint32_t dbgOffset = 0x1000;
uint32_t dbgValue = 0xDEAD;
DebugManager.flags.AubDumpOverrideMmioRegister.set(static_cast<int32_t>(dbgOffset));
DebugManager.flags.AubDumpOverrideMmioRegisterValue.set(static_cast<int32_t>(dbgValue));
uint32_t offset = 0x2000;
uint32_t value = 0x3000;
MMIOPair mmio = std::make_pair(offset, value);
MockAubFileStreamMockMmioWrite mockAubStream;
mockAubStream.writeMMIO(offset, value);
EXPECT_EQ(1u, mockAubStream.mmioList.size());
EXPECT_TRUE(mockAubStream.isOnMmioList(mmio));
}
TEST(AubMemDumpBasic, givenDebugOverrideMmioWhenMmioMatchThenAlterValue) {
DebugManagerStateRestore dbgRestore;
uint32_t dbgOffset = 0x2000;
uint32_t dbgValue = 0xDEAD;
MMIOPair dbgMmio = std::make_pair(dbgOffset, dbgValue);
DebugManager.flags.AubDumpOverrideMmioRegister.set(static_cast<int32_t>(dbgOffset));
DebugManager.flags.AubDumpOverrideMmioRegisterValue.set(static_cast<int32_t>(dbgValue));
uint32_t offset = 0x2000;
uint32_t value = 0x3000;
MockAubFileStreamMockMmioWrite mockAubStream;
mockAubStream.writeMMIO(offset, value);
EXPECT_EQ(1u, mockAubStream.mmioList.size());
EXPECT_TRUE(mockAubStream.isOnMmioList(dbgMmio));
}

View File

@ -72,10 +72,10 @@ class AUBFixture : public CommandQueueHwFixture {
if (offset > length)
abort();
aubCsr->stream->expectMemory(physAddress,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(srcAddress) + offset),
size,
aubCsr->getAddressSpaceFromPTEBits(entryBits));
aubCsr->getAubStream()->expectMemory(physAddress,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(srcAddress) + offset),
size,
aubCsr->getAddressSpaceFromPTEBits(entryBits));
};
aubCsr->ppgtt->pageWalk(reinterpret_cast<uintptr_t>(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::BankNotSpecified);

View File

@ -1686,3 +1686,37 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenEngineI
aubCsr->initializeEngine(engineIndex);
EXPECT_NE(0u, aubCsr->handle);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAddMmioKeySetToZeroWhenInitAdditionalMmioCalledThenDoNotWriteMmio) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.AubDumpAddMmioRegister.set(0);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
aubCsr->stream = stream.get();
EXPECT_EQ(0u, stream->mmioList.size());
aubCsr->initAdditionalMMIO();
EXPECT_EQ(0u, stream->mmioList.size());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAddMmioKeySetToNonZeroWhenInitAdditionalMmioCalledThenWriteGivenMmio) {
uint32_t offset = 0xdead;
uint32_t value = 0xbeef;
MMIOPair mmioPair(offset, value);
DebugManagerStateRestore stateRestore;
DebugManager.flags.AubDumpAddMmioRegister.set(offset);
DebugManager.flags.AubDumpAddMmioRegisterValue.set(value);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
aubCsr->stream = stream.get();
EXPECT_EQ(0u, stream->mmioList.size());
aubCsr->initAdditionalMMIO();
EXPECT_EQ(1u, stream->mmioList.size());
EXPECT_TRUE(stream->isOnMmioList(mmioPair));
};

View File

@ -182,7 +182,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMMIOIsCalled
aubCsr->expectMMIO(5, 10);
aubCsr->stream->fileHandle.flush();
aubCsr->getAubStream()->fileHandle.flush();
std::ifstream aubFile(fileName);
EXPECT_TRUE(aubFile.is_open());

View File

@ -21,7 +21,7 @@
namespace OCLRT {
struct MockAubFileStreamMockMmioWrite : public AubMemDump::AubFileStream {
void writeMMIO(uint32_t offset, uint32_t value) override {
void writeMMIOImpl(uint32_t offset, uint32_t value) override {
mmioList.push_back(std::make_pair(offset, value));
}
bool isOnMmioList(const MMIOPair &mmio) {

View File

@ -92,3 +92,7 @@ LimitAmountOfReturnedDevices = 0
UseMallocToObtainHeap32Base = false
EnableLocalMemory = false
UseAubStream = false
AubDumpOverrideMmioRegister = 0
AubDumpOverrideMmioRegisterValue = 0
AubDumpAddMmioRegister = 0
AubDumpAddMmioRegisterValue = 0