162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright 2016 Advanced Micro Devices, Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation 762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 1262306a36Sopenharmony_ci * all copies or substantial portions of the Software. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 2162306a36Sopenharmony_ci * 2262306a36Sopenharmony_ci * Author: Monk.liu@amd.com 2362306a36Sopenharmony_ci */ 2462306a36Sopenharmony_ci#ifndef AMDGPU_VIRT_H 2562306a36Sopenharmony_ci#define AMDGPU_VIRT_H 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#include "amdgv_sriovmsg.h" 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define AMDGPU_SRIOV_CAPS_SRIOV_VBIOS (1 << 0) /* vBIOS is sr-iov ready */ 3062306a36Sopenharmony_ci#define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1) /* sr-iov is enabled on this GPU */ 3162306a36Sopenharmony_ci#define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2) /* this GPU is a virtual function */ 3262306a36Sopenharmony_ci#define AMDGPU_PASSTHROUGH_MODE (1 << 3) /* thw whole GPU is pass through for VM */ 3362306a36Sopenharmony_ci#define AMDGPU_SRIOV_CAPS_RUNTIME (1 << 4) /* is out of full access mode */ 3462306a36Sopenharmony_ci#define AMDGPU_VF_MMIO_ACCESS_PROTECT (1 << 5) /* MMIO write access is not allowed in sriov runtime */ 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/* flags for indirect register access path supported by rlcg for sriov */ 3762306a36Sopenharmony_ci#define AMDGPU_RLCG_GC_WRITE_LEGACY (0x8 << 28) 3862306a36Sopenharmony_ci#define AMDGPU_RLCG_GC_WRITE (0x0 << 28) 3962306a36Sopenharmony_ci#define AMDGPU_RLCG_GC_READ (0x1 << 28) 4062306a36Sopenharmony_ci#define AMDGPU_RLCG_MMHUB_WRITE (0x2 << 28) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* error code for indirect register access path supported by rlcg for sriov */ 4362306a36Sopenharmony_ci#define AMDGPU_RLCG_VFGATE_DISABLED 0x4000000 4462306a36Sopenharmony_ci#define AMDGPU_RLCG_WRONG_OPERATION_TYPE 0x2000000 4562306a36Sopenharmony_ci#define AMDGPU_RLCG_REG_NOT_IN_RANGE 0x1000000 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define AMDGPU_RLCG_SCRATCH1_ADDRESS_MASK 0xFFFFF 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* all asic after AI use this offset */ 5062306a36Sopenharmony_ci#define mmRCC_IOV_FUNC_IDENTIFIER 0xDE5 5162306a36Sopenharmony_ci/* tonga/fiji use this offset */ 5262306a36Sopenharmony_ci#define mmBIF_IOV_FUNC_IDENTIFIER 0x1503 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cienum amdgpu_sriov_vf_mode { 5562306a36Sopenharmony_ci SRIOV_VF_MODE_BARE_METAL = 0, 5662306a36Sopenharmony_ci SRIOV_VF_MODE_ONE_VF, 5762306a36Sopenharmony_ci SRIOV_VF_MODE_MULTI_VF, 5862306a36Sopenharmony_ci}; 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_cistruct amdgpu_mm_table { 6162306a36Sopenharmony_ci struct amdgpu_bo *bo; 6262306a36Sopenharmony_ci uint32_t *cpu_addr; 6362306a36Sopenharmony_ci uint64_t gpu_addr; 6462306a36Sopenharmony_ci}; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#define AMDGPU_VF_ERROR_ENTRY_SIZE 16 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci/* struct error_entry - amdgpu VF error information. */ 6962306a36Sopenharmony_cistruct amdgpu_vf_error_buffer { 7062306a36Sopenharmony_ci struct mutex lock; 7162306a36Sopenharmony_ci int read_count; 7262306a36Sopenharmony_ci int write_count; 7362306a36Sopenharmony_ci uint16_t code[AMDGPU_VF_ERROR_ENTRY_SIZE]; 7462306a36Sopenharmony_ci uint16_t flags[AMDGPU_VF_ERROR_ENTRY_SIZE]; 7562306a36Sopenharmony_ci uint64_t data[AMDGPU_VF_ERROR_ENTRY_SIZE]; 7662306a36Sopenharmony_ci}; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_cienum idh_request; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci/** 8162306a36Sopenharmony_ci * struct amdgpu_virt_ops - amdgpu device virt operations 8262306a36Sopenharmony_ci */ 8362306a36Sopenharmony_cistruct amdgpu_virt_ops { 8462306a36Sopenharmony_ci int (*req_full_gpu)(struct amdgpu_device *adev, bool init); 8562306a36Sopenharmony_ci int (*rel_full_gpu)(struct amdgpu_device *adev, bool init); 8662306a36Sopenharmony_ci int (*req_init_data)(struct amdgpu_device *adev); 8762306a36Sopenharmony_ci int (*reset_gpu)(struct amdgpu_device *adev); 8862306a36Sopenharmony_ci int (*wait_reset)(struct amdgpu_device *adev); 8962306a36Sopenharmony_ci void (*trans_msg)(struct amdgpu_device *adev, enum idh_request req, 9062306a36Sopenharmony_ci u32 data1, u32 data2, u32 data3); 9162306a36Sopenharmony_ci void (*ras_poison_handler)(struct amdgpu_device *adev); 9262306a36Sopenharmony_ci}; 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci/* 9562306a36Sopenharmony_ci * Firmware Reserve Frame buffer 9662306a36Sopenharmony_ci */ 9762306a36Sopenharmony_cistruct amdgpu_virt_fw_reserve { 9862306a36Sopenharmony_ci struct amd_sriov_msg_pf2vf_info_header *p_pf2vf; 9962306a36Sopenharmony_ci struct amd_sriov_msg_vf2pf_info_header *p_vf2pf; 10062306a36Sopenharmony_ci unsigned int checksum_key; 10162306a36Sopenharmony_ci}; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci/* 10462306a36Sopenharmony_ci * Legacy GIM header 10562306a36Sopenharmony_ci * 10662306a36Sopenharmony_ci * Defination between PF and VF 10762306a36Sopenharmony_ci * Structures forcibly aligned to 4 to keep the same style as PF. 10862306a36Sopenharmony_ci */ 10962306a36Sopenharmony_ci#define AMDGIM_DATAEXCHANGE_OFFSET (64 * 1024) 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci#define AMDGIM_GET_STRUCTURE_RESERVED_SIZE(total, u8, u16, u32, u64) \ 11262306a36Sopenharmony_ci (total - (((u8)+3) / 4 + ((u16)+1) / 2 + (u32) + (u64)*2)) 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_cienum AMDGIM_FEATURE_FLAG { 11562306a36Sopenharmony_ci /* GIM supports feature of Error log collecting */ 11662306a36Sopenharmony_ci AMDGIM_FEATURE_ERROR_LOG_COLLECT = 0x1, 11762306a36Sopenharmony_ci /* GIM supports feature of loading uCodes */ 11862306a36Sopenharmony_ci AMDGIM_FEATURE_GIM_LOAD_UCODES = 0x2, 11962306a36Sopenharmony_ci /* VRAM LOST by GIM */ 12062306a36Sopenharmony_ci AMDGIM_FEATURE_GIM_FLR_VRAMLOST = 0x4, 12162306a36Sopenharmony_ci /* MM bandwidth */ 12262306a36Sopenharmony_ci AMDGIM_FEATURE_GIM_MM_BW_MGR = 0x8, 12362306a36Sopenharmony_ci /* PP ONE VF MODE in GIM */ 12462306a36Sopenharmony_ci AMDGIM_FEATURE_PP_ONE_VF = (1 << 4), 12562306a36Sopenharmony_ci /* Indirect Reg Access enabled */ 12662306a36Sopenharmony_ci AMDGIM_FEATURE_INDIRECT_REG_ACCESS = (1 << 5), 12762306a36Sopenharmony_ci /* AV1 Support MODE*/ 12862306a36Sopenharmony_ci AMDGIM_FEATURE_AV1_SUPPORT = (1 << 6), 12962306a36Sopenharmony_ci}; 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_cienum AMDGIM_REG_ACCESS_FLAG { 13262306a36Sopenharmony_ci /* Use PSP to program IH_RB_CNTL */ 13362306a36Sopenharmony_ci AMDGIM_FEATURE_IH_REG_PSP_EN = (1 << 0), 13462306a36Sopenharmony_ci /* Use RLC to program MMHUB regs */ 13562306a36Sopenharmony_ci AMDGIM_FEATURE_MMHUB_REG_RLC_EN = (1 << 1), 13662306a36Sopenharmony_ci /* Use RLC to program GC regs */ 13762306a36Sopenharmony_ci AMDGIM_FEATURE_GC_REG_RLC_EN = (1 << 2), 13862306a36Sopenharmony_ci}; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_cistruct amdgim_pf2vf_info_v1 { 14162306a36Sopenharmony_ci /* header contains size and version */ 14262306a36Sopenharmony_ci struct amd_sriov_msg_pf2vf_info_header header; 14362306a36Sopenharmony_ci /* max_width * max_height */ 14462306a36Sopenharmony_ci unsigned int uvd_enc_max_pixels_count; 14562306a36Sopenharmony_ci /* 16x16 pixels/sec, codec independent */ 14662306a36Sopenharmony_ci unsigned int uvd_enc_max_bandwidth; 14762306a36Sopenharmony_ci /* max_width * max_height */ 14862306a36Sopenharmony_ci unsigned int vce_enc_max_pixels_count; 14962306a36Sopenharmony_ci /* 16x16 pixels/sec, codec independent */ 15062306a36Sopenharmony_ci unsigned int vce_enc_max_bandwidth; 15162306a36Sopenharmony_ci /* MEC FW position in kb from the start of visible frame buffer */ 15262306a36Sopenharmony_ci unsigned int mecfw_kboffset; 15362306a36Sopenharmony_ci /* The features flags of the GIM driver supports. */ 15462306a36Sopenharmony_ci unsigned int feature_flags; 15562306a36Sopenharmony_ci /* use private key from mailbox 2 to create chueksum */ 15662306a36Sopenharmony_ci unsigned int checksum; 15762306a36Sopenharmony_ci} __aligned(4); 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_cistruct amdgim_vf2pf_info_v1 { 16062306a36Sopenharmony_ci /* header contains size and version */ 16162306a36Sopenharmony_ci struct amd_sriov_msg_vf2pf_info_header header; 16262306a36Sopenharmony_ci /* driver version */ 16362306a36Sopenharmony_ci char driver_version[64]; 16462306a36Sopenharmony_ci /* driver certification, 1=WHQL, 0=None */ 16562306a36Sopenharmony_ci unsigned int driver_cert; 16662306a36Sopenharmony_ci /* guest OS type and version: need a define */ 16762306a36Sopenharmony_ci unsigned int os_info; 16862306a36Sopenharmony_ci /* in the unit of 1M */ 16962306a36Sopenharmony_ci unsigned int fb_usage; 17062306a36Sopenharmony_ci /* guest gfx engine usage percentage */ 17162306a36Sopenharmony_ci unsigned int gfx_usage; 17262306a36Sopenharmony_ci /* guest gfx engine health percentage */ 17362306a36Sopenharmony_ci unsigned int gfx_health; 17462306a36Sopenharmony_ci /* guest compute engine usage percentage */ 17562306a36Sopenharmony_ci unsigned int compute_usage; 17662306a36Sopenharmony_ci /* guest compute engine health percentage */ 17762306a36Sopenharmony_ci unsigned int compute_health; 17862306a36Sopenharmony_ci /* guest vce engine usage percentage. 0xffff means N/A. */ 17962306a36Sopenharmony_ci unsigned int vce_enc_usage; 18062306a36Sopenharmony_ci /* guest vce engine health percentage. 0xffff means N/A. */ 18162306a36Sopenharmony_ci unsigned int vce_enc_health; 18262306a36Sopenharmony_ci /* guest uvd engine usage percentage. 0xffff means N/A. */ 18362306a36Sopenharmony_ci unsigned int uvd_enc_usage; 18462306a36Sopenharmony_ci /* guest uvd engine usage percentage. 0xffff means N/A. */ 18562306a36Sopenharmony_ci unsigned int uvd_enc_health; 18662306a36Sopenharmony_ci unsigned int checksum; 18762306a36Sopenharmony_ci} __aligned(4); 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_cistruct amdgim_vf2pf_info_v2 { 19062306a36Sopenharmony_ci /* header contains size and version */ 19162306a36Sopenharmony_ci struct amd_sriov_msg_vf2pf_info_header header; 19262306a36Sopenharmony_ci uint32_t checksum; 19362306a36Sopenharmony_ci /* driver version */ 19462306a36Sopenharmony_ci uint8_t driver_version[64]; 19562306a36Sopenharmony_ci /* driver certification, 1=WHQL, 0=None */ 19662306a36Sopenharmony_ci uint32_t driver_cert; 19762306a36Sopenharmony_ci /* guest OS type and version: need a define */ 19862306a36Sopenharmony_ci uint32_t os_info; 19962306a36Sopenharmony_ci /* in the unit of 1M */ 20062306a36Sopenharmony_ci uint32_t fb_usage; 20162306a36Sopenharmony_ci /* guest gfx engine usage percentage */ 20262306a36Sopenharmony_ci uint32_t gfx_usage; 20362306a36Sopenharmony_ci /* guest gfx engine health percentage */ 20462306a36Sopenharmony_ci uint32_t gfx_health; 20562306a36Sopenharmony_ci /* guest compute engine usage percentage */ 20662306a36Sopenharmony_ci uint32_t compute_usage; 20762306a36Sopenharmony_ci /* guest compute engine health percentage */ 20862306a36Sopenharmony_ci uint32_t compute_health; 20962306a36Sopenharmony_ci /* guest vce engine usage percentage. 0xffff means N/A. */ 21062306a36Sopenharmony_ci uint32_t vce_enc_usage; 21162306a36Sopenharmony_ci /* guest vce engine health percentage. 0xffff means N/A. */ 21262306a36Sopenharmony_ci uint32_t vce_enc_health; 21362306a36Sopenharmony_ci /* guest uvd engine usage percentage. 0xffff means N/A. */ 21462306a36Sopenharmony_ci uint32_t uvd_enc_usage; 21562306a36Sopenharmony_ci /* guest uvd engine usage percentage. 0xffff means N/A. */ 21662306a36Sopenharmony_ci uint32_t uvd_enc_health; 21762306a36Sopenharmony_ci uint32_t reserved[AMDGIM_GET_STRUCTURE_RESERVED_SIZE(256, 64, 0, (12 + sizeof(struct amd_sriov_msg_vf2pf_info_header)/sizeof(uint32_t)), 0)]; 21862306a36Sopenharmony_ci} __aligned(4); 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_cistruct amdgpu_virt_ras_err_handler_data { 22162306a36Sopenharmony_ci /* point to bad page records array */ 22262306a36Sopenharmony_ci struct eeprom_table_record *bps; 22362306a36Sopenharmony_ci /* point to reserved bo array */ 22462306a36Sopenharmony_ci struct amdgpu_bo **bps_bo; 22562306a36Sopenharmony_ci /* the count of entries */ 22662306a36Sopenharmony_ci int count; 22762306a36Sopenharmony_ci /* last reserved entry's index + 1 */ 22862306a36Sopenharmony_ci int last_reserved; 22962306a36Sopenharmony_ci}; 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci/* GPU virtualization */ 23262306a36Sopenharmony_cistruct amdgpu_virt { 23362306a36Sopenharmony_ci uint32_t caps; 23462306a36Sopenharmony_ci struct amdgpu_bo *csa_obj; 23562306a36Sopenharmony_ci void *csa_cpu_addr; 23662306a36Sopenharmony_ci bool chained_ib_support; 23762306a36Sopenharmony_ci uint32_t reg_val_offs; 23862306a36Sopenharmony_ci struct amdgpu_irq_src ack_irq; 23962306a36Sopenharmony_ci struct amdgpu_irq_src rcv_irq; 24062306a36Sopenharmony_ci struct work_struct flr_work; 24162306a36Sopenharmony_ci struct amdgpu_mm_table mm_table; 24262306a36Sopenharmony_ci const struct amdgpu_virt_ops *ops; 24362306a36Sopenharmony_ci struct amdgpu_vf_error_buffer vf_errors; 24462306a36Sopenharmony_ci struct amdgpu_virt_fw_reserve fw_reserve; 24562306a36Sopenharmony_ci uint32_t gim_feature; 24662306a36Sopenharmony_ci uint32_t reg_access_mode; 24762306a36Sopenharmony_ci int req_init_data_ver; 24862306a36Sopenharmony_ci bool tdr_debug; 24962306a36Sopenharmony_ci struct amdgpu_virt_ras_err_handler_data *virt_eh_data; 25062306a36Sopenharmony_ci bool ras_init_done; 25162306a36Sopenharmony_ci uint32_t reg_access; 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci /* vf2pf message */ 25462306a36Sopenharmony_ci struct delayed_work vf2pf_work; 25562306a36Sopenharmony_ci uint32_t vf2pf_update_interval_ms; 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci /* multimedia bandwidth config */ 25862306a36Sopenharmony_ci bool is_mm_bw_enabled; 25962306a36Sopenharmony_ci uint32_t decode_max_dimension_pixels; 26062306a36Sopenharmony_ci uint32_t decode_max_frame_pixels; 26162306a36Sopenharmony_ci uint32_t encode_max_dimension_pixels; 26262306a36Sopenharmony_ci uint32_t encode_max_frame_pixels; 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_ci /* the ucode id to signal the autoload */ 26562306a36Sopenharmony_ci uint32_t autoload_ucode_id; 26662306a36Sopenharmony_ci}; 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_cistruct amdgpu_video_codec_info; 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci#define amdgpu_sriov_enabled(adev) \ 27162306a36Sopenharmony_ci((adev)->virt.caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV) 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci#define amdgpu_sriov_vf(adev) \ 27462306a36Sopenharmony_ci((adev)->virt.caps & AMDGPU_SRIOV_CAPS_IS_VF) 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci#define amdgpu_sriov_bios(adev) \ 27762306a36Sopenharmony_ci((adev)->virt.caps & AMDGPU_SRIOV_CAPS_SRIOV_VBIOS) 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci#define amdgpu_sriov_runtime(adev) \ 28062306a36Sopenharmony_ci((adev)->virt.caps & AMDGPU_SRIOV_CAPS_RUNTIME) 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ci#define amdgpu_sriov_fullaccess(adev) \ 28362306a36Sopenharmony_ci(amdgpu_sriov_vf((adev)) && !amdgpu_sriov_runtime((adev))) 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ci#define amdgpu_sriov_reg_indirect_en(adev) \ 28662306a36Sopenharmony_ci(amdgpu_sriov_vf((adev)) && \ 28762306a36Sopenharmony_ci ((adev)->virt.gim_feature & (AMDGIM_FEATURE_INDIRECT_REG_ACCESS))) 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_ci#define amdgpu_sriov_reg_indirect_ih(adev) \ 29062306a36Sopenharmony_ci(amdgpu_sriov_vf((adev)) && \ 29162306a36Sopenharmony_ci ((adev)->virt.reg_access & (AMDGIM_FEATURE_IH_REG_PSP_EN))) 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci#define amdgpu_sriov_reg_indirect_mmhub(adev) \ 29462306a36Sopenharmony_ci(amdgpu_sriov_vf((adev)) && \ 29562306a36Sopenharmony_ci ((adev)->virt.reg_access & (AMDGIM_FEATURE_MMHUB_REG_RLC_EN))) 29662306a36Sopenharmony_ci 29762306a36Sopenharmony_ci#define amdgpu_sriov_reg_indirect_gc(adev) \ 29862306a36Sopenharmony_ci(amdgpu_sriov_vf((adev)) && \ 29962306a36Sopenharmony_ci ((adev)->virt.reg_access & (AMDGIM_FEATURE_GC_REG_RLC_EN))) 30062306a36Sopenharmony_ci 30162306a36Sopenharmony_ci#define amdgpu_sriov_rlcg_error_report_enabled(adev) \ 30262306a36Sopenharmony_ci (amdgpu_sriov_reg_indirect_mmhub(adev) || amdgpu_sriov_reg_indirect_gc(adev)) 30362306a36Sopenharmony_ci 30462306a36Sopenharmony_ci#define amdgpu_passthrough(adev) \ 30562306a36Sopenharmony_ci((adev)->virt.caps & AMDGPU_PASSTHROUGH_MODE) 30662306a36Sopenharmony_ci 30762306a36Sopenharmony_ci#define amdgpu_sriov_vf_mmio_access_protection(adev) \ 30862306a36Sopenharmony_ci((adev)->virt.caps & AMDGPU_VF_MMIO_ACCESS_PROTECT) 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_cistatic inline bool is_virtual_machine(void) 31162306a36Sopenharmony_ci{ 31262306a36Sopenharmony_ci#if defined(CONFIG_X86) 31362306a36Sopenharmony_ci return boot_cpu_has(X86_FEATURE_HYPERVISOR); 31462306a36Sopenharmony_ci#elif defined(CONFIG_ARM64) 31562306a36Sopenharmony_ci return !is_kernel_in_hyp_mode(); 31662306a36Sopenharmony_ci#else 31762306a36Sopenharmony_ci return false; 31862306a36Sopenharmony_ci#endif 31962306a36Sopenharmony_ci} 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_ci#define amdgpu_sriov_is_pp_one_vf(adev) \ 32262306a36Sopenharmony_ci ((adev)->virt.gim_feature & AMDGIM_FEATURE_PP_ONE_VF) 32362306a36Sopenharmony_ci#define amdgpu_sriov_is_debug(adev) \ 32462306a36Sopenharmony_ci ((!amdgpu_in_reset(adev)) && adev->virt.tdr_debug) 32562306a36Sopenharmony_ci#define amdgpu_sriov_is_normal(adev) \ 32662306a36Sopenharmony_ci ((!amdgpu_in_reset(adev)) && (!adev->virt.tdr_debug)) 32762306a36Sopenharmony_ci#define amdgpu_sriov_is_av1_support(adev) \ 32862306a36Sopenharmony_ci ((adev)->virt.gim_feature & AMDGIM_FEATURE_AV1_SUPPORT) 32962306a36Sopenharmony_cibool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev); 33062306a36Sopenharmony_civoid amdgpu_virt_init_setting(struct amdgpu_device *adev); 33162306a36Sopenharmony_civoid amdgpu_virt_kiq_reg_write_reg_wait(struct amdgpu_device *adev, 33262306a36Sopenharmony_ci uint32_t reg0, uint32_t rreg1, 33362306a36Sopenharmony_ci uint32_t ref, uint32_t mask); 33462306a36Sopenharmony_ciint amdgpu_virt_request_full_gpu(struct amdgpu_device *adev, bool init); 33562306a36Sopenharmony_ciint amdgpu_virt_release_full_gpu(struct amdgpu_device *adev, bool init); 33662306a36Sopenharmony_ciint amdgpu_virt_reset_gpu(struct amdgpu_device *adev); 33762306a36Sopenharmony_civoid amdgpu_virt_request_init_data(struct amdgpu_device *adev); 33862306a36Sopenharmony_ciint amdgpu_virt_wait_reset(struct amdgpu_device *adev); 33962306a36Sopenharmony_ciint amdgpu_virt_alloc_mm_table(struct amdgpu_device *adev); 34062306a36Sopenharmony_civoid amdgpu_virt_free_mm_table(struct amdgpu_device *adev); 34162306a36Sopenharmony_civoid amdgpu_virt_release_ras_err_handler_data(struct amdgpu_device *adev); 34262306a36Sopenharmony_civoid amdgpu_virt_init_data_exchange(struct amdgpu_device *adev); 34362306a36Sopenharmony_civoid amdgpu_virt_exchange_data(struct amdgpu_device *adev); 34462306a36Sopenharmony_civoid amdgpu_virt_fini_data_exchange(struct amdgpu_device *adev); 34562306a36Sopenharmony_civoid amdgpu_detect_virtualization(struct amdgpu_device *adev); 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_cibool amdgpu_virt_can_access_debugfs(struct amdgpu_device *adev); 34862306a36Sopenharmony_ciint amdgpu_virt_enable_access_debugfs(struct amdgpu_device *adev); 34962306a36Sopenharmony_civoid amdgpu_virt_disable_access_debugfs(struct amdgpu_device *adev); 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_cienum amdgpu_sriov_vf_mode amdgpu_virt_get_sriov_vf_mode(struct amdgpu_device *adev); 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_civoid amdgpu_virt_update_sriov_video_codec(struct amdgpu_device *adev, 35462306a36Sopenharmony_ci struct amdgpu_video_codec_info *encode, uint32_t encode_array_size, 35562306a36Sopenharmony_ci struct amdgpu_video_codec_info *decode, uint32_t decode_array_size); 35662306a36Sopenharmony_civoid amdgpu_sriov_wreg(struct amdgpu_device *adev, 35762306a36Sopenharmony_ci u32 offset, u32 value, 35862306a36Sopenharmony_ci u32 acc_flags, u32 hwip, u32 xcc_id); 35962306a36Sopenharmony_ciu32 amdgpu_sriov_rreg(struct amdgpu_device *adev, 36062306a36Sopenharmony_ci u32 offset, u32 acc_flags, u32 hwip, u32 xcc_id); 36162306a36Sopenharmony_cibool amdgpu_virt_fw_load_skip_check(struct amdgpu_device *adev, 36262306a36Sopenharmony_ci uint32_t ucode_id); 36362306a36Sopenharmony_civoid amdgpu_virt_post_reset(struct amdgpu_device *adev); 36462306a36Sopenharmony_ci#endif 365