From 240563099cd47149716860005a8947bdccb1fd6d Mon Sep 17 00:00:00 2001 From: Vinod Tipparaju Date: Wed, 11 Nov 2020 01:08:54 +0530 Subject: [PATCH] Clean up code for nullptr device check during cmdlist create Signed-off-by: Vinod Tipparaju --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 2 -- level_zero/core/source/cmdqueue/cmdqueue.cpp | 4 +--- shared/source/command_container/cmdcontainer.cpp | 4 ---- shared/source/command_container/cmdcontainer.h | 3 +-- .../unit_test/command_container/command_container_tests.cpp | 6 ------ 5 files changed, 2 insertions(+), 17 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 03987c64dc..d8e02a3fdc 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -40,8 +40,6 @@ struct EncodeStateBaseAddress; inline ze_result_t parseErrorCode(NEO::ErrorCode returnValue) { switch (returnValue) { - case NEO::ErrorCode::INVALID_DEVICE: - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; case NEO::ErrorCode::OUT_OF_DEVICE_MEMORY: return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY; default: diff --git a/level_zero/core/source/cmdqueue/cmdqueue.cpp b/level_zero/core/source/cmdqueue/cmdqueue.cpp index d2049515e3..61deb9ae85 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue.cpp +++ b/level_zero/core/source/cmdqueue/cmdqueue.cpp @@ -36,9 +36,7 @@ ze_result_t CommandQueueImp::initialize(bool copyOnly, bool isInternal) { NEO::GraphicsAllocation *bufferAllocation = buffers.getCurrentBufferAllocation(); commandStream = new NEO::LinearStream(bufferAllocation->getUnderlyingBuffer(), defaultQueueCmdBufferSize); - if (!commandStream) { - return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY; - } + UNRECOVERABLE_IF(commandStream == nullptr); commandStream->replaceGraphicsAllocation(bufferAllocation); isCopyOnlyCommandQueue = copyOnly; } diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index c517550907..199b041a42 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -44,10 +44,6 @@ CommandContainer::~CommandContainer() { } ErrorCode CommandContainer::initialize(Device *device) { - if (!device) { - DEBUG_BREAK_IF(device); - return ErrorCode::INVALID_DEVICE; - } this->device = device; size_t alignedSize = alignUp(totalCmdBufferSize, MemoryConstants::pageSize64k); diff --git a/shared/source/command_container/cmdcontainer.h b/shared/source/command_container/cmdcontainer.h index 591c20268f..055baee42f 100644 --- a/shared/source/command_container/cmdcontainer.h +++ b/shared/source/command_container/cmdcontainer.h @@ -27,8 +27,7 @@ using HeapType = IndirectHeap::Type; enum class ErrorCode { SUCCESS = 0, - INVALID_DEVICE = 1, - OUT_OF_DEVICE_MEMORY = 2 + OUT_OF_DEVICE_MEMORY = 1 }; class CommandContainer : public NonCopyableOrMovableClass { diff --git a/shared/test/unit_test/command_container/command_container_tests.cpp b/shared/test/unit_test/command_container/command_container_tests.cpp index f1c8927127..1cb97c35f1 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -140,12 +140,6 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIs pDevice->getMemoryManager()->getInternalHeapBaseAddress(0, !hwHelper.useSystemMemoryPlacementForISA(pDevice->getHardwareInfo()))); } -TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeWithoutDeviceThenReturnedFalse) { - CommandContainer cmdContainer; - auto status = cmdContainer.initialize(nullptr); - EXPECT_EQ(ErrorCode::INVALID_DEVICE, status); -} - TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateGfxMemoryFailsThenErrorIsReturned) { CommandContainer cmdContainer; pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(0, *pDevice->executionEnvironment));