NVIDIA – Fix for 418.43 to Work with Kernel 5.1-rc1..
I have done some more investigation into the NVIDIA compile failures with Kernel 5.1-rc1, and now have a – rather inelegant – solution.
I found clues to some of the errors in a post relating to nouveau: https://lkml.org/lkml/2019/2/20/50 and the rest were due to content removed from /include/drm/drm_crtc_helper.h in Kernel 5.1-rc1: https://elixir.bootlin.com/linux/v5.1-rc1/source/include/drm/drm_crtc_helper.h compared to: https://elixir.bootlin.com/linux/v5.0.3/source/include/drm/drm_crtc_helper.h. I also incorporated the name change mentioned in my previous article, from list_is_first to nv_list_is_first
And from all this, made the following changes:
In NVIDIA-Linux-x86_64-418.43/kernel/nvidia-drm, add #include <linux/version.h> to nvidia-drm-connector.c nvidia-drm-drv.c nvidia-drm-encoder.c and nvidia-drm-gem-nvkms-memory.c
NVIDIA-Linux-x86_64-418.43/kernel/common/inc/nv-list-helpers.h
change line 94
static inline int list_is_first(const struct list_head *list,
to
static inline int nv_list_is_first(const struct list_head *list,
NVIDIA-Linux-x86_64-418.43/kernel/nvidia-drm/nvidia-drm-connector.c
around line 203 add
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
/* Add header constants missing after 5.1-rc1 */
int drm_helper_probe_single_connector_modes(struct drm_connector
*connector, uint32_t maxX,
uint32_t maxY);
#endif
NVIDIA-Linux-x86_64-418.43/kernel/nvidia-drm/nvidia-drm-drv.c
around line 37 add
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
/* Add header constants missing after 5.1-rc1 */
void drm_kms_helper_poll_init(struct drm_device *dev);
void drm_kms_helper_poll_fini(struct drm_device *dev);
bool drm_helper_hpd_irq_event(struct drm_device *dev);
void drm_kms_helper_poll_disable(struct drm_device *dev);
#endif
NVIDIA-Linux-x86_64-418.43/kernel/nvidia-drm/nvidia-drm-encoder.c
around line 33 add
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
/* Add header constants missing after 5.1-rc1 */
void drm_kms_helper_hotplug_event(struct drm_device *dev);
#endif
around line 161 add
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
/* Add header constants missing after 5.1-rc1 */
int drm_helper_probe_single_connector_modes(struct drm_connector
*connector, uint32_t maxX,
uint32_t maxY);
#endif
NVIDIA-Linux-x86_64-418.43/kernel/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
change line 377
from
static int nv_drm_vma_fault(struct vm_fault *vmf)
to
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
static int nv_drm_vma_fault(struct vm_fault *vmf)
#else
static vm_fault_t nv_drm_vma_fault(struct vm_fault *vmf)
#endif
NVIDIA-Linux-x86_64-418.43/kernel/nvidia-uvm/uvm8.c
change line 176
from
static int uvm_vm_fault_sigbus_wrapper(struct vm_fault *vmf)
to
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
static int uvm_vm_fault_sigbus_wrapper(struct vm_fault *vmf)
#else
static vm_fault_t uvm_vm_fault_sigbus_wrapper(struct vm_fault *vmf)
#endif
change line 515
from
static int uvm_vm_fault_wrapper(struct vm_fault *vmf)
to
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
static int uvm_vm_fault_wrapper(struct vm_fault *vmf)
#else
static vm_fault_t uvm_vm_fault_wrapper(struct vm_fault *vmf)
#endif
NVIDIA-Linux-x86_64-418.43/kernel/nvidia-uvm/uvm8_range_tree.c
change line 34
from
if (list_is_first(&node->list, &tree->head))
to
if (nv_list_is_first(&node->list, &tree->head))
I did try to put the ‘missing’ kernel header items into a new header within the NVIDIA source code tree, and add references to that, but for some reason this produced more errors, so I left things as above..
I have tested these changes, and the resulting code compiles cleanly:
............... ld -r -o /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia-modeset/nv-modeset-interface.o /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia-modeset/nvidia-modeset-linux.o Building modules, stage 2. MODPOST 4 modules CC /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia-drm.mod.o LD [M] /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia-drm.ko CC /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia-modeset.mod.o LD [M] /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia-modeset.ko CC /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia-uvm.mod.o LD [M] /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia-uvm.ko CC /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia.mod.o LD [M] /home/rgadsdon/kernel/NVIDIA-Linux-x86_64-418.43-510patched/kernel/nvidia.ko make[2]: Leaving directory '/usr/src/linux-5.1-rc1' make[1]: Leaving directory '/usr/src/linux-5.1-rc1'
– and the resulting nvidia—.ko modules load/run OK (tested with Plasma/KDE, and with HD video)
Robert Gadsdon. March 19, 2019.
Hi RG
you can made a patch for this?
is for easy apply instead of do it by hand
greetings
There is a later version available, that does not need patching, now.
RG
Thank you! Applied it to 390.116 on 5.1.11 – compiled and works well!