From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH v2 3/4] OvmfPkg/VirtioMmioDeviceLib: Add default QueueNum for virtio 1.0
Date: Mon, 16 Aug 2021 09:11:08 +0200 [thread overview]
Message-ID: <20210816071109.101122-4-kraxel@redhat.com> (raw)
In-Reply-To: <20210816071109.101122-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>
---
.../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 8b19996b716f..232393bb9114 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
@@ -27,6 +27,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 bf8523a6fb3b..c7a22c1e1cc4 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 == 1) {
+ Device->QueueNum = QueueSize;
+ } else {
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize);
+ }
return EFI_SUCCESS;
}
@@ -171,6 +175,10 @@ VirtioMmioSetQueueSel (
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_SEL, Sel);
+ if (Device->Version == 1) {
+ 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 = (UINT64)Ring->Base;
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO,
(UINT32)Address);
--
2.31.1
next prev parent reply other threads:[~2021-08-16 10:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 7:11 [PATCH v2 0/4] add support for virtio-mmio 1.0 Gerd Hoffmann
2021-08-16 7:11 ` [PATCH v2 1/4] OvmfPkg/Virtio10: Add virtio-mmio 1.0 defines Gerd Hoffmann
2021-08-16 7:11 ` [PATCH v2 2/4] OvmfPkg/VirtioMmioDeviceLib: Add virtio 1.0 support Gerd Hoffmann
2021-08-16 13:35 ` [edk2-devel] " Yao, Jiewen
2021-08-16 16:04 ` Philippe Mathieu-Daudé
[not found] ` <169BCCE38BFCC61F.3513@groups.io>
2021-08-16 13:37 ` Yao, Jiewen
2021-08-16 7:11 ` Gerd Hoffmann [this message]
2021-08-16 7:11 ` [PATCH v2 4/4] OvmfPkg/VirtioMmioDeviceLib: Add virtio 1.0 feature bit handling 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=20210816071109.101122-4-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