Skip to content

Commit e88bad7

Browse files
Dont pass drm to ioctl helper methods - use Ioctl Helper's member instead
Related-To: NEO-6999 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 28edaa9 commit e88bad7

File tree

18 files changed

+233
-233
lines changed

18 files changed

+233
-233
lines changed

level_zero/tools/source/debug/linux/prelim/drm_helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace L0 {
1515

1616
int DrmHelper::ioctl(Device *device, NEO::DrmIoctl request, void *arg) {
1717
auto drm = device->getOsInterface().getDriverModel()->as<NEO::Drm>();
18-
return drm->getIoctlHelper()->ioctl(drm, request, arg);
18+
return drm->getIoctlHelper()->ioctl(request, arg);
1919
}
2020

2121
int DrmHelper::getErrno(Device *device) {

shared/source/os_interface/linux/clos_cache.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ CacheRegion ClosCacheReservation::freeCache(CacheLevel cacheLevel, CacheRegion c
3838
}
3939

4040
CacheRegion ClosCacheReservation::allocEntry() {
41-
return drm.getIoctlHelper()->closAlloc(&drm);
41+
return drm.getIoctlHelper()->closAlloc();
4242
}
4343

4444
CacheRegion ClosCacheReservation::freeEntry(CacheRegion closIndex) {
45-
return drm.getIoctlHelper()->closFree(&drm, closIndex);
45+
return drm.getIoctlHelper()->closFree(closIndex);
4646
}
4747

4848
uint16_t ClosCacheReservation::allocCacheWay(CacheRegion closIndex, CacheLevel cacheLevel, uint16_t numWays) {
49-
return drm.getIoctlHelper()->closAllocWays(&drm, closIndex, static_cast<uint16_t>(cacheLevel), numWays);
49+
return drm.getIoctlHelper()->closAllocWays(closIndex, static_cast<uint16_t>(cacheLevel), numWays);
5050
}
5151

5252
} // namespace NEO

shared/source/os_interface/linux/device_time_drm.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ void DeviceTimeDrm::timestampTypeDetect() {
3232

3333
reg.offset = (REG_GLOBAL_TIMESTAMP_LDW | 1);
3434
auto ioctlHelper = pDrm->getIoctlHelper();
35-
err = ioctlHelper->ioctl(pDrm, DrmIoctl::RegRead, &reg);
35+
err = ioctlHelper->ioctl(DrmIoctl::RegRead, &reg);
3636
if (err) {
3737
reg.offset = REG_GLOBAL_TIMESTAMP_UN;
38-
err = ioctlHelper->ioctl(pDrm, DrmIoctl::RegRead, &reg);
38+
err = ioctlHelper->ioctl(DrmIoctl::RegRead, &reg);
3939
if (err) {
4040
getGpuTime = &DeviceTimeDrm::getGpuTime32;
4141
} else {
@@ -52,7 +52,7 @@ bool DeviceTimeDrm::getGpuTime32(uint64_t *timestamp) {
5252
reg.offset = REG_GLOBAL_TIMESTAMP_LDW;
5353

5454
auto ioctlHelper = pDrm->getIoctlHelper();
55-
if (ioctlHelper->ioctl(pDrm, DrmIoctl::RegRead, &reg)) {
55+
if (ioctlHelper->ioctl(DrmIoctl::RegRead, &reg)) {
5656
return false;
5757
}
5858
*timestamp = reg.value >> 32;
@@ -65,7 +65,7 @@ bool DeviceTimeDrm::getGpuTime36(uint64_t *timestamp) {
6565
reg.offset = REG_GLOBAL_TIMESTAMP_LDW | 1;
6666

6767
auto ioctlHelper = pDrm->getIoctlHelper();
68-
if (ioctlHelper->ioctl(pDrm, DrmIoctl::RegRead, &reg)) {
68+
if (ioctlHelper->ioctl(DrmIoctl::RegRead, &reg)) {
6969
return false;
7070
}
7171
*timestamp = reg.value;
@@ -82,11 +82,11 @@ bool DeviceTimeDrm::getGpuTimeSplitted(uint64_t *timestamp) {
8282
regLo.offset = REG_GLOBAL_TIMESTAMP_LDW;
8383

8484
auto ioctlHelper = pDrm->getIoctlHelper();
85-
err += ioctlHelper->ioctl(pDrm, DrmIoctl::RegRead, &regHi);
85+
err += ioctlHelper->ioctl(DrmIoctl::RegRead, &regHi);
8686
do {
8787
tmpHi = regHi.value;
88-
err += ioctlHelper->ioctl(pDrm, DrmIoctl::RegRead, &regLo);
89-
err += ioctlHelper->ioctl(pDrm, DrmIoctl::RegRead, &regHi);
88+
err += ioctlHelper->ioctl(DrmIoctl::RegRead, &regLo);
89+
err += ioctlHelper->ioctl(DrmIoctl::RegRead, &regHi);
9090
} while (err == 0 && regHi.value != tmpHi && --loop);
9191

9292
if (err) {

shared/source/os_interface/linux/drm_allocation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ bool DrmAllocation::setMemAdvise(Drm *drm, MemAdviseFlags flags) {
272272
if (flags.non_atomic != enabledMemAdviseFlags.non_atomic) {
273273
for (auto bo : bufferObjects) {
274274
if (bo != nullptr) {
275-
success &= ioctlHelper->setVmBoAdvise(drm, bo->peekHandle(), ioctlHelper->getAtomicAdvise(flags.non_atomic), nullptr);
275+
success &= ioctlHelper->setVmBoAdvise(bo->peekHandle(), ioctlHelper->getAtomicAdvise(flags.non_atomic), nullptr);
276276
}
277277
}
278278
}
@@ -289,7 +289,7 @@ bool DrmAllocation::setMemAdvise(Drm *drm, MemAdviseFlags flags) {
289289
region.memoryClass = -1;
290290
region.memoryInstance = 0;
291291
}
292-
success &= ioctlHelper->setVmBoAdvise(drm, bo->peekHandle(), ioctlHelper->getPreferredLocationAdvise(), &region);
292+
success &= ioctlHelper->setVmBoAdvise(bo->peekHandle(), ioctlHelper->getPreferredLocationAdvise(), &region);
293293
}
294294
}
295295
}
@@ -309,7 +309,7 @@ bool DrmAllocation::setMemPrefetch(Drm *drm, uint32_t subDeviceId) {
309309
for (auto bo : bufferObjects) {
310310
if (bo != nullptr) {
311311
auto region = static_cast<uint32_t>((memoryClassDevice << 16u) | subDeviceId);
312-
success &= ioctlHelper->setVmPrefetch(drm, bo->peekAddress(), bo->peekSize(), region);
312+
success &= ioctlHelper->setVmPrefetch(bo->peekAddress(), bo->peekSize(), region);
313313
}
314314
}
315315

shared/source/os_interface/linux/drm_buffer_object.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool BufferObject::close() {
6969
PRINT_DEBUG_STRING(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Calling gem close on handle: BO-%d\n", this->handle);
7070

7171
auto ioctlHelper = this->drm->getIoctlHelper();
72-
int ret = ioctlHelper->ioctl(drm, DrmIoctl::GemClose, &close);
72+
int ret = ioctlHelper->ioctl(DrmIoctl::GemClose, &close);
7373
if (ret != 0) {
7474
int err = errno;
7575
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(GEM_CLOSE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
@@ -104,7 +104,7 @@ bool BufferObject::setTiling(uint32_t mode, uint32_t stride) {
104104
setTiling.stride = stride;
105105
auto ioctlHelper = this->drm->getIoctlHelper();
106106

107-
if (ioctlHelper->ioctl(drm, DrmIoctl::GemSetTiling, &setTiling) != 0) {
107+
if (ioctlHelper->ioctl(DrmIoctl::GemSetTiling, &setTiling) != 0) {
108108
return false;
109109
}
110110

@@ -144,7 +144,7 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo
144144
printExecutionBuffer(execbuf, residencyCount, execObjectsStorage, residency);
145145
}
146146

147-
int ret = ioctlHelper->execBuffer(drm, &execbuf, completionGpuAddress, completionValue);
147+
int ret = ioctlHelper->execBuffer(&execbuf, completionGpuAddress, completionValue);
148148

149149
if (ret != 0) {
150150
int err = this->drm->getErrno();
@@ -154,7 +154,7 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo
154154
}
155155

156156
evictUnusedAllocations(false, true);
157-
ret = ioctlHelper->execBuffer(drm, &execbuf, completionGpuAddress, completionValue);
157+
ret = ioctlHelper->execBuffer(&execbuf, completionGpuAddress, completionValue);
158158
}
159159

160160
if (ret != 0) {
@@ -164,7 +164,7 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo
164164
return gpuHangDetected;
165165
}
166166

167-
ret = ioctlHelper->execBuffer(drm, &execbuf, completionGpuAddress, completionValue);
167+
ret = ioctlHelper->execBuffer(&execbuf, completionGpuAddress, completionValue);
168168
}
169169

170170
if (ret == 0) {

shared/source/os_interface/linux/drm_debug.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bool Drm::registerResourceClasses() {
2121
auto className = classNameUUID.first;
2222
auto uuid = classNameUUID.second;
2323

24-
const auto result = ioctlHelper->registerStringClassUuid(this, uuid, (uintptr_t)className, strnlen_s(className, 100));
24+
const auto result = ioctlHelper->registerStringClassUuid(uuid, (uintptr_t)className, strnlen_s(className, 100));
2525
if (result.retVal != 0) {
2626
return false;
2727
}
@@ -45,7 +45,7 @@ uint32_t Drm::registerResource(DrmResourceClass classType, const void *data, siz
4545

4646
const auto uuidClass = classHandles[static_cast<uint32_t>(classType)];
4747
const auto ptr = size > 0 ? (uintptr_t)data : 0;
48-
const auto result = ioctlHelper->registerUuid(this, uuid, uuidClass, ptr, size);
48+
const auto result = ioctlHelper->registerUuid(uuid, uuidClass, ptr, size);
4949

5050
PRINT_DEBUGGER_INFO_LOG("PRELIM_DRM_IOCTL_I915_UUID_REGISTER: classType = %d, uuid = %s, data = %p, handle = %lu, ret = %d\n", (int)classType, std::string(uuid, 36).c_str(), ptr, result.handle, result.retVal);
5151
DEBUG_BREAK_IF(result.retVal != 0);
@@ -56,7 +56,7 @@ uint32_t Drm::registerResource(DrmResourceClass classType, const void *data, siz
5656
uint32_t Drm::registerIsaCookie(uint32_t isaHandle) {
5757
auto uuid = generateUUID();
5858

59-
const auto result = ioctlHelper->registerUuid(this, uuid, isaHandle, 0, 0);
59+
const auto result = ioctlHelper->registerUuid(uuid, isaHandle, 0, 0);
6060

6161
PRINT_DEBUGGER_INFO_LOG("PRELIM_DRM_IOCTL_I915_UUID_REGISTER: isa handle = %lu, uuid = %s, data = %p, handle = %lu, ret = %d\n", isaHandle, std::string(uuid, 36).c_str(), 0, result.handle, result.retVal);
6262
DEBUG_BREAK_IF(result.retVal != 0);
@@ -66,7 +66,7 @@ uint32_t Drm::registerIsaCookie(uint32_t isaHandle) {
6666

6767
void Drm::unregisterResource(uint32_t handle) {
6868
PRINT_DEBUGGER_INFO_LOG("PRELIM_DRM_IOCTL_I915_UUID_UNREGISTER: handle = %lu\n", handle);
69-
[[maybe_unused]] const auto ret = ioctlHelper->unregisterUuid(this, handle);
69+
[[maybe_unused]] const auto ret = ioctlHelper->unregisterUuid(handle);
7070
DEBUG_BREAK_IF(ret != 0);
7171
}
7272

@@ -101,16 +101,16 @@ std::string Drm::generateElfUUID(const void *data) {
101101
}
102102

103103
void Drm::checkContextDebugSupport() {
104-
contextDebugSupported = ioctlHelper->isContextDebugSupported(this);
104+
contextDebugSupported = ioctlHelper->isContextDebugSupported();
105105
}
106106

107107
void Drm::setContextDebugFlag(uint32_t drmContextId) {
108-
[[maybe_unused]] const auto retVal = ioctlHelper->setContextDebugFlag(this, drmContextId);
108+
[[maybe_unused]] const auto retVal = ioctlHelper->setContextDebugFlag(drmContextId);
109109
DEBUG_BREAK_IF(retVal != 0 && contextDebugSupported);
110110
}
111111

112112
uint32_t Drm::notifyFirstCommandQueueCreated() {
113-
const auto result = ioctlHelper->registerStringClassUuid(this, uuidL0CommandQueueHash, (uintptr_t)uuidL0CommandQueueName, strnlen_s(uuidL0CommandQueueName, 100));
113+
const auto result = ioctlHelper->registerStringClassUuid(uuidL0CommandQueueHash, (uintptr_t)uuidL0CommandQueueName, strnlen_s(uuidL0CommandQueueName, 100));
114114
DEBUG_BREAK_IF(result.retVal);
115115
return result.handle;
116116
}

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ NEO::BufferObject *DrmMemoryManager::allocUserptr(uintptr_t address, size_t size
248248
auto &drm = this->getDrm(rootDeviceIndex);
249249
auto ioctlHelper = drm.getIoctlHelper();
250250

251-
if (ioctlHelper->ioctl(&drm, DrmIoctl::GemUserptr, &userptr) != 0) {
251+
if (ioctlHelper->ioctl(DrmIoctl::GemUserptr, &userptr) != 0) {
252252
return nullptr;
253253
}
254254

@@ -523,7 +523,7 @@ GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData &
523523
auto &drm = getDrm(allocationData.rootDeviceIndex);
524524
auto ioctlHelper = drm.getIoctlHelper();
525525

526-
[[maybe_unused]] auto ret = ioctlHelper->ioctl(&drm, DrmIoctl::GemCreate, &create);
526+
[[maybe_unused]] auto ret = ioctlHelper->ioctl(DrmIoctl::GemCreate, &create);
527527
DEBUG_BREAK_IF(ret != 0);
528528

529529
auto patIndex = drm.getPatIndex(gmm.get(), allocationData.type, CacheRegion::Default, CachePolicy::WriteBack, false);
@@ -557,7 +557,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A
557557
auto &drm = this->getDrm(allocationData.rootDeviceIndex);
558558
auto ioctlHelper = drm.getIoctlHelper();
559559

560-
[[maybe_unused]] auto ret = ioctlHelper->ioctl(&drm, DrmIoctl::GemCreate, &create);
560+
[[maybe_unused]] auto ret = ioctlHelper->ioctl(DrmIoctl::GemCreate, &create);
561561
DEBUG_BREAK_IF(ret != 0);
562562

563563
auto patIndex = drm.getPatIndex(gmm.get(), allocationData.type, CacheRegion::Default, CachePolicy::WriteBack, false);
@@ -690,7 +690,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromMultipleShared
690690
PrimeHandle openFd = {0, 0, 0};
691691
openFd.fileDescriptor = handle;
692692

693-
auto ret = ioctlHelper->ioctl(&drm, DrmIoctl::PrimeFdToHandle, &openFd);
693+
auto ret = ioctlHelper->ioctl(DrmIoctl::PrimeFdToHandle, &openFd);
694694

695695
if (ret != 0) {
696696
[[maybe_unused]] int err = errno;
@@ -777,7 +777,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
777777
auto &drm = this->getDrm(properties.rootDeviceIndex);
778778
auto ioctlHelper = drm.getIoctlHelper();
779779

780-
auto ret = ioctlHelper->ioctl(&drm, DrmIoctl::PrimeFdToHandle, &openFd);
780+
auto ret = ioctlHelper->ioctl(DrmIoctl::PrimeFdToHandle, &openFd);
781781

782782
if (ret != 0) {
783783
[[maybe_unused]] int err = errno;
@@ -830,7 +830,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
830830
GemGetTiling getTiling{};
831831
getTiling.handle = boHandle;
832832
auto ioctlHelper = drm.getIoctlHelper();
833-
ret = ioctlHelper->ioctl(&drm, DrmIoctl::GemGetTiling, &getTiling);
833+
ret = ioctlHelper->ioctl(DrmIoctl::GemGetTiling, &getTiling);
834834

835835
if (ret == 0) {
836836
auto ioctlHelper = drm.getIoctlHelper();
@@ -1052,7 +1052,7 @@ bool DrmMemoryManager::setDomainCpu(GraphicsAllocation &graphicsAllocation, bool
10521052

10531053
auto &drm = this->getDrm(graphicsAllocation.getRootDeviceIndex());
10541054
auto ioctlHelper = drm.getIoctlHelper();
1055-
return ioctlHelper->ioctl(&drm, DrmIoctl::GemSetDomain, &setDomain) == 0;
1055+
return ioctlHelper->ioctl(DrmIoctl::GemSetDomain, &setDomain) == 0;
10561056
}
10571057

10581058
void *DrmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation) {
@@ -1091,7 +1091,7 @@ int DrmMemoryManager::obtainFdFromHandle(int boHandle, uint32_t rootDeviceIndex)
10911091

10921092
auto &drm = this->getDrm(rootDeviceIndex);
10931093
auto ioctlHelper = drm.getIoctlHelper();
1094-
ioctlHelper->ioctl(&drm, DrmIoctl::PrimeHandleToFd, &openFd);
1094+
ioctlHelper->ioctl(DrmIoctl::PrimeHandleToFd, &openFd);
10951095

10961096
return openFd.fileDescriptor;
10971097
}
@@ -1589,10 +1589,10 @@ bool DrmMemoryManager::retrieveMmapOffsetForBufferObject(uint32_t rootDeviceInde
15891589
mmapOffset.flags = isLocalMemorySupported(rootDeviceIndex) ? mmapOffsetFixed : flags;
15901590
auto &drm = this->getDrm(rootDeviceIndex);
15911591
auto ioctlHelper = drm.getIoctlHelper();
1592-
auto ret = ioctlHelper->ioctl(&drm, DrmIoctl::GemMmapOffset, &mmapOffset);
1592+
auto ret = ioctlHelper->ioctl(DrmIoctl::GemMmapOffset, &mmapOffset);
15931593
if (ret != 0 && isLocalMemorySupported(rootDeviceIndex)) {
15941594
mmapOffset.flags = flags;
1595-
ret = ioctlHelper->ioctl(&drm, DrmIoctl::GemMmapOffset, &mmapOffset);
1595+
ret = ioctlHelper->ioctl(DrmIoctl::GemMmapOffset, &mmapOffset);
15961596
}
15971597
if (ret != 0) {
15981598
int err = drm.getErrno();
@@ -1793,7 +1793,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
17931793

17941794
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(&drm, patIndex, handle, size, maxOsContextCount));
17951795

1796-
if (!drm.getIoctlHelper()->setVmBoAdvise(&drm, bo->peekHandle(), vmAdviseAttribute, nullptr)) {
1796+
if (!drm.getIoctlHelper()->setVmBoAdvise(bo->peekHandle(), vmAdviseAttribute, nullptr)) {
17971797
return nullptr;
17981798
}
17991799

@@ -1840,7 +1840,7 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl
18401840
auto patIndex = drm.getPatIndex(nullptr, properties.allocationType, CacheRegion::Default, CachePolicy::WriteBack, false);
18411841
auto ioctlHelper = drm.getIoctlHelper();
18421842

1843-
auto ret = ioctlHelper->ioctl(&drm, DrmIoctl::PrimeFdToHandle, &openFd);
1843+
auto ret = ioctlHelper->ioctl(DrmIoctl::PrimeFdToHandle, &openFd);
18441844
if (ret != 0) {
18451845
int err = drm.getErrno();
18461846
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(PRIME_FD_TO_HANDLE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));

0 commit comments

Comments
 (0)