[edk2] [PATCH v2 14/23] OvmfPkg/Virtio10Dxe: add the RingBaseShift offset

Brijesh Singh posted 21 patches 7 years, 4 months ago
There is a newer version of this series
[edk2] [PATCH v2 14/23] OvmfPkg/Virtio10Dxe: add the RingBaseShift offset
Posted by Brijesh Singh 7 years, 4 months ago
virtio drivers uses VirtioRingMap() to map the ring buffer host address
to a device address. If an IOMMU is present then RingBaseShift contains
the offset from the host address.

Suggested-by: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
---
 OvmfPkg/Virtio10Dxe/Virtio10.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c
index d102e1fd8551..e9041dec91a4 100644
--- a/OvmfPkg/Virtio10Dxe/Virtio10.c
+++ b/OvmfPkg/Virtio10Dxe/Virtio10.c
@@ -498,11 +498,10 @@ Virtio10SetQueueAddress (
   UINT64         Address;
   UINT16         Enable;
 
-  ASSERT (RingBaseShift == 0);
-
   Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This);
 
   Address = (UINTN)Ring->Desc;
+  Address += RingBaseShift;
   Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE,
              OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueDesc),
              sizeof Address, &Address);
@@ -511,6 +510,7 @@ Virtio10SetQueueAddress (
   }
 
   Address = (UINTN)Ring->Avail.Flags;
+  Address += RingBaseShift;
   Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE,
              OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueAvail),
              sizeof Address, &Address);
@@ -519,6 +519,7 @@ Virtio10SetQueueAddress (
   }
 
   Address = (UINTN)Ring->Used.Flags;
+  Address += RingBaseShift;
   Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE,
              OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueUsed),
              sizeof Address, &Address);
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v2 14/23] OvmfPkg/Virtio10Dxe: add the RingBaseShift offset
Posted by Laszlo Ersek 7 years, 4 months ago
On 08/14/17 13:36, Brijesh Singh wrote:
> virtio drivers uses VirtioRingMap() to map the ring buffer host address

(1) Please replace

  "drivers uses VirtioRingMap()"

with

  "drivers use VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer()"

The rest looks fine, thanks!
Laszlo

> to a device address. If an IOMMU is present then RingBaseShift contains
> the offset from the host address.
> 
> Suggested-by: Laszlo Ersek <lersek@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
> ---
>  OvmfPkg/Virtio10Dxe/Virtio10.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c
> index d102e1fd8551..e9041dec91a4 100644
> --- a/OvmfPkg/Virtio10Dxe/Virtio10.c
> +++ b/OvmfPkg/Virtio10Dxe/Virtio10.c
> @@ -498,11 +498,10 @@ Virtio10SetQueueAddress (
>    UINT64         Address;
>    UINT16         Enable;
>  
> -  ASSERT (RingBaseShift == 0);
> -
>    Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This);
>  
>    Address = (UINTN)Ring->Desc;
> +  Address += RingBaseShift;
>    Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE,
>               OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueDesc),
>               sizeof Address, &Address);
> @@ -511,6 +510,7 @@ Virtio10SetQueueAddress (
>    }
>  
>    Address = (UINTN)Ring->Avail.Flags;
> +  Address += RingBaseShift;
>    Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE,
>               OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueAvail),
>               sizeof Address, &Address);
> @@ -519,6 +519,7 @@ Virtio10SetQueueAddress (
>    }
>  
>    Address = (UINTN)Ring->Used.Flags;
> +  Address += RingBaseShift;
>    Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE,
>               OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueUsed),
>               sizeof Address, &Address);
> 

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel