Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 593624 | Differences between
and this patch

Collapse All | Expand All

(-)work.orig/kernel/common/inc/nv-linux.h (+3 lines)
Lines 1312-1317 extern void *nvidia_stack_t_cache; Link Here
1312
#define NV_KMEM_CACHE_CREATE(name, type)    \
1312
#define NV_KMEM_CACHE_CREATE(name, type)    \
1313
    NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, 0, NULL)
1313
    NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, 0, NULL)
1314
1314
1315
#define NV_KMEM_CACHE_CREATE_USERCOPY(name, type)    \
1316
    NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, SLAB_USERCOPY, NULL)
1317
1315
#define NV_KMEM_CACHE_DESTROY(kmem_cache)   \
1318
#define NV_KMEM_CACHE_DESTROY(kmem_cache)   \
1316
    kmem_cache_destroy(kmem_cache)
1319
    kmem_cache_destroy(kmem_cache)
1317
1320
(-)work.orig/kernel/common/inc/nv-modeset-interface.h (-2 / +2 lines)
Lines 72-78 typedef struct { Link Here
72
     * mix nvidia and nvidia-modeset kernel modules from different
72
     * mix nvidia and nvidia-modeset kernel modules from different
73
     * releases.
73
     * releases.
74
     */
74
     */
75
    const char *version_string;
75
    // const char *version_string;
76
76
77
    /*
77
    /*
78
     * Return system information.
78
     * Return system information.
Lines 117-122 typedef struct { Link Here
117
117
118
} nvidia_modeset_rm_ops_t;
118
} nvidia_modeset_rm_ops_t;
119
119
120
NV_STATUS nvidia_get_rm_ops(nvidia_modeset_rm_ops_t *rm_ops);
120
NV_STATUS nvidia_get_rm_ops(const nvidia_modeset_rm_ops_t **rm_ops, const char **version_string);
121
121
122
#endif /* _NV_MODESET_INTERFACE_H_ */
122
#endif /* _NV_MODESET_INTERFACE_H_ */
(-)work.orig/kernel/common/inc/nv-register-module.h (-1 / +1 lines)
Lines 34-40 typedef struct nvidia_module_s { Link Here
34
    int (*ioctl)(struct inode *, struct file * file, unsigned int cmd, unsigned long arg);
34
    int (*ioctl)(struct inode *, struct file * file, unsigned int cmd, unsigned long arg);
35
    unsigned int (*poll)(struct file * file, poll_table *wait);
35
    unsigned int (*poll)(struct file * file, poll_table *wait);
36
36
37
} nvidia_module_t;
37
} __do_const nvidia_module_t;
38
38
39
int nvidia_register_module(nvidia_module_t *);
39
int nvidia_register_module(nvidia_module_t *);
40
int nvidia_unregister_module(nvidia_module_t *);
40
int nvidia_unregister_module(nvidia_module_t *);
(-)work.orig/kernel/nvidia/nv.c (-2 / +2 lines)
Lines 660-667 int __init nvidia_init_module(void) Link Here
660
    NV_SPIN_LOCK_INIT(&km_lock);
660
    NV_SPIN_LOCK_INIT(&km_lock);
661
#endif
661
#endif
662
662
663
    nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE(nvidia_stack_cache_name,
663
    nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE_USERCOPY(nvidia_stack_cache_name,
664
                                                nvidia_stack_t);
664
                                                         nvidia_stack_t);
665
    if (nvidia_stack_t_cache == NULL)
665
    if (nvidia_stack_t_cache == NULL)
