mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Use correct virtual addresses in TBX CSR makeCoherent method
- cpu virtual address was used instead of gpu va - this caused incorrect behaviour of TBX server when special heap allocator assigning GPU addresses was used Change-Id: I2328cf2441be797311fd6a3c7b331b0fff79d4fc
This commit is contained in:

committed by
sys_ocldev

parent
b56289a507
commit
4703417813
@ -142,7 +142,9 @@ volatile uint32_t *CommandQueue::getHwTagAddress() const {
|
||||
DEBUG_BREAK_IF(!this->device);
|
||||
auto &commandStreamReceiver = device->getCommandStreamReceiver();
|
||||
auto tag_address = commandStreamReceiver.getTagAddress();
|
||||
commandStreamReceiver.makeCoherent((void *)tag_address, sizeof(tag_address));
|
||||
auto allocation = commandStreamReceiver.getTagAllocation();
|
||||
UNRECOVERABLE_IF(allocation == nullptr);
|
||||
commandStreamReceiver.makeCoherent(*allocation);
|
||||
return tag_address;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ void CommandStreamReceiver::processEviction() {
|
||||
|
||||
void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
|
||||
if (gfxAllocation.residencyTaskCount != ObjectNotResident) {
|
||||
makeCoherent(gfxAllocation.getUnderlyingBuffer(), gfxAllocation.getUnderlyingBufferSize());
|
||||
makeCoherent(gfxAllocation);
|
||||
getMemoryManager()->pushAllocationForEviction(&gfxAllocation);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class CommandStreamReceiver {
|
||||
|
||||
virtual void flushBatchedSubmissions() = 0;
|
||||
|
||||
virtual void makeCoherent(void *address, size_t length){};
|
||||
virtual void makeCoherent(GraphicsAllocation &gfxAllocation){};
|
||||
virtual void makeResident(GraphicsAllocation &gfxAllocation);
|
||||
virtual void makeNonResident(GraphicsAllocation &gfxAllocation);
|
||||
void makeSurfacePackNonResident(ResidencyContainer *allocationsForResidency);
|
||||
@ -86,6 +86,9 @@ class CommandStreamReceiver {
|
||||
OSInterface *getOSInterface() { return osInterface.get(); };
|
||||
|
||||
MOCKABLE_VIRTUAL void setTagAllocation(GraphicsAllocation *allocation);
|
||||
GraphicsAllocation *getTagAllocation() const {
|
||||
return tagAllocation;
|
||||
}
|
||||
volatile uint32_t *getTagAddress() const { return tagAddress; }
|
||||
|
||||
virtual bool waitForFlushStamp(FlushStamp &flushStampToWait) { return true; };
|
||||
|
@ -46,7 +46,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
|
||||
|
||||
public:
|
||||
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer *allocationsForResidency) override;
|
||||
void makeCoherent(void *address, size_t length) override;
|
||||
void makeCoherent(GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
void processResidency(ResidencyContainer *allocationsForResidency) override;
|
||||
bool writeMemory(GraphicsAllocation &gfxAllocation);
|
||||
|
@ -361,14 +361,18 @@ void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void TbxCommandStreamReceiverHw<GfxFamily>::makeCoherent(void *address, size_t length) {
|
||||
void TbxCommandStreamReceiverHw<GfxFamily>::makeCoherent(GraphicsAllocation &gfxAllocation) {
|
||||
auto cpuAddress = gfxAllocation.getUnderlyingBuffer();
|
||||
auto gpuAddress = gfxAllocation.getGpuAddress();
|
||||
auto length = gfxAllocation.getUnderlyingBufferSize();
|
||||
|
||||
if (length) {
|
||||
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset) {
|
||||
DEBUG_BREAK_IF(offset > length);
|
||||
stream.readMemory(physAddress, ptrOffset(address, offset), size);
|
||||
stream.readMemory(physAddress, ptrOffset(cpuAddress, offset), size);
|
||||
};
|
||||
|
||||
ppgtt.pageWalk(reinterpret_cast<uintptr_t>(address), length, 0, walker);
|
||||
ppgtt.pageWalk(static_cast<uintptr_t>(gpuAddress), length, 0, walker);
|
||||
}
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
@ -257,3 +257,15 @@ HWTEST_F(CommandStreamReceiverTest, givenDefaultCommandStreamReceiverThenDefault
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
EXPECT_EQ(CommandStreamReceiver::DispatchMode::ImmediateDispatch, csr.dispatchMode);
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCSRWithoutTagAllocationWhenGetTagAllocationIsCalledThenNullptrIsReturned) {
|
||||
MockCommandStreamReceiver csr;
|
||||
EXPECT_EQ(nullptr, csr.getTagAllocation());
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCSRWithTagAllocationSetWhenGetTagAllocationIsCalledThenCorrectAllocationIsReturned) {
|
||||
MockCommandStreamReceiver csr;
|
||||
GraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
csr.setTagAllocation(&allocation);
|
||||
EXPECT_EQ(&allocation, csr.getTagAllocation());
|
||||
}
|
||||
|
Reference in New Issue
Block a user