1 /* $NetBSD: nouveau_nvkm_subdev_mmu_gm200.c,v 1.2 2021/12/18 23:45:40 riastradh Exp $ */ 2 3 /* 4 * Copyright 2017 Red Hat Inc. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 #include <sys/cdefs.h> 25 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_mmu_gm200.c,v 1.2 2021/12/18 23:45:40 riastradh Exp $"); 26 27 #include "mem.h" 28 #include "vmm.h" 29 30 #include <subdev/fb.h> 31 32 #include <nvif/class.h> 33 34 const u8 * 35 gm200_mmu_kind(struct nvkm_mmu *mmu, int *count, u8 *invalid) 36 { 37 static const u8 38 kind[256] = { 39 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0x01, /* 0x00 */ 40 0x01, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 41 0xff, 0x11, 0xff, 0xff, 0xff, 0xff, 0xff, 0x11, /* 0x10 */ 42 0x11, 0x11, 0x11, 0xff, 0xff, 0xff, 0xff, 0xff, 43 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x26, 0x27, /* 0x20 */ 44 0x28, 0x29, 0x2a, 0x2b, 0xff, 0xff, 0xff, 0xff, 45 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x30 */ 46 0xff, 0xff, 0x26, 0x27, 0x28, 0x29, 0x26, 0x27, 47 0x28, 0x29, 0xff, 0xff, 0xff, 0xff, 0x46, 0xff, /* 0x40 */ 48 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 49 0xff, 0x46, 0x46, 0x46, 0x46, 0xff, 0xff, 0xff, /* 0x50 */ 50 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 51 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x60 */ 52 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 53 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x70 */ 54 0xff, 0xff, 0xff, 0x7b, 0xff, 0xff, 0xff, 0xff, 55 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7b, 0x7b, /* 0x80 */ 56 0x7b, 0x7b, 0xff, 0x8b, 0x8c, 0x8d, 0x8e, 0xff, 57 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x90 */ 58 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 59 0xff, 0xff, 0xff, 0x8b, 0x8c, 0x8d, 0x8e, 0xa7, /* 0xa0 */ 60 0xa8, 0xa9, 0xaa, 0xff, 0xff, 0xff, 0xff, 0xff, 61 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb0 */ 62 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa7, 63 0xa8, 0xa9, 0xaa, 0xc3, 0xff, 0xff, 0xff, 0xff, /* 0xc0 */ 64 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xc3, 0xc3, 65 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xd0 */ 66 0xfe, 0xff, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 67 0xfe, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, /* 0xe0 */ 68 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xfe, 0xff, 69 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, /* 0xf0 */ 70 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xfd, 0xfe, 0xff 71 }; 72 *count = ARRAY_SIZE(kind); 73 *invalid = 0xff; 74 return kind; 75 } 76 77 static const struct nvkm_mmu_func 78 gm200_mmu = { 79 .dma_bits = 40, 80 .mmu = {{ -1, -1, NVIF_CLASS_MMU_GF100}}, 81 .mem = {{ -1, 0, NVIF_CLASS_MEM_GF100}, gf100_mem_new, gf100_mem_map }, 82 .vmm = {{ -1, 0, NVIF_CLASS_VMM_GM200}, gm200_vmm_new }, 83 .kind = gm200_mmu_kind, 84 .kind_sys = true, 85 }; 86 87 static const struct nvkm_mmu_func 88 gm200_mmu_fixed = { 89 .dma_bits = 40, 90 .mmu = {{ -1, -1, NVIF_CLASS_MMU_GF100}}, 91 .mem = {{ -1, 0, NVIF_CLASS_MEM_GF100}, gf100_mem_new, gf100_mem_map }, 92 .vmm = {{ -1, -1, NVIF_CLASS_VMM_GM200}, gm200_vmm_new_fixed }, 93 .kind = gm200_mmu_kind, 94 .kind_sys = true, 95 }; 96 97 int 98 gm200_mmu_new(struct nvkm_device *device, int index, struct nvkm_mmu **pmmu) 99 { 100 if (device->fb->page) 101 return nvkm_mmu_new_(&gm200_mmu_fixed, device, index, pmmu); 102 return nvkm_mmu_new_(&gm200_mmu, device, index, pmmu); 103 } 104