From aff75c955f5dafb3723b97ca2e0c361e288a40f7 Mon Sep 17 00:00:00 2001 From: Mukul Joshi Date: Mon, 10 Aug 2020 12:50:33 -0400 Subject: [PATCH] Add support for KFD Thermal Throttling SMI event Add handling for receiving thermal throttling SMI event from the kernel. Also, update the event notification test to work with the new event. Change-Id: Ib89c12b244f90998ccbae0a38b37f25705d156e0 --- include/rocm_smi/kfd_ioctl.h | 1 + include/rocm_smi/rocm_smi.h | 7 ++++--- tests/rocm_smi_test/functional/evt_notif_read_write.cc | 2 +- tests/rocm_smi_test/test_utils.cc | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/rocm_smi/kfd_ioctl.h b/include/rocm_smi/kfd_ioctl.h index da9b985304..1af726d75a 100755 --- a/include/rocm_smi/kfd_ioctl.h +++ b/include/rocm_smi/kfd_ioctl.h @@ -544,6 +544,7 @@ struct kfd_ioctl_import_dmabuf_args { enum kfd_smi_event { KFD_SMI_EVENT_NONE = 0, /* not used */ KFD_SMI_EVENT_VMFAULT = 1, /* event start counting at 1 */ + KFD_SMI_EVENT_THERMAL_THROTTLE = 2, }; #define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1)) diff --git a/include/rocm_smi/rocm_smi.h b/include/rocm_smi/rocm_smi.h index ef1025bebc..ffe77cd49b 100755 --- a/include/rocm_smi/rocm_smi.h +++ b/include/rocm_smi/rocm_smi.h @@ -280,8 +280,9 @@ typedef struct { typedef enum { RSMI_EVT_NOTIF_VMFAULT = KFD_SMI_EVENT_VMFAULT, //!< VM page fault RSMI_EVT_NOTIF_FIRST = RSMI_EVT_NOTIF_VMFAULT, + RSMI_EVT_NOTIF_THERMAL_THROTTLE = KFD_SMI_EVENT_THERMAL_THROTTLE, - RSMI_EVT_NOTIF_LAST = RSMI_EVT_NOTIF_VMFAULT + RSMI_EVT_NOTIF_LAST = RSMI_EVT_NOTIF_THERMAL_THROTTLE } rsmi_evt_notification_type_t; /* @@ -3228,8 +3229,8 @@ rsmi_event_notification_init(uint32_t dv_ind); * bit position starting from 1. * For example, if the mask field is 0x0000000000000003, which means first bit, * bit 1 (bit position start from 1) and bit 2 are set, which indicate interest - * in receiving RSMI_EVT_NOTIF_VMFAULT (which has a value of 1) and the next - * event in that list which has a value of 2. + * in receiving RSMI_EVT_NOTIF_VMFAULT (which has a value of 1) and + * RSMI_EVT_NOTIF_THERMAL_THROTTLE event (which has a value of 2). * * @retval ::RSMI_STATUS_INIT_ERROR is returned if * ::rsmi_event_notification_init() has not been called before a call to this diff --git a/tests/rocm_smi_test/functional/evt_notif_read_write.cc b/tests/rocm_smi_test/functional/evt_notif_read_write.cc index cab9f07b4a..e0abf0fd00 100755 --- a/tests/rocm_smi_test/functional/evt_notif_read_write.cc +++ b/tests/rocm_smi_test/functional/evt_notif_read_write.cc @@ -102,7 +102,7 @@ void TestEvtNotifReadWrite::Run(void) { rsmi_evt_notification_type_t evt_type = RSMI_EVT_NOTIF_FIRST; uint64_t mask = RSMI_EVENT_MASK_FROM_INDEX(evt_type); - while (evt_type != RSMI_EVT_NOTIF_LAST) { + while (evt_type <= RSMI_EVT_NOTIF_LAST) { mask |= RSMI_EVENT_MASK_FROM_INDEX(evt_type); evt_type = static_cast( static_cast(evt_type)+1); diff --git a/tests/rocm_smi_test/test_utils.cc b/tests/rocm_smi_test/test_utils.cc index b434a078e8..9618b8f0e3 100755 --- a/tests/rocm_smi_test/test_utils.cc +++ b/tests/rocm_smi_test/test_utils.cc @@ -80,6 +80,7 @@ NameFromFWEnum(rsmi_fw_block_t blk) { static const std::map kEvtNotifEvntNameMap = { {RSMI_EVT_NOTIF_VMFAULT, "RSMI_EVT_NOTIF_VMFAULT"}, + {RSMI_EVT_NOTIF_THERMAL_THROTTLE, "RSMI_EVT_NOTIF_THERMAL_THROTTLE"}, }; const char * NameFromEvtNotifType(rsmi_evt_notification_type_t evt) {