<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>sure, thanks.<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Christian König <ckoenig.leichtzumerken@gmail.com><br>
<b>Sent:</b> Friday, September 15, 2017 4:13:45 PM<br>
<b>To:</b> Wang, Ken; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Add GPU reset functionality for Vega10</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Am 15.09.2017 um 09:57 schrieb Ken.Wang@amd.com:<br>
> From: Ken Wang <Ken.Wang@amd.com><br>
><br>
> V2<br>
><br>
> Signed-off-by: Ken Wang <Ken.Wang@amd.com><br>
<br>
Acked-by: Christian König <christian.koenig@amd.com><br>
<br>
I would give an rb, but I can't judge if the PSP stuff is actually <br>
correct, maybe wait for Alex to have a look as well.<br>
<br>
Regards,<br>
Christian.<br>
<br>
> Change-Id: I6fd2c216a84747313f18db25a444be5ed43b4f4b<br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++-<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 21 +++++++++++++++++-<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 3 +++<br>
> drivers/gpu/drm/amd/amdgpu/psp_v10_0.c | 7 ++++++<br>
> drivers/gpu/drm/amd/amdgpu/psp_v10_0.h | 2 ++<br>
> drivers/gpu/drm/amd/amdgpu/psp_v3_1.c | 34 ++++++++++++++++++++++++++++++<br>
> drivers/gpu/drm/amd/amdgpu/psp_v3_1.h | 1 +<br>
> drivers/gpu/drm/amd/amdgpu/soc15.c | 27 ++++++++++++------------<br>
> 8 files changed, 83 insertions(+), 15 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> index fc1c5437..2ad9737 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> @@ -2644,7 +2644,8 @@ static bool amdgpu_need_full_reset(struct amdgpu_device *adev)<br>
> if ((adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) ||<br>
> (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) ||<br>
> (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_ACP) ||<br>
> - (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE)) {<br>
> + (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE) ||<br>
> + adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_PSP) {<br>
> if (adev->ip_blocks[i].status.hang) {<br>
> DRM_INFO("Some block need full reset!\n");<br>
> return true;<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> index 8a1ee97..8e53650 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> @@ -62,6 +62,7 @@ static int psp_sw_init(void *handle)<br>
> psp->cmd_submit = psp_v3_1_cmd_submit;<br>
> psp->compare_sram_data = psp_v3_1_compare_sram_data;<br>
> psp->smu_reload_quirk = psp_v3_1_smu_reload_quirk;<br>
> + psp->mode1_reset = psp_v3_1_mode1_reset;<br>
> break;<br>
> case CHIP_RAVEN:<br>
> psp->init_microcode = psp_v10_0_init_microcode;<br>
> @@ -72,6 +73,7 @@ static int psp_sw_init(void *handle)<br>
> psp->ring_destroy = psp_v10_0_ring_destroy;<br>
> psp->cmd_submit = psp_v10_0_cmd_submit;<br>
> psp->compare_sram_data = psp_v10_0_compare_sram_data;<br>
> + psp->mode1_reset = psp_v10_0_mode1_reset;<br>
> break;<br>
> default:<br>
> return -EINVAL;<br>
> @@ -497,6 +499,22 @@ static int psp_resume(void *handle)<br>
> return ret;<br>
> }<br>
> <br>
> +static bool psp_check_reset(void* handle)<br>
> +{<br>
> + struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
> +<br>
> + if (adev->asic_type == CHIP_VEGA10)<br>
> + return true;<br>
> +<br>
> + return false;<br>
> +}<br>
> +<br>
> +static int psp_reset(void* handle)<br>
> +{<br>
> + struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
> + return psp_mode1_reset(&adev->psp);<br>
> +}<br>
> +<br>
> static bool psp_check_fw_loading_status(struct amdgpu_device *adev,<br>
> enum AMDGPU_UCODE_ID ucode_type)<br>
> {<br>
> @@ -540,8 +558,9 @@ const struct amd_ip_funcs psp_ip_funcs = {<br>
> .suspend = psp_suspend,<br>
> .resume = psp_resume,<br>
> .is_idle = NULL,<br>
> + .check_soft_reset = psp_check_reset,<br>
> .wait_for_idle = NULL,<br>
> - .soft_reset = NULL,<br>
> + .soft_reset = psp_reset,<br>
> .set_clockgating_state = psp_set_clockgating_state,<br>
> .set_powergating_state = psp_set_powergating_state,<br>
> };<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
> index 1b7d12d..ce465455 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
> @@ -76,6 +76,7 @@ struct psp_context<br>
> struct amdgpu_firmware_info *ucode,<br>
> enum AMDGPU_UCODE_ID ucode_type);<br>
> bool (*smu_reload_quirk)(struct psp_context *psp);<br>
> + int (*mode1_reset)(struct psp_context *psp);<br>
> <br>
> /* fence buffer */<br>
> struct amdgpu_bo *fw_pri_bo;<br>
> @@ -139,6 +140,8 @@ struct amdgpu_psp_funcs {<br>
> ((psp)->bootloader_load_sos ? (psp)->bootloader_load_sos((psp)) : 0)<br>
> #define psp_smu_reload_quirk(psp) \<br>
> ((psp)->smu_reload_quirk ? (psp)->smu_reload_quirk((psp)) : false)<br>
> +#define psp_mode1_reset(psp) \<br>
> + ((psp)->mode1_reset ? (psp)->mode1_reset((psp)) : false)<br>
> <br>
> extern const struct amd_ip_funcs psp_ip_funcs;<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c<br>
> index 6b324da..cbc43bb 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c<br>
> @@ -406,3 +406,10 @@ bool psp_v10_0_compare_sram_data(struct psp_context *psp,<br>
> <br>
> return true;<br>
> }<br>
> +<br>
> +<br>
> +int psp_v10_0_mode1_reset(struct psp_context *psp)<br>
> +{<br>
> + DRM_INFO("psp mode 1 reset not supported now! \n");<br>
> + return -EINVAL;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h<br>
> index 3af3ad1..451e830 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h<br>
> @@ -45,4 +45,6 @@ extern int psp_v10_0_cmd_submit(struct psp_context *psp,<br>
> extern bool psp_v10_0_compare_sram_data(struct psp_context *psp,<br>
> struct amdgpu_firmware_info *ucode,<br>
> enum AMDGPU_UCODE_ID ucode_type);<br>
> +<br>
> +extern int psp_v10_0_mode1_reset(struct psp_context *psp);<br>
> #endif<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c<br>
> index eb73931..4e70bad 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c<br>
> @@ -530,3 +530,37 @@ bool psp_v3_1_smu_reload_quirk(struct psp_context *psp)<br>
> reg = RREG32_SOC15(NBIO, 0, mmPCIE_DATA2);<br>
> return (reg & MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK) ? true : false;<br>
> }<br>
> +<br>
> +int psp_v3_1_mode1_reset(struct psp_context *psp)<br>
> +{<br>
> + int ret;<br>
> + uint32_t offset;<br>
> + struct amdgpu_device *adev = psp->adev;<br>
> +<br>
> + offset = SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64);<br>
> +<br>
> + ret = psp_wait_for(psp, offset, 0x80000000, 0x8000FFFF, false);<br>
> +<br>
> + if (ret) {<br>
> + DRM_INFO("psp is not working correctly before mode1 reset!\n");<br>
> + return -EINVAL;<br>
> + }<br>
> +<br>
> + /*send the mode 1 reset command*/<br>
> + WREG32(offset, 0x70000);<br>
> +<br>
> + mdelay(1000);<br>
> +<br>
> + offset = SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_33);<br>
> +<br>
> + ret = psp_wait_for(psp, offset, 0x80000000, 0x80000000, false);<br>
> +<br>
> + if (ret) {<br>
> + DRM_INFO("psp mode 1 reset failed!\n");<br>
> + return -EINVAL;<br>
> + }<br>
> +<br>
> + DRM_INFO("psp mode1 reset succeed \n");<br>
> +<br>
> + return 0;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h<br>
> index 5af2231..b05dbad 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h<br>
> @@ -53,4 +53,5 @@ extern bool psp_v3_1_compare_sram_data(struct psp_context *psp,<br>
> struct amdgpu_firmware_info *ucode,<br>
> enum AMDGPU_UCODE_ID ucode_type);<br>
> extern bool psp_v3_1_smu_reload_quirk(struct psp_context *psp);<br>
> +extern int psp_v3_1_mode1_reset(struct psp_context *psp);<br>
> #endif<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
> index a74d616..9c75961 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
> @@ -407,18 +407,27 @@ static int soc15_read_register(struct amdgpu_device *adev, u32 se_num,<br>
> return -EINVAL;<br>
> }<br>
> <br>
> -static void soc15_gpu_pci_config_reset(struct amdgpu_device *adev)<br>
> +static int soc15_asic_reset(struct amdgpu_device *adev)<br>
> {<br>
> u32 i;<br>
> <br>
> - dev_info(adev->dev, "GPU pci config reset\n");<br>
> + amdgpu_atombios_scratch_regs_engine_hung(adev, true);<br>
> +<br>
> + dev_info(adev->dev, "GPU reset\n");<br>
> <br>
> /* disable BM */<br>
> pci_clear_master(adev->pdev);<br>
> - /* reset */<br>
> - amdgpu_pci_config_reset(adev);<br>
> <br>
> - udelay(100);<br>
> + pci_save_state(adev->pdev);<br>
> +<br>
> + for (i = 0; i < AMDGPU_MAX_IP_NUM; i++) {<br>
> + if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_PSP){<br>
> + adev->ip_blocks[i].version->funcs->soft_reset((void *)adev);<br>
> + break;<br>
> + }<br>
> + }<br>
> +<br>
> + pci_restore_state(adev->pdev);<br>
> <br>
> /* wait for asic to come out of reset */<br>
> for (i = 0; i < adev->usec_timeout; i++) {<br>
> @@ -430,14 +439,6 @@ static void soc15_gpu_pci_config_reset(struct amdgpu_device *adev)<br>
> udelay(1);<br>
> }<br>
> <br>
> -}<br>
> -<br>
> -static int soc15_asic_reset(struct amdgpu_device *adev)<br>
> -{<br>
> - amdgpu_atombios_scratch_regs_engine_hung(adev, true);<br>
> -<br>
> - soc15_gpu_pci_config_reset(adev);<br>
> -<br>
> amdgpu_atombios_scratch_regs_engine_hung(adev, false);<br>
> <br>
> return 0;<br>
<br>
<br>
</div>
</span></font>
</body>
</html>