feature(sysman): supports pci module for zesInit windows

Related-To: LOCI-4204

Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
Kulkarni, Ashwin Kumar
2023-07-03 10:26:26 +00:00
committed by Compute-Runtime-Automation
parent 6f29e3b100
commit ed972bb21c
7 changed files with 620 additions and 8 deletions

View File

@@ -7,36 +7,208 @@
#include "level_zero/sysman/source/pci/windows/sysman_os_pci_imp.h"
#include "level_zero/sysman/source/windows/sysman_kmd_sys_manager.h"
#include "level_zero/sysman/source/windows/zes_os_sysman_imp.h"
namespace L0 {
namespace Sysman {
ze_result_t WddmPciImp::getProperties(zes_pci_properties_t *properties) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
properties->haveBandwidthCounters = false;
properties->havePacketCounters = false;
properties->haveReplayCounters = false;
return ZE_RESULT_SUCCESS;
}
ze_result_t WddmPciImp::getPciBdf(zes_pci_properties_t &pciProperties) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
uint32_t domain = 0, bus = 0, dev = 0, func = 0;
std::vector<KmdSysman::RequestProperty> vRequests = {};
std::vector<KmdSysman::ResponseProperty> vResponses = {};
KmdSysman::RequestProperty request = {};
request.commandId = KmdSysman::Command::Get;
request.componentId = KmdSysman::Component::PciComponent;
request.paramInfo = (isLocalMemSupported()) ? KmdSysman::PciDomainsType::PciRootPort : KmdSysman::PciDomainsType::PciCurrentDevice;
request.requestId = KmdSysman::Requests::Pci::Bus;
vRequests.push_back(request);
request.requestId = KmdSysman::Requests::Pci::Domain;
vRequests.push_back(request);
request.requestId = KmdSysman::Requests::Pci::Device;
vRequests.push_back(request);
request.requestId = KmdSysman::Requests::Pci::Function;
vRequests.push_back(request);
ze_result_t status = pKmdSysManager->requestMultiple(vRequests, vResponses);
if ((status != ZE_RESULT_SUCCESS) || (vResponses.size() != vRequests.size())) {
return status;
}
if (vResponses[0].returnCode == KmdSysman::Success) {
memcpy_s(&bus, sizeof(uint32_t), vResponses[0].dataBuffer, sizeof(uint32_t));
}
if (vResponses[1].returnCode == KmdSysman::Success) {
memcpy_s(&domain, sizeof(uint32_t), vResponses[1].dataBuffer, sizeof(uint32_t));
}
if (vResponses[2].returnCode == KmdSysman::Success) {
memcpy_s(&dev, sizeof(uint32_t), vResponses[2].dataBuffer, sizeof(uint32_t));
}
if (vResponses[3].returnCode == KmdSysman::Success) {
memcpy_s(&func, sizeof(uint32_t), vResponses[3].dataBuffer, sizeof(uint32_t));
}
pciProperties.address.domain = domain;
pciProperties.address.bus = bus;
pciProperties.address.device = dev;
pciProperties.address.function = func;
return ZE_RESULT_SUCCESS;
}
void WddmPciImp::getMaxLinkCaps(double &maxLinkSpeed, int32_t &maxLinkWidth) {}
void WddmPciImp::getMaxLinkCaps(double &maxLinkSpeed, int32_t &maxLinkWidth) {
uint32_t valueSmall = 0;
KmdSysman::RequestProperty request;
KmdSysman::ResponseProperty response;
request.commandId = KmdSysman::Command::Get;
request.componentId = KmdSysman::Component::PciComponent;
request.requestId = KmdSysman::Requests::Pci::MaxLinkSpeed;
request.paramInfo = (isLocalMemSupported()) ? KmdSysman::PciDomainsType::PciRootPort : KmdSysman::PciDomainsType::PciCurrentDevice;
ze_result_t status = pKmdSysManager->requestSingle(request, response);
if (status != ZE_RESULT_SUCCESS) {
maxLinkSpeed = 0;
} else {
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
maxLinkSpeed = convertPciGenToLinkSpeed(valueSmall);
}
request.requestId = KmdSysman::Requests::Pci::MaxLinkWidth;
status = pKmdSysManager->requestSingle(request, response);
if (status != ZE_RESULT_SUCCESS) {
maxLinkWidth = -1;
return;
}
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
maxLinkWidth = static_cast<int32_t>(valueSmall);
return;
}
ze_result_t WddmPciImp::getState(zes_pci_state_t *state) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
uint32_t valueSmall = 0;
std::vector<KmdSysman::RequestProperty> vRequests = {};
std::vector<KmdSysman::ResponseProperty> vResponses = {};
KmdSysman::RequestProperty request = {};
state->qualityIssues = ZES_PCI_LINK_QUAL_ISSUE_FLAG_FORCE_UINT32;
state->stabilityIssues = ZES_PCI_LINK_STAB_ISSUE_FLAG_FORCE_UINT32;
state->status = ZES_PCI_LINK_STATUS_FORCE_UINT32;
state->speed.gen = -1;
state->speed.width = -1;
state->speed.maxBandwidth = -1;
request.commandId = KmdSysman::Command::Get;
request.componentId = KmdSysman::Component::PciComponent;
request.paramInfo = (isLocalMemSupported()) ? KmdSysman::PciDomainsType::PciRootPort : KmdSysman::PciDomainsType::PciCurrentDevice;
request.requestId = KmdSysman::Requests::Pci::CurrentLinkSpeed;
vRequests.push_back(request);
request.requestId = KmdSysman::Requests::Pci::CurrentLinkWidth;
vRequests.push_back(request);
ze_result_t status = pKmdSysManager->requestMultiple(vRequests, vResponses);
if ((status != ZE_RESULT_SUCCESS) || (vResponses.size() != vRequests.size())) {
return status;
}
if (vResponses[0].returnCode == KmdSysman::Success) {
memcpy_s(&valueSmall, sizeof(uint32_t), vResponses[0].dataBuffer, sizeof(uint32_t));
state->speed.gen = static_cast<int32_t>(valueSmall);
}
if (vResponses[1].returnCode == KmdSysman::Success) {
memcpy_s(&valueSmall, sizeof(uint32_t), vResponses[1].dataBuffer, sizeof(uint32_t));
state->speed.width = static_cast<int32_t>(valueSmall);
}
double currentLinkSpeed = convertPciGenToLinkSpeed(state->speed.gen);
state->speed.maxBandwidth = state->speed.width * convertPcieSpeedFromGTsToBs(currentLinkSpeed);
if (state->speed.maxBandwidth == 0) {
state->speed.maxBandwidth = -1;
}
return ZE_RESULT_SUCCESS;
}
bool WddmPciImp::resizableBarSupported() {
return false;
uint32_t valueSmall = 0;
bool supported = false;
KmdSysman::RequestProperty request;
KmdSysman::ResponseProperty response;
request.commandId = KmdSysman::Command::Get;
request.componentId = KmdSysman::Component::PciComponent;
request.paramInfo = KmdSysman::PciDomainsType::PciCurrentDevice;
request.requestId = KmdSysman::Requests::Pci::ResizableBarSupported;
if (pKmdSysManager->requestSingle(request, response) == ZE_RESULT_SUCCESS) {
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
supported = static_cast<bool>(valueSmall);
}
return supported;
}
bool WddmPciImp::resizableBarEnabled(uint32_t barIndex) {
return false;
uint32_t valueSmall = 0;
bool enabled = false;
KmdSysman::RequestProperty request;
KmdSysman::ResponseProperty response;
request.commandId = KmdSysman::Command::Get;
request.componentId = KmdSysman::Component::PciComponent;
request.paramInfo = KmdSysman::PciDomainsType::PciCurrentDevice;
request.requestId = KmdSysman::Requests::Pci::ResizableBarEnabled;
if (pKmdSysManager->requestSingle(request, response) == ZE_RESULT_SUCCESS) {
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
enabled = static_cast<bool>(valueSmall);
}
return enabled;
}
ze_result_t WddmPciImp::initializeBarProperties(std::vector<zes_pci_bar_properties_t *> &pBarProperties) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
zes_pci_bar_properties_t *pBarProp = new zes_pci_bar_properties_t;
memset(pBarProp, 0, sizeof(zes_pci_bar_properties_t));
pBarProperties.push_back(pBarProp);
return ZE_RESULT_SUCCESS;
}
WddmPciImp::WddmPciImp(OsSysman *pOsSysman) {}
WddmPciImp::WddmPciImp(OsSysman *pOsSysman) {
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
pKmdSysManager = &pWddmSysmanImp->getKmdSysManager();
isLmemSupported = !(pWddmSysmanImp->getSysmanDeviceImp()->getRootDeviceEnvironment().getHardwareInfo()->capabilityTable.isIntegratedDevice);
}
bool WddmPciImp::isLocalMemSupported() {
return isLmemSupported;
}
OsPci *OsPci::create(OsSysman *pOsSysman) {
WddmPciImp *pWddmPciImp = new WddmPciImp(pOsSysman);

View File

@@ -13,6 +13,7 @@
namespace L0 {
namespace Sysman {
struct OsSysman;
class KmdSysManager;
class WddmPciImp : public OsPci, NEO::NonCopyableOrMovableClass {
public:
ze_result_t getPciBdf(zes_pci_properties_t &pciProperties) override;
@@ -24,6 +25,13 @@ class WddmPciImp : public OsPci, NEO::NonCopyableOrMovableClass {
ze_result_t initializeBarProperties(std::vector<zes_pci_bar_properties_t *> &pBarProperties) override;
WddmPciImp(OsSysman *pOsSysman);
~WddmPciImp() override = default;
bool isLocalMemSupported();
protected:
KmdSysManager *pKmdSysManager = nullptr;
private:
bool isLmemSupported = false;
};
} // namespace Sysman

View File

@@ -42,6 +42,10 @@ uint32_t WddmSysmanImp::getSubDeviceCount() {
return subDeviceCount;
}
SysmanDeviceImp *WddmSysmanImp::getSysmanDeviceImp() {
return pParentSysmanDeviceImp;
}
void WddmSysmanImp::createFwUtilInterface() {
const auto pciBusInfo = pParentSysmanDeviceImp->getRootDeviceEnvironment().osInterface->getDriverModel()->getPciBusInfo();
const uint16_t domain = static_cast<uint16_t>(pciBusInfo.pciDomain);

View File

@@ -33,6 +33,7 @@ class WddmSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
void releaseFwUtilInterface();
uint32_t getSubDeviceCount() override;
SysmanDeviceImp *getSysmanDeviceImp();
protected:
FirmwareUtil *pFwUtilInterface = nullptr;