summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2021-08-27 21:44:57 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-08-30 01:05:49 +0000
commit6a3e9576b835a766b558864d798f71b0d61136f6 (patch)
tree1800799766d83d1b286d09764e426523bf61a6b6
parent537a724421393191f8a47eae6653b071e970016e (diff)
downloadedk2-6a3e9576b835a766b558864d798f71b0d61136f6.tar.gz
edk2-6a3e9576b835a766b558864d798f71b0d61136f6.tar.bz2
edk2-6a3e9576b835a766b558864d798f71b0d61136f6.zip
OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Add default QueueNum
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> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h1
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c12
2 files changed, 12 insertions, 1 deletions
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
index 0c2f99633c..5ad951f415 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 cb1f9358ea..436da2a2b4 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);