fix: Proper update of device count that generated events

numDeviceEvents out param is not being updated in case
there are no events and device events map is not overridden
on multiple register calls result in failure.

Related-To: LOCI-4751

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran
2023-08-03 06:48:59 +00:00
committed by Compute-Runtime-Automation
parent 742bc15be9
commit 63fa05e776
4 changed files with 8 additions and 4 deletions

View File

@@ -122,7 +122,7 @@ void LinuxEventsUtil::eventRegister(zes_event_type_flags_t events, SysmanDeviceI
registeredEvents = deviceEventsMap[pSysmanDevice];
}
registeredEvents |= (events & supportedEventMask);
deviceEventsMap.emplace(pSysmanDevice, registeredEvents);
deviceEventsMap[pSysmanDevice] = registeredEvents;
}
// Write to Pipe only if eventregister() is called during listen and previously registered events are modified.
@@ -142,6 +142,7 @@ void LinuxEventsUtil::init() {
ze_result_t LinuxEventsUtil::eventsListen(uint64_t timeout, uint32_t count, zes_device_handle_t *phDevices, uint32_t *pNumDeviceEvents, zes_event_type_flags_t *pEvents) {
memset(pEvents, 0, count * sizeof(zes_event_type_flags_t));
*pNumDeviceEvents = 0;
std::vector<zes_event_type_flags_t> registeredEvents(count);
for (uint32_t devIndex = 0; devIndex < count; devIndex++) {
auto device = static_cast<SysmanDeviceImp *>(L0::SysmanDevice::fromHandle(phDevices[devIndex]));

View File

@@ -618,7 +618,7 @@ TEST_F(SysmanEventsFixture,
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED));
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
phDevices[0] = device->toHandle();
uint32_t numDeviceEvents = 0;
uint32_t numDeviceEvents = std::numeric_limits<uint32_t>::max();
zes_event_type_flags_t *pDeviceEvents = new zes_event_type_flags_t[1];
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListen(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
EXPECT_EQ(0u, numDeviceEvents);
@@ -714,6 +714,7 @@ TEST_F(SysmanEventsFixture, GivenEventsAreRegisteredWhenEventRegisterWithNoEvent
pLinuxEventsImp->deviceEventsMap = deviceEventsMap;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), 0));
EXPECT_EQ(0u, pLinuxEventsImp->deviceEventsMap[pLinuxSysmanImp->getSysmanDeviceImp()]);
pPublicLinuxSysmanDriverImp->pLinuxEventsUtil = pLinuxEventsUtilOld;
L0::osSysmanDriverDestructor();