18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/************************************************************************** 38c2ecf20Sopenharmony_ci * Copyright (c) 2007-2011, Intel Corporation. 48c2ecf20Sopenharmony_ci * All Rights Reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci **************************************************************************/ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __MMU_H 98c2ecf20Sopenharmony_ci#define __MMU_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct psb_mmu_driver { 128c2ecf20Sopenharmony_ci /* protects driver- and pd structures. Always take in read mode 138c2ecf20Sopenharmony_ci * before taking the page table spinlock. 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci struct rw_semaphore sem; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci /* protects page tables, directory tables and pt tables. 188c2ecf20Sopenharmony_ci * and pt structures. 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci spinlock_t lock; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci atomic_t needs_tlbflush; 238c2ecf20Sopenharmony_ci atomic_t *msvdx_mmu_invaldc; 248c2ecf20Sopenharmony_ci struct psb_mmu_pd *default_pd; 258c2ecf20Sopenharmony_ci uint32_t bif_ctrl; 268c2ecf20Sopenharmony_ci int has_clflush; 278c2ecf20Sopenharmony_ci int clflush_add; 288c2ecf20Sopenharmony_ci unsigned long clflush_mask; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci struct drm_device *dev; 318c2ecf20Sopenharmony_ci}; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct psb_mmu_pd; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct psb_mmu_pt { 368c2ecf20Sopenharmony_ci struct psb_mmu_pd *pd; 378c2ecf20Sopenharmony_ci uint32_t index; 388c2ecf20Sopenharmony_ci uint32_t count; 398c2ecf20Sopenharmony_ci struct page *p; 408c2ecf20Sopenharmony_ci uint32_t *v; 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct psb_mmu_pd { 448c2ecf20Sopenharmony_ci struct psb_mmu_driver *driver; 458c2ecf20Sopenharmony_ci int hw_context; 468c2ecf20Sopenharmony_ci struct psb_mmu_pt **tables; 478c2ecf20Sopenharmony_ci struct page *p; 488c2ecf20Sopenharmony_ci struct page *dummy_pt; 498c2ecf20Sopenharmony_ci struct page *dummy_page; 508c2ecf20Sopenharmony_ci uint32_t pd_mask; 518c2ecf20Sopenharmony_ci uint32_t invalid_pde; 528c2ecf20Sopenharmony_ci uint32_t invalid_pte; 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciextern struct psb_mmu_driver *psb_mmu_driver_init(struct drm_device *dev, 568c2ecf20Sopenharmony_ci int trap_pagefaults, 578c2ecf20Sopenharmony_ci int invalid_type, 588c2ecf20Sopenharmony_ci atomic_t *msvdx_mmu_invaldc); 598c2ecf20Sopenharmony_ciextern void psb_mmu_driver_takedown(struct psb_mmu_driver *driver); 608c2ecf20Sopenharmony_ciextern struct psb_mmu_pd *psb_mmu_get_default_pd(struct psb_mmu_driver 618c2ecf20Sopenharmony_ci *driver); 628c2ecf20Sopenharmony_ciextern struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver, 638c2ecf20Sopenharmony_ci int trap_pagefaults, 648c2ecf20Sopenharmony_ci int invalid_type); 658c2ecf20Sopenharmony_ciextern void psb_mmu_free_pagedir(struct psb_mmu_pd *pd); 668c2ecf20Sopenharmony_ciextern void psb_mmu_flush(struct psb_mmu_driver *driver); 678c2ecf20Sopenharmony_ciextern void psb_mmu_remove_pfn_sequence(struct psb_mmu_pd *pd, 688c2ecf20Sopenharmony_ci unsigned long address, 698c2ecf20Sopenharmony_ci uint32_t num_pages); 708c2ecf20Sopenharmony_ciextern int psb_mmu_insert_pfn_sequence(struct psb_mmu_pd *pd, 718c2ecf20Sopenharmony_ci uint32_t start_pfn, 728c2ecf20Sopenharmony_ci unsigned long address, 738c2ecf20Sopenharmony_ci uint32_t num_pages, int type); 748c2ecf20Sopenharmony_ciextern int psb_mmu_virtual_to_pfn(struct psb_mmu_pd *pd, uint32_t virtual, 758c2ecf20Sopenharmony_ci unsigned long *pfn); 768c2ecf20Sopenharmony_ciextern void psb_mmu_set_pd_context(struct psb_mmu_pd *pd, int hw_context); 778c2ecf20Sopenharmony_ciextern int psb_mmu_insert_pages(struct psb_mmu_pd *pd, struct page **pages, 788c2ecf20Sopenharmony_ci unsigned long address, uint32_t num_pages, 798c2ecf20Sopenharmony_ci uint32_t desired_tile_stride, 808c2ecf20Sopenharmony_ci uint32_t hw_tile_stride, int type); 818c2ecf20Sopenharmony_ciextern void psb_mmu_remove_pages(struct psb_mmu_pd *pd, 828c2ecf20Sopenharmony_ci unsigned long address, uint32_t num_pages, 838c2ecf20Sopenharmony_ci uint32_t desired_tile_stride, 848c2ecf20Sopenharmony_ci uint32_t hw_tile_stride); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#endif 87