From: Tushar Dave <tushar.n.dave@oracle.com>
To: davem@davemloft.net, chris.hyser@oracle.com,
sowmini.varadhan@oracle.com, vgupta@synopsys.com,
robin.murphy@arm.com, jroedel@suse.de, egtvedt@samfundet.no,
krzk@kernel.org, sparclinux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/6] sparc64: Initialize iommu_map_table and iommu_pool
Date: Thu, 6 Oct 2016 16:33:33 -0700 [thread overview]
Message-ID: <1475796816-14448-4-git-send-email-tushar.n.dave@oracle.com> (raw)
In-Reply-To: <1475796816-14448-1-git-send-email-tushar.n.dave@oracle.com>
Like legacy IOMMU, use common iommu_map_table and iommu_pool for ATU.
This change initializes iommu_map_table and iommu_pool for ATU.
Signed-off-by: Tushar Dave <tushar.n.dave@oracle.com>
Reviewed-by: chris hyser <chris.hyser@oracle.com>
Reviewed-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
---
arch/sparc/include/asm/iommu_64.h | 2 ++
arch/sparc/kernel/pci_sun4v.c | 19 +++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/arch/sparc/include/asm/iommu_64.h b/arch/sparc/include/asm/iommu_64.h
index 93daa59..f24f356 100644
--- a/arch/sparc/include/asm/iommu_64.h
+++ b/arch/sparc/include/asm/iommu_64.h
@@ -45,8 +45,10 @@ struct atu_ranges {
struct atu {
struct atu_ranges *ranges;
struct atu_iotsb *iotsb;
+ struct iommu_map_table tbl;
u64 base;
u64 size;
+ u64 dma_addr_mask;
};
struct iommu {
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index a1c4d5e..5404b33 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -643,6 +643,8 @@ static int pci_sun4v_atu_init(struct pci_pbm_info *pbm)
struct atu *atu = pbm->iommu->atu;
unsigned long err;
const u64 *ranges;
+ u64 map_size, num_iotte;
+ u64 dma_mask;
const u32 *page_size;
int len;
@@ -681,6 +683,23 @@ static int pci_sun4v_atu_init(struct pci_pbm_info *pbm)
return err;
}
+ /* Create ATU iommu map.
+ * One bit represents one iotte in IOTSB table.
+ */
+ dma_mask = (roundup_pow_of_two(atu->size) - 1UL);
+ num_iotte = atu->size / IO_PAGE_SIZE;
+ map_size = num_iotte / 8;
+ atu->tbl.table_map_base = atu->base;
+ atu->dma_addr_mask = dma_mask;
+ atu->tbl.map = kzalloc(map_size, GFP_KERNEL);
+ if (!atu->tbl.map)
+ return -ENOMEM;
+
+ iommu_tbl_pool_init(&atu->tbl, num_iotte, IO_PAGE_SHIFT,
+ NULL, false /* no large_pool */,
+ 0 /* default npools */,
+ false /* want span boundary checking */);
+
return 0;
}
--
1.9.1
next prev parent reply other threads:[~2016-10-06 23:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 23:33 [RFC PATCH 0/6] sparc: Enable sun4v hypervisor PCI IOMMU v2 APIs and ATU Tushar Dave
2016-10-06 23:33 ` [RFC PATCH 1/6] sparc64: Add FORCE_MAX_ZONEORDER and default to 13 Tushar Dave
2016-10-06 23:33 ` [RFC PATCH 2/6] sparc64: Add ATU (new IOMMU) support Tushar Dave
2016-10-06 23:33 ` Tushar Dave [this message]
2016-10-06 23:33 ` [RFC PATCH 4/6] sparc64: Bind PCIe devices to use IOMMU v2 service Tushar Dave
2016-10-06 23:33 ` [RFC PATCH 5/6] sparc64: Enable sun4v dma ops to use IOMMU v2 APIs Tushar Dave
2016-10-06 23:33 ` [RFC PATCH 6/6] sparc64: Enable 64-bit DMA Tushar Dave
2016-10-07 7:32 ` Christoph Hellwig
2016-10-07 8:09 ` tndave
2016-10-11 16:38 ` Christoph Hellwig
2016-10-11 19:42 ` tndave
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=1475796816-14448-4-git-send-email-tushar.n.dave@oracle.com \
--to=tushar.n.dave@oracle.com \
--cc=chris.hyser@oracle.com \
--cc=davem@davemloft.net \
--cc=egtvedt@samfundet.no \
--cc=jroedel@suse.de \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=sowmini.varadhan@oracle.com \
--cc=sparclinux@vger.kernel.org \
--cc=vgupta@synopsys.com \
/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
all inboxes | Powered by JetHome®