Skip to content

Commit 5bf0257

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/mmu/r535: initial support
- Valid VRAM regions are read from GSP-RM, and used to construct our MM - BAR1/BAR2 VMMs modified to be shared with RM - Client VMMs have RM VASPACE objects created for them - Adds FBSR to backup system objects in VRAM across suspend Signed-off-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 830531e commit 5bf0257

File tree

33 files changed

+1201
-4
lines changed

33 files changed

+1201
-4
lines changed

drivers/gpu/drm/nouveau/include/nvkm/subdev/bar.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ struct nvkm_bar {
1111
spinlock_t lock;
1212
bool bar2;
1313

14+
void __iomem *flushBAR2PhysMode;
15+
struct nvkm_memory *flushFBZero;
16+
void __iomem *flushBAR2;
17+
1418
/* whether the BAR supports to be ioremapped WC or should be uncached */
1519
bool iomap_uncached;
1620
};

drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ struct nvkm_gsp {
6565
} heap;
6666
u64 addr;
6767
u64 size;
68+
69+
struct {
70+
u64 addr;
71+
u64 size;
72+
} region[16];
73+
int region_nr;
74+
u32 rsvd_size;
6875
} fb;
6976

7077
struct {
@@ -159,6 +166,11 @@ struct nvkm_gsp {
159166
} intr[32];
160167
int intr_nr;
161168

169+
struct {
170+
u64 rm_bar1_pdb;
171+
u64 rm_bar2_pdb;
172+
} bar;
173+
162174
const struct nvkm_gsp_rm {
163175
void *(*rpc_get)(struct nvkm_gsp *, u32 fn, u32 argc);
164176
void *(*rpc_push)(struct nvkm_gsp *, void *argv, bool wait, u32 repc);

drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ struct nvkm_instmem {
2424
struct nvkm_ramht *ramht;
2525
struct nvkm_memory *ramro;
2626
struct nvkm_memory *ramfc;
27+
28+
struct {
29+
struct sg_table fbsr;
30+
bool fbsr_valid;
31+
} rm;
2732
};
2833

2934
u32 nvkm_instmem_rd32(struct nvkm_instmem *, u32 addr);

drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef __NVKM_MMU_H__
33
#define __NVKM_MMU_H__
44
#include <core/subdev.h>
5+
#include <subdev/gsp.h>
56

67
struct nvkm_vma {
78
struct list_head head;
@@ -63,6 +64,16 @@ struct nvkm_vmm {
6364
void *nullp;
6465

6566
bool replay;
67+
68+
struct {
69+
u64 bar2_pdb;
70+
71+
struct nvkm_gsp_client client;
72+
struct nvkm_gsp_device device;
73+
struct nvkm_gsp_object object;
74+
75+
struct nvkm_vma *rsvd;
76+
} rm;
6677
};
6778

6879
int nvkm_vmm_new(struct nvkm_device *, u64 addr, u64 size, void *argv, u32 argc,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef __src_common_sdk_nvidia_inc_class_cl84a0_h__
2+
#define __src_common_sdk_nvidia_inc_class_cl84a0_h__
3+
4+
/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */
5+
6+
/*
7+
* SPDX-FileCopyrightText: Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
8+
* SPDX-License-Identifier: MIT
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a
11+
* copy of this software and associated documentation files (the "Software"),
12+
* to deal in the Software without restriction, including without limitation
13+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
* and/or sell copies of the Software, and to permit persons to whom the
15+
* Software is furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
* DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#define NV01_MEMORY_LIST_SYSTEM (0x00000081)
30+
31+
#define NV01_MEMORY_LIST_FBMEM (0x00000082)
32+
33+
#endif
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef __src_common_sdk_nvidia_inc_class_cl90f1_h__
2+
#define __src_common_sdk_nvidia_inc_class_cl90f1_h__
3+
4+
/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */
5+
6+
/*
7+
* SPDX-FileCopyrightText: Copyright (c) 2011 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
8+
* SPDX-License-Identifier: MIT
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a
11+
* copy of this software and associated documentation files (the "Software"),
12+
* to deal in the Software without restriction, including without limitation
13+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
* and/or sell copies of the Software, and to permit persons to whom the
15+
* Software is furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
* DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#define FERMI_VASPACE_A (0x000090f1)
30+
31+
#endif

drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080internal.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,26 @@ typedef struct NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_PARAMS {
5959
NV2080_INTR_CATEGORY_SUBTREE_MAP subtreeMap[NV2080_INTR_CATEGORY_ENUM_COUNT];
6060
} NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_PARAMS;
6161

62+
#define NV2080_CTRL_CMD_INTERNAL_FBSR_INIT (0x20800ac2) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS_MESSAGE_ID" */
63+
64+
typedef struct NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS {
65+
NvU32 fbsrType;
66+
NvU32 numRegions;
67+
NvHandle hClient;
68+
NvHandle hSysMem;
69+
NV_DECLARE_ALIGNED(NvU64 gspFbAllocsSysOffset, 8);
70+
NvBool bEnteringGcoffState;
71+
} NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS;
72+
73+
#define NV2080_CTRL_CMD_INTERNAL_FBSR_SEND_REGION_INFO (0x20800ac3) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_FBSR_SEND_REGION_INFO_PARAMS_MESSAGE_ID" */
74+
75+
typedef struct NV2080_CTRL_INTERNAL_FBSR_SEND_REGION_INFO_PARAMS {
76+
NvU32 fbsrType;
77+
NvHandle hClient;
78+
NvHandle hVidMem;
79+
NV_DECLARE_ALIGNED(NvU64 vidOffset, 8);
80+
NV_DECLARE_ALIGNED(NvU64 sysOffset, 8);
81+
NV_DECLARE_ALIGNED(NvU64 size, 8);
82+
} NV2080_CTRL_INTERNAL_FBSR_SEND_REGION_INFO_PARAMS;
83+
6284
#endif
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#ifndef __src_common_sdk_nvidia_inc_ctrl_ctrl90f1_h__
2+
#define __src_common_sdk_nvidia_inc_ctrl_ctrl90f1_h__
3+
4+
/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */
5+
6+
/*
7+
* SPDX-FileCopyrightText: Copyright (c) 2014-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
8+
* SPDX-License-Identifier: MIT
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a
11+
* copy of this software and associated documentation files (the "Software"),
12+
* to deal in the Software without restriction, including without limitation
13+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
* and/or sell copies of the Software, and to permit persons to whom the
15+
* Software is furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
* DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#define GMMU_FMT_MAX_LEVELS 6U
30+
31+
#define NV90F1_CTRL_CMD_VASPACE_COPY_SERVER_RESERVED_PDES (0x90f10106U) /* finn: Evaluated from "(FINN_FERMI_VASPACE_A_VASPACE_INTERFACE_ID << 8) | NV90F1_CTRL_VASPACE_COPY_SERVER_RESERVED_PDES_PARAMS_MESSAGE_ID" */
32+
33+
typedef struct NV90F1_CTRL_VASPACE_COPY_SERVER_RESERVED_PDES_PARAMS {
34+
/*!
35+
* [in] GPU sub-device handle - this API only supports unicast.
36+
* Pass 0 to use subDeviceId instead.
37+
*/
38+
NvHandle hSubDevice;
39+
40+
/*!
41+
* [in] GPU sub-device ID. Ignored if hSubDevice is non-zero.
42+
*/
43+
NvU32 subDeviceId;
44+
45+
/*!
46+
* [in] Page size (VA coverage) of the level to reserve.
47+
* This need not be a leaf (page table) page size - it can be
48+
* the coverage of an arbitrary level (including root page directory).
49+
*/
50+
NV_DECLARE_ALIGNED(NvU64 pageSize, 8);
51+
52+
/*!
53+
* [in] First GPU virtual address of the range to reserve.
54+
* This must be aligned to pageSize.
55+
*/
56+
NV_DECLARE_ALIGNED(NvU64 virtAddrLo, 8);
57+
58+
/*!
59+
* [in] Last GPU virtual address of the range to reserve.
60+
* This (+1) must be aligned to pageSize.
61+
*/
62+
NV_DECLARE_ALIGNED(NvU64 virtAddrHi, 8);
63+
64+
/*!
65+
* [in] Number of PDE levels to copy.
66+
*/
67+
NvU32 numLevelsToCopy;
68+
69+
/*!
70+
* [in] Per-level information.
71+
*/
72+
struct {
73+
/*!
74+
* Physical address of this page level instance.
75+
*/
76+
NV_DECLARE_ALIGNED(NvU64 physAddress, 8);
77+
78+
/*!
79+
* Size in bytes allocated for this level instance.
80+
*/
81+
NV_DECLARE_ALIGNED(NvU64 size, 8);
82+
83+
/*!
84+
* Aperture in which this page level instance resides.
85+
*/
86+
NvU32 aperture;
87+
88+
/*!
89+
* Page shift corresponding to the level
90+
*/
91+
NvU8 pageShift;
92+
} levels[GMMU_FMT_MAX_LEVELS];
93+
} NV90F1_CTRL_VASPACE_COPY_SERVER_RESERVED_PDES_PARAMS;
94+
95+
#endif
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#ifndef __src_common_sdk_nvidia_inc_nvos_h__
2+
#define __src_common_sdk_nvidia_inc_nvos_h__
3+
4+
/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */
5+
6+
/*
7+
* SPDX-FileCopyrightText: Copyright (c) 1993-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
8+
* SPDX-License-Identifier: MIT
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a
11+
* copy of this software and associated documentation files (the "Software"),
12+
* to deal in the Software without restriction, including without limitation
13+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
* and/or sell copies of the Software, and to permit persons to whom the
15+
* Software is furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
* DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#define NVOS02_FLAGS_PHYSICALITY 7:4
30+
#define NVOS02_FLAGS_PHYSICALITY_CONTIGUOUS (0x00000000)
31+
#define NVOS02_FLAGS_PHYSICALITY_NONCONTIGUOUS (0x00000001)
32+
#define NVOS02_FLAGS_LOCATION 11:8
33+
#define NVOS02_FLAGS_LOCATION_PCI (0x00000000)
34+
#define NVOS02_FLAGS_LOCATION_AGP (0x00000001)
35+
#define NVOS02_FLAGS_LOCATION_VIDMEM (0x00000002)
36+
#define NVOS02_FLAGS_COHERENCY 15:12
37+
#define NVOS02_FLAGS_COHERENCY_UNCACHED (0x00000000)
38+
#define NVOS02_FLAGS_COHERENCY_CACHED (0x00000001)
39+
#define NVOS02_FLAGS_COHERENCY_WRITE_COMBINE (0x00000002)
40+
#define NVOS02_FLAGS_COHERENCY_WRITE_THROUGH (0x00000003)
41+
#define NVOS02_FLAGS_COHERENCY_WRITE_PROTECT (0x00000004)
42+
#define NVOS02_FLAGS_COHERENCY_WRITE_BACK (0x00000005)
43+
#define NVOS02_FLAGS_ALLOC 17:16
44+
#define NVOS02_FLAGS_ALLOC_NONE (0x00000001)
45+
#define NVOS02_FLAGS_GPU_CACHEABLE 18:18
46+
#define NVOS02_FLAGS_GPU_CACHEABLE_NO (0x00000000)
47+
#define NVOS02_FLAGS_GPU_CACHEABLE_YES (0x00000001)
48+
49+
#define NVOS02_FLAGS_KERNEL_MAPPING 19:19
50+
#define NVOS02_FLAGS_KERNEL_MAPPING_NO_MAP (0x00000000)
51+
#define NVOS02_FLAGS_KERNEL_MAPPING_MAP (0x00000001)
52+
#define NVOS02_FLAGS_ALLOC_NISO_DISPLAY 20:20
53+
#define NVOS02_FLAGS_ALLOC_NISO_DISPLAY_NO (0x00000000)
54+
#define NVOS02_FLAGS_ALLOC_NISO_DISPLAY_YES (0x00000001)
55+
56+
#define NVOS02_FLAGS_ALLOC_USER_READ_ONLY 21:21
57+
#define NVOS02_FLAGS_ALLOC_USER_READ_ONLY_NO (0x00000000)
58+
#define NVOS02_FLAGS_ALLOC_USER_READ_ONLY_YES (0x00000001)
59+
60+
#define NVOS02_FLAGS_ALLOC_DEVICE_READ_ONLY 22:22
61+
#define NVOS02_FLAGS_ALLOC_DEVICE_READ_ONLY_NO (0x00000000)
62+
#define NVOS02_FLAGS_ALLOC_DEVICE_READ_ONLY_YES (0x00000001)
63+
64+
#define NVOS02_FLAGS_PEER_MAP_OVERRIDE 23:23
65+
#define NVOS02_FLAGS_PEER_MAP_OVERRIDE_DEFAULT (0x00000000)
66+
#define NVOS02_FLAGS_PEER_MAP_OVERRIDE_REQUIRED (0x00000001)
67+
68+
#define NVOS02_FLAGS_ALLOC_TYPE_SYNCPOINT 24:24
69+
#define NVOS02_FLAGS_ALLOC_TYPE_SYNCPOINT_APERTURE (0x00000001)
70+
71+
#define NVOS02_FLAGS_MEMORY_PROTECTION 26:25
72+
#define NVOS02_FLAGS_MEMORY_PROTECTION_DEFAULT (0x00000000)
73+
#define NVOS02_FLAGS_MEMORY_PROTECTION_PROTECTED (0x00000001)
74+
#define NVOS02_FLAGS_MEMORY_PROTECTION_UNPROTECTED (0x00000002)
75+
76+
#define NVOS02_FLAGS_MAPPING 31:30
77+
#define NVOS02_FLAGS_MAPPING_DEFAULT (0x00000000)
78+
#define NVOS02_FLAGS_MAPPING_NO_MAP (0x00000001)
79+
#define NVOS02_FLAGS_MAPPING_NEVER_MAP (0x00000002)
80+
81+
typedef struct
82+
{
83+
NvU32 index;
84+
NvV32 flags;
85+
NvU64 vaSize NV_ALIGN_BYTES(8);
86+
NvU64 vaStartInternal NV_ALIGN_BYTES(8);
87+
NvU64 vaLimitInternal NV_ALIGN_BYTES(8);
88+
NvU32 bigPageSize;
89+
NvU64 vaBase NV_ALIGN_BYTES(8);
90+
} NV_VASPACE_ALLOCATION_PARAMETERS;
91+
92+
#define NV_VASPACE_ALLOCATION_INDEX_GPU_NEW 0x00 //<! Create new VASpace, by default
93+
94+
#endif
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef __src_nvidia_generated_g_fbsr_nvoc_h__
2+
#define __src_nvidia_generated_g_fbsr_nvoc_h__
3+
4+
/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */
5+
6+
/*
7+
* SPDX-FileCopyrightText: Copyright (c) 2009-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
8+
* SPDX-License-Identifier: MIT
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a
11+
* copy of this software and associated documentation files (the "Software"),
12+
* to deal in the Software without restriction, including without limitation
13+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
* and/or sell copies of the Software, and to permit persons to whom the
15+
* Software is furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
* DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#define FBSR_TYPE_DMA 4 // Copy using DMA. Fastest.
30+
31+
#endif

0 commit comments

Comments
 (0)