All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
@ 2020-01-02  7:43 Jack Zhang
  2020-01-02  8:03 ` Quan, Evan
  0 siblings, 1 reply; 8+ messages in thread
From: Jack Zhang @ 2020-01-02  7:43 UTC (permalink / raw)
  To: amd-gfx; +Cc: Jack.Zhang1

Before, initialization of smu ip block would be skipped
for sriov ASICs. But if there's only one VF being used,
guest driver should be able to dump some HW info such as
clks, temperature,etc.

To solve this, now after onevf mode is enabled, host
driver will notify guest. If it's onevf mode, guest will
do smu hw_init and skip some steps in normal smu hw_init
flow because host driver has already done it for smu.

With this fix, guest app can talk with smu and dump hw
information from smu.

v2: refine the logic for pm_enabled.Skip hw_init by not
changing pm_enabled.
v3: refine is_support_sw_smu and fix some indentation
issue.

Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 98 ++++++++++++++++--------------
 3 files changed, 56 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 0d842a1..5341905 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1454,7 +1454,8 @@ static int psp_np_fw_load(struct psp_context *psp)
                     || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
-	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
 			/*skip ucode loading in SRIOV VF */
 			continue;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 6129fab..26e1c8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -826,8 +826,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
 			amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
-		if (!amdgpu_sriov_vf(adev))
-			amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
+		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
 
 		if (unlikely(adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT))
 			amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 4ed8bdc..4b96937 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -531,7 +531,7 @@ bool is_support_sw_smu(struct amdgpu_device *adev)
 	if (adev->asic_type == CHIP_VEGA20)
 		return (amdgpu_dpm == 2) ? true : false;
 	else if (adev->asic_type >= CHIP_ARCTURUS) {
-		if (amdgpu_sriov_vf(adev))
+		if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
 			return false;
 		else
 			return true;
@@ -1061,28 +1061,27 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	}
 
 	/* smu_dump_pptable(smu); */
+	if (!amdgpu_sriov_vf(adev)) {
+		/*
+		 * Copy pptable bo in the vram to smc with SMU MSGs such as
+		 * SetDriverDramAddr and TransferTableDram2Smu.
+		 */
+		ret = smu_write_pptable(smu);
+		if (ret)
+			return ret;
 
-	/*
-	 * Copy pptable bo in the vram to smc with SMU MSGs such as
-	 * SetDriverDramAddr and TransferTableDram2Smu.
-	 */
-	ret = smu_write_pptable(smu);
-	if (ret)
-		return ret;
-
-	/* issue Run*Btc msg */
-	ret = smu_run_btc(smu);
-	if (ret)
-		return ret;
-
-	ret = smu_feature_set_allowed_mask(smu);
-	if (ret)
-		return ret;
-
-	ret = smu_system_features_control(smu, true);
-	if (ret)
-		return ret;
+		/* issue Run*Btc msg */
+		ret = smu_run_btc(smu);
+		if (ret)
+			return ret;
+		ret = smu_feature_set_allowed_mask(smu);
+		if (ret)
+			return ret;
 
+		ret = smu_system_features_control(smu, true);
+		if (ret)
+			return ret;
+	}
 	if (adev->asic_type != CHIP_ARCTURUS) {
 		ret = smu_notify_display_change(smu);
 		if (ret)
@@ -1135,8 +1134,9 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	/*
 	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools.
 	 */
-	ret = smu_set_tool_table_location(smu);
-
+	if (!amdgpu_sriov_vf(adev)) {
+		ret = smu_set_tool_table_location(smu);
+	}
 	if (!smu_is_dpm_running(smu))
 		pr_info("dpm has been disabled\n");
 
@@ -1248,6 +1248,9 @@ static int smu_hw_init(void *handle)
 		smu_set_gfx_cgpg(&adev->smu, true);
 	}
 
+	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+		return 0;
+
 	if (!smu->pm_enabled)
 		return 0;
 
@@ -1300,37 +1303,42 @@ static int smu_hw_fini(void *handle)
 	struct smu_table_context *table_context = &smu->smu_table;
 	int ret = 0;
 
+	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
+		return 0;
+
 	if (adev->flags & AMD_IS_APU) {
 		smu_powergate_sdma(&adev->smu, true);
 		smu_powergate_vcn(&adev->smu, true);
 		smu_powergate_jpeg(&adev->smu, true);
 	}
 
-	ret = smu_stop_thermal_control(smu);
-	if (ret) {
-		pr_warn("Fail to stop thermal control!\n");
-		return ret;
-	}
-
-	/*
-	 * For custom pptable uploading, skip the DPM features
-	 * disable process on Navi1x ASICs.
-	 *   - As the gfx related features are under control of
-	 *     RLC on those ASICs. RLC reinitialization will be
-	 *     needed to reenable them. That will cost much more
-	 *     efforts.
-	 *
-	 *   - SMU firmware can handle the DPM reenablement
-	 *     properly.
-	 */
-	if (!smu->uploading_custom_pp_table ||
-	    !((adev->asic_type >= CHIP_NAVI10) &&
-	      (adev->asic_type <= CHIP_NAVI12))) {
-		ret = smu_stop_dpms(smu);
+	if (!amdgpu_sriov_vf(adev)){
+		ret = smu_stop_thermal_control(smu);
 		if (ret) {
-			pr_warn("Fail to stop Dpms!\n");
+			pr_warn("Fail to stop thermal control!\n");
 			return ret;
 		}
+
+		/*
+		 * For custom pptable uploading, skip the DPM features
+		 * disable process on Navi1x ASICs.
+		 *   - As the gfx related features are under control of
+		 *     RLC on those ASICs. RLC reinitialization will be
+		 *     needed to reenable them. That will cost much more
+		 *     efforts.
+		 *
+		 *   - SMU firmware can handle the DPM reenablement
+		 *     properly.
+		 */
+		if (!smu->uploading_custom_pp_table ||
+				!((adev->asic_type >= CHIP_NAVI10) &&
+					(adev->asic_type <= CHIP_NAVI12))) {
+			ret = smu_stop_dpms(smu);
+			if (ret) {
+				pr_warn("Fail to stop Dpms!\n");
+				return ret;
+			}
+		}
 	}
 
 	kfree(table_context->driver_pptable);
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
  2020-01-02  7:43 [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF Jack Zhang
@ 2020-01-02  8:03 ` Quan, Evan
  0 siblings, 0 replies; 8+ messages in thread
From: Quan, Evan @ 2020-01-02  8:03 UTC (permalink / raw)
  To: Zhang, Jack (Jian), amd-gfx; +Cc: Zhang, Jack (Jian)

Acked-by: Evan Quan <evan.quan@amd.com>

> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Jack
> Zhang
> Sent: Thursday, January 2, 2020 3:44 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
> Subject: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
> 
> Before, initialization of smu ip block would be skipped for sriov ASICs. But if
> there's only one VF being used, guest driver should be able to dump some HW
> info such as clks, temperature,etc.
> 
> To solve this, now after onevf mode is enabled, host driver will notify guest. If
> it's onevf mode, guest will do smu hw_init and skip some steps in normal smu
> hw_init flow because host driver has already done it for smu.
> 
> With this fix, guest app can talk with smu and dump hw information from smu.
> 
> v2: refine the logic for pm_enabled.Skip hw_init by not changing pm_enabled.
> v3: refine is_support_sw_smu and fix some indentation issue.
> 
> Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
>  drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 98 ++++++++++++++++------
> --------
>  3 files changed, 56 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 0d842a1..5341905 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -1454,7 +1454,8 @@ static int psp_np_fw_load(struct psp_context *psp)
>                      || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
>  	            || ucode->ucode_id ==
> AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
>  	            || ucode->ucode_id ==
> AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
> -	            || ucode->ucode_id ==
> AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
> +	            || ucode->ucode_id ==
> AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
> +	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
>  			/*skip ucode loading in SRIOV VF */
>  			continue;
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c
> b/drivers/gpu/drm/amd/amdgpu/soc15.c
> index 6129fab..26e1c8c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/soc15.c
> +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
> @@ -826,8 +826,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
>  			amdgpu_device_ip_block_add(adev,
> &dce_virtual_ip_block);
>  		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
>  		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
> -		if (!amdgpu_sriov_vf(adev))
> -			amdgpu_device_ip_block_add(adev,
> &smu_v11_0_ip_block);
> +		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
> 
>  		if (unlikely(adev->firmware.load_type ==
> AMDGPU_FW_LOAD_DIRECT))
>  			amdgpu_device_ip_block_add(adev,
> &vcn_v2_5_ip_block); diff --git
> a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 4ed8bdc..4b96937 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -531,7 +531,7 @@ bool is_support_sw_smu(struct amdgpu_device *adev)
>  	if (adev->asic_type == CHIP_VEGA20)
>  		return (amdgpu_dpm == 2) ? true : false;
>  	else if (adev->asic_type >= CHIP_ARCTURUS) {
> -		if (amdgpu_sriov_vf(adev))
> +		if
> (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
>  			return false;
>  		else
>  			return true;
> @@ -1061,28 +1061,27 @@ static int smu_smc_table_hw_init(struct
> smu_context *smu,
>  	}
> 
>  	/* smu_dump_pptable(smu); */
> +	if (!amdgpu_sriov_vf(adev)) {
> +		/*
> +		 * Copy pptable bo in the vram to smc with SMU MSGs such as
> +		 * SetDriverDramAddr and TransferTableDram2Smu.
> +		 */
> +		ret = smu_write_pptable(smu);
> +		if (ret)
> +			return ret;
> 
> -	/*
> -	 * Copy pptable bo in the vram to smc with SMU MSGs such as
> -	 * SetDriverDramAddr and TransferTableDram2Smu.
> -	 */
> -	ret = smu_write_pptable(smu);
> -	if (ret)
> -		return ret;
> -
> -	/* issue Run*Btc msg */
> -	ret = smu_run_btc(smu);
> -	if (ret)
> -		return ret;
> -
> -	ret = smu_feature_set_allowed_mask(smu);
> -	if (ret)
> -		return ret;
> -
> -	ret = smu_system_features_control(smu, true);
> -	if (ret)
> -		return ret;
> +		/* issue Run*Btc msg */
> +		ret = smu_run_btc(smu);
> +		if (ret)
> +			return ret;
> +		ret = smu_feature_set_allowed_mask(smu);
> +		if (ret)
> +			return ret;
> 
> +		ret = smu_system_features_control(smu, true);
> +		if (ret)
> +			return ret;
> +	}
>  	if (adev->asic_type != CHIP_ARCTURUS) {
>  		ret = smu_notify_display_change(smu);
>  		if (ret)
> @@ -1135,8 +1134,9 @@ static int smu_smc_table_hw_init(struct
> smu_context *smu,
>  	/*
>  	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for
> tools.
>  	 */
> -	ret = smu_set_tool_table_location(smu);
> -
> +	if (!amdgpu_sriov_vf(adev)) {
> +		ret = smu_set_tool_table_location(smu);
> +	}
>  	if (!smu_is_dpm_running(smu))
>  		pr_info("dpm has been disabled\n");
> 
> @@ -1248,6 +1248,9 @@ static int smu_hw_init(void *handle)
>  		smu_set_gfx_cgpg(&adev->smu, true);
>  	}
> 
> +	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
> +		return 0;
> +
>  	if (!smu->pm_enabled)
>  		return 0;
> 
> @@ -1300,37 +1303,42 @@ static int smu_hw_fini(void *handle)
>  	struct smu_table_context *table_context = &smu->smu_table;
>  	int ret = 0;
> 
> +	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
> +		return 0;
> +
>  	if (adev->flags & AMD_IS_APU) {
>  		smu_powergate_sdma(&adev->smu, true);
>  		smu_powergate_vcn(&adev->smu, true);
>  		smu_powergate_jpeg(&adev->smu, true);
>  	}
> 
> -	ret = smu_stop_thermal_control(smu);
> -	if (ret) {
> -		pr_warn("Fail to stop thermal control!\n");
> -		return ret;
> -	}
> -
> -	/*
> -	 * For custom pptable uploading, skip the DPM features
> -	 * disable process on Navi1x ASICs.
> -	 *   - As the gfx related features are under control of
> -	 *     RLC on those ASICs. RLC reinitialization will be
> -	 *     needed to reenable them. That will cost much more
> -	 *     efforts.
> -	 *
> -	 *   - SMU firmware can handle the DPM reenablement
> -	 *     properly.
> -	 */
> -	if (!smu->uploading_custom_pp_table ||
> -	    !((adev->asic_type >= CHIP_NAVI10) &&
> -	      (adev->asic_type <= CHIP_NAVI12))) {
> -		ret = smu_stop_dpms(smu);
> +	if (!amdgpu_sriov_vf(adev)){
> +		ret = smu_stop_thermal_control(smu);
>  		if (ret) {
> -			pr_warn("Fail to stop Dpms!\n");
> +			pr_warn("Fail to stop thermal control!\n");
>  			return ret;
>  		}
> +
> +		/*
> +		 * For custom pptable uploading, skip the DPM features
> +		 * disable process on Navi1x ASICs.
> +		 *   - As the gfx related features are under control of
> +		 *     RLC on those ASICs. RLC reinitialization will be
> +		 *     needed to reenable them. That will cost much more
> +		 *     efforts.
> +		 *
> +		 *   - SMU firmware can handle the DPM reenablement
> +		 *     properly.
> +		 */
> +		if (!smu->uploading_custom_pp_table ||
> +				!((adev->asic_type >= CHIP_NAVI10) &&
> +					(adev->asic_type <= CHIP_NAVI12))) {
> +			ret = smu_stop_dpms(smu);
> +			if (ret) {
> +				pr_warn("Fail to stop Dpms!\n");
> +				return ret;
> +			}
> +		}
>  	}
> 
>  	kfree(table_context->driver_pptable);
> --
> 2.7.4
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free
> desktop.org%2Fmailman%2Flistinfo%2Famd-
> gfx&amp;data=02%7C01%7Cevan.quan%40amd.com%7C229782939fa0482d84f
> 308d78f5787c2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6371
> 35478506764166&amp;sdata=pX92Zwa84idHjZsFY%2BUjLEamVuF6UuIg4oiJffe
> 0fj8%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
  2020-01-02  5:50 Jack Zhang
@ 2020-01-02  6:18 ` Quan, Evan
  0 siblings, 0 replies; 8+ messages in thread
From: Quan, Evan @ 2020-01-02  6:18 UTC (permalink / raw)
  To: Zhang, Jack (Jian), amd-gfx; +Cc: Zhang, Jack (Jian)



> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Jack
> Zhang
> Sent: Thursday, January 2, 2020 1:50 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
> Subject: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
> 
> Before, initialization of smu ip block would be skipped
> for sriov ASICs. But if there's only one VF being used,
> guest driver should be able to dump some HW info such as
> clks, temperature,etc.
> 
> To solve this, now after onevf mode is enabled, host
> driver will notify guest. If it's onevf mode, guest will
> do smu hw_init and skip some steps in normal smu hw_init
> flow because host driver has already done it for smu.
> 
> With this fix, guest app can talk with smu and dump hw
> information from smu.
> 
> v2: refine the logic for pm_enabled.Skip hw_init by not
> changing pm_enabled.
> 
> Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
>  drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 94 +++++++++++++++++----
> ---------
>  3 files changed, 56 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 0d842a1..5341905 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -1454,7 +1454,8 @@ static int psp_np_fw_load(struct psp_context *psp)
>                      || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
>  	            || ucode->ucode_id ==
> AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
>  	            || ucode->ucode_id ==
> AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
> -	            || ucode->ucode_id ==
> AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
> +	            || ucode->ucode_id ==
> AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
> +	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
>  			/*skip ucode loading in SRIOV VF */
>  			continue;
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c
> b/drivers/gpu/drm/amd/amdgpu/soc15.c
> index 6129fab..26e1c8c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/soc15.c
> +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
> @@ -826,8 +826,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
>  			amdgpu_device_ip_block_add(adev,
> &dce_virtual_ip_block);
>  		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
>  		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
> -		if (!amdgpu_sriov_vf(adev))
> -			amdgpu_device_ip_block_add(adev,
> &smu_v11_0_ip_block);
> +		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
> 
>  		if (unlikely(adev->firmware.load_type ==
> AMDGPU_FW_LOAD_DIRECT))
>  			amdgpu_device_ip_block_add(adev,
> &vcn_v2_5_ip_block);
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 4ed8bdc..fa17265 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -531,10 +531,14 @@ bool is_support_sw_smu(struct amdgpu_device
> *adev)
>  	if (adev->asic_type == CHIP_VEGA20)
>  		return (amdgpu_dpm == 2) ? true : false;
>  	else if (adev->asic_type >= CHIP_ARCTURUS) {
> -		if (amdgpu_sriov_vf(adev))
> -			return false;
> -		else
> +		if (amdgpu_sriov_vf(adev)) {
> +			if(amdgpu_sriov_is_pp_one_vf(adev))
> +				return true;
> +			else
> +				return false;
> +		} else {
>  			return true;
> +		}
[Quan, Evan] Maybe this can be simplified as below:
if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
          return false;
else
          return true;
>  	} else
>  		return false;
>  }
> @@ -1061,20 +1065,19 @@ static int smu_smc_table_hw_init(struct
> smu_context *smu,
>  	}
> 
>  	/* smu_dump_pptable(smu); */
> +	if (!amdgpu_sriov_vf(adev)) {
> +		/*
> +		 * Copy pptable bo in the vram to smc with SMU MSGs such as
> +		 * SetDriverDramAddr and TransferTableDram2Smu.
> +		 */
> +		ret = smu_write_pptable(smu);
> +		if (ret)
> +			return ret;
> 
> -	/*
> -	 * Copy pptable bo in the vram to smc with SMU MSGs such as
> -	 * SetDriverDramAddr and TransferTableDram2Smu.
> -	 */
> -	ret = smu_write_pptable(smu);
> -	if (ret)
> -		return ret;
> -
> -	/* issue Run*Btc msg */
> -	ret = smu_run_btc(smu);
> -	if (ret)
> -		return ret;
> -
> +		/* issue Run*Btc msg */
> +		ret = smu_run_btc(smu);
> +		if (ret)
> +			return ret;
>  	ret = smu_feature_set_allowed_mask(smu);
>  	if (ret)
>  		return ret;
> @@ -1082,7 +1085,7 @@ static int smu_smc_table_hw_init(struct
> smu_context *smu,
>  	ret = smu_system_features_control(smu, true);
>  	if (ret)
>  		return ret;
> -
> +	}
[Quan, Evan] Please check the code style here. It seems the code above does not have the same indentation.
>  	if (adev->asic_type != CHIP_ARCTURUS) {
>  		ret = smu_notify_display_change(smu);
>  		if (ret)
> @@ -1135,8 +1138,9 @@ static int smu_smc_table_hw_init(struct
> smu_context *smu,
>  	/*
>  	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for
> tools.
>  	 */
> -	ret = smu_set_tool_table_location(smu);
> -
> +	if (!amdgpu_sriov_vf(adev)) {
> +		ret = smu_set_tool_table_location(smu);
> +	}
>  	if (!smu_is_dpm_running(smu))
>  		pr_info("dpm has been disabled\n");
> 
> @@ -1248,6 +1252,9 @@ static int smu_hw_init(void *handle)
>  		smu_set_gfx_cgpg(&adev->smu, true);
>  	}
> 
> +	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
> +		return 0;
> +
>  	if (!smu->pm_enabled)
>  		return 0;
> 
> @@ -1300,37 +1307,42 @@ static int smu_hw_fini(void *handle)
>  	struct smu_table_context *table_context = &smu->smu_table;
>  	int ret = 0;
> 
> +	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
> +		return 0;
> +
>  	if (adev->flags & AMD_IS_APU) {
>  		smu_powergate_sdma(&adev->smu, true);
>  		smu_powergate_vcn(&adev->smu, true);
>  		smu_powergate_jpeg(&adev->smu, true);
>  	}
> 
> -	ret = smu_stop_thermal_control(smu);
> -	if (ret) {
> -		pr_warn("Fail to stop thermal control!\n");
> -		return ret;
> -	}
> -
> -	/*
> -	 * For custom pptable uploading, skip the DPM features
> -	 * disable process on Navi1x ASICs.
> -	 *   - As the gfx related features are under control of
> -	 *     RLC on those ASICs. RLC reinitialization will be
> -	 *     needed to reenable them. That will cost much more
> -	 *     efforts.
> -	 *
> -	 *   - SMU firmware can handle the DPM reenablement
> -	 *     properly.
> -	 */
> -	if (!smu->uploading_custom_pp_table ||
> -	    !((adev->asic_type >= CHIP_NAVI10) &&
> -	      (adev->asic_type <= CHIP_NAVI12))) {
> -		ret = smu_stop_dpms(smu);
> +	if (!amdgpu_sriov_vf(adev)){
> +		ret = smu_stop_thermal_control(smu);
>  		if (ret) {
> -			pr_warn("Fail to stop Dpms!\n");
> +			pr_warn("Fail to stop thermal control!\n");
>  			return ret;
>  		}
> +
> +		/*
> +		 * For custom pptable uploading, skip the DPM features
> +		 * disable process on Navi1x ASICs.
> +		 *   - As the gfx related features are under control of
> +		 *     RLC on those ASICs. RLC reinitialization will be
> +		 *     needed to reenable them. That will cost much more
> +		 *     efforts.
> +		 *
> +		 *   - SMU firmware can handle the DPM reenablement
> +		 *     properly.
> +		 */
> +		if (!smu->uploading_custom_pp_table ||
> +				!((adev->asic_type >= CHIP_NAVI10) &&
> +					(adev->asic_type <= CHIP_NAVI12))) {
> +			ret = smu_stop_dpms(smu);
> +			if (ret) {
> +				pr_warn("Fail to stop Dpms!\n");
> +				return ret;
> +			}
> +		}
>  	}
> 
>  	kfree(table_context->driver_pptable);
> --
> 2.7.4
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free
> desktop.org%2Fmailman%2Flistinfo%2Famd-
> gfx&amp;data=02%7C01%7Cevan.quan%40amd.com%7Cfbd41f8689704e60cb8
> f08d78f47aac1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63713
> 5410346465153&amp;sdata=7xQsqRAFgxZTPkU9v5zEAaWzmKIMA%2FiQyn1wD
> ftSZgQ%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
@ 2020-01-02  5:50 Jack Zhang
  2020-01-02  6:18 ` Quan, Evan
  0 siblings, 1 reply; 8+ messages in thread
From: Jack Zhang @ 2020-01-02  5:50 UTC (permalink / raw)
  To: amd-gfx; +Cc: Jack.Zhang1

Before, initialization of smu ip block would be skipped
for sriov ASICs. But if there's only one VF being used,
guest driver should be able to dump some HW info such as
clks, temperature,etc.

To solve this, now after onevf mode is enabled, host
driver will notify guest. If it's onevf mode, guest will
do smu hw_init and skip some steps in normal smu hw_init
flow because host driver has already done it for smu.

With this fix, guest app can talk with smu and dump hw
information from smu.

v2: refine the logic for pm_enabled.Skip hw_init by not
changing pm_enabled.

Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 94 +++++++++++++++++-------------
 3 files changed, 56 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 0d842a1..5341905 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1454,7 +1454,8 @@ static int psp_np_fw_load(struct psp_context *psp)
                     || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
-	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
 			/*skip ucode loading in SRIOV VF */
 			continue;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 6129fab..26e1c8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -826,8 +826,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
 			amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
-		if (!amdgpu_sriov_vf(adev))
-			amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
+		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
 
 		if (unlikely(adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT))
 			amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 4ed8bdc..fa17265 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -531,10 +531,14 @@ bool is_support_sw_smu(struct amdgpu_device *adev)
 	if (adev->asic_type == CHIP_VEGA20)
 		return (amdgpu_dpm == 2) ? true : false;
 	else if (adev->asic_type >= CHIP_ARCTURUS) {
-		if (amdgpu_sriov_vf(adev))
-			return false;
-		else
+		if (amdgpu_sriov_vf(adev)) {
+			if(amdgpu_sriov_is_pp_one_vf(adev))
+				return true;
+			else
+				return false;
+		} else {
 			return true;
+		}
 	} else
 		return false;
 }
@@ -1061,20 +1065,19 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	}
 
 	/* smu_dump_pptable(smu); */
+	if (!amdgpu_sriov_vf(adev)) {
+		/*
+		 * Copy pptable bo in the vram to smc with SMU MSGs such as
+		 * SetDriverDramAddr and TransferTableDram2Smu.
+		 */
+		ret = smu_write_pptable(smu);
+		if (ret)
+			return ret;
 
-	/*
-	 * Copy pptable bo in the vram to smc with SMU MSGs such as
-	 * SetDriverDramAddr and TransferTableDram2Smu.
-	 */
-	ret = smu_write_pptable(smu);
-	if (ret)
-		return ret;
-
-	/* issue Run*Btc msg */
-	ret = smu_run_btc(smu);
-	if (ret)
-		return ret;
-
+		/* issue Run*Btc msg */
+		ret = smu_run_btc(smu);
+		if (ret)
+			return ret;
 	ret = smu_feature_set_allowed_mask(smu);
 	if (ret)
 		return ret;
@@ -1082,7 +1085,7 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	ret = smu_system_features_control(smu, true);
 	if (ret)
 		return ret;
-
+	}
 	if (adev->asic_type != CHIP_ARCTURUS) {
 		ret = smu_notify_display_change(smu);
 		if (ret)
@@ -1135,8 +1138,9 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	/*
 	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools.
 	 */
-	ret = smu_set_tool_table_location(smu);
-
+	if (!amdgpu_sriov_vf(adev)) {
+		ret = smu_set_tool_table_location(smu);
+	}
 	if (!smu_is_dpm_running(smu))
 		pr_info("dpm has been disabled\n");
 
@@ -1248,6 +1252,9 @@ static int smu_hw_init(void *handle)
 		smu_set_gfx_cgpg(&adev->smu, true);
 	}
 
+	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+		return 0;
+
 	if (!smu->pm_enabled)
 		return 0;
 
@@ -1300,37 +1307,42 @@ static int smu_hw_fini(void *handle)
 	struct smu_table_context *table_context = &smu->smu_table;
 	int ret = 0;
 
+	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
+		return 0;
+
 	if (adev->flags & AMD_IS_APU) {
 		smu_powergate_sdma(&adev->smu, true);
 		smu_powergate_vcn(&adev->smu, true);
 		smu_powergate_jpeg(&adev->smu, true);
 	}
 
-	ret = smu_stop_thermal_control(smu);
-	if (ret) {
-		pr_warn("Fail to stop thermal control!\n");
-		return ret;
-	}
-
-	/*
-	 * For custom pptable uploading, skip the DPM features
-	 * disable process on Navi1x ASICs.
-	 *   - As the gfx related features are under control of
-	 *     RLC on those ASICs. RLC reinitialization will be
-	 *     needed to reenable them. That will cost much more
-	 *     efforts.
-	 *
-	 *   - SMU firmware can handle the DPM reenablement
-	 *     properly.
-	 */
-	if (!smu->uploading_custom_pp_table ||
-	    !((adev->asic_type >= CHIP_NAVI10) &&
-	      (adev->asic_type <= CHIP_NAVI12))) {
-		ret = smu_stop_dpms(smu);
+	if (!amdgpu_sriov_vf(adev)){
+		ret = smu_stop_thermal_control(smu);
 		if (ret) {
-			pr_warn("Fail to stop Dpms!\n");
+			pr_warn("Fail to stop thermal control!\n");
 			return ret;
 		}
+
+		/*
+		 * For custom pptable uploading, skip the DPM features
+		 * disable process on Navi1x ASICs.
+		 *   - As the gfx related features are under control of
+		 *     RLC on those ASICs. RLC reinitialization will be
+		 *     needed to reenable them. That will cost much more
+		 *     efforts.
+		 *
+		 *   - SMU firmware can handle the DPM reenablement
+		 *     properly.
+		 */
+		if (!smu->uploading_custom_pp_table ||
+				!((adev->asic_type >= CHIP_NAVI10) &&
+					(adev->asic_type <= CHIP_NAVI12))) {
+			ret = smu_stop_dpms(smu);
+			if (ret) {
+				pr_warn("Fail to stop Dpms!\n");
+				return ret;
+			}
+		}
 	}
 
 	kfree(table_context->driver_pptable);
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
  2019-12-27  7:26   ` Deng, Emily
@ 2019-12-27  8:08     ` Zhang, Jack (Jian)
  0 siblings, 0 replies; 8+ messages in thread
From: Zhang, Jack (Jian) @ 2019-12-27  8:08 UTC (permalink / raw)
  To: Deng, Emily, Feng, Kenneth, Deucher, Alexander, Quan, Evan, Wang,
	Kevin(Yang),
	Tao, Yintian, Min, Frank, Liu,  Monk, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 6667 bytes --]

hi, Emily,

Thank you for your review.
Comment inline, updated patch attached

-----Original Message-----
From: Deng, Emily <Emily.Deng@amd.com> 
Sent: Friday, December 27, 2019 3:27 PM
To: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>; Feng, Kenneth <Kenneth.Feng@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; Tao, Yintian <Yintian.Tao@amd.com>; Min, Frank <Frank.Min@amd.com>; Liu, Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org
Subject: RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF

[AMD Official Use Only - Internal Distribution Only]



>-----Original Message-----
>From: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
>Sent: Friday, December 27, 2019 3:00 PM
>To: Feng, Kenneth <Kenneth.Feng@amd.com>; Deucher, Alexander 
><Alexander.Deucher@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Wang,
>Kevin(Yang) <Kevin1.Wang@amd.com>; Tao, Yintian <Yintian.Tao@amd.com>; 
>Deng, Emily <Emily.Deng@amd.com>; Min, Frank <Frank.Min@amd.com>; Liu, 
>Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org; Zhang, Jack 
>(Jian) <Jack.Zhang1@amd.com>
>Subject: RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for 
>ARCTURUS VF
>
>
>
>-----Original Message-----
>From: Jack Zhang <Jack.Zhang1@amd.com>
>Sent: Friday, December 27, 2019 2:57 PM
>To: amd-gfx@lists.freedesktop.org
>Cc: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
>Subject: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
>
>Before, initialization of smu ip block would be skipped for sriov 
>ASICs. But if there's only one VF being used, guest driver should be 
>able to dump some HW info such as clks, temperature,etc.
>
>To solve this, now after onevf mode is enabled, host driver will notify 
>guest. If it's onevf mode, guest will do smu hw_init and skip some 
>steps in normal smu hw_init flow because host driver has already done it for smu.
>
>With this fix, guest app can talk with smu and dump hw information from smu.
>
>v2: refine the logic for pm_enabled.Skip hw_init by not changing pm_enabled.
>
>Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
>---
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
> drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
> drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 45 
>+++++++++++++++++------
>-------
> 3 files changed, 29 insertions(+), 22 deletions(-)
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>index 8469834..08130a6 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>@@ -1448,7 +1448,8 @@ static int psp_np_fw_load(struct psp_context *psp)
>                     || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
> 	            || ucode->ucode_id ==
>AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
> 	            || ucode->ucode_id ==
>AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
>-	            || ucode->ucode_id ==
>AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
>+	            || ucode->ucode_id ==
>AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
>+	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
> 			/*skip ucode loading in SRIOV VF */
> 			continue;
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c
>b/drivers/gpu/drm/amd/amdgpu/soc15.c
>index b53d401..a271496 100644
>--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
>+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
>@@ -827,8 +827,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
> 			amdgpu_device_ip_block_add(adev,
>&dce_virtual_ip_block);
> 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
> 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
>-		if (!amdgpu_sriov_vf(adev))
>-			amdgpu_device_ip_block_add(adev,
>&smu_v11_0_ip_block);
>+		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
>
> 		if (amdgpu_sriov_vf(adev)) {
> 			if (likely(adev->firmware.load_type ==
>AMDGPU_FW_LOAD_PSP)) diff --git
>a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>index 936c682..42c0a6d 100644
>--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>@@ -531,10 +531,14 @@ bool is_support_sw_smu(struct amdgpu_device
>*adev)
> 	if (adev->asic_type == CHIP_VEGA20)
> 		return (amdgpu_dpm == 2) ? true : false;
> 	else if (adev->asic_type >= CHIP_ARCTURUS) {
>-		if (amdgpu_sriov_vf(adev))
>-			return false;
>-		else
>+		if (amdgpu_sriov_vf(adev)) {
>+			if(amdgpu_sriov_is_pp_one_vf(adev))
>+				return true;
>+			else
>+				return false;
>+		} else {
> 			return true;
>+		}
> 	} else
> 		return false;
> }
>@@ -1062,20 +1066,19 @@ static int smu_smc_table_hw_init(struct 
>smu_context *smu,
> 	}
>
> 	/* smu_dump_pptable(smu); */
>+	if(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)){
>+		/*
>+		 * Copy pptable bo in the vram to smc with SMU MSGs such as
>+		 * SetDriverDramAddr and TransferTableDram2Smu.
>+		 */
>+		ret = smu_write_pptable(smu);
>+		if (ret)
>+			return ret;
[Emily]Why only sriov and non one vf mode need to this? What about bare metal?
[Jack] changed to "if(!amdgpu_sriov_vf(adev) || !amdgpu_sriov_is_pp_one_vf(adev))"
>
>-	/*
>-	 * Copy pptable bo in the vram to smc with SMU MSGs such as
>-	 * SetDriverDramAddr and TransferTableDram2Smu.
>-	 */
>-	ret = smu_write_pptable(smu);
>-	if (ret)
>-		return ret;
>-
>-	/* issue Run*Btc msg */
>-	ret = smu_run_btc(smu);
>-	if (ret)
>-		return ret;
>-
>+		/* issue Run*Btc msg */
>+		ret = smu_run_btc(smu);
>+		if (ret)
>+			return ret;
> 	ret = smu_feature_set_allowed_mask(smu);
> 	if (ret)
> 		return ret;
>@@ -1083,7 +1086,7 @@ static int smu_smc_table_hw_init(struct 
>smu_context *smu,
> 	ret = smu_system_features_control(smu, true);
> 	if (ret)
> 		return ret;
>-
>+	}
> 	if (adev->asic_type != CHIP_ARCTURUS) {
> 		ret = smu_notify_display_change(smu);
> 		if (ret)
>@@ -1136,8 +1139,9 @@ static int smu_smc_table_hw_init(struct 
>smu_context *smu,
> 	/*
> 	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for 
>tools.
> 	 */
>-	ret = smu_set_tool_table_location(smu);
>-
>+	if(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)){
>+		ret = smu_set_tool_table_location(smu);
>+	}
> 	if (!smu_is_dpm_running(smu))
> 		pr_info("dpm has been disabled\n");
>
>@@ -1249,6 +1253,9 @@ static int smu_hw_init(void *handle)
> 		smu_set_gfx_cgpg(&adev->smu, true);
> 	}
>
>+	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
>+		return 0;
>+
> 	if (!smu->pm_enabled)
> 		return 0;
>
>--
>2.7.4

[-- Attachment #2: 0001-amd-amdgpu-sriov-enable-onevf-mode-for-ARCTURUS-VF.patch --]
[-- Type: application/octet-stream, Size: 4894 bytes --]

From d7132a9c3c570007f1cc24b950f0818c50792b23 Mon Sep 17 00:00:00 2001
From: Jack Zhang <Jack.Zhang1@amd.com>
Date: Tue, 10 Dec 2019 10:51:01 +0800
Subject: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF

Before, initialization of smu ip block would be skipped
for sriov ASICs. But if there's only one VF being used,
guest driver should be able to dump some HW info such as
clks, temperature,etc.

To solve this, now after onevf mode is enabled, host
driver will notify guest. If it's onevf mode, guest will
do smu hw_init and skip some steps in normal smu hw_init
flow because host driver has already done it for smu.

With this fix, guest app can talk with smu and dump hw
information from smu.

v2: refine the logic for pm_enabled.Skip hw_init by not
changing pm_enabled.

Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 45 +++++++++++++++++-------------
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 8469834..08130a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1448,7 +1448,8 @@ static int psp_np_fw_load(struct psp_context *psp)
                     || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
-	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
 			/*skip ucode loading in SRIOV VF */
 			continue;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index b53d401..a271496 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -827,8 +827,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
 			amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
-		if (!amdgpu_sriov_vf(adev))
-			amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
+		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
 
 		if (amdgpu_sriov_vf(adev)) {
 			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP))
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 936c682..49917e2 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -531,10 +531,14 @@ bool is_support_sw_smu(struct amdgpu_device *adev)
 	if (adev->asic_type == CHIP_VEGA20)
 		return (amdgpu_dpm == 2) ? true : false;
 	else if (adev->asic_type >= CHIP_ARCTURUS) {
-		if (amdgpu_sriov_vf(adev))
-			return false;
-		else
+		if (amdgpu_sriov_vf(adev)) {
+			if(amdgpu_sriov_is_pp_one_vf(adev))
+				return true;
+			else
+				return false;
+		} else {
 			return true;
+		}
 	} else
 		return false;
 }
@@ -1062,20 +1066,19 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	}
 
 	/* smu_dump_pptable(smu); */
