On Tue, Nov 21, 2017 at 04:01:16PM +0100, Karol Herbst wrote:
> This should make systems more stable where resuming the GPU fails. This
> can happen due to bad firmware or due to a bug within the kernel. The
> last thing which should happen in either case is an unusable system.
> 
> v2: do the same in nouveau_pmops_resume
> 
> Tested-by: Karl Hastings <ka...@redhat.com>
> Signed-off-by: Karol Herbst <kher...@redhat.com>
> ---
>  drm/nouveau/nouveau_drm.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/drm/nouveau/nouveau_drm.c b/drm/nouveau/nouveau_drm.c
> index 8d4a5be3..6e4cb4f7 100644
> --- a/drm/nouveau/nouveau_drm.c
> +++ b/drm/nouveau/nouveau_drm.c
> @@ -792,6 +792,27 @@ nouveau_pmops_suspend(struct device *dev)
>       return 0;
>  }
>  
> +static int
> +nouveau_set_power_state_D0(struct pci_dev *pdev)
> +{
> +     struct nouveau_drm *drm = nouveau_drm(pci_get_drvdata(pdev));
> +     int ret;
> +
> +     pci_set_power_state(pdev, PCI_D0);
> +     /* abort if anything went wrong */
> +     if (pdev->current_state != PCI_D0) {
> +             NV_ERROR(drm, "couldn't wake up GPU!\n");
> +             return -EBUSY;
> +     }

Looks to me like the more idiomatic way to do this is:

        ret = pci_set_power_state(pdev, PCI_D0);
        if (ret < 0 && ret != -EIO)
                return ret;

> +     pci_restore_state(pdev);
> +     ret = pci_enable_device(pdev);
> +     if (ret)
> +             return ret;
> +
> +     pci_set_master(pdev);

Looking closer it also seems like pci_enable_device() will already set
the power state to D0 (via do_pci_enable_device()). Is the sequence
above really necessary because the hardware is quirky, or was it
cargo-culted?

Thierry

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

Reply via email to