Codebase list nvidia-persistenced / upstream/470.63.01
Import upstream version 470.63.01 Debian Janitor 2 years ago
9 changed file(s) with 173 addition(s) and 62 deletion(s). Raw diff Collapse all Expand all
5757 RPC_DIR ?= .
5858 NVIDIA_CFG_DIR ?= .
5959 NVIDIA_NUMA_DIR ?= .
60 NV_IOCTL_INC_DIR ?= .
6061
6162 ##############################################################################
6263 # The common-utils directory may be in one of two places: either elsewhere in
8384 common_cflags += -I $(COMMON_UTILS_DIR)
8485 common_cflags += -I $(NVIDIA_CFG_DIR)
8586 common_cflags += -I $(NVIDIA_NUMA_DIR)
87 common_cflags += -I $(NV_IOCTL_INC_DIR)
8688 common_cflags += -I $(RPC_DIR)
8789 common_cflags += -I $(OUTPUTDIR)
8890 common_cflags += -I .
3030
3131 static void print_option(const NVGetoptOption *o)
3232 {
33 char scratch[64], *s;
33 char scratch[64];
34 const char *s;
3435 int j, len;
3536
3637 int italics, bold, omitWhiteSpace, firstchar;
116116 const char *name;
117117 int val;
118118 unsigned int flags;
119 char *arg_name; /* not used by nvgetopt() */
120 char *description; /* not used by nvgetopt() */
119 const char *arg_name; /* not used by nvgetopt() */
120 const char *description; /* not used by nvgetopt() */
121121 } NVGetoptOption;
122122
123123
0 /*
1 * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
20 */
21
22
23 #ifndef NV_IOCTL_NUMA_H
24 #define NV_IOCTL_NUMA_H
25
26 #if defined(NV_LINUX)
27
28 #include <nv-ioctl-numbers.h>
29
30 #if defined(NV_KERNEL_INTERFACE_LAYER)
31
32 #include <linux/types.h>
33
34 #else
35
36 #include <stdint.h>
37
38 #if !defined(__aligned)
39 #define __aligned(n) __attribute__((aligned(n)))
40 #endif
41
42 #endif
43
44 #define NV_ESC_NUMA_INFO (NV_IOCTL_BASE + 15)
45 #define NV_ESC_SET_NUMA_STATUS (NV_IOCTL_BASE + 16)
46
47 #define NV_IOCTL_NUMA_INFO_MAX_OFFLINE_ADDRESSES 64
48 typedef struct offline_addresses
49 {
50 uint64_t addresses[NV_IOCTL_NUMA_INFO_MAX_OFFLINE_ADDRESSES] __aligned(8);
51 uint32_t numEntries;
52 } nv_offline_addresses_t;
53
54
55 /* per-device NUMA memory info as assigned by the system */
56 typedef struct nv_ioctl_numa_info
57 {
58 int32_t nid;
59 int32_t status;
60 uint64_t memblock_size __aligned(8);
61 uint64_t numa_mem_addr __aligned(8);
62 uint64_t numa_mem_size __aligned(8);
63 nv_offline_addresses_t offline_addresses __aligned(8);
64 } nv_ioctl_numa_info_t;
65
66 /* set the status of the device NUMA memory */
67 typedef struct nv_ioctl_set_numa_status
68 {
69 int32_t status;
70 } nv_ioctl_set_numa_status_t;
71
72 #define NV_IOCTL_NUMA_STATUS_DISABLED 0
73 #define NV_IOCTL_NUMA_STATUS_OFFLINE 1
74 #define NV_IOCTL_NUMA_STATUS_ONLINE_IN_PROGRESS 2
75 #define NV_IOCTL_NUMA_STATUS_ONLINE 3
76 #define NV_IOCTL_NUMA_STATUS_ONLINE_FAILED 4
77 #define NV_IOCTL_NUMA_STATUS_OFFLINE_IN_PROGRESS 5
78 #define NV_IOCTL_NUMA_STATUS_OFFLINE_FAILED 6
79
80 #endif
81
82 #endif
0 /*
1 * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
20 */
21
22
23 #ifndef NV_IOCTL_NUMBERS_H
24 #define NV_IOCTL_NUMBERS_H
25
26 /* NOTE: using an ioctl() number > 55 will overflow! */
27 #define NV_IOCTL_MAGIC 'F'
28 #define NV_IOCTL_BASE 200
29 #define NV_ESC_CARD_INFO (NV_IOCTL_BASE + 0)
30 #define NV_ESC_REGISTER_FD (NV_IOCTL_BASE + 1)
31 #define NV_ESC_ALLOC_OS_EVENT (NV_IOCTL_BASE + 6)
32 #define NV_ESC_FREE_OS_EVENT (NV_IOCTL_BASE + 7)
33 #define NV_ESC_STATUS_CODE (NV_IOCTL_BASE + 9)
34 #define NV_ESC_CHECK_VERSION_STR (NV_IOCTL_BASE + 10)
35 #define NV_ESC_IOCTL_XFER_CMD (NV_IOCTL_BASE + 11)
36 #define NV_ESC_ATTACH_GPUS_TO_FD (NV_IOCTL_BASE + 12)
37 #define NV_ESC_QUERY_DEVICE_INTR (NV_IOCTL_BASE + 13)
38 #define NV_ESC_SYS_PARAMS (NV_IOCTL_BASE + 14)
39
40 #endif
3737 #include <errno.h>
3838
3939 #include "common-utils.h"
40 #include "nv-ioctl-numa.h"
4041 #include "nvidia-numa.h"
4142
4243 #define NV_DEVICE_INFO_PATH_FMT \
5657 #define STATE_ONLINE "online"
5758 #define VALID_MOVABLE_STATE "Movable"
5859
59 #define NV_IOCTL_MAGIC 'F'
60 #define NV_IOCTL_BASE 200
61 #define NV_ESC_NUMA_INFO (NV_IOCTL_BASE + 15)
62 #define NV_ESC_SET_NUMA_STATUS (NV_IOCTL_BASE + 16)
63
6460 #ifndef NV_IS_ALIGNED
6561 #define NV_IS_ALIGNED(v, gran) (0 == ((v) & ((gran) - 1)))
6662 #endif
63
64 typedef int mem_state_t;
6765
6866 static inline char* mem_state_to_string(mem_state_t state)
6967 {
487485 }
488486
489487 static
490 int offline_blacklisted_pages(nv_blacklist_addresses_t *blacklist_addresses)
488 int offline_blacklisted_pages(nv_offline_addresses_t *blacklist_addresses)
491489 {
492490 int index;
493491 int status = 0;
885883 }
886884
887885 set_driver_status:
888 status = offline_blacklisted_pages(&numa_info_params.blacklist_addresses);
886 status = offline_blacklisted_pages(&numa_info_params.offline_addresses);
889887 if (status < 0) {
890888 syslog_device(device_pci_info,
891889 LOG_ERR,
2525 #include "nvpd_rpc.h"
2626 #include "nvidia-syslog-utils.h"
2727
28 #define NV_IOCTL_NUMA_INFO_MAX_BLACKLIST_ADDRESSES 64
29
30 typedef enum
31 {
32 NV_IOCTL_NUMA_STATUS_DISABLED = 0,
33 NV_IOCTL_NUMA_STATUS_OFFLINE = 1,
34 NV_IOCTL_NUMA_STATUS_ONLINE_IN_PROGRESS = 2,
35 NV_IOCTL_NUMA_STATUS_ONLINE = 3,
36 NV_IOCTL_NUMA_STATUS_ONLINE_FAILED = 4,
37 NV_IOCTL_NUMA_STATUS_OFFLINE_IN_PROGRESS = 5,
38 NV_IOCTL_NUMA_STATUS_OFFLINE_FAILED = 6
39 } mem_state_t;
40
41 /* system parameters that the kernel driver may use for configuration */
42 typedef struct nv_ioctl_sys_params
43 {
44 uint64_t memblock_size;
45 } nv_ioctl_sys_params_t;
46
47 /* list of device blacklisted addresses */
48 typedef struct blacklist_addresses
49 {
50 uint64_t addresses[NV_IOCTL_NUMA_INFO_MAX_BLACKLIST_ADDRESSES];
51 uint32_t numEntries;
52 } nv_blacklist_addresses_t;
53
54 /* per-device NUMA memory info as assigned by the system */
55 typedef struct nv_ioctl_numa_info
56 {
57 int nid;
58 int status;
59 uint64_t memblock_size;
60 uint64_t numa_mem_addr;
61 uint64_t numa_mem_size;
62 nv_blacklist_addresses_t blacklist_addresses;
63 } nv_ioctl_numa_info_t;
64
65 /* set the status of the device NUMA memory */
66 typedef struct nv_ioctl_set_numa_status
67 {
68 int status;
69 } nv_ioctl_set_numa_status_t;
70
7128 /* per-device NUMA context */
7229 typedef struct
7330 {
3232 ##############################################################################
3333
3434 CC ?= gcc
35 CXX ?= g++
3536 LD ?= ld
3637 AR ?= ar
37 # only set these warnings and optimizations if CFLAGS is unset
38 CFLAGS ?= -Wall -O2
38 # only set these warnings if CFLAGS is unset
39 CFLAGS ?= -Wall
3940 # always set these -f CFLAGS
4041 CFLAGS += -fno-strict-aliasing -fno-omit-frame-pointer -Wformat=2
4142 CC_ONLY_CFLAGS ?=
5758 HOST_CC_ONLY_CFLAGS += -Wno-format-zero-length
5859 HOST_CFLAGS += -Wno-unused-parameter
5960
61 DEBUG ?=
62 DEVELOP ?=
63
6064 ifeq ($(DEBUG),1)
6165 STRIP_CMD ?= true
6266 DO_STRIP ?=
6367 CFLAGS += -O0 -g
6468 CFLAGS += -DDEBUG=1
6569 else
66 STRIP_CMD ?= strip
67 DO_STRIP ?= 1
68 endif
70 CFLAGS += -O2
71 endif
72
73 ifeq ($(DEVELOP),1)
74 STRIP_CMD ?= true
75 DO_STRIP ?=
76 CFLAGS += -DDEVELOP=1
77 endif
78
79 STRIP_CMD ?= strip
80 DO_STRIP ?= 1
6981
7082 INSTALL ?= install
7183 INSTALL_BIN_ARGS ?= -m 755
185197
186198
187199 ##############################################################################
200 # Test passing $(1) to $(CC). If $(CC) succeeds, then echo $(1).
201 #
202 # Because this uses $(shell), it is best to use this to assign simply expanded
203 # variables (e.g., ":=").
204 #
205 # Example usage:
206 # CONDITIONAL_CFLAGS := $(call TEST_CC_ARG, -ffoo)
207 ##############################################################################
208
209 TEST_CC_ARG = \
210 $(shell $(CC) -c -x c /dev/null $(1) -o /dev/null > /dev/null 2>&1 && \
211 $(ECHO) $(1))
212
213
214 ##############################################################################
188215 # define variables used when installing the open source utilities from
189216 # the source tarball
190217 ##############################################################################
275302
276303 ifeq ($(NV_AUTO_DEPEND),1)
277304 AUTO_DEP_SUFFIX = -MMD -MF $$(@:.o=.d.to_be_processed) -MP -MT $$@ && \
278 $$(SED) -e "1,3s@ $$< @ @" < $$(@:.o=.d.to_be_processed) > $$(@:.o=.d)
305 $$(SED) -e "1,3s| $$< | |" < $$(@:.o=.d.to_be_processed) > $$(@:.o=.d)
279306 else
280307 AUTO_DEP_SUFFIX =
281308 endif
485512 define GENERATE_NVIDSTRING
486513 # g_nvid_string.c depends on all objects except g_nvid_string.o, and version.mk
487514 $(NVIDSTRING): $$(filter-out $$(call BUILD_OBJECT_LIST,$$(NVIDSTRING)), $(3)) $$(VERSION_MK)
488 @$$(ECHO) "const char $(1)[] = \"nvidia id: NVIDIA $$(strip $(2)) for $$(TARGET_ARCH) $$(NVIDIA_VERSION) $$(NVIDSTRING_BUILD_TYPE_STRING) (`$$(WHOAMI)`@`$$(HOSTNAME)`) `$$(DATE)`\";" > $$@
489 @$$(ECHO) "const char *const p$$(strip $(1)) = $(1) + 11;" >> $$@;
515 $(at_if_quiet)$$(MKDIR) $$(dir $$@)
516 $(at_if_quiet)$$(ECHO) "const char $(1)[] = \"nvidia id: NVIDIA $$(strip $(2)) for $$(TARGET_ARCH) $$(NVIDIA_VERSION) $$(NVIDSTRING_BUILD_TYPE_STRING) (`$$(WHOAMI)`@`$$(HOSTNAME)`) `$$(DATE)`\";" > $$@
517 $(at_if_quiet)$$(ECHO) "const char *const p$$(strip $(1)) = $(1) + 11;" >> $$@;
490518 endef
491519
492520
509537
510538 define READ_ONLY_OBJECT_FROM_FILE_RULE
511539 $$(OUTPUTDIR)/$$(notdir $(1)).o: $(1)
540 $(at_if_quiet)$$(MKDIR) $$(OUTPUTDIR)
512541 $(at_if_quiet)cd $$(dir $(1)); \
513542 $$(call quiet_cmd_no_at,LD) -r -z noexecstack --format=binary \
514543 $$(notdir $(1)) -o $$(OUTPUTDIR_ABSOLUTE)/$$(notdir $$@)
0 NVIDIA_VERSION = 460.32.03
0 NVIDIA_VERSION = 470.63.01
11
22 # This file.
33 VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST))