• Home
  • Raw
  • Download

Lines Matching refs:pfdev

29 static int wait_ready(struct panfrost_device *pfdev, u32 as_nr)  in wait_ready()  argument
36 ret = readl_relaxed_poll_timeout_atomic(pfdev->iomem + AS_STATUS(as_nr), in wait_ready()
40 dev_err(pfdev->dev, "AS_ACTIVE bit stuck\n"); in wait_ready()
45 static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd) in write_cmd() argument
50 status = wait_ready(pfdev, as_nr); in write_cmd()
52 mmu_write(pfdev, AS_COMMAND(as_nr), cmd); in write_cmd()
57 static void lock_region(struct panfrost_device *pfdev, u32 as_nr, in lock_region() argument
71 mmu_write(pfdev, AS_LOCKADDR_LO(as_nr), region & 0xFFFFFFFFUL); in lock_region()
72 mmu_write(pfdev, AS_LOCKADDR_HI(as_nr), (region >> 32) & 0xFFFFFFFFUL); in lock_region()
73 write_cmd(pfdev, as_nr, AS_COMMAND_LOCK); in lock_region()
77 static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, in mmu_hw_do_operation_locked() argument
84 lock_region(pfdev, as_nr, iova, size); in mmu_hw_do_operation_locked()
87 write_cmd(pfdev, as_nr, op); in mmu_hw_do_operation_locked()
90 return wait_ready(pfdev, as_nr); in mmu_hw_do_operation_locked()
93 static int mmu_hw_do_operation(struct panfrost_device *pfdev, in mmu_hw_do_operation() argument
99 spin_lock(&pfdev->as_lock); in mmu_hw_do_operation()
100 ret = mmu_hw_do_operation_locked(pfdev, mmu->as, iova, size, op); in mmu_hw_do_operation()
101 spin_unlock(&pfdev->as_lock); in mmu_hw_do_operation()
105 static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_mmu *mmu) in panfrost_mmu_enable() argument
112 mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM); in panfrost_mmu_enable()
114 mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL); in panfrost_mmu_enable()
115 mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), transtab >> 32); in panfrost_mmu_enable()
120 mmu_write(pfdev, AS_MEMATTR_LO(as_nr), memattr & 0xffffffffUL); in panfrost_mmu_enable()
121 mmu_write(pfdev, AS_MEMATTR_HI(as_nr), memattr >> 32); in panfrost_mmu_enable()
123 write_cmd(pfdev, as_nr, AS_COMMAND_UPDATE); in panfrost_mmu_enable()
126 static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr) in panfrost_mmu_disable() argument
128 mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM); in panfrost_mmu_disable()
130 mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0); in panfrost_mmu_disable()
131 mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0); in panfrost_mmu_disable()
133 mmu_write(pfdev, AS_MEMATTR_LO(as_nr), 0); in panfrost_mmu_disable()
134 mmu_write(pfdev, AS_MEMATTR_HI(as_nr), 0); in panfrost_mmu_disable()
136 write_cmd(pfdev, as_nr, AS_COMMAND_UPDATE); in panfrost_mmu_disable()
139 u32 panfrost_mmu_as_get(struct panfrost_device *pfdev, struct panfrost_mmu *mmu) in panfrost_mmu_as_get() argument
143 spin_lock(&pfdev->as_lock); in panfrost_mmu_as_get()
155 list_move(&mmu->list, &pfdev->as_lru_list); in panfrost_mmu_as_get()
160 as = ffz(pfdev->as_alloc_mask); in panfrost_mmu_as_get()
161 if (!(BIT(as) & pfdev->features.as_present)) { in panfrost_mmu_as_get()
164 list_for_each_entry_reverse(lru_mmu, &pfdev->as_lru_list, list) { in panfrost_mmu_as_get()
168 WARN_ON(&lru_mmu->list == &pfdev->as_lru_list); in panfrost_mmu_as_get()
179 set_bit(as, &pfdev->as_alloc_mask); in panfrost_mmu_as_get()
181 list_add(&mmu->list, &pfdev->as_lru_list); in panfrost_mmu_as_get()
183 dev_dbg(pfdev->dev, "Assigned AS%d to mmu %p, alloc_mask=%lx", as, mmu, pfdev->as_alloc_mask); in panfrost_mmu_as_get()
185 panfrost_mmu_enable(pfdev, mmu); in panfrost_mmu_as_get()
188 spin_unlock(&pfdev->as_lock); in panfrost_mmu_as_get()
192 void panfrost_mmu_as_put(struct panfrost_device *pfdev, struct panfrost_mmu *mmu) in panfrost_mmu_as_put() argument
198 void panfrost_mmu_reset(struct panfrost_device *pfdev) in panfrost_mmu_reset() argument
202 spin_lock(&pfdev->as_lock); in panfrost_mmu_reset()
204 pfdev->as_alloc_mask = 0; in panfrost_mmu_reset()
206 list_for_each_entry_safe(mmu, mmu_tmp, &pfdev->as_lru_list, list) { in panfrost_mmu_reset()
212 spin_unlock(&pfdev->as_lock); in panfrost_mmu_reset()
214 mmu_write(pfdev, MMU_INT_CLEAR, ~0); in panfrost_mmu_reset()
215 mmu_write(pfdev, MMU_INT_MASK, ~0); in panfrost_mmu_reset()
226 static void panfrost_mmu_flush_range(struct panfrost_device *pfdev, in panfrost_mmu_flush_range() argument
233 pm_runtime_get_noresume(pfdev->dev); in panfrost_mmu_flush_range()
236 if (pm_runtime_active(pfdev->dev)) in panfrost_mmu_flush_range()
237 mmu_hw_do_operation(pfdev, mmu, iova, size, AS_COMMAND_FLUSH_PT); in panfrost_mmu_flush_range()
239 pm_runtime_put_sync_autosuspend(pfdev->dev); in panfrost_mmu_flush_range()
242 static int mmu_map_sg(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, in mmu_map_sg() argument
254 dev_dbg(pfdev->dev, "map: as=%d, iova=%llx, paddr=%lx, len=%zx", mmu->as, iova, paddr, len); in mmu_map_sg()
266 panfrost_mmu_flush_range(pfdev, mmu, start_iova, iova - start_iova); in mmu_map_sg()
275 struct panfrost_device *pfdev = to_panfrost_device(obj->dev); in panfrost_mmu_map() local
289 mmu_map_sg(pfdev, mapping->mmu, mapping->mmnode.start << PAGE_SHIFT, in panfrost_mmu_map()
300 struct panfrost_device *pfdev = to_panfrost_device(obj->dev); in panfrost_mmu_unmap() local
309 dev_dbg(pfdev->dev, "unmap: as=%d, iova=%llx, len=%zx", in panfrost_mmu_unmap()
324 panfrost_mmu_flush_range(pfdev, mapping->mmu, in panfrost_mmu_unmap()
357 addr_to_mapping(struct panfrost_device *pfdev, int as, u64 addr) in addr_to_mapping() argument
364 spin_lock(&pfdev->as_lock); in addr_to_mapping()
365 list_for_each_entry(mmu, &pfdev->as_lru_list, list) { in addr_to_mapping()
387 spin_unlock(&pfdev->as_lock); in addr_to_mapping()
393 static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, in panfrost_mmu_map_fault_addr() argument
404 bomapping = addr_to_mapping(pfdev, as, addr); in panfrost_mmu_map_fault_addr()
410 dev_WARN(pfdev->dev, "matching BO is not heap type (GPU VA = %llx)", in panfrost_mmu_map_fault_addr()
473 ret = dma_map_sgtable(pfdev->dev, sgt, DMA_BIDIRECTIONAL, 0); in panfrost_mmu_map_fault_addr()
477 mmu_map_sg(pfdev, bomapping->mmu, addr, in panfrost_mmu_map_fault_addr()
482 dev_dbg(pfdev->dev, "mapped page fault @ AS%d %llx", as, addr); in panfrost_mmu_map_fault_addr()
502 struct panfrost_device *pfdev = mmu->pfdev; in panfrost_mmu_release_ctx() local
504 spin_lock(&pfdev->as_lock); in panfrost_mmu_release_ctx()
506 pm_runtime_get_noresume(pfdev->dev); in panfrost_mmu_release_ctx()
507 if (pm_runtime_active(pfdev->dev)) in panfrost_mmu_release_ctx()
508 panfrost_mmu_disable(pfdev, mmu->as); in panfrost_mmu_release_ctx()
509 pm_runtime_put_autosuspend(pfdev->dev); in panfrost_mmu_release_ctx()
511 clear_bit(mmu->as, &pfdev->as_alloc_mask); in panfrost_mmu_release_ctx()
512 clear_bit(mmu->as, &pfdev->as_in_use_mask); in panfrost_mmu_release_ctx()
515 spin_unlock(&pfdev->as_lock); in panfrost_mmu_release_ctx()
560 struct panfrost_mmu *panfrost_mmu_ctx_create(struct panfrost_device *pfdev) in panfrost_mmu_ctx_create() argument
568 mmu->pfdev = pfdev; in panfrost_mmu_ctx_create()
580 .ias = FIELD_GET(0xff, pfdev->features.mmu_features), in panfrost_mmu_ctx_create()
581 .oas = FIELD_GET(0xff00, pfdev->features.mmu_features), in panfrost_mmu_ctx_create()
582 .coherent_walk = pfdev->coherent, in panfrost_mmu_ctx_create()
584 .iommu_dev = pfdev->dev, in panfrost_mmu_ctx_create()
599 static const char *access_type_name(struct panfrost_device *pfdev, in access_type_name() argument
604 if (panfrost_has_hw_feature(pfdev, HW_FEATURE_AARCH64_MMU)) in access_type_name()
622 struct panfrost_device *pfdev = data; in panfrost_mmu_irq_handler() local
624 if (!mmu_read(pfdev, MMU_INT_STAT)) in panfrost_mmu_irq_handler()
627 mmu_write(pfdev, MMU_INT_MASK, 0); in panfrost_mmu_irq_handler()
633 struct panfrost_device *pfdev = data; in panfrost_mmu_irq_handler_thread() local
634 u32 status = mmu_read(pfdev, MMU_INT_RAWSTAT); in panfrost_mmu_irq_handler_thread()
648 fault_status = mmu_read(pfdev, AS_FAULTSTATUS(i)); in panfrost_mmu_irq_handler_thread()
649 addr = mmu_read(pfdev, AS_FAULTADDRESS_LO(i)); in panfrost_mmu_irq_handler_thread()
650 addr |= (u64)mmu_read(pfdev, AS_FAULTADDRESS_HI(i)) << 32; in panfrost_mmu_irq_handler_thread()
657 mmu_write(pfdev, MMU_INT_CLEAR, mask); in panfrost_mmu_irq_handler_thread()
662 ret = panfrost_mmu_map_fault_addr(pfdev, i, addr); in panfrost_mmu_irq_handler_thread()
666 dev_err(pfdev->dev, in panfrost_mmu_irq_handler_thread()
678 exception_type, panfrost_exception_name(pfdev, exception_type), in panfrost_mmu_irq_handler_thread()
679 access_type, access_type_name(pfdev, fault_status), in panfrost_mmu_irq_handler_thread()
685 mmu_write(pfdev, MMU_INT_MASK, ~0); in panfrost_mmu_irq_handler_thread()
689 int panfrost_mmu_init(struct panfrost_device *pfdev) in panfrost_mmu_init() argument
693 irq = platform_get_irq_byname(to_platform_device(pfdev->dev), "mmu"); in panfrost_mmu_init()
697 err = devm_request_threaded_irq(pfdev->dev, irq, in panfrost_mmu_init()
701 pfdev); in panfrost_mmu_init()
704 dev_err(pfdev->dev, "failed to request mmu irq"); in panfrost_mmu_init()
711 void panfrost_mmu_fini(struct panfrost_device *pfdev) in panfrost_mmu_fini() argument
713 mmu_write(pfdev, MMU_INT_MASK, 0); in panfrost_mmu_fini()