k/kmod-nvidia: improve building 390.144 with kernel 5.15.

Building module for kernel 5.15 requires the same patch as
for previous one (5.14), but at the same time it generates
a lot of warnings with gcc 11.2.
Remedy for these warnings is put atop existing 5.14 fix and
combined into one patch that makes compilation successful
and with no warnings at all.

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
Michal Cieslakiewicz 2021-11-22 23:58:28 +01:00
parent 246d7f38aa
commit 1abf1aa5b2

View File

@ -0,0 +1,113 @@
diff --git a/kernel/common/inc/nv.h b/kernel/common/inc/nv.h
index c085b97..d8ece09 100644
--- a/kernel/common/inc/nv.h
+++ b/kernel/common/inc/nv.h
@@ -15,7 +15,7 @@
#include <nvlimits.h>
#include <nvtypes.h>
#include <nvCpuUuid.h>
-#include <stdarg.h>
+#include <linux/stdarg.h>
#include <nv-kernel-interface-api.h>
#ifndef __KERNEL__
#include "g_nvconfig.h"
diff --git a/kernel/common/inc/os-interface.h b/kernel/common/inc/os-interface.h
index 4009855..68f83a3 100644
--- a/kernel/common/inc/os-interface.h
+++ b/kernel/common/inc/os-interface.h
@@ -24,7 +24,7 @@
* *
\***************************************************************************/
-#include <stdarg.h>
+#include <linux/stdarg.h>
#include <nv-kernel-interface-api.h>
#include "nvipmi.h"
diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index 54389be..f74738f 100644
--- a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/nvidia-drm/nvidia-drm-drv.c
@@ -20,6 +20,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/version.h>
#include "nvidia-drm-conftest.h" /* NV_DRM_AVAILABLE and NV_DRM_DRM_GEM_H_PRESENT */
#include "nvidia-drm-priv.h"
@@ -811,7 +812,10 @@ static void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
dev->dev_private = nv_dev;
nv_dev->dev = dev;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0))
+ // Rel. commit "drm: Remove pdev field from struct drm_device" (Thomas Zimmermann, 3 May 2021)
dev->pdev = pdev;
+#endif
/* Register DRM device to DRM sub-system */
diff --git a/kernel/nvidia-modeset/nvidia-modeset-os-interface.h b/kernel/nvidia-modeset/nvidia-modeset-os-interface.h
index a7bb7c9..9172ca1 100644
--- a/kernel/nvidia-modeset/nvidia-modeset-os-interface.h
+++ b/kernel/nvidia-modeset/nvidia-modeset-os-interface.h
@@ -17,7 +17,7 @@
#define _NVIDIA_MODESET_OS_INTERFACE_H_
#include <stddef.h> /* size_t */
-#include <stdarg.h> /* va_list */
+#include <linux/stdarg.h> /* va_list */
#include "nvtypes.h" /* NvU8 */
diff --git a/kernel/nvidia-uvm/uvm8_mmu.c b/kernel/nvidia-uvm/uvm8_mmu.c
index b51c527..521e98b 100644
--- a/kernel/nvidia-uvm/uvm8_mmu.c
+++ b/kernel/nvidia-uvm/uvm8_mmu.c
@@ -32,7 +32,7 @@
#include "uvm8_push.h"
#include "uvm8_mem.h"
#include "uvm8_va_space.h"
-#include <stdarg.h>
+#include <linux/stdarg.h>
// The page tree has 5 levels on pascal, and the root is never freed by a normal 'put' operation
// which leaves a maximum of 4 levels
diff --git a/kernel/nvidia/nv-mmap.c b/kernel/nvidia/nv-mmap.c
index 288a1e0..d3c751c 100644
--- a/kernel/nvidia/nv-mmap.c
+++ b/kernel/nvidia/nv-mmap.c
@@ -254,6 +254,7 @@ int nv_encode_caching(
case NV_MEMORY_CACHED:
if (NV_ALLOW_CACHING(memory_type))
break;
+ __attribute__((__fallthrough__));
default:
nv_printf(NV_DBG_ERRORS,
"NVRM: VM: cache type %d not supported for memory type %d!\n",
diff --git a/kernel/nvidia/nvlink_linux.c b/kernel/nvidia/nvlink_linux.c
index 872bc90..ba57b86 100644
--- a/kernel/nvidia/nvlink_linux.c
+++ b/kernel/nvidia/nvlink_linux.c
@@ -597,7 +597,7 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms)
// the requested timeout has expired, loop until less
// than a jiffie of the desired delay remains.
//
- current->state = TASK_INTERRUPTIBLE;
+ set_current_state(TASK_INTERRUPTIBLE);
do
{
schedule_timeout(jiffies);
diff --git a/kernel/nvidia/os-interface.c b/kernel/nvidia/os-interface.c
index 3603a5a..262171f 100644
--- a/kernel/nvidia/os-interface.c
+++ b/kernel/nvidia/os-interface.c
@@ -580,7 +580,7 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
// the requested timeout has expired, loop until less
// than a jiffie of the desired delay remains.
//
- current->state = TASK_INTERRUPTIBLE;
+ set_current_state(TASK_INTERRUPTIBLE);
do
{
schedule_timeout(jiffies);