public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Jiewen Yao <jiewen.yao@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Philippe Mathieu-Daude <philmd@redhat.com>
Subject: [PATCH v5 5/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Add default QueueNum
Date: Fri, 27 Aug 2021 15:44:57 +0200	[thread overview]
Message-ID: <20210827134459.635098-6-kraxel@redhat.com> (raw)
In-Reply-To: <20210827134459.635098-1-kraxel@redhat.com>

Use QueueNumMax as QueueNum default for drivers which do not
explicitly call VIRTIO_DEVICE_PROTOCOL->SetQueueSize().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
 .../Library/VirtioMmioDeviceLib/VirtioMmioDevice.h   |  1 +
 .../VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c  | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
index 0c2f99633c46..5ad951f4154a 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
@@ -30,6 +30,7 @@
 typedef struct {
   UINT32                 Signature;
   UINT32                 Version;
+  UINT16                 QueueNum;
   VIRTIO_DEVICE_PROTOCOL VirtioDevice;
   PHYSICAL_ADDRESS       BaseAddress;
 } VIRTIO_MMIO_DEVICE;
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
index cb1f9358eabd..436da2a2b497 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
@@ -83,7 +83,11 @@ VirtioMmioSetQueueSize (
 
   Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
 
-  VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize);
+  if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+    VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize);
+  } else {
+    Device->QueueNum = QueueSize;
+  }
 
   return EFI_SUCCESS;
 }
@@ -171,6 +175,10 @@ VirtioMmioSetQueueSel (
 
   VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_SEL, Sel);
 
+  if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+    Device->QueueNum = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX) & 0xFFFF;
+  }
+
   return EFI_SUCCESS;
 }
 
@@ -193,6 +201,8 @@ VirtioMmioSetQueueAddress (
     VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN,
       (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT));
   } else {
+    VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, Device->QueueNum);
+
     Address = (UINTN)Ring->Base;
     VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO,
                       (UINT32)Address);
-- 
2.31.1


  parent reply	other threads:[~2021-08-27 13:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 13:44 [PATCH v5 0/7] add support for virtio-mmio 1.0 Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 1/7] OvmfPkg/Virtio10: Add virtio-mmio 1.0 defines Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 2/7] OvmfPkg/VirtioMmioDeviceLib: Add virtio 1.0 detection Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 3/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetPageSize Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 4/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetQueueAddress Gerd Hoffmann
2021-08-27 13:44 ` Gerd Hoffmann [this message]
2021-08-27 13:44 ` [PATCH v5 6/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Adapt feature bit handling Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 7/7] OvmfPkg/VirtioMmioDeviceLib: enable virtio 1.0 Gerd Hoffmann
2021-08-28  1:49 ` [PATCH v5 0/7] add support for virtio-mmio 1.0 Yao, Jiewen
2021-08-30  1:20 ` Yao, Jiewen
2021-08-30  1:21 ` Yao, Jiewen
2021-08-30  3:17   ` 回复: [edk2-devel] " gaoliming
2021-08-30  7:54     ` Gerd Hoffmann

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-list 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=20210827134459.635098-6-kraxel@redhat.com \
    --to=devel@edk2.groups.io \
    /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