|
1 | 1 | /* |
2 | | - * Copyright (C) 2020-2021 Intel Corporation |
| 2 | + * Copyright (C) 2022-2023 Intel Corporation |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: MIT |
5 | 5 | * |
|
8 | 8 | #pragma once |
9 | 9 | #include "level_zero/tools/source/sysman/events/os_events.h" |
10 | 10 | #include "level_zero/tools/source/sysman/linux/os_sysman_imp.h" |
| 11 | +#include "level_zero/tools/source/sysman/linux/udev/udev_lib.h" |
11 | 12 |
|
12 | 13 | namespace L0 { |
13 | 14 |
|
14 | 15 | class LinuxEventsImp : public OsEvents, NEO::NonCopyableOrMovableClass { |
15 | 16 | public: |
16 | 17 | bool eventListen(zes_event_type_flags_t &pEvent, uint64_t timeout) override; |
17 | 18 | ze_result_t eventRegister(zes_event_type_flags_t events) override; |
18 | | - LinuxEventsImp() = default; |
| 19 | + LinuxEventsImp() = delete; |
19 | 20 | LinuxEventsImp(OsSysman *pOsSysman); |
20 | 21 | ~LinuxEventsImp() override = default; |
21 | 22 |
|
22 | 23 | protected: |
23 | 24 | LinuxSysmanImp *pLinuxSysmanImp = nullptr; |
24 | | - void getPciIdPathTag(); |
25 | | - zes_mem_health_t currentMemHealth(); |
26 | | - bool isResetRequired(zes_event_type_flags_t &pEvent); |
| 25 | +}; |
| 26 | + |
| 27 | +class LinuxEventsUtil { |
| 28 | + |
| 29 | + public: |
| 30 | + LinuxEventsUtil() = default; |
| 31 | + ~LinuxEventsUtil() = default; |
| 32 | + |
| 33 | + ze_result_t eventsListen(uint64_t timeout, uint32_t count, zes_device_handle_t *phDevices, uint32_t *pNumDeviceEvents, zes_event_type_flags_t *pEvents); |
| 34 | + void eventRegister(zes_event_type_flags_t events, SysmanDeviceImp *pSysmanDevice); |
| 35 | + |
| 36 | + protected: |
| 37 | + UdevLib *pUdevLib = nullptr; |
| 38 | + bool checkRasEvent(zes_event_type_flags_t &pEvent, SysmanDeviceImp *pSysmanDeviceImp, zes_event_type_flags_t registeredEvents); |
| 39 | + bool isResetRequired(void *dev, zes_event_type_flags_t &pEvent); |
27 | 40 | bool checkDeviceDetachEvent(zes_event_type_flags_t &pEvent); |
28 | 41 | bool checkDeviceAttachEvent(zes_event_type_flags_t &pEvent); |
29 | | - bool checkIfMemHealthChanged(zes_event_type_flags_t &pEvent); |
30 | | - std::string pciIdPathTag; |
31 | | - zes_mem_health_t memHealthAtEventRegister = ZES_MEM_HEALTH_UNKNOWN; |
| 42 | + bool checkIfMemHealthChanged(void *dev, zes_event_type_flags_t &pEvent); |
| 43 | + bool listenSystemEvents(zes_event_type_flags_t *pEvents, uint32_t count, std::vector<zes_event_type_flags_t> ®isteredEvents, zes_device_handle_t *phDevices, uint64_t timeout); |
32 | 44 |
|
33 | 45 | private: |
34 | | - FsAccess *pFsAccess = nullptr; |
35 | | - SysfsAccess *pSysfsAccess = nullptr; |
36 | | - static const std::string varFs; |
37 | | - static const std::string detachEvent; |
38 | | - static const std::string attachEvent; |
39 | | - zes_event_type_flags_t registeredEvents = 0; |
| 46 | + std::map<SysmanDeviceImp *, zes_event_type_flags_t> deviceEventsMap; |
| 47 | + std::string action; |
| 48 | + static const std::string add; |
| 49 | + static const std::string remove; |
| 50 | + static const std::string change; |
| 51 | + static const std::string unbind; |
| 52 | + static const std::string bind; |
| 53 | + static bool checkRasEventOccured(Ras *rasHandle); |
| 54 | + std::once_flag initEventsOnce; |
| 55 | + void init(); |
40 | 56 | }; |
41 | 57 |
|
42 | 58 | } // namespace L0 |
0 commit comments