[kvm-unit-tests PATCH v1 4/6] s390x: lib: css: add expectations to wait for interrupt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When waiting for an interrupt we may need to check the cause of
the interrupt depending on the test case.

Let's provide the tests the possibility to check if the last valid
IRQ received is for the expected instruction.

Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
---
 lib/s390x/css.h     |  2 +-
 lib/s390x/css_lib.c | 11 ++++++++++-
 s390x/css.c         |  4 ++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 65fc335..add3b4e 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -316,7 +316,7 @@ 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 wait_and_check_io_completion(int schid, uint32_t pending);
 
 /*
  * CHSC definitions
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index 211c73c..4cdd7ad 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -537,7 +537,7 @@ struct ccw1 *ccw_alloc(int code, void *data, int count, unsigned char flags)
  * completion.
  * Only report failures.
  */
-int wait_and_check_io_completion(int schid)
+int wait_and_check_io_completion(int schid, uint32_t pending)
 {
 	int ret = 0;
 	struct irq_entry *irq = NULL;
@@ -569,6 +569,15 @@ int wait_and_check_io_completion(int schid)
 		goto end;
 	}
 
+	if (pending) {
+		if (!(pending & irq->irb.scsw.ctrl)) {
+			report_info("%08x : %s", schid, dump_scsw_flags(irq->irb.scsw.ctrl));
+			report_info("expect   : %s", dump_scsw_flags(pending));
+			ret = -1;
+			goto end;
+		}
+	}
+
 	/* clear and halt pending are valid even without secondary or primary status */
 	if (irq->irb.scsw.ctrl & (SCSW_FC_CLEAR | SCSW_FC_HALT)) {
 		ret = 0;
diff --git a/s390x/css.c b/s390x/css.c
index c340c53..a6a9773 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -94,7 +94,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, SCSW_FC_START) < 0)
 		goto error;
 
 	/* Test transfer completion */
@@ -137,7 +137,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, SCSW_FC_START) >= 0);
 }
 
 static void css_init(void)
-- 
2.17.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux