From: jsg Date: Fri, 31 Mar 2023 01:59:24 +0000 (+0000) Subject: drm/amdgpu/nv: Apply ASPM quirk on Intel ADL + AMD Navi X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e73b73371c6e54c1f512d80bf9b2c36cfb37f0f1;p=openbsd drm/amdgpu/nv: Apply ASPM quirk on Intel ADL + AMD Navi From Kai-Heng Feng ed6364fb7c407ca53447d8b0723a61d320bcbae9 in linux-6.1.y/6.1.22 2b072442f4962231a8516485012bb2d2551ef2fe in mainline linux --- diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu.h b/sys/dev/pci/drm/amd/amdgpu/amdgpu.h index 43866a7c3d6..4bce41041d3 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu.h +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu.h @@ -1292,6 +1292,7 @@ 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/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c index a0891745c0e..9149a5d7f79 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c @@ -78,6 +78,10 @@ #include +#if IS_ENABLED(CONFIG_X86) && defined(__linux__) +#include +#endif + MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin"); MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); @@ -1371,6 +1375,17 @@ 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 cpu_info *ci = curcpu(); + + return !(ci->ci_family == 6 && ci->ci_model == 0x97); +#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/sys/dev/pci/drm/amd/amdgpu/nv.c b/sys/dev/pci/drm/amd/amdgpu/nv.c index df3388e8dec..87798927829 100644 --- a/sys/dev/pci/drm/amd/amdgpu/nv.c +++ b/sys/dev/pci/drm/amd/amdgpu/nv.c @@ -527,7 +527,7 @@ static void nv_pcie_gen3_enable(struct amdgpu_device *adev) static void nv_program_aspm(struct amdgpu_device *adev) { - if (!amdgpu_device_should_use_aspm(adev)) + if (!amdgpu_device_should_use_aspm(adev) || !amdgpu_device_aspm_support_quirk()) return; if (!(adev->flags & AMD_IS_APU) && diff --git a/sys/dev/pci/drm/amd/amdgpu/vi.c b/sys/dev/pci/drm/amd/amdgpu/vi.c index 5a3a2fcaaf3..1e52c5f581e 100644 --- a/sys/dev/pci/drm/amd/amdgpu/vi.c +++ b/sys/dev/pci/drm/amd/amdgpu/vi.c @@ -81,10 +81,6 @@ #include "mxgpu_vi.h" #include "amdgpu_dm.h" -#if IS_ENABLED(CONFIG_X86) && defined(__linux__) -#include -#endif - #define ixPCIE_LC_L1_PM_SUBSTATE 0x100100C6 #define PCIE_LC_L1_PM_SUBSTATE__LC_L1_SUBSTATES_OVERRIDE_EN_MASK 0x00000001L #define PCIE_LC_L1_PM_SUBSTATE__LC_PCI_PM_L1_2_OVERRIDE_MASK 0x00000002L @@ -1138,24 +1134,13 @@ static void vi_enable_aspm(struct amdgpu_device *adev) WREG32_PCIE(ixPCIE_LC_CNTL, data); } -static bool aspm_support_quirk_check(void) -{ -#if IS_ENABLED(CONFIG_X86) - struct cpu_info *ci = curcpu(); - - return !(ci->ci_family == 6 && ci->ci_model == 0x97); -#else - return true; -#endif -} - static void vi_program_aspm(struct amdgpu_device *adev) { u32 data, data1, orig; bool bL1SS = false; bool bClkReqSupport = true; - if (!amdgpu_device_should_use_aspm(adev) || !aspm_support_quirk_check()) + if (!amdgpu_device_should_use_aspm(adev) || !amdgpu_device_aspm_support_quirk()) return; if (adev->flags & AMD_IS_APU ||