From 6af9856e33d054f66f827396633ce951c1d142b9 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Mon, 25 Mar 2024 10:39:49 +0000 Subject: [PATCH] fix: reorder members in BufferObject class Related-To: HSD-13011781488 Signed-off-by: Mateusz Jablonski --- .../os_interface/linux/drm_allocation.cpp | 2 +- .../os_interface/linux/drm_buffer_object.cpp | 2 +- .../os_interface/linux/drm_buffer_object.h | 51 ++++++++++--------- .../os_interface/linux/drm_memory_manager.cpp | 4 +- .../drm_memory_operations_handler_bind.cpp | 2 +- .../linux/drm_memory_manager_tests.cpp | 2 +- ...m_memory_operations_handler_bind_tests.cpp | 2 +- .../linux/drm_vm_bind_prelim_tests.cpp | 4 +- .../linux/drm_with_prelim_tests.cpp | 4 +- 9 files changed, 37 insertions(+), 36 deletions(-) diff --git a/shared/source/os_interface/linux/drm_allocation.cpp b/shared/source/os_interface/linux/drm_allocation.cpp index 7758281f33..3569320cea 100644 --- a/shared/source/os_interface/linux/drm_allocation.cpp +++ b/shared/source/os_interface/linux/drm_allocation.cpp @@ -515,7 +515,7 @@ bool DrmAllocation::setMemPrefetch(Drm *drm, SubDeviceIdsVec &subDeviceIds) { } } else { auto bo = this->getBO(); - if (bo->isChunked) { + if (bo->isChunked()) { auto drm = bo->peekDrm(); success = prefetchBOWithChunking(const_cast(drm)); } else { diff --git a/shared/source/os_interface/linux/drm_buffer_object.cpp b/shared/source/os_interface/linux/drm_buffer_object.cpp index 2b921dca2d..ea5f7eb768 100644 --- a/shared/source/os_interface/linux/drm_buffer_object.cpp +++ b/shared/source/os_interface/linux/drm_buffer_object.cpp @@ -81,7 +81,7 @@ BufferObject::BufferObject(uint32_t rootDeviceIndex, Drm *drm, uint64_t patIndex : BufferObject(rootDeviceIndex, drm, patIndex, BufferObjectHandleWrapper{handle}, size, maxOsContextCount) {} BufferObject::BufferObject(uint32_t rootDeviceIndex, Drm *drm, uint64_t patIndex, BufferObjectHandleWrapper &&handle, size_t size, size_t maxOsContextCount) - : drm(drm), refCount(1), rootDeviceIndex(rootDeviceIndex), handle(std::move(handle)), size(size) { + : drm(drm), handle(std::move(handle)), size(size), refCount(1), rootDeviceIndex(rootDeviceIndex) { auto ioctlHelper = drm->getIoctlHelper(); this->tilingMode = ioctlHelper->getDrmParamValue(DrmParam::tilingNone); diff --git a/shared/source/os_interface/linux/drm_buffer_object.h b/shared/source/os_interface/linux/drm_buffer_object.h index b4d0df6d49..ae626881d2 100644 --- a/shared/source/os_interface/linux/drm_buffer_object.h +++ b/shared/source/os_interface/linux/drm_buffer_object.h @@ -223,9 +223,11 @@ class BufferObject { static constexpr int gpuHangDetected{-7171}; uint32_t getOsContextId(OsContext *osContext); - std::vector> bindInfo; - bool isChunked = false; + const auto &getBindInfo() const { return bindInfo; } + + void setChunked(bool chunked) { this->chunked = chunked; } + bool isChunked() const { return this->chunked; } protected: MOCKABLE_VIRTUAL MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded); @@ -233,35 +235,34 @@ class BufferObject { void printBOBindingResult(OsContext *osContext, uint32_t vmHandleId, bool bind, int retVal); Drm *drm = nullptr; - bool perContextVmsUsed = false; - std::atomic refCount; - uint32_t rootDeviceIndex = std::numeric_limits::max(); - uint32_t tilingMode; BufferObjectHandleWrapper handle; // i915 gem object handle + void *lockedAddress = nullptr; // CPU side virtual address - bool isReused = false; - bool boHandleShared = false; - - bool allowCapture = false; - bool requiresImmediateBinding = false; - bool requiresExplicitResidency = false; - void *lockedAddress = nullptr; // CPU side virtual address - bool requiresLocked = false; - - BOType boType = BOType::legacy; - uint64_t size; + uint64_t size = 0; uint64_t unmapSize = 0; uint64_t patIndex = CommonConstants::unsupportedPatIndex; uint64_t userptr = 0u; - CacheRegion cacheRegion = CacheRegion::defaultRegion; - CachePolicy cachePolicy = CachePolicy::writeBack; - StackVec bindExtHandles; - bool colourWithBind = false; - size_t colourChunk = 0; - std::vector bindAddresses; - - private: uint64_t gpuAddress = 0llu; + + std::vector bindAddresses; + std::vector> bindInfo; + StackVec bindExtHandles; + BOType boType = BOType::legacy; + std::atomic refCount; + uint32_t rootDeviceIndex = std::numeric_limits::max(); + uint32_t tilingMode = 0; + CachePolicy cachePolicy = CachePolicy::writeBack; + CacheRegion cacheRegion = CacheRegion::defaultRegion; + + bool colourWithBind = false; + bool perContextVmsUsed = false; + bool boHandleShared = false; + bool allowCapture = false; + bool requiresImmediateBinding = false; + bool requiresExplicitResidency = false; + bool requiresLocked = false; + bool chunked = false; + bool isReused = false; }; } // namespace NEO diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 835bcbcc20..4698972c00 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -2024,7 +2024,7 @@ bool DrmMemoryManager::createDrmChunkedAllocation(Drm *drm, DrmAllocation *alloc allocation->getBufferObjectToModify(0) = bo; - bo->isChunked = 1; + bo->setChunked(true); storageInfo.isChunked = true; storageInfo.numOfChunks = numOfChunks; @@ -2480,7 +2480,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const bo->setAddress(castToUint64(currentAddress)); - bo->isChunked = useChunking; + bo->setChunked(useChunking); bos.push_back(bo.release()); diff --git a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp index 6844ea078c..ad6ff9b392 100644 --- a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp +++ b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp @@ -65,7 +65,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsConte bo = drmAllocation->getBO(); } - if (!bo->bindInfo[bo->getOsContextId(osContext)][drmIterator]) { + if (!bo->getBindInfo()[bo->getOsContextId(osContext)][drmIterator]) { bo->requireExplicitLockedMemory(drmAllocation->isLockedMemory()); int result = drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, true); if (result) { diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index f3e63cbbf2..41053d5c6e 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -6417,7 +6417,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenAllocati auto bo = bos[handleId]; auto contextId = bo->getOsContextId(osContext); ASSERT_NE(nullptr, bo); - EXPECT_FALSE(bo->bindInfo[contextId][handleId]); + EXPECT_FALSE(bo->getBindInfo()[contextId][handleId]); } EXPECT_EQ(0u, allocation->getGpuAddress()); memoryManager->freeGraphicsMemory(allocation); diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp index 578cd84f5a..85c932b6c8 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp @@ -570,7 +570,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, auto size = 4096u; BufferObjects bos; MockBufferObject mockBo(device->getRootDeviceIndex(), mock, 3, 0, 0, 1); - mockBo.isChunked = 1; + mockBo.setChunked(true); mockBo.setSize(1024); bos.push_back(&mockBo); diff --git a/shared/test/unit_test/os_interface/linux/drm_vm_bind_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_vm_bind_prelim_tests.cpp index 239a01d8a6..55148ba9b0 100644 --- a/shared/test/unit_test/os_interface/linux/drm_vm_bind_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_vm_bind_prelim_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -71,7 +71,7 @@ TEST(DrmVmBindTest, for (auto requireResidency : {false, true}) { MockBufferObject bo(0, &drm, 3, 0, 0, 1); - bo.isChunked = true; + bo.setChunked(true); bo.requireExplicitResidency(requireResidency); OsContextLinux osContext(drm, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor()); diff --git a/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp index f9aacf493e..aa01e6602d 100644 --- a/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp @@ -573,7 +573,7 @@ TEST_F(IoctlHelperPrelimFixture, drm->ioctlCallsCount = 0; MockBufferObject bo(0u, drm.get(), 3, 0, 0, 1); - bo.isChunked = 1; + bo.setChunked(true); bo.setSize(1024); MockDrmAllocation allocation(0u, AllocationType::buffer, MemoryPool::localMemory); allocation.bufferObjects[0] = &bo; @@ -602,7 +602,7 @@ TEST_F(IoctlHelperPrelimFixture, drm->ioctlCallsCount = 0; MockBufferObject bo(0u, drm.get(), 3, 0, 0, 1); - bo.isChunked = 1; + bo.setChunked(true); bo.setSize(1024); MockDrmAllocation allocation(0u, AllocationType::buffer, MemoryPool::localMemory); allocation.bufferObjects[0] = &bo;