L0Debug - Notify cmdQueue create for subdevices

- PROCESS ENTRY triggered for first cmdQ created

Related-To: NEO-5784

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2022-07-19 18:05:13 +00:00
committed by Compute-Runtime-Automation
parent 547dd59272
commit ebcb3faad2
16 changed files with 244 additions and 51 deletions

View File

@@ -25,6 +25,14 @@ DebugerL0CreateFn debuggerL0Factory[IGFX_MAX_CORE] = {};
DebuggerL0::DebuggerL0(NEO::Device *device) : device(device) {
isLegacyMode = false;
const auto deviceCount = std::max(1u, device->getNumSubDevices());
commandQueueCount.resize(deviceCount);
uuidL0CommandQueueHandle.resize(deviceCount);
for (uint32_t i = 0; i < deviceCount; i++) {
commandQueueCount[i] = 0;
uuidL0CommandQueueHandle[i] = 0;
}
initialize();
}

View File

@@ -12,6 +12,7 @@
#include <cstdint>
#include <memory>
#include <type_traits>
#include <unordered_map>
namespace NEO {
@@ -91,8 +92,8 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
void captureStateBaseAddress(NEO::LinearStream &cmdStream, SbaAddresses sba) override;
void printTrackedAddresses(uint32_t contextId);
MOCKABLE_VIRTUAL void registerElf(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation);
MOCKABLE_VIRTUAL void notifyCommandQueueCreated();
MOCKABLE_VIRTUAL void notifyCommandQueueDestroyed();
MOCKABLE_VIRTUAL void notifyCommandQueueCreated(NEO::Device *device);
MOCKABLE_VIRTUAL void notifyCommandQueueDestroyed(NEO::Device *device);
MOCKABLE_VIRTUAL void notifyModuleLoadAllocations(const StackVec<NEO::GraphicsAllocation *, 32> &allocs);
MOCKABLE_VIRTUAL void notifyModuleCreate(void *module, uint32_t moduleSize, uint64_t moduleLoadAddress);
MOCKABLE_VIRTUAL void registerAllocationType(GraphicsAllocation *allocation);
@@ -110,6 +111,11 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
}
bool getSingleAddressSpaceSbaTracking() { return singleAddressSpaceSbaTracking; }
struct CommandQueueNotification {
uint32_t subDeviceIndex = 0;
uint32_t subDeviceCount = 0;
};
protected:
static bool isAnyTrackedAddressChanged(SbaAddresses sba) {
return sba.GeneralStateBaseAddress != 0 ||
@@ -125,12 +131,14 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
std::unordered_map<uint32_t, NEO::GraphicsAllocation *> perContextSbaAllocations;
NEO::AddressRange sbaTrackingGpuVa{};
NEO::GraphicsAllocation *moduleDebugArea = nullptr;
std::atomic<uint32_t> commandQueueCount = 0u;
uint32_t uuidL0CommandQueueHandle = 0;
std::vector<uint32_t> commandQueueCount;
std::vector<uint32_t> uuidL0CommandQueueHandle;
bool singleAddressSpaceSbaTracking = false;
std::mutex debuggerL0Mutex;
};
static_assert(std::is_standard_layout<DebuggerL0::CommandQueueNotification>::value, "DebuggerL0::CommandQueueNotification issue");
using DebugerL0CreateFn = DebuggerL0 *(*)(NEO::Device *device);
extern DebugerL0CreateFn debuggerL0Factory[];

View File

@@ -64,20 +64,31 @@ bool DebuggerL0::removeZebinModule(uint32_t moduleHandle) {
return true;
}
void DebuggerL0::notifyCommandQueueCreated() {
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
if (++commandQueueCount == 1) {
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
uuidL0CommandQueueHandle = drm->notifyFirstCommandQueueCreated();
void DebuggerL0::notifyCommandQueueCreated(NEO::Device *device) {
if (this->device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
auto index = device->isSubDevice() ? static_cast<NEO::SubDevice *>(device)->getSubDeviceIndex() : 0;
if (++commandQueueCount[index] == 1) {
auto drm = this->device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
CommandQueueNotification notification = {index, this->device->getNumSubDevices()};
uuidL0CommandQueueHandle[index] = drm->notifyFirstCommandQueueCreated(&notification, sizeof(CommandQueueNotification));
}
}
}
void DebuggerL0::notifyCommandQueueDestroyed() {
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
if (--commandQueueCount == 0) {
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
drm->notifyLastCommandQueueDestroyed(uuidL0CommandQueueHandle);
void DebuggerL0::notifyCommandQueueDestroyed(NEO::Device *device) {
if (this->device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
auto index = device->isSubDevice() ? static_cast<NEO::SubDevice *>(device)->getSubDeviceIndex() : 0;
if (--commandQueueCount[index] == 0) {
auto drm = this->device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
drm->notifyLastCommandQueueDestroyed(uuidL0CommandQueueHandle[index]);
uuidL0CommandQueueHandle[index] = 0;
}
}
}

View File

@@ -186,10 +186,10 @@ static NTSTATUS runEscape(NEO::Wddm *wddm, KM_ESCAPE_INFO &escapeInfo) {
return wddm->escape(escapeCommand);
}
void DebuggerL0::notifyCommandQueueCreated() {
void DebuggerL0::notifyCommandQueueCreated(NEO::Device *deviceIn) {
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
if (++commandQueueCount == 1) {
if (++commandQueueCount[0] == 1) {
auto pWddm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Wddm>();
int val = 0;
KM_ESCAPE_INFO escapeInfo = {0};
@@ -202,10 +202,10 @@ void DebuggerL0::notifyCommandQueueCreated() {
}
}
void DebuggerL0::notifyCommandQueueDestroyed() {
void DebuggerL0::notifyCommandQueueDestroyed(NEO::Device *deviceIn) {
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
if (--commandQueueCount == 0) {
if (--commandQueueCount[0] == 0) {
auto pWddm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Wddm>();
int val = 0;
KM_ESCAPE_INFO escapeInfo = {0};

View File

@@ -109,8 +109,8 @@ void Drm::setContextDebugFlag(uint32_t drmContextId) {
DEBUG_BREAK_IF(retVal != 0 && contextDebugSupported);
}
uint32_t Drm::notifyFirstCommandQueueCreated() {
const auto result = ioctlHelper->registerStringClassUuid(uuidL0CommandQueueHash, (uintptr_t)uuidL0CommandQueueName, strnlen_s(uuidL0CommandQueueName, 100));
uint32_t Drm::notifyFirstCommandQueueCreated(const void *data, size_t size) {
const auto result = ioctlHelper->registerStringClassUuid(uuidL0CommandQueueHash, (uintptr_t)data, size);
DEBUG_BREAK_IF(result.retVal);
return result.handle;
}

View File

@@ -244,7 +244,7 @@ class Drm : public DriverModel {
MOCKABLE_VIRTUAL bool completionFenceSupport();
MOCKABLE_VIRTUAL uint32_t notifyFirstCommandQueueCreated();
MOCKABLE_VIRTUAL uint32_t notifyFirstCommandQueueCreated(const void *data, size_t size);
MOCKABLE_VIRTUAL void notifyLastCommandQueueDestroyed(uint32_t handle);
uint64_t getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion cacheRegion, CachePolicy cachePolicy, bool closEnabled) const;