public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: [PATCH 6/6] OvmfPkg/VirtioGpuDxe: negotiate VIRTIO_F_IOMMU_PLATFORM
Date: Mon, 28 Aug 2017 15:24:36 +0200	[thread overview]
Message-ID: <20170828132436.15933-7-lersek@redhat.com> (raw)
In-Reply-To: <20170828132436.15933-1-lersek@redhat.com>

VirtioGpuDxe is now IOMMU-clean; it translates system memory addresses to
bus master device addresses. Negotiate VIRTIO_F_IOMMU_PLATFORM in parallel
with VIRTIO_F_VERSION_1. (Note: the VirtIo GPU device, and this driver,
are virtio-1.0 only (a.k.a. "modern-only").)

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

diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c
index db5bdbca4bee..6e70b1c33f65 100644
--- a/OvmfPkg/VirtioGpuDxe/Commands.c
+++ b/OvmfPkg/VirtioGpuDxe/Commands.c
@@ -39,131 +39,131 @@ EFI_STATUS
 VirtioGpuInit (
   IN OUT VGPU_DEV *VgpuDev
   )
 {
   UINT8      NextDevStat;
   EFI_STATUS Status;
   UINT64     Features;
   UINT16     QueueSize;
   UINT64     RingBaseShift;
 
   //
   // Execute virtio-v1.0-cs04, 3.1.1 Driver Requirements: Device
   // Initialization.
   //
   // 1. Reset the device.
   //
   NextDevStat = 0;
   Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // 2. Set the ACKNOWLEDGE status bit [...]
   //
   NextDevStat |= VSTAT_ACK;
   Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // 3. Set the DRIVER status bit [...]
   //
   NextDevStat |= VSTAT_DRIVER;
   Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // 4. Read device feature bits...
   //
   Status = VgpuDev->VirtIo->GetDeviceFeatures (VgpuDev->VirtIo, &Features);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
   if ((Features & VIRTIO_F_VERSION_1) == 0) {
     Status = EFI_UNSUPPORTED;
     goto Failed;
   }
   //
   // We only want the most basic 2D features.
   //
-  Features &= VIRTIO_F_VERSION_1;
+  Features &= VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM;
 
   //
   // ... and write the subset of feature bits understood by the [...] driver to
   // the device. [...]
   // 5. Set the FEATURES_OK status bit.
   // 6. Re-read device status to ensure the FEATURES_OK bit is still set [...]
   //
   Status = Virtio10WriteFeatures (VgpuDev->VirtIo, Features, &NextDevStat);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // 7. Perform device-specific setup, including discovery of virtqueues for
   // the device [...]
   //
   Status = VgpuDev->VirtIo->SetQueueSel (VgpuDev->VirtIo,
                               VIRTIO_GPU_CONTROL_QUEUE);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
   Status = VgpuDev->VirtIo->GetQueueNumMax (VgpuDev->VirtIo, &QueueSize);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // We implement each VirtIo GPU command that we use with two descriptors:
   // request, response.
   //
   if (QueueSize < 2) {
     Status = EFI_UNSUPPORTED;
     goto Failed;
   }
 
   //
   // [...] population of virtqueues [...]
   //
   Status = VirtioRingInit (VgpuDev->VirtIo, QueueSize, &VgpuDev->Ring);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
   //
   // If anything fails from here on, we have to release the ring.
   //
   Status = VirtioRingMap (
              VgpuDev->VirtIo,
              &VgpuDev->Ring,
              &RingBaseShift,
              &VgpuDev->RingMap
              );
   if (EFI_ERROR (Status)) {
     goto ReleaseQueue;
   }
   //
   // If anything fails from here on, we have to unmap the ring.
   //
   Status = VgpuDev->VirtIo->SetQueueAddress (
                               VgpuDev->VirtIo,
                               &VgpuDev->Ring,
                               RingBaseShift
                               );
   if (EFI_ERROR (Status)) {
     goto UnmapQueue;
   }
 
   //
   // 8. Set the DRIVER_OK status bit.
   //
   NextDevStat |= VSTAT_DRIVER_OK;
   Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
   if (EFI_ERROR (Status)) {
     goto UnmapQueue;
   }
 
   return EFI_SUCCESS;
-- 
2.14.1.3.gb7cf6e02401b



  parent reply	other threads:[~2017-08-28 13:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 13:24 [PATCH 0/6] OvmfPkg/VirtioGpuDxe: map system memory addresses to device addresses Laszlo Ersek
2017-08-28 13:24 ` [PATCH 1/6] OvmfPkg/VirtioGpuDxe: map VRING for bus master common buffer operation Laszlo Ersek
2017-08-28 13:24 ` [PATCH 2/6] OvmfPkg/VirtioGpuDxe: map virtio GPU command objects to device addresses Laszlo Ersek
2017-08-28 13:24 ` [PATCH 3/6] OvmfPkg/VirtioGpuDxe: take EFI_PHYSICAL_ADDRESS in ResourceAttachBacking() Laszlo Ersek
2017-08-28 13:24 ` [PATCH 4/6] OvmfPkg/VirtioGpuDxe: helpers for backing store (de)allocation+(un)mapping Laszlo Ersek
2017-08-28 13:24 ` [PATCH 5/6] OvmfPkg/VirtioGpuDxe: map backing store to bus master device address Laszlo Ersek
2017-08-28 13:24 ` Laszlo Ersek [this message]
2017-08-29 23:02 ` [PATCH 0/6] OvmfPkg/VirtioGpuDxe: map system memory addresses to device addresses Laszlo Ersek
2017-08-30 15:47   ` Brijesh Singh
2017-08-30 16:15     ` Laszlo Ersek
2017-09-01 12:31     ` Laszlo Ersek

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=20170828132436.15933-7-lersek@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