Skip to contentSkip to conversation

kexec fixes

PATCH In review Alex Deucher 4 participants 10 messages Jan 8, 2019 – Jan 9, 2019 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover kexec fixes

Fixes for kexec. The GPU needs to be reset before the driver can be loaded again reliably. Needed for kexec for booting some ppc platforms. See:
https://bugs.freedesktop.org/show_bug.cgi?id=108585

Alex Deucher (6):
drm/amdgpu: add need_reset_on_init asic callback (v2) drm/amdgpu/si: add need_reset_on_init asic callback for SI (v2) drm/amdgpu/cik: add need_reset_on_init asic callback for CIK (v2) drm/amdgpu/vi: add need_reset_on_init asic callback for VI (v2) drm/amdgpu/soc15: add need_reset_on_init asic callback for SOC15 (v2) drm/amdgpu: check if we need to reset at init time (v2)

 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/cik.c           | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/si.c            |  6 ++++++
 drivers/gpu/drm/amd/amdgpu/soc15.c         | 20 ++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/vi.c            | 18 ++++++++++++++++++
 6 files changed, 76 insertions(+)
Signature · 6 lines
2.20.1

_______________________________________________
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): 20190108221156.24388-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/6 drm/amdgpu: add need_reset_on_init asic callback (v2)

Used to determine if we need to reset the asic on init due to the driver having been previously loaded or not shutdown cleanly. E.g., kexec or VM passthrough.

v2: rebase

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
index bcef6ea4bcf9..d27fa2ffb2f0 100644
@@ -542,6 +542,8 @@ struct amdgpu_asic_funcs {
 	bool (*need_full_reset)(struct amdgpu_device *adev);
 	/* initialize doorbell layout for specific asic*/
 	void (*init_doorbell_index)(struct amdgpu_device *adev);
+	/* do we need to reset the asic at init time (e.g., kexec) */
+	bool (*need_reset_on_init)(struct amdgpu_device *adev);
 };
 
 /*
@@ -1042,6 +1044,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
 #define amdgpu_asic_invalidate_hdp(adev, r) (adev)->asic_funcs->invalidate_hdp((adev), (r))
 #define amdgpu_asic_need_full_reset(adev) (adev)->asic_funcs->need_full_reset((adev))
 #define amdgpu_asic_init_doorbell_index(adev) (adev)->asic_funcs->init_doorbell_index((adev))
+#define amdgpu_asic_need_reset_on_init(adev) (adev)->asic_funcs->need_reset_on_init((adev))
 
 /* Common functions */
 bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 2/6 drm/amdgpu/si: add need_reset_on_init asic callback for SI (v2)

In reply to a message not in the archive

SI chips don't require a reset on reload due to the nature of the SMU on them.

v2: rebase

---
 drivers/gpu/drm/amd/amdgpu/si.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/si.c +6 -0
index f8408f88cd37..51adfe986da3 100644
@@ -1258,6 +1258,11 @@ static bool si_need_full_reset(struct amdgpu_device *adev)
 	return true;
 }
 
+static bool si_need_reset_on_init(struct amdgpu_device *adev)
+{
+	return false;
+}
+
 static int si_get_pcie_lanes(struct amdgpu_device *adev)
 {
 	u32 link_width_cntl;
@@ -1339,6 +1344,7 @@ static const struct amdgpu_asic_funcs si_asic_funcs =
 	.flush_hdp = &si_flush_hdp,
 	.invalidate_hdp = &si_invalidate_hdp,
 	.need_full_reset = &si_need_full_reset,
+	.need_reset_on_init = &si_need_reset_on_init,
 };
 
 static uint32_t si_get_rev_id(struct amdgpu_device *adev)
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw

PATCH 3/6 drm/amdgpu/cik: add need_reset_on_init asic callback for CIK (v2)

In reply to a message not in the archive

CIK chips require a reset if the driver was previously loaded because the SMU can only be loaded once between each reset.

v2: rebase

---
 drivers/gpu/drm/amd/amdgpu/cik.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/amd/amdgpu/cik.c +18 -0
index 71c50d8900e3..09dfaff63502 100644
@@ -1741,6 +1741,23 @@ static bool cik_need_full_reset(struct amdgpu_device *adev)
 	return true;
 }
 
+static bool cik_need_reset_on_init(struct amdgpu_device *adev)
+{
+	u32 clock_cntl, pc;
+
+	if (adev->flags & AMD_IS_APU)
+		return false;
+
+	/* check if the SMC is already running */
+	clock_cntl = RREG32_SMC(ixSMC_SYSCON_CLOCK_CNTL_0);
+	pc = RREG32_SMC(ixSMC_PC_C);
+	if ((0 == REG_GET_FIELD(clock_cntl, SMC_SYSCON_CLOCK_CNTL_0, ck_disable)) &&
+	    (0x20100 <= pc))
+		return true;
+
+	return false;
+}
+
 static const struct amdgpu_asic_funcs cik_asic_funcs =
 {
 	.read_disabled_bios = &cik_read_disabled_bios,
@@ -1756,6 +1773,7 @@ static const struct amdgpu_asic_funcs cik_asic_funcs =
 	.invalidate_hdp = &cik_invalidate_hdp,
 	.need_full_reset = &cik_need_full_reset,
 	.init_doorbell_index = &legacy_doorbell_index_init,
+	.need_reset_on_init = &cik_need_reset_on_init,
 };
 
 static int cik_common_early_init(void *handle)
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#5 lore raw

PATCH 4/6 drm/amdgpu/vi: add need_reset_on_init asic callback for VI (v2)

In reply to a message not in the archive

VI chips require a reset if the driver was previously loaded because the SMU can only be loaded once between each reset.

v2: rebase

---
 drivers/gpu/drm/amd/amdgpu/vi.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/amd/amdgpu/vi.c +18 -0
index 03e7be595a0d..60ce2c1dac5c 100644
@@ -941,6 +941,23 @@ static bool vi_need_full_reset(struct amdgpu_device *adev)
 	}
 }
 
+static bool vi_need_reset_on_init(struct amdgpu_device *adev)
+{
+	u32 clock_cntl, pc;
+
+	if (adev->flags & AMD_IS_APU)
+		return false;
+
+	/* check if the SMC is already running */
+	clock_cntl = RREG32_SMC(ixSMC_SYSCON_CLOCK_CNTL_0);
+	pc = RREG32_SMC(ixSMC_PC_C);
+	if ((0 == REG_GET_FIELD(clock_cntl, SMC_SYSCON_CLOCK_CNTL_0, ck_disable)) &&
+	    (0x20100 <= pc))
+		return true;
+
+	return false;
+}
+
 static const struct amdgpu_asic_funcs vi_asic_funcs =
 {
 	.read_disabled_bios = &vi_read_disabled_bios,
@@ -956,6 +973,7 @@ static const struct amdgpu_asic_funcs vi_asic_funcs =
 	.invalidate_hdp = &vi_invalidate_hdp,
 	.need_full_reset = &vi_need_full_reset,
 	.init_doorbell_index = &legacy_doorbell_index_init,
+	.need_reset_on_init = &vi_need_reset_on_init,
 };
 
 #define CZ_REV_BRISTOL(rev)	 \
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#6 lore raw

PATCH 5/6 drm/amdgpu/soc15: add need_reset_on_init asic callback for SOC15 (v2)

In reply to a message not in the archive

SOC15 chips require a reset if the driver was previously loaded because the PSP can only be loaded once between each reset.

v2: rebase, handle multiple asic funcs

---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc15.c +20 -0
index 8849b74078d6..fb01a6cda262 100644
@@ -43,6 +43,7 @@
 #include "hdp/hdp_4_0_sh_mask.h"
 #include "smuio/smuio_9_0_offset.h"
 #include "smuio/smuio_9_0_sh_mask.h"
+#include "mp/mp_9_0_offset.h"
 
 #include "soc15.h"
 #include "soc15_common.h"
@@ -602,6 +603,23 @@ static bool soc15_need_full_reset(struct amdgpu_device *adev)
 	return true;
 }
 
+static bool soc15_need_reset_on_init(struct amdgpu_device *adev)
+{
+	u32 sol_reg;
+
+	if (adev->flags & AMD_IS_APU)
+		return false;
+
+	/* Check sOS sign of life register to confirm sys driver and sOS
+	 * are already been loaded.
+	 */
+	sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
+	if (sol_reg)
+		return true;
+
+	return false;
+}
+
 static const struct amdgpu_asic_funcs soc15_asic_funcs =
 {
 	.read_disabled_bios = &soc15_read_disabled_bios,
@@ -617,6 +635,7 @@ static const struct amdgpu_asic_funcs soc15_asic_funcs =
 	.invalidate_hdp = &soc15_invalidate_hdp,
 	.need_full_reset = &soc15_need_full_reset,
 	.init_doorbell_index = &vega10_doorbell_index_init,
+	.need_reset_on_init = &soc15_need_reset_on_init,
 };
 
 static const struct amdgpu_asic_funcs vega20_asic_funcs =
@@ -634,6 +653,7 @@ static const struct amdgpu_asic_funcs vega20_asic_funcs =
 	.invalidate_hdp = &soc15_invalidate_hdp,
 	.need_full_reset = &soc15_need_full_reset,
 	.init_doorbell_index = &vega20_doorbell_index_init,
+	.need_reset_on_init = &soc15_need_reset_on_init,
 };
 
 static int soc15_common_early_init(void *handle)
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#7 lore raw

PATCH 6/6 drm/amdgpu: check if we need to reset at init time (v2)

In reply to a message not in the archive

To deal with situations like kexec or GPU VM passthrough where the device may have been used previously without a proper GPU reset between.

