2021-10-13 13:30:46 +00:00
/*
2023-01-18 20:22:32 +00:00
* Copyright ( C ) 2021 - 2023 Intel Corporation
2021-10-13 13:30:46 +00:00
*
* SPDX - License - Identifier : MIT
*
*/
# include "shared/source/debug_settings/debug_settings_manager.h"
2022-04-11 17:13:44 +00:00
# include "shared/source/helpers/common_types.h"
2021-12-10 12:55:55 +00:00
# include "shared/source/os_interface/linux/cache_info.h"
2022-05-17 21:40:34 +00:00
# include "shared/source/os_interface/linux/drm_wrappers.h"
2022-07-15 13:12:14 +02:00
# include "shared/source/os_interface/linux/i915_upstream.h"
2021-12-01 11:45:29 +00:00
# include "shared/source/os_interface/linux/ioctl_helper.h"
2021-10-13 13:30:46 +00:00
namespace NEO {
2022-09-12 12:50:07 +00:00
bool IoctlHelperUpstream : : initialize ( ) {
return true ;
}
2022-09-20 07:07:59 +00:00
bool IoctlHelperUpstream : : isSetPairAvailable ( ) {
return false ;
}
2023-03-08 04:06:00 +00:00
bool IoctlHelperUpstream : : isChunkingAvailable ( ) {
return false ;
}
2022-06-29 16:49:29 +00:00
bool IoctlHelperUpstream : : isVmBindAvailable ( ) {
2022-02-15 09:33:27 +00:00
return false ;
}
2023-07-02 04:46:49 +02:00
int IoctlHelperUpstream : : createGemExt ( const MemRegionsVec & memClassInstances , size_t allocSize , uint32_t & handle , std : : optional < uint32_t > vmId , int32_t pairHandle , bool isChunked , uint32_t numOfChunks ) {
2021-12-22 14:25:53 +00:00
uint32_t regionsSize = static_cast < uint32_t > ( memClassInstances . size ( ) ) ;
2021-12-28 13:19:45 +00:00
std : : vector < drm_i915_gem_memory_class_instance > regions ( regionsSize ) ;
2021-12-22 14:25:53 +00:00
for ( uint32_t i = 0 ; i < regionsSize ; i + + ) {
2021-12-28 13:19:45 +00:00
regions [ i ] . memory_class = memClassInstances [ i ] . memoryClass ;
regions [ i ] . memory_instance = memClassInstances [ i ] . memoryInstance ;
2021-12-22 14:25:53 +00:00
}
2021-12-14 09:46:01 +00:00
drm_i915_gem_create_ext_memory_regions memRegions { } ;
2021-12-22 14:25:53 +00:00
memRegions . num_regions = regionsSize ;
2021-12-28 13:19:45 +00:00
memRegions . regions = reinterpret_cast < uintptr_t > ( regions . data ( ) ) ;
2021-10-13 13:30:46 +00:00
memRegions . base . name = I915_GEM_CREATE_EXT_MEMORY_REGIONS ;
drm_i915_gem_create_ext createExt { } ;
createExt . size = allocSize ;
createExt . extensions = reinterpret_cast < uintptr_t > ( & memRegions ) ;
2023-07-02 04:46:49 +02:00
printDebugString ( DebugManager . flags . PrintBOCreateDestroyResult . get ( ) , stdout , " Performing GEM_CREATE_EXT with { size: %lu " ,
allocSize ) ;
2021-10-13 13:30:46 +00:00
if ( DebugManager . flags . PrintBOCreateDestroyResult . get ( ) ) {
2021-12-22 14:25:53 +00:00
for ( uint32_t i = 0 ; i < regionsSize ; i + + ) {
2021-12-28 13:19:45 +00:00
auto region = regions [ i ] ;
2021-10-13 13:30:46 +00:00
printDebugString ( DebugManager . flags . PrintBOCreateDestroyResult . get ( ) , stdout , " , memory class: %d, memory instance: %d " ,
region . memory_class , region . memory_instance ) ;
}
printDebugString ( DebugManager . flags . PrintBOCreateDestroyResult . get ( ) , stdout , " %s " , " } \n " ) ;
}
2022-06-29 16:49:29 +00:00
auto ret = ioctl ( DrmIoctl : : GemCreateExt , & createExt ) ;
2023-06-28 17:27:53 +02:00
2023-07-02 04:46:49 +02:00
printDebugString ( DebugManager . flags . PrintBOCreateDestroyResult . get ( ) , stdout , " GEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: %d BO-%u with size: %lu \n " , ret , createExt . handle , createExt . size ) ;
handle = createExt . handle ;
2021-10-13 13:30:46 +00:00
return ret ;
}
2022-06-29 16:49:29 +00:00
CacheRegion IoctlHelperUpstream : : closAlloc ( ) {
2021-12-10 12:55:55 +00:00
return CacheRegion : : None ;
}
2022-06-29 16:49:29 +00:00
uint16_t IoctlHelperUpstream : : closAllocWays ( CacheRegion closIndex , uint16_t cacheLevel , uint16_t numWays ) {
2021-12-10 12:55:55 +00:00
return 0 ;
}
2022-06-29 16:49:29 +00:00
CacheRegion IoctlHelperUpstream : : closFree ( CacheRegion closIndex ) {
2021-12-10 12:55:55 +00:00
return CacheRegion : : None ;
}
2022-06-29 16:49:29 +00:00
int IoctlHelperUpstream : : waitUserFence ( uint32_t ctxId , uint64_t address ,
2021-12-14 09:46:01 +00:00
uint64_t value , uint32_t dataWidth , int64_t timeout , uint16_t flags ) {
return 0 ;
}
2021-12-14 14:09:19 +00:00
uint32_t IoctlHelperUpstream : : getAtomicAdvise ( bool isNonAtomic ) {
return 0 ;
}
uint32_t IoctlHelperUpstream : : getPreferredLocationAdvise ( ) {
return 0 ;
}
2023-04-21 00:36:45 +00:00
std : : optional < MemoryClassInstance > IoctlHelperUpstream : : getPreferredLocationRegion ( PreferredLocation memoryLocation , uint32_t memoryInstance ) {
2023-03-30 12:42:02 +00:00
return std : : nullopt ;
}
2022-06-29 16:49:29 +00:00
bool IoctlHelperUpstream : : setVmBoAdvise ( int32_t handle , uint32_t attribute , void * region ) {
2021-12-14 14:09:19 +00:00
return true ;
}
2023-03-08 04:06:00 +00:00
bool IoctlHelperUpstream : : setVmBoAdviseForChunking ( int32_t handle , uint64_t start , uint64_t length , uint32_t attribute , void * region ) {
return true ;
}
2022-11-15 12:15:28 +00:00
bool IoctlHelperUpstream : : setVmPrefetch ( uint64_t start , uint64_t length , uint32_t region , uint32_t vmId ) {
2022-03-02 13:38:28 +00:00
return true ;
}
2021-12-14 12:41:38 +00:00
uint32_t IoctlHelperUpstream : : getDirectSubmissionFlag ( ) {
return 0u ;
}
2022-02-14 19:34:50 +00:00
std : : unique_ptr < uint8_t [ ] > IoctlHelperUpstream : : prepareVmBindExt ( const StackVec < uint32_t , 2 > & bindExtHandles ) {
return { } ;
}
2022-02-28 13:56:41 +00:00
2022-02-14 19:34:50 +00:00
uint64_t IoctlHelperUpstream : : getFlagsForVmBind ( bool bindCapture , bool bindImmediate , bool bindMakeResident ) {
return 0u ;
}
2023-01-18 20:22:32 +00:00
int IoctlHelperUpstream : : queryDistances ( std : : vector < QueryItem > & queryItems , std : : vector < DistanceInfo > & distanceInfos ) {
2022-01-03 14:16:00 +00:00
for ( auto & query : queryItems ) {
query . length = - EINVAL ;
}
return 0 ;
}
2022-02-11 15:03:58 +00:00
uint16_t IoctlHelperUpstream : : getWaitUserFenceSoftFlag ( ) {
return 0 ;
2022-02-28 13:56:41 +00:00
}
2022-02-11 15:03:58 +00:00
2022-11-22 13:53:59 +00:00
int IoctlHelperUpstream : : execBuffer ( ExecBuffer * execBuffer , uint64_t completionGpuAddress , TaskCountType counterValue ) {
2022-06-29 16:49:29 +00:00
return ioctl ( DrmIoctl : : GemExecbuffer2 , execBuffer ) ;
2022-01-19 18:14:10 +00:00
}
2022-05-27 11:01:46 +00:00
bool IoctlHelperUpstream : : completionFenceExtensionSupported ( const bool isVmBindAvailable ) {
2022-01-20 18:13:07 +00:00
return false ;
}
2022-06-06 15:48:31 +00:00
std : : optional < DrmParam > IoctlHelperUpstream : : getHasPageFaultParamId ( ) {
2022-02-10 16:16:37 +00:00
return std : : nullopt ;
2022-02-12 18:53:38 +01:00
} ;
2022-02-28 13:56:41 +00:00
2022-05-26 15:00:06 +00:00
bool IoctlHelperUpstream : : getEuStallProperties ( std : : array < uint64_t , 12u > & properties , uint64_t dssBufferSize ,
uint64_t samplingRate , uint64_t pollPeriod , uint64_t engineInstance ,
uint64_t notifyNReports ) {
2022-02-03 13:26:53 +00:00
return false ;
}
uint32_t IoctlHelperUpstream : : getEuStallFdParameter ( ) {
return 0u ;
}
2022-02-10 16:16:37 +00:00
2022-02-15 16:46:35 +00:00
std : : unique_ptr < uint8_t [ ] > IoctlHelperUpstream : : createVmControlExtRegion ( const std : : optional < MemoryClassInstance > & regionInstanceClass ) {
return { } ;
}
2022-04-21 16:59:48 +00:00
uint32_t IoctlHelperUpstream : : getFlagsForVmCreate ( bool disableScratch , bool enablePageFault , bool useVmBind ) {
2022-02-15 16:46:35 +00:00
return 0u ;
}
2022-06-29 16:49:29 +00:00
uint32_t IoctlHelperUpstream : : createContextWithAccessCounters ( GemContextCreateExt & gcc ) {
2022-02-14 16:26:25 +00:00
return EINVAL ;
}
2022-02-28 13:56:41 +00:00
2022-06-29 16:49:29 +00:00
uint32_t IoctlHelperUpstream : : createCooperativeContext ( GemContextCreateExt & gcc ) {
2022-02-14 16:26:25 +00:00
return EINVAL ;
}
2022-02-15 12:56:31 +00:00
2022-04-05 17:04:53 +02:00
void IoctlHelperUpstream : : fillVmBindExtSetPat ( VmBindExtSetPatT & vmBindExtSetPat , uint64_t patIndex , uint64_t nextExtension ) { }
2022-02-28 13:56:41 +00:00
2022-04-05 17:04:53 +02:00
void IoctlHelperUpstream : : fillVmBindExtUserFence ( VmBindExtUserFenceT & vmBindExtUserFence , uint64_t fenceAddress , uint64_t fenceValue , uint64_t nextExtension ) { }
2022-02-15 12:56:31 +00:00
std : : optional < uint64_t > IoctlHelperUpstream : : getCopyClassSaturatePCIECapability ( ) {
return std : : nullopt ;
}
std : : optional < uint64_t > IoctlHelperUpstream : : getCopyClassSaturateLinkCapability ( ) {
return std : : nullopt ;
}
2022-03-21 16:02:12 +00:00
uint32_t IoctlHelperUpstream : : getVmAdviseAtomicAttribute ( ) {
return 0 ;
}
2022-06-29 16:49:29 +00:00
int IoctlHelperUpstream : : vmBind ( const VmBindParams & vmBindParams ) {
2022-02-15 14:54:16 +00:00
return 0 ;
}
2022-02-28 13:56:41 +00:00
2022-06-29 16:49:29 +00:00
int IoctlHelperUpstream : : vmUnbind ( const VmBindParams & vmBindParams ) {
2022-02-15 14:54:16 +00:00
return 0 ;
}
2022-02-28 13:56:41 +00:00
2022-06-29 16:49:29 +00:00
UuidRegisterResult IoctlHelperUpstream : : registerUuid ( const std : : string & uuid , uint32_t uuidClass , uint64_t ptr , uint64_t size ) {
2022-02-28 13:56:41 +00:00
return { 0 , 0 } ;
}
2022-06-29 16:49:29 +00:00
UuidRegisterResult IoctlHelperUpstream : : registerStringClassUuid ( const std : : string & uuid , uint64_t ptr , uint64_t size ) {
2022-02-28 13:56:41 +00:00
return { 0 , 0 } ;
}
2022-06-29 16:49:29 +00:00
int IoctlHelperUpstream : : unregisterUuid ( uint32_t handle ) {
2022-02-28 13:56:41 +00:00
return 0 ;
}
2022-06-29 16:49:29 +00:00
bool IoctlHelperUpstream : : isContextDebugSupported ( ) {
2022-02-28 13:56:41 +00:00
return false ;
}
2022-06-29 16:49:29 +00:00
int IoctlHelperUpstream : : setContextDebugFlag ( uint32_t drmContextId ) {
2022-02-28 13:56:41 +00:00
return 0 ;
}
2022-03-25 18:51:25 +00:00
bool IoctlHelperUpstream : : isDebugAttachAvailable ( ) {
return false ;
}
2022-06-03 13:57:42 +00:00
unsigned int IoctlHelperUpstream : : getIoctlRequestValue ( DrmIoctl ioctlRequest ) const {
2022-05-31 20:11:40 +02:00
switch ( ioctlRequest ) {
case DrmIoctl : : GemCreateExt :
2022-05-25 17:05:52 +00:00
return DRM_IOCTL_I915_GEM_CREATE_EXT ;
2022-05-31 20:11:40 +02:00
default :
2022-06-01 18:53:00 +00:00
return getIoctlRequestValueBase ( ioctlRequest ) ;
2022-05-25 17:05:52 +00:00
}
}
2022-06-01 13:04:38 +00:00
int IoctlHelperUpstream : : getDrmParamValue ( DrmParam drmParam ) const {
switch ( drmParam ) {
case DrmParam : : EngineClassCompute :
return 4 ;
2022-06-01 16:03:01 +00:00
case DrmParam : : QueryHwconfigTable :
2023-05-18 08:31:32 +02:00
return DRM_I915_QUERY_HWCONFIG_BLOB ;
2022-06-01 18:35:56 +00:00
case DrmParam : : QueryComputeSlices :
return 0 ;
2022-06-01 13:04:38 +00:00
default :
return getDrmParamValueBase ( drmParam ) ;
}
}
2022-07-14 15:32:26 +00:00
std : : string IoctlHelperUpstream : : getDrmParamString ( DrmParam param ) const {
return getDrmParamStringBase ( param ) ;
}
std : : string IoctlHelperUpstream : : getIoctlString ( DrmIoctl ioctlRequest ) const {
switch ( ioctlRequest ) {
case DrmIoctl : : GemCreateExt :
return " DRM_IOCTL_I915_GEM_CREATE_EXT " ;
default :
return getIoctlStringBase ( ioctlRequest ) ;
}
}
2022-09-30 12:57:38 +00:00
2022-10-25 07:21:48 +00:00
bool IoctlHelperUpstream : : getFabricLatency ( uint32_t fabricId , uint32_t & latency , uint32_t & bandwidth ) {
2022-09-30 12:57:38 +00:00
return false ;
}
2023-03-17 13:00:44 +00:00
bool IoctlHelperUpstream : : isWaitBeforeBindRequired ( bool bind ) const {
return false ;
}
2021-10-13 13:30:46 +00:00
} // namespace NEO