Update Event Notification test for GPU Reset event

Update the event notification tests to handle both GPU pre reset
and GPU post reset events. GPU post reset event takes sometime to
be generated after the pre reset event, so issue another
notification read to wait for post reset event.

Change-Id: I2812760b184d5357130e478cc35d27b14592abb3


[ROCm/amdsmi commit: 446ab5c8c7]
This commit is contained in:
Mukul Joshi
2020-11-20 15:41:07 -05:00
parent 273ab71c38
commit c017960507
@@ -125,6 +125,7 @@ void TestEvtNotifReadWrite::Run(void) {
rsmi_evt_notification_data_t data[10];
uint32_t num_elem = 10;
bool read_again = false;
ret = rsmi_event_notification_get(10000, &num_elem, data);
if (ret == RSMI_STATUS_SUCCESS || ret == RSMI_STATUS_INSUFFICIENT_SIZE) {
@@ -135,6 +136,9 @@ void TestEvtNotifReadWrite::Run(void) {
std::cout << "\tdv_ind=" << data[i].dv_ind <<
" Type: " << NameFromEvtNotifType(data[i].event) <<
" Mesg: " << data[i].message << std::endl;
if (data[i].event == RSMI_EVT_NOTIF_GPU_PRE_RESET) {
read_again = true;
}
}
}
IF_VERB(STANDARD) {
@@ -154,6 +158,38 @@ void TestEvtNotifReadWrite::Run(void) {
"Unexpected return code for rsmi_event_notification_get()";
}
// In case GPU Pre reset event was collected in the previous read,
// read again to get the GPU Post reset event.
if (read_again) {
ret = rsmi_event_notification_get(10000, &num_elem, data);
if (ret == RSMI_STATUS_SUCCESS || ret == RSMI_STATUS_INSUFFICIENT_SIZE) {
EXPECT_LE(num_elem, 10) <<
"Expected the number of elements found to be <= buffer size (10)";
IF_VERB(STANDARD) {
for (uint32_t i = 0; i < num_elem; ++i) {
std::cout << "\tdv_ind=" << data[i].dv_ind <<
" Type: " << NameFromEvtNotifType(data[i].event) <<
" Mesg: " << data[i].message << std::endl;
}
}
IF_VERB(STANDARD) {
if (ret == RSMI_STATUS_INSUFFICIENT_SIZE) {
std::cout <<
"\t\tBuffer size is 10, but more than 10 events are available." <<
std::endl;
}
}
} else if (ret == RSMI_STATUS_NO_DATA) {
IF_VERB(STANDARD) {
std::cout << "\tNo further events were collected." << std::endl;
}
} else {
// This should always fail. We want to print out the return code.
EXPECT_EQ(ret, RSMI_STATUS_SUCCESS) <<
"Unexpected return code for rsmi_event_notification_get()";
}
}
for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) {
ret = rsmi_event_notification_stop(dv_ind);
ASSERT_EQ(ret, RSMI_STATUS_SUCCESS);