535.104.05

This commit is contained in:
Aaron Plattner
2023-08-23 09:30:45 -07:00
parent b16a4aa667
commit e44a009276
8 changed files with 141 additions and 52 deletions

View File

@@ -210,7 +210,7 @@ CommandList *build_command_list(Options *op, Package *p)
/* find any possibly conflicting modules and/or libraries */
if (!op->no_kernel_modules) {
if (!op->no_kernel_modules && !op->dkms_registered) {
find_conflicting_kernel_modules(op, l);
}
@@ -291,6 +291,17 @@ CommandList *build_command_list(Options *op, Package *p)
tmp_installable_files = installable_files;
add_symlinks_to_file_type_list(&tmp_installable_files);
if (op->dkms_registered) {
/*
* These files were imported from the DKMS tarball and DKMS will remove
* them when the kernel modules are `dkms remove`d, so nvidia-installer
* should not install them over the existing copies.
*/
remove_file_type_from_file_type_list(&tmp_installable_files,
FILE_TYPE_DKMS_CONF);
remove_file_type_from_file_type_list(&tmp_installable_files,
FILE_TYPE_KERNEL_MODULE_SRC);
}
find_existing_files(p, l, &tmp_installable_files);

33
detect-self-hosted.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef __DETECT_SELF_HOSTED_H__
#define __DETECT_SELF_HOSTED_H__
// PCI devIds 0x2340-0x237f are for Self-Hosted Hopper
static inline int pci_devid_is_self_hosted(unsigned short devid)
{
return devid >= 0x2340 && devid <= 0x237f;
}
#endif

View File

@@ -285,19 +285,26 @@ int install_from_cwd(Options *op)
if (!op->kernel_modules_only && !op->no_opengl_files) {
add_libgl_abi_symlink(op, p);
}
/*
* uninstall the existing driver; this needs to be done before
* building the command list.
*
* XXX if we uninstall now, then build the command list, and
* then ask the user if they really want to execute the
* command list, if the user decides not to execute the
* command list, they'll be left with no driver installed.
*/
if (!op->kernel_modules_only) {
/*
* uninstall the existing driver; this needs to be done before
* building the command list.
*
* XXX if we uninstall now, then build the command list, and
* then ask the user if they really want to execute the
* command list, if the user decides not to execute the
* command list, they'll be left with no driver installed.
*/
if (!run_existing_uninstaller(op)) goto failed;
/* initialize the backup log */
if (!init_backup(op, p)) goto failed;
}
if (!op->no_kernel_modules) {
/* Import the modules into DKMS, if requested */
dkms_register_module(op, p, get_kernel_name(op));
}
if (!check_libglvnd_files(op, p)) {
@@ -313,12 +320,6 @@ int install_from_cwd(Options *op)
if (!ui_approve_command_list(op, c, "%s", p->description)) {
goto exit_install;
}
/* initialize the backup log file */
if (!op->kernel_modules_only) {
if (!init_backup(op, p)) goto failed;
}
/* execute the command list */
@@ -354,14 +355,6 @@ int install_from_cwd(Options *op)
check_installed_files_from_package(op, p);
/*
* Import the kernel modules into DKMS, if requested. This is done after
* the post-install sanity check because DKMS may move or rename files
*/
dkms_register_module(op, p, get_kernel_name(op));
/* done */
if (!op->kernel_modules_only) {

View File

@@ -199,6 +199,10 @@ void get_installable_file_type_list(
continue;
}
if (type == FILE_TYPE_KERNEL_MODULE && op->dkms_registered) {
continue;
}
if (((type == FILE_TYPE_NVIDIA_MODPROBE) ||
(type == FILE_TYPE_NVIDIA_MODPROBE_MANPAGE)) &&
!op->nvidia_modprobe) {
@@ -237,3 +241,9 @@ void add_symlinks_to_file_type_list(PackageEntryFileTypeList *file_type_list)
file_type_list->types[type] = 1;
}
}
void remove_file_type_from_file_type_list(PackageEntryFileTypeList *list,
PackageEntryFileType type)
{
list->types[type] = 0;
}

View File

@@ -36,4 +36,6 @@ void get_installable_file_type_list(
void add_symlinks_to_file_type_list(
PackageEntryFileTypeList *file_type_list);
void remove_file_type_from_file_type_list(
PackageEntryFileTypeList *list, PackageEntryFileType type);
#endif /* __NVIDIA_INSTALLER_MANIFEST_H__ */

91
misc.c
View File

@@ -48,6 +48,7 @@
#include "nvLegacy.h"
#include "manifest.h"
#include "nvpci-utils.h"
#include "detect-self-hosted.h"
static int check_symlink(Options*, const char*, const char*, const char*);
@@ -1640,13 +1641,15 @@ int check_for_running_x(Options *op)
* NVIDIA graphics devices installed in this system. If no supported devices
* are found, a warning message is printed. If legacy devices are detected
* in the system, a warning message is printed for each one.
* Other special requirements (e.g. defaulting to "-m kernel-open" for self-
* hosted Hopper) are handled here as well.
*/
void check_for_nvidia_graphics_devices(Options *op, Package *p)
{
struct pci_device_iterator *iter;
struct pci_device *dev;
int i, found_supported_device = FALSE;
int i, found_supported_device = FALSE, found_self_hosted = FALSE;
int found_vga_device = FALSE;
if (pci_system_init()) {
@@ -1719,6 +1722,10 @@ void check_for_nvidia_graphics_devices(Options *op, Package *p)
if (nvpci_dev_is_vga(dev)) {
found_vga_device = TRUE;
}
if (pci_devid_is_self_hosted(dev->device_id)) {
found_self_hosted = TRUE;
}
}
}
}
@@ -1738,6 +1745,13 @@ void check_for_nvidia_graphics_devices(Options *op, Package *p)
if (!found_vga_device)
op->no_nvidia_xconfig_question = TRUE;
if (found_self_hosted && !op->kernel_module_build_directory_override) {
ui_log(op, "This system requires use of the NVIDIA open kernel "
"modules; these will be selected by default.");
nvfree(p->kernel_module_build_directory);
p->kernel_module_build_directory = nvstrdup("kernel-open");
}
} /* check_for_nvidia_graphics_devices() */
@@ -2458,19 +2472,18 @@ int dkms_module_installed(Options* op, const char *driver, const char *kernel)
/*
* Generate a tar archive conforming to the `dkms mktarball --binaries-only`
* export format.
* Generate a tar archive conforming to the `dkms mktarball` export format.
*/
static char *dkms_gen_tarball(Options *op, Package *p, const char *kernel)
{
char *tmpdir, *binariesdir, *treedir, *builddir, *logdir, *moduledir, *dst;
char *tmpdir, *sourcedir, *treedir, *builddir, *logdir, *moduledir, *dst;
char *tarball = NULL;
int ret, i;
tmpdir = make_tmpdir(op);
if (!tmpdir) return NULL;
binariesdir = nvdircat(tmpdir, "dkms_binaries_only", NULL);
sourcedir = nvdircat(tmpdir, "dkms_source_tree", NULL);
treedir = nvdircat(tmpdir, "dkms_main_tree", NULL);
builddir = nvdircat(treedir, kernel, get_machine_arch(op), NULL);
logdir = nvdircat(builddir, "log", NULL);
@@ -2492,33 +2505,57 @@ static char *dkms_gen_tarball(Options *op, Package *p, const char *kernel)
nvfree(dst);
if (!ret) goto done;
/* Write the "binaries_only" metadata to the tarball staging directory */
dst = nvdircat(binariesdir, "PACKAGE_NAME", NULL);
ret = nv_string_to_file(dst, "nvidia");
nvfree(dst);
if (!ret) goto done;
dst = nvdircat(binariesdir, "PACKAGE_VERSION", NULL);
ret = nv_string_to_file(dst, p->version);
nvfree(dst);
if (!ret) goto done;
/* Copy the (already installed) dkms.conf file to the staging directory */
/* Copy the module sources and dkms.conf to the staging directory */
ret = FALSE;
dst = nvdircat(binariesdir, "dkms.conf", NULL);
for (i = 0; i < p->num_entries; i++) {
if (p->entries[i].type == FILE_TYPE_DKMS_CONF) {
ret = copy_file(op, p->entries[i].dst, dst, 0644);
char *dst_copy, *dstdir;
char *dkms_dstdir, *dkms_srcdir;
switch (p->entries[i].type) {
case FILE_TYPE_DKMS_CONF:
case FILE_TYPE_KERNEL_MODULE_SRC:
dst = nvdircat(sourcedir, p->entries[i].path, p->entries[i].name,
NULL);
dst_copy = nvstrdup(dst);
dstdir = dirname(dst_copy);
if (!directory_exists(dstdir)) {
ret = mkdir_recursive(op, dstdir, 0755, FALSE);
}
dkms_srcdir = nvstrcat("/usr/src/nvidia-", p->version, NULL);
dkms_dstdir = nvdircat(dkms_srcdir, p->entries[i].path, NULL);
nvfree(dkms_srcdir);
/*
* Create any missing directories which will contain the kernel
* module sources once the modules are installed via DKMS. This
* is done ahead of time, with mkdir logging enabled, so these
* directories can be removed upon uninstallation.
*/
if (!directory_exists(dkms_dstdir)) {
mkdir_recursive(op, dkms_dstdir, 0755, TRUE);
}
nvfree(dkms_dstdir);
ret = ret && copy_file(op, p->entries[i].file, dst, 0644);
nvfree(dst);
nvfree(dst_copy);
if (!ret) goto done;
break;
default:
break;
}
}
nvfree(dst);
/* If ret wasn't set to TRUE above, there are no source files */
if (!ret) goto done;
ret = mkdir_recursive(op, moduledir, 0755, FALSE);
if (!ret) goto done;
/* Copy the (already built and installed) kernel modules */
/* Copy the (already built) kernel modules */
for (i = 0; i < p->num_kernel_modules; i++) {
char *src = nvdircat(p->kernel_module_build_directory,
p->kernel_modules[i].module_filename, NULL);
@@ -2557,7 +2594,7 @@ static char *dkms_gen_tarball(Options *op, Package *p, const char *kernel)
done:
remove_directory(op, tmpdir);
nvfree(tmpdir);
nvfree(binariesdir);
nvfree(sourcedir);
nvfree(treedir);
nvfree(builddir);
nvfree(logdir);
@@ -2600,7 +2637,7 @@ void dkms_register_module(Options *op, Package *p, const char *kernel)
ui_status_begin(op, "Registering the kernel modules with DKMS:",
"Generating DKMS tarball");
/* Create a DKMS "binaries_only" tarball */
/* Create a DKMS tarball */
tarball = dkms_gen_tarball(op, p, kernel);
if (tarball) {
char *cmd, *output;
@@ -2648,9 +2685,11 @@ done:
} else {
ui_status_end(op, "Error.");
ui_warn(op, "Failed to register the NVIDIA kernel modules with DKMS. "
"The NVIDIA kernel modules were installed, but will not be "
"automatically rebuilt if you change your kernel.");
"The NVIDIA kernel modules will be installed, but will not "
"be automatically rebuilt if you change your kernel.");
}
op->dkms_registered = ret;
}
/*

View File

@@ -297,6 +297,7 @@ typedef struct __options {
char *external_platform_json_path;
int kernel_module_signed;
int dkms_registered;
void *ui_priv; /* for use by the ui's */

View File

@@ -1,4 +1,4 @@
NVIDIA_VERSION = 535.98
NVIDIA_VERSION = 535.104.05
# This file.
VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST))