Skip to content

Commit bb71f92

Browse files
Move common ioctl request values to common method
Related-To: NEO-7028 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent c4bb209 commit bb71f92

File tree

4 files changed

+53
-88
lines changed

4 files changed

+53
-88
lines changed

shared/source/os_interface/linux/ioctl_helper.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,56 @@ uint32_t IoctlHelper::createDrmContext(Drm &drm, const OsContext &osContext, uin
106106
return drmContextId;
107107
}
108108

109+
unsigned int IoctlHelper::getIoctlRequestValueBase(DrmIoctl ioctlRequest) const {
110+
switch (ioctlRequest) {
111+
case DrmIoctl::GemExecbuffer2:
112+
return DRM_IOCTL_I915_GEM_EXECBUFFER2;
113+
case DrmIoctl::GemWait:
114+
return DRM_IOCTL_I915_GEM_WAIT;
115+
case DrmIoctl::GemClose:
116+
return DRM_IOCTL_GEM_CLOSE;
117+
case DrmIoctl::GemUserptr:
118+
return DRM_IOCTL_I915_GEM_USERPTR;
119+
case DrmIoctl::GemCreate:
120+
return DRM_IOCTL_I915_GEM_CREATE;
121+
case DrmIoctl::GemSetDomain:
122+
return DRM_IOCTL_I915_GEM_SET_DOMAIN;
123+
case DrmIoctl::GemSetTiling:
124+
return DRM_IOCTL_I915_GEM_SET_TILING;
125+
case DrmIoctl::GemGetTiling:
126+
return DRM_IOCTL_I915_GEM_GET_TILING;
127+
case DrmIoctl::GemContextCreateExt:
128+
return DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT;
129+
case DrmIoctl::GemContextDestroy:
130+
return DRM_IOCTL_I915_GEM_CONTEXT_DESTROY;
131+
case DrmIoctl::RegRead:
132+
return DRM_IOCTL_I915_REG_READ;
133+
case DrmIoctl::GetResetStats:
134+
return DRM_IOCTL_I915_GET_RESET_STATS;
135+
case DrmIoctl::GemContextGetparam:
136+
return DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM;
137+
case DrmIoctl::GemContextSetparam:
138+
return DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM;
139+
case DrmIoctl::Query:
140+
return DRM_IOCTL_I915_QUERY;
141+
case DrmIoctl::GemMmap:
142+
return DRM_IOCTL_I915_GEM_MMAP;
143+
case DrmIoctl::PrimeFdToHandle:
144+
return DRM_IOCTL_PRIME_FD_TO_HANDLE;
145+
case DrmIoctl::PrimeHandleToFd:
146+
return DRM_IOCTL_PRIME_HANDLE_TO_FD;
147+
case DrmIoctl::GemMmapOffset:
148+
return DRM_IOCTL_I915_GEM_MMAP_OFFSET;
149+
case DrmIoctl::GemVmCreate:
150+
return DRM_IOCTL_I915_GEM_VM_CREATE;
151+
case DrmIoctl::GemVmDestroy:
152+
return DRM_IOCTL_I915_GEM_VM_DESTROY;
153+
default:
154+
UNRECOVERABLE_IF(true);
155+
return 0u;
156+
}
157+
}
158+
109159
int IoctlHelper::getDrmParamValueBase(DrmParam drmParam) const {
110160
switch (drmParam) {
111161
case DrmParam::EngineClassRender:

shared/source/os_interface/linux/ioctl_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class IoctlHelper {
123123
void fillExecBuffer(ExecBuffer &execBuffer, uintptr_t buffersPtr, uint32_t bufferCount, uint32_t startOffset, uint32_t size, uint64_t flags, uint32_t drmContextId);
124124
void logExecBuffer(const ExecBuffer &execBuffer, std::stringstream &logger);
125125
int getDrmParamValueBase(DrmParam drmParam) const;
126+
unsigned int getIoctlRequestValueBase(DrmIoctl ioctlRequest) const;
126127
};
127128

128129
class IoctlHelperUpstream : public IoctlHelper {

shared/source/os_interface/linux/ioctl_helper_prelim.cpp

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -552,42 +552,6 @@ bool IoctlHelperPrelim20::isDebugAttachAvailable() {
552552

553553
unsigned int IoctlHelperPrelim20::getIoctlRequestValue(DrmIoctl ioctlRequest) {
554554
switch (ioctlRequest) {
555-
case DrmIoctl::GemExecbuffer2:
556-
return DRM_IOCTL_I915_GEM_EXECBUFFER2;
557-
case DrmIoctl::GemWait:
558-
return DRM_IOCTL_I915_GEM_WAIT;
559-
case DrmIoctl::GemClose:
560-
return DRM_IOCTL_GEM_CLOSE;
561-
case DrmIoctl::GemUserptr:
562-
return DRM_IOCTL_I915_GEM_USERPTR;
563-
case DrmIoctl::GemCreate:
564-
return DRM_IOCTL_I915_GEM_CREATE;
565-
case DrmIoctl::GemSetDomain:
566-
return DRM_IOCTL_I915_GEM_SET_DOMAIN;
567-
case DrmIoctl::GemSetTiling:
568-
return DRM_IOCTL_I915_GEM_SET_TILING;
569-
case DrmIoctl::GemGetTiling:
570-
return DRM_IOCTL_I915_GEM_GET_TILING;
571-
case DrmIoctl::GemContextCreateExt:
572-
return DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT;
573-
case DrmIoctl::GemContextDestroy:
574-
return DRM_IOCTL_I915_GEM_CONTEXT_DESTROY;
575-
case DrmIoctl::RegRead:
576-
return DRM_IOCTL_I915_REG_READ;
577-
case DrmIoctl::GetResetStats:
578-
return DRM_IOCTL_I915_GET_RESET_STATS;
579-
case DrmIoctl::GemContextGetparam:
580-
return DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM;
581-
case DrmIoctl::GemContextSetparam:
582-
return DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM;
583-
case DrmIoctl::Query:
584-
return DRM_IOCTL_I915_QUERY;
585-
case DrmIoctl::GemMmap:
586-
return DRM_IOCTL_I915_GEM_MMAP;
587-
case DrmIoctl::PrimeFdToHandle:
588-
return DRM_IOCTL_PRIME_FD_TO_HANDLE;
589-
case DrmIoctl::PrimeHandleToFd:
590-
return DRM_IOCTL_PRIME_HANDLE_TO_FD;
591555
case DrmIoctl::GemVmBind:
592556
return PRELIM_DRM_IOCTL_I915_GEM_VM_BIND;
593557
case DrmIoctl::GemVmUnbind:
@@ -612,15 +576,8 @@ unsigned int IoctlHelperPrelim20::getIoctlRequestValue(DrmIoctl ioctlRequest) {
612576
return PRELIM_DRM_IOCTL_I915_GEM_CLOS_FREE;
613577
case DrmIoctl::GemCacheReserve:
614578
return PRELIM_DRM_IOCTL_I915_GEM_CACHE_RESERVE;
615-
case DrmIoctl::GemMmapOffset:
616-
return DRM_IOCTL_I915_GEM_MMAP_OFFSET;
617-
case DrmIoctl::GemVmCreate:
618-
return DRM_IOCTL_I915_GEM_VM_CREATE;
619-
case DrmIoctl::GemVmDestroy:
620-
return DRM_IOCTL_I915_GEM_VM_DESTROY;
621579
default:
622-
UNRECOVERABLE_IF(true);
623-
return 0u;
580+
return getIoctlRequestValueBase(ioctlRequest);
624581
}
625582
}
626583

shared/source/os_interface/linux/ioctl_helper_upstream.cpp

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -234,53 +234,10 @@ bool IoctlHelperUpstream::isDebugAttachAvailable() {
234234

235235
unsigned int IoctlHelperUpstream::getIoctlRequestValue(DrmIoctl ioctlRequest) {
236236
switch (ioctlRequest) {
237-
case DrmIoctl::GemExecbuffer2:
238-
return DRM_IOCTL_I915_GEM_EXECBUFFER2;
239-
case DrmIoctl::GemWait:
240-
return DRM_IOCTL_I915_GEM_WAIT;
241-
case DrmIoctl::GemClose:
242-
return DRM_IOCTL_GEM_CLOSE;
243-
case DrmIoctl::GemUserptr:
244-
return DRM_IOCTL_I915_GEM_USERPTR;
245-
case DrmIoctl::GemCreate:
246-
return DRM_IOCTL_I915_GEM_CREATE;
247237
case DrmIoctl::GemCreateExt:
248238
return DRM_IOCTL_I915_GEM_CREATE_EXT;
249-
case DrmIoctl::GemSetDomain:
250-
return DRM_IOCTL_I915_GEM_SET_DOMAIN;
251-
case DrmIoctl::GemSetTiling:
252-
return DRM_IOCTL_I915_GEM_SET_TILING;
253-
case DrmIoctl::GemGetTiling:
254-
return DRM_IOCTL_I915_GEM_GET_TILING;
255-
case DrmIoctl::GemContextCreateExt:
256-
return DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT;
257-
case DrmIoctl::GemContextDestroy:
258-
return DRM_IOCTL_I915_GEM_CONTEXT_DESTROY;
259-
case DrmIoctl::RegRead:
260-
return DRM_IOCTL_I915_REG_READ;
261-
case DrmIoctl::GetResetStats:
262-
return DRM_IOCTL_I915_GET_RESET_STATS;
263-
case DrmIoctl::GemContextGetparam:
264-
return DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM;
265-
case DrmIoctl::GemContextSetparam:
266-
return DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM;
267-
case DrmIoctl::Query:
268-
return DRM_IOCTL_I915_QUERY;
269-
case DrmIoctl::GemMmap:
270-
return DRM_IOCTL_I915_GEM_MMAP;
271-
case DrmIoctl::PrimeFdToHandle:
272-
return DRM_IOCTL_PRIME_FD_TO_HANDLE;
273-
case DrmIoctl::PrimeHandleToFd:
274-
return DRM_IOCTL_PRIME_HANDLE_TO_FD;
275-
case DrmIoctl::GemMmapOffset:
276-
return DRM_IOCTL_I915_GEM_MMAP_OFFSET;
277-
case DrmIoctl::GemVmCreate:
278-
return DRM_IOCTL_I915_GEM_VM_CREATE;
279-
case DrmIoctl::GemVmDestroy:
280-
return DRM_IOCTL_I915_GEM_VM_DESTROY;
281239
default:
282-
UNRECOVERABLE_IF(true);
283-
return 0u;
240+
return getIoctlRequestValueBase(ioctlRequest);
284241
}
285242
}
286243

0 commit comments

Comments
 (0)