From eb42a21118e08445ad80e7ebf1c882668d577aba Mon Sep 17 00:00:00 2001 From: Adam Madsen Date: Sun, 1 Nov 2020 21:41:46 -0600 Subject: [PATCH] Vega10 BACO reset should work now. --- src/amd/common.c | 60 +++++++++++++++++++++++++++++++++++++++--------- src/amd/common.h | 1 + src/amd/vega10.c | 6 ++--- 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/amd/common.c b/src/amd/common.c index 0a3a7a8..94d958c 100644 --- a/src/amd/common.c +++ b/src/amd/common.c @@ -22,6 +22,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include "vendor-reset-dev.h" +#include "soc15_common.h" +#include "soc15.h" #include "common.h" int amd_common_pre_reset(struct vendor_reset_dev *dev) @@ -93,22 +95,58 @@ int amd_common_post_reset(struct vendor_reset_dev *dev) return 0; } -int smum_send_msg_to_smc(struct amd_fake_dev *adev, uint16_t msg, uint32_t *resp) +static int smu_wait(struct amd_fake_dev *adev) { - int ret = 0; - u32 timeout; - - mutex_lock(&adev->private->smu_lock); + u32 ret; + int timeout; for (timeout = 100000; timeout && - (RREG32(mmMP1_SMN_C2PMSG_90) & MP1_C2PMSG_90__CONTENT_MASK) == 0; + (RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90) & MP1_C2PMSG_90__CONTENT_MASK) == 0; --timeout) udelay(1); - if ((ret = RREG32(mmMP1_SMN_C2PMSG_90)) != 0x1) - pci_info(adev->private->vdev->pdev, "SMU error 0x%x (line %d)\n", - ret, __LINE__); + if ((ret = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90)) != 0x1) + pci_info(adev->private->vdev->pdev, "SMU error 0x%x\n", ret); - mutex_unlock(&adev->private->smu_lock); - return ret != 0x1; + return ret; } + +int smum_send_msg_to_smc_with_parameter(struct amd_fake_dev *adev, uint16_t msg, uint32_t parameter, uint32_t *resp) +{ + int ret = 0; + + mutex_lock(&adev->private->smu_lock); + + ret = smu_wait(adev); + if (ret != 0x1) + { + ret = -ETIMEDOUT; + goto out; + } + + WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90, 0); + WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_82, parameter); + + WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_66, msg); + + ret = smu_wait(adev); + if (ret != 0x01) + { + pci_err(adev->private->vdev->pdev, "Failed to send message 0x%x: return 0x%x\n", msg, ret); + goto out; + } + + if (resp) + *resp = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_82); + + ret = ret != 0x01; + +out: + mutex_unlock(&adev->private->smu_lock); + return ret; +} + +int smum_send_msg_to_smc(struct amd_fake_dev *adev, uint16_t msg, uint32_t *resp) +{ + return smum_send_msg_to_smc_with_parameter(adev, msg, 0, resp); +} \ No newline at end of file diff --git a/src/amd/common.h b/src/amd/common.h index 560b9e6..4f91273 100644 --- a/src/amd/common.h +++ b/src/amd/common.h @@ -182,5 +182,6 @@ int amd_common_pre_reset(struct vendor_reset_dev *); int amd_common_post_reset(struct vendor_reset_dev *); int smum_send_msg_to_smc(struct amd_fake_dev *adev, uint16_t msg, uint32_t *resp); +int smum_send_msg_to_smc_with_parameter(struct amd_fake_dev *adev, uint16_t msg, uint32_t parameter, uint32_t *resp); #endif \ No newline at end of file diff --git a/src/amd/vega10.c b/src/amd/vega10.c index 3661d5f..9a649e3 100644 --- a/src/amd/vega10.c +++ b/src/amd/vega10.c @@ -141,7 +141,7 @@ static int amd_vega10_reset(struct vendor_reset_dev *dev) /* it's important we wait for the SOC to be ready */ for (timeout = 100000; timeout; --timeout) { - sol = RREG32(mmMP0_SMN_C2PMSG_81); + sol = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81); if (sol != 0xFFFFFFFF && sol != 0) break; udelay(1); @@ -150,7 +150,7 @@ static int amd_vega10_reset(struct vendor_reset_dev *dev) pci_info(dev->pdev, "Vega10: bus reset disabled? %s\n", (dev->pdev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET) ? "yes" : "no"); /* collect some info for logging for now */ - smu_resp = RREG32(mmMP1_SMN_C2PMSG_90); + smu_resp = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); mp1_intr = (RREG32_PCIE(MP1_Public | (smnMP1_FIRMWARE_FLAGS & 0xffffffff)) & MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK) >> @@ -162,7 +162,7 @@ static int amd_vega10_reset(struct vendor_reset_dev *dev) smu_resp, sol, mp1_intr ? "yes" : "no", psp_bl_ready ? "yes" : "no"); - if (!sol) + if (sol == ~1L) { pci_warn(dev->pdev, "Vega10: Timed out waiting for SOL to be valid\n"); return -EINVAL;