18c2ecf20Sopenharmony_ci/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
28c2ecf20Sopenharmony_ci */
38c2ecf20Sopenharmony_ci/*
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
68c2ecf20Sopenharmony_ci * All Rights Reserved.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
98c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the
108c2ecf20Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
118c2ecf20Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
128c2ecf20Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
138c2ecf20Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
148c2ecf20Sopenharmony_ci * the following conditions:
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the
178c2ecf20Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
188c2ecf20Sopenharmony_ci * of the Software.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
218c2ecf20Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
228c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
238c2ecf20Sopenharmony_ci * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
248c2ecf20Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
258c2ecf20Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
268c2ecf20Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#ifndef _I915_DRV_H_
318c2ecf20Sopenharmony_ci#define _I915_DRV_H_
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#include <uapi/drm/i915_drm.h>
348c2ecf20Sopenharmony_ci#include <uapi/drm/drm_fourcc.h>
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#include <asm/hypervisor.h>
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#include <linux/io-mapping.h>
398c2ecf20Sopenharmony_ci#include <linux/i2c.h>
408c2ecf20Sopenharmony_ci#include <linux/i2c-algo-bit.h>
418c2ecf20Sopenharmony_ci#include <linux/backlight.h>
428c2ecf20Sopenharmony_ci#include <linux/hash.h>
438c2ecf20Sopenharmony_ci#include <linux/intel-iommu.h>
448c2ecf20Sopenharmony_ci#include <linux/kref.h>
458c2ecf20Sopenharmony_ci#include <linux/mm_types.h>
468c2ecf20Sopenharmony_ci#include <linux/perf_event.h>
478c2ecf20Sopenharmony_ci#include <linux/pm_qos.h>
488c2ecf20Sopenharmony_ci#include <linux/dma-resv.h>
498c2ecf20Sopenharmony_ci#include <linux/shmem_fs.h>
508c2ecf20Sopenharmony_ci#include <linux/stackdepot.h>
518c2ecf20Sopenharmony_ci#include <linux/xarray.h>
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#include <drm/intel-gtt.h>
548c2ecf20Sopenharmony_ci#include <drm/drm_legacy.h> /* for struct drm_dma_handle */
558c2ecf20Sopenharmony_ci#include <drm/drm_gem.h>
568c2ecf20Sopenharmony_ci#include <drm/drm_auth.h>
578c2ecf20Sopenharmony_ci#include <drm/drm_cache.h>
588c2ecf20Sopenharmony_ci#include <drm/drm_util.h>
598c2ecf20Sopenharmony_ci#include <drm/drm_dsc.h>
608c2ecf20Sopenharmony_ci#include <drm/drm_atomic.h>
618c2ecf20Sopenharmony_ci#include <drm/drm_connector.h>
628c2ecf20Sopenharmony_ci#include <drm/i915_mei_hdcp_interface.h>
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#include "i915_params.h"
658c2ecf20Sopenharmony_ci#include "i915_reg.h"
668c2ecf20Sopenharmony_ci#include "i915_utils.h"
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#include "display/intel_bios.h"
698c2ecf20Sopenharmony_ci#include "display/intel_display.h"
708c2ecf20Sopenharmony_ci#include "display/intel_display_power.h"
718c2ecf20Sopenharmony_ci#include "display/intel_dpll_mgr.h"
728c2ecf20Sopenharmony_ci#include "display/intel_dsb.h"
738c2ecf20Sopenharmony_ci#include "display/intel_frontbuffer.h"
748c2ecf20Sopenharmony_ci#include "display/intel_global_state.h"
758c2ecf20Sopenharmony_ci#include "display/intel_gmbus.h"
768c2ecf20Sopenharmony_ci#include "display/intel_opregion.h"
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#include "gem/i915_gem_context_types.h"
798c2ecf20Sopenharmony_ci#include "gem/i915_gem_shrinker.h"
808c2ecf20Sopenharmony_ci#include "gem/i915_gem_stolen.h"
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#include "gt/intel_lrc.h"
838c2ecf20Sopenharmony_ci#include "gt/intel_engine.h"
848c2ecf20Sopenharmony_ci#include "gt/intel_gt_types.h"
858c2ecf20Sopenharmony_ci#include "gt/intel_workarounds.h"
868c2ecf20Sopenharmony_ci#include "gt/uc/intel_uc.h"
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#include "intel_device_info.h"
898c2ecf20Sopenharmony_ci#include "intel_pch.h"
908c2ecf20Sopenharmony_ci#include "intel_runtime_pm.h"
918c2ecf20Sopenharmony_ci#include "intel_memory_region.h"
928c2ecf20Sopenharmony_ci#include "intel_uncore.h"
938c2ecf20Sopenharmony_ci#include "intel_wakeref.h"
948c2ecf20Sopenharmony_ci#include "intel_wopcm.h"
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#include "i915_gem.h"
978c2ecf20Sopenharmony_ci#include "i915_gem_gtt.h"
988c2ecf20Sopenharmony_ci#include "i915_gpu_error.h"
998c2ecf20Sopenharmony_ci#include "i915_perf_types.h"
1008c2ecf20Sopenharmony_ci#include "i915_request.h"
1018c2ecf20Sopenharmony_ci#include "i915_scheduler.h"
1028c2ecf20Sopenharmony_ci#include "gt/intel_timeline.h"
1038c2ecf20Sopenharmony_ci#include "i915_vma.h"
1048c2ecf20Sopenharmony_ci#include "i915_irq.h"
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci#include "intel_region_lmem.h"
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/* General customization:
1098c2ecf20Sopenharmony_ci */
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#define DRIVER_NAME		"i915"
1128c2ecf20Sopenharmony_ci#define DRIVER_DESC		"Intel Graphics"
1138c2ecf20Sopenharmony_ci#define DRIVER_DATE		"20200917"
1148c2ecf20Sopenharmony_ci#define DRIVER_TIMESTAMP	1600375437
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_cistruct drm_i915_gem_object;
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cienum hpd_pin {
1198c2ecf20Sopenharmony_ci	HPD_NONE = 0,
1208c2ecf20Sopenharmony_ci	HPD_TV = HPD_NONE,     /* TV is known to be unreliable */
1218c2ecf20Sopenharmony_ci	HPD_CRT,
1228c2ecf20Sopenharmony_ci	HPD_SDVO_B,
1238c2ecf20Sopenharmony_ci	HPD_SDVO_C,
1248c2ecf20Sopenharmony_ci	HPD_PORT_A,
1258c2ecf20Sopenharmony_ci	HPD_PORT_B,
1268c2ecf20Sopenharmony_ci	HPD_PORT_C,
1278c2ecf20Sopenharmony_ci	HPD_PORT_D,
1288c2ecf20Sopenharmony_ci	HPD_PORT_E,
1298c2ecf20Sopenharmony_ci	HPD_PORT_TC1,
1308c2ecf20Sopenharmony_ci	HPD_PORT_TC2,
1318c2ecf20Sopenharmony_ci	HPD_PORT_TC3,
1328c2ecf20Sopenharmony_ci	HPD_PORT_TC4,
1338c2ecf20Sopenharmony_ci	HPD_PORT_TC5,
1348c2ecf20Sopenharmony_ci	HPD_PORT_TC6,
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	HPD_NUM_PINS
1378c2ecf20Sopenharmony_ci};
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci#define for_each_hpd_pin(__pin) \
1408c2ecf20Sopenharmony_ci	for ((__pin) = (HPD_NONE + 1); (__pin) < HPD_NUM_PINS; (__pin)++)
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci/* Threshold == 5 for long IRQs, 50 for short */
1438c2ecf20Sopenharmony_ci#define HPD_STORM_DEFAULT_THRESHOLD 50
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_cistruct i915_hotplug {
1468c2ecf20Sopenharmony_ci	struct delayed_work hotplug_work;
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	const u32 *hpd, *pch_hpd;
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	struct {
1518c2ecf20Sopenharmony_ci		unsigned long last_jiffies;
1528c2ecf20Sopenharmony_ci		int count;
1538c2ecf20Sopenharmony_ci		enum {
1548c2ecf20Sopenharmony_ci			HPD_ENABLED = 0,
1558c2ecf20Sopenharmony_ci			HPD_DISABLED = 1,
1568c2ecf20Sopenharmony_ci			HPD_MARK_DISABLED = 2
1578c2ecf20Sopenharmony_ci		} state;
1588c2ecf20Sopenharmony_ci	} stats[HPD_NUM_PINS];
1598c2ecf20Sopenharmony_ci	u32 event_bits;
1608c2ecf20Sopenharmony_ci	u32 retry_bits;
1618c2ecf20Sopenharmony_ci	struct delayed_work reenable_work;
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci	u32 long_port_mask;
1648c2ecf20Sopenharmony_ci	u32 short_port_mask;
1658c2ecf20Sopenharmony_ci	struct work_struct dig_port_work;
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	struct work_struct poll_init_work;
1688c2ecf20Sopenharmony_ci	bool poll_enabled;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	unsigned int hpd_storm_threshold;
1718c2ecf20Sopenharmony_ci	/* Whether or not to count short HPD IRQs in HPD storms */
1728c2ecf20Sopenharmony_ci	u8 hpd_short_storm_enabled;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	/*
1758c2ecf20Sopenharmony_ci	 * if we get a HPD irq from DP and a HPD irq from non-DP
1768c2ecf20Sopenharmony_ci	 * the non-DP HPD could block the workqueue on a mode config
1778c2ecf20Sopenharmony_ci	 * mutex getting, that userspace may have taken. However
1788c2ecf20Sopenharmony_ci	 * userspace is waiting on the DP workqueue to run which is
1798c2ecf20Sopenharmony_ci	 * blocked behind the non-DP one.
1808c2ecf20Sopenharmony_ci	 */
1818c2ecf20Sopenharmony_ci	struct workqueue_struct *dp_wq;
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci#define I915_GEM_GPU_DOMAINS \
1858c2ecf20Sopenharmony_ci	(I915_GEM_DOMAIN_RENDER | \
1868c2ecf20Sopenharmony_ci	 I915_GEM_DOMAIN_SAMPLER | \
1878c2ecf20Sopenharmony_ci	 I915_GEM_DOMAIN_COMMAND | \
1888c2ecf20Sopenharmony_ci	 I915_GEM_DOMAIN_INSTRUCTION | \
1898c2ecf20Sopenharmony_ci	 I915_GEM_DOMAIN_VERTEX)
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_cistruct drm_i915_private;
1928c2ecf20Sopenharmony_cistruct i915_mm_struct;
1938c2ecf20Sopenharmony_cistruct i915_mmu_object;
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_cistruct drm_i915_file_private {
1968c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv;
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci	union {
1998c2ecf20Sopenharmony_ci		struct drm_file *file;
2008c2ecf20Sopenharmony_ci		struct rcu_head rcu;
2018c2ecf20Sopenharmony_ci	};
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci	struct xarray context_xa;
2048c2ecf20Sopenharmony_ci	struct xarray vm_xa;
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci	unsigned int bsd_engine;
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci/*
2098c2ecf20Sopenharmony_ci * Every context ban increments per client ban score. Also
2108c2ecf20Sopenharmony_ci * hangs in short succession increments ban score. If ban threshold
2118c2ecf20Sopenharmony_ci * is reached, client is considered banned and submitting more work
2128c2ecf20Sopenharmony_ci * will fail. This is a stop gap measure to limit the badly behaving
2138c2ecf20Sopenharmony_ci * clients access to gpu. Note that unbannable contexts never increment
2148c2ecf20Sopenharmony_ci * the client ban score.
2158c2ecf20Sopenharmony_ci */
2168c2ecf20Sopenharmony_ci#define I915_CLIENT_SCORE_HANG_FAST	1
2178c2ecf20Sopenharmony_ci#define   I915_CLIENT_FAST_HANG_JIFFIES (60 * HZ)
2188c2ecf20Sopenharmony_ci#define I915_CLIENT_SCORE_CONTEXT_BAN   3
2198c2ecf20Sopenharmony_ci#define I915_CLIENT_SCORE_BANNED	9
2208c2ecf20Sopenharmony_ci	/** ban_score: Accumulated score of all ctx bans and fast hangs. */
2218c2ecf20Sopenharmony_ci	atomic_t ban_score;
2228c2ecf20Sopenharmony_ci	unsigned long hang_timestamp;
2238c2ecf20Sopenharmony_ci};
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci/* Interface history:
2268c2ecf20Sopenharmony_ci *
2278c2ecf20Sopenharmony_ci * 1.1: Original.
2288c2ecf20Sopenharmony_ci * 1.2: Add Power Management
2298c2ecf20Sopenharmony_ci * 1.3: Add vblank support
2308c2ecf20Sopenharmony_ci * 1.4: Fix cmdbuffer path, add heap destroy
2318c2ecf20Sopenharmony_ci * 1.5: Add vblank pipe configuration
2328c2ecf20Sopenharmony_ci * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
2338c2ecf20Sopenharmony_ci *      - Support vertical blank on secondary display pipe
2348c2ecf20Sopenharmony_ci */
2358c2ecf20Sopenharmony_ci#define DRIVER_MAJOR		1
2368c2ecf20Sopenharmony_ci#define DRIVER_MINOR		6
2378c2ecf20Sopenharmony_ci#define DRIVER_PATCHLEVEL	0
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_cistruct intel_overlay;
2408c2ecf20Sopenharmony_cistruct intel_overlay_error_state;
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_cistruct sdvo_device_mapping {
2438c2ecf20Sopenharmony_ci	u8 initialized;
2448c2ecf20Sopenharmony_ci	u8 dvo_port;
2458c2ecf20Sopenharmony_ci	u8 slave_addr;
2468c2ecf20Sopenharmony_ci	u8 dvo_wiring;
2478c2ecf20Sopenharmony_ci	u8 i2c_pin;
2488c2ecf20Sopenharmony_ci	u8 ddc_pin;
2498c2ecf20Sopenharmony_ci};
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistruct intel_connector;
2528c2ecf20Sopenharmony_cistruct intel_encoder;
2538c2ecf20Sopenharmony_cistruct intel_atomic_state;
2548c2ecf20Sopenharmony_cistruct intel_cdclk_config;
2558c2ecf20Sopenharmony_cistruct intel_cdclk_state;
2568c2ecf20Sopenharmony_cistruct intel_cdclk_vals;
2578c2ecf20Sopenharmony_cistruct intel_initial_plane_config;
2588c2ecf20Sopenharmony_cistruct intel_crtc;
2598c2ecf20Sopenharmony_cistruct intel_limit;
2608c2ecf20Sopenharmony_cistruct dpll;
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_cistruct drm_i915_display_funcs {
2638c2ecf20Sopenharmony_ci	void (*get_cdclk)(struct drm_i915_private *dev_priv,
2648c2ecf20Sopenharmony_ci			  struct intel_cdclk_config *cdclk_config);
2658c2ecf20Sopenharmony_ci	void (*set_cdclk)(struct drm_i915_private *dev_priv,
2668c2ecf20Sopenharmony_ci			  const struct intel_cdclk_config *cdclk_config,
2678c2ecf20Sopenharmony_ci			  enum pipe pipe);
2688c2ecf20Sopenharmony_ci	int (*bw_calc_min_cdclk)(struct intel_atomic_state *state);
2698c2ecf20Sopenharmony_ci	int (*get_fifo_size)(struct drm_i915_private *dev_priv,
2708c2ecf20Sopenharmony_ci			     enum i9xx_plane_id i9xx_plane);
2718c2ecf20Sopenharmony_ci	int (*compute_pipe_wm)(struct intel_crtc_state *crtc_state);
2728c2ecf20Sopenharmony_ci	int (*compute_intermediate_wm)(struct intel_crtc_state *crtc_state);
2738c2ecf20Sopenharmony_ci	void (*initial_watermarks)(struct intel_atomic_state *state,
2748c2ecf20Sopenharmony_ci				   struct intel_crtc *crtc);
2758c2ecf20Sopenharmony_ci	void (*atomic_update_watermarks)(struct intel_atomic_state *state,
2768c2ecf20Sopenharmony_ci					 struct intel_crtc *crtc);
2778c2ecf20Sopenharmony_ci	void (*optimize_watermarks)(struct intel_atomic_state *state,
2788c2ecf20Sopenharmony_ci				    struct intel_crtc *crtc);
2798c2ecf20Sopenharmony_ci	int (*compute_global_watermarks)(struct intel_atomic_state *state);
2808c2ecf20Sopenharmony_ci	void (*update_wm)(struct intel_crtc *crtc);
2818c2ecf20Sopenharmony_ci	int (*modeset_calc_cdclk)(struct intel_cdclk_state *state);
2828c2ecf20Sopenharmony_ci	u8 (*calc_voltage_level)(int cdclk);
2838c2ecf20Sopenharmony_ci	/* Returns the active state of the crtc, and if the crtc is active,
2848c2ecf20Sopenharmony_ci	 * fills out the pipe-config with the hw state. */
2858c2ecf20Sopenharmony_ci	bool (*get_pipe_config)(struct intel_crtc *,
2868c2ecf20Sopenharmony_ci				struct intel_crtc_state *);
2878c2ecf20Sopenharmony_ci	void (*get_initial_plane_config)(struct intel_crtc *,
2888c2ecf20Sopenharmony_ci					 struct intel_initial_plane_config *);
2898c2ecf20Sopenharmony_ci	int (*crtc_compute_clock)(struct intel_crtc *crtc,
2908c2ecf20Sopenharmony_ci				  struct intel_crtc_state *crtc_state);
2918c2ecf20Sopenharmony_ci	void (*crtc_enable)(struct intel_atomic_state *state,
2928c2ecf20Sopenharmony_ci			    struct intel_crtc *crtc);
2938c2ecf20Sopenharmony_ci	void (*crtc_disable)(struct intel_atomic_state *state,
2948c2ecf20Sopenharmony_ci			     struct intel_crtc *crtc);
2958c2ecf20Sopenharmony_ci	void (*commit_modeset_enables)(struct intel_atomic_state *state);
2968c2ecf20Sopenharmony_ci	void (*commit_modeset_disables)(struct intel_atomic_state *state);
2978c2ecf20Sopenharmony_ci	void (*audio_codec_enable)(struct intel_encoder *encoder,
2988c2ecf20Sopenharmony_ci				   const struct intel_crtc_state *crtc_state,
2998c2ecf20Sopenharmony_ci				   const struct drm_connector_state *conn_state);
3008c2ecf20Sopenharmony_ci	void (*audio_codec_disable)(struct intel_encoder *encoder,
3018c2ecf20Sopenharmony_ci				    const struct intel_crtc_state *old_crtc_state,
3028c2ecf20Sopenharmony_ci				    const struct drm_connector_state *old_conn_state);
3038c2ecf20Sopenharmony_ci	void (*fdi_link_train)(struct intel_crtc *crtc,
3048c2ecf20Sopenharmony_ci			       const struct intel_crtc_state *crtc_state);
3058c2ecf20Sopenharmony_ci	void (*init_clock_gating)(struct drm_i915_private *dev_priv);
3068c2ecf20Sopenharmony_ci	void (*hpd_irq_setup)(struct drm_i915_private *dev_priv);
3078c2ecf20Sopenharmony_ci	/* clock updates for mode set */
3088c2ecf20Sopenharmony_ci	/* cursor updates */
3098c2ecf20Sopenharmony_ci	/* render clock increase/decrease */
3108c2ecf20Sopenharmony_ci	/* display clock increase/decrease */
3118c2ecf20Sopenharmony_ci	/* pll clock increase/decrease */
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	int (*color_check)(struct intel_crtc_state *crtc_state);
3148c2ecf20Sopenharmony_ci	/*
3158c2ecf20Sopenharmony_ci	 * Program double buffered color management registers during
3168c2ecf20Sopenharmony_ci	 * vblank evasion. The registers should then latch during the
3178c2ecf20Sopenharmony_ci	 * next vblank start, alongside any other double buffered registers
3188c2ecf20Sopenharmony_ci	 * involved with the same commit.
3198c2ecf20Sopenharmony_ci	 */
3208c2ecf20Sopenharmony_ci	void (*color_commit)(const struct intel_crtc_state *crtc_state);
3218c2ecf20Sopenharmony_ci	/*
3228c2ecf20Sopenharmony_ci	 * Load LUTs (and other single buffered color management
3238c2ecf20Sopenharmony_ci	 * registers). Will (hopefully) be called during the vblank
3248c2ecf20Sopenharmony_ci	 * following the latching of any double buffered registers
3258c2ecf20Sopenharmony_ci	 * involved with the same commit.
3268c2ecf20Sopenharmony_ci	 */
3278c2ecf20Sopenharmony_ci	void (*load_luts)(const struct intel_crtc_state *crtc_state);
3288c2ecf20Sopenharmony_ci	void (*read_luts)(struct intel_crtc_state *crtc_state);
3298c2ecf20Sopenharmony_ci};
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_cistruct intel_csr {
3328c2ecf20Sopenharmony_ci	struct work_struct work;
3338c2ecf20Sopenharmony_ci	const char *fw_path;
3348c2ecf20Sopenharmony_ci	u32 required_version;
3358c2ecf20Sopenharmony_ci	u32 max_fw_size; /* bytes */
3368c2ecf20Sopenharmony_ci	u32 *dmc_payload;
3378c2ecf20Sopenharmony_ci	u32 dmc_fw_size; /* dwords */
3388c2ecf20Sopenharmony_ci	u32 version;
3398c2ecf20Sopenharmony_ci	u32 mmio_count;
3408c2ecf20Sopenharmony_ci	i915_reg_t mmioaddr[20];
3418c2ecf20Sopenharmony_ci	u32 mmiodata[20];
3428c2ecf20Sopenharmony_ci	u32 dc_state;
3438c2ecf20Sopenharmony_ci	u32 target_dc_state;
3448c2ecf20Sopenharmony_ci	u32 allowed_dc_mask;
3458c2ecf20Sopenharmony_ci	intel_wakeref_t wakeref;
3468c2ecf20Sopenharmony_ci};
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_cienum i915_cache_level {
3498c2ecf20Sopenharmony_ci	I915_CACHE_NONE = 0,
3508c2ecf20Sopenharmony_ci	I915_CACHE_LLC, /* also used for snoopable memory on non-LLC */
3518c2ecf20Sopenharmony_ci	I915_CACHE_L3_LLC, /* gen7+, L3 sits between the domain specifc
3528c2ecf20Sopenharmony_ci			      caches, eg sampler/render caches, and the
3538c2ecf20Sopenharmony_ci			      large Last-Level-Cache. LLC is coherent with
3548c2ecf20Sopenharmony_ci			      the CPU, but L3 is only visible to the GPU. */
3558c2ecf20Sopenharmony_ci	I915_CACHE_WT, /* hsw:gt3e WriteThrough for scanouts */
3568c2ecf20Sopenharmony_ci};
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci#define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_cistruct intel_fbc {
3618c2ecf20Sopenharmony_ci	/* This is always the inner lock when overlapping with struct_mutex and
3628c2ecf20Sopenharmony_ci	 * it's the outer lock when overlapping with stolen_lock. */
3638c2ecf20Sopenharmony_ci	struct mutex lock;
3648c2ecf20Sopenharmony_ci	unsigned threshold;
3658c2ecf20Sopenharmony_ci	unsigned int possible_framebuffer_bits;
3668c2ecf20Sopenharmony_ci	unsigned int busy_bits;
3678c2ecf20Sopenharmony_ci	struct intel_crtc *crtc;
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci	struct drm_mm_node compressed_fb;
3708c2ecf20Sopenharmony_ci	struct drm_mm_node *compressed_llb;
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	bool false_color;
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci	bool active;
3758c2ecf20Sopenharmony_ci	bool activated;
3768c2ecf20Sopenharmony_ci	bool flip_pending;
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_ci	bool underrun_detected;
3798c2ecf20Sopenharmony_ci	struct work_struct underrun_work;
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci	/*
3828c2ecf20Sopenharmony_ci	 * Due to the atomic rules we can't access some structures without the
3838c2ecf20Sopenharmony_ci	 * appropriate locking, so we cache information here in order to avoid
3848c2ecf20Sopenharmony_ci	 * these problems.
3858c2ecf20Sopenharmony_ci	 */
3868c2ecf20Sopenharmony_ci	struct intel_fbc_state_cache {
3878c2ecf20Sopenharmony_ci		struct {
3888c2ecf20Sopenharmony_ci			unsigned int mode_flags;
3898c2ecf20Sopenharmony_ci			u32 hsw_bdw_pixel_rate;
3908c2ecf20Sopenharmony_ci		} crtc;
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci		struct {
3938c2ecf20Sopenharmony_ci			unsigned int rotation;
3948c2ecf20Sopenharmony_ci			int src_w;
3958c2ecf20Sopenharmony_ci			int src_h;
3968c2ecf20Sopenharmony_ci			bool visible;
3978c2ecf20Sopenharmony_ci			/*
3988c2ecf20Sopenharmony_ci			 * Display surface base address adjustement for
3998c2ecf20Sopenharmony_ci			 * pageflips. Note that on gen4+ this only adjusts up
4008c2ecf20Sopenharmony_ci			 * to a tile, offsets within a tile are handled in
4018c2ecf20Sopenharmony_ci			 * the hw itself (with the TILEOFF register).
4028c2ecf20Sopenharmony_ci			 */
4038c2ecf20Sopenharmony_ci			int adjusted_x;
4048c2ecf20Sopenharmony_ci			int adjusted_y;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci			u16 pixel_blend_mode;
4078c2ecf20Sopenharmony_ci		} plane;
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci		struct {
4108c2ecf20Sopenharmony_ci			const struct drm_format_info *format;
4118c2ecf20Sopenharmony_ci			unsigned int stride;
4128c2ecf20Sopenharmony_ci			u64 modifier;
4138c2ecf20Sopenharmony_ci		} fb;
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci		unsigned int fence_y_offset;
4168c2ecf20Sopenharmony_ci		u16 gen9_wa_cfb_stride;
4178c2ecf20Sopenharmony_ci		u16 interval;
4188c2ecf20Sopenharmony_ci		s8 fence_id;
4198c2ecf20Sopenharmony_ci	} state_cache;
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci	/*
4228c2ecf20Sopenharmony_ci	 * This structure contains everything that's relevant to program the
4238c2ecf20Sopenharmony_ci	 * hardware registers. When we want to figure out if we need to disable
4248c2ecf20Sopenharmony_ci	 * and re-enable FBC for a new configuration we just check if there's
4258c2ecf20Sopenharmony_ci	 * something different in the struct. The genx_fbc_activate functions
4268c2ecf20Sopenharmony_ci	 * are supposed to read from it in order to program the registers.
4278c2ecf20Sopenharmony_ci	 */
4288c2ecf20Sopenharmony_ci	struct intel_fbc_reg_params {
4298c2ecf20Sopenharmony_ci		struct {
4308c2ecf20Sopenharmony_ci			enum pipe pipe;
4318c2ecf20Sopenharmony_ci			enum i9xx_plane_id i9xx_plane;
4328c2ecf20Sopenharmony_ci		} crtc;
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci		struct {
4358c2ecf20Sopenharmony_ci			const struct drm_format_info *format;
4368c2ecf20Sopenharmony_ci			unsigned int stride;
4378c2ecf20Sopenharmony_ci			u64 modifier;
4388c2ecf20Sopenharmony_ci		} fb;
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci		int cfb_size;
4418c2ecf20Sopenharmony_ci		unsigned int fence_y_offset;
4428c2ecf20Sopenharmony_ci		u16 gen9_wa_cfb_stride;
4438c2ecf20Sopenharmony_ci		u16 interval;
4448c2ecf20Sopenharmony_ci		s8 fence_id;
4458c2ecf20Sopenharmony_ci		bool plane_visible;
4468c2ecf20Sopenharmony_ci	} params;
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci	const char *no_fbc_reason;
4498c2ecf20Sopenharmony_ci};
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci/*
4528c2ecf20Sopenharmony_ci * HIGH_RR is the highest eDP panel refresh rate read from EDID
4538c2ecf20Sopenharmony_ci * LOW_RR is the lowest eDP panel refresh rate found from EDID
4548c2ecf20Sopenharmony_ci * parsing for same resolution.
4558c2ecf20Sopenharmony_ci */
4568c2ecf20Sopenharmony_cienum drrs_refresh_rate_type {
4578c2ecf20Sopenharmony_ci	DRRS_HIGH_RR,
4588c2ecf20Sopenharmony_ci	DRRS_LOW_RR,
4598c2ecf20Sopenharmony_ci	DRRS_MAX_RR, /* RR count */
4608c2ecf20Sopenharmony_ci};
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_cienum drrs_support_type {
4638c2ecf20Sopenharmony_ci	DRRS_NOT_SUPPORTED = 0,
4648c2ecf20Sopenharmony_ci	STATIC_DRRS_SUPPORT = 1,
4658c2ecf20Sopenharmony_ci	SEAMLESS_DRRS_SUPPORT = 2
4668c2ecf20Sopenharmony_ci};
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_cistruct intel_dp;
4698c2ecf20Sopenharmony_cistruct i915_drrs {
4708c2ecf20Sopenharmony_ci	struct mutex mutex;
4718c2ecf20Sopenharmony_ci	struct delayed_work work;
4728c2ecf20Sopenharmony_ci	struct intel_dp *dp;
4738c2ecf20Sopenharmony_ci	unsigned busy_frontbuffer_bits;
4748c2ecf20Sopenharmony_ci	enum drrs_refresh_rate_type refresh_rate_type;
4758c2ecf20Sopenharmony_ci	enum drrs_support_type type;
4768c2ecf20Sopenharmony_ci};
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_cistruct i915_psr {
4798c2ecf20Sopenharmony_ci	struct mutex lock;
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_ci#define I915_PSR_DEBUG_MODE_MASK	0x0f
4828c2ecf20Sopenharmony_ci#define I915_PSR_DEBUG_DEFAULT		0x00
4838c2ecf20Sopenharmony_ci#define I915_PSR_DEBUG_DISABLE		0x01
4848c2ecf20Sopenharmony_ci#define I915_PSR_DEBUG_ENABLE		0x02
4858c2ecf20Sopenharmony_ci#define I915_PSR_DEBUG_FORCE_PSR1	0x03
4868c2ecf20Sopenharmony_ci#define I915_PSR_DEBUG_IRQ		0x10
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci	u32 debug;
4898c2ecf20Sopenharmony_ci	bool sink_support;
4908c2ecf20Sopenharmony_ci	bool enabled;
4918c2ecf20Sopenharmony_ci	struct intel_dp *dp;
4928c2ecf20Sopenharmony_ci	enum pipe pipe;
4938c2ecf20Sopenharmony_ci	enum transcoder transcoder;
4948c2ecf20Sopenharmony_ci	bool active;
4958c2ecf20Sopenharmony_ci	struct work_struct work;
4968c2ecf20Sopenharmony_ci	unsigned busy_frontbuffer_bits;
4978c2ecf20Sopenharmony_ci	bool sink_psr2_support;
4988c2ecf20Sopenharmony_ci	bool link_standby;
4998c2ecf20Sopenharmony_ci	bool colorimetry_support;
5008c2ecf20Sopenharmony_ci	bool psr2_enabled;
5018c2ecf20Sopenharmony_ci	bool psr2_sel_fetch_enabled;
5028c2ecf20Sopenharmony_ci	u8 sink_sync_latency;
5038c2ecf20Sopenharmony_ci	ktime_t last_entry_attempt;
5048c2ecf20Sopenharmony_ci	ktime_t last_exit;
5058c2ecf20Sopenharmony_ci	bool sink_not_reliable;
5068c2ecf20Sopenharmony_ci	bool irq_aux_error;
5078c2ecf20Sopenharmony_ci	u16 su_x_granularity;
5088c2ecf20Sopenharmony_ci	bool dc3co_enabled;
5098c2ecf20Sopenharmony_ci	u32 dc3co_exit_delay;
5108c2ecf20Sopenharmony_ci	struct delayed_work dc3co_work;
5118c2ecf20Sopenharmony_ci	bool force_mode_changed;
5128c2ecf20Sopenharmony_ci	struct drm_dp_vsc_sdp vsc;
5138c2ecf20Sopenharmony_ci};
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci#define QUIRK_LVDS_SSC_DISABLE (1<<1)
5168c2ecf20Sopenharmony_ci#define QUIRK_INVERT_BRIGHTNESS (1<<2)
5178c2ecf20Sopenharmony_ci#define QUIRK_BACKLIGHT_PRESENT (1<<3)
5188c2ecf20Sopenharmony_ci#define QUIRK_PIN_SWIZZLED_PAGES (1<<5)
5198c2ecf20Sopenharmony_ci#define QUIRK_INCREASE_T12_DELAY (1<<6)
5208c2ecf20Sopenharmony_ci#define QUIRK_INCREASE_DDI_DISABLED_TIME (1<<7)
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_cistruct intel_fbdev;
5238c2ecf20Sopenharmony_cistruct intel_fbc_work;
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_cistruct intel_gmbus {
5268c2ecf20Sopenharmony_ci	struct i2c_adapter adapter;
5278c2ecf20Sopenharmony_ci#define GMBUS_FORCE_BIT_RETRY (1U << 31)
5288c2ecf20Sopenharmony_ci	u32 force_bit;
5298c2ecf20Sopenharmony_ci	u32 reg0;
5308c2ecf20Sopenharmony_ci	i915_reg_t gpio_reg;
5318c2ecf20Sopenharmony_ci	struct i2c_algo_bit_data bit_algo;
5328c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv;
5338c2ecf20Sopenharmony_ci};
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_cistruct i915_suspend_saved_registers {
5368c2ecf20Sopenharmony_ci	u32 saveDSPARB;
5378c2ecf20Sopenharmony_ci	u32 saveSWF0[16];
5388c2ecf20Sopenharmony_ci	u32 saveSWF1[16];
5398c2ecf20Sopenharmony_ci	u32 saveSWF3[3];
5408c2ecf20Sopenharmony_ci	u16 saveGCDGMBUS;
5418c2ecf20Sopenharmony_ci};
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_cistruct vlv_s0ix_state;
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci#define MAX_L3_SLICES 2
5468c2ecf20Sopenharmony_cistruct intel_l3_parity {
5478c2ecf20Sopenharmony_ci	u32 *remap_info[MAX_L3_SLICES];
5488c2ecf20Sopenharmony_ci	struct work_struct error_work;
5498c2ecf20Sopenharmony_ci	int which_slice;
5508c2ecf20Sopenharmony_ci};
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_cistruct i915_gem_mm {
5538c2ecf20Sopenharmony_ci	/** Memory allocator for GTT stolen memory */
5548c2ecf20Sopenharmony_ci	struct drm_mm stolen;
5558c2ecf20Sopenharmony_ci	/** Protects the usage of the GTT stolen memory allocator. This is
5568c2ecf20Sopenharmony_ci	 * always the inner lock when overlapping with struct_mutex. */
5578c2ecf20Sopenharmony_ci	struct mutex stolen_lock;
5588c2ecf20Sopenharmony_ci
5598c2ecf20Sopenharmony_ci	/* Protects bound_list/unbound_list and #drm_i915_gem_object.mm.link */
5608c2ecf20Sopenharmony_ci	spinlock_t obj_lock;
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci	/**
5638c2ecf20Sopenharmony_ci	 * List of objects which are purgeable.
5648c2ecf20Sopenharmony_ci	 */
5658c2ecf20Sopenharmony_ci	struct list_head purge_list;
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_ci	/**
5688c2ecf20Sopenharmony_ci	 * List of objects which have allocated pages and are shrinkable.
5698c2ecf20Sopenharmony_ci	 */
5708c2ecf20Sopenharmony_ci	struct list_head shrink_list;
5718c2ecf20Sopenharmony_ci
5728c2ecf20Sopenharmony_ci	/**
5738c2ecf20Sopenharmony_ci	 * List of objects which are pending destruction.
5748c2ecf20Sopenharmony_ci	 */
5758c2ecf20Sopenharmony_ci	struct llist_head free_list;
5768c2ecf20Sopenharmony_ci	struct work_struct free_work;
5778c2ecf20Sopenharmony_ci	/**
5788c2ecf20Sopenharmony_ci	 * Count of objects pending destructions. Used to skip needlessly
5798c2ecf20Sopenharmony_ci	 * waiting on an RCU barrier if no objects are waiting to be freed.
5808c2ecf20Sopenharmony_ci	 */
5818c2ecf20Sopenharmony_ci	atomic_t free_count;
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_ci	/**
5848c2ecf20Sopenharmony_ci	 * tmpfs instance used for shmem backed objects
5858c2ecf20Sopenharmony_ci	 */
5868c2ecf20Sopenharmony_ci	struct vfsmount *gemfs;
5878c2ecf20Sopenharmony_ci
5888c2ecf20Sopenharmony_ci	struct intel_memory_region *regions[INTEL_REGION_UNKNOWN];
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci	struct notifier_block oom_notifier;
5918c2ecf20Sopenharmony_ci	struct notifier_block vmap_notifier;
5928c2ecf20Sopenharmony_ci	struct shrinker shrinker;
5938c2ecf20Sopenharmony_ci
5948c2ecf20Sopenharmony_ci	/**
5958c2ecf20Sopenharmony_ci	 * Workqueue to fault in userptr pages, flushed by the execbuf
5968c2ecf20Sopenharmony_ci	 * when required but otherwise left to userspace to try again
5978c2ecf20Sopenharmony_ci	 * on EAGAIN.
5988c2ecf20Sopenharmony_ci	 */
5998c2ecf20Sopenharmony_ci	struct workqueue_struct *userptr_wq;
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ci	/* shrinker accounting, also useful for userland debugging */
6028c2ecf20Sopenharmony_ci	u64 shrink_memory;
6038c2ecf20Sopenharmony_ci	u32 shrink_count;
6048c2ecf20Sopenharmony_ci};
6058c2ecf20Sopenharmony_ci
6068c2ecf20Sopenharmony_ci#define I915_IDLE_ENGINES_TIMEOUT (200) /* in ms */
6078c2ecf20Sopenharmony_ci
6088c2ecf20Sopenharmony_ciunsigned long i915_fence_context_timeout(const struct drm_i915_private *i915,
6098c2ecf20Sopenharmony_ci					 u64 context);
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_cistatic inline unsigned long
6128c2ecf20Sopenharmony_cii915_fence_timeout(const struct drm_i915_private *i915)
6138c2ecf20Sopenharmony_ci{
6148c2ecf20Sopenharmony_ci	return i915_fence_context_timeout(i915, U64_MAX);
6158c2ecf20Sopenharmony_ci}
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_ci/* Amount of SAGV/QGV points, BSpec precisely defines this */
6188c2ecf20Sopenharmony_ci#define I915_NUM_QGV_POINTS 8
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_cistruct ddi_vbt_port_info {
6218c2ecf20Sopenharmony_ci	/* Non-NULL if port present. */
6228c2ecf20Sopenharmony_ci	const struct child_device_config *child;
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_ci	int max_tmds_clock;
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ci	/* This is an index in the HDMI/DVI DDI buffer translation table. */
6278c2ecf20Sopenharmony_ci	u8 hdmi_level_shift;
6288c2ecf20Sopenharmony_ci	u8 hdmi_level_shift_set:1;
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci	u8 supports_dvi:1;
6318c2ecf20Sopenharmony_ci	u8 supports_hdmi:1;
6328c2ecf20Sopenharmony_ci	u8 supports_dp:1;
6338c2ecf20Sopenharmony_ci	u8 supports_edp:1;
6348c2ecf20Sopenharmony_ci	u8 supports_typec_usb:1;
6358c2ecf20Sopenharmony_ci	u8 supports_tbt:1;
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ci	u8 alternate_aux_channel;
6388c2ecf20Sopenharmony_ci	u8 alternate_ddc_pin;
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ci	u8 dp_boost_level;
6418c2ecf20Sopenharmony_ci	u8 hdmi_boost_level;
6428c2ecf20Sopenharmony_ci	int dp_max_link_rate;		/* 0 for not limited by VBT */
6438c2ecf20Sopenharmony_ci};
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_cienum psr_lines_to_wait {
6468c2ecf20Sopenharmony_ci	PSR_0_LINES_TO_WAIT = 0,
6478c2ecf20Sopenharmony_ci	PSR_1_LINE_TO_WAIT,
6488c2ecf20Sopenharmony_ci	PSR_4_LINES_TO_WAIT,
6498c2ecf20Sopenharmony_ci	PSR_8_LINES_TO_WAIT
6508c2ecf20Sopenharmony_ci};
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_cistruct intel_vbt_data {
6538c2ecf20Sopenharmony_ci	struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
6548c2ecf20Sopenharmony_ci	struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci	/* Feature bits */
6578c2ecf20Sopenharmony_ci	unsigned int int_tv_support:1;
6588c2ecf20Sopenharmony_ci	unsigned int lvds_dither:1;
6598c2ecf20Sopenharmony_ci	unsigned int int_crt_support:1;
6608c2ecf20Sopenharmony_ci	unsigned int lvds_use_ssc:1;
6618c2ecf20Sopenharmony_ci	unsigned int int_lvds_support:1;
6628c2ecf20Sopenharmony_ci	unsigned int display_clock_mode:1;
6638c2ecf20Sopenharmony_ci	unsigned int fdi_rx_polarity_inverted:1;
6648c2ecf20Sopenharmony_ci	unsigned int panel_type:4;
6658c2ecf20Sopenharmony_ci	int lvds_ssc_freq;
6668c2ecf20Sopenharmony_ci	unsigned int bios_lvds_val; /* initial [PCH_]LVDS reg val in VBIOS */
6678c2ecf20Sopenharmony_ci	enum drm_panel_orientation orientation;
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci	enum drrs_support_type drrs_type;
6708c2ecf20Sopenharmony_ci
6718c2ecf20Sopenharmony_ci	struct {
6728c2ecf20Sopenharmony_ci		int rate;
6738c2ecf20Sopenharmony_ci		int lanes;
6748c2ecf20Sopenharmony_ci		int preemphasis;
6758c2ecf20Sopenharmony_ci		int vswing;
6768c2ecf20Sopenharmony_ci		bool low_vswing;
6778c2ecf20Sopenharmony_ci		bool initialized;
6788c2ecf20Sopenharmony_ci		int bpp;
6798c2ecf20Sopenharmony_ci		struct edp_power_seq pps;
6808c2ecf20Sopenharmony_ci		bool hobl;
6818c2ecf20Sopenharmony_ci	} edp;
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci	struct {
6848c2ecf20Sopenharmony_ci		bool enable;
6858c2ecf20Sopenharmony_ci		bool full_link;
6868c2ecf20Sopenharmony_ci		bool require_aux_wakeup;
6878c2ecf20Sopenharmony_ci		int idle_frames;
6888c2ecf20Sopenharmony_ci		enum psr_lines_to_wait lines_to_wait;
6898c2ecf20Sopenharmony_ci		int tp1_wakeup_time_us;
6908c2ecf20Sopenharmony_ci		int tp2_tp3_wakeup_time_us;
6918c2ecf20Sopenharmony_ci		int psr2_tp2_tp3_wakeup_time_us;
6928c2ecf20Sopenharmony_ci	} psr;
6938c2ecf20Sopenharmony_ci
6948c2ecf20Sopenharmony_ci	struct {
6958c2ecf20Sopenharmony_ci		u16 pwm_freq_hz;
6968c2ecf20Sopenharmony_ci		bool present;
6978c2ecf20Sopenharmony_ci		bool active_low_pwm;
6988c2ecf20Sopenharmony_ci		u8 min_brightness;	/* min_brightness/255 of max */
6998c2ecf20Sopenharmony_ci		u8 controller;		/* brightness controller number */
7008c2ecf20Sopenharmony_ci		enum intel_backlight_type type;
7018c2ecf20Sopenharmony_ci	} backlight;
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_ci	/* MIPI DSI */
7048c2ecf20Sopenharmony_ci	struct {
7058c2ecf20Sopenharmony_ci		u16 panel_id;
7068c2ecf20Sopenharmony_ci		struct mipi_config *config;
7078c2ecf20Sopenharmony_ci		struct mipi_pps_data *pps;
7088c2ecf20Sopenharmony_ci		u16 bl_ports;
7098c2ecf20Sopenharmony_ci		u16 cabc_ports;
7108c2ecf20Sopenharmony_ci		u8 seq_version;
7118c2ecf20Sopenharmony_ci		u32 size;
7128c2ecf20Sopenharmony_ci		u8 *data;
7138c2ecf20Sopenharmony_ci		const u8 *sequence[MIPI_SEQ_MAX];
7148c2ecf20Sopenharmony_ci		u8 *deassert_seq; /* Used by fixup_mipi_sequences() */
7158c2ecf20Sopenharmony_ci		enum drm_panel_orientation orientation;
7168c2ecf20Sopenharmony_ci	} dsi;
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_ci	int crt_ddc_pin;
7198c2ecf20Sopenharmony_ci
7208c2ecf20Sopenharmony_ci	struct list_head display_devices;
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_ci	struct ddi_vbt_port_info ddi_port_info[I915_MAX_PORTS];
7238c2ecf20Sopenharmony_ci	struct sdvo_device_mapping sdvo_mappings[2];
7248c2ecf20Sopenharmony_ci};
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_cienum intel_ddb_partitioning {
7278c2ecf20Sopenharmony_ci	INTEL_DDB_PART_1_2,
7288c2ecf20Sopenharmony_ci	INTEL_DDB_PART_5_6, /* IVB+ */
7298c2ecf20Sopenharmony_ci};
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_cistruct ilk_wm_values {
7328c2ecf20Sopenharmony_ci	u32 wm_pipe[3];
7338c2ecf20Sopenharmony_ci	u32 wm_lp[3];
7348c2ecf20Sopenharmony_ci	u32 wm_lp_spr[3];
7358c2ecf20Sopenharmony_ci	bool enable_fbc_wm;
7368c2ecf20Sopenharmony_ci	enum intel_ddb_partitioning partitioning;
7378c2ecf20Sopenharmony_ci};
7388c2ecf20Sopenharmony_ci
7398c2ecf20Sopenharmony_cistruct g4x_pipe_wm {
7408c2ecf20Sopenharmony_ci	u16 plane[I915_MAX_PLANES];
7418c2ecf20Sopenharmony_ci	u16 fbc;
7428c2ecf20Sopenharmony_ci};
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_cistruct g4x_sr_wm {
7458c2ecf20Sopenharmony_ci	u16 plane;
7468c2ecf20Sopenharmony_ci	u16 cursor;
7478c2ecf20Sopenharmony_ci	u16 fbc;
7488c2ecf20Sopenharmony_ci};
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_cistruct vlv_wm_ddl_values {
7518c2ecf20Sopenharmony_ci	u8 plane[I915_MAX_PLANES];
7528c2ecf20Sopenharmony_ci};
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_cistruct vlv_wm_values {
7558c2ecf20Sopenharmony_ci	struct g4x_pipe_wm pipe[3];
7568c2ecf20Sopenharmony_ci	struct g4x_sr_wm sr;
7578c2ecf20Sopenharmony_ci	struct vlv_wm_ddl_values ddl[3];
7588c2ecf20Sopenharmony_ci	u8 level;
7598c2ecf20Sopenharmony_ci	bool cxsr;
7608c2ecf20Sopenharmony_ci};
7618c2ecf20Sopenharmony_ci
7628c2ecf20Sopenharmony_cistruct g4x_wm_values {
7638c2ecf20Sopenharmony_ci	struct g4x_pipe_wm pipe[2];
7648c2ecf20Sopenharmony_ci	struct g4x_sr_wm sr;
7658c2ecf20Sopenharmony_ci	struct g4x_sr_wm hpll;
7668c2ecf20Sopenharmony_ci	bool cxsr;
7678c2ecf20Sopenharmony_ci	bool hpll_en;
7688c2ecf20Sopenharmony_ci	bool fbc_en;
7698c2ecf20Sopenharmony_ci};
7708c2ecf20Sopenharmony_ci
7718c2ecf20Sopenharmony_cistruct skl_ddb_entry {
7728c2ecf20Sopenharmony_ci	u16 start, end;	/* in number of blocks, 'end' is exclusive */
7738c2ecf20Sopenharmony_ci};
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_cistatic inline u16 skl_ddb_entry_size(const struct skl_ddb_entry *entry)
7768c2ecf20Sopenharmony_ci{
7778c2ecf20Sopenharmony_ci	return entry->end - entry->start;
7788c2ecf20Sopenharmony_ci}
7798c2ecf20Sopenharmony_ci
7808c2ecf20Sopenharmony_cistatic inline bool skl_ddb_entry_equal(const struct skl_ddb_entry *e1,
7818c2ecf20Sopenharmony_ci				       const struct skl_ddb_entry *e2)
7828c2ecf20Sopenharmony_ci{
7838c2ecf20Sopenharmony_ci	if (e1->start == e2->start && e1->end == e2->end)
7848c2ecf20Sopenharmony_ci		return true;
7858c2ecf20Sopenharmony_ci
7868c2ecf20Sopenharmony_ci	return false;
7878c2ecf20Sopenharmony_ci}
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_cistruct i915_frontbuffer_tracking {
7908c2ecf20Sopenharmony_ci	spinlock_t lock;
7918c2ecf20Sopenharmony_ci
7928c2ecf20Sopenharmony_ci	/*
7938c2ecf20Sopenharmony_ci	 * Tracking bits for delayed frontbuffer flushing du to gpu activity or
7948c2ecf20Sopenharmony_ci	 * scheduled flips.
7958c2ecf20Sopenharmony_ci	 */
7968c2ecf20Sopenharmony_ci	unsigned busy_bits;
7978c2ecf20Sopenharmony_ci	unsigned flip_bits;
7988c2ecf20Sopenharmony_ci};
7998c2ecf20Sopenharmony_ci
8008c2ecf20Sopenharmony_cistruct i915_virtual_gpu {
8018c2ecf20Sopenharmony_ci	struct mutex lock; /* serialises sending of g2v_notify command pkts */
8028c2ecf20Sopenharmony_ci	bool active;
8038c2ecf20Sopenharmony_ci	u32 caps;
8048c2ecf20Sopenharmony_ci};
8058c2ecf20Sopenharmony_ci
8068c2ecf20Sopenharmony_cistruct intel_cdclk_config {
8078c2ecf20Sopenharmony_ci	unsigned int cdclk, vco, ref, bypass;
8088c2ecf20Sopenharmony_ci	u8 voltage_level;
8098c2ecf20Sopenharmony_ci};
8108c2ecf20Sopenharmony_ci
8118c2ecf20Sopenharmony_cistruct i915_selftest_stash {
8128c2ecf20Sopenharmony_ci	atomic_t counter;
8138c2ecf20Sopenharmony_ci};
8148c2ecf20Sopenharmony_ci
8158c2ecf20Sopenharmony_cistruct drm_i915_private {
8168c2ecf20Sopenharmony_ci	struct drm_device drm;
8178c2ecf20Sopenharmony_ci
8188c2ecf20Sopenharmony_ci	/* FIXME: Device release actions should all be moved to drmm_ */
8198c2ecf20Sopenharmony_ci	bool do_release;
8208c2ecf20Sopenharmony_ci
8218c2ecf20Sopenharmony_ci	/* i915 device parameters */
8228c2ecf20Sopenharmony_ci	struct i915_params params;
8238c2ecf20Sopenharmony_ci
8248c2ecf20Sopenharmony_ci	const struct intel_device_info __info; /* Use INTEL_INFO() to access. */
8258c2ecf20Sopenharmony_ci	struct intel_runtime_info __runtime; /* Use RUNTIME_INFO() to access. */
8268c2ecf20Sopenharmony_ci	struct intel_driver_caps caps;
8278c2ecf20Sopenharmony_ci
8288c2ecf20Sopenharmony_ci	/**
8298c2ecf20Sopenharmony_ci	 * Data Stolen Memory - aka "i915 stolen memory" gives us the start and
8308c2ecf20Sopenharmony_ci	 * end of stolen which we can optionally use to create GEM objects
8318c2ecf20Sopenharmony_ci	 * backed by stolen memory. Note that stolen_usable_size tells us
8328c2ecf20Sopenharmony_ci	 * exactly how much of this we are actually allowed to use, given that
8338c2ecf20Sopenharmony_ci	 * some portion of it is in fact reserved for use by hardware functions.
8348c2ecf20Sopenharmony_ci	 */
8358c2ecf20Sopenharmony_ci	struct resource dsm;
8368c2ecf20Sopenharmony_ci	/**
8378c2ecf20Sopenharmony_ci	 * Reseved portion of Data Stolen Memory
8388c2ecf20Sopenharmony_ci	 */
8398c2ecf20Sopenharmony_ci	struct resource dsm_reserved;
8408c2ecf20Sopenharmony_ci
8418c2ecf20Sopenharmony_ci	/*
8428c2ecf20Sopenharmony_ci	 * Stolen memory is segmented in hardware with different portions
8438c2ecf20Sopenharmony_ci	 * offlimits to certain functions.
8448c2ecf20Sopenharmony_ci	 *
8458c2ecf20Sopenharmony_ci	 * The drm_mm is initialised to the total accessible range, as found
8468c2ecf20Sopenharmony_ci	 * from the PCI config. On Broadwell+, this is further restricted to
8478c2ecf20Sopenharmony_ci	 * avoid the first page! The upper end of stolen memory is reserved for
8488c2ecf20Sopenharmony_ci	 * hardware functions and similarly removed from the accessible range.
8498c2ecf20Sopenharmony_ci	 */
8508c2ecf20Sopenharmony_ci	resource_size_t stolen_usable_size;	/* Total size minus reserved ranges */
8518c2ecf20Sopenharmony_ci
8528c2ecf20Sopenharmony_ci	struct intel_uncore uncore;
8538c2ecf20Sopenharmony_ci	struct intel_uncore_mmio_debug mmio_debug;
8548c2ecf20Sopenharmony_ci
8558c2ecf20Sopenharmony_ci	struct i915_virtual_gpu vgpu;
8568c2ecf20Sopenharmony_ci
8578c2ecf20Sopenharmony_ci	struct intel_gvt *gvt;
8588c2ecf20Sopenharmony_ci
8598c2ecf20Sopenharmony_ci	struct intel_wopcm wopcm;
8608c2ecf20Sopenharmony_ci
8618c2ecf20Sopenharmony_ci	struct intel_csr csr;
8628c2ecf20Sopenharmony_ci
8638c2ecf20Sopenharmony_ci	struct intel_gmbus gmbus[GMBUS_NUM_PINS];
8648c2ecf20Sopenharmony_ci
8658c2ecf20Sopenharmony_ci	/** gmbus_mutex protects against concurrent usage of the single hw gmbus
8668c2ecf20Sopenharmony_ci	 * controller on different i2c buses. */
8678c2ecf20Sopenharmony_ci	struct mutex gmbus_mutex;
8688c2ecf20Sopenharmony_ci
8698c2ecf20Sopenharmony_ci	/**
8708c2ecf20Sopenharmony_ci	 * Base address of where the gmbus and gpio blocks are located (either
8718c2ecf20Sopenharmony_ci	 * on PCH or on SoC for platforms without PCH).
8728c2ecf20Sopenharmony_ci	 */
8738c2ecf20Sopenharmony_ci	u32 gpio_mmio_base;
8748c2ecf20Sopenharmony_ci
8758c2ecf20Sopenharmony_ci	u32 hsw_psr_mmio_adjust;
8768c2ecf20Sopenharmony_ci
8778c2ecf20Sopenharmony_ci	/* MMIO base address for MIPI regs */
8788c2ecf20Sopenharmony_ci	u32 mipi_mmio_base;
8798c2ecf20Sopenharmony_ci
8808c2ecf20Sopenharmony_ci	u32 pps_mmio_base;
8818c2ecf20Sopenharmony_ci
8828c2ecf20Sopenharmony_ci	wait_queue_head_t gmbus_wait_queue;
8838c2ecf20Sopenharmony_ci
8848c2ecf20Sopenharmony_ci	struct pci_dev *bridge_dev;
8858c2ecf20Sopenharmony_ci
8868c2ecf20Sopenharmony_ci	struct rb_root uabi_engines;
8878c2ecf20Sopenharmony_ci
8888c2ecf20Sopenharmony_ci	struct resource mch_res;
8898c2ecf20Sopenharmony_ci
8908c2ecf20Sopenharmony_ci	/* protects the irq masks */
8918c2ecf20Sopenharmony_ci	spinlock_t irq_lock;
8928c2ecf20Sopenharmony_ci
8938c2ecf20Sopenharmony_ci	bool display_irqs_enabled;
8948c2ecf20Sopenharmony_ci
8958c2ecf20Sopenharmony_ci	/* Sideband mailbox protection */
8968c2ecf20Sopenharmony_ci	struct mutex sb_lock;
8978c2ecf20Sopenharmony_ci	struct pm_qos_request sb_qos;
8988c2ecf20Sopenharmony_ci
8998c2ecf20Sopenharmony_ci	/** Cached value of IMR to avoid reads in updating the bitfield */
9008c2ecf20Sopenharmony_ci	union {
9018c2ecf20Sopenharmony_ci		u32 irq_mask;
9028c2ecf20Sopenharmony_ci		u32 de_irq_mask[I915_MAX_PIPES];
9038c2ecf20Sopenharmony_ci	};
9048c2ecf20Sopenharmony_ci	u32 pipestat_irq_mask[I915_MAX_PIPES];
9058c2ecf20Sopenharmony_ci
9068c2ecf20Sopenharmony_ci	struct i915_hotplug hotplug;
9078c2ecf20Sopenharmony_ci	struct intel_fbc fbc;
9088c2ecf20Sopenharmony_ci	struct i915_drrs drrs;
9098c2ecf20Sopenharmony_ci	struct intel_opregion opregion;
9108c2ecf20Sopenharmony_ci	struct intel_vbt_data vbt;
9118c2ecf20Sopenharmony_ci
9128c2ecf20Sopenharmony_ci	bool preserve_bios_swizzle;
9138c2ecf20Sopenharmony_ci
9148c2ecf20Sopenharmony_ci	/* overlay */
9158c2ecf20Sopenharmony_ci	struct intel_overlay *overlay;
9168c2ecf20Sopenharmony_ci
9178c2ecf20Sopenharmony_ci	/* backlight registers and fields in struct intel_panel */
9188c2ecf20Sopenharmony_ci	struct mutex backlight_lock;
9198c2ecf20Sopenharmony_ci
9208c2ecf20Sopenharmony_ci	/* protects panel power sequencer state */
9218c2ecf20Sopenharmony_ci	struct mutex pps_mutex;
9228c2ecf20Sopenharmony_ci
9238c2ecf20Sopenharmony_ci	unsigned int fsb_freq, mem_freq, is_ddr3;
9248c2ecf20Sopenharmony_ci	unsigned int skl_preferred_vco_freq;
9258c2ecf20Sopenharmony_ci	unsigned int max_cdclk_freq;
9268c2ecf20Sopenharmony_ci
9278c2ecf20Sopenharmony_ci	unsigned int max_dotclk_freq;
9288c2ecf20Sopenharmony_ci	unsigned int hpll_freq;
9298c2ecf20Sopenharmony_ci	unsigned int fdi_pll_freq;
9308c2ecf20Sopenharmony_ci	unsigned int czclk_freq;
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_ci	struct {
9338c2ecf20Sopenharmony_ci		/* The current hardware cdclk configuration */
9348c2ecf20Sopenharmony_ci		struct intel_cdclk_config hw;
9358c2ecf20Sopenharmony_ci
9368c2ecf20Sopenharmony_ci		/* cdclk, divider, and ratio table from bspec */
9378c2ecf20Sopenharmony_ci		const struct intel_cdclk_vals *table;
9388c2ecf20Sopenharmony_ci
9398c2ecf20Sopenharmony_ci		struct intel_global_obj obj;
9408c2ecf20Sopenharmony_ci	} cdclk;
9418c2ecf20Sopenharmony_ci
9428c2ecf20Sopenharmony_ci	struct {
9438c2ecf20Sopenharmony_ci		/* The current hardware dbuf configuration */
9448c2ecf20Sopenharmony_ci		u8 enabled_slices;
9458c2ecf20Sopenharmony_ci
9468c2ecf20Sopenharmony_ci		struct intel_global_obj obj;
9478c2ecf20Sopenharmony_ci	} dbuf;
9488c2ecf20Sopenharmony_ci
9498c2ecf20Sopenharmony_ci	/**
9508c2ecf20Sopenharmony_ci	 * wq - Driver workqueue for GEM.
9518c2ecf20Sopenharmony_ci	 *
9528c2ecf20Sopenharmony_ci	 * NOTE: Work items scheduled here are not allowed to grab any modeset
9538c2ecf20Sopenharmony_ci	 * locks, for otherwise the flushing done in the pageflip code will
9548c2ecf20Sopenharmony_ci	 * result in deadlocks.
9558c2ecf20Sopenharmony_ci	 */
9568c2ecf20Sopenharmony_ci	struct workqueue_struct *wq;
9578c2ecf20Sopenharmony_ci
9588c2ecf20Sopenharmony_ci	/* ordered wq for modesets */
9598c2ecf20Sopenharmony_ci	struct workqueue_struct *modeset_wq;
9608c2ecf20Sopenharmony_ci	/* unbound hipri wq for page flips/plane updates */
9618c2ecf20Sopenharmony_ci	struct workqueue_struct *flip_wq;
9628c2ecf20Sopenharmony_ci
9638c2ecf20Sopenharmony_ci	/* Display functions */
9648c2ecf20Sopenharmony_ci	struct drm_i915_display_funcs display;
9658c2ecf20Sopenharmony_ci
9668c2ecf20Sopenharmony_ci	/* PCH chipset type */
9678c2ecf20Sopenharmony_ci	enum intel_pch pch_type;
9688c2ecf20Sopenharmony_ci	unsigned short pch_id;
9698c2ecf20Sopenharmony_ci
9708c2ecf20Sopenharmony_ci	unsigned long quirks;
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_ci	struct drm_atomic_state *modeset_restore_state;
9738c2ecf20Sopenharmony_ci	struct drm_modeset_acquire_ctx reset_ctx;
9748c2ecf20Sopenharmony_ci
9758c2ecf20Sopenharmony_ci	struct i915_ggtt ggtt; /* VM representing the global address space */
9768c2ecf20Sopenharmony_ci
9778c2ecf20Sopenharmony_ci	struct i915_gem_mm mm;
9788c2ecf20Sopenharmony_ci	DECLARE_HASHTABLE(mm_structs, 7);
9798c2ecf20Sopenharmony_ci	spinlock_t mm_lock;
9808c2ecf20Sopenharmony_ci
9818c2ecf20Sopenharmony_ci	/* Kernel Modesetting */
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_ci	struct intel_crtc *plane_to_crtc_mapping[I915_MAX_PIPES];
9848c2ecf20Sopenharmony_ci	struct intel_crtc *pipe_to_crtc_mapping[I915_MAX_PIPES];
9858c2ecf20Sopenharmony_ci
9868c2ecf20Sopenharmony_ci	/**
9878c2ecf20Sopenharmony_ci	 * dpll and cdclk state is protected by connection_mutex
9888c2ecf20Sopenharmony_ci	 * dpll.lock serializes intel_{prepare,enable,disable}_shared_dpll.
9898c2ecf20Sopenharmony_ci	 * Must be global rather than per dpll, because on some platforms plls
9908c2ecf20Sopenharmony_ci	 * share registers.
9918c2ecf20Sopenharmony_ci	 */
9928c2ecf20Sopenharmony_ci	struct {
9938c2ecf20Sopenharmony_ci		struct mutex lock;
9948c2ecf20Sopenharmony_ci
9958c2ecf20Sopenharmony_ci		int num_shared_dpll;
9968c2ecf20Sopenharmony_ci		struct intel_shared_dpll shared_dplls[I915_NUM_PLLS];
9978c2ecf20Sopenharmony_ci		const struct intel_dpll_mgr *mgr;
9988c2ecf20Sopenharmony_ci
9998c2ecf20Sopenharmony_ci		struct {
10008c2ecf20Sopenharmony_ci			int nssc;
10018c2ecf20Sopenharmony_ci			int ssc;
10028c2ecf20Sopenharmony_ci		} ref_clks;
10038c2ecf20Sopenharmony_ci	} dpll;
10048c2ecf20Sopenharmony_ci
10058c2ecf20Sopenharmony_ci	struct list_head global_obj_list;
10068c2ecf20Sopenharmony_ci
10078c2ecf20Sopenharmony_ci	/*
10088c2ecf20Sopenharmony_ci	 * For reading active_pipes holding any crtc lock is
10098c2ecf20Sopenharmony_ci	 * sufficient, for writing must hold all of them.
10108c2ecf20Sopenharmony_ci	 */
10118c2ecf20Sopenharmony_ci	u8 active_pipes;
10128c2ecf20Sopenharmony_ci
10138c2ecf20Sopenharmony_ci	struct i915_wa_list gt_wa_list;
10148c2ecf20Sopenharmony_ci
10158c2ecf20Sopenharmony_ci	struct i915_frontbuffer_tracking fb_tracking;
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_ci	struct intel_atomic_helper {
10188c2ecf20Sopenharmony_ci		struct llist_head free_list;
10198c2ecf20Sopenharmony_ci		struct work_struct free_work;
10208c2ecf20Sopenharmony_ci	} atomic_helper;
10218c2ecf20Sopenharmony_ci
10228c2ecf20Sopenharmony_ci	bool mchbar_need_disable;
10238c2ecf20Sopenharmony_ci
10248c2ecf20Sopenharmony_ci	struct intel_l3_parity l3_parity;
10258c2ecf20Sopenharmony_ci
10268c2ecf20Sopenharmony_ci	/*
10278c2ecf20Sopenharmony_ci	 * HTI (aka HDPORT) state read during initial hw readout.  Most
10288c2ecf20Sopenharmony_ci	 * platforms don't have HTI, so this will just stay 0.  Those that do
10298c2ecf20Sopenharmony_ci	 * will use this later to figure out which PLLs and PHYs are unavailable
10308c2ecf20Sopenharmony_ci	 * for driver usage.
10318c2ecf20Sopenharmony_ci	 */
10328c2ecf20Sopenharmony_ci	u32 hti_state;
10338c2ecf20Sopenharmony_ci
10348c2ecf20Sopenharmony_ci	/*
10358c2ecf20Sopenharmony_ci	 * edram size in MB.
10368c2ecf20Sopenharmony_ci	 * Cannot be determined by PCIID. You must always read a register.
10378c2ecf20Sopenharmony_ci	 */
10388c2ecf20Sopenharmony_ci	u32 edram_size_mb;
10398c2ecf20Sopenharmony_ci
10408c2ecf20Sopenharmony_ci	struct i915_power_domains power_domains;
10418c2ecf20Sopenharmony_ci
10428c2ecf20Sopenharmony_ci	struct i915_psr psr;
10438c2ecf20Sopenharmony_ci
10448c2ecf20Sopenharmony_ci	struct i915_gpu_error gpu_error;
10458c2ecf20Sopenharmony_ci
10468c2ecf20Sopenharmony_ci	struct drm_i915_gem_object *vlv_pctx;
10478c2ecf20Sopenharmony_ci
10488c2ecf20Sopenharmony_ci	/* list of fbdev register on this device */
10498c2ecf20Sopenharmony_ci	struct intel_fbdev *fbdev;
10508c2ecf20Sopenharmony_ci	struct work_struct fbdev_suspend_work;
10518c2ecf20Sopenharmony_ci
10528c2ecf20Sopenharmony_ci	struct drm_property *broadcast_rgb_property;
10538c2ecf20Sopenharmony_ci	struct drm_property *force_audio_property;
10548c2ecf20Sopenharmony_ci
10558c2ecf20Sopenharmony_ci	/* hda/i915 audio component */
10568c2ecf20Sopenharmony_ci	struct i915_audio_component *audio_component;
10578c2ecf20Sopenharmony_ci	bool audio_component_registered;
10588c2ecf20Sopenharmony_ci	/**
10598c2ecf20Sopenharmony_ci	 * av_mutex - mutex for audio/video sync
10608c2ecf20Sopenharmony_ci	 *
10618c2ecf20Sopenharmony_ci	 */
10628c2ecf20Sopenharmony_ci	struct mutex av_mutex;
10638c2ecf20Sopenharmony_ci	int audio_power_refcount;
10648c2ecf20Sopenharmony_ci	u32 audio_freq_cntrl;
10658c2ecf20Sopenharmony_ci
10668c2ecf20Sopenharmony_ci	u32 fdi_rx_config;
10678c2ecf20Sopenharmony_ci
10688c2ecf20Sopenharmony_ci	/* Shadow for DISPLAY_PHY_CONTROL which can't be safely read */
10698c2ecf20Sopenharmony_ci	u32 chv_phy_control;
10708c2ecf20Sopenharmony_ci	/*
10718c2ecf20Sopenharmony_ci	 * Shadows for CHV DPLL_MD regs to keep the state
10728c2ecf20Sopenharmony_ci	 * checker somewhat working in the presence hardware
10738c2ecf20Sopenharmony_ci	 * crappiness (can't read out DPLL_MD for pipes B & C).
10748c2ecf20Sopenharmony_ci	 */
10758c2ecf20Sopenharmony_ci	u32 chv_dpll_md[I915_MAX_PIPES];
10768c2ecf20Sopenharmony_ci	u32 bxt_phy_grc;
10778c2ecf20Sopenharmony_ci
10788c2ecf20Sopenharmony_ci	u32 suspend_count;
10798c2ecf20Sopenharmony_ci	bool power_domains_suspended;
10808c2ecf20Sopenharmony_ci	struct i915_suspend_saved_registers regfile;
10818c2ecf20Sopenharmony_ci	struct vlv_s0ix_state *vlv_s0ix_state;
10828c2ecf20Sopenharmony_ci
10838c2ecf20Sopenharmony_ci	enum {
10848c2ecf20Sopenharmony_ci		I915_SAGV_UNKNOWN = 0,
10858c2ecf20Sopenharmony_ci		I915_SAGV_DISABLED,
10868c2ecf20Sopenharmony_ci		I915_SAGV_ENABLED,
10878c2ecf20Sopenharmony_ci		I915_SAGV_NOT_CONTROLLED
10888c2ecf20Sopenharmony_ci	} sagv_status;
10898c2ecf20Sopenharmony_ci
10908c2ecf20Sopenharmony_ci	u32 sagv_block_time_us;
10918c2ecf20Sopenharmony_ci
10928c2ecf20Sopenharmony_ci	struct {
10938c2ecf20Sopenharmony_ci		/*
10948c2ecf20Sopenharmony_ci		 * Raw watermark latency values:
10958c2ecf20Sopenharmony_ci		 * in 0.1us units for WM0,
10968c2ecf20Sopenharmony_ci		 * in 0.5us units for WM1+.
10978c2ecf20Sopenharmony_ci		 */
10988c2ecf20Sopenharmony_ci		/* primary */
10998c2ecf20Sopenharmony_ci		u16 pri_latency[5];
11008c2ecf20Sopenharmony_ci		/* sprite */
11018c2ecf20Sopenharmony_ci		u16 spr_latency[5];
11028c2ecf20Sopenharmony_ci		/* cursor */
11038c2ecf20Sopenharmony_ci		u16 cur_latency[5];
11048c2ecf20Sopenharmony_ci		/*
11058c2ecf20Sopenharmony_ci		 * Raw watermark memory latency values
11068c2ecf20Sopenharmony_ci		 * for SKL for all 8 levels
11078c2ecf20Sopenharmony_ci		 * in 1us units.
11088c2ecf20Sopenharmony_ci		 */
11098c2ecf20Sopenharmony_ci		u16 skl_latency[8];
11108c2ecf20Sopenharmony_ci
11118c2ecf20Sopenharmony_ci		/* current hardware state */
11128c2ecf20Sopenharmony_ci		union {
11138c2ecf20Sopenharmony_ci			struct ilk_wm_values hw;
11148c2ecf20Sopenharmony_ci			struct vlv_wm_values vlv;
11158c2ecf20Sopenharmony_ci			struct g4x_wm_values g4x;
11168c2ecf20Sopenharmony_ci		};
11178c2ecf20Sopenharmony_ci
11188c2ecf20Sopenharmony_ci		u8 max_level;
11198c2ecf20Sopenharmony_ci
11208c2ecf20Sopenharmony_ci		/*
11218c2ecf20Sopenharmony_ci		 * Should be held around atomic WM register writing; also
11228c2ecf20Sopenharmony_ci		 * protects * intel_crtc->wm.active and
11238c2ecf20Sopenharmony_ci		 * crtc_state->wm.need_postvbl_update.
11248c2ecf20Sopenharmony_ci		 */
11258c2ecf20Sopenharmony_ci		struct mutex wm_mutex;
11268c2ecf20Sopenharmony_ci
11278c2ecf20Sopenharmony_ci		/*
11288c2ecf20Sopenharmony_ci		 * Set during HW readout of watermarks/DDB.  Some platforms
11298c2ecf20Sopenharmony_ci		 * need to know when we're still using BIOS-provided values
11308c2ecf20Sopenharmony_ci		 * (which we don't fully trust).
11318c2ecf20Sopenharmony_ci		 *
11328c2ecf20Sopenharmony_ci		 * FIXME get rid of this.
11338c2ecf20Sopenharmony_ci		 */
11348c2ecf20Sopenharmony_ci		bool distrust_bios_wm;
11358c2ecf20Sopenharmony_ci	} wm;
11368c2ecf20Sopenharmony_ci
11378c2ecf20Sopenharmony_ci	struct dram_info {
11388c2ecf20Sopenharmony_ci		bool valid;
11398c2ecf20Sopenharmony_ci		bool is_16gb_dimm;
11408c2ecf20Sopenharmony_ci		u8 num_channels;
11418c2ecf20Sopenharmony_ci		u8 ranks;
11428c2ecf20Sopenharmony_ci		u32 bandwidth_kbps;
11438c2ecf20Sopenharmony_ci		bool symmetric_memory;
11448c2ecf20Sopenharmony_ci		enum intel_dram_type {
11458c2ecf20Sopenharmony_ci			INTEL_DRAM_UNKNOWN,
11468c2ecf20Sopenharmony_ci			INTEL_DRAM_DDR3,
11478c2ecf20Sopenharmony_ci			INTEL_DRAM_DDR4,
11488c2ecf20Sopenharmony_ci			INTEL_DRAM_LPDDR3,
11498c2ecf20Sopenharmony_ci			INTEL_DRAM_LPDDR4
11508c2ecf20Sopenharmony_ci		} type;
11518c2ecf20Sopenharmony_ci		u8 num_qgv_points;
11528c2ecf20Sopenharmony_ci	} dram_info;
11538c2ecf20Sopenharmony_ci
11548c2ecf20Sopenharmony_ci	struct intel_bw_info {
11558c2ecf20Sopenharmony_ci		/* for each QGV point */
11568c2ecf20Sopenharmony_ci		unsigned int deratedbw[I915_NUM_QGV_POINTS];
11578c2ecf20Sopenharmony_ci		u8 num_qgv_points;
11588c2ecf20Sopenharmony_ci		u8 num_planes;
11598c2ecf20Sopenharmony_ci	} max_bw[6];
11608c2ecf20Sopenharmony_ci
11618c2ecf20Sopenharmony_ci	struct intel_global_obj bw_obj;
11628c2ecf20Sopenharmony_ci
11638c2ecf20Sopenharmony_ci	struct intel_runtime_pm runtime_pm;
11648c2ecf20Sopenharmony_ci
11658c2ecf20Sopenharmony_ci	struct i915_perf perf;
11668c2ecf20Sopenharmony_ci
11678c2ecf20Sopenharmony_ci	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
11688c2ecf20Sopenharmony_ci	struct intel_gt gt;
11698c2ecf20Sopenharmony_ci
11708c2ecf20Sopenharmony_ci	struct {
11718c2ecf20Sopenharmony_ci		struct i915_gem_contexts {
11728c2ecf20Sopenharmony_ci			spinlock_t lock; /* locks list */
11738c2ecf20Sopenharmony_ci			struct list_head list;
11748c2ecf20Sopenharmony_ci
11758c2ecf20Sopenharmony_ci			struct llist_head free_list;
11768c2ecf20Sopenharmony_ci			struct work_struct free_work;
11778c2ecf20Sopenharmony_ci		} contexts;
11788c2ecf20Sopenharmony_ci
11798c2ecf20Sopenharmony_ci		/*
11808c2ecf20Sopenharmony_ci		 * We replace the local file with a global mappings as the
11818c2ecf20Sopenharmony_ci		 * backing storage for the mmap is on the device and not
11828c2ecf20Sopenharmony_ci		 * on the struct file, and we do not want to prolong the
11838c2ecf20Sopenharmony_ci		 * lifetime of the local fd. To minimise the number of
11848c2ecf20Sopenharmony_ci		 * anonymous inodes we create, we use a global singleton to
11858c2ecf20Sopenharmony_ci		 * share the global mapping.
11868c2ecf20Sopenharmony_ci		 */
11878c2ecf20Sopenharmony_ci		struct file *mmap_singleton;
11888c2ecf20Sopenharmony_ci	} gem;
11898c2ecf20Sopenharmony_ci
11908c2ecf20Sopenharmony_ci	u8 pch_ssc_use;
11918c2ecf20Sopenharmony_ci
11928c2ecf20Sopenharmony_ci	/* For i915gm/i945gm vblank irq workaround */
11938c2ecf20Sopenharmony_ci	u8 vblank_enabled;
11948c2ecf20Sopenharmony_ci
11958c2ecf20Sopenharmony_ci	/* perform PHY state sanity checks? */
11968c2ecf20Sopenharmony_ci	bool chv_phy_assert[2];
11978c2ecf20Sopenharmony_ci
11988c2ecf20Sopenharmony_ci	bool ipc_enabled;
11998c2ecf20Sopenharmony_ci
12008c2ecf20Sopenharmony_ci	/* Used to save the pipe-to-encoder mapping for audio */
12018c2ecf20Sopenharmony_ci	struct intel_encoder *av_enc_map[I915_MAX_PIPES];
12028c2ecf20Sopenharmony_ci
12038c2ecf20Sopenharmony_ci	/* necessary resource sharing with HDMI LPE audio driver. */
12048c2ecf20Sopenharmony_ci	struct {
12058c2ecf20Sopenharmony_ci		struct platform_device *platdev;
12068c2ecf20Sopenharmony_ci		int	irq;
12078c2ecf20Sopenharmony_ci	} lpe_audio;
12088c2ecf20Sopenharmony_ci
12098c2ecf20Sopenharmony_ci	struct i915_pmu pmu;
12108c2ecf20Sopenharmony_ci
12118c2ecf20Sopenharmony_ci	struct i915_hdcp_comp_master *hdcp_master;
12128c2ecf20Sopenharmony_ci	bool hdcp_comp_added;
12138c2ecf20Sopenharmony_ci
12148c2ecf20Sopenharmony_ci	/* Mutex to protect the above hdcp component related values. */
12158c2ecf20Sopenharmony_ci	struct mutex hdcp_comp_mutex;
12168c2ecf20Sopenharmony_ci
12178c2ecf20Sopenharmony_ci	I915_SELFTEST_DECLARE(struct i915_selftest_stash selftest;)
12188c2ecf20Sopenharmony_ci
12198c2ecf20Sopenharmony_ci	/*
12208c2ecf20Sopenharmony_ci	 * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch
12218c2ecf20Sopenharmony_ci	 * will be rejected. Instead look for a better place.
12228c2ecf20Sopenharmony_ci	 */
12238c2ecf20Sopenharmony_ci};
12248c2ecf20Sopenharmony_ci
12258c2ecf20Sopenharmony_cistatic inline struct drm_i915_private *to_i915(const struct drm_device *dev)
12268c2ecf20Sopenharmony_ci{
12278c2ecf20Sopenharmony_ci	return container_of(dev, struct drm_i915_private, drm);
12288c2ecf20Sopenharmony_ci}
12298c2ecf20Sopenharmony_ci
12308c2ecf20Sopenharmony_cistatic inline struct drm_i915_private *kdev_to_i915(struct device *kdev)
12318c2ecf20Sopenharmony_ci{
12328c2ecf20Sopenharmony_ci	return dev_get_drvdata(kdev);
12338c2ecf20Sopenharmony_ci}
12348c2ecf20Sopenharmony_ci
12358c2ecf20Sopenharmony_cistatic inline struct drm_i915_private *pdev_to_i915(struct pci_dev *pdev)
12368c2ecf20Sopenharmony_ci{
12378c2ecf20Sopenharmony_ci	return pci_get_drvdata(pdev);
12388c2ecf20Sopenharmony_ci}
12398c2ecf20Sopenharmony_ci
12408c2ecf20Sopenharmony_ci/* Simple iterator over all initialised engines */
12418c2ecf20Sopenharmony_ci#define for_each_engine(engine__, dev_priv__, id__) \
12428c2ecf20Sopenharmony_ci	for ((id__) = 0; \
12438c2ecf20Sopenharmony_ci	     (id__) < I915_NUM_ENGINES; \
12448c2ecf20Sopenharmony_ci	     (id__)++) \
12458c2ecf20Sopenharmony_ci		for_each_if ((engine__) = (dev_priv__)->engine[(id__)])
12468c2ecf20Sopenharmony_ci
12478c2ecf20Sopenharmony_ci/* Iterator over subset of engines selected by mask */
12488c2ecf20Sopenharmony_ci#define for_each_engine_masked(engine__, gt__, mask__, tmp__) \
12498c2ecf20Sopenharmony_ci	for ((tmp__) = (mask__) & (gt__)->info.engine_mask; \
12508c2ecf20Sopenharmony_ci	     (tmp__) ? \
12518c2ecf20Sopenharmony_ci	     ((engine__) = (gt__)->engine[__mask_next_bit(tmp__)]), 1 : \
12528c2ecf20Sopenharmony_ci	     0;)
12538c2ecf20Sopenharmony_ci
12548c2ecf20Sopenharmony_ci#define rb_to_uabi_engine(rb) \
12558c2ecf20Sopenharmony_ci	rb_entry_safe(rb, struct intel_engine_cs, uabi_node)
12568c2ecf20Sopenharmony_ci
12578c2ecf20Sopenharmony_ci#define for_each_uabi_engine(engine__, i915__) \
12588c2ecf20Sopenharmony_ci	for ((engine__) = rb_to_uabi_engine(rb_first(&(i915__)->uabi_engines));\
12598c2ecf20Sopenharmony_ci	     (engine__); \
12608c2ecf20Sopenharmony_ci	     (engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node)))
12618c2ecf20Sopenharmony_ci
12628c2ecf20Sopenharmony_ci#define for_each_uabi_class_engine(engine__, class__, i915__) \
12638c2ecf20Sopenharmony_ci	for ((engine__) = intel_engine_lookup_user((i915__), (class__), 0); \
12648c2ecf20Sopenharmony_ci	     (engine__) && (engine__)->uabi_class == (class__); \
12658c2ecf20Sopenharmony_ci	     (engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node)))
12668c2ecf20Sopenharmony_ci
12678c2ecf20Sopenharmony_ci#define I915_GTT_OFFSET_NONE ((u32)-1)
12688c2ecf20Sopenharmony_ci
12698c2ecf20Sopenharmony_ci/*
12708c2ecf20Sopenharmony_ci * Frontbuffer tracking bits. Set in obj->frontbuffer_bits while a gem bo is
12718c2ecf20Sopenharmony_ci * considered to be the frontbuffer for the given plane interface-wise. This
12728c2ecf20Sopenharmony_ci * doesn't mean that the hw necessarily already scans it out, but that any
12738c2ecf20Sopenharmony_ci * rendering (by the cpu or gpu) will land in the frontbuffer eventually.
12748c2ecf20Sopenharmony_ci *
12758c2ecf20Sopenharmony_ci * We have one bit per pipe and per scanout plane type.
12768c2ecf20Sopenharmony_ci */
12778c2ecf20Sopenharmony_ci#define INTEL_FRONTBUFFER_BITS_PER_PIPE 8
12788c2ecf20Sopenharmony_ci#define INTEL_FRONTBUFFER(pipe, plane_id) ({ \
12798c2ecf20Sopenharmony_ci	BUILD_BUG_ON(INTEL_FRONTBUFFER_BITS_PER_PIPE * I915_MAX_PIPES > 32); \
12808c2ecf20Sopenharmony_ci	BUILD_BUG_ON(I915_MAX_PLANES > INTEL_FRONTBUFFER_BITS_PER_PIPE); \
12818c2ecf20Sopenharmony_ci	BIT((plane_id) + INTEL_FRONTBUFFER_BITS_PER_PIPE * (pipe)); \
12828c2ecf20Sopenharmony_ci})
12838c2ecf20Sopenharmony_ci#define INTEL_FRONTBUFFER_OVERLAY(pipe) \
12848c2ecf20Sopenharmony_ci	BIT(INTEL_FRONTBUFFER_BITS_PER_PIPE - 1 + INTEL_FRONTBUFFER_BITS_PER_PIPE * (pipe))
12858c2ecf20Sopenharmony_ci#define INTEL_FRONTBUFFER_ALL_MASK(pipe) \
12868c2ecf20Sopenharmony_ci	GENMASK(INTEL_FRONTBUFFER_BITS_PER_PIPE * ((pipe) + 1) - 1, \
12878c2ecf20Sopenharmony_ci		INTEL_FRONTBUFFER_BITS_PER_PIPE * (pipe))
12888c2ecf20Sopenharmony_ci
12898c2ecf20Sopenharmony_ci#define INTEL_INFO(dev_priv)	(&(dev_priv)->__info)
12908c2ecf20Sopenharmony_ci#define RUNTIME_INFO(dev_priv)	(&(dev_priv)->__runtime)
12918c2ecf20Sopenharmony_ci#define DRIVER_CAPS(dev_priv)	(&(dev_priv)->caps)
12928c2ecf20Sopenharmony_ci
12938c2ecf20Sopenharmony_ci#define INTEL_GEN(dev_priv)	(INTEL_INFO(dev_priv)->gen)
12948c2ecf20Sopenharmony_ci#define INTEL_DEVID(dev_priv)	(RUNTIME_INFO(dev_priv)->device_id)
12958c2ecf20Sopenharmony_ci
12968c2ecf20Sopenharmony_ci#define REVID_FOREVER		0xff
12978c2ecf20Sopenharmony_ci#define INTEL_REVID(dev_priv)	((dev_priv)->drm.pdev->revision)
12988c2ecf20Sopenharmony_ci
12998c2ecf20Sopenharmony_ci#define INTEL_GEN_MASK(s, e) ( \
13008c2ecf20Sopenharmony_ci	BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \
13018c2ecf20Sopenharmony_ci	BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \
13028c2ecf20Sopenharmony_ci	GENMASK((e) - 1, (s) - 1))
13038c2ecf20Sopenharmony_ci
13048c2ecf20Sopenharmony_ci/* Returns true if Gen is in inclusive range [Start, End] */
13058c2ecf20Sopenharmony_ci#define IS_GEN_RANGE(dev_priv, s, e) \
13068c2ecf20Sopenharmony_ci	(!!(INTEL_INFO(dev_priv)->gen_mask & INTEL_GEN_MASK((s), (e))))
13078c2ecf20Sopenharmony_ci
13088c2ecf20Sopenharmony_ci#define IS_GEN(dev_priv, n) \
13098c2ecf20Sopenharmony_ci	(BUILD_BUG_ON_ZERO(!__builtin_constant_p(n)) + \
13108c2ecf20Sopenharmony_ci	 INTEL_INFO(dev_priv)->gen == (n))
13118c2ecf20Sopenharmony_ci
13128c2ecf20Sopenharmony_ci#define HAS_DSB(dev_priv)	(INTEL_INFO(dev_priv)->display.has_dsb)
13138c2ecf20Sopenharmony_ci
13148c2ecf20Sopenharmony_ci/*
13158c2ecf20Sopenharmony_ci * Return true if revision is in range [since,until] inclusive.
13168c2ecf20Sopenharmony_ci *
13178c2ecf20Sopenharmony_ci * Use 0 for open-ended since, and REVID_FOREVER for open-ended until.
13188c2ecf20Sopenharmony_ci */
13198c2ecf20Sopenharmony_ci#define IS_REVID(p, since, until) \
13208c2ecf20Sopenharmony_ci	(INTEL_REVID(p) >= (since) && INTEL_REVID(p) <= (until))
13218c2ecf20Sopenharmony_ci
13228c2ecf20Sopenharmony_cistatic __always_inline unsigned int
13238c2ecf20Sopenharmony_ci__platform_mask_index(const struct intel_runtime_info *info,
13248c2ecf20Sopenharmony_ci		      enum intel_platform p)
13258c2ecf20Sopenharmony_ci{
13268c2ecf20Sopenharmony_ci	const unsigned int pbits =
13278c2ecf20Sopenharmony_ci		BITS_PER_TYPE(info->platform_mask[0]) - INTEL_SUBPLATFORM_BITS;
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ci	/* Expand the platform_mask array if this fails. */
13308c2ecf20Sopenharmony_ci	BUILD_BUG_ON(INTEL_MAX_PLATFORMS >
13318c2ecf20Sopenharmony_ci		     pbits * ARRAY_SIZE(info->platform_mask));
13328c2ecf20Sopenharmony_ci
13338c2ecf20Sopenharmony_ci	return p / pbits;
13348c2ecf20Sopenharmony_ci}
13358c2ecf20Sopenharmony_ci
13368c2ecf20Sopenharmony_cistatic __always_inline unsigned int
13378c2ecf20Sopenharmony_ci__platform_mask_bit(const struct intel_runtime_info *info,
13388c2ecf20Sopenharmony_ci		    enum intel_platform p)
13398c2ecf20Sopenharmony_ci{
13408c2ecf20Sopenharmony_ci	const unsigned int pbits =
13418c2ecf20Sopenharmony_ci		BITS_PER_TYPE(info->platform_mask[0]) - INTEL_SUBPLATFORM_BITS;
13428c2ecf20Sopenharmony_ci
13438c2ecf20Sopenharmony_ci	return p % pbits + INTEL_SUBPLATFORM_BITS;
13448c2ecf20Sopenharmony_ci}
13458c2ecf20Sopenharmony_ci
13468c2ecf20Sopenharmony_cistatic inline u32
13478c2ecf20Sopenharmony_ciintel_subplatform(const struct intel_runtime_info *info, enum intel_platform p)
13488c2ecf20Sopenharmony_ci{
13498c2ecf20Sopenharmony_ci	const unsigned int pi = __platform_mask_index(info, p);
13508c2ecf20Sopenharmony_ci
13518c2ecf20Sopenharmony_ci	return info->platform_mask[pi] & ((1 << INTEL_SUBPLATFORM_BITS) - 1);
13528c2ecf20Sopenharmony_ci}
13538c2ecf20Sopenharmony_ci
13548c2ecf20Sopenharmony_cistatic __always_inline bool
13558c2ecf20Sopenharmony_ciIS_PLATFORM(const struct drm_i915_private *i915, enum intel_platform p)
13568c2ecf20Sopenharmony_ci{
13578c2ecf20Sopenharmony_ci	const struct intel_runtime_info *info = RUNTIME_INFO(i915);
13588c2ecf20Sopenharmony_ci	const unsigned int pi = __platform_mask_index(info, p);
13598c2ecf20Sopenharmony_ci	const unsigned int pb = __platform_mask_bit(info, p);
13608c2ecf20Sopenharmony_ci
13618c2ecf20Sopenharmony_ci	BUILD_BUG_ON(!__builtin_constant_p(p));
13628c2ecf20Sopenharmony_ci
13638c2ecf20Sopenharmony_ci	return info->platform_mask[pi] & BIT(pb);
13648c2ecf20Sopenharmony_ci}
13658c2ecf20Sopenharmony_ci
13668c2ecf20Sopenharmony_cistatic __always_inline bool
13678c2ecf20Sopenharmony_ciIS_SUBPLATFORM(const struct drm_i915_private *i915,
13688c2ecf20Sopenharmony_ci	       enum intel_platform p, unsigned int s)
13698c2ecf20Sopenharmony_ci{
13708c2ecf20Sopenharmony_ci	const struct intel_runtime_info *info = RUNTIME_INFO(i915);
13718c2ecf20Sopenharmony_ci	const unsigned int pi = __platform_mask_index(info, p);
13728c2ecf20Sopenharmony_ci	const unsigned int pb = __platform_mask_bit(info, p);
13738c2ecf20Sopenharmony_ci	const unsigned int msb = BITS_PER_TYPE(info->platform_mask[0]) - 1;
13748c2ecf20Sopenharmony_ci	const u32 mask = info->platform_mask[pi];
13758c2ecf20Sopenharmony_ci
13768c2ecf20Sopenharmony_ci	BUILD_BUG_ON(!__builtin_constant_p(p));
13778c2ecf20Sopenharmony_ci	BUILD_BUG_ON(!__builtin_constant_p(s));
13788c2ecf20Sopenharmony_ci	BUILD_BUG_ON((s) >= INTEL_SUBPLATFORM_BITS);
13798c2ecf20Sopenharmony_ci
13808c2ecf20Sopenharmony_ci	/* Shift and test on the MSB position so sign flag can be used. */
13818c2ecf20Sopenharmony_ci	return ((mask << (msb - pb)) & (mask << (msb - s))) & BIT(msb);
13828c2ecf20Sopenharmony_ci}
13838c2ecf20Sopenharmony_ci
13848c2ecf20Sopenharmony_ci#define IS_MOBILE(dev_priv)	(INTEL_INFO(dev_priv)->is_mobile)
13858c2ecf20Sopenharmony_ci#define IS_DGFX(dev_priv)   (INTEL_INFO(dev_priv)->is_dgfx)
13868c2ecf20Sopenharmony_ci
13878c2ecf20Sopenharmony_ci#define IS_I830(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I830)
13888c2ecf20Sopenharmony_ci#define IS_I845G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I845G)
13898c2ecf20Sopenharmony_ci#define IS_I85X(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I85X)
13908c2ecf20Sopenharmony_ci#define IS_I865G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I865G)
13918c2ecf20Sopenharmony_ci#define IS_I915G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I915G)
13928c2ecf20Sopenharmony_ci#define IS_I915GM(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I915GM)
13938c2ecf20Sopenharmony_ci#define IS_I945G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I945G)
13948c2ecf20Sopenharmony_ci#define IS_I945GM(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I945GM)
13958c2ecf20Sopenharmony_ci#define IS_I965G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I965G)
13968c2ecf20Sopenharmony_ci#define IS_I965GM(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I965GM)
13978c2ecf20Sopenharmony_ci#define IS_G45(dev_priv)	IS_PLATFORM(dev_priv, INTEL_G45)
13988c2ecf20Sopenharmony_ci#define IS_GM45(dev_priv)	IS_PLATFORM(dev_priv, INTEL_GM45)
13998c2ecf20Sopenharmony_ci#define IS_G4X(dev_priv)	(IS_G45(dev_priv) || IS_GM45(dev_priv))
14008c2ecf20Sopenharmony_ci#define IS_PINEVIEW(dev_priv)	IS_PLATFORM(dev_priv, INTEL_PINEVIEW)
14018c2ecf20Sopenharmony_ci#define IS_G33(dev_priv)	IS_PLATFORM(dev_priv, INTEL_G33)
14028c2ecf20Sopenharmony_ci#define IS_IRONLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_IRONLAKE)
14038c2ecf20Sopenharmony_ci#define IS_IRONLAKE_M(dev_priv) \
14048c2ecf20Sopenharmony_ci	(IS_PLATFORM(dev_priv, INTEL_IRONLAKE) && IS_MOBILE(dev_priv))
14058c2ecf20Sopenharmony_ci#define IS_IVYBRIDGE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_IVYBRIDGE)
14068c2ecf20Sopenharmony_ci#define IS_IVB_GT1(dev_priv)	(IS_IVYBRIDGE(dev_priv) && \
14078c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 1)
14088c2ecf20Sopenharmony_ci#define IS_VALLEYVIEW(dev_priv)	IS_PLATFORM(dev_priv, INTEL_VALLEYVIEW)
14098c2ecf20Sopenharmony_ci#define IS_CHERRYVIEW(dev_priv)	IS_PLATFORM(dev_priv, INTEL_CHERRYVIEW)
14108c2ecf20Sopenharmony_ci#define IS_HASWELL(dev_priv)	IS_PLATFORM(dev_priv, INTEL_HASWELL)
14118c2ecf20Sopenharmony_ci#define IS_BROADWELL(dev_priv)	IS_PLATFORM(dev_priv, INTEL_BROADWELL)
14128c2ecf20Sopenharmony_ci#define IS_SKYLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_SKYLAKE)
14138c2ecf20Sopenharmony_ci#define IS_BROXTON(dev_priv)	IS_PLATFORM(dev_priv, INTEL_BROXTON)
14148c2ecf20Sopenharmony_ci#define IS_KABYLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_KABYLAKE)
14158c2ecf20Sopenharmony_ci#define IS_GEMINILAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_GEMINILAKE)
14168c2ecf20Sopenharmony_ci#define IS_COFFEELAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_COFFEELAKE)
14178c2ecf20Sopenharmony_ci#define IS_COMETLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_COMETLAKE)
14188c2ecf20Sopenharmony_ci#define IS_CANNONLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_CANNONLAKE)
14198c2ecf20Sopenharmony_ci#define IS_ICELAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_ICELAKE)
14208c2ecf20Sopenharmony_ci#define IS_ELKHARTLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_ELKHARTLAKE)
14218c2ecf20Sopenharmony_ci#define IS_TIGERLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_TIGERLAKE)
14228c2ecf20Sopenharmony_ci#define IS_ROCKETLAKE(dev_priv)	IS_PLATFORM(dev_priv, INTEL_ROCKETLAKE)
14238c2ecf20Sopenharmony_ci#define IS_DG1(dev_priv)        IS_PLATFORM(dev_priv, INTEL_DG1)
14248c2ecf20Sopenharmony_ci#define IS_HSW_EARLY_SDV(dev_priv) (IS_HASWELL(dev_priv) && \
14258c2ecf20Sopenharmony_ci				    (INTEL_DEVID(dev_priv) & 0xFF00) == 0x0C00)
14268c2ecf20Sopenharmony_ci#define IS_BDW_ULT(dev_priv) \
14278c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_BROADWELL, INTEL_SUBPLATFORM_ULT)
14288c2ecf20Sopenharmony_ci#define IS_BDW_ULX(dev_priv) \
14298c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_BROADWELL, INTEL_SUBPLATFORM_ULX)
14308c2ecf20Sopenharmony_ci#define IS_BDW_GT3(dev_priv)	(IS_BROADWELL(dev_priv) && \
14318c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 3)
14328c2ecf20Sopenharmony_ci#define IS_HSW_ULT(dev_priv) \
14338c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_HASWELL, INTEL_SUBPLATFORM_ULT)
14348c2ecf20Sopenharmony_ci#define IS_HSW_GT3(dev_priv)	(IS_HASWELL(dev_priv) && \
14358c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 3)
14368c2ecf20Sopenharmony_ci#define IS_HSW_GT1(dev_priv)	(IS_HASWELL(dev_priv) && \
14378c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 1)
14388c2ecf20Sopenharmony_ci/* ULX machines are also considered ULT. */
14398c2ecf20Sopenharmony_ci#define IS_HSW_ULX(dev_priv) \
14408c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_HASWELL, INTEL_SUBPLATFORM_ULX)
14418c2ecf20Sopenharmony_ci#define IS_SKL_ULT(dev_priv) \
14428c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_SKYLAKE, INTEL_SUBPLATFORM_ULT)
14438c2ecf20Sopenharmony_ci#define IS_SKL_ULX(dev_priv) \
14448c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_SKYLAKE, INTEL_SUBPLATFORM_ULX)
14458c2ecf20Sopenharmony_ci#define IS_KBL_ULT(dev_priv) \
14468c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_KABYLAKE, INTEL_SUBPLATFORM_ULT)
14478c2ecf20Sopenharmony_ci#define IS_KBL_ULX(dev_priv) \
14488c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_KABYLAKE, INTEL_SUBPLATFORM_ULX)
14498c2ecf20Sopenharmony_ci#define IS_SKL_GT2(dev_priv)	(IS_SKYLAKE(dev_priv) && \
14508c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 2)
14518c2ecf20Sopenharmony_ci#define IS_SKL_GT3(dev_priv)	(IS_SKYLAKE(dev_priv) && \
14528c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 3)
14538c2ecf20Sopenharmony_ci#define IS_SKL_GT4(dev_priv)	(IS_SKYLAKE(dev_priv) && \
14548c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 4)
14558c2ecf20Sopenharmony_ci#define IS_KBL_GT2(dev_priv)	(IS_KABYLAKE(dev_priv) && \
14568c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 2)
14578c2ecf20Sopenharmony_ci#define IS_KBL_GT3(dev_priv)	(IS_KABYLAKE(dev_priv) && \
14588c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 3)
14598c2ecf20Sopenharmony_ci#define IS_CFL_ULT(dev_priv) \
14608c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_COFFEELAKE, INTEL_SUBPLATFORM_ULT)
14618c2ecf20Sopenharmony_ci#define IS_CFL_ULX(dev_priv) \
14628c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_COFFEELAKE, INTEL_SUBPLATFORM_ULX)
14638c2ecf20Sopenharmony_ci#define IS_CFL_GT2(dev_priv)	(IS_COFFEELAKE(dev_priv) && \
14648c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 2)
14658c2ecf20Sopenharmony_ci#define IS_CFL_GT3(dev_priv)	(IS_COFFEELAKE(dev_priv) && \
14668c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 3)
14678c2ecf20Sopenharmony_ci
14688c2ecf20Sopenharmony_ci#define IS_CML_ULT(dev_priv) \
14698c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_COMETLAKE, INTEL_SUBPLATFORM_ULT)
14708c2ecf20Sopenharmony_ci#define IS_CML_ULX(dev_priv) \
14718c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_COMETLAKE, INTEL_SUBPLATFORM_ULX)
14728c2ecf20Sopenharmony_ci#define IS_CML_GT2(dev_priv)	(IS_COMETLAKE(dev_priv) && \
14738c2ecf20Sopenharmony_ci				 INTEL_INFO(dev_priv)->gt == 2)
14748c2ecf20Sopenharmony_ci
14758c2ecf20Sopenharmony_ci#define IS_CNL_WITH_PORT_F(dev_priv) \
14768c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_CANNONLAKE, INTEL_SUBPLATFORM_PORTF)
14778c2ecf20Sopenharmony_ci#define IS_ICL_WITH_PORT_F(dev_priv) \
14788c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_ICELAKE, INTEL_SUBPLATFORM_PORTF)
14798c2ecf20Sopenharmony_ci
14808c2ecf20Sopenharmony_ci#define IS_TGL_U(dev_priv) \
14818c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_TIGERLAKE, INTEL_SUBPLATFORM_ULT)
14828c2ecf20Sopenharmony_ci
14838c2ecf20Sopenharmony_ci#define IS_TGL_Y(dev_priv) \
14848c2ecf20Sopenharmony_ci	IS_SUBPLATFORM(dev_priv, INTEL_TIGERLAKE, INTEL_SUBPLATFORM_ULX)
14858c2ecf20Sopenharmony_ci
14868c2ecf20Sopenharmony_ci#define SKL_REVID_A0		0x0
14878c2ecf20Sopenharmony_ci#define SKL_REVID_B0		0x1
14888c2ecf20Sopenharmony_ci#define SKL_REVID_C0		0x2
14898c2ecf20Sopenharmony_ci#define SKL_REVID_D0		0x3
14908c2ecf20Sopenharmony_ci#define SKL_REVID_E0		0x4
14918c2ecf20Sopenharmony_ci#define SKL_REVID_F0		0x5
14928c2ecf20Sopenharmony_ci#define SKL_REVID_G0		0x6
14938c2ecf20Sopenharmony_ci#define SKL_REVID_H0		0x7
14948c2ecf20Sopenharmony_ci
14958c2ecf20Sopenharmony_ci#define IS_SKL_REVID(p, since, until) (IS_SKYLAKE(p) && IS_REVID(p, since, until))
14968c2ecf20Sopenharmony_ci
14978c2ecf20Sopenharmony_ci#define BXT_REVID_A0		0x0
14988c2ecf20Sopenharmony_ci#define BXT_REVID_A1		0x1
14998c2ecf20Sopenharmony_ci#define BXT_REVID_B0		0x3
15008c2ecf20Sopenharmony_ci#define BXT_REVID_B_LAST	0x8
15018c2ecf20Sopenharmony_ci#define BXT_REVID_C0		0x9
15028c2ecf20Sopenharmony_ci
15038c2ecf20Sopenharmony_ci#define IS_BXT_REVID(dev_priv, since, until) \
15048c2ecf20Sopenharmony_ci	(IS_BROXTON(dev_priv) && IS_REVID(dev_priv, since, until))
15058c2ecf20Sopenharmony_ci
15068c2ecf20Sopenharmony_cienum {
15078c2ecf20Sopenharmony_ci	KBL_REVID_A0,
15088c2ecf20Sopenharmony_ci	KBL_REVID_B0,
15098c2ecf20Sopenharmony_ci	KBL_REVID_B1,
15108c2ecf20Sopenharmony_ci	KBL_REVID_C0,
15118c2ecf20Sopenharmony_ci	KBL_REVID_D0,
15128c2ecf20Sopenharmony_ci	KBL_REVID_D1,
15138c2ecf20Sopenharmony_ci	KBL_REVID_E0,
15148c2ecf20Sopenharmony_ci	KBL_REVID_F0,
15158c2ecf20Sopenharmony_ci	KBL_REVID_G0,
15168c2ecf20Sopenharmony_ci};
15178c2ecf20Sopenharmony_ci
15188c2ecf20Sopenharmony_cistruct i915_rev_steppings {
15198c2ecf20Sopenharmony_ci	u8 gt_stepping;
15208c2ecf20Sopenharmony_ci	u8 disp_stepping;
15218c2ecf20Sopenharmony_ci};
15228c2ecf20Sopenharmony_ci
15238c2ecf20Sopenharmony_ci/* Defined in intel_workarounds.c */
15248c2ecf20Sopenharmony_ciextern const struct i915_rev_steppings kbl_revids[];
15258c2ecf20Sopenharmony_ci
15268c2ecf20Sopenharmony_ci#define IS_KBL_GT_REVID(dev_priv, since, until) \
15278c2ecf20Sopenharmony_ci	(IS_KABYLAKE(dev_priv) && \
15288c2ecf20Sopenharmony_ci	 kbl_revids[INTEL_REVID(dev_priv)].gt_stepping >= since && \
15298c2ecf20Sopenharmony_ci	 kbl_revids[INTEL_REVID(dev_priv)].gt_stepping <= until)
15308c2ecf20Sopenharmony_ci#define IS_KBL_DISP_REVID(dev_priv, since, until) \
15318c2ecf20Sopenharmony_ci	(IS_KABYLAKE(dev_priv) && \
15328c2ecf20Sopenharmony_ci	 kbl_revids[INTEL_REVID(dev_priv)].disp_stepping >= since && \
15338c2ecf20Sopenharmony_ci	 kbl_revids[INTEL_REVID(dev_priv)].disp_stepping <= until)
15348c2ecf20Sopenharmony_ci
15358c2ecf20Sopenharmony_ci#define GLK_REVID_A0		0x0
15368c2ecf20Sopenharmony_ci#define GLK_REVID_A1		0x1
15378c2ecf20Sopenharmony_ci#define GLK_REVID_A2		0x2
15388c2ecf20Sopenharmony_ci#define GLK_REVID_B0		0x3
15398c2ecf20Sopenharmony_ci
15408c2ecf20Sopenharmony_ci#define IS_GLK_REVID(dev_priv, since, until) \
15418c2ecf20Sopenharmony_ci	(IS_GEMINILAKE(dev_priv) && IS_REVID(dev_priv, since, until))
15428c2ecf20Sopenharmony_ci
15438c2ecf20Sopenharmony_ci#define CNL_REVID_A0		0x0
15448c2ecf20Sopenharmony_ci#define CNL_REVID_B0		0x1
15458c2ecf20Sopenharmony_ci#define CNL_REVID_C0		0x2
15468c2ecf20Sopenharmony_ci
15478c2ecf20Sopenharmony_ci#define IS_CNL_REVID(p, since, until) \
15488c2ecf20Sopenharmony_ci	(IS_CANNONLAKE(p) && IS_REVID(p, since, until))
15498c2ecf20Sopenharmony_ci
15508c2ecf20Sopenharmony_ci#define ICL_REVID_A0		0x0
15518c2ecf20Sopenharmony_ci#define ICL_REVID_A2		0x1
15528c2ecf20Sopenharmony_ci#define ICL_REVID_B0		0x3
15538c2ecf20Sopenharmony_ci#define ICL_REVID_B2		0x4
15548c2ecf20Sopenharmony_ci#define ICL_REVID_C0		0x5
15558c2ecf20Sopenharmony_ci
15568c2ecf20Sopenharmony_ci#define IS_ICL_REVID(p, since, until) \
15578c2ecf20Sopenharmony_ci	(IS_ICELAKE(p) && IS_REVID(p, since, until))
15588c2ecf20Sopenharmony_ci
15598c2ecf20Sopenharmony_ci#define EHL_REVID_A0            0x0
15608c2ecf20Sopenharmony_ci
15618c2ecf20Sopenharmony_ci#define IS_EHL_REVID(p, since, until) \
15628c2ecf20Sopenharmony_ci	(IS_ELKHARTLAKE(p) && IS_REVID(p, since, until))
15638c2ecf20Sopenharmony_ci
15648c2ecf20Sopenharmony_cienum {
15658c2ecf20Sopenharmony_ci	TGL_REVID_A0,
15668c2ecf20Sopenharmony_ci	TGL_REVID_B0,
15678c2ecf20Sopenharmony_ci	TGL_REVID_B1,
15688c2ecf20Sopenharmony_ci	TGL_REVID_C0,
15698c2ecf20Sopenharmony_ci	TGL_REVID_D0,
15708c2ecf20Sopenharmony_ci};
15718c2ecf20Sopenharmony_ci
15728c2ecf20Sopenharmony_ciextern const struct i915_rev_steppings tgl_uy_revids[];
15738c2ecf20Sopenharmony_ciextern const struct i915_rev_steppings tgl_revids[];
15748c2ecf20Sopenharmony_ci
15758c2ecf20Sopenharmony_cistatic inline const struct i915_rev_steppings *
15768c2ecf20Sopenharmony_citgl_revids_get(struct drm_i915_private *dev_priv)
15778c2ecf20Sopenharmony_ci{
15788c2ecf20Sopenharmony_ci	if (IS_TGL_U(dev_priv) || IS_TGL_Y(dev_priv))
15798c2ecf20Sopenharmony_ci		return tgl_uy_revids;
15808c2ecf20Sopenharmony_ci	else
15818c2ecf20Sopenharmony_ci		return tgl_revids;
15828c2ecf20Sopenharmony_ci}
15838c2ecf20Sopenharmony_ci
15848c2ecf20Sopenharmony_ci#define IS_TGL_DISP_REVID(p, since, until) \
15858c2ecf20Sopenharmony_ci	(IS_TIGERLAKE(p) && \
15868c2ecf20Sopenharmony_ci	 tgl_revids_get(p)->disp_stepping >= (since) && \
15878c2ecf20Sopenharmony_ci	 tgl_revids_get(p)->disp_stepping <= (until))
15888c2ecf20Sopenharmony_ci
15898c2ecf20Sopenharmony_ci#define IS_TGL_UY_GT_REVID(p, since, until) \
15908c2ecf20Sopenharmony_ci	((IS_TGL_U(p) || IS_TGL_Y(p)) && \
15918c2ecf20Sopenharmony_ci	 tgl_uy_revids->gt_stepping >= (since) && \
15928c2ecf20Sopenharmony_ci	 tgl_uy_revids->gt_stepping <= (until))
15938c2ecf20Sopenharmony_ci
15948c2ecf20Sopenharmony_ci#define IS_TGL_GT_REVID(p, since, until) \
15958c2ecf20Sopenharmony_ci	(IS_TIGERLAKE(p) && \
15968c2ecf20Sopenharmony_ci	 !(IS_TGL_U(p) || IS_TGL_Y(p)) && \
15978c2ecf20Sopenharmony_ci	 tgl_revids->gt_stepping >= (since) && \
15988c2ecf20Sopenharmony_ci	 tgl_revids->gt_stepping <= (until))
15998c2ecf20Sopenharmony_ci
16008c2ecf20Sopenharmony_ci#define RKL_REVID_A0		0x0
16018c2ecf20Sopenharmony_ci#define RKL_REVID_B0		0x1
16028c2ecf20Sopenharmony_ci#define RKL_REVID_C0		0x4
16038c2ecf20Sopenharmony_ci
16048c2ecf20Sopenharmony_ci#define IS_RKL_REVID(p, since, until) \
16058c2ecf20Sopenharmony_ci	(IS_ROCKETLAKE(p) && IS_REVID(p, since, until))
16068c2ecf20Sopenharmony_ci
16078c2ecf20Sopenharmony_ci#define DG1_REVID_A0		0x0
16088c2ecf20Sopenharmony_ci#define DG1_REVID_B0		0x1
16098c2ecf20Sopenharmony_ci
16108c2ecf20Sopenharmony_ci#define IS_DG1_REVID(p, since, until) \
16118c2ecf20Sopenharmony_ci	(IS_DG1(p) && IS_REVID(p, since, until))
16128c2ecf20Sopenharmony_ci
16138c2ecf20Sopenharmony_ci#define IS_LP(dev_priv)	(INTEL_INFO(dev_priv)->is_lp)
16148c2ecf20Sopenharmony_ci#define IS_GEN9_LP(dev_priv)	(IS_GEN(dev_priv, 9) && IS_LP(dev_priv))
16158c2ecf20Sopenharmony_ci#define IS_GEN9_BC(dev_priv)	(IS_GEN(dev_priv, 9) && !IS_LP(dev_priv))
16168c2ecf20Sopenharmony_ci
16178c2ecf20Sopenharmony_ci#define __HAS_ENGINE(engine_mask, id) ((engine_mask) & BIT(id))
16188c2ecf20Sopenharmony_ci#define HAS_ENGINE(gt, id) __HAS_ENGINE((gt)->info.engine_mask, id)
16198c2ecf20Sopenharmony_ci
16208c2ecf20Sopenharmony_ci#define ENGINE_INSTANCES_MASK(gt, first, count) ({		\
16218c2ecf20Sopenharmony_ci	unsigned int first__ = (first);					\
16228c2ecf20Sopenharmony_ci	unsigned int count__ = (count);					\
16238c2ecf20Sopenharmony_ci	((gt)->info.engine_mask &						\
16248c2ecf20Sopenharmony_ci	 GENMASK(first__ + count__ - 1, first__)) >> first__;		\
16258c2ecf20Sopenharmony_ci})
16268c2ecf20Sopenharmony_ci#define VDBOX_MASK(gt) \
16278c2ecf20Sopenharmony_ci	ENGINE_INSTANCES_MASK(gt, VCS0, I915_MAX_VCS)
16288c2ecf20Sopenharmony_ci#define VEBOX_MASK(gt) \
16298c2ecf20Sopenharmony_ci	ENGINE_INSTANCES_MASK(gt, VECS0, I915_MAX_VECS)
16308c2ecf20Sopenharmony_ci
16318c2ecf20Sopenharmony_ci/*
16328c2ecf20Sopenharmony_ci * The Gen7 cmdparser copies the scanned buffer to the ggtt for execution
16338c2ecf20Sopenharmony_ci * All later gens can run the final buffer from the ppgtt
16348c2ecf20Sopenharmony_ci */
16358c2ecf20Sopenharmony_ci#define CMDPARSER_USES_GGTT(dev_priv) IS_GEN(dev_priv, 7)
16368c2ecf20Sopenharmony_ci
16378c2ecf20Sopenharmony_ci#define HAS_LLC(dev_priv)	(INTEL_INFO(dev_priv)->has_llc)
16388c2ecf20Sopenharmony_ci#define HAS_SNOOP(dev_priv)	(INTEL_INFO(dev_priv)->has_snoop)
16398c2ecf20Sopenharmony_ci#define HAS_EDRAM(dev_priv)	((dev_priv)->edram_size_mb)
16408c2ecf20Sopenharmony_ci#define HAS_SECURE_BATCHES(dev_priv) (INTEL_GEN(dev_priv) < 6)
16418c2ecf20Sopenharmony_ci#define HAS_WT(dev_priv)	((IS_HASWELL(dev_priv) || \
16428c2ecf20Sopenharmony_ci				 IS_BROADWELL(dev_priv)) && HAS_EDRAM(dev_priv))
16438c2ecf20Sopenharmony_ci
16448c2ecf20Sopenharmony_ci#define HWS_NEEDS_PHYSICAL(dev_priv)	(INTEL_INFO(dev_priv)->hws_needs_physical)
16458c2ecf20Sopenharmony_ci
16468c2ecf20Sopenharmony_ci#define HAS_LOGICAL_RING_CONTEXTS(dev_priv) \
16478c2ecf20Sopenharmony_ci		(INTEL_INFO(dev_priv)->has_logical_ring_contexts)
16488c2ecf20Sopenharmony_ci#define HAS_LOGICAL_RING_ELSQ(dev_priv) \
16498c2ecf20Sopenharmony_ci		(INTEL_INFO(dev_priv)->has_logical_ring_elsq)
16508c2ecf20Sopenharmony_ci#define HAS_LOGICAL_RING_PREEMPTION(dev_priv) \
16518c2ecf20Sopenharmony_ci		(INTEL_INFO(dev_priv)->has_logical_ring_preemption)
16528c2ecf20Sopenharmony_ci
16538c2ecf20Sopenharmony_ci#define HAS_MASTER_UNIT_IRQ(dev_priv) (INTEL_INFO(dev_priv)->has_master_unit_irq)
16548c2ecf20Sopenharmony_ci
16558c2ecf20Sopenharmony_ci#define HAS_EXECLISTS(dev_priv) HAS_LOGICAL_RING_CONTEXTS(dev_priv)
16568c2ecf20Sopenharmony_ci
16578c2ecf20Sopenharmony_ci#define INTEL_PPGTT(dev_priv) (INTEL_INFO(dev_priv)->ppgtt_type)
16588c2ecf20Sopenharmony_ci#define HAS_PPGTT(dev_priv) \
16598c2ecf20Sopenharmony_ci	(INTEL_PPGTT(dev_priv) != INTEL_PPGTT_NONE)
16608c2ecf20Sopenharmony_ci#define HAS_FULL_PPGTT(dev_priv) \
16618c2ecf20Sopenharmony_ci	(INTEL_PPGTT(dev_priv) >= INTEL_PPGTT_FULL)
16628c2ecf20Sopenharmony_ci
16638c2ecf20Sopenharmony_ci#define HAS_PAGE_SIZES(dev_priv, sizes) ({ \
16648c2ecf20Sopenharmony_ci	GEM_BUG_ON((sizes) == 0); \
16658c2ecf20Sopenharmony_ci	((sizes) & ~INTEL_INFO(dev_priv)->page_sizes) == 0; \
16668c2ecf20Sopenharmony_ci})
16678c2ecf20Sopenharmony_ci
16688c2ecf20Sopenharmony_ci#define HAS_OVERLAY(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_overlay)
16698c2ecf20Sopenharmony_ci#define OVERLAY_NEEDS_PHYSICAL(dev_priv) \
16708c2ecf20Sopenharmony_ci		(INTEL_INFO(dev_priv)->display.overlay_needs_physical)
16718c2ecf20Sopenharmony_ci
16728c2ecf20Sopenharmony_ci/* Early gen2 have a totally busted CS tlb and require pinned batches. */
16738c2ecf20Sopenharmony_ci#define HAS_BROKEN_CS_TLB(dev_priv)	(IS_I830(dev_priv) || IS_I845G(dev_priv))
16748c2ecf20Sopenharmony_ci
16758c2ecf20Sopenharmony_ci#define NEEDS_RC6_CTX_CORRUPTION_WA(dev_priv)	\
16768c2ecf20Sopenharmony_ci	(IS_BROADWELL(dev_priv) || IS_GEN(dev_priv, 9))
16778c2ecf20Sopenharmony_ci
16788c2ecf20Sopenharmony_ci/* WaRsDisableCoarsePowerGating:skl,cnl */
16798c2ecf20Sopenharmony_ci#define NEEDS_WaRsDisableCoarsePowerGating(dev_priv)			\
16808c2ecf20Sopenharmony_ci	(IS_CANNONLAKE(dev_priv) ||					\
16818c2ecf20Sopenharmony_ci	 IS_SKL_GT3(dev_priv) ||					\
16828c2ecf20Sopenharmony_ci	 IS_SKL_GT4(dev_priv))
16838c2ecf20Sopenharmony_ci
16848c2ecf20Sopenharmony_ci#define HAS_GMBUS_IRQ(dev_priv) (INTEL_GEN(dev_priv) >= 4)
16858c2ecf20Sopenharmony_ci#define HAS_GMBUS_BURST_READ(dev_priv) (INTEL_GEN(dev_priv) >= 10 || \
16868c2ecf20Sopenharmony_ci					IS_GEMINILAKE(dev_priv) || \
16878c2ecf20Sopenharmony_ci					IS_KABYLAKE(dev_priv))
16888c2ecf20Sopenharmony_ci
16898c2ecf20Sopenharmony_ci/* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
16908c2ecf20Sopenharmony_ci * rows, which changed the alignment requirements and fence programming.
16918c2ecf20Sopenharmony_ci */
16928c2ecf20Sopenharmony_ci#define HAS_128_BYTE_Y_TILING(dev_priv) (!IS_GEN(dev_priv, 2) && \
16938c2ecf20Sopenharmony_ci					 !(IS_I915G(dev_priv) || \
16948c2ecf20Sopenharmony_ci					 IS_I915GM(dev_priv)))
16958c2ecf20Sopenharmony_ci#define SUPPORTS_TV(dev_priv)		(INTEL_INFO(dev_priv)->display.supports_tv)
16968c2ecf20Sopenharmony_ci#define I915_HAS_HOTPLUG(dev_priv)	(INTEL_INFO(dev_priv)->display.has_hotplug)
16978c2ecf20Sopenharmony_ci
16988c2ecf20Sopenharmony_ci#define HAS_FW_BLC(dev_priv) 	(INTEL_GEN(dev_priv) > 2)
16998c2ecf20Sopenharmony_ci#define HAS_FBC(dev_priv)	(INTEL_INFO(dev_priv)->display.has_fbc)
17008c2ecf20Sopenharmony_ci#define HAS_CUR_FBC(dev_priv)	(!HAS_GMCH(dev_priv) && INTEL_GEN(dev_priv) >= 7)
17018c2ecf20Sopenharmony_ci
17028c2ecf20Sopenharmony_ci#define HAS_IPS(dev_priv)	(IS_HSW_ULT(dev_priv) || IS_BROADWELL(dev_priv))
17038c2ecf20Sopenharmony_ci
17048c2ecf20Sopenharmony_ci#define HAS_DP_MST(dev_priv)	(INTEL_INFO(dev_priv)->display.has_dp_mst)
17058c2ecf20Sopenharmony_ci
17068c2ecf20Sopenharmony_ci#define HAS_DDI(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_ddi)
17078c2ecf20Sopenharmony_ci#define HAS_FPGA_DBG_UNCLAIMED(dev_priv) (INTEL_INFO(dev_priv)->has_fpga_dbg)
17088c2ecf20Sopenharmony_ci#define HAS_PSR(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_psr)
17098c2ecf20Sopenharmony_ci#define HAS_PSR_HW_TRACKING(dev_priv) \
17108c2ecf20Sopenharmony_ci	(INTEL_INFO(dev_priv)->display.has_psr_hw_tracking)
17118c2ecf20Sopenharmony_ci#define HAS_PSR2_SEL_FETCH(dev_priv)	 (INTEL_GEN(dev_priv) >= 12)
17128c2ecf20Sopenharmony_ci#define HAS_TRANSCODER(dev_priv, trans)	 ((INTEL_INFO(dev_priv)->cpu_transcoder_mask & BIT(trans)) != 0)
17138c2ecf20Sopenharmony_ci
17148c2ecf20Sopenharmony_ci#define HAS_RC6(dev_priv)		 (INTEL_INFO(dev_priv)->has_rc6)
17158c2ecf20Sopenharmony_ci#define HAS_RC6p(dev_priv)		 (INTEL_INFO(dev_priv)->has_rc6p)
17168c2ecf20Sopenharmony_ci#define HAS_RC6pp(dev_priv)		 (false) /* HW was never validated */
17178c2ecf20Sopenharmony_ci
17188c2ecf20Sopenharmony_ci#define HAS_RPS(dev_priv)	(INTEL_INFO(dev_priv)->has_rps)
17198c2ecf20Sopenharmony_ci
17208c2ecf20Sopenharmony_ci#define HAS_CSR(dev_priv)	(INTEL_INFO(dev_priv)->display.has_csr)
17218c2ecf20Sopenharmony_ci
17228c2ecf20Sopenharmony_ci#define HAS_RUNTIME_PM(dev_priv) (INTEL_INFO(dev_priv)->has_runtime_pm)
17238c2ecf20Sopenharmony_ci#define HAS_64BIT_RELOC(dev_priv) (INTEL_INFO(dev_priv)->has_64bit_reloc)
17248c2ecf20Sopenharmony_ci
17258c2ecf20Sopenharmony_ci#define HAS_IPC(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_ipc)
17268c2ecf20Sopenharmony_ci
17278c2ecf20Sopenharmony_ci#define HAS_REGION(i915, i) (INTEL_INFO(i915)->memory_regions & (i))
17288c2ecf20Sopenharmony_ci#define HAS_LMEM(i915) HAS_REGION(i915, REGION_LMEM)
17298c2ecf20Sopenharmony_ci
17308c2ecf20Sopenharmony_ci#define HAS_GT_UC(dev_priv)	(INTEL_INFO(dev_priv)->has_gt_uc)
17318c2ecf20Sopenharmony_ci
17328c2ecf20Sopenharmony_ci#define HAS_POOLED_EU(dev_priv)	(INTEL_INFO(dev_priv)->has_pooled_eu)
17338c2ecf20Sopenharmony_ci
17348c2ecf20Sopenharmony_ci#define HAS_GLOBAL_MOCS_REGISTERS(dev_priv)	(INTEL_INFO(dev_priv)->has_global_mocs)
17358c2ecf20Sopenharmony_ci
17368c2ecf20Sopenharmony_ci
17378c2ecf20Sopenharmony_ci#define HAS_GMCH(dev_priv) (INTEL_INFO(dev_priv)->display.has_gmch)
17388c2ecf20Sopenharmony_ci
17398c2ecf20Sopenharmony_ci#define HAS_LSPCON(dev_priv) (INTEL_GEN(dev_priv) >= 9)
17408c2ecf20Sopenharmony_ci
17418c2ecf20Sopenharmony_ci/* DPF == dynamic parity feature */
17428c2ecf20Sopenharmony_ci#define HAS_L3_DPF(dev_priv) (INTEL_INFO(dev_priv)->has_l3_dpf)
17438c2ecf20Sopenharmony_ci#define NUM_L3_SLICES(dev_priv) (IS_HSW_GT3(dev_priv) ? \
17448c2ecf20Sopenharmony_ci				 2 : HAS_L3_DPF(dev_priv))
17458c2ecf20Sopenharmony_ci
17468c2ecf20Sopenharmony_ci#define GT_FREQUENCY_MULTIPLIER 50
17478c2ecf20Sopenharmony_ci#define GEN9_FREQ_SCALER 3
17488c2ecf20Sopenharmony_ci
17498c2ecf20Sopenharmony_ci#define INTEL_NUM_PIPES(dev_priv) (hweight8(INTEL_INFO(dev_priv)->pipe_mask))
17508c2ecf20Sopenharmony_ci
17518c2ecf20Sopenharmony_ci#define HAS_DISPLAY(dev_priv) (INTEL_INFO(dev_priv)->pipe_mask != 0)
17528c2ecf20Sopenharmony_ci
17538c2ecf20Sopenharmony_ci/* Only valid when HAS_DISPLAY() is true */
17548c2ecf20Sopenharmony_ci#define INTEL_DISPLAY_ENABLED(dev_priv) \
17558c2ecf20Sopenharmony_ci	(drm_WARN_ON(&(dev_priv)->drm, !HAS_DISPLAY(dev_priv)), !(dev_priv)->params.disable_display)
17568c2ecf20Sopenharmony_ci
17578c2ecf20Sopenharmony_cistatic inline bool intel_vtd_active(void)
17588c2ecf20Sopenharmony_ci{
17598c2ecf20Sopenharmony_ci#ifdef CONFIG_INTEL_IOMMU
17608c2ecf20Sopenharmony_ci	if (intel_iommu_gfx_mapped)
17618c2ecf20Sopenharmony_ci		return true;
17628c2ecf20Sopenharmony_ci#endif
17638c2ecf20Sopenharmony_ci
17648c2ecf20Sopenharmony_ci	/* Running as a guest, we assume the host is enforcing VT'd */
17658c2ecf20Sopenharmony_ci	return !hypervisor_is_type(X86_HYPER_NATIVE);
17668c2ecf20Sopenharmony_ci}
17678c2ecf20Sopenharmony_ci
17688c2ecf20Sopenharmony_cistatic inline bool intel_scanout_needs_vtd_wa(struct drm_i915_private *dev_priv)
17698c2ecf20Sopenharmony_ci{
17708c2ecf20Sopenharmony_ci	return INTEL_GEN(dev_priv) >= 6 && intel_vtd_active();
17718c2ecf20Sopenharmony_ci}
17728c2ecf20Sopenharmony_ci
17738c2ecf20Sopenharmony_cistatic inline bool
17748c2ecf20Sopenharmony_ciintel_ggtt_update_needs_vtd_wa(struct drm_i915_private *dev_priv)
17758c2ecf20Sopenharmony_ci{
17768c2ecf20Sopenharmony_ci	return IS_BROXTON(dev_priv) && intel_vtd_active();
17778c2ecf20Sopenharmony_ci}
17788c2ecf20Sopenharmony_ci
17798c2ecf20Sopenharmony_ci/* i915_drv.c */
17808c2ecf20Sopenharmony_ciextern const struct dev_pm_ops i915_pm_ops;
17818c2ecf20Sopenharmony_ci
17828c2ecf20Sopenharmony_ciint i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
17838c2ecf20Sopenharmony_civoid i915_driver_remove(struct drm_i915_private *i915);
17848c2ecf20Sopenharmony_ci
17858c2ecf20Sopenharmony_ciint i915_resume_switcheroo(struct drm_i915_private *i915);
17868c2ecf20Sopenharmony_ciint i915_suspend_switcheroo(struct drm_i915_private *i915, pm_message_t state);
17878c2ecf20Sopenharmony_ci
17888c2ecf20Sopenharmony_ciint i915_getparam_ioctl(struct drm_device *dev, void *data,
17898c2ecf20Sopenharmony_ci			struct drm_file *file_priv);
17908c2ecf20Sopenharmony_ci
17918c2ecf20Sopenharmony_ci/* i915_gem.c */
17928c2ecf20Sopenharmony_ciint i915_gem_init_userptr(struct drm_i915_private *dev_priv);
17938c2ecf20Sopenharmony_civoid i915_gem_cleanup_userptr(struct drm_i915_private *dev_priv);
17948c2ecf20Sopenharmony_civoid i915_gem_init_early(struct drm_i915_private *dev_priv);
17958c2ecf20Sopenharmony_civoid i915_gem_cleanup_early(struct drm_i915_private *dev_priv);
17968c2ecf20Sopenharmony_ciint i915_gem_freeze(struct drm_i915_private *dev_priv);
17978c2ecf20Sopenharmony_ciint i915_gem_freeze_late(struct drm_i915_private *dev_priv);
17988c2ecf20Sopenharmony_ci
17998c2ecf20Sopenharmony_cistruct intel_memory_region *i915_gem_shmem_setup(struct drm_i915_private *i915);
18008c2ecf20Sopenharmony_ci
18018c2ecf20Sopenharmony_cistatic inline void i915_gem_drain_freed_objects(struct drm_i915_private *i915)
18028c2ecf20Sopenharmony_ci{
18038c2ecf20Sopenharmony_ci	/*
18048c2ecf20Sopenharmony_ci	 * A single pass should suffice to release all the freed objects (along
18058c2ecf20Sopenharmony_ci	 * most call paths) , but be a little more paranoid in that freeing
18068c2ecf20Sopenharmony_ci	 * the objects does take a little amount of time, during which the rcu
18078c2ecf20Sopenharmony_ci	 * callbacks could have added new objects into the freed list, and
18088c2ecf20Sopenharmony_ci	 * armed the work again.
18098c2ecf20Sopenharmony_ci	 */
18108c2ecf20Sopenharmony_ci	while (atomic_read(&i915->mm.free_count)) {
18118c2ecf20Sopenharmony_ci		flush_work(&i915->mm.free_work);
18128c2ecf20Sopenharmony_ci		rcu_barrier();
18138c2ecf20Sopenharmony_ci	}
18148c2ecf20Sopenharmony_ci}
18158c2ecf20Sopenharmony_ci
18168c2ecf20Sopenharmony_cistatic inline void i915_gem_drain_workqueue(struct drm_i915_private *i915)
18178c2ecf20Sopenharmony_ci{
18188c2ecf20Sopenharmony_ci	/*
18198c2ecf20Sopenharmony_ci	 * Similar to objects above (see i915_gem_drain_freed-objects), in
18208c2ecf20Sopenharmony_ci	 * general we have workers that are armed by RCU and then rearm
18218c2ecf20Sopenharmony_ci	 * themselves in their callbacks. To be paranoid, we need to
18228c2ecf20Sopenharmony_ci	 * drain the workqueue a second time after waiting for the RCU
18238c2ecf20Sopenharmony_ci	 * grace period so that we catch work queued via RCU from the first
18248c2ecf20Sopenharmony_ci	 * pass. As neither drain_workqueue() nor flush_workqueue() report
18258c2ecf20Sopenharmony_ci	 * a result, we make an assumption that we only don't require more
18268c2ecf20Sopenharmony_ci	 * than 3 passes to catch all _recursive_ RCU delayed work.
18278c2ecf20Sopenharmony_ci	 *
18288c2ecf20Sopenharmony_ci	 */
18298c2ecf20Sopenharmony_ci	int pass = 3;
18308c2ecf20Sopenharmony_ci	do {
18318c2ecf20Sopenharmony_ci		flush_workqueue(i915->wq);
18328c2ecf20Sopenharmony_ci		rcu_barrier();
18338c2ecf20Sopenharmony_ci		i915_gem_drain_freed_objects(i915);
18348c2ecf20Sopenharmony_ci	} while (--pass);
18358c2ecf20Sopenharmony_ci	drain_workqueue(i915->wq);
18368c2ecf20Sopenharmony_ci}
18378c2ecf20Sopenharmony_ci
18388c2ecf20Sopenharmony_cistruct i915_vma * __must_check
18398c2ecf20Sopenharmony_cii915_gem_object_ggtt_pin_ww(struct drm_i915_gem_object *obj,
18408c2ecf20Sopenharmony_ci			    struct i915_gem_ww_ctx *ww,
18418c2ecf20Sopenharmony_ci			    const struct i915_ggtt_view *view,
18428c2ecf20Sopenharmony_ci			    u64 size, u64 alignment, u64 flags);
18438c2ecf20Sopenharmony_ci
18448c2ecf20Sopenharmony_cistatic inline struct i915_vma * __must_check
18458c2ecf20Sopenharmony_cii915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
18468c2ecf20Sopenharmony_ci			 const struct i915_ggtt_view *view,
18478c2ecf20Sopenharmony_ci			 u64 size, u64 alignment, u64 flags)
18488c2ecf20Sopenharmony_ci{
18498c2ecf20Sopenharmony_ci	return i915_gem_object_ggtt_pin_ww(obj, NULL, view, size, alignment, flags);
18508c2ecf20Sopenharmony_ci}
18518c2ecf20Sopenharmony_ci
18528c2ecf20Sopenharmony_ciint i915_gem_object_unbind(struct drm_i915_gem_object *obj,
18538c2ecf20Sopenharmony_ci			   unsigned long flags);
18548c2ecf20Sopenharmony_ci#define I915_GEM_OBJECT_UNBIND_ACTIVE BIT(0)
18558c2ecf20Sopenharmony_ci#define I915_GEM_OBJECT_UNBIND_BARRIER BIT(1)
18568c2ecf20Sopenharmony_ci#define I915_GEM_OBJECT_UNBIND_TEST BIT(2)
18578c2ecf20Sopenharmony_ci
18588c2ecf20Sopenharmony_civoid i915_gem_runtime_suspend(struct drm_i915_private *dev_priv);
18598c2ecf20Sopenharmony_ci
18608c2ecf20Sopenharmony_ciint i915_gem_dumb_create(struct drm_file *file_priv,
18618c2ecf20Sopenharmony_ci			 struct drm_device *dev,
18628c2ecf20Sopenharmony_ci			 struct drm_mode_create_dumb *args);
18638c2ecf20Sopenharmony_ci
18648c2ecf20Sopenharmony_ciint __must_check i915_gem_set_global_seqno(struct drm_device *dev, u32 seqno);
18658c2ecf20Sopenharmony_ci
18668c2ecf20Sopenharmony_cistatic inline u32 i915_reset_count(struct i915_gpu_error *error)
18678c2ecf20Sopenharmony_ci{
18688c2ecf20Sopenharmony_ci	return atomic_read(&error->reset_count);
18698c2ecf20Sopenharmony_ci}
18708c2ecf20Sopenharmony_ci
18718c2ecf20Sopenharmony_cistatic inline u32 i915_reset_engine_count(struct i915_gpu_error *error,
18728c2ecf20Sopenharmony_ci					  const struct intel_engine_cs *engine)
18738c2ecf20Sopenharmony_ci{
18748c2ecf20Sopenharmony_ci	return atomic_read(&error->reset_engine_count[engine->uabi_class]);
18758c2ecf20Sopenharmony_ci}
18768c2ecf20Sopenharmony_ci
18778c2ecf20Sopenharmony_ciint __must_check i915_gem_init(struct drm_i915_private *dev_priv);
18788c2ecf20Sopenharmony_civoid i915_gem_driver_register(struct drm_i915_private *i915);
18798c2ecf20Sopenharmony_civoid i915_gem_driver_unregister(struct drm_i915_private *i915);
18808c2ecf20Sopenharmony_civoid i915_gem_driver_remove(struct drm_i915_private *dev_priv);
18818c2ecf20Sopenharmony_civoid i915_gem_driver_release(struct drm_i915_private *dev_priv);
18828c2ecf20Sopenharmony_civoid i915_gem_suspend(struct drm_i915_private *dev_priv);
18838c2ecf20Sopenharmony_civoid i915_gem_suspend_late(struct drm_i915_private *dev_priv);
18848c2ecf20Sopenharmony_civoid i915_gem_resume(struct drm_i915_private *dev_priv);
18858c2ecf20Sopenharmony_ci
18868c2ecf20Sopenharmony_ciint i915_gem_open(struct drm_i915_private *i915, struct drm_file *file);
18878c2ecf20Sopenharmony_ci
18888c2ecf20Sopenharmony_ciint i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
18898c2ecf20Sopenharmony_ci				    enum i915_cache_level cache_level);
18908c2ecf20Sopenharmony_ci
18918c2ecf20Sopenharmony_cistruct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
18928c2ecf20Sopenharmony_ci				struct dma_buf *dma_buf);
18938c2ecf20Sopenharmony_ci
18948c2ecf20Sopenharmony_cistruct dma_buf *i915_gem_prime_export(struct drm_gem_object *gem_obj, int flags);
18958c2ecf20Sopenharmony_ci
18968c2ecf20Sopenharmony_cistatic inline struct i915_gem_context *
18978c2ecf20Sopenharmony_ci__i915_gem_context_lookup_rcu(struct drm_i915_file_private *file_priv, u32 id)
18988c2ecf20Sopenharmony_ci{
18998c2ecf20Sopenharmony_ci	return xa_load(&file_priv->context_xa, id);
19008c2ecf20Sopenharmony_ci}
19018c2ecf20Sopenharmony_ci
19028c2ecf20Sopenharmony_cistatic inline struct i915_gem_context *
19038c2ecf20Sopenharmony_cii915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id)
19048c2ecf20Sopenharmony_ci{
19058c2ecf20Sopenharmony_ci	struct i915_gem_context *ctx;
19068c2ecf20Sopenharmony_ci
19078c2ecf20Sopenharmony_ci	rcu_read_lock();
19088c2ecf20Sopenharmony_ci	ctx = __i915_gem_context_lookup_rcu(file_priv, id);
19098c2ecf20Sopenharmony_ci	if (ctx && !kref_get_unless_zero(&ctx->ref))
19108c2ecf20Sopenharmony_ci		ctx = NULL;
19118c2ecf20Sopenharmony_ci	rcu_read_unlock();
19128c2ecf20Sopenharmony_ci
19138c2ecf20Sopenharmony_ci	return ctx;
19148c2ecf20Sopenharmony_ci}
19158c2ecf20Sopenharmony_ci
19168c2ecf20Sopenharmony_ci/* i915_gem_evict.c */
19178c2ecf20Sopenharmony_ciint __must_check i915_gem_evict_something(struct i915_address_space *vm,
19188c2ecf20Sopenharmony_ci					  u64 min_size, u64 alignment,
19198c2ecf20Sopenharmony_ci					  unsigned long color,
19208c2ecf20Sopenharmony_ci					  u64 start, u64 end,
19218c2ecf20Sopenharmony_ci					  unsigned flags);
19228c2ecf20Sopenharmony_ciint __must_check i915_gem_evict_for_node(struct i915_address_space *vm,
19238c2ecf20Sopenharmony_ci					 struct drm_mm_node *node,
19248c2ecf20Sopenharmony_ci					 unsigned int flags);
19258c2ecf20Sopenharmony_ciint i915_gem_evict_vm(struct i915_address_space *vm);
19268c2ecf20Sopenharmony_ci
19278c2ecf20Sopenharmony_ci/* i915_gem_internal.c */
19288c2ecf20Sopenharmony_cistruct drm_i915_gem_object *
19298c2ecf20Sopenharmony_cii915_gem_object_create_internal(struct drm_i915_private *dev_priv,
19308c2ecf20Sopenharmony_ci				phys_addr_t size);
19318c2ecf20Sopenharmony_ci
19328c2ecf20Sopenharmony_ci/* i915_gem_tiling.c */
19338c2ecf20Sopenharmony_cistatic inline bool i915_gem_object_needs_bit17_swizzle(struct drm_i915_gem_object *obj)
19348c2ecf20Sopenharmony_ci{
19358c2ecf20Sopenharmony_ci	struct drm_i915_private *i915 = to_i915(obj->base.dev);
19368c2ecf20Sopenharmony_ci
19378c2ecf20Sopenharmony_ci	return i915->ggtt.bit_6_swizzle_x == I915_BIT_6_SWIZZLE_9_10_17 &&
19388c2ecf20Sopenharmony_ci		i915_gem_object_is_tiled(obj);
19398c2ecf20Sopenharmony_ci}
19408c2ecf20Sopenharmony_ci
19418c2ecf20Sopenharmony_ciu32 i915_gem_fence_size(struct drm_i915_private *dev_priv, u32 size,
19428c2ecf20Sopenharmony_ci			unsigned int tiling, unsigned int stride);
19438c2ecf20Sopenharmony_ciu32 i915_gem_fence_alignment(struct drm_i915_private *dev_priv, u32 size,
19448c2ecf20Sopenharmony_ci			     unsigned int tiling, unsigned int stride);
19458c2ecf20Sopenharmony_ci
19468c2ecf20Sopenharmony_ciconst char *i915_cache_level_str(struct drm_i915_private *i915, int type);
19478c2ecf20Sopenharmony_ci
19488c2ecf20Sopenharmony_ci/* i915_cmd_parser.c */
19498c2ecf20Sopenharmony_ciint i915_cmd_parser_get_version(struct drm_i915_private *dev_priv);
19508c2ecf20Sopenharmony_ciint intel_engine_init_cmd_parser(struct intel_engine_cs *engine);
19518c2ecf20Sopenharmony_civoid intel_engine_cleanup_cmd_parser(struct intel_engine_cs *engine);
19528c2ecf20Sopenharmony_ciint intel_engine_cmd_parser(struct intel_engine_cs *engine,
19538c2ecf20Sopenharmony_ci			    struct i915_vma *batch,
19548c2ecf20Sopenharmony_ci			    unsigned long batch_offset,
19558c2ecf20Sopenharmony_ci			    unsigned long batch_length,
19568c2ecf20Sopenharmony_ci			    struct i915_vma *shadow,
19578c2ecf20Sopenharmony_ci			    bool trampoline);
19588c2ecf20Sopenharmony_ci#define I915_CMD_PARSER_TRAMPOLINE_SIZE 8
19598c2ecf20Sopenharmony_ci
19608c2ecf20Sopenharmony_ci/* intel_device_info.c */
19618c2ecf20Sopenharmony_cistatic inline struct intel_device_info *
19628c2ecf20Sopenharmony_cimkwrite_device_info(struct drm_i915_private *dev_priv)
19638c2ecf20Sopenharmony_ci{
19648c2ecf20Sopenharmony_ci	return (struct intel_device_info *)INTEL_INFO(dev_priv);
19658c2ecf20Sopenharmony_ci}
19668c2ecf20Sopenharmony_ci
19678c2ecf20Sopenharmony_ciint i915_reg_read_ioctl(struct drm_device *dev, void *data,
19688c2ecf20Sopenharmony_ci			struct drm_file *file);
19698c2ecf20Sopenharmony_ci
19708c2ecf20Sopenharmony_ci#define __I915_REG_OP(op__, dev_priv__, ...) \
19718c2ecf20Sopenharmony_ci	intel_uncore_##op__(&(dev_priv__)->uncore, __VA_ARGS__)
19728c2ecf20Sopenharmony_ci
19738c2ecf20Sopenharmony_ci#define I915_READ(reg__)	 __I915_REG_OP(read, dev_priv, (reg__))
19748c2ecf20Sopenharmony_ci#define I915_WRITE(reg__, val__) __I915_REG_OP(write, dev_priv, (reg__), (val__))
19758c2ecf20Sopenharmony_ci
19768c2ecf20Sopenharmony_ci#define POSTING_READ(reg__)	__I915_REG_OP(posting_read, dev_priv, (reg__))
19778c2ecf20Sopenharmony_ci
19788c2ecf20Sopenharmony_ci/* These are untraced mmio-accessors that are only valid to be used inside
19798c2ecf20Sopenharmony_ci * critical sections, such as inside IRQ handlers, where forcewake is explicitly
19808c2ecf20Sopenharmony_ci * controlled.
19818c2ecf20Sopenharmony_ci *
19828c2ecf20Sopenharmony_ci * Think twice, and think again, before using these.
19838c2ecf20Sopenharmony_ci *
19848c2ecf20Sopenharmony_ci * As an example, these accessors can possibly be used between:
19858c2ecf20Sopenharmony_ci *
19868c2ecf20Sopenharmony_ci * spin_lock_irq(&dev_priv->uncore.lock);
19878c2ecf20Sopenharmony_ci * intel_uncore_forcewake_get__locked();
19888c2ecf20Sopenharmony_ci *
19898c2ecf20Sopenharmony_ci * and
19908c2ecf20Sopenharmony_ci *
19918c2ecf20Sopenharmony_ci * intel_uncore_forcewake_put__locked();
19928c2ecf20Sopenharmony_ci * spin_unlock_irq(&dev_priv->uncore.lock);
19938c2ecf20Sopenharmony_ci *
19948c2ecf20Sopenharmony_ci *
19958c2ecf20Sopenharmony_ci * Note: some registers may not need forcewake held, so
19968c2ecf20Sopenharmony_ci * intel_uncore_forcewake_{get,put} can be omitted, see
19978c2ecf20Sopenharmony_ci * intel_uncore_forcewake_for_reg().
19988c2ecf20Sopenharmony_ci *
19998c2ecf20Sopenharmony_ci * Certain architectures will die if the same cacheline is concurrently accessed
20008c2ecf20Sopenharmony_ci * by different clients (e.g. on Ivybridge). Access to registers should
20018c2ecf20Sopenharmony_ci * therefore generally be serialised, by either the dev_priv->uncore.lock or
20028c2ecf20Sopenharmony_ci * a more localised lock guarding all access to that bank of registers.
20038c2ecf20Sopenharmony_ci */
20048c2ecf20Sopenharmony_ci#define I915_READ_FW(reg__) __I915_REG_OP(read_fw, dev_priv, (reg__))
20058c2ecf20Sopenharmony_ci#define I915_WRITE_FW(reg__, val__) __I915_REG_OP(write_fw, dev_priv, (reg__), (val__))
20068c2ecf20Sopenharmony_ci
20078c2ecf20Sopenharmony_ci/* i915_mm.c */
20088c2ecf20Sopenharmony_ciint remap_io_mapping(struct vm_area_struct *vma,
20098c2ecf20Sopenharmony_ci		     unsigned long addr, unsigned long pfn, unsigned long size,
20108c2ecf20Sopenharmony_ci		     struct io_mapping *iomap);
20118c2ecf20Sopenharmony_ciint remap_io_sg(struct vm_area_struct *vma,
20128c2ecf20Sopenharmony_ci		unsigned long addr, unsigned long size,
20138c2ecf20Sopenharmony_ci		struct scatterlist *sgl, resource_size_t iobase);
20148c2ecf20Sopenharmony_ci
20158c2ecf20Sopenharmony_cistatic inline int intel_hws_csb_write_index(struct drm_i915_private *i915)
20168c2ecf20Sopenharmony_ci{
20178c2ecf20Sopenharmony_ci	if (INTEL_GEN(i915) >= 10)
20188c2ecf20Sopenharmony_ci		return CNL_HWS_CSB_WRITE_INDEX;
20198c2ecf20Sopenharmony_ci	else
20208c2ecf20Sopenharmony_ci		return I915_HWS_CSB_WRITE_INDEX;
20218c2ecf20Sopenharmony_ci}
20228c2ecf20Sopenharmony_ci
20238c2ecf20Sopenharmony_cistatic inline enum i915_map_type
20248c2ecf20Sopenharmony_cii915_coherent_map_type(struct drm_i915_private *i915)
20258c2ecf20Sopenharmony_ci{
20268c2ecf20Sopenharmony_ci	return HAS_LLC(i915) ? I915_MAP_WB : I915_MAP_WC;
20278c2ecf20Sopenharmony_ci}
20288c2ecf20Sopenharmony_ci
20298c2ecf20Sopenharmony_cistatic inline u64 i915_cs_timestamp_ns_to_ticks(struct drm_i915_private *i915, u64 val)
20308c2ecf20Sopenharmony_ci{
20318c2ecf20Sopenharmony_ci	return DIV_ROUND_UP_ULL(val * RUNTIME_INFO(i915)->cs_timestamp_frequency_hz,
20328c2ecf20Sopenharmony_ci				1000000000);
20338c2ecf20Sopenharmony_ci}
20348c2ecf20Sopenharmony_ci
20358c2ecf20Sopenharmony_cistatic inline u64 i915_cs_timestamp_ticks_to_ns(struct drm_i915_private *i915, u64 val)
20368c2ecf20Sopenharmony_ci{
20378c2ecf20Sopenharmony_ci	return div_u64(val * 1000000000,
20388c2ecf20Sopenharmony_ci		       RUNTIME_INFO(i915)->cs_timestamp_frequency_hz);
20398c2ecf20Sopenharmony_ci}
20408c2ecf20Sopenharmony_ci
20418c2ecf20Sopenharmony_ci#endif
2042