Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Check swus/ds for switch state save

For saving switch state, check if the GPU is having SWUS/DS
architecture. Otherwise, skip saving.

Reported-by: Roman Elshin <roman.elshin@gmail.com>
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4602
Fixes: 1dd2fa0e00f1 ("drm/amdgpu: Save and restore switch state")
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
9b608fe9 1f086d25

+15 -8
+15 -8
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 7157 7157 7158 7158 static void amdgpu_device_cache_switch_state(struct amdgpu_device *adev) 7159 7159 { 7160 - struct pci_dev *parent = pci_upstream_bridge(adev->pdev); 7160 + struct pci_dev *swus, *swds; 7161 7161 int r; 7162 7162 7163 - if (!parent || parent->vendor != PCI_VENDOR_ID_ATI) 7163 + swds = pci_upstream_bridge(adev->pdev); 7164 + if (!swds || swds->vendor != PCI_VENDOR_ID_ATI || 7165 + pci_pcie_type(swds) != PCI_EXP_TYPE_DOWNSTREAM) 7166 + return; 7167 + swus = pci_upstream_bridge(swds); 7168 + if (!swus || 7169 + (swus->vendor != PCI_VENDOR_ID_ATI && 7170 + swus->vendor != PCI_VENDOR_ID_AMD) || 7171 + pci_pcie_type(swus) != PCI_EXP_TYPE_UPSTREAM) 7164 7172 return; 7165 7173 7166 7174 /* If already saved, return */ 7167 7175 if (adev->pcie_reset_ctx.swus) 7168 7176 return; 7169 7177 /* Upstream bridge is ATI, assume it's SWUS/DS architecture */ 7170 - r = pci_save_state(parent); 7178 + r = pci_save_state(swds); 7171 7179 if (r) 7172 7180 return; 7173 - adev->pcie_reset_ctx.swds_pcistate = pci_store_saved_state(parent); 7181 + adev->pcie_reset_ctx.swds_pcistate = pci_store_saved_state(swds); 7174 7182 7175 - parent = pci_upstream_bridge(parent); 7176 - r = pci_save_state(parent); 7183 + r = pci_save_state(swus); 7177 7184 if (r) 7178 7185 return; 7179 - adev->pcie_reset_ctx.swus_pcistate = pci_store_saved_state(parent); 7186 + adev->pcie_reset_ctx.swus_pcistate = pci_store_saved_state(swus); 7180 7187 7181 - adev->pcie_reset_ctx.swus = parent; 7188 + adev->pcie_reset_ctx.swus = swus; 7182 7189 } 7183 7190 7184 7191 static void amdgpu_device_load_switch_state(struct amdgpu_device *adev)