Home | History | Annotate | Line # | Download | only in mmu
      1 /*	$NetBSD: nouveau_nvkm_subdev_mmu_tu102.c,v 1.3 2021/12/19 10:51:58 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2018 Red Hat Inc.
      5  * Copyright 2019 NVIDIA Corporation.
      6  *
      7  * Permission is hereby granted, free of charge, to any person obtaining a
      8  * copy of this software and associated documentation files (the "Software"),
      9  * to deal in the Software without restriction, including without limitation
     10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     11  * and/or sell copies of the Software, and to permit persons to whom the
     12  * Software is furnished to do so, subject to the following conditions:
     13  *
     14  * The above copyright notice and this permission notice shall be included in
     15  * all copies or substantial portions of the Software.
     16  *
     17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     23  * OTHER DEALINGS IN THE SOFTWARE.
     24  */
     25 #include <sys/cdefs.h>
     26 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_mmu_tu102.c,v 1.3 2021/12/19 10:51:58 riastradh Exp $");
     27 
     28 #include "mem.h"
     29 #include "vmm.h"
     30 
     31 #include <core/option.h>
     32 
     33 #include <nvif/class.h>
     34 
     35 static const u8 *
     36 tu102_mmu_kind(struct nvkm_mmu *mmu, int *count, u8 *invalid)
     37 {
     38 	static const u8
     39 	kind[16] = {
     40 		0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 */
     41 		0x06, 0x06, 0x02, 0x01, 0x03, 0x04, 0x05, 0x07,
     42 	};
     43 	*count = ARRAY_SIZE(kind);
     44 	*invalid = 0x07;
     45 	return kind;
     46 }
     47 
     48 static const struct nvkm_mmu_func
     49 tu102_mmu = {
     50 	.dma_bits = 47,
     51 	.mmu = {{ -1, -1, NVIF_CLASS_MMU_GF100}},
     52 	.mem = {{ -1,  0, NVIF_CLASS_MEM_GF100}, gf100_mem_new, gf100_mem_map },
     53 	.vmm = {{ -1,  0, NVIF_CLASS_VMM_GP100}, tu102_vmm_new },
     54 	.kind = tu102_mmu_kind,
     55 	.kind_sys = true,
     56 };
     57 
     58 int
     59 tu102_mmu_new(struct nvkm_device *device, int index, struct nvkm_mmu **pmmu)
     60 {
     61 	return nvkm_mmu_new_(&tu102_mmu, device, index, pmmu);
     62 }
     63