diff mbox series

[kvm-unit-tests,v3,05/16] s390x: lib: css: add SCSW ctrl expectations to check I/O completion

Message ID 1617694853-6881-6-git-send-email-pmorel@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390x: Testing SSCH, CSCH and HSCH for errors | expand

Commit Message

Pierre Morel April 6, 2021, 7:40 a.m. UTC
When we check for the completion of an I/O, we may need to check
the cause of the interrupt depending on the test case.

Let's make it possible for the tests to check whether the last valid
IRB received indicates the expected functions after executing
an instruction or sequence of instructions and if all ctrl flags
of the SCSW are set as expected.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h     |  4 ++--
 lib/s390x/css_lib.c | 21 ++++++++++++++++-----
 s390x/css.c         |  4 ++--
 3 files changed, 20 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 5d1e1f0..1603781 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -316,8 +316,8 @@  void css_irq_io(void);
 int css_residual_count(unsigned int schid);
 
 void enable_io_isc(uint8_t isc);
-int wait_and_check_io_completion(int schid);
-int check_io_completion(int schid);
+int wait_and_check_io_completion(int schid, uint32_t ctrl);
+int check_io_completion(int schid, uint32_t ctrl);
 
 /*
  * CHSC definitions
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index e81076a..97bf032 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -484,8 +484,9 @@  struct ccw1 *ccw_alloc(int code, void *data, int count, unsigned char flags)
 
 /* wait_and_check_io_completion:
  * @schid: the subchannel ID
+ * @ctrl : expected SCSW control flags
  */
-int wait_and_check_io_completion(int schid)
+int wait_and_check_io_completion(int schid, uint32_t ctrl)
 {
 	wait_for_interrupt(PSW_MASK_IO);
 
@@ -494,22 +495,32 @@  int wait_and_check_io_completion(int schid)
 		return -1;
 	}
 
-	return check_io_completion(schid);
+	return check_io_completion(schid, ctrl);
 }
 
 /* check_io_completion:
  * @schid: the subchannel ID
+ * @ctrl : expected SCSW control flags
  *
- * Makes the most common check to validate a successful I/O
- * completion.
+ * Perform some standard checks to validate a successful I/O completion.
+ * If the ctrl parameter is not zero, additionally verify that the
+ * specified bits are indicated in the IRB SCSW ctrl flags.
  * Only report failures.
  */
-int check_io_completion(int schid)
+int check_io_completion(int schid, uint32_t ctrl)
 {
 	int ret = -1;
 
 	report_prefix_push("check I/O completion");
 
+	if (ctrl) {
+		if (ctrl == irb.scsw.ctrl)
+			ret = 0;
+		else
+			report_info("extected %s != %s", dump_scsw_flags(irb.scsw.ctrl), dump_scsw_flags(ctrl));
+		goto end;
+	}
+
 	/* Verify that device status is valid */
 	if (!(irb.scsw.ctrl & SCSW_SC_PENDING)) {
 		report(0, "No status pending after interrupt. Subch Ctrl: %08x",
diff --git a/s390x/css.c b/s390x/css.c
index 17a6e1d..f4b7af1 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -84,7 +84,7 @@  static void test_sense(void)
 		goto error;
 	}
 
-	if (wait_and_check_io_completion(test_device_sid) < 0)
+	if (wait_and_check_io_completion(test_device_sid, 0) < 0)
 		goto error;
 
 	/* Test transfer completion */
@@ -127,7 +127,7 @@  static void sense_id(void)
 {
 	assert(!start_ccw1_chain(test_device_sid, ccw));
 
-	assert(wait_and_check_io_completion(test_device_sid) >= 0);
+	assert(wait_and_check_io_completion(test_device_sid, 0) >= 0);
 }
 
 static void css_init(void)