Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Red Hat Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | * Authors: Ben Skeggs |
| 23 | */ |
| 24 | |
| 25 | #ifndef __NOUVEAU_VM_H__ |
| 26 | #define __NOUVEAU_VM_H__ |
| 27 | |
| 28 | #include "drmP.h" |
| 29 | |
| 30 | #include "nouveau_drv.h" |
| 31 | #include "nouveau_mm.h" |
| 32 | |
| 33 | struct nouveau_vm_pgt { |
Ben Skeggs | 3ee0128 | 2010-12-15 11:04:39 +1000 | [diff] [blame] | 34 | struct nouveau_gpuobj *obj[2]; |
| 35 | u32 refcount[2]; |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | struct nouveau_vm_pgd { |
| 39 | struct list_head head; |
| 40 | struct nouveau_gpuobj *obj; |
| 41 | }; |
| 42 | |
| 43 | struct nouveau_vma { |
| 44 | struct nouveau_vm *vm; |
| 45 | struct nouveau_mm_node *node; |
| 46 | u64 offset; |
| 47 | u32 access; |
| 48 | }; |
| 49 | |
| 50 | struct nouveau_vm { |
| 51 | struct drm_device *dev; |
| 52 | struct nouveau_mm *mm; |
| 53 | int refcount; |
| 54 | |
| 55 | struct list_head pgd_list; |
Ben Skeggs | 6dfdd7a | 2011-03-31 15:40:43 +1000 | [diff] [blame] | 56 | atomic_t engref[16]; |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 57 | |
| 58 | struct nouveau_vm_pgt *pgt; |
| 59 | u32 fpde; |
| 60 | u32 lpde; |
| 61 | |
| 62 | u32 pgt_bits; |
| 63 | u8 spg_shift; |
| 64 | u8 lpg_shift; |
| 65 | |
Ben Skeggs | 3ee0128 | 2010-12-15 11:04:39 +1000 | [diff] [blame] | 66 | void (*map_pgt)(struct nouveau_gpuobj *pgd, u32 pde, |
| 67 | struct nouveau_gpuobj *pgt[2]); |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 68 | void (*map)(struct nouveau_vma *, struct nouveau_gpuobj *, |
Ben Skeggs | 8f7286f | 2011-02-14 09:57:35 +1000 | [diff] [blame] | 69 | struct nouveau_mem *, u32 pte, u32 cnt, |
| 70 | u64 phys, u64 delta); |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 71 | void (*map_sg)(struct nouveau_vma *, struct nouveau_gpuobj *, |
Ben Skeggs | 26c0c9e | 2011-02-10 12:59:51 +1000 | [diff] [blame] | 72 | struct nouveau_mem *, u32 pte, u32 cnt, dma_addr_t *); |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 73 | void (*unmap)(struct nouveau_gpuobj *pgt, u32 pte, u32 cnt); |
| 74 | void (*flush)(struct nouveau_vm *); |
| 75 | }; |
| 76 | |
| 77 | /* nouveau_vm.c */ |
| 78 | int nouveau_vm_new(struct drm_device *, u64 offset, u64 length, u64 mm_offset, |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 79 | struct nouveau_vm **); |
| 80 | int nouveau_vm_ref(struct nouveau_vm *, struct nouveau_vm **, |
| 81 | struct nouveau_gpuobj *pgd); |
| 82 | int nouveau_vm_get(struct nouveau_vm *, u64 size, u32 page_shift, |
| 83 | u32 access, struct nouveau_vma *); |
| 84 | void nouveau_vm_put(struct nouveau_vma *); |
Ben Skeggs | d5f4239 | 2011-02-10 12:22:52 +1000 | [diff] [blame] | 85 | void nouveau_vm_map(struct nouveau_vma *, struct nouveau_mem *); |
| 86 | void nouveau_vm_map_at(struct nouveau_vma *, u64 offset, struct nouveau_mem *); |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 87 | void nouveau_vm_unmap(struct nouveau_vma *); |
| 88 | void nouveau_vm_unmap_at(struct nouveau_vma *, u64 offset, u64 length); |
| 89 | void nouveau_vm_map_sg(struct nouveau_vma *, u64 offset, u64 length, |
Ben Skeggs | 26c0c9e | 2011-02-10 12:59:51 +1000 | [diff] [blame] | 90 | struct nouveau_mem *, dma_addr_t *); |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 91 | |
| 92 | /* nv50_vm.c */ |
Ben Skeggs | 3ee0128 | 2010-12-15 11:04:39 +1000 | [diff] [blame] | 93 | void nv50_vm_map_pgt(struct nouveau_gpuobj *pgd, u32 pde, |
| 94 | struct nouveau_gpuobj *pgt[2]); |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 95 | void nv50_vm_map(struct nouveau_vma *, struct nouveau_gpuobj *, |
Ben Skeggs | 8f7286f | 2011-02-14 09:57:35 +1000 | [diff] [blame] | 96 | struct nouveau_mem *, u32 pte, u32 cnt, u64 phys, u64 delta); |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 97 | void nv50_vm_map_sg(struct nouveau_vma *, struct nouveau_gpuobj *, |
Ben Skeggs | 26c0c9e | 2011-02-10 12:59:51 +1000 | [diff] [blame] | 98 | struct nouveau_mem *, u32 pte, u32 cnt, dma_addr_t *); |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 99 | void nv50_vm_unmap(struct nouveau_gpuobj *, u32 pte, u32 cnt); |
| 100 | void nv50_vm_flush(struct nouveau_vm *); |
| 101 | void nv50_vm_flush_engine(struct drm_device *, int engine); |
| 102 | |
Ben Skeggs | 4c74eb7 | 2010-11-10 14:10:04 +1000 | [diff] [blame] | 103 | /* nvc0_vm.c */ |
| 104 | void nvc0_vm_map_pgt(struct nouveau_gpuobj *pgd, u32 pde, |
| 105 | struct nouveau_gpuobj *pgt[2]); |
| 106 | void nvc0_vm_map(struct nouveau_vma *, struct nouveau_gpuobj *, |
Ben Skeggs | 8f7286f | 2011-02-14 09:57:35 +1000 | [diff] [blame] | 107 | struct nouveau_mem *, u32 pte, u32 cnt, u64 phys, u64 delta); |
Ben Skeggs | 4c74eb7 | 2010-11-10 14:10:04 +1000 | [diff] [blame] | 108 | void nvc0_vm_map_sg(struct nouveau_vma *, struct nouveau_gpuobj *, |
Ben Skeggs | 26c0c9e | 2011-02-10 12:59:51 +1000 | [diff] [blame] | 109 | struct nouveau_mem *, u32 pte, u32 cnt, dma_addr_t *); |
Ben Skeggs | 4c74eb7 | 2010-11-10 14:10:04 +1000 | [diff] [blame] | 110 | void nvc0_vm_unmap(struct nouveau_gpuobj *, u32 pte, u32 cnt); |
| 111 | void nvc0_vm_flush(struct nouveau_vm *); |
| 112 | |
Ben Skeggs | a11c319 | 2010-08-27 10:00:25 +1000 | [diff] [blame] | 113 | #endif |