checking return values for HSCH for various configurations. Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx> --- lib/s390x/css.h | 4 ++++ lib/s390x/css_lib.c | 4 ++++ s390x/css.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index e1e9264..cf48abc 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -93,6 +93,10 @@ struct scsw { #define SCSW_SSCH_COMPLETED (SCSW_CCW_FORMAT | SCSW_FC_START | \ SCSW_SC_PENDING | SCSW_SC_SECONDARY | \ SCSW_SC_PRIMARY) +#define SCSW_HSCH_COMPLETED (SCSW_CCW_FORMAT | SCSW_FC_HALT | \ + SCSW_SC_PENDING) +#define SCSW_CSCH_COMPLETED (SCSW_CCW_FORMAT | SCSW_FC_CLEAR | \ + SCSW_SC_PENDING) uint32_t ctrl; uint32_t ccw_addr; #define SCSW_DEVS_DEV_END 0x04 diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 7c93e94..d9ed2c3 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -533,6 +533,10 @@ int check_io_completion(int schid, uint32_t ctrl) goto end; } + /* We do not need more check for HSCH or CSCH */ + if (irb.scsw.ctrl & (SCSW_FC_HALT | SCSW_FC_CLEAR)) + 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); diff --git a/s390x/css.c b/s390x/css.c index f6890f2..ffc067e 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -56,6 +56,62 @@ static void test_enable(void) report(cc == 0, "Enable subchannel %08x", test_device_sid); } +static void test_hsch(void) +{ + struct orb orb = { + .intparm = test_device_sid, + .ctrl = ORB_CTRL_ISIC | ORB_CTRL_FMT | ORB_LPM_DFLT, + }; + struct ccw1 *ccw; + + NODEV_SKIP(test_device_sid); + + 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; + + /* 1- Basic HSCH */ + report_prefix_push("HSCH on a quiet subchannel"); + assert(css_enable(test_device_sid, 0) == 0); + report(hsch(test_device_sid) == 0, "subchannel halted"); + report_prefix_pop(); + + /* now we check the flags */ + report_prefix_push("Ctrl flags"); + assert(tsch(test_device_sid, &irb) == 0); + report(check_io_completion(test_device_sid, SCSW_HSCH_COMPLETED) == 0, "expected"); + report_prefix_pop(); + + /* 2- Check HSCH after SSCH */ + report_prefix_push("HSCH on status pending subchannel"); + assert(ssch(test_device_sid, &orb) == 0); + report(hsch(test_device_sid) == 1, "Halt subchannel should fail with CC 1"); + assert(tsch(test_device_sid, &irb) == 0); + check_io_completion(test_device_sid, SCSW_SSCH_COMPLETED); + report_prefix_pop(); + + /* 3- Check HSCH after CSCH */ + report_prefix_push("HSCH on busy on CSCH subchannel"); + assert(csch(test_device_sid) == 0); + report(hsch(test_device_sid) == 1, "Halt subchannel should fail with CC 1"); + assert(tsch(test_device_sid, &irb) == 0); + check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED); + report_prefix_pop(); + + /* 4- Check HSCH after HSCH */ + report_prefix_push("HSCH on busy on HSCH subchannel"); + assert(hsch(test_device_sid) == 0); + report(hsch(test_device_sid) == 1, "Halt subchannel should fail with CC 1"); + assert(tsch(test_device_sid, &irb) == 0); + check_io_completion(test_device_sid, SCSW_HSCH_COMPLETED); + report_prefix_pop(); + + free_io_mem(senseid, sizeof(*senseid)); + free_io_mem(ccw, sizeof(*ccw)); +} + static void test_ssch(void) { struct orb orb = { @@ -439,6 +495,7 @@ static struct { { "enumerate (stsch)", test_enumerate }, { "enable (msch)", test_enable }, { "start subchannel", test_ssch }, + { "halt subchannel", test_hsch }, { "sense (ssch/tsch)", test_sense }, { "measurement block (schm)", test_schm }, { "measurement block format0", test_schm_fmt0 }, -- 2.17.1