v2: rebase

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11 -0
index 1a558dc41ba6..8a61764e64cf 100644
@@ -2550,6 +2550,17 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	/* detect if we are with an SRIOV vbios */
 	amdgpu_device_detect_sriov_bios(adev);
 
+	/* check if we need to reset the asic
+	 *  E.g., driver was not cleanly unloaded previously, etc.
+	 */
+	if (amdgpu_asic_need_reset_on_init(adev)) {
+		r = amdgpu_asic_reset(adev);
+		if (r) {
+			dev_err(adev->dev, "asic reset on init failed\n");
+			goto failed;
+		}
+	}
+
 	/* Post card if necessary */
 	if (amdgpu_device_need_post(adev)) {
 		if (!adev->bios) {
Signature · 6 lines
2.20.1

_______________________________________________
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): 20190108221156.24388-7-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#9 lore raw

RE: [PATCH 6/6] drm/amdgpu: check if we need to reset at init time (v2)

Series is Reviewed-by: Evan Quan <[email protected]>

Quoted 47 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: 2019年1月9日 6:12
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 6/6] drm/amdgpu: check if we need to reset at init time (v2)

To deal with situations like kexec or GPU VM passthrough where the device may have been used previously without a proper GPU reset between.

v2: rebase

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11 -0
index 1a558dc41ba6..8a61764e64cf 100644
@@ -2550,6 +2550,17 @@ int amdgpu_device_init(struct amdgpu_device
 *adev,
 	/* detect if we are with an SRIOV vbios */
 	amdgpu_device_detect_sriov_bios(adev);
 
+	/* check if we need to reset the asic
+	 *  E.g., driver was not cleanly unloaded previously, etc.
+	 */
+	if (amdgpu_asic_need_reset_on_init(adev)) {
+		r = amdgpu_asic_reset(adev);
+		if (r) {
+			dev_err(adev->dev, "asic reset on init failed\n");
+			goto failed;
+		}
+	}
+
 	/* Post card if necessary */
 	if (amdgpu_device_need_post(adev)) {

if (!adev->bios) {
--
2.20.1

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

#10 lore raw
In reply to a message not in the archive

Thanks for this. I trust that your method for detecting that SMU or PSP are running is correct. With that caveat the series is Reviewed-by:
Felix Kuehling <[email protected]>

Regards,
  Felix

Quoted 13 lines · Alex Deucher

Fixes for kexec. The GPU needs to be reset before the driver can be loaded again reliably. Needed for kexec for booting some ppc platforms. See:
https://bugs.freedesktop.org/show_bug.cgi?id=108585

Alex Deucher (6):
drm/amdgpu: add need_reset_on_init asic callback (v2) drm/amdgpu/si: add need_reset_on_init asic callback for SI (v2) drm/amdgpu/cik: add need_reset_on_init asic callback for CIK (v2) drm/amdgpu/vi: add need_reset_on_init asic callback for VI (v2) drm/amdgpu/soc15: add need_reset_on_init asic callback for SOC15 (v2) drm/amdgpu: check if we need to reset at init time (v2)

Quoted 8 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/cik.c           | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/si.c            |  6 ++++++
 drivers/gpu/drm/amd/amdgpu/soc15.c         | 20 ++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/vi.c            | 18 ++++++++++++++++++
 6 files changed, 76 insertions(+)

_______________________________________________
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): 139d62ef-e36c-23ba-785d-914d5383f8d7-5C7GfCeVMHo@public.gmane.org

#12 lore raw

Yes, the checks are taken from the existing SMU and PSP code.

Alex

________________________________
From: Kuehling, Felix
Sent: Tuesday, January 8, 2019 6:22:48 PM
To: Alex Deucher; [email protected]
Cc: Deucher, Alexander
Subject: Re: [PATCH 0/6] kexec fixes

Thanks for this. I trust that your method for detecting that SMU or PSP are running is correct. With that caveat the series is Reviewed-by:
Felix Kuehling <[email protected]>

Regards,
Felix

Quoted 13 lines · Alex Deucher

Fixes for kexec. The GPU needs to be reset before the driver can be loaded again reliably. Needed for kexec for booting some ppc platforms. See:
https://bugs.freedesktop.org/show_bug.cgi?id=108585

Alex Deucher (6):
drm/amdgpu: add need_reset_on_init asic callback (v2) drm/amdgpu/si: add need_reset_on_init asic callback for SI (v2) drm/amdgpu/cik: add need_reset_on_init asic callback for CIK (v2) drm/amdgpu/vi: add need_reset_on_init asic callback for VI (v2) drm/amdgpu/soc15: add need_reset_on_init asic callback for SOC15 (v2) drm/amdgpu: check if we need to reset at init time (v2)

Quoted 8 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/cik.c           | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/si.c            |  6 ++++++
 drivers/gpu/drm/amd/amdgpu/soc15.c         | 20 ++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/vi.c            | 18 ++++++++++++++++++
 6 files changed, 76 insertions(+)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx