Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2018 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 "vmm.h"
0023 
0024 #include <subdev/timer.h>
0025 
0026 static void
0027 tu102_vmm_flush(struct nvkm_vmm *vmm, int depth)
0028 {
0029     struct nvkm_device *device = vmm->mmu->subdev.device;
0030     u32 type = (5 /* CACHE_LEVEL_UP_TO_PDE3 */ - depth) << 24;
0031 
0032     type |= 0x00000001; /* PAGE_ALL */
0033     if (atomic_read(&vmm->engref[NVKM_SUBDEV_BAR]))
0034         type |= 0x00000004; /* HUB_ONLY */
0035 
0036     mutex_lock(&vmm->mmu->mutex);
0037 
0038     nvkm_wr32(device, 0xb830a0, vmm->pd->pt[0]->addr >> 8);
0039     nvkm_wr32(device, 0xb830a4, 0x00000000);
0040     nvkm_wr32(device, 0x100e68, 0x00000000);
0041     nvkm_wr32(device, 0xb830b0, 0x80000000 | type);
0042 
0043     nvkm_msec(device, 2000,
0044         if (!(nvkm_rd32(device, 0xb830b0) & 0x80000000))
0045             break;
0046     );
0047 
0048     mutex_unlock(&vmm->mmu->mutex);
0049 }
0050 
0051 static const struct nvkm_vmm_func
0052 tu102_vmm = {
0053     .join = gv100_vmm_join,
0054     .part = gf100_vmm_part,
0055     .aper = gf100_vmm_aper,
0056     .valid = gp100_vmm_valid,
0057     .flush = tu102_vmm_flush,
0058     .mthd = gp100_vmm_mthd,
0059     .page = {
0060         { 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
0061         { 38, &gp100_vmm_desc_16[3], NVKM_VMM_PAGE_Sxxx },
0062         { 29, &gp100_vmm_desc_16[2], NVKM_VMM_PAGE_Sxxx },
0063         { 21, &gp100_vmm_desc_16[1], NVKM_VMM_PAGE_SVxC },
0064         { 16, &gp100_vmm_desc_16[0], NVKM_VMM_PAGE_SVxC },
0065         { 12, &gp100_vmm_desc_12[0], NVKM_VMM_PAGE_SVHx },
0066         {}
0067     }
0068 };
0069 
0070 int
0071 tu102_vmm_new(struct nvkm_mmu *mmu, bool managed, u64 addr, u64 size,
0072           void *argv, u32 argc, struct lock_class_key *key,
0073           const char *name, struct nvkm_vmm **pvmm)
0074 {
0075     return gp100_vmm_new_(&tu102_vmm, mmu, managed, addr, size,
0076                   argv, argc, key, name, pvmm);
0077 }