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 4/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetQueueAddress
Date: Fri, 27 Aug 2021 15:44:56 +0200 [thread overview]
Message-ID: <20210827134459.635098-5-kraxel@redhat.com> (raw)
In-Reply-To: <20210827134459.635098-1-kraxel@redhat.com>
Virtio 1.0 allows a more flexible virtio ring layout, so we have to set
addresses for descriptors avail flags and use flags separately. We
continue to use a ring layout compatible with virtio 0.9.5 though, so no
other changes are needed to setup the virtio queues.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
.../VirtioMmioDeviceFunctions.c | 27 +++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
index 50a4fd2100ee..cb1f9358eabd 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
@@ -183,13 +183,36 @@ VirtioMmioSetQueueAddress (
)
{
VIRTIO_MMIO_DEVICE *Device;
+ UINT64 Address;
ASSERT (RingBaseShift == 0);
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN,
- (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT));
+ if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN,
+ (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT));
+ } else {
+ Address = (UINTN)Ring->Base;
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO,
+ (UINT32)Address);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_HI,
+ (UINT32)RShiftU64(Address, 32));
+
+ Address = (UINTN)Ring->Avail.Flags;
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_LO,
+ (UINT32)Address);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_HI,
+ (UINT32)RShiftU64(Address, 32));
+
+ Address = (UINTN)Ring->Used.Flags;
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_USED_LO,
+ (UINT32)Address);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_USED_HI,
+ (UINT32)RShiftU64(Address, 32));
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_READY, 1);
+ }
return EFI_SUCCESS;
}
--
2.31.1
next prev 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 ` Gerd Hoffmann [this message]
2021-08-27 13:44 ` [PATCH v5 5/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Add default QueueNum Gerd Hoffmann
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-5-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