[5/5] pci: restore the boot pcie link speed on fini

Submitted by Karol Herbst on May 4, 2019, 4:32 p.m.

Details

Message ID 20190504163219.8349-6-kherbst@redhat.com
State New
Headers show
Series "Potential fix for runpm issues on various laptops" ( rev: 1 ) in Nouveau

Not browsing as part of any series.

Commit Message

Karol Herbst May 4, 2019, 4:32 p.m.
fixes runtime suspend on my gp107

Signed-off-by: Karol Herbst <kherbst@redhat.com>
---
 drm/nouveau/nvkm/subdev/pci/base.c | 2 ++
 drm/nouveau/nvkm/subdev/pci/pcie.c | 8 ++++++++
 drm/nouveau/nvkm/subdev/pci/priv.h | 1 +
 3 files changed, 11 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/nvkm/subdev/pci/base.c b/drm/nouveau/nvkm/subdev/pci/base.c
index b6ebee6f..d9fb5a83 100644
--- a/drm/nouveau/nvkm/subdev/pci/base.c
+++ b/drm/nouveau/nvkm/subdev/pci/base.c
@@ -90,6 +90,8 @@  nvkm_pci_fini(struct nvkm_subdev *subdev, bool suspend)
 
 	if (pci->agp.bridge)
 		nvkm_agp_fini(pci);
+	else if (pci_is_pcie(pci->pdev))
+		nvkm_pcie_fini(pci);
 
 	return 0;
 }
diff --git a/drm/nouveau/nvkm/subdev/pci/pcie.c b/drm/nouveau/nvkm/subdev/pci/pcie.c
index 727b5d6a..00c07fd8 100644
--- a/drm/nouveau/nvkm/subdev/pci/pcie.c
+++ b/drm/nouveau/nvkm/subdev/pci/pcie.c
@@ -118,6 +118,14 @@  nvkm_pcie_init(struct nvkm_pci *pci)
 	return 0;
 }
 
+int
+nvkm_pcie_fini(struct nvkm_pci *pci)
+{
+	if (!IS_ERR_VALUE(pci->pcie.def_speed))
+		return nvkm_pcie_set_link(pci, pci->pcie.def_speed, 16);
+	return 0;
+}
+
 int
 nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)
 {
diff --git a/drm/nouveau/nvkm/subdev/pci/priv.h b/drm/nouveau/nvkm/subdev/pci/priv.h
index dc3ae3cd..e7744671 100644
--- a/drm/nouveau/nvkm/subdev/pci/priv.h
+++ b/drm/nouveau/nvkm/subdev/pci/priv.h
@@ -62,4 +62,5 @@  int gk104_pcie_version_supported(struct nvkm_pci *);
 int nvkm_pcie_oneinit(struct nvkm_pci *);
 int nvkm_pcie_preinit(struct nvkm_pci *);
 int nvkm_pcie_init(struct nvkm_pci *);
+int nvkm_pcie_fini(struct nvkm_pci *);
 #endif

Comments

I think it should be fine to just squash this and the previous patch together.
If not, longer commit message here at least

up to you, either way: Reviewed-by: Lyude Paul <lyude@redhat.com>

On Sat, 2019-05-04 at 18:32 +0200, Karol Herbst wrote:
> fixes runtime suspend on my gp107
> 
> Signed-off-by: Karol Herbst <kherbst@redhat.com>
> ---
>  drm/nouveau/nvkm/subdev/pci/base.c | 2 ++
>  drm/nouveau/nvkm/subdev/pci/pcie.c | 8 ++++++++
>  drm/nouveau/nvkm/subdev/pci/priv.h | 1 +
>  3 files changed, 11 insertions(+)
> 
> diff --git a/drm/nouveau/nvkm/subdev/pci/base.c
> b/drm/nouveau/nvkm/subdev/pci/base.c
> index b6ebee6f..d9fb5a83 100644
> --- a/drm/nouveau/nvkm/subdev/pci/base.c
> +++ b/drm/nouveau/nvkm/subdev/pci/base.c
> @@ -90,6 +90,8 @@ nvkm_pci_fini(struct nvkm_subdev *subdev, bool suspend)
>  
>  	if (pci->agp.bridge)
>  		nvkm_agp_fini(pci);
> +	else if (pci_is_pcie(pci->pdev))
> +		nvkm_pcie_fini(pci);
>  
>  	return 0;
>  }
> diff --git a/drm/nouveau/nvkm/subdev/pci/pcie.c
> b/drm/nouveau/nvkm/subdev/pci/pcie.c
> index 727b5d6a..00c07fd8 100644
> --- a/drm/nouveau/nvkm/subdev/pci/pcie.c
> +++ b/drm/nouveau/nvkm/subdev/pci/pcie.c
> @@ -118,6 +118,14 @@ nvkm_pcie_init(struct nvkm_pci *pci)
>  	return 0;
>  }
>  
> +int
> +nvkm_pcie_fini(struct nvkm_pci *pci)
> +{
> +	if (!IS_ERR_VALUE(pci->pcie.def_speed))
> +		return nvkm_pcie_set_link(pci, pci->pcie.def_speed, 16);
> +	return 0;
> +}
> +
>  int
>  nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8
> width)
>  {
> diff --git a/drm/nouveau/nvkm/subdev/pci/priv.h
> b/drm/nouveau/nvkm/subdev/pci/priv.h
> index dc3ae3cd..e7744671 100644
> --- a/drm/nouveau/nvkm/subdev/pci/priv.h
> +++ b/drm/nouveau/nvkm/subdev/pci/priv.h
> @@ -62,4 +62,5 @@ int gk104_pcie_version_supported(struct nvkm_pci *);
>  int nvkm_pcie_oneinit(struct nvkm_pci *);
>  int nvkm_pcie_preinit(struct nvkm_pci *);
>  int nvkm_pcie_init(struct nvkm_pci *);
> +int nvkm_pcie_fini(struct nvkm_pci *);
>  #endif