• Home
  • Raw
  • Download

Lines Matching full:as

288 	struct tegra_smmu_as *as;  in tegra_smmu_domain_alloc()  local
293 as = kzalloc(sizeof(*as), GFP_KERNEL); in tegra_smmu_domain_alloc()
294 if (!as) in tegra_smmu_domain_alloc()
297 as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE; in tegra_smmu_domain_alloc()
299 as->pd = alloc_page(GFP_KERNEL | __GFP_DMA | __GFP_ZERO); in tegra_smmu_domain_alloc()
300 if (!as->pd) { in tegra_smmu_domain_alloc()
301 kfree(as); in tegra_smmu_domain_alloc()
305 as->count = kcalloc(SMMU_NUM_PDE, sizeof(u32), GFP_KERNEL); in tegra_smmu_domain_alloc()
306 if (!as->count) { in tegra_smmu_domain_alloc()
307 __free_page(as->pd); in tegra_smmu_domain_alloc()
308 kfree(as); in tegra_smmu_domain_alloc()
312 as->pts = kcalloc(SMMU_NUM_PDE, sizeof(*as->pts), GFP_KERNEL); in tegra_smmu_domain_alloc()
313 if (!as->pts) { in tegra_smmu_domain_alloc()
314 kfree(as->count); in tegra_smmu_domain_alloc()
315 __free_page(as->pd); in tegra_smmu_domain_alloc()
316 kfree(as); in tegra_smmu_domain_alloc()
320 spin_lock_init(&as->lock); in tegra_smmu_domain_alloc()
323 as->domain.geometry.aperture_start = 0; in tegra_smmu_domain_alloc()
324 as->domain.geometry.aperture_end = 0xffffffff; in tegra_smmu_domain_alloc()
325 as->domain.geometry.force_aperture = true; in tegra_smmu_domain_alloc()
327 return &as->domain; in tegra_smmu_domain_alloc()
332 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_domain_free() local
336 WARN_ON_ONCE(as->use_count); in tegra_smmu_domain_free()
337 kfree(as->count); in tegra_smmu_domain_free()
338 kfree(as->pts); in tegra_smmu_domain_free()
339 kfree(as); in tegra_smmu_domain_free()
420 struct tegra_smmu_as *as) in tegra_smmu_as_prepare() argument
425 if (as->use_count > 0) { in tegra_smmu_as_prepare()
426 as->use_count++; in tegra_smmu_as_prepare()
430 as->pd_dma = dma_map_page(smmu->dev, as->pd, 0, SMMU_SIZE_PD, in tegra_smmu_as_prepare()
432 if (dma_mapping_error(smmu->dev, as->pd_dma)) in tegra_smmu_as_prepare()
436 if (!smmu_dma_addr_valid(smmu, as->pd_dma)) { in tegra_smmu_as_prepare()
441 err = tegra_smmu_alloc_asid(smmu, &as->id); in tegra_smmu_as_prepare()
445 smmu_flush_ptc(smmu, as->pd_dma, 0); in tegra_smmu_as_prepare()
446 smmu_flush_tlb_asid(smmu, as->id); in tegra_smmu_as_prepare()
448 smmu_writel(smmu, as->id & 0x7f, SMMU_PTB_ASID); in tegra_smmu_as_prepare()
449 value = SMMU_PTB_DATA_VALUE(as->pd_dma, as->attr); in tegra_smmu_as_prepare()
453 as->smmu = smmu; in tegra_smmu_as_prepare()
454 as->use_count++; in tegra_smmu_as_prepare()
459 dma_unmap_page(smmu->dev, as->pd_dma, SMMU_SIZE_PD, DMA_TO_DEVICE); in tegra_smmu_as_prepare()
464 struct tegra_smmu_as *as) in tegra_smmu_as_unprepare() argument
466 if (--as->use_count > 0) in tegra_smmu_as_unprepare()
469 tegra_smmu_free_asid(smmu, as->id); in tegra_smmu_as_unprepare()
471 dma_unmap_page(smmu->dev, as->pd_dma, SMMU_SIZE_PD, DMA_TO_DEVICE); in tegra_smmu_as_unprepare()
473 as->smmu = NULL; in tegra_smmu_as_unprepare()
480 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_attach_dev() local
497 err = tegra_smmu_as_prepare(smmu, as); in tegra_smmu_attach_dev()
501 tegra_smmu_enable(smmu, swgroup, as->id); in tegra_smmu_attach_dev()
513 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_detach_dev() local
515 struct tegra_smmu *smmu = as->smmu; in tegra_smmu_detach_dev()
530 tegra_smmu_disable(smmu, swgroup, as->id); in tegra_smmu_detach_dev()
531 tegra_smmu_as_unprepare(smmu, as); in tegra_smmu_detach_dev()
536 static void tegra_smmu_set_pde(struct tegra_smmu_as *as, unsigned long iova, in tegra_smmu_set_pde() argument
540 struct tegra_smmu *smmu = as->smmu; in tegra_smmu_set_pde()
541 u32 *pd = page_address(as->pd); in tegra_smmu_set_pde()
548 dma_sync_single_range_for_device(smmu->dev, as->pd_dma, offset, in tegra_smmu_set_pde()
552 smmu_flush_ptc(smmu, as->pd_dma, offset); in tegra_smmu_set_pde()
553 smmu_flush_tlb_section(smmu, as->id, iova); in tegra_smmu_set_pde()
564 static u32 *tegra_smmu_pte_lookup(struct tegra_smmu_as *as, unsigned long iova, in tegra_smmu_pte_lookup() argument
568 struct tegra_smmu *smmu = as->smmu; in tegra_smmu_pte_lookup()
572 pt_page = as->pts[pd_index]; in tegra_smmu_pte_lookup()
576 pd = page_address(as->pd); in tegra_smmu_pte_lookup()
582 static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova, in as_get_pte() argument
586 struct tegra_smmu *smmu = as->smmu; in as_get_pte()
588 if (!as->pts[pde]) { in as_get_pte()
605 as->pts[pde] = page; in as_get_pte()
607 tegra_smmu_set_pde(as, iova, SMMU_MK_PDE(dma, SMMU_PDE_ATTR | in as_get_pte()
612 u32 *pd = page_address(as->pd); in as_get_pte()
617 return tegra_smmu_pte_offset(as->pts[pde], iova); in as_get_pte()
620 static void tegra_smmu_pte_get_use(struct tegra_smmu_as *as, unsigned long iova) in tegra_smmu_pte_get_use() argument
624 as->count[pd_index]++; in tegra_smmu_pte_get_use()
627 static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova) in tegra_smmu_pte_put_use() argument
630 struct page *page = as->pts[pde]; in tegra_smmu_pte_put_use()
636 if (--as->count[pde] == 0) { in tegra_smmu_pte_put_use()
637 struct tegra_smmu *smmu = as->smmu; in tegra_smmu_pte_put_use()
638 u32 *pd = page_address(as->pd); in tegra_smmu_pte_put_use()
641 tegra_smmu_set_pde(as, iova, 0); in tegra_smmu_pte_put_use()
645 as->pts[pde] = NULL; in tegra_smmu_pte_put_use()
649 static void tegra_smmu_set_pte(struct tegra_smmu_as *as, unsigned long iova, in tegra_smmu_set_pte() argument
652 struct tegra_smmu *smmu = as->smmu; in tegra_smmu_set_pte()
660 smmu_flush_tlb_group(smmu, as->id, iova); in tegra_smmu_set_pte()
664 static struct page *as_get_pde_page(struct tegra_smmu_as *as, in as_get_pde_page() argument
669 struct page *page = as->pts[pde]; in as_get_pde_page()
681 spin_unlock_irqrestore(&as->lock, *flags); in as_get_pde_page()
686 spin_lock_irqsave(&as->lock, *flags); in as_get_pde_page()
693 if (as->pts[pde]) { in as_get_pde_page()
697 page = as->pts[pde]; in as_get_pde_page()
708 struct tegra_smmu_as *as = to_smmu_as(domain); in __tegra_smmu_map() local
714 page = as_get_pde_page(as, iova, gfp, flags); in __tegra_smmu_map()
718 pte = as_get_pte(as, iova, &pte_dma, page); in __tegra_smmu_map()
724 tegra_smmu_pte_get_use(as, iova); in __tegra_smmu_map()
734 tegra_smmu_set_pte(as, iova, pte, pte_dma, in __tegra_smmu_map()
744 struct tegra_smmu_as *as = to_smmu_as(domain); in __tegra_smmu_unmap() local
748 pte = tegra_smmu_pte_lookup(as, iova, &pte_dma); in __tegra_smmu_unmap()
752 tegra_smmu_set_pte(as, iova, pte, pte_dma, 0); in __tegra_smmu_unmap()
753 tegra_smmu_pte_put_use(as, iova); in __tegra_smmu_unmap()
761 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_map() local
765 spin_lock_irqsave(&as->lock, flags); in tegra_smmu_map()
767 spin_unlock_irqrestore(&as->lock, flags); in tegra_smmu_map()
775 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_unmap() local
778 spin_lock_irqsave(&as->lock, flags); in tegra_smmu_unmap()
780 spin_unlock_irqrestore(&as->lock, flags); in tegra_smmu_unmap()
788 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_iova_to_phys() local
793 pte = tegra_smmu_pte_lookup(as, iova, &pte_dma); in tegra_smmu_iova_to_phys()
797 pfn = *pte & as->smmu->pfn_mask; in tegra_smmu_iova_to_phys()