Commit 5c3bd454 authored by Liam Middlebrook's avatar Liam Middlebrook

410.57

parent 29fa64b7
...@@ -72,8 +72,6 @@ MODPROBE_UTILS_DIR ?= modprobe-utils ...@@ -72,8 +72,6 @@ MODPROBE_UTILS_DIR ?= modprobe-utils
# include the list of source files; defines SRC # include the list of source files; defines SRC
include dist-files.mk include dist-files.mk
SRC += $(STAMP_C)
include $(COMMON_UTILS_DIR)/src.mk include $(COMMON_UTILS_DIR)/src.mk
SRC += $(addprefix $(COMMON_UTILS_DIR)/,$(COMMON_UTILS_SRC)) SRC += $(addprefix $(COMMON_UTILS_DIR)/,$(COMMON_UTILS_SRC))
...@@ -121,11 +119,8 @@ $(NVIDIA_MODPROBE).unstripped: $(OBJS) ...@@ -121,11 +119,8 @@ $(NVIDIA_MODPROBE).unstripped: $(OBJS)
# define the rule to build each object file # define the rule to build each object file
$(foreach src,$(SRC),$(eval $(call DEFINE_OBJECT_RULE,TARGET,$(src)))) $(foreach src,$(SRC),$(eval $(call DEFINE_OBJECT_RULE,TARGET,$(src))))
# define the rule to generate $(STAMP_C)
$(eval $(call DEFINE_STAMP_C_RULE, $(OBJS),$(NVIDIA_MODPROBE_PROGRAM_NAME)))
clean clobber: clean clobber:
rm -rf $(NVIDIA_MODPROBE) $(MANPAGE) *~ $(STAMP_C) \ rm -rf $(NVIDIA_MODPROBE) $(MANPAGE) *~ \
$(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d \ $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d \
$(GEN_MANPAGE_OPTS) $(OPTIONS_1_INC) $(GEN_MANPAGE_OPTS) $(OPTIONS_1_INC)
......
...@@ -132,4 +132,6 @@ typedef enum { ...@@ -132,4 +132,6 @@ typedef enum {
NV_OPTIONAL_BOOL_TRUE = TRUE NV_OPTIONAL_BOOL_TRUE = TRUE
} NVOptionalBool; } NVOptionalBool;
#define NV_ID_STRING PROGRAM_NAME ": version " NVIDIA_VERSION
#endif /* __COMMON_UTILS_H__ */ #endif /* __COMMON_UTILS_H__ */
...@@ -67,6 +67,9 @@ ...@@ -67,6 +67,9 @@
#define NV_NVLINK_MODULE_NAME "nvidia-nvlink" #define NV_NVLINK_MODULE_NAME "nvidia-nvlink"
#define NV_NVLINK_PROC_PERM_PATH "/proc/driver/nvidia-nvlink/permissions" #define NV_NVLINK_PROC_PERM_PATH "/proc/driver/nvidia-nvlink/permissions"
#define NV_NVSWITCH_MODULE_NAME "nvidia-nvswitch"
#define NV_NVSWITCH_PROC_PERM_PATH "/proc/driver/nvidia-nvswitch/permissions"
#define NV_DEVICE_FILE_MODE_MASK (S_IRWXU|S_IRWXG|S_IRWXO) #define NV_DEVICE_FILE_MODE_MASK (S_IRWXU|S_IRWXG|S_IRWXO)
#define NV_DEVICE_FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) #define NV_DEVICE_FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
#define NV_DEVICE_FILE_UID 0 #define NV_DEVICE_FILE_UID 0
...@@ -396,18 +399,20 @@ static int modprobe_helper(const int print_errors, const char *module_name) ...@@ -396,18 +399,20 @@ static int modprobe_helper(const int print_errors, const char *module_name)
return 0; return 0;
default: default:
if (waitpid(pid, &status, 0) < 0) /*
{ * waitpid(2) is not always guaranteed to return success even if
return 0; * the child terminated normally. For example, if the process
} * explicitly configured the handling of the SIGCHLD signal
if (WIFEXITED(status) && WEXITSTATUS(status) == 0) * to SIG_IGN, then waitpid(2) will instead block until all
{ * children terminate and return the error ECHILD, regardless
return 1; * of the child's exit codes.
} *
else * Hence, ignore waitpid(2) error codes and instead check
{ * whether the desired kernel module is loaded.
return 0; */
} waitpid(pid, NULL, 0);
return is_kernel_module_loaded(module_name);
} }
return 1; return 1;
...@@ -548,8 +553,8 @@ int nvidia_get_file_state(int minor, int module_instance) ...@@ -548,8 +553,8 @@ int nvidia_get_file_state(int minor, int module_instance)
* permissions. Returns 1 if the file is successfully created; returns 0 * permissions. Returns 1 if the file is successfully created; returns 0
* if the file could not be created. * if the file could not be created.
*/ */
int mknod_helper(int major, int minor, const char *path, static int mknod_helper(int major, int minor, const char *path,
const char *proc_path) const char *proc_path)
{ {
dev_t dev = NV_MAKE_DEVICE(major, minor); dev_t dev = NV_MAKE_DEVICE(major, minor);
mode_t mode; mode_t mode;
...@@ -659,7 +664,7 @@ int nvidia_mknod(int minor, int module_instance) ...@@ -659,7 +664,7 @@ int nvidia_mknod(int minor, int module_instance)
* device with the specified name. Returns the major number on success, * device with the specified name. Returns the major number on success,
* or -1 on failure. * or -1 on failure.
*/ */
int get_chardev_major(const char *name) static int get_chardev_major(const char *name)
{ {
int ret = -1; int ret = -1;
char line[NV_MAX_LINE_LENGTH]; char line[NV_MAX_LINE_LENGTH];
...@@ -796,11 +801,47 @@ int nvidia_nvlink_mknod(void) ...@@ -796,11 +801,47 @@ int nvidia_nvlink_mknod(void)
NV_NVLINK_PROC_PERM_PATH); NV_NVLINK_PROC_PERM_PATH);
} }
/*
* Attempt to create the NVIDIA NVSwitch driver device files.
*/
int nvidia_nvswitch_mknod(int minor)
{
int major = 0;
char name[NV_MAX_CHARACTER_DEVICE_FILE_STRLEN];
int ret;
major = get_chardev_major(NV_NVSWITCH_MODULE_NAME);
if (major < 0)
{
return 0;
}
if (minor == NV_NVSWITCH_CTL_MINOR)
{
ret = snprintf(name, NV_MAX_CHARACTER_DEVICE_FILE_STRLEN,
NV_NVSWITCH_CTL_NAME);
}
else
{
ret = snprintf(name, NV_MAX_CHARACTER_DEVICE_FILE_STRLEN,
NV_NVSWITCH_DEVICE_NAME, minor);
}
if (ret <= 0)
{
return 0;
}
return mknod_helper(major, minor, name, NV_NVSWITCH_PROC_PERM_PATH);
}
int nvidia_vgpu_vfio_mknod(int minor_num) int nvidia_vgpu_vfio_mknod(int minor_num)
{ {
int major = get_chardev_major(NV_VGPU_VFIO_MODULE_NAME); int major = get_chardev_major(NV_VGPU_VFIO_MODULE_NAME);
char vgpu_dev_name[NV_MAX_CHARACTER_DEVICE_FILE_STRLEN]; char vgpu_dev_name[NV_MAX_CHARACTER_DEVICE_FILE_STRLEN];
char proc_path[NV_MAX_PROC_REGISTRY_PATH_SIZE]; char proc_path[NV_MAX_PROC_REGISTRY_PATH_SIZE];
int ret;
if (major < 0) if (major < 0)
{ {
...@@ -809,8 +850,12 @@ int nvidia_vgpu_vfio_mknod(int minor_num) ...@@ -809,8 +850,12 @@ int nvidia_vgpu_vfio_mknod(int minor_num)
assign_proc_registry_path(proc_path, NV_MODULE_INSTANCE_NONE); assign_proc_registry_path(proc_path, NV_MODULE_INSTANCE_NONE);
snprintf(vgpu_dev_name, NV_MAX_CHARACTER_DEVICE_FILE_STRLEN, ret = snprintf(vgpu_dev_name, NV_MAX_CHARACTER_DEVICE_FILE_STRLEN,
NV_VGPU_VFIO_DEVICE_NAME, minor_num); NV_VGPU_VFIO_DEVICE_NAME, minor_num);
if (ret <= 0)
{
return 0;
}
vgpu_dev_name[NV_MAX_CHARACTER_DEVICE_FILE_STRLEN - 1] = '\0'; vgpu_dev_name[NV_MAX_CHARACTER_DEVICE_FILE_STRLEN - 1] = '\0';
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#define NV_MAX_MODULE_INSTANCES 8 #define NV_MAX_MODULE_INSTANCES 8
#define NV_CTL_DEVICE_NUM 255 #define NV_CTL_DEVICE_NUM 255
#define NV_MODESET_MINOR_DEVICE_NUM 254 #define NV_MODESET_MINOR_DEVICE_NUM 254
#define NV_NVSWITCH_CTL_MINOR 255
#define NV_FRONTEND_CONTROL_DEVICE_MINOR_MAX NV_CTL_DEVICE_NUM #define NV_FRONTEND_CONTROL_DEVICE_MINOR_MAX NV_CTL_DEVICE_NUM
...@@ -44,6 +45,8 @@ ...@@ -44,6 +45,8 @@
#define NV_MODESET_DEVICE_NAME "/dev/nvidia-modeset" #define NV_MODESET_DEVICE_NAME "/dev/nvidia-modeset"
#define NV_VGPU_VFIO_DEVICE_NAME "/dev/nvidia-vgpu%d" #define NV_VGPU_VFIO_DEVICE_NAME "/dev/nvidia-vgpu%d"
#define NV_NVLINK_DEVICE_NAME "/dev/nvidia-nvlink" #define NV_NVLINK_DEVICE_NAME "/dev/nvidia-nvlink"
#define NV_NVSWITCH_CTL_NAME "/dev/nvidia-nvswitchctl"
#define NV_NVSWITCH_DEVICE_NAME "/dev/nvidia-nvswitch%d"
#define NV_NMODULE_CTRL_DEVICE_FILE_PATH "/dev/nvidiactl%d" #define NV_NMODULE_CTRL_DEVICE_FILE_PATH "/dev/nvidiactl%d"
...@@ -85,9 +88,7 @@ int nvidia_modeset_modprobe(void); ...@@ -85,9 +88,7 @@ int nvidia_modeset_modprobe(void);
int nvidia_modeset_mknod(void); int nvidia_modeset_mknod(void);
int nvidia_vgpu_vfio_mknod(int minor_num); int nvidia_vgpu_vfio_mknod(int minor_num);
int nvidia_nvlink_mknod(void); int nvidia_nvlink_mknod(void);
int nvidia_nvswitch_mknod(int minor);
int mknod_helper(int major, int minor, const char *path, const char *proc_path);
int get_chardev_major(const char *name);
#endif /* NV_LINUX */ #endif /* NV_LINUX */
......
...@@ -44,13 +44,10 @@ ...@@ -44,13 +44,10 @@
#include "common-utils.h" #include "common-utils.h"
#include "msg.h" #include "msg.h"
extern const char *pNV_ID;
static void print_version(void) static void print_version(void)
{ {
nv_info_msg(NULL, ""); nv_info_msg(NULL, "");
nv_info_msg(NULL, "%s", pNV_ID); nv_info_msg(NULL, "%s", NV_ID_STRING);
nv_info_msg(NULL, ""); nv_info_msg(NULL, "");
} }
......
...@@ -74,9 +74,7 @@ PRINTF ?= printf ...@@ -74,9 +74,7 @@ PRINTF ?= printf
MKDIR ?= mkdir -p MKDIR ?= mkdir -p
RM ?= rm -f RM ?= rm -f
TOUCH ?= touch TOUCH ?= touch
WHOAMI ?= whoami
HARDLINK ?= ln -f HARDLINK ?= ln -f
HOSTNAME_CMD ?= hostname
DATE ?= date DATE ?= date
GZIP_CMD ?= gzip GZIP_CMD ?= gzip
CHMOD ?= chmod CHMOD ?= chmod
...@@ -214,6 +212,8 @@ ifndef NVIDIA_VERSION ...@@ -214,6 +212,8 @@ ifndef NVIDIA_VERSION
$(error NVIDIA_VERSION undefined) $(error NVIDIA_VERSION undefined)
endif endif
CFLAGS += -DNVIDIA_VERSION=\"$(NVIDIA_VERSION)\"
############################################################################## ##############################################################################
# Several of the functions below take an argument that indicates if # Several of the functions below take an argument that indicates if
...@@ -424,37 +424,6 @@ define DEBUG_INFO_RULES ...@@ -424,37 +424,6 @@ define DEBUG_INFO_RULES
endif endif
endef endef
##############################################################################
# STAMP_C - this is a source file that is generated during the build
# to capture information about the build environment for the utility.
#
# The DEFINE_STAMP_C_RULE function is used to define the rule for
# generating STAMP_C. First argument is a list of dependencies for
# STAMP_C (g_stamp.o is filtered out of the list); second argument is
# the name of the program being built.
#
# The includer of utils.mk should add $(STAMP_C) to its list of source
# files
##############################################################################
STAMP_C = $(OUTPUTDIR)/g_stamp.c
define DEFINE_STAMP_C_RULE
$$(STAMP_C): $$(filter-out \
$$(call BUILD_OBJECT_LIST,$$(STAMP_C)),$(1)) \
$$(VERSION_MK)
@ $$(RM) $$@
@ $$(PRINTF) "%s" "const char NV_ID[] = \"nvidia id: " >> $$@
@ $$(PRINTF) "%s" "$(2): " >> $$@
@ $$(PRINTF) "%s" "version $$(NVIDIA_VERSION) " >> $$@
@ $$(PRINTF) "%s" "($$(shell $$(WHOAMI))" >> $$@
@ $$(PRINTF) "%s" "@$$(shell $$(HOSTNAME_CMD))) " >> $$@
@ $$(PRINTF) "%s\n" "$$(shell $(DATE))\";" >> $$@
@ $$(PRINTF) "%s\n" "const char *pNV_ID = NV_ID + 11;" >> $$@
endef
############################################################################## ##############################################################################
# Define rules that can be used for embedding a file into an ELF object that # Define rules that can be used for embedding a file into an ELF object that
# contains the raw contents of that file and symbols pointing to the embedded # contains the raw contents of that file and symbols pointing to the embedded
......
NVIDIA_VERSION = 396.54 NVIDIA_VERSION = 410.57
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment