Lines Matching refs:as
266 struct smmu_as *as; member
323 struct smmu_as as[0]; /* Run-time allocated array */ member
388 struct smmu_as *as = c->as; in __smmu_client_set_hwgrp() local
389 u32 val, offs, mask = SMMU_ASID_ENABLE(as->asid); in __smmu_client_set_hwgrp()
390 struct smmu_device *smmu = as->smmu; in __smmu_client_set_hwgrp()
429 struct smmu_as *as = c->as; in smmu_client_set_hwgrp() local
430 struct smmu_device *smmu = as->smmu; in smmu_client_set_hwgrp()
463 struct smmu_as *as = &smmu->as[i]; in smmu_setup_regs() local
466 smmu_write(smmu, SMMU_PTB_ASID_CUR(as->asid), SMMU_PTB_ASID); in smmu_setup_regs()
467 val = as->pdir_page ? in smmu_setup_regs()
468 SMMU_MK_PDIR(as->pdir_page, as->pdir_attr) : in smmu_setup_regs()
472 list_for_each_entry(c, &as->client, list) in smmu_setup_regs()
489 struct smmu_as *as, dma_addr_t iova, in flush_ptc_and_tlb() argument
502 (as->asid << SMMU_TLB_FLUSH_ASID_SHIFT); in flush_ptc_and_tlb()
507 static void free_ptbl(struct smmu_as *as, dma_addr_t iova) in free_ptbl() argument
510 unsigned long *pdir = (unsigned long *)page_address(as->pdir_page); in free_ptbl()
513 dev_dbg(as->smmu->dev, "pdn: %lx\n", pdn); in free_ptbl()
518 FLUSH_CPU_DCACHE(&pdir[pdn], as->pdir_page, sizeof pdir[pdn]); in free_ptbl()
519 flush_ptc_and_tlb(as->smmu, as, iova, &pdir[pdn], in free_ptbl()
520 as->pdir_page, 1); in free_ptbl()
524 static void free_pdir(struct smmu_as *as) in free_pdir() argument
528 struct device *dev = as->smmu->dev; in free_pdir()
530 if (!as->pdir_page) in free_pdir()
533 addr = as->smmu->iovmm_base; in free_pdir()
534 count = as->smmu->page_count; in free_pdir()
536 free_ptbl(as, addr); in free_pdir()
539 ClearPageReserved(as->pdir_page); in free_pdir()
540 __free_page(as->pdir_page); in free_pdir()
541 as->pdir_page = NULL; in free_pdir()
542 devm_kfree(dev, as->pte_count); in free_pdir()
543 as->pte_count = NULL; in free_pdir()
550 static unsigned long *locate_pte(struct smmu_as *as, in locate_pte() argument
557 unsigned long *pdir = page_address(as->pdir_page); in locate_pte()
571 dev_dbg(as->smmu->dev, "New PTBL pdn: %lx\n", pdn); in locate_pte()
575 dev_err(as->smmu->dev, in locate_pte()
587 as->pde_attr | _PDE_NEXT); in locate_pte()
588 FLUSH_CPU_DCACHE(&pdir[pdn], as->pdir_page, sizeof pdir[pdn]); in locate_pte()
589 flush_ptc_and_tlb(as->smmu, as, iova, &pdir[pdn], in locate_pte()
590 as->pdir_page, 1); in locate_pte()
592 *count = &as->pte_count[pdn]; in locate_pte()
598 static void put_signature(struct smmu_as *as, in put_signature() argument
614 static inline void put_signature(struct smmu_as *as, in put_signature() argument
623 static int alloc_pdir(struct smmu_as *as) in alloc_pdir() argument
628 struct smmu_device *smmu = as->smmu; in alloc_pdir()
640 spin_lock_irqsave(&as->lock, flags); in alloc_pdir()
642 if (as->pdir_page) { in alloc_pdir()
654 as->pdir_page = page; in alloc_pdir()
655 as->pte_count = cnt; in alloc_pdir()
657 SetPageReserved(as->pdir_page); in alloc_pdir()
658 pdir = page_address(as->pdir_page); in alloc_pdir()
662 FLUSH_CPU_DCACHE(pdir, as->pdir_page, SMMU_PDIR_SIZE); in alloc_pdir()
663 val = SMMU_PTC_FLUSH_TYPE_ADR | VA_PAGE_TO_PA(pdir, as->pdir_page); in alloc_pdir()
665 FLUSH_SMMU_REGS(as->smmu); in alloc_pdir()
668 (as->asid << SMMU_TLB_FLUSH_ASID_SHIFT); in alloc_pdir()
670 FLUSH_SMMU_REGS(as->smmu); in alloc_pdir()
672 spin_unlock_irqrestore(&as->lock, flags); in alloc_pdir()
677 spin_unlock_irqrestore(&as->lock, flags); in alloc_pdir()
685 static void __smmu_iommu_unmap(struct smmu_as *as, dma_addr_t iova) in __smmu_iommu_unmap() argument
691 pte = locate_pte(as, iova, false, &page, &count); in __smmu_iommu_unmap()
700 flush_ptc_and_tlb(as->smmu, as, iova, pte, page, 0); in __smmu_iommu_unmap()
702 free_ptbl(as, iova); in __smmu_iommu_unmap()
705 static void __smmu_iommu_map_pfn(struct smmu_as *as, dma_addr_t iova, in __smmu_iommu_map_pfn() argument
708 struct smmu_device *smmu = as->smmu; in __smmu_iommu_map_pfn()
713 pte = locate_pte(as, iova, true, &page, &count); in __smmu_iommu_map_pfn()
719 *pte = SMMU_PFN_TO_PTE(pfn, as->pte_attr); in __smmu_iommu_map_pfn()
723 flush_ptc_and_tlb(smmu, as, iova, pte, page, 0); in __smmu_iommu_map_pfn()
724 put_signature(as, iova, pfn); in __smmu_iommu_map_pfn()
730 struct smmu_as *as = domain->priv; in smmu_iommu_map() local
734 dev_dbg(as->smmu->dev, "[%d] %08lx:%08x\n", as->asid, iova, pa); in smmu_iommu_map()
739 spin_lock_irqsave(&as->lock, flags); in smmu_iommu_map()
740 __smmu_iommu_map_pfn(as, iova, pfn); in smmu_iommu_map()
741 spin_unlock_irqrestore(&as->lock, flags); in smmu_iommu_map()
748 struct smmu_as *as = domain->priv; in smmu_iommu_unmap() local
751 dev_dbg(as->smmu->dev, "[%d] %08lx\n", as->asid, iova); in smmu_iommu_unmap()
753 spin_lock_irqsave(&as->lock, flags); in smmu_iommu_unmap()
754 __smmu_iommu_unmap(as, iova); in smmu_iommu_unmap()
755 spin_unlock_irqrestore(&as->lock, flags); in smmu_iommu_unmap()
762 struct smmu_as *as = domain->priv; in smmu_iommu_iova_to_phys() local
769 spin_lock_irqsave(&as->lock, flags); in smmu_iommu_iova_to_phys()
771 pte = locate_pte(as, iova, true, &page, &count); in smmu_iommu_iova_to_phys()
774 dev_dbg(as->smmu->dev, in smmu_iommu_iova_to_phys()
776 pfn, as->asid); in smmu_iommu_iova_to_phys()
778 spin_unlock_irqrestore(&as->lock, flags); in smmu_iommu_iova_to_phys()
791 struct smmu_as *as = domain->priv; in smmu_iommu_attach_dev() local
792 struct smmu_device *smmu = as->smmu; in smmu_iommu_attach_dev()
801 client->as = as; in smmu_iommu_attach_dev()
810 spin_lock(&as->client_lock); in smmu_iommu_attach_dev()
811 list_for_each_entry(c, &as->client, list) { in smmu_iommu_attach_dev()
819 list_add(&client->list, &as->client); in smmu_iommu_attach_dev()
820 spin_unlock(&as->client_lock); in smmu_iommu_attach_dev()
829 page = as->smmu->avp_vector_page; in smmu_iommu_attach_dev()
830 __smmu_iommu_map_pfn(as, 0, page_to_pfn(page)); in smmu_iommu_attach_dev()
840 spin_unlock(&as->client_lock); in smmu_iommu_attach_dev()
849 struct smmu_as *as = domain->priv; in smmu_iommu_detach_dev() local
850 struct smmu_device *smmu = as->smmu; in smmu_iommu_detach_dev()
853 spin_lock(&as->client_lock); in smmu_iommu_detach_dev()
855 list_for_each_entry(c, &as->client, list) { in smmu_iommu_detach_dev()
860 c->as = NULL; in smmu_iommu_detach_dev()
868 spin_unlock(&as->client_lock); in smmu_iommu_detach_dev()
875 struct smmu_as *as; in smmu_iommu_domain_init() local
880 as = &smmu->as[i]; in smmu_iommu_domain_init()
882 if (as->pdir_page) in smmu_iommu_domain_init()
885 err = alloc_pdir(as); in smmu_iommu_domain_init()
900 smmu_write(smmu, SMMU_PTB_ASID_CUR(as->asid), SMMU_PTB_ASID); in smmu_iommu_domain_init()
902 SMMU_MK_PDIR(as->pdir_page, as->pdir_attr), SMMU_PTB_DATA); in smmu_iommu_domain_init()
907 domain->priv = as; in smmu_iommu_domain_init()
914 dev_dbg(smmu->dev, "smmu_as@%p\n", as); in smmu_iommu_domain_init()
921 struct smmu_as *as = domain->priv; in smmu_iommu_domain_destroy() local
922 struct smmu_device *smmu = as->smmu; in smmu_iommu_domain_destroy()
925 spin_lock_irqsave(&as->lock, flags); in smmu_iommu_domain_destroy()
927 if (as->pdir_page) { in smmu_iommu_domain_destroy()
929 smmu_write(smmu, SMMU_PTB_ASID_CUR(as->asid), SMMU_PTB_ASID); in smmu_iommu_domain_destroy()
934 free_pdir(as); in smmu_iommu_domain_destroy()
937 if (!list_empty(&as->client)) { in smmu_iommu_domain_destroy()
940 list_for_each_entry(c, &as->client, list) in smmu_iommu_domain_destroy()
944 spin_unlock_irqrestore(&as->lock, flags); in smmu_iommu_domain_destroy()
947 dev_dbg(smmu->dev, "smmu_as@%p\n", as); in smmu_iommu_domain_destroy()
1163 bytes = sizeof(*smmu) + asids * sizeof(*smmu->as); in tegra_smmu_probe()
1216 struct smmu_as *as = &smmu->as[i]; in tegra_smmu_probe() local
1218 as->smmu = smmu; in tegra_smmu_probe()
1219 as->asid = i; in tegra_smmu_probe()
1220 as->pdir_attr = _PDIR_ATTR; in tegra_smmu_probe()
1221 as->pde_attr = _PDE_ATTR; in tegra_smmu_probe()
1222 as->pte_attr = _PTE_ATTR; in tegra_smmu_probe()
1224 spin_lock_init(&as->lock); in tegra_smmu_probe()
1225 spin_lock_init(&as->client_lock); in tegra_smmu_probe()
1226 INIT_LIST_HEAD(&as->client); in tegra_smmu_probe()
1253 free_pdir(&smmu->as[i]); in tegra_smmu_remove()