]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sparc64: Initialize iommu_map_table and iommu_pool
authorTushar Dave <tushar.n.dave@oracle.com>
Wed, 18 May 2016 09:11:29 +0000 (02:11 -0700)
committerAllen Pais <allen.pais@oracle.com>
Tue, 11 Jul 2017 07:36:49 +0000 (13:06 +0530)
Like legacy IOMMU, use common iommu_map_table and iommu_pool for ATU.
This change initializes iommu_map_table and iommu_pool for ATU.

Orabug: 23239179

Reviewed-by: chris hyser <chris.hyser@oracle.com>
Signed-off-by: Tushar Dave <tushar.n.dave@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
arch/sparc/include/asm/iommu_64.h
arch/sparc/kernel/pci_sun4v.c

index 93daa5965b3d26a7cf4b900ef63b7702d93d57fa..f24f356f250376e0931a4d4bc5d6bc631f469a74 100644 (file)
@@ -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 {
index 16d9711bcb4f7ac818ae50af4008eaac1ae7c117..459f5bd14346613d0a45c2e9fd778bbdef569154 100644 (file)
@@ -680,6 +680,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;
 
@@ -718,6 +720,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;
 }