All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: David Miller <davem@davemloft.net>,
	cornelia.huck@de.ibm.com, rusty@au1.ibm.com, nab@linux-iscsi.org,
	pbonzini@redhat.com, thuth@linux.vnet.ibm.com,
	dahi@linux.vnet.ibm.com,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	linux390@de.ibm.com, Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH v8 17/50] KVM: s390: Set virtio-ccw transport revision
Date: Thu, 4 Dec 2014 18:10:22 +0200	[thread overview]
Message-ID: <20141204161022.GA23199@redhat.com> (raw)
In-Reply-To: <1417449619-24896-18-git-send-email-mst@redhat.com>

On Mon, Dec 01, 2014 at 06:04:11PM +0200, Michael S. Tsirkin wrote:
> From: Thomas Huth <thuth@linux.vnet.ibm.com>
> 
> With the new SET-VIRTIO-REVISION command of the virtio 1.0 standard, we
> can now negotiate the virtio-ccw revision after setting a channel online.
> 
> Note that we don't negotiate version 1 yet.
> 
> [Cornelia Huck: reworked revision loop a bit]
> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Looking at this some more: to me it looks
like this command should be repeated whenever we reset
the device.

No?


> ---
>  drivers/s390/kvm/virtio_ccw.c | 63 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
> 
> diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
> index 65d0c80..f6eb47b 100644
> --- a/drivers/s390/kvm/virtio_ccw.c
> +++ b/drivers/s390/kvm/virtio_ccw.c
> @@ -55,6 +55,7 @@ struct virtio_ccw_device {
>  	struct ccw_device *cdev;
>  	__u32 curr_io;
>  	int err;
> +	unsigned int revision; /* Transport revision */
>  	wait_queue_head_t wait_q;
>  	spinlock_t lock;
>  	struct list_head virtqueues;
> @@ -86,6 +87,15 @@ struct virtio_thinint_area {
>  	u8 isc;
>  } __packed;
>  
> +struct virtio_rev_info {
> +	__u16 revision;
> +	__u16 length;
> +	__u8 data[];
> +};
> +
> +/* the highest virtio-ccw revision we support */
> +#define VIRTIO_CCW_REV_MAX 0
> +
>  struct virtio_ccw_vq_info {
>  	struct virtqueue *vq;
>  	int num;
> @@ -122,6 +132,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];
>  #define CCW_CMD_WRITE_STATUS 0x31
>  #define CCW_CMD_READ_VQ_CONF 0x32
>  #define CCW_CMD_SET_IND_ADAPTER 0x73
> +#define CCW_CMD_SET_VIRTIO_REV 0x83
>  
>  #define VIRTIO_CCW_DOING_SET_VQ 0x00010000
>  #define VIRTIO_CCW_DOING_RESET 0x00040000
> @@ -134,6 +145,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];
>  #define VIRTIO_CCW_DOING_READ_VQ_CONF 0x02000000
>  #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_INTPARM_MASK 0xffff0000
>  
>  static struct virtio_ccw_device *to_vc_device(struct virtio_device *vdev)
> @@ -933,6 +945,7 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev,
>  		case VIRTIO_CCW_DOING_RESET:
>  		case VIRTIO_CCW_DOING_READ_VQ_CONF:
>  		case VIRTIO_CCW_DOING_SET_IND_ADAPTER:
> +		case VIRTIO_CCW_DOING_SET_VIRTIO_REV:
>  			vcdev->curr_io &= ~activity;
>  			wake_up(&vcdev->wait_q);
>  			break;
> @@ -1048,6 +1061,51 @@ static int virtio_ccw_offline(struct ccw_device *cdev)
>  	return 0;
>  }
>  
> +static int virtio_ccw_set_transport_rev(struct virtio_ccw_device *vcdev)
> +{
> +	struct virtio_rev_info *rev;
> +	struct ccw1 *ccw;
> +	int ret;
> +
> +	ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL);
> +	if (!ccw)
> +		return -ENOMEM;
> +	rev = kzalloc(sizeof(*rev), GFP_DMA | GFP_KERNEL);
> +	if (!rev) {
> +		kfree(ccw);
> +		return -ENOMEM;
> +	}
> +
> +	/* Set transport revision */
> +	ccw->cmd_code = CCW_CMD_SET_VIRTIO_REV;
> +	ccw->flags = 0;
> +	ccw->count = sizeof(*rev);
> +	ccw->cda = (__u32)(unsigned long)rev;
> +
> +	vcdev->revision = VIRTIO_CCW_REV_MAX;
> +	do {
> +		rev->revision = vcdev->revision;
> +		/* none of our supported revisions carry payload */
> +		rev->length = 0;
> +		ret = ccw_io_helper(vcdev, ccw,
> +				    VIRTIO_CCW_DOING_SET_VIRTIO_REV);
> +		if (ret == -EOPNOTSUPP) {
> +			if (vcdev->revision == 0)
> +				/*
> +				 * The host device does not support setting
> +				 * the revision: let's operate it in legacy
> +				 * mode.
> +				 */
> +				ret = 0;
> +			else
> +				vcdev->revision--;
> +		}
> +	} while (ret == -EOPNOTSUPP);
> +
> +	kfree(ccw);
> +	kfree(rev);
> +	return ret;
> +}
>  
>  static int virtio_ccw_online(struct ccw_device *cdev)
>  {
> @@ -1088,6 +1146,11 @@ static int virtio_ccw_online(struct ccw_device *cdev)
>  	spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
>  	vcdev->vdev.id.vendor = cdev->id.cu_type;
>  	vcdev->vdev.id.device = cdev->id.cu_model;
> +
> +	ret = virtio_ccw_set_transport_rev(vcdev);
> +	if (ret)
> +		goto out_free;
> +
>  	ret = register_virtio_device(&vcdev->vdev);
>  	if (ret) {
>  		dev_warn(&cdev->dev, "Failed to register virtio device: %d\n",
> -- 
> MST
> 

  reply	other threads:[~2014-12-04 16:10 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01 16:02 [PATCH v8 00/50] linux: towards virtio-1 guest support Michael S. Tsirkin
2014-12-01 16:02 ` [PATCH v8 01/50] virtio: add low-level APIs for feature bits Michael S. Tsirkin
2014-12-01 16:02 ` Michael S. Tsirkin
2014-12-01 16:02 ` [PATCH v8 02/50] virtio: use u32, not bitmap for features Michael S. Tsirkin
2014-12-01 16:02   ` Michael S. Tsirkin
2014-12-01 16:02 ` [PATCH v8 03/50] mic_virtio: robust feature array size calculation Michael S. Tsirkin
2014-12-02 10:13   ` Thomas Huth
2014-12-01 16:03 ` [PATCH v8 04/50] virtio: add support for 64 bit features Michael S. Tsirkin
2014-12-01 16:03   ` Michael S. Tsirkin
2014-12-01 16:03 ` [PATCH v8 05/50] virtio: assert 32 bit features in transports Michael S. Tsirkin
2014-12-01 16:03 ` Michael S. Tsirkin
2014-12-01 16:03 ` [PATCH v8 06/50] virtio_ccw: add support for 64 bit features Michael S. Tsirkin
2014-12-02 11:14   ` Thomas Huth
2014-12-01 16:03 ` [PATCH v8 07/50] virtio: add virtio 1.0 feature bit Michael S. Tsirkin
2014-12-01 16:03   ` Michael S. Tsirkin
2014-12-01 16:03 ` [PATCH v8 08/50] virtio: memory access APIs Michael S. Tsirkin
2014-12-01 16:03   ` Michael S. Tsirkin
2014-12-03  0:48   ` Prabhakar Lad
2014-12-03  0:48     ` Prabhakar Lad
2014-12-01 16:03 ` [PATCH v8 09/50] virtio_ring: switch to new " Michael S. Tsirkin
2014-12-01 16:03   ` Michael S. Tsirkin
2014-12-01 16:03 ` [PATCH v8 10/50] virtio_config: endian conversion for v1.0 Michael S. Tsirkin
2014-12-01 16:03   ` Michael S. Tsirkin
2014-12-01 16:03 ` [PATCH v8 11/50] virtio: allow transports to get avail/used addresses Michael S. Tsirkin
2014-12-01 16:03 ` Michael S. Tsirkin
2014-12-01 16:03 ` [PATCH v8 12/50] virtio: set FEATURES_OK Michael S. Tsirkin
2014-12-01 16:03   ` Michael S. Tsirkin
2014-12-01 16:03 ` [PATCH v8 13/50] virtio: simplify feature bit handling Michael S. Tsirkin
2014-12-01 16:03   ` Michael S. Tsirkin
2014-12-01 16:03 ` [PATCH v8 14/50] virtio: add legacy feature table support Michael S. Tsirkin
2014-12-01 16:03 ` Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 15/50] virtio_net: v1.0 endianness Michael S. Tsirkin
2014-12-01 16:04   ` Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 16/50] virtio_blk: v1.0 support Michael S. Tsirkin
2014-12-01 16:04 ` Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 17/50] KVM: s390: Set virtio-ccw transport revision Michael S. Tsirkin
2014-12-04 16:10   ` Michael S. Tsirkin [this message]
2014-12-04 16:19     ` Cornelia Huck
2014-12-01 16:04 ` [PATCH v8 18/50] KVM: s390: virtio-ccw revision 1 SET_VQ Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 19/50] KVM: s390 allow virtio_ccw status writes to fail Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 20/50] KVM: s390: enable virtio-ccw revision 1 Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 21/50] virtio_blk: make serial attribute static Michael S. Tsirkin
2014-12-01 16:04   ` Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 22/50] virtio_blk: fix race at module removal Michael S. Tsirkin
2014-12-01 16:04   ` Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 23/50] virtio_net: pass vi around Michael S. Tsirkin
2014-12-01 16:04   ` Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 24/50] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr Michael S. Tsirkin
2014-12-01 16:04   ` Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 25/50] virtio_net: stricter short buffer length checks Michael S. Tsirkin
2014-12-01 16:04 ` Michael S. Tsirkin
2014-12-01 16:04 ` [PATCH v8 26/50] virtio_net: bigger header when VERSION_1 is set Michael S. Tsirkin
2014-12-01 16:04   ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 27/50] virtio_net: disable mac write for virtio 1.0 Michael S. Tsirkin
2014-12-01 16:05   ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 28/50] virtio_net: enable v1.0 support Michael S. Tsirkin
2014-12-01 16:05   ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 29/50] vhost: make features 64 bit Michael S. Tsirkin
2014-12-01 16:05 ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 30/50] vhost: add memory access wrappers Michael S. Tsirkin
2014-12-01 16:05   ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 31/50] vhost/net: force len for TX to host endian Michael S. Tsirkin
2014-12-01 16:05   ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 32/50] vhost: switch to __get/__put_user exclusively Michael S. Tsirkin
2014-12-01 16:05 ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 33/50] vhost: virtio 1.0 endian-ness support Michael S. Tsirkin
2014-12-01 16:05   ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 34/50] vhost/net: virtio 1.0 byte swap Michael S. Tsirkin
2014-12-01 16:05   ` Michael S. Tsirkin
2015-01-06 23:55   ` Alex Williamson
2015-01-06 23:55   ` Alex Williamson
2015-01-07  8:31     ` Greg Kurz
2015-01-07  8:31       ` Greg Kurz
2015-01-07  8:57       ` Michael S. Tsirkin
2015-01-07  8:57       ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 35/50] vhost/net: larger header for virtio 1.0 Michael S. Tsirkin
2014-12-01 16:05   ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 36/50] vhost/net: enable " Michael S. Tsirkin
2014-12-01 16:05   ` Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 37/50] tun: move internal flag defines out of uapi Michael S. Tsirkin
2014-12-01 16:05 ` [PATCH v8 38/50] tun: drop most type defines Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 39/50] tun: add VNET_LE flag Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 40/50] tun: TUN_VNET_LE support, fix sparse warnings for virtio headers Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 41/50] macvtap: TUN_VNET_LE support Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 42/50] virtio_scsi: v1.0 support Michael S. Tsirkin
2014-12-01 16:06   ` Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 43/50] virtio_scsi: move to uapi Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 44/50] virtio_scsi: export to userspace Michael S. Tsirkin
2014-12-01 16:06   ` Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 45/50] vhost/scsi: partial virtio 1.0 support Michael S. Tsirkin
2014-12-01 16:06 ` Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 46/50] af_packet: virtio 1.0 stubs Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 47/50] virtio_console: virtio 1.0 support Michael S. Tsirkin
2014-12-01 16:06   ` Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 48/50] virtio_balloon: add legacy_only flag Michael S. Tsirkin
2014-12-01 16:06   ` Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 49/50] virtio: make VIRTIO_F_VERSION_1 a transport bit Michael S. Tsirkin
2014-12-01 16:06   ` Michael S. Tsirkin
2014-12-01 16:06 ` [PATCH v8 50/50] virtio: drop VIRTIO_F_VERSION_1 from drivers Michael S. Tsirkin
2014-12-01 16:06 ` Michael S. Tsirkin
2014-12-08  8:58 ` [PATCH v8 00/50] linux: towards virtio-1 guest support Michael S. Tsirkin
2014-12-09  0:33   ` David Miller
2014-12-10 23:09     ` Rusty Russell
2014-12-10 19:14 ` Michael S. Tsirkin
2014-12-12 23:48   ` Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141204161022.GA23199@redhat.com \
    --to=mst@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=dahi@linux.vnet.ibm.com \
    --cc=davem@davemloft.net \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux390@de.ibm.com \
    --cc=nab@linux-iscsi.org \
    --cc=pbonzini@redhat.com \
    --cc=rusty@au1.ibm.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=thuth@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.