i915_drv.h 33.7 KB
Newer Older
L
Linus Torvalds 已提交
1 2
/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
 */
D
Dave Airlie 已提交
3
/*
4
 *
L
Linus Torvalds 已提交
5 6
 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
 * All Rights Reserved.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
D
Dave Airlie 已提交
28
 */
L
Linus Torvalds 已提交
29 30 31 32

#ifndef _I915_DRV_H_
#define _I915_DRV_H_

33 34
#include <uapi/drm/i915_drm.h>

35
#include <linux/pm_qos.h>
36

37
#include <drm/ttm/ttm_device.h>
38

39
#include "display/intel_display.h"
40
#include "display/intel_display_core.h"
41

42
#include "gem/i915_gem_context_types.h"
43
#include "gem/i915_gem_shrinker.h"
44 45
#include "gem/i915_gem_stolen.h"

46
#include "gt/intel_engine.h"
47
#include "gt/intel_gt_types.h"
48
#include "gt/intel_region_lmem.h"
49
#include "gt/intel_workarounds.h"
50
#include "gt/uc/intel_uc.h"
51

52
#include "i915_drm_client.h"
53 54 55 56 57 58
#include "i915_gem.h"
#include "i915_gpu_error.h"
#include "i915_params.h"
#include "i915_perf_types.h"
#include "i915_scheduler.h"
#include "i915_utils.h"
59
#include "intel_device_info.h"
60
#include "intel_memory_region.h"
61
#include "intel_pch.h"
62
#include "intel_runtime_pm.h"
63
#include "intel_step.h"
64
#include "intel_uncore.h"
65

66
struct drm_i915_clock_gating_funcs;
67
struct drm_i915_gem_object;
68 69 70 71 72 73 74
struct drm_i915_private;
struct intel_connector;
struct intel_dp;
struct intel_encoder;
struct intel_limit;
struct intel_overlay_error_state;
struct vlv_s0ix_state;
75
struct intel_pxp;
76

77 78 79 80 81 82
#define I915_GEM_GPU_DOMAINS \
	(I915_GEM_DOMAIN_RENDER | \
	 I915_GEM_DOMAIN_SAMPLER | \
	 I915_GEM_DOMAIN_COMMAND | \
	 I915_GEM_DOMAIN_INSTRUCTION | \
	 I915_GEM_DOMAIN_VERTEX)
83

84 85
#define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */

86 87
#define GEM_QUIRK_PIN_SWIZZLED_PAGES	BIT(0)

88
struct i915_suspend_saved_registers {
89
	u32 saveDSPARB;
J
Jesse Barnes 已提交
90 91
	u32 saveSWF0[16];
	u32 saveSWF1[16];
92
	u32 saveSWF3[3];
93
	u16 saveGCDGMBUS;
94
};
95

96
#define MAX_L3_SLICES 2
97
struct intel_l3_parity {
98
	u32 *remap_info[MAX_L3_SLICES];
99
	struct work_struct error_work;
100
	int which_slice;
101 102
};

103
struct i915_gem_mm {
104 105 106 107 108 109 110
	/*
	 * Shortcut for the stolen region. This points to either
	 * INTEL_REGION_STOLEN_SMEM for integrated platforms, or
	 * INTEL_REGION_STOLEN_LMEM for discrete, or NULL if the device doesn't
	 * support stolen.
	 */
	struct intel_memory_region *stolen_region;
111 112
	/** Memory allocator for GTT stolen memory */
	struct drm_mm stolen;
113 114 115 116
	/** Protects the usage of the GTT stolen memory allocator. This is
	 * always the inner lock when overlapping with struct_mutex. */
	struct mutex stolen_lock;

117 118 119
	/* Protects bound_list/unbound_list and #drm_i915_gem_object.mm.link */
	spinlock_t obj_lock;

120
	/**
121
	 * List of objects which are purgeable.
122
	 */
123 124
	struct list_head purge_list;

125
	/**
126
	 * List of objects which have allocated pages and are shrinkable.
127
	 */
128
	struct list_head shrink_list;
129

130 131 132 133
	/**
	 * List of objects which are pending destruction.
	 */
	struct llist_head free_list;
134
	struct work_struct free_work;
135 136 137 138 139
	/**
	 * Count of objects pending destructions. Used to skip needlessly
	 * waiting on an RCU barrier if no objects are waiting to be freed.
	 */
	atomic_t free_count;
140

M
Matthew Auld 已提交
141 142 143 144 145
	/**
	 * tmpfs instance used for shmem backed objects
	 */
	struct vfsmount *gemfs;

146 147
	struct intel_memory_region *regions[INTEL_REGION_UNKNOWN];

148
	struct notifier_block oom_notifier;
149
	struct notifier_block vmap_notifier;
150
	struct shrinker shrinker;
151

152
#ifdef CONFIG_MMU_NOTIFIER
153
	/**
154 155
	 * notifier_lock for mmu notifiers, memory may not be allocated
	 * while holding this lock.
156
	 */
157
	rwlock_t notifier_lock;
158
#endif
159

160 161 162
	/* shrinker accounting, also useful for userland debugging */
	u64 shrink_memory;
	u32 shrink_count;
163 164
};

165 166
#define I915_IDLE_ENGINES_TIMEOUT (200) /* in ms */

167 168 169 170 171 172 173 174 175
unsigned long i915_fence_context_timeout(const struct drm_i915_private *i915,
					 u64 context);

static inline unsigned long
i915_fence_timeout(const struct drm_i915_private *i915)
{
	return i915_fence_context_timeout(i915, U64_MAX);
}

176 177
#define HAS_HW_SAGV_WM(i915) (DISPLAY_VER(i915) >= 13 && !IS_DGFX(i915))

178
struct i915_virtual_gpu {
179
	struct mutex lock; /* serialises sending of g2v_notify command pkts */
180
	bool active;
181
	u32 caps;
182 183
	u32 *initial_mmio;
	u8 *initial_cfg_space;
184
	struct list_head entry;
185 186
};

187 188
struct i915_selftest_stash {
	atomic_t counter;
189
	struct ida mock_region_instances;
190 191
};

