Lines Matching refs:as

237 	struct tegra_smmu_as *as;  in tegra_smmu_domain_alloc()  local
244 as = kzalloc(sizeof(*as), GFP_KERNEL); in tegra_smmu_domain_alloc()
245 if (!as) in tegra_smmu_domain_alloc()
248 as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE; in tegra_smmu_domain_alloc()
250 as->pd = alloc_page(GFP_KERNEL | __GFP_DMA); in tegra_smmu_domain_alloc()
251 if (!as->pd) { in tegra_smmu_domain_alloc()
252 kfree(as); in tegra_smmu_domain_alloc()
256 as->count = alloc_page(GFP_KERNEL); in tegra_smmu_domain_alloc()
257 if (!as->count) { in tegra_smmu_domain_alloc()
258 __free_page(as->pd); in tegra_smmu_domain_alloc()
259 kfree(as); in tegra_smmu_domain_alloc()
264 pd = page_address(as->pd); in tegra_smmu_domain_alloc()
265 SetPageReserved(as->pd); in tegra_smmu_domain_alloc()
271 pd = page_address(as->count); in tegra_smmu_domain_alloc()
272 SetPageReserved(as->count); in tegra_smmu_domain_alloc()
278 as->domain.geometry.aperture_start = 0; in tegra_smmu_domain_alloc()
279 as->domain.geometry.aperture_end = 0xffffffff; in tegra_smmu_domain_alloc()
280 as->domain.geometry.force_aperture = true; in tegra_smmu_domain_alloc()
282 return &as->domain; in tegra_smmu_domain_alloc()
287 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_domain_free() local
290 ClearPageReserved(as->pd); in tegra_smmu_domain_free()
292 kfree(as); in tegra_smmu_domain_free()
368 struct tegra_smmu_as *as) in tegra_smmu_as_prepare() argument
373 if (as->use_count > 0) { in tegra_smmu_as_prepare()
374 as->use_count++; in tegra_smmu_as_prepare()
378 err = tegra_smmu_alloc_asid(smmu, &as->id); in tegra_smmu_as_prepare()
382 smmu->soc->ops->flush_dcache(as->pd, 0, SMMU_SIZE_PD); in tegra_smmu_as_prepare()
383 smmu_flush_ptc(smmu, as->pd, 0); in tegra_smmu_as_prepare()
384 smmu_flush_tlb_asid(smmu, as->id); in tegra_smmu_as_prepare()
386 smmu_writel(smmu, as->id & 0x7f, SMMU_PTB_ASID); in tegra_smmu_as_prepare()
387 value = SMMU_PTB_DATA_VALUE(as->pd, as->attr); in tegra_smmu_as_prepare()
391 as->smmu = smmu; in tegra_smmu_as_prepare()
392 as->use_count++; in tegra_smmu_as_prepare()
398 struct tegra_smmu_as *as) in tegra_smmu_as_unprepare() argument
400 if (--as->use_count > 0) in tegra_smmu_as_unprepare()
403 tegra_smmu_free_asid(smmu, as->id); in tegra_smmu_as_unprepare()
404 as->smmu = NULL; in tegra_smmu_as_unprepare()
411 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_attach_dev() local
428 err = tegra_smmu_as_prepare(smmu, as); in tegra_smmu_attach_dev()
432 tegra_smmu_enable(smmu, swgroup, as->id); in tegra_smmu_attach_dev()
444 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_detach_dev() local
446 struct tegra_smmu *smmu = as->smmu; in tegra_smmu_detach_dev()
461 tegra_smmu_disable(smmu, swgroup, as->id); in tegra_smmu_detach_dev()
462 tegra_smmu_as_unprepare(smmu, as); in tegra_smmu_detach_dev()
467 static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova, in as_get_pte() argument
470 u32 *pd = page_address(as->pd), *pt, *count; in as_get_pte()
473 struct tegra_smmu *smmu = as->smmu; in as_get_pte()
492 smmu->soc->ops->flush_dcache(as->pd, pde << 2, 4); in as_get_pte()
493 smmu_flush_ptc(smmu, as->pd, pde << 2); in as_get_pte()
494 smmu_flush_tlb_section(smmu, as->id, iova); in as_get_pte()
504 count = page_address(as->count); in as_get_pte()
511 static void as_put_pte(struct tegra_smmu_as *as, dma_addr_t iova) in as_put_pte() argument
515 u32 *count = page_address(as->count); in as_put_pte()
516 u32 *pd = page_address(as->pd), *pt; in as_put_pte()
519 page = pfn_to_page(pd[pde] & as->smmu->pfn_mask); in as_put_pte()
540 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_map() local
541 struct tegra_smmu *smmu = as->smmu; in tegra_smmu_map()
546 pte = as_get_pte(as, iova, &page); in tegra_smmu_map()
555 smmu_flush_tlb_group(smmu, as->id, iova); in tegra_smmu_map()
564 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_unmap() local
565 struct tegra_smmu *smmu = as->smmu; in tegra_smmu_unmap()
570 pte = as_get_pte(as, iova, &page); in tegra_smmu_unmap()
575 as_put_pte(as, iova); in tegra_smmu_unmap()
579 smmu_flush_tlb_group(smmu, as->id, iova); in tegra_smmu_unmap()
588 struct tegra_smmu_as *as = to_smmu_as(domain); in tegra_smmu_iova_to_phys() local
593 pte = as_get_pte(as, iova, &page); in tegra_smmu_iova_to_phys()
594 pfn = *pte & as->smmu->pfn_mask; in tegra_smmu_iova_to_phys()