refactor: store gmm callback functions in global arrays

Related-To: NEO-11080
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2025-08-12 12:20:10 +00:00
committed by Compute-Runtime-Automation
parent 796866b2d6
commit a68ea38ba1
11 changed files with 59 additions and 30 deletions

View File

@@ -6,9 +6,13 @@
*/
#include "shared/source/gen12lp/hw_cmds_base.h"
static auto gfxCore = IGFX_GEN12LP_CORE;
#include "shared/source/helpers/windows/gmm_callbacks.inl"
namespace NEO {
template struct DeviceCallbacks<Gen12LpFamily>;
template struct TTCallbacks<Gen12LpFamily>;
GmmCallbacksFactory<Gen12LpFamily> gmmCallbacksGen12lp;
} // namespace NEO

View File

@@ -1,14 +1,13 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include <cstdint>
#include "shared/source/helpers/windows/gmm_callbacks.h"
namespace NEO {
long(__stdcall *notifyAubCaptureImpl)(void *csrHandle, uint64_t gfxAddress, size_t gfxSize, bool allocate) = nullptr;
NotifyAubCaptureFunc notifyAubCaptureFuncFactory[IGFX_MAX_CORE]{};
WriteL3AddressFunc writeL3AddressFuncFactory[IGFX_MAX_CORE]{};
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
* Copyright (C) 2019-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,21 +8,29 @@
#pragma once
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include "neo_igfxfmid.h"
#include <cstdint>
namespace NEO {
using NotifyAubCaptureFunc = long(__stdcall *)(void *csrHandle, uint64_t gfxAddress, size_t gfxSize, bool allocate);
using WriteL3AddressFunc = int(__stdcall *)(void *queueHandle, uint64_t l3GfxAddress, uint64_t regOffset);
extern NotifyAubCaptureFunc notifyAubCaptureFuncFactory[IGFX_MAX_CORE];
extern WriteL3AddressFunc writeL3AddressFuncFactory[IGFX_MAX_CORE];
extern long(__stdcall *notifyAubCaptureImpl)(void *csrHandle, uint64_t gfxAddress, size_t gfxSize, bool allocate);
template <typename GfxFamily>
struct DeviceCallbacks {
static long __stdcall notifyAubCapture(void *csrHandle, uint64_t gfxAddress, size_t gfxSize, bool allocate);
};
template <typename GfxFamily>
struct TTCallbacks {
using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM;
static int __stdcall writeL3Address(void *queueHandle, uint64_t l3GfxAddress, uint64_t regOffset);
};
template <typename GfxFamily>
struct GmmCallbacksFactory {
GmmCallbacksFactory() noexcept;
};
} // namespace NEO

View File

@@ -6,9 +6,7 @@
*/
#include "shared/source/command_stream/aub_command_stream_receiver_hw.h"
#include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/windows/gmm_callbacks.h"
#include "shared/source/os_interface/windows/wddm_device_command_stream.h"
@@ -51,4 +49,10 @@ int __stdcall TTCallbacks<GfxFamily>::writeL3Address(void *queueHandle, uint64_t
return 1;
}
template <typename GfxFamily>
GmmCallbacksFactory<GfxFamily>::GmmCallbacksFactory() noexcept {
notifyAubCaptureFuncFactory[gfxCore] = DeviceCallbacks<GfxFamily>::notifyAubCapture;
writeL3AddressFuncFactory[gfxCore] = TTCallbacks<GfxFamily>::writeL3Address;
}
} // namespace NEO

View File

