| .. | .. |
|---|
| 1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 1 | +/* SPDX-License-Identifier: MIT */ |
|---|
| 2 | 2 | #ifndef __NOUVEAU_DRV_H__ |
|---|
| 3 | 3 | #define __NOUVEAU_DRV_H__ |
|---|
| 4 | 4 | |
|---|
| .. | .. |
|---|
| 46 | 46 | #include <nvif/mmu.h> |
|---|
| 47 | 47 | #include <nvif/vmm.h> |
|---|
| 48 | 48 | |
|---|
| 49 | | -#include <drm/drmP.h> |
|---|
| 49 | +#include <drm/drm_connector.h> |
|---|
| 50 | +#include <drm/drm_device.h> |
|---|
| 51 | +#include <drm/drm_drv.h> |
|---|
| 52 | +#include <drm/drm_file.h> |
|---|
| 50 | 53 | |
|---|
| 51 | 54 | #include <drm/ttm/ttm_bo_api.h> |
|---|
| 52 | 55 | #include <drm/ttm/ttm_bo_driver.h> |
|---|
| .. | .. |
|---|
| 55 | 58 | #include <drm/ttm/ttm_module.h> |
|---|
| 56 | 59 | #include <drm/ttm/ttm_page_alloc.h> |
|---|
| 57 | 60 | |
|---|
| 61 | +#include <drm/drm_audio_component.h> |
|---|
| 62 | + |
|---|
| 58 | 63 | #include "uapi/drm/nouveau_drm.h" |
|---|
| 59 | 64 | |
|---|
| 60 | 65 | struct nouveau_channel; |
|---|
| 61 | 66 | struct platform_device; |
|---|
| 62 | | - |
|---|
| 63 | | -#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) |
|---|
| 64 | 67 | |
|---|
| 65 | 68 | #include "nouveau_fence.h" |
|---|
| 66 | 69 | #include "nouveau_bios.h" |
|---|
| .. | .. |
|---|
| 96 | 99 | struct nvif_device device; |
|---|
| 97 | 100 | struct nvif_mmu mmu; |
|---|
| 98 | 101 | struct nouveau_vmm vmm; |
|---|
| 102 | + struct nouveau_vmm svm; |
|---|
| 99 | 103 | const struct nvif_mclass *mem; |
|---|
| 100 | 104 | |
|---|
| 101 | 105 | struct list_head head; |
|---|
| .. | .. |
|---|
| 128 | 132 | } |
|---|
| 129 | 133 | |
|---|
| 130 | 134 | #include <nvif/object.h> |
|---|
| 131 | | -#include <nvif/device.h> |
|---|
| 135 | +#include <nvif/parent.h> |
|---|
| 132 | 136 | |
|---|
| 133 | 137 | struct nouveau_drm { |
|---|
| 138 | + struct nvif_parent parent; |
|---|
| 134 | 139 | struct nouveau_cli master; |
|---|
| 135 | 140 | struct nouveau_cli client; |
|---|
| 136 | 141 | struct drm_device *dev; |
|---|
| 137 | 142 | |
|---|
| 138 | 143 | struct list_head clients; |
|---|
| 144 | + |
|---|
| 145 | + /** |
|---|
| 146 | + * @clients_lock: Protects access to the @clients list of &struct nouveau_cli. |
|---|
| 147 | + */ |
|---|
| 148 | + struct mutex clients_lock; |
|---|
| 149 | + |
|---|
| 150 | + u8 old_pm_cap; |
|---|
| 139 | 151 | |
|---|
| 140 | 152 | struct { |
|---|
| 141 | 153 | struct agp_bridge_data *bridge; |
|---|
| .. | .. |
|---|
| 146 | 158 | |
|---|
| 147 | 159 | /* TTM interface support */ |
|---|
| 148 | 160 | struct { |
|---|
| 149 | | - struct drm_global_reference mem_global_ref; |
|---|
| 150 | | - struct ttm_bo_global_ref bo_global_ref; |
|---|
| 151 | 161 | struct ttm_bo_device bdev; |
|---|
| 152 | 162 | atomic_t validate_sequence; |
|---|
| 153 | 163 | int (*move)(struct nouveau_channel *, |
|---|
| 154 | 164 | struct ttm_buffer_object *, |
|---|
| 155 | | - struct ttm_mem_reg *, struct ttm_mem_reg *); |
|---|
| 165 | + struct ttm_resource *, struct ttm_resource *); |
|---|
| 156 | 166 | struct nouveau_channel *chan; |
|---|
| 157 | 167 | struct nvif_object copy; |
|---|
| 158 | 168 | int mtrr; |
|---|
| 159 | 169 | int type_vram; |
|---|
| 160 | 170 | int type_host[2]; |
|---|
| 161 | 171 | int type_ncoh[2]; |
|---|
| 172 | + struct mutex io_reserve_mutex; |
|---|
| 173 | + struct list_head io_reserve_lru; |
|---|
| 162 | 174 | } ttm; |
|---|
| 163 | 175 | |
|---|
| 164 | 176 | /* GEM interface support */ |
|---|
| .. | .. |
|---|
| 181 | 193 | struct nouveau_channel *channel; |
|---|
| 182 | 194 | struct nvkm_gpuobj *notify; |
|---|
| 183 | 195 | struct nouveau_fbdev *fbcon; |
|---|
| 184 | | - struct nvif_object nvsw; |
|---|
| 185 | 196 | struct nvif_object ntfy; |
|---|
| 186 | | - struct nvif_notify flip; |
|---|
| 187 | 197 | |
|---|
| 188 | 198 | /* nv10-nv40 tiling regions */ |
|---|
| 189 | 199 | struct { |
|---|
| .. | .. |
|---|
| 194 | 204 | /* modesetting */ |
|---|
| 195 | 205 | struct nvbios vbios; |
|---|
| 196 | 206 | struct nouveau_display *display; |
|---|
| 197 | | - struct backlight_device *backlight; |
|---|
| 198 | | - struct list_head bl_connectors; |
|---|
| 199 | 207 | struct work_struct hpd_work; |
|---|
| 208 | + struct mutex hpd_lock; |
|---|
| 209 | + u32 hpd_pending; |
|---|
| 200 | 210 | struct work_struct fbcon_work; |
|---|
| 201 | 211 | int fbcon_new_state; |
|---|
| 202 | 212 | #ifdef CONFIG_ACPI |
|---|
| .. | .. |
|---|
| 210 | 220 | /* led management */ |
|---|
| 211 | 221 | struct nouveau_led *led; |
|---|
| 212 | 222 | |
|---|
| 213 | | - /* display power reference */ |
|---|
| 214 | | - bool have_disp_power_ref; |
|---|
| 215 | | - |
|---|
| 216 | 223 | struct dev_pm_domain vga_pm_domain; |
|---|
| 224 | + |
|---|
| 225 | + struct nouveau_svm *svm; |
|---|
| 226 | + |
|---|
| 227 | + struct nouveau_dmem *dmem; |
|---|
| 228 | + |
|---|
| 229 | + struct { |
|---|
| 230 | + struct drm_audio_component *component; |
|---|
| 231 | + bool component_registered; |
|---|
| 232 | + } audio; |
|---|
| 217 | 233 | }; |
|---|
| 218 | 234 | |
|---|
| 219 | 235 | static inline struct nouveau_drm * |
|---|
| .. | .. |
|---|
| 244 | 260 | struct nouveau_cli *_cli = (c); \ |
|---|
| 245 | 261 | dev_##l(_cli->drm->dev->dev, "%s: "f, _cli->name, ##a); \ |
|---|
| 246 | 262 | } while(0) |
|---|
| 263 | + |
|---|
| 247 | 264 | #define NV_FATAL(drm,f,a...) NV_PRINTK(crit, &(drm)->client, f, ##a) |
|---|
| 248 | 265 | #define NV_ERROR(drm,f,a...) NV_PRINTK(err, &(drm)->client, f, ##a) |
|---|
| 249 | 266 | #define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a) |
|---|
| 250 | 267 | #define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a) |
|---|
| 268 | + |
|---|
| 251 | 269 | #define NV_DEBUG(drm,f,a...) do { \ |
|---|
| 252 | | - if (unlikely(drm_debug & DRM_UT_DRIVER)) \ |
|---|
| 270 | + if (drm_debug_enabled(DRM_UT_DRIVER)) \ |
|---|
| 253 | 271 | NV_PRINTK(info, &(drm)->client, f, ##a); \ |
|---|
| 254 | 272 | } while(0) |
|---|
| 255 | 273 | #define NV_ATOMIC(drm,f,a...) do { \ |
|---|
| 256 | | - if (unlikely(drm_debug & DRM_UT_ATOMIC)) \ |
|---|
| 274 | + if (drm_debug_enabled(DRM_UT_ATOMIC)) \ |
|---|
| 257 | 275 | NV_PRINTK(info, &(drm)->client, f, ##a); \ |
|---|
| 258 | 276 | } while(0) |
|---|
| 259 | 277 | |
|---|
| 278 | +#define NV_PRINTK_ONCE(l,c,f,a...) NV_PRINTK(l##_once,c,f, ##a) |
|---|
| 279 | + |
|---|
| 280 | +#define NV_ERROR_ONCE(drm,f,a...) NV_PRINTK_ONCE(err, &(drm)->client, f, ##a) |
|---|
| 281 | +#define NV_WARN_ONCE(drm,f,a...) NV_PRINTK_ONCE(warn, &(drm)->client, f, ##a) |
|---|
| 282 | +#define NV_INFO_ONCE(drm,f,a...) NV_PRINTK_ONCE(info, &(drm)->client, f, ##a) |
|---|
| 283 | + |
|---|
| 260 | 284 | extern int nouveau_modeset; |
|---|
| 261 | 285 | |
|---|
| 262 | 286 | #endif |
|---|