Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1439339
| Path | csiph.com!feeder.erje.net!1.us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Joerg Roedel <joro@8bytes.org> |
| Newsgroups | linux.kernel |
| Subject | [PATCH 03/20] iommu/amd: Allocate iova_domain for dma_ops_domain |
| Date | Fri, 08 Jul 2016 13:50:02 +0200 |
| Message-ID | <rSCsa-4e3-35@gated-at.bofh.it> (permalink) |
| References | <rSCs9-4e3-3@gated-at.bofh.it> |
| X-Original-To | iommu@lists.linux-foundation.org |
| Dkim-Signature | v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1467978324; bh=DnwYtGOVeCL5FUoTmIwvpX7hWxQAjA7HIiH9Ytn6grU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fCdgk3HnXYa64Ir8ZXC5SCPUjxDEfRWUD3xJCuAhoQW3Ry7JFe+ochwaHDnfHd2yU 8QrORzwWTxr2bPhMis8n7uKu86dGIgooN+ofUKA3QR4weVKqcrRk7G5J/P6JbZrZJJ VP7zIATaQtDbtM7qmfl5dOqWbIwYAsn9P7BzU3pCiLW7DGOmUTXp5JZ47SliXqplv7 yDu5iA7GN0flaP4d2v79wucOnXwQD39tj8sfxAGoiEIOFou4sc531GomX5eO6pmqKr 3rL8ttfxDhFucZV3GdrMGMyCJQc8PLq5ECqTghYTg6Q9zfWgWWtSTQy3txFaNDYiPB Gc3A//yBKoWpg== |
| X-Mailer | git-send-email 1.9.1 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 77 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linux-kernel@vger.kernel.org, Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>, Vincent.Wan@amd.com, Joerg Roedel <jroedel@suse.de> |
| X-Original-Date | Fri, 8 Jul 2016 13:44:54 +0200 |
| X-Original-Message-ID | <1467978311-28322-4-git-send-email-joro@8bytes.org> |
| X-Original-References | <1467978311-28322-1-git-send-email-joro@8bytes.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1439339 |
Show key headers only | View raw
From: Joerg Roedel <jroedel@suse.de>
Use it later for allocating the IO virtual addresses.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/amd_iommu.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 634f636..71af367 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -38,6 +38,7 @@
#include <linux/dma-contiguous.h>
#include <linux/irqdomain.h>
#include <linux/percpu.h>
+#include <linux/iova.h>
#include <asm/irq_remapping.h>
#include <asm/io_apic.h>
#include <asm/apic.h>
@@ -56,6 +57,11 @@
#define LOOP_TIMEOUT 100000
+/* IO virtual address start page frame number */
+#define IOVA_START_PFN (1)
+#define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT)
+#define DMA_32BIT_PFN IOVA_PFN(DMA_BIT_MASK(32))
+
/*
* This bitmap is used to advertise the page sizes our hardware support
* to the IOMMU core, which will then use this information to split
@@ -157,6 +163,9 @@ struct dma_ops_domain {
/* address space relevant data */
struct aperture_range *aperture[APERTURE_MAX_RANGES];
+
+ /* IOVA RB-Tree */
+ struct iova_domain iovad;
};
/****************************************************************************
@@ -1966,6 +1975,8 @@ static void dma_ops_domain_free(struct dma_ops_domain *dom)
if (!dom)
return;
+ put_iova_domain(&dom->iovad);
+
free_percpu(dom->next_index);
del_domain_from_list(&dom->domain);
@@ -2041,6 +2052,9 @@ static struct dma_ops_domain *dma_ops_domain_alloc(void)
for_each_possible_cpu(cpu)
*per_cpu_ptr(dma_dom->next_index, cpu) = 0;
+ init_iova_domain(&dma_dom->iovad, PAGE_SIZE,
+ IOVA_START_PFN, DMA_32BIT_PFN);
+
return dma_dom;
free_dma_dom:
@@ -2948,7 +2962,11 @@ static struct dma_map_ops amd_iommu_dma_ops = {
int __init amd_iommu_init_api(void)
{
- int err = 0;
+ int ret, err = 0;
+
+ ret = iova_cache_get();
+ if (ret)
+ return ret;
err = bus_set_iommu(&pci_bus_type, &amd_iommu_ops);
if (err)
--
1.9.1
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 03/20] iommu/amd: Allocate iova_domain for dma_ops_domain Joerg Roedel <joro@8bytes.org> - 2016-07-08 13:50 +0200
csiph-web