diff options
author | Tushar Dave <tushar.n.dave@oracle.com> | 2016-10-28 13:12:42 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-18 14:16:59 -0500 |
commit | 31f077dc7dffd4a444932a9fe7fe84d9c7b90b73 (patch) | |
tree | efe2f9f8e8a1cb91dca0a34ac2cc83ed5cee7805 /arch/sparc | |
parent | f0248c1524fae654e9746e6843b9657fb3917387 (diff) |
sparc64: Initialize iommu_map_table and iommu_pool
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/include/asm/iommu_64.h | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/pci_sun4v.c | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/arch/sparc/include/asm/iommu_64.h b/arch/sparc/include/asm/iommu_64.h index 93daa5965b3d..f24f356f2503 100644 --- a/arch/sparc/include/asm/iommu_64.h +++ b/arch/sparc/include/asm/iommu_64.h | |||
@@ -45,8 +45,10 @@ struct atu_ranges { | |||
45 | struct atu { | 45 | struct atu { |
46 | struct atu_ranges *ranges; | 46 | struct atu_ranges *ranges; |
47 | struct atu_iotsb *iotsb; | 47 | struct atu_iotsb *iotsb; |
48 | struct iommu_map_table tbl; | ||
48 | u64 base; | 49 | u64 base; |
49 | u64 size; | 50 | u64 size; |
51 | u64 dma_addr_mask; | ||
50 | }; | 52 | }; |
51 | 53 | ||
52 | struct iommu { | 54 | struct iommu { |
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index 2afb86c73da9..242477cbfdf2 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c | |||
@@ -644,6 +644,8 @@ static int pci_sun4v_atu_init(struct pci_pbm_info *pbm) | |||
644 | struct atu *atu = pbm->iommu->atu; | 644 | struct atu *atu = pbm->iommu->atu; |
645 | unsigned long err; | 645 | unsigned long err; |
646 | const u64 *ranges; | 646 | const u64 *ranges; |
647 | u64 map_size, num_iotte; | ||
648 | u64 dma_mask; | ||
647 | const u32 *page_size; | 649 | const u32 *page_size; |
648 | int len; | 650 | int len; |
649 | 651 | ||
@@ -682,6 +684,23 @@ static int pci_sun4v_atu_init(struct pci_pbm_info *pbm) | |||
682 | return err; | 684 | return err; |
683 | } | 685 | } |
684 | 686 | ||
687 | /* Create ATU iommu map. | ||
688 | * One bit represents one iotte in IOTSB table. | ||
689 | */ | ||
690 | dma_mask = (roundup_pow_of_two(atu->size) - 1UL); | ||
691 | num_iotte = atu->size / IO_PAGE_SIZE; | ||
692 | map_size = num_iotte / 8; | ||
693 | atu->tbl.table_map_base = atu->base; | ||
694 | atu->dma_addr_mask = dma_mask; | ||
695 | atu->tbl.map = kzalloc(map_size, GFP_KERNEL); | ||
696 | if (!atu->tbl.map) | ||
697 | return -ENOMEM; | ||
698 | |||
699 | iommu_tbl_pool_init(&atu->tbl, num_iotte, IO_PAGE_SHIFT, | ||
700 | NULL, false /* no large_pool */, | ||
701 | 0 /* default npools */, | ||
702 | false /* want span boundary checking */); | ||
703 | |||
685 | return 0; | 704 | return 0; |
686 | } | 705 | } |
687 | 706 | ||