mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 16:48:45 +08:00
The new classes SysmanKmdInterface, SysmanKmdInterfaceI915 and SysmanKmdInterfaceXe have been introduced. A map is maintained in the SysmanKmdInterfaceI915 and SysmanKmdInterfaceXe class for the sysfs file names. The access specifier of the function getDrmVersion has been changed from protected to public so as to use it in the sysman code. This is required for the SysmanKmdInterface pointer to point to the SysmanKmdInterfaceI915 and SysmanKmdInterfaceXe accordingly. The ULTs have been added for the new sysfs file path corresponding to the i915 and the Xe driver. Related-To: LOCI-4399 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
120 lines
4.3 KiB
C++
120 lines
4.3 KiB
C++
/*
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
|
#include "shared/source/os_interface/os_interface.h"
|
|
|
|
#include "level_zero/core/source/device/device.h"
|
|
#include "level_zero/tools/source/sysman/linux/fs_access.h"
|
|
#include "level_zero/tools/source/sysman/linux/pmt/pmt.h"
|
|
#include "level_zero/tools/source/sysman/linux/pmu/pmu_imp.h"
|
|
#include "level_zero/tools/source/sysman/linux/udev/udev_lib.h"
|
|
#include "level_zero/tools/source/sysman/sysman_const.h"
|
|
#include "level_zero/tools/source/sysman/sysman_imp.h"
|
|
|
|
#include <map>
|
|
#include <mutex>
|
|
|
|
namespace L0 {
|
|
namespace Sysman {
|
|
class SysmanKmdInterface;
|
|
} // namespace Sysman
|
|
} // namespace L0
|
|
|
|
namespace L0 {
|
|
|
|
class PmuInterface;
|
|
class FirmwareUtil;
|
|
|
|
class ExecutionEnvironmentRefCountRestore {
|
|
public:
|
|
ExecutionEnvironmentRefCountRestore() = delete;
|
|
ExecutionEnvironmentRefCountRestore(NEO::ExecutionEnvironment *executionEnvironmentRecevied) {
|
|
executionEnvironment = executionEnvironmentRecevied;
|
|
executionEnvironment->incRefInternal();
|
|
}
|
|
~ExecutionEnvironmentRefCountRestore() {
|
|
executionEnvironment->decRefInternal();
|
|
}
|
|
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
|
|
};
|
|
|
|
class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
|
public:
|
|
LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp);
|
|
~LinuxSysmanImp() override;
|
|
|
|
ze_result_t init() override;
|
|
|
|
PmuInterface *getPmuInterface();
|
|
FirmwareUtil *getFwUtilInterface();
|
|
FsAccess &getFsAccess();
|
|
ProcfsAccess &getProcfsAccess();
|
|
SysfsAccess &getSysfsAccess();
|
|
NEO::Drm &getDrm();
|
|
PlatformMonitoringTech *getPlatformMonitoringTechAccess(uint32_t subDeviceId);
|
|
Device *getDeviceHandle();
|
|
std::vector<ze_device_handle_t> &getDeviceHandles() override;
|
|
ze_device_handle_t getCoreDeviceHandle() override;
|
|
SysmanDeviceImp *getSysmanDeviceImp();
|
|
std::string getPciCardBusDirectoryPath(std::string realPciPath);
|
|
uint32_t getMemoryType();
|
|
static std::string getPciRootPortDirectoryPath(std::string realPciPath);
|
|
void releasePmtObject();
|
|
ze_result_t createPmtHandles();
|
|
void createFwUtilInterface();
|
|
void releaseFwUtilInterface();
|
|
void releaseLocalDrmHandle();
|
|
void releaseSysmanDeviceResources();
|
|
MOCKABLE_VIRTUAL void releaseDeviceResources();
|
|
MOCKABLE_VIRTUAL ze_result_t initDevice();
|
|
void reInitSysmanDeviceResources();
|
|
MOCKABLE_VIRTUAL void getPidFdsForOpenDevice(ProcfsAccess *, SysfsAccess *, const ::pid_t, std::vector<int> &);
|
|
MOCKABLE_VIRTUAL ze_result_t osWarmReset();
|
|
MOCKABLE_VIRTUAL ze_result_t osColdReset();
|
|
ze_result_t gpuProcessCleanup();
|
|
std::string getAddressFromPath(std::string &rootPortPath);
|
|
decltype(&NEO::SysCalls::open) openFunction = NEO::SysCalls::open;
|
|
decltype(&NEO::SysCalls::close) closeFunction = NEO::SysCalls::close;
|
|
decltype(&NEO::SysCalls::pread) preadFunction = NEO::SysCalls::pread;
|
|
decltype(&NEO::SysCalls::pwrite) pwriteFunction = NEO::SysCalls::pwrite;
|
|
std::string devicePciBdf = "";
|
|
uint32_t rootDeviceIndex = 0u;
|
|
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
|
|
bool diagnosticsReset = false;
|
|
bool isMemoryDiagnostics = false;
|
|
Device *pDevice = nullptr;
|
|
std::string gtDevicePath;
|
|
L0::Sysman::SysmanKmdInterface *getSysmanKmdInterface() { return pSysmanKmdInterface.get(); }
|
|
|
|
protected:
|
|
std::unique_ptr<L0::Sysman::SysmanKmdInterface> pSysmanKmdInterface;
|
|
FsAccess *pFsAccess = nullptr;
|
|
ProcfsAccess *pProcfsAccess = nullptr;
|
|
SysfsAccess *pSysfsAccess = nullptr;
|
|
NEO::Drm *pDrm = nullptr;
|
|
PmuInterface *pPmuInterface = nullptr;
|
|
FirmwareUtil *pFwUtilInterface = nullptr;
|
|
std::map<uint32_t, L0::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject;
|
|
ze_result_t initLocalDeviceAndDrmHandles();
|
|
uint32_t memType = unknownMemoryType;
|
|
|
|
private:
|
|
bool isMemTypeRetrieved = false;
|
|
LinuxSysmanImp() = delete;
|
|
SysmanDeviceImp *pParentSysmanDeviceImp = nullptr;
|
|
static const std::string deviceDir;
|
|
void clearHPIE(int fd);
|
|
ze_result_t resizeVfBar(uint8_t size);
|
|
std::mutex fwLock;
|
|
};
|
|
|
|
} // namespace L0
|