blob: cac693083b43d679696dc79b426e04ad5a31f0e1 [file] [log] [blame]
Jordan Crouse6d76c4d2012-03-26 09:50:43 -06001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Shubhraprakash Das767fdda2011-08-15 15:49:45 -06002 *
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
39extern struct kgsl_mmu_ops gpummu_ops;
40extern struct kgsl_mmu_pt_ops gpummu_pt_ops;
41
42struct kgsl_tlbflushfilter {
43 unsigned int *base;
44 unsigned int size;
45};
46
47struct kgsl_gpummu_pt {
48 struct kgsl_memdesc base;
49 unsigned int last_superpte;
50 unsigned int tlb_flags;
51 /* Maintain filter to manage tlb flushing */
52 struct kgsl_tlbflushfilter tlbflushfilter;
53};
54
55struct kgsl_ptpool_chunk {
56 size_t size;
57 unsigned int count;
58 int dynamic;
59
60 void *data;
61 unsigned int phys;
62
63 unsigned long *bitmap;
64 struct list_head list;
65};
66
67struct kgsl_ptpool {
68 size_t ptsize;
69 struct mutex lock;
70 struct list_head list;
71 int entries;
72 int static_entries;
73 int chunks;
74};
75
Jordan Crouse6d76c4d2012-03-26 09:50:43 -060076void *kgsl_gpummu_ptpool_init(int entries);
Shubhraprakash Das767fdda2011-08-15 15:49:45 -060077void kgsl_gpummu_ptpool_destroy(void *ptpool);
78
79static inline unsigned int kgsl_pt_get_base_addr(struct kgsl_pagetable *pt)
80{
81 struct kgsl_gpummu_pt *gpummu_pt = pt->priv;
82 return gpummu_pt->base.gpuaddr;
83}
84#endif /* __KGSL_GPUMMU_H */