drm/amdgpu: request init data in virt detection
Subsystems (2)
PATCH 1/4 drm/amdgpu: request init data in virt detection
From: Wenhui Sheng <[email protected]>
Move request init data to virt detection func, so we can insert request full access between request init data and set ip blocks.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 28 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/nv.c | 11 +++++----- drivers/gpu/drm/amd/amdgpu/nv.h | 1 + drivers/gpu/drm/amd/amdgpu/soc15.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/soc15.h | 1 + drivers/gpu/drm/amd/amdgpu/vi.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.h | 1 + 7 files changed, 46 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +28 -0
@@ -27,6 +27,9 @@#include "amdgpu.h" #include "amdgpu_ras.h" +#include "vi.h" +#include "soc15.h" +#include "nv.h" bool amdgpu_virt_mmio_blocked (struct amdgpu_device *adev) {
@@ -513,6 +516,31 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)if (is_virtual_machine ())/* passthrough mode exclus sriov mod */ adev->virt.caps |=AMDGPU_PASSTHROUGH_MODE ; } + +/* we have the ability to check now */ +if (amdgpu_sriov_vf (adev)) { +switch (adev->asic_type) { +case CHIP_TONGA : +case CHIP_FIJI : +vi_set_virt_ops (adev); +break ; +case CHIP_VEGA10 : +case CHIP_VEGA20 : +case CHIP_ARCTURUS : +soc15_set_virt_ops (adev); +break ; +case CHIP_NAVI10 : +case CHIP_NAVI12 : +case CHIP_SIENNA_CICHLID : +nv_set_virt_ops (adev); +/* try send GPU_INIT_DATA request to host */ +amdgpu_virt_request_init_data (adev); +break ; +default :/* other chip doesn't support SRIOV */ +DRM_ERROR ("Unknown asic type: %d!\n" , adev->asic_type); +break ; + } + } }static bool amdgpu_virt_access_debugfs_is_mmio (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/nv.c +5 -6
@@ -420,6 +420,11 @@ static int nv_reg_base_init(struct amdgpu_device *adev)return 0 ; } +void nv_set_virt_ops (struct amdgpu_device *adev) +{ + adev->virt.ops = &xgpu_nv_virt_ops; +} +int nv_set_ip_blocks (struct amdgpu_device *adev) {int r;
@@ -427,12 +432,6 @@ int nv_set_ip_blocks(struct amdgpu_device *adev) adev->nbio.funcs = &nbio_v2_3_funcs; adev->nbio.hdp_flush_reg = &nbio_v2_3_hdp_flush_reg; -if (amdgpu_sriov_vf (adev)) { - adev->virt.ops = &xgpu_nv_virt_ops; -/* try send GPU_INIT_DATA request to host */ -amdgpu_virt_request_init_data (adev); - } -/* Set IP register base before any HW register access */ r =nv_reg_base_init (adev);if (r)
drivers/gpu/drm/amd/amdgpu/nv.h +1 -0
@@ -28,6 +28,7 @@void nv_grbm_select (struct amdgpu_device *adev,u32 me,u32 pipe,u32 queue,u32 vmid); +void nv_set_virt_ops (struct amdgpu_device *adev);int nv_set_ip_blocks (struct amdgpu_device *adev);int navi10_reg_base_init (struct amdgpu_device *adev);int navi14_reg_base_init (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/soc15.c +5 -3
@@ -669,6 +669,11 @@ static uint32_t soc15_get_rev_id(struct amdgpu_device *adev)return adev->nbio.funcs->get_rev_id (adev); } +void soc15_set_virt_ops (struct amdgpu_device *adev) +{ + adev->virt.ops = &xgpu_ai_virt_ops; +} +int soc15_set_ip_blocks (struct amdgpu_device *adev) {int r;
@@ -722,9 +727,6 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) adev->rev_id =soc15_get_rev_id (adev); -if (amdgpu_sriov_vf (adev)) - adev->virt.ops = &xgpu_ai_virt_ops; -switch (adev->asic_type) {case CHIP_VEGA10 :case CHIP_VEGA12 :
drivers/gpu/drm/amd/amdgpu/soc15.h +1 -0
@@ -90,6 +90,7 @@ struct soc15_ras_field_entry {void soc15_grbm_select (struct amdgpu_device *adev,u32 me,u32 pipe,u32 queue,u32 vmid); +void soc15_set_virt_ops (struct amdgpu_device *adev);int soc15_set_ip_blocks (struct amdgpu_device *adev); void soc15_program_register_sequence(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/vi.c +5 -3
@@ -1705,11 +1705,13 @@ static const struct amdgpu_ip_block_version vi_common_ip_block = .funcs = &vi_common_ip_funcs, }; -int vi_set_ip_blocks (struct amdgpu_device *adev) +void vi_set_virt_ops (struct amdgpu_device *adev) { -if (amdgpu_sriov_vf (adev)) - adev->virt.ops = &xgpu_vi_virt_ops; + adev->virt.ops = &xgpu_vi_virt_ops; +} +int vi_set_ip_blocks (struct amdgpu_device *adev) +{switch (adev->asic_type) {case CHIP_TOPAZ :/* topaz has no DCE, UVD, VCE */
drivers/gpu/drm/amd/amdgpu/vi.h +1 -0
@@ -28,6 +28,7 @@void vi_srbm_select (struct amdgpu_device *adev,u32 me,u32 pipe,u32 queue,u32 vmid); +void vi_set_virt_ops (struct amdgpu_device *adev);int vi_set_ip_blocks (struct amdgpu_device *adev);void legacy_doorbell_index_init (struct amdgpu_device *adev);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/4 drm/amdgpu: move reg base init forward for soc15
From: Wenhui Sheng <[email protected]>
Init soc15 reg base early enough so we can touch mailbox related registers in request full access for sriov before set_ip_blocks, vi&nv arch doesn't use reg base in virt ops.
v2: fix reg_base_init missed in bare metal case.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +22 -7
@@ -669,12 +669,7 @@ static uint32_t soc15_get_rev_id(struct amdgpu_device *adev)return adev->nbio.funcs->get_rev_id (adev); } -void soc15_set_virt_ops (struct amdgpu_device *adev) -{ - adev->virt.ops = &xgpu_ai_virt_ops; -} - -int soc15_set_ip_blocks (struct amdgpu_device *adev) +static void soc15_reg_base_init (struct amdgpu_device *adev) {int r;
@@ -686,6 +681,8 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)vega10_reg_base_init (adev);break ;case CHIP_RENOIR : +/* It's safe to do ip discovery here for Renior, +* it doesn't support SRIOV. */ if (amdgpu_discovery) { r =amdgpu_discovery_reg_base_init (adev);if (r) {
@@ -702,8 +699,26 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)arct_reg_base_init (adev);break ;default : -return -EINVAL ; +DRM_ERROR ("Unsupported asic type: %d!\n" , adev->asic_type); +break ; } +} + +void soc15_set_virt_ops (struct amdgpu_device *adev) +{ + adev->virt.ops = &xgpu_ai_virt_ops; + +/* init soc15 reg base early enough so we can +* request request full access for sriov before +* set_ip_blocks. */ +soc15_reg_base_init (adev); +} + +int soc15_set_ip_blocks (struct amdgpu_device *adev) +{ +/* for bare metal case */ +if (!amdgpu_sriov_vf (adev)) +soc15_reg_base_init (adev);if (adev->asic_type ==CHIP_VEGA20 || adev->asic_type ==CHIP_ARCTURUS ) adev->gmc.xgmi.supported = true;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu: invoke req full access early enough
In reply to Wenhui.ShengFrom: Wenhui Sheng <[email protected]>
From SIENNA_CICHLID, HW introduce a new protection feature which can control the FB, doorbell and MMIO write access for VF, so guest driver should request full access before ip discovery, or we couldn't access ip discovery data in FB.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 54 +++++++++------------- 1 file changed, 23 insertions(+), 31 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +23 -31
@@ -1722,6 +1722,29 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)amdgpu_device_enable_virtual_display (adev); +if (amdgpu_sriov_vf (adev)) { +/* handle vbios stuff prior full access mode for new handshake */ +if (adev->virt.req_init_data_ver ==1 ) { +if (!amdgpu_get_bios (adev)) { +DRM_ERROR ("failed to get vbios\n" ); +return -EINVAL ; + } + + r =amdgpu_atombios_init (adev); +if (r) { +dev_err (adev->dev,"amdgpu_atombios_init failed\n" ); +amdgpu_vf_error_put (adev,AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL ,0 ,0 ); +return r; + } + } + + r =amdgpu_virt_request_full_gpu (adev, true); +if (r) { +amdgpu_atombios_fini (adev); +return r; + } + } +switch (adev->asic_type) {#ifdef CONFIG_DRM_AMDGPU_SI case CHIP_VERDE :
@@ -1801,31 +1824,6 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)amdgpu_amdkfd_device_probe (adev); -if (amdgpu_sriov_vf (adev)) { -/* handle vbios stuff prior full access mode for new handshake */ -if (adev->virt.req_init_data_ver ==1 ) { -if (!amdgpu_get_bios (adev)) { -DRM_ERROR ("failed to get vbios\n" ); -return -EINVAL ; - } - - r =amdgpu_atombios_init (adev); -if (r) { -dev_err (adev->dev,"amdgpu_atombios_init failed\n" ); -amdgpu_vf_error_put (adev,AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL ,0 ,0 ); -return r; - } - } - } - -/* we need to send REQ_GPU here for legacy handshaker otherwise the vbios -* will not be prepared by host for this VF */ -if (amdgpu_sriov_vf (adev) && adev->virt.req_init_data_ver <1 ) { - r =amdgpu_virt_request_full_gpu (adev, true); -if (r) -return r; - } - adev->pm.pp_feature = amdgpu_pp_feature_mask;if (amdgpu_sriov_vf (adev) || sched_policy ==KFD_SCHED_POLICY_NO_HWS ) adev->pm.pp_feature &= ~PP_GFXOFF_MASK ;
@@ -1987,12 +1985,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)if (r)return r; -if (amdgpu_sriov_vf (adev) && adev->virt.req_init_data_ver >0 ) { - r =amdgpu_virt_request_full_gpu (adev, true); -if (r) -return -EAGAIN ; - } -for (i =0 ; i < adev->num_ip_blocks; i++) {if (!adev->ip_blocks[i].status.valid)continue ;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdgpu: merge atombios init block
In reply to Wenhui.ShengFrom: Wenhui Sheng <[email protected]>
After we move request full access before set
ip blocks, we can merge atombios init block
of SRIOV and baremetal together.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +--------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -22
@@ -1723,26 +1723,9 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)amdgpu_device_enable_virtual_display (adev);if (amdgpu_sriov_vf (adev)) { -/* handle vbios stuff prior full access mode for new handshake */ -if (adev->virt.req_init_data_ver ==1 ) { -if (!amdgpu_get_bios (adev)) { -DRM_ERROR ("failed to get vbios\n" ); -return -EINVAL ; - } - - r =amdgpu_atombios_init (adev); -if (r) { -dev_err (adev->dev,"amdgpu_atombios_init failed\n" ); -amdgpu_vf_error_put (adev,AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL ,0 ,0 ); -return r; - } - } - r =amdgpu_virt_request_full_gpu (adev, true); -if (r) { -amdgpu_atombios_fini (adev); +if (r)return r; - } }switch (adev->asic_type) {
@@ -1855,10 +1838,6 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)if (r)return r; -/* skip vbios handling for new handshake */ -if (amdgpu_sriov_vf (adev) && adev->virt.req_init_data_ver ==1 ) -continue ; -/* Read BIOS */ if (!amdgpu_get_bios (adev))return -EINVAL ;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/4] drm/amdgpu: merge atombios init block
Series is
Regards,
Hawking
Sent from my iPhone
Quoted 59 lines · Wenhui
From: Wenhui Sheng <[email protected]>
After we move request full access before set
ip blocks, we can merge atombios init block
of SRIOV and baremetal together.Signed-off-by Wenhui Sheng <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 23 +---------------------1 file changed, 1 insertion(+), 22 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-22@@ -1723,26 +1723,9 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)amdgpu_device_enable_virtual_display (adev);if (amdgpu_sriov_vf (adev)) { -/* handle vbios stuff prior full access mode for new handshake */ -if (adev->virt.req_init_data_ver ==1 ) { -if (!amdgpu_get_bios (adev)) { -DRM_ERROR ("failed to get vbios\n" ); -return -EINVAL ; - } - - r =amdgpu_atombios_init (adev); -if (r) { -dev_err (adev->dev,"amdgpu_atombios_init failed\n" ); -amdgpu_vf_error_put (adev,AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL ,0 ,0 ); -return r; - } - } - r =amdgpu_virt_request_full_gpu (adev, true); -if (r) { -amdgpu_atombios_fini (adev); +if (r)return r; - } }switch (adev->asic_type) {@@ -1855,10 +1838,6 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)if (r)return r; -/* skip vbios handling for new handshake */ -if (amdgpu_sriov_vf (adev) && adev->virt.req_init_data_ver ==1 ) -continue ; -/* Read BIOS */ if (!amdgpu_get_bios (adev))return -EINVAL ;Signature · 1 line
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx