On Tue, Sep 30, 2025 at 3:01 AM Lijo Lazar <[email protected]> wrote:
>
> For saving switch state, check if the GPU is having SWUS/DS
> architecture. Otherwise, skip saving.
>
> Reported-by: Roman Elshin <[email protected]>
> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4602
> Fixes: 1dd2fa0e00f1 ("drm/amdgpu: Save and restore switch state")
> Signed-off-by: Lijo Lazar <[email protected]>

Acked-by: Alex Deucher <[email protected]>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 ++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 58287a006b87..562c5d7b8cfb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -7171,28 +7171,35 @@ void amdgpu_pci_resume(struct pci_dev *pdev)
>
>  static void amdgpu_device_cache_switch_state(struct amdgpu_device *adev)
>  {
> -       struct pci_dev *parent = pci_upstream_bridge(adev->pdev);
> +       struct pci_dev *swus, *swds;
>         int r;
>
> -       if (!parent || parent->vendor != PCI_VENDOR_ID_ATI)
> +       swds = pci_upstream_bridge(adev->pdev);
> +       if (!swds || swds->vendor != PCI_VENDOR_ID_ATI ||
> +           pci_pcie_type(swds) != PCI_EXP_TYPE_DOWNSTREAM)
> +               return;
> +       swus = pci_upstream_bridge(swds);
> +       if (!swus ||
> +           (swus->vendor != PCI_VENDOR_ID_ATI &&
> +            swus->vendor != PCI_VENDOR_ID_AMD) ||
> +           pci_pcie_type(swus) != PCI_EXP_TYPE_UPSTREAM)
>                 return;
>
>         /* If already saved, return */
>         if (adev->pcie_reset_ctx.swus)
>                 return;
>         /* Upstream bridge is ATI, assume it's SWUS/DS architecture */
> -       r = pci_save_state(parent);
> +       r = pci_save_state(swds);
>         if (r)
>                 return;
> -       adev->pcie_reset_ctx.swds_pcistate = pci_store_saved_state(parent);
> +       adev->pcie_reset_ctx.swds_pcistate = pci_store_saved_state(swds);
>
> -       parent = pci_upstream_bridge(parent);
> -       r = pci_save_state(parent);
> +       r = pci_save_state(swus);
>         if (r)
>                 return;
> -       adev->pcie_reset_ctx.swus_pcistate = pci_store_saved_state(parent);
> +       adev->pcie_reset_ctx.swus_pcistate = pci_store_saved_state(swus);
>
> -       adev->pcie_reset_ctx.swus = parent;
> +       adev->pcie_reset_ctx.swus = swus;
>  }
>
>  static void amdgpu_device_load_switch_state(struct amdgpu_device *adev)
> --
> 2.49.0
>

Reply via email to