vsock.c (2b703bbda2713fd2a7d98029ea6c44f9c3159f34) vsock.c (247643f85782fc1119ccbd712a5075535ebf9d43)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * vhost transport for vsock
4 *
5 * Copyright (C) 2013-2015 Red Hat, Inc.
6 * Author: Asias He <asias@redhat.com>
7 * Stefan Hajnoczi <stefanha@redhat.com>
8 */

--- 77 unchanged lines hidden (view full) ---

86{
87 struct vhost_virtqueue *tx_vq = &vsock->vqs[VSOCK_VQ_TX];
88 int pkts = 0, total_len = 0;
89 bool added = false;
90 bool restart_tx = false;
91
92 mutex_lock(&vq->mutex);
93
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * vhost transport for vsock
4 *
5 * Copyright (C) 2013-2015 Red Hat, Inc.
6 * Author: Asias He <asias@redhat.com>
7 * Stefan Hajnoczi <stefanha@redhat.com>
8 */

--- 77 unchanged lines hidden (view full) ---

86{
87 struct vhost_virtqueue *tx_vq = &vsock->vqs[VSOCK_VQ_TX];
88 int pkts = 0, total_len = 0;
89 bool added = false;
90 bool restart_tx = false;
91
92 mutex_lock(&vq->mutex);
93
94 if (!vq->private_data)
94 if (!vhost_vq_get_backend(vq))
95 goto out;
96
97 /* Avoid further vmexits, we're already processing the virtqueue */
98 vhost_disable_notify(&vsock->dev, vq);
99
100 do {
101 struct virtio_vsock_pkt *pkt;
102 struct iov_iter iov_iter;

--- 332 unchanged lines hidden (view full) ---

435 dev);
436 struct virtio_vsock_pkt *pkt;
437 int head, pkts = 0, total_len = 0;
438 unsigned int out, in;
439 bool added = false;
440
441 mutex_lock(&vq->mutex);
442
95 goto out;
96
97 /* Avoid further vmexits, we're already processing the virtqueue */
98 vhost_disable_notify(&vsock->dev, vq);
99
100 do {
101 struct virtio_vsock_pkt *pkt;
102 struct iov_iter iov_iter;

--- 332 unchanged lines hidden (view full) ---

435 dev);
436 struct virtio_vsock_pkt *pkt;
437 int head, pkts = 0, total_len = 0;
438 unsigned int out, in;
439 bool added = false;
440
441 mutex_lock(&vq->mutex);
442
443 if (!vq->private_data)
443 if (!vhost_vq_get_backend(vq))
444 goto out;
445
446 vhost_disable_notify(&vsock->dev, vq);
447 do {
448 u32 len;
449
450 if (!vhost_vsock_more_replies(vsock)) {
451 /* Stop tx until the device processes already

--- 76 unchanged lines hidden (view full) ---

528
529 mutex_lock(&vq->mutex);
530
531 if (!vhost_vq_access_ok(vq)) {
532 ret = -EFAULT;
533 goto err_vq;
534 }
535
444 goto out;
445
446 vhost_disable_notify(&vsock->dev, vq);
447 do {
448 u32 len;
449
450 if (!vhost_vsock_more_replies(vsock)) {
451 /* Stop tx until the device processes already

--- 76 unchanged lines hidden (view full) ---

528
529 mutex_lock(&vq->mutex);
530
531 if (!vhost_vq_access_ok(vq)) {
532 ret = -EFAULT;
533 goto err_vq;
534 }
535
536 if (!vq->private_data) {
537 vq->private_data = vsock;
536 if (!vhost_vq_get_backend(vq)) {
537 vhost_vq_set_backend(vq, vsock);
538 ret = vhost_vq_init_access(vq);
539 if (ret)
540 goto err_vq;
541 }
542
543 mutex_unlock(&vq->mutex);
544 }
545
546 mutex_unlock(&vsock->dev.mutex);
547 return 0;
548
549err_vq:
538 ret = vhost_vq_init_access(vq);
539 if (ret)
540 goto err_vq;
541 }
542
543 mutex_unlock(&vq->mutex);
544 }
545
546 mutex_unlock(&vsock->dev.mutex);
547 return 0;
548
549err_vq:
550 vq->private_data = NULL;
550 vhost_vq_set_backend(vq, NULL);
551 mutex_unlock(&vq->mutex);
552
553 for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) {
554 vq = &vsock->vqs[i];
555
556 mutex_lock(&vq->mutex);
551 mutex_unlock(&vq->mutex);
552
553 for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) {
554 vq = &vsock->vqs[i];
555
556 mutex_lock(&vq->mutex);
557 vq->private_data = NULL;
557 vhost_vq_set_backend(vq, NULL);
558 mutex_unlock(&vq->mutex);
559 }
560err:
561 mutex_unlock(&vsock->dev.mutex);
562 return ret;
563}
564
565static int vhost_vsock_stop(struct vhost_vsock *vsock)

--- 6 unchanged lines hidden (view full) ---

572 ret = vhost_dev_check_owner(&vsock->dev);
573 if (ret)
574 goto err;
575
576 for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) {
577 struct vhost_virtqueue *vq = &vsock->vqs[i];
578
579 mutex_lock(&vq->mutex);
558 mutex_unlock(&vq->mutex);
559 }
560err:
561 mutex_unlock(&vsock->dev.mutex);
562 return ret;
563}
564
565static int vhost_vsock_stop(struct vhost_vsock *vsock)

--- 6 unchanged lines hidden (view full) ---

572 ret = vhost_dev_check_owner(&vsock->dev);
573 if (ret)
574 goto err;
575
576 for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) {
577 struct vhost_virtqueue *vq = &vsock->vqs[i];
578
579 mutex_lock(&vq->mutex);
580 vq->private_data = NULL;
580 vhost_vq_set_backend(vq, NULL);
581 mutex_unlock(&vq->mutex);
582 }
583
584err:
585 mutex_unlock(&vsock->dev.mutex);
586 return ret;
587}
588

--- 265 unchanged lines hidden ---
581 mutex_unlock(&vq->mutex);
582 }
583
584err:
585 mutex_unlock(&vsock->dev.mutex);
586 return ret;
587}
588

--- 265 unchanged lines hidden ---