192
struct drm_i915_private {
193 194
	struct drm_device drm;

195 196
	struct intel_display display;

197 198 199
	/* FIXME: Device release actions should all be moved to drmm_ */
	bool do_release;

200 201 202
	/* i915 device parameters */
	struct i915_params params;

203
	const struct intel_device_info __info; /* Use INTEL_INFO() to access. */
204
	struct intel_runtime_info __runtime; /* Use RUNTIME_INFO() to access. */
205
	struct intel_driver_caps caps;
206

207 208 209
	/**
	 * Data Stolen Memory - aka "i915 stolen memory" gives us the start and
	 * end of stolen which we can optionally use to create GEM objects
210
	 * backed by stolen memory. Note that stolen_usable_size tells us
211 212 213 214
	 * exactly how much of this we are actually allowed to use, given that
	 * some portion of it is in fact reserved for use by hardware functions.
	 */
	struct resource dsm;
215 216 217 218
	/**
	 * Reseved portion of Data Stolen Memory
	 */
	struct resource dsm_reserved;
219

220 221 222 223 224 225 226 227 228
	/*
	 * Stolen memory is segmented in hardware with different portions
	 * offlimits to certain functions.
	 *
	 * The drm_mm is initialised to the total accessible range, as found
	 * from the PCI config. On Broadwell+, this is further restricted to
	 * avoid the first page! The upper end of stolen memory is reserved for
	 * hardware functions and similarly removed from the accessible range.
	 */
229
	resource_size_t stolen_usable_size;	/* Total size minus reserved ranges */
230

231
	struct intel_uncore uncore;
232
	struct intel_uncore_mmio_debug mmio_debug;
233

234 235
	struct i915_virtual_gpu vgpu;

236
	struct intel_gvt *gvt;
237

238
	struct pci_dev *bridge_dev;
239 240

	struct rb_root uabi_engines;
241
	unsigned int engine_uabi_class_count[I915_LAST_UABI_ENGINE_CLASS + 1];
242 243 244 245 246 247

	struct resource mch_res;

	/* protects the irq masks */
	spinlock_t irq_lock;

248 249
	bool display_irqs_enabled;

V
Ville Syrjälä 已提交
250 251
	/* Sideband mailbox protection */
	struct mutex sb_lock;
252
	struct pm_qos_request sb_qos;
253 254

	/** Cached value of IMR to avoid reads in updating the bitfield */
255 256 257 258
	union {
		u32 irq_mask;
		u32 de_irq_mask[I915_MAX_PIPES];
	};
259
	u32 pipestat_irq_mask[I915_MAX_PIPES];
260

261 262
	bool preserve_bios_swizzle;

263
	unsigned int fsb_freq, mem_freq, is_ddr3;
264
	unsigned int skl_preferred_vco_freq;
265

M
Mika Kahola 已提交
266
	unsigned int max_dotclk_freq;
267
	unsigned int hpll_freq;
268
	unsigned int czclk_freq;
269

270 271 272 273 274 275 276
	/**
	 * wq - Driver workqueue for GEM.
	 *
	 * NOTE: Work items scheduled here are not allowed to grab any modeset
	 * locks, for otherwise the flushing done in the pageflip code will
	 * result in deadlocks.
	 */
277 278
	struct workqueue_struct *wq;

279
	/* pm private clock gating functions */
280
	const struct drm_i915_clock_gating_funcs *clock_gating_funcs;
281

282 283
	/* PCH chipset type */
	enum intel_pch pch_type;
284
	unsigned short pch_id;
285

286
	unsigned long gem_quirks;
287

288
	struct drm_atomic_state *modeset_restore_state;
289
	struct drm_modeset_acquire_ctx reset_ctx;
290

291
	struct i915_gem_mm mm;
292 293 294

	/* Kernel Modesetting */

295 296
	struct list_head global_obj_list;

297
	bool mchbar_need_disable;
298

299 300
	struct intel_l3_parity l3_parity;

M
Matt Roper 已提交
301 302 303 304 305 306 307 308
	/*
	 * HTI (aka HDPORT) state read during initial hw readout.  Most
	 * platforms don't have HTI, so this will just stay 0.  Those that do
	 * will use this later to figure out which PLLs and PHYs are unavailable
	 * for driver usage.
	 */
	u32 hti_state;

309 310 311 312 313
	/*
	 * edram size in MB.
	 * Cannot be determined by PCIID. You must always read a register.
	 */
	u32 edram_size_mb;
B
Ben Widawsky 已提交
314

315
	struct i915_gpu_error gpu_error;
316

317 318 319 320 321 322
	/*
	 * Shadows for CHV DPLL_MD regs to keep the state
	 * checker somewhat working in the presence hardware
	 * crappiness (can't read out DPLL_MD for pipes B & C).
	 */
	u32 chv_dpll_md[I915_MAX_PIPES];
323
	u32 bxt_phy_grc;
324

325
	u32 suspend_count;
326
	struct i915_suspend_saved_registers regfile;
327
	struct vlv_s0ix_state *vlv_s0ix_state;
328

329
	struct dram_info {
330
		bool wm_lv_0_adjust_needed;
331
		u8 num_channels;
332
		bool symmetric_memory;
V
Ville Syrjälä 已提交
333 334 335 336 337
		enum intel_dram_type {
			INTEL_DRAM_UNKNOWN,
			INTEL_DRAM_DDR3,
			INTEL_DRAM_DDR4,
			INTEL_DRAM_LPDDR3,
338 339 340
			INTEL_DRAM_LPDDR4,
			INTEL_DRAM_DDR5,
			INTEL_DRAM_LPDDR5,
V
Ville Syrjälä 已提交
341
		} type;
342
		u8 num_qgv_points;
343
		u8 num_psf_gv_points;
344 345
	} dram_info;

346
	struct intel_runtime_pm runtime_pm;
347

348
	struct i915_perf perf;
349

350 351
	struct i915_hwmon *hwmon;

352
	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
353
	struct intel_gt gt0;
354

355 356 357 358 359 360
	/*
	 * i915->gt[0] == &i915->gt0
	 */
#define I915_MAX_GT 4
	struct intel_gt *gt[I915_MAX_GT];

361 362
	struct kobject *sysfs_gt;

363 364 365
	/* Quick lookup of media GT (current platforms only have one) */
	struct intel_gt *media_gt;

366
	struct {
367 368 369 370
		struct i915_gem_contexts {
			spinlock_t lock; /* locks list */
			struct list_head list;
		} contexts;
371 372 373 374 375 376 377 378 379 380

