s390-ccw.img: Some more updates.
cover s390-ccw.img: Some more updates.
Some changes I hacked up quickly for the ccw loader.
Only compile tested as my main test system is currently unavailable.
Cornelia Huck (4):
s390-ccw.img: Detect devices with stsch.
s390-ccw.img: Enhance drain_irqs().
s390-ccw.img: Rudimentary error checking.
s390-ccw.img: Get queue config from host.
pc-bios/s390-ccw/main.c | 9 +++++--- pc-bios/s390-ccw/virtio.c | 52 ++++++++++++++++++++++++++++++++++++----------- pc-bios/s390-ccw/virtio.h | 5 +++++ 3 files changed, 51 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.12.4
PATCH 1/4 s390-ccw.img: Detect devices with stsch.
stsch is the canonical way to detect devices. As a bonus, we can abort the loop if we get cc 3, and we need to check only the valid devices (dnv set).
--- pc-bios/s390-ccw/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/main.c +6 -3
@@ -22,7 +22,7 @@ void virtio_panic(const char *string)static void virtio_setup (void ) { -struct irb irb; +struct schib schib;int i;int r;bool found = false;
@@ -31,8 +31,11 @@ static void virtio_setup(void)for (i =0 ; i <0x10000 ; i++) { blk_schid.sch_no = i; - r =tsch (blk_schid, &irb); -if (r !=3 ) { + r =stsch_err (blk_schid, &schib); +if (r ==3 ) { +break ; + } +if (schib.pmcw.dnv) {if (virtio_is_blk (blk_schid)) { found = true;break ;
Signature · 1 line
1.7.12.4
PATCH 2/4 s390-ccw.img: Enhance drain_irqs().
In reply to Cornelia Huck- Use tpi + tsch to get interrupts.
- Return an error if the irb indicates problems.
--- pc-bios/s390-ccw/virtio.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/virtio.c +18 -3
@@ -38,12 +38,27 @@ static void virtio_notify(struct subchannel_id schid)* Virtio functions * ***********************************************/ -static void drain_irqs (struct subchannel_id schid) +static int drain_irqs (struct subchannel_id schid) {struct irb irb = {}; +struct tpi_info tpi_info = {}; +int r =0 ; +while (1 ) { -if (tsch (schid, &irb)) { -return ; +if (tpi (&tpi_info)) { +if (tpi_info.schid.sch_no != schid.sch_no) { +/* should not really happen... */ +continue ; + } +if (tsch (schid, &irb)) { +/* Might want to differentiate error codes later on. */ +if (irb.scsw.cstat) { + r = -EIO ; + }else if (irb.scsw.dstat !=0xc ) { + r = -EIO ; + } +return r; + } } } }
Signature · 1 line
1.7.12.4
PATCH 3/4 s390-ccw.img: Rudimentary error checking.
In reply to Cornelia HuckTry to handle at least some of the errors that may happen.
--- pc-bios/s390-ccw/virtio.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/virtio.c +15 -6
@@ -90,7 +90,9 @@ static int run_ccw(struct subchannel_id schid, int cmd, void *ptr, int len)* assume that a simple tsch will have finished the CCW processing, * but the architecture allows for asynchronous operation */ -drain_irqs (schid); +if (!r) { + r =drain_irqs (schid); + }return r; }
@@ -98,7 +100,9 @@ static void virtio_set_status(struct subchannel_id schid, unsigned long dev_addr) {unsigned char status = dev_addr; -run_ccw (schid,CCW_CMD_WRITE_STATUS , &status,sizeof (status)); +if (run_ccw (schid,CCW_CMD_WRITE_STATUS , &status,sizeof (status))) { +virtio_panic ("Could not write status to host!\n" ); + } }static void virtio_reset (struct subchannel_id schid)
@@ -197,6 +201,7 @@ static int virtio_read_many(ulong sector, void *load_addr, int sec_num) {struct virtio_blk_outhdr out_hdr;u8 status; +int r;/* Tell the host we want to read */ out_hdr.type =VIRTIO_BLK_T_IN ;
@@ -217,8 +222,11 @@ static int virtio_read_many(ulong sector, void *load_addr, int sec_num)/* Now we can tell the host to read */ vring_wait_reply (&block,0 ); -drain_irqs (block.schid); - + r =drain_irqs (block.schid); +if (r) { +/* Well, whatever status is supposed to contain... */ + status =1 ; + }return status; }
@@ -266,8 +274,9 @@ void virtio_setup_block(struct subchannel_id schid) info.num =128 ; block.schid = schid; -run_ccw (schid,CCW_CMD_SET_VQ , &info,sizeof (info)); -virtio_set_status (schid,VIRTIO_CONFIG_S_DRIVER_OK ); +if (!run_ccw (schid,CCW_CMD_SET_VQ , &info,sizeof (info))) { +virtio_set_status (schid,VIRTIO_CONFIG_S_DRIVER_OK ); + } }bool virtio_is_blk (struct subchannel_id schid)
Signature · 1 line
1.7.12.4
PATCH 4/4 s390-ccw.img: Get queue config from host.
In reply to Cornelia HuckAsk the host about the configuration instead of guessing it.
--- pc-bios/s390-ccw/virtio.c | 10 +++++++--- pc-bios/s390-ccw/virtio.h | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/virtio.c +7 -3
@@ -261,17 +261,21 @@ int virtio_read(ulong sector, void *load_addr)void virtio_setup_block (struct subchannel_id schid) {struct vq_info_block info; +struct vq_config_block config = {};virtio_reset (schid); -/* XXX need to fetch the 128 from host */ -vring_init (&block,128 , (void *)(100 *1024 *1024 ), + config.index =0 ; +if (run_ccw (schid,CCW_CMD_READ_VQ_CONF , &config,sizeof (config))) { +virtio_panic ("Could not get block device configuration\n" ); + } +vring_init (&block, config.num, (void *)(100 *1024 *1024 ),KVM_S390_VIRTIO_RING_ALIGN ); info.queue = (100ULL *1024ULL *1024ULL ); info.align =KVM_S390_VIRTIO_RING_ALIGN ; info.index =0 ; - info.num =128 ; + info.num = config.num; block.schid = schid;if (!run_ccw (schid,CCW_CMD_SET_VQ , &info,sizeof (info))) {
pc-bios/s390-ccw/virtio.h +5 -0
@@ -53,6 +53,11 @@ struct vq_info_block {u16 num; } __attribute__((packed)); +struct vq_config_block { +u16 index; +u16 num; +} __attribute__((packed)); +struct virtio_dev {struct virtio_dev_header *header;struct virtio_vqconfig *vqconfig;
Signature · 1 line
1.7.12.4
Quoted 3 lines · Cornelia Huck
Some changes I hacked up quickly for the ccw loader.
Only compile tested as my main test system is currently unavailable.
Yup, doesn't work :)
Alex