Message ID | 1587725152-25569-11-git-send-email-pmorel@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | s390x: Testing the Channel Subsystem I/O | expand |
On 4/24/20 12:45 PM, Pierre Morel wrote: > To test a write command with the SSCH instruction we need a QEMU device, > with control unit type 0xC0CA. The PONG device is such a device. > > This type of device responds to PONG_WRITE requests by incrementing an > integer, stored as a string at offset 0 of the CCW data. > > Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> > --- > s390x/css.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/s390x/css.c b/s390x/css.c > index b9dbf01..7cd8731 100644 > --- a/s390x/css.c > +++ b/s390x/css.c > @@ -23,6 +23,12 @@ > #define PSW_PRG_MASK (PSW_MASK_EA | PSW_MASK_BA) > > #define PONG_CU_TYPE 0xc0ca > +/* Channel Commands for PONG device */ > +#define PONG_WRITE 0x21 /* Write */ > +#define PONG_READ 0x22 /* Read buffer */ > + > +#define BUFSZ 9 > +static char buffer[BUFSZ]; > > struct lowcore *lowcore = (void *)0x0; > > @@ -262,6 +268,53 @@ unreg_cb: > unregister_io_int_func(irq_io); > } > > +static void test_ping(void) > +{ > + int success, result; > + int cnt = 0, max = 4; > + > + if (senseid.cu_type != PONG_CU) { > + report_skip("No PONG, no ping-pong"); "Device is not a pong device." > + return; > + } > + > + result = register_io_int_func(irq_io); > + if (result) { > + report(0, "Could not register IRQ handler"); > + return; > + } I'm not sure if it's worth checking the return values or even having a check in register_io_int_func() in the first place. > + > + while (cnt++ < max) { > + snprintf(buffer, BUFSZ, "%08x\n", cnt); > + success = start_subchannel(PONG_WRITE, buffer, BUFSZ); > + if (!success) { > + report(0, "start_subchannel failed"); > + goto unreg_cb; > + } > + > + wfi(PSW_MASK_IO); > + > + success = start_subchannel(PONG_READ, buffer, BUFSZ); > + if (!success) { > + report(0, "start_subchannel failed"); > + goto unreg_cb; > + } > + > + wfi(PSW_MASK_IO); > + > + result = atol(buffer); > + if (result != (cnt + 1)) { > + report(0, "Bad answer from pong: %08x - %08x", > + cnt, result); > + goto unreg_cb; > + } > + } > + report(1, "ping-pong count 0x%08x", cnt); > + > +unreg_cb: > + unregister_io_int_func(irq_io); > +} > + > static struct { > const char *name; > void (*func)(void); > @@ -269,6 +322,7 @@ static struct { > { "enumerate (stsch)", test_enumerate }, > { "enable (msch)", test_enable }, > { "sense (ssch/tsch)", test_sense }, > + { "ping-pong (ssch/tsch)", test_ping }, > { NULL, NULL } > }; > >
On 2020-04-27 15:14, Janosch Frank wrote: > On 4/24/20 12:45 PM, Pierre Morel wrote: >> To test a write command with the SSCH instruction we need a QEMU device, >> with control unit type 0xC0CA. The PONG device is such a device. >> >> This type of device responds to PONG_WRITE requests by incrementing an >> integer, stored as a string at offset 0 of the CCW data. >> >> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> >> +static void test_ping(void) >> +{ >> + int success, result; >> + int cnt = 0, max = 4; >> + >> + if (senseid.cu_type != PONG_CU) { >> + report_skip("No PONG, no ping-pong"); > > "Device is not a pong device." :( so far for poetry > >> + return; >> + } >> + >> + result = register_io_int_func(irq_io); >> + if (result) { >> + report(0, "Could not register IRQ handler"); >> + return; >> + } > > I'm not sure if it's worth checking the return values or even having a > check in register_io_int_func() in the first place. I wait for reviewers/maintainers having already given their reviewed-by to the interrupt registration patch to give their opinion. Then I change it if needed. Regards, Pierre
diff --git a/s390x/css.c b/s390x/css.c index b9dbf01..7cd8731 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -23,6 +23,12 @@ #define PSW_PRG_MASK (PSW_MASK_EA | PSW_MASK_BA) #define PONG_CU_TYPE 0xc0ca +/* Channel Commands for PONG device */ +#define PONG_WRITE 0x21 /* Write */ +#define PONG_READ 0x22 /* Read buffer */ + +#define BUFSZ 9 +static char buffer[BUFSZ]; struct lowcore *lowcore = (void *)0x0; @@ -262,6 +268,53 @@ unreg_cb: unregister_io_int_func(irq_io); } +static void test_ping(void) +{ + int success, result; + int cnt = 0, max = 4; + + if (senseid.cu_type != PONG_CU) { + report_skip("No PONG, no ping-pong"); + return; + } + + result = register_io_int_func(irq_io); + if (result) { + report(0, "Could not register IRQ handler"); + return; + } + + while (cnt++ < max) { + snprintf(buffer, BUFSZ, "%08x\n", cnt); + success = start_subchannel(PONG_WRITE, buffer, BUFSZ); + if (!success) { + report(0, "start_subchannel failed"); + goto unreg_cb; + } + + wfi(PSW_MASK_IO); + + success = start_subchannel(PONG_READ, buffer, BUFSZ); + if (!success) { + report(0, "start_subchannel failed"); + goto unreg_cb; + } + + wfi(PSW_MASK_IO); + + result = atol(buffer); + if (result != (cnt + 1)) { + report(0, "Bad answer from pong: %08x - %08x", + cnt, result); + goto unreg_cb; + } + } + report(1, "ping-pong count 0x%08x", cnt); + +unreg_cb: + unregister_io_int_func(irq_io); +} + static struct { const char *name; void (*func)(void); @@ -269,6 +322,7 @@ static struct { { "enumerate (stsch)", test_enumerate }, { "enable (msch)", test_enable }, { "sense (ssch/tsch)", test_sense }, + { "ping-pong (ssch/tsch)", test_ping }, { NULL, NULL } };
To test a write command with the SSCH instruction we need a QEMU device, with control unit type 0xC0CA. The PONG device is such a device. This type of device responds to PONG_WRITE requests by incrementing an integer, stored as a string at offset 0 of the CCW data. Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> --- s390x/css.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)