diff mbox series

[kvm-unit-tests,v3,04/16] s390x: lib: css: separate wait for IRQ and check I/O completion

Message ID 1617694853-6881-5-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
We will may want to check the result of an I/O without waiting
for an interrupt.
For example because we do not handle interrupt.
Let's separate waiting for interrupt and the I/O completion check.

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

Patch

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 0058355..5d1e1f0 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -317,6 +317,7 @@  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);
 
 /*
  * CHSC definitions
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index 9711b0b..e81076a 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -483,55 +483,59 @@  struct ccw1 *ccw_alloc(int code, void *data, int count, unsigned char flags)
 }
 
 /* wait_and_check_io_completion:
+ * @schid: the subchannel ID
+ */
+int wait_and_check_io_completion(int schid)
+{
+	wait_for_interrupt(PSW_MASK_IO);
+
+	if (lowcore_ptr->io_int_param != schid) {
+		report(0, "interrupt parameter: expected %08x got %08x", schid, lowcore_ptr->io_int_param);
+		return -1;
+	}
+
+	return check_io_completion(schid);
+}
+
+/* check_io_completion:
  * @schid: the subchannel ID
  *
  * Makes the most common check to validate a successful I/O
  * completion.
  * Only report failures.
  */
-int wait_and_check_io_completion(int schid)
+int check_io_completion(int schid)
 {
-	int ret = 0;
-
-	wait_for_interrupt(PSW_MASK_IO);
+	int ret = -1;
 
 	report_prefix_push("check I/O completion");
 
-	if (lowcore_ptr->io_int_param != schid) {
-		report(0, "interrupt parameter: expected %08x got %08x",
-		       schid, lowcore_ptr->io_int_param);
-		ret = -1;
-		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",
 		       irb.scsw.ctrl);
-		ret = -1;
 		goto end;
 	}
 
 	if (!(irb.scsw.ctrl & (SCSW_SC_SECONDARY | SCSW_SC_PRIMARY))) {
 		report(0, "Primary or secondary status missing. Subch Ctrl: %08x",
 		       irb.scsw.ctrl);
-		ret = -1;
 		goto end;
 	}
 
 	if (!(irb.scsw.dev_stat & (SCSW_DEVS_DEV_END | SCSW_DEVS_SCH_END))) {
 		report(0, "No device end or sch end. Dev. status: %02x",
 		       irb.scsw.dev_stat);
-		ret = -1;
 		goto end;
 	}
 
 	if (irb.scsw.sch_stat & ~SCSW_SCHS_IL) {
 		report_info("Unexpected Subch. status %02x", irb.scsw.sch_stat);
-		ret = -1;
 		goto end;
 	}
 
+	ret = 0;
+
 end:
 	report_prefix_pop();
 	return ret;