virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Feng Liu via Virtualization <virtualization@lists.linux-foundation.org>
To: <virtualization@lists.linux-foundation.org>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	Jiri Pirko <jiri@nvidia.com>, Bodong Wang <bodong@nvidia.com>,
	Gavin Li <gavinl@nvidia.com>
Subject: [PATCH v2 1/3] virtio_pci_modern: Allow non power of 2 sizes for virtqueues
Date: Fri, 10 Mar 2023 07:34:26 +0200	[thread overview]
Message-ID: <20230310053428.3376-2-feliu@nvidia.com> (raw)
In-Reply-To: <20230310053428.3376-1-feliu@nvidia.com>

According to the Virtio Specification, the Queue Size parameter of a
virtqueue corresponds to the maximum number of descriptors in that
queue, and it does not have to be a power of 2 for packed virtqueues.
However, the virtio_pci_modern driver enforced a power of 2 check for
virtqueue sizes, which is unnecessary and restrictive. This commit
removes that check, allowing virtqueues to have arbitrary sizes as
specified by the Virtio Specification.

To validate this change, we tested various virtqueue sizes for packed
rings, including 128, 256, 512, 100, 200, 500, and 1000, with
CONFIG_PAGE_POISONING enabled, and all tests passed successfully.

Signed-off-by: Feng Liu <feliu@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Gavin Li <gavinl@nvidia.com>
Reviewed-by: Bodong Wang <bodong@nvidia.com>
Reviewed-by: David Edmondson <david.edmondson@oracle.com>

---
v1 -> v2
feedbacks from Jason Wang and Michael S. Tsirkin
- remove power_of_2 check of virtqueue size
---
 drivers/virtio/virtio_pci_modern.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index 9e496e288cfa..6e713904d8e8 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -310,11 +310,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
 	if (!num || vp_modern_get_queue_enable(mdev, index))
 		return ERR_PTR(-ENOENT);
 
-	if (!is_power_of_2(num)) {
-		dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num);
-		return ERR_PTR(-EINVAL);
-	}
-
 	info->msix_vector = msix_vec;
 
 	/* create the vring */
-- 
2.34.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2023-03-10  5:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10  5:34 [PATCH v2 0/3] virtio_ring: Clean up code for virtio ring and pci Feng Liu via Virtualization
2023-03-10  5:34 ` Feng Liu via Virtualization [this message]
2023-03-10 13:36   ` [PATCH v2 1/3] virtio_pci_modern: Allow non power of 2 sizes for virtqueues Parav Pandit via Virtualization
2023-03-10 15:23     ` Feng Liu via Virtualization
2023-03-11 19:05       ` Michael S. Tsirkin
2023-03-11 22:25         ` Feng Liu via Virtualization
2023-03-12  6:46           ` Michael S. Tsirkin
2023-03-12 12:05             ` Feng Liu via Virtualization
2023-03-10  5:34 ` [PATCH v2 2/3] virtio_ring: Avoid using inline for small functions Feng Liu via Virtualization
2023-03-10  5:34 ` [PATCH v2 3/3] virtio_ring: Use const to annotate read-only pointer params Feng Liu via Virtualization
2023-03-10  8:06 ` [PATCH v2 0/3] virtio_ring: Clean up code for virtio ring and pci Michael S. Tsirkin
2023-03-10 13:21   ` Feng Liu via Virtualization
2023-03-11 19:06     ` Michael S. Tsirkin
2023-03-11 22:19       ` Feng Liu via Virtualization
2023-03-12  6:47         ` Michael S. Tsirkin
2023-03-12 12:00           ` Feng Liu via Virtualization

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=20230310053428.3376-2-feliu@nvidia.com \
    --to=virtualization@lists.linux-foundation.org \
    --cc=bodong@nvidia.com \
    --cc=feliu@nvidia.com \
    --cc=gavinl@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=mst@redhat.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).