		/*
		 * We replace the local file with a global mappings as the
		 * backing storage for the mmap is on the device and not
		 * on the struct file, and we do not want to prolong the
		 * lifetime of the local fd. To minimise the number of
		 * anonymous inodes we create, we use a global singleton to
		 * share the global mapping.
		 */
		struct file *mmap_singleton;
381
	} gem;
382

383 384
	struct intel_pxp *pxp;

385 386
	u8 pch_ssc_use;

387 388
	/* For i915gm/i945gm vblank irq workaround */
	u8 vblank_enabled;
389

390 391
	bool irq_enabled;

392 393 394 395 396
	/*
	 * DG2: Mask of PHYs that were not calibrated by the firmware
	 * and should not be used.
	 */
	u8 snps_phy_failed_calibration;
397

398 399
	struct i915_pmu pmu;

400 401
	struct i915_drm_clients clients;

402 403 404
	/* The TTM device structure. */
	struct ttm_device bdev;

405 406
	I915_SELFTEST_DECLARE(struct i915_selftest_stash selftest;)

407 408 409 410
	/*
	 * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch
	 * will be rejected. Instead look for a better place.
	 */
411
};
L
Linus Torvalds 已提交
412

413 414
static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
{
415
	return container_of(dev, struct drm_i915_private, drm);
416 417
}

418
static inline struct drm_i915_private *kdev_to_i915(struct device *kdev)
I
Imre Deak 已提交
419
{
420 421 422 423 424 425
	return dev_get_drvdata(kdev);
}

static inline struct drm_i915_private *pdev_to_i915(struct pci_dev *pdev)
{
	return pci_get_drvdata(pdev);
I
Imre Deak 已提交
426 427
}

428 429
static inline struct intel_gt *to_gt(struct drm_i915_private *i915)
{
430
	return &i915->gt0;
431 432
}

433
/* Simple iterator over all initialised engines */
434 435 436 437 438
#define for_each_engine(engine__, dev_priv__, id__) \
	for ((id__) = 0; \
	     (id__) < I915_NUM_ENGINES; \
	     (id__)++) \
		for_each_if ((engine__) = (dev_priv__)->engine[(id__)])
439 440

/* Iterator over subset of engines selected by mask */
441
#define for_each_engine_masked(engine__, gt__, mask__, tmp__) \
442
	for ((tmp__) = (mask__) & (gt__)->info.engine_mask; \
443
	     (tmp__) ? \
444
	     ((engine__) = (gt__)->engine[__mask_next_bit(tmp__)]), 1 : \
445
	     0;)
446

447 448 449 450 451 452 453 454
#define rb_to_uabi_engine(rb) \
	rb_entry_safe(rb, struct intel_engine_cs, uabi_node)

#define for_each_uabi_engine(engine__, i915__) \
	for ((engine__) = rb_to_uabi_engine(rb_first(&(i915__)->uabi_engines));\
	     (engine__); \
	     (engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node)))

455 456 457 458 459
#define for_each_uabi_class_engine(engine__, class__, i915__) \
	for ((engine__) = intel_engine_lookup_user((i915__), (class__), 0); \
	     (engine__) && (engine__)->uabi_class == (class__); \
	     (engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node)))

460
#define INTEL_INFO(dev_priv)	(&(dev_priv)->__info)
461
#define RUNTIME_INFO(dev_priv)	(&(dev_priv)->__runtime)
462
#define DRIVER_CAPS(dev_priv)	(&(dev_priv)->caps)
463

464
#define INTEL_DEVID(dev_priv)	(RUNTIME_INFO(dev_priv)->device_id)
465

466
#define IP_VER(ver, rel)		((ver) << 8 | (rel))
467

468 469 470
#define GRAPHICS_VER(i915)		(RUNTIME_INFO(i915)->graphics.ip.ver)
#define GRAPHICS_VER_FULL(i915)		IP_VER(RUNTIME_INFO(i915)->graphics.ip.ver, \
					       RUNTIME_INFO(i915)->graphics.ip.rel)
471 472 473
#define IS_GRAPHICS_VER(i915, from, until) \
	(GRAPHICS_VER(i915) >= (from) && GRAPHICS_VER(i915) <= (until))

474 475 476
#define MEDIA_VER(i915)			(RUNTIME_INFO(i915)->media.ip.ver)
#define MEDIA_VER_FULL(i915)		IP_VER(RUNTIME_INFO(i915)->media.ip.ver, \
					       RUNTIME_INFO(i915)->media.ip.rel)
477 478 479
#define IS_MEDIA_VER(i915, from, until) \
	(MEDIA_VER(i915) >= (from) && MEDIA_VER(i915) <= (until))

480
#define DISPLAY_VER(i915)	(RUNTIME_INFO(i915)->display.ip.ver)
481
#define IS_DISPLAY_VER(i915, from, until) \
482 483
	(DISPLAY_VER(i915) >= (from) && DISPLAY_VER(i915) <= (until))

484
#define INTEL_REVID(dev_priv)	(to_pci_dev((dev_priv)->drm.dev)->revision)
485

486 487
#define HAS_DSB(dev_priv)	(INTEL_INFO(dev_priv)->display.has_dsb)

488
#define INTEL_DISPLAY_STEP(__i915) (RUNTIME_INFO(__i915)->step.display_step)
489
#define INTEL_GRAPHICS_STEP(__i915) (RUNTIME_INFO(__i915)->step.graphics_step)
490
#define INTEL_MEDIA_STEP(__i915) (RUNTIME_INFO(__i915)->step.media_step)
491
#define INTEL_BASEDIE_STEP(__i915) (RUNTIME_INFO(__i915)->step.basedie_step)
492 493 494

#define IS_DISPLAY_STEP(__i915, since, until) \
	(drm_WARN_ON(&(__i915)->drm, INTEL_DISPLAY_STEP(__i915) == STEP_NONE), \
495
	 INTEL_DISPLAY_STEP(__i915) >= (since) && INTEL_DISPLAY_STEP(__i915) < (until))
496

497 498 499
#define IS_GRAPHICS_STEP(__i915, since, until) \
	(drm_WARN_ON(&(__i915)->drm, INTEL_GRAPHICS_STEP(__i915) == STEP_NONE), \
	 INTEL_GRAPHICS_STEP(__i915) >= (since) && INTEL_GRAPHICS_STEP(__i915) < (until))
500

501 502 503 504
#define IS_MEDIA_STEP(__i915, since, until) \
	(drm_WARN_ON(&(__i915)->drm, INTEL_MEDIA_STEP(__i915) == STEP_NONE), \
	 INTEL_MEDIA_STEP(__i915) >= (since) && INTEL_MEDIA_STEP(__i915) < (until))

