virtio_ccw: new status accessor in driver
Subsystems (3)
cover virtio_ccw: new status accessor in driver
This patch (on top of "virtio/s390: handle failures of READ_VQ_CONF ccw") implements the guest side of the new status ccw.
Pierre Morel (1):
virtio/s390: support READ_STATUS command for virtio-ccw
drivers/s390/virtio/virtio_ccw.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
Signature · 1 line
2.3.8
RFC PATCH 1/1 virtio/s390: support READ_STATUS command for virtio-ccw
From: Pierre Morel <[email protected]>
As virtio-1 introduced the possibility of the device manipulating the status byte, revision 2 of the virtio-ccw transport introduced a means of getting the status byte from the device via READ_STATUS. Let's wire it up for revisions >= 2 and fall back to returning the stored status byte if not supported.
--- drivers/s390/virtio/virtio_ccw.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/s390/virtio/virtio_ccw.c +25 -0
@@ -144,6 +144,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];#define CCW_CMD_WRITE_CONF 0x21#define CCW_CMD_WRITE_STATUS 0x31#define CCW_CMD_READ_VQ_CONF 0x32 +#define CCW_CMD_READ_STATUS 0x72#define CCW_CMD_SET_IND_ADAPTER 0x73#define CCW_CMD_SET_VIRTIO_REV 0x83
@@ -159,6 +160,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];#define VIRTIO_CCW_DOING_SET_CONF_IND 0x04000000#define VIRTIO_CCW_DOING_SET_IND_ADAPTER 0x08000000#define VIRTIO_CCW_DOING_SET_VIRTIO_REV 0x10000000 +#define VIRTIO_CCW_DOING_READ_STATUS 0x20000000#define VIRTIO_CCW_INTPARM_MASK 0xffff0000static struct virtio_ccw_device *to_vc_device (struct virtio_device *vdev)
@@ -889,6 +891,28 @@ out_free:static u8 virtio_ccw_get_status (struct virtio_device *vdev) {struct virtio_ccw_device *vcdev =to_vc_device (vdev); +u8 old_status = *vcdev->status; +struct ccw1 *ccw; + +if (vcdev->revision <1 ) +return *vcdev->status; + + ccw =kzalloc (sizeof (*ccw),GFP_DMA |GFP_KERNEL ); +if (!ccw) +return old_status; + + ccw->cmd_code =CCW_CMD_READ_STATUS ; + ccw->flags =0 ; + ccw->count =sizeof (*vcdev->status); + ccw->cda = (__u32 )(unsigned long )vcdev->status; +ccw_io_helper (vcdev, ccw,VIRTIO_CCW_DOING_READ_STATUS ); +/* +* If the channel program failed (should only happen if the device +* was hotunplugged, and then we clean up via the machine check +* handler anyway), vcdev->status was not overwritten and we just +* return the old status, which is fine. +*/ +kfree (ccw);return *vcdev->status; }
@@ -1008,6 +1032,7 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev,case VIRTIO_CCW_DOING_READ_CONFIG :case VIRTIO_CCW_DOING_WRITE_CONFIG :case VIRTIO_CCW_DOING_WRITE_STATUS : +case VIRTIO_CCW_DOING_READ_STATUS :case VIRTIO_CCW_DOING_SET_VQ :case VIRTIO_CCW_DOING_SET_IND :case VIRTIO_CCW_DOING_SET_CONF_IND :
Signature · 1 line
2.3.8
RFC PATCH 1/1 virtio/s390: support READ_STATUS command for virtio-ccw
In reply to Cornelia HuckFrom: Pierre Morel <[email protected]>
As virtio-1 introduced the possibility of the device manipulating the status byte, revision 2 of the virtio-ccw transport introduced a means of getting the status byte from the device via READ_STATUS. Let's wire it up for revisions >= 2 and fall back to returning the stored status byte if not supported.
--- drivers/s390/virtio/virtio_ccw.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/s390/virtio/virtio_ccw.c +25 -0
@@ -144,6 +144,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];#define CCW_CMD_WRITE_CONF 0x21#define CCW_CMD_WRITE_STATUS 0x31#define CCW_CMD_READ_VQ_CONF 0x32 +#define CCW_CMD_READ_STATUS 0x72#define CCW_CMD_SET_IND_ADAPTER 0x73#define CCW_CMD_SET_VIRTIO_REV 0x83
@@ -159,6 +160,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];#define VIRTIO_CCW_DOING_SET_CONF_IND 0x04000000#define VIRTIO_CCW_DOING_SET_IND_ADAPTER 0x08000000#define VIRTIO_CCW_DOING_SET_VIRTIO_REV 0x10000000 +#define VIRTIO_CCW_DOING_READ_STATUS 0x20000000#define VIRTIO_CCW_INTPARM_MASK 0xffff0000static struct virtio_ccw_device *to_vc_device (struct virtio_device *vdev)
@@ -889,6 +891,28 @@ out_free:static u8 virtio_ccw_get_status (struct virtio_device *vdev) {struct virtio_ccw_device *vcdev =to_vc_device (vdev); +u8 old_status = *vcdev->status; +struct ccw1 *ccw; + +if (vcdev->revision <1 ) +return *vcdev->status; + + ccw =kzalloc (sizeof (*ccw),GFP_DMA |GFP_KERNEL ); +if (!ccw) +return old_status; + + ccw->cmd_code =CCW_CMD_READ_STATUS ; + ccw->flags =0 ; + ccw->count =sizeof (*vcdev->status); + ccw->cda = (__u32 )(unsigned long )vcdev->status; +ccw_io_helper (vcdev, ccw,VIRTIO_CCW_DOING_READ_STATUS ); +/* +* If the channel program failed (should only happen if the device +* was hotunplugged, and then we clean up via the machine check +* handler anyway), vcdev->status was not overwritten and we just +* return the old status, which is fine. +*/ +kfree (ccw);return *vcdev->status; }
@@ -1008,6 +1032,7 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev,case VIRTIO_CCW_DOING_READ_CONFIG :case VIRTIO_CCW_DOING_WRITE_CONFIG :case VIRTIO_CCW_DOING_WRITE_STATUS : +case VIRTIO_CCW_DOING_READ_STATUS :case VIRTIO_CCW_DOING_SET_VQ :case VIRTIO_CCW_DOING_SET_IND :case VIRTIO_CCW_DOING_SET_CONF_IND :
Signature · 1 line
2.3.8