* [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates.
@ 2013-04-23 12:37 Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 1/4] s390-ccw.img: Detect devices with stsch Cornelia Huck
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Cornelia Huck @ 2013-04-23 12:37 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, qemu-devel, Dominik Dingel
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(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/4] s390-ccw.img: Detect devices with stsch.
2013-04-23 12:37 [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Cornelia Huck
@ 2013-04-23 12:37 ` Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 2/4] s390-ccw.img: Enhance drain_irqs() Cornelia Huck
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Cornelia Huck @ 2013-04-23 12:37 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, qemu-devel, Dominik Dingel
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).
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
pc-bios/s390-ccw/main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
index 67f4987..fd40fa5 100644
--- a/pc-bios/s390-ccw/main.c
+++ b/pc-bios/s390-ccw/main.c
@@ -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;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/4] s390-ccw.img: Enhance drain_irqs().
2013-04-23 12:37 [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 1/4] s390-ccw.img: Detect devices with stsch Cornelia Huck
@ 2013-04-23 12:37 ` Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 3/4] s390-ccw.img: Rudimentary error checking Cornelia Huck
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Cornelia Huck @ 2013-04-23 12:37 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, qemu-devel, Dominik Dingel
- Use tpi + tsch to get interrupts.
- Return an error if the irb indicates problems.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
pc-bios/s390-ccw/virtio.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 79e2941..2a132f8 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -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;
+ }
}
}
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 3/4] s390-ccw.img: Rudimentary error checking.
2013-04-23 12:37 [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 1/4] s390-ccw.img: Detect devices with stsch Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 2/4] s390-ccw.img: Enhance drain_irqs() Cornelia Huck
@ 2013-04-23 12:37 ` Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 4/4] s390-ccw.img: Get queue config from host Cornelia Huck
2013-04-24 18:08 ` [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Alexander Graf
4 siblings, 0 replies; 6+ messages in thread
From: Cornelia Huck @ 2013-04-23 12:37 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, qemu-devel, Dominik Dingel
Try to handle at least some of the errors that may happen.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
pc-bios/s390-ccw/virtio.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 2a132f8..8e37dce 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -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)
--
1.7.12.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 4/4] s390-ccw.img: Get queue config from host.
2013-04-23 12:37 [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Cornelia Huck
` (2 preceding siblings ...)
2013-04-23 12:37 ` [Qemu-devel] [PATCH 3/4] s390-ccw.img: Rudimentary error checking Cornelia Huck
@ 2013-04-23 12:37 ` Cornelia Huck
2013-04-24 18:08 ` [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Alexander Graf
4 siblings, 0 replies; 6+ messages in thread
From: Cornelia Huck @ 2013-04-23 12:37 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, qemu-devel, Dominik Dingel
Ask the host about the configuration instead of guessing it.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
pc-bios/s390-ccw/virtio.c | 10 +++++++---
pc-bios/s390-ccw/virtio.h | 5 +++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 8e37dce..6b28aab 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -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))) {
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
index a33199d..86fdd57 100644
--- a/pc-bios/s390-ccw/virtio.h
+++ b/pc-bios/s390-ccw/virtio.h
@@ -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;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates.
2013-04-23 12:37 [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Cornelia Huck
` (3 preceding siblings ...)
2013-04-23 12:37 ` [Qemu-devel] [PATCH 4/4] s390-ccw.img: Get queue config from host Cornelia Huck
@ 2013-04-24 18:08 ` Alexander Graf
4 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2013-04-24 18:08 UTC (permalink / raw)
To: Cornelia Huck; +Cc: Christian Borntraeger, qemu-devel, Dominik Dingel
On 23.04.2013, at 14:37, Cornelia Huck wrote:
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-24 18:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-23 12:37 [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 1/4] s390-ccw.img: Detect devices with stsch Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 2/4] s390-ccw.img: Enhance drain_irqs() Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 3/4] s390-ccw.img: Rudimentary error checking Cornelia Huck
2013-04-23 12:37 ` [Qemu-devel] [PATCH 4/4] s390-ccw.img: Get queue config from host Cornelia Huck
2013-04-24 18:08 ` [Qemu-devel] [PATCH 0/4] s390-ccw.img: Some more updates Alexander Graf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).