1 1.49 riastrad /* $NetBSD: i915_drv.h,v 1.49 2024/04/16 14:34:02 riastradh Exp $ */ 2 1.12 riastrad 3 1.1 riastrad /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*- 4 1.1 riastrad */ 5 1.1 riastrad /* 6 1.1 riastrad * 7 1.1 riastrad * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 8 1.1 riastrad * All Rights Reserved. 9 1.1 riastrad * 10 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 11 1.1 riastrad * copy of this software and associated documentation files (the 12 1.1 riastrad * "Software"), to deal in the Software without restriction, including 13 1.1 riastrad * without limitation the rights to use, copy, modify, merge, publish, 14 1.1 riastrad * distribute, sub license, and/or sell copies of the Software, and to 15 1.1 riastrad * permit persons to whom the Software is furnished to do so, subject to 16 1.1 riastrad * the following conditions: 17 1.1 riastrad * 18 1.1 riastrad * The above copyright notice and this permission notice (including the 19 1.1 riastrad * next paragraph) shall be included in all copies or substantial portions 20 1.1 riastrad * of the Software. 21 1.1 riastrad * 22 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 23 1.1 riastrad * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 1.1 riastrad * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 25 1.1 riastrad * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 26 1.1 riastrad * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 27 1.1 riastrad * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 28 1.1 riastrad * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 1.1 riastrad * 30 1.1 riastrad */ 31 1.1 riastrad 32 1.1 riastrad #ifndef _I915_DRV_H_ 33 1.1 riastrad #define _I915_DRV_H_ 34 1.1 riastrad 35 1.4 riastrad #include <uapi/drm/i915_drm.h> 36 1.12 riastrad #include <uapi/drm/drm_fourcc.h> 37 1.4 riastrad 38 1.1 riastrad #include <linux/io-mapping.h> 39 1.1 riastrad #include <linux/i2c.h> 40 1.1 riastrad #include <linux/i2c-algo-bit.h> 41 1.1 riastrad #include <linux/backlight.h> 42 1.34 riastrad #include <linux/hash.h> 43 1.1 riastrad #include <linux/intel-iommu.h> 44 1.1 riastrad #include <linux/kref.h> 45 1.34 riastrad #include <linux/mm_types.h> 46 1.34 riastrad #include <linux/perf_event.h> 47 1.4 riastrad #include <linux/pm_qos.h> 48 1.34 riastrad #include <linux/dma-resv.h> 49 1.34 riastrad #include <linux/shmem_fs.h> 50 1.34 riastrad #include <linux/stackdepot.h> 51 1.34 riastrad #include <linux/xarray.h> 52 1.35 riastrad #include <linux/uuid.h> 53 1.49 riastrad #include <linux/acpi.h> 54 1.34 riastrad 55 1.34 riastrad #include <drm/intel-gtt.h> 56 1.34 riastrad #include <drm/drm_legacy.h> /* for struct drm_dma_handle */ 57 1.34 riastrad #include <drm/drm_gem.h> 58 1.34 riastrad #include <drm/drm_auth.h> 59 1.34 riastrad #include <drm/drm_cache.h> 60 1.34 riastrad #include <drm/drm_util.h> 61 1.34 riastrad #include <drm/drm_dsc.h> 62 1.34 riastrad #include <drm/drm_atomic.h> 63 1.34 riastrad #include <drm/drm_connector.h> 64 1.34 riastrad #include <drm/i915_mei_hdcp_interface.h> 65 1.1 riastrad 66 1.34 riastrad #include "i915_fixed.h" 67 1.34 riastrad #include "i915_params.h" 68 1.34 riastrad #include "i915_reg.h" 69 1.34 riastrad #include "i915_utils.h" 70 1.1 riastrad 71 1.34 riastrad #include "display/intel_bios.h" 72 1.34 riastrad #include "display/intel_display.h" 73 1.34 riastrad #include "display/intel_display_power.h" 74 1.34 riastrad #include "display/intel_dpll_mgr.h" 75 1.34 riastrad #include "display/intel_dsb.h" 76 1.34 riastrad #include "display/intel_frontbuffer.h" 77 1.34 riastrad #include "display/intel_gmbus.h" 78 1.34 riastrad #include "display/intel_opregion.h" 79 1.34 riastrad 80 1.34 riastrad #include "gem/i915_gem_context_types.h" 81 1.34 riastrad #include "gem/i915_gem_shrinker.h" 82 1.34 riastrad #include "gem/i915_gem_stolen.h" 83 1.34 riastrad 84 1.34 riastrad #include "gt/intel_lrc.h" 85 1.34 riastrad #include "gt/intel_engine.h" 86 1.34 riastrad #include "gt/intel_gt_types.h" 87 1.34 riastrad #include "gt/intel_workarounds.h" 88 1.34 riastrad #include "gt/uc/intel_uc.h" 89 1.34 riastrad 90 1.34 riastrad #include "intel_device_info.h" 91 1.34 riastrad #include "intel_pch.h" 92 1.34 riastrad #include "intel_runtime_pm.h" 93 1.34 riastrad #include "intel_memory_region.h" 94 1.34 riastrad #include "intel_uncore.h" 95 1.34 riastrad #include "intel_wakeref.h" 96 1.34 riastrad #include "intel_wopcm.h" 97 1.12 riastrad 98 1.34 riastrad #include "i915_gem.h" 99 1.34 riastrad #include "i915_gem_fence_reg.h" 100 1.34 riastrad #include "i915_gem_gtt.h" 101 1.34 riastrad #include "i915_gpu_error.h" 102 1.34 riastrad #include "i915_perf_types.h" 103 1.34 riastrad #include "i915_request.h" 104 1.34 riastrad #include "i915_scheduler.h" 105 1.34 riastrad #include "gt/intel_timeline.h" 106 1.34 riastrad #include "i915_vma.h" 107 1.34 riastrad #include "i915_irq.h" 108 1.12 riastrad 109 1.34 riastrad #include "intel_region_lmem.h" 110 1.12 riastrad 111 1.34 riastrad #include "intel_gvt.h" 112 1.12 riastrad 113 1.34 riastrad /* General customization: 114 1.12 riastrad */ 115 1.12 riastrad 116 1.34 riastrad #define DRIVER_NAME "i915" 117 1.34 riastrad #define DRIVER_DESC "Intel Graphics" 118 1.34 riastrad #define DRIVER_DATE "20200114" 119 1.34 riastrad #define DRIVER_TIMESTAMP 1579001978 120 1.1 riastrad 121 1.34 riastrad struct drm_i915_gem_object; 122 1.4 riastrad 123 1.4 riastrad enum hpd_pin { 124 1.4 riastrad HPD_NONE = 0, 125 1.4 riastrad HPD_TV = HPD_NONE, /* TV is known to be unreliable */ 126 1.4 riastrad HPD_CRT, 127 1.4 riastrad HPD_SDVO_B, 128 1.4 riastrad HPD_SDVO_C, 129 1.12 riastrad HPD_PORT_A, 130 1.4 riastrad HPD_PORT_B, 131 1.4 riastrad HPD_PORT_C, 132 1.4 riastrad HPD_PORT_D, 133 1.12 riastrad HPD_PORT_E, 134 1.34 riastrad HPD_PORT_F, 135 1.34 riastrad HPD_PORT_G, 136 1.34 riastrad HPD_PORT_H, 137 1.34 riastrad HPD_PORT_I, 138 1.34 riastrad 139 1.4 riastrad HPD_NUM_PINS 140 1.4 riastrad }; 141 1.4 riastrad 142 1.12 riastrad #define for_each_hpd_pin(__pin) \ 143 1.12 riastrad for ((__pin) = (HPD_NONE + 1); (__pin) < HPD_NUM_PINS; (__pin)++) 144 1.12 riastrad 145 1.34 riastrad /* Threshold == 5 for long IRQs, 50 for short */ 146 1.34 riastrad #define HPD_STORM_DEFAULT_THRESHOLD 50 147 1.34 riastrad 148 1.12 riastrad struct i915_hotplug { 149 1.34 riastrad struct delayed_work hotplug_work; 150 1.12 riastrad 151 1.12 riastrad struct { 152 1.12 riastrad unsigned long last_jiffies; 153 1.12 riastrad int count; 154 1.12 riastrad enum { 155 1.12 riastrad HPD_ENABLED = 0, 156 1.12 riastrad HPD_DISABLED = 1, 157 1.12 riastrad HPD_MARK_DISABLED = 2 158 1.12 riastrad } state; 159 1.12 riastrad } stats[HPD_NUM_PINS]; 160 1.12 riastrad u32 event_bits; 161 1.34 riastrad u32 retry_bits; 162 1.12 riastrad struct delayed_work reenable_work; 163 1.12 riastrad 164 1.12 riastrad u32 long_port_mask; 165 1.12 riastrad u32 short_port_mask; 166 1.12 riastrad struct work_struct dig_port_work; 167 1.12 riastrad 168 1.34 riastrad struct work_struct poll_init_work; 169 1.34 riastrad bool poll_enabled; 170 1.34 riastrad 171 1.34 riastrad unsigned int hpd_storm_threshold; 172 1.34 riastrad /* Whether or not to count short HPD IRQs in HPD storms */ 173 1.34 riastrad u8 hpd_short_storm_enabled; 174 1.34 riastrad 175 1.12 riastrad /* 176 1.12 riastrad * if we get a HPD irq from DP and a HPD irq from non-DP 177 1.12 riastrad * the non-DP HPD could block the workqueue on a mode config 178 1.12 riastrad * mutex getting, that userspace may have taken. However 179 1.12 riastrad * userspace is waiting on the DP workqueue to run which is 180 1.12 riastrad * blocked behind the non-DP one. 181 1.12 riastrad */ 182 1.12 riastrad struct workqueue_struct *dp_wq; 183 1.12 riastrad }; 184 1.12 riastrad 185 1.4 riastrad #define I915_GEM_GPU_DOMAINS \ 186 1.4 riastrad (I915_GEM_DOMAIN_RENDER | \ 187 1.4 riastrad I915_GEM_DOMAIN_SAMPLER | \ 188 1.4 riastrad I915_GEM_DOMAIN_COMMAND | \ 189 1.4 riastrad I915_GEM_DOMAIN_INSTRUCTION | \ 190 1.4 riastrad I915_GEM_DOMAIN_VERTEX) 191 1.1 riastrad 192 1.4 riastrad struct drm_i915_private; 193 1.12 riastrad struct i915_mm_struct; 194 1.12 riastrad struct i915_mmu_object; 195 1.12 riastrad 196 1.12 riastrad struct drm_i915_file_private { 197 1.12 riastrad struct drm_i915_private *dev_priv; 198 1.34 riastrad 199 1.34 riastrad union { 200 1.34 riastrad struct drm_file *file; 201 1.34 riastrad struct rcu_head rcu; 202 1.34 riastrad }; 203 1.12 riastrad 204 1.12 riastrad struct { 205 1.12 riastrad spinlock_t lock; 206 1.12 riastrad struct list_head request_list; 207 1.12 riastrad } mm; 208 1.12 riastrad 209 1.34 riastrad struct xarray context_xa; 210 1.12 riastrad 211 1.34 riastrad struct idr vm_idr; 212 1.34 riastrad struct mutex vm_idr_lock; /* guards vm_idr */ 213 1.34 riastrad 214 1.34 riastrad unsigned int bsd_engine; 215 1.34 riastrad 216 1.34 riastrad /* 217 1.34 riastrad * Every context ban increments per client ban score. Also 218 1.34 riastrad * hangs in short succession increments ban score. If ban threshold 219 1.34 riastrad * is reached, client is considered banned and submitting more work 220 1.34 riastrad * will fail. This is a stop gap measure to limit the badly behaving 221 1.34 riastrad * clients access to gpu. Note that unbannable contexts never increment 222 1.34 riastrad * the client ban score. 223 1.34 riastrad */ 224 1.34 riastrad #define I915_CLIENT_SCORE_HANG_FAST 1 225 1.34 riastrad #define I915_CLIENT_FAST_HANG_JIFFIES (60 * HZ) 226 1.34 riastrad #define I915_CLIENT_SCORE_CONTEXT_BAN 3 227 1.34 riastrad #define I915_CLIENT_SCORE_BANNED 9 228 1.34 riastrad /** ban_score: Accumulated score of all ctx bans and fast hangs. */ 229 1.34 riastrad atomic_t ban_score; 230 1.34 riastrad unsigned long hang_timestamp; 231 1.34 riastrad }; 232 1.1 riastrad 233 1.1 riastrad /* Interface history: 234 1.1 riastrad * 235 1.1 riastrad * 1.1: Original. 236 1.1 riastrad * 1.2: Add Power Management 237 1.1 riastrad * 1.3: Add vblank support 238 1.1 riastrad * 1.4: Fix cmdbuffer path, add heap destroy 239 1.1 riastrad * 1.5: Add vblank pipe configuration 240 1.1 riastrad * 1.6: - New ioctl for scheduling buffer swaps on vertical blank 241 1.1 riastrad * - Support vertical blank on secondary display pipe 242 1.1 riastrad */ 243 1.1 riastrad #define DRIVER_MAJOR 1 244 1.1 riastrad #define DRIVER_MINOR 6 245 1.1 riastrad #define DRIVER_PATCHLEVEL 0 246 1.1 riastrad 247 1.1 riastrad struct intel_overlay; 248 1.1 riastrad struct intel_overlay_error_state; 249 1.1 riastrad 250 1.1 riastrad struct sdvo_device_mapping { 251 1.1 riastrad u8 initialized; 252 1.1 riastrad u8 dvo_port; 253 1.1 riastrad u8 slave_addr; 254 1.1 riastrad u8 dvo_wiring; 255 1.1 riastrad u8 i2c_pin; 256 1.1 riastrad u8 ddc_pin; 257 1.1 riastrad }; 258 1.1 riastrad 259 1.4 riastrad struct intel_connector; 260 1.12 riastrad struct intel_encoder; 261 1.34 riastrad struct intel_atomic_state; 262 1.12 riastrad struct intel_crtc_state; 263 1.12 riastrad struct intel_initial_plane_config; 264 1.4 riastrad struct intel_crtc; 265 1.4 riastrad struct intel_limit; 266 1.4 riastrad struct dpll; 267 1.34 riastrad struct intel_cdclk_state; 268 1.4 riastrad 269 1.1 riastrad struct drm_i915_display_funcs { 270 1.34 riastrad void (*get_cdclk)(struct drm_i915_private *dev_priv, 271 1.34 riastrad struct intel_cdclk_state *cdclk_state); 272 1.34 riastrad void (*set_cdclk)(struct drm_i915_private *dev_priv, 273 1.34 riastrad const struct intel_cdclk_state *cdclk_state, 274 1.34 riastrad enum pipe pipe); 275 1.34 riastrad int (*get_fifo_size)(struct drm_i915_private *dev_priv, 276 1.34 riastrad enum i9xx_plane_id i9xx_plane); 277 1.34 riastrad int (*compute_pipe_wm)(struct intel_crtc_state *crtc_state); 278 1.34 riastrad int (*compute_intermediate_wm)(struct intel_crtc_state *crtc_state); 279 1.34 riastrad void (*initial_watermarks)(struct intel_atomic_state *state, 280 1.34 riastrad struct intel_crtc *crtc); 281 1.34 riastrad void (*atomic_update_watermarks)(struct intel_atomic_state *state, 282 1.34 riastrad struct intel_crtc *crtc); 283 1.34 riastrad void (*optimize_watermarks)(struct intel_atomic_state *state, 284 1.34 riastrad struct intel_crtc *crtc); 285 1.34 riastrad int (*compute_global_watermarks)(struct intel_atomic_state *state); 286 1.34 riastrad void (*update_wm)(struct intel_crtc *crtc); 287 1.34 riastrad int (*modeset_calc_cdclk)(struct intel_atomic_state *state); 288 1.34 riastrad u8 (*calc_voltage_level)(int cdclk); 289 1.4 riastrad /* Returns the active state of the crtc, and if the crtc is active, 290 1.4 riastrad * fills out the pipe-config with the hw state. */ 291 1.4 riastrad bool (*get_pipe_config)(struct intel_crtc *, 292 1.12 riastrad struct intel_crtc_state *); 293 1.12 riastrad void (*get_initial_plane_config)(struct intel_crtc *, 294 1.12 riastrad struct intel_initial_plane_config *); 295 1.12 riastrad int (*crtc_compute_clock)(struct intel_crtc *crtc, 296 1.12 riastrad struct intel_crtc_state *crtc_state); 297 1.34 riastrad void (*crtc_enable)(struct intel_atomic_state *state, 298 1.34 riastrad struct intel_crtc *crtc); 299 1.34 riastrad void (*crtc_disable)(struct intel_atomic_state *state, 300 1.34 riastrad struct intel_crtc *crtc); 301 1.34 riastrad void (*commit_modeset_enables)(struct intel_atomic_state *state); 302 1.34 riastrad void (*commit_modeset_disables)(struct intel_atomic_state *state); 303 1.34 riastrad void (*audio_codec_enable)(struct intel_encoder *encoder, 304 1.34 riastrad const struct intel_crtc_state *crtc_state, 305 1.34 riastrad const struct drm_connector_state *conn_state); 306 1.34 riastrad void (*audio_codec_disable)(struct intel_encoder *encoder, 307 1.34 riastrad const struct intel_crtc_state *old_crtc_state, 308 1.34 riastrad const struct drm_connector_state *old_conn_state); 309 1.34 riastrad void (*fdi_link_train)(struct intel_crtc *crtc, 310 1.34 riastrad const struct intel_crtc_state *crtc_state); 311 1.34 riastrad void (*init_clock_gating)(struct drm_i915_private *dev_priv); 312 1.34 riastrad void (*hpd_irq_setup)(struct drm_i915_private *dev_priv); 313 1.1 riastrad /* clock updates for mode set */ 314 1.1 riastrad /* cursor updates */ 315 1.1 riastrad /* render clock increase/decrease */ 316 1.1 riastrad /* display clock increase/decrease */ 317 1.1 riastrad /* pll clock increase/decrease */ 318 1.4 riastrad 319 1.34 riastrad int (*color_check)(struct intel_crtc_state *crtc_state); 320 1.34 riastrad /* 321 1.34 riastrad * Program double buffered color management registers during 322 1.34 riastrad * vblank evasion. The registers should then latch during the 323 1.34 riastrad * next vblank start, alongside any other double buffered registers 324 1.34 riastrad * involved with the same commit. 325 1.34 riastrad */ 326 1.34 riastrad void (*color_commit)(const struct intel_crtc_state *crtc_state); 327 1.34 riastrad /* 328 1.34 riastrad * Load LUTs (and other single buffered color management 329 1.34 riastrad * registers). Will (hopefully) be called during the vblank 330 1.34 riastrad * following the latching of any double buffered registers 331 1.34 riastrad * involved with the same commit. 332 1.34 riastrad */ 333 1.34 riastrad void (*load_luts)(const struct intel_crtc_state *crtc_state); 334 1.34 riastrad void (*read_luts)(struct intel_crtc_state *crtc_state); 335 1.12 riastrad }; 336 1.12 riastrad 337 1.12 riastrad struct intel_csr { 338 1.34 riastrad struct work_struct work; 339 1.12 riastrad const char *fw_path; 340 1.34 riastrad u32 required_version; 341 1.34 riastrad u32 max_fw_size; /* bytes */ 342 1.34 riastrad u32 *dmc_payload; 343 1.34 riastrad u32 dmc_fw_size; /* dwords */ 344 1.34 riastrad u32 version; 345 1.34 riastrad u32 mmio_count; 346 1.34 riastrad i915_reg_t mmioaddr[20]; 347 1.34 riastrad u32 mmiodata[20]; 348 1.34 riastrad u32 dc_state; 349 1.34 riastrad u32 target_dc_state; 350 1.34 riastrad u32 allowed_dc_mask; 351 1.34 riastrad intel_wakeref_t wakeref; 352 1.4 riastrad }; 353 1.4 riastrad 354 1.4 riastrad enum i915_cache_level { 355 1.4 riastrad I915_CACHE_NONE = 0, 356 1.4 riastrad I915_CACHE_LLC, /* also used for snoopable memory on non-LLC */ 357 1.4 riastrad I915_CACHE_L3_LLC, /* gen7+, L3 sits between the domain specifc 358 1.4 riastrad caches, eg sampler/render caches, and the 359 1.4 riastrad large Last-Level-Cache. LLC is coherent with 360 1.4 riastrad the CPU, but L3 is only visible to the GPU. */ 361 1.4 riastrad I915_CACHE_WT, /* hsw:gt3e WriteThrough for scanouts */ 362 1.4 riastrad }; 363 1.4 riastrad 364 1.34 riastrad #define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */ 365 1.12 riastrad 366 1.34 riastrad struct intel_fbc { 367 1.12 riastrad /* This is always the inner lock when overlapping with struct_mutex and 368 1.12 riastrad * it's the outer lock when overlapping with stolen_lock. */ 369 1.12 riastrad struct mutex lock; 370 1.12 riastrad unsigned threshold; 371 1.12 riastrad unsigned int possible_framebuffer_bits; 372 1.12 riastrad unsigned int busy_bits; 373 1.12 riastrad struct intel_crtc *crtc; 374 1.4 riastrad 375 1.12 riastrad struct drm_mm_node compressed_fb; 376 1.4 riastrad struct drm_mm_node *compressed_llb; 377 1.4 riastrad 378 1.12 riastrad bool false_color; 379 1.12 riastrad 380 1.34 riastrad bool active; 381 1.34 riastrad bool activated; 382 1.34 riastrad bool flip_pending; 383 1.34 riastrad 384 1.34 riastrad bool underrun_detected; 385 1.34 riastrad struct work_struct underrun_work; 386 1.34 riastrad 387 1.34 riastrad /* 388 1.34 riastrad * Due to the atomic rules we can't access some structures without the 389 1.34 riastrad * appropriate locking, so we cache information here in order to avoid 390 1.34 riastrad * these problems. 391 1.34 riastrad */ 392 1.34 riastrad struct intel_fbc_state_cache { 393 1.34 riastrad struct { 394 1.34 riastrad unsigned int mode_flags; 395 1.34 riastrad u32 hsw_bdw_pixel_rate; 396 1.34 riastrad } crtc; 397 1.34 riastrad 398 1.34 riastrad struct { 399 1.34 riastrad unsigned int rotation; 400 1.34 riastrad int src_w; 401 1.34 riastrad int src_h; 402 1.34 riastrad bool visible; 403 1.34 riastrad /* 404 1.34 riastrad * Display surface base address adjustement for 405 1.34 riastrad * pageflips. Note that on gen4+ this only adjusts up 406 1.34 riastrad * to a tile, offsets within a tile are handled in 407 1.34 riastrad * the hw itself (with the TILEOFF register). 408 1.34 riastrad */ 409 1.34 riastrad int adjusted_x; 410 1.34 riastrad int adjusted_y; 411 1.34 riastrad 412 1.34 riastrad int y; 413 1.34 riastrad 414 1.34 riastrad u16 pixel_blend_mode; 415 1.34 riastrad } plane; 416 1.34 riastrad 417 1.34 riastrad struct { 418 1.34 riastrad const struct drm_format_info *format; 419 1.34 riastrad unsigned int stride; 420 1.34 riastrad } fb; 421 1.34 riastrad u16 gen9_wa_cfb_stride; 422 1.34 riastrad s8 fence_id; 423 1.34 riastrad } state_cache; 424 1.34 riastrad 425 1.34 riastrad /* 426 1.34 riastrad * This structure contains everything that's relevant to program the 427 1.34 riastrad * hardware registers. When we want to figure out if we need to disable 428 1.34 riastrad * and re-enable FBC for a new configuration we just check if there's 429 1.34 riastrad * something different in the struct. The genx_fbc_activate functions 430 1.34 riastrad * are supposed to read from it in order to program the registers. 431 1.34 riastrad */ 432 1.34 riastrad struct intel_fbc_reg_params { 433 1.34 riastrad struct { 434 1.34 riastrad enum pipe pipe; 435 1.34 riastrad enum i9xx_plane_id i9xx_plane; 436 1.34 riastrad unsigned int fence_y_offset; 437 1.34 riastrad } crtc; 438 1.34 riastrad 439 1.34 riastrad struct { 440 1.34 riastrad const struct drm_format_info *format; 441 1.34 riastrad unsigned int stride; 442 1.34 riastrad } fb; 443 1.34 riastrad 444 1.34 riastrad int cfb_size; 445 1.34 riastrad u16 gen9_wa_cfb_stride; 446 1.34 riastrad s8 fence_id; 447 1.34 riastrad bool plane_visible; 448 1.34 riastrad } params; 449 1.12 riastrad 450 1.34 riastrad const char *no_fbc_reason; 451 1.12 riastrad }; 452 1.12 riastrad 453 1.34 riastrad /* 454 1.12 riastrad * HIGH_RR is the highest eDP panel refresh rate read from EDID 455 1.12 riastrad * LOW_RR is the lowest eDP panel refresh rate found from EDID 456 1.12 riastrad * parsing for same resolution. 457 1.12 riastrad */ 458 1.12 riastrad enum drrs_refresh_rate_type { 459 1.12 riastrad DRRS_HIGH_RR, 460 1.12 riastrad DRRS_LOW_RR, 461 1.12 riastrad DRRS_MAX_RR, /* RR count */ 462 1.12 riastrad }; 463 1.12 riastrad 464 1.12 riastrad enum drrs_support_type { 465 1.12 riastrad DRRS_NOT_SUPPORTED = 0, 466 1.12 riastrad STATIC_DRRS_SUPPORT = 1, 467 1.12 riastrad SEAMLESS_DRRS_SUPPORT = 2 468 1.12 riastrad }; 469 1.12 riastrad 470 1.12 riastrad struct intel_dp; 471 1.12 riastrad struct i915_drrs { 472 1.12 riastrad struct mutex mutex; 473 1.12 riastrad struct delayed_work work; 474 1.12 riastrad struct intel_dp *dp; 475 1.12 riastrad unsigned busy_frontbuffer_bits; 476 1.12 riastrad enum drrs_refresh_rate_type refresh_rate_type; 477 1.12 riastrad enum drrs_support_type type; 478 1.4 riastrad }; 479 1.4 riastrad 480 1.4 riastrad struct i915_psr { 481 1.12 riastrad struct mutex lock; 482 1.34 riastrad 483 1.34 riastrad #define I915_PSR_DEBUG_MODE_MASK 0x0f 484 1.34 riastrad #define I915_PSR_DEBUG_DEFAULT 0x00 485 1.34 riastrad #define I915_PSR_DEBUG_DISABLE 0x01 486 1.34 riastrad #define I915_PSR_DEBUG_ENABLE 0x02 487 1.34 riastrad #define I915_PSR_DEBUG_FORCE_PSR1 0x03 488 1.34 riastrad #define I915_PSR_DEBUG_IRQ 0x10 489 1.34 riastrad 490 1.34 riastrad u32 debug; 491 1.4 riastrad bool sink_support; 492 1.34 riastrad bool enabled; 493 1.34 riastrad struct intel_dp *dp; 494 1.34 riastrad enum pipe pipe; 495 1.34 riastrad enum transcoder transcoder; 496 1.12 riastrad bool active; 497 1.34 riastrad struct work_struct work; 498 1.12 riastrad unsigned busy_frontbuffer_bits; 499 1.34 riastrad bool sink_psr2_support; 500 1.34 riastrad bool link_standby; 501 1.34 riastrad bool colorimetry_support; 502 1.34 riastrad bool psr2_enabled; 503 1.34 riastrad u8 sink_sync_latency; 504 1.34 riastrad ktime_t last_entry_attempt; 505 1.34 riastrad ktime_t last_exit; 506 1.34 riastrad bool sink_not_reliable; 507 1.34 riastrad bool irq_aux_error; 508 1.34 riastrad u16 su_x_granularity; 509 1.34 riastrad bool dc3co_enabled; 510 1.34 riastrad u32 dc3co_exit_delay; 511 1.34 riastrad struct delayed_work idle_work; 512 1.34 riastrad bool initially_probed; 513 1.1 riastrad }; 514 1.1 riastrad 515 1.1 riastrad #define QUIRK_LVDS_SSC_DISABLE (1<<1) 516 1.1 riastrad #define QUIRK_INVERT_BRIGHTNESS (1<<2) 517 1.12 riastrad #define QUIRK_BACKLIGHT_PRESENT (1<<3) 518 1.12 riastrad #define QUIRK_PIN_SWIZZLED_PAGES (1<<5) 519 1.34 riastrad #define QUIRK_INCREASE_T12_DELAY (1<<6) 520 1.34 riastrad #define QUIRK_INCREASE_DDI_DISABLED_TIME (1<<7) 521 1.1 riastrad 522 1.24 riastrad #ifdef __NetBSD__ 523 1.24 riastrad /* NetBSD hack to note version was called and thus mmap flags valid. */ 524 1.24 riastrad #define QUIRK_NETBSD_VERSION_CALLED (1ul<<31) 525 1.24 riastrad #endif 526 1.24 riastrad 527 1.1 riastrad struct intel_fbdev; 528 1.1 riastrad struct intel_fbc_work; 529 1.1 riastrad 530 1.1 riastrad struct intel_gmbus { 531 1.1 riastrad struct i2c_adapter adapter; 532 1.34 riastrad #define GMBUS_FORCE_BIT_RETRY (1U << 31) 533 1.1 riastrad u32 force_bit; 534 1.1 riastrad u32 reg0; 535 1.34 riastrad i915_reg_t gpio_reg; 536 1.1 riastrad struct i2c_algo_bit_data bit_algo; 537 1.1 riastrad struct drm_i915_private *dev_priv; 538 1.1 riastrad }; 539 1.1 riastrad 540 1.1 riastrad struct i915_suspend_saved_registers { 541 1.1 riastrad u32 saveDSPARB; 542 1.1 riastrad u32 saveFBC_CONTROL; 543 1.1 riastrad u32 saveCACHE_MODE_0; 544 1.1 riastrad u32 saveMI_ARB_STATE; 545 1.1 riastrad u32 saveSWF0[16]; 546 1.1 riastrad u32 saveSWF1[16]; 547 1.12 riastrad u32 saveSWF3[3]; 548 1.34 riastrad u64 saveFENCE[I915_MAX_NUM_FENCES]; 549 1.1 riastrad u32 savePCH_PORT_HOTPLUG; 550 1.12 riastrad u16 saveGCDGMBUS; 551 1.12 riastrad }; 552 1.12 riastrad 553 1.34 riastrad struct vlv_s0ix_state; 554 1.4 riastrad 555 1.4 riastrad #define MAX_L3_SLICES 2 556 1.1 riastrad struct intel_l3_parity { 557 1.4 riastrad u32 *remap_info[MAX_L3_SLICES]; 558 1.1 riastrad struct work_struct error_work; 559 1.4 riastrad int which_slice; 560 1.4 riastrad }; 561 1.4 riastrad 562 1.4 riastrad struct i915_gem_mm { 563 1.4 riastrad /** Memory allocator for GTT stolen memory */ 564 1.4 riastrad struct drm_mm stolen; 565 1.12 riastrad /** Protects the usage of the GTT stolen memory allocator. This is 566 1.12 riastrad * always the inner lock when overlapping with struct_mutex. */ 567 1.12 riastrad struct mutex stolen_lock; 568 1.12 riastrad 569 1.34 riastrad /* Protects bound_list/unbound_list and #drm_i915_gem_object.mm.link */ 570 1.34 riastrad spinlock_t obj_lock; 571 1.34 riastrad 572 1.4 riastrad /** 573 1.34 riastrad * List of objects which are purgeable. 574 1.4 riastrad */ 575 1.34 riastrad struct list_head purge_list; 576 1.4 riastrad 577 1.4 riastrad /** 578 1.34 riastrad * List of objects which have allocated pages and are shrinkable. 579 1.4 riastrad */ 580 1.34 riastrad struct list_head shrink_list; 581 1.4 riastrad 582 1.4 riastrad /** 583 1.34 riastrad * List of objects which are pending destruction. 584 1.4 riastrad */ 585 1.34 riastrad struct llist_head free_list; 586 1.34 riastrad struct work_struct free_work; 587 1.4 riastrad /** 588 1.34 riastrad * Count of objects pending destructions. Used to skip needlessly 589 1.34 riastrad * waiting on an RCU barrier if no objects are waiting to be freed. 590 1.4 riastrad */ 591 1.34 riastrad atomic_t free_count; 592 1.4 riastrad 593 1.4 riastrad /** 594 1.34 riastrad * Small stash of WC pages 595 1.4 riastrad */ 596 1.34 riastrad struct pagestash wc_stash; 597 1.4 riastrad 598 1.4 riastrad /** 599 1.34 riastrad * tmpfs instance used for shmem backed objects 600 1.4 riastrad */ 601 1.34 riastrad struct vfsmount *gemfs; 602 1.4 riastrad 603 1.34 riastrad struct intel_memory_region *regions[INTEL_REGION_UNKNOWN]; 604 1.34 riastrad 605 1.34 riastrad struct notifier_block oom_notifier; 606 1.34 riastrad struct notifier_block vmap_notifier; 607 1.34 riastrad struct shrinker shrinker; 608 1.4 riastrad 609 1.4 riastrad /** 610 1.34 riastrad * Workqueue to fault in userptr pages, flushed by the execbuf 611 1.34 riastrad * when required but otherwise left to userspace to try again 612 1.34 riastrad * on EAGAIN. 613 1.4 riastrad */ 614 1.34 riastrad struct workqueue_struct *userptr_wq; 615 1.4 riastrad 616 1.34 riastrad /* shrinker accounting, also useful for userland debugging */ 617 1.34 riastrad u64 shrink_memory; 618 1.34 riastrad u32 shrink_count; 619 1.34 riastrad }; 620 1.4 riastrad 621 1.34 riastrad #define I915_IDLE_ENGINES_TIMEOUT (200) /* in ms */ 622 1.12 riastrad 623 1.34 riastrad #define I915_RESET_TIMEOUT (10 * HZ) /* 10s */ 624 1.34 riastrad #define I915_FENCE_TIMEOUT (10 * HZ) /* 10s */ 625 1.4 riastrad 626 1.34 riastrad #define I915_ENGINE_DEAD_TIMEOUT (4 * HZ) /* Seqno, head and subunits dead */ 627 1.34 riastrad #define I915_SEQNO_DEAD_TIMEOUT (12 * HZ) /* Seqno dead with active head */ 628 1.4 riastrad 629 1.34 riastrad #define I915_ENGINE_WEDGED_TIMEOUT (60 * HZ) /* Reset but no recovery? */ 630 1.12 riastrad 631 1.34 riastrad /* Amount of SAGV/QGV points, BSpec precisely defines this */ 632 1.34 riastrad #define I915_NUM_QGV_POINTS 8 633 1.12 riastrad 634 1.4 riastrad struct ddi_vbt_port_info { 635 1.34 riastrad /* Non-NULL if port present. */ 636 1.34 riastrad const struct child_device_config *child; 637 1.12 riastrad 638 1.34 riastrad int max_tmds_clock; 639 1.12 riastrad 640 1.34 riastrad /* This is an index in the HDMI/DVI DDI buffer translation table. */ 641 1.34 riastrad u8 hdmi_level_shift; 642 1.34 riastrad u8 hdmi_level_shift_set:1; 643 1.34 riastrad 644 1.34 riastrad u8 supports_dvi:1; 645 1.34 riastrad u8 supports_hdmi:1; 646 1.34 riastrad u8 supports_dp:1; 647 1.34 riastrad u8 supports_edp:1; 648 1.34 riastrad u8 supports_typec_usb:1; 649 1.34 riastrad u8 supports_tbt:1; 650 1.34 riastrad 651 1.34 riastrad u8 alternate_aux_channel; 652 1.34 riastrad u8 alternate_ddc_pin; 653 1.34 riastrad 654 1.34 riastrad u8 dp_boost_level; 655 1.34 riastrad u8 hdmi_boost_level; 656 1.34 riastrad int dp_max_link_rate; /* 0 for not limited by VBT */ 657 1.12 riastrad }; 658 1.12 riastrad 659 1.12 riastrad enum psr_lines_to_wait { 660 1.12 riastrad PSR_0_LINES_TO_WAIT = 0, 661 1.12 riastrad PSR_1_LINE_TO_WAIT, 662 1.12 riastrad PSR_4_LINES_TO_WAIT, 663 1.12 riastrad PSR_8_LINES_TO_WAIT 664 1.4 riastrad }; 665 1.4 riastrad 666 1.4 riastrad struct intel_vbt_data { 667 1.4 riastrad struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */ 668 1.4 riastrad struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */ 669 1.4 riastrad 670 1.4 riastrad /* Feature bits */ 671 1.4 riastrad unsigned int int_tv_support:1; 672 1.4 riastrad unsigned int lvds_dither:1; 673 1.4 riastrad unsigned int int_crt_support:1; 674 1.4 riastrad unsigned int lvds_use_ssc:1; 675 1.34 riastrad unsigned int int_lvds_support:1; 676 1.4 riastrad unsigned int display_clock_mode:1; 677 1.4 riastrad unsigned int fdi_rx_polarity_inverted:1; 678 1.34 riastrad unsigned int panel_type:4; 679 1.4 riastrad int lvds_ssc_freq; 680 1.4 riastrad unsigned int bios_lvds_val; /* initial [PCH_]LVDS reg val in VBIOS */ 681 1.34 riastrad enum drm_panel_orientation orientation; 682 1.4 riastrad 683 1.12 riastrad enum drrs_support_type drrs_type; 684 1.12 riastrad 685 1.34 riastrad struct { 686 1.34 riastrad int rate; 687 1.34 riastrad int lanes; 688 1.34 riastrad int preemphasis; 689 1.34 riastrad int vswing; 690 1.34 riastrad bool low_vswing; 691 1.34 riastrad bool initialized; 692 1.34 riastrad int bpp; 693 1.34 riastrad struct edp_power_seq pps; 694 1.34 riastrad } edp; 695 1.4 riastrad 696 1.4 riastrad struct { 697 1.34 riastrad bool enable; 698 1.12 riastrad bool full_link; 699 1.12 riastrad bool require_aux_wakeup; 700 1.12 riastrad int idle_frames; 701 1.12 riastrad enum psr_lines_to_wait lines_to_wait; 702 1.34 riastrad int tp1_wakeup_time_us; 703 1.34 riastrad int tp2_tp3_wakeup_time_us; 704 1.34 riastrad int psr2_tp2_tp3_wakeup_time_us; 705 1.12 riastrad } psr; 706 1.12 riastrad 707 1.12 riastrad struct { 708 1.4 riastrad u16 pwm_freq_hz; 709 1.4 riastrad bool present; 710 1.4 riastrad bool active_low_pwm; 711 1.12 riastrad u8 min_brightness; /* min_brightness/255 of max */ 712 1.34 riastrad u8 controller; /* brightness controller number */ 713 1.34 riastrad enum intel_backlight_type type; 714 1.4 riastrad } backlight; 715 1.4 riastrad 716 1.4 riastrad /* MIPI DSI */ 717 1.4 riastrad struct { 718 1.4 riastrad u16 panel_id; 719 1.12 riastrad struct mipi_config *config; 720 1.12 riastrad struct mipi_pps_data *pps; 721 1.34 riastrad u16 bl_ports; 722 1.34 riastrad u16 cabc_ports; 723 1.12 riastrad u8 seq_version; 724 1.12 riastrad u32 size; 725 1.12 riastrad u8 *data; 726 1.34 riastrad const u8 *sequence[MIPI_SEQ_MAX]; 727 1.34 riastrad u8 *deassert_seq; /* Used by fixup_mipi_sequences() */ 728 1.34 riastrad enum drm_panel_orientation orientation; 729 1.4 riastrad } dsi; 730 1.4 riastrad 731 1.4 riastrad int crt_ddc_pin; 732 1.4 riastrad 733 1.34 riastrad struct list_head display_devices; 734 1.4 riastrad 735 1.4 riastrad struct ddi_vbt_port_info ddi_port_info[I915_MAX_PORTS]; 736 1.34 riastrad struct sdvo_device_mapping sdvo_mappings[2]; 737 1.4 riastrad }; 738 1.4 riastrad 739 1.4 riastrad enum intel_ddb_partitioning { 740 1.4 riastrad INTEL_DDB_PART_1_2, 741 1.4 riastrad INTEL_DDB_PART_5_6, /* IVB+ */ 742 1.4 riastrad }; 743 1.4 riastrad 744 1.4 riastrad struct intel_wm_level { 745 1.4 riastrad bool enable; 746 1.34 riastrad u32 pri_val; 747 1.34 riastrad u32 spr_val; 748 1.34 riastrad u32 cur_val; 749 1.34 riastrad u32 fbc_val; 750 1.4 riastrad }; 751 1.4 riastrad 752 1.4 riastrad struct ilk_wm_values { 753 1.34 riastrad u32 wm_pipe[3]; 754 1.34 riastrad u32 wm_lp[3]; 755 1.34 riastrad u32 wm_lp_spr[3]; 756 1.34 riastrad u32 wm_linetime[3]; 757 1.4 riastrad bool enable_fbc_wm; 758 1.4 riastrad enum intel_ddb_partitioning partitioning; 759 1.4 riastrad }; 760 1.4 riastrad 761 1.34 riastrad struct g4x_pipe_wm { 762 1.34 riastrad u16 plane[I915_MAX_PLANES]; 763 1.34 riastrad u16 fbc; 764 1.34 riastrad }; 765 1.34 riastrad 766 1.34 riastrad struct g4x_sr_wm { 767 1.34 riastrad u16 plane; 768 1.34 riastrad u16 cursor; 769 1.34 riastrad u16 fbc; 770 1.12 riastrad }; 771 1.12 riastrad 772 1.34 riastrad struct vlv_wm_ddl_values { 773 1.34 riastrad u8 plane[I915_MAX_PLANES]; 774 1.12 riastrad }; 775 1.12 riastrad 776 1.12 riastrad struct vlv_wm_values { 777 1.34 riastrad struct g4x_pipe_wm pipe[3]; 778 1.34 riastrad struct g4x_sr_wm sr; 779 1.34 riastrad struct vlv_wm_ddl_values ddl[3]; 780 1.34 riastrad u8 level; 781 1.34 riastrad bool cxsr; 782 1.34 riastrad }; 783 1.34 riastrad 784 1.34 riastrad struct g4x_wm_values { 785 1.34 riastrad struct g4x_pipe_wm pipe[2]; 786 1.34 riastrad struct g4x_sr_wm sr; 787 1.34 riastrad struct g4x_sr_wm hpll; 788 1.12 riastrad bool cxsr; 789 1.34 riastrad bool hpll_en; 790 1.34 riastrad bool fbc_en; 791 1.12 riastrad }; 792 1.12 riastrad 793 1.12 riastrad struct skl_ddb_entry { 794 1.34 riastrad u16 start, end; /* in number of blocks, 'end' is exclusive */ 795 1.12 riastrad }; 796 1.12 riastrad 797 1.34 riastrad static inline u16 skl_ddb_entry_size(const struct skl_ddb_entry *entry) 798 1.12 riastrad { 799 1.12 riastrad return entry->end - entry->start; 800 1.12 riastrad } 801 1.12 riastrad 802 1.12 riastrad static inline bool skl_ddb_entry_equal(const struct skl_ddb_entry *e1, 803 1.12 riastrad const struct skl_ddb_entry *e2) 804 1.12 riastrad { 805 1.12 riastrad if (e1->start == e2->start && e1->end == e2->end) 806 1.12 riastrad return true; 807 1.12 riastrad 808 1.12 riastrad return false; 809 1.12 riastrad } 810 1.12 riastrad 811 1.12 riastrad struct skl_ddb_allocation { 812 1.34 riastrad u8 enabled_slices; /* GEN11 has configurable 2 slices */ 813 1.12 riastrad }; 814 1.12 riastrad 815 1.34 riastrad struct skl_ddb_values { 816 1.34 riastrad unsigned dirty_pipes; 817 1.12 riastrad struct skl_ddb_allocation ddb; 818 1.12 riastrad }; 819 1.12 riastrad 820 1.12 riastrad struct skl_wm_level { 821 1.34 riastrad u16 min_ddb_alloc; 822 1.34 riastrad u16 plane_res_b; 823 1.34 riastrad u8 plane_res_l; 824 1.34 riastrad bool plane_en; 825 1.34 riastrad bool ignore_lines; 826 1.34 riastrad }; 827 1.34 riastrad 828 1.34 riastrad /* Stores plane specific WM parameters */ 829 1.34 riastrad struct skl_wm_params { 830 1.34 riastrad bool x_tiled, y_tiled; 831 1.34 riastrad bool rc_surface; 832 1.34 riastrad bool is_planar; 833 1.34 riastrad u32 width; 834 1.34 riastrad u8 cpp; 835 1.34 riastrad u32 plane_pixel_rate; 836 1.34 riastrad u32 y_min_scanlines; 837 1.34 riastrad u32 plane_bytes_per_line; 838 1.34 riastrad uint_fixed_16_16_t plane_blocks_per_line; 839 1.34 riastrad uint_fixed_16_16_t y_tile_minimum; 840 1.34 riastrad u32 linetime_us; 841 1.34 riastrad u32 dbuf_block_size; 842 1.4 riastrad }; 843 1.4 riastrad 844 1.4 riastrad enum intel_pipe_crc_source { 845 1.4 riastrad INTEL_PIPE_CRC_SOURCE_NONE, 846 1.4 riastrad INTEL_PIPE_CRC_SOURCE_PLANE1, 847 1.4 riastrad INTEL_PIPE_CRC_SOURCE_PLANE2, 848 1.34 riastrad INTEL_PIPE_CRC_SOURCE_PLANE3, 849 1.34 riastrad INTEL_PIPE_CRC_SOURCE_PLANE4, 850 1.34 riastrad INTEL_PIPE_CRC_SOURCE_PLANE5, 851 1.34 riastrad INTEL_PIPE_CRC_SOURCE_PLANE6, 852 1.34 riastrad INTEL_PIPE_CRC_SOURCE_PLANE7, 853 1.4 riastrad INTEL_PIPE_CRC_SOURCE_PIPE, 854 1.4 riastrad /* TV/DP on pre-gen5/vlv can't use the pipe source. */ 855 1.4 riastrad INTEL_PIPE_CRC_SOURCE_TV, 856 1.4 riastrad INTEL_PIPE_CRC_SOURCE_DP_B, 857 1.4 riastrad INTEL_PIPE_CRC_SOURCE_DP_C, 858 1.4 riastrad INTEL_PIPE_CRC_SOURCE_DP_D, 859 1.4 riastrad INTEL_PIPE_CRC_SOURCE_AUTO, 860 1.4 riastrad INTEL_PIPE_CRC_SOURCE_MAX, 861 1.4 riastrad }; 862 1.4 riastrad 863 1.4 riastrad #define INTEL_PIPE_CRC_ENTRIES_NR 128 864 1.4 riastrad struct intel_pipe_crc { 865 1.4 riastrad spinlock_t lock; 866 1.34 riastrad int skipped; 867 1.4 riastrad enum intel_pipe_crc_source source; 868 1.1 riastrad }; 869 1.1 riastrad 870 1.12 riastrad struct i915_frontbuffer_tracking { 871 1.34 riastrad spinlock_t lock; 872 1.12 riastrad 873 1.12 riastrad /* 874 1.12 riastrad * Tracking bits for delayed frontbuffer flushing du to gpu activity or 875 1.12 riastrad * scheduled flips. 876 1.12 riastrad */ 877 1.12 riastrad unsigned busy_bits; 878 1.12 riastrad unsigned flip_bits; 879 1.12 riastrad }; 880 1.12 riastrad 881 1.34 riastrad struct i915_virtual_gpu { 882 1.34 riastrad struct mutex lock; /* serialises sending of g2v_notify command pkts */ 883 1.34 riastrad bool active; 884 1.34 riastrad u32 caps; 885 1.12 riastrad }; 886 1.12 riastrad 887 1.34 riastrad /* used in computing the new watermarks state */ 888 1.34 riastrad struct intel_wm_config { 889 1.34 riastrad unsigned int num_pipes_active; 890 1.34 riastrad bool sprites_enabled; 891 1.34 riastrad bool sprites_scaled; 892 1.12 riastrad }; 893 1.12 riastrad 894 1.34 riastrad struct intel_cdclk_state { 895 1.34 riastrad unsigned int cdclk, vco, ref, bypass; 896 1.34 riastrad u8 voltage_level; 897 1.12 riastrad }; 898 1.12 riastrad 899 1.34 riastrad struct i915_selftest_stash { 900 1.34 riastrad atomic_t counter; 901 1.12 riastrad }; 902 1.12 riastrad 903 1.5 riastrad #ifdef __NetBSD__ 904 1.5 riastrad # define __i915_iomem 905 1.5 riastrad # define __iomem __i915_iomem 906 1.5 riastrad #endif 907 1.5 riastrad 908 1.12 riastrad struct drm_i915_private { 909 1.34 riastrad struct drm_device drm; 910 1.1 riastrad 911 1.41 riastrad struct intel_device_info __info; /* Use INTEL_INFO() to access. */ 912 1.34 riastrad struct intel_runtime_info __runtime; /* Use RUNTIME_INFO() to access. */ 913 1.34 riastrad struct intel_driver_caps caps; 914 1.1 riastrad 915 1.34 riastrad /** 916 1.34 riastrad * Data Stolen Memory - aka "i915 stolen memory" gives us the start and 917 1.34 riastrad * end of stolen which we can optionally use to create GEM objects 918 1.34 riastrad * backed by stolen memory. Note that stolen_usable_size tells us 919 1.34 riastrad * exactly how much of this we are actually allowed to use, given that 920 1.34 riastrad * some portion of it is in fact reserved for use by hardware functions. 921 1.34 riastrad */ 922 1.34 riastrad struct resource dsm; 923 1.34 riastrad /** 924 1.34 riastrad * Reseved portion of Data Stolen Memory 925 1.34 riastrad */ 926 1.34 riastrad struct resource dsm_reserved; 927 1.1 riastrad 928 1.34 riastrad /* 929 1.34 riastrad * Stolen memory is segmented in hardware with different portions 930 1.34 riastrad * offlimits to certain functions. 931 1.34 riastrad * 932 1.34 riastrad * The drm_mm is initialised to the total accessible range, as found 933 1.34 riastrad * from the PCI config. On Broadwell+, this is further restricted to 934 1.34 riastrad * avoid the first page! The upper end of stolen memory is reserved for 935 1.34 riastrad * hardware functions and similarly removed from the accessible range. 936 1.34 riastrad */ 937 1.34 riastrad resource_size_t stolen_usable_size; /* Total size minus reserved ranges */ 938 1.1 riastrad 939 1.4 riastrad struct intel_uncore uncore; 940 1.34 riastrad struct intel_uncore_mmio_debug mmio_debug; 941 1.1 riastrad 942 1.12 riastrad struct i915_virtual_gpu vgpu; 943 1.12 riastrad 944 1.34 riastrad struct intel_gvt *gvt; 945 1.34 riastrad 946 1.34 riastrad struct intel_wopcm wopcm; 947 1.1 riastrad 948 1.12 riastrad struct intel_csr csr; 949 1.12 riastrad 950 1.12 riastrad struct intel_gmbus gmbus[GMBUS_NUM_PINS]; 951 1.4 riastrad 952 1.1 riastrad /** gmbus_mutex protects against concurrent usage of the single hw gmbus 953 1.1 riastrad * controller on different i2c buses. */ 954 1.1 riastrad struct mutex gmbus_mutex; 955 1.1 riastrad 956 1.1 riastrad /** 957 1.34 riastrad * Base address of where the gmbus and gpio blocks are located (either 958 1.34 riastrad * on PCH or on SoC for platforms without PCH). 959 1.1 riastrad */ 960 1.34 riastrad u32 gpio_mmio_base; 961 1.34 riastrad 962 1.34 riastrad u32 hsw_psr_mmio_adjust; 963 1.1 riastrad 964 1.12 riastrad /* MMIO base address for MIPI regs */ 965 1.34 riastrad u32 mipi_mmio_base; 966 1.34 riastrad 967 1.34 riastrad u32 pps_mmio_base; 968 1.12 riastrad 969 1.5 riastrad #ifdef __NetBSD__ 970 1.5 riastrad spinlock_t gmbus_wait_lock; 971 1.5 riastrad drm_waitqueue_t gmbus_wait_queue; 972 1.5 riastrad #else 973 1.4 riastrad wait_queue_head_t gmbus_wait_queue; 974 1.5 riastrad #endif 975 1.4 riastrad 976 1.1 riastrad struct pci_dev *bridge_dev; 977 1.1 riastrad 978 1.34 riastrad struct intel_engine_cs *engine[I915_NUM_ENGINES]; 979 1.34 riastrad struct rb_root uabi_engines; 980 1.45 riastrad struct llist_head uabi_engines_llist; 981 1.34 riastrad 982 1.1 riastrad struct resource mch_res; 983 1.1 riastrad 984 1.1 riastrad /* protects the irq masks */ 985 1.1 riastrad spinlock_t irq_lock; 986 1.1 riastrad 987 1.4 riastrad bool display_irqs_enabled; 988 1.4 riastrad 989 1.4 riastrad /* To control wakeup latency, e.g. for irq-driven dp aux transfers. */ 990 1.4 riastrad struct pm_qos_request pm_qos; 991 1.4 riastrad 992 1.12 riastrad /* Sideband mailbox protection */ 993 1.12 riastrad struct mutex sb_lock; 994 1.34 riastrad struct pm_qos_request sb_qos; 995 1.1 riastrad 996 1.1 riastrad /** Cached value of IMR to avoid reads in updating the bitfield */ 997 1.4 riastrad union { 998 1.4 riastrad u32 irq_mask; 999 1.4 riastrad u32 de_irq_mask[I915_MAX_PIPES]; 1000 1.4 riastrad }; 1001 1.4 riastrad u32 pipestat_irq_mask[I915_MAX_PIPES]; 1002 1.1 riastrad 1003 1.12 riastrad struct i915_hotplug hotplug; 1004 1.34 riastrad struct intel_fbc fbc; 1005 1.12 riastrad struct i915_drrs drrs; 1006 1.1 riastrad struct intel_opregion opregion; 1007 1.4 riastrad struct intel_vbt_data vbt; 1008 1.1 riastrad 1009 1.12 riastrad bool preserve_bios_swizzle; 1010 1.12 riastrad 1011 1.1 riastrad /* overlay */ 1012 1.1 riastrad struct intel_overlay *overlay; 1013 1.1 riastrad 1014 1.4 riastrad /* backlight registers and fields in struct intel_panel */ 1015 1.12 riastrad struct mutex backlight_lock; 1016 1.1 riastrad 1017 1.12 riastrad /* protects panel power sequencer state */ 1018 1.12 riastrad struct mutex pps_mutex; 1019 1.12 riastrad 1020 1.34 riastrad unsigned int fsb_freq, mem_freq, is_ddr3; 1021 1.34 riastrad unsigned int skl_preferred_vco_freq; 1022 1.34 riastrad unsigned int max_cdclk_freq; 1023 1.1 riastrad 1024 1.12 riastrad unsigned int max_dotclk_freq; 1025 1.34 riastrad unsigned int rawclk_freq; 1026 1.12 riastrad unsigned int hpll_freq; 1027 1.34 riastrad unsigned int fdi_pll_freq; 1028 1.12 riastrad unsigned int czclk_freq; 1029 1.1 riastrad 1030 1.34 riastrad /* 1031 1.34 riastrad * For reading holding any crtc lock is sufficient, 1032 1.34 riastrad * for writing must hold all of them. 1033 1.34 riastrad */ 1034 1.34 riastrad struct { 1035 1.34 riastrad /* 1036 1.34 riastrad * The current logical cdclk state. 1037 1.34 riastrad * See intel_atomic_state.cdclk.logical 1038 1.34 riastrad */ 1039 1.34 riastrad struct intel_cdclk_state logical; 1040 1.34 riastrad /* 1041 1.34 riastrad * The current actual cdclk state. 1042 1.34 riastrad * See intel_atomic_state.cdclk.actual 1043 1.34 riastrad */ 1044 1.34 riastrad struct intel_cdclk_state actual; 1045 1.34 riastrad /* The current hardware cdclk state */ 1046 1.34 riastrad struct intel_cdclk_state hw; 1047 1.34 riastrad 1048 1.34 riastrad /* cdclk, divider, and ratio table from bspec */ 1049 1.34 riastrad const struct intel_cdclk_vals *table; 1050 1.34 riastrad 1051 1.34 riastrad int force_min_cdclk; 1052 1.34 riastrad } cdclk; 1053 1.34 riastrad 1054 1.4 riastrad /** 1055 1.4 riastrad * wq - Driver workqueue for GEM. 1056 1.4 riastrad * 1057 1.4 riastrad * NOTE: Work items scheduled here are not allowed to grab any modeset 1058 1.4 riastrad * locks, for otherwise the flushing done in the pageflip code will 1059 1.4 riastrad * result in deadlocks. 1060 1.4 riastrad */ 1061 1.1 riastrad struct workqueue_struct *wq; 1062 1.1 riastrad 1063 1.34 riastrad /* ordered wq for modesets */ 1064 1.34 riastrad struct workqueue_struct *modeset_wq; 1065 1.34 riastrad /* unbound hipri wq for page flips/plane updates */ 1066 1.34 riastrad struct workqueue_struct *flip_wq; 1067 1.34 riastrad 1068 1.1 riastrad /* Display functions */ 1069 1.1 riastrad struct drm_i915_display_funcs display; 1070 1.1 riastrad 1071 1.1 riastrad /* PCH chipset type */ 1072 1.1 riastrad enum intel_pch pch_type; 1073 1.1 riastrad unsigned short pch_id; 1074 1.1 riastrad 1075 1.1 riastrad unsigned long quirks; 1076 1.1 riastrad 1077 1.34 riastrad struct drm_atomic_state *modeset_restore_state; 1078 1.34 riastrad struct drm_modeset_acquire_ctx reset_ctx; 1079 1.1 riastrad 1080 1.46 riastrad spinlock_t atomic_commit_lock; 1081 1.46 riastrad drm_waitqueue_t atomic_commit_wq; 1082 1.46 riastrad 1083 1.34 riastrad struct i915_ggtt ggtt; /* VM representing the global address space */ 1084 1.1 riastrad 1085 1.4 riastrad struct i915_gem_mm mm; 1086 1.12 riastrad DECLARE_HASHTABLE(mm_structs, 7); 1087 1.12 riastrad struct mutex mm_lock; 1088 1.1 riastrad 1089 1.1 riastrad /* Kernel Modesetting */ 1090 1.1 riastrad 1091 1.34 riastrad struct intel_crtc *plane_to_crtc_mapping[I915_MAX_PIPES]; 1092 1.34 riastrad struct intel_crtc *pipe_to_crtc_mapping[I915_MAX_PIPES]; 1093 1.1 riastrad 1094 1.4 riastrad #ifdef CONFIG_DEBUG_FS 1095 1.4 riastrad struct intel_pipe_crc pipe_crc[I915_MAX_PIPES]; 1096 1.4 riastrad #endif 1097 1.4 riastrad 1098 1.34 riastrad /* dpll and cdclk state is protected by connection_mutex */ 1099 1.4 riastrad int num_shared_dpll; 1100 1.4 riastrad struct intel_shared_dpll shared_dplls[I915_NUM_PLLS]; 1101 1.34 riastrad const struct intel_dpll_mgr *dpll_mgr; 1102 1.1 riastrad 1103 1.34 riastrad /* 1104 1.34 riastrad * dpll_lock serializes intel_{prepare,enable,disable}_shared_dpll. 1105 1.34 riastrad * Must be global rather than per dpll, because on some platforms 1106 1.34 riastrad * plls share registers. 1107 1.34 riastrad */ 1108 1.34 riastrad struct mutex dpll_lock; 1109 1.12 riastrad 1110 1.34 riastrad /* 1111 1.34 riastrad * For reading active_pipes, min_cdclk, min_voltage_level holding 1112 1.34 riastrad * any crtc lock is sufficient, for writing must hold all of them. 1113 1.34 riastrad */ 1114 1.34 riastrad u8 active_pipes; 1115 1.34 riastrad /* minimum acceptable cdclk for each pipe */ 1116 1.34 riastrad int min_cdclk[I915_MAX_PIPES]; 1117 1.34 riastrad /* minimum acceptable voltage level for each pipe */ 1118 1.34 riastrad u8 min_voltage_level[I915_MAX_PIPES]; 1119 1.34 riastrad 1120 1.34 riastrad int dpio_phy_iosf_port[I915_NUM_PHYS_VLV]; 1121 1.34 riastrad 1122 1.34 riastrad struct i915_wa_list gt_wa_list; 1123 1.12 riastrad 1124 1.12 riastrad struct i915_frontbuffer_tracking fb_tracking; 1125 1.12 riastrad 1126 1.34 riastrad struct intel_atomic_helper { 1127 1.34 riastrad struct llist_head free_list; 1128 1.34 riastrad struct work_struct free_work; 1129 1.34 riastrad } atomic_helper; 1130 1.34 riastrad 1131 1.1 riastrad u16 orig_clock; 1132 1.1 riastrad 1133 1.1 riastrad bool mchbar_need_disable; 1134 1.1 riastrad 1135 1.1 riastrad struct intel_l3_parity l3_parity; 1136 1.1 riastrad 1137 1.34 riastrad /* 1138 1.34 riastrad * edram size in MB. 1139 1.34 riastrad * Cannot be determined by PCIID. You must always read a register. 1140 1.34 riastrad */ 1141 1.34 riastrad u32 edram_size_mb; 1142 1.1 riastrad 1143 1.4 riastrad struct i915_power_domains power_domains; 1144 1.1 riastrad 1145 1.4 riastrad struct i915_psr psr; 1146 1.4 riastrad 1147 1.4 riastrad struct i915_gpu_error gpu_error; 1148 1.1 riastrad 1149 1.4 riastrad struct drm_i915_gem_object *vlv_pctx; 1150 1.1 riastrad 1151 1.1 riastrad /* list of fbdev register on this device */ 1152 1.1 riastrad struct intel_fbdev *fbdev; 1153 1.12 riastrad struct work_struct fbdev_suspend_work; 1154 1.1 riastrad 1155 1.1 riastrad struct drm_property *broadcast_rgb_property; 1156 1.1 riastrad struct drm_property *force_audio_property; 1157 1.1 riastrad 1158 1.12 riastrad /* hda/i915 audio component */ 1159 1.12 riastrad struct i915_audio_component *audio_component; 1160 1.12 riastrad bool audio_component_registered; 1161 1.12 riastrad /** 1162 1.12 riastrad * av_mutex - mutex for audio/video sync 1163 1.12 riastrad * 1164 1.12 riastrad */ 1165 1.12 riastrad struct mutex av_mutex; 1166 1.34 riastrad int audio_power_refcount; 1167 1.34 riastrad u32 audio_freq_cntrl; 1168 1.1 riastrad 1169 1.4 riastrad u32 fdi_rx_config; 1170 1.1 riastrad 1171 1.34 riastrad /* Shadow for DISPLAY_PHY_CONTROL which can't be safely read */ 1172 1.12 riastrad u32 chv_phy_control; 1173 1.34 riastrad /* 1174 1.34 riastrad * Shadows for CHV DPLL_MD regs to keep the state 1175 1.34 riastrad * checker somewhat working in the presence hardware 1176 1.34 riastrad * crappiness (can't read out DPLL_MD for pipes B & C). 1177 1.34 riastrad */ 1178 1.34 riastrad u32 chv_dpll_md[I915_MAX_PIPES]; 1179 1.34 riastrad u32 bxt_phy_grc; 1180 1.12 riastrad 1181 1.4 riastrad u32 suspend_count; 1182 1.34 riastrad bool power_domains_suspended; 1183 1.1 riastrad struct i915_suspend_saved_registers regfile; 1184 1.34 riastrad struct vlv_s0ix_state *vlv_s0ix_state; 1185 1.34 riastrad 1186 1.34 riastrad enum { 1187 1.34 riastrad I915_SAGV_UNKNOWN = 0, 1188 1.34 riastrad I915_SAGV_DISABLED, 1189 1.34 riastrad I915_SAGV_ENABLED, 1190 1.34 riastrad I915_SAGV_NOT_CONTROLLED 1191 1.34 riastrad } sagv_status; 1192 1.34 riastrad 1193 1.34 riastrad u32 sagv_block_time_us; 1194 1.1 riastrad 1195 1.4 riastrad struct { 1196 1.4 riastrad /* 1197 1.4 riastrad * Raw watermark latency values: 1198 1.4 riastrad * in 0.1us units for WM0, 1199 1.4 riastrad * in 0.5us units for WM1+. 1200 1.4 riastrad */ 1201 1.4 riastrad /* primary */ 1202 1.34 riastrad u16 pri_latency[5]; 1203 1.4 riastrad /* sprite */ 1204 1.34 riastrad u16 spr_latency[5]; 1205 1.4 riastrad /* cursor */ 1206 1.34 riastrad u16 cur_latency[5]; 1207 1.12 riastrad /* 1208 1.12 riastrad * Raw watermark memory latency values 1209 1.12 riastrad * for SKL for all 8 levels 1210 1.12 riastrad * in 1us units. 1211 1.12 riastrad */ 1212 1.34 riastrad u16 skl_latency[8]; 1213 1.4 riastrad 1214 1.4 riastrad /* current hardware state */ 1215 1.12 riastrad union { 1216 1.12 riastrad struct ilk_wm_values hw; 1217 1.34 riastrad struct skl_ddb_values skl_hw; 1218 1.12 riastrad struct vlv_wm_values vlv; 1219 1.34 riastrad struct g4x_wm_values g4x; 1220 1.12 riastrad }; 1221 1.12 riastrad 1222 1.34 riastrad u8 max_level; 1223 1.34 riastrad 1224 1.34 riastrad /* 1225 1.34 riastrad * Should be held around atomic WM register writing; also 1226 1.34 riastrad * protects * intel_crtc->wm.active and 1227 1.34 riastrad * crtc_state->wm.need_postvbl_update. 1228 1.34 riastrad */ 1229 1.34 riastrad struct mutex wm_mutex; 1230 1.34 riastrad 1231 1.34 riastrad /* 1232 1.34 riastrad * Set during HW readout of watermarks/DDB. Some platforms 1233 1.34 riastrad * need to know when we're still using BIOS-provided values 1234 1.34 riastrad * (which we don't fully trust). 1235 1.34 riastrad */ 1236 1.34 riastrad bool distrust_bios_wm; 1237 1.4 riastrad } wm; 1238 1.4 riastrad 1239 1.34 riastrad struct dram_info { 1240 1.34 riastrad bool valid; 1241 1.34 riastrad bool is_16gb_dimm; 1242 1.34 riastrad u8 num_channels; 1243 1.34 riastrad u8 ranks; 1244 1.34 riastrad u32 bandwidth_kbps; 1245 1.34 riastrad bool symmetric_memory; 1246 1.34 riastrad enum intel_dram_type { 1247 1.34 riastrad INTEL_DRAM_UNKNOWN, 1248 1.34 riastrad INTEL_DRAM_DDR3, 1249 1.34 riastrad INTEL_DRAM_DDR4, 1250 1.34 riastrad INTEL_DRAM_LPDDR3, 1251 1.34 riastrad INTEL_DRAM_LPDDR4 1252 1.34 riastrad } type; 1253 1.34 riastrad } dram_info; 1254 1.34 riastrad 1255 1.34 riastrad struct intel_bw_info { 1256 1.34 riastrad /* for each QGV point */ 1257 1.34 riastrad unsigned int deratedbw[I915_NUM_QGV_POINTS]; 1258 1.34 riastrad u8 num_qgv_points; 1259 1.34 riastrad u8 num_planes; 1260 1.34 riastrad } max_bw[6]; 1261 1.34 riastrad 1262 1.34 riastrad struct drm_private_obj bw_obj; 1263 1.34 riastrad 1264 1.34 riastrad struct intel_runtime_pm runtime_pm; 1265 1.34 riastrad 1266 1.34 riastrad struct i915_perf perf; 1267 1.4 riastrad 1268 1.12 riastrad /* Abstract the submission mechanism (legacy ringbuffer or execlists) away */ 1269 1.34 riastrad struct intel_gt gt; 1270 1.34 riastrad 1271 1.12 riastrad struct { 1272 1.34 riastrad struct i915_gem_contexts { 1273 1.34 riastrad spinlock_t lock; /* locks list */ 1274 1.34 riastrad struct list_head list; 1275 1.34 riastrad 1276 1.34 riastrad struct llist_head free_list; 1277 1.34 riastrad struct work_struct free_work; 1278 1.34 riastrad } contexts; 1279 1.12 riastrad 1280 1.34 riastrad /* 1281 1.34 riastrad * We replace the local file with a global mappings as the 1282 1.34 riastrad * backing storage for the mmap is on the device and not 1283 1.34 riastrad * on the struct file, and we do not want to prolong the 1284 1.34 riastrad * lifetime of the local fd. To minimise the number of 1285 1.34 riastrad * anonymous inodes we create, we use a global singleton to 1286 1.34 riastrad * share the global mapping. 1287 1.34 riastrad */ 1288 1.34 riastrad struct file *mmap_singleton; 1289 1.34 riastrad } gem; 1290 1.34 riastrad 1291 1.34 riastrad u8 pch_ssc_use; 1292 1.34 riastrad 1293 1.34 riastrad /* For i915gm/i945gm vblank irq workaround */ 1294 1.34 riastrad u8 vblank_enabled; 1295 1.12 riastrad 1296 1.12 riastrad /* perform PHY state sanity checks? */ 1297 1.12 riastrad bool chv_phy_assert[2]; 1298 1.12 riastrad 1299 1.34 riastrad bool ipc_enabled; 1300 1.34 riastrad 1301 1.34 riastrad /* Used to save the pipe-to-encoder mapping for audio */ 1302 1.34 riastrad struct intel_encoder *av_enc_map[I915_MAX_PIPES]; 1303 1.34 riastrad 1304 1.34 riastrad /* necessary resource sharing with HDMI LPE audio driver. */ 1305 1.34 riastrad struct { 1306 1.34 riastrad struct platform_device *platdev; 1307 1.34 riastrad int irq; 1308 1.34 riastrad } lpe_audio; 1309 1.34 riastrad 1310 1.34 riastrad struct i915_pmu pmu; 1311 1.34 riastrad 1312 1.34 riastrad struct i915_hdcp_comp_master *hdcp_master; 1313 1.34 riastrad bool hdcp_comp_added; 1314 1.34 riastrad 1315 1.34 riastrad /* Mutex to protect the above hdcp component related values. */ 1316 1.34 riastrad struct mutex hdcp_comp_mutex; 1317 1.34 riastrad 1318 1.34 riastrad I915_SELFTEST_DECLARE(struct i915_selftest_stash selftest;) 1319 1.34 riastrad 1320 1.44 riastrad #ifdef __NetBSD__ 1321 1.44 riastrad pci_intr_handle_t *pci_ihp; 1322 1.44 riastrad void *pci_intrcookie; 1323 1.44 riastrad #endif 1324 1.44 riastrad 1325 1.12 riastrad /* 1326 1.12 riastrad * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch 1327 1.12 riastrad * will be rejected. Instead look for a better place. 1328 1.12 riastrad */ 1329 1.12 riastrad }; 1330 1.1 riastrad 1331 1.5 riastrad #ifdef __NetBSD__ 1332 1.5 riastrad # undef __iomem 1333 1.5 riastrad # undef __i915_iomem 1334 1.5 riastrad #endif 1335 1.5 riastrad 1336 1.34 riastrad struct dram_dimm_info { 1337 1.34 riastrad u8 size, width, ranks; 1338 1.34 riastrad }; 1339 1.34 riastrad 1340 1.34 riastrad struct dram_channel_info { 1341 1.34 riastrad struct dram_dimm_info dimm_l, dimm_s; 1342 1.34 riastrad u8 ranks; 1343 1.34 riastrad bool is_16gb_dimm; 1344 1.34 riastrad }; 1345 1.34 riastrad 1346 1.4 riastrad static inline struct drm_i915_private *to_i915(const struct drm_device *dev) 1347 1.4 riastrad { 1348 1.35 riastrad return __UNCONST(const_container_of(dev, struct drm_i915_private, drm)); 1349 1.4 riastrad } 1350 1.4 riastrad 1351 1.14 riastrad #ifndef __NetBSD__ 1352 1.34 riastrad static inline struct drm_i915_private *kdev_to_i915(struct device *kdev) 1353 1.12 riastrad { 1354 1.34 riastrad return dev_get_drvdata(kdev); 1355 1.12 riastrad } 1356 1.14 riastrad #endif 1357 1.12 riastrad 1358 1.34 riastrad static inline struct drm_i915_private *pdev_to_i915(struct pci_dev *pdev) 1359 1.12 riastrad { 1360 1.34 riastrad return pci_get_drvdata(pdev); 1361 1.12 riastrad } 1362 1.12 riastrad 1363 1.34 riastrad /* Simple iterator over all initialised engines */ 1364 1.34 riastrad #define for_each_engine(engine__, dev_priv__, id__) \ 1365 1.34 riastrad for ((id__) = 0; \ 1366 1.34 riastrad (id__) < I915_NUM_ENGINES; \ 1367 1.34 riastrad (id__)++) \ 1368 1.34 riastrad for_each_if ((engine__) = (dev_priv__)->engine[(id__)]) 1369 1.34 riastrad 1370 1.34 riastrad /* Iterator over subset of engines selected by mask */ 1371 1.34 riastrad #define for_each_engine_masked(engine__, gt__, mask__, tmp__) \ 1372 1.34 riastrad for ((tmp__) = (mask__) & INTEL_INFO((gt__)->i915)->engine_mask; \ 1373 1.34 riastrad (tmp__) ? \ 1374 1.34 riastrad ((engine__) = (gt__)->engine[__mask_next_bit(tmp__)]), 1 : \ 1375 1.34 riastrad 0;) 1376 1.34 riastrad 1377 1.34 riastrad #define rb_to_uabi_engine(rb) \ 1378 1.45 riastrad rb_entry_safe(rb, struct intel_engine_cs, uabi_node.rbtree) 1379 1.1 riastrad 1380 1.34 riastrad #define for_each_uabi_engine(engine__, i915__) \ 1381 1.34 riastrad for ((engine__) = rb_to_uabi_engine(rb_first(&(i915__)->uabi_engines));\ 1382 1.34 riastrad (engine__); \ 1383 1.45 riastrad (engine__) = rb_to_uabi_engine(rb_next2(&(i915__)->uabi_engines, &(engine__)->uabi_node.rbtree))) 1384 1.1 riastrad 1385 1.4 riastrad #define I915_GTT_OFFSET_NONE ((u32)-1) 1386 1.1 riastrad 1387 1.12 riastrad /* 1388 1.12 riastrad * Frontbuffer tracking bits. Set in obj->frontbuffer_bits while a gem bo is 1389 1.12 riastrad * considered to be the frontbuffer for the given plane interface-wise. This 1390 1.12 riastrad * doesn't mean that the hw necessarily already scans it out, but that any 1391 1.12 riastrad * rendering (by the cpu or gpu) will land in the frontbuffer eventually. 1392 1.12 riastrad * 1393 1.12 riastrad * We have one bit per pipe and per scanout plane type. 1394 1.12 riastrad */ 1395 1.12 riastrad #define INTEL_FRONTBUFFER_BITS_PER_PIPE 8 1396 1.34 riastrad #define INTEL_FRONTBUFFER(pipe, plane_id) ({ \ 1397 1.34 riastrad BUILD_BUG_ON(INTEL_FRONTBUFFER_BITS_PER_PIPE * I915_MAX_PIPES > 32); \ 1398 1.34 riastrad BUILD_BUG_ON(I915_MAX_PLANES > INTEL_FRONTBUFFER_BITS_PER_PIPE); \ 1399 1.34 riastrad BIT((plane_id) + INTEL_FRONTBUFFER_BITS_PER_PIPE * (pipe)); \ 1400 1.34 riastrad }) 1401 1.12 riastrad #define INTEL_FRONTBUFFER_OVERLAY(pipe) \ 1402 1.34 riastrad BIT(INTEL_FRONTBUFFER_BITS_PER_PIPE - 1 + INTEL_FRONTBUFFER_BITS_PER_PIPE * (pipe)) 1403 1.12 riastrad #define INTEL_FRONTBUFFER_ALL_MASK(pipe) \ 1404 1.34 riastrad GENMASK(INTEL_FRONTBUFFER_BITS_PER_PIPE * ((pipe) + 1) - 1, \ 1405 1.34 riastrad INTEL_FRONTBUFFER_BITS_PER_PIPE * (pipe)) 1406 1.12 riastrad 1407 1.34 riastrad #define INTEL_INFO(dev_priv) (&(dev_priv)->__info) 1408 1.34 riastrad #define RUNTIME_INFO(dev_priv) (&(dev_priv)->__runtime) 1409 1.34 riastrad #define DRIVER_CAPS(dev_priv) (&(dev_priv)->caps) 1410 1.1 riastrad 1411 1.34 riastrad #define INTEL_GEN(dev_priv) (INTEL_INFO(dev_priv)->gen) 1412 1.34 riastrad #define INTEL_DEVID(dev_priv) (RUNTIME_INFO(dev_priv)->device_id) 1413 1.1 riastrad 1414 1.34 riastrad #define REVID_FOREVER 0xff 1415 1.34 riastrad #define INTEL_REVID(dev_priv) ((dev_priv)->drm.pdev->revision) 1416 1.4 riastrad 1417 1.34 riastrad #define INTEL_GEN_MASK(s, e) ( \ 1418 1.34 riastrad BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \ 1419 1.34 riastrad BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \ 1420 1.34 riastrad GENMASK((e) - 1, (s) - 1)) 1421 1.1 riastrad 1422 1.34 riastrad /* Returns true if Gen is in inclusive range [Start, End] */ 1423 1.34 riastrad #define IS_GEN_RANGE(dev_priv, s, e) \ 1424 1.34 riastrad (!!(INTEL_INFO(dev_priv)->gen_mask & INTEL_GEN_MASK((s), (e)))) 1425 1.1 riastrad 1426 1.34 riastrad #define IS_GEN(dev_priv, n) \ 1427 1.34 riastrad (BUILD_BUG_ON_ZERO(!__builtin_constant_p(n)) + \ 1428 1.34 riastrad INTEL_INFO(dev_priv)->gen == (n)) 1429 1.12 riastrad 1430 1.34 riastrad #define HAS_DSB(dev_priv) (INTEL_INFO(dev_priv)->display.has_dsb) 1431 1.28 mrg 1432 1.28 mrg /* 1433 1.28 mrg * Return true if revision is in range [since,until] inclusive. 1434 1.28 mrg * 1435 1.28 mrg * Use 0 for open-ended since, and REVID_FOREVER for open-ended until. 1436 1.28 mrg */ 1437 1.28 mrg #define IS_REVID(p, since, until) \ 1438 1.28 mrg (INTEL_REVID(p) >= (since) && INTEL_REVID(p) <= (until)) 1439 1.28 mrg 1440 1.34 riastrad static __always_inline unsigned int 1441 1.34 riastrad __platform_mask_index(const struct intel_runtime_info *info, 1442 1.34 riastrad enum intel_platform p) 1443 1.34 riastrad { 1444 1.34 riastrad const unsigned int pbits = 1445 1.34 riastrad BITS_PER_TYPE(info->platform_mask[0]) - INTEL_SUBPLATFORM_BITS; 1446 1.34 riastrad 1447 1.34 riastrad /* Expand the platform_mask array if this fails. */ 1448 1.34 riastrad BUILD_BUG_ON(INTEL_MAX_PLATFORMS > 1449 1.34 riastrad pbits * ARRAY_SIZE(info->platform_mask)); 1450 1.34 riastrad 1451 1.34 riastrad return p / pbits; 1452 1.34 riastrad } 1453 1.34 riastrad 1454 1.34 riastrad static __always_inline unsigned int 1455 1.34 riastrad __platform_mask_bit(const struct intel_runtime_info *info, 1456 1.34 riastrad enum intel_platform p) 1457 1.34 riastrad { 1458 1.34 riastrad const unsigned int pbits = 1459 1.34 riastrad BITS_PER_TYPE(info->platform_mask[0]) - INTEL_SUBPLATFORM_BITS; 1460 1.34 riastrad 1461 1.34 riastrad return p % pbits + INTEL_SUBPLATFORM_BITS; 1462 1.34 riastrad } 1463 1.34 riastrad 1464 1.34 riastrad static inline u32 1465 1.34 riastrad intel_subplatform(const struct intel_runtime_info *info, enum intel_platform p) 1466 1.34 riastrad { 1467 1.34 riastrad const unsigned int pi = __platform_mask_index(info, p); 1468 1.34 riastrad 1469 1.34 riastrad return info->platform_mask[pi] & INTEL_SUBPLATFORM_BITS; 1470 1.34 riastrad } 1471 1.34 riastrad 1472 1.34 riastrad static __always_inline bool 1473 1.34 riastrad IS_PLATFORM(const struct drm_i915_private *i915, enum intel_platform p) 1474 1.34 riastrad { 1475 1.34 riastrad const struct intel_runtime_info *info = RUNTIME_INFO(i915); 1476 1.34 riastrad const unsigned int pi = __platform_mask_index(info, p); 1477 1.34 riastrad const unsigned int pb = __platform_mask_bit(info, p); 1478 1.34 riastrad 1479 1.36 riastrad #if 0 1480 1.34 riastrad BUILD_BUG_ON(!__builtin_constant_p(p)); 1481 1.36 riastrad #endif 1482 1.34 riastrad 1483 1.34 riastrad return info->platform_mask[pi] & BIT(pb); 1484 1.34 riastrad } 1485 1.34 riastrad 1486 1.38 riastrad static __always_inline inline bool 1487 1.34 riastrad IS_SUBPLATFORM(const struct drm_i915_private *i915, 1488 1.34 riastrad enum intel_platform p, unsigned int s) 1489 1.34 riastrad { 1490 1.34 riastrad const struct intel_runtime_info *info = RUNTIME_INFO(i915); 1491 1.34 riastrad const unsigned int pi = __platform_mask_index(info, p); 1492 1.34 riastrad const unsigned int pb = __platform_mask_bit(info, p); 1493 1.34 riastrad const unsigned int msb = BITS_PER_TYPE(info->platform_mask[0]) - 1; 1494 1.34 riastrad const u32 mask = info->platform_mask[pi]; 1495 1.34 riastrad 1496 1.36 riastrad #if 0 1497 1.34 riastrad BUILD_BUG_ON(!__builtin_constant_p(p)); 1498 1.34 riastrad BUILD_BUG_ON(!__builtin_constant_p(s)); 1499 1.34 riastrad BUILD_BUG_ON((s) >= INTEL_SUBPLATFORM_BITS); 1500 1.36 riastrad #endif 1501 1.34 riastrad 1502 1.34 riastrad /* Shift and test on the MSB position so sign flag can be used. */ 1503 1.34 riastrad return ((mask << (msb - pb)) & (mask << (msb - s))) & BIT(msb); 1504 1.34 riastrad } 1505 1.34 riastrad 1506 1.34 riastrad #define IS_MOBILE(dev_priv) (INTEL_INFO(dev_priv)->is_mobile) 1507 1.34 riastrad #define IS_DGFX(dev_priv) (INTEL_INFO(dev_priv)->is_dgfx) 1508 1.34 riastrad 1509 1.34 riastrad #define IS_I830(dev_priv) IS_PLATFORM(dev_priv, INTEL_I830) 1510 1.34 riastrad #define IS_I845G(dev_priv) IS_PLATFORM(dev_priv, INTEL_I845G) 1511 1.34 riastrad #define IS_I85X(dev_priv) IS_PLATFORM(dev_priv, INTEL_I85X) 1512 1.34 riastrad #define IS_I865G(dev_priv) IS_PLATFORM(dev_priv, INTEL_I865G) 1513 1.34 riastrad #define IS_I915G(dev_priv) IS_PLATFORM(dev_priv, INTEL_I915G) 1514 1.34 riastrad #define IS_I915GM(dev_priv) IS_PLATFORM(dev_priv, INTEL_I915GM) 1515 1.34 riastrad #define IS_I945G(dev_priv) IS_PLATFORM(dev_priv, INTEL_I945G) 1516 1.34 riastrad #define IS_I945GM(dev_priv) IS_PLATFORM(dev_priv, INTEL_I945GM) 1517 1.34 riastrad #define IS_I965G(dev_priv) IS_PLATFORM(dev_priv, INTEL_I965G) 1518 1.34 riastrad #define IS_I965GM(dev_priv) IS_PLATFORM(dev_priv, INTEL_I965GM) 1519 1.34 riastrad #define IS_G45(dev_priv) IS_PLATFORM(dev_priv, INTEL_G45) 1520 1.34 riastrad #define IS_GM45(dev_priv) IS_PLATFORM(dev_priv, INTEL_GM45) 1521 1.34 riastrad #define IS_G4X(dev_priv) (IS_G45(dev_priv) || IS_GM45(dev_priv)) 1522 1.34 riastrad #define IS_PINEVIEW(dev_priv) IS_PLATFORM(dev_priv, INTEL_PINEVIEW) 1523 1.34 riastrad #define IS_G33(dev_priv) IS_PLATFORM(dev_priv, INTEL_G33) 1524 1.34 riastrad #define IS_IRONLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_IRONLAKE) 1525 1.34 riastrad #define IS_IRONLAKE_M(dev_priv) \ 1526 1.34 riastrad (IS_PLATFORM(dev_priv, INTEL_IRONLAKE) && IS_MOBILE(dev_priv)) 1527 1.34 riastrad #define IS_IVYBRIDGE(dev_priv) IS_PLATFORM(dev_priv, INTEL_IVYBRIDGE) 1528 1.34 riastrad #define IS_IVB_GT1(dev_priv) (IS_IVYBRIDGE(dev_priv) && \ 1529 1.34 riastrad INTEL_INFO(dev_priv)->gt == 1) 1530 1.34 riastrad #define IS_VALLEYVIEW(dev_priv) IS_PLATFORM(dev_priv, INTEL_VALLEYVIEW) 1531 1.34 riastrad #define IS_CHERRYVIEW(dev_priv) IS_PLATFORM(dev_priv, INTEL_CHERRYVIEW) 1532 1.34 riastrad #define IS_HASWELL(dev_priv) IS_PLATFORM(dev_priv, INTEL_HASWELL) 1533 1.34 riastrad #define IS_BROADWELL(dev_priv) IS_PLATFORM(dev_priv, INTEL_BROADWELL) 1534 1.34 riastrad #define IS_SKYLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_SKYLAKE) 1535 1.34 riastrad #define IS_BROXTON(dev_priv) IS_PLATFORM(dev_priv, INTEL_BROXTON) 1536 1.34 riastrad #define IS_KABYLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_KABYLAKE) 1537 1.34 riastrad #define IS_GEMINILAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_GEMINILAKE) 1538 1.34 riastrad #define IS_COFFEELAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_COFFEELAKE) 1539 1.34 riastrad #define IS_CANNONLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_CANNONLAKE) 1540 1.34 riastrad #define IS_ICELAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_ICELAKE) 1541 1.34 riastrad #define IS_ELKHARTLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_ELKHARTLAKE) 1542 1.34 riastrad #define IS_TIGERLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_TIGERLAKE) 1543 1.34 riastrad #define IS_HSW_EARLY_SDV(dev_priv) (IS_HASWELL(dev_priv) && \ 1544 1.34 riastrad (INTEL_DEVID(dev_priv) & 0xFF00) == 0x0C00) 1545 1.34 riastrad #define IS_BDW_ULT(dev_priv) \ 1546 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_BROADWELL, INTEL_SUBPLATFORM_ULT) 1547 1.34 riastrad #define IS_BDW_ULX(dev_priv) \ 1548 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_BROADWELL, INTEL_SUBPLATFORM_ULX) 1549 1.34 riastrad #define IS_BDW_GT3(dev_priv) (IS_BROADWELL(dev_priv) && \ 1550 1.34 riastrad INTEL_INFO(dev_priv)->gt == 3) 1551 1.34 riastrad #define IS_HSW_ULT(dev_priv) \ 1552 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_HASWELL, INTEL_SUBPLATFORM_ULT) 1553 1.34 riastrad #define IS_HSW_GT3(dev_priv) (IS_HASWELL(dev_priv) && \ 1554 1.34 riastrad INTEL_INFO(dev_priv)->gt == 3) 1555 1.34 riastrad #define IS_HSW_GT1(dev_priv) (IS_HASWELL(dev_priv) && \ 1556 1.34 riastrad INTEL_INFO(dev_priv)->gt == 1) 1557 1.4 riastrad /* ULX machines are also considered ULT. */ 1558 1.34 riastrad #define IS_HSW_ULX(dev_priv) \ 1559 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_HASWELL, INTEL_SUBPLATFORM_ULX) 1560 1.34 riastrad #define IS_SKL_ULT(dev_priv) \ 1561 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_SKYLAKE, INTEL_SUBPLATFORM_ULT) 1562 1.34 riastrad #define IS_SKL_ULX(dev_priv) \ 1563 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_SKYLAKE, INTEL_SUBPLATFORM_ULX) 1564 1.34 riastrad #define IS_KBL_ULT(dev_priv) \ 1565 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_KABYLAKE, INTEL_SUBPLATFORM_ULT) 1566 1.34 riastrad #define IS_KBL_ULX(dev_priv) \ 1567 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_KABYLAKE, INTEL_SUBPLATFORM_ULX) 1568 1.34 riastrad #define IS_SKL_GT2(dev_priv) (IS_SKYLAKE(dev_priv) && \ 1569 1.34 riastrad INTEL_INFO(dev_priv)->gt == 2) 1570 1.34 riastrad #define IS_SKL_GT3(dev_priv) (IS_SKYLAKE(dev_priv) && \ 1571 1.34 riastrad INTEL_INFO(dev_priv)->gt == 3) 1572 1.34 riastrad #define IS_SKL_GT4(dev_priv) (IS_SKYLAKE(dev_priv) && \ 1573 1.34 riastrad INTEL_INFO(dev_priv)->gt == 4) 1574 1.34 riastrad #define IS_KBL_GT2(dev_priv) (IS_KABYLAKE(dev_priv) && \ 1575 1.34 riastrad INTEL_INFO(dev_priv)->gt == 2) 1576 1.34 riastrad #define IS_KBL_GT3(dev_priv) (IS_KABYLAKE(dev_priv) && \ 1577 1.34 riastrad INTEL_INFO(dev_priv)->gt == 3) 1578 1.34 riastrad #define IS_CFL_ULT(dev_priv) \ 1579 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_COFFEELAKE, INTEL_SUBPLATFORM_ULT) 1580 1.34 riastrad #define IS_CFL_ULX(dev_priv) \ 1581 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_COFFEELAKE, INTEL_SUBPLATFORM_ULX) 1582 1.34 riastrad #define IS_CFL_GT2(dev_priv) (IS_COFFEELAKE(dev_priv) && \ 1583 1.34 riastrad INTEL_INFO(dev_priv)->gt == 2) 1584 1.34 riastrad #define IS_CFL_GT3(dev_priv) (IS_COFFEELAKE(dev_priv) && \ 1585 1.34 riastrad INTEL_INFO(dev_priv)->gt == 3) 1586 1.34 riastrad #define IS_CNL_WITH_PORT_F(dev_priv) \ 1587 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_CANNONLAKE, INTEL_SUBPLATFORM_PORTF) 1588 1.34 riastrad #define IS_ICL_WITH_PORT_F(dev_priv) \ 1589 1.34 riastrad IS_SUBPLATFORM(dev_priv, INTEL_ICELAKE, INTEL_SUBPLATFORM_PORTF) 1590 1.34 riastrad 1591 1.34 riastrad #define SKL_REVID_A0 0x0 1592 1.34 riastrad #define SKL_REVID_B0 0x1 1593 1.34 riastrad #define SKL_REVID_C0 0x2 1594 1.34 riastrad #define SKL_REVID_D0 0x3 1595 1.34 riastrad #define SKL_REVID_E0 0x4 1596 1.34 riastrad #define SKL_REVID_F0 0x5 1597 1.34 riastrad #define SKL_REVID_G0 0x6 1598 1.34 riastrad #define SKL_REVID_H0 0x7 1599 1.12 riastrad 1600 1.28 mrg #define IS_SKL_REVID(p, since, until) (IS_SKYLAKE(p) && IS_REVID(p, since, until)) 1601 1.28 mrg 1602 1.34 riastrad #define BXT_REVID_A0 0x0 1603 1.34 riastrad #define BXT_REVID_A1 0x1 1604 1.34 riastrad #define BXT_REVID_B0 0x3 1605 1.34 riastrad #define BXT_REVID_B_LAST 0x8 1606 1.34 riastrad #define BXT_REVID_C0 0x9 1607 1.34 riastrad 1608 1.34 riastrad #define IS_BXT_REVID(dev_priv, since, until) \ 1609 1.34 riastrad (IS_BROXTON(dev_priv) && IS_REVID(dev_priv, since, until)) 1610 1.34 riastrad 1611 1.34 riastrad #define KBL_REVID_A0 0x0 1612 1.34 riastrad #define KBL_REVID_B0 0x1 1613 1.34 riastrad #define KBL_REVID_C0 0x2 1614 1.34 riastrad #define KBL_REVID_D0 0x3 1615 1.34 riastrad #define KBL_REVID_E0 0x4 1616 1.34 riastrad 1617 1.34 riastrad #define IS_KBL_REVID(dev_priv, since, until) \ 1618 1.34 riastrad (IS_KABYLAKE(dev_priv) && IS_REVID(dev_priv, since, until)) 1619 1.34 riastrad 1620 1.34 riastrad #define GLK_REVID_A0 0x0 1621 1.34 riastrad #define GLK_REVID_A1 0x1 1622 1.34 riastrad 1623 1.34 riastrad #define IS_GLK_REVID(dev_priv, since, until) \ 1624 1.34 riastrad (IS_GEMINILAKE(dev_priv) && IS_REVID(dev_priv, since, until)) 1625 1.34 riastrad 1626 1.34 riastrad #define CNL_REVID_A0 0x0 1627 1.34 riastrad #define CNL_REVID_B0 0x1 1628 1.34 riastrad #define CNL_REVID_C0 0x2 1629 1.34 riastrad 1630 1.34 riastrad #define IS_CNL_REVID(p, since, until) \ 1631 1.34 riastrad (IS_CANNONLAKE(p) && IS_REVID(p, since, until)) 1632 1.34 riastrad 1633 1.34 riastrad #define ICL_REVID_A0 0x0 1634 1.34 riastrad #define ICL_REVID_A2 0x1 1635 1.34 riastrad #define ICL_REVID_B0 0x3 1636 1.34 riastrad #define ICL_REVID_B2 0x4 1637 1.34 riastrad #define ICL_REVID_C0 0x5 1638 1.34 riastrad 1639 1.34 riastrad #define IS_ICL_REVID(p, since, until) \ 1640 1.34 riastrad (IS_ICELAKE(p) && IS_REVID(p, since, until)) 1641 1.34 riastrad 1642 1.34 riastrad #define TGL_REVID_A0 0x0 1643 1.34 riastrad 1644 1.34 riastrad #define IS_TGL_REVID(p, since, until) \ 1645 1.34 riastrad (IS_TIGERLAKE(p) && IS_REVID(p, since, until)) 1646 1.34 riastrad 1647 1.34 riastrad #define IS_LP(dev_priv) (INTEL_INFO(dev_priv)->is_lp) 1648 1.34 riastrad #define IS_GEN9_LP(dev_priv) (IS_GEN(dev_priv, 9) && IS_LP(dev_priv)) 1649 1.34 riastrad #define IS_GEN9_BC(dev_priv) (IS_GEN(dev_priv, 9) && !IS_LP(dev_priv)) 1650 1.34 riastrad 1651 1.34 riastrad #define HAS_ENGINE(dev_priv, id) (INTEL_INFO(dev_priv)->engine_mask & BIT(id)) 1652 1.34 riastrad 1653 1.34 riastrad #define ENGINE_INSTANCES_MASK(dev_priv, first, count) ({ \ 1654 1.34 riastrad unsigned int first__ = (first); \ 1655 1.34 riastrad unsigned int count__ = (count); \ 1656 1.34 riastrad (INTEL_INFO(dev_priv)->engine_mask & \ 1657 1.34 riastrad GENMASK(first__ + count__ - 1, first__)) >> first__; \ 1658 1.34 riastrad }) 1659 1.34 riastrad #define VDBOX_MASK(dev_priv) \ 1660 1.34 riastrad ENGINE_INSTANCES_MASK(dev_priv, VCS0, I915_MAX_VCS) 1661 1.34 riastrad #define VEBOX_MASK(dev_priv) \ 1662 1.34 riastrad ENGINE_INSTANCES_MASK(dev_priv, VECS0, I915_MAX_VECS) 1663 1.28 mrg 1664 1.1 riastrad /* 1665 1.34 riastrad * The Gen7 cmdparser copies the scanned buffer to the ggtt for execution 1666 1.34 riastrad * All later gens can run the final buffer from the ppgtt 1667 1.1 riastrad */ 1668 1.34 riastrad #define CMDPARSER_USES_GGTT(dev_priv) IS_GEN(dev_priv, 7) 1669 1.1 riastrad 1670 1.34 riastrad #define HAS_LLC(dev_priv) (INTEL_INFO(dev_priv)->has_llc) 1671 1.34 riastrad #define HAS_SNOOP(dev_priv) (INTEL_INFO(dev_priv)->has_snoop) 1672 1.34 riastrad #define HAS_EDRAM(dev_priv) ((dev_priv)->edram_size_mb) 1673 1.34 riastrad #define HAS_SECURE_BATCHES(dev_priv) (INTEL_GEN(dev_priv) < 6) 1674 1.34 riastrad #define HAS_WT(dev_priv) ((IS_HASWELL(dev_priv) || \ 1675 1.34 riastrad IS_BROADWELL(dev_priv)) && HAS_EDRAM(dev_priv)) 1676 1.34 riastrad 1677 1.34 riastrad #define HWS_NEEDS_PHYSICAL(dev_priv) (INTEL_INFO(dev_priv)->hws_needs_physical) 1678 1.34 riastrad 1679 1.34 riastrad #define HAS_LOGICAL_RING_CONTEXTS(dev_priv) \ 1680 1.34 riastrad (INTEL_INFO(dev_priv)->has_logical_ring_contexts) 1681 1.34 riastrad #define HAS_LOGICAL_RING_ELSQ(dev_priv) \ 1682 1.34 riastrad (INTEL_INFO(dev_priv)->has_logical_ring_elsq) 1683 1.34 riastrad #define HAS_LOGICAL_RING_PREEMPTION(dev_priv) \ 1684 1.34 riastrad (INTEL_INFO(dev_priv)->has_logical_ring_preemption) 1685 1.34 riastrad 1686 1.34 riastrad #define HAS_EXECLISTS(dev_priv) HAS_LOGICAL_RING_CONTEXTS(dev_priv) 1687 1.34 riastrad 1688 1.34 riastrad #define INTEL_PPGTT(dev_priv) (INTEL_INFO(dev_priv)->ppgtt_type) 1689 1.34 riastrad #define HAS_PPGTT(dev_priv) \ 1690 1.34 riastrad (INTEL_PPGTT(dev_priv) != INTEL_PPGTT_NONE) 1691 1.34 riastrad #define HAS_FULL_PPGTT(dev_priv) \ 1692 1.34 riastrad (INTEL_PPGTT(dev_priv) >= INTEL_PPGTT_FULL) 1693 1.34 riastrad 1694 1.34 riastrad #define HAS_PAGE_SIZES(dev_priv, sizes) ({ \ 1695 1.34 riastrad GEM_BUG_ON((sizes) == 0); \ 1696 1.34 riastrad ((sizes) & ~INTEL_INFO(dev_priv)->page_sizes) == 0; \ 1697 1.34 riastrad }) 1698 1.34 riastrad 1699 1.34 riastrad #define HAS_OVERLAY(dev_priv) (INTEL_INFO(dev_priv)->display.has_overlay) 1700 1.34 riastrad #define OVERLAY_NEEDS_PHYSICAL(dev_priv) \ 1701 1.34 riastrad (INTEL_INFO(dev_priv)->display.overlay_needs_physical) 1702 1.1 riastrad 1703 1.1 riastrad /* Early gen2 have a totally busted CS tlb and require pinned batches. */ 1704 1.34 riastrad #define HAS_BROKEN_CS_TLB(dev_priv) (IS_I830(dev_priv) || IS_I845G(dev_priv)) 1705 1.30 maya 1706 1.34 riastrad #define NEEDS_RC6_CTX_CORRUPTION_WA(dev_priv) \ 1707 1.34 riastrad (IS_BROADWELL(dev_priv) || IS_GEN(dev_priv, 9)) 1708 1.30 maya 1709 1.34 riastrad /* WaRsDisableCoarsePowerGating:skl,cnl */ 1710 1.34 riastrad #define NEEDS_WaRsDisableCoarsePowerGating(dev_priv) \ 1711 1.34 riastrad (IS_CANNONLAKE(dev_priv) || \ 1712 1.34 riastrad IS_SKL_GT3(dev_priv) || \ 1713 1.34 riastrad IS_SKL_GT4(dev_priv)) 1714 1.34 riastrad 1715 1.34 riastrad #define HAS_GMBUS_IRQ(dev_priv) (INTEL_GEN(dev_priv) >= 4) 1716 1.34 riastrad #define HAS_GMBUS_BURST_READ(dev_priv) (INTEL_GEN(dev_priv) >= 10 || \ 1717 1.34 riastrad IS_GEMINILAKE(dev_priv) || \ 1718 1.34 riastrad IS_KABYLAKE(dev_priv)) 1719 1.1 riastrad 1720 1.1 riastrad /* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte 1721 1.1 riastrad * rows, which changed the alignment requirements and fence programming. 1722 1.1 riastrad */ 1723 1.34 riastrad #define HAS_128_BYTE_Y_TILING(dev_priv) (!IS_GEN(dev_priv, 2) && \ 1724 1.34 riastrad !(IS_I915G(dev_priv) || \ 1725 1.34 riastrad IS_I915GM(dev_priv))) 1726 1.34 riastrad #define SUPPORTS_TV(dev_priv) (INTEL_INFO(dev_priv)->display.supports_tv) 1727 1.34 riastrad #define I915_HAS_HOTPLUG(dev_priv) (INTEL_INFO(dev_priv)->display.has_hotplug) 1728 1.34 riastrad 1729 1.34 riastrad #define HAS_FW_BLC(dev_priv) (INTEL_GEN(dev_priv) > 2) 1730 1.34 riastrad #define HAS_FBC(dev_priv) (INTEL_INFO(dev_priv)->display.has_fbc) 1731 1.34 riastrad #define HAS_CUR_FBC(dev_priv) (!HAS_GMCH(dev_priv) && INTEL_GEN(dev_priv) >= 7) 1732 1.1 riastrad 1733 1.34 riastrad #define HAS_IPS(dev_priv) (IS_HSW_ULT(dev_priv) || IS_BROADWELL(dev_priv)) 1734 1.12 riastrad 1735 1.34 riastrad #define HAS_DP_MST(dev_priv) (INTEL_INFO(dev_priv)->display.has_dp_mst) 1736 1.1 riastrad 1737 1.34 riastrad #define HAS_DDI(dev_priv) (INTEL_INFO(dev_priv)->display.has_ddi) 1738 1.34 riastrad #define HAS_FPGA_DBG_UNCLAIMED(dev_priv) (INTEL_INFO(dev_priv)->has_fpga_dbg) 1739 1.34 riastrad #define HAS_PSR(dev_priv) (INTEL_INFO(dev_priv)->display.has_psr) 1740 1.34 riastrad #define HAS_TRANSCODER_EDP(dev_priv) (INTEL_INFO(dev_priv)->trans_offsets[TRANSCODER_EDP] != 0) 1741 1.1 riastrad 1742 1.34 riastrad #define HAS_RC6(dev_priv) (INTEL_INFO(dev_priv)->has_rc6) 1743 1.34 riastrad #define HAS_RC6p(dev_priv) (INTEL_INFO(dev_priv)->has_rc6p) 1744 1.34 riastrad #define HAS_RC6pp(dev_priv) (false) /* HW was never validated */ 1745 1.1 riastrad 1746 1.34 riastrad #define HAS_RPS(dev_priv) (INTEL_INFO(dev_priv)->has_rps) 1747 1.1 riastrad 1748 1.34 riastrad #define HAS_CSR(dev_priv) (INTEL_INFO(dev_priv)->display.has_csr) 1749 1.1 riastrad 1750 1.34 riastrad #define HAS_RUNTIME_PM(dev_priv) (INTEL_INFO(dev_priv)->has_runtime_pm) 1751 1.34 riastrad #define HAS_64BIT_RELOC(dev_priv) (INTEL_INFO(dev_priv)->has_64bit_reloc) 1752 1.1 riastrad 1753 1.34 riastrad #define HAS_IPC(dev_priv) (INTEL_INFO(dev_priv)->display.has_ipc) 1754 1.12 riastrad 1755 1.34 riastrad #define HAS_REGION(i915, i) (INTEL_INFO(i915)->memory_regions & (i)) 1756 1.34 riastrad #define HAS_LMEM(i915) HAS_REGION(i915, REGION_LMEM) 1757 1.4 riastrad 1758 1.34 riastrad #define HAS_GT_UC(dev_priv) (INTEL_INFO(dev_priv)->has_gt_uc) 1759 1.12 riastrad 1760 1.34 riastrad /* Having GuC is not the same as using GuC */ 1761 1.34 riastrad #define USES_GUC(dev_priv) intel_uc_uses_guc(&(dev_priv)->gt.uc) 1762 1.34 riastrad #define USES_GUC_SUBMISSION(dev_priv) intel_uc_uses_guc_submission(&(dev_priv)->gt.uc) 1763 1.12 riastrad 1764 1.34 riastrad #define HAS_POOLED_EU(dev_priv) (INTEL_INFO(dev_priv)->has_pooled_eu) 1765 1.4 riastrad 1766 1.34 riastrad #define HAS_GLOBAL_MOCS_REGISTERS(dev_priv) (INTEL_INFO(dev_priv)->has_global_mocs) 1767 1.12 riastrad 1768 1.1 riastrad 1769 1.34 riastrad #define HAS_GMCH(dev_priv) (INTEL_INFO(dev_priv)->display.has_gmch) 1770 1.1 riastrad 1771 1.34 riastrad #define HAS_LSPCON(dev_priv) (INTEL_GEN(dev_priv) >= 9) 1772 1.1 riastrad 1773 1.34 riastrad /* DPF == dynamic parity feature */ 1774 1.34 riastrad #define HAS_L3_DPF(dev_priv) (INTEL_INFO(dev_priv)->has_l3_dpf) 1775 1.34 riastrad #define NUM_L3_SLICES(dev_priv) (IS_HSW_GT3(dev_priv) ? \ 1776 1.34 riastrad 2 : HAS_L3_DPF(dev_priv)) 1777 1.1 riastrad 1778 1.34 riastrad #define GT_FREQUENCY_MULTIPLIER 50 1779 1.34 riastrad #define GEN9_FREQ_SCALER 3 1780 1.12 riastrad 1781 1.34 riastrad #define INTEL_NUM_PIPES(dev_priv) (hweight8(INTEL_INFO(dev_priv)->pipe_mask)) 1782 1.4 riastrad 1783 1.34 riastrad #define HAS_DISPLAY(dev_priv) (INTEL_INFO(dev_priv)->pipe_mask != 0) 1784 1.12 riastrad 1785 1.34 riastrad /* Only valid when HAS_DISPLAY() is true */ 1786 1.34 riastrad #define INTEL_DISPLAY_ENABLED(dev_priv) (WARN_ON(!HAS_DISPLAY(dev_priv)), !i915_modparams.disable_display) 1787 1.4 riastrad 1788 1.34 riastrad static inline bool intel_vtd_active(void) 1789 1.4 riastrad { 1790 1.34 riastrad #ifdef CONFIG_INTEL_IOMMU 1791 1.34 riastrad if (intel_iommu_gfx_mapped) 1792 1.34 riastrad return true; 1793 1.34 riastrad #endif 1794 1.34 riastrad return false; 1795 1.4 riastrad } 1796 1.4 riastrad 1797 1.34 riastrad static inline bool intel_scanout_needs_vtd_wa(struct drm_i915_private *dev_priv) 1798 1.4 riastrad { 1799 1.34 riastrad return INTEL_GEN(dev_priv) >= 6 && intel_vtd_active(); 1800 1.4 riastrad } 1801 1.1 riastrad 1802 1.34 riastrad static inline bool 1803 1.34 riastrad intel_ggtt_update_needs_vtd_wa(struct drm_i915_private *dev_priv) 1804 1.12 riastrad { 1805 1.34 riastrad return IS_BROXTON(dev_priv) && intel_vtd_active(); 1806 1.12 riastrad } 1807 1.12 riastrad 1808 1.34 riastrad /* i915_drv.c */ 1809 1.34 riastrad #ifdef CONFIG_COMPAT 1810 1.34 riastrad long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); 1811 1.2 riastrad #else 1812 1.34 riastrad #define i915_compat_ioctl NULL 1813 1.2 riastrad #endif 1814 1.34 riastrad extern const struct dev_pm_ops i915_pm_ops; 1815 1.1 riastrad 1816 1.34 riastrad int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent); 1817 1.34 riastrad void i915_driver_remove(struct drm_i915_private *i915); 1818 1.1 riastrad 1819 1.42 riastrad int i915_drm_resume(struct drm_device *); 1820 1.42 riastrad int i915_drm_resume_early(struct drm_device *); 1821 1.48 riastrad int i915_drm_prepare(struct drm_device *); 1822 1.42 riastrad int i915_drm_suspend(struct drm_device *); 1823 1.42 riastrad int i915_drm_suspend_late(struct drm_device *, bool); 1824 1.42 riastrad 1825 1.34 riastrad int i915_resume_switcheroo(struct drm_i915_private *i915); 1826 1.34 riastrad int i915_suspend_switcheroo(struct drm_i915_private *i915, pm_message_t state); 1827 1.1 riastrad 1828 1.34 riastrad int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool on); 1829 1.1 riastrad 1830 1.34 riastrad static inline bool intel_gvt_active(struct drm_i915_private *dev_priv) 1831 1.34 riastrad { 1832 1.34 riastrad return dev_priv->gvt; 1833 1.34 riastrad } 1834 1.1 riastrad 1835 1.34 riastrad static inline bool intel_vgpu_active(struct drm_i915_private *dev_priv) 1836 1.12 riastrad { 1837 1.34 riastrad return dev_priv->vgpu.active; 1838 1.12 riastrad } 1839 1.4 riastrad 1840 1.34 riastrad int i915_getparam_ioctl(struct drm_device *dev, void *data, 1841 1.34 riastrad struct drm_file *file_priv); 1842 1.12 riastrad 1843 1.34 riastrad /* i915_gem.c */ 1844 1.34 riastrad int i915_gem_init_userptr(struct drm_i915_private *dev_priv); 1845 1.34 riastrad void i915_gem_cleanup_userptr(struct drm_i915_private *dev_priv); 1846 1.34 riastrad void i915_gem_init_early(struct drm_i915_private *dev_priv); 1847 1.34 riastrad void i915_gem_cleanup_early(struct drm_i915_private *dev_priv); 1848 1.34 riastrad int i915_gem_freeze(struct drm_i915_private *dev_priv); 1849 1.34 riastrad int i915_gem_freeze_late(struct drm_i915_private *dev_priv); 1850 1.12 riastrad 1851 1.34 riastrad struct intel_memory_region *i915_gem_shmem_setup(struct drm_i915_private *i915); 1852 1.4 riastrad 1853 1.34 riastrad static inline void i915_gem_drain_freed_objects(struct drm_i915_private *i915) 1854 1.12 riastrad { 1855 1.34 riastrad /* 1856 1.34 riastrad * A single pass should suffice to release all the freed objects (along 1857 1.34 riastrad * most call paths) , but be a little more paranoid in that freeing 1858 1.34 riastrad * the objects does take a little amount of time, during which the rcu 1859 1.34 riastrad * callbacks could have added new objects into the freed list, and 1860 1.34 riastrad * armed the work again. 1861 1.34 riastrad */ 1862 1.34 riastrad while (atomic_read(&i915->mm.free_count)) { 1863 1.34 riastrad flush_work(&i915->mm.free_work); 1864 1.34 riastrad rcu_barrier(); 1865 1.34 riastrad } 1866 1.4 riastrad } 1867 1.4 riastrad 1868 1.34 riastrad static inline void i915_gem_drain_workqueue(struct drm_i915_private *i915) 1869 1.4 riastrad { 1870 1.34 riastrad /* 1871 1.34 riastrad * Similar to objects above (see i915_gem_drain_freed-objects), in 1872 1.34 riastrad * general we have workers that are armed by RCU and then rearm 1873 1.34 riastrad * themselves in their callbacks. To be paranoid, we need to 1874 1.34 riastrad * drain the workqueue a second time after waiting for the RCU 1875 1.34 riastrad * grace period so that we catch work queued via RCU from the first 1876 1.34 riastrad * pass. As neither drain_workqueue() nor flush_workqueue() report 1877 1.34 riastrad * a result, we make an assumption that we only don't require more 1878 1.34 riastrad * than 3 passes to catch all _recursive_ RCU delayed work. 1879 1.34 riastrad * 1880 1.34 riastrad */ 1881 1.34 riastrad int pass = 3; 1882 1.34 riastrad do { 1883 1.34 riastrad flush_workqueue(i915->wq); 1884 1.34 riastrad rcu_barrier(); 1885 1.34 riastrad i915_gem_drain_freed_objects(i915); 1886 1.34 riastrad } while (--pass); 1887 1.34 riastrad drain_workqueue(i915->wq); 1888 1.4 riastrad } 1889 1.4 riastrad 1890 1.34 riastrad struct i915_vma * __must_check 1891 1.34 riastrad i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, 1892 1.34 riastrad const struct i915_ggtt_view *view, 1893 1.34 riastrad u64 size, 1894 1.34 riastrad u64 alignment, 1895 1.34 riastrad u64 flags); 1896 1.34 riastrad 1897 1.34 riastrad int i915_gem_object_unbind(struct drm_i915_gem_object *obj, 1898 1.34 riastrad unsigned long flags); 1899 1.34 riastrad #define I915_GEM_OBJECT_UNBIND_ACTIVE BIT(0) 1900 1.34 riastrad #define I915_GEM_OBJECT_UNBIND_BARRIER BIT(1) 1901 1.12 riastrad 1902 1.34 riastrad void i915_gem_runtime_suspend(struct drm_i915_private *dev_priv); 1903 1.4 riastrad 1904 1.34 riastrad static inline int __must_check 1905 1.34 riastrad i915_mutex_lock_interruptible(struct drm_device *dev) 1906 1.4 riastrad { 1907 1.34 riastrad return mutex_lock_interruptible(&dev->struct_mutex); 1908 1.4 riastrad } 1909 1.4 riastrad 1910 1.34 riastrad int i915_gem_dumb_create(struct drm_file *file_priv, 1911 1.34 riastrad struct drm_device *dev, 1912 1.34 riastrad struct drm_mode_create_dumb *args); 1913 1.4 riastrad 1914 1.34 riastrad int __must_check i915_gem_set_global_seqno(struct drm_device *dev, u32 seqno); 1915 1.4 riastrad 1916 1.34 riastrad static inline u32 i915_reset_count(struct i915_gpu_error *error) 1917 1.4 riastrad { 1918 1.34 riastrad return atomic_read(&error->reset_count); 1919 1.4 riastrad } 1920 1.4 riastrad 1921 1.34 riastrad static inline u32 i915_reset_engine_count(struct i915_gpu_error *error, 1922 1.34 riastrad const struct intel_engine_cs *engine) 1923 1.12 riastrad { 1924 1.34 riastrad return atomic_read(&error->reset_engine_count[engine->uabi_class]); 1925 1.12 riastrad } 1926 1.12 riastrad 1927 1.34 riastrad int __must_check i915_gem_init(struct drm_i915_private *dev_priv); 1928 1.34 riastrad void i915_gem_driver_register(struct drm_i915_private *i915); 1929 1.34 riastrad void i915_gem_driver_unregister(struct drm_i915_private *i915); 1930 1.34 riastrad void i915_gem_driver_remove(struct drm_i915_private *dev_priv); 1931 1.34 riastrad void i915_gem_driver_release(struct drm_i915_private *dev_priv); 1932 1.34 riastrad void i915_gem_suspend(struct drm_i915_private *dev_priv); 1933 1.34 riastrad void i915_gem_suspend_late(struct drm_i915_private *dev_priv); 1934 1.34 riastrad void i915_gem_resume(struct drm_i915_private *dev_priv); 1935 1.12 riastrad 1936 1.34 riastrad int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file); 1937 1.34 riastrad void i915_gem_release(struct drm_device *dev, struct drm_file *file); 1938 1.12 riastrad 1939 1.34 riastrad int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj, 1940 1.34 riastrad enum i915_cache_level cache_level); 1941 1.12 riastrad 1942 1.34 riastrad struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, 1943 1.34 riastrad struct dma_buf *dma_buf); 1944 1.4 riastrad 1945 1.34 riastrad struct dma_buf *i915_gem_prime_export(struct drm_gem_object *gem_obj, int flags); 1946 1.34 riastrad 1947 1.34 riastrad static inline struct i915_gem_context * 1948 1.34 riastrad __i915_gem_context_lookup_rcu(struct drm_i915_file_private *file_priv, u32 id) 1949 1.4 riastrad { 1950 1.34 riastrad return xa_load(&file_priv->context_xa, id); 1951 1.4 riastrad } 1952 1.4 riastrad 1953 1.34 riastrad static inline struct i915_gem_context * 1954 1.34 riastrad i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id) 1955 1.4 riastrad { 1956 1.34 riastrad struct i915_gem_context *ctx; 1957 1.34 riastrad 1958 1.34 riastrad rcu_read_lock(); 1959 1.34 riastrad ctx = __i915_gem_context_lookup_rcu(file_priv, id); 1960 1.34 riastrad if (ctx && !kref_get_unless_zero(&ctx->ref)) 1961 1.34 riastrad ctx = NULL; 1962 1.34 riastrad rcu_read_unlock(); 1963 1.4 riastrad 1964 1.34 riastrad return ctx; 1965 1.4 riastrad } 1966 1.4 riastrad 1967 1.4 riastrad /* i915_gem_evict.c */ 1968 1.34 riastrad int __must_check i915_gem_evict_something(struct i915_address_space *vm, 1969 1.34 riastrad u64 min_size, u64 alignment, 1970 1.34 riastrad unsigned long color, 1971 1.34 riastrad u64 start, u64 end, 1972 1.4 riastrad unsigned flags); 1973 1.34 riastrad int __must_check i915_gem_evict_for_node(struct i915_address_space *vm, 1974 1.34 riastrad struct drm_mm_node *node, 1975 1.34 riastrad unsigned int flags); 1976 1.34 riastrad int i915_gem_evict_vm(struct i915_address_space *vm); 1977 1.4 riastrad 1978 1.34 riastrad /* i915_gem_internal.c */ 1979 1.4 riastrad struct drm_i915_gem_object * 1980 1.34 riastrad i915_gem_object_create_internal(struct drm_i915_private *dev_priv, 1981 1.34 riastrad phys_addr_t size); 1982 1.1 riastrad 1983 1.1 riastrad /* i915_gem_tiling.c */ 1984 1.4 riastrad static inline bool i915_gem_object_needs_bit17_swizzle(struct drm_i915_gem_object *obj) 1985 1.4 riastrad { 1986 1.34 riastrad struct drm_i915_private *i915 = to_i915(obj->base.dev); 1987 1.4 riastrad 1988 1.34 riastrad return i915->ggtt.bit_6_swizzle_x == I915_BIT_6_SWIZZLE_9_10_17 && 1989 1.34 riastrad i915_gem_object_is_tiled(obj); 1990 1.4 riastrad } 1991 1.4 riastrad 1992 1.34 riastrad u32 i915_gem_fence_size(struct drm_i915_private *dev_priv, u32 size, 1993 1.34 riastrad unsigned int tiling, unsigned int stride); 1994 1.34 riastrad u32 i915_gem_fence_alignment(struct drm_i915_private *dev_priv, u32 size, 1995 1.34 riastrad unsigned int tiling, unsigned int stride); 1996 1.4 riastrad 1997 1.12 riastrad const char *i915_cache_level_str(struct drm_i915_private *i915, int type); 1998 1.4 riastrad 1999 1.4 riastrad /* i915_cmd_parser.c */ 2000 1.30 maya int i915_cmd_parser_get_version(struct drm_i915_private *dev_priv); 2001 1.34 riastrad void intel_engine_init_cmd_parser(struct intel_engine_cs *engine); 2002 1.34 riastrad void intel_engine_cleanup_cmd_parser(struct intel_engine_cs *engine); 2003 1.34 riastrad int intel_engine_cmd_parser(struct intel_engine_cs *engine, 2004 1.34 riastrad struct i915_vma *batch, 2005 1.34 riastrad u32 batch_offset, 2006 1.34 riastrad u32 batch_length, 2007 1.34 riastrad struct i915_vma *shadow, 2008 1.34 riastrad bool trampoline); 2009 1.34 riastrad #define I915_CMD_PARSER_TRAMPOLINE_SIZE 8 2010 1.34 riastrad 2011 1.34 riastrad /* intel_device_info.c */ 2012 1.41 riastrad static inline struct intel_device_info * 2013 1.34 riastrad mkwrite_device_info(struct drm_i915_private *dev_priv) 2014 1.4 riastrad { 2015 1.41 riastrad return (struct intel_device_info *)INTEL_INFO(dev_priv); 2016 1.4 riastrad } 2017 1.1 riastrad 2018 1.1 riastrad int i915_reg_read_ioctl(struct drm_device *dev, void *data, 2019 1.1 riastrad struct drm_file *file); 2020 1.1 riastrad 2021 1.34 riastrad #define __I915_REG_OP(op__, dev_priv__, ...) \ 2022 1.34 riastrad intel_uncore_##op__(&(dev_priv__)->uncore, __VA_ARGS__) 2023 1.4 riastrad 2024 1.34 riastrad #define I915_READ(reg__) __I915_REG_OP(read, dev_priv, (reg__)) 2025 1.34 riastrad #define I915_WRITE(reg__, val__) __I915_REG_OP(write, dev_priv, (reg__), (val__)) 2026 1.4 riastrad 2027 1.34 riastrad #define POSTING_READ(reg__) __I915_REG_OP(posting_read, dev_priv, (reg__)) 2028 1.4 riastrad 2029 1.12 riastrad /* These are untraced mmio-accessors that are only valid to be used inside 2030 1.34 riastrad * critical sections, such as inside IRQ handlers, where forcewake is explicitly 2031 1.12 riastrad * controlled. 2032 1.34 riastrad * 2033 1.12 riastrad * Think twice, and think again, before using these. 2034 1.34 riastrad * 2035 1.34 riastrad * As an example, these accessors can possibly be used between: 2036 1.34 riastrad * 2037 1.34 riastrad * spin_lock_irq(&dev_priv->uncore.lock); 2038 1.34 riastrad * intel_uncore_forcewake_get__locked(); 2039 1.34 riastrad * 2040 1.34 riastrad * and 2041 1.34 riastrad * 2042 1.34 riastrad * intel_uncore_forcewake_put__locked(); 2043 1.34 riastrad * spin_unlock_irq(&dev_priv->uncore.lock); 2044 1.34 riastrad * 2045 1.34 riastrad * 2046 1.34 riastrad * Note: some registers may not need forcewake held, so 2047 1.34 riastrad * intel_uncore_forcewake_{get,put} can be omitted, see 2048 1.34 riastrad * intel_uncore_forcewake_for_reg(). 2049 1.34 riastrad * 2050 1.34 riastrad * Certain architectures will die if the same cacheline is concurrently accessed 2051 1.34 riastrad * by different clients (e.g. on Ivybridge). Access to registers should 2052 1.34 riastrad * therefore generally be serialised, by either the dev_priv->uncore.lock or 2053 1.34 riastrad * a more localised lock guarding all access to that bank of registers. 2054 1.12 riastrad */ 2055 1.34 riastrad #define I915_READ_FW(reg__) __I915_REG_OP(read_fw, dev_priv, (reg__)) 2056 1.34 riastrad #define I915_WRITE_FW(reg__, val__) __I915_REG_OP(write_fw, dev_priv, (reg__), (val__)) 2057 1.12 riastrad 2058 1.34 riastrad /* register wait wrappers for display regs */ 2059 1.34 riastrad #define intel_de_wait_for_register(dev_priv_, reg_, mask_, value_, timeout_) \ 2060 1.34 riastrad intel_wait_for_register(&(dev_priv_)->uncore, \ 2061 1.34 riastrad (reg_), (mask_), (value_), (timeout_)) 2062 1.34 riastrad 2063 1.34 riastrad #define intel_de_wait_for_set(dev_priv_, reg_, mask_, timeout_) ({ \ 2064 1.34 riastrad u32 mask__ = (mask_); \ 2065 1.34 riastrad intel_de_wait_for_register((dev_priv_), (reg_), \ 2066 1.34 riastrad mask__, mask__, (timeout_)); \ 2067 1.34 riastrad }) 2068 1.1 riastrad 2069 1.34 riastrad #define intel_de_wait_for_clear(dev_priv_, reg_, mask_, timeout_) \ 2070 1.34 riastrad intel_de_wait_for_register((dev_priv_), (reg_), (mask_), 0, (timeout_)) 2071 1.1 riastrad 2072 1.34 riastrad /* i915_mm.c */ 2073 1.35 riastrad #ifndef __NetBSD__ 2074 1.34 riastrad int remap_io_mapping(struct vm_area_struct *vma, 2075 1.34 riastrad unsigned long addr, unsigned long pfn, unsigned long size, 2076 1.34 riastrad struct io_mapping *iomap); 2077 1.34 riastrad int remap_io_sg(struct vm_area_struct *vma, 2078 1.34 riastrad unsigned long addr, unsigned long size, 2079 1.34 riastrad struct scatterlist *sgl, resource_size_t iobase); 2080 1.35 riastrad #endif 2081 1.1 riastrad 2082 1.34 riastrad static inline int intel_hws_csb_write_index(struct drm_i915_private *i915) 2083 1.12 riastrad { 2084 1.34 riastrad if (INTEL_GEN(i915) >= 10) 2085 1.34 riastrad return CNL_HWS_CSB_WRITE_INDEX; 2086 1.34 riastrad else 2087 1.34 riastrad return I915_HWS_CSB_WRITE_INDEX; 2088 1.12 riastrad } 2089 1.12 riastrad 2090 1.34 riastrad static inline enum i915_map_type 2091 1.34 riastrad i915_coherent_map_type(struct drm_i915_private *i915) 2092 1.4 riastrad { 2093 1.34 riastrad return HAS_LLC(i915) ? I915_MAP_WB : I915_MAP_WC; 2094 1.4 riastrad } 2095 1.1 riastrad 2096 1.34 riastrad static inline bool intel_guc_submission_is_enabled(struct intel_guc *guc) 2097 1.12 riastrad { 2098 1.34 riastrad return intel_guc_is_submission_supported(guc) && 2099 1.34 riastrad intel_guc_is_running(guc); 2100 1.12 riastrad } 2101 1.12 riastrad 2102 1.1 riastrad #endif 2103