update Sysman PCI APIs to lastest Spec

Change-Id: Ie4daf2eb3596f05f824579eff3fe811ebb2f2032
This commit is contained in:
Vilvaraj, T J Vivek
2020-07-23 07:04:28 +05:30
committed by sys_ocldev
parent 171c40d58a
commit a6ea7ab7db
14 changed files with 173 additions and 124 deletions

View File

@@ -74,7 +74,7 @@ ze_result_t LinuxPciImp::getMaxLinkSpeed(double &maxLinkSpeed) {
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxPciImp::getMaxLinkWidth(uint32_t &maxLinkwidth) {
ze_result_t LinuxPciImp::getMaxLinkWidth(int32_t &maxLinkwidth) {
ze_result_t result;
if (isLmemSupported) {
std::string rootPortPath;
@@ -85,30 +85,30 @@ ze_result_t LinuxPciImp::getMaxLinkWidth(uint32_t &maxLinkwidth) {
// the root port is always at a fixed distance as defined in HW
rootPortPath = changeDirNLevelsUp(realRootPath, 2);
if (ZE_RESULT_SUCCESS != result) {
maxLinkwidth = 0;
maxLinkwidth = -1;
return result;
}
result = pfsAccess->read(rootPortPath + '/' + "max_link_width", maxLinkwidth);
if (ZE_RESULT_SUCCESS != result) {
maxLinkwidth = 0;
maxLinkwidth = -1;
return result;
}
if (maxLinkwidth == static_cast<uint32_t>(unknownPcieLinkWidth)) {
maxLinkwidth = 0;
if (maxLinkwidth == static_cast<int32_t>(unknownPcieLinkWidth)) {
maxLinkwidth = -1;
}
} else {
result = pSysfsAccess->read(maxLinkWidthFile, maxLinkwidth);
if (ZE_RESULT_SUCCESS != result) {
return result;
}
if (maxLinkwidth == static_cast<uint32_t>(unknownPcieLinkWidth)) {
maxLinkwidth = 0;
if (maxLinkwidth == static_cast<int32_t>(unknownPcieLinkWidth)) {
maxLinkwidth = -1;
}
}
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxPciImp::getLinkGen(uint32_t &linkGen) {
ze_result_t LinuxPciImp::getLinkGen(int32_t &linkGen) {
double maxLinkSpeed;
getMaxLinkSpeed(maxLinkSpeed);
if (maxLinkSpeed == 2.5) {
@@ -122,7 +122,7 @@ ze_result_t LinuxPciImp::getLinkGen(uint32_t &linkGen) {
} else if (maxLinkSpeed == 32) {
linkGen = 5;
} else {
linkGen = 0;
linkGen = -1;
}
return ZE_RESULT_SUCCESS;
@@ -152,18 +152,20 @@ ze_result_t LinuxPciImp::initializeBarProperties(std::vector<zes_pci_bar_propert
for (uint32_t i = 0; i <= maxPciBars; i++) {
uint64_t baseAddr, barSize, barFlags;
getBarBaseAndSize(ReadBytes[i], baseAddr, barSize, barFlags);
if (baseAddr) {
if (baseAddr && !(barFlags & 0x1)) { // we do not update for I/O ports
zes_pci_bar_properties_t *pBarProp = new zes_pci_bar_properties_t;
pBarProp->index = i;
pBarProp->base = baseAddr;
pBarProp->size = barSize;
// Bar Flags Desc.
// Bit-0 - Value 0x0 -> MMIO type BAR
// Bit-0 - Value 0x1 -> I/O Type BAR
// Bit-1 - Reserved
// Bit-2 - Valid only for MMIO type BAR
// Value 0x1 -> 64bit BAR*/
pBarProp->type = ZES_PCI_BAR_TYPE_MMIO;
// Bit-0 - Value 0x1 -> I/O type BAR
if (i == 0) { // GRaphics MMIO is at BAR0, and is a 64-bit
pBarProp->type = ZES_PCI_BAR_TYPE_MMIO;
}
if (i == 2) {
pBarProp->type = ZES_PCI_BAR_TYPE_MEM; // device memory is always at BAR2
}
if (i == 6) { // the 7th entry of resource file is expected to be ROM BAR
pBarProp->type = ZES_PCI_BAR_TYPE_ROM;
}

View File

@@ -19,8 +19,8 @@ class LinuxPciImp : public OsPci, NEO::NonCopyableOrMovableClass {
public:
ze_result_t getPciBdf(std::string &bdf) override;
ze_result_t getMaxLinkSpeed(double &maxLinkSpeed) override;
ze_result_t getMaxLinkWidth(uint32_t &maxLinkwidth) override;
ze_result_t getLinkGen(uint32_t &linkGen) override;
ze_result_t getMaxLinkWidth(int32_t &maxLinkwidth) override;
ze_result_t getLinkGen(int32_t &linkGen) override;
void setLmemSupport(bool val) override;
ze_result_t initializeBarProperties(std::vector<zes_pci_bar_properties_t *> &pBarProperties) override;
LinuxPciImp() = default;

View File

@@ -19,8 +19,8 @@ class OsPci {
public:
virtual ze_result_t getPciBdf(std::string &bdf) = 0;
virtual ze_result_t getMaxLinkSpeed(double &maxLinkSpeed) = 0;
virtual ze_result_t getMaxLinkWidth(uint32_t &maxLinkWidth) = 0;
virtual ze_result_t getLinkGen(uint32_t &linkGen) = 0;
virtual ze_result_t getMaxLinkWidth(int32_t &maxLinkWidth) = 0;
virtual ze_result_t getLinkGen(int32_t &linkGen) = 0;
virtual void setLmemSupport(bool val) = 0;
virtual ze_result_t initializeBarProperties(std::vector<zes_pci_bar_properties_t *> &pBarProperties) = 0;
static OsPci *create(OsSysman *pOsSysman);

View File

@@ -23,7 +23,7 @@ namespace L0 {
// pcieSpeedWithEnc = maxLinkSpeedInGt * (Gigabit to Megabit) * Encoding =
// maxLinkSpeedInGt * 1000 * Encoding
//
uint64_t convertPcieSpeedFromGTsToBs(double maxLinkSpeedInGt) {
int64_t convertPcieSpeedFromGTsToBs(double maxLinkSpeedInGt) {
double pcieSpeedWithEnc;
if ((maxLinkSpeedInGt == 16) || (maxLinkSpeedInGt == 8)) {
pcieSpeedWithEnc = maxLinkSpeedInGt * 1000 * 128 / 130;
@@ -39,7 +39,7 @@ uint64_t convertPcieSpeedFromGTsToBs(double maxLinkSpeedInGt) {
// Now, because 1Mb/s = (1000*1000)/8 bytes/second = 125000 bytes/second
//
pcieSpeedWithEnc = pcieSpeedWithEnc * 125000;
return static_cast<uint64_t>(pcieSpeedWithEnc);
return static_cast<int64_t>(pcieSpeedWithEnc);
}
ze_result_t PciImp::pciStaticProperties(zes_pci_properties_t *pProperties) {
@@ -80,14 +80,17 @@ void PciImp::init() {
&pciProperties.address.device, &pciProperties.address.function);
}
uint32_t maxLinkWidth = 0, gen = 0;
uint64_t maxBandWidth = 0;
int32_t maxLinkWidth = -1, gen = -1;
int64_t maxBandWidth = -1;
double maxLinkSpeed = 0;
pOsPci->getMaxLinkSpeed(maxLinkSpeed);
pOsPci->getMaxLinkWidth(maxLinkWidth);
maxBandWidth = maxLinkWidth * convertPcieSpeedFromGTsToBs(maxLinkSpeed);
pciProperties.maxSpeed.maxBandwidth = maxBandWidth;
if (maxBandWidth == 0) {
pciProperties.maxSpeed.maxBandwidth = -1;
} else {
pciProperties.maxSpeed.maxBandwidth = maxBandWidth;
}
pciProperties.maxSpeed.width = maxLinkWidth;
pOsPci->getLinkGen(gen);
pciProperties.maxSpeed.gen = gen;

View File

@@ -14,8 +14,8 @@ class WddmPciImp : public OsPci {
public:
ze_result_t getPciBdf(std::string &bdf) override;
ze_result_t getMaxLinkSpeed(double &maxLinkSpeed) override;
ze_result_t getMaxLinkWidth(uint32_t &maxLinkwidth) override;
ze_result_t getLinkGen(uint32_t &linkGen) override;
ze_result_t getMaxLinkWidth(int32_t &maxLinkwidth) override;
ze_result_t getLinkGen(int32_t &linkGen) override;
void setLmemSupport(bool val) override;
ze_result_t initializeBarProperties(std::vector<zes_pci_bar_properties_t *> &pBarProperties) override;
~WddmPciImp() override = default;
@@ -29,11 +29,11 @@ ze_result_t WddmPciImp::getMaxLinkSpeed(double &maxLinkSpeed) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t WddmPciImp::getMaxLinkWidth(uint32_t &maxLinkwidth) {
ze_result_t WddmPciImp::getMaxLinkWidth(int32_t &maxLinkwidth) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t WddmPciImp::getLinkGen(uint32_t &linkGen) {
ze_result_t WddmPciImp::getLinkGen(int32_t &linkGen) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}