+	if (!amdgpu_sriov_vf(adev) || !amdgpu_sriov_is_pp_one_vf(adev)) {
+		/*
+		 * Copy pptable bo in the vram to smc with SMU MSGs such as
+		 * SetDriverDramAddr and TransferTableDram2Smu.
+		 */
+		ret = smu_write_pptable(smu);
+		if (ret)
+			return ret;
 
-	/*
-	 * Copy pptable bo in the vram to smc with SMU MSGs such as
-	 * SetDriverDramAddr and TransferTableDram2Smu.
-	 */
-	ret = smu_write_pptable(smu);
-	if (ret)
-		return ret;
-
-	/* issue Run*Btc msg */
-	ret = smu_run_btc(smu);
-	if (ret)
-		return ret;
-
+		/* issue Run*Btc msg */
+		ret = smu_run_btc(smu);
+		if (ret)
+			return ret;
 	ret = smu_feature_set_allowed_mask(smu);
 	if (ret)
 		return ret;
@@ -1083,7 +1086,7 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	ret = smu_system_features_control(smu, true);
 	if (ret)
 		return ret;
-
+	}
 	if (adev->asic_type != CHIP_ARCTURUS) {
 		ret = smu_notify_display_change(smu);
 		if (ret)
@@ -1136,8 +1139,9 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	/*
 	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools.
 	 */
-	ret = smu_set_tool_table_location(smu);
-
+	if (!amdgpu_sriov_vf(adev) || !amdgpu_sriov_is_pp_one_vf(adev)) {
+		ret = smu_set_tool_table_location(smu);
+	}
 	if (!smu_is_dpm_running(smu))
 		pr_info("dpm has been disabled\n");
 
@@ -1249,6 +1253,9 @@ static int smu_hw_init(void *handle)
 		smu_set_gfx_cgpg(&adev->smu, true);
 	}
 
