From 935acf11de5f5445cca2c196a79473fdb532c6c3 Mon Sep 17 00:00:00 2001 From: Shivangi Agarwal Date: Tue, 12 May 2020 09:55:34 -0700 Subject: [PATCH] CR-1032457 Display warning if OS or Kernel isn't officially supported (#3373) --- .../core/pcie/tools/xbutil/xbutil.cpp | 50 +++++++++++++++++++ .../core/pcie/tools/xbutil/xbutil.h | 1 + 2 files changed, 51 insertions(+) diff --git a/src/runtime_src/core/pcie/tools/xbutil/xbutil.cpp b/src/runtime_src/core/pcie/tools/xbutil/xbutil.cpp index 2e463dcf359..31059152949 100644 --- a/src/runtime_src/core/pcie/tools/xbutil/xbutil.cpp +++ b/src/runtime_src/core/pcie/tools/xbutil/xbutil.cpp @@ -89,6 +89,35 @@ static int str2index(const char *arg, unsigned& index) return 0; } +static bool +check_os_release(const std::vector kernel_versions, std::ostream &ostr) +{ + const std::string release = sensor_tree::get("system.release"); + for (const auto& ver : kernel_versions) { + if (release.find(ver) != std::string::npos) + return true; + } + ostr << "WARNING: Kernel verison " << release << " is not officially supported. " + << kernel_versions.back() << " is the latest supported version" << std::endl; + return false; +} + +static bool +is_supported_kernel_version(std::ostream &ostr) +{ + std::vector ubuntu_kernel_versions = + { "4.4.0", "4.13.0", "4.15.0", "4.18.0", "5.0.0" }; + std::vector centos_rh_kernel_versions = + { "3.10.0-693", "3.10.0-862", "3.10.0-957", "3.10.0-1062" }; + const std::string os = sensor_tree::get("system.linux", "N/A"); + + if(os.find("Ubuntu") != std::string::npos) + return check_os_release(ubuntu_kernel_versions, ostr); + else if(os.find("Red Hat") != std::string::npos || os.find("CentOS") != std::string::npos) + return check_os_release(centos_rh_kernel_versions, ostr); + + return true; +} static void print_pci_info(std::ostream &ostr) { @@ -117,6 +146,8 @@ static void print_pci_info(std::ostream &ostr) ostr << " please also run 'xbmgmt flash --scan --verbose' to further check card details." << std::endl; } + + is_supported_kernel_version(ostr); } static int xrt_xbutil_version_cmp() @@ -1463,6 +1494,19 @@ int xcldev::device::getXclbinuuid(uuid_t &uuid) { return 0; } + +int xcldev::device::kernelVersionTest(void) +{ + if (getenv_or_null("INTERNAL_BUILD")) { + std::cout << "Developer's build. Skipping validation" << std::endl; + return -EOPNOTSUPP; + } + if (!is_supported_kernel_version(std::cout)) { + return 1; + } + return 0; +} + /* * validate */ @@ -1471,6 +1515,12 @@ int xcldev::device::validate(bool quick) bool withWarning = false; int retVal = 0; + retVal = runOneTest("Kernel version check", + std::bind(&xcldev::device::kernelVersionTest, this)); + withWarning = withWarning || (retVal == 1); + if (retVal < 0) + return retVal; + retVal = runOneTest("AUX power connector check", std::bind(&xcldev::device::auxConnectionTest, this)); withWarning = withWarning || (retVal == 1); diff --git a/src/runtime_src/core/pcie/tools/xbutil/xbutil.h b/src/runtime_src/core/pcie/tools/xbutil/xbutil.h index ae259b0e028..37af1879ff7 100644 --- a/src/runtime_src/core/pcie/tools/xbutil/xbutil.h +++ b/src/runtime_src/core/pcie/tools/xbutil/xbutil.h @@ -1764,6 +1764,7 @@ class device { int auxConnectionTest(void); int verifyKernelTest(void); int bandwidthKernelTest(void); + int kernelVersionTest(void); // testFunc must return 0 for success, 1 for warning, and < 0 for error int runOneTest(std::string testName, std::function testFunc);