505 506 507 508
#define IS_BASEDIE_STEP(__i915, since, until) \
	(drm_WARN_ON(&(__i915)->drm, INTEL_BASEDIE_STEP(__i915) == STEP_NONE), \
	 INTEL_BASEDIE_STEP(__i915) >= (since) && INTEL_BASEDIE_STEP(__i915) < (until))

509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
static __always_inline unsigned int
__platform_mask_index(const struct intel_runtime_info *info,
		      enum intel_platform p)
{
	const unsigned int pbits =
		BITS_PER_TYPE(info->platform_mask[0]) - INTEL_SUBPLATFORM_BITS;

	/* Expand the platform_mask array if this fails. */
	BUILD_BUG_ON(INTEL_MAX_PLATFORMS >
		     pbits * ARRAY_SIZE(info->platform_mask));

	return p / pbits;
}

static __always_inline unsigned int
__platform_mask_bit(const struct intel_runtime_info *info,
		    enum intel_platform p)
{
	const unsigned int pbits =
		BITS_PER_TYPE(info->platform_mask[0]) - INTEL_SUBPLATFORM_BITS;

	return p % pbits + INTEL_SUBPLATFORM_BITS;
}

static inline u32
intel_subplatform(const struct intel_runtime_info *info, enum intel_platform p)
{
	const unsigned int pi = __platform_mask_index(info, p);

538
	return info->platform_mask[pi] & INTEL_SUBPLATFORM_MASK;
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
}

static __always_inline bool
IS_PLATFORM(const struct drm_i915_private *i915, enum intel_platform p)
{
	const struct intel_runtime_info *info = RUNTIME_INFO(i915);
	const unsigned int pi = __platform_mask_index(info, p);
	const unsigned int pb = __platform_mask_bit(info, p);

	BUILD_BUG_ON(!__builtin_constant_p(p));

	return info->platform_mask[pi] & BIT(pb);
}

static __always_inline bool
IS_SUBPLATFORM(const struct drm_i915_private *i915,
	       enum intel_platform p, unsigned int s)
{
	const struct intel_runtime_info *info = RUNTIME_INFO(i915);
	const unsigned int pi = __platform_mask_index(info, p);
	const unsigned int pb = __platform_mask_bit(info, p);
	const unsigned int msb = BITS_PER_TYPE(info->platform_mask[0]) - 1;
	const u32 mask = info->platform_mask[pi];

	BUILD_BUG_ON(!__builtin_constant_p(p));
	BUILD_BUG_ON(!__builtin_constant_p(s));
	BUILD_BUG_ON((s) >= INTEL_SUBPLATFORM_BITS);

	/* Shift and test on the MSB position so sign flag can be used. */
	return ((mask << (msb - pb)) & (mask << (msb - s))) & BIT(msb);
}
T
Tvrtko Ursulin 已提交
570

571
#define IS_MOBILE(dev_priv)	(INTEL_INFO(dev_priv)->is_mobile)
572
#define IS_DGFX(dev_priv)   (INTEL_INFO(dev_priv)->is_dgfx)
573

T
Tvrtko Ursulin 已提交
574 575 576 577 578 579 580 581 582 583 584 585
#define IS_I830(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I830)
#define IS_I845G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I845G)
#define IS_I85X(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I85X)
#define IS_I865G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I865G)
#define IS_I915G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I915G)
#define IS_I915GM(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I915GM)
#define IS_I945G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I945G)
#define IS_I945GM(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I945GM)
#define IS_I965G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I965G)
#define IS_I965GM(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I965GM)
#define IS_G45(dev_priv)	IS_PLATFORM(dev_priv, INTEL_G45)
#define IS_GM45(dev_priv)	IS_PLATFORM(dev_priv, INTEL_GM45)
586
#define IS_G4X(dev_priv)	(IS_G45(dev_priv) || IS_GM45(dev_priv))
T
Tvrtko Ursulin 已提交
587 588
#define IS_PINEVIEW(dev_priv)	IS_PLATFORM(dev_priv, INTEL_PINEVIEW)
#define IS_G33(dev_priv)	IS_PLATFORM(dev_priv, INTEL_G33)
589 590 591
#define IS_IRONLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_IRONLAKE)
#define IS_IRONLAKE_M(dev_priv) \
	(IS_PLATFORM(dev_priv, INTEL_IRONLAKE) && IS_MOBILE(dev_priv))
592
#define IS_SANDYBRIDGE(dev_priv) IS_PLATFORM(dev_priv, INTEL_SANDYBRIDGE)
T
Tvrtko Ursulin 已提交
593
#define IS_IVYBRIDGE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_IVYBRIDGE)
594
#define IS_IVB_GT1(dev_priv)	(IS_IVYBRIDGE(dev_priv) && \
595
				 INTEL_INFO(dev_priv)->gt == 1)
T
Tvrtko Ursulin 已提交
596 597 598 599 600 601 602 603 604
#define IS_VALLEYVIEW(dev_priv)	IS_PLATFORM(dev_priv, INTEL_VALLEYVIEW)
#define IS_CHERRYVIEW(dev_priv)	IS_PLATFORM(dev_priv, INTEL_CHERRYVIEW)
#define IS_HASWELL(dev_priv)	IS_PLATFORM(dev_priv, INTEL_HASWELL)
#define IS_BROADWELL(dev_priv)	IS_PLATFORM(dev_priv, INTEL_BROADWELL)
#define IS_SKYLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_SKYLAKE)
#define IS_BROXTON(dev_priv)	IS_PLATFORM(dev_priv, INTEL_BROXTON)
#define IS_KABYLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_KABYLAKE)
#define IS_GEMINILAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_GEMINILAKE)
#define IS_COFFEELAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_COFFEELAKE)
605
#define IS_COMETLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_COMETLAKE)
606
#define IS_ICELAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_ICELAKE)
607 608
#define IS_JSL_EHL(dev_priv)	(IS_PLATFORM(dev_priv, INTEL_JASPERLAKE) || \
				IS_PLATFORM(dev_priv, INTEL_ELKHARTLAKE))