666
    {
666
    {
667
        nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n");
667
        nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n");
(-)work.orig/kernel/nvidia/nv-chrdev.c (-2 lines)
Lines 20-27 int nv_register_chrdev(void *param) Link Here
20
{
20
{
21
    nvidia_module_t *module = (nvidia_module_t *)param;
21
    nvidia_module_t *module = (nvidia_module_t *)param;
22
22
23
    module->instance = nv_module_instance;
24
25
    return (nvidia_register_module(module));
23
    return (nvidia_register_module(module));
26
}
24
}
27
25
(-)work.orig/kernel/nvidia/nv-instance.c (+1 lines)
Lines 51-56 struct pci_driver nv_pci_driver = { Link Here
51
nvidia_module_t nv_fops = {
51
nvidia_module_t nv_fops = {
52
    .owner       = THIS_MODULE,
52
    .owner       = THIS_MODULE,
53
    .module_name = MODULE_NAME,
53
    .module_name = MODULE_NAME,
54
    .instance    = MODULE_INSTANCE_NUMBER,
54
    .open        = nvidia_open,
55
    .open        = nvidia_open,
55
    .close       = nvidia_close,
56
    .close       = nvidia_close,
56
    .ioctl       = nvidia_ioctl,
57
    .ioctl       = nvidia_ioctl,
(-)work.orig/kernel/nvidia/nv-mmap.c (-2 / +2 lines)
Lines 113-124 nvidia_vma_release(struct vm_area_struct Link Here
113
}
113
}
114
114
115
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_ACCESS)
115
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_ACCESS)
116
static int
116
static ssize_t
117
nvidia_vma_access(
117
nvidia_vma_access(
118
    struct vm_area_struct *vma,
118
    struct vm_area_struct *vma,
119
    unsigned long addr,
119
    unsigned long addr,
120
    void *buffer,
120
    void *buffer,
121
    int length,
121
    size_t length,
122
    int write
122
    int write
123
)
123
)
124
{
124
{
(-)work.orig/kernel/nvidia/nv-modeset-interface.c (-7 / +6 lines)
Lines 100-109 static NvU32 nvidia_modeset_enumerate_gp Link Here
100
    return count;
100
    return count;
101
}
101
}
102
102
103
NV_STATUS nvidia_get_rm_ops(nvidia_modeset_rm_ops_t *rm_ops)
103
NV_STATUS nvidia_get_rm_ops(const nvidia_modeset_rm_ops_t **rm_ops, const char **version_string)
104
{
104
{
105
    const nvidia_modeset_rm_ops_t local_rm_ops = {
105
    static nvidia_modeset_rm_ops_t local_rm_ops = {
106
        .version_string = NV_VERSION_STRING,
107
        .system_info    = {
106
        .system_info    = {
108
            .allow_write_combining = NV_FALSE,
107
            .allow_write_combining = NV_FALSE,
109
        },
108
        },
Lines 116-131 NV_STATUS nvidia_get_rm_ops(nvidia_modes Link Here
116
        .set_callbacks  = nvidia_modeset_set_callbacks,
115
        .set_callbacks  = nvidia_modeset_set_callbacks,
117
    };
116
    };
118
117
119
    if (strcmp(rm_ops->version_string, NV_VERSION_STRING) != 0)
118
    if (strcmp(*version_string, NV_VERSION_STRING) != 0)
120
    {
119
    {
121
        rm_ops->version_string = NV_VERSION_STRING;
120
        *version_string = NV_VERSION_STRING;
122
        return NV_ERR_GENERIC;
121
        return NV_ERR_GENERIC;
123
    }
122
    }
124
123
125
    *rm_ops = local_rm_ops;
124
    *rm_ops = (const nvidia_modeset_rm_ops_t *) &local_rm_ops;
126
125
127
    if (NV_ALLOW_WRITE_COMBINING(NV_MEMORY_TYPE_FRAMEBUFFER)) {
126
    if (NV_ALLOW_WRITE_COMBINING(NV_MEMORY_TYPE_FRAMEBUFFER)) {
128
        rm_ops->system_info.allow_write_combining = NV_TRUE;
127
        local_rm_ops.system_info.allow_write_combining = NV_TRUE;
129
    }
128
    }
130
129
131
    return NV_OK;
130
    return NV_OK;
(-)work.orig/kernel/nvidia-drm/nvidia-drm-drv.c (-1 / +3 lines)
Lines 612-618 static const struct drm_ioctl_desc nv_dr Link Here
612
                      DRM_CONTROL_ALLOW|DRM_RENDER_ALLOW|DRM_UNLOCKED),
612
                      DRM_CONTROL_ALLOW|DRM_RENDER_ALLOW|DRM_UNLOCKED),
613
};
613
};
614
614
615
static struct drm_driver nv_drm_driver = {
615
static drm_driver_no_const nv_drm_driver __read_only  = {
616
616
617
    .driver_features        = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER,
617
    .driver_features        = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER,
618
618
Lines 673-678 static void nvidia_update_drm_driver_fea Link Here
673
        return;
673
        return;
674
    }
674
    }
675
675
676
    pax_open_kernel();
676
    nv_drm_driver.driver_features |= DRIVER_MODESET | DRIVER_ATOMIC;
677
    nv_drm_driver.driver_features |= DRIVER_MODESET | DRIVER_ATOMIC;
677
678
678
    nv_drm_driver.master_set       = nvidia_drm_master_set;
679
    nv_drm_driver.master_set       = nvidia_drm_master_set;
Lines 681-686 static void nvidia_update_drm_driver_fea Link Here
681
    nv_drm_driver.dumb_create      = nvidia_drm_dumb_create;
682
    nv_drm_driver.dumb_create      = nvidia_drm_dumb_create;
682
    nv_drm_driver.dumb_map_offset  = nvidia_drm_dumb_map_offset;
683
    nv_drm_driver.dumb_map_offset  = nvidia_drm_dumb_map_offset;
683
    nv_drm_driver.dumb_destroy     = drm_gem_dumb_destroy;
684
    nv_drm_driver.dumb_destroy     = drm_gem_dumb_destroy;
685
    pax_close_kernel();
684
686
685
#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
687
#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
686
}
688
}
(-)work.orig/kernel/nvidia-modeset/nvidia-modeset-linux.c (-20 / +20 lines)
Lines 322-350 static void nvkms_resume(NvU32 gpuId) Link Here
322
 * Interface with resman.
