From patchwork Wed Mar 29 09:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 13192238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA3F8C761A6 for ; Wed, 29 Mar 2023 10:00:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C86010EA50; Wed, 29 Mar 2023 10:00:36 +0000 (UTC) Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id A77F410EA50; Wed, 29 Mar 2023 10:00:34 +0000 (UTC) Received: from localhost.localdomain (unknown [10.101.196.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 9D3493F326; Wed, 29 Mar 2023 10:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680084032; bh=X736Xo2cMDDW60Y3vTbzigd2Xc6Dr2xSpP9bWqw8uGc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=BofD7a6Vm5hTCXvD6Qwb7kJmA/nDRL7QMu2lsS9dynDzisMxrRiO/8CeNWiUhUkoE rJB19HbYNUdJxfYNmQKyUq4geowyOwQNQQPICNEX65CFUHDPSNHtdT71U5pHFjlBRf aOqXnJzD2CN/RS7Vy145g5BIL9Wj/yErU00fopXZ/QsHOaDXoROHJmjGZQGLsOJn1L HZtYQVctKfWrnslEL+jFO5sh0nnnX5eRrA6YBzvnJ/wRdsPLh5HVMKsmYwC5wr35+Z UXD+LP4o4mGVK7n0yA7ML5ChhCclQVzzBUz/uAnM8Wo3bmNSjHCFoMbC+gFUadGTW+ Ea17loXeZ68Dw== From: Kai-Heng Feng To: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com Subject: [PATCH 1/2] drm/amdgpu: Reset GPU on S0ix when device supports BOCO Date: Wed, 29 Mar 2023 17:59:29 +0800 Message-Id: <20230329095933.1203559-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jingyu Wang , Andrey Grodzovsky , Lijo Lazar , dri-devel@lists.freedesktop.org, =?utf-8?q?Michel_D=C3=A4nzer?= , YiPeng Chai , Mario Limonciello , Guchun Chen , "Rafael J. Wysocki" , amd-gfx@lists.freedesktop.org, Jiansong Chen , Kenneth Feng , Tim Huang , Bokun Zhang , Hans de Goede , Maxime Ripard , Evan Quan , Somalapuram Amaranath , linux-kernel@vger.kernel.org, Kai-Heng Feng , Hawking Zhang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When the power is lost due to ACPI power resources being turned off, the driver should reset the GPU so it can work anew. First, _PR3 support of the hierarchy needs to be found correctly. Since the GPU on some discrete GFX cards is behind a PCIe switch, checking the _PR3 on downstream port alone is not enough, as the _PR3 can associate to the root port above the PCIe switch. Once the _PR3 is found and BOCO support is correctly marked, use that information to inform the GPU should be reset. This solves an issue that system freeze on a Intel ADL desktop that uses S0ix for sleep and D3cold is supported for the GFX slot. Fixes: 0064b0ce85bb ("drm/amd/pm: enable ASPM by default") Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1885 Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2458 Signed-off-by: Kai-Heng Feng --- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 ++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c index 60b1857f469e..407456ac0e84 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c @@ -987,6 +987,9 @@ bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev) if (amdgpu_sriov_vf(adev)) return false; + if (amdgpu_device_supports_boco(adev_to_drm(adev))) + return true; + #if IS_ENABLED(CONFIG_SUSPEND) return pm_suspend_target_state != PM_SUSPEND_TO_IDLE; #else diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index f5658359ff5c..d56b7a2bafa6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2181,7 +2181,12 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) if (!(adev->flags & AMD_IS_APU)) { parent = pci_upstream_bridge(adev->pdev); - adev->has_pr3 = parent ? pci_pr3_present(parent) : false; + do { + if (pci_pr3_present(parent)) { + adev->has_pr3 = true; + break; + } + } while ((parent = pci_upstream_bridge(parent))); } amdgpu_amdkfd_device_probe(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index ba5def374368..5d81fcac4b0a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2415,10 +2415,11 @@ static int amdgpu_pmops_suspend(struct device *dev) struct drm_device *drm_dev = dev_get_drvdata(dev); struct amdgpu_device *adev = drm_to_adev(drm_dev); - if (amdgpu_acpi_is_s0ix_active(adev)) - adev->in_s0ix = true; - else if (amdgpu_acpi_is_s3_active(adev)) + if (amdgpu_acpi_is_s3_active(adev) || + amdgpu_device_supports_boco(drm_dev)) adev->in_s3 = true; + else if (amdgpu_acpi_is_s0ix_active(adev)) + adev->in_s0ix = true; if (!adev->in_s0ix && !adev->in_s3) return 0; return amdgpu_device_suspend(drm_dev, true); @@ -2449,10 +2450,7 @@ static int amdgpu_pmops_resume(struct device *dev) adev->no_hw_access = true; r = amdgpu_device_resume(drm_dev, true); - if (amdgpu_acpi_is_s0ix_active(adev)) - adev->in_s0ix = false; - else - adev->in_s3 = false; + adev->in_s0ix = adev->in_s3 = false; return r; } From patchwork Wed Mar 29 09:59:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 13192239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04B82C6FD18 for ; Wed, 29 Mar 2023 10:00:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 212B810EA6D; Wed, 29 Mar 2023 10:00:49 +0000 (UTC) Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 02DD810EA6C; Wed, 29 Mar 2023 10:00:47 +0000 (UTC) Received: from localhost.localdomain (unknown [10.101.196.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 269323F7EC; Wed, 29 Mar 2023 10:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680084045; bh=VMzLHhxzhHC4PRmh66lC+fdivOWneh5TdLK3pKLgHuw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U47maoOSC0R9+1f324S7g9AXqoEBBe5DM30hBLFLgstnYXuA0PCxRV4f7Q0xji9hB SNBLKM9vNscR9YFs2QQlZsqLWbnOltBK/xgZPLYZVAZjvbtw9ZVe299refxOwoED9e 5KB+Qnj4QWJIjxXRSCm8Myfu28dC7V1GThjgS5ud7xyOZbYQ1sgdZ9UZjx0yx4omrT Ym0JORgjADjxPLfnpx2irA1zRSXtclujWx2pOkYMTgLMz/mZ47UjORV+JGYO78Lo0v TQMilsci3clidA0S14HDJk3oKdsdlJusRuUEyMvgGx4Hv8Lyu6a6TFLhBcOxe1Xz1s H+cFLdJD1Lq0Q== From: Kai-Heng Feng To: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com Subject: [PATCH 2/2] drm/amdgpu: Remove ASPM workaround on VI and NV Date: Wed, 29 Mar 2023 17:59:30 +0800 Message-Id: <20230329095933.1203559-2-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230329095933.1203559-1-kai.heng.feng@canonical.com> References: <20230329095933.1203559-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Victor Zhao , dri-devel@lists.freedesktop.org, Kai-Heng Feng , Mario Limonciello , Likun Gao , Guchun Chen , amd-gfx@lists.freedesktop.org, Veerabadhran Gopalakrishnan , Andrey Grodzovsky , Lijo Lazar , Bokun Zhang , Evan Quan , Jack Xiao , Richard Gong , Felix Kuehling , Somalapuram Amaranath , linux-kernel@vger.kernel.org, YiPeng Chai , Hawking Zhang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since the original issue is resolved by a new fix, the ASPM workaround can be dropped. Signed-off-by: Kai-Heng Feng --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 --------------- drivers/gpu/drm/amd/amdgpu/nv.c | 2 +- drivers/gpu/drm/amd/amdgpu/vi.c | 2 +- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 8cf2cc50b3de..a19a6489b117 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1248,7 +1248,6 @@ void amdgpu_device_pci_config_reset(struct amdgpu_device *adev); int amdgpu_device_pci_reset(struct amdgpu_device *adev); bool amdgpu_device_need_post(struct amdgpu_device *adev); bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev); -bool amdgpu_device_aspm_support_quirk(void); void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes, u64 num_vis_bytes); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index d56b7a2bafa6..0cacace2d6c2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -81,10 +81,6 @@ #include -#if IS_ENABLED(CONFIG_X86) -#include -#endif - MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin"); MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); @@ -1377,17 +1373,6 @@ bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev) return pcie_aspm_enabled(adev->pdev); } -bool amdgpu_device_aspm_support_quirk(void) -{ -#if IS_ENABLED(CONFIG_X86) - struct cpuinfo_x86 *c = &cpu_data(0); - - return !(c->x86 == 6 && c->x86_model == INTEL_FAM6_ALDERLAKE); -#else - return true; -#endif -} - /* if we get transitioned to only one device, take VGA back */ /** * amdgpu_device_vga_set_decode - enable/disable vga decode diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c index 47420b403871..15f3c6745ea9 100644 --- a/drivers/gpu/drm/amd/amdgpu/nv.c +++ b/drivers/gpu/drm/amd/amdgpu/nv.c @@ -522,7 +522,7 @@ static int nv_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk) static void nv_program_aspm(struct amdgpu_device *adev) { - if (!amdgpu_device_should_use_aspm(adev) || !amdgpu_device_aspm_support_quirk()) + if (!amdgpu_device_should_use_aspm(adev)) return; if (!(adev->flags & AMD_IS_APU) && diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 531f173ade2d..81dcb1148a60 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c @@ -1122,7 +1122,7 @@ static void vi_program_aspm(struct amdgpu_device *adev) bool bL1SS = false; bool bClkReqSupport = true; - if (!amdgpu_device_should_use_aspm(adev) || !amdgpu_device_aspm_support_quirk()) + if (!amdgpu_device_should_use_aspm(adev)) return; if (adev->flags & AMD_IS_APU ||