609
#define IS_TIGERLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_TIGERLAKE)
610
#define IS_ROCKETLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_ROCKETLAKE)
611
#define IS_DG1(dev_priv)        IS_PLATFORM(dev_priv, INTEL_DG1)
612
#define IS_ALDERLAKE_S(dev_priv) IS_PLATFORM(dev_priv, INTEL_ALDERLAKE_S)
613
#define IS_ALDERLAKE_P(dev_priv) IS_PLATFORM(dev_priv, INTEL_ALDERLAKE_P)
614
#define IS_XEHPSDV(dev_priv) IS_PLATFORM(dev_priv, INTEL_XEHPSDV)
M
Matt Roper 已提交
615
#define IS_DG2(dev_priv)	IS_PLATFORM(dev_priv, INTEL_DG2)
616
#define IS_PONTEVECCHIO(dev_priv) IS_PLATFORM(dev_priv, INTEL_PONTEVECCHIO)
617
#define IS_METEORLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_METEORLAKE)
618

619 620 621 622
#define IS_METEORLAKE_M(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_METEORLAKE, INTEL_SUBPLATFORM_M)
#define IS_METEORLAKE_P(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_METEORLAKE, INTEL_SUBPLATFORM_P)
M
Matt Roper 已提交
623 624 625 626
#define IS_DG2_G10(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_DG2, INTEL_SUBPLATFORM_G10)
#define IS_DG2_G11(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_DG2, INTEL_SUBPLATFORM_G11)
627 628
#define IS_DG2_G12(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_DG2, INTEL_SUBPLATFORM_G12)
629
#define IS_ADLS_RPLS(dev_priv) \
M
Matt Atwood 已提交
630
	IS_SUBPLATFORM(dev_priv, INTEL_ALDERLAKE_S, INTEL_SUBPLATFORM_RPL)
631 632
#define IS_ADLP_N(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_ALDERLAKE_P, INTEL_SUBPLATFORM_N)
M
Matt Atwood 已提交
633 634
#define IS_ADLP_RPLP(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_ALDERLAKE_P, INTEL_SUBPLATFORM_RPL)
635 636
#define IS_HSW_EARLY_SDV(dev_priv) (IS_HASWELL(dev_priv) && \
				    (INTEL_DEVID(dev_priv) & 0xFF00) == 0x0C00)
637 638 639 640
#define IS_BDW_ULT(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_BROADWELL, INTEL_SUBPLATFORM_ULT)
#define IS_BDW_ULX(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_BROADWELL, INTEL_SUBPLATFORM_ULX)
641
#define IS_BDW_GT3(dev_priv)	(IS_BROADWELL(dev_priv) && \
642
				 INTEL_INFO(dev_priv)->gt == 3)
643 644
#define IS_HSW_ULT(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_HASWELL, INTEL_SUBPLATFORM_ULT)
645
#define IS_HSW_GT3(dev_priv)	(IS_HASWELL(dev_priv) && \
646
				 INTEL_INFO(dev_priv)->gt == 3)
647
#define IS_HSW_GT1(dev_priv)	(IS_HASWELL(dev_priv) && \
648
				 INTEL_INFO(dev_priv)->gt == 1)
649
/* ULX machines are also considered ULT. */
650 651 652 653 654 655 656 657 658 659
#define IS_HSW_ULX(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_HASWELL, INTEL_SUBPLATFORM_ULX)
#define IS_SKL_ULT(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_SKYLAKE, INTEL_SUBPLATFORM_ULT)
#define IS_SKL_ULX(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_SKYLAKE, INTEL_SUBPLATFORM_ULX)
#define IS_KBL_ULT(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_KABYLAKE, INTEL_SUBPLATFORM_ULT)
#define IS_KBL_ULX(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_KABYLAKE, INTEL_SUBPLATFORM_ULX)
660
#define IS_SKL_GT2(dev_priv)	(IS_SKYLAKE(dev_priv) && \
661
				 INTEL_INFO(dev_priv)->gt == 2)
662
#define IS_SKL_GT3(dev_priv)	(IS_SKYLAKE(dev_priv) && \
663
				 INTEL_INFO(dev_priv)->gt == 3)
664
#define IS_SKL_GT4(dev_priv)	(IS_SKYLAKE(dev_priv) && \
665
				 INTEL_INFO(dev_priv)->gt == 4)
666
#define IS_KBL_GT2(dev_priv)	(IS_KABYLAKE(dev_priv) && \
667
				 INTEL_INFO(dev_priv)->gt == 2)
668
#define IS_KBL_GT3(dev_priv)	(IS_KABYLAKE(dev_priv) && \
669
				 INTEL_INFO(dev_priv)->gt == 3)
670 671
#define IS_CFL_ULT(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_COFFEELAKE, INTEL_SUBPLATFORM_ULT)
672 673
#define IS_CFL_ULX(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_COFFEELAKE, INTEL_SUBPLATFORM_ULX)
674
#define IS_CFL_GT2(dev_priv)	(IS_COFFEELAKE(dev_priv) && \
675
				 INTEL_INFO(dev_priv)->gt == 2)
676
#define IS_CFL_GT3(dev_priv)	(IS_COFFEELAKE(dev_priv) && \
677
				 INTEL_INFO(dev_priv)->gt == 3)
678 679 680 681 682 683 684 685

#define IS_CML_ULT(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_COMETLAKE, INTEL_SUBPLATFORM_ULT)
#define IS_CML_ULX(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_COMETLAKE, INTEL_SUBPLATFORM_ULX)
#define IS_CML_GT2(dev_priv)	(IS_COMETLAKE(dev_priv) && \
				 INTEL_INFO(dev_priv)->gt == 2)

686 687
#define IS_ICL_WITH_PORT_F(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_ICELAKE, INTEL_SUBPLATFORM_PORTF)
688

689 690
#define IS_TGL_UY(dev_priv) \
	IS_SUBPLATFORM(dev_priv, INTEL_TIGERLAKE, INTEL_SUBPLATFORM_UY)
691

692
#define IS_SKL_GRAPHICS_STEP(p, since, until) (IS_SKYLAKE(p) && IS_GRAPHICS_STEP(p, since, until))
693

694 695
#define IS_KBL_GRAPHICS_STEP(dev_priv, since, until) \
	(IS_KABYLAKE(dev_priv) && IS_GRAPHICS_STEP(dev_priv, since, until))
696 697
#define IS_KBL_DISPLAY_STEP(dev_priv, since, until) \
	(IS_KABYLAKE(dev_priv) && IS_DISPLAY_STEP(dev_priv, since, until))
M
Mika Kuoppala 已提交
698

699 700
#define IS_JSL_EHL_GRAPHICS_STEP(p, since, until) \
	(IS_JSL_EHL(p) && IS_GRAPHICS_STEP(p, since, until))