+	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+		return 0;
+
 	if (!smu->pm_enabled)
 		return 0;
 
-- 
2.7.4


[-- Attachment #3: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
  2019-12-27  7:00 ` Zhang, Jack (Jian)
  2019-12-27  7:13   ` Zhang, Jack (Jian)
@ 2019-12-27  7:26   ` Deng, Emily
  2019-12-27  8:08     ` Zhang, Jack (Jian)
  1 sibling, 1 reply; 8+ messages in thread
From: Deng, Emily @ 2019-12-27  7:26 UTC (permalink / raw)
  To: Zhang, Jack (Jian),
	Feng, Kenneth, Deucher, Alexander, Quan, Evan, Wang, Kevin(Yang),
	Tao, Yintian, Min, Frank, Liu,  Monk, amd-gfx

[AMD Official Use Only - Internal Distribution Only]



>-----Original Message-----
>From: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
>Sent: Friday, December 27, 2019 3:00 PM
>To: Feng, Kenneth <Kenneth.Feng@amd.com>; Deucher, Alexander
><Alexander.Deucher@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Wang,
>Kevin(Yang) <Kevin1.Wang@amd.com>; Tao, Yintian <Yintian.Tao@amd.com>;
>Deng, Emily <Emily.Deng@amd.com>; Min, Frank <Frank.Min@amd.com>; Liu,
>Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org; Zhang, Jack (Jian)
><Jack.Zhang1@amd.com>
>Subject: RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS
>VF
>
>
>
>-----Original Message-----
>From: Jack Zhang <Jack.Zhang1@amd.com>
>Sent: Friday, December 27, 2019 2:57 PM
>To: amd-gfx@lists.freedesktop.org
>Cc: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
>Subject: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
>
>Before, initialization of smu ip block would be skipped for sriov ASICs. But if
>there's only one VF being used, guest driver should be able to dump some HW
>info such as clks, temperature,etc.
>
>To solve this, now after onevf mode is enabled, host driver will notify guest. If
>it's onevf mode, guest will do smu hw_init and skip some steps in normal smu
>hw_init flow because host driver has already done it for smu.
>
>With this fix, guest app can talk with smu and dump hw information from smu.
>
>v2: refine the logic for pm_enabled.Skip hw_init by not changing pm_enabled.
>
>Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
>---
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
> drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
> drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 45 +++++++++++++++++------
>-------
> 3 files changed, 29 insertions(+), 22 deletions(-)
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>index 8469834..08130a6 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>@@ -1448,7 +1448,8 @@ static int psp_np_fw_load(struct psp_context *psp)
>                     || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
> 	            || ucode->ucode_id ==
>AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
> 	            || ucode->ucode_id ==
>AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
>-	            || ucode->ucode_id ==
>AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
>+	            || ucode->ucode_id ==
>AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
>+	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
> 			/*skip ucode loading in SRIOV VF */
> 			continue;
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c
>b/drivers/gpu/drm/amd/amdgpu/soc15.c
>index b53d401..a271496 100644
>--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
>+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
>@@ -827,8 +827,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
> 			amdgpu_device_ip_block_add(adev,
>&dce_virtual_ip_block);
> 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
> 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
>-		if (!amdgpu_sriov_vf(adev))
>-			amdgpu_device_ip_block_add(adev,
>&smu_v11_0_ip_block);
>+		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
>
> 		if (amdgpu_sriov_vf(adev)) {
> 			if (likely(adev->firmware.load_type ==
>AMDGPU_FW_LOAD_PSP)) diff --git
>a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>index 936c682..42c0a6d 100644
>--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>@@ -531,10 +531,14 @@ bool is_support_sw_smu(struct amdgpu_device
>*adev)
> 	if (adev->asic_type == CHIP_VEGA20)
> 		return (amdgpu_dpm == 2) ? true : false;
> 	else if (adev->asic_type >= CHIP_ARCTURUS) {
>-		if (amdgpu_sriov_vf(adev))
>-			return false;
>-		else
>+		if (amdgpu_sriov_vf(adev)) {
>+			if(amdgpu_sriov_is_pp_one_vf(adev))
>+				return true;
>+			else
>+				return false;
>+		} else {
> 			return true;
>+		}
> 	} else
> 		return false;
> }
>@@ -1062,20 +1066,19 @@ static int smu_smc_table_hw_init(struct
>smu_context *smu,
> 	}
>
> 	/* smu_dump_pptable(smu); */
>+	if(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)){
>+		/*
>+		 * Copy pptable bo in the vram to smc with SMU MSGs such as
>+		 * SetDriverDramAddr and TransferTableDram2Smu.
>+		 */
>+		ret = smu_write_pptable(smu);
>+		if (ret)
>+			return ret;
Why only sriov and non one vf mode need to this? What about bare metal?
>
>-	/*
>-	 * Copy pptable bo in the vram to smc with SMU MSGs such as
>-	 * SetDriverDramAddr and TransferTableDram2Smu.
>-	 */
>-	ret = smu_write_pptable(smu);
>-	if (ret)
>-		return ret;
>-
>-	/* issue Run*Btc msg */
>-	ret = smu_run_btc(smu);
>-	if (ret)
>-		return ret;
>-
>+		/* issue Run*Btc msg */
>+		ret = smu_run_btc(smu);
>+		if (ret)
>+			return ret;
> 	ret = smu_feature_set_allowed_mask(smu);
> 	if (ret)
> 		return ret;
>@@ -1083,7 +1086,7 @@ static int smu_smc_table_hw_init(struct
>smu_context *smu,
> 	ret = smu_system_features_control(smu, true);
> 	if (ret)
> 		return ret;
>-
>+	}
> 	if (adev->asic_type != CHIP_ARCTURUS) {
> 		ret = smu_notify_display_change(smu);
> 		if (ret)
>@@ -1136,8 +1139,9 @@ static int smu_smc_table_hw_init(struct
>smu_context *smu,
> 	/*
> 	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for
>tools.
> 	 */
>-	ret = smu_set_tool_table_location(smu);
>-
>+	if(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)){
>+		ret = smu_set_tool_table_location(smu);
>+	}
> 	if (!smu_is_dpm_running(smu))
> 		pr_info("dpm has been disabled\n");
>
>@@ -1249,6 +1253,9 @@ static int smu_hw_init(void *handle)
> 		smu_set_gfx_cgpg(&adev->smu, true);
> 	}
>
>+	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
>+		return 0;
>+
> 	if (!smu->pm_enabled)
> 		return 0;
>
>--
>2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
  2019-12-27  7:00 ` Zhang, Jack (Jian)
@ 2019-12-27  7:13   ` Zhang, Jack (Jian)
  2019-12-27  7:26   ` Deng, Emily
  1 sibling, 0 replies; 8+ messages in thread
From: Zhang, Jack (Jian) @ 2019-12-27  7:13 UTC (permalink / raw)
  To: Feng, Kenneth, Deucher, Alexander, Quan, Evan, Wang, Kevin(Yang),
	Tao, Yintian, Deng, Emily, Min, Frank, Liu, Monk, amd-gfx

Hi, all,

Here is some description about sriov and pp_one_vf mode:
1)	amdgpu_sriov_vf  marks if it is sriov or bare-metal. While amdgpu_sriov_is_pp_one_vf is a mode of sriov- It means there is only one VF  generated by host driver.
2)	Host administrator can determine “vf number” when host driver is loaded. If vf_num =1, host driver will notify guest driver  it is under one vf mode --- pp_one_vf return true. 
	Otherwise, pp_one_vf return false. Without unloading guest driver and host driver, vf_num cannot be changed. So it is a static process.
3)	Under  pp_one_vf mode in sriov platform, guest driver will do smu hw_init, the goal of it is to let guest driver “talk” with smu by sending authorized smu messages. This will help user mode app to dump info like clks, temperature, GPU usage…. 
	Currently we don’t support guest driver to write value to smu. We can  only read  smu information.
	Besides, as host driver has already initialized smu hw such as loading smu firmware and and set some feature control modes, some hw init steps need to skip in guest driver, such as write pptable, load smc firmware.
4)	At the same time, pp_one_vf mode need smu some firmware changes to open permission for certain messages in VF.


B.R.
Jack
-----Original Message-----
From: Zhang, Jack (Jian) 
Sent: Friday, December 27, 2019 3:00 PM
To: Feng, Kenneth <Kenneth.Feng@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; Tao, Yintian <Yintian.Tao@amd.com>; Deng, Emily <Emily.Deng@amd.com>; Min, Frank <Frank.Min@amd.com>; Liu, Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org; Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
Subject: RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF



-----Original Message-----
From: Jack Zhang <Jack.Zhang1@amd.com> 
Sent: Friday, December 27, 2019 2:57 PM
To: amd-gfx@lists.freedesktop.org
Cc: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
Subject: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF

Before, initialization of smu ip block would be skipped for sriov ASICs. But if there's only one VF being used, guest driver should be able to dump some HW info such as clks, temperature,etc.

To solve this, now after onevf mode is enabled, host driver will notify guest. If it's onevf mode, guest will do smu hw_init and skip some steps in normal smu hw_init flow because host driver has already done it for smu.

With this fix, guest app can talk with smu and dump hw information from smu.

v2: refine the logic for pm_enabled.Skip hw_init by not changing pm_enabled.

Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 45 +++++++++++++++++-------------
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 8469834..08130a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1448,7 +1448,8 @@ static int psp_np_fw_load(struct psp_context *psp)
                     || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
-	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
 			/*skip ucode loading in SRIOV VF */
 			continue;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index b53d401..a271496 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -827,8 +827,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
 			amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
-		if (!amdgpu_sriov_vf(adev))
-			amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
+		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
 
 		if (amdgpu_sriov_vf(adev)) {
 			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 936c682..42c0a6d 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -531,10 +531,14 @@ bool is_support_sw_smu(struct amdgpu_device *adev)
 	if (adev->asic_type == CHIP_VEGA20)
 		return (amdgpu_dpm == 2) ? true : false;
 	else if (adev->asic_type >= CHIP_ARCTURUS) {
-		if (amdgpu_sriov_vf(adev))
-			return false;
-		else
+		if (amdgpu_sriov_vf(adev)) {
+			if(amdgpu_sriov_is_pp_one_vf(adev))
+				return true;
+			else
+				return false;
+		} else {
 			return true;
+		}
 	} else
 		return false;
 }
@@ -1062,20 +1066,19 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	}
 
 	/* smu_dump_pptable(smu); */
+	if(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)){
+		/*
+		 * Copy pptable bo in the vram to smc with SMU MSGs such as
+		 * SetDriverDramAddr and TransferTableDram2Smu.
+		 */
+		ret = smu_write_pptable(smu);
+		if (ret)
+			return ret;
 
-	/*
-	 * Copy pptable bo in the vram to smc with SMU MSGs such as
-	 * SetDriverDramAddr and TransferTableDram2Smu.
-	 */
-	ret = smu_write_pptable(smu);
-	if (ret)
-		return ret;
-
-	/* issue Run*Btc msg */
-	ret = smu_run_btc(smu);
-	if (ret)
-		return ret;
-
+		/* issue Run*Btc msg */
+		ret = smu_run_btc(smu);
+		if (ret)
+			return ret;
 	ret = smu_feature_set_allowed_mask(smu);
 	if (ret)
 		return ret;
@@ -1083,7 +1086,7 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	ret = smu_system_features_control(smu, true);
 	if (ret)
 		return ret;
-
+	}
 	if (adev->asic_type != CHIP_ARCTURUS) {
 		ret = smu_notify_display_change(smu);
 		if (ret)
@@ -1136,8 +1139,9 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	/*
 	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools.
 	 */
-	ret = smu_set_tool_table_location(smu);
-
+	if(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)){
+		ret = smu_set_tool_table_location(smu);
+	}
 	if (!smu_is_dpm_running(smu))
 		pr_info("dpm has been disabled\n");
 
@@ -1249,6 +1253,9 @@ static int smu_hw_init(void *handle)
 		smu_set_gfx_cgpg(&adev->smu, true);
 	}
 
+	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
+		return 0;
+
 	if (!smu->pm_enabled)
 		return 0;
 
--
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF
       [not found] <20191227065710.3261-1-Jack.Zhang1@amd.com>
@ 2019-12-27  7:00 ` Zhang, Jack (Jian)
  2019-12-27  7:13   ` Zhang, Jack (Jian)
  2019-12-27  7:26   ` Deng, Emily
  0 siblings, 2 replies; 8+ messages in thread
From: Zhang, Jack (Jian) @ 2019-12-27  7:00 UTC (permalink / raw)
  To: Feng, Kenneth, Deucher, Alexander, Quan, Evan, Wang, Kevin(Yang),
	Tao, Yintian, Deng, Emily, Min, Frank, Liu, Monk, amd-gfx, Zhang,
	Jack (Jian)



-----Original Message-----
From: Jack Zhang <Jack.Zhang1@amd.com> 
Sent: Friday, December 27, 2019 2:57 PM
To: amd-gfx@lists.freedesktop.org
Cc: Zhang, Jack (Jian) <Jack.Zhang1@amd.com>
Subject: [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF

Before, initialization of smu ip block would be skipped for sriov ASICs. But if there's only one VF being used, guest driver should be able to dump some HW info such as clks, temperature,etc.

To solve this, now after onevf mode is enabled, host driver will notify guest. If it's onevf mode, guest will do smu hw_init and skip some steps in normal smu hw_init flow because host driver has already done it for smu.

With this fix, guest app can talk with smu and dump hw information from smu.

v2: refine the logic for pm_enabled.Skip hw_init by not changing pm_enabled.

Signed-off-by: Jack Zhang <Jack.Zhang1@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    |  3 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c         |  3 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 45 +++++++++++++++++-------------
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 8469834..08130a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1448,7 +1448,8 @@ static int psp_np_fw_load(struct psp_context *psp)
                     || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
 	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
-	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM))
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+	            || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
 			/*skip ucode loading in SRIOV VF */
 			continue;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index b53d401..a271496 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -827,8 +827,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
 			amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