322
 * Interface with resman.
323
 *************************************************************************/
323
 *************************************************************************/
324
324
325
static nvidia_modeset_rm_ops_t __rm_ops = { 0 };
325
static const nvidia_modeset_rm_ops_t *__rm_ops;
326
326
static nvidia_modeset_callbacks_t nvkms_rm_callbacks = {
327
static nvidia_modeset_callbacks_t nvkms_rm_callbacks = {
327
    nvkms_suspend,
328
    .suspend = nvkms_suspend,
328
    nvkms_resume
329
    .resume = nvkms_resume
329
};
330
};
330
331
331
static int nvkms_alloc_rm(void)
332
static int nvkms_alloc_rm(void)
332
{
333
{
333
    NV_STATUS nvstatus;
334
    NV_STATUS nvstatus;
334
    int ret;
335
    int ret;
336
    const char * version_string = NV_VERSION_STRING;
335
337
336
    __rm_ops.version_string = NV_VERSION_STRING;
338
    nvstatus = nvidia_get_rm_ops(&__rm_ops, &version_string);
337
338
    nvstatus = nvidia_get_rm_ops(&__rm_ops);
339
339
340
    if (nvstatus != NV_OK) {
340
    if (nvstatus != NV_OK) {
341
        printk(KERN_ERR NVKMS_LOG_PREFIX "Version mismatch: "
341
        printk(KERN_ERR NVKMS_LOG_PREFIX "Version mismatch: "
342
               "nvidia.ko(%s) nvidia-modeset.ko(%s)\n",
342
               "nvidia.ko(%s) nvidia-modeset.ko(%s)\n",
343
               __rm_ops.version_string, NV_VERSION_STRING);
343
	       version_string, NV_VERSION_STRING);
344
        return -EINVAL;
344
        return -EINVAL;
345
    }
345
    }
346
346
347
    ret = __rm_ops.set_callbacks(&nvkms_rm_callbacks);
347
    ret = __rm_ops->set_callbacks(&nvkms_rm_callbacks);
348
    if (ret < 0) {
348
    if (ret < 0) {
349
        printk(KERN_ERR NVKMS_LOG_PREFIX "Failed to register callbacks\n");
349
        printk(KERN_ERR NVKMS_LOG_PREFIX "Failed to register callbacks\n");
350
        return ret;
350
        return ret;
Lines 355-374 static int nvkms_alloc_rm(void) Link Here
355
355
356
static void nvkms_free_rm(void)
356
static void nvkms_free_rm(void)
357
{
357
{
358
    __rm_ops.set_callbacks(NULL);
358
    __rm_ops->set_callbacks(NULL);
359
}
359
}
360
360
361
void NVKMS_API_CALL nvkms_call_rm(void *ops)
361
void NVKMS_API_CALL nvkms_call_rm(void *ops)
362
{
362
{
363
    nvidia_modeset_stack_ptr stack = NULL;
363
    nvidia_modeset_stack_ptr stack = NULL;
364
364
365
    if (__rm_ops.alloc_stack(&stack) != 0) {
365
    if (__rm_ops->alloc_stack(&stack) != 0) {
366
        return;
366
        return;
367
    }
367
    }
368
368
369
    __rm_ops.op(stack, ops);
369
    __rm_ops->op(stack, ops);
370
370
371
    __rm_ops.free_stack(stack);
371
    __rm_ops->free_stack(stack);
372
}
372
}
373
373
374
/*************************************************************************
374
/*************************************************************************
Lines 690-702 NvBool NVKMS_API_CALL nvkms_open_gpu(NvU Link Here
690
    nvidia_modeset_stack_ptr stack = NULL;
690
    nvidia_modeset_stack_ptr stack = NULL;
691
    NvBool ret;
691
    NvBool ret;
692
692
693
    if (__rm_ops.alloc_stack(&stack) != 0) {
693
    if (__rm_ops->alloc_stack(&stack) != 0) {
694
        return NV_FALSE;
694
        return NV_FALSE;
695
    }
695
    }
696
696
697
    ret = __rm_ops.open_gpu(gpuId, stack) == 0;
697
    ret = __rm_ops->open_gpu(gpuId, stack) == 0;
698
698
699
    __rm_ops.free_stack(stack);
699
    __rm_ops->free_stack(stack);
700
700
701
    return ret;
701
    return ret;
702
}
702
}
Lines 705-727 void NVKMS_API_CALL nvkms_close_gpu(NvU3 Link Here
705
{
705
{
706
    nvidia_modeset_stack_ptr stack = NULL;
706
    nvidia_modeset_stack_ptr stack = NULL;
707
707
708
    if (__rm_ops.alloc_stack(&stack) != 0) {
708
    if (__rm_ops->alloc_stack(&stack) != 0) {
709
        return;
709
        return;
710
    }
710
    }
711
711
712
    __rm_ops.close_gpu(gpuId, stack);
712
    __rm_ops->close_gpu(gpuId, stack);
713
713
714
    __rm_ops.free_stack(stack);
714
    __rm_ops->free_stack(stack);
715
}
715
}
716
716
717
NvU32 NVKMS_API_CALL nvkms_enumerate_gpus(nv_gpu_info_t *gpu_info)
717
NvU32 NVKMS_API_CALL nvkms_enumerate_gpus(nv_gpu_info_t *gpu_info)
718
{
718
{
719
    return __rm_ops.enumerate_gpus(gpu_info);
719
    return __rm_ops->enumerate_gpus(gpu_info);
720
}
720
}
721
721
722
NvBool NVKMS_API_CALL nvkms_allow_write_combining(void)
722
NvBool NVKMS_API_CALL nvkms_allow_write_combining(void)
723
{
723
{
724
    return __rm_ops.system_info.allow_write_combining;
724
    return __rm_ops->system_info.allow_write_combining;
725
}
725
}
726
726
727
/*************************************************************************
727
/*************************************************************************
(-)work.orig/kernel/nvidia-uvm/uvm8_global.c (-5 / +5 lines)
Lines 35-51 Link Here
35
#include "nv_uvm_interface.h"
35
#include "nv_uvm_interface.h"
36
36
37
uvm_global_t g_uvm_global;
37
uvm_global_t g_uvm_global;
38
static struct UvmOpsUvmEvents g_exported_uvm8_ops;
38
static struct UvmOpsUvmEvents g_exported_uvm8_ops = {
39
    .startDevice = NULL,
40
    .stopDevice  = NULL,
41
    .isrTopHalf  = uvm8_isr_top_half,
42
};
39
static bool g_ops_registered = false;
43
static bool g_ops_registered = false;
40
44
41
static NV_STATUS uvm8_register_callbacks(void)
45
static NV_STATUS uvm8_register_callbacks(void)
42
{
46
{
43
    NV_STATUS status = NV_OK;
47
    NV_STATUS status = NV_OK;
44
48
45
    g_exported_uvm8_ops.startDevice = NULL;
46
    g_exported_uvm8_ops.stopDevice  = NULL;
47
    g_exported_uvm8_ops.isrTopHalf  = uvm8_isr_top_half;
48
49
    // Register the UVM callbacks with the main GPU driver:
49
    // Register the UVM callbacks with the main GPU driver:
50
    status = uvm_rm_locked_call(nvUvmInterfaceRegisterUvmCallbacks(&g_exported_uvm8_ops));
50
    status = uvm_rm_locked_call(nvUvmInterfaceRegisterUvmCallbacks(&g_exported_uvm8_ops));
51
    if (status != NV_OK)
51
    if (status != NV_OK)
(-)work.orig/kernel/nvidia-uvm/uvm8_gpu_semaphore.c (-2 / +2 lines)
Lines 352-358 NvU64 uvm_gpu_semaphore_get_gpu_va(uvm_g Link Here
352
352
353
NvU32 uvm_gpu_semaphore_get_payload(uvm_gpu_semaphore_t *semaphore)
353
NvU32 uvm_gpu_semaphore_get_payload(uvm_gpu_semaphore_t *semaphore)
354
{
354
{
355
    return ACCESS_ONCE(*semaphore->payload);
355
    return ACCESS_ONCE_RW(*semaphore->payload);
356
}
356
}
357
357
358
void uvm_gpu_semaphore_set_payload(uvm_gpu_semaphore_t *semaphore, NvU32 payload)
358
void uvm_gpu_semaphore_set_payload(uvm_gpu_semaphore_t *semaphore, NvU32 payload)
Lines 368-374 void uvm_gpu_semaphore_set_payload(uvm_g Link Here
368
    // being optimized out on non-SMP configs (we need them for interacting with
368
    // being optimized out on non-SMP configs (we need them for interacting with
369
    // the GPU correctly even on non-SMP).
369
    // the GPU correctly even on non-SMP).
370
    mb();
370
    mb();
371
    ACCESS_ONCE(*semaphore->payload) = payload;
371
    ACCESS_ONCE_RW(*semaphore->payload) = payload;
372
}
372
}
373
373
374
// This function is intended to catch channels which have been left dangling in
374
// This function is intended to catch channels which have been left dangling in
(-)work.orig/kernel/nvidia-uvm/uvm8_hal.h (-1 / +1 lines)
Lines 316-322 typedef struct Link Here
316
        // fault_buffer_ops: id is a hardware class
316
        // fault_buffer_ops: id is a hardware class
317
        uvm_fault_buffer_hal_t fault_buffer_ops;
317
        uvm_fault_buffer_hal_t fault_buffer_ops;
318
    } u;
318
    } u;
319
} uvm_hal_class_ops_t;
319
} __do_const uvm_hal_class_ops_t;
320
320
321
// When UVM next support is enabled support for future chips in the hal is
321
// When UVM next support is enabled support for future chips in the hal is
322
// enabled by providing additional hal table entries below.
322
// enabled by providing additional hal table entries below.
(-)work.orig/kernel/nvidia-uvm/uvm8_mmu.h (-1 lines)
Lines 24-30 Link Here
24
#ifndef __UVM8_MMU_H__
24
#ifndef __UVM8_MMU_H__
25
#define __UVM8_MMU_H__
25
#define __UVM8_MMU_H__
26
26
27
#include "uvm8_forward_decl.h"
28
#include "uvm8_hal_types.h"
27
#include "uvm8_hal_types.h"
29
#include "uvm8_pmm_gpu.h"
28
#include "uvm8_pmm_gpu.h"
30
#include "uvmtypes.h"
29
#include "uvmtypes.h"
(-)work.orig/kernel/nvidia-uvm/uvm_common.c (-3 / +4 lines)
Lines 51-57 Link Here
51
#define UVM_SPIN_LOOP_PRINT_TIMEOUT_SEC     30ULL
51
#define UVM_SPIN_LOOP_PRINT_TIMEOUT_SEC     30ULL
52
52
53
static dev_t g_uvmBaseDev;
53
static dev_t g_uvmBaseDev;
54
struct UvmOpsUvmEvents g_exportedUvmOps;
55
54
56
static char* uvm_driver_mode = "8";
55
static char* uvm_driver_mode = "8";
57
56
Lines 178-185 static NV_STATUS uvmSetupGpuProvider(voi Link Here
178
{
177
{
179
    NV_STATUS status = NV_OK;
178
    NV_STATUS status = NV_OK;
180
179
181
    g_exportedUvmOps.startDevice = uvm_gpu_event_start_device;
180
    static struct UvmOpsUvmEvents g_exportedUvmOps = {
182
    g_exportedUvmOps.stopDevice  = uvm_gpu_event_stop_device;
181
        .startDevice = uvm_gpu_event_start_device,
182
        .stopDevice  = uvm_gpu_event_stop_device,
183
    };
183
184
184
    // call RM to exchange the function pointers.
185
    // call RM to exchange the function pointers.
185
    status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps);
186
    status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps);
(-)work.orig/kernel/nvidia-uvm/uvm_full_fault_buffer.h (-1 / +2 lines)
Lines 30-35 Link Here
30
#ifndef _UVM_FULL_FAULT_BUFFER_H_
30
#ifndef _UVM_FULL_FAULT_BUFFER_H_
31
#define _UVM_FULL_FAULT_BUFFER_H_
31
#define _UVM_FULL_FAULT_BUFFER_H_
32
32
33
#include <linux/compiler.h>
33
#include "uvmtypes.h"
34
#include "uvmtypes.h"
34
35
35
#define MAXWELL_FAULT_BUFFER_A (0xb069)
36
#define MAXWELL_FAULT_BUFFER_A (0xb069)
Lines 303-309 typedef struct Link Here
303
    NvUvmControlPrefetch_t              controlPrefetch;
304
    NvUvmControlPrefetch_t              controlPrefetch;
304
    NvUvmTestFaultBufferOverflow_t      testFaultBufferOverflow;
305
    NvUvmTestFaultBufferOverflow_t      testFaultBufferOverflow;
305
    NvUvmClearFaultBufferOverflow_t     clearFaultBufferOverflow;
306
    NvUvmClearFaultBufferOverflow_t     clearFaultBufferOverflow;
306
} UvmFaultBufferOps;
307
} __no_const UvmFaultBufferOps;
307
308
308
/******************************************************************************
309
/******************************************************************************
309
    uvmfull_fault_buffer_init
310
    uvmfull_fault_buffer_init
(-)work.orig/kernel/nvidia-uvm/uvm_linux.h (-1 / +1 lines)
Lines 420-426 static inline NvU64 NV_GETTIME(void) Link Here
420
420
421
// WRITE_ONCE/READ_ONCE have incompatible definitions across versions, which produces warnings.
421
// WRITE_ONCE/READ_ONCE have incompatible definitions across versions, which produces warnings.
422
// Therefore, we define our own macros
422
// Therefore, we define our own macros
423
#define UVM_WRITE_ONCE(x, val) (ACCESS_ONCE(x) = (val))
423
#define UVM_WRITE_ONCE(x, val) (ACCESS_ONCE_RW(x) = (val))
424
#define UVM_READ_ONCE(x) ACCESS_ONCE(x)
424
#define UVM_READ_ONCE(x) ACCESS_ONCE(x)
425
425
426
// Added in 3.11
426
// Added in 3.11

Return to bug 593624