2 * Copyright 2017 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #include <core/memory.h>
25 #include <subdev/fb.h>
27 #include <nvif/if000b.h>
28 #include <nvif/unpack.h>
31 nv04_mem_map(struct nvkm_mmu
*mmu
, struct nvkm_memory
*memory
, void *argv
,
32 u32 argc
, u64
*paddr
, u64
*psize
, struct nvkm_vma
**pvma
)
35 struct nv04_mem_map_vn vn
;
37 struct nvkm_device
*device
= mmu
->subdev
.device
;
38 const u64 addr
= nvkm_memory_addr(memory
);
41 if ((ret
= nvif_unvers(ret
, &argv
, &argc
, args
->vn
)))
44 *paddr
= device
->func
->resource_addr(device
, 1) + addr
;
45 *psize
= nvkm_memory_size(memory
);
46 *pvma
= ERR_PTR(-ENODEV
);
51 nv04_mem_new(struct nvkm_mmu
*mmu
, int type
, u8 page
, u64 size
,
52 void *argv
, u32 argc
, struct nvkm_memory
**pmemory
)
55 struct nv04_mem_vn vn
;
59 if ((ret
= nvif_unvers(ret
, &argv
, &argc
, args
->vn
)))
62 if (mmu
->type
[type
].type
& NVKM_MEM_MAPPABLE
)
63 type
= NVKM_RAM_MM_NORMAL
;
65 type
= NVKM_RAM_MM_NOMAP
;
67 return nvkm_ram_get(mmu
->subdev
.device
, type
, 0x01, page
,
68 size
, true, false, pmemory
);