Add support AMD GPU virtualization soultion
Subsystems (2)
cover Add support AMD GPU virtualization soultion
This patch series will enable AMD GPU virtualization and wires it into amdgpu modules.
The code design is base on below ideas:
1. Make virtualization code independent;
2. Self-maintain related GPU virtualization codes;
3. Easy to maintain virtualization codes;
4. Reduce the influence on other amdgpu components;
5. Easy to support different chips;
According to above ideas, make the following changes:
1. Create a new directory for virtualization and put all of related virtualization code into it;
2. Create new IP block to support different virtual features.
3. Create new file for each different hardware;
In the end, the patch series is support serval virtualization features:
1. Support CSA feature;
2. Support Mailbox communication with GPU hypervisor;
3. Support KIQ feature;
Xiangliang Yu (23):
drm/amdgpu: add support kernel interface queue(KIQ) drm/amdgpu: add kiq into compiling
drm/amdgpu: export KIQ interfaces
drm/amdgpu: add new structure for KIQ memory allcation drm/amdgpu/gfx8: add support KIQ for FIJI/TONGA chips drm/amdgpu/gfx8: correct KIQ hdp flush
drm/amdgpu: create new directory for GPU virtualization drm/amdgpu: add new flag for virtual function
drm/amdgpu: enable virtualization feature for FIJI/TONGA drm/amdgpu: export gem va update interface
drm/amdgpu: implement context save area(CSA) feature drm/amdgpu: Insert meta data during submitting IB drm/amdgpu/mxgpu: add support for mailbox communication drm/amdgpu: export two mailbox interface to amdgpu drm/amdgpu/mxgpu: implement register access function with KIQ drm/amdgpu: add flag to indicate VF runtime state drm/amdgpu: export vi common ip block
drm/amdgpu: add new maroc to identify virtualization ip block drm/amdgpu/mxgpu: add implementation of GPU virtualization of VI drm/amdgpu/mxgpu: enable VI virtualization
drm/amdgpu: change golden register program sequence of virtualization drm/amdgpu: do not reset gpu for virtualization drm/amdgpu/mxgpu: add Makefie and Kconfig for GPU virtualization
drivers/gpu/drm/amd/amdgpu/Makefile | 9 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 35 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c | 436 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 34 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 + drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 240 ++++++++++++++- drivers/gpu/drm/amd/amdgpu/vi.c | 8 +- drivers/gpu/drm/amd/amdgpu/vi.h | 2 +- drivers/gpu/drm/amd/amdgpu/vid.h | 2 + drivers/gpu/drm/amd/include/amd_shared.h | 2 + drivers/gpu/drm/amd/mxgpu/Kconfig | 13 + drivers/gpu/drm/amd/mxgpu/Makefile | 11 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c | 105 +++++++ drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 93 ++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 297 ++++++++++++++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c | 110 +++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c | 159 ++++++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 472 +++++++++++++++++++++++++++++ 24 files changed, 2058 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c create mode 100644 drivers/gpu/drm/amd/mxgpu/Kconfig create mode 100644 drivers/gpu/drm/amd/mxgpu/Makefile create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-1-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
PATCH 1/23 drm/amdgpu: add support kernel interface queue(KIQ)
KIQ is queue-memory based initialization method: setup KIQ queue firstly, then send command to KIQ to setup other queues, without accessing registers.
For virtualization, need KIQ to access virtual function registers when running on guest mode.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c | 436 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vid.h | 2 + 2 files changed, 438 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +436 -0
@@ -0,0 +1,436 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +* [email protected] +*/ +#include "amdgpu.h" +#include "vid.h" +#include "vi_structs.h" +#include "gca/gfx_8_0_d.h" +#include "gca/gfx_8_0_sh_mask.h" + +enum amdgpu_kiq_irq { +AMDGPU_CP_KIQ_IRQ_DRIVER0 =0 , +AMDGPU_CP_KIQ_IRQ_LAST +}; + +int amdgpu_kiq_init_ring (struct amdgpu_device *adev,struct amdgpu_ring *ring, +struct amdgpu_irq_src *irq) +{ +int r =0 ; + + ring->adev =NULL ; + ring->ring_obj =NULL ; + ring->use_doorbell = true; + ring->doorbell_index =AMDGPU_DOORBELL_KIQ ; +if (adev->gfx.mec2_fw) { + ring->me =2 ; + ring->pipe =0 ; + }else { + ring->me =1 ; + ring->pipe =1 ; + } + + irq->data = ring; + ring->queue =0 ; +sprintf (ring->name,"kiq %d.%d.%d" , ring->me, ring->pipe, ring->queue); + r =amdgpu_ring_init (adev, ring,1024 , + irq,AMDGPU_CP_KIQ_IRQ_DRIVER0 ); +if (r) +dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); + +return r; +} + +void amdgpu_kiq_free_ring (struct amdgpu_ring *ring,struct amdgpu_irq_src *irq) +{ +amdgpu_ring_fini (ring); + irq->data =NULL ; +} + +void amdgpu_kiq_enable (struct amdgpu_ring *ring) +{ +uint32_t tmp; +struct amdgpu_device *adev = ring->adev; + +/* tell RLC which is KIQ queue */ + tmp =RREG32 (mmRLC_CP_SCHEDULERS); + tmp &=0xffffff00 ; + tmp |= (ring->me <<5 ) | (ring->pipe <<3 ) | (ring->queue); +WREG32 (mmRLC_CP_SCHEDULERS, tmp); + tmp |=0x80 ; +WREG32 (mmRLC_CP_SCHEDULERS, tmp); +} + +void amdgpu_kiq_start (struct amdgpu_ring *ring) +{ +amdgpu_ring_alloc (ring,8 ); +/* set resources */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_RESOURCES ,6 )); +amdgpu_ring_write (ring,0 );/* vmid_mask:0 queue_type:0 (KIQ) */ +amdgpu_ring_write (ring,0x000000FF );/* queue mask lo */ +amdgpu_ring_write (ring,0 );/* queue mask hi */ +amdgpu_ring_write (ring,0 );/* gws mask lo */ +amdgpu_ring_write (ring,0 );/* gws mask hi */ +amdgpu_ring_write (ring,0 );/* oac mask */ +amdgpu_ring_write (ring,0 );/* gds heap base:0, gds heap size:0 */ +amdgpu_ring_commit (ring); +udelay (50 ); +} + +void amdgpu_kiq_map_queue (struct amdgpu_ring *kiq_ring, +struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = kiq_ring->adev; +uint64_t mqd_addr, wptr_addr; + + mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj); + wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); +amdgpu_ring_alloc (kiq_ring,8 ); + +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_MAP_QUEUES ,5 )); +/* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ +amdgpu_ring_write (kiq_ring,0x21010000 ); +amdgpu_ring_write (kiq_ring, (ring->doorbell_index <<2 ) | + (ring->queue <<26 ) | + (ring->pipe <<29 ) | + ((ring->me ==1 ?0 :1 ) <<31 ));/* doorbell */ +amdgpu_ring_write (kiq_ring,lower_32_bits (mqd_addr)); +amdgpu_ring_write (kiq_ring,upper_32_bits (mqd_addr)); +amdgpu_ring_write (kiq_ring,lower_32_bits (wptr_addr)); +amdgpu_ring_write (kiq_ring,upper_32_bits (wptr_addr)); +amdgpu_ring_commit (kiq_ring); +udelay (50 ); +} + +#define MEC_HPD_SIZE 2048 + +int amdgpu_mqd_init (struct amdgpu_device *adev, +struct vi_mqd *mqd, +uint64_t mqd_gpu_addr, +uint64_t eop_gpu_addr, +struct amdgpu_ring *ring) +{ +uint64_t hqd_gpu_addr, wb_gpu_addr, eop_base_addr; +uint32_t tmp; + + mqd->header =0xC0310800 ; + mqd->compute_pipelinestat_enable =0x00000001 ; + mqd->compute_static_thread_mgmt_se0 =0xffffffff ; + mqd->compute_static_thread_mgmt_se1 =0xffffffff ; + mqd->compute_static_thread_mgmt_se2 =0xffffffff ; + mqd->compute_static_thread_mgmt_se3 =0xffffffff ; + mqd->compute_misc_reserved =0x00000003 ; + + eop_base_addr = eop_gpu_addr >>8 ; + mqd->cp_hqd_eop_base_addr_lo = eop_base_addr; + mqd->cp_hqd_eop_base_addr_hi =upper_32_bits (eop_base_addr); + +/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ + tmp =RREG32 (mmCP_HQD_EOP_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_EOP_CONTROL ,EOP_SIZE , + (order_base_2 (MEC_HPD_SIZE /4 ) -1 )); + + mqd->cp_hqd_eop_control = tmp; + +/* enable doorbell? */ + tmp =RREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL); + +if (ring->use_doorbell) + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,1 ); +else + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,0 ); + + mqd->cp_hqd_pq_doorbell_control = tmp; + +/* disable the queue if it's active */ + mqd->cp_hqd_dequeue_request =0 ; + mqd->cp_hqd_pq_rptr =0 ; + mqd->cp_hqd_pq_wptr =0 ; + +/* set the pointer to the MQD */ + mqd->cp_mqd_base_addr_lo = mqd_gpu_addr &0xfffffffc ; + mqd->cp_mqd_base_addr_hi =upper_32_bits (mqd_gpu_addr); + +/* set MQD vmid to 0 */ + tmp =RREG32 (mmCP_MQD_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_MQD_CONTROL ,VMID ,0 ); + mqd->cp_mqd_control = tmp; + +/* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ + hqd_gpu_addr = ring->gpu_addr >>8 ; + mqd->cp_hqd_pq_base_lo = hqd_gpu_addr; + mqd->cp_hqd_pq_base_hi =upper_32_bits (hqd_gpu_addr); + +/* set up the HQD, this is similar to CP_RB0_CNTL */ + tmp =RREG32 (mmCP_HQD_PQ_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,QUEUE_SIZE , + (order_base_2 (ring->ring_size /4 ) -1 )); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,RPTR_BLOCK_SIZE , + ((order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 ) <<8 )); +#ifdef __BIG_ENDIAN + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ENDIAN_SWAP ,1 ); +#endif + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ROQ_PQ_IB_FLIP ,0 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,PRIV_STATE ,1 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,KMD_QUEUE ,1 ); + mqd->cp_hqd_pq_control = tmp; + +/* set the wb address whether it's enabled or not */ + wb_gpu_addr = adev->wb.gpu_addr + (ring->rptr_offs *4 ); + mqd->cp_hqd_pq_rptr_report_addr_lo = wb_gpu_addr &0xfffffffc ; + mqd->cp_hqd_pq_rptr_report_addr_hi = +upper_32_bits (wb_gpu_addr) &0xffff ; + +/* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */ + wb_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); + mqd->cp_hqd_pq_wptr_poll_addr_lo = wb_gpu_addr &0xfffffffc ; + mqd->cp_hqd_pq_wptr_poll_addr_hi =upper_32_bits (wb_gpu_addr) &0xffff ; + + tmp =0 ; +/* enable the doorbell if requested */ +if (ring->use_doorbell) { + tmp =RREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_OFFSET , ring->doorbell_index); + + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,1 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_SOURCE ,0 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_HIT ,0 ); + } + + mqd->cp_hqd_pq_doorbell_control = tmp; + +/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */ + ring->wptr =0 ; + mqd->cp_hqd_pq_wptr = ring->wptr; + mqd->cp_hqd_pq_rptr =RREG32 (mmCP_HQD_PQ_RPTR); + +/* set the vmid for the queue */ + mqd->cp_hqd_vmid =0 ; + + tmp =RREG32 (mmCP_HQD_PERSISTENT_STATE); + tmp =REG_SET_FIELD (tmp,CP_HQD_PERSISTENT_STATE ,PRELOAD_SIZE ,0x53 ); + mqd->cp_hqd_persistent_state = tmp; + +/* activate the queue */ + mqd->cp_hqd_active =1 ; + +return 0 ; +} + +int amdgpu_kiq_init (struct amdgpu_device *adev, +struct vi_mqd *mqd, +struct amdgpu_ring *ring) +{ +uint32_t tmp; +int j; + +/* disable wptr polling */ + tmp =RREG32 (mmCP_PQ_WPTR_POLL_CNTL); + tmp =REG_SET_FIELD (tmp,CP_PQ_WPTR_POLL_CNTL ,EN ,0 ); +WREG32 (mmCP_PQ_WPTR_POLL_CNTL, tmp); + +WREG32 (mmCP_HQD_EOP_BASE_ADDR, mqd->cp_hqd_eop_base_addr_lo); +WREG32 (mmCP_HQD_EOP_BASE_ADDR_HI, mqd->cp_hqd_eop_base_addr_hi); + +/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ +WREG32 (mmCP_HQD_EOP_CONTROL, mqd->cp_hqd_eop_control); + +/* enable doorbell? */ +WREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL, mqd->cp_hqd_pq_doorbell_control); + +/* disable the queue if it's active */ +if (RREG32 (mmCP_HQD_ACTIVE) &1 ) { +WREG32 (mmCP_HQD_DEQUEUE_REQUEST,1 ); +for (j =0 ; j < adev->usec_timeout; j++) { +if (!(RREG32 (mmCP_HQD_ACTIVE) &1 )) +break ; +udelay (1 ); + } +WREG32 (mmCP_HQD_DEQUEUE_REQUEST, mqd->cp_hqd_dequeue_request); +WREG32 (mmCP_HQD_PQ_RPTR, mqd->cp_hqd_pq_rptr); +WREG32 (mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr); + } + +/* set the pointer to the MQD */ +WREG32 (mmCP_MQD_BASE_ADDR, mqd->cp_mqd_base_addr_lo); +WREG32 (mmCP_MQD_BASE_ADDR_HI, mqd->cp_mqd_base_addr_hi); + +/* set MQD vmid to 0 */ +WREG32 (mmCP_MQD_CONTROL, mqd->cp_mqd_control); + +/* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ +WREG32 (mmCP_HQD_PQ_BASE, mqd->cp_hqd_pq_base_lo); +WREG32 (mmCP_HQD_PQ_BASE_HI, mqd->cp_hqd_pq_base_hi); + +/* set up the HQD, this is similar to CP_RB0_CNTL */ +WREG32 (mmCP_HQD_PQ_CONTROL, mqd->cp_hqd_pq_control); + +/* set the wb address whether it's enabled or not */ +WREG32 (mmCP_HQD_PQ_RPTR_REPORT_ADDR, + mqd->cp_hqd_pq_rptr_report_addr_lo); +WREG32 (mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI, + mqd->cp_hqd_pq_rptr_report_addr_hi); + +/* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */ +WREG32 (mmCP_HQD_PQ_WPTR_POLL_ADDR, mqd->cp_hqd_pq_wptr_poll_addr_lo); +WREG32 (mmCP_HQD_PQ_WPTR_POLL_ADDR_HI, mqd->cp_hqd_pq_wptr_poll_addr_hi); + +/* enable the doorbell if requested */ +if (ring->use_doorbell) { +if ((adev->asic_type ==CHIP_CARRIZO ) || + (adev->asic_type ==CHIP_FIJI ) || + (adev->asic_type ==CHIP_STONEY )) { +WREG32 (mmCP_MEC_DOORBELL_RANGE_LOWER, +AMDGPU_DOORBELL_KIQ <<2 ); +WREG32 (mmCP_MEC_DOORBELL_RANGE_UPPER, +AMDGPU_DOORBELL_MEC_RING7 <<2 ); + } + } +WREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL, mqd->cp_hqd_pq_doorbell_control); + +/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */ +WREG32 (mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr); + +/* set the vmid for the queue */ +WREG32 (mmCP_HQD_VMID, mqd->cp_hqd_vmid); + +WREG32 (mmCP_HQD_PERSISTENT_STATE, mqd->cp_hqd_persistent_state); + +/* activate the queue */ +WREG32 (mmCP_HQD_ACTIVE, mqd->cp_hqd_active); + +if (ring->use_doorbell) { + tmp =RREG32 (mmCP_PQ_STATUS); + tmp =REG_SET_FIELD (tmp,CP_PQ_STATUS ,DOORBELL_ENABLE ,1 ); +WREG32 (mmCP_PQ_STATUS, tmp); + } + +return 0 ; +} + +void amdgpu_kiq_ring_emit_fence (struct amdgpu_ring *ring,u64 addr, +u64 seq,unsigned int flags) +{ +/* we only allocate 32bit for each seq wb address */ +if (flags &AMDGPU_FENCE_FLAG_64BIT ) +BUG (); + +/* write fence seq to the "addr" */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (WRITE_DATA_ENGINE_SEL (0 ) | +WRITE_DATA_DST_SEL (5 ) |WR_CONFIRM )); +amdgpu_ring_write (ring,lower_32_bits (addr)); +amdgpu_ring_write (ring,upper_32_bits (addr)); +amdgpu_ring_write (ring,lower_32_bits (seq)); + +if (flags &AMDGPU_FENCE_FLAG_INT ) { +/* set register to trigger INT */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (WRITE_DATA_ENGINE_SEL (0 ) | +WRITE_DATA_DST_SEL (0 ) |WR_CONFIRM )); +amdgpu_ring_write (ring, mmCPC_INT_STATUS); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,0x20000000 );/* src_id is 178 */ + } +} + +static int amdgpu_kiq_set_interrupt_state (struct amdgpu_device *adev, +struct amdgpu_irq_src *src, +unsigned int type, +enum amdgpu_interrupt_state state) +{ +uint32_t tmp, target; +struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data; + +BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); + + target = (ring->me ==1 ) ? mmCP_ME1_PIPE0_INT_CNTL : mmCP_ME2_PIPE0_INT_CNTL; + target += ring->pipe; + +switch (type) { +case AMDGPU_CP_KIQ_IRQ_DRIVER0 : +if (state ==AMDGPU_IRQ_STATE_DISABLE ) { + tmp =RREG32 (mmCPC_INT_CNTL); + tmp =REG_SET_FIELD (tmp,CPC_INT_CNTL , +GENERIC2_INT_ENABLE ,0 ); +WREG32 (mmCPC_INT_CNTL, tmp); + + tmp =RREG32 (target); + tmp =REG_SET_FIELD (tmp,CP_ME2_PIPE0_INT_CNTL , +GENERIC2_INT_ENABLE ,0 ); +WREG32 (target, tmp); + }else { + tmp =RREG32 (mmCPC_INT_CNTL); + tmp =REG_SET_FIELD (tmp,CPC_INT_CNTL , +GENERIC2_INT_ENABLE ,1 ); +WREG32 (mmCPC_INT_CNTL, tmp); + + tmp =RREG32 (target); + tmp =REG_SET_FIELD (tmp,CP_ME2_PIPE0_INT_CNTL , +GENERIC2_INT_ENABLE ,1 ); +WREG32 (target, tmp); + } +break ; +default : +BUG ();/* kiq only support GENERIC2_INT now */ +break ; + } +return 0 ; +} + +static int amdgpu_kiq_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +u8 me_id, pipe_id, queue_id; +struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data; + +BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); + + me_id = (entry->ring_id &0x0c ) >>2 ; + pipe_id = (entry->ring_id &0x03 ) >>0 ; + queue_id = (entry->ring_id &0x70 ) >>4 ; +DRM_DEBUG ("IH: CPC GENERIC2_INT, me:%d, pipe:%d, queue:%d\n" , + me_id, pipe_id, queue_id); + +amdgpu_fence_process (ring); +return 0 ; +} + +static const struct amdgpu_irq_src_funcs amdgpu_kiq_irq_funcs = { + .set = amdgpu_kiq_set_interrupt_state, + .process = amdgpu_kiq_irq, +}; + +void amdgpu_kiq_set_irq_funcs (struct amdgpu_irq_src *irq) +{ + irq->num_types =AMDGPU_CP_KIQ_IRQ_LAST ; + irq->funcs = &amdgpu_kiq_irq_funcs; +}
drivers/gpu/drm/amd/amdgpu/vid.h +2 -0
@@ -360,6 +360,8 @@#define PACKET3_WAIT_ON_CE_COUNTER 0x86#define PACKET3_WAIT_ON_DE_COUNTER_DIFF 0x88#define PACKET3_SWITCH_BUFFER 0x8B +#define PACKET3_SET_RESOURCES 0xA0 +#define PACKET3_MAP_QUEUES 0xA2#define VCE_CMD_NO_OP 0x00000000#define VCE_CMD_END 0x00000001
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-2-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 01/23] drm/amdgpu: add support kernel interface queue(KIQ)
Quoted 9 lines · Xiangliang Yu
KIQ is queue-memory based initialization method: setup KIQ queue firstly, then send command to KIQ to setup other queues, without accessing registers.
For virtualization, need KIQ to access virtual function registers when running on guest mode.
Signed-off-by Xiangliang Yu <[email protected]>Signed-off-by Monk Liu <[email protected]>
kiq is just another CP ring. Please add the asic specific parts to gfx_v8_0.c. If there is any common KIQ helper code that is non asic dependent, that should be in amdgpu_kiq.c.
Alex
Quoted 464 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c | 436 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vid.h | 2 + 2 files changed, 438 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.cdrivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +436
-0@@ -0,0 +1,436 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +* [email protected] +*/ +#include "amdgpu.h" +#include "vid.h" +#include "vi_structs.h" +#include "gca/gfx_8_0_d.h" +#include "gca/gfx_8_0_sh_mask.h" + +enum amdgpu_kiq_irq { +AMDGPU_CP_KIQ_IRQ_DRIVER0 =0 , +AMDGPU_CP_KIQ_IRQ_LAST +}; + +int amdgpu_kiq_init_ring (struct amdgpu_device *adev,struct amdgpu_ring *ring, +struct amdgpu_irq_src *irq) +{ +int r =0 ; + + ring->adev =NULL ; + ring->ring_obj =NULL ; + ring->use_doorbell = true; + ring->doorbell_index =AMDGPU_DOORBELL_KIQ ; +if (adev->gfx.mec2_fw) { + ring->me =2 ; + ring->pipe =0 ; + }else { + ring->me =1 ; + ring->pipe =1 ; + } + + irq->data = ring; + ring->queue =0 ; +sprintf (ring->name,"kiq %d.%d.%d" , ring->me, ring->pipe, ring->queue); + r =amdgpu_ring_init (adev, ring,1024 , + irq,AMDGPU_CP_KIQ_IRQ_DRIVER0 ); +if (r) +dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); + +return r; +} + +void amdgpu_kiq_free_ring (struct amdgpu_ring *ring,struct amdgpu_irq_src *irq) +{ +amdgpu_ring_fini (ring); + irq->data =NULL ; +} + +void amdgpu_kiq_enable (struct amdgpu_ring *ring) +{ +uint32_t tmp; +struct amdgpu_device *adev = ring->adev; + +/* tell RLC which is KIQ queue */ + tmp =RREG32 (mmRLC_CP_SCHEDULERS); + tmp &=0xffffff00 ; + tmp |= (ring->me <<5 ) | (ring->pipe <<3 ) | (ring->queue); +WREG32 (mmRLC_CP_SCHEDULERS, tmp); + tmp |=0x80 ; +WREG32 (mmRLC_CP_SCHEDULERS, tmp); +} + +void amdgpu_kiq_start (struct amdgpu_ring *ring) +{ +amdgpu_ring_alloc (ring,8 ); +/* set resources */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_RESOURCES ,6 )); +amdgpu_ring_write (ring,0 );/* vmid_mask:0 queue_type:0 (KIQ) */ +amdgpu_ring_write (ring,0x000000FF );/* queue mask lo */ +amdgpu_ring_write (ring,0 );/* queue mask hi */ +amdgpu_ring_write (ring,0 );/* gws mask lo */ +amdgpu_ring_write (ring,0 );/* gws mask hi */ +amdgpu_ring_write (ring,0 );/* oac mask */ +amdgpu_ring_write (ring,0 );/* gds heap base:0, gds heap size:0 */ +amdgpu_ring_commit (ring); +udelay (50 ); +} + +void amdgpu_kiq_map_queue (struct amdgpu_ring *kiq_ring, +struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = kiq_ring->adev; +uint64_t mqd_addr, wptr_addr; + + mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj); + wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); +amdgpu_ring_alloc (kiq_ring,8 ); + +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_MAP_QUEUES ,5 )); +/* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ +amdgpu_ring_write (kiq_ring,0x21010000 ); +amdgpu_ring_write (kiq_ring, (ring->doorbell_index <<2 ) | + (ring->queue <<26 ) | + (ring->pipe <<29 ) | + ((ring->me ==1 ?0 :1 ) <<31 ));/* doorbell */ +amdgpu_ring_write (kiq_ring,lower_32_bits (mqd_addr)); +amdgpu_ring_write (kiq_ring,upper_32_bits (mqd_addr)); +amdgpu_ring_write (kiq_ring,lower_32_bits (wptr_addr)); +amdgpu_ring_write (kiq_ring,upper_32_bits (wptr_addr)); +amdgpu_ring_commit (kiq_ring); +udelay (50 ); +} + +#define MEC_HPD_SIZE 2048 + +int amdgpu_mqd_init (struct amdgpu_device *adev, +struct vi_mqd *mqd, +uint64_t mqd_gpu_addr, +uint64_t eop_gpu_addr, +struct amdgpu_ring *ring) +{ +uint64_t hqd_gpu_addr, wb_gpu_addr, eop_base_addr; +uint32_t tmp; + + mqd->header =0xC0310800 ; + mqd->compute_pipelinestat_enable =0x00000001 ; + mqd->compute_static_thread_mgmt_se0 =0xffffffff ; + mqd->compute_static_thread_mgmt_se1 =0xffffffff ; + mqd->compute_static_thread_mgmt_se2 =0xffffffff ; + mqd->compute_static_thread_mgmt_se3 =0xffffffff ; + mqd->compute_misc_reserved =0x00000003 ; + + eop_base_addr = eop_gpu_addr >>8 ; + mqd->cp_hqd_eop_base_addr_lo = eop_base_addr; + mqd->cp_hqd_eop_base_addr_hi =upper_32_bits (eop_base_addr); + +/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ + tmp =RREG32 (mmCP_HQD_EOP_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_EOP_CONTROL ,EOP_SIZE , + (order_base_2 (MEC_HPD_SIZE /4 ) -1 )); + + mqd->cp_hqd_eop_control = tmp; + +/* enable doorbell? */ + tmp =RREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL); + +if (ring->use_doorbell) + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,1 ); +else + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,0 ); + + mqd->cp_hqd_pq_doorbell_control = tmp; + +/* disable the queue if it's active */ + mqd->cp_hqd_dequeue_request =0 ; + mqd->cp_hqd_pq_rptr =0 ; + mqd->cp_hqd_pq_wptr =0 ; + +/* set the pointer to the MQD */ + mqd->cp_mqd_base_addr_lo = mqd_gpu_addr &0xfffffffc ; + mqd->cp_mqd_base_addr_hi =upper_32_bits (mqd_gpu_addr); + +/* set MQD vmid to 0 */ + tmp =RREG32 (mmCP_MQD_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_MQD_CONTROL ,VMID ,0 ); + mqd->cp_mqd_control = tmp; + +/* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ + hqd_gpu_addr = ring->gpu_addr >>8 ; + mqd->cp_hqd_pq_base_lo = hqd_gpu_addr; + mqd->cp_hqd_pq_base_hi =upper_32_bits (hqd_gpu_addr); + +/* set up the HQD, this is similar to CP_RB0_CNTL */ + tmp =RREG32 (mmCP_HQD_PQ_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,QUEUE_SIZE , + (order_base_2 (ring->ring_size /4 ) -1 )); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,RPTR_BLOCK_SIZE , + ((order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 ) <<8 )); +#ifdef __BIG_ENDIAN + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ENDIAN_SWAP ,1 ); +#endif + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ROQ_PQ_IB_FLIP ,0 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,PRIV_STATE ,1 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,KMD_QUEUE ,1 ); + mqd->cp_hqd_pq_control = tmp; + +/* set the wb address whether it's enabled or not */ + wb_gpu_addr = adev->wb.gpu_addr + (ring->rptr_offs *4 ); + mqd->cp_hqd_pq_rptr_report_addr_lo = wb_gpu_addr &0xfffffffc ; + mqd->cp_hqd_pq_rptr_report_addr_hi = +upper_32_bits (wb_gpu_addr) &0xffff ; + +/* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */ + wb_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); + mqd->cp_hqd_pq_wptr_poll_addr_lo = wb_gpu_addr &0xfffffffc ; + mqd->cp_hqd_pq_wptr_poll_addr_hi =upper_32_bits (wb_gpu_addr) &0xffff ; + + tmp =0 ; +/* enable the doorbell if requested */ +if (ring->use_doorbell) { + tmp =RREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_OFFSET , ring->doorbell_index); + + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,1 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_SOURCE ,0 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_HIT ,0 ); + } + + mqd->cp_hqd_pq_doorbell_control = tmp; + +/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */ + ring->wptr =0 ; + mqd->cp_hqd_pq_wptr = ring->wptr; + mqd->cp_hqd_pq_rptr =RREG32 (mmCP_HQD_PQ_RPTR); + +/* set the vmid for the queue */ + mqd->cp_hqd_vmid =0 ; + + tmp =RREG32 (mmCP_HQD_PERSISTENT_STATE); + tmp =REG_SET_FIELD (tmp,CP_HQD_PERSISTENT_STATE ,PRELOAD_SIZE ,0x53 ); + mqd->cp_hqd_persistent_state = tmp; + +/* activate the queue */ + mqd->cp_hqd_active =1 ; + +return 0 ; +} + +int amdgpu_kiq_init (struct amdgpu_device *adev, +struct vi_mqd *mqd, +struct amdgpu_ring *ring) +{ +uint32_t tmp; +int j; + +/* disable wptr polling */ + tmp =RREG32 (mmCP_PQ_WPTR_POLL_CNTL); + tmp =REG_SET_FIELD (tmp,CP_PQ_WPTR_POLL_CNTL ,EN ,0 ); +WREG32 (mmCP_PQ_WPTR_POLL_CNTL, tmp); + +WREG32 (mmCP_HQD_EOP_BASE_ADDR, mqd->cp_hqd_eop_base_addr_lo); +WREG32 (mmCP_HQD_EOP_BASE_ADDR_HI, mqd->cp_hqd_eop_base_addr_hi); + +/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ +WREG32 (mmCP_HQD_EOP_CONTROL, mqd->cp_hqd_eop_control); + +/* enable doorbell? */ +WREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL, mqd->cp_hqd_pq_doorbell_control); + +/* disable the queue if it's active */ +if (RREG32 (mmCP_HQD_ACTIVE) &1 ) { +WREG32 (mmCP_HQD_DEQUEUE_REQUEST,1 ); +for (j =0 ; j < adev->usec_timeout; j++) { +if (!(RREG32 (mmCP_HQD_ACTIVE) &1 )) +break ; +udelay (1 ); + } +WREG32 (mmCP_HQD_DEQUEUE_REQUEST, mqd->cp_hqd_dequeue_request); +WREG32 (mmCP_HQD_PQ_RPTR, mqd->cp_hqd_pq_rptr); +WREG32 (mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr); + } + +/* set the pointer to the MQD */ +WREG32 (mmCP_MQD_BASE_ADDR, mqd->cp_mqd_base_addr_lo); +WREG32 (mmCP_MQD_BASE_ADDR_HI, mqd->cp_mqd_base_addr_hi); + +/* set MQD vmid to 0 */ +WREG32 (mmCP_MQD_CONTROL, mqd->cp_mqd_control); + +/* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ +WREG32 (mmCP_HQD_PQ_BASE, mqd->cp_hqd_pq_base_lo); +WREG32 (mmCP_HQD_PQ_BASE_HI, mqd->cp_hqd_pq_base_hi); + +/* set up the HQD, this is similar to CP_RB0_CNTL */ +WREG32 (mmCP_HQD_PQ_CONTROL, mqd->cp_hqd_pq_control); + +/* set the wb address whether it's enabled or not */ +WREG32 (mmCP_HQD_PQ_RPTR_REPORT_ADDR, + mqd->cp_hqd_pq_rptr_report_addr_lo); +WREG32 (mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI, + mqd->cp_hqd_pq_rptr_report_addr_hi); + +/* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */ +WREG32 (mmCP_HQD_PQ_WPTR_POLL_ADDR, mqd->cp_hqd_pq_wptr_poll_addr_lo); +WREG32 (mmCP_HQD_PQ_WPTR_POLL_ADDR_HI, mqd->cp_hqd_pq_wptr_poll_addr_hi); + +/* enable the doorbell if requested */ +if (ring->use_doorbell) { +if ((adev->asic_type ==CHIP_CARRIZO ) || + (adev->asic_type ==CHIP_FIJI ) || + (adev->asic_type ==CHIP_STONEY )) { +WREG32 (mmCP_MEC_DOORBELL_RANGE_LOWER, +AMDGPU_DOORBELL_KIQ <<2 ); +WREG32 (mmCP_MEC_DOORBELL_RANGE_UPPER, +AMDGPU_DOORBELL_MEC_RING7 <<2 ); + } + } +WREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL, mqd->cp_hqd_pq_doorbell_control); + +/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */ +WREG32 (mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr); + +/* set the vmid for the queue */ +WREG32 (mmCP_HQD_VMID, mqd->cp_hqd_vmid); + +WREG32 (mmCP_HQD_PERSISTENT_STATE, mqd->cp_hqd_persistent_state); + +/* activate the queue */ +WREG32 (mmCP_HQD_ACTIVE, mqd->cp_hqd_active); + +if (ring->use_doorbell) { + tmp =RREG32 (mmCP_PQ_STATUS); + tmp =REG_SET_FIELD (tmp,CP_PQ_STATUS ,DOORBELL_ENABLE ,1 ); +WREG32 (mmCP_PQ_STATUS, tmp); + } + +return 0 ; +} + +void amdgpu_kiq_ring_emit_fence (struct amdgpu_ring *ring,u64 addr, +u64 seq,unsigned int flags) +{ +/* we only allocate 32bit for each seq wb address */ +if (flags &AMDGPU_FENCE_FLAG_64BIT ) +BUG (); + +/* write fence seq to the "addr" */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (WRITE_DATA_ENGINE_SEL (0 ) | +WRITE_DATA_DST_SEL (5 ) |WR_CONFIRM )); +amdgpu_ring_write (ring,lower_32_bits (addr)); +amdgpu_ring_write (ring,upper_32_bits (addr)); +amdgpu_ring_write (ring,lower_32_bits (seq)); + +if (flags &AMDGPU_FENCE_FLAG_INT ) { +/* set register to trigger INT */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (WRITE_DATA_ENGINE_SEL (0 ) | +WRITE_DATA_DST_SEL (0 ) |WR_CONFIRM )); +amdgpu_ring_write (ring, mmCPC_INT_STATUS); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,0x20000000 );/* src_id is 178 */ + } +} + +static int amdgpu_kiq_set_interrupt_state (struct amdgpu_device *adev, +struct amdgpu_irq_src *src, +unsigned int type, +enum amdgpu_interrupt_state state) +{ +uint32_t tmp, target; +struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data; + +BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); + + target = (ring->me ==1 ) ? mmCP_ME1_PIPE0_INT_CNTL : mmCP_ME2_PIPE0_INT_CNTL; + target += ring->pipe; + +switch (type) { +case AMDGPU_CP_KIQ_IRQ_DRIVER0 : +if (state ==AMDGPU_IRQ_STATE_DISABLE ) { + tmp =RREG32 (mmCPC_INT_CNTL); + tmp =REG_SET_FIELD (tmp,CPC_INT_CNTL , +GENERIC2_INT_ENABLE ,0 ); +WREG32 (mmCPC_INT_CNTL, tmp); + + tmp =RREG32 (target); + tmp =REG_SET_FIELD (tmp,CP_ME2_PIPE0_INT_CNTL , +GENERIC2_INT_ENABLE ,0 ); +WREG32 (target, tmp); + }else { + tmp =RREG32 (mmCPC_INT_CNTL); + tmp =REG_SET_FIELD (tmp,CPC_INT_CNTL , +GENERIC2_INT_ENABLE ,1 ); +WREG32 (mmCPC_INT_CNTL, tmp); + + tmp =RREG32 (target); + tmp =REG_SET_FIELD (tmp,CP_ME2_PIPE0_INT_CNTL , +GENERIC2_INT_ENABLE ,1 ); +WREG32 (target, tmp); + } +break ; +default : +BUG ();/* kiq only support GENERIC2_INT now */ +break ; + } +return 0 ; +} + +static int amdgpu_kiq_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +u8 me_id, pipe_id, queue_id; +struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data; + +BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); + + me_id = (entry->ring_id &0x0c ) >>2 ; + pipe_id = (entry->ring_id &0x03 ) >>0 ; + queue_id = (entry->ring_id &0x70 ) >>4 ; +DRM_DEBUG ("IH: CPC GENERIC2_INT, me:%d, pipe:%d, queue:%d\n" , + me_id, pipe_id, queue_id); + +amdgpu_fence_process (ring); +return 0 ; +} + +static const struct amdgpu_irq_src_funcs amdgpu_kiq_irq_funcs = { + .set = amdgpu_kiq_set_interrupt_state, + .process = amdgpu_kiq_irq, +}; + +void amdgpu_kiq_set_irq_funcs (struct amdgpu_irq_src *irq) +{ + irq->num_types =AMDGPU_CP_KIQ_IRQ_LAST ; + irq->funcs = &amdgpu_kiq_irq_funcs; +}drivers/gpu/drm/amd/amdgpu/vid.h +2
-1@@ -360,6 +360,8 @@#define PACKET3_WAIT_ON_CE_COUNTER 0x86#define PACKET3_WAIT_ON_DE_COUNTER_DIFF 0x88#define PACKET3_SWITCH_BUFFER 0x8B +#define PACKET3_SET_RESOURCES 0xA0 +#define PACKET3_MAP_QUEUES 0xA2#define VCE_CMD_NO_OP 0x00000000#define VCE_CMD_END 0x00000001 --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_P1An3GF9CJAdw5-av7oT0VDAN1YTgni9Q2waT81yyBtQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 01/23] drm/amdgpu: add support kernel interface queue(KIQ)
Quoted 20 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:11 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>; Liu, Monk <[email protected]>
Subject: Re: [PATCH 01/23] drm/amdgpu: add support kernel interface queue(KIQ)Quoted 7 lines · Xiangliang Yu
KIQ is queue-memory based initialization method: setup KIQ queue firstly, then send command to KIQ to setup other queues, without accessing registers.
For virtualization, need KIQ to access virtual function registers when running on guest mode.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Xiangliang Yu <[email protected]>Signed-off-by Monk Liu <[email protected]>kiq is just another CP ring. Please add the asic specific parts to
gfx_v8_0.c. If there is any common KIQ helper code that is non asic dependent, that should be inamdgpu_kiq.c.
You are right, I erroneously think KIQ is not relate to chips, I'll put it into gfx_v8_0.c later.
Quoted 496 lines
Alex
Quoted 2 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c | 436++++++++++++++++++++++++++++++++
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/vid.h | 2 + 2 files changed, 438 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.cdrivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +10
-0@@ -0,0 +1,436 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c line 20
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +10
-0+sublicense, + * and/or sell copies of the Software, and to permit persons to whom +the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be +included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANYKIND,
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c line 24
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c line 30
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +6
-0+SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ORTHE USE
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +8
-0+OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +* [email protected] +*/ +#include "amdgpu.h" +#include "vid.h" drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +10
-0+#include "vi_structs.h" +#include "gca/gfx_8_0_d.h" +#include "gca/gfx_8_0_sh_mask.h" + +enum amdgpu_kiq_irq { +AMDGPU_CP_KIQ_IRQ_DRIVER0 =0 , +AMDGPU_CP_KIQ_IRQ_LAST +}; + +int amdgpu_kiq_init_ring(struct amdgpu_device *adev, struct
amdgpu_ring*ring,Quoted 140 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +18
-0+ struct amdgpu_irq_src *irq) { +int r =0 ; + + ring->adev =NULL ; + ring->ring_obj =NULL ; + ring->use_doorbell = true; + ring->doorbell_index =AMDGPU_DOORBELL_KIQ ; +if (adev->gfx.mec2_fw) { + ring->me =2 ; + ring->pipe =0 ; + }else { + ring->me =1 ; + ring->pipe =1 ; + } + + irq->data = ring; + ring->queue =0 ; + sprintf(ring->name, "kiq %d.%d.%d", ring->me, ring->pipe, ring-queue);
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +121
-0+ r =amdgpu_ring_init (adev, ring,1024 , + irq,AMDGPU_CP_KIQ_IRQ_DRIVER0 ); +if (r) +dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , + r); + +return r; +} + +void amdgpu_kiq_free_ring (struct amdgpu_ring *ring,struct +amdgpu_irq_src *irq) { +amdgpu_ring_fini (ring); + irq->data =NULL ; +} + +void amdgpu_kiq_enable (struct amdgpu_ring *ring) { +uint32_t tmp; +struct amdgpu_device *adev = ring->adev; + +/* tell RLC which is KIQ queue */ + tmp =RREG32 (mmRLC_CP_SCHEDULERS); + tmp &=0xffffff00 ; + tmp |= (ring->me <<5 ) | (ring->pipe <<3 ) | (ring->queue); +WREG32 (mmRLC_CP_SCHEDULERS, tmp); + tmp |=0x80 ; +WREG32 (mmRLC_CP_SCHEDULERS, tmp); } + +void amdgpu_kiq_start (struct amdgpu_ring *ring) { +amdgpu_ring_alloc (ring,8 ); +/* set resources */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_RESOURCES ,6 )); +amdgpu_ring_write (ring,0 );/* vmid_mask:0 queue_type:0 (KIQ) */ +amdgpu_ring_write (ring,0x000000FF );/* queue mask lo */ +amdgpu_ring_write (ring,0 );/* queue mask hi */ +amdgpu_ring_write (ring,0 );/* gws mask lo */ +amdgpu_ring_write (ring,0 );/* gws mask hi */ +amdgpu_ring_write (ring,0 );/* oac mask */ +amdgpu_ring_write (ring,0 );/* gds heap base:0, gds heap size:0 */ +amdgpu_ring_commit (ring); +udelay (50 ); +} + +void amdgpu_kiq_map_queue (struct amdgpu_ring *kiq_ring, +struct amdgpu_ring *ring) { +struct amdgpu_device *adev = kiq_ring->adev; +uint64_t mqd_addr, wptr_addr; + + mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj); + wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); +amdgpu_ring_alloc (kiq_ring,8 ); + +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_MAP_QUEUES ,5 )); +/* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ +amdgpu_ring_write (kiq_ring,0x21010000 ); +amdgpu_ring_write (kiq_ring, (ring->doorbell_index <<2 ) | + (ring->queue <<26 ) | + (ring->pipe <<29 ) | + ((ring->me ==1 ?0 :1 ) <<31 ));/* doorbell */ +amdgpu_ring_write (kiq_ring,lower_32_bits (mqd_addr)); +amdgpu_ring_write (kiq_ring,upper_32_bits (mqd_addr)); +amdgpu_ring_write (kiq_ring,lower_32_bits (wptr_addr)); +amdgpu_ring_write (kiq_ring,upper_32_bits (wptr_addr)); +amdgpu_ring_commit (kiq_ring); +udelay (50 ); +} + +#define MEC_HPD_SIZE 2048 + +int amdgpu_mqd_init (struct amdgpu_device *adev, +struct vi_mqd *mqd, +uint64_t mqd_gpu_addr, +uint64_t eop_gpu_addr, +struct amdgpu_ring *ring) { +uint64_t hqd_gpu_addr, wb_gpu_addr, eop_base_addr; +uint32_t tmp; + + mqd->header =0xC0310800 ; + mqd->compute_pipelinestat_enable =0x00000001 ; + mqd->compute_static_thread_mgmt_se0 =0xffffffff ; + mqd->compute_static_thread_mgmt_se1 =0xffffffff ; + mqd->compute_static_thread_mgmt_se2 =0xffffffff ; + mqd->compute_static_thread_mgmt_se3 =0xffffffff ; + mqd->compute_misc_reserved =0x00000003 ; + + eop_base_addr = eop_gpu_addr >>8 ; + mqd->cp_hqd_eop_base_addr_lo = eop_base_addr; + mqd->cp_hqd_eop_base_addr_hi =upper_32_bits (eop_base_addr); + +/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ + tmp =RREG32 (mmCP_HQD_EOP_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_EOP_CONTROL ,EOP_SIZE , + (order_base_2 (MEC_HPD_SIZE /4 ) -1 )); + + mqd->cp_hqd_eop_control = tmp; + +/* enable doorbell? */ + tmp =RREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL); + +if (ring->use_doorbell) + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,1 ); +else + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,0 ); + + mqd->cp_hqd_pq_doorbell_control = tmp; + +/* disable the queue if it's active */ + mqd->cp_hqd_dequeue_request =0 ; + mqd->cp_hqd_pq_rptr =0 ; + mqd->cp_hqd_pq_wptr =0 ; + +/* set the pointer to the MQD */ + mqd->cp_mqd_base_addr_lo = mqd_gpu_addr &0xfffffffc ; + mqd->cp_mqd_base_addr_hi =upper_32_bits (mqd_gpu_addr); + +/* set MQD vmid to 0 */ + tmp =RREG32 (mmCP_MQD_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_MQD_CONTROL ,VMID ,0 ); + mqd->cp_mqd_control = tmp; +drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +10
-0+/* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ + hqd_gpu_addr = ring->gpu_addr >>8 ; + mqd->cp_hqd_pq_base_lo = hqd_gpu_addr; + mqd->cp_hqd_pq_base_hi =upper_32_bits (hqd_gpu_addr); + +/* set up the HQD, this is similar to CP_RB0_CNTL */ + tmp =RREG32 (mmCP_HQD_PQ_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,QUEUE_SIZE , + (order_base_2 (ring->ring_size /4 ) -1 )); + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,
RPTR_BLOCK_SIZE,drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +3
-0+ ((order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 ) +<< 8)); #ifdef __BIG_ENDIAN + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ENDIAN_SWAP,1);
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +2
-0+#endif + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,
UNORD_DISPATCH, 0);Quoted 1 line
+ tmp = REG_SET_FIELD(tmp,
CP_HQD_PQ_CONTROL,ROQ_PQ_IB_FLIP,0);
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +11
-0+ tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,PRIV_STATE ,1 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,KMD_QUEUE ,1 ); + mqd->cp_hqd_pq_control = tmp; + +/* set the wb address whether it's enabled or not */ + wb_gpu_addr = adev->wb.gpu_addr + (ring->rptr_offs *4 ); + mqd->cp_hqd_pq_rptr_report_addr_lo = wb_gpu_addr &0xfffffffc ; + mqd->cp_hqd_pq_rptr_report_addr_hi = +upper_32_bits (wb_gpu_addr) &0xffff ; + +/* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */
Quoted 23 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +23
-0+ wb_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); + mqd->cp_hqd_pq_wptr_poll_addr_lo = wb_gpu_addr &0xfffffffc ; + mqd->cp_hqd_pq_wptr_poll_addr_hi =upper_32_bits (wb_gpu_addr) + &0xffff ; + + tmp =0 ; +/* enable the doorbell if requested */ +if (ring->use_doorbell) { + tmp =RREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_OFFSET , + ring->doorbell_index); + + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_EN ,1 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_SOURCE ,0 ); + tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_DOORBELL_CONTROL , +DOORBELL_HIT ,0 ); + } + + mqd->cp_hqd_pq_doorbell_control = tmp; +drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +10
-0+/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */ + ring->wptr =0 ; + mqd->cp_hqd_pq_wptr = ring->wptr; + mqd->cp_hqd_pq_rptr =RREG32 (mmCP_HQD_PQ_RPTR); + +/* set the vmid for the queue */ + mqd->cp_hqd_vmid =0 ; + + tmp =RREG32 (mmCP_HQD_PERSISTENT_STATE); + tmp = REG_SET_FIELD(tmp, CP_HQD_PERSISTENT_STATE,
PRELOAD_SIZE,0x53);Quoted 57 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +20
-0+ mqd->cp_hqd_persistent_state = tmp; + +/* activate the queue */ + mqd->cp_hqd_active =1 ; + +return 0 ; +} + +int amdgpu_kiq_init (struct amdgpu_device *adev, +struct vi_mqd *mqd, +struct amdgpu_ring *ring) { +uint32_t tmp; +int j; + +/* disable wptr polling */ + tmp =RREG32 (mmCP_PQ_WPTR_POLL_CNTL); + tmp =REG_SET_FIELD (tmp,CP_PQ_WPTR_POLL_CNTL ,EN ,0 ); +WREG32 (mmCP_PQ_WPTR_POLL_CNTL, tmp); + + WREG32(mmCP_HQD_EOP_BASE_ADDR, mqd-
cp_hqd_eop_base_addr_lo);drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +19
-0+WREG32 (mmCP_HQD_EOP_BASE_ADDR_HI, + mqd->cp_hqd_eop_base_addr_hi); + +/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ +WREG32 (mmCP_HQD_EOP_CONTROL, mqd->cp_hqd_eop_control); + +/* enable doorbell? */ +WREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL, + mqd->cp_hqd_pq_doorbell_control); + +/* disable the queue if it's active */ +if (RREG32 (mmCP_HQD_ACTIVE) &1 ) { +WREG32 (mmCP_HQD_DEQUEUE_REQUEST,1 ); +for (j =0 ; j < adev->usec_timeout; j++) { +if (!(RREG32 (mmCP_HQD_ACTIVE) &1 )) +break ; +udelay (1 ); + } + WREG32(mmCP_HQD_DEQUEUE_REQUEST, mqd-
cp_hqd_dequeue_request);drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +7
-0+WREG32 (mmCP_HQD_PQ_RPTR, mqd->cp_hqd_pq_rptr); +WREG32 (mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr); + } + +/* set the pointer to the MQD */ +WREG32 (mmCP_MQD_BASE_ADDR, mqd->cp_mqd_base_addr_lo); + WREG32(mmCP_MQD_BASE_ADDR_HI, mqd-
cp_mqd_base_addr_hi);drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +8
-0+ +/* set MQD vmid to 0 */ +WREG32 (mmCP_MQD_CONTROL, mqd->cp_mqd_control); + +/* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ +WREG32 (mmCP_HQD_PQ_BASE, mqd->cp_hqd_pq_base_lo); +WREG32 (mmCP_HQD_PQ_BASE_HI, mqd->cp_hqd_pq_base_hi); +drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +10
-0+/* set up the HQD, this is similar to CP_RB0_CNTL */ +WREG32 (mmCP_HQD_PQ_CONTROL, mqd->cp_hqd_pq_control); + +/* set the wb address whether it's enabled or not */ +WREG32 (mmCP_HQD_PQ_RPTR_REPORT_ADDR, + mqd->cp_hqd_pq_rptr_report_addr_lo); +WREG32 (mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI, + mqd->cp_hqd_pq_rptr_report_addr_hi); + +/* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */
Quoted 24 lines
+ WREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR, mqd-
cp_hqd_pq_wptr_poll_addr_lo);drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +22
-0+WREG32 (mmCP_HQD_PQ_WPTR_POLL_ADDR_HI, + mqd->cp_hqd_pq_wptr_poll_addr_hi); + +/* enable the doorbell if requested */ +if (ring->use_doorbell) { +if ((adev->asic_type ==CHIP_CARRIZO ) || + (adev->asic_type ==CHIP_FIJI ) || + (adev->asic_type ==CHIP_STONEY )) { +WREG32 (mmCP_MEC_DOORBELL_RANGE_LOWER, +AMDGPU_DOORBELL_KIQ <<2 ); +WREG32 (mmCP_MEC_DOORBELL_RANGE_UPPER, +AMDGPU_DOORBELL_MEC_RING7 <<2 ); + } + } +WREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL, + mqd->cp_hqd_pq_doorbell_control); + +/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */ +WREG32 (mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr); + +/* set the vmid for the queue */ +WREG32 (mmCP_HQD_VMID, mqd->cp_hqd_vmid);drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +10
-0+ +WREG32 (mmCP_HQD_PERSISTENT_STATE, + mqd->cp_hqd_persistent_state); + +/* activate the queue */ +WREG32 (mmCP_HQD_ACTIVE, mqd->cp_hqd_active); + +if (ring->use_doorbell) { + tmp =RREG32 (mmCP_PQ_STATUS); + tmp = REG_SET_FIELD(tmp, CP_PQ_STATUS, DOORBELL_ENABLE,1);
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +32
-0+WREG32 (mmCP_PQ_STATUS, tmp); + } + +return 0 ; +} + +void amdgpu_kiq_ring_emit_fence (struct amdgpu_ring *ring,u64 addr, +u64 seq,unsigned int flags) { +/* we only allocate 32bit for each seq wb address */ +if (flags &AMDGPU_FENCE_FLAG_64BIT ) +BUG (); + +/* write fence seq to the "addr" */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (WRITE_DATA_ENGINE_SEL (0 ) | +WRITE_DATA_DST_SEL (5 ) |WR_CONFIRM )); +amdgpu_ring_write (ring,lower_32_bits (addr)); +amdgpu_ring_write (ring,upper_32_bits (addr)); +amdgpu_ring_write (ring,lower_32_bits (seq)); + +if (flags &AMDGPU_FENCE_FLAG_INT ) { +/* set register to trigger INT */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (WRITE_DATA_ENGINE_SEL (0 ) | +WRITE_DATA_DST_SEL (0 ) |WR_CONFIRM )); +amdgpu_ring_write (ring, mmCPC_INT_STATUS); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,0x20000000 );/* src_id is 178 */ + } +} + +static int amdgpu_kiq_set_interrupt_state(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +10
-0+struct amdgpu_irq_src *src, + unsigned int type, + enum amdgpu_interrupt_state +state) { + uint32_t tmp, target; +struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data; + +BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); + + target = (ring->me == 1) ? mmCP_ME1_PIPE0_INT_CNTL :
mmCP_ME2_PIPE0_INT_CNTL;Quoted 76 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c new file +59
-0+ target += ring->pipe; + +switch (type) { +case AMDGPU_CP_KIQ_IRQ_DRIVER0 : +if (state ==AMDGPU_IRQ_STATE_DISABLE ) { + tmp =RREG32 (mmCPC_INT_CNTL); + tmp =REG_SET_FIELD (tmp,CPC_INT_CNTL , +GENERIC2_INT_ENABLE ,0 ); +WREG32 (mmCPC_INT_CNTL, tmp); + + tmp =RREG32 (target); + tmp =REG_SET_FIELD (tmp,CP_ME2_PIPE0_INT_CNTL , +GENERIC2_INT_ENABLE ,0 ); +WREG32 (target, tmp); + }else { + tmp =RREG32 (mmCPC_INT_CNTL); + tmp =REG_SET_FIELD (tmp,CPC_INT_CNTL , +GENERIC2_INT_ENABLE ,1 ); +WREG32 (mmCPC_INT_CNTL, tmp); + + tmp =RREG32 (target); + tmp =REG_SET_FIELD (tmp,CP_ME2_PIPE0_INT_CNTL , +GENERIC2_INT_ENABLE ,1 ); +WREG32 (target, tmp); + } +break ; +default : +BUG ();/* kiq only support GENERIC2_INT now */ +break ; + } +return 0 ; +} + +static int amdgpu_kiq_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) { +u8 me_id, pipe_id, queue_id; +struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data; + +BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); + + me_id = (entry->ring_id &0x0c ) >>2 ; + pipe_id = (entry->ring_id &0x03 ) >>0 ; + queue_id = (entry->ring_id &0x70 ) >>4 ; +DRM_DEBUG ("IH: CPC GENERIC2_INT, me:%d, pipe:%d, queue:%d\n" , + me_id, pipe_id, queue_id); + +amdgpu_fence_process (ring); +return 0 ; +} + +static const struct amdgpu_irq_src_funcs amdgpu_kiq_irq_funcs = { + .set = amdgpu_kiq_set_interrupt_state, + .process = amdgpu_kiq_irq, +}; + +void amdgpu_kiq_set_irq_funcs (struct amdgpu_irq_src *irq) { + irq->num_types =AMDGPU_CP_KIQ_IRQ_LAST ; + irq->funcs = &amdgpu_kiq_irq_funcs; }drivers/gpu/drm/amd/amdgpu/vid.h +2
-1@@ -360,6 +360,8 @@#define PACKET3_WAIT_ON_CE_COUNTER 0x86#define PACKET3_WAIT_ON_DE_COUNTER_DIFF 0x88#define PACKET3_SWITCH_BUFFER 0x8B +#define PACKET3_SET_RESOURCES 0xA0 +#define PACKET3_MAP_QUEUES 0xA2#define VCE_CMD_NO_OP 0x00000000#define VCE_CMD_END 0x00000001 --2.7.4
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/23 drm/amdgpu: add kiq into compiling
In reply to a message not in the archiveAdd support KIQ in Makefile to make it into module.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB170115ECFEEDEE2B92071FE7EB9E0@CY4PR12MB1701.namprd12.prod.outlook.com
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB170115ECFEEDEE2B92071FE7EB9E0-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
PATCH 2/23 drm/amdgpu: add kiq into compiling
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a amdgpu_kiq.c file to cover the function of kiq,
Kiq is good enough to be in each gfx_x_x.c file .e.g :
KIQ for VI is in gfx_v8_0.c
And KIQ for AI is in gfx_v9_0.c
Most important is that the "queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ part
BR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling
-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization <[email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compiling
Add support KIQ in Makefile to make it into module.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BY2PR12MB0054C15BB4903E12764EABF684910-K//h7OWB4q7GdVlgMuSljQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 02/23] drm/amdgpu: add kiq into compiling
Quoted 6 lines
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a
amdgpu_kiq.cfile to cover the function of kiq,
Quoted 7 lines
Kiq is good enough to be in each
gfx_x_x.cfile .e.g :
KIQ for VI is ingfx_v8_0.c
And KIQ for AI is ingfx_v9_0.cMost important is that the "
queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ part
Sure.
Quoted 43 lines
BR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization <[email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compilingAdd support KIQ in
Makefileto make it into module.Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.okv_dpm.o \
--
2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: 转发: [PATCH 02/23] drm/amdgpu: add kiq into compiling
In reply to a message not in the archiveYeah, agree totally with Monk here.
If you find that you need some KIQ helpers which are independent of the hardware generation you can put them into amdgpu_kiq.c.
Monk, David or maybe even Michel and Nicolai could you guys take a closer look at the patches.
I'm currently to busy with private issues, so I just briefly skimmed over them, but still found some issues.
The VA update stuff seems incorrectly handled to me for example. You only update the page tables once and then assume that everything stays as it is.
Regards,
Christian.
Am 19.12.2016 um 08:13 schrieb Liu, Monk:
Quoted 39 lines
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a
amdgpu_kiq.cfile to cover the function of kiq,Kiq is good enough to be in each
gfx_x_x.cfile .e.g :
KIQ for VI is ingfx_v8_0.c
And KIQ for AI is ingfx_v9_0.cMost important is that the "
queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ partBR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization <[email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compilingAdd support KIQ in
Makefileto make it into module.Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +0
-0
drivers/gpu/drm/amd/amdgpu/Makefile amdgpu-y += amdgpu_device.o amdgpu_kms.o \ · line 36
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): beb83cf9-2683-569e-ea68-df3894e11dc0-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: 转发: [PATCH 02/23] drm/amdgpu: add kiq into compiling
Quoted 5 lines · Christian König
Yeah, agree totally with Monk here.
If you find that you need some KIQ helpers which are independent of the hardware generation you can put them into
amdgpu_kiq.c.
Quoted 9 lines
Monk, David or maybe even Michel and Nicolai could you guys take a closer look at the patches.
I'm currently to busy with private issues, so I just briefly skimmed over them, but still found some issues.
The VA update stuff seems incorrectly handled to me for example. You only update the page tables once and then assume that everything stays as it is.
I agree with all of Christian and Monk's comments. Please see my comments on the patches.
Alex
Quoted 58 lines
Regards,
Christian.Am 19.12.2016 um 08:13 schrieb Liu, Monk:
Quoted 53 lines
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a
amdgpu_kiq.cfile to cover the function of kiq,Kiq is good enough to be in each
gfx_x_x.cfile .e.g :
KIQ for VI is ingfx_v8_0.c
And KIQ for AI is ingfx_v9_0.cMost important is that the "
queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ partBR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization <[email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compilingAdd support KIQ in
Makefileto make it into module.Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/Makefile amdgpu-y += amdgpu_device.o amdgpu_kms.o \ · line 36
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/Makefile +0
-0amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_MDTdnOcarCkDFdb5d=nJxDpt4ATkvmDG+BFG5thLa-eA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
答复: 转发: [PATCH 02/23] drm/amdgpu: add kiq into compiling
yeah, I'll take a deep look, we are not in hurry to submit those SRIOV patches, for the VA update part (if you mean CSA mappings) I'll pay attention on it, thanks
BR Monk
________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2016年12月20日 7:38:10
收件人: Christian König
抄送: Liu, Monk; [email protected]
主题: Re: 转发: [PATCH 02/23] drm/amdgpu: add kiq into compiling
Quoted 5 lines · Christian König
Yeah, agree totally with Monk here.
If you find that you need some KIQ helpers which are independent of the hardware generation you can put them into
amdgpu_kiq.c.
Quoted 9 lines
Monk, David or maybe even Michel and Nicolai could you guys take a closer look at the patches.
I'm currently to busy with private issues, so I just briefly skimmed over them, but still found some issues.
The VA update stuff seems incorrectly handled to me for example. You only update the page tables once and then assume that everything stays as it is.
I agree with all of Christian and Monk's comments. Please see my comments on the patches.
Alex
Quoted 58 lines
Regards,
Christian.Am 19.12.2016 um 08:13 schrieb Liu, Monk:
Quoted 53 lines
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a
amdgpu_kiq.cfile to cover the function of kiq,Kiq is good enough to be in each
gfx_x_x.cfile .e.g :
KIQ for VI is ingfx_v8_0.c
And KIQ for AI is ingfx_v9_0.cMost important is that the "
queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ partBR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization <[email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compilingAdd support KIQ in
Makefileto make it into module.Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/Makefile amdgpu-y += amdgpu_device.o amdgpu_kms.o \ · line 36
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/Makefile +0
-0amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
答复: 转发: [PATCH 02/23] drm/amdgpu: add kiq into compiling
In reply to a message not in the archiveHi Christian,
the CSA VA update should be correct, we pin it after it allocated per device during init stage, and we map it upon each process creates their vm page tables,
since this CSA is pined, I assume there is no need to validate it prior to submission
please correct me if I missed something
BR Monk
________________________________
发件人: amd-gfx <[email protected]> 代表 Christian König <[email protected]> 发送时间: 2016年12月19日 19:17:38
收件人: Liu, Monk; [email protected]
主题: Re: 转发: [PATCH 02/23] drm/amdgpu: add kiq into compiling
Yeah, agree totally with Monk here.
If you find that you need some KIQ helpers which are independent of the hardware generation you can put them into amdgpu_kiq.c.
Monk, David or maybe even Michel and Nicolai could you guys take a closer look at the patches.
I'm currently to busy with private issues, so I just briefly skimmed over them, but still found some issues.
The VA update stuff seems incorrectly handled to me for example. You only update the page tables once and then assume that everything stays as it is.
Regards,
Christian.
Am 19.12.2016 um 08:13 schrieb Liu, Monk:
Quoted 39 lines
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a
amdgpu_kiq.cfile to cover the function of kiq,Kiq is good enough to be in each
gfx_x_x.cfile .e.g :
KIQ for VI is ingfx_v8_0.c
And KIQ for AI is ingfx_v9_0.cMost important is that the "
queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ partBR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization <[email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compilingAdd support KIQ in
Makefileto make it into module.Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +0
-0
drivers/gpu/drm/amd/amdgpu/Makefile amdgpu-y += amdgpu_device.o amdgpu_kms.o \ · line 36
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 02/23] drm/amdgpu: add kiq into compiling
In reply to a message not in the archiveI'd be curious to know what AI stands for in this context
Quoted 57 lines · Monk
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a
amdgpu_kiq.cfile to cover the function of kiq,Kiq is good enough to be in each
gfx_x_x.cfile .e.g :
KIQ for VI is ingfx_v8_0.c
And KIQ for AI is ingfx_v9_0.cMost important is that the "
queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ partBR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization < [email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compilingAdd support KIQ in
Makefileto make it into module.Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +1
-2@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ --2.7.4
Quoted 5 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CAHbf0-EqT1YHuxButQkfb8s3mGT4WjVdcjCWMFetiqwjEME8pA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 02/23] drm/amdgpu: add kiq into compiling
An upcoming GPU generation (Vega).
From: amd-gfx [mailto:[email protected]] On Behalf Of Mike Lothian
Sent: Monday, December 19, 2016 10:49 PM
To: Liu, Monk; [email protected]
Subject: Re: [PATCH 02/23] drm/amdgpu: add kiq into compiling
I'd be curious to know what AI stands for in this context
On Mon, 19 Dec 2016 at 07:28 Liu, Monk <[email protected]<mailto:[email protected]>> wrote:
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a amdgpu_kiq.c file to cover the function of kiq,
Kiq is good enough to be in each gfx_x_x.c file .e.g :
KIQ for VI is in gfx_v8_0.c
And KIQ for AI is in gfx_v9_0.c
Most important is that the "queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ part
BR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling
-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]<mailto:[email protected]>]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]<mailto:[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]<mailto:[email protected]>>
Cc: Yu, Xiangliang <[email protected]<mailto:[email protected]>>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compiling
Add support KIQ in Makefile to make it into module.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BN6PR12MB13487A20F8218E81FB87B846E8900-/b2+HYfkarQX0pEhCR5T8QdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 02/23] drm/amdgpu: add kiq into compiling
Ah, I've clicked now - I thought Vega was a star name
AI - Arctic Islands :D
Quoted 75 lines · John
An upcoming GPU generation (Vega).
*From:* amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] *On Behalf Of *Mike Lothian
*Sent:* Monday, December 19, 2016 10:49 PM
*To:* Liu, Monk; [email protected]
*Subject:* Re: [PATCH 02/23] drm/amdgpu: add kiq into compilingI'd be curious to know what AI stands for in this context
On Mon, 19 Dec 2016 at 07:28 Liu, Monk <[email protected]> wrote:
Sorry, NAK for the KIQ implement patches.
KIQ is just another compute queue, and each generation of compute queue initialization is different, so there is no need of a
amdgpu_kiq.cfile to cover the function of kiq,Kiq is good enough to be in each
gfx_x_x.cfile .e.g :
KIQ for VI is ingfx_v8_0.c
And KIQ for AI is ingfx_v9_0.cMost important is that the "
queue_init" routine of above two chips on KIQ is different (MQD descriptor as well as registers need programing ... ), please just align with the previous patch style in amd-sriov-4.6 for KIQ partBR Monk
-----邮件原件-----
发件人: Yu, Xiangliang
发送时间: Sunday, December 18, 2016 9:47 AM
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 02/23] drm/amdgpu: add kiq into compiling-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization < [email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: add kiq into compilingAdd support KIQ in
Makefileto make it into module.Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +1
-2@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ - amdgpu_gtt_mgr.o amdgpu_vram_mgr.o + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_kiq.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ --2.7.4
Quoted 6 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/23 drm/amdgpu: export KIQ interfaces
In reply to a message not in the archiveExport KIQ interfaces so that others components can use the interfaces to setup queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +20 -0
@@ -157,6 +157,7 @@ struct amdgpu_cs_parser;struct amdgpu_job ;struct amdgpu_irq_src ;struct amdgpu_fpriv ; +struct vi_mqd ;enum amdgpu_cp_irq {AMDGPU_CP_IRQ_GFX_EOP =0 ,
@@ -691,6 +692,25 @@ void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr);void amdgpu_ctx_mgr_fini (struct amdgpu_ctx_mgr *mgr);/* +* Kernel Interface Queue functions +*/ +int amdgpu_kiq_init_ring (struct amdgpu_device *adev,struct amdgpu_ring *ring, +struct amdgpu_irq_src *irq); +void amdgpu_kiq_free_ring (struct amdgpu_ring *ring,struct amdgpu_irq_src *irq); +void amdgpu_kiq_enable (struct amdgpu_ring *ring); +void amdgpu_kiq_start (struct amdgpu_ring *ring); +int amdgpu_kiq_init (struct amdgpu_device *adev,struct vi_mqd *mqd, +struct amdgpu_ring *ring); +void amdgpu_kiq_map_queue (struct amdgpu_ring *kiq_ring, +struct amdgpu_ring *ring); +int amdgpu_mqd_init (struct amdgpu_device *adev,struct vi_mqd *mqd, +uint64_t mqd_gpu_addr,uint64_t eop_gpu_addr, +struct amdgpu_ring *ring); +void amdgpu_kiq_ring_emit_fence (struct amdgpu_ring *ring,u64 addr, +u64 seq,unsigned flags); +void amdgpu_kiq_set_irq_funcs (struct amdgpu_irq_src *irq); + +/* * file private structure */
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/23 drm/amdgpu: add new structure for KIQ memory allcation
In reply to a message not in the archiveKIQ need three memory spaces: interrupt, ring and buffer object. If want to setup KIQ, must to allocate related memory firstly.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +10 -0
@@ -691,6 +691,13 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,void amdgpu_ctx_mgr_init (struct amdgpu_ctx_mgr *mgr);void amdgpu_ctx_mgr_fini (struct amdgpu_ctx_mgr *mgr); +struct amdgpu_kiq { +u64 eop_gpu_addr; +struct amdgpu_bo *eop_obj; +struct amdgpu_ring ring; +struct amdgpu_irq_src irq; +}; +/* * Kernel Interface Queue functions */
@@ -1461,6 +1468,9 @@ struct amdgpu_device {/* gfx */ struct amdgpu_gfx gfx; +/* KIQ */ +struct amdgpu_kiq kiq; +/* sdma */ struct amdgpu_sdma sdma;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/23 drm/amdgpu/gfx8: add support KIQ for FIJI/TONGA chips
In reply to a message not in the archiveFIJI/TONGA chips must enable KIQ feature to support virtualization.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 237 +++++++++++++++++++++++++++++++++- 1 file changed, 236 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +236 -1
@@ -1410,6 +1410,67 @@ static int gfx_v8_0_mec_init(struct amdgpu_device *adev)return 0 ; } +static void gfx_v8_0_kiq_fini (struct amdgpu_device *adev) +{ +int r; + +if (adev->kiq.eop_obj) { + r =amdgpu_bo_reserve (adev->kiq.eop_obj, false); +if (unlikely (r !=0 )) +dev_warn (adev->dev,"(%d) reserve HPD EOP bo failed\n" , r); +amdgpu_bo_unpin (adev->kiq.eop_obj); +amdgpu_bo_unreserve (adev->kiq.eop_obj); +amdgpu_bo_unref (&adev->kiq.eop_obj); + adev->kiq.eop_obj =NULL ; + } +} + +static int gfx_v8_0_kiq_init (struct amdgpu_device *adev) +{ +int r; +u32 *hpd; + +if (adev->kiq.eop_obj ==NULL ) { + r =amdgpu_bo_create (adev, +MEC_HPD_SIZE , +PAGE_SIZE , true, +AMDGPU_GEM_DOMAIN_GTT ,0 ,NULL ,NULL , + &adev->kiq.eop_obj); +if (r) { +dev_warn (adev->dev,"(%d) create HDP EOP bo failed\n" , r); +return r; + } + } + + r =amdgpu_bo_reserve (adev->kiq.eop_obj, false); +if (unlikely (r !=0 )) { +gfx_v8_0_kiq_fini (adev); +return r; + } + + r =amdgpu_bo_pin (adev->kiq.eop_obj,AMDGPU_GEM_DOMAIN_GTT , + &adev->kiq.eop_gpu_addr); +if (r) { +dev_warn (adev->dev,"(%d) pin HDP EOP bo failed\n" , r); +gfx_v8_0_kiq_fini (adev); +return r; + } + + r =amdgpu_bo_kmap (adev->kiq.eop_obj, (void **)&hpd); +if (r) { +dev_warn (adev->dev,"(%d) map HDP EOP bo failed\n" , r); +gfx_v8_0_kiq_fini (adev); +return r; + } + +memset (hpd,0 ,MEC_HPD_SIZE ); + +amdgpu_bo_kunmap (adev->kiq.eop_obj); +amdgpu_bo_unreserve (adev->kiq.eop_obj); + +return 0 ; +} +static const u32 vgpr_init_compute_shader[] = {0x7e000209 ,0x7e020208 ,
@@ -1987,6 +2048,11 @@ static int gfx_v8_0_sw_init(void *handle)struct amdgpu_ring *ring;struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* KIQ event */ + r =amdgpu_irq_add_id (adev,178 , &adev->kiq.irq); +if (r) +return r; +/* EOP Event */ r =amdgpu_irq_add_id (adev,181 , &adev->gfx.eop_irq);if (r)
@@ -2024,6 +2090,16 @@ static int gfx_v8_0_sw_init(void *handle)return r; } + r =gfx_v8_0_kiq_init (adev); +if (r) { +DRM_ERROR ("Failed to init KIQ BOs!\n" ); +return r; + } + + r =amdgpu_kiq_init_ring (adev, &adev->kiq.ring, &adev->kiq.irq); +if (r) +return r; +/* set up the gfx ring */ for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { ring = &adev->gfx.gfx_ring[i];
@@ -2107,7 +2183,9 @@ static int gfx_v8_0_sw_fini(void *handle)amdgpu_ring_fini (&adev->gfx.gfx_ring[i]);for (i =0 ; i < adev->gfx.num_compute_rings; i++)amdgpu_ring_fini (&adev->gfx.compute_ring[i]); +amdgpu_kiq_free_ring (&adev->kiq.ring, &adev->kiq.irq); +gfx_v8_0_kiq_fini (adev);gfx_v8_0_mec_fini (adev);gfx_v8_0_rlc_fini (adev);gfx_v8_0_free_microcode (adev);
@@ -4468,6 +4546,131 @@ static int gfx_v8_0_cp_compute_load_microcode(struct amdgpu_device *adev)return 0 ; } +static int gfx_v8_0_kiq_init_queue (struct amdgpu_ring *ring, +struct vi_mqd *mqd, +u64 mqd_gpu_addr) +{ +struct amdgpu_device *adev = ring->adev; +struct amdgpu_kiq *kiq = &adev->kiq; +uint64_t eop_gpu_addr; +bool is_kiq = false; + +if (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ) + is_kiq = true; + +if (is_kiq) { + eop_gpu_addr = kiq->eop_gpu_addr; +amdgpu_kiq_enable (&kiq->ring); + }else + eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr + ring->queue *MEC_HPD_SIZE ; + +mutex_lock (&adev->srbm_mutex); +vi_srbm_select (adev, ring->me, ring->pipe, ring->queue,0 ); + +amdgpu_mqd_init (adev, mqd, mqd_gpu_addr, eop_gpu_addr, ring); + +if (is_kiq) +amdgpu_kiq_init (adev, mqd, ring); + +vi_srbm_select (adev,0 ,0 ,0 ,0 ); +mutex_unlock (&adev->srbm_mutex); + +if (is_kiq) +amdgpu_kiq_start (ring); +else +amdgpu_kiq_map_queue (&kiq->ring, ring); + +return 0 ; +} + +static int gfx_v8_0_kiq_map_queue (struct amdgpu_device *adev, +struct amdgpu_ring *ring) +{ +struct vi_mqd *mqd; +u64 mqd_gpu_addr; +u32 *buf; +int r =0 ; + + r =amdgpu_bo_create (adev,sizeof (struct vi_mqd ),PAGE_SIZE , true, +AMDGPU_GEM_DOMAIN_GTT ,0 ,NULL ,NULL , + &ring->mqd_obj); +if (r) { +dev_warn (adev->dev,"(%d) create MQD bo failed\n" , r); +return r; + } + r =amdgpu_bo_reserve (ring->mqd_obj, false); +if (unlikely (r !=0 )) { +amdgpu_bo_unref (&ring->mqd_obj); +return r; + } + r =amdgpu_bo_pin (ring->mqd_obj,AMDGPU_GEM_DOMAIN_GTT , + &mqd_gpu_addr); +if (r) { +dev_warn (adev->dev,"(%d) pin MQD bo failed\n" , r); +amdgpu_bo_unreserve (ring->mqd_obj); +amdgpu_bo_unref (&ring->mqd_obj); +return r; + } + r =amdgpu_bo_kmap (ring->mqd_obj, (void **)&buf); +if (r) { +dev_warn (adev->dev,"(%d) map MQD bo failed\n" , r); +amdgpu_bo_unpin (ring->mqd_obj); +amdgpu_bo_unreserve (ring->mqd_obj); +amdgpu_bo_unref (&ring->mqd_obj); +return r; + } + +/* init the mqd struct */ +memset (buf,0 ,sizeof (struct vi_mqd )); + mqd = (struct vi_mqd *)buf; + + r =gfx_v8_0_kiq_init_queue (ring, mqd, mqd_gpu_addr); +if (r) +return r; + +amdgpu_bo_kunmap (ring->mqd_obj); +amdgpu_bo_unreserve (ring->mqd_obj); + +return 0 ; +} + +static int gfx_v8_0_kiq_resume (struct amdgpu_device *adev) +{ +struct amdgpu_ring *ring =NULL ; +int r, i; + + ring = &adev->kiq.ring; + r =gfx_v8_0_kiq_map_queue (adev, ring); +if (r) +return r; + +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + ring = &adev->gfx.compute_ring[i]; + r =gfx_v8_0_kiq_map_queue (adev, ring); +if (r) +return r; + } + +gfx_v8_0_cp_compute_enable (adev, true); + +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + ring = &adev->gfx.compute_ring[i]; + + ring->ready = true; + r =amdgpu_ring_test_ring (ring); +if (r) + ring->ready = false; + } + + ring = &adev->kiq.ring; + ring->ready = true; + r =amdgpu_ring_test_ring (ring); +if (r) + ring->ready = false; + +return 0 ; +} +static void gfx_v8_0_cp_compute_fini (struct amdgpu_device *adev) {int i, r;
@@ -4787,7 +4990,10 @@ static int gfx_v8_0_cp_resume(struct amdgpu_device *adev)if (r)return r; - r =gfx_v8_0_cp_compute_resume (adev); +if (amdgpu_sriov_vf (adev)) + r =gfx_v8_0_kiq_resume (adev); +else + r =gfx_v8_0_cp_compute_resume (adev);if (r)return r;
@@ -6464,10 +6670,37 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { .pad_ib = amdgpu_ring_generic_pad_ib, }; +static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_kiq = { + .type =AMDGPU_RING_TYPE_KIQ , + .align_mask =0xff , + .nop =PACKET3 (PACKET3_NOP ,0x3FFF ), + .get_rptr = gfx_v8_0_ring_get_rptr, + .get_wptr = gfx_v8_0_ring_get_wptr_compute, + .set_wptr = gfx_v8_0_ring_set_wptr_compute, + .emit_frame_size = +20 +/* gfx_v8_0_ring_emit_gds_switch */ +7 +/* gfx_v8_0_ring_emit_hdp_flush */ +5 +/* gfx_v8_0_ring_emit_hdp_invalidate */ +7 +/* gfx_v8_0_ring_emit_pipeline_sync */ +17 +/* gfx_v8_0_ring_emit_vm_flush */ +7 +7 +7 ,/* gfx_v8_0_ring_emit_fence_compute x3 for user fence, vm fence */ + .emit_ib_size =4 ,/* gfx_v8_0_ring_emit_ib_compute */ + .emit_ib = gfx_v8_0_ring_emit_ib_compute, + .emit_fence = amdgpu_kiq_ring_emit_fence, + .emit_hdp_flush = gfx_v8_0_ring_emit_hdp_flush, + .emit_hdp_invalidate = gfx_v8_0_ring_emit_hdp_invalidate, + .test_ring = gfx_v8_0_ring_test_ring, + .test_ib = gfx_v8_0_ring_test_ib, + .insert_nop = amdgpu_ring_insert_nop, + .pad_ib = amdgpu_ring_generic_pad_ib, +}; +static void gfx_v8_0_set_ring_funcs (struct amdgpu_device *adev) {int i; + adev->kiq.ring.funcs = &gfx_v8_0_ring_funcs_kiq; +for (i =0 ; i < adev->gfx.num_gfx_rings; i++) adev->gfx.gfx_ring[i].funcs = &gfx_v8_0_ring_funcs_gfx;
@@ -6500,6 +6733,8 @@ static void gfx_v8_0_set_irq_funcs(struct amdgpu_device *adev) adev->gfx.priv_inst_irq.num_types =1 ; adev->gfx.priv_inst_irq.funcs = &gfx_v8_0_priv_inst_irq_funcs; + +amdgpu_kiq_set_irq_funcs (&adev->kiq.irq); }static void gfx_v8_0_set_rlc_funcs (struct amdgpu_device *adev)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/23 drm/amdgpu/gfx8: correct KIQ hdp flush
In reply to a message not in the archiveKIQ has some behavior as compute ring.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2 -1
@@ -6196,7 +6196,8 @@ static void gfx_v8_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) {u32 ref_and_mask, reg_mem_engine; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask =GPU_HDP_FLUSH_DONE__CP2_MASK << ring->pipe;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-7-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 06/23] drm/amdgpu/gfx8: correct KIQ hdp flush
Quoted 3 lines · Xiangliang Yu
KIQ has some behavior as compute ring.
Signed-off-by Xiangliang Yu <[email protected]>
Should be squashed into patch 5.
Alex
Quoted 21 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2
-2@@ -6196,7 +6196,8 @@ static void gfx_v8_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) {u32 ref_and_mask, reg_mem_engine; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask =GPU_HDP_FLUSH_DONE__CP2_MASK << ring->pipe; --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 06/23] drm/amdgpu/gfx8: correct KIQ hdp flush
Quoted 9 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:14 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>
Subject: Re: [PATCH 06/23] drm/amdgpu/gfx8: correct KIQ hdp flush
Quoted 7 lines
Quoted 3 lines · Xiangliang Yu
KIQ has some behavior as compute ring.
Signed-off-by Xiangliang Yu <[email protected]>Should be squashed into patch 5.
Sure.
Quoted 26 lines
Alex
Quoted 23 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2
-1@@ -6196,7 +6196,8 @@ static void gfx_v8_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) {u32 ref_and_mask, reg_mem_engine; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask = GPU_HDP_FLUSH_DONE__CP2_MASK <<
ring->pipe;
--
2.7.4
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/23 drm/amdgpu: create new directory for GPU virtualization
In reply to a message not in the archiveCreate new directory for GPU virtualization and name it with marketing name, so it will easy to mantainer all realted virtual code and make it independent so that will not affect other parts.
And create new pointer and interface to connect virtualization code with amdgpu core code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 3 +- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c | 104 +++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 37 +++++++++++ 4 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1511,6 +1511,8 @@ struct amdgpu_device {spinlock_t gtt_list_lock;struct list_head gtt_list; +/* GPU virtualization */ +void *priv_data; };static inline struct amdgpu_device *amdgpu_ttm_adev (struct ttm_bo_device *bdev)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -1
@@ -54,4 +54,5 @@ static inline bool is_virtual_machine(void) #endif } -#endif +int amd_xgpu_set_ip_blocks (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c new file +104 -0
104 lines not on this page · raw message
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Author: [email protected] +*/ +#ifndef __AMDGPU_XGPU_H__ +#define __AMDGPU_XGPU_H__ + +#include "amdgpu.h" + +struct amd_xgpu { +struct amdgpu_device *adev; +struct mutex lock; +u32 reg_val_offs; +}; + +extern int amd_xgpu_alloc (struct amdgpu_device *adev); +extern void amd_xgpu_free (struct amd_xgpu *xgpu); +#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB1701171F8B54171FCF66B30EEB9E0@CY4PR12MB1701.namprd12.prod.outlook.com
A message that is not in the archive (sent off-list or not yet received): BY2PR12MB005475C762077C442361FBD284910@BY2PR12MB0054.namprd12.prod.outlook.com
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB1701DB3B08413BBDA717E73FEB910@CY4PR12MB1701.namprd12.prod.outlook.com
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB1701DB3B08413BBDA717E73FEB910-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Liu, Monk
NAKPATCH 7/23 drm/amdgpu: create new directory for GPU virtualization
Forward to amd-gfx.
发件人: Yu, Xiangliang
发送时间: Monday, December 19, 2016 1:49 PM
收件人: Liu, Monk; dl.SRDC_SW_GPUVirtualization
主题: RE: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization
Make sense.
Thanks!
Xiangliang Yu
From: Liu, Monk
Sent: Monday, December 19, 2016 1:28 PM
To: Yu, Xiangliang <[email protected]<mailto:[email protected]>>; dl.SRDC_SW_GPUVirtualization <[email protected]<mailto:[email protected]>>
Subject: 答复: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization
NAK, there is not need to do that
spinlock_t gtt_list_lock;
struct list_head gtt_list;+ /* GPU virtualization */
+ void *priv_data;
};
just do like this:
spinlock_t gtt_list_lock;
struct list_head gtt_list;+ /* GPU virtualization */
+ struct amdgpu_virtualization virtualization;
};
don't use needless pointer in amdgpu_device structures, which brings more kmalloc/kfree cost on,
you can just put "struct amdgpu_virtualization" structure definition in amdgpu_virt.h
________________________________
发件人: Yu, Xiangliang
发送时间: 2016年12月18日 9:48:30
收件人: dl.SRDC_SW_GPUVirtualization
主题: FW: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization
-----Original Message-----
From: Xiangliang Yu [mailto:[email protected]]
Sent: Sunday, December 18, 2016 12:16 AM
To: [email protected]<mailto:[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]<mailto:[email protected]>>
Cc: Yu, Xiangliang <[email protected]<mailto:[email protected]>>
Subject: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization
Create new directory for GPU virtualization and name it with marketing name, so it will easy to mantainer all realted virtual code and make it independent so that will not affect other parts.
And create new pointer and interface to connect virtualization code with amdgpu core code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 3 +- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c | 104 +++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 37 +++++++++++ 4 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1511,6 +1511,8 @@ struct amdgpu_device {spinlock_t gtt_list_lock;struct list_head gtt_list; +/* GPU virtualization */ +void *priv_data; }; static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
index 2c37a37..8ee70f8 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1 -1
@@ -54,4 +54,5 @@ static inline bool is_virtual_machine(void) #endif } -#endif +int amd_xgpu_set_ip_blocks (struct amdgpu_device *adev);#endif
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c new file +104 -0
104 lines not on this page · raw message
+ if (r)
+ return r;
+
+ amd_xgpu_init_default_setting(adev);
+
+ return 0;
+}
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, +sublicense, +* and/or sell copies of the Software, and to permit persons to whom +the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be +included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Author: [email protected]<mailto:[email protected]> +*/ +#ifndef __AMDGPU_XGPU_H__ +#define __AMDGPU_XGPU_H__
+
+#include "amdgpu.h"
+
+struct amd_xgpu {
+ struct amdgpu_device *adev; + struct mutex lock; + u32 reg_val_offs;
+};
+
+extern int amd_xgpu_alloc(struct amdgpu_device *adev); extern void +amd_xgpu_free(struct amd_xgpu *xgpu); #endif
--
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/23 drm/amdgpu: add new flag for virtual function
In reply to a message not in the archiveAdd new flag to identify chips that is support virtualization.
--- drivers/gpu/drm/amd/include/amd_shared.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/include/amd_shared.h +1 -0
@@ -59,6 +59,7 @@ enum amd_chip_flags {AMD_IS_APU =0x00020000UL ,AMD_IS_PX =0x00040000UL ,AMD_EXP_HW_SUPPORT =0x00080000UL , + AMD_IS_VF = 0x00100000UL, }; enum amd_ip_block_type {
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/23 drm/amdgpu: enable virtualization feature for FIJI/TONGA
In reply to a message not in the archiveAccording to chip device id to set VF flag, and call virtual interface to setup all realted IP blocks.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
@@ -1285,7 +1285,10 @@ static int amdgpu_early_init(struct amdgpu_device *adev)else adev->family =AMDGPU_FAMILY_VI ; - r =vi_set_ip_blocks (adev); +if (adev->flags &AMD_IS_VF ) + r =amd_xgpu_set_ip_blocks (adev); +else + r =vi_set_ip_blocks (adev);if (r)return r;break ;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
@@ -385,13 +385,13 @@ static const struct pci_device_id pciidlist[] = { {0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, - {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, + {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA | AMD_IS_VF}, {0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},/* fiji */ {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, - {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, + {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI | AMD_IS_VF},/* carrizo */ {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU}, {0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-10-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
答复: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
- r = vi_set_ip_blocks(adev);
detect_sriov(adev);
if (amdgpu_sriov_vf(adev))+ adev->flags |= AMD_IS_VF;
if (adev->flags & AMD_IS_VF)
+ r = amd_xgpu_set_ip_blocks(adev);
+ else
+ r = vi_set_ip_blocks(adev);
if (r)
return r;________________________________
发件人: amd-gfx <[email protected]> 代表 Xiangliang Yu <[email protected]> 发送时间: 2016年12月18日 0:16:31
收件人: [email protected]; dl.SRDC_SW_GPUVirtualization
抄送: Yu, Xiangliang
主题: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
According to chip device id to set VF flag, and call virtual interface to setup all realted IP blocks.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
@@ -1285,7 +1285,10 @@ static int amdgpu_early_init(struct amdgpu_device *adev)else adev->family =AMDGPU_FAMILY_VI ; - r =vi_set_ip_blocks (adev); +if (adev->flags &AMD_IS_VF ) + r =amd_xgpu_set_ip_blocks (adev); +else + r =vi_set_ip_blocks (adev);if (r)return r;break ;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
@@ -385,13 +385,13 @@ static const struct pci_device_id pciidlist[] = { {0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, - {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, + {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA | AMD_IS_VF}, {0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},/* fiji */ {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, - {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, + {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI | AMD_IS_VF},/* carrizo */ {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU}, {0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
--
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
In reply to a message not in the archiveQuoted 14 lines · Xiangliang Yu
According to chip device id to set VF flag, and call virtual interface to setup all realted IP blocks.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct amdgpu_device *adev) · line 1289
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1@@ -1285,7 +1285,10 @@ static int amdgpu_early_init(struct amdgpu_device *adev)else adev->family =AMDGPU_FAMILY_VI ; - r =vi_set_ip_blocks (adev); +if (adev->flags &AMD_IS_VF ) + r =amd_xgpu_set_ip_blocks (adev);
As far as I can see there's no need for a special amd_xgpu_set_ip_blocks() function. Just handle the VF case directly in vi_set_ip_blocks() and avoid all the extra indirection.
Alex
Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+else + r =vi_set_ip_blocks (adev);if (r)return r;break ;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-3@@ -385,13 +385,13 @@ static const struct pci_device_id pciidlist[] = { {0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, - {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, + {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA | AMD_IS_VF}, {0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},/* fiji */ {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, - {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, + {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI | AMD_IS_VF},/* carrizo */ {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU}, {0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU}, --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_PC6oukr7dzoi=wpWthUd9A-zx+-WDW8P0wm1zbRdnz1A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
答复: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
agree with Alex on that, the patch looks overhead on the ip blocks cherry-picking logic, we could keep it as simple as original style,
as long as we know current device is a VF device, we shall know how many ip blocks need be cherry-picked and assembled together
BR Monk
________________________________
发件人: amd-gfx <[email protected]> 代表 Alex Deucher <[email protected]> 发送时间: 2016年12月20日 7:17:26
收件人: Yu, Xiangliang
抄送: dl.SRDC_SW_GPUVirtualization; amd-gfx list
主题: Re: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
Quoted 14 lines · Xiangliang Yu
According to chip device id to set VF flag, and call virtual interface to setup all realted IP blocks.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct amdgpu_device *adev) · line 1289
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1@@ -1285,7 +1285,10 @@ static int amdgpu_early_init(struct amdgpu_device *adev)else adev->family =AMDGPU_FAMILY_VI ; - r =vi_set_ip_blocks (adev); +if (adev->flags &AMD_IS_VF ) + r =amd_xgpu_set_ip_blocks (adev);
As far as I can see there's no need for a special amd_xgpu_set_ip_blocks() function. Just handle the VF case directly in vi_set_ip_blocks() and avoid all the extra indirection.
Alex
Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+else + r =vi_set_ip_blocks (adev);if (r)return r;break ;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-3@@ -385,13 +385,13 @@ static const struct pci_device_id pciidlist[] = { {0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, - {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, + {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA | AMD_IS_VF}, {0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},/* fiji */ {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, - {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, + {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI | AMD_IS_VF},/* carrizo */ {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU}, {0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU}, --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
In reply to a message not in the archiveQuoted 31 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:17 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>
Subject: Re: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGAdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct
Quoted 15 lines · Xiangliang Yu
According to chip device id to set VF flag, and call virtual interface to setup all realted IP blocks.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1285,7 +1285,10 @@ static int amdgpu_early_init(struct
amdgpu_device*adev)Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0else adev->family =AMDGPU_FAMILY_VI ;
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct amdgpu_device *adev) · line 1289
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1- r =vi_set_ip_blocks (adev); +if (adev->flags &AMD_IS_VF ) + r =amd_xgpu_set_ip_blocks (adev);As far as I can see there's no need for a special
amd_xgpu_set_ip_blocks()function. Just handle the VF case directly invi_set_ip_blocks()and avoid all the extra indirection.
My idea is that all virtualization chip share one common interface as a special chip family. It will bring some benefits:
1. Logic code is very clear;
2. Avoid to scatter virtualization code throughout all amdgpu components;
3. Easy to support next virtualization chip without change amdgpu code;
Quoted 22 lines
Alex
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+else + r =vi_set_ip_blocks (adev);if (r)return r;break ;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -385,13 +385,13 @@ static const struct pci_device_id pciidlist[] = { {0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, - {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, + {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA | + AMD_IS_VF}, {0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct pci_device_id pciidlist[] = {
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1/* fiji */ {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, - {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, + {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI | + AMD_IS_VF},/* carrizo */ {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0,CHIP_CARRIZO|AMD_IS_APU},
Quoted 9 lines
{0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0,CHIP_CARRIZO|AMD_IS_APU},
--
2.7.4_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB170197EFF75F8AB758618A21EB900-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
Quoted 49 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Yu, Xiangliang
Sent: Tuesday, December 20, 2016 12:41 AM
To: Alex Deucher
Cc: dl.SRDC_SW_GPUVirtualization; amd-gfx list
Subject: RE: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGAQuoted 6 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:17 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>;
dl.SRDC_SW_GPUVirtualizationQuoted 24 lines
Subject: Re: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct
Quoted 15 lines · Xiangliang Yu
According to chip device id to set VF flag, and call virtual interface to setup all realted IP blocks.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1285,7 +1285,10 @@ static int amdgpu_early_init(struct
amdgpu_device*adev)Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0else adev->family =AMDGPU_FAMILY_VI ;Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct amdgpu_device *adev) · line 1289
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1- r =vi_set_ip_blocks (adev); +if (adev->flags &AMD_IS_VF ) + r =amd_xgpu_set_ip_blocks (adev);As far as I can see there's no need for a special
amd_xgpu_set_ip_blocks()function. Just handle the VF case directly invi_set_ip_blocks()and avoid all the extra indirection.
Quoted 6 lines
My idea is that all virtualization chip share one common interface as a special chip family. It will bring some benefits:
1. Logic code is very clear;
2. Avoid to scatter virtualization code throughout all amdgpu components;
3. Easy to support next virtualization chip without change amdgpu code;
I don't mind having a separate IP module for special VF related setup, but I think the differences in the list of IP modules is small enough that it doesn't warrant all of the redirection. Basically just:
if (VF) {
add_ip_module(A);
add_ip_module(X);
add_ip_module(C);
} else {
add_ip_module(A);
add_ip_module(B);
add_ip_module(C);
add_ip_module(D);
}That way it's obvious in one place which modules are present in the VF and bare metal cases without having to trace through a bunch of indirection. It also makes it easier to update the lists if we ever rework the ip module interface or add a new IP module or something like that.
Alex
Quoted 35 lines
Quoted 35 lines
Alex
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+else + r =vi_set_ip_blocks (adev);if (r)return r;break ;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -385,13 +385,13 @@ static const struct pci_device_id pciidlist[] = { {0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, - {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, + {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA | + AMD_IS_VF},drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct pci_device_id pciidlist[] = {
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1{0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},/* fiji */ {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, - {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, + {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI | + AMD_IS_VF},/* carrizo */ {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0,CHIP_CARRIZO|AMD_IS_APU},
Quoted 5 lines
{0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0,CHIP_CARRIZO|AMD_IS_APU},
--
2.7.4
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1652A9F6AB1818BD6C7D3542F7900-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
Quoted 86 lines
-----Original Message-----
From: Deucher, Alexander
Sent: Tuesday, December 20, 2016 11:53 PM
To: Yu, Xiangliang <[email protected]>; Alex Deucher <[email protected]>
Cc: dl.SRDC_SW_GPUVirtualization <[email protected]>; amd-gfx list <amd- [email protected]>
Subject: RE: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGAQuoted 51 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Yu, Xiangliang
Sent: Tuesday, December 20, 2016 12:41 AM
To: Alex Deucher
Cc: dl.SRDC_SW_GPUVirtualization; amd-gfx list
Subject: RE: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGAQuoted 6 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:17 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualizationQuoted 25 lines
Subject: Re: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct
Quoted 15 lines · Xiangliang Yu
According to chip device id to set VF flag, and call virtual interface to setup all realted IP blocks.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1285,7 +1285,10 @@ static int amdgpu_early_init(struct
amdgpu_device*adev)Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0else adev->family =AMDGPU_FAMILY_VI ;Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct · line 1289
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1- r =vi_set_ip_blocks (adev); +if (adev->flags &AMD_IS_VF ) + r =amd_xgpu_set_ip_blocks (adev);As far as I can see there's no need for a special
amd_xgpu_set_ip_blocks()function. Just handle the VF case directly invi_set_ip_blocks()and avoid all the extra indirection.Quoted 7 lines
My idea is that all virtualization chip share one common interface as a special chip family. It will bring some benefits:
1. Logic code is very clear;
2. Avoid to scatter virtualization code throughout all amdgpu components; 3. Easy to support next virtualization chip without change amdgpu code;I don't mind having a separate IP module for special VF related setup, but I think the differences in the list of IP modules is small enough that it doesn't warrant all of the redirection. Basically just:
if (VF) { add_ip_module(A); add_ip_module(X); add_ip_module(C); } else { add_ip_module(A); add_ip_module(B); add_ip_module(C); add_ip_module(D); }
Quoted 4 lines
That way it's obvious in one place which modules are present in the VF and bare metal cases without having to trace through a bunch of indirection. It also makes it easier to update the lists if we ever rework the ip module interface or add a new IP module or something like that.
My point is we want to centrally manage all virtualization, like as power play component does.
For you, the code is not big difference, but for us, easy to implement new features, support new chips, and add new setting for virtualization. Otherwise, there are lot of virtualization check in amdgpu and bring lot of effects to maintain virtualization code.
You know, virtualization is very big feature for graphics.
Please think about from what I'm standing.
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+else + r =vi_set_ip_blocks (adev);if (r)return r;break ;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -385,13 +385,13 @@ static const struct pci_device_id pciidlist[] = { {0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, - {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, + {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA + | AMD_IS_VF},drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct pci_device_id pciidlist[] = {
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1{0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},/* fiji */ {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, - {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, + {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI | + AMD_IS_VF},/* carrizo */ {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0,CHIP_CARRIZO|AMD_IS_APU},
Quoted 5 lines
{0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0,CHIP_CARRIZO|AMD_IS_APU},
--
2.7.4
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB1701ACAA1FD55685C05F0B73EB930-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
Am 21.12.2016 um 02:59 schrieb Yu, Xiangliang:
Quoted 86 lines
Quoted 82 lines
-----Original Message-----
From: Deucher, Alexander
Sent: Tuesday, December 20, 2016 11:53 PM
To: Yu, Xiangliang <[email protected]>; Alex Deucher <[email protected]>
Cc: dl.SRDC_SW_GPUVirtualization <[email protected]>; amd-gfx list <amd- [email protected]>
Subject: RE: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGAQuoted 49 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Yu, Xiangliang
Sent: Tuesday, December 20, 2016 12:41 AM
To: Alex Deucher
Cc: dl.SRDC_SW_GPUVirtualization; amd-gfx list
Subject: RE: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGAQuoted 6 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:17 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualizationQuoted 25 lines
Subject: Re: [PATCH 09/23] drm/amdgpu: enable virtualization feature for FIJI/TONGA
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct
Quoted 15 lines · Xiangliang Yu
According to chip device id to set VF flag, and call virtual interface to setup all realted IP blocks.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1285,7 +1285,10 @@ static int amdgpu_early_init(struct
amdgpu_device*adev)Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0else adev->family =AMDGPU_FAMILY_VI ;Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_early_init(struct · line 1289
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1- r =vi_set_ip_blocks (adev); +if (adev->flags &AMD_IS_VF ) + r =amd_xgpu_set_ip_blocks (adev);As far as I can see there's no need for a special
amd_xgpu_set_ip_blocks()function. Just handle the VF case directly invi_set_ip_blocks()and avoid all the extra indirection.Quoted 7 lines
My idea is that all virtualization chip share one common interface as a special chip family. It will bring some benefits:
1. Logic code is very clear;
2. Avoid to scatter virtualization code throughout all amdgpu components; 3. Easy to support next virtualization chip without change amdgpu code;I don't mind having a separate IP module for special VF related setup, but I think the differences in the list of IP modules is small enough that it doesn't warrant all of the redirection. Basically just:
if (VF) { add_ip_module(A); add_ip_module(X); add_ip_module(C); } else { add_ip_module(A); add_ip_module(B); add_ip_module(C); add_ip_module(D); }Quoted 4 lines
That way it's obvious in one place which modules are present in the VF and bare metal cases without having to trace through a bunch of indirection. It also makes it easier to update the lists if we ever rework the ip module interface or add a new IP module or something like that.
Quoted 6 lines
My point is we want to centrally manage all virtualization, like as power play component does.
For you, the code is not big difference, but for us, easy to implement new features, support new chips, and add new setting for virtualization. Otherwise, there are lot of virtualization check in amdgpu and bring lot of effects to maintain virtualization code.
You know, virtualization is very big feature for graphics.Please think about from what I'm standing.
Sorry, but I have to agree with Alex here. Powerplay is separate because it affects multiple components at the same time.
Virtualization doesn't justify at all having it a separate module like Powerplay. It's just an addition to the existing IP modules, not something completely new.
Additional to that it is likely that virtualization will change over time, so the separation like Alex suggest makes a lot of sense.
Regards,
Christian.
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+else + r =vi_set_ip_blocks (adev);if (r)return r;break ;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -385,13 +385,13 @@ static const struct pci_device_id pciidlist[] = { {0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, - {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, + {0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA + | AMD_IS_VF},drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct pci_device_id pciidlist[] = {
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1{0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},/* fiji */ {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, - {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, + {0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI | + AMD_IS_VF},/* carrizo */ {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0,CHIP_CARRIZO|AMD_IS_APU},
Quoted 9 lines
{0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0,CHIP_CARRIZO|AMD_IS_APU},
--
2.7.4_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/23 drm/amdgpu: export gem va update interface
In reply to a message not in the archiveContext Save Area feature need to update va info so that hardware can save state into correct area. So export it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -412,6 +412,9 @@ struct amdgpu_bo { };#define gem_to_amdgpu_bo (gobj) container_of((gobj), struct amdgpu_bo, gem_base) +void amdgpu_gem_va_update_vm (struct amdgpu_device *adev, +struct amdgpu_bo_va *bo_va, +uint32_t operation);void amdgpu_gem_object_free (struct drm_gem_object *obj);int amdgpu_gem_object_open (struct drm_gem_object *obj,struct drm_file *file_priv);
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -3
@@ -490,9 +490,9 @@ static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo)* Update the bo_va directly after setting it's address. Errors are not * vital here, so they are not reported back to userspace. */ -static void amdgpu_gem_va_update_vm (struct amdgpu_device *adev, -struct amdgpu_bo_va *bo_va, -uint32_t operation) +void amdgpu_gem_va_update_vm (struct amdgpu_device *adev, +struct amdgpu_bo_va *bo_va, +uint32_t operation) {struct ttm_validate_buffer tv, *entry;struct amdgpu_bo_list_entry vm_pd;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/23 drm/amdgpu: implement context save area(CSA) feature
In reply to a message not in the archiveCSA is need by world switch. This patch implement CSA feature and bind it to each VM, so hardware can save the state into the area and restore it when running again.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 14 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 12 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 209 +++++++++++++++++++++++++++++++ 5 files changed, 247 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +14 -0
@@ -24,6 +24,8 @@#ifndef AMDGPU_VIRT_H #define AMDGPU_VIRT_H +struct amdgpu_vm ; +#define AMDGPU_SRIOV_CAPS_SRIOV_VBIOS (1 << 0)/* vBIOS is sr-iov ready */ #define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1)/* sr-iov is enabled on this GPU */ #define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2)/* this GPU is a virtual function */
@@ -33,6 +35,14 @@ struct amdgpu_virtualization {uint32_t virtual_caps; }; +struct amdgpu_csa { +struct amdgpu_bo_va *va; +struct ttm_validate_buffer tv; +uint64_t reserved_top; +uint64_t csa_addr; +uint64_t gds_addr; +}; +#define amdgpu_sriov_enabled (adev) \ ((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)
@@ -55,4 +65,8 @@ static inline bool is_virtual_machine(void) }int amd_xgpu_set_ip_blocks (struct amdgpu_device *adev); + +/* Context Save Area functions */ +int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm); +void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8 -0
@@ -1539,6 +1539,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) pd_size =amdgpu_vm_directory_size (adev); pd_entries =amdgpu_vm_num_pdes (adev); + vm->csa.reserved_top =AMDGPU_VA_RESERVED_SIZE ; +/* allocate page table array */ vm->page_tables =drm_calloc_large (pd_entries,sizeof (struct amdgpu_vm_pt ));if (vm->page_tables ==NULL ) {
@@ -1576,6 +1578,10 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) vm->last_eviction_counter =atomic64_read (&adev->num_evictions);amdgpu_bo_unreserve (vm->page_directory); + r =amdgpu_vm_map_csa (adev, vm); +if (r) + goto error_free_page_directory; +return 0 ; error_free_page_directory:
@@ -1606,6 +1612,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)struct amdgpu_bo_va_mapping *mapping, *tmp;int i; +amdgpu_vm_unmap_csa (adev, vm); +amd_sched_entity_fini (vm->entity.sched, &vm->entity);if (!RB_EMPTY_ROOT (&vm->va)) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4 -0
@@ -29,6 +29,7 @@#include "gpu_scheduler.h" #include "amdgpu_sync.h" #include "amdgpu_ring.h" +#include "amdgpu_virt.h" struct amdgpu_bo_va ;struct amdgpu_job ;
@@ -109,6 +110,9 @@ struct amdgpu_vm {/* Scheduler entity for page table updates */ struct amd_sched_entity entity; +/* Context Save Area */ +struct amdgpu_csa csa; +/* client id */ u64 client_id; };
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +12 -0
@@ -26,12 +26,24 @@#include "amdgpu.h" +/* xgpu structures */ +struct amd_xgpu_csa { +struct amdgpu_bo *robj; +uint64_t gpu_addr; +uint64_t gds_addr; +int32_t size; +}; +struct amd_xgpu {struct amdgpu_device *adev;struct mutex lock; +struct amd_xgpu_csa sa;u32 reg_val_offs; };extern int amd_xgpu_alloc (struct amdgpu_device *adev);extern void amd_xgpu_free (struct amd_xgpu *xgpu); + +extern int xgpu_allocate_csa (struct amd_xgpu *xgpu); +extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa);#endif
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +209 -0
209 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-12-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) feature
Quoted 6 lines · Xiangliang Yu
CSA is need by world switch. This patch implement CSA feature and bind it to each VM, so hardware can save the state into the area and restore it when running again.
Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>
Isn't the CSA actually for preemption? Preemption is useful outside of the VF case as well so it should be untangled from the mxgpu code so it can be utilized independently.
Alex
Quoted 348 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 14 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 12 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 209 +++++++++++++++++++++++++++++++ 5 files changed, 247 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_csa.cdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +14
-0@@ -24,6 +24,8 @@#ifndef AMDGPU_VIRT_H #define AMDGPU_VIRT_H +struct amdgpu_vm ; +#define AMDGPU_SRIOV_CAPS_SRIOV_VBIOS (1 << 0)/* vBIOS is sr-iov ready */ #define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1)/* sr-iov is enabled on this GPU */ #define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2)/* this GPU is a virtual function */ @@ -33,6 +35,14 @@ struct amdgpu_virtualization {uint32_t virtual_caps; }; +struct amdgpu_csa { +struct amdgpu_bo_va *va; +struct ttm_validate_buffer tv; +uint64_t reserved_top; +uint64_t csa_addr; +uint64_t gds_addr; +}; +#define amdgpu_sriov_enabled (adev) \ ((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)@@ -55,4 +65,8 @@ static inline bool is_virtual_machine(void) }int amd_xgpu_set_ip_blocks (struct amdgpu_device *adev); + +/* Context Save Area functions */ +int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm); +void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm);#endif drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-0@@ -1539,6 +1539,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) pd_size =amdgpu_vm_directory_size (adev); pd_entries =amdgpu_vm_num_pdes (adev); + vm->csa.reserved_top =AMDGPU_VA_RESERVED_SIZE ; +/* allocate page table array */ vm->page_tables =drm_calloc_large (pd_entries,sizeof (struct amdgpu_vm_pt ));if (vm->page_tables ==NULL ) {@@ -1576,6 +1578,10 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) vm->last_eviction_counter =atomic64_read (&adev->num_evictions);amdgpu_bo_unreserve (vm->page_directory); + r =amdgpu_vm_map_csa (adev, vm); +if (r) + goto error_free_page_directory; +return 0 ; error_free_page_directory:@@ -1606,6 +1612,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)struct amdgpu_bo_va_mapping *mapping, *tmp;int i; +amdgpu_vm_unmap_csa (adev, vm); +amd_sched_entity_fini (vm->entity.sched, &vm->entity);if (!RB_EMPTY_ROOT (&vm->va)) {drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4
-0@@ -29,6 +29,7 @@#include "gpu_scheduler.h" #include "amdgpu_sync.h" #include "amdgpu_ring.h" +#include "amdgpu_virt.h" struct amdgpu_bo_va ;struct amdgpu_job ;@@ -109,6 +110,9 @@ struct amdgpu_vm {/* Scheduler entity for page table updates */ struct amd_sched_entity entity; +/* Context Save Area */ +struct amdgpu_csa csa; +/* client id */ u64 client_id; };drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +12
-0@@ -26,12 +26,24 @@#include "amdgpu.h" +/* xgpu structures */ +struct amd_xgpu_csa { +struct amdgpu_bo *robj; +uint64_t gpu_addr; +uint64_t gds_addr; +int32_t size; +}; +struct amd_xgpu {struct amdgpu_device *adev;struct mutex lock; +struct amd_xgpu_csa sa;u32 reg_val_offs; };extern int amd_xgpu_alloc (struct amdgpu_device *adev);extern void amd_xgpu_free (struct amd_xgpu *xgpu); + +extern int xgpu_allocate_csa (struct amd_xgpu *xgpu); +extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +209
-1@@ -0,0 +1,209 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +* [email protected] +* +*/ +#include "amd_mxgpu.h" +#include "vid.h" + +static int xgpu_init_csa (struct amdgpu_device *adev,struct amd_xgpu_csa *sa) +{ +int r, size; +void *ptr; + +/* meta data (4k) + gds-gfx (4k)*/ + size =PAGE_SIZE + adev->gds.mem.gfx_partition_size; + + r =amdgpu_bo_create (adev, size,PAGE_SIZE , true, +AMDGPU_GEM_DOMAIN_GTT , +AMDGPU_GEM_CREATE_CPU_GTT_USWC , +NULL ,NULL , &sa->robj); +if (r) { +dev_err (adev->dev,"(%d) failed to allocate csa bo\n" , r); +return r; + } + + r =amdgpu_bo_reserve (sa->robj, true); +if (unlikely (r !=0 )) + goto error_free; + + r =amdgpu_bo_pin (sa->robj,AMDGPU_GEM_DOMAIN_GTT , &sa->gpu_addr); +if (r) + goto error_unreserve; + + r =amdgpu_bo_kmap (sa->robj, &ptr); +if (r) + goto error_unpin; + +memset (ptr,0 , size); +amdgpu_bo_unreserve (sa->robj); + + sa->size = size; + sa->gds_addr = sa->gpu_addr +PAGE_SIZE ; + +return 0 ; + +error_unpin: +amdgpu_bo_unpin (sa->robj); +error_unreserve: +amdgpu_bo_unreserve (sa->robj); +error_free: +amdgpu_bo_unref (&sa->robj); +return r; +} + +int xgpu_allocate_csa (struct amd_xgpu *xgpu) +{ +struct amdgpu_device *adev = xgpu->adev; +struct amd_xgpu_csa *sa = &xgpu->sa; + +return xgpu_init_csa (adev, sa); +} + +void xgpu_destroy_csa (struct amd_xgpu_csa *sa) +{ +amdgpu_bo_reserve (sa->robj, true); +amdgpu_bo_unpin (sa->robj); +amdgpu_bo_unreserve (sa->robj); +amdgpu_bo_unref (&sa->robj); + sa->gpu_addr =0 ; + sa->gds_addr =0 ; +} + +static int xgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amd_xgpu_csa *sa) +{ +int r; +uint64_t vaddr; +struct ww_acquire_ctx ticket; +struct list_head list, duplicates; +struct amdgpu_bo_list_entry pd; +struct amdgpu_bo_va *bo_va; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); +INIT_LIST_HEAD (&vm->csa.tv.head); + vm->csa.tv.bo = &sa->robj->tbo; + vm->csa.tv.shared = true; + +list_add (&vm->csa.tv.head, &list); +amdgpu_vm_get_pd_bo (vm, &list, &pd); + +spin_lock (&vm->status_lock); + vm->csa.reserved_top -= sa->size; + vaddr = vm->csa.reserved_top; +spin_unlock (&vm->status_lock); + + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates); +if (r) { +DRM_ERROR ("failed to reserve global CSA buffer(%d).\n" , r); +return r; + } + + bo_va =amdgpu_vm_bo_add (adev, vm, sa->robj); +if (!bo_va) { +DRM_ERROR ("failed to create bo_va for global CSA buffer.\n" ); +return -ENOMEM ; + } + + + r =amdgpu_vm_bo_map (adev, bo_va, vaddr,0 , sa->size, +AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE | +AMDGPU_PTE_EXECUTABLE ); +if (r) { +DRM_ERROR ("failed to do bo_map on global CSA buffer(%d).\n" , r); +amdgpu_vm_bo_rmv (adev, bo_va); +ttm_eu_backoff_reservation (&ticket, &list); +kfree (bo_va); +return r; + } + +ttm_eu_backoff_reservation (&ticket, &list); +amdgpu_gem_va_update_vm (adev, bo_va,AMDGPU_VA_OP_MAP ); + + vm->csa.va = bo_va; + vm->csa.csa_addr = vaddr; + vm->csa.gds_addr = vaddr +PAGE_SIZE ; + +return 0 ; +} + +int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm) +{ +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amd_xgpu_csa *sa =NULL ; + +if (!xgpu) +return 0 ; + + sa = &xgpu->sa; + +return xgpu_vm_map_csa (adev, vm, sa); +} + +static void xgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amd_xgpu_csa *sa) +{ +int r; +struct ww_acquire_ctx ticket; +struct list_head list, duplicates; +struct amdgpu_bo_list_entry pd; + +if (!vm->csa.va) +return ; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); +list_add (&vm->csa.tv.head, &list); +amdgpu_vm_get_pd_bo (vm, &list, &pd); + + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates); +if (r) { +DRM_ERROR ("failed to reserve global CSA buffer(%d).\n" , r); +return ; + } + +amdgpu_vm_bo_rmv (adev, vm->csa.va); +/* maybe we don't need to do real clearing for the vm will die soon */ + r =amdgpu_vm_clear_freed (adev, vm); +if (r) { +DRM_ERROR ("failed to clear global CSA bo(%d).\n" , r); +return ; + } + +ttm_eu_backoff_reservation (&ticket, &list); + vm->csa.va =NULL ; + vm->csa.csa_addr = vm->csa.gds_addr =0 ; +} + +void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm) +{ +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amd_xgpu_csa *sa =NULL ; + +if (!xgpu) +return ; + + sa = &xgpu->sa; +xgpu_vm_unmap_csa (adev, vm, sa); +} --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_P1hOrd7Vk1G01Gj7aM1RjkyhgLGWV6CnTu9mvrGhtxsg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
答复: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) feature
the CSA is used for world switch, and each amdgpu device should have one and only one CSA,
and this CSA will pined, and mapped to each virtual memory /process.
CP/RLCV will use this CSA buffer when preemption occurred, and will write some hardware status into this CSA buffer, within the current IB's context (that's why need do mapping for each virtual memory on CSA)
BR Monk
________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2016年12月20日 7:20:09
收件人: Yu, Xiangliang
抄送: amd-gfx list; dl.SRDC_SW_GPUVirtualization; Liu, Monk
主题: Re: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) feature
Quoted 6 lines · Xiangliang Yu
CSA is need by world switch. This patch implement CSA feature and bind it to each VM, so hardware can save the state into the area and restore it when running again.
Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>
Isn't the CSA actually for preemption? Preemption is useful outside of the VF case as well so it should be untangled from the mxgpu code so it can be utilized independently.
Alex
Quoted 348 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 14 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 12 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 209 +++++++++++++++++++++++++++++++ 5 files changed, 247 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_csa.cdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +14
-0@@ -24,6 +24,8 @@#ifndef AMDGPU_VIRT_H #define AMDGPU_VIRT_H +struct amdgpu_vm ; +#define AMDGPU_SRIOV_CAPS_SRIOV_VBIOS (1 << 0)/* vBIOS is sr-iov ready */ #define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1)/* sr-iov is enabled on this GPU */ #define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2)/* this GPU is a virtual function */ @@ -33,6 +35,14 @@ struct amdgpu_virtualization {uint32_t virtual_caps; }; +struct amdgpu_csa { +struct amdgpu_bo_va *va; +struct ttm_validate_buffer tv; +uint64_t reserved_top; +uint64_t csa_addr; +uint64_t gds_addr; +}; +#define amdgpu_sriov_enabled (adev) \ ((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)@@ -55,4 +65,8 @@ static inline bool is_virtual_machine(void) }int amd_xgpu_set_ip_blocks (struct amdgpu_device *adev); + +/* Context Save Area functions */ +int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm); +void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm);#endif drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-0@@ -1539,6 +1539,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) pd_size =amdgpu_vm_directory_size (adev); pd_entries =amdgpu_vm_num_pdes (adev); + vm->csa.reserved_top =AMDGPU_VA_RESERVED_SIZE ; +/* allocate page table array */ vm->page_tables =drm_calloc_large (pd_entries,sizeof (struct amdgpu_vm_pt ));if (vm->page_tables ==NULL ) {@@ -1576,6 +1578,10 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) vm->last_eviction_counter =atomic64_read (&adev->num_evictions);amdgpu_bo_unreserve (vm->page_directory); + r =amdgpu_vm_map_csa (adev, vm); +if (r) + goto error_free_page_directory; +return 0 ; error_free_page_directory:@@ -1606,6 +1612,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)struct amdgpu_bo_va_mapping *mapping, *tmp;int i; +amdgpu_vm_unmap_csa (adev, vm); +amd_sched_entity_fini (vm->entity.sched, &vm->entity);if (!RB_EMPTY_ROOT (&vm->va)) {drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4
-0@@ -29,6 +29,7 @@#include "gpu_scheduler.h" #include "amdgpu_sync.h" #include "amdgpu_ring.h" +#include "amdgpu_virt.h" struct amdgpu_bo_va ;struct amdgpu_job ;@@ -109,6 +110,9 @@ struct amdgpu_vm {/* Scheduler entity for page table updates */ struct amd_sched_entity entity; +/* Context Save Area */ +struct amdgpu_csa csa; +/* client id */ u64 client_id; };drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +12
-0@@ -26,12 +26,24 @@#include "amdgpu.h" +/* xgpu structures */ +struct amd_xgpu_csa { +struct amdgpu_bo *robj; +uint64_t gpu_addr; +uint64_t gds_addr; +int32_t size; +}; +struct amd_xgpu {struct amdgpu_device *adev;struct mutex lock; +struct amd_xgpu_csa sa;u32 reg_val_offs; };extern int amd_xgpu_alloc (struct amdgpu_device *adev);extern void amd_xgpu_free (struct amd_xgpu *xgpu); + +extern int xgpu_allocate_csa (struct amd_xgpu *xgpu); +extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +209
-1@@ -0,0 +1,209 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +* [email protected] +* +*/ +#include "amd_mxgpu.h" +#include "vid.h" + +static int xgpu_init_csa (struct amdgpu_device *adev,struct amd_xgpu_csa *sa) +{ +int r, size; +void *ptr; + +/* meta data (4k) + gds-gfx (4k)*/ + size =PAGE_SIZE + adev->gds.mem.gfx_partition_size; + + r =amdgpu_bo_create (adev, size,PAGE_SIZE , true, +AMDGPU_GEM_DOMAIN_GTT , +AMDGPU_GEM_CREATE_CPU_GTT_USWC , +NULL ,NULL , &sa->robj); +if (r) { +dev_err (adev->dev,"(%d) failed to allocate csa bo\n" , r); +return r; + } + + r =amdgpu_bo_reserve (sa->robj, true); +if (unlikely (r !=0 )) + goto error_free; + + r =amdgpu_bo_pin (sa->robj,AMDGPU_GEM_DOMAIN_GTT , &sa->gpu_addr); +if (r) + goto error_unreserve; + + r =amdgpu_bo_kmap (sa->robj, &ptr); +if (r) + goto error_unpin; + +memset (ptr,0 , size); +amdgpu_bo_unreserve (sa->robj); + + sa->size = size; + sa->gds_addr = sa->gpu_addr +PAGE_SIZE ; + +return 0 ; + +error_unpin: +amdgpu_bo_unpin (sa->robj); +error_unreserve: +amdgpu_bo_unreserve (sa->robj); +error_free: +amdgpu_bo_unref (&sa->robj); +return r; +} + +int xgpu_allocate_csa (struct amd_xgpu *xgpu) +{ +struct amdgpu_device *adev = xgpu->adev; +struct amd_xgpu_csa *sa = &xgpu->sa; + +return xgpu_init_csa (adev, sa); +} + +void xgpu_destroy_csa (struct amd_xgpu_csa *sa) +{ +amdgpu_bo_reserve (sa->robj, true); +amdgpu_bo_unpin (sa->robj); +amdgpu_bo_unreserve (sa->robj); +amdgpu_bo_unref (&sa->robj); + sa->gpu_addr =0 ; + sa->gds_addr =0 ; +} + +static int xgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amd_xgpu_csa *sa) +{ +int r; +uint64_t vaddr; +struct ww_acquire_ctx ticket; +struct list_head list, duplicates; +struct amdgpu_bo_list_entry pd; +struct amdgpu_bo_va *bo_va; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); +INIT_LIST_HEAD (&vm->csa.tv.head); + vm->csa.tv.bo = &sa->robj->tbo; + vm->csa.tv.shared = true; + +list_add (&vm->csa.tv.head, &list); +amdgpu_vm_get_pd_bo (vm, &list, &pd); + +spin_lock (&vm->status_lock); + vm->csa.reserved_top -= sa->size; + vaddr = vm->csa.reserved_top; +spin_unlock (&vm->status_lock); + + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates); +if (r) { +DRM_ERROR ("failed to reserve global CSA buffer(%d).\n" , r); +return r; + } + + bo_va =amdgpu_vm_bo_add (adev, vm, sa->robj); +if (!bo_va) { +DRM_ERROR ("failed to create bo_va for global CSA buffer.\n" ); +return -ENOMEM ; + } + + + r =amdgpu_vm_bo_map (adev, bo_va, vaddr,0 , sa->size, +AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE | +AMDGPU_PTE_EXECUTABLE ); +if (r) { +DRM_ERROR ("failed to do bo_map on global CSA buffer(%d).\n" , r); +amdgpu_vm_bo_rmv (adev, bo_va); +ttm_eu_backoff_reservation (&ticket, &list); +kfree (bo_va); +return r; + } + +ttm_eu_backoff_reservation (&ticket, &list); +amdgpu_gem_va_update_vm (adev, bo_va,AMDGPU_VA_OP_MAP ); + + vm->csa.va = bo_va; + vm->csa.csa_addr = vaddr; + vm->csa.gds_addr = vaddr +PAGE_SIZE ; + +return 0 ; +} + +int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm) +{ +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amd_xgpu_csa *sa =NULL ; + +if (!xgpu) +return 0 ; + + sa = &xgpu->sa; + +return xgpu_vm_map_csa (adev, vm, sa); +} + +static void xgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amd_xgpu_csa *sa) +{ +int r; +struct ww_acquire_ctx ticket; +struct list_head list, duplicates; +struct amdgpu_bo_list_entry pd; + +if (!vm->csa.va) +return ; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); +list_add (&vm->csa.tv.head, &list); +amdgpu_vm_get_pd_bo (vm, &list, &pd); + + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates); +if (r) { +DRM_ERROR ("failed to reserve global CSA buffer(%d).\n" , r); +return ; + } + +amdgpu_vm_bo_rmv (adev, vm->csa.va); +/* maybe we don't need to do real clearing for the vm will die soon */ + r =amdgpu_vm_clear_freed (adev, vm); +if (r) { +DRM_ERROR ("failed to clear global CSA bo(%d).\n" , r); +return ; + } + +ttm_eu_backoff_reservation (&ticket, &list); + vm->csa.va =NULL ; + vm->csa.csa_addr = vm->csa.gds_addr =0 ; +} + +void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm) +{ +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amd_xgpu_csa *sa =NULL ; + +if (!xgpu) +return ; + + sa = &xgpu->sa; +xgpu_vm_unmap_csa (adev, vm, sa); +} --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BY2PR12MB00547F38C7E612AE3A4D027184900-K//h7OWB4q7GdVlgMuSljQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) feature
Thank monk’s detail expanation.
And I think this patch is only support virtualization world switch, not touch whole amdpgu preemption.
Thanks!
Xiangliang Yu
From: Liu, Monk
Sent: Tuesday, December 20, 2016 11:58 AM
To: Alex Deucher <[email protected]>; Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>
Subject: 答复: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) feature
the CSA is used for world switch, and each amdgpu device should have one and only one CSA,
and this CSA will pined, and mapped to each virtual memory /process.
CP/RLCV will use this CSA buffer when preemption occurred, and will write some hardware status into this CSA buffer, within the current IB's context (that's why need do mapping for each virtual memory on CSA)
BR Monk
________________________________
发件人: Alex Deucher <[email protected]<mailto:[email protected]>> 发送时间: 2016年12月20日 7:20:09
收件人: Yu, Xiangliang
抄送: amd-gfx list; dl.SRDC_SW_GPUVirtualization; Liu, Monk
主题: Re: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) feature
Quoted 6 lines · On Sat, Dec 17, 2016 at 11:16 AM, Xiangliang Yu…
CSA is need by world switch. This patch implement CSA feature and bind it to each VM, so hardware can save the state into the area and restore it when running again.
Isn't the CSA actually for preemption? Preemption is useful outside of the VF case as well so it should be untangled from the mxgpu code so it can be utilized independently.
Alex
Quoted 348 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 14 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 12 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 209 +++++++++++++++++++++++++++++++ 5 files changed, 247 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_csa.cdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +14
-0@@ -24,6 +24,8 @@#ifndef AMDGPU_VIRT_H #define AMDGPU_VIRT_H +struct amdgpu_vm ; +#define AMDGPU_SRIOV_CAPS_SRIOV_VBIOS (1 << 0)/* vBIOS is sr-iov ready */ #define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1)/* sr-iov is enabled on this GPU */ #define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2)/* this GPU is a virtual function */ @@ -33,6 +35,14 @@ struct amdgpu_virtualization {uint32_t virtual_caps; }; +struct amdgpu_csa { +struct amdgpu_bo_va *va; +struct ttm_validate_buffer tv; +uint64_t reserved_top; +uint64_t csa_addr; +uint64_t gds_addr; +}; +#define amdgpu_sriov_enabled (adev) \ ((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)@@ -55,4 +65,8 @@ static inline bool is_virtual_machine(void) }int amd_xgpu_set_ip_blocks (struct amdgpu_device *adev); + +/* Context Save Area functions */ +int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm); +void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm);#endif drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-0@@ -1539,6 +1539,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) pd_size =amdgpu_vm_directory_size (adev); pd_entries =amdgpu_vm_num_pdes (adev); + vm->csa.reserved_top =AMDGPU_VA_RESERVED_SIZE ; +/* allocate page table array */ vm->page_tables =drm_calloc_large (pd_entries,sizeof (struct amdgpu_vm_pt ));if (vm->page_tables ==NULL ) {@@ -1576,6 +1578,10 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) vm->last_eviction_counter =atomic64_read (&adev->num_evictions);amdgpu_bo_unreserve (vm->page_directory); + r =amdgpu_vm_map_csa (adev, vm); +if (r) + goto error_free_page_directory; +return 0 ; error_free_page_directory:@@ -1606,6 +1612,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)struct amdgpu_bo_va_mapping *mapping, *tmp;int i; +amdgpu_vm_unmap_csa (adev, vm); +amd_sched_entity_fini (vm->entity.sched, &vm->entity);if (!RB_EMPTY_ROOT (&vm->va)) {drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4
-0@@ -29,6 +29,7 @@#include "gpu_scheduler.h" #include "amdgpu_sync.h" #include "amdgpu_ring.h" +#include "amdgpu_virt.h" struct amdgpu_bo_va ;struct amdgpu_job ;@@ -109,6 +110,9 @@ struct amdgpu_vm {/* Scheduler entity for page table updates */ struct amd_sched_entity entity; +/* Context Save Area */ +struct amdgpu_csa csa; +/* client id */ u64 client_id; };drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +12
-0@@ -26,12 +26,24 @@#include "amdgpu.h" +/* xgpu structures */ +struct amd_xgpu_csa { +struct amdgpu_bo *robj; +uint64_t gpu_addr; +uint64_t gds_addr; +int32_t size; +}; +struct amd_xgpu {struct amdgpu_device *adev;struct mutex lock; +struct amd_xgpu_csa sa;u32 reg_val_offs; };extern int amd_xgpu_alloc (struct amdgpu_device *adev);extern void amd_xgpu_free (struct amd_xgpu *xgpu); + +extern int xgpu_allocate_csa (struct amd_xgpu *xgpu); +extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +209
-1@@ -0,0 +1,209 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected]<mailto:[email protected]> +* [email protected]<mailto:[email protected]> +* +*/ +#include "amd_mxgpu.h" +#include "vid.h" + +static int xgpu_init_csa (struct amdgpu_device *adev,struct amd_xgpu_csa *sa) +{ +int r, size; +void *ptr; + +/* meta data (4k) + gds-gfx (4k)*/ + size =PAGE_SIZE + adev->gds.mem.gfx_partition_size; + + r =amdgpu_bo_create (adev, size,PAGE_SIZE , true, +AMDGPU_GEM_DOMAIN_GTT , +AMDGPU_GEM_CREATE_CPU_GTT_USWC , +NULL ,NULL , &sa->robj); +if (r) { +dev_err (adev->dev,"(%d) failed to allocate csa bo\n" , r); +return r; + } + + r =amdgpu_bo_reserve (sa->robj, true); +if (unlikely (r !=0 )) + goto error_free; + + r =amdgpu_bo_pin (sa->robj,AMDGPU_GEM_DOMAIN_GTT , &sa->gpu_addr); +if (r) + goto error_unreserve; + + r =amdgpu_bo_kmap (sa->robj, &ptr); +if (r) + goto error_unpin; + +memset (ptr,0 , size); +amdgpu_bo_unreserve (sa->robj); + + sa->size = size; + sa->gds_addr = sa->gpu_addr +PAGE_SIZE ; + +return 0 ; + +error_unpin: +amdgpu_bo_unpin (sa->robj); +error_unreserve: +amdgpu_bo_unreserve (sa->robj); +error_free: +amdgpu_bo_unref (&sa->robj); +return r; +} + +int xgpu_allocate_csa (struct amd_xgpu *xgpu) +{ +struct amdgpu_device *adev = xgpu->adev; +struct amd_xgpu_csa *sa = &xgpu->sa; + +return xgpu_init_csa (adev, sa); +} + +void xgpu_destroy_csa (struct amd_xgpu_csa *sa) +{ +amdgpu_bo_reserve (sa->robj, true); +amdgpu_bo_unpin (sa->robj); +amdgpu_bo_unreserve (sa->robj); +amdgpu_bo_unref (&sa->robj); + sa->gpu_addr =0 ; + sa->gds_addr =0 ; +} + +static int xgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amd_xgpu_csa *sa) +{ +int r; +uint64_t vaddr; +struct ww_acquire_ctx ticket; +struct list_head list, duplicates; +struct amdgpu_bo_list_entry pd; +struct amdgpu_bo_va *bo_va; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); +INIT_LIST_HEAD (&vm->csa.tv.head); + vm->csa.tv.bo = &sa->robj->tbo; + vm->csa.tv.shared = true; + +list_add (&vm->csa.tv.head, &list); +amdgpu_vm_get_pd_bo (vm, &list, &pd); + +spin_lock (&vm->status_lock); + vm->csa.reserved_top -= sa->size; + vaddr = vm->csa.reserved_top; +spin_unlock (&vm->status_lock); + + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates); +if (r) { +DRM_ERROR ("failed to reserve global CSA buffer(%d).\n" , r); +return r; + } + + bo_va =amdgpu_vm_bo_add (adev, vm, sa->robj); +if (!bo_va) { +DRM_ERROR ("failed to create bo_va for global CSA buffer.\n" ); +return -ENOMEM ; + } + + + r =amdgpu_vm_bo_map (adev, bo_va, vaddr,0 , sa->size, +AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE | +AMDGPU_PTE_EXECUTABLE ); +if (r) { +DRM_ERROR ("failed to do bo_map on global CSA buffer(%d).\n" , r); +amdgpu_vm_bo_rmv (adev, bo_va); +ttm_eu_backoff_reservation (&ticket, &list); +kfree (bo_va); +return r; + } + +ttm_eu_backoff_reservation (&ticket, &list); +amdgpu_gem_va_update_vm (adev, bo_va,AMDGPU_VA_OP_MAP ); + + vm->csa.va = bo_va; + vm->csa.csa_addr = vaddr; + vm->csa.gds_addr = vaddr +PAGE_SIZE ; + +return 0 ; +} + +int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm) +{ +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amd_xgpu_csa *sa =NULL ; + +if (!xgpu) +return 0 ; + + sa = &xgpu->sa; + +return xgpu_vm_map_csa (adev, vm, sa); +} + +static void xgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amd_xgpu_csa *sa) +{ +int r; +struct ww_acquire_ctx ticket; +struct list_head list, duplicates; +struct amdgpu_bo_list_entry pd; + +if (!vm->csa.va) +return ; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); +list_add (&vm->csa.tv.head, &list); +amdgpu_vm_get_pd_bo (vm, &list, &pd); + + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates); +if (r) { +DRM_ERROR ("failed to reserve global CSA buffer(%d).\n" , r); +return ; + } + +amdgpu_vm_bo_rmv (adev, vm->csa.va); +/* maybe we don't need to do real clearing for the vm will die soon */ + r =amdgpu_vm_clear_freed (adev, vm); +if (r) { +DRM_ERROR ("failed to clear global CSA bo(%d).\n" , r); +return ; + } + +ttm_eu_backoff_reservation (&ticket, &list); + vm->csa.va =NULL ; + vm->csa.csa_addr = vm->csa.gds_addr =0 ; +} + +void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm) +{ +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amd_xgpu_csa *sa =NULL ; + +if (!xgpu) +return ; + + sa = &xgpu->sa; +xgpu_vm_unmap_csa (adev, vm, sa); +} --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB1701351D6DCEA18714735B3DEB900-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) feature
NAK on that whole approach. We previously had similar handling in radeon for the temporary IB buffer and it was a pain to support correctly.
The main problem is that you might then have a mismatch between the housekeeping structures in the VM and what is really in the page tables / page directory.
Additional a concrete problem is that you simply assume that the PD and PTs are present when the VM is created, but that might not be correct under memory pressure. In this case the code below will just fail miserable.
I suggest that you go a step back and fully implement the support for the CSA for each context and not just a quick hack like this. If I remember our internal discussion correctly Monk already had promising locking patches for this for the general preemption support.
Regards,
Christian.
Am 20.12.2016 um 06:43 schrieb Yu, Xiangliang:
Quoted 433 lines
Thank monk’s detail expanation.
And I think this patch is only support virtualization world switch, not touch whole amdpgu preemption.
Thanks!
Xiangliang Yu
*From:*Liu, Monk
*Sent:* Tuesday, December 20, 2016 11:58 AM
*To:* Alex Deucher <[email protected]>; Yu, Xiangliang <[email protected]>
*Cc:* amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]> *Subject:* 答复: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) featurethe CSA is used for world switch, and each amdgpu device should have one and only one CSA,
and this CSA will pined, and mapped to each virtual memory /process.
CP/RLCV will use this CSA buffer when preemption occurred, and will write some hardware status into this CSA buffer, within the current IB's context (that's why need do mapping for each virtual memory on CSA)
BR Monk
------------------------------------------------------------------------
*发件人**:*Alex Deucher <[email protected] <mailto:[email protected]>> *发送时间**:*2016年12月20日7:20:09
*收件人**:*Yu, Xiangliang
*抄送**:*amd-gfx list; dl.SRDC_SW_GPUVirtualization; Liu, Monk
*主题**:*Re: [PATCH 11/23] drm/amdgpu: implement context save area(CSA) featureQuoted 6 lines · On Sat, Dec 17, 2016 at 11:16 AM, Xiangliang Yu…
CSA is need by world switch. This patch implement CSA feature and bind it to each VM, so hardware can save the state into the area and restore it when running again.
Signed-off-by Monk Liu <[email protected] <mailto:[email protected]>>Signed-off-by Xiangliang Yu <[email protected]<mailto:[email protected]>>
Isn't the CSA actually for preemption? Preemption is useful outside of the VF case as well so it should be untangled from the mxgpu code so it can be utilized independently.
Alex
Quoted 6 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 14 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 12 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 209+++++++++++++++++++++++++++++++
Review
Quoted 4 lines
5 files changed, 247 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.hdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.h line 29
Quoted 10 lines
index 8ee70f8..dff1248 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2
-0@@ -24,6 +24,8 @@#ifndef AMDGPU_VIRT_H #define AMDGPU_VIRT_H +struct amdgpu_vm ; +#define AMDGPU_SRIOV_CAPS_SRIOV_VBIOS (1 << 0)/* vBIOS is sr-iov ready */
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h line 30
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +0
-0#define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1)/* sr-iov is enabled on this GPU */
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h line 31
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +0
-0#define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2)/* this GPU is a virtual function */
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +8
-0@@ -33,6 +35,14 @@ struct amdgpu_virtualization {uint32_t virtual_caps; }; +struct amdgpu_csa { +struct amdgpu_bo_va *va; +struct ttm_validate_buffer tv; +uint64_t reserved_top; +uint64_t csa_addr; +uint64_t gds_addr; +}; +#define amdgpu_sriov_enabled (adev) \ ((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h static inline bool is_virtual_machine(void) · line 70
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +3
-0@@ -55,4 +65,8 @@ static inline bool is_virtual_machine(void) }int amd_xgpu_set_ip_blocks (struct amdgpu_device *adev); + +/* Context Save Area functions */ +int amdgpu_vm_map_csa(struct amdgpu_device *adev, struct amdgpu_vm*vm);
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h static inline bool is_virtual_machine(void) · line 71
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1
-0+void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct
amdgpu_vm*vm);Review
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +0
-0#endif (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.cdrivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev,
Quoted 4 lines
index d05546e..98540d9 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1539,6 +1539,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev,struct
amdgpu_vm*vm)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, · line 1545
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-0pd_size =amdgpu_vm_directory_size (adev); pd_entries =amdgpu_vm_num_pdes (adev); + vm->csa.reserved_top =AMDGPU_VA_RESERVED_SIZE ; +/* allocate page table array */ vm->page_tables = drm_calloc_large(pd_entries, sizeof(struct
amdgpu_vm_pt));drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0if (vm->page_tables ==NULL ) {@@ -1576,6 +1578,10 @@ int amdgpu_vm_init(struct amdgpu_device*adev, struct
amdgpu_vm*vm)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c void amdgpu_vm_fini(struct amdgpu_device
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-0vm->last_eviction_counter =atomic64_read (&adev->num_evictions);amdgpu_bo_unreserve (vm->page_directory); + r =amdgpu_vm_map_csa (adev, vm); +if (r) + goto error_free_page_directory; +return 0 ; error_free_page_directory:@@ -1606,6 +1612,8 @@ void amdgpu_vm_fini(struct amdgpu_device*adev, struct
amdgpu_vm*vm)Review
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-0struct amdgpu_bo_va_mapping *mapping, *tmp;int i; +amdgpu_vm_unmap_csa (adev, vm); +amd_sched_entity_fini (vm->entity.sched, &vm->entity);if (!RB_EMPTY_ROOT (&vm->va)) {(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.hReview
Quoted 22 lines
index 42a629b..d90630a 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4
-0@@ -29,6 +29,7 @@#include "gpu_scheduler.h" #include "amdgpu_sync.h" #include "amdgpu_ring.h" +#include "amdgpu_virt.h" struct amdgpu_bo_va ;struct amdgpu_job ;@@ -109,6 +110,9 @@ struct amdgpu_vm {/* Scheduler entity for page table updates */ struct amd_sched_entity entity; +/* Context Save Area */ +struct amdgpu_csa csa; +/* client id */ u64 client_id; };(quoted diff) +0
-0
b/drivers/gpu/drm/amd/mxgpu/amd_mxgpu.hReview
Quoted 29 lines
index 6ab13bc..a25e07f 100644
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +12
-0@@ -26,12 +26,24 @@#include "amdgpu.h" +/* xgpu structures */ +struct amd_xgpu_csa { +struct amdgpu_bo *robj; +uint64_t gpu_addr; +uint64_t gds_addr; +int32_t size; +}; +struct amd_xgpu {struct amdgpu_device *adev;struct mutex lock; +struct amd_xgpu_csa sa;u32 reg_val_offs; };extern int amd_xgpu_alloc (struct amdgpu_device *adev);extern void amd_xgpu_free (struct amd_xgpu *xgpu); + +extern int xgpu_allocate_csa (struct amd_xgpu *xgpu); +extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa);#endif (quoted diff) +0
-0
b/drivers/gpu/drm/amd/mxgpu/mxgpu_csa.cdrivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 4
Quoted 9 lines
new file mode 100644
index 0000000..246a747drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +4
-0@@ -0,0 +1,209 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 5
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* copy of this software and associated documentation files (the "Software"),
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 6
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* to deal in the Software without restriction, including without limitation
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 7
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 8
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* and/or sell copies of the Software, and to permit persons to whom the
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 11
Quoted 3 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +3
-0+* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 14
Quoted 3 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +3
-0+* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 15
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 16
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 17
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 18
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 19
Quoted 1 line
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +1
-0+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 29
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +10
-0+* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] <mailto:[email protected]> +* [email protected] <mailto:[email protected]> +* +*/ +#include "amd_mxgpu.h" +#include "vid.h" + +static int xgpu_init_csa(struct amdgpu_device *adev, struct
amd_xgpu_csa*sa)drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 42
Quoted 13 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +13
-0+{ +int r, size; +void *ptr; + +/* meta data (4k) + gds-gfx (4k)*/ + size =PAGE_SIZE + adev->gds.mem.gfx_partition_size; + + r =amdgpu_bo_create (adev, size,PAGE_SIZE , true, +AMDGPU_GEM_DOMAIN_GTT , +AMDGPU_GEM_CREATE_CPU_GTT_USWC , +NULL ,NULL , &sa->robj); +if (r) { + dev_err(adev->dev, "(%d) failed to allocate csabo\n", r);
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 50
Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +8
-0+return r; + } + + r =amdgpu_bo_reserve (sa->robj, true); +if (unlikely (r !=0 )) + goto error_free; + + r = amdgpu_bo_pin(sa->robj, AMDGPU_GEM_DOMAIN_GTT,
&sa->gpu_addr);Quoted 33 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +33
-0+if (r) + goto error_unreserve; + + r =amdgpu_bo_kmap (sa->robj, &ptr); +if (r) + goto error_unpin; + +memset (ptr,0 , size); +amdgpu_bo_unreserve (sa->robj); + + sa->size = size; + sa->gds_addr = sa->gpu_addr +PAGE_SIZE ; + +return 0 ; + +error_unpin: +amdgpu_bo_unpin (sa->robj); +error_unreserve: +amdgpu_bo_unreserve (sa->robj); +error_free: +amdgpu_bo_unref (&sa->robj); +return r; +} + +int xgpu_allocate_csa (struct amd_xgpu *xgpu) +{ +struct amdgpu_device *adev = xgpu->adev; +struct amd_xgpu_csa *sa = &xgpu->sa; + +return xgpu_init_csa (adev, sa); +} + +void xgpu_destroy_csa (struct amd_xgpu_csa *sa)drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 93
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +10
-0+{ +amdgpu_bo_reserve (sa->robj, true); +amdgpu_bo_unpin (sa->robj); +amdgpu_bo_unreserve (sa->robj); +amdgpu_bo_unref (&sa->robj); + sa->gpu_addr =0 ; + sa->gds_addr =0 ; +} + +static int xgpu_vm_map_csa(struct amdgpu_device *adev, struct
amdgpu_vm*vm,Quoted 16 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +16
-0+ struct amd_xgpu_csa *sa) +{ +int r; +uint64_t vaddr; +struct ww_acquire_ctx ticket; +struct list_head list, duplicates; +struct amdgpu_bo_list_entry pd; +struct amdgpu_bo_va *bo_va; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); +INIT_LIST_HEAD (&vm->csa.tv.head); + vm->csa.tv.bo = &sa->robj->tbo; + vm->csa.tv.shared = true; + +list_add (&vm->csa.tv.head, &list);drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 119
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +10
-0+amdgpu_vm_get_pd_bo (vm, &list, &pd); + +spin_lock (&vm->status_lock); + vm->csa.reserved_top -= sa->size; + vaddr = vm->csa.reserved_top; +spin_unlock (&vm->status_lock); + + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates); +if (r) { + DRM_ERROR("failed to reserve global CSAbuffer(%d).\n", r);
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 125
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +6
-0+return r; + } + + bo_va =amdgpu_vm_bo_add (adev, vm, sa->robj); +if (!bo_va) { + DRM_ERROR("failed to create bo_va for global CSAbuffer.\n");
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 131
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +6
-0+return -ENOMEM ; + } + + + r = amdgpu_vm_bo_map(adev, bo_va, vaddr, 0, sa->size, + AMDGPU_PTE_READABLE |
AMDGPU_PTE_WRITEABLE|drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 134
Quoted 3 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +3
-0+ AMDGPU_PTE_EXECUTABLE); +if (r) { + DRM_ERROR("failed to do bo_map on global CSAbuffer(%d).\n", r);
Quoted 20 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +20
-0+amdgpu_vm_bo_rmv (adev, bo_va); +ttm_eu_backoff_reservation (&ticket, &list); +kfree (bo_va); +return r; + } + +ttm_eu_backoff_reservation (&ticket, &list); +amdgpu_gem_va_update_vm (adev, bo_va,AMDGPU_VA_OP_MAP ); + + vm->csa.va = bo_va; + vm->csa.csa_addr = vaddr; + vm->csa.gds_addr = vaddr +PAGE_SIZE ; + +return 0 ; +} + +int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm) +{ +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amd_xgpu_csa *sa =NULL ;drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 164
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +10
-0+ +if (!xgpu) +return 0 ; + + sa = &xgpu->sa; + +return xgpu_vm_map_csa (adev, vm, sa); +} + +static void xgpu_vm_unmap_csa(struct amdgpu_device *adev, struct
amdgpu_vm*vm,Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +8
-0+ struct amd_xgpu_csa *sa) +{ +int r; +struct ww_acquire_ctx ticket; +struct list_head list, duplicates; +struct amdgpu_bo_list_entry pd; + +if (!vm->csa.va)drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 182
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +10
-0+return ; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); +list_add (&vm->csa.tv.head, &list); +amdgpu_vm_get_pd_bo (vm, &list, &pd); + + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates); +if (r) { + DRM_ERROR("failed to reserve global CSAbuffer(%d).\n", r);
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 187
Quoted 5 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +5
-0+return ; + } + +amdgpu_vm_bo_rmv (adev, vm->csa.va); +/* maybe we don't need to do real clearing for the vm will die soon */
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c line 199
Quoted 12 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +12
-0+ r =amdgpu_vm_clear_freed (adev, vm); +if (r) { +DRM_ERROR ("failed to clear global CSA bo(%d).\n" , r); +return ; + } + +ttm_eu_backoff_reservation (&ticket, &list); + vm->csa.va =NULL ; + vm->csa.csa_addr = vm->csa.gds_addr =0 ; +} + +void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct
amdgpu_vm*vm)Quoted 13 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c new file +10
-1+{ +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amd_xgpu_csa *sa =NULL ; + +if (!xgpu) +return ; + + sa = &xgpu->sa; +xgpu_vm_unmap_csa (adev, vm, sa); +} --2.7.4
Quoted 11 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected] <mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/23 drm/amdgpu: Insert meta data during submitting IB
In reply to a message not in the archiveVirtualization world switch need each command that is submitted into GFX with an extra entry, which will using WRITE_DATA to fullfill CSA. In this way, CP will save CE/DE snapshots when preemption occurred and restore it later.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 39 ++++++++++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 88 ++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -0
@@ -175,6 +175,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,if (ring->funcs->emit_hdp_flush)amdgpu_ring_emit_hdp_flush (ring); +amdgpu_gfx_ring_emit_meta_data (ring, vm); +/* always set cond_exec_polling to CONTINUE */ *ring->cond_exe_cpu_addr =1 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -0
@@ -69,4 +69,6 @@ int amd_xgpu_set_ip_blocks(struct amdgpu_device *adev);/* Context Save Area functions */ int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm);void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm); +void amdgpu_gfx_ring_emit_meta_data (struct amdgpu_ring *ring, +struct amdgpu_vm *vm);#endif
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +39 -0
@@ -26,9 +26,48 @@#include "amdgpu.h" +/* context save area structures */ +struct amdgpu_ce_ib_state { +uint32_t ce_ib_completion_status; +uint32_t ce_const_engine_count; +uint32_t ce_ib_offset_ib1; +uint32_t ce_ib_offset_ib2; +}; + +struct amdgpu_de_ib_state { +uint32_t de_ib_completion_status; +uint32_t de_const_engine_count; +uint32_t de_ib_offset_ib1; +uint32_t de_ib_offset_ib2; +uint32_t preamble_begin_ib1; +uint32_t preamble_begin_ib2; +uint32_t preamble_end_ib1; +uint32_t preamble_end_ib2; +uint32_t draw_indirect_base_lo; +uint32_t draw_indirect_base_hi; +uint32_t disp_indirect_base_lo; +uint32_t disp_indirect_base_hi; +uint32_t gds_backup_addr_lo; +uint32_t gds_backup_addr_hi; +uint32_t index_base_addr_lo; +uint32_t index_base_addr_hi; +uint32_t sample_cntl; +}; + +struct amdgpu_gfx_meta_data { +struct amdgpu_ce_ib_state ce_payload; +uint32_t reserved1[60 ]; +struct amdgpu_de_ib_state de_payload; +uint32_t de_ib_base_addr_lo; +uint32_t de_ib_base_addr_hi; +uint32_t reserved2[941 ]; +}; +/* xgpu structures */ struct amd_xgpu_csa {struct amdgpu_bo *robj; +struct amdgpu_ce_ib_state ce_payload; +struct amdgpu_de_ib_state de_payload;uint64_t gpu_addr;uint64_t gds_addr;int32_t size;
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +88 -0
91 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-13-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 12/23] drm/amdgpu: Insert meta data during submitting IB
Quoted 73 lines · Xiangliang Yu
Virtualization world switch need each command that is submitted into GFX with an extra entry, which will using
WRITE_DATAto fullfill CSA. In this way, CP will save CE/DE snapshots when preemption occurred and restore it later.Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 39 ++++++++++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 88 ++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2
-0@@ -175,6 +175,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,if (ring->funcs->emit_hdp_flush)amdgpu_ring_emit_hdp_flush (ring); +amdgpu_gfx_ring_emit_meta_data (ring, vm); +/* always set cond_exec_polling to CONTINUE */ *ring->cond_exe_cpu_addr =1 ;drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2
-0@@ -69,4 +69,6 @@ int amd_xgpu_set_ip_blocks(struct amdgpu_device *adev);/* Context Save Area functions */ int amdgpu_vm_map_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm);void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm); +void amdgpu_gfx_ring_emit_meta_data (struct amdgpu_ring *ring, +struct amdgpu_vm *vm);#endif drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +27
-0@@ -26,9 +26,48 @@#include "amdgpu.h" +/* context save area structures */ +struct amdgpu_ce_ib_state { +uint32_t ce_ib_completion_status; +uint32_t ce_const_engine_count; +uint32_t ce_ib_offset_ib1; +uint32_t ce_ib_offset_ib2; +}; + +struct amdgpu_de_ib_state { +uint32_t de_ib_completion_status; +uint32_t de_const_engine_count; +uint32_t de_ib_offset_ib1; +uint32_t de_ib_offset_ib2; +uint32_t preamble_begin_ib1; +uint32_t preamble_begin_ib2; +uint32_t preamble_end_ib1; +uint32_t preamble_end_ib2; +uint32_t draw_indirect_base_lo; +uint32_t draw_indirect_base_hi; +uint32_t disp_indirect_base_lo; +uint32_t disp_indirect_base_hi; +uint32_t gds_backup_addr_lo; +uint32_t gds_backup_addr_hi; +uint32_t index_base_addr_lo; +uint32_t index_base_addr_hi; +uint32_t sample_cntl; +};
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h line 65
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +10
-0+ +struct amdgpu_gfx_meta_data { +struct amdgpu_ce_ib_state ce_payload; +uint32_t reserved1[60 ]; +struct amdgpu_de_ib_state de_payload; +uint32_t de_ib_base_addr_lo; +uint32_t de_ib_base_addr_hi; +uint32_t reserved2[941 ]; +}; +
These are gfx8 specific and should be moved to gfx8 module.
Quoted 54 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +2
-0/* xgpu structures */ struct amd_xgpu_csa {struct amdgpu_bo *robj; +struct amdgpu_ce_ib_state ce_payload; +struct amdgpu_de_ib_state de_payload;uint64_t gpu_addr;uint64_t gds_addr;int32_t size;drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +38
-0@@ -207,3 +207,91 @@ void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm) sa = &xgpu->sa;xgpu_vm_unmap_csa (adev, vm, sa); } + +static void amdgpu_ring_write_multiple (struct amdgpu_ring *ring, +void *src,int count_dw) +{ +if (ring->count_dw < count_dw) +DRM_ERROR ("writing more dwords to the ring than expected:%d.\n" , + count_dw); +else { +unsigned int chunk1, chunk2; +void *dst = (void *)&ring->ring[ring->wptr]; + + chunk1 = ring->ptr_mask +1 - ring->wptr; + chunk1 = (chunk1 >= count_dw) ? count_dw : chunk1; + chunk2 = count_dw - chunk1; + chunk1 <<=2 ; + chunk2 <<=2 ; +if (chunk1) { +memcpy (dst, src, chunk1); + dst = (void *)(((uint64_t )dst + chunk1) & + ring->ptr_mask); + } + +if (chunk2) { + src += chunk1; + dst = (void *)ring->ring; +memcpy (dst, src, chunk2); + } + + ring->wptr += count_dw; + ring->wptr &= ring->ptr_mask; + ring->count_dw -= count_dw; + } +} + +void amdgpu_gfx_ring_emit_meta_data (struct amdgpu_ring *ring, +struct amdgpu_vm *vm) +{ +struct amdgpu_ce_ib_state *ce_payload;
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm) · line 257
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +10
-0+struct amdgpu_de_ib_state *de_payload; +struct amd_xgpu_csa *sa =NULL ; +struct amd_xgpu *xgpu = (struct amd_xgpu *)ring->adev->priv_data; +uint64_t csa_addr, gds_addr; +int cnt; + +if (!xgpu || (ring->funcs->type !=AMDGPU_RING_TYPE_GFX )) +return ; + + sa = &xgpu->sa;
No need to make this dependent on xgpu. As I said in the previous patch preemption is useful independent of xgpu.
Quoted 30 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +30
-0+ + ce_payload = &sa->ce_payload; + de_payload = &sa->de_payload; +memset (ce_payload,0 ,sizeof (*ce_payload)); +memset (de_payload,0 ,sizeof (*de_payload)); + + cnt = (sizeof (*ce_payload) >>2 ) +4 -2 ; + csa_addr = vm ? vm->csa.csa_addr : sa->gpu_addr; + gds_addr = vm ? vm->csa.gds_addr : sa->gds_addr; + de_payload->gds_backup_addr_lo =lower_32_bits (gds_addr); + de_payload->gds_backup_addr_hi =upper_32_bits (gds_addr); + +/* write CE meta data */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA , cnt)); +amdgpu_ring_write (ring,WRITE_DATA_ENGINE_SEL (2 ) | +WRITE_DATA_DST_SEL (8 ) | +WR_CONFIRM |WRITE_DATA_CACHE_POLICY (0 )); +amdgpu_ring_write (ring,lower_32_bits (csa_addr + + offsetof(struct amdgpu_gfx_meta_data , ce_payload))); +amdgpu_ring_write (ring,upper_32_bits (csa_addr + + offsetof(struct amdgpu_gfx_meta_data , ce_payload))); + +amdgpu_ring_write_multiple (ring, (void *)ce_payload, +sizeof (*ce_payload) >>2 ); + +/* write DE meta data */ + cnt = (sizeof (*de_payload) >>2 ) +4 -2 ; + +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA , cnt)); + amdgpu_ring_write(ring, WRITE_DATA_ENGINE_SEL(1) |
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm) · line 297
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +10
-0+WRITE_DATA_DST_SEL (8 ) | + WR_CONFIRM | WRITE_DATA_CACHE_POLICY(0)); +amdgpu_ring_write (ring,lower_32_bits (csa_addr + + offsetof(struct amdgpu_gfx_meta_data , de_payload))); +amdgpu_ring_write (ring,upper_32_bits (csa_addr + + offsetof(struct amdgpu_gfx_meta_data , de_payload))); + +amdgpu_ring_write_multiple (ring, (void *)de_payload, +sizeof (*de_payload) >>2 ); +}
This function is gfx8 specific and should be moved to the gfx8 module.
Alex
Quoted 7 lines
--
2.7.4_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_M++bzSVb-58Mesk1eAyK7Phwfgnx-XGCtEGygAomP-iQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 12/23] drm/amdgpu: Insert meta data during submitting IB
Quoted 99 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:23 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>; Liu, Monk <[email protected]>
Subject: Re: [PATCH 12/23] drm/amdgpu: Insert meta data during submitting IBQuoted 5 lines · Xiangliang Yu
Virtualization world switch need each command that is submitted into GFX with an extra entry, which will using
WRITE_DATAto fullfill CSA. In this way, CP will save CE/DE snapshots when preemption occurred and restore it later.Quoted 7 lines
Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 39 ++++++++++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 88++++++++++++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring,
Quoted 8 lines
4 files changed, 131 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -175,6 +175,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring,unsigned
num_ibs,Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2
-0if (ring->funcs->emit_hdp_flush)amdgpu_ring_emit_hdp_flush (ring); +amdgpu_gfx_ring_emit_meta_data (ring, vm); +/* always set cond_exec_polling to CONTINUE */ *ring->cond_exe_cpu_addr =1 ;drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h int amd_xgpu_set_ip_blocks(struct amdgpu_device · line 71
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +0
-0@@ -69,4 +69,6 @@ int amd_xgpu_set_ip_blocks(struct amdgpu_device *adev);/* Context Save Area functions */ int amdgpu_vm_map_csa(struct amdgpu_device *adev, struct
amdgpu_vmQuoted 45 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +0
-0*vm); void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct
amdgpu_vm*vm);drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2
-0+void amdgpu_gfx_ring_emit_meta_data (struct amdgpu_ring *ring, +struct amdgpu_vm *vm);#endif drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +31
-0@@ -26,9 +26,48 @@#include "amdgpu.h" +/* context save area structures */ +struct amdgpu_ce_ib_state { +uint32_t ce_ib_completion_status; +uint32_t ce_const_engine_count; +uint32_t ce_ib_offset_ib1; +uint32_t ce_ib_offset_ib2; +}; + +struct amdgpu_de_ib_state { +uint32_t de_ib_completion_status; +uint32_t de_const_engine_count; +uint32_t de_ib_offset_ib1; +uint32_t de_ib_offset_ib2; +uint32_t preamble_begin_ib1; +uint32_t preamble_begin_ib2; +uint32_t preamble_end_ib1; +uint32_t preamble_end_ib2; +uint32_t draw_indirect_base_lo; +uint32_t draw_indirect_base_hi; +uint32_t disp_indirect_base_lo; +uint32_t disp_indirect_base_hi; +uint32_t gds_backup_addr_lo; +uint32_t gds_backup_addr_hi; +uint32_t index_base_addr_lo; +uint32_t index_base_addr_hi; +uint32_t sample_cntl; +}; + +struct amdgpu_gfx_meta_data { +struct amdgpu_ce_ib_state ce_payload; +uint32_t reserved1[60 ];
Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h line 65
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +6
-0+struct amdgpu_de_ib_state de_payload; +uint32_t de_ib_base_addr_lo; +uint32_t de_ib_base_addr_hi; +uint32_t reserved2[941 ]; +}; +These are gfx8 specific and should be moved to gfx8 module.
I think it is only relate to virtualization right now. I'm fine to move it out if support whole preemption solution later.
Quoted 60 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c void amdgpu_vm_unmap_csa(struct
Quoted 15 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +2
-0/* xgpu structures */ struct amd_xgpu_csa {struct amdgpu_bo *robj; +struct amdgpu_ce_ib_state ce_payload; +struct amdgpu_de_ib_state de_payload;uint64_t gpu_addr;uint64_t gds_addr;int32_t size;drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +0
-0@@ -207,3 +207,91 @@ void amdgpu_vm_unmap_csa(struct
amdgpu_device*adev, structamdgpu_vm*vm)drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm)
Quoted 7 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +5
-0sa = &xgpu->sa;xgpu_vm_unmap_csa (adev, vm, sa); } + +static void amdgpu_ring_write_multiple (struct amdgpu_ring *ring, +void *src,int count_dw) { +if (ring->count_dw < count_dw) + DRM_ERROR("writing more dwords to the ring thanexpected:%d.\n",
Quoted 36 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +36
-0+ count_dw); + else { +unsigned int chunk1, chunk2; +void *dst = (void *)&ring->ring[ring->wptr]; + + chunk1 = ring->ptr_mask +1 - ring->wptr; + chunk1 = (chunk1 >= count_dw) ? count_dw : chunk1; + chunk2 = count_dw - chunk1; + chunk1 <<=2 ; + chunk2 <<=2 ; +if (chunk1) { +memcpy (dst, src, chunk1); + dst = (void *)(((uint64_t )dst + chunk1) & + ring->ptr_mask); + } + +if (chunk2) { + src += chunk1; + dst = (void *)ring->ring; +memcpy (dst, src, chunk2); + } + + ring->wptr += count_dw; + ring->wptr &= ring->ptr_mask; + ring->count_dw -= count_dw; + } +} + +void amdgpu_gfx_ring_emit_meta_data (struct amdgpu_ring *ring, +struct amdgpu_vm *vm) { +struct amdgpu_ce_ib_state *ce_payload; +struct amdgpu_de_ib_state *de_payload; +struct amd_xgpu_csa *sa =NULL ; +struct amd_xgpu *xgpu = (struct amd_xgpu *)ring->adev->priv_data; +uint64_t csa_addr, gds_addr; +int cnt;
Quoted 9 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm) · line 257
Quoted 5 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +5
-0+ +if (!xgpu || (ring->funcs->type !=AMDGPU_RING_TYPE_GFX )) +return ; + + sa = &xgpu->sa;No need to make this dependent on xgpu. As I said in the previous patch preemption is useful independent of xgpu.
Ditto
Quoted 35 lines
Quoted 35 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +35
-0+ + ce_payload = &sa->ce_payload; + de_payload = &sa->de_payload; +memset (ce_payload,0 ,sizeof (*ce_payload)); +memset (de_payload,0 ,sizeof (*de_payload)); + + cnt = (sizeof (*ce_payload) >>2 ) +4 -2 ; + csa_addr = vm ? vm->csa.csa_addr : sa->gpu_addr; + gds_addr = vm ? vm->csa.gds_addr : sa->gds_addr; + de_payload->gds_backup_addr_lo =lower_32_bits (gds_addr); + de_payload->gds_backup_addr_hi =upper_32_bits (gds_addr); + +/* write CE meta data */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA , cnt)); +amdgpu_ring_write (ring,WRITE_DATA_ENGINE_SEL (2 ) | +WRITE_DATA_DST_SEL (8 ) | +WR_CONFIRM |WRITE_DATA_CACHE_POLICY (0 )); +amdgpu_ring_write (ring,lower_32_bits (csa_addr + + offsetof(struct amdgpu_gfx_meta_data , ce_payload))); +amdgpu_ring_write (ring,upper_32_bits (csa_addr + + offsetof(struct amdgpu_gfx_meta_data , + ce_payload))); + +amdgpu_ring_write_multiple (ring, (void *)ce_payload, +sizeof (*ce_payload) >>2 ); + +/* write DE meta data */ + cnt = (sizeof (*de_payload) >>2 ) +4 -2 ; + +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA , cnt)); +amdgpu_ring_write (ring,WRITE_DATA_ENGINE_SEL (1 ) | +WRITE_DATA_DST_SEL (8 ) | +WR_CONFIRM |WRITE_DATA_CACHE_POLICY (0 )); +amdgpu_ring_write (ring,lower_32_bits (csa_addr + + offsetof(struct amdgpu_gfx_meta_data , de_payload)));
Quoted 9 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm)
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +6
-0+amdgpu_ring_write (ring,upper_32_bits (csa_addr + + offsetof(struct amdgpu_gfx_meta_data , + de_payload))); + +amdgpu_ring_write_multiple (ring, (void *)de_payload, +sizeof (*de_payload) >>2 ); }This function is gfx8 specific and should be moved to the gfx8 module.
Ditto
Quoted 9 lines
Alex
Quoted 7 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c +0
-1--2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 13/23 drm/amdgpu/mxgpu: add support for mailbox communication
In reply to a message not in the archiveGPU guest driver send mailbox messages to hyperverisor to request full access to all of registers and release it when access is done.
--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 3 + drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c | 128 ++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +3 -0
@@ -85,4 +85,7 @@ extern void amd_xgpu_free(struct amd_xgpu *xgpu);extern int xgpu_allocate_csa (struct amd_xgpu *xgpu);extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa); + +extern int xgpu_request_full_gpu_access (struct amdgpu_device *adev,bool init); +extern int xgpu_release_full_gpu_access (struct amdgpu_device *adev,bool init);#endif
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +128 -0
128 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-14-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 13/23] drm/amdgpu/mxgpu: add support for mailbox communication
Quoted 124 lines · Xiangliang Yu
GPU guest driver send mailbox messages to hyperverisor to request full access to all of registers and release it when access is done.
Signed-off-by Xiangliang Yu <[email protected]>Signed-off-by shaoyunl <[email protected]>--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 3 + drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c | 128 ++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_mb.cdrivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +3
-0@@ -85,4 +85,7 @@ extern void amd_xgpu_free(struct amd_xgpu *xgpu);extern int xgpu_allocate_csa (struct amd_xgpu *xgpu);extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa); + +extern int xgpu_request_full_gpu_access (struct amdgpu_device *adev,bool init); +extern int xgpu_release_full_gpu_access (struct amdgpu_device *adev,bool init);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +95
-0@@ -0,0 +1,128 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +*/ +#include "amd_mxgpu.h" +#include "bif/bif_5_0_d.h" +#include "bif/bif_5_0_sh_mask.h" + +/* mailbox messages request */ +enum idh_request { +IDH_REQ_GPU_INIT_ACCESS =1 , +IDH_REL_GPU_INIT_ACCESS , +IDH_REQ_GPU_FINI_ACCESS , +IDH_REL_GPU_FINI_ACCESS , +IDH_REQ_GPU_RESET_ACCESS +}; + +/* mailbox messages data */ +enum idh_event { +IDH_CLR_MSG_BUF =0 , +IDH_READY_TO_ACCESS_GPU , +IDH_FLR_NOTIFICATION , +IDH_FLR_NOTIFICATION_CMPL +}; + +/* mailbox state */ +enum mail_state { +AMDGPU_START_INIT =1 , +AMDGPU_END_INIT , +AMDGPU_START_FINI , +AMDGPU_END_FINI , +}; + +/* +* Mailbox communicate between PF and VF +*/ +static int xgpu_request_reg_access (struct amdgpu_device *adev, +enum mail_state state) +{ +u32 temp, timeout =150000 ; +u32 req =IDH_REQ_GPU_INIT_ACCESS ; + +if (state ==AMDGPU_START_FINI ) + req =IDH_REQ_GPU_FINI_ACCESS ; +else if (state !=AMDGPU_START_INIT ) +return -EINVAL ; + +WREG32 (mmMAILBOX_MSGBUF_TRN_DW0, req); +WREG32 (mmMAILBOX_CONTROL, +REG_SET_FIELD (RREG32 (mmMAILBOX_CONTROL), +MAILBOX_CONTROL ,TRN_MSG_VALID ,1 )); + +/* wait respond from PF */ +while (true) { + temp =RREG32 (mmMAILBOX_MSGBUF_RCV_DW0); +if (temp ==IDH_READY_TO_ACCESS_GPU ) +break ; +if (timeout ==0 ) { +pr_err ("amdgpu: VF request GPU access failed(0x%x) \ +in state %d\n" , temp, state); +return -ETIME ; + } +msleep (20 ); + timeout -=20 ; + } +return 0 ; +} + +static int xgpu_release_reg_access (struct amdgpu_device *adev, +enum mail_state state) +{ +u32 rel =IDH_REL_GPU_INIT_ACCESS ; + +if (state ==AMDGPU_END_FINI ) + rel =IDH_REL_GPU_FINI_ACCESS ; +else if (state !=AMDGPU_END_INIT )
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 105
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +10
-0+return -EINVAL ; + +WREG32 (mmMAILBOX_MSGBUF_TRN_DW0, rel); +WREG32 (mmMAILBOX_CONTROL, +REG_SET_FIELD (RREG32 (mmMAILBOX_CONTROL), +MAILBOX_CONTROL ,TRN_MSG_VALID ,1 )); + +return 0 ; +} +
These are gfx8 specific. they should be handled in a gfx8 specific code. mxgpu_mb.c should only contain asic independent code.
Alex
Quoted 26 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +23
-1+int xgpu_request_full_gpu_access (struct amdgpu_device *adev,bool init) +{ +int r; + +if (init) + r =xgpu_request_reg_access (adev,AMDGPU_START_INIT ); +else + r =xgpu_request_reg_access (adev,AMDGPU_START_FINI ); + +return r; +} + +int xgpu_release_full_gpu_access (struct amdgpu_device *adev,bool init) +{ +int r; + +if (init) + r =xgpu_release_reg_access (adev,AMDGPU_END_INIT ); +else + r =xgpu_release_reg_access (adev,AMDGPU_END_FINI ); + +return r; +} --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_MZVK4c_eiYqoxxKSSPCtazki=0uB4bOAX8OjVKDnZCBg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 13/23] drm/amdgpu/mxgpu: add support for mailbox communication
Quoted 159 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:25 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: Re: [PATCH 13/23] drm/amdgpu/mxgpu: add support for mailbox communicationQuoted 43 lines · Xiangliang Yu
GPU guest driver send mailbox messages to hyperverisor to request full access to all of registers and release it when access is done.
Signed-off-by Xiangliang Yu <[email protected]>Signed-off-by shaoyunl <[email protected]>--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 3 + drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c | 128 ++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_mb.cdrivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +4
-0@@ -85,4 +85,7 @@ extern void amd_xgpu_free(struct amd_xgpu *xgpu);extern int xgpu_allocate_csa (struct amd_xgpu *xgpu);extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa); + +extern int xgpu_request_full_gpu_access (struct amdgpu_device *adev, +bool init);extern int xgpu_release_full_gpu_access (struct +amdgpu_device *adev,bool init);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +10
-0@@ -0,0 +1,128 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 20
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +10
-0+sublicense, + * and/or sell copies of the Software, and to permit persons to whom +the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be +included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANYKIND,
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 24
Quoted 4 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 30
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +6
-0+SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ORTHE USE
Quoted 79 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +79
-0+OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +*/ +#include "amd_mxgpu.h" +#include "bif/bif_5_0_d.h" +#include "bif/bif_5_0_sh_mask.h" + +/* mailbox messages request */ +enum idh_request { +IDH_REQ_GPU_INIT_ACCESS =1 , +IDH_REL_GPU_INIT_ACCESS , +IDH_REQ_GPU_FINI_ACCESS , +IDH_REL_GPU_FINI_ACCESS , +IDH_REQ_GPU_RESET_ACCESS +}; + +/* mailbox messages data */ +enum idh_event { +IDH_CLR_MSG_BUF =0 , +IDH_READY_TO_ACCESS_GPU , +IDH_FLR_NOTIFICATION , +IDH_FLR_NOTIFICATION_CMPL +}; + +/* mailbox state */ +enum mail_state { +AMDGPU_START_INIT =1 , +AMDGPU_END_INIT , +AMDGPU_START_FINI , +AMDGPU_END_FINI , +}; + +/* +* Mailbox communicate between PF and VF */ static int +xgpu_request_reg_access (struct amdgpu_device *adev, +enum mail_state state) { +u32 temp, timeout =150000 ; +u32 req =IDH_REQ_GPU_INIT_ACCESS ; + +if (state ==AMDGPU_START_FINI ) + req =IDH_REQ_GPU_FINI_ACCESS ; +else if (state !=AMDGPU_START_INIT ) +return -EINVAL ; + +WREG32 (mmMAILBOX_MSGBUF_TRN_DW0, req); +WREG32 (mmMAILBOX_CONTROL, +REG_SET_FIELD (RREG32 (mmMAILBOX_CONTROL), +MAILBOX_CONTROL ,TRN_MSG_VALID ,1 )); + +/* wait respond from PF */ +while (true) { + temp =RREG32 (mmMAILBOX_MSGBUF_RCV_DW0); +if (temp ==IDH_READY_TO_ACCESS_GPU ) +break ; +if (timeout ==0 ) { +pr_err ("amdgpu: VF request GPU access failed(0x%x) \ +in state %d\n" , temp, state); +return -ETIME ; + } +msleep (20 ); + timeout -=20 ; + } +return 0 ; +} + +static int xgpu_release_reg_access (struct amdgpu_device *adev, +enum mail_state state) { +u32 rel =IDH_REL_GPU_INIT_ACCESS ; + +if (state ==AMDGPU_END_FINI ) + rel =IDH_REL_GPU_FINI_ACCESS ; +else if (state !=AMDGPU_END_INIT ) +return -EINVAL ; + +WREG32 (mmMAILBOX_MSGBUF_TRN_DW0, rel); + WREG32(mmMAILBOX_CONTROL, + REG_SET_FIELD(RREG32(mmMAILBOX_CONTROL),
Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 87
Quoted 5 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +5
-0+ MAILBOX_CONTROL, TRN_MSG_VALID, 1)); + +return 0 ; +} +These are gfx8 specific. they should be handled in a gfx8 specific code.
mxgpu_mb.cshould only contain asic independent code.
I don't think so. The mailbox is only used by virtualization, and I'd like to put it into virtualization component.
As I said in cover letter, the main aim of the series is put all virtualization code together and manage different virtualization chips and features. Do not want to mix it into amdgpu components. Otherwise the series will lost meaning.
Quoted 30 lines
Alex
Quoted 26 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +23
-1+int xgpu_request_full_gpu_access (struct amdgpu_device *adev,bool +init) { +int r; + +if (init) + r =xgpu_request_reg_access (adev,AMDGPU_START_INIT ); +else + r =xgpu_request_reg_access (adev,AMDGPU_START_FINI ); + +return r; +} + +int xgpu_release_full_gpu_access (struct amdgpu_device *adev,bool +init) { +int r; + +if (init) + r =xgpu_release_reg_access (adev,AMDGPU_END_INIT ); +else + r =xgpu_release_reg_access (adev,AMDGPU_END_FINI ); + +return r; +} --2.7.4
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB1701DEB3053096F2E9CD1416EB900-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 13/23] drm/amdgpu/mxgpu: add support for mailbox communication
Hi,
I didn't check others changes in the series. For these two specific changes regarding the mailbox communication , I have two concerns
1. This code should only works on SRIOV enabled VF , in your code seems you use adev->priv_data for the check , I would like to have some more meaningful name than priv_data if possible .
2. How you handle the asic specific MAILBOX programming ? ex, for Vega10 support .
Regards
Shaoyun.liu
-----Original Message-----
From: Yu, Xiangliang
Sent: Tuesday, December 20, 2016 1:06 AM
To: Alex Deucher
Cc: amd-gfx list; dl.SRDC_SW_GPUVirtualization; Liu, Shaoyun
Subject: RE: [PATCH 13/23] drm/amdgpu/mxgpu: add support for mailbox communication
Quoted 158 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:25 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: Re: [PATCH 13/23] drm/amdgpu/mxgpu: add support for mailbox communicationQuoted 43 lines · Xiangliang Yu
GPU guest driver send mailbox messages to hyperverisor to request full access to all of registers and release it when access is done.
Signed-off-by Xiangliang Yu <[email protected]>Signed-off-by shaoyunl <[email protected]>--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 3 + drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c | 128 ++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_mb.cdrivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +4
-0@@ -85,4 +85,7 @@ extern void amd_xgpu_free(struct amd_xgpu *xgpu);extern int xgpu_allocate_csa (struct amd_xgpu *xgpu);extern void xgpu_destroy_csa (struct amd_xgpu_csa *csa); + +extern int xgpu_request_full_gpu_access (struct amdgpu_device *adev, +bool init);extern int xgpu_release_full_gpu_access (struct +amdgpu_device *adev,bool init);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +10
-0@@ -0,0 +1,128 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 20
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +10
-0+sublicense, + * and/or sell copies of the Software, and to permit persons to +whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be +included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANYKIND,
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 24
Quoted 4 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 30
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +6
-0+SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ORTHE USE
Quoted 79 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +79
-0+OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +*/ +#include "amd_mxgpu.h" +#include "bif/bif_5_0_d.h" +#include "bif/bif_5_0_sh_mask.h" + +/* mailbox messages request */ +enum idh_request { +IDH_REQ_GPU_INIT_ACCESS =1 , +IDH_REL_GPU_INIT_ACCESS , +IDH_REQ_GPU_FINI_ACCESS , +IDH_REL_GPU_FINI_ACCESS , +IDH_REQ_GPU_RESET_ACCESS +}; + +/* mailbox messages data */ +enum idh_event { +IDH_CLR_MSG_BUF =0 , +IDH_READY_TO_ACCESS_GPU , +IDH_FLR_NOTIFICATION , +IDH_FLR_NOTIFICATION_CMPL +}; + +/* mailbox state */ +enum mail_state { +AMDGPU_START_INIT =1 , +AMDGPU_END_INIT , +AMDGPU_START_FINI , +AMDGPU_END_FINI , +}; + +/* +* Mailbox communicate between PF and VF */ static int +xgpu_request_reg_access (struct amdgpu_device *adev, +enum mail_state state) { +u32 temp, timeout =150000 ; +u32 req =IDH_REQ_GPU_INIT_ACCESS ; + +if (state ==AMDGPU_START_FINI ) + req =IDH_REQ_GPU_FINI_ACCESS ; +else if (state !=AMDGPU_START_INIT ) +return -EINVAL ; + +WREG32 (mmMAILBOX_MSGBUF_TRN_DW0, req); +WREG32 (mmMAILBOX_CONTROL, +REG_SET_FIELD (RREG32 (mmMAILBOX_CONTROL), +MAILBOX_CONTROL ,TRN_MSG_VALID ,1 )); + +/* wait respond from PF */ +while (true) { + temp =RREG32 (mmMAILBOX_MSGBUF_RCV_DW0); +if (temp ==IDH_READY_TO_ACCESS_GPU ) +break ; +if (timeout ==0 ) { +pr_err ("amdgpu: VF request GPU access failed(0x%x) \ +in state %d\n" , temp, state); +return -ETIME ; + } +msleep (20 ); + timeout -=20 ; + } +return 0 ; +} + +static int xgpu_release_reg_access (struct amdgpu_device *adev, +enum mail_state state) { +u32 rel =IDH_REL_GPU_INIT_ACCESS ; + +if (state ==AMDGPU_END_FINI ) + rel =IDH_REL_GPU_FINI_ACCESS ; +else if (state !=AMDGPU_END_INIT ) +return -EINVAL ; + +WREG32 (mmMAILBOX_MSGBUF_TRN_DW0, rel); + WREG32(mmMAILBOX_CONTROL, + REG_SET_FIELD(RREG32(mmMAILBOX_CONTROL),
Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c line 87
Quoted 5 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +5
-0+ MAILBOX_CONTROL, TRN_MSG_VALID, 1)); + +return 0 ; +} +These are gfx8 specific. they should be handled in a gfx8 specific code.
mxgpu_mb.cshould only contain asic independent code.
I don't think so. The mailbox is only used by virtualization, and I'd like to put it into virtualization component.
As I said in cover letter, the main aim of the series is put all virtualization code together and manage different virtualization chips and features. Do not want to mix it into amdgpu components. Otherwise the series will lost meaning.
Quoted 31 lines
Alex
Quoted 27 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c new file +24
-1+int xgpu_request_full_gpu_access (struct amdgpu_device *adev,bool +init) { +int r; + +if (init) + r =xgpu_request_reg_access (adev,AMDGPU_START_INIT ); +else + r =xgpu_request_reg_access (adev, +AMDGPU_START_FINI ); + +return r; +} + +int xgpu_release_full_gpu_access (struct amdgpu_device *adev,bool +init) { +int r; + +if (init) + r =xgpu_release_reg_access (adev,AMDGPU_END_INIT ); +else + r =xgpu_release_reg_access (adev,AMDGPU_END_FINI ); + +return r; +} --2.7.4
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 14/23 drm/amdgpu: export two mailbox interface to amdgpu
In reply to a message not in the archiveKFD also will access GPU registers when loading/unloading drivers, so can't hide the mailbox in mxgpu. Right now, can't find any way to put it into kfd interface, export it into amdgpu.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 4 ++++ drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
@@ -60,6 +60,8 @@ int amdgpu_driver_unload_kms(struct drm_device *dev)if (adev->rmmio ==NULL ) goto done_free; +amdgpu_get_gpu (adev); +if (amdgpu_device_is_px (dev)) {pm_runtime_get_sync (dev->dev);pm_runtime_forbid (dev->dev);
@@ -139,6 +141,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)pm_runtime_put_autosuspend (dev->dev); } +amdgpu_put_gpu (adev); + out:if (r) {/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +4 -0
@@ -71,4 +71,8 @@ int amdgpu_vm_map_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm);void amdgpu_vm_unmap_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm);void amdgpu_gfx_ring_emit_meta_data (struct amdgpu_ring *ring,struct amdgpu_vm *vm); + +/* get full gpu access */ +int amdgpu_get_gpu (struct amdgpu_device *adev); +int amdgpu_put_gpu (struct amdgpu_device *adev);#endif
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c +28 -0
@@ -126,3 +126,31 @@ int xgpu_release_full_gpu_access(struct amdgpu_device *adev, bool init)return r; } + +int amdgpu_get_gpu (struct amdgpu_device *adev) +{ +int r =0 ; + +if (!adev->priv_data) +return 0 ; + + r =xgpu_request_full_gpu_access (adev, false); +if (r) +return r; + +return 0 ; +} + +int amdgpu_put_gpu (struct amdgpu_device *adev) +{ +int r =0 ; + +if (!adev->priv_data) +return 0 ; + + r =xgpu_release_full_gpu_access (adev, true); +if (r) +return r; + +return 0 ; +}
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 15/23 drm/amdgpu/mxgpu: implement register access function with KIQ
In reply to a message not in the archiveOne of important role of KIQ is provide one way to access VF registers. This patch implement the feature and export interfaces.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 4 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c | 110 +++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +4 -0
@@ -75,4 +75,8 @@ void amdgpu_gfx_ring_emit_meta_data(struct amdgpu_ring *ring,/* get full gpu access */ int amdgpu_get_gpu (struct amdgpu_device *adev);int amdgpu_put_gpu (struct amdgpu_device *adev); + +/* access vf registers */ +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg); +void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v);#endif
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +110 -0
110 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-16-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 15/23] drm/amdgpu/mxgpu: implement register access function with KIQ
Quoted 74 lines · Xiangliang Yu
One of important role of KIQ is provide one way to access VF registers. This patch implement the feature and export interfaces.
Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 4 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c | 110 +++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.cdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +4
-0@@ -75,4 +75,8 @@ void amdgpu_gfx_ring_emit_meta_data(struct amdgpu_ring *ring,/* get full gpu access */ int amdgpu_get_gpu (struct amdgpu_device *adev);int amdgpu_put_gpu (struct amdgpu_device *adev); + +/* access vf registers */ +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg); +void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +44
-0@@ -0,0 +1,110 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +* [email protected] +*/ +#include "amd_mxgpu.h" +#include "vid.h" +#include "gca/gfx_8_0_d.h" +#include "gca/gfx_8_0_sh_mask.h" + +static void xgpu_kiq_ring_emit_rreg (struct amdgpu_ring *ring,u32 idx) +{ +struct amdgpu_device *adev = ring->adev; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +amdgpu_ring_write (ring,PACKET3 (PACKET3_COPY_DATA ,4 )); +amdgpu_ring_write (ring,0 |/* src: register*/ + (5 <<8 ) |/* dst: memory */ + (1 <<20 ));/* write confirm */ +amdgpu_ring_write (ring, idx); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (adev->wb.gpu_addr + + xgpu->reg_val_offs *4 )); +amdgpu_ring_write (ring,upper_32_bits (adev->wb.gpu_addr + + xgpu->reg_val_offs *4 ));
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 54
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +10
-0+} + +static void xgpu_kiq_ring_emit_wreg (struct amdgpu_ring *ring,u32 idx,u32 val) +{ +amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (1 <<16 ));/* no inc addr */ +amdgpu_ring_write (ring, idx); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring, val); +}
These should be in gfx8.
Alex
Quoted 59 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +56
-1+ +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) +{ +signed long r; +uint32_t val; +struct fence *f; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amdgpu_kiq *kiq = &adev->kiq; + +if (in_interrupt ()) +return 0 ; + +mutex_lock (&xgpu->lock); +amdgpu_ring_alloc (&kiq->ring,32 ); +amdgpu_ring_emit_hdp_flush (&kiq->ring); +xgpu_kiq_ring_emit_rreg (&kiq->ring, reg); +amdgpu_ring_emit_hdp_invalidate (&kiq->ring); +amdgpu_fence_emit (&kiq->ring, &f); +fence_get (f); +amdgpu_ring_commit (&kiq->ring); +mutex_unlock (&xgpu->lock); + + r =fence_wait (f, false); +fence_put (f); +if (r) +DRM_ERROR ("wait for kiq fence error: %ld.\n" , r); +fence_put (f); + + val = adev->wb.wb[xgpu->reg_val_offs]; + +return val; +} + +void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v) +{ +signed long r; +struct fence *f; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amdgpu_kiq *kiq = &adev->kiq; + +mutex_lock (&xgpu->lock); +amdgpu_ring_alloc (&kiq->ring,32 ); +amdgpu_ring_emit_hdp_flush (&kiq->ring); +xgpu_kiq_ring_emit_wreg (&kiq->ring, reg, v); +amdgpu_ring_emit_hdp_invalidate (&kiq->ring); +amdgpu_fence_emit (&kiq->ring, &f); +fence_get (f); +amdgpu_ring_commit (&kiq->ring); +mutex_unlock (&xgpu->lock); + + r =fence_wait (f, false); +fence_put (f); +if (r) +DRM_ERROR ("wait for kiq fence error: %ld.\n" , r); +fence_put (f); +} --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_M2Mh-=wo0Aa-pS4P-59uLv6My0-LNn_Zuxy913MwhLbA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 15/23] drm/amdgpu/mxgpu: implement register access function with KIQ
Quoted 112 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:27 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>; Liu, Monk <[email protected]>
Subject: Re: [PATCH 15/23] drm/amdgpu/mxgpu: implement register access function with KIQQuoted 8 lines · Xiangliang Yu
One of important role of KIQ is provide one way to access VF registers. This patch implement the feature and export interfaces.
Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 4 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c | 110+++++++++++++++++++++++++++++++
Quoted 36 lines
2 files changed, 114 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.cdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +5
-0@@ -75,4 +75,8 @@ void amdgpu_gfx_ring_emit_meta_data(structamdgpu_ring *ring,/* get full gpu access */ int amdgpu_get_gpu(struct amdgpu_device *adev); intamdgpu_put_gpu (struct amdgpu_device *adev); + +/* access vf registers */ +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg); +void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg, +uint32_t v);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +10
-0@@ -0,0 +1,110 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 20
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +10
-0+sublicense, + * and/or sell copies of the Software, and to permit persons to whom +the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be +included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANYKIND,
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 24
Quoted 4 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 30
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +6
-0+SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ORTHE USE
Quoted 29 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +29
-0+OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +* [email protected] +*/ +#include "amd_mxgpu.h" +#include "vid.h" +#include "gca/gfx_8_0_d.h" +#include "gca/gfx_8_0_sh_mask.h" + +static void xgpu_kiq_ring_emit_rreg (struct amdgpu_ring *ring,u32 +idx) { +struct amdgpu_device *adev = ring->adev; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +amdgpu_ring_write (ring,PACKET3 (PACKET3_COPY_DATA ,4 )); +amdgpu_ring_write (ring,0 |/* src: register*/ + (5 <<8 ) |/* dst: memory */ + (1 <<20 ));/* write confirm */ +amdgpu_ring_write (ring, idx); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (adev->wb.gpu_addr + + xgpu->reg_val_offs *4 )); +amdgpu_ring_write (ring,upper_32_bits (adev->wb.gpu_addr + + xgpu->reg_val_offs *4 )); } + +static void xgpu_kiq_ring_emit_wreg (struct amdgpu_ring *ring,u32 +idx,u32 val) {
Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 54
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +6
-0+amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (1 <<16 ));/* no inc addr */ +amdgpu_ring_write (ring, idx); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring, val); +}These should be in gfx8.
This is only for virtualization, please see my previous patch's comment.
Quoted 61 lines
Alex
Quoted 58 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +55
-1+ +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) { +signed long r; +uint32_t val; +struct fence *f; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amdgpu_kiq *kiq = &adev->kiq; + +if (in_interrupt ()) +return 0 ; + +mutex_lock (&xgpu->lock); +amdgpu_ring_alloc (&kiq->ring,32 ); +amdgpu_ring_emit_hdp_flush (&kiq->ring); +xgpu_kiq_ring_emit_rreg (&kiq->ring, reg); +amdgpu_ring_emit_hdp_invalidate (&kiq->ring); +amdgpu_fence_emit (&kiq->ring, &f); +fence_get (f); +amdgpu_ring_commit (&kiq->ring); +mutex_unlock (&xgpu->lock); + + r =fence_wait (f, false); +fence_put (f); +if (r) +DRM_ERROR ("wait for kiq fence error: %ld.\n" , r); +fence_put (f); + + val = adev->wb.wb[xgpu->reg_val_offs]; + +return val; +} + +void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg, +uint32_t v) { +signed long r; +struct fence *f; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amdgpu_kiq *kiq = &adev->kiq; + +mutex_lock (&xgpu->lock); +amdgpu_ring_alloc (&kiq->ring,32 ); +amdgpu_ring_emit_hdp_flush (&kiq->ring); +xgpu_kiq_ring_emit_wreg (&kiq->ring, reg, v); +amdgpu_ring_emit_hdp_invalidate (&kiq->ring); +amdgpu_fence_emit (&kiq->ring, &f); +fence_get (f); +amdgpu_ring_commit (&kiq->ring); +mutex_unlock (&xgpu->lock); + + r =fence_wait (f, false); +fence_put (f); +if (r) +DRM_ERROR ("wait for kiq fence error: %ld.\n" , r); +fence_put (f); +} --2.7.4
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB170162420FF46FECF0D783B4EB900-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 15/23] drm/amdgpu/mxgpu: implement register access function with KIQ
Quoted 131 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Yu, Xiangliang
Sent: Tuesday, December 20, 2016 1:08 AM
To: Alex Deucher
Cc: dl.SRDC_SW_GPUVirtualization; Liu, Monk; amd-gfx list
Subject: RE: [PATCH 15/23] drm/amdgpu/mxgpu: implement register access function with KIQQuoted 9 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:27 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>; Liu, Monk <[email protected]>
Subject: Re: [PATCH 15/23] drm/amdgpu/mxgpu: implement registeraccess
Quoted 101 lines
function with KIQ
Quoted 8 lines · Xiangliang Yu
One of important role of KIQ is provide one way to access VF registers. This patch implement the feature and export interfaces.
Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 4 ++ drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c | 110+++++++++++++++++++++++++++++++
Quoted 36 lines
2 files changed, 114 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.cdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +5
-0@@ -75,4 +75,8 @@ void amdgpu_gfx_ring_emit_meta_data(structamdgpu_ring *ring,/* get full gpu access */ int amdgpu_get_gpu(struct amdgpu_device *adev); intamdgpu_put_gpu (struct amdgpu_device *adev); + +/* access vf registers */ +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg); +void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg, +uint32_t v);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +10
-0@@ -0,0 +1,110 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 20
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +10
-0+sublicense, + * and/or sell copies of the Software, and to permit persons to whom +the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be +included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANYKIND,
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 24
Quoted 4 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 30
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +6
-0+SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ORTHE USE
Quoted 29 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +29
-0+OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: [email protected] +* [email protected] +*/ +#include "amd_mxgpu.h" +#include "vid.h" +#include "gca/gfx_8_0_d.h" +#include "gca/gfx_8_0_sh_mask.h" + +static void xgpu_kiq_ring_emit_rreg (struct amdgpu_ring *ring,u32 +idx) { +struct amdgpu_device *adev = ring->adev; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +amdgpu_ring_write (ring,PACKET3 (PACKET3_COPY_DATA ,4 )); +amdgpu_ring_write (ring,0 |/* src: register*/ + (5 <<8 ) |/* dst: memory */ + (1 <<20 ));/* write confirm */ +amdgpu_ring_write (ring, idx); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring,lower_32_bits (adev->wb.gpu_addr + + xgpu->reg_val_offs *4 )); +amdgpu_ring_write (ring,upper_32_bits (adev->wb.gpu_addr + + xgpu->reg_val_offs *4 )); } + +static void xgpu_kiq_ring_emit_wreg (struct amdgpu_ring *ring,u32 +idx,u32 val) {Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c line 54
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +6
-0+amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); +amdgpu_ring_write (ring, (1 <<16 ));/* no inc addr */ +amdgpu_ring_write (ring, idx); +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring, val); +}These should be in gfx8.
Quoted 1 line
This is only for virtualization, please see my previous patch's comment.
Right, but it's gfx8 specific. The packet and register interface may change on other asics. Maybe put the gfx8 specific bits in gfx_v8_0_kiq.c or something like that.
Alex
Quoted 62 lines
Quoted 62 lines
Alex
Quoted 58 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c new file +55
-1+ +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) { +signed long r; +uint32_t val; +struct fence *f; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amdgpu_kiq *kiq = &adev->kiq; + +if (in_interrupt ()) +return 0 ; + +mutex_lock (&xgpu->lock); +amdgpu_ring_alloc (&kiq->ring,32 ); +amdgpu_ring_emit_hdp_flush (&kiq->ring); +xgpu_kiq_ring_emit_rreg (&kiq->ring, reg); +amdgpu_ring_emit_hdp_invalidate (&kiq->ring); +amdgpu_fence_emit (&kiq->ring, &f); +fence_get (f); +amdgpu_ring_commit (&kiq->ring); +mutex_unlock (&xgpu->lock); + + r =fence_wait (f, false); +fence_put (f); +if (r) +DRM_ERROR ("wait for kiq fence error: %ld.\n" , r); +fence_put (f); + + val = adev->wb.wb[xgpu->reg_val_offs]; + +return val; +} + +void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg, +uint32_t v) { +signed long r; +struct fence *f; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +struct amdgpu_kiq *kiq = &adev->kiq; + +mutex_lock (&xgpu->lock); +amdgpu_ring_alloc (&kiq->ring,32 ); +amdgpu_ring_emit_hdp_flush (&kiq->ring); +xgpu_kiq_ring_emit_wreg (&kiq->ring, reg, v); +amdgpu_ring_emit_hdp_invalidate (&kiq->ring); +amdgpu_fence_emit (&kiq->ring, &f); +fence_get (f); +amdgpu_ring_commit (&kiq->ring); +mutex_unlock (&xgpu->lock); + + r =fence_wait (f, false); +fence_put (f); +if (r) +DRM_ERROR ("wait for kiq fence error: %ld.\n" , r); +fence_put (f); +} --2.7.4
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 16/23 drm/amdgpu: add flag to indicate VF runtime state
In reply to a message not in the archiveGuest driver will select using KIQ to access gpu registers if runtime flas is set, or will use MMIO method to r/w registers directly.
When VF's initialization is done, VF should use set runtime flag and use KIQ method. And clear runtime flag when starting to unload driver.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 +++++ drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c | 3 +++ 3 files changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
@@ -94,6 +94,9 @@ uint32_t amdgpu_mm_rreg(struct amdgpu_device *adev, uint32_t reg, {uint32_t ret; +if (amdgpu_sriov_runtime (adev)) +return amdgpu_kiq_rreg (adev, reg); +if ((reg *4 ) < adev->rmmio_size && !always_indirect) ret =readl (((void __iomem *)adev->rmmio) + (reg *4 ));else {
@@ -113,6 +116,9 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, {trace_amdgpu_mm_wreg (adev->pdev->device, reg, v); +if (amdgpu_sriov_runtime (adev)) +return amdgpu_kiq_wreg (adev, reg, v); +if ((reg *4 ) < adev->rmmio_size && !always_indirect)writel (v, ((void __iomem *)adev->rmmio) + (reg *4 ));else {
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +5 -0
@@ -30,6 +30,8 @@ struct amdgpu_vm;#define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1)/* sr-iov is enabled on this GPU */ #define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2)/* this GPU is a virtual function */ #define AMDGPU_PASSTHROUGH_MODE (1 << 3)/* thw whole GPU is pass through for VM */ +/* now GPU is not in init/fini stage */ +#define AMDGPU_SRIOV_CAPS_IS_RUNTIME (1 << 4)/* GPU virtualization */ struct amdgpu_virtualization {uint32_t virtual_caps;
@@ -55,6 +57,9 @@ struct amdgpu_csa {#define amdgpu_passthrough (adev) \ ((adev)->virtualization.virtual_caps & AMDGPU_PASSTHROUGH_MODE) +#define amdgpu_sriov_runtime (adev) \ +((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_IS_RUNTIME) +static inline bool is_virtual_machine (void ) {#ifdef CONFIG_X86
drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c +3 -0
@@ -134,6 +134,7 @@ int amdgpu_get_gpu(struct amdgpu_device *adev)if (!adev->priv_data)return 0 ; + adev->virtualization.virtual_caps &= ~AMDGPU_SRIOV_CAPS_IS_RUNTIME ; r =xgpu_request_full_gpu_access (adev, false);if (r)return r;
@@ -152,5 +153,7 @@ int amdgpu_put_gpu(struct amdgpu_device *adev)if (r)return r; + adev->virtualization.virtual_caps |=AMDGPU_SRIOV_CAPS_IS_RUNTIME ; +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 17/23 drm/amdgpu: export vi common ip block
In reply to a message not in the archiveGPU virtualization component need vim common ip block and the block was also public before. Export it again.
--- drivers/gpu/drm/amd/amdgpu/vi.c | 2 +- drivers/gpu/drm/amd/amdgpu/vi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/vi.c +1 -1
@@ -1377,7 +1377,7 @@ static const struct amd_ip_funcs vi_common_ip_funcs = { .set_powergating_state = vi_common_set_powergating_state, }; -static const struct amdgpu_ip_block_version vi_common_ip_block = +const struct amdgpu_ip_block_version vi_common_ip_block = { .type =AMD_IP_BLOCK_TYPE_COMMON , .major =1 ,
drivers/gpu/drm/amd/amdgpu/vi.h +1 -1
@@ -27,5 +27,5 @@void vi_srbm_select (struct amdgpu_device *adev,u32 me,u32 pipe,u32 queue,u32 vmid);int vi_set_ip_blocks (struct amdgpu_device *adev); - +extern const struct amdgpu_ip_block_version vi_common_ip_block;#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-18-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 17/23] drm/amdgpu: export vi common ip block
Quoted 27 lines · Xiangliang Yu
GPU virtualization component need vim common ip block and the block was also public before. Export it again.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vi.c | 2 +- drivers/gpu/drm/amd/amdgpu/vi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/vi.c +1
-1@@ -1377,7 +1377,7 @@ static const struct amd_ip_funcs vi_common_ip_funcs = { .set_powergating_state = vi_common_set_powergating_state, }; -static const struct amdgpu_ip_block_version vi_common_ip_block = +const struct amdgpu_ip_block_version vi_common_ip_block = { .type =AMD_IP_BLOCK_TYPE_COMMON , .major =1 ,drivers/gpu/drm/amd/amdgpu/vi.h +0
-0
drivers/gpu/drm/amd/amdgpu/vi.h line 30
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/vi.h +1
-1@@ -27,5 +27,5 @@void vi_srbm_select (struct amdgpu_device *adev,u32 me,u32 pipe,u32 queue,u32 vmid);int vi_set_ip_blocks (struct amdgpu_device *adev); - +extern const struct amdgpu_ip_block_version vi_common_ip_block;
No need to do this if you handle the VF case directly in vi.c
Alex
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.h +0
-1#endif --2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 18/23 drm/amdgpu: add new maroc to identify virtualization ip block
In reply to a message not in the archiveCreate a new ip block for virtualization, its main role is to make virtual code independent and flexible, and also eary to maintainer virtualization code.
--- drivers/gpu/drm/amd/include/amd_shared.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/include/amd_shared.h +1 -0
@@ -69,6 +69,7 @@ enum amd_ip_block_type {AMD_IP_BLOCK_TYPE_SMC ,AMD_IP_BLOCK_TYPE_DCE ,AMD_IP_BLOCK_TYPE_GFX , +AMD_IP_BLOCK_TYPE_XGPU ,AMD_IP_BLOCK_TYPE_SDMA ,AMD_IP_BLOCK_TYPE_UVD , AMD_IP_BLOCK_TYPE_VCE,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 19/23 drm/amdgpu/mxgpu: add implementation of GPU virtualization of VI
In reply to a message not in the archiveDifferent chips will have different virtual behaviors, so need to implemnt different virtual feature according to hardware design.
This patch will implemnt Vi family virtualization, it will call CSA, mailbox interface and allocate wb offset for KIQ.
--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 2 + drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 205 ++++++++++++++++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +2 -0
@@ -88,4 +88,6 @@ extern void xgpu_destroy_csa(struct amd_xgpu_csa *csa);extern int xgpu_request_full_gpu_access (struct amdgpu_device *adev,bool init);extern int xgpu_release_full_gpu_access (struct amdgpu_device *adev,bool init); + +extern void xgpu_vi_add_ip_blocks (struct amdgpu_device *adev);#endif
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +205 -0
205 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-20-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 19/23] drm/amdgpu/mxgpu: add implementation of GPU virtualization of VI
Quoted 63 lines · Xiangliang Yu
Different chips will have different virtual behaviors, so need to implemnt different virtual feature according to hardware design.
This patch will implemnt Vi family virtualization, it will call CSA, mailbox interface and allocate wb offset for KIQ.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 2 + drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 205 ++++++++++++++++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_vi.cdrivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +2
-0@@ -88,4 +88,6 @@ extern void xgpu_destroy_csa(struct amd_xgpu_csa *csa);extern int xgpu_request_full_gpu_access (struct amdgpu_device *adev,bool init);extern int xgpu_release_full_gpu_access (struct amdgpu_device *adev,bool init); + +extern void xgpu_vi_add_ip_blocks (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +33
-0@@ -0,0 +1,205 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Author: [email protected] +*/ +#include "amd_mxgpu.h" +#include "vi.h" +#include "gmc_v8_0.h" +#include "gfx_v8_0.h" +#include "sdma_v3_0.h" +#include "tonga_ih.h" +#include "gmc/gmc_8_2_d.h" +#include "gmc/gmc_8_2_sh_mask.h" +#include "oss/oss_3_0_d.h" +#include "oss/oss_3_0_sh_mask.h"
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 43
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +10
-0+#include "bif/bif_5_0_d.h" +#include "bif/bif_5_0_sh_mask.h" +#include "amdgpu_powerplay.h" +#include "dce_virtual.h" +#include "gca/gfx_8_0_d.h" +#include "gca/gfx_8_0_enum.h" +#include "gca/gfx_8_0_sh_mask.h" +#include "dce/dce_10_0_d.h" +#include "dce/dce_10_0_sh_mask.h" +#include "smu/smu_7_1_3_d.h"
You don't need all of these register headers. there aren't even any registers used in this code.
Quoted 66 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +66
-0+ +static int xgpu_vi_early_init (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int r; + + r =amd_xgpu_alloc (adev); +if (r) +return r; + + r =xgpu_request_full_gpu_access (adev, true); +if (r) { +DRM_ERROR ("failed to send message to HV (%d).\n" , r); +return r; + } + +return 0 ; +} + +static int xgpu_vi_late_init (void *handle) +{ +return 0 ; +} + +static int xgpu_vi_sw_init (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +return xgpu_allocate_csa (xgpu); +} + +static int xgpu_vi_sw_fini (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +xgpu_destroy_csa (&xgpu->sa); + +return 0 ; +} + +static int xgpu_vi_hw_init (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +int r; + + r =amdgpu_wb_get (adev, &xgpu->reg_val_offs); +if (r) { +DRM_ERROR ("failed to alloc reg val offs(%d).\n" , r); +return r; + } + +return 0 ; +} + +static int xgpu_vi_hw_fini (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +amdgpu_wb_free (adev, xgpu->reg_val_offs); +return 0 ; +} +
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 119
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +10
-0+static void xgpu_vi_late_fini (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +amd_xgpu_free (xgpu); + adev->priv_data =NULL ; + +xgpu_release_full_gpu_access (adev, false); +}
Most of this code seems like it would be better to just add directly to the relevant code in vi.c (VF reg offset stuff, mail box requests) and gfx_v8_0.c (CSA stuff).
Quoted 76 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +76
-0+ +static int xgpu_vi_suspend (void *handle) +{ +return 0 ; +} + +static int xgpu_vi_resume (void *handle) +{ +return 0 ; +} + +static bool xgpu_vi_is_idle (void *handle) +{ +return false; +} + +static int xgpu_vi_wait_for_idle (void *handle) +{ +return 0 ; +} + +static bool xgpu_vi_check_soft_reset (void *handle) +{ +return false; +} + +static int xgpu_vi_pre_soft_reset (void *handle) +{ +return 0 ; +} + +static int xgpu_vi_soft_reset (void *handle) +{ +return 0 ; +} + +static int xgpu_vi_post_soft_reset (void *handle) +{ +return 0 ; +} + +static int xgpu_vi_set_clockgating_state (void *handle, +enum amd_clockgating_state state) +{ +return 0 ; +} + +const struct amd_ip_funcs xgpu_vi_ip_funcs = { + .name ="xgpu-vi" , + .early_init = xgpu_vi_early_init, + .late_init = xgpu_vi_late_init, + .sw_init = xgpu_vi_sw_init, + .sw_fini = xgpu_vi_sw_fini, + .hw_init = xgpu_vi_hw_init, + .hw_fini = xgpu_vi_hw_fini, + .late_fini = xgpu_vi_late_fini, + .suspend = xgpu_vi_suspend, + .resume = xgpu_vi_resume, + .is_idle = xgpu_vi_is_idle, + .wait_for_idle = xgpu_vi_wait_for_idle, + .check_soft_reset = xgpu_vi_check_soft_reset, + .pre_soft_reset = xgpu_vi_pre_soft_reset, + .soft_reset = xgpu_vi_soft_reset, + .post_soft_reset = xgpu_vi_post_soft_reset, + .set_clockgating_state = xgpu_vi_set_clockgating_state, +}; + +static const struct amdgpu_ip_block_version xgpu_vi_ip_block = { + .type =AMD_IP_BLOCK_TYPE_XGPU , + .major =1 , + .minor =0 , + .rev =0 , + .funcs = &xgpu_vi_ip_funcs, +}; + +void xgpu_vi_add_ip_blocks (struct amdgpu_device *adev)
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 205
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +10
-0+{ +amdgpu_ip_block_add (adev, &vi_common_ip_block); +amdgpu_ip_block_add (adev, &gmc_v8_5_ip_block); +amdgpu_ip_block_add (adev, &tonga_ih_ip_block); +amdgpu_ip_block_add (adev, &amdgpu_pp_ip_block); +amdgpu_ip_block_add (adev, &dce_virtual_ip_block); +amdgpu_ip_block_add (adev, &gfx_v8_0_ip_block); +amdgpu_ip_block_add (adev, &xgpu_vi_ip_block); +amdgpu_ip_block_add (adev, &sdma_v3_0_ip_block); +}
Handle the VF specific IP blocks directly in vi.c
Quoted 7 lines
--
2.7.4_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_Oeoqx_MhuVODGz5ukU6qKWMU=v=VB9cV_jBd4V9HBKeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 19/23] drm/amdgpu/mxgpu: add implementation of GPU virtualization of VI
Quoted 100 lines
-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Tuesday, December 20, 2016 7:35 AM
To: Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>
Subject: Re: [PATCH 19/23] drm/amdgpu/mxgpu: add implementation of GPU virtualization of VIQuoted 45 lines · Xiangliang Yu
Different chips will have different virtual behaviors, so need to implemnt different virtual feature according to hardware design.
This patch will implemnt Vi family virtualization, it will call CSA, mailbox interface and allocate wb offset for KIQ.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 2 + drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 205 ++++++++++++++++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_vi.cdrivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +0
-0@@ -88,4 +88,6 @@ extern void xgpu_destroy_csa(struct amd_xgpu_csa *csa); extern int xgpu_request_full_gpu_access(struct amdgpu_device *adev,bool init); extern int
xgpu_release_full_gpu_access(struct amdgpu_device *adev, bool init);drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h +2
-0+ +extern void xgpu_vi_add_ip_blocks (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +10
-0@@ -0,0 +1,205 @@ +/* +* Copyright 2016 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 20
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +10
-0+sublicense, + * and/or sell copies of the Software, and to permit persons to whom +the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be +included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANYKIND,
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 24
Quoted 4 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 30
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +6
-0+SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ORTHE USE
Quoted 20 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +20
-0+OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Author: [email protected] +*/ +#include "amd_mxgpu.h" +#include "vi.h" +#include "gmc_v8_0.h" +#include "gfx_v8_0.h" +#include "sdma_v3_0.h" +#include "tonga_ih.h" +#include "gmc/gmc_8_2_d.h" +#include "gmc/gmc_8_2_sh_mask.h" +#include "oss/oss_3_0_d.h" +#include "oss/oss_3_0_sh_mask.h" +#include "bif/bif_5_0_d.h" +#include "bif/bif_5_0_sh_mask.h" +#include "amdgpu_powerplay.h" +#include "dce_virtual.h" +#include "gca/gfx_8_0_d.h"
Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 43
Quoted 5 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +5
-0+#include "gca/gfx_8_0_enum.h" +#include "gca/gfx_8_0_sh_mask.h" +#include "dce/dce_10_0_d.h" +#include "dce/dce_10_0_sh_mask.h" +#include "smu/smu_7_1_3_d.h" You don't need all of these register headers. there aren't even any registers used in this code.
The headers is need by golden setting.
Quoted 65 lines
Quoted 65 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +63
-0+ +static int xgpu_vi_early_init (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int r; + + r =amd_xgpu_alloc (adev); +if (r) +return r; + + r =xgpu_request_full_gpu_access (adev, true); +if (r) { +DRM_ERROR ("failed to send message to HV (%d).\n" , r); +return r; + } + +return 0 ; +} + +static int xgpu_vi_late_init (void *handle) { +return 0 ; +} + +static int xgpu_vi_sw_init (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +return xgpu_allocate_csa (xgpu); } + +static int xgpu_vi_sw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +xgpu_destroy_csa (&xgpu->sa); + +return 0 ; +} + +static int xgpu_vi_hw_init (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +int r; + + r =amdgpu_wb_get (adev, &xgpu->reg_val_offs); +if (r) { +DRM_ERROR ("failed to alloc reg val offs(%d).\n" , r); +return r; + } + +return 0 ; +} + +static int xgpu_vi_hw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; + +amdgpu_wb_free (adev, xgpu->reg_val_offs); +return 0 ; +} + +static void xgpu_vi_late_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amd_xgpu *xgpu = (struct amd_xgpu *)adev->priv_data; +
Quoted 8 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c
Quoted 4 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +4
-0+amd_xgpu_free (xgpu); + adev->priv_data =NULL ; + +xgpu_release_full_gpu_access (adev, false); }Most of this code seems like it would be better to just add directly to the relevant code in
vi.c(VF reg offset stuff, mail box requests) andgfx_v8_0.c(CSA stuff).
As I said in previous patch comments, the main aim of the series is support centralized management of virtualization chips and features.
We don't want to interrupt amdgpu component for each commit later. This design will bring us lot of room for support virtualization.
Quoted 70 lines
Quoted 70 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +69
-0+ +static int xgpu_vi_suspend (void *handle) { +return 0 ; +} + +static int xgpu_vi_resume (void *handle) { +return 0 ; +} + +static bool xgpu_vi_is_idle (void *handle) { +return false; +} + +static int xgpu_vi_wait_for_idle (void *handle) { +return 0 ; +} + +static bool xgpu_vi_check_soft_reset (void *handle) { +return false; +} + +static int xgpu_vi_pre_soft_reset (void *handle) { +return 0 ; +} + +static int xgpu_vi_soft_reset (void *handle) { +return 0 ; +} + +static int xgpu_vi_post_soft_reset (void *handle) { +return 0 ; +} + +static int xgpu_vi_set_clockgating_state (void *handle, +enum amd_clockgating_state +state) { +return 0 ; +} + +const struct amd_ip_funcs xgpu_vi_ip_funcs = { + .name ="xgpu-vi" , + .early_init = xgpu_vi_early_init, + .late_init = xgpu_vi_late_init, + .sw_init = xgpu_vi_sw_init, + .sw_fini = xgpu_vi_sw_fini, + .hw_init = xgpu_vi_hw_init, + .hw_fini = xgpu_vi_hw_fini, + .late_fini = xgpu_vi_late_fini, + .suspend = xgpu_vi_suspend, + .resume = xgpu_vi_resume, + .is_idle = xgpu_vi_is_idle, + .wait_for_idle = xgpu_vi_wait_for_idle, + .check_soft_reset = xgpu_vi_check_soft_reset, + .pre_soft_reset = xgpu_vi_pre_soft_reset, + .soft_reset = xgpu_vi_soft_reset, + .post_soft_reset = xgpu_vi_post_soft_reset, + .set_clockgating_state = xgpu_vi_set_clockgating_state, }; + +static const struct amdgpu_ip_block_version xgpu_vi_ip_block = { + .type =AMD_IP_BLOCK_TYPE_XGPU , + .major =1 , + .minor =0 , + .rev =0 , + .funcs = &xgpu_vi_ip_funcs, +}; + +void xgpu_vi_add_ip_blocks (struct amdgpu_device *adev) { +amdgpu_ip_block_add (adev, &vi_common_ip_block); +amdgpu_ip_block_add (adev, &gmc_v8_5_ip_block);
Quoted 16 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c
Quoted 6 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c new file +6
-0+amdgpu_ip_block_add (adev, &tonga_ih_ip_block); +amdgpu_ip_block_add (adev, &amdgpu_pp_ip_block); +amdgpu_ip_block_add (adev, &dce_virtual_ip_block); +amdgpu_ip_block_add (adev, &gfx_v8_0_ip_block); +amdgpu_ip_block_add (adev, &xgpu_vi_ip_block); +amdgpu_ip_block_add (adev, &sdma_v3_0_ip_block); }Handle the VF specific IP blocks directly in
vi.cQuoted 7 lines
--
2.7.4_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 20/23 drm/amdgpu/mxgpu: enable VI virtualization
In reply to a message not in the archiveCall vi ip block setup function to enable vi virtualization.
--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c +1 -0
@@ -62,6 +62,7 @@ static int amd_xgpu_init_ip_blocks(struct amdgpu_device *adev)case CHIP_TONGA :case CHIP_FIJI :/* add IP blocks*/ +xgpu_vi_add_ip_blocks (adev);break ;default :DRM_ERROR ("Does not support this chip.\n" );
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-21-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
RE: [PATCH 20/23] drm/amdgpu/mxgpu: enable VI virtualization
Quoted 21 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Xiangliang Yu
Sent: Saturday, December 17, 2016 11:17 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization
Cc: Yu, Xiangliang
Subject: [PATCH 20/23] drm/amdgpu/mxgpu: enable VI virtualizationCall vi ip block setup function to enable vi virtualization.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c +0
-0
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c static int amd_xgpu_init_ip_blocks(struct · line 66
Quoted 5 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c +1
-0@@ -62,6 +62,7 @@ static int amd_xgpu_init_ip_blocks(struct amdgpu_device *adev)case CHIP_TONGA :case CHIP_FIJI :/* add IP blocks*/ +xgpu_vi_add_ip_blocks (adev);
Rather than going through all this indirection, just check for the VF flag in vi.c and add the appropriate IP blocks for the bare metal vs VF cases there. It would also allow you to keep the vi_common functions static.
Alex
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c +0
-0break ;default :
DRM_ERROR("Does not support this chip.\n");
--
2.7.4_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1652B3D6D0409C00F89F4493F7910-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 20/23] drm/amdgpu/mxgpu: enable VI virtualization
Quoted 24 lines
-----Original Message-----
From: Deucher, Alexander
Sent: Tuesday, December 20, 2016 7:08 AM
To: Yu, Xiangliang <[email protected]>; amd- [email protected]; dl.SRDC_SW_GPUVirtualization <[email protected]>
Cc: Yu, Xiangliang <[email protected]>
Subject: RE: [PATCH 20/23] drm/amdgpu/mxgpu: enable VI virtualizationQuoted 15 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Xiangliang Yu
Sent: Saturday, December 17, 2016 11:17 AM
To: [email protected]; dl.SRDC_SW_GPUVirtualization
Cc: Yu, Xiangliang
Subject: [PATCH 20/23] drm/amdgpu/mxgpu: enable VI virtualizationCall vi ip block setup function to enable vi virtualization.
Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c | 1 + 1 file changed, 1 insertion(+)
Quoted 15 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c static int amd_xgpu_init_ip_blocks(struct · line 66
Quoted 11 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c +1
-0@@ -62,6 +62,7 @@ static int amd_xgpu_init_ip_blocks(struct amdgpu_device *adev)case CHIP_TONGA :case CHIP_FIJI :/* add IP blocks*/ +xgpu_vi_add_ip_blocks (adev);Rather than going through all this indirection, just check for the VF flag in
vi.cand add the appropriate IP blocks for the bare metal vs VF cases there. It would also allow you to keep thevi_commonfunctions static.
The method let us easy to put all virtualization implementation together, just export one interface to amdgpu. That is also the main aim of Re-org monk's sriov patches, don't want to mix virtualization into amdgpu.
I don't why you keep vi_common function as static, I remember it is public before.
Quoted 13 lines
Alex
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c +0
-0break ;default :
DRM_ERROR("Does not support this chip.\n");
--
2.7.4_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 21/23 drm/amdgpu: change golden register program sequence of virtualization
In reply to a message not in the archiveGPU virtualization has different sequence from normal, change it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 + drivers/gpu/drm/amd/amdgpu/vi.c | 6 + drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 267 +++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -0
@@ -84,4 +84,6 @@ int amdgpu_put_gpu(struct amdgpu_device *adev);/* access vf registers */ uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +void amdgpu_xgpu_init_golden_registers (struct amdgpu_device *adev);#endif
drivers/gpu/drm/amd/amdgpu/vi.c +6 -0
@@ -285,6 +285,12 @@ static void vi_init_golden_registers(struct amdgpu_device *adev)/* Some of the registers might be dependent on GRBM_GFX_INDEX */ mutex_lock (&adev->grbm_idx_mutex); +if (adev->flags &AMD_IS_VF ) { +amdgpu_xgpu_init_golden_registers (adev); +mutex_unlock (&adev->grbm_idx_mutex); +return ; + } +switch (adev->asic_type) {case CHIP_TOPAZ : amdgpu_program_register_sequence(adev,
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +267 -0
273 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481991405-30422-22-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
Quoted 303 lines · Xiangliang Yu
GPU virtualization has different sequence from normal, change it.
Signed-off-by Frank Min <[email protected]>Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 + drivers/gpu/drm/amd/amdgpu/vi.c | 6 + drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 267 +++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2
-0@@ -84,4 +84,6 @@ int amdgpu_put_gpu(struct amdgpu_device *adev);/* access vf registers */ uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +void amdgpu_xgpu_init_golden_registers (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/vi.c +6
-0@@ -285,6 +285,12 @@ static void vi_init_golden_registers(struct amdgpu_device *adev)/* Some of the registers might be dependent on GRBM_GFX_INDEX */ mutex_lock (&adev->grbm_idx_mutex); +if (adev->flags &AMD_IS_VF ) { +amdgpu_xgpu_init_golden_registers (adev); +mutex_unlock (&adev->grbm_idx_mutex); +return ; + } +switch (adev->asic_type) {case CHIP_TOPAZ : amdgpu_program_register_sequence(adev,drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +256
-0@@ -42,6 +42,273 @@ #include "dce/dce_10_0_sh_mask.h" #include "smu/smu_7_1_3_d.h" +static const u32 xgpu_fiji_mgcg_cgcg_init[] = { + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, + mmPCIE_INDEX, 0xffffffff, 0x0140001c, + mmPCIE_DATA, 0x000f0000, 0x00000000, + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, +}; + +static const u32 xgpu_golden_settings_fiji_a10[] = { + mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040, + mmDB_DEBUG2, 0xf00fffff, 0x00000400, + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, + mmFBC_MISC, 0x1f311fff, 0x12300000, + mmHDMI_CONTROL, 0x31000111, 0x00000011, + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000ff, + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, +}; + +static const u32 xgpu_fiji_golden_common_all[] = { + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x3a00161a, + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002e, + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, + mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x00000009, +}; + +static const u32 xgpu_tonga_mgcg_cgcg_init[] = { + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCGTS_CU0_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU0_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU0_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU0_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU0_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU1_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU1_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU1_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU1_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU1_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU2_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU2_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU2_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU2_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU2_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU3_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU3_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU3_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU3_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU3_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU4_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU4_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU4_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU4_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU4_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU5_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU5_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU5_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU5_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU5_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU6_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU6_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU6_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU6_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU6_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU7_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU7_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU7_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU7_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU7_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, + mmPCIE_INDEX, 0xffffffff, 0x0140001c, + mmPCIE_DATA, 0x000f0000, 0x00000000, + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, +}; + +static const u32 xgpu_golden_settings_tonga_a11[] = { + mmCB_HW_CONTROL, 0xfffdf3cf, 0x00007208, + mmCB_HW_CONTROL_3, 0x00000040, 0x00000040, + mmDB_DEBUG2, 0xf00fffff, 0x00000400, + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, + mmFBC_MISC, 0x1f311fff, 0x12300000, + mmGB_GPU_ID, 0x0000000f, 0x00000000, + mmHDMI_CONTROL, 0x31000111, 0x00000011, + mmMC_ARB_WTM_GRPWT_RD, 0x00000003, 0x00000000, + mmMC_HUB_RDREQ_DMIF_LIMIT, 0x0000007f, 0x00000028, + mmMC_HUB_WDP_UMC, 0x00007fb6, 0x00000991, + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, + mmPA_SC_FIFO_DEPTH_CNTL, 0x000003ff, 0x000000fc, + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, + mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0000003c, + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA0_CLK_CTRL, 0xff000fff, 0x00000000, + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA1_CLK_CTRL, 0xff000fff, 0x00000000, + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, + mmTCC_CTRL, 0x00100000, 0xf31fff7f, + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000002fb, + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, + mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, +}; + +static const u32 xgpu_tonga_golden_common_all[] = { + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x16000012, + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002A, + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002, + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, +}; + +void amdgpu_xgpu_init_golden_registers(struct amdgpu_device *adev) +{ + switch (adev->asic_type) { + case CHIP_FIJI: + amdgpu_program_register_sequence(adev, + xgpu_fiji_mgcg_cgcg_init, + (const u32)ARRAY_SIZE( + xgpu_fiji_mgcg_cgcg_init)); + amdgpu_program_register_sequence(adev, + xgpu_golden_settings_fiji_a10, + (const u32)ARRAY_SIZE( + xgpu_golden_settings_fiji_a10)); + amdgpu_program_register_sequence(adev, + xgpu_fiji_golden_common_all, + (const u32)ARRAY_SIZE( + xgpu_fiji_golden_common_all)); + break; + case CHIP_TONGA: + amdgpu_program_register_sequence(adev, + xgpu_tonga_mgcg_cgcg_init, + (const u32)ARRAY_SIZE( + xgpu_tonga_mgcg_cgcg_init)); + amdgpu_program_register_sequence(adev, + xgpu_golden_settings_tonga_a11, + (const u32)ARRAY_SIZE(
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 310
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +10
-0+ xgpu_golden_settings_tonga_a11)); +amdgpu_program_register_sequence (adev, + xgpu_tonga_golden_common_all, + (const u32 )ARRAY_SIZE ( + xgpu_tonga_golden_common_all)); +break ; +default : +break ; + } +}
Cleaner to just put this in vi.c.
Alex
Quoted 11 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +1
-1+static int xgpu_vi_early_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; --2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_PqscSCAOGn+suNGkoUQdF5Z7O69wrL_CvH27hfKE4b0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
答复: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
Hi Alex
I agree with you that this patch's GOLDEN setting programming should be put in VI.C, but I found a hardware issue :
original linux logic is that we set golden setting registers separately within each IP's hw init routine, but for TONGA VF, it is really strange that we must set all GOLDEN setting value to chip in one shoot (means we use one routine to programing all IP's golden setting to registers), ortherwise we found TONGA vf just failed in RING TEST.
and I admit I don't know why (I checked windows CAIL code, it is also set all golden setting registers in one routine)
BR Monk
________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2016年12月20日 7:37:06
收件人: Yu, Xiangliang
抄送: amd-gfx list; dl.SRDC_SW_GPUVirtualization; Min, Frank; Liu, Monk
主题: Re: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
Quoted 303 lines · Xiangliang Yu
GPU virtualization has different sequence from normal, change it.
Signed-off-by Frank Min <[email protected]>Signed-off-by Monk Liu <[email protected]>Signed-off-by Xiangliang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 + drivers/gpu/drm/amd/amdgpu/vi.c | 6 + drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 267 +++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2
-0@@ -84,4 +84,6 @@ int amdgpu_put_gpu(struct amdgpu_device *adev);/* access vf registers */ uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +void amdgpu_xgpu_init_golden_registers (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/vi.c +6
-0@@ -285,6 +285,12 @@ static void vi_init_golden_registers(struct amdgpu_device *adev)/* Some of the registers might be dependent on GRBM_GFX_INDEX */ mutex_lock (&adev->grbm_idx_mutex); +if (adev->flags &AMD_IS_VF ) { +amdgpu_xgpu_init_golden_registers (adev); +mutex_unlock (&adev->grbm_idx_mutex); +return ; + } +switch (adev->asic_type) {case CHIP_TOPAZ : amdgpu_program_register_sequence(adev,drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +256
-0@@ -42,6 +42,273 @@ #include "dce/dce_10_0_sh_mask.h" #include "smu/smu_7_1_3_d.h" +static const u32 xgpu_fiji_mgcg_cgcg_init[] = { + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, + mmPCIE_INDEX, 0xffffffff, 0x0140001c, + mmPCIE_DATA, 0x000f0000, 0x00000000, + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, +}; + +static const u32 xgpu_golden_settings_fiji_a10[] = { + mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040, + mmDB_DEBUG2, 0xf00fffff, 0x00000400, + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, + mmFBC_MISC, 0x1f311fff, 0x12300000, + mmHDMI_CONTROL, 0x31000111, 0x00000011, + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000ff, + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, +}; + +static const u32 xgpu_fiji_golden_common_all[] = { + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x3a00161a, + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002e, + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, + mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x00000009, +}; + +static const u32 xgpu_tonga_mgcg_cgcg_init[] = { + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCGTS_CU0_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU0_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU0_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU0_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU0_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU1_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU1_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU1_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU1_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU1_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU2_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU2_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU2_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU2_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU2_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU3_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU3_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU3_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU3_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU3_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU4_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU4_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU4_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU4_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU4_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU5_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU5_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU5_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU5_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU5_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU6_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU6_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU6_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU6_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU6_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU7_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU7_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU7_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU7_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU7_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, + mmPCIE_INDEX, 0xffffffff, 0x0140001c, + mmPCIE_DATA, 0x000f0000, 0x00000000, + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, +}; + +static const u32 xgpu_golden_settings_tonga_a11[] = { + mmCB_HW_CONTROL, 0xfffdf3cf, 0x00007208, + mmCB_HW_CONTROL_3, 0x00000040, 0x00000040, + mmDB_DEBUG2, 0xf00fffff, 0x00000400, + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, + mmFBC_MISC, 0x1f311fff, 0x12300000, + mmGB_GPU_ID, 0x0000000f, 0x00000000, + mmHDMI_CONTROL, 0x31000111, 0x00000011, + mmMC_ARB_WTM_GRPWT_RD, 0x00000003, 0x00000000, + mmMC_HUB_RDREQ_DMIF_LIMIT, 0x0000007f, 0x00000028, + mmMC_HUB_WDP_UMC, 0x00007fb6, 0x00000991, + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, + mmPA_SC_FIFO_DEPTH_CNTL, 0x000003ff, 0x000000fc, + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, + mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0000003c, + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA0_CLK_CTRL, 0xff000fff, 0x00000000, + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA1_CLK_CTRL, 0xff000fff, 0x00000000, + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, + mmTCC_CTRL, 0x00100000, 0xf31fff7f, + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000002fb, + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, + mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, +}; + +static const u32 xgpu_tonga_golden_common_all[] = { + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x16000012, + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002A, + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002, + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, +}; + +void amdgpu_xgpu_init_golden_registers(struct amdgpu_device *adev) +{ + switch (adev->asic_type) { + case CHIP_FIJI: + amdgpu_program_register_sequence(adev, + xgpu_fiji_mgcg_cgcg_init, + (const u32)ARRAY_SIZE( + xgpu_fiji_mgcg_cgcg_init)); + amdgpu_program_register_sequence(adev, + xgpu_golden_settings_fiji_a10, + (const u32)ARRAY_SIZE( + xgpu_golden_settings_fiji_a10)); + amdgpu_program_register_sequence(adev, + xgpu_fiji_golden_common_all, + (const u32)ARRAY_SIZE( + xgpu_fiji_golden_common_all)); + break; + case CHIP_TONGA: + amdgpu_program_register_sequence(adev, + xgpu_tonga_mgcg_cgcg_init, + (const u32)ARRAY_SIZE( + xgpu_tonga_mgcg_cgcg_init)); + amdgpu_program_register_sequence(adev, + xgpu_golden_settings_tonga_a11, + (const u32)ARRAY_SIZE(
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 310
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +10
-0+ xgpu_golden_settings_tonga_a11)); +amdgpu_program_register_sequence (adev, + xgpu_tonga_golden_common_all, + (const u32 )ARRAY_SIZE ( + xgpu_tonga_golden_common_all)); +break ; +default : +break ; + } +}
Cleaner to just put this in vi.c.
Alex
Quoted 11 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +1
-1+static int xgpu_vi_early_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; --2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BY2PR12MB005449FC3CC2D91B41B3487884900-K//h7OWB4q7GdVlgMuSljQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
Thank monk’s comments.
From: Liu, Monk
Sent: Tuesday, December 20, 2016 12:09 PM
To: Alex Deucher <[email protected]>; Yu, Xiangliang <[email protected]>
Cc: amd-gfx list <[email protected]>; dl.SRDC_SW_GPUVirtualization <[email protected]>; Min, Frank <[email protected]>
Subject: 答复: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
Hi Alex
I agree with you that this patch's GOLDEN setting programming should be put in VI.C, but I found a hardware issue :
original linux logic is that we set golden setting registers separately within each IP's hw init routine, but for TONGA VF, it is really strange that we must set all GOLDEN setting value to chip in one shoot (means we use one routine to programing all IP's golden setting to registers), ortherwise we found TONGA vf just failed in RING TEST.
and I admit I don't know why (I checked windows CAIL code, it is also set all golden setting registers in one routine)
BR Monk
________________________________
发件人: Alex Deucher <[email protected]<mailto:[email protected]>> 发送时间: 2016年12月20日 7:37:06
收件人: Yu, Xiangliang
抄送: amd-gfx list; dl.SRDC_SW_GPUVirtualization; Min, Frank; Liu, Monk
主题: Re: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
Quoted 303 lines · On Sat, Dec 17, 2016 at 11:16 AM, Xiangliang Yu…
GPU virtualization has different sequence from normal, change it.
Signed-off-by Frank Min <[email protected]<mailto:[email protected]>>Signed-off-by Monk Liu <[email protected]<mailto:[email protected]>>--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 + drivers/gpu/drm/amd/amdgpu/vi.c | 6 + drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 267 +++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2
-0@@ -84,4 +84,6 @@ int amdgpu_put_gpu(struct amdgpu_device *adev);/* access vf registers */ uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +void amdgpu_xgpu_init_golden_registers (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/vi.c +6
-0@@ -285,6 +285,12 @@ static void vi_init_golden_registers(struct amdgpu_device *adev)/* Some of the registers might be dependent on GRBM_GFX_INDEX */ mutex_lock (&adev->grbm_idx_mutex); +if (adev->flags &AMD_IS_VF ) { +amdgpu_xgpu_init_golden_registers (adev); +mutex_unlock (&adev->grbm_idx_mutex); +return ; + } +switch (adev->asic_type) {case CHIP_TOPAZ : amdgpu_program_register_sequence(adev,drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +256
-0@@ -42,6 +42,273 @@ #include "dce/dce_10_0_sh_mask.h" #include "smu/smu_7_1_3_d.h" +static const u32 xgpu_fiji_mgcg_cgcg_init[] = { + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, + mmPCIE_INDEX, 0xffffffff, 0x0140001c, + mmPCIE_DATA, 0x000f0000, 0x00000000, + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, +}; + +static const u32 xgpu_golden_settings_fiji_a10[] = { + mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040, + mmDB_DEBUG2, 0xf00fffff, 0x00000400, + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, + mmFBC_MISC, 0x1f311fff, 0x12300000, + mmHDMI_CONTROL, 0x31000111, 0x00000011, + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000ff, + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, +}; + +static const u32 xgpu_fiji_golden_common_all[] = { + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x3a00161a, + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002e, + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, + mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x00000009, +}; + +static const u32 xgpu_tonga_mgcg_cgcg_init[] = { + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCGTS_CU0_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU0_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU0_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU0_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU0_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU1_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU1_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU1_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU1_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU1_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU2_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU2_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU2_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU2_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU2_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU3_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU3_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU3_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU3_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU3_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU4_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU4_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU4_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU4_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU4_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU5_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU5_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU5_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU5_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU5_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU6_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU6_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU6_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU6_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU6_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU7_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU7_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU7_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU7_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU7_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, + mmPCIE_INDEX, 0xffffffff, 0x0140001c, + mmPCIE_DATA, 0x000f0000, 0x00000000, + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, +}; + +static const u32 xgpu_golden_settings_tonga_a11[] = { + mmCB_HW_CONTROL, 0xfffdf3cf, 0x00007208, + mmCB_HW_CONTROL_3, 0x00000040, 0x00000040, + mmDB_DEBUG2, 0xf00fffff, 0x00000400, + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, + mmFBC_MISC, 0x1f311fff, 0x12300000, + mmGB_GPU_ID, 0x0000000f, 0x00000000, + mmHDMI_CONTROL, 0x31000111, 0x00000011, + mmMC_ARB_WTM_GRPWT_RD, 0x00000003, 0x00000000, + mmMC_HUB_RDREQ_DMIF_LIMIT, 0x0000007f, 0x00000028, + mmMC_HUB_WDP_UMC, 0x00007fb6, 0x00000991, + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, + mmPA_SC_FIFO_DEPTH_CNTL, 0x000003ff, 0x000000fc, + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, + mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0000003c, + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA0_CLK_CTRL, 0xff000fff, 0x00000000, + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA1_CLK_CTRL, 0xff000fff, 0x00000000, + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, + mmTCC_CTRL, 0x00100000, 0xf31fff7f, + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000002fb, + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, + mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, +}; + +static const u32 xgpu_tonga_golden_common_all[] = { + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x16000012, + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002A, + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002, + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, +}; + +void amdgpu_xgpu_init_golden_registers(struct amdgpu_device *adev) +{ + switch (adev->asic_type) { + case CHIP_FIJI: + amdgpu_program_register_sequence(adev, + xgpu_fiji_mgcg_cgcg_init, + (const u32)ARRAY_SIZE( + xgpu_fiji_mgcg_cgcg_init)); + amdgpu_program_register_sequence(adev, + xgpu_golden_settings_fiji_a10, + (const u32)ARRAY_SIZE( + xgpu_golden_settings_fiji_a10)); + amdgpu_program_register_sequence(adev, + xgpu_fiji_golden_common_all, + (const u32)ARRAY_SIZE( + xgpu_fiji_golden_common_all)); + break; + case CHIP_TONGA: + amdgpu_program_register_sequence(adev, + xgpu_tonga_mgcg_cgcg_init, + (const u32)ARRAY_SIZE( + xgpu_tonga_mgcg_cgcg_init)); + amdgpu_program_register_sequence(adev, + xgpu_golden_settings_tonga_a11, + (const u32)ARRAY_SIZE(
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 310
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +10
-0+ xgpu_golden_settings_tonga_a11)); +amdgpu_program_register_sequence (adev, + xgpu_tonga_golden_common_all, + (const u32 )ARRAY_SIZE ( + xgpu_tonga_golden_common_all)); +break ; +default : +break ; + } +}
Cleaner to just put this in vi.c.
Alex
Quoted 11 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +1
-1+static int xgpu_vi_early_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; --2.7.4
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
In reply to a message not in the archiveI don't mind keeping the list together.
Alex
From: amd-gfx [mailto:[email protected]] On Behalf Of Liu, Monk
Sent: Monday, December 19, 2016 11:09 PM
To: Alex Deucher; Yu, Xiangliang
Cc: Min, Frank; dl.SRDC_SW_GPUVirtualization; amd-gfx list
Subject: 答复: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
Hi Alex
I agree with you that this patch's GOLDEN setting programming should be put in VI.C, but I found a hardware issue :
original linux logic is that we set golden setting registers separately within each IP's hw init routine, but for TONGA VF, it is really strange that we must set all GOLDEN setting value to chip in one shoot (means we use one routine to programing all IP's golden setting to registers), ortherwise we found TONGA vf just failed in RING TEST.
and I admit I don't know why (I checked windows CAIL code, it is also set all golden setting registers in one routine)
BR Monk
________________________________
发件人: Alex Deucher <[email protected]<mailto:[email protected]>> 发送时间: 2016年12月20日 7:37:06
收件人: Yu, Xiangliang
抄送: amd-gfx list; dl.SRDC_SW_GPUVirtualization; Min, Frank; Liu, Monk
主题: Re: [PATCH 21/23] drm/amdgpu: change golden register program sequence of virtualization
Quoted 303 lines · On Sat, Dec 17, 2016 at 11:16 AM, Xiangliang Yu…
GPU virtualization has different sequence from normal, change it.
Signed-off-by Frank Min <[email protected]<mailto:[email protected]>>Signed-off-by Monk Liu <[email protected]<mailto:[email protected]>>--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 + drivers/gpu/drm/amd/amdgpu/vi.c | 6 + drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 267 +++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2
-0@@ -84,4 +84,6 @@ int amdgpu_put_gpu(struct amdgpu_device *adev);/* access vf registers */ uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +void amdgpu_xgpu_init_golden_registers (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/vi.c +6
-0@@ -285,6 +285,12 @@ static void vi_init_golden_registers(struct amdgpu_device *adev)/* Some of the registers might be dependent on GRBM_GFX_INDEX */ mutex_lock (&adev->grbm_idx_mutex); +if (adev->flags &AMD_IS_VF ) { +amdgpu_xgpu_init_golden_registers (adev); +mutex_unlock (&adev->grbm_idx_mutex); +return ; + } +switch (adev->asic_type) {case CHIP_TOPAZ : amdgpu_program_register_sequence(adev,drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +256
-0@@ -42,6 +42,273 @@ #include "dce/dce_10_0_sh_mask.h" #include "smu/smu_7_1_3_d.h" +static const u32 xgpu_fiji_mgcg_cgcg_init[] = { + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, + mmPCIE_INDEX, 0xffffffff, 0x0140001c, + mmPCIE_DATA, 0x000f0000, 0x00000000, + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, +}; + +static const u32 xgpu_golden_settings_fiji_a10[] = { + mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040, + mmDB_DEBUG2, 0xf00fffff, 0x00000400, + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, + mmFBC_MISC, 0x1f311fff, 0x12300000, + mmHDMI_CONTROL, 0x31000111, 0x00000011, + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000ff, + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, +}; + +static const u32 xgpu_fiji_golden_common_all[] = { + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x3a00161a, + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002e, + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, + mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x00000009, +}; + +static const u32 xgpu_tonga_mgcg_cgcg_init[] = { + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmCGTS_CU0_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU0_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU0_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU0_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU0_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU1_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU1_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU1_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU1_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU1_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU2_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU2_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU2_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU2_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU2_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU3_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU3_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU3_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU3_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU3_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU4_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU4_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU4_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU4_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU4_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU5_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU5_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU5_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU5_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU5_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU6_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU6_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU6_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU6_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU6_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_CU7_SP0_CTRL_REG, 0xffffffff, 0x00010000, + mmCGTS_CU7_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, + mmCGTS_CU7_TA_CTRL_REG, 0xffffffff, 0x00040007, + mmCGTS_CU7_SP1_CTRL_REG, 0xffffffff, 0x00060005, + mmCGTS_CU7_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, + mmPCIE_INDEX, 0xffffffff, 0x0140001c, + mmPCIE_DATA, 0x000f0000, 0x00000000, + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, +}; + +static const u32 xgpu_golden_settings_tonga_a11[] = { + mmCB_HW_CONTROL, 0xfffdf3cf, 0x00007208, + mmCB_HW_CONTROL_3, 0x00000040, 0x00000040, + mmDB_DEBUG2, 0xf00fffff, 0x00000400, + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, + mmFBC_MISC, 0x1f311fff, 0x12300000, + mmGB_GPU_ID, 0x0000000f, 0x00000000, + mmHDMI_CONTROL, 0x31000111, 0x00000011, + mmMC_ARB_WTM_GRPWT_RD, 0x00000003, 0x00000000, + mmMC_HUB_RDREQ_DMIF_LIMIT, 0x0000007f, 0x00000028, + mmMC_HUB_WDP_UMC, 0x00007fb6, 0x00000991, + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, + mmPA_SC_FIFO_DEPTH_CNTL, 0x000003ff, 0x000000fc, + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, + mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0000003c, + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA0_CLK_CTRL, 0xff000fff, 0x00000000, + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, + mmSDMA1_CLK_CTRL, 0xff000fff, 0x00000000, + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, + mmTCC_CTRL, 0x00100000, 0xf31fff7f, + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000002fb, + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, + mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, +}; + +static const u32 xgpu_tonga_golden_common_all[] = { + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x16000012, + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002A, + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002, + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, +}; + +void amdgpu_xgpu_init_golden_registers(struct amdgpu_device *adev) +{ + switch (adev->asic_type) { + case CHIP_FIJI: + amdgpu_program_register_sequence(adev, + xgpu_fiji_mgcg_cgcg_init, + (const u32)ARRAY_SIZE( + xgpu_fiji_mgcg_cgcg_init)); + amdgpu_program_register_sequence(adev, + xgpu_golden_settings_fiji_a10, + (const u32)ARRAY_SIZE( + xgpu_golden_settings_fiji_a10)); + amdgpu_program_register_sequence(adev, + xgpu_fiji_golden_common_all, + (const u32)ARRAY_SIZE( + xgpu_fiji_golden_common_all)); + break; + case CHIP_TONGA: + amdgpu_program_register_sequence(adev, + xgpu_tonga_mgcg_cgcg_init, + (const u32)ARRAY_SIZE( + xgpu_tonga_mgcg_cgcg_init)); + amdgpu_program_register_sequence(adev, + xgpu_golden_settings_tonga_a11, + (const u32)ARRAY_SIZE(
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c line 310
Quoted 10 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +10
-0+ xgpu_golden_settings_tonga_a11)); +amdgpu_program_register_sequence (adev, + xgpu_tonga_golden_common_all, + (const u32 )ARRAY_SIZE ( + xgpu_tonga_golden_common_all)); +break ; +default : +break ; + } +}
Cleaner to just put this in vi.c.
Alex
Quoted 11 lines
drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c +1
-1+static int xgpu_vi_early_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; --2.7.4
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 22/23 drm/amdgpu: do not reset gpu for virtualization
In reply to a message not in the archiveCurrent job timeout setting is not fit for virtualization, so it will cause job timeout sometimes. Add workaround for this when timeout happen.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -2322,6 +2322,9 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)int resched;bool need_full_reset; +if (amdgpu_sriov_vf (adev)) +return 0 ; +if (!amdgpu_check_soft_reset (adev)) {DRM_INFO ("No hardware hang detected. Did some blocks stall?\n" );return 0 ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 23/23 drm/amdgpu/mxgpu: add Makefie and Kconfig for GPU virtualization
In reply to a message not in the archiveAdd Kconfig for user configure and add Makefile to compile GPU virtualization code and wires it into amdpgu modules.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 7 +++++++ drivers/gpu/drm/amd/mxgpu/Kconfig | 13 +++++++++++++ drivers/gpu/drm/amd/mxgpu/Makefile | 11 +++++++++++ 3 files changed, 31 insertions(+) create mode 100644 drivers/gpu/drm/amd/mxgpu/Kconfig create mode 100644 drivers/gpu/drm/amd/mxgpu/Makefile
drivers/gpu/drm/amd/amdgpu/Makefile +7 -0
@@ -88,6 +88,13 @@ amdgpu-y += \ amdgpu_vce.o \ vce_v3_0.o +# MxGPU componet +ifneq ($(CONFIG_DRM_AMD_MXGPU),) +MxGPU_PATH = ../mxgpu +include $(FULL_AMD_PATH)/mxgpu/Makefile +amdgpu-y += $(AMD_Mx_GPU_FILES) +endif + # add amdkfd interfaces amdgpu-y += \ amdgpu_amdkfd.o \
drivers/gpu/drm/amd/mxgpu/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +menu "AMD GPU virtualization Configuration" + +config DRM_AMD_MXGPU + bool "Enable AMD GPU virtualization support" + depends on DRM_AMDGPU + help + Choose this option if you want to enable experimental support + for AMD GPU virtualization. + This adds AMD GPU virtualization driver and wires it up into + the amdgpu drivers. User can load the driver in guest OS and + run graphics applications on AMD hardware in guest mode. + +endmenu
drivers/gpu/drm/amd/mxgpu/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# +# Makefile for Mxgpu +# + +subdir-ccflags-y += -I$(MxGPU_PATH)/ + +MxGPU = amd_mxgpu.o mxgpu_kiq.o mxgpu_csa.o mxgpu_mb.o mxgpu_vi.o + +AMD_MxGPU = $(addprefix $(MxGPU_PATH)/,$(MxGPU)) + +AMD_Mx_GPU_FILES := $(AMD_MxGPU)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi xiangliang
seems only the cover page was sent to amd-gfx loops, the rest of your serials were not
BR Monk
________________________________
发件人: amd-gfx <[email protected]> 代表 Xiangliang Yu <[email protected]> 发送时间: 2016年12月18日 0:16:22
收件人: [email protected]; dl.SRDC_SW_GPUVirtualization
抄送: Yu, Xiangliang
主题: [PATCH 00/23] Add support AMD GPU virtualization soultion
This patch series will enable AMD GPU virtualization and wires it into amdgpu modules.
The code design is base on below ideas:
1. Make virtualization code independent;
2. Self-maintain related GPU virtualization codes;
3. Easy to maintain virtualization codes;
4. Reduce the influence on other amdgpu components;
5. Easy to support different chips;
According to above ideas, make the following changes:
1. Create a new directory for virtualization and put all of related virtualization code into it;
2. Create new IP block to support different virtual features.
3. Create new file for each different hardware;
In the end, the patch series is support serval virtualization features:
1. Support CSA feature;
2. Support Mailbox communication with GPU hypervisor;
3. Support KIQ feature;
Xiangliang Yu (23):
drm/amdgpu: add support kernel interface queue(KIQ) drm/amdgpu: add kiq into compiling
drm/amdgpu: export KIQ interfaces
drm/amdgpu: add new structure for KIQ memory allcation drm/amdgpu/gfx8: add support KIQ for FIJI/TONGA chips drm/amdgpu/gfx8: correct KIQ hdp flush
drm/amdgpu: create new directory for GPU virtualization drm/amdgpu: add new flag for virtual function
drm/amdgpu: enable virtualization feature for FIJI/TONGA drm/amdgpu: export gem va update interface
drm/amdgpu: implement context save area(CSA) feature drm/amdgpu: Insert meta data during submitting IB drm/amdgpu/mxgpu: add support for mailbox communication drm/amdgpu: export two mailbox interface to amdgpu drm/amdgpu/mxgpu: implement register access function with KIQ drm/amdgpu: add flag to indicate VF runtime state drm/amdgpu: export vi common ip block
drm/amdgpu: add new maroc to identify virtualization ip block drm/amdgpu/mxgpu: add implementation of GPU virtualization of VI drm/amdgpu/mxgpu: enable VI virtualization
drm/amdgpu: change golden register program sequence of virtualization drm/amdgpu: do not reset gpu for virtualization drm/amdgpu/mxgpu: add Makefie and Kconfig for GPU virtualization
drivers/gpu/drm/amd/amdgpu/Makefile | 9 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 35 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c | 436 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 34 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 + drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 240 ++++++++++++++- drivers/gpu/drm/amd/amdgpu/vi.c | 8 +- drivers/gpu/drm/amd/amdgpu/vi.h | 2 +- drivers/gpu/drm/amd/amdgpu/vid.h | 2 + drivers/gpu/drm/amd/include/amd_shared.h | 2 + drivers/gpu/drm/amd/mxgpu/Kconfig | 13 + drivers/gpu/drm/amd/mxgpu/Makefile | 11 + drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c | 105 +++++++ drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h | 93 ++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c | 297 ++++++++++++++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c | 110 +++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c | 159 ++++++++++ drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c | 472 +++++++++++++++++++++++++++++ 24 files changed, 2058 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_kiq.c create mode 100644 drivers/gpu/drm/amd/mxgpu/Kconfig create mode 100644 drivers/gpu/drm/amd/mxgpu/Makefile create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_csa.c create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_kiq.c create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c create mode 100644 drivers/gpu/drm/amd/mxgpu/mxgpu_vi.c
--
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx