Message ID | 1476123127-24314-4-git-send-email-tushar.n.dave@oracle.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
From: Tushar Dave <tushar.n.dave@oracle.com> Date: Mon, 10 Oct 2016 11:12:04 -0700 > 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> I suspect you are adding a bisection problem here. It looks to me like patch #2 starts setting up to use the ATU but these changes in #3 and later are necessary for it to even work properly. You can't leave the tree in an intermediate non-working state between changes like that. -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10/24/2016 10:47 AM, David Miller wrote: > From: Tushar Dave <tushar.n.dave@oracle.com> > Date: Mon, 10 Oct 2016 11:12:04 -0700 > >> 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> > > I suspect you are adding a bisection problem here. > > It looks to me like patch #2 starts setting up to use the ATU > but these changes in #3 and later are necessary for it to even > work properly. > > You can't leave the tree in an intermediate non-working state > between changes like that. I agree but even if you apply only patch #1, #2 things still work using legacy IOMMU. (and the same is true for rest of the other patches i.e. #3, #4, #5). All the patches, except patch #6 , sets up needed data structures and functions for ATU however ATU will only be used in action after you apply patch #6 which actually enables 64bit DMA. Until then, things are going to work using legacy IOMMU with 32bit DMA. Thanks. -Tushar > -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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; }