701 702
#define IS_JSL_EHL_DISPLAY_STEP(p, since, until) \
	(IS_JSL_EHL(p) && IS_DISPLAY_STEP(p, since, until))
703

704
#define IS_TGL_DISPLAY_STEP(__i915, since, until) \
705 706
	(IS_TIGERLAKE(__i915) && \
	 IS_DISPLAY_STEP(__i915, since, until))
707

708
#define IS_TGL_UY_GRAPHICS_STEP(__i915, since, until) \
709
	(IS_TGL_UY(__i915) && \
710
	 IS_GRAPHICS_STEP(__i915, since, until))
711

712
#define IS_TGL_GRAPHICS_STEP(__i915, since, until) \
713
	(IS_TIGERLAKE(__i915) && !IS_TGL_UY(__i915)) && \
714
	 IS_GRAPHICS_STEP(__i915, since, until))
M
Mika Kuoppala 已提交
715

716 717
#define IS_RKL_DISPLAY_STEP(p, since, until) \
	(IS_ROCKETLAKE(p) && IS_DISPLAY_STEP(p, since, until))
718

719 720
#define IS_DG1_GRAPHICS_STEP(p, since, until) \
	(IS_DG1(p) && IS_GRAPHICS_STEP(p, since, until))
721 722
#define IS_DG1_DISPLAY_STEP(p, since, until) \
	(IS_DG1(p) && IS_DISPLAY_STEP(p, since, until))
723

724
#define IS_ADLS_DISPLAY_STEP(__i915, since, until) \
725 726
	(IS_ALDERLAKE_S(__i915) && \
	 IS_DISPLAY_STEP(__i915, since, until))
727

728
#define IS_ADLS_GRAPHICS_STEP(__i915, since, until) \
729
	(IS_ALDERLAKE_S(__i915) && \
730
	 IS_GRAPHICS_STEP(__i915, since, until))
731

732 733 734 735
#define IS_ADLP_DISPLAY_STEP(__i915, since, until) \
	(IS_ALDERLAKE_P(__i915) && \
	 IS_DISPLAY_STEP(__i915, since, until))

736
#define IS_ADLP_GRAPHICS_STEP(__i915, since, until) \
737
	(IS_ALDERLAKE_P(__i915) && \
738
	 IS_GRAPHICS_STEP(__i915, since, until))
739

740 741
#define IS_XEHPSDV_GRAPHICS_STEP(__i915, since, until) \
	(IS_XEHPSDV(__i915) && IS_GRAPHICS_STEP(__i915, since, until))
742

743 744 745 746
#define IS_MTL_GRAPHICS_STEP(__i915, variant, since, until) \
	(IS_SUBPLATFORM(__i915, INTEL_METEORLAKE, INTEL_SUBPLATFORM_##variant) && \
	 IS_GRAPHICS_STEP(__i915, since, until))

M
Matt Roper 已提交
747
/*
748 749 750 751 752 753 754 755
 * DG2 hardware steppings are a bit unusual.  The hardware design was forked to
 * create three variants (G10, G11, and G12) which each have distinct
 * workaround sets.  The G11 and G12 forks of the DG2 design reset the GT
 * stepping back to "A0" for their first iterations, even though they're more
 * similar to a G10 B0 stepping and G10 C0 stepping respectively in terms of
 * functionality and workarounds.  However the display stepping does not reset
 * in the same manner --- a specific stepping like "B0" has a consistent
 * meaning regardless of whether it belongs to a G10, G11, or G12 DG2.
M
Matt Roper 已提交
756 757
 *
 * TLDR:  All GT workarounds and stepping-specific logic must be applied in
758
 * relation to a specific subplatform (G10/G11/G12), whereas display workarounds
M
Matt Roper 已提交
759 760 761
 * and stepping-specific logic will be applied with a general DG2-wide stepping
 * number.
 */
762
#define IS_DG2_GRAPHICS_STEP(__i915, variant, since, until) \
M
Matt Roper 已提交
763
	(IS_SUBPLATFORM(__i915, INTEL_DG2, INTEL_SUBPLATFORM_##variant) && \
764
	 IS_GRAPHICS_STEP(__i915, since, until))
M
Matt Roper 已提交
765

766
#define IS_DG2_DISPLAY_STEP(__i915, since, until) \
M
Matt Roper 已提交
767 768 769
	(IS_DG2(__i915) && \
	 IS_DISPLAY_STEP(__i915, since, until))

770 771 772 773 774 775 776 777
#define IS_PVC_BD_STEP(__i915, since, until) \
	(IS_PONTEVECCHIO(__i915) && \
	 IS_BASEDIE_STEP(__i915, since, until))

#define IS_PVC_CT_STEP(__i915, since, until) \
	(IS_PONTEVECCHIO(__i915) && \
	 IS_GRAPHICS_STEP(__i915, since, until))

778 779 780
#define IS_LP(dev_priv)		(INTEL_INFO(dev_priv)->is_lp)
#define IS_GEN9_LP(dev_priv)	(GRAPHICS_VER(dev_priv) == 9 && IS_LP(dev_priv))
#define IS_GEN9_BC(dev_priv)	(GRAPHICS_VER(dev_priv) == 9 && !IS_LP(dev_priv))
781

782
#define __HAS_ENGINE(engine_mask, id) ((engine_mask) & BIT(id))
783
#define HAS_ENGINE(gt, id) __HAS_ENGINE((gt)->info.engine_mask, id)
784

785
#define __ENGINE_INSTANCES_MASK(mask, first, count) ({			\
786 787
	unsigned int first__ = (first);					\
	unsigned int count__ = (count);					\
788
	((mask) & GENMASK(first__ + count__ - 1, first__)) >> first__;	\
789
})
790 791 792 793

#define ENGINE_INSTANCES_MASK(gt, first, count) \
	__ENGINE_INSTANCES_MASK((gt)->info.engine_mask, first, count)

794 795
#define RCS_MASK(gt) \
	ENGINE_INSTANCES_MASK(gt, RCS0, I915_MAX_RCS)
796 797
#define BCS_MASK(gt) \
	ENGINE_INSTANCES_MASK(gt, BCS0, I915_MAX_BCS)
798 799 800 801
#define VDBOX_MASK(gt) \
	ENGINE_INSTANCES_MASK(gt, VCS0, I915_MAX_VCS)
