mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Fixed crash in direct submission dtor
Crash on an attempt to read from tag address when ring is not started Related-to: NEO-5869 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
68aea5bf62
commit
88121a6f24
@@ -760,6 +760,68 @@ struct DrmCommandStreamBlitterDirectSubmissionTest : public DrmCommandStreamDire
|
||||
std::unique_ptr<OsContext> osContext;
|
||||
};
|
||||
|
||||
struct DrmDirectSubmissionFunctionsCalled {
|
||||
bool stopRingBuffer;
|
||||
bool wait;
|
||||
bool deallocateResources;
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct MockDrmDirectSubmissionToTestDtor : public DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>> {
|
||||
MockDrmDirectSubmissionToTestDtor<GfxFamily>(Device &device, OsContext &osContext, DrmDirectSubmissionFunctionsCalled &functionsCalled)
|
||||
: DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>(device, osContext), functionsCalled(functionsCalled) {
|
||||
}
|
||||
~MockDrmDirectSubmissionToTestDtor() override {
|
||||
if (ringStart) {
|
||||
stopRingBuffer();
|
||||
wait(static_cast<uint32_t>(this->currentTagData.tagValue));
|
||||
}
|
||||
deallocateResources();
|
||||
}
|
||||
using DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>::ringStart;
|
||||
bool stopRingBuffer() override {
|
||||
functionsCalled.stopRingBuffer = true;
|
||||
return true;
|
||||
}
|
||||
void wait(uint32_t taskCountToWait) override {
|
||||
functionsCalled.wait = true;
|
||||
}
|
||||
void deallocateResources() override {
|
||||
functionsCalled.deallocateResources = true;
|
||||
}
|
||||
DrmDirectSubmissionFunctionsCalled &functionsCalled;
|
||||
};
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenEnabledDirectSubmissionWhenDtorIsCalledButRingIsNotStartedThenDontCallStopRingBufferNorWaitForTagValue) {
|
||||
DrmDirectSubmissionFunctionsCalled functionsCalled{};
|
||||
auto directSubmission = std::make_unique<MockDrmDirectSubmissionToTestDtor<FamilyType>>(*device.get(), *device->getDefaultEngine().osContext, functionsCalled);
|
||||
ASSERT_NE(nullptr, directSubmission);
|
||||
|
||||
EXPECT_FALSE(directSubmission->ringStart);
|
||||
|
||||
directSubmission.reset();
|
||||
|
||||
EXPECT_FALSE(functionsCalled.stopRingBuffer);
|
||||
EXPECT_FALSE(functionsCalled.wait);
|
||||
EXPECT_TRUE(functionsCalled.deallocateResources);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct MockDrmDirectSubmissionToTestRingStop : public DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>> {
|
||||
MockDrmDirectSubmissionToTestRingStop<GfxFamily>(Device &device, OsContext &osContext)
|
||||
: DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>(device, osContext) {
|
||||
}
|
||||
using DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>::ringStart;
|
||||
};
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenEnabledDirectSubmissionWhenStopRingBufferIsCalledThenClearRingStart) {
|
||||
auto directSubmission = std::make_unique<MockDrmDirectSubmissionToTestRingStop<FamilyType>>(*device.get(), *device->getDefaultEngine().osContext);
|
||||
ASSERT_NE(nullptr, directSubmission);
|
||||
|
||||
directSubmission->stopRingBuffer();
|
||||
EXPECT_FALSE(directSubmission->ringStart);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct MockDrmDirectSubmission : public DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>> {
|
||||
using DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>::currentTagData;
|
||||
|
||||
@@ -61,7 +61,7 @@ class DirectSubmissionHw {
|
||||
|
||||
bool initialize(bool submitOnInit);
|
||||
|
||||
bool stopRingBuffer();
|
||||
MOCKABLE_VIRTUAL bool stopRingBuffer();
|
||||
|
||||
bool startRingBuffer();
|
||||
|
||||
@@ -73,7 +73,7 @@ class DirectSubmissionHw {
|
||||
static constexpr size_t prefetchSize = 8 * MemoryConstants::cacheLineSize;
|
||||
static constexpr size_t prefetchNoops = prefetchSize / sizeof(uint32_t);
|
||||
bool allocateResources();
|
||||
void deallocateResources();
|
||||
MOCKABLE_VIRTUAL void deallocateResources();
|
||||
MOCKABLE_VIRTUAL bool makeResourcesResident(DirectSubmissionAllocations &allocations);
|
||||
virtual bool allocateOsResources() = 0;
|
||||
virtual bool submit(uint64_t gpuAddress, size_t size) = 0;
|
||||
|
||||
@@ -34,7 +34,7 @@ class DrmDirectSubmission : public DirectSubmissionHw<GfxFamily, Dispatcher> {
|
||||
uint64_t updateTagValue() override;
|
||||
void getTagAddressValue(TagData &tagData) override;
|
||||
|
||||
void wait(uint32_t taskCountToWait);
|
||||
MOCKABLE_VIRTUAL void wait(uint32_t taskCountToWait);
|
||||
|
||||
TagData currentTagData;
|
||||
volatile uint32_t *tagAddress;
|
||||
|
||||
@@ -50,8 +50,10 @@ DrmDirectSubmission<GfxFamily, Dispatcher>::DrmDirectSubmission(Device &device,
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline DrmDirectSubmission<GfxFamily, Dispatcher>::~DrmDirectSubmission() {
|
||||
if (this->ringStart) {
|
||||
this->stopRingBuffer();
|
||||
this->wait(static_cast<uint32_t>(this->currentTagData.tagValue));
|
||||
}
|
||||
this->deallocateResources();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user