qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel@redhat.com>,
	peterx@redhat.com, Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PATCH 2/3] intel_iommu: cleanup vtd_iommu_translate()
Date: Fri,  9 Jun 2017 21:04:12 +0800	[thread overview]
Message-ID: <1497013453-13688-3-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1497013453-13688-1-git-send-email-peterx@redhat.com>

So even with PT we'll get a log now. Also, remove useless assignments.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 hw/i386/intel_iommu.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index c818dd4..f94fc4e 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2253,25 +2253,21 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
     VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
     IntelIOMMUState *s = vtd_as->iommu_state;
     IOMMUTLBEntry ret = {
+        /* We'll fill in the rest later. */
         .target_as = &address_space_memory,
-        .iova = addr,
-        .translated_addr = 0,
-        .addr_mask = ~(hwaddr)0,
-        .perm = IOMMU_NONE,
     };
 
-    if (!s->dmar_enabled) {
+    if (likely(s->dmar_enabled)) {
+        vtd_do_iommu_translate(vtd_as, vtd_as->bus, vtd_as->devfn, addr,
+                               flag & IOMMU_WO, &ret);
+    } else {
         /* DMAR disabled, passthrough, use 4k-page*/
         ret.iova = addr & VTD_PAGE_MASK_4K;
         ret.translated_addr = addr & VTD_PAGE_MASK_4K;
         ret.addr_mask = ~VTD_PAGE_MASK_4K;
         ret.perm = IOMMU_RW;
-        return ret;
     }
 
-    vtd_do_iommu_translate(vtd_as, vtd_as->bus, vtd_as->devfn, addr,
-                           flag & IOMMU_WO, &ret);
-
     trace_vtd_dmar_translate(pci_bus_num(vtd_as->bus),
                              VTD_PCI_SLOT(vtd_as->devfn),
                              VTD_PCI_FUNC(vtd_as->devfn),
-- 
2.7.4

  parent reply	other threads:[~2017-06-09 13:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 13:04 [Qemu-devel] [PATCH 0/3] VT-d: convert the rest of DPRINTF()s Peter Xu
2017-06-09 13:04 ` [Qemu-devel] [PATCH 1/3] intel_iommu: switching the rest DPRINTF to trace Peter Xu
2017-06-09 13:04 ` Peter Xu [this message]
2017-06-09 13:04 ` [Qemu-devel] [PATCH 3/3] intel_iommu: cleanup vtd_interrupt_remap_msi() Peter Xu
2017-06-09 13:24 ` [Qemu-devel] [PATCH 0/3] VT-d: convert the rest of DPRINTF()s no-reply
2017-06-09 13:43   ` Peter Xu

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-all 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=1497013453-13688-3-git-send-email-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).