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

Collapse All | Expand All

(-)work.orig/kernel/common/inc/nv-linux.h (+3 lines)
Lines 1308-1313 extern void *nvidia_stack_t_cache; Link Here
1308
#define NV_KMEM_CACHE_CREATE(name, type)    \
1308
#define NV_KMEM_CACHE_CREATE(name, type)    \
1309
    NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, 0, NULL)
1309
    NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, 0, NULL)
1310
1310
1311
#define NV_KMEM_CACHE_CREATE_USERCOPY(name, type)    \
1312
    NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, SLAB_USERCOPY, NULL)
1313
1311
#define NV_KMEM_CACHE_DESTROY(kmem_cache)   \
1314
#define NV_KMEM_CACHE_DESTROY(kmem_cache)   \
1312
    kmem_cache_destroy(kmem_cache)
1315
    kmem_cache_destroy(kmem_cache)
1313
1316
(-)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 (-1 / +1 lines)
Lines 654-660 int __init nvidia_init_module(void) Link Here
654
    NV_SPIN_LOCK_INIT(&km_lock);
654
    NV_SPIN_LOCK_INIT(&km_lock);
655
#endif
655
#endif
656
656
657
    nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE(nvidia_stack_cache_name,
657
    nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE_USERCOPY(nvidia_stack_cache_name,
658
                                                nvidia_stack_t);
658
                                                nvidia_stack_t);
659
    if (nvidia_stack_t_cache == NULL)
659
    if (nvidia_stack_t_cache == NULL)
660
    {
660
    {
(-)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 (-10 / +18 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 const 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-132 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
    static const nvidia_modeset_rm_ops_t local_rm_ops_wc = {
119
        .system_info    = {
120
            .allow_write_combining = NV_TRUE,
121
        },
122
        .alloc_stack    = nvidia_modeset_rm_ops_alloc_stack,
123
        .free_stack     = nvidia_modeset_rm_ops_free_stack,
124
        .enumerate_gpus = nvidia_modeset_enumerate_gpus,
125
        .open_gpu       = nvidia_dev_get,
126
        .close_gpu      = nvidia_dev_put,
127
        .op             = rm_kernel_rmapi_op, /* provided by nv-kernel.o */
128
        .set_callbacks  = nvidia_modeset_set_callbacks,
129
    };
130
131
    if (strcmp(*version_string, NV_VERSION_STRING) != 0)
120
    {
132
    {
121
        rm_ops->version_string = NV_VERSION_STRING;
133
        *version_string = NV_VERSION_STRING;
122
        return NV_ERR_GENERIC;
134
        return NV_ERR_GENERIC;
123
    }
135
    }
124
136
125
    *rm_ops = local_rm_ops;
137
    *rm_ops = NV_ALLOW_WRITE_COMBINING(NV_MEMORY_TYPE_FRAMEBUFFER) ? &local_rm_ops_wc : &local_rm_ops;
126
127
    if (NV_ALLOW_WRITE_COMBINING(NV_MEMORY_TYPE_FRAMEBUFFER)) {
128
        rm_ops->system_info.allow_write_combining = NV_TRUE;
129
    }
130
138
131
    return NV_OK;
139
    return NV_OK;
132
}
140
}
(-)work.orig/kernel/nvidia-drm/nvidia-drm-drv.c (-1 / +3 lines)
Lines 592-598 static const struct drm_ioctl_desc nv_dr Link Here
592
                      DRM_CONTROL_ALLOW|DRM_RENDER_ALLOW|DRM_UNLOCKED),
592
                      DRM_CONTROL_ALLOW|DRM_RENDER_ALLOW|DRM_UNLOCKED),
593
};
593
};
594
594
595
static struct drm_driver nv_drm_driver = {
595
static drm_driver_no_const nv_drm_driver __read_only = {
596
596
597
    .driver_features        = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER,
597
    .driver_features        = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER,
598
598
Lines 649-654 static void nvidia_update_drm_driver_fea Link Here
649
        return;
649
        return;
650
    }
650
    }
651
651
652
    pax_open_kernel();
652
    nv_drm_driver.driver_features |= DRIVER_MODESET | DRIVER_ATOMIC;
653
    nv_drm_driver.driver_features |= DRIVER_MODESET | DRIVER_ATOMIC;
653
654
654
    nv_drm_driver.master_set       = nvidia_drm_master_set;
655
    nv_drm_driver.master_set       = nvidia_drm_master_set;
Lines 657-662 static void nvidia_update_drm_driver_fea Link Here
657
    nv_drm_driver.dumb_create      = nvidia_drm_dumb_create;
658
    nv_drm_driver.dumb_create      = nvidia_drm_dumb_create;
658
    nv_drm_driver.dumb_map_offset  = nvidia_drm_dumb_map_offset;
