fix: add rootDeviceIndex for BufferObjectHandleWrapper

Modified sharedBoHandles to use the (boHandle, rootDeviceIndex) pair
as a key instead of boHandle, and added rootDeviceIndex variable in
the BufferObjectHandleWrapper class of drm_buffer_object.h.

Previously sharedBoHandles uses boHandle as a key. However, this will
not work with the system using multiple devices, because each devices
can return the same handle to refer different memory region.

Related-To: GSD-9024
Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
Young Jin Yoon
2024-09-10 00:41:25 +00:00
committed by Compute-Runtime-Automation
parent ea5b586c37
commit 675ec13439
6 changed files with 156 additions and 49 deletions

View File

@@ -35,7 +35,7 @@ BufferObjectHandleWrapper BufferObjectHandleWrapper::acquireSharedOwnership() {
std::lock_guard lock{controlBlock->blockMutex};
controlBlock->refCount++;
return BufferObjectHandleWrapper{boHandle, Ownership::strong, controlBlock};
return BufferObjectHandleWrapper{boHandle, rootDeviceIndex, Ownership::strong, controlBlock};
}
BufferObjectHandleWrapper BufferObjectHandleWrapper::acquireWeakOwnership() {
@@ -46,7 +46,7 @@ BufferObjectHandleWrapper BufferObjectHandleWrapper::acquireWeakOwnership() {
std::lock_guard lock{controlBlock->blockMutex};
controlBlock->weakRefCount++;
return BufferObjectHandleWrapper{boHandle, Ownership::weak, controlBlock};
return BufferObjectHandleWrapper{boHandle, rootDeviceIndex, Ownership::weak, controlBlock};
}
BufferObjectHandleWrapper::~BufferObjectHandleWrapper() {
@@ -79,7 +79,7 @@ bool BufferObjectHandleWrapper::canCloseBoHandle() {
}
BufferObject::BufferObject(uint32_t rootDeviceIndex, Drm *drm, uint64_t patIndex, int handle, size_t size, size_t maxOsContextCount)
: BufferObject(rootDeviceIndex, drm, patIndex, BufferObjectHandleWrapper{handle}, size, maxOsContextCount) {}
: BufferObject(rootDeviceIndex, drm, patIndex, BufferObjectHandleWrapper{handle, rootDeviceIndex}, size, maxOsContextCount) {}
BufferObject::BufferObject(uint32_t rootDeviceIndex, Drm *drm, uint64_t patIndex, BufferObjectHandleWrapper &&handle, size_t size, size_t maxOsContextCount)
: drm(drm), handle(std::move(handle)), size(size), refCount(1), rootDeviceIndex(rootDeviceIndex) {