xref: /openbmc/linux/drivers/gpu/drm/i915/gvt/execlist.h (revision d0034a7a4ac7fae708146ac0059b9c47a1543f0d)
18453d674SZhi Wang /*
28453d674SZhi Wang  * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
38453d674SZhi Wang  *
48453d674SZhi Wang  * Permission is hereby granted, free of charge, to any person obtaining a
58453d674SZhi Wang  * copy of this software and associated documentation files (the "Software"),
68453d674SZhi Wang  * to deal in the Software without restriction, including without limitation
78453d674SZhi Wang  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88453d674SZhi Wang  * and/or sell copies of the Software, and to permit persons to whom the
98453d674SZhi Wang  * Software is furnished to do so, subject to the following conditions:
108453d674SZhi Wang  *
118453d674SZhi Wang  * The above copyright notice and this permission notice (including the next
128453d674SZhi Wang  * paragraph) shall be included in all copies or substantial portions of the
138453d674SZhi Wang  * Software.
148453d674SZhi Wang  *
158453d674SZhi Wang  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168453d674SZhi Wang  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178453d674SZhi Wang  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
188453d674SZhi Wang  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198453d674SZhi Wang  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
208453d674SZhi Wang  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
218453d674SZhi Wang  * SOFTWARE.
228453d674SZhi Wang  *
238453d674SZhi Wang  * Authors:
248453d674SZhi Wang  *    Zhiyuan Lv <zhiyuan.lv@intel.com>
258453d674SZhi Wang  *    Zhi Wang <zhi.a.wang@intel.com>
268453d674SZhi Wang  *
278453d674SZhi Wang  * Contributors:
288453d674SZhi Wang  *    Min He <min.he@intel.com>
298453d674SZhi Wang  *    Bing Niu <bing.niu@intel.com>
308453d674SZhi Wang  *    Ping Gao <ping.a.gao@intel.com>
318453d674SZhi Wang  *    Tina Zhang <tina.zhang@intel.com>
328453d674SZhi Wang  *
338453d674SZhi Wang  */
348453d674SZhi Wang 
358453d674SZhi Wang #ifndef _GVT_EXECLIST_H_
368453d674SZhi Wang #define _GVT_EXECLIST_H_
378453d674SZhi Wang 
38ab11a927SMasahiro Yamada #include <linux/types.h>
39ab11a927SMasahiro Yamada 
408453d674SZhi Wang struct execlist_ctx_descriptor_format {
418453d674SZhi Wang 	union {
428453d674SZhi Wang 		u32 ldw;
438453d674SZhi Wang 		struct {
448453d674SZhi Wang 			u32 valid                  : 1;
458453d674SZhi Wang 			u32 force_pd_restore       : 1;
468453d674SZhi Wang 			u32 force_restore          : 1;
478453d674SZhi Wang 			u32 addressing_mode        : 2;
488453d674SZhi Wang 			u32 llc_coherency          : 1;
498453d674SZhi Wang 			u32 fault_handling         : 2;
508453d674SZhi Wang 			u32 privilege_access       : 1;
518453d674SZhi Wang 			u32 reserved               : 3;
528453d674SZhi Wang 			u32 lrca                   : 20;
538453d674SZhi Wang 		};
548453d674SZhi Wang 	};
5554cff647SZhi Wang 	union {
5654cff647SZhi Wang 		u32 udw;
5754cff647SZhi Wang 		u32 context_id;
5854cff647SZhi Wang 	};
598453d674SZhi Wang };
608453d674SZhi Wang 
618453d674SZhi Wang struct execlist_status_format {
628453d674SZhi Wang 	union {
638453d674SZhi Wang 		u32 ldw;
648453d674SZhi Wang 		struct {
658453d674SZhi Wang 			u32 current_execlist_pointer       :1;
668453d674SZhi Wang 			u32 execlist_write_pointer         :1;
678453d674SZhi Wang 			u32 execlist_queue_full            :1;
688453d674SZhi Wang 			u32 execlist_1_valid               :1;
698453d674SZhi Wang 			u32 execlist_0_valid               :1;
708453d674SZhi Wang 			u32 last_ctx_switch_reason         :9;
718453d674SZhi Wang 			u32 current_active_elm_status      :2;
728453d674SZhi Wang 			u32 arbitration_enable             :1;
738453d674SZhi Wang 			u32 execlist_1_active              :1;
748453d674SZhi Wang 			u32 execlist_0_active              :1;
758453d674SZhi Wang 			u32 reserved                       :13;
768453d674SZhi Wang 		};
778453d674SZhi Wang 	};
788453d674SZhi Wang 	union {
798453d674SZhi Wang 		u32 udw;
808453d674SZhi Wang 		u32 context_id;
818453d674SZhi Wang 	};
828453d674SZhi Wang };
838453d674SZhi Wang 
848453d674SZhi Wang struct execlist_context_status_pointer_format {
858453d674SZhi Wang 	union {
868453d674SZhi Wang 		u32 dw;
878453d674SZhi Wang 		struct {
888453d674SZhi Wang 			u32 write_ptr              :3;
898453d674SZhi Wang 			u32 reserved               :5;
908453d674SZhi Wang 			u32 read_ptr               :3;
918453d674SZhi Wang 			u32 reserved2              :5;
928453d674SZhi Wang 			u32 mask                   :16;
938453d674SZhi Wang 		};
948453d674SZhi Wang 	};
958453d674SZhi Wang };
968453d674SZhi Wang 
978453d674SZhi Wang struct execlist_context_status_format {
988453d674SZhi Wang 	union {
998453d674SZhi Wang 		u32 ldw;
1008453d674SZhi Wang 		struct {
1018453d674SZhi Wang 			u32 idle_to_active         :1;
1028453d674SZhi Wang 			u32 preempted              :1;
1038453d674SZhi Wang 			u32 element_switch         :1;
1048453d674SZhi Wang 			u32 active_to_idle         :1;
1058453d674SZhi Wang 			u32 context_complete       :1;
1068453d674SZhi Wang 			u32 wait_on_sync_flip      :1;
1078453d674SZhi Wang 			u32 wait_on_vblank         :1;
1088453d674SZhi Wang 			u32 wait_on_semaphore      :1;
1098453d674SZhi Wang 			u32 wait_on_scanline       :1;
1108453d674SZhi Wang 			u32 reserved               :2;
1118453d674SZhi Wang 			u32 semaphore_wait_mode    :1;
1128453d674SZhi Wang 			u32 display_plane          :3;
1138453d674SZhi Wang 			u32 lite_restore           :1;
1148453d674SZhi Wang 			u32 reserved_2             :16;
1158453d674SZhi Wang 		};
1168453d674SZhi Wang 	};
1178453d674SZhi Wang 	union {
1188453d674SZhi Wang 		u32 udw;
1198453d674SZhi Wang 		u32 context_id;
1208453d674SZhi Wang 	};
1218453d674SZhi Wang };
1228453d674SZhi Wang 
12328c4c6caSZhi Wang struct execlist_mmio_pair {
12428c4c6caSZhi Wang 	u32 addr;
12528c4c6caSZhi Wang 	u32 val;
12628c4c6caSZhi Wang };
12728c4c6caSZhi Wang 
12828c4c6caSZhi Wang /* The first 52 dwords in register state context */
12928c4c6caSZhi Wang struct execlist_ring_context {
13028c4c6caSZhi Wang 	u32 nop1;
13128c4c6caSZhi Wang 	u32 lri_cmd_1;
13228c4c6caSZhi Wang 	struct execlist_mmio_pair ctx_ctrl;
13328c4c6caSZhi Wang 	struct execlist_mmio_pair ring_header;
13428c4c6caSZhi Wang 	struct execlist_mmio_pair ring_tail;
13528c4c6caSZhi Wang 	struct execlist_mmio_pair rb_start;
13628c4c6caSZhi Wang 	struct execlist_mmio_pair rb_ctrl;
13728c4c6caSZhi Wang 	struct execlist_mmio_pair bb_cur_head_UDW;
13828c4c6caSZhi Wang 	struct execlist_mmio_pair bb_cur_head_LDW;
13928c4c6caSZhi Wang 	struct execlist_mmio_pair bb_state;
14028c4c6caSZhi Wang 	struct execlist_mmio_pair second_bb_addr_UDW;
14128c4c6caSZhi Wang 	struct execlist_mmio_pair second_bb_addr_LDW;
14228c4c6caSZhi Wang 	struct execlist_mmio_pair second_bb_state;
14328c4c6caSZhi Wang 	struct execlist_mmio_pair bb_per_ctx_ptr;
14428c4c6caSZhi Wang 	struct execlist_mmio_pair rcs_indirect_ctx;
14528c4c6caSZhi Wang 	struct execlist_mmio_pair rcs_indirect_ctx_offset;
14628c4c6caSZhi Wang 	u32 nop2;
14728c4c6caSZhi Wang 	u32 nop3;
14828c4c6caSZhi Wang 	u32 nop4;
14928c4c6caSZhi Wang 	u32 lri_cmd_2;
15028c4c6caSZhi Wang 	struct execlist_mmio_pair ctx_timestamp;
1511417fad7SXinyun Liu 	/*
1521417fad7SXinyun Liu 	 * pdps[8]={ pdp3_UDW, pdp3_LDW, pdp2_UDW, pdp2_LDW,
1531417fad7SXinyun Liu 	 *           pdp1_UDW, pdp1_LDW, pdp0_UDW, pdp0_LDW}
1541417fad7SXinyun Liu 	 */
1551417fad7SXinyun Liu 	struct execlist_mmio_pair pdps[8];
15628c4c6caSZhi Wang };
15728c4c6caSZhi Wang 
15828c4c6caSZhi Wang struct intel_vgpu_elsp_dwords {
15928c4c6caSZhi Wang 	u32 data[4];
16028c4c6caSZhi Wang 	u32 index;
16128c4c6caSZhi Wang };
16228c4c6caSZhi Wang 
1638453d674SZhi Wang struct intel_vgpu_execlist_slot {
1648453d674SZhi Wang 	struct execlist_ctx_descriptor_format ctx[2];
1658453d674SZhi Wang 	u32 index;
1668453d674SZhi Wang };
1678453d674SZhi Wang 
1688453d674SZhi Wang struct intel_vgpu_execlist {
1698453d674SZhi Wang 	struct intel_vgpu_execlist_slot slot[2];
1708453d674SZhi Wang 	struct intel_vgpu_execlist_slot *running_slot;
1718453d674SZhi Wang 	struct intel_vgpu_execlist_slot *pending_slot;
1728453d674SZhi Wang 	struct execlist_ctx_descriptor_format *running_context;
1738453d674SZhi Wang 	struct intel_vgpu *vgpu;
17428c4c6caSZhi Wang 	struct intel_vgpu_elsp_dwords elsp_dwords;
175*8fde4107SChris Wilson 	const struct intel_engine_cs *engine;
1768453d674SZhi Wang };
1778453d674SZhi Wang 
17828c4c6caSZhi Wang void intel_vgpu_clean_execlist(struct intel_vgpu *vgpu);
17928c4c6caSZhi Wang 
1808453d674SZhi Wang int intel_vgpu_init_execlist(struct intel_vgpu *vgpu);
1818453d674SZhi Wang 
182*8fde4107SChris Wilson int intel_vgpu_submit_execlist(struct intel_vgpu *vgpu,
183*8fde4107SChris Wilson 			       const struct intel_engine_cs *engine);
18428c4c6caSZhi Wang 
1858453d674SZhi Wang #endif /*_GVT_EXECLIST_H_*/
186