Import upstream version 470.63.01
Debian Janitor
2 years ago
57 | 57 | RPC_DIR ?= . |
58 | 58 | NVIDIA_CFG_DIR ?= . |
59 | 59 | NVIDIA_NUMA_DIR ?= . |
60 | NV_IOCTL_INC_DIR ?= . | |
60 | 61 | |
61 | 62 | ############################################################################## |
62 | 63 | # The common-utils directory may be in one of two places: either elsewhere in |
83 | 84 | common_cflags += -I $(COMMON_UTILS_DIR) |
84 | 85 | common_cflags += -I $(NVIDIA_CFG_DIR) |
85 | 86 | common_cflags += -I $(NVIDIA_NUMA_DIR) |
87 | common_cflags += -I $(NV_IOCTL_INC_DIR) | |
86 | 88 | common_cflags += -I $(RPC_DIR) |
87 | 89 | common_cflags += -I $(OUTPUTDIR) |
88 | 90 | common_cflags += -I . |
30 | 30 | |
31 | 31 | static void print_option(const NVGetoptOption *o) |
32 | 32 | { |
33 | char scratch[64], *s; | |
33 | char scratch[64]; | |
34 | const char *s; | |
34 | 35 | int j, len; |
35 | 36 | |
36 | 37 | int italics, bold, omitWhiteSpace, firstchar; |
116 | 116 | const char *name; |
117 | 117 | int val; |
118 | 118 | 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() */ | |
121 | 121 | } NVGetoptOption; |
122 | 122 | |
123 | 123 |
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 |
37 | 37 | #include <errno.h> |
38 | 38 | |
39 | 39 | #include "common-utils.h" |
40 | #include "nv-ioctl-numa.h" | |
40 | 41 | #include "nvidia-numa.h" |
41 | 42 | |
42 | 43 | #define NV_DEVICE_INFO_PATH_FMT \ |
56 | 57 | #define STATE_ONLINE "online" |
57 | 58 | #define VALID_MOVABLE_STATE "Movable" |
58 | 59 | |
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 | ||
64 | 60 | #ifndef NV_IS_ALIGNED |
65 | 61 | #define NV_IS_ALIGNED(v, gran) (0 == ((v) & ((gran) - 1))) |
66 | 62 | #endif |
63 | ||
64 | typedef int mem_state_t; | |
67 | 65 | |
68 | 66 | static inline char* mem_state_to_string(mem_state_t state) |
69 | 67 | { |
487 | 485 | } |
488 | 486 | |
489 | 487 | static |
490 | int offline_blacklisted_pages(nv_blacklist_addresses_t *blacklist_addresses) | |
488 | int offline_blacklisted_pages(nv_offline_addresses_t *blacklist_addresses) | |
491 | 489 | { |
492 | 490 | int index; |
493 | 491 | int status = 0; |
885 | 883 | } |
886 | 884 | |
887 | 885 | set_driver_status: |
888 | status = offline_blacklisted_pages(&numa_info_params.blacklist_addresses); | |
886 | status = offline_blacklisted_pages(&numa_info_params.offline_addresses); | |
889 | 887 | if (status < 0) { |
890 | 888 | syslog_device(device_pci_info, |
891 | 889 | LOG_ERR, |
25 | 25 | #include "nvpd_rpc.h" |
26 | 26 | #include "nvidia-syslog-utils.h" |
27 | 27 | |
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 | ||
71 | 28 | /* per-device NUMA context */ |
72 | 29 | typedef struct |
73 | 30 | { |
32 | 32 | ############################################################################## |
33 | 33 | |
34 | 34 | CC ?= gcc |
35 | CXX ?= g++ | |
35 | 36 | LD ?= ld |
36 | 37 | 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 | |
39 | 40 | # always set these -f CFLAGS |
40 | 41 | CFLAGS += -fno-strict-aliasing -fno-omit-frame-pointer -Wformat=2 |
41 | 42 | CC_ONLY_CFLAGS ?= |
57 | 58 | HOST_CC_ONLY_CFLAGS += -Wno-format-zero-length |
58 | 59 | HOST_CFLAGS += -Wno-unused-parameter |
59 | 60 | |
61 | DEBUG ?= | |
62 | DEVELOP ?= | |
63 | ||
60 | 64 | ifeq ($(DEBUG),1) |
61 | 65 | STRIP_CMD ?= true |
62 | 66 | DO_STRIP ?= |
63 | 67 | CFLAGS += -O0 -g |
64 | 68 | CFLAGS += -DDEBUG=1 |
65 | 69 | 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 | |
69 | 81 | |
70 | 82 | INSTALL ?= install |
71 | 83 | INSTALL_BIN_ARGS ?= -m 755 |
185 | 197 | |
186 | 198 | |
187 | 199 | ############################################################################## |
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 | ############################################################################## | |
188 | 215 | # define variables used when installing the open source utilities from |
189 | 216 | # the source tarball |
190 | 217 | ############################################################################## |
275 | 302 | |
276 | 303 | ifeq ($(NV_AUTO_DEPEND),1) |
277 | 304 | 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) | |
279 | 306 | else |
280 | 307 | AUTO_DEP_SUFFIX = |
281 | 308 | endif |
485 | 512 | define GENERATE_NVIDSTRING |
486 | 513 | # g_nvid_string.c depends on all objects except g_nvid_string.o, and version.mk |
487 | 514 | $(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;" >> $$@; | |
490 | 518 | endef |
491 | 519 | |
492 | 520 | |
509 | 537 | |
510 | 538 | define READ_ONLY_OBJECT_FROM_FILE_RULE |
511 | 539 | $$(OUTPUTDIR)/$$(notdir $(1)).o: $(1) |
540 | $(at_if_quiet)$$(MKDIR) $$(OUTPUTDIR) | |
512 | 541 | $(at_if_quiet)cd $$(dir $(1)); \ |
513 | 542 | $$(call quiet_cmd_no_at,LD) -r -z noexecstack --format=binary \ |
514 | 543 | $$(notdir $(1)) -o $$(OUTPUTDIR_ABSOLUTE)/$$(notdir $$@) |