diff --git a/level_zero/sysman/test/unit_tests/sources/events/linux/mock_events.h b/level_zero/sysman/test/unit_tests/sources/events/linux/mock_events.h index 818510d4a4..7ad0926536 100644 --- a/level_zero/sysman/test/unit_tests/sources/events/linux/mock_events.h +++ b/level_zero/sysman/test/unit_tests/sources/events/linux/mock_events.h @@ -22,6 +22,8 @@ #include "level_zero/sysman/source/shared/linux/zes_os_sysman_driver_imp.h" #include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h" +#include + using namespace NEO; namespace L0 { diff --git a/level_zero/tools/test/unit_tests/sources/sysman/events/linux/mock_events.h b/level_zero/tools/test/unit_tests/sources/sysman/events/linux/mock_events.h index fb6ea5d8a5..bc6511e5ef 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/events/linux/mock_events.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/events/linux/mock_events.h @@ -20,6 +20,8 @@ #include "level_zero/tools/source/sysman/linux/os_sysman_imp.h" #include "level_zero/tools/source/sysman/linux/pmu/pmu_imp.h" +#include + using namespace NEO; namespace L0 { namespace ult { diff --git a/level_zero/tools/test/unit_tests/sources/sysman/ras/linux/mock_sysman_ras.h b/level_zero/tools/test/unit_tests/sources/sysman/ras/linux/mock_sysman_ras.h index 00d52518b4..331424167f 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/ras/linux/mock_sysman_ras.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/ras/linux/mock_sysman_ras.h @@ -19,6 +19,8 @@ #include "level_zero/tools/source/sysman/ras/ras.h" #include "level_zero/tools/source/sysman/ras/ras_imp.h" +#include + using namespace NEO; namespace L0 { namespace ult { diff --git a/shared/source/gmm_helper/CMakeLists.txt b/shared/source/gmm_helper/CMakeLists.txt index 2f73b18862..2e642cbade 100644 --- a/shared/source/gmm_helper/CMakeLists.txt +++ b/shared/source/gmm_helper/CMakeLists.txt @@ -6,6 +6,7 @@ set(NEO_CORE_GMM_HELPER ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/adapter_bdf.h ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}resource_info_${DRIVER_MODEL}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.h diff --git a/shared/source/gmm_helper/adapter_bdf.h b/shared/source/gmm_helper/adapter_bdf.h new file mode 100644 index 0000000000..bb4f29527b --- /dev/null +++ b/shared/source/gmm_helper/adapter_bdf.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include + +namespace NEO { + +struct AdapterBdf { + union { + struct { + uint32_t bus : 8; + uint32_t device : 8; + uint32_t function : 8; + uint32_t reserved : 8; + }; + uint32_t data; + }; +}; + +} // namespace NEO diff --git a/shared/source/gmm_helper/gmm_wrappers.cpp b/shared/source/gmm_helper/gmm_wrappers.cpp index 2928214a57..0ad345380e 100644 --- a/shared/source/gmm_helper/gmm_wrappers.cpp +++ b/shared/source/gmm_helper/gmm_wrappers.cpp @@ -5,9 +5,12 @@ * */ +#include "shared/source/gmm_helper/adapter_bdf.h" #include "shared/source/gmm_helper/gmm_lib.h" #include "shared/source/helpers/surface_format_info.h" +#include + namespace NEO { static_assert(static_cast(ImagePlane::noPlane) == GMM_NO_PLANE); static_assert(static_cast(ImagePlane::planeY) == GMM_PLANE_Y); @@ -22,4 +25,9 @@ static_assert(static_cast(ImageTilingMode::tiledW) == GMM_TILED_W static_assert(static_cast(ImageTilingMode::notTiled) == GMM_NOT_TILED); static_assert(static_cast(ImageTilingMode::tiled4) == GMM_TILED_4); static_assert(static_cast(ImageTilingMode::tiled64) == GMM_TILED_64); + +static_assert(sizeof(AdapterBdf) == sizeof(ADAPTER_BDF)); +static_assert(offsetof(AdapterBdf, data) == offsetof(ADAPTER_BDF, Data)); +static_assert(std::is_same_v); + } // namespace NEO diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 380f8208f1..db349c8f55 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -28,7 +28,6 @@ #include "shared/source/os_interface/linux/cache_info.h" #include "shared/source/os_interface/linux/drm_buffer_object.h" #include "shared/source/os_interface/linux/drm_engine_mapper.h" -#include "shared/source/os_interface/linux/drm_gem_close_worker.h" #include "shared/source/os_interface/linux/drm_memory_manager.h" #include "shared/source/os_interface/linux/drm_memory_operations_handler_bind.h" #include "shared/source/os_interface/linux/drm_wrappers.h" @@ -46,7 +45,6 @@ #include "shared/source/os_interface/os_environment.h" #include "shared/source/os_interface/os_interface.h" #include "shared/source/os_interface/product_helper.h" -#include "shared/source/release_helper/release_helper.h" #include "shared/source/utilities/api_intercept.h" #include "shared/source/utilities/cpu_info.h" #include "shared/source/utilities/directory.h" @@ -888,11 +886,11 @@ void Drm::setNewResourceBoundToVM(BufferObject *bo, uint32_t vmHandleId) { PhysicalDevicePciBusInfo Drm::getPciBusInfo() const { PhysicalDevicePciBusInfo pciBusInfo(PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue); - if (adapterBDF.Data != std::numeric_limits::max()) { + if (adapterBDF.data != std::numeric_limits::max()) { pciBusInfo.pciDomain = this->pciDomain; - pciBusInfo.pciBus = adapterBDF.Bus; - pciBusInfo.pciDevice = adapterBDF.Device; - pciBusInfo.pciFunction = adapterBDF.Function; + pciBusInfo.pciBus = adapterBDF.bus; + pciBusInfo.pciDevice = adapterBDF.device; + pciBusInfo.pciFunction = adapterBDF.function; } return pciBusInfo; } @@ -911,22 +909,22 @@ int Drm::queryAdapterBDF() { uint8_t bus = -1, device = -1, function = -1; if (NEO::parseBdfString(hwDeviceId->getPciPath(), domain, bus, device, function) != pciBusInfoTokensNum) { - adapterBDF.Data = std::numeric_limits::max(); + adapterBDF.data = std::numeric_limits::max(); return 1; } setPciDomain(domain); - adapterBDF.Bus = bus; - adapterBDF.Function = function; - adapterBDF.Device = device; + adapterBDF.bus = bus; + adapterBDF.function = function; + adapterBDF.device = device; return 0; } void Drm::setGmmInputArgs(void *args) { auto gmmInArgs = reinterpret_cast(args); #if defined(__linux__) - gmmInArgs->FileDescriptor = adapterBDF.Data; + gmmInArgs->FileDescriptor = adapterBDF.data; #else - gmmInArgs->stAdapterBDF = adapterBDF; + gmmInArgs->stAdapterBDF.Data = adapterBDF.data; #endif gmmInArgs->ClientType = GMM_CLIENT::GMM_OCL_VISTA; } diff --git a/shared/source/os_interface/linux/drm_neo.h b/shared/source/os_interface/linux/drm_neo.h index 74fff65b3a..62541faf64 100644 --- a/shared/source/os_interface/linux/drm_neo.h +++ b/shared/source/os_interface/linux/drm_neo.h @@ -6,7 +6,7 @@ */ #pragma once -#include "shared/source/gmm_helper/gmm_lib.h" +#include "shared/source/gmm_helper/adapter_bdf.h" #include "shared/source/helpers/driver_model_type.h" #include "shared/source/memory_manager/definitions/engine_limits.h" #include "shared/source/os_interface/linux/drm_debug.h" @@ -14,6 +14,8 @@ #include "shared/source/os_interface/linux/hw_device_id.h" #include "shared/source/os_interface/os_interface.h" +#include "neo_igfxfmid.h" + #include #include #include @@ -22,10 +24,9 @@ #include #include #include +#include #include -struct GT_SYSTEM_INFO; - namespace aub_stream { enum EngineType : uint32_t; } @@ -318,7 +319,7 @@ class Drm : public DriverModel { #pragma pack() GemContextParamSseu sseu{}; - ADAPTER_BDF adapterBDF{}; + AdapterBdf adapterBDF{}; uint32_t pciDomain = 0; struct IoctlStatisticsEntry { diff --git a/shared/source/os_interface/windows/hw_device_id.h b/shared/source/os_interface/windows/hw_device_id.h index 25616269f3..0286445725 100644 --- a/shared/source/os_interface/windows/hw_device_id.h +++ b/shared/source/os_interface/windows/hw_device_id.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,10 +8,9 @@ #pragma once #include "shared/source/helpers/driver_model_type.h" #include "shared/source/os_interface/os_interface.h" +#include "shared/source/os_interface/windows/d3dkmthk_wrapper.h" #include "shared/source/os_interface/windows/windows_wrapper.h" -#include - #include namespace NEO { diff --git a/shared/source/os_interface/windows/wddm/set_gmm_input_args_wddm.cpp b/shared/source/os_interface/windows/wddm/set_gmm_input_args_wddm.cpp index d9d98f0fab..b06d62a6e0 100644 --- a/shared/source/os_interface/windows/wddm/set_gmm_input_args_wddm.cpp +++ b/shared/source/os_interface/windows/wddm/set_gmm_input_args_wddm.cpp @@ -1,11 +1,11 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * */ -#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/gmm_helper/gmm_lib.h" #include "shared/source/os_interface/windows/wddm/wddm.h" namespace NEO { @@ -18,7 +18,7 @@ void Wddm::setGmmInputArgs(void *args) { gmmInArgs->pSkuTable = gfxFeatureTable.get(); gmmInArgs->pWaTable = gfxWorkaroundTable.get(); - gmmInArgs->stAdapterBDF = this->adapterBDF; + gmmInArgs->stAdapterBDF.Data = this->adapterBDF.data; gmmInArgs->ClientType = GMM_CLIENT::GMM_OCL_VISTA; gmmInArgs->DeviceRegistryPath = deviceRegistryPath.c_str(); } diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 59a28280f1..69bbd78def 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -1416,10 +1416,10 @@ void Wddm::createPagingFenceLogger() { } PhysicalDevicePciBusInfo Wddm::getPciBusInfo() const { - if (adapterBDF.Data == std::numeric_limits::max()) { + if (adapterBDF.data == std::numeric_limits::max()) { return PhysicalDevicePciBusInfo(PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue); } - return PhysicalDevicePciBusInfo(0, adapterBDF.Bus, adapterBDF.Device, adapterBDF.Function); + return PhysicalDevicePciBusInfo(0, adapterBDF.bus, adapterBDF.device, adapterBDF.function); } PhysicalDevicePciSpeedInfo Wddm::getPciSpeedInfo() const { diff --git a/shared/source/os_interface/windows/wddm/wddm.h b/shared/source/os_interface/windows/wddm/wddm.h index 937cad77e9..68b0046bee 100644 --- a/shared/source/os_interface/windows/wddm/wddm.h +++ b/shared/source/os_interface/windows/wddm/wddm.h @@ -8,7 +8,7 @@ #pragma once #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/root_device_environment.h" -#include "shared/source/gmm_helper/gmm_lib.h" +#include "shared/source/gmm_helper/adapter_bdf.h" #include "shared/source/os_interface/windows/hw_device_id.h" #include "shared/source/os_interface/windows/sharedata_wrapper.h" #include "shared/source/os_interface/windows/wddm/wddm_defs.h" @@ -275,7 +275,7 @@ class Wddm : public DriverModel { WddmResidencyController residencyController; GMM_GFX_PARTITIONING gfxPartition{}; - ADAPTER_BDF adapterBDF{}; + AdapterBdf adapterBDF{}; std::string deviceRegistryPath; diff --git a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp index e140b3f3fd..2e525c2024 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/source/gmm_helper/adapter_bdf.h" #include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/helpers/gfx_core_helper.h" @@ -675,6 +676,22 @@ TEST_F(GmmHelperTests, givenSizeIsAllignedTo64kbWhenForceDisablingLargePagesThen EXPECT_EQ(allocationSize + MemoryConstants::pageSize, gmm.resourceParams.BaseWidth64); } +TEST_F(GmmHelperTests, givenAdapterBdfWhenComparingMemoryLayoutThenDataMatchesOriginalStruct) { + AdapterBdf local{}; + ADAPTER_BDF original{}; + + local.bus = 0xAA; + original.Bus = 0xAA; + local.device = 0xBB; + original.Device = 0xBB; + local.function = 0xCC; + original.Function = 0xCC; + local.reserved = 0xDD; + original.Reserved = 0xDD; + + EXPECT_EQ(local.data, original.Data); +} + TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedThenSetThisHwInfoToGmmHelper) { std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_EQ(&device->getHardwareInfo(), device->getGmmHelper()->getHardwareInfo()); diff --git a/shared/test/unit_test/os_interface/linux/drm_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_tests.cpp index e97d87e0ad..413a917e13 100644 --- a/shared/test/unit_test/os_interface/linux/drm_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_tests.cpp @@ -74,9 +74,9 @@ TEST(DrmTest, GivenValidPciPathWhenGettingAdapterBdfThenCorrectValuesAreReturned drm.setPciPath("0000:ab:cd.e"); EXPECT_EQ(0, drm.queryAdapterBDF()); auto adapterBdf = drm.adapterBDF; - EXPECT_EQ(0xabu, adapterBdf.Bus); - EXPECT_EQ(0xcdu, adapterBdf.Device); - EXPECT_EQ(0xeu, adapterBdf.Function); + EXPECT_EQ(0xabu, adapterBdf.bus); + EXPECT_EQ(0xcdu, adapterBdf.device); + EXPECT_EQ(0xeu, adapterBdf.function); auto pciInfo = drm.getPciBusInfo(); EXPECT_EQ(0x0u, pciInfo.pciDomain); @@ -89,9 +89,9 @@ TEST(DrmTest, GivenValidPciPathWhenGettingAdapterBdfThenCorrectValuesAreReturned drm.setPciPath("0000:01:23.4"); EXPECT_EQ(0, drm.queryAdapterBDF()); auto adapterBdf = drm.adapterBDF; - EXPECT_EQ(0x1u, adapterBdf.Bus); - EXPECT_EQ(0x23u, adapterBdf.Device); - EXPECT_EQ(0x4u, adapterBdf.Function); + EXPECT_EQ(0x1u, adapterBdf.bus); + EXPECT_EQ(0x23u, adapterBdf.device); + EXPECT_EQ(0x4u, adapterBdf.function); auto pciInfo = drm.getPciBusInfo(); EXPECT_EQ(0x0u, pciInfo.pciDomain); @@ -108,7 +108,7 @@ TEST(DrmTest, GivenInvalidPciPathWhenGettingAdapterBdfThenInvalidPciInfoIsReturn drm.setPciPath("invalidPci"); EXPECT_EQ(1, drm.queryAdapterBDF()); auto adapterBdf = drm.adapterBDF; - EXPECT_EQ(std::numeric_limits::max(), adapterBdf.Data); + EXPECT_EQ(std::numeric_limits::max(), adapterBdf.data); auto pciInfo = drm.getPciBusInfo(); EXPECT_EQ(PhysicalDevicePciBusInfo::invalidValue, pciInfo.pciDomain); diff --git a/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp b/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp index 91c053bdc7..fbb50707ae 100644 --- a/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp @@ -80,11 +80,11 @@ TEST_F(OsInterfaceTest, whenOsInterfaceSetupGmmInputArgsThenArgsAreSet) { auto expectedRegistryPath = wddm->deviceRegistryPath.c_str(); auto &adapterBDF = wddm->adapterBDF; uint32_t bus = 0x12; - adapterBDF.Bus = bus; + adapterBDF.bus = bus; uint32_t device = 0x34; - adapterBDF.Device = device; + adapterBDF.device = device; uint32_t function = 0x56; - adapterBDF.Function = function; + adapterBDF.function = function; GMM_INIT_IN_ARGS gmmInputArgs = {}; wddm->Wddm::setGmmInputArgs(&gmmInputArgs);