Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2017 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  */
0022 #include "mem.h"
0023 #include "vmm.h"
0024 
0025 #include <subdev/fb.h>
0026 
0027 #include <nvif/class.h>
0028 
0029 const u8 *
0030 gm200_mmu_kind(struct nvkm_mmu *mmu, int *count, u8 *invalid)
0031 {
0032     static const u8
0033     kind[256] = {
0034         0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0x01, /* 0x00 */
0035         0x01, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff,
0036         0xff, 0x11, 0xff, 0xff, 0xff, 0xff, 0xff, 0x11, /* 0x10 */
0037         0x11, 0x11, 0x11, 0xff, 0xff, 0xff, 0xff, 0xff,
0038         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x26, 0x27, /* 0x20 */
0039         0x28, 0x29, 0x2a, 0x2b, 0xff, 0xff, 0xff, 0xff,
0040         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x30 */
0041         0xff, 0xff, 0x26, 0x27, 0x28, 0x29, 0x26, 0x27,
0042         0x28, 0x29, 0xff, 0xff, 0xff, 0xff, 0x46, 0xff, /* 0x40 */
0043         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0044         0xff, 0x46, 0x46, 0x46, 0x46, 0xff, 0xff, 0xff, /* 0x50 */
0045         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0046         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x60 */
0047         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0048         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x70 */
0049         0xff, 0xff, 0xff, 0x7b, 0xff, 0xff, 0xff, 0xff,
0050         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7b, 0x7b, /* 0x80 */
0051         0x7b, 0x7b, 0xff, 0x8b, 0x8c, 0x8d, 0x8e, 0xff,
0052         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x90 */
0053         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0054         0xff, 0xff, 0xff, 0x8b, 0x8c, 0x8d, 0x8e, 0xa7, /* 0xa0 */
0055         0xa8, 0xa9, 0xaa, 0xff, 0xff, 0xff, 0xff, 0xff,
0056         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb0 */
0057         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa7,
0058         0xa8, 0xa9, 0xaa, 0xc3, 0xff, 0xff, 0xff, 0xff, /* 0xc0 */
0059         0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xc3, 0xc3,
0060         0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xd0 */
0061         0xfe, 0xff, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
0062         0xfe, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, /* 0xe0 */
0063         0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xfe, 0xff,
0064         0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, /* 0xf0 */
0065         0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xfd, 0xfe, 0xff
0066     };
0067     *count = ARRAY_SIZE(kind);
0068     *invalid = 0xff;
0069     return kind;
0070 }
0071 
0072 static const struct nvkm_mmu_func
0073 gm200_mmu = {
0074     .dma_bits = 40,
0075     .mmu = {{ -1, -1, NVIF_CLASS_MMU_GF100}},
0076     .mem = {{ -1,  0, NVIF_CLASS_MEM_GF100}, gf100_mem_new, gf100_mem_map },
0077     .vmm = {{ -1,  0, NVIF_CLASS_VMM_GM200}, gm200_vmm_new },
0078     .kind = gm200_mmu_kind,
0079     .kind_sys = true,
0080 };
0081 
0082 static const struct nvkm_mmu_func
0083 gm200_mmu_fixed = {
0084     .dma_bits = 40,
0085     .mmu = {{ -1, -1, NVIF_CLASS_MMU_GF100}},
0086     .mem = {{ -1,  0, NVIF_CLASS_MEM_GF100}, gf100_mem_new, gf100_mem_map },
0087     .vmm = {{ -1, -1, NVIF_CLASS_VMM_GM200}, gm200_vmm_new_fixed },
0088     .kind = gm200_mmu_kind,
0089     .kind_sys = true,
0090 };
0091 
0092 int
0093 gm200_mmu_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0094           struct nvkm_mmu **pmmu)
0095 {
0096     if (device->fb->page)
0097         return nvkm_mmu_new_(&gm200_mmu_fixed, device, type, inst, pmmu);
0098     return nvkm_mmu_new_(&gm200_mmu, device, type, inst, pmmu);
0099 }