Linux: pass adapter BDF to GmmLib

Resolves: NEO-5785
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-04-23 14:30:04 +00:00
committed by Compute-Runtime-Automation
parent dfb935fdcf
commit 1823054e08
5 changed files with 52 additions and 6 deletions

View File

@ -18,13 +18,15 @@ namespace NEO {
extern GMM_INIT_IN_ARGS passedInputArgs;
extern bool copyInputArgs;
TEST(OsInterfaceTest, whenOsInterfaceSetupsGmmInputArgsThenProperFileDescriptorIsSet) {
TEST(OsInterfaceTest, whenOsInterfaceSetupsGmmInputArgsThenFileDescriptorIsSetWithValueOfAdapterBdf) {
MockExecutionEnvironment executionEnvironment;
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
auto osInterface = new OSInterface();
rootDeviceEnvironment->osInterface.reset(osInterface);
auto drm = new DrmMock(fakeFd, *rootDeviceEnvironment);
drm->setPciPath("01:23.4");
osInterface->get()->setDrm(drm);
GMM_INIT_IN_ARGS gmmInputArgs = {};
@ -32,8 +34,11 @@ TEST(OsInterfaceTest, whenOsInterfaceSetupsGmmInputArgsThenProperFileDescriptorI
osInterface->setGmmInputArgs(&gmmInputArgs);
EXPECT_NE(0u, gmmInputArgs.FileDescriptor);
auto expectedFileDescriptor = drm->getFileDescriptor();
EXPECT_EQ(static_cast<uint32_t>(expectedFileDescriptor), gmmInputArgs.FileDescriptor);
ADAPTER_BDF expectedAdapterBDF{};
expectedAdapterBDF.Bus = 0x1;
expectedAdapterBDF.Device = 0x23;
expectedAdapterBDF.Function = 0x4;
EXPECT_EQ(expectedAdapterBDF.Data, gmmInputArgs.FileDescriptor);
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, gmmInputArgs.ClientType);
}

View File

@ -38,6 +38,28 @@ TEST(DrmTest, WhenGettingDeviceIdThenCorrectIdReturned) {
delete pDrm;
}
TEST(DrmTest, GivenValidPciPathWhenGettingAdapterBdfThenCorrectValuesAreReturned) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
{
drm.setPciPath("ab:cd.e");
auto adapterBdf = drm.getAdapterBDF();
EXPECT_EQ(0xabu, adapterBdf.Bus);
EXPECT_EQ(0xcdu, adapterBdf.Device);
EXPECT_EQ(0xeu, adapterBdf.Function);
}
{
drm.setPciPath("01:23.4");
auto adapterBdf = drm.getAdapterBDF();
EXPECT_EQ(0x1u, adapterBdf.Bus);
EXPECT_EQ(0x23u, adapterBdf.Device);
EXPECT_EQ(0x4u, adapterBdf.Function);
}
}
TEST(DrmTest, GivenInvalidPciPathWhenFrequencyIsQueriedThenReturnError) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);