@@ -16,10 +16,6 @@
namespace NEO {
long __stdcall notifyAubCapture(void *csrHandle, uint64_t gfxAddress, size_t gfxSize, bool allocate) {
return notifyAubCaptureImpl(csrHandle, gfxAddress, gfxSize, allocate);
}
bool Wddm::configureDeviceAddressSpace() {
GMM_DEVICE_CALLBACKS_INT deviceCallbacks{};
deviceCallbacks.Adapter.KmtHandle = getAdapter();
@@ -41,7 +37,10 @@ bool Wddm::configureDeviceAddressSpace() {
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUnLock = getGdi()->unlock2;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEscape = getGdi()->escape;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnFreeGPUVA = getGdi()->freeGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = notifyAubCapture;
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = notifyAubCaptureFuncFactory[hwInfo->platform.eRenderCoreFamily];
GMM_DEVICE_INFO deviceInfo{};
deviceInfo.pGfxPartition = &gfxPartition;
@@ -63,7 +62,7 @@ bool Wddm::configureDeviceAddressSpace() {
? maximumApplicationAddress + 1u
: 0u;
bool obtainMinAddress = rootDeviceEnvironment.getHardwareInfo()->platform.eRenderCoreFamily == IGFX_GEN12LP_CORE;
bool obtainMinAddress = hwInfo->platform.eRenderCoreFamily == IGFX_GEN12LP_CORE;
return gmmMemory->configureDevice(getAdapter(), device, getGdi()->escape, svmSize, featureTable->flags.ftrL3IACoherency, minAddress, obtainMinAddress);
}

View File

@@ -16,6 +16,7 @@
#include "shared/source/direct_submission/windows/wddm_direct_submission.h"
#include "shared/source/gmm_helper/page_table_mngr.h"
#include "shared/source/helpers/flush_stamp.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/ptr_math.h"
#include "shared/source/helpers/windows/gmm_callbacks.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
@@ -40,7 +41,6 @@ WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver(ExecutionEnviron
const DeviceBitfield deviceBitfield)
: BaseClass(executionEnvironment, rootDeviceIndex, deviceBitfield) {
notifyAubCaptureImpl = DeviceCallbacks<GfxFamily>::notifyAubCapture;
this->wddm = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as<Wddm>();
PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(this->peekHwInfo());
@@ -175,9 +175,10 @@ bool WddmCommandStreamReceiver<GfxFamily>::isTlbFlushRequiredForStateCacheFlush(
template <typename GfxFamily>
GmmPageTableMngr *WddmCommandStreamReceiver<GfxFamily>::createPageTableManager() {
GMM_TRANSLATIONTABLE_CALLBACKS ttCallbacks = {};
ttCallbacks.pfWriteL3Adr = TTCallbacks<GfxFamily>::writeL3Address;
auto rootDeviceEnvironment = this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex].get();
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
ttCallbacks.pfWriteL3Adr = writeL3AddressFuncFactory[hwInfo->platform.eRenderCoreFamily];
GmmPageTableMngr *gmmPageTableMngr = GmmPageTableMngr::create(rootDeviceEnvironment->getGmmClientContext(), TT_TYPE::AUXTT, &ttCallbacks);
gmmPageTableMngr->setCsrHandle(this);

View File

@@ -5,12 +5,16 @@
*
*/
#include "shared/source/helpers/windows/gmm_callbacks.inl"
#include "shared/source/xe2_hpg_core/hw_cmds.h"
static auto gfxCore = IGFX_XE2_HPG_CORE;
#include "shared/source/helpers/windows/gmm_callbacks.inl"
namespace NEO {
template struct DeviceCallbacks<Xe2HpgCoreFamily>;
template struct TTCallbacks<Xe2HpgCoreFamily>;
GmmCallbacksFactory<Xe2HpgCoreFamily> gmmCallbacksXe2Hpg;
} // namespace NEO

View File

@@ -5,12 +5,16 @@
*
*/
#include "shared/source/helpers/windows/gmm_callbacks.inl"
#include "shared/source/xe3_core/hw_cmds_base.h"
static auto gfxCore = IGFX_XE3_CORE;
#include "shared/source/helpers/windows/gmm_callbacks.inl"
namespace NEO {
template struct DeviceCallbacks<Xe3CoreFamily>;
template struct TTCallbacks<Xe3CoreFamily>;
GmmCallbacksFactory<Xe3CoreFamily> gmmCallbacksXe3;
} // namespace NEO

View File

@@ -5,12 +5,16 @@
*
*/
#include "shared/source/helpers/windows/gmm_callbacks.inl"
#include "shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.h"
static auto gfxCore = IGFX_XE_HPC_CORE;
#include "shared/source/helpers/windows/gmm_callbacks.inl"
namespace NEO {
template struct DeviceCallbacks<XeHpcCoreFamily>;
template struct TTCallbacks<XeHpcCoreFamily>;
GmmCallbacksFactory<XeHpcCoreFamily> gmmCallbacksXeHpc;
} // namespace NEO

View File

@@ -5,12 +5,16 @@
*
*/
#include "shared/source/helpers/windows/gmm_callbacks.inl"
#include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h"
static auto gfxCore = IGFX_XE_HPG_CORE;
#include "shared/source/helpers/windows/gmm_callbacks.inl"
namespace NEO {
template struct DeviceCallbacks<XeHpgCoreFamily>;
template struct TTCallbacks<XeHpgCoreFamily>;
GmmCallbacksFactory<XeHpgCoreFamily> gmmCallbacksXeHpg;
} // namespace NEO

View File

@@ -7,6 +7,7 @@
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/windows/gmm_callbacks.h"
#include "shared/source/os_interface/windows/driver_info_windows.h"
#include "shared/source/os_interface/windows/dxgi_wrapper.h"
#include "shared/source/os_interface/windows/sharedata_wrapper.h"
@@ -181,10 +182,6 @@ TEST(WddmGfxPartitionTests, WhenInitializingGfxPartitionThen64KBHeapsAreUsed) {
EXPECT_EQ(wddm->gfxPartition.Standard64KB.Base + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::heapStandard64KB));
}
namespace NEO {
long __stdcall notifyAubCapture(void *csrHandle, uint64_t gfxAddress, size_t gfxSize, bool allocate);
}
TEST_F(Wddm20WithMockGdiDllTests, whenSetDeviceInfoSucceedsThenDeviceCallbacksArePassedToGmmMemory) {
GMM_DEVICE_CALLBACKS_INT expectedDeviceCb{};
wddm->init();
@@ -210,7 +207,7 @@ TEST_F(Wddm20WithMockGdiDllTests, whenSetDeviceInfoSucceedsThenDeviceCallbacksAr
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUnLock = gdi->unlock2;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEscape = gdi->escape;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnFreeGPUVA = gdi->freeGpuVirtualAddress;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = notifyAubCapture;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = notifyAubCaptureFuncFactory[defaultHwInfo->platform.eRenderCoreFamily];
EXPECT_EQ(expectedDeviceCb.Adapter.KmtHandle, gmmMemory->deviceCallbacks.Adapter.KmtHandle);
EXPECT_EQ(expectedDeviceCb.hDevice.KmtHandle, gmmMemory->deviceCallbacks.hDevice.KmtHandle);
@@ -231,6 +228,7 @@ TEST_F(Wddm20WithMockGdiDllTests, whenSetDeviceInfoSucceedsThenDeviceCallbacksAr
EXPECT_EQ(expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEscape, gmmMemory->deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEscape);
EXPECT_EQ(expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnFreeGPUVA, gmmMemory->deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnFreeGPUVA);
EXPECT_EQ(expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture, gmmMemory->deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture);
EXPECT_NE(nullptr, gmmMemory->deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture);
}
class MockGmmMemoryWindows : public MockGmmMemoryBase {