mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
fix: Avoid mutex deadlock when switch ulls light ring buffer
Related-To: NEO-14406 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
dda7876d3a
commit
6cb52f71b4
@@ -420,7 +420,7 @@ bool DirectSubmissionHw<GfxFamily, Dispatcher>::allocateResources() {
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
bool DirectSubmissionHw<GfxFamily, Dispatcher>::makeResourcesResident(DirectSubmissionAllocations &allocations) {
|
||||
auto ret = memoryOperationHandler->makeResidentWithinOsContext(&this->osContext, ArrayRef<GraphicsAllocation *>(allocations), false, false) == MemoryOperationsStatus::success;
|
||||
auto ret = memoryOperationHandler->makeResidentWithinOsContext(&this->osContext, ArrayRef<GraphicsAllocation *>(allocations), false, false, true) == MemoryOperationsStatus::success;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1142,7 +1142,7 @@ inline GraphicsAllocation *DirectSubmissionHw<GfxFamily, Dispatcher>::switchRing
|
||||
nextAllocation = memoryManager->allocateGraphicsMemoryWithProperties(commandStreamAllocationProperties);
|
||||
this->currentRingBuffer = static_cast<uint32_t>(this->ringBuffers.size());
|
||||
this->ringBuffers.emplace_back(0ull, nextAllocation);
|
||||
auto ret = memoryOperationHandler->makeResidentWithinOsContext(&this->osContext, ArrayRef<GraphicsAllocation *>(&nextAllocation, 1u), false, false) == MemoryOperationsStatus::success;
|
||||
auto ret = memoryOperationHandler->makeResidentWithinOsContext(&this->osContext, ArrayRef<GraphicsAllocation *>(&nextAllocation, 1u), false, false, false) == MemoryOperationsStatus::success;
|
||||
UNRECOVERABLE_IF(!ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class MemoryOperationsHandler {
|
||||
virtual MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) = 0;
|
||||
virtual MemoryOperationsStatus free(Device *device, GraphicsAllocation &gfxAllocation) { return MemoryOperationsStatus::success; }
|
||||
|
||||
virtual MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) = 0;
|
||||
virtual MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) = 0;
|
||||
virtual MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) = 0;
|
||||
virtual void processFlushResidency(CommandStreamReceiver *csr) {}
|
||||
};
|
||||
|
||||
@@ -98,7 +98,7 @@ MemoryOperationsStatus AubMemoryOperationsHandler::free(Device *device, Graphics
|
||||
return MemoryOperationsStatus::success;
|
||||
}
|
||||
|
||||
MemoryOperationsStatus AubMemoryOperationsHandler::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) {
|
||||
MemoryOperationsStatus AubMemoryOperationsHandler::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) {
|
||||
return makeResident(nullptr, gfxAllocations, false, forcePagingFence);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class AubMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||
MemoryOperationsStatus free(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override;
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override;
|
||||
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
void processFlushResidency(CommandStreamReceiver *csr) override;
|
||||
|
||||
@@ -1535,7 +1535,7 @@ void *DrmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation)
|
||||
if (ioctlHelper->makeResidentBeforeLockNeeded()) {
|
||||
auto memoryOperationsInterface = static_cast<DrmMemoryOperationsHandler *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
auto graphicsAllocationPtr = &graphicsAllocation;
|
||||
[[maybe_unused]] auto ret = memoryOperationsInterface->makeResidentWithinOsContext(getDefaultOsContext(rootDeviceIndex), ArrayRef<NEO::GraphicsAllocation *>(&graphicsAllocationPtr, 1), false, false) == MemoryOperationsStatus::success;
|
||||
[[maybe_unused]] auto ret = memoryOperationsInterface->makeResidentWithinOsContext(getDefaultOsContext(rootDeviceIndex), ArrayRef<NEO::GraphicsAllocation *>(&graphicsAllocationPtr, 1), false, false, true) == MemoryOperationsStatus::success;
|
||||
DEBUG_BREAK_IF(!ret);
|
||||
}
|
||||
|
||||
@@ -1689,8 +1689,10 @@ bool DrmMemoryManager::makeAllocationResident(GraphicsAllocation *allocation) {
|
||||
auto memoryOperationsInterface = static_cast<DrmMemoryOperationsHandler *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
const auto &engines = this->getRegisteredEngines(rootDeviceIndex);
|
||||
for (const auto &engine : engines) {
|
||||
if (engine.osContext->isDirectSubmissionLightActive()) {
|
||||
memoryOperationsInterface->makeResidentWithinOsContext(engine.osContext, ArrayRef<NEO::GraphicsAllocation *>(&allocation, 1), false, false);
|
||||
if (engine.osContext->isDirectSubmissionLightActive() &&
|
||||
allocation->getAllocationType() != AllocationType::ringBuffer &&
|
||||
allocation->getAllocationType() != AllocationType::semaphoreBuffer) {
|
||||
memoryOperationsInterface->makeResidentWithinOsContext(engine.osContext, ArrayRef<NEO::GraphicsAllocation *>(&allocation, 1), false, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResident(Device *devi
|
||||
MemoryOperationsStatus result = MemoryOperationsStatus::success;
|
||||
for (const auto &engine : engines) {
|
||||
engine.commandStreamReceiver->initializeResources(false, device->getPreemptionMode());
|
||||
result = this->makeResidentWithinOsContext(engine.osContext, gfxAllocations, false, forcePagingFence);
|
||||
result = this->makeResidentWithinOsContext(engine.osContext, gfxAllocations, false, forcePagingFence, true);
|
||||
if (result != MemoryOperationsStatus::success) {
|
||||
break;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::lock(Device *device, Arra
|
||||
return makeResident(device, gfxAllocations, false, false);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) {
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) {
|
||||
auto deviceBitfield = osContext->getDeviceBitfield();
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
@@ -144,11 +144,11 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::mergeWithResidencyContain
|
||||
auto memoryManager = static_cast<DrmMemoryManager *>(this->rootDeviceEnvironment.executionEnvironment.memoryManager.get());
|
||||
|
||||
auto allocLock = memoryManager->acquireAllocLock();
|
||||
this->makeResidentWithinOsContext(osContext, ArrayRef<GraphicsAllocation *>(memoryManager->getSysMemAllocs()), true, false);
|
||||
this->makeResidentWithinOsContext(osContext, ArrayRef<GraphicsAllocation *>(memoryManager->getLocalMemAllocs(this->rootDeviceIndex)), true, false);
|
||||
this->makeResidentWithinOsContext(osContext, ArrayRef<GraphicsAllocation *>(memoryManager->getSysMemAllocs()), true, false, true);
|
||||
this->makeResidentWithinOsContext(osContext, ArrayRef<GraphicsAllocation *>(memoryManager->getLocalMemAllocs(this->rootDeviceIndex)), true, false, true);
|
||||
}
|
||||
|
||||
auto retVal = this->makeResidentWithinOsContext(osContext, ArrayRef<GraphicsAllocation *>(residencyContainer), true, false);
|
||||
auto retVal = this->makeResidentWithinOsContext(osContext, ArrayRef<GraphicsAllocation *>(residencyContainer), true, false, true);
|
||||
if (retVal != MemoryOperationsStatus::success) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class DrmMemoryOperationsHandlerBind : public DrmMemoryOperationsHandler {
|
||||
DrmMemoryOperationsHandlerBind(const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t rootDeviceIndex);
|
||||
~DrmMemoryOperationsHandlerBind() override;
|
||||
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override;
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override;
|
||||
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations, bool isDummyExecNeeded, const bool forcePagingFence) override;
|
||||
MemoryOperationsStatus lock(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
@@ -24,8 +25,12 @@ DrmMemoryOperationsHandlerDefault::DrmMemoryOperationsHandlerDefault(uint32_t ro
|
||||
;
|
||||
DrmMemoryOperationsHandlerDefault::~DrmMemoryOperationsHandlerDefault() = default;
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) {
|
||||
std::unique_lock<std::mutex> lock;
|
||||
if (acquireLock) {
|
||||
lock = std::unique_lock<std::mutex>(this->mutex);
|
||||
}
|
||||
|
||||
this->residency.insert(this->residency.end(), gfxAllocations.begin(), gfxAllocations.end());
|
||||
this->newResourcesSinceLastRingSubmit = true;
|
||||
return MemoryOperationsStatus::success;
|
||||
@@ -33,7 +38,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResidentWithinOsCo
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations, bool isDummyExecNeeded, const bool forcePagingFence) {
|
||||
OsContext *osContext = nullptr;
|
||||
auto ret = this->makeResidentWithinOsContext(osContext, gfxAllocations, false, forcePagingFence);
|
||||
auto ret = this->makeResidentWithinOsContext(osContext, gfxAllocations, false, forcePagingFence, true);
|
||||
if (!isDummyExecNeeded || ret != MemoryOperationsStatus::success) {
|
||||
return ret;
|
||||
}
|
||||
@@ -55,7 +60,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::lock(Device *device, A
|
||||
bo->requireExplicitLockedMemory(true);
|
||||
}
|
||||
}
|
||||
return this->makeResidentWithinOsContext(osContext, gfxAllocations, false, false);
|
||||
return this->makeResidentWithinOsContext(osContext, gfxAllocations, false, false, true);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) {
|
||||
|
||||
@@ -19,7 +19,7 @@ class DrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandler {
|
||||
DrmMemoryOperationsHandlerDefault(const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t rootDeviceIndex) : DrmMemoryOperationsHandlerDefault(rootDeviceIndex) {}
|
||||
~DrmMemoryOperationsHandlerDefault() override;
|
||||
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override;
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override;
|
||||
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations, bool isDummyExecNeeded, const bool forcePagingFence) override;
|
||||
MemoryOperationsStatus lock(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
@@ -61,9 +61,9 @@ class DrmMemoryOperationsHandlerWithAubDump : public BaseOperationsHandler {
|
||||
return BaseOperationsHandler::isResident(device, gfxAllocation);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override {
|
||||
aubMemoryOperationsHandler->makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence);
|
||||
return BaseOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence);
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override {
|
||||
aubMemoryOperationsHandler->makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence, acquireLock);
|
||||
return BaseOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence, acquireLock);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override {
|
||||
|
||||
@@ -30,7 +30,7 @@ class WddmMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||
MemoryOperationsStatus lock(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override {
|
||||
return MemoryOperationsStatus::unsupported;
|
||||
}
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override {
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override {
|
||||
return makeResident(nullptr, gfxAllocations, false, forcePagingFence);
|
||||
}
|
||||
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override {
|
||||
|
||||
@@ -56,9 +56,9 @@ class WddmMemoryOperationsHandlerWithAubDump : public BaseOperationsHandler {
|
||||
return BaseOperationsHandler::isResident(device, gfxAllocation);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override {
|
||||
aubMemoryOperationsHandler->makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence);
|
||||
return BaseOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence);
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override {
|
||||
aubMemoryOperationsHandler->makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence, acquireLock);
|
||||
return BaseOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence, acquireLock);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override {
|
||||
|
||||
@@ -36,9 +36,9 @@ struct MockAubMemoryOperationsHandler : public AubMemoryOperationsHandler {
|
||||
return AubMemoryOperationsHandler::isResident(device, gfxAllocation);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override {
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override {
|
||||
makeResidentWithinOsContextCalled = true;
|
||||
return AubMemoryOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence);
|
||||
return AubMemoryOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable, forcePagingFence, acquireLock);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override {
|
||||
|
||||
@@ -24,7 +24,7 @@ class MockMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||
MemoryOperationsStatus lock(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override { return MemoryOperationsStatus::unsupported; }
|
||||
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::unsupported; }
|
||||
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::unsupported; }
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override { return MemoryOperationsStatus::unsupported; }
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override { return MemoryOperationsStatus::unsupported; }
|
||||
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::unsupported; }
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ class MockMemoryOperationsHandlerTests : public MemoryOperationsHandler {
|
||||
ADDMETHOD_NOBASE(lock, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (Device * device, ArrayRef<GraphicsAllocation *> gfxAllocations));
|
||||
ADDMETHOD_NOBASE(evict, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (Device * device, GraphicsAllocation &gfxAllocation));
|
||||
ADDMETHOD_NOBASE(isResident, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (Device * device, GraphicsAllocation &gfxAllocation));
|
||||
ADDMETHOD_NOBASE(makeResidentWithinOsContext, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (OsContext * osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence));
|
||||
ADDMETHOD_NOBASE(makeResidentWithinOsContext, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (OsContext * osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock));
|
||||
ADDMETHOD_NOBASE(evictWithinOsContext, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (OsContext * osContext, GraphicsAllocation &gfxAllocation));
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ class MockMemoryOperations : public MemoryOperationsHandler {
|
||||
return MemoryOperationsStatus::success;
|
||||
}
|
||||
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override {
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override {
|
||||
makeResidentCalledCount++;
|
||||
if (osContext) {
|
||||
makeResidentContextId = osContext->getContextId();
|
||||
|
||||
@@ -1428,7 +1428,7 @@ struct MockMergeResidencyContainerMemoryOperationsHandler : public DrmMemoryOper
|
||||
(OsContext * osContext, ResidencyContainer &residencyContainer));
|
||||
|
||||
ADDMETHOD_NOBASE(makeResidentWithinOsContext, NEO::MemoryOperationsStatus, NEO::MemoryOperationsStatus::success,
|
||||
(OsContext * osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence));
|
||||
(OsContext * osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock));
|
||||
};
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMergeWithResidencyContainerFailsThenFlushReturnsError) {
|
||||
|
||||
@@ -309,17 +309,17 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenObjectAlwaysResidentAndNotUsedWh
|
||||
for (auto &engine : device->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateTaskCount(GraphicsAllocation::objectNotUsed, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
for (auto &engine : device->getSubDevice(0u)->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
for (auto &engine : device->getSubDevice(1u)->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateTaskCount(GraphicsAllocation::objectNotUsed, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
|
||||
EXPECT_EQ(mock->context.vmBindCalled, 2u);
|
||||
@@ -375,17 +375,17 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, whenEvictUnusedResourcesWithWaitFor
|
||||
for (auto &engine : device->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
for (auto &engine : device->getSubDevice(0u)->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
for (auto &engine : device->getSubDevice(1u)->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
*device->getSubDevice(1u)->getDefaultEngine().commandStreamReceiver->getTagAddress() = 5;
|
||||
|
||||
@@ -420,17 +420,17 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, whenRunningOutOfMemoryThenUnusedAlloc
|
||||
for (auto &engine : device->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
for (auto &engine : device->getSubDevice(0u)->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
for (auto &engine : device->getSubDevice(1u)->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 10;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
*device->getSubDevice(1u)->getDefaultEngine().commandStreamReceiver->getTagAddress() = 5;
|
||||
|
||||
@@ -450,17 +450,17 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenUsedAllocationInBothSubdevicesWh
|
||||
for (auto &engine : device->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 5;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
for (auto &engine : device->getSubDevice(0u)->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 5;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
for (auto &engine : device->getSubDevice(1u)->getAllEngines()) {
|
||||
*engine.commandStreamReceiver->getTagAddress() = 5;
|
||||
allocation->updateTaskCount(8u, engine.osContext->getContextId());
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(engine.osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
}
|
||||
|
||||
EXPECT_EQ(mock->context.vmBindCalled, 2u);
|
||||
@@ -478,7 +478,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenResidencyWithinOsContextFailsThe
|
||||
MockDrmMemoryOperationsHandlerBindResidencyFail(RootDeviceEnvironment &rootDeviceEnvironment, uint32_t rootDeviceIndex)
|
||||
: DrmMemoryOperationsHandlerBind(rootDeviceEnvironment, rootDeviceIndex) {}
|
||||
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence) override {
|
||||
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock) override {
|
||||
return NEO::MemoryOperationsStatus::failed;
|
||||
}
|
||||
};
|
||||
@@ -552,7 +552,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenMakeBOsResidentFailsThenMakeResi
|
||||
auto allocation = new MockDrmAllocationBOsResident(0, AllocationType::unknown, bos, nullptr, 0u, size, MemoryPool::localMemory);
|
||||
auto graphicsAllocation = static_cast<GraphicsAllocation *>(allocation);
|
||||
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&graphicsAllocation, 1), false, false), MemoryOperationsStatus::outOfMemory);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&graphicsAllocation, 1), false, false, true), MemoryOperationsStatus::outOfMemory);
|
||||
delete allocation;
|
||||
}
|
||||
|
||||
@@ -581,19 +581,19 @@ TEST_F(DrmMemoryOperationsHandlerBindTest,
|
||||
allocation->storageInfo.subDeviceBitfield = 0b0011;
|
||||
auto graphicsAllocation = static_cast<GraphicsAllocation *>(allocation);
|
||||
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&graphicsAllocation, 1), false, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&graphicsAllocation, 1), false, false, true), MemoryOperationsStatus::success);
|
||||
delete allocation;
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryOperationsHandlerBindTest, givenDrmMemoryOperationBindWhenMakeResidentWithinOsContextEvictableAllocationThenAllocationIsNotMarkedAsAlwaysResident) {
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), false, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), false, false, true), MemoryOperationsStatus::success);
|
||||
EXPECT_TRUE(allocation->isAlwaysResident(device->getDefaultEngine().osContext->getContextId()));
|
||||
|
||||
EXPECT_EQ(operationHandler->evict(device, *allocation), MemoryOperationsStatus::success);
|
||||
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
EXPECT_FALSE(allocation->isAlwaysResident(device->getDefaultEngine().osContext->getContextId()));
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
@@ -603,12 +603,12 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenDrmMemoryOperationBindWhenMakeRe
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
allocation->storageInfo.isChunked = true;
|
||||
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), false, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), false, false, true), MemoryOperationsStatus::success);
|
||||
EXPECT_TRUE(allocation->isAlwaysResident(device->getDefaultEngine().osContext->getContextId()));
|
||||
|
||||
EXPECT_EQ(operationHandler->evict(device, *allocation), MemoryOperationsStatus::success);
|
||||
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
EXPECT_FALSE(allocation->isAlwaysResident(device->getDefaultEngine().osContext->getContextId()));
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
@@ -619,12 +619,12 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenDrmMemoryOperationBindWhenMakeRe
|
||||
allocation->storageInfo.isChunked = true;
|
||||
allocation->storageInfo.memoryBanks = 0x5;
|
||||
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), false, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), false, false, true), MemoryOperationsStatus::success);
|
||||
EXPECT_TRUE(allocation->isAlwaysResident(device->getDefaultEngine().osContext->getContextId()));
|
||||
|
||||
EXPECT_EQ(operationHandler->evict(device, *allocation), MemoryOperationsStatus::success);
|
||||
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false), MemoryOperationsStatus::success);
|
||||
EXPECT_EQ(operationHandler->makeResidentWithinOsContext(device->getDefaultEngine().osContext, ArrayRef<GraphicsAllocation *>(&allocation, 1), true, false, true), MemoryOperationsStatus::success);
|
||||
EXPECT_FALSE(allocation->isAlwaysResident(device->getDefaultEngine().osContext->getContextId()));
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
|
||||
@@ -23,7 +23,7 @@ struct MockDrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandler
|
||||
using BaseClass = DrmMemoryOperationsHandlerDefault;
|
||||
using DrmMemoryOperationsHandlerDefault::DrmMemoryOperationsHandlerDefault;
|
||||
using DrmMemoryOperationsHandlerDefault::residency;
|
||||
ADDMETHOD(makeResidentWithinOsContext, MemoryOperationsStatus, true, MemoryOperationsStatus::success, (OsContext * osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence), (osContext, gfxAllocations, evictable, forcePagingFence));
|
||||
ADDMETHOD(makeResidentWithinOsContext, MemoryOperationsStatus, true, MemoryOperationsStatus::success, (OsContext * osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable, const bool forcePagingFence, const bool acquireLock), (osContext, gfxAllocations, evictable, forcePagingFence, acquireLock));
|
||||
ADDMETHOD(flushDummyExec, MemoryOperationsStatus, true, MemoryOperationsStatus::success, (Device * device, ArrayRef<GraphicsAllocation *> gfxAllocations), (device, gfxAllocations));
|
||||
ADDMETHOD(evictWithinOsContext, MemoryOperationsStatus, true, MemoryOperationsStatus::success, (OsContext * osContext, GraphicsAllocation &gfxAllocation), (osContext, gfxAllocation));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user