#define VEBOX_MASK(gt) \
	ENGINE_INSTANCES_MASK(gt, VECS0, I915_MAX_VECS)
802 803
#define CCS_MASK(gt) \
	ENGINE_INSTANCES_MASK(gt, CCS0, I915_MAX_CCS)
804

805 806
#define HAS_MEDIA_RATIO_MODE(dev_priv) (INTEL_INFO(dev_priv)->has_media_ratio_mode)

807 808 809 810
/*
 * The Gen7 cmdparser copies the scanned buffer to the ggtt for execution
 * All later gens can run the final buffer from the ppgtt
 */
811
#define CMDPARSER_USES_GGTT(dev_priv) (GRAPHICS_VER(dev_priv) == 7)
812

813
#define HAS_LLC(dev_priv)	(INTEL_INFO(dev_priv)->has_llc)
814
#define HAS_4TILE(dev_priv)	(INTEL_INFO(dev_priv)->has_4tile)
815
#define HAS_SNOOP(dev_priv)	(INTEL_INFO(dev_priv)->has_snoop)
816
#define HAS_EDRAM(dev_priv)	((dev_priv)->edram_size_mb)
817
#define HAS_SECURE_BATCHES(dev_priv) (GRAPHICS_VER(dev_priv) < 6)
818
#define HAS_WT(dev_priv)	HAS_EDRAM(dev_priv)
819

820
#define HWS_NEEDS_PHYSICAL(dev_priv)	(INTEL_INFO(dev_priv)->hws_needs_physical)
821

822
#define HAS_LOGICAL_RING_CONTEXTS(dev_priv) \
823
		(INTEL_INFO(dev_priv)->has_logical_ring_contexts)
824
#define HAS_LOGICAL_RING_ELSQ(dev_priv) \
825
		(INTEL_INFO(dev_priv)->has_logical_ring_elsq)
826 827 828

#define HAS_EXECLISTS(dev_priv) HAS_LOGICAL_RING_CONTEXTS(dev_priv)

829
#define INTEL_PPGTT(dev_priv) (RUNTIME_INFO(dev_priv)->ppgtt_type)
830 831 832 833 834
#define HAS_PPGTT(dev_priv) \
	(INTEL_PPGTT(dev_priv) != INTEL_PPGTT_NONE)
#define HAS_FULL_PPGTT(dev_priv) \
	(INTEL_PPGTT(dev_priv) >= INTEL_PPGTT_FULL)

835 836
#define HAS_PAGE_SIZES(dev_priv, sizes) ({ \
	GEM_BUG_ON((sizes) == 0); \
837
	((sizes) & ~RUNTIME_INFO(dev_priv)->page_sizes) == 0; \
838
})
839

840
#define HAS_OVERLAY(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_overlay)
841
#define OVERLAY_NEEDS_PHYSICAL(dev_priv) \
842
		(INTEL_INFO(dev_priv)->display.overlay_needs_physical)
843

844
/* Early gen2 have a totally busted CS tlb and require pinned batches. */
845
#define HAS_BROKEN_CS_TLB(dev_priv)	(IS_I830(dev_priv) || IS_I845G(dev_priv))
846

847
#define NEEDS_RC6_CTX_CORRUPTION_WA(dev_priv)	\
848
	(IS_BROADWELL(dev_priv) || GRAPHICS_VER(dev_priv) == 9)
849

850
/* WaRsDisableCoarsePowerGating:skl,cnl */
851
#define NEEDS_WaRsDisableCoarsePowerGating(dev_priv)			\
852
	(IS_SKL_GT3(dev_priv) || IS_SKL_GT4(dev_priv))
853

854 855
#define HAS_GMBUS_IRQ(dev_priv) (DISPLAY_VER(dev_priv) >= 4)
#define HAS_GMBUS_BURST_READ(dev_priv) (DISPLAY_VER(dev_priv) >= 11 || \
R
Ramalingam C 已提交
856 857
					IS_GEMINILAKE(dev_priv) || \
					IS_KABYLAKE(dev_priv))
858

859 860 861
/* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
 * rows, which changed the alignment requirements and fence programming.
 */
862 863
#define HAS_128_BYTE_Y_TILING(dev_priv) (GRAPHICS_VER(dev_priv) != 2 && \
					 !(IS_I915G(dev_priv) || IS_I915GM(dev_priv)))
864 865
#define SUPPORTS_TV(dev_priv)		(INTEL_INFO(dev_priv)->display.supports_tv)
#define I915_HAS_HOTPLUG(dev_priv)	(INTEL_INFO(dev_priv)->display.has_hotplug)
866

867
#define HAS_FW_BLC(dev_priv)	(DISPLAY_VER(dev_priv) > 2)
868
#define HAS_FBC(dev_priv)	(RUNTIME_INFO(dev_priv)->fbc_mask != 0)
869
#define HAS_CUR_FBC(dev_priv)	(!HAS_GMCH(dev_priv) && DISPLAY_VER(dev_priv) >= 7)
870

871
#define HAS_IPS(dev_priv)	(IS_HSW_ULT(dev_priv) || IS_BROADWELL(dev_priv))
872

873
#define HAS_DP_MST(dev_priv)	(INTEL_INFO(dev_priv)->display.has_dp_mst)
874
#define HAS_DP20(dev_priv)	(IS_DG2(dev_priv) || DISPLAY_VER(dev_priv) >= 14)
875

876 877
#define HAS_DOUBLE_BUFFERED_M_N(dev_priv)	(DISPLAY_VER(dev_priv) >= 9 || IS_BROADWELL(dev_priv))

878
#define HAS_CDCLK_CRAWL(dev_priv)	 (INTEL_INFO(dev_priv)->display.has_cdclk_crawl)
879
#define HAS_CDCLK_SQUASH(dev_priv)	 (INTEL_INFO(dev_priv)->display.has_cdclk_squash)
880
#define HAS_DDI(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_ddi)
881
#define HAS_FPGA_DBG_UNCLAIMED(dev_priv) (INTEL_INFO(dev_priv)->display.has_fpga_dbg)
882
#define HAS_PSR(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_psr)
883 884
#define HAS_PSR_HW_TRACKING(dev_priv) \
	(INTEL_INFO(dev_priv)->display.has_psr_hw_tracking)
885
#define HAS_PSR2_SEL_FETCH(dev_priv)	 (DISPLAY_VER(dev_priv) >= 12)
886
#define HAS_TRANSCODER(dev_priv, trans)	 ((RUNTIME_INFO(dev_priv)->cpu_transcoder_mask & BIT(trans)) != 0)
887

