diff options
Diffstat (limited to 'include/os/linux/os_linux.h')
| -rw-r--r-- | include/os/linux/os_linux.h | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/include/os/linux/os_linux.h b/include/os/linux/os_linux.h new file mode 100644 index 0000000..25c6c03 --- /dev/null +++ b/include/os/linux/os_linux.h | |||
| @@ -0,0 +1,187 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef NVGPU_OS_LINUX_H | ||
| 18 | #define NVGPU_OS_LINUX_H | ||
| 19 | |||
| 20 | #include <linux/cdev.h> | ||
| 21 | #include <linux/iommu.h> | ||
| 22 | #include <linux/hashtable.h> | ||
| 23 | |||
| 24 | #include <nvgpu/gk20a.h> | ||
| 25 | |||
| 26 | #include "cde.h" | ||
| 27 | #include "sched.h" | ||
| 28 | |||
| 29 | struct nvgpu_os_linux_ops { | ||
| 30 | struct { | ||
| 31 | void (*get_program_numbers)(struct gk20a *g, | ||
| 32 | u32 block_height_log2, | ||
| 33 | u32 shader_parameter, | ||
| 34 | int *hprog, int *vprog); | ||
| 35 | bool (*need_scatter_buffer)(struct gk20a *g); | ||
| 36 | int (*populate_scatter_buffer)(struct gk20a *g, | ||
| 37 | struct sg_table *sgt, | ||
| 38 | size_t surface_size, | ||
| 39 | void *scatter_buffer_ptr, | ||
| 40 | size_t scatter_buffer_size); | ||
| 41 | } cde; | ||
| 42 | |||
| 43 | struct { | ||
| 44 | int (*init_debugfs)(struct gk20a *g); | ||
| 45 | } clk; | ||
| 46 | |||
| 47 | struct { | ||
| 48 | int (*init_debugfs)(struct gk20a *g); | ||
| 49 | } therm; | ||
| 50 | |||
| 51 | struct { | ||
| 52 | int (*init_debugfs)(struct gk20a *g); | ||
| 53 | } fecs_trace; | ||
| 54 | }; | ||
| 55 | |||
| 56 | struct nvgpu_os_linux { | ||
| 57 | struct gk20a g; | ||
| 58 | struct device *dev; | ||
| 59 | |||
| 60 | struct { | ||
| 61 | struct cdev cdev; | ||
| 62 | struct device *node; | ||
| 63 | } channel; | ||
| 64 | |||
| 65 | struct { | ||
| 66 | struct cdev cdev; | ||
| 67 | struct device *node; | ||
| 68 | /* see gk20a_ctrl_priv */ | ||
| 69 | struct nvgpu_list_node privs; | ||
| 70 | /* guards modifications to the list and its contents */ | ||
| 71 | struct nvgpu_mutex privs_lock; | ||
| 72 | } ctrl; | ||
| 73 | |||
| 74 | struct { | ||
| 75 | struct cdev cdev; | ||
| 76 | struct device *node; | ||
| 77 | } as_dev; | ||
| 78 | |||
| 79 | struct { | ||
| 80 | struct cdev cdev; | ||
| 81 | struct device *node; | ||
| 82 | } dbg; | ||
| 83 | |||
| 84 | struct { | ||
| 85 | struct cdev cdev; | ||
| 86 | struct device *node; | ||
| 87 | } prof; | ||
| 88 | |||
| 89 | struct { | ||
| 90 | struct cdev cdev; | ||
| 91 | struct device *node; | ||
| 92 | } tsg; | ||
| 93 | |||
| 94 | struct { | ||
| 95 | struct cdev cdev; | ||
| 96 | struct device *node; | ||
| 97 | } ctxsw; | ||
| 98 | |||
| 99 | struct { | ||
| 100 | struct cdev cdev; | ||
| 101 | struct device *node; | ||
| 102 | } sched; | ||
| 103 | |||
| 104 | dev_t cdev_region; | ||
| 105 | |||
| 106 | struct devfreq *devfreq; | ||
| 107 | |||
| 108 | struct device_dma_parameters dma_parms; | ||
| 109 | |||
| 110 | atomic_t hw_irq_stall_count; | ||
| 111 | atomic_t hw_irq_nonstall_count; | ||
| 112 | |||
| 113 | struct nvgpu_cond sw_irq_stall_last_handled_wq; | ||
| 114 | atomic_t sw_irq_stall_last_handled; | ||
| 115 | |||
| 116 | atomic_t nonstall_ops; | ||
| 117 | |||
| 118 | struct nvgpu_cond sw_irq_nonstall_last_handled_wq; | ||
| 119 | atomic_t sw_irq_nonstall_last_handled; | ||
| 120 | |||
| 121 | struct work_struct nonstall_fn_work; | ||
| 122 | struct workqueue_struct *nonstall_work_queue; | ||
| 123 | |||
| 124 | struct resource *reg_mem; | ||
| 125 | void __iomem *regs; | ||
| 126 | void __iomem *regs_saved; | ||
| 127 | |||
| 128 | struct resource *bar1_mem; | ||
| 129 | void __iomem *bar1; | ||
| 130 | void __iomem *bar1_saved; | ||
| 131 | |||
| 132 | void __iomem *usermode_regs; | ||
| 133 | void __iomem *usermode_regs_saved; | ||
| 134 | |||
| 135 | u64 regs_bus_addr; | ||
| 136 | |||
| 137 | struct nvgpu_os_linux_ops ops; | ||
| 138 | |||
| 139 | #ifdef CONFIG_DEBUG_FS | ||
| 140 | struct dentry *debugfs; | ||
| 141 | struct dentry *debugfs_alias; | ||
| 142 | |||
| 143 | struct dentry *debugfs_ltc_enabled; | ||
| 144 | struct dentry *debugfs_timeouts_enabled; | ||
| 145 | struct dentry *debugfs_gr_idle_timeout_default; | ||
| 146 | struct dentry *debugfs_disable_bigpage; | ||
| 147 | struct dentry *debugfs_gr_default_attrib_cb_size; | ||
| 148 | |||
| 149 | struct dentry *debugfs_timeslice_low_priority_us; | ||
| 150 | struct dentry *debugfs_timeslice_medium_priority_us; | ||
| 151 | struct dentry *debugfs_timeslice_high_priority_us; | ||
| 152 | struct dentry *debugfs_runlist_interleave; | ||
| 153 | struct dentry *debugfs_allocators; | ||
| 154 | struct dentry *debugfs_xve; | ||
| 155 | struct dentry *debugfs_kmem; | ||
| 156 | struct dentry *debugfs_hal; | ||
| 157 | struct dentry *debugfs_ltc; | ||
| 158 | |||
| 159 | struct dentry *debugfs_force_preemption_cilp; | ||
| 160 | struct dentry *debugfs_force_preemption_gfxp; | ||
| 161 | struct dentry *debugfs_dump_ctxsw_stats; | ||
| 162 | #endif | ||
| 163 | DECLARE_HASHTABLE(ecc_sysfs_stats_htable, 5); | ||
| 164 | struct dev_ext_attribute *ecc_attrs; | ||
| 165 | |||
| 166 | struct gk20a_cde_app cde_app; | ||
| 167 | |||
| 168 | struct rw_semaphore busy_lock; | ||
| 169 | |||
| 170 | bool init_done; | ||
| 171 | }; | ||
| 172 | |||
| 173 | static inline struct nvgpu_os_linux *nvgpu_os_linux_from_gk20a(struct gk20a *g) | ||
| 174 | { | ||
| 175 | return container_of(g, struct nvgpu_os_linux, g); | ||
| 176 | } | ||
| 177 | |||
| 178 | static inline struct device *dev_from_gk20a(struct gk20a *g) | ||
| 179 | { | ||
| 180 | return nvgpu_os_linux_from_gk20a(g)->dev; | ||
| 181 | } | ||
| 182 | |||
| 183 | #define INTERFACE_NAME "nvhost%s-gpu" | ||
| 184 | |||
| 185 | #define totalram_size_in_mb (totalram_pages >> (10 - (PAGE_SHIFT - 10))) | ||
| 186 | |||
| 187 | #endif | ||
