[3/3] pci/gk104: wait for ltssm idle before changing the link

Submitted by Karol Herbst on Sept. 12, 2019, 7 p.m.

Details

Message ID 20190912190028.27977-4-kherbst@redhat.com
State New
Headers show
Series "PCIe link change improvements" ( rev: 1 ) in Nouveau

Not browsing as part of any series.

Commit Message

Karol Herbst Sept. 12, 2019, 7 p.m.
taken from nvgpu

Signed-off-by: Karol Herbst <kherbst@redhat.com>
---
 drm/nouveau/nvkm/subdev/pci/gk104.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/nvkm/subdev/pci/gk104.c b/drm/nouveau/nvkm/subdev/pci/gk104.c
index 6aeb07fe4..2d1fa67eb 100644
--- a/drm/nouveau/nvkm/subdev/pci/gk104.c
+++ b/drm/nouveau/nvkm/subdev/pci/gk104.c
@@ -23,6 +23,8 @@ 
  */
 #include "priv.h"
 
+#include <subdev/timer.h>
+
 static int
 gk104_pcie_version_supported(struct nvkm_pci *pci)
 {
@@ -142,6 +144,11 @@  gk104_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
 		break;
 	}
 
+	/* wait for ltssm idle */
+	nvkm_msec(device, 200,
+		if ((nvkm_rd32(device, 0x8c040) & 0x1f) == 0)
+			break;
+	);
 	nvkm_mask(device, 0x8c040, 0xc0000, mask_value);
 	nvkm_mask(device, 0x8c040, 0x1, 0x1);
 }

Comments

On Thu, Sep 12, 2019 at 3:00 PM Karol Herbst <kherbst@redhat.com> wrote:
>
> taken from nvgpu
>
> Signed-off-by: Karol Herbst <kherbst@redhat.com>
> ---
>  drm/nouveau/nvkm/subdev/pci/gk104.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drm/nouveau/nvkm/subdev/pci/gk104.c b/drm/nouveau/nvkm/subdev/pci/gk104.c
> index 6aeb07fe4..2d1fa67eb 100644
> --- a/drm/nouveau/nvkm/subdev/pci/gk104.c
> +++ b/drm/nouveau/nvkm/subdev/pci/gk104.c
> @@ -23,6 +23,8 @@
>   */
>  #include "priv.h"
>
> +#include <subdev/timer.h>
> +
>  static int
>  gk104_pcie_version_supported(struct nvkm_pci *pci)
>  {
> @@ -142,6 +144,11 @@ gk104_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
>                 break;
>         }
>
> +       /* wait for ltssm idle */
> +       nvkm_msec(device, 200,
> +               if ((nvkm_rd32(device, 0x8c040) & 0x1f) == 0)
> +                       break;
> +       );

What if it doesn't idle? Should you still do the below things?

>         nvkm_mask(device, 0x8c040, 0xc0000, mask_value);
>         nvkm_mask(device, 0x8c040, 0x1, 0x1);
>  }
> --
> 2.21.0
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
On Thu, Sep 12, 2019 at 9:07 PM Ilia Mirkin <imirkin@alum.mit.edu> wrote:
>
> On Thu, Sep 12, 2019 at 3:00 PM Karol Herbst <kherbst@redhat.com> wrote:
> >
> > taken from nvgpu
> >
> > Signed-off-by: Karol Herbst <kherbst@redhat.com>
> > ---
> >  drm/nouveau/nvkm/subdev/pci/gk104.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drm/nouveau/nvkm/subdev/pci/gk104.c b/drm/nouveau/nvkm/subdev/pci/gk104.c
> > index 6aeb07fe4..2d1fa67eb 100644
> > --- a/drm/nouveau/nvkm/subdev/pci/gk104.c
> > +++ b/drm/nouveau/nvkm/subdev/pci/gk104.c
> > @@ -23,6 +23,8 @@
> >   */
> >  #include "priv.h"
> >
> > +#include <subdev/timer.h>
> > +
> >  static int
> >  gk104_pcie_version_supported(struct nvkm_pci *pci)
> >  {
> > @@ -142,6 +144,11 @@ gk104_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
> >                 break;
> >         }
> >
> > +       /* wait for ltssm idle */
> > +       nvkm_msec(device, 200,
> > +               if ((nvkm_rd32(device, 0x8c040) & 0x1f) == 0)
> > +                       break;
> > +       );
>
> What if it doesn't idle? Should you still do the below things?
>

ohh, good point. I totally didn't think about that. nvgpu aborts the
operation of course and we should do the same.

> >         nvkm_mask(device, 0x8c040, 0xc0000, mask_value);
> >         nvkm_mask(device, 0x8c040, 0x1, 0x1);
> >  }
> > --
> > 2.21.0
> >
> > _______________________________________________
> > Nouveau mailing list
> > Nouveau@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/nouveau