fix: pass additional adapter info caps to gmmlib for wddm windows

Related-To: HSD-18041684792
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2025-05-27 09:50:14 +00:00 committed by Compute-Runtime-Automation
parent 48917f14cc
commit 72e1ec3b42
7 changed files with 58 additions and 0 deletions

View File

@ -183,6 +183,8 @@ struct ADAPTER_INFO_KMD : ADAPTER_INFO_GMM { // NOLINT(readability-identifier-na
GMM_GFX_PARTITIONING GfxPartition; // NOLINT(readability-identifier-naming)
ADAPTER_BDF stAdapterBDF;
PLATFORM_KMD GfxPlatform; // NOLINT(readability-identifier-naming)
uint64_t LMemBarSize; // NOLINT(readability-identifier-naming)
uint8_t SegmentId[3]; // NOLINT(readability-identifier-naming)
};
static constexpr COMMAND_BUFFER_HEADER initCommandBufferHeader(uint32_t umdContextType, uint32_t umdPatchList, uint32_t usesResourceStreamer, uint32_t perfTag) {

View File

@ -46,6 +46,9 @@ bool Wddm::configureDeviceAddressSpace() {
GMM_DEVICE_INFO deviceInfo{};
deviceInfo.pGfxPartition = &gfxPartition;
deviceInfo.pDeviceCb = &deviceCallbacks;
memcpy_s(deviceInfo.MsSegId, sizeof(deviceInfo.MsSegId), segmentId, sizeof(segmentId));
deviceInfo.AdapterLocalMemory = dedicatedVideoMemory;
deviceInfo.AdapterCpuVisibleLocalMemory = lmemBarSize;
if (!gmmMemory->setDeviceInfo(&deviceInfo)) {
return false;
}

View File

@ -306,11 +306,13 @@ bool Wddm::queryAdapterInfo() {
memcpy_s(&gfxPartition, sizeof(gfxPartition), &adapterInfo.GfxPartition, sizeof(GMM_GFX_PARTITIONING));
memcpy_s(&adapterBDF, sizeof(adapterBDF), &adapterInfo.stAdapterBDF, sizeof(ADAPTER_BDF));
memcpy_s(segmentId, sizeof(segmentId), adapterInfo.SegmentId, sizeof(adapterInfo.SegmentId));
deviceRegistryPath = std::string(adapterInfo.DeviceRegistryPath, sizeof(adapterInfo.DeviceRegistryPath)).c_str();
systemSharedMemory = adapterInfo.SystemSharedMemory;
dedicatedVideoMemory = adapterInfo.DedicatedVideoMemory;
lmemBarSize = adapterInfo.LMemBarSize;
maxRenderFrequency = adapterInfo.MaxRenderFreq;
timestampFrequency = adapterInfo.GfxTimeStampFreq;
instrumentationEnabled = adapterInfo.Caps.InstrumentationIsEnabled != 0;

View File

@ -271,6 +271,7 @@ class Wddm : public DriverModel {
uint64_t systemSharedMemory = 0;
uint64_t dedicatedVideoMemory = 0;
uint64_t lmemBarSize = 0;
// Adapter information
std::unique_ptr<PLATFORM_KMD> gfxPlatform;
@ -309,6 +310,8 @@ class Wddm : public DriverModel {
uint32_t additionalAdapterInfoOptions = 0u;
int32_t forceEvictOnlyIfNecessary = -1;
uint8_t segmentId[3]{};
unsigned int enablePreemptionRegValue = 1;
bool platformSupportsEvictIfNecessary = false;

View File

@ -388,6 +388,8 @@ NTSTATUS __stdcall mockD3DKMTQueryAdapterInfo(IN CONST D3DKMT_QUERYADAPTERINFO *
adapterInfo->GfxMemorySize = 2181038080;
adapterInfo->SystemSharedMemory = 4249540608;
adapterInfo->SystemVideoMemory = 0;
adapterInfo->DedicatedVideoMemory = 0x123467800;
adapterInfo->LMemBarSize = 0x123467A0;
adapterInfo->GfxTimeStampFreq = 1;
adapterInfo->GfxPartition.Standard.Base = gAdapterInfo.GfxPartition.Standard.Base;
@ -406,6 +408,10 @@ NTSTATUS __stdcall mockD3DKMTQueryAdapterInfo(IN CONST D3DKMT_QUERYADAPTERINFO *
adapterInfo->GfxPartition.Heap32[3].Base = gAdapterInfo.GfxPartition.Heap32[3].Base;
adapterInfo->GfxPartition.Heap32[3].Limit = gAdapterInfo.GfxPartition.Heap32[3].Limit;
adapterInfo->SegmentId[0] = 0x12;
adapterInfo->SegmentId[1] = 0x34;
adapterInfo->SegmentId[2] = 0x56;
adapterInfo->stAdapterBDF.Data = gAdapterBDF.Data;
return STATUS_SUCCESS;
}

View File

@ -56,6 +56,7 @@ class WddmMock : public Wddm {
using Wddm::hwDeviceId;
using Wddm::isReadOnlyFlagFallbackAvailable;
using Wddm::isReadOnlyFlagFallbackSupported;
using Wddm::lmemBarSize;
using Wddm::mapGpuVirtualAddress;
using Wddm::minAddress;
using Wddm::pagingFenceAddress;
@ -66,6 +67,7 @@ class WddmMock : public Wddm {
using Wddm::populateIpVersion;
using Wddm::residencyLogger;
using Wddm::rootDeviceEnvironment;
using Wddm::segmentId;
using Wddm::setNewResourceBoundToPageTable;
using Wddm::setPlatformSupportEvictIfNecessaryFlag;
using Wddm::temporaryResources;

View File

@ -233,6 +233,46 @@ TEST_F(Wddm20WithMockGdiDllTests, whenSetDeviceInfoSucceedsThenDeviceCallbacksAr
EXPECT_EQ(expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture, gmmMemory->deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture);
}
class MockGmmMemoryWindows : public MockGmmMemoryBase {
public:
using MockGmmMemoryBase::MockGmmMemoryBase;
bool setDeviceInfo(GMM_DEVICE_INFO *deviceInfo) override {
for (int i = 0; i < 3; i++) {
segmentId[i] = deviceInfo->MsSegId[i];
}
adapterLocalMemory = deviceInfo->AdapterLocalMemory;
adapterCpuVisibleMemory = deviceInfo->AdapterCpuVisibleLocalMemory;
return MockGmmMemoryBase::setDeviceInfo(deviceInfo);
}
uint64_t adapterLocalMemory = 0;
uint64_t adapterCpuVisibleMemory = 0;
uint8_t segmentId[3]{};
};
TEST_F(Wddm20WithMockGdiDllTests, whenInitWddmThenAdapterInfoCapsArePassedToGmmLibViaSetDeviceInfo) {
uint8_t expectedSegmentId[3] = {0x12, 0x34, 0x56};
uint64_t expectedAdapterLocalMemory = 0x123467800u;
uint64_t expectedAdapterCpuVisibleMemory = 0x123467A0u;
wddm->segmentId[0] = 0u;
wddm->segmentId[1] = 0u;
wddm->segmentId[2] = 0u;
wddm->lmemBarSize = 0u;
wddm->dedicatedVideoMemory = 0u;
wddm->gmmMemory = std::make_unique<MockGmmMemoryWindows>(getGmmClientContext());
auto gmmMemory = static_cast<MockGmmMemoryWindows *>(wddm->getGmmMemory());
wddm->init();
EXPECT_EQ(1u, gmmMemory->setDeviceInfoCalled);
EXPECT_EQ(expectedSegmentId[0], gmmMemory->segmentId[0]);
EXPECT_EQ(expectedSegmentId[1], gmmMemory->segmentId[1]);
EXPECT_EQ(expectedSegmentId[2], gmmMemory->segmentId[2]);
EXPECT_EQ(expectedAdapterLocalMemory, gmmMemory->adapterLocalMemory);
EXPECT_EQ(expectedAdapterCpuVisibleMemory, gmmMemory->adapterCpuVisibleMemory);
}
class MockRegistryReaderWithDriverStorePath : public SettingsReader {
public:
MockRegistryReaderWithDriverStorePath(const char *driverStorePathArg) : driverStorePath(driverStorePathArg){};