888 889
#define HAS_RC6(dev_priv)		 (INTEL_INFO(dev_priv)->has_rc6)
#define HAS_RC6p(dev_priv)		 (INTEL_INFO(dev_priv)->has_rc6p)
890
#define HAS_RC6pp(dev_priv)		 (false) /* HW was never validated */
P
Paulo Zanoni 已提交
891

892 893
#define HAS_RPS(dev_priv)	(INTEL_INFO(dev_priv)->has_rps)

894
#define HAS_DMC(dev_priv)	(RUNTIME_INFO(dev_priv)->has_dmc)
895

896 897 898 899 900 901 902 903
#define HAS_HECI_PXP(dev_priv) \
	(INTEL_INFO(dev_priv)->has_heci_pxp)

#define HAS_HECI_GSCFI(dev_priv) \
	(INTEL_INFO(dev_priv)->has_heci_gscfi)

#define HAS_HECI_GSC(dev_priv) (HAS_HECI_PXP(dev_priv) || HAS_HECI_GSCFI(dev_priv))

904
#define HAS_MSO(i915)		(DISPLAY_VER(i915) >= 12)
905

906 907
#define HAS_RUNTIME_PM(dev_priv) (INTEL_INFO(dev_priv)->has_runtime_pm)
#define HAS_64BIT_RELOC(dev_priv) (INTEL_INFO(dev_priv)->has_64bit_reloc)
908

909 910
#define HAS_OA_BPC_REPORTING(dev_priv) \
	(INTEL_INFO(dev_priv)->has_oa_bpc_reporting)
911 912
#define HAS_OA_SLICE_CONTRIB_LIMITS(dev_priv) \
	(INTEL_INFO(dev_priv)->has_oa_slice_contrib_limits)
913

S
Stuart Summers 已提交
914 915
/*
 * Set this flag, when platform requires 64K GTT page sizes or larger for
916
 * device local memory access.
S
Stuart Summers 已提交
917 918 919
 */
#define HAS_64K_PAGES(dev_priv) (INTEL_INFO(dev_priv)->has_64k_pages)

920
#define HAS_IPC(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_ipc)
921

922
#define HAS_REGION(i915, i) (RUNTIME_INFO(i915)->memory_regions & (i))
923
#define HAS_LMEM(i915) HAS_REGION(i915, REGION_LMEM)
924

925 926
#define HAS_EXTRA_GT_LIST(dev_priv)   (INTEL_INFO(dev_priv)->extra_gt_list)

927 928 929 930 931 932
/*
 * Platform has the dedicated compression control state for each lmem surfaces
 * stored in lmem to support the 3D and media compression formats.
 */
#define HAS_FLAT_CCS(dev_priv)   (INTEL_INFO(dev_priv)->has_flat_ccs)

933
#define HAS_GT_UC(dev_priv)	(INTEL_INFO(dev_priv)->has_gt_uc)
934

935
#define HAS_POOLED_EU(dev_priv)	(RUNTIME_INFO(dev_priv)->has_pooled_eu)
936

937 938
#define HAS_GLOBAL_MOCS_REGISTERS(dev_priv)	(INTEL_INFO(dev_priv)->has_global_mocs)

R
Rodrigo Vivi 已提交
939
#define HAS_GMCH(dev_priv) (INTEL_INFO(dev_priv)->display.has_gmch)
940

941 942
#define HAS_GMD_ID(i915)	(INTEL_INFO(i915)->has_gmd_id)

943
#define HAS_LSPCON(dev_priv) (IS_DISPLAY_VER(dev_priv, 9, 10))
944

945 946
#define HAS_L3_CCS_READ(i915) (INTEL_INFO(i915)->has_l3_ccs_read)

947
/* DPF == dynamic parity feature */
948
#define HAS_L3_DPF(dev_priv) (INTEL_INFO(dev_priv)->has_l3_dpf)
949 950
#define NUM_L3_SLICES(dev_priv) (IS_HSW_GT3(dev_priv) ? \
				 2 : HAS_L3_DPF(dev_priv))
951

952
#define GT_FREQUENCY_MULTIPLIER 50
A
Akash Goel 已提交
953
#define GEN9_FREQ_SCALER 3
954

955
#define INTEL_NUM_PIPES(dev_priv) (hweight8(RUNTIME_INFO(dev_priv)->pipe_mask))
956

957
#define HAS_DISPLAY(dev_priv) (RUNTIME_INFO(dev_priv)->pipe_mask != 0)
958

959
#define HAS_VRR(i915)	(DISPLAY_VER(i915) >= 11)
960

961 962
#define HAS_ASYNC_FLIPS(i915)		(DISPLAY_VER(i915) >= 5)

963
/* Only valid when HAS_DISPLAY() is true */
964
#define INTEL_DISPLAY_ENABLED(dev_priv) \
965 966 967
	(drm_WARN_ON(&(dev_priv)->drm, !HAS_DISPLAY(dev_priv)),		\
	 !(dev_priv)->params.disable_display &&				\
	 !intel_opregion_headless_sku(dev_priv))
968

969 970 971
#define HAS_GUC_DEPRIVILEGE(dev_priv) \
	(INTEL_INFO(dev_priv)->has_guc_deprivilege)

972 973 974
#define HAS_D12_PLANE_MINIMIZATION(dev_priv) (IS_ROCKETLAKE(dev_priv) || \
					      IS_ALDERLAKE_S(dev_priv))

975
#define HAS_MBUS_JOINING(i915) (IS_ALDERLAKE_P(i915) || DISPLAY_VER(i915) >= 14)
976

977 978
#define HAS_3D_PIPELINE(i915)	(INTEL_INFO(i915)->has_3d_pipeline)

M
Matt Roper 已提交
979 980
#define HAS_ONE_EU_PER_FUSE_BIT(i915)	(INTEL_INFO(i915)->has_one_eu_per_fuse_bit)

981 982
#define HAS_LMEMBAR_SMEM_STOLEN(i915) (!HAS_LMEM(i915) && \
				       GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70))
983

984 985 986 987
/* intel_device_info.c */
static inline struct intel_device_info *
mkwrite_device_info(struct drm_i915_private *dev_priv)
{
988
	return (struct intel_device_info *)INTEL_INFO(dev_priv);
989 990
}

L
Linus Torvalds 已提交
991
#endif