qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Eugenio Pérez" <eperezma@redhat.com>
To: qemu-devel@nongnu.org
Cc: Parav Pandit <parav@mellanox.com>,
	Dragos Tatulea <dtatulea@nvidia.com>,
	Lei Yang <leiyang@redhat.com>, Jason Wang <jasowang@redhat.com>,
	si-wei.liu@oracle.com, Zhu Lingshan <lingshan.zhu@intel.com>,
	Stefano Garzarella <sgarzare@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>
Subject: [PATCH v3 13/14] vdpa: factor out vhost_vdpa_last_dev
Date: Thu, 21 Dec 2023 12:53:18 +0100	[thread overview]
Message-ID: <20231221115319.3067586-14-eperezma@redhat.com> (raw)
In-Reply-To: <20231221115319.3067586-1-eperezma@redhat.com>

From: Si-Wei Liu <si-wei.liu@oracle.com>

Generalize duplicated condition check for the last vq of vdpa
device to a common function.

This is used in next patches.

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
---
v3: Cherry-picked from Si-Wei's series
---
 hw/virtio/vhost-vdpa.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 61553ad196..a846abccb0 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -557,6 +557,11 @@ static bool vhost_vdpa_first_dev(struct vhost_dev *dev)
     return v->index == 0;
 }
 
+static bool vhost_vdpa_last_dev(struct vhost_dev *dev)
+{
+    return dev->vq_index + dev->nvqs == dev->vq_index_end;
+}
+
 static int vhost_vdpa_get_dev_features(struct vhost_dev *dev,
                                        uint64_t *features)
 {
@@ -1317,7 +1322,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
         vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
     }
 
-    if (dev->vq_index + dev->nvqs != dev->vq_index_end) {
+    if (!vhost_vdpa_last_dev(dev)) {
         return 0;
     }
 
@@ -1339,7 +1344,7 @@ static void vhost_vdpa_reset_status(struct vhost_dev *dev)
 {
     struct vhost_vdpa *v = dev->opaque;
 
-    if (dev->vq_index + dev->nvqs != dev->vq_index_end) {
+    if (!vhost_vdpa_last_dev(dev)) {
         return;
     }
 
-- 
2.39.3



  parent reply	other threads:[~2023-12-21 11:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 11:53 [PATCH v3 00/14] Consolidate common vdpa members in VhostVDPAShared Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 01/14] vdpa: add VhostVDPAShared Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 02/14] vdpa: move iova tree to the shared struct Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 03/14] vdpa: move iova_range to vhost_vdpa_shared Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 04/14] vdpa: move shadow_data " Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 05/14] vdpa: use vdpa shared for tracing Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 06/14] vdpa: move file descriptor to vhost_vdpa_shared Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 07/14] vdpa: move iotlb_batch_begin_sent " Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 08/14] vdpa: move backend_cap " Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 09/14] vdpa: remove msg type of vhost_vdpa Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 10/14] vdpa: move iommu_list to vhost_vdpa_shared Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 11/14] vdpa: use VhostVDPAShared in vdpa_dma_map and unmap Eugenio Pérez
2023-12-21 11:53 ` [PATCH v3 12/14] vdpa: use dev_shared in vdpa_iommu Eugenio Pérez
2023-12-21 11:53 ` Eugenio Pérez [this message]
2023-12-21 11:53 ` [PATCH v3 14/14] vdpa: move memory listener to vhost_vdpa_shared Eugenio Pérez

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=20231221115319.3067586-14-eperezma@redhat.com \
    --to=eperezma@redhat.com \
    --cc=dtatulea@nvidia.com \
    --cc=jasowang@redhat.com \
    --cc=leiyang@redhat.com \
    --cc=lingshan.zhu@intel.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=parav@mellanox.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=si-wei.liu@oracle.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 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).