659
    nv_drm_driver.dumb_map_offset  = nvidia_drm_dumb_map_offset;
659
    nv_drm_driver.dumb_destroy     = drm_gem_dumb_destroy;
660
    nv_drm_driver.dumb_destroy     = drm_gem_dumb_destroy;
661
    pax_close_kernel();
660
662
661
#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
663
#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
662
}
664
}
(-)work.orig/kernel/nvidia-modeset/nvidia-modeset-linux.c (-20 / +19 lines)
Lines 317-345 static void nvkms_resume(NvU32 gpuId) Link Here
317
 * Interface with resman.
317
 * Interface with resman.
318
 *************************************************************************/
318
 *************************************************************************/
319
319
320
static nvidia_modeset_rm_ops_t __rm_ops = { 0 };
320
static const nvidia_modeset_rm_ops_t *__rm_ops;
321
static nvidia_modeset_callbacks_t nvkms_rm_callbacks = {
321
static nvidia_modeset_callbacks_t nvkms_rm_callbacks = {
322
    nvkms_suspend,
322
    .suspend = nvkms_suspend,
323
    nvkms_resume
323
    .resume = nvkms_resume
324
};
324
};
325
325
326
static int nvkms_alloc_rm(void)
326
static int nvkms_alloc_rm(void)
327
{
327
{
328
    NV_STATUS nvstatus;
328
    NV_STATUS nvstatus;
329
    int ret;
329
    int ret;
330
    const char *version_string = NV_VERSION_STRING;
330
331
331
    __rm_ops.version_string = NV_VERSION_STRING;
332
    nvstatus = nvidia_get_rm_ops(&__rm_ops, &version_string);
332
333
    nvstatus = nvidia_get_rm_ops(&__rm_ops);
334
333
335
    if (nvstatus != NV_OK) {
334
    if (nvstatus != NV_OK) {
336
        printk(KERN_ERR NVKMS_LOG_PREFIX "Version mismatch: "
335
        printk(KERN_ERR NVKMS_LOG_PREFIX "Version mismatch: "
337
               "nvidia.ko(%s) nvidia-modeset.ko(%s)\n",
336
               "nvidia.ko(%s) nvidia-modeset.ko(%s)\n",
338
               __rm_ops.version_string, NV_VERSION_STRING);
337
               version_string, NV_VERSION_STRING);
339
        return -EINVAL;
338
        return -EINVAL;
340
    }
339
    }
341
340
342
    ret = __rm_ops.set_callbacks(&nvkms_rm_callbacks);
341
    ret = __rm_ops->set_callbacks(&nvkms_rm_callbacks);
343
    if (ret < 0) {
342
    if (ret < 0) {
344
        printk(KERN_ERR NVKMS_LOG_PREFIX "Failed to register callbacks\n");
343
        printk(KERN_ERR NVKMS_LOG_PREFIX "Failed to register callbacks\n");
345
        return ret;
344
        return ret;
Lines 350-369 static int nvkms_alloc_rm(void) Link Here
350
349
351
static void nvkms_free_rm(void)
350
static void nvkms_free_rm(void)
352
{
351
{
353
    __rm_ops.set_callbacks(NULL);
352
    __rm_ops->set_callbacks(NULL);
354
}
353
}
355
354
356
void NVKMS_API_CALL nvkms_call_rm(void *ops)
355
void NVKMS_API_CALL nvkms_call_rm(void *ops)
357
{
356
{
358
    nvidia_modeset_stack_ptr stack = NULL;
357
    nvidia_modeset_stack_ptr stack = NULL;
359
358
360
    if (__rm_ops.alloc_stack(&stack) != 0) {
359
    if (__rm_ops->alloc_stack(&stack) != 0) {
361
        return;
360
        return;
362
    }
361
    }
363
362
364
    __rm_ops.op(stack, ops);
363
    __rm_ops->op(stack, ops);
365
364
366
    __rm_ops.free_stack(stack);
365
    __rm_ops->free_stack(stack);
367
}
366
}
368
367
369
/*************************************************************************
368
/*************************************************************************
Lines 685-697 NvBool NVKMS_API_CALL nvkms_open_gpu(NvU Link Here
685
    nvidia_modeset_stack_ptr stack = NULL;
684
    nvidia_modeset_stack_ptr stack = NULL;
686
    NvBool ret;
685
    NvBool ret;
687
686
688
    if (__rm_ops.alloc_stack(&stack) != 0) {
687
    if (__rm_ops->alloc_stack(&stack) != 0) {
689
        return NV_FALSE;
688
        return NV_FALSE;
690
    }
689
    }
691
690
692
    ret = __rm_ops.open_gpu(gpuId, stack) == 0;
691
    ret = __rm_ops->open_gpu(gpuId, stack) == 0;
693
692
694
    __rm_ops.free_stack(stack);
693
    __rm_ops->free_stack(stack);
695
694
696
    return ret;
695
    return ret;
697
}
696
}
Lines 700-722 void NVKMS_API_CALL nvkms_close_gpu(NvU3 Link Here
700
{
699
{
701
    nvidia_modeset_stack_ptr stack = NULL;
700
    nvidia_modeset_stack_ptr stack = NULL;
702
701
703
    if (__rm_ops.alloc_stack(&stack) != 0) {
702
    if (__rm_ops->alloc_stack(&stack) != 0) {
704
        return;
703
        return;
705
    }
704
    }
706
705
707
    __rm_ops.close_gpu(gpuId, stack);
706
    __rm_ops->close_gpu(gpuId, stack);
708
707
709
    __rm_ops.free_stack(stack);
708
    __rm_ops->free_stack(stack);
710
}
709
}
711
710
712
NvU32 NVKMS_API_CALL nvkms_enumerate_gpus(nv_gpu_info_t *gpu_info)
711
NvU32 NVKMS_API_CALL nvkms_enumerate_gpus(nv_gpu_info_t *gpu_info)
713
{
712
{
714
    return __rm_ops.enumerate_gpus(gpu_info);
713
    return __rm_ops->enumerate_gpus(gpu_info);
715
}
714
}
716
715
717
NvBool NVKMS_API_CALL nvkms_allow_write_combining(void)
716
NvBool NVKMS_API_CALL nvkms_allow_write_combining(void)
718
{
717
{
719
    return __rm_ops.system_info.allow_write_combining;
718
    return __rm_ops->system_info.allow_write_combining;
720
}
719
}
721
720
722
/*************************************************************************
721
/*************************************************************************
(-)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 (-1 / +1 lines)
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 310-316 typedef struct Link Here
310
        // fault_buffer_ops: id is a hardware class
310
        // fault_buffer_ops: id is a hardware class
311
        uvm_fault_buffer_hal_t fault_buffer_ops;
311
        uvm_fault_buffer_hal_t fault_buffer_ops;
312
    } u;
312
    } u;
313
} uvm_hal_class_ops_t;
313
} __do_const uvm_hal_class_ops_t;
314
314
315
// When UVM next support is enabled support for future chips in the hal is
315
// When UVM next support is enabled support for future chips in the hal is
316
// enabled by providing additional hal table entries below.
316
// 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 175-182 static NV_STATUS uvmSetupGpuProvider(voi Link Here
175
{
174
{
176
    NV_STATUS status = NV_OK;
175
    NV_STATUS status = NV_OK;
177
176
178
    g_exportedUvmOps.startDevice = uvm_gpu_event_start_device;
177
    static struct UvmOpsUvmEvents g_exportedUvmOps = {
179
    g_exportedUvmOps.stopDevice  = uvm_gpu_event_stop_device;
178
        .startDevice = uvm_gpu_event_start_device,
179
        .stopDevice  = uvm_gpu_event_stop_device,
180
    };
180
181
181
    // call RM to exchange the function pointers.
182
    // call RM to exchange the function pointers.
182
    status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps);
183
    status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps);
(-)work.orig/kernel/nvidia-uvm/uvm_full_fault_buffer.h (-1 / +2 lines)
Lines 31-36 Link Here
31
#define _UVM_FULL_FAULT_BUFFER_H_
31
#define _UVM_FULL_FAULT_BUFFER_H_
32
32
33
#include "uvmtypes.h"
33
#include "uvmtypes.h"
34
#include "linux/compiler.h"
34
35
35
#define MAXWELL_FAULT_BUFFER_A (0xb069)
36
#define MAXWELL_FAULT_BUFFER_A (0xb069)
36
#define MEM_RD32(a) (*(const volatile NvU32 *)(a)) 
37
#define MEM_RD32(a) (*(const volatile NvU32 *)(a)) 
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 508-514 static inline NvU64 NV_GETTIME(void) Link Here
508
508
509
// WRITE_ONCE/READ_ONCE have incompatible definitions across versions, which produces warnings.
509
// WRITE_ONCE/READ_ONCE have incompatible definitions across versions, which produces warnings.
510
// Therefore, we define our own macros
510
// Therefore, we define our own macros
511
#define UVM_WRITE_ONCE(x, val) (ACCESS_ONCE(x) = (val))
511
#define UVM_WRITE_ONCE(x, val) (ACCESS_ONCE_RW(x) = (val))
512
#define UVM_READ_ONCE(x) ACCESS_ONCE(x)
512
#define UVM_READ_ONCE(x) ACCESS_ONCE(x)
513
513
514
// Added in 3.11
514
// Added in 3.11

Return to bug 586028