-		if (!amdgpu_sriov_vf(adev))
-			amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
+		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
 
 		if (amdgpu_sriov_vf(adev)) {
 			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 936c682..42c0a6d 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -531,10 +531,14 @@ bool is_support_sw_smu(struct amdgpu_device *adev)
 	if (adev->asic_type == CHIP_VEGA20)
 		return (amdgpu_dpm == 2) ? true : false;
 	else if (adev->asic_type >= CHIP_ARCTURUS) {
-		if (amdgpu_sriov_vf(adev))
-			return false;
-		else
+		if (amdgpu_sriov_vf(adev)) {
+			if(amdgpu_sriov_is_pp_one_vf(adev))
+				return true;
+			else
+				return false;
+		} else {
 			return true;
+		}
 	} else
 		return false;
 }
@@ -1062,20 +1066,19 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	}
 
 	/* smu_dump_pptable(smu); */
+	if(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)){
+		/*
+		 * Copy pptable bo in the vram to smc with SMU MSGs such as
+		 * SetDriverDramAddr and TransferTableDram2Smu.
+		 */
+		ret = smu_write_pptable(smu);
+		if (ret)
+			return ret;
 
-	/*
-	 * Copy pptable bo in the vram to smc with SMU MSGs such as
-	 * SetDriverDramAddr and TransferTableDram2Smu.
-	 */
-	ret = smu_write_pptable(smu);
-	if (ret)
-		return ret;
-
-	/* issue Run*Btc msg */
-	ret = smu_run_btc(smu);
-	if (ret)
-		return ret;
-
+		/* issue Run*Btc msg */
+		ret = smu_run_btc(smu);
+		if (ret)
+			return ret;
 	ret = smu_feature_set_allowed_mask(smu);
 	if (ret)
 		return ret;
@@ -1083,7 +1086,7 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	ret = smu_system_features_control(smu, true);
 	if (ret)
 		return ret;
-
+	}
 	if (adev->asic_type != CHIP_ARCTURUS) {
 		ret = smu_notify_display_change(smu);
 		if (ret)
@@ -1136,8 +1139,9 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
 	/*
 	 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools.
 	 */
-	ret = smu_set_tool_table_location(smu);
-
+	if(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)){
+		ret = smu_set_tool_table_location(smu);
+	}
 	if (!smu_is_dpm_running(smu))
 		pr_info("dpm has been disabled\n");
 
@@ -1249,6 +1253,9 @@ static int smu_hw_init(void *handle)
 		smu_set_gfx_cgpg(&adev->smu, true);
 	}
 
+	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
+		return 0;
+
 	if (!smu->pm_enabled)
 		return 0;
 
--
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-01-02  8:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-02  7:43 [PATCH 1/2] amd/amdgpu/sriov enable onevf mode for ARCTURUS VF Jack Zhang
2020-01-02  8:03 ` Quan, Evan
  -- strict thread matches above, loose matches on Subject: below --
2020-01-02  5:50 Jack Zhang
2020-01-02  6:18 ` Quan, Evan
     [not found] <20191227065710.3261-1-Jack.Zhang1@amd.com>
2019-12-27  7:00 ` Zhang, Jack (Jian)
2019-12-27  7:13   ` Zhang, Jack (Jian)
2019-12-27  7:26   ` Deng, Emily
2019-12-27  8:08     ` Zhang, Jack (Jian)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.