diff mbox series

[kvm-unit-tests,v3,16/16] s390x: css: testing clear subchannel

Message ID 1617694853-6881-17-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
Checking return values for CSCH for various configurations.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 s390x/css.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
diff mbox series

Patch

diff --git a/s390x/css.c b/s390x/css.c
index 0f80a44..00c77c7 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -362,6 +362,69 @@  static void test_hsch(void)
 	free_io_mem(ccw, sizeof(*ccw));
 }
 
+static void test_csch(void)
+{
+	struct orb orb = {
+		.intparm = test_device_sid,
+		.ctrl = ORB_CTRL_ISIC | ORB_CTRL_FMT | ORB_LPM_DFLT,
+	};
+	struct ccw1 *ccw;
+
+	senseid = alloc_io_mem(sizeof(*senseid), 0);
+	assert(senseid);
+	ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI);
+	assert(ccw);
+	orb.cpa = (uint64_t)ccw;
+
+	/* CSCH is a privilege operation */
+	report_prefix_push("Privilege");
+	enter_pstate();
+	expect_pgm_int();
+	csch(test_device_sid);
+	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
+	report_prefix_pop();
+
+	/* Basic check for CSCH */
+	report_prefix_push("CSCH on a quiet subchannel");
+	assert(css_enable(test_device_sid, 0) == 0);
+	report(csch(test_device_sid) == 0, "subchannel clear");
+	report_prefix_pop();
+
+	/* now we check the flags */
+	report_prefix_push("IRQ flags");
+	assert(tsch(test_device_sid, &irb) == 0);
+	report(check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED) == 0, "expected");
+	report_prefix_pop();
+
+	/* We want to check if the IRQ flags of SSCH are erased by clear */
+	report_prefix_push("CSCH on SSCH status pending subchannel");
+	assert(ssch(test_device_sid, &orb) == 0);
+	report(csch(test_device_sid) == 0, "subchannel cleared");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED |
+			    SCSW_SC_SECONDARY | SCSW_SC_PRIMARY);
+	report_prefix_pop();
+
+	/* Checking CSCH after HSCH */
+	report_prefix_push("CSCH on a halted subchannel");
+	assert(hsch(test_device_sid) == 0);
+	report(csch(test_device_sid) == 0, "subchannel cleared");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED);
+	report_prefix_pop();
+
+	/* Checking CSCH after CSCH */
+	report_prefix_push("CSCH on a cleared subchannel");
+	assert(csch(test_device_sid) == 0);
+	report(csch(test_device_sid) == 0, "subchannel cleared");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED);
+	report_prefix_pop();
+
+	free_io_mem(senseid, sizeof(*senseid));
+	free_io_mem(ccw, sizeof(*ccw));
+}
+
 /*
  * test_sense
  * Pre-requisites:
@@ -632,6 +695,7 @@  static struct tests tests[] = {
 	{ "enable (msch)", test_enable },
 	{ "start subchannel", test_ssch },
 	{ "halt subchannel", test_hsch },
+	{ "clear subchannel", test_csch },
 	{ "sense (ssch/tsch)", test_sense },
 	{ "measurement block (schm)", test_schm },
 	{ "measurement block format0", test_schm_fmt0 },