Duy Truong | e833aca | 2013-02-12 13:35:08 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef __KGSL_GPUMMU_H |
| 15 | #define __KGSL_GPUMMU_H |
| 16 | |
| 17 | #define GSL_PT_PAGE_BITS_MASK 0x00000007 |
| 18 | #define GSL_PT_PAGE_ADDR_MASK PAGE_MASK |
| 19 | |
| 20 | #define GSL_MMU_INT_MASK \ |
| 21 | (MH_INTERRUPT_MASK__AXI_READ_ERROR | \ |
| 22 | MH_INTERRUPT_MASK__AXI_WRITE_ERROR) |
| 23 | |
| 24 | /* Macros to manage TLB flushing */ |
| 25 | #define GSL_TLBFLUSH_FILTER_ENTRY_NUMBITS (sizeof(unsigned char) * 8) |
| 26 | #define GSL_TLBFLUSH_FILTER_GET(superpte) \ |
| 27 | (*((unsigned char *) \ |
| 28 | (((unsigned int)gpummu_pt->tlbflushfilter.base) \ |
| 29 | + (superpte / GSL_TLBFLUSH_FILTER_ENTRY_NUMBITS)))) |
| 30 | #define GSL_TLBFLUSH_FILTER_SETDIRTY(superpte) \ |
| 31 | (GSL_TLBFLUSH_FILTER_GET((superpte)) |= 1 << \ |
| 32 | (superpte % GSL_TLBFLUSH_FILTER_ENTRY_NUMBITS)) |
| 33 | #define GSL_TLBFLUSH_FILTER_ISDIRTY(superpte) \ |
| 34 | (GSL_TLBFLUSH_FILTER_GET((superpte)) & \ |
| 35 | (1 << (superpte % GSL_TLBFLUSH_FILTER_ENTRY_NUMBITS))) |
| 36 | #define GSL_TLBFLUSH_FILTER_RESET() memset(gpummu_pt->tlbflushfilter.base,\ |
| 37 | 0, gpummu_pt->tlbflushfilter.size) |
| 38 | |
| 39 | extern struct kgsl_mmu_ops gpummu_ops; |
| 40 | extern struct kgsl_mmu_pt_ops gpummu_pt_ops; |
| 41 | |
| 42 | struct kgsl_tlbflushfilter { |
| 43 | unsigned int *base; |
| 44 | unsigned int size; |
| 45 | }; |
| 46 | |
| 47 | struct kgsl_gpummu_pt { |
| 48 | struct kgsl_memdesc base; |
| 49 | unsigned int last_superpte; |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 50 | /* Maintain filter to manage tlb flushing */ |
| 51 | struct kgsl_tlbflushfilter tlbflushfilter; |
| 52 | }; |
| 53 | |
| 54 | struct kgsl_ptpool_chunk { |
| 55 | size_t size; |
| 56 | unsigned int count; |
| 57 | int dynamic; |
| 58 | |
| 59 | void *data; |
| 60 | unsigned int phys; |
| 61 | |
| 62 | unsigned long *bitmap; |
| 63 | struct list_head list; |
| 64 | }; |
| 65 | |
| 66 | struct kgsl_ptpool { |
| 67 | size_t ptsize; |
| 68 | struct mutex lock; |
| 69 | struct list_head list; |
| 70 | int entries; |
| 71 | int static_entries; |
| 72 | int chunks; |
| 73 | }; |
| 74 | |
Jordan Crouse | 6d76c4d | 2012-03-26 09:50:43 -0600 | [diff] [blame] | 75 | void *kgsl_gpummu_ptpool_init(int entries); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 76 | void kgsl_gpummu_ptpool_destroy(void *ptpool); |
| 77 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 78 | #endif /* __KGSL_GPUMMU_H */ |