All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Karol Herbst <kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH v2] drm: don't continue with anything after the GPU couldn't be woken up
Date: Tue, 21 Nov 2017 18:46:09 +0100	[thread overview]
Message-ID: <20171121174609.GA28301@ulmo> (raw)
In-Reply-To: <20171121150116.24956-1-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1762 bytes --]

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 <kazen-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Karol Herbst <kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  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 #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

  parent reply	other threads:[~2017-11-21 17:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 15:01 [PATCH v2] drm: don't continue with anything after the GPU couldn't be woken up Karol Herbst
     [not found] ` <20171121150116.24956-1-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-21 17:46   ` Thierry Reding [this message]
2017-11-21 19:03     ` Karol Herbst
2017-11-22 10:31       ` [Nouveau] " Thierry Reding
2017-11-22 10:51         ` Karol Herbst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171121174609.GA28301@ulmo \
    --to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.