add PCIe workaround to fix runpm on laptops
v4 cover add PCIe workaround to fix runpm on laptops
not much changed since the last time I sent those patches out, but there are a couple of annoying bug fixes, which users would probably never hit unless they do rmmod/modprobe nouveau cycles.
Biggest change is that I force the link to a 8.0 speed rather than the speed the GPU came up with.
Also this series depends on the PCIe improvement patches I sent out recently.
Karol Herbst (4):
pci: enable pcie link changes for pascal
pci: add nvkm_pcie_get_speed
pci: set the pcie link speed to 8.0 when suspending
drm: abort runtime suspend if we hit an error
drm/nouveau/include/nvkm/core/device.h | 2 ++ drm/nouveau/include/nvkm/subdev/pci.h | 4 ++- drm/nouveau/nouveau_drm.c | 6 +++++ drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/pci/base.c | 2 ++ drm/nouveau/nvkm/subdev/pci/gk104.c | 8 +++--- drm/nouveau/nvkm/subdev/pci/gp100.c | 11 ++++++++ drm/nouveau/nvkm/subdev/pci/pcie.c | 35 +++++++++++++++++++++++--- drm/nouveau/nvkm/subdev/pci/priv.h | 6 +++++ 9 files changed, 66 insertions(+), 10 deletions(-)
Signature · 6 lines
2.21.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20190913113306.20972-1-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH v4 1/4 pci: enable pcie link changes for pascal
v2: add force disable ASPM func pointer
--- drm/nouveau/nvkm/subdev/pci/gk104.c | 8 ++++---- drm/nouveau/nvkm/subdev/pci/gp100.c | 11 +++++++++++ drm/nouveau/nvkm/subdev/pci/priv.h | 5 +++++ 3 files changed, 20 insertions(+), 4 deletions(-)
drm/nouveau/nvkm/subdev/pci/gk104.c +4 -4
@@ -25,7 +25,7 @@#include <subdev/timer.h> -static int +int gk104_pcie_version_supported (struct nvkm_pci *pci) {return (nvkm_rd32 (pci->subdev.device,0x8c1c0 ) &0x4 ) ==0x4 ?2 :1 ;
@@ -110,7 +110,7 @@ gk104_pcie_lnkctl_speed(struct nvkm_pci *pci)return -1 ; } -static enum nvkm_pcie_speed +enum nvkm_pcie_speed gk104_pcie_max_speed (struct nvkm_pci *pci) {u32 max_speed =nvkm_rd32 (pci->subdev.device,0x8c1c0 ) &0x300000 ;
@@ -156,7 +156,7 @@ gk104_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)return 0 ; } -static int +int gk104_pcie_init (struct nvkm_pci * pci) {enum nvkm_pcie_speed lnkctl_speed, max_speed, cap_speed;
@@ -188,7 +188,7 @@ gk104_pcie_init(struct nvkm_pci * pci)return 0 ; } -static int +int gk104_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width) {struct nvkm_subdev *subdev = &pci->subdev;
drm/nouveau/nvkm/subdev/pci/gp100.c +11 -0
@@ -35,6 +35,17 @@ gp100_pci_func = { .wr08 = nv40_pci_wr08, .wr32 = nv40_pci_wr32, .msi_rearm = gp100_pci_msi_rearm, + + .pcie.init = gk104_pcie_init, + .pcie.set_link = gk104_pcie_set_link, + + .pcie.max_speed = gk104_pcie_max_speed, + .pcie.cur_speed = g84_pcie_cur_speed, + + .pcie.set_version = gf100_pcie_set_version, + .pcie.version = gf100_pcie_version, + .pcie.version_supported = gk104_pcie_version_supported, + .pcie.force_aspm_off = g84_pcie_force_aspm_off, };int
drm/nouveau/nvkm/subdev/pci/priv.h +5 -0
@@ -56,6 +56,11 @@ int gf100_pcie_cap_speed(struct nvkm_pci *);int gf100_pcie_init (struct nvkm_pci *);int gf100_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 ); +int gk104_pcie_init (struct nvkm_pci *); +int gk104_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +enum nvkm_pcie_speed gk104_pcie_max_speed (struct nvkm_pci *); +int gk104_pcie_version_supported (struct nvkm_pci *); +int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *);#endif
Signature · 6 lines
2.21.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20190913113306.20972-2-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Lyude Paul
Reviewed-byRe: [PATCH v4 1/4] pci: enable pcie link changes for pascal
Quoted 93 lines · Karol Herbst
v2: add force disable ASPM func pointer
Signed-off-by Karol Herbst <[email protected]>Reviewed-by Lyude Paul <[email protected]> (v1)--- drm/nouveau/nvkm/subdev/pci/gk104.c | 8 ++++---- drm/nouveau/nvkm/subdev/pci/gp100.c | 11 +++++++++++ drm/nouveau/nvkm/subdev/pci/priv.h | 5 +++++ 3 files changed, 20 insertions(+), 4 deletions(-)drm/nouveau/nvkm/subdev/pci/gk104.c +3
-3@@ -25,7 +25,7 @@#include <subdev/timer.h> -static int +int gk104_pcie_version_supported (struct nvkm_pci *pci) {return (nvkm_rd32 (pci->subdev.device,0x8c1c0 ) &0x4 ) ==0x4 ?2 :1 ;@@ -110,7 +110,7 @@ gk104_pcie_lnkctl_speed(struct nvkm_pci *pci)return -1 ; } -static enum nvkm_pcie_speed +enum nvkm_pcie_speed gk104_pcie_max_speed (struct nvkm_pci *pci) {u32 max_speed =nvkm_rd32 (pci->subdev.device,0x8c1c0 ) &0x300000 ;@@ -156,7 +156,7 @@ gk104_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)return 0 ; } -static int +int gk104_pcie_init (struct nvkm_pci * pci) {drm/nouveau/nvkm/subdev/pci/gk104.c +1
-1enum nvkm_pcie_speed lnkctl_speed, max_speed, cap_speed;@@ -188,7 +188,7 @@ gk104_pcie_init(struct nvkm_pci * pci)return 0 ; } -static int +int gk104_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width) {drm/nouveau/nvkm/subdev/pci/gk104.c +0
-0struct nvkm_subdev *subdev = &pci->subdev;drm/nouveau/nvkm/subdev/pci/gp100.c +11
-0@@ -35,6 +35,17 @@ gp100_pci_func = { .wr08 = nv40_pci_wr08, .wr32 = nv40_pci_wr32, .msi_rearm = gp100_pci_msi_rearm, + + .pcie.init = gk104_pcie_init, + .pcie.set_link = gk104_pcie_set_link, + + .pcie.max_speed = gk104_pcie_max_speed, + .pcie.cur_speed = g84_pcie_cur_speed, + + .pcie.set_version = gf100_pcie_set_version, + .pcie.version = gf100_pcie_version, + .pcie.version_supported = gk104_pcie_version_supported, + .pcie.force_aspm_off = g84_pcie_force_aspm_off, };int drm/nouveau/nvkm/subdev/pci/priv.h +5
-0@@ -56,6 +56,11 @@ int gf100_pcie_cap_speed(struct nvkm_pci *);int gf100_pcie_init (struct nvkm_pci *);int gf100_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 ); +int gk104_pcie_init (struct nvkm_pci *); +int gk104_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +enum nvkm_pcie_speed gk104_pcie_max_speed (struct nvkm_pci *); +int gk104_pcie_version_supported (struct nvkm_pci *); +int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *);#endif
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH v4 2/4 pci: add nvkm_pcie_get_speed
In reply to a message not in the archivev2: fixed compilation error
--- drm/nouveau/include/nvkm/subdev/pci.h | 1 + drm/nouveau/nvkm/subdev/pci/pcie.c | 8 ++++++++ 2 files changed, 9 insertions(+)
drm/nouveau/include/nvkm/subdev/pci.h +1 -0
@@ -53,4 +53,5 @@ int gp100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);/* pcie functions */ int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif
drm/nouveau/nvkm/subdev/pci/pcie.c +8 -0
@@ -177,3 +177,11 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)return ret; } + +enum nvkm_pcie_speed +nvkm_pcie_get_speed (struct nvkm_pci *pci) +{ +if (!pci || !pci_is_pcie (pci->pdev) || !pci->func->pcie.cur_speed) +return -ENODEV ; +return pci->func->pcie.cur_speed (pci); +}
Signature · 6 lines
2.21.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20190913113306.20972-3-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH v4 2/4] pci: add nvkm_pcie_get_speed
Quoted 2 lines · Karol Herbst
v2: fixed compilation error
Is there any need for this patch at all now, if you're forcing 8_0 rather than the pre-DEVINIT speed?
Quoted 37 lines
Signed-off-by Karol Herbst <[email protected]>Reviewed-by Lyude Paul <[email protected]>--- drm/nouveau/include/nvkm/subdev/pci.h | 1 + drm/nouveau/nvkm/subdev/pci/pcie.c | 8 ++++++++ 2 files changed, 9 insertions(+)drm/nouveau/include/nvkm/subdev/pci.h +1
-0@@ -53,4 +53,5 @@ int gp100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);/* pcie functions */ int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif drm/nouveau/nvkm/subdev/pci/pcie.c +8
-1@@ -177,3 +177,11 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)return ret; } + +enum nvkm_pcie_speed +nvkm_pcie_get_speed (struct nvkm_pci *pci) +{ +if (!pci || !pci_is_pcie (pci->pdev) || !pci->func->pcie.cur_speed) +return -ENODEV ; +return pci->func->pcie.cur_speed (pci); +} --2.21.0
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH v4 3/4 pci: set the pcie link speed to 8.0 when suspending
In reply to a message not in the archiveApperantly things go south if we suspend the device with a PCIe link speed set to 2.5. Fixes runtime suspend on my gp107.
This all looks like some bug inside the pci subsystem and I would prefer a fix there instead of nouveau, but maybe there is no real nice way of doing that outside of drivers?
v2: squashed together patch 4 and 5
v3: only restore pcie speed on machines with runpm
add NvRunpmWorkaround config option to disable the workaround
v4: only run the code on suspend
always put the card into 8.0 mode, not what nouveau detected on load
--- drm/nouveau/include/nvkm/core/device.h | 2 ++ drm/nouveau/include/nvkm/subdev/pci.h | 3 ++- drm/nouveau/nouveau_drm.c | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/pci/base.c | 2 ++ drm/nouveau/nvkm/subdev/pci/pcie.c | 27 ++++++++++++++++++++++---- drm/nouveau/nvkm/subdev/pci/priv.h | 1 + 7 files changed, 32 insertions(+), 6 deletions(-)
drm/nouveau/include/nvkm/core/device.h +2 -0
@@ -125,6 +125,8 @@ struct nvkm_device {u8 chiprev;u32 crystal; +bool has_runpm; +struct {struct notifier_block nb; } acpi;
drm/nouveau/include/nvkm/subdev/pci.h +2 -1
@@ -52,6 +52,7 @@ int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);int gp100_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);/* pcie functions */ -int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width, +bool save);enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif
drm/nouveau/nouveau_drm.c +1 -0
@@ -676,6 +676,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,if (nouveau_atomic) driver_pci.driver_features |=DRIVER_ATOMIC ; + device->has_runpm =nouveau_pmops_runtime (); drm_dev =drm_dev_alloc (&driver_pci, &pdev->dev);if (IS_ERR (drm_dev)) {
drm/nouveau/nvkm/subdev/clk/base.c +1 -1
@@ -277,7 +277,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)nvkm_debug (subdev,"setting performance state %d\n" , pstatei); clk->pstate = pstatei; -nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width); +nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width, true);if (fb && fb->ram && fb->ram->func->calc) {struct nvkm_ram *ram = fb->ram;
drm/nouveau/nvkm/subdev/pci/base.c +2 -0
@@ -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, suspend);return 0 ; }
drm/nouveau/nvkm/subdev/pci/pcie.c +23 -4
@@ -23,6 +23,8 @@*/ #include "priv.h" +#include <core/option.h> +static char *nvkm_pcie_speeds[] = {"2.5GT/s" ,"5.0GT/s" ,
@@ -106,11 +108,25 @@ nvkm_pcie_init(struct nvkm_pci *pci) pci->func->pcie.init (pci);if (pci->pcie.speed !=-1 ) -nvkm_pcie_set_link (pci, pci->pcie.speed, pci->pcie.width); +nvkm_pcie_set_link (pci, pci->pcie.speed, + pci->pcie.width, false);return 0 ; } +int +nvkm_pcie_fini (struct nvkm_pci *pci,bool suspend) +{ +struct nvkm_device *device = pci->subdev.device; +if (!device->has_runpm || !suspend) +return 0 ; + +if (!nvkm_boolopt (device->cfgopt,"NvRunpmWorkaround" , true)) +return 0 ; + +return nvkm_pcie_set_link (pci,NVKM_PCIE_SPEED_8_0 ,16 , false); +} +void nvkm_pcie_force_aspm_off (struct nvkm_pci *pci,bool status) {
@@ -120,7 +136,8 @@ nvkm_pcie_force_aspm_off(struct nvkm_pci *pci, bool status) }int -nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width) +nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width, +bool save) {struct nvkm_subdev *subdev = &pci->subdev;enum nvkm_pcie_speed cur_speed, max_speed;
@@ -154,8 +171,10 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width) speed = max_speed; } - pci->pcie.speed = speed; - pci->pcie.width = width; +if (save) { + pci->pcie.speed = speed; + pci->pcie.width = width; + }if (speed == cur_speed) {nvkm_debug (subdev,"requested matches current speed\n" );
drm/nouveau/nvkm/subdev/pci/priv.h +1 -0
@@ -63,4 +63,5 @@ int gk104_pcie_version_supported(struct nvkm_pci *);int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *); +int nvkm_pcie_fini (struct nvkm_pci *,bool suspend);#endif
Signature · 6 lines
2.21.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20190913113306.20972-4-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH v4 3/4] pci: set the pcie link speed to 8.0 when suspending
Quoted 8 lines · Karol Herbst
Apperantly things go south if we suspend the device with a PCIe link speed set to 2.5. Fixes runtime suspend on my gp107.
This all looks like some bug inside the pci subsystem and I would prefer a fix there instead of nouveau, but maybe there is no real nice way of doing that outside of drivers?
Quoted 5 lines
v2: squashed together patch 4 and 5
v3: only restore pcie speed on machines with runpm
add NvRunpmWorkaround config option to disable the workaround
v4: only run the code on suspend
always put the card into 8.0 mode, not what nouveau detected on load
Why this change? Also, I know we don't currently touch it, but what if x16 isn't available on some systems and we break stuff when we do start playing with link width?
Quoted 153 lines
Signed-off-by Karol Herbst <[email protected]>Reviewed-by Lyude Paul <[email protected]> (v2)--- drm/nouveau/include/nvkm/core/device.h | 2 ++ drm/nouveau/include/nvkm/subdev/pci.h | 3 ++- drm/nouveau/nouveau_drm.c | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/pci/base.c | 2 ++ drm/nouveau/nvkm/subdev/pci/pcie.c | 27 ++++++++++++++++++++++---- drm/nouveau/nvkm/subdev/pci/priv.h | 1 + 7 files changed, 32 insertions(+), 6 deletions(-)drm/nouveau/include/nvkm/core/device.h +2
-0@@ -125,6 +125,8 @@ struct nvkm_device {u8 chiprev;u32 crystal; +bool has_runpm; +struct {struct notifier_block nb; } acpi;drm/nouveau/include/nvkm/subdev/pci.h +2
-1@@ -52,6 +52,7 @@ int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);int gp100_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);/* pcie functions */ -int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width, +bool save);enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif drm/nouveau/nouveau_drm.c +1
-0@@ -676,6 +676,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,if (nouveau_atomic) driver_pci.driver_features |=DRIVER_ATOMIC ; + device->has_runpm =nouveau_pmops_runtime (); drm_dev =drm_dev_alloc (&driver_pci, &pdev->dev);if (IS_ERR (drm_dev)) {drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -277,7 +277,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)nvkm_debug (subdev,"setting performance state %d\n" , pstatei); clk->pstate = pstatei; -nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width); +nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width, true);if (fb && fb->ram && fb->ram->func->calc) {struct nvkm_ram *ram = fb->ram;drm/nouveau/nvkm/subdev/pci/base.c +2
-0@@ -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, suspend);return 0 ; }drm/nouveau/nvkm/subdev/pci/pcie.c +23
-4@@ -23,6 +23,8 @@*/ #include "priv.h" +#include <core/option.h> +static char *nvkm_pcie_speeds[] = {"2.5GT/s" ,"5.0GT/s" ,@@ -106,11 +108,25 @@ nvkm_pcie_init(struct nvkm_pci *pci) pci->func->pcie.init (pci);if (pci->pcie.speed !=-1 ) -nvkm_pcie_set_link (pci, pci->pcie.speed, pci->pcie.width); +nvkm_pcie_set_link (pci, pci->pcie.speed, + pci->pcie.width, false);return 0 ; } +int +nvkm_pcie_fini (struct nvkm_pci *pci,bool suspend) +{ +struct nvkm_device *device = pci->subdev.device; +if (!device->has_runpm || !suspend) +return 0 ; + +if (!nvkm_boolopt (device->cfgopt,"NvRunpmWorkaround" , true)) +return 0 ; + +return nvkm_pcie_set_link (pci,NVKM_PCIE_SPEED_8_0 ,16 , false); +} +void nvkm_pcie_force_aspm_off (struct nvkm_pci *pci,bool status) {@@ -120,7 +136,8 @@ nvkm_pcie_force_aspm_off(struct nvkm_pci *pci, bool status) }int -nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width) +nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width, +bool save) {struct nvkm_subdev *subdev = &pci->subdev;enum nvkm_pcie_speed cur_speed, max_speed;@@ -154,8 +171,10 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width) speed = max_speed; } - pci->pcie.speed = speed; - pci->pcie.width = width; +if (save) { + pci->pcie.speed = speed; + pci->pcie.width = width; + }if (speed == cur_speed) {nvkm_debug (subdev,"requested matches current speed\n" );drm/nouveau/nvkm/subdev/pci/priv.h +1
-1@@ -63,4 +63,5 @@ int gk104_pcie_version_supported(struct nvkm_pci *);int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *); +int nvkm_pcie_fini (struct nvkm_pci *,bool suspend);#endif --2.21.0
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CACAvsv4gP5rX2K9pCx2TSHtgAGbqPfYYMA05TgRZkAKXb3RMow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v4 3/4] pci: set the pcie link speed to 8.0 when suspending
Quoted 10 lines · Ben Skeggs
Quoted 8 lines · Karol Herbst
Apperantly things go south if we suspend the device with a PCIe link speed set to 2.5. Fixes runtime suspend on my gp107.
This all looks like some bug inside the pci subsystem and I would prefer a fix there instead of nouveau, but maybe there is no real nice way of doing that outside of drivers?
Quoted 6 lines
Quoted 5 lines
v2: squashed together patch 4 and 5
v3: only restore pcie speed on machines with runpm
add NvRunpmWorkaround config option to disable the workaround
v4: only run the code on suspend
always put the card into 8.0 mode, not what nouveau detected on loadWhy this change?
modprobe nouveau
rmmod nouveau
modprobe nouveau (saved 2.5 as the "boot" speed)
runpm breaks.
Mainly I don't actually want to depend on the initial state as we lower to 2.5/5.0 depending on what we queried is possible and not using 2.5 is actually the fix, not use whatever the GPU booted with.
Quoted 4 lines
Also, I know we don't currently touch it, but what
if x16 isn't available on some systems and we break stuff when we do start playing with link width?
I think if we add code for the width, we would add a maximum width detection as well as we do for the link speed.
Quoted 153 lines
Quoted 153 lines
Signed-off-by Karol Herbst <[email protected]>Reviewed-by Lyude Paul <[email protected]> (v2)--- drm/nouveau/include/nvkm/core/device.h | 2 ++ drm/nouveau/include/nvkm/subdev/pci.h | 3 ++- drm/nouveau/nouveau_drm.c | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/pci/base.c | 2 ++ drm/nouveau/nvkm/subdev/pci/pcie.c | 27 ++++++++++++++++++++++---- drm/nouveau/nvkm/subdev/pci/priv.h | 1 + 7 files changed, 32 insertions(+), 6 deletions(-)drm/nouveau/include/nvkm/core/device.h +2
-0@@ -125,6 +125,8 @@ struct nvkm_device {u8 chiprev;u32 crystal; +bool has_runpm; +struct {struct notifier_block nb; } acpi;drm/nouveau/include/nvkm/subdev/pci.h +2
-1@@ -52,6 +52,7 @@ int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);int gp100_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);/* pcie functions */ -int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width, +bool save);enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif drm/nouveau/nouveau_drm.c +1
-0@@ -676,6 +676,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,if (nouveau_atomic) driver_pci.driver_features |=DRIVER_ATOMIC ; + device->has_runpm =nouveau_pmops_runtime (); drm_dev =drm_dev_alloc (&driver_pci, &pdev->dev);if (IS_ERR (drm_dev)) {drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -277,7 +277,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)nvkm_debug (subdev,"setting performance state %d\n" , pstatei); clk->pstate = pstatei; -nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width); +nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width, true);if (fb && fb->ram && fb->ram->func->calc) {struct nvkm_ram *ram = fb->ram;drm/nouveau/nvkm/subdev/pci/base.c +2
-0@@ -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, suspend);return 0 ; }drm/nouveau/nvkm/subdev/pci/pcie.c +23
-4@@ -23,6 +23,8 @@*/ #include "priv.h" +#include <core/option.h> +static char *nvkm_pcie_speeds[] = {"2.5GT/s" ,"5.0GT/s" ,@@ -106,11 +108,25 @@ nvkm_pcie_init(struct nvkm_pci *pci) pci->func->pcie.init (pci);if (pci->pcie.speed !=-1 ) -nvkm_pcie_set_link (pci, pci->pcie.speed, pci->pcie.width); +nvkm_pcie_set_link (pci, pci->pcie.speed, + pci->pcie.width, false);return 0 ; } +int +nvkm_pcie_fini (struct nvkm_pci *pci,bool suspend) +{ +struct nvkm_device *device = pci->subdev.device; +if (!device->has_runpm || !suspend) +return 0 ; + +if (!nvkm_boolopt (device->cfgopt,"NvRunpmWorkaround" , true)) +return 0 ; + +return nvkm_pcie_set_link (pci,NVKM_PCIE_SPEED_8_0 ,16 , false); +} +void nvkm_pcie_force_aspm_off (struct nvkm_pci *pci,bool status) {@@ -120,7 +136,8 @@ nvkm_pcie_force_aspm_off(struct nvkm_pci *pci, bool status) }int -nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width) +nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width, +bool save) {struct nvkm_subdev *subdev = &pci->subdev;enum nvkm_pcie_speed cur_speed, max_speed;@@ -154,8 +171,10 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width) speed = max_speed; } - pci->pcie.speed = speed; - pci->pcie.width = width; +if (save) { + pci->pcie.speed = speed; + pci->pcie.width = width; + }if (speed == cur_speed) {nvkm_debug (subdev,"requested matches current speed\n" );drm/nouveau/nvkm/subdev/pci/priv.h +1
-1@@ -63,4 +63,5 @@ int gk104_pcie_version_supported(struct nvkm_pci *);int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *); +int nvkm_pcie_fini (struct nvkm_pci *,bool suspend);#endif --2.21.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CACO55tsU1hHz=KxP392vkJ8NZRtY5cGx+t51jOVwTNdftHyUzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v4 3/4] pci: set the pcie link speed to 8.0 when suspending
Quoted 17 lines · Karol Herbst
Quoted 15 lines · Ben Skeggs
Quoted 13 lines · Karol Herbst
Apperantly things go south if we suspend the device with a PCIe link speed set to 2.5. Fixes runtime suspend on my gp107.
This all looks like some bug inside the pci subsystem and I would prefer a fix there instead of nouveau, but maybe there is no real nice way of doing that outside of drivers?
v2: squashed together patch 4 and 5
v3: only restore pcie speed on machines with runpm
add NvRunpmWorkaround config option to disable the workaround
v4: only run the code on suspend
always put the card into 8.0 mode, not what nouveau detected on load
Quoted 6 lines
Quoted 1 line
Why this change?
modprobe nouveau
rmmod nouveau
modprobe nouveau (saved 2.5 as the "boot" speed)
runpm breaks.
Given that this is more than likely a hack/workaround for another issue to begin with, that isn't the end of the world.
Quoted 4 lines
Mainly I don't actually want to depend on the initial state as we lower to 2.5/5.0 depending on what we queried is possible and not using 2.5 is actually the fix, not use whatever the GPU booted with.
Is 8 available everywhere we're going to be using this?
Quoted 162 lines
Quoted 5 lines
Also, I know we don't currently touch it, but what
if x16 isn't available on some systems and we break stuff when we do start playing with link width?I think if we add code for the width, we would add a maximum width detection as well as we do for the link speed.
Quoted 153 lines
Quoted 153 lines
Signed-off-by Karol Herbst <[email protected]>Reviewed-by Lyude Paul <[email protected]> (v2)--- drm/nouveau/include/nvkm/core/device.h | 2 ++ drm/nouveau/include/nvkm/subdev/pci.h | 3 ++- drm/nouveau/nouveau_drm.c | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/pci/base.c | 2 ++ drm/nouveau/nvkm/subdev/pci/pcie.c | 27 ++++++++++++++++++++++---- drm/nouveau/nvkm/subdev/pci/priv.h | 1 + 7 files changed, 32 insertions(+), 6 deletions(-)drm/nouveau/include/nvkm/core/device.h +2
-0@@ -125,6 +125,8 @@ struct nvkm_device {u8 chiprev;u32 crystal; +bool has_runpm; +struct {struct notifier_block nb; } acpi;drm/nouveau/include/nvkm/subdev/pci.h +2
-1@@ -52,6 +52,7 @@ int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);int gp100_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);/* pcie functions */ -int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width, +bool save);enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif drm/nouveau/nouveau_drm.c +1
-0@@ -676,6 +676,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,if (nouveau_atomic) driver_pci.driver_features |=DRIVER_ATOMIC ; + device->has_runpm =nouveau_pmops_runtime (); drm_dev =drm_dev_alloc (&driver_pci, &pdev->dev);if (IS_ERR (drm_dev)) {drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -277,7 +277,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)nvkm_debug (subdev,"setting performance state %d\n" , pstatei); clk->pstate = pstatei; -nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width); +nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width, true);if (fb && fb->ram && fb->ram->func->calc) {struct nvkm_ram *ram = fb->ram;drm/nouveau/nvkm/subdev/pci/base.c +2
-0@@ -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, suspend);return 0 ; }drm/nouveau/nvkm/subdev/pci/pcie.c +23
-4@@ -23,6 +23,8 @@*/ #include "priv.h" +#include <core/option.h> +static char *nvkm_pcie_speeds[] = {"2.5GT/s" ,"5.0GT/s" ,@@ -106,11 +108,25 @@ nvkm_pcie_init(struct nvkm_pci *pci) pci->func->pcie.init (pci);if (pci->pcie.speed !=-1 ) -nvkm_pcie_set_link (pci, pci->pcie.speed, pci->pcie.width); +nvkm_pcie_set_link (pci, pci->pcie.speed, + pci->pcie.width, false);return 0 ; } +int +nvkm_pcie_fini (struct nvkm_pci *pci,bool suspend) +{ +struct nvkm_device *device = pci->subdev.device; +if (!device->has_runpm || !suspend) +return 0 ; + +if (!nvkm_boolopt (device->cfgopt,"NvRunpmWorkaround" , true)) +return 0 ; + +return nvkm_pcie_set_link (pci,NVKM_PCIE_SPEED_8_0 ,16 , false); +} +void nvkm_pcie_force_aspm_off (struct nvkm_pci *pci,bool status) {@@ -120,7 +136,8 @@ nvkm_pcie_force_aspm_off(struct nvkm_pci *pci, bool status) }int -nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width) +nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width, +bool save) {struct nvkm_subdev *subdev = &pci->subdev;enum nvkm_pcie_speed cur_speed, max_speed;@@ -154,8 +171,10 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width) speed = max_speed; } - pci->pcie.speed = speed; - pci->pcie.width = width; +if (save) { + pci->pcie.speed = speed; + pci->pcie.width = width; + }if (speed == cur_speed) {nvkm_debug (subdev,"requested matches current speed\n" );drm/nouveau/nvkm/subdev/pci/priv.h +1
-1@@ -63,4 +63,5 @@ int gk104_pcie_version_supported(struct nvkm_pci *);int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *); +int nvkm_pcie_fini (struct nvkm_pci *,bool suspend);#endif --2.21.0
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CACAvsv7a2O8Z1A6czhr6-eTUy0qa5n6Xen4atzrbTEZAq0mkTg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v4 3/4] pci: set the pcie link speed to 8.0 when suspending
Quoted 25 lines · Ben Skeggs
Quoted 17 lines · Karol Herbst
Quoted 15 lines · Ben Skeggs
Quoted 13 lines · Karol Herbst
Apperantly things go south if we suspend the device with a PCIe link speed set to 2.5. Fixes runtime suspend on my gp107.
This all looks like some bug inside the pci subsystem and I would prefer a fix there instead of nouveau, but maybe there is no real nice way of doing that outside of drivers?
v2: squashed together patch 4 and 5
v3: only restore pcie speed on machines with runpm
add NvRunpmWorkaround config option to disable the workaround
v4: only run the code on suspend
always put the card into 8.0 mode, not what nouveau detected on loadQuoted 6 lines
Quoted 1 line
Why this change?
modprobe nouveau
rmmod nouveau
modprobe nouveau (saved 2.5 as the "boot" speed)
runpm breaks.
Quoted 9 lines
Given that this is more than likely a hack/workaround for another issue to begin with, that isn't the end of the world.
Quoted 4 lines
Mainly I don't actually want to depend on the initial state as we lower to 2.5/5.0 depending on what we queried is possible and not using 2.5 is actually the fix, not use whatever the GPU booted with.
Is 8 available everywhere we're going to be using this?
nouveau fallsback to a lower speed if the requested one is not available. We have to do this detection for pstates anyway, where the vbios requests 8.0, but the system can only do 5.0 or 2.5
Quoted 162 lines
Quoted 162 lines
Quoted 5 lines
Also, I know we don't currently touch it, but what
if x16 isn't available on some systems and we break stuff when we do start playing with link width?I think if we add code for the width, we would add a maximum width detection as well as we do for the link speed.
Quoted 153 lines
Quoted 153 lines
Signed-off-by Karol Herbst <[email protected]>Reviewed-by Lyude Paul <[email protected]> (v2)--- drm/nouveau/include/nvkm/core/device.h | 2 ++ drm/nouveau/include/nvkm/subdev/pci.h | 3 ++- drm/nouveau/nouveau_drm.c | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/pci/base.c | 2 ++ drm/nouveau/nvkm/subdev/pci/pcie.c | 27 ++++++++++++++++++++++---- drm/nouveau/nvkm/subdev/pci/priv.h | 1 + 7 files changed, 32 insertions(+), 6 deletions(-)drm/nouveau/include/nvkm/core/device.h +2
-0@@ -125,6 +125,8 @@ struct nvkm_device {u8 chiprev;u32 crystal; +bool has_runpm; +struct {struct notifier_block nb; } acpi;drm/nouveau/include/nvkm/subdev/pci.h +2
-1@@ -52,6 +52,7 @@ int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);int gp100_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);/* pcie functions */ -int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width, +bool save);enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif drm/nouveau/nouveau_drm.c +1
-0@@ -676,6 +676,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,if (nouveau_atomic) driver_pci.driver_features |=DRIVER_ATOMIC ; + device->has_runpm =nouveau_pmops_runtime (); drm_dev =drm_dev_alloc (&driver_pci, &pdev->dev);if (IS_ERR (drm_dev)) {drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -277,7 +277,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)nvkm_debug (subdev,"setting performance state %d\n" , pstatei); clk->pstate = pstatei; -nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width); +nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width, true);if (fb && fb->ram && fb->ram->func->calc) {struct nvkm_ram *ram = fb->ram;drm/nouveau/nvkm/subdev/pci/base.c +2
-0@@ -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, suspend);return 0 ; }drm/nouveau/nvkm/subdev/pci/pcie.c +23
-4@@ -23,6 +23,8 @@*/ #include "priv.h" +#include <core/option.h> +static char *nvkm_pcie_speeds[] = {"2.5GT/s" ,"5.0GT/s" ,@@ -106,11 +108,25 @@ nvkm_pcie_init(struct nvkm_pci *pci) pci->func->pcie.init (pci);if (pci->pcie.speed !=-1 ) -nvkm_pcie_set_link (pci, pci->pcie.speed, pci->pcie.width); +nvkm_pcie_set_link (pci, pci->pcie.speed, + pci->pcie.width, false);return 0 ; } +int +nvkm_pcie_fini (struct nvkm_pci *pci,bool suspend) +{ +struct nvkm_device *device = pci->subdev.device; +if (!device->has_runpm || !suspend) +return 0 ; + +if (!nvkm_boolopt (device->cfgopt,"NvRunpmWorkaround" , true)) +return 0 ; + +return nvkm_pcie_set_link (pci,NVKM_PCIE_SPEED_8_0 ,16 , false); +} +void nvkm_pcie_force_aspm_off (struct nvkm_pci *pci,bool status) {@@ -120,7 +136,8 @@ nvkm_pcie_force_aspm_off(struct nvkm_pci *pci, bool status) }int -nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width) +nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width, +bool save) {struct nvkm_subdev *subdev = &pci->subdev;enum nvkm_pcie_speed cur_speed, max_speed;@@ -154,8 +171,10 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width) speed = max_speed; } - pci->pcie.speed = speed; - pci->pcie.width = width; +if (save) { + pci->pcie.speed = speed; + pci->pcie.width = width; + }if (speed == cur_speed) {nvkm_debug (subdev,"requested matches current speed\n" );drm/nouveau/nvkm/subdev/pci/priv.h +1
-1@@ -63,4 +63,5 @@ int gk104_pcie_version_supported(struct nvkm_pci *);int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *); +int nvkm_pcie_fini (struct nvkm_pci *,bool suspend);#endif --2.21.0
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CACO55tsRU4cj37S9vt3RK_3+kv49P9v+daoZhn1=68hD_ecarg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v4 3/4] pci: set the pcie link speed to 8.0 when suspending
Quoted 34 lines · Karol Herbst
Quoted 32 lines · Ben Skeggs
Quoted 17 lines · Karol Herbst
Quoted 15 lines · Ben Skeggs
Quoted 13 lines · Karol Herbst
Apperantly things go south if we suspend the device with a PCIe link speed set to 2.5. Fixes runtime suspend on my gp107.
This all looks like some bug inside the pci subsystem and I would prefer a fix there instead of nouveau, but maybe there is no real nice way of doing that outside of drivers?
v2: squashed together patch 4 and 5
v3: only restore pcie speed on machines with runpm
add NvRunpmWorkaround config option to disable the workaround
v4: only run the code on suspend
always put the card into 8.0 mode, not what nouveau detected on loadQuoted 6 lines
Quoted 1 line
Why this change?
modprobe nouveau
rmmod nouveau
modprobe nouveau (saved 2.5 as the "boot" speed)
runpm breaks.Given that this is more than likely a hack/workaround for another issue to begin with, that isn't the end of the world.
Quoted 4 lines
Mainly I don't actually want to depend on the initial state as we lower to 2.5/5.0 depending on what we queried is possible and not using 2.5 is actually the fix, not use whatever the GPU booted with.
Quoted 6 lines
Quoted 2 lines
Is 8 available everywhere we're going to be using this?
nouveau fallsback to a lower speed if the requested one is not available. We have to do this detection for pstates anyway, where the vbios requests 8.0, but the system can only do 5.0 or 2.5
Ack. I guess I'm OK with this then. I wouldn't mind a comment in fini() before the call, explaining why we're actually doing this so the rationale doesn't get lost in history at some point.
Quoted 163 lines
Quoted 163 lines
Quoted 163 lines
Quoted 6 lines
Also, I know we don't currently touch it, but what
if x16 isn't available on some systems and we break stuff when we do start playing with link width?I think if we add code for the width, we would add a maximum width detection as well as we do for the link speed.
Quoted 153 lines
Quoted 153 lines
Signed-off-by Karol Herbst <[email protected]>Reviewed-by Lyude Paul <[email protected]> (v2)--- drm/nouveau/include/nvkm/core/device.h | 2 ++ drm/nouveau/include/nvkm/subdev/pci.h | 3 ++- drm/nouveau/nouveau_drm.c | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/pci/base.c | 2 ++ drm/nouveau/nvkm/subdev/pci/pcie.c | 27 ++++++++++++++++++++++---- drm/nouveau/nvkm/subdev/pci/priv.h | 1 + 7 files changed, 32 insertions(+), 6 deletions(-)drm/nouveau/include/nvkm/core/device.h +2
-0@@ -125,6 +125,8 @@ struct nvkm_device {u8 chiprev;u32 crystal; +bool has_runpm; +struct {struct notifier_block nb; } acpi;drm/nouveau/include/nvkm/subdev/pci.h +2
-1@@ -52,6 +52,7 @@ int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);int gp100_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);/* pcie functions */ -int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width, +bool save);enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif drm/nouveau/nouveau_drm.c +1
-0@@ -676,6 +676,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,if (nouveau_atomic) driver_pci.driver_features |=DRIVER_ATOMIC ; + device->has_runpm =nouveau_pmops_runtime (); drm_dev =drm_dev_alloc (&driver_pci, &pdev->dev);if (IS_ERR (drm_dev)) {drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -277,7 +277,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)nvkm_debug (subdev,"setting performance state %d\n" , pstatei); clk->pstate = pstatei; -nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width); +nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width, true);if (fb && fb->ram && fb->ram->func->calc) {struct nvkm_ram *ram = fb->ram;drm/nouveau/nvkm/subdev/pci/base.c +2
-0@@ -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, suspend);return 0 ; }drm/nouveau/nvkm/subdev/pci/pcie.c +23
-4@@ -23,6 +23,8 @@*/ #include "priv.h" +#include <core/option.h> +static char *nvkm_pcie_speeds[] = {"2.5GT/s" ,"5.0GT/s" ,@@ -106,11 +108,25 @@ nvkm_pcie_init(struct nvkm_pci *pci) pci->func->pcie.init (pci);if (pci->pcie.speed !=-1 ) -nvkm_pcie_set_link (pci, pci->pcie.speed, pci->pcie.width); +nvkm_pcie_set_link (pci, pci->pcie.speed, + pci->pcie.width, false);return 0 ; } +int +nvkm_pcie_fini (struct nvkm_pci *pci,bool suspend) +{ +struct nvkm_device *device = pci->subdev.device; +if (!device->has_runpm || !suspend) +return 0 ; + +if (!nvkm_boolopt (device->cfgopt,"NvRunpmWorkaround" , true)) +return 0 ; + +return nvkm_pcie_set_link (pci,NVKM_PCIE_SPEED_8_0 ,16 , false); +} +void nvkm_pcie_force_aspm_off (struct nvkm_pci *pci,bool status) {@@ -120,7 +136,8 @@ nvkm_pcie_force_aspm_off(struct nvkm_pci *pci, bool status) }int -nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width) +nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width, +bool save) {struct nvkm_subdev *subdev = &pci->subdev;enum nvkm_pcie_speed cur_speed, max_speed;@@ -154,8 +171,10 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width) speed = max_speed; } - pci->pcie.speed = speed; - pci->pcie.width = width; +if (save) { + pci->pcie.speed = speed; + pci->pcie.width = width; + }if (speed == cur_speed) {nvkm_debug (subdev,"requested matches current speed\n" );drm/nouveau/nvkm/subdev/pci/priv.h +1
-1@@ -63,4 +63,5 @@ int gk104_pcie_version_supported(struct nvkm_pci *);int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *); +int nvkm_pcie_fini (struct nvkm_pci *,bool suspend);#endif --2.21.0
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Lyude Paul
Reviewed-byRe: [PATCH v4 3/4] pci: set the pcie link speed to 8.0 when suspending
In reply to a message not in the archiveQuoted 31 lines · Karol Herbst
Apperantly things go south if we suspend the device with a PCIe link speed set to 2.5. Fixes runtime suspend on my gp107.
This all looks like some bug inside the pci subsystem and I would prefer a fix there instead of nouveau, but maybe there is no real nice way of doing that outside of drivers?
v2: squashed together patch 4 and 5
v3: only restore pcie speed on machines with runpm
add NvRunpmWorkaround config option to disable the workaround
v4: only run the code on suspend
always put the card into 8.0 mode, not what nouveau detected on loadSigned-off-by Karol Herbst <[email protected]>Reviewed-by Lyude Paul <[email protected]> (v2)--- drm/nouveau/include/nvkm/core/device.h | 2 ++ drm/nouveau/include/nvkm/subdev/pci.h | 3 ++- drm/nouveau/nouveau_drm.c | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/pci/base.c | 2 ++ drm/nouveau/nvkm/subdev/pci/pcie.c | 27 ++++++++++++++++++++++---- drm/nouveau/nvkm/subdev/pci/priv.h | 1 + 7 files changed, 32 insertions(+), 6 deletions(-)drm/nouveau/include/nvkm/core/device.h +0
-0
drm/nouveau/include/nvkm/core/device.h struct nvkm_device { · line 129
Quoted 5 lines
drm/nouveau/include/nvkm/core/device.h +2
-0@@ -125,6 +125,8 @@ struct nvkm_device {u8 chiprev;u32 crystal; +bool has_runpm; +
This could be a bitfield, up to you. Other then that:
Quoted 137 lines
drm/nouveau/include/nvkm/core/device.h +0
-0struct {struct notifier_block nb; } acpi;drm/nouveau/include/nvkm/subdev/pci.h +2
-1@@ -52,6 +52,7 @@ int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);int gp100_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);/* pcie functions */ -int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width); +int nvkm_pcie_set_link (struct nvkm_pci *,enum nvkm_pcie_speed ,u8 width, +bool save);enum nvkm_pcie_speed nvkm_pcie_get_speed (struct nvkm_pci *);#endif
drm/nouveau/nouveau_drm.c +1
-0@@ -676,6 +676,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,if (nouveau_atomic) driver_pci.driver_features |=DRIVER_ATOMIC ; + device->has_runpm =nouveau_pmops_runtime (); drm_dev =drm_dev_alloc (&driver_pci, &pdev->dev);if (IS_ERR (drm_dev)) {drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -277,7 +277,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)nvkm_debug (subdev,"setting performance state %d\n" , pstatei); clk->pstate = pstatei; -nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width); +nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width, true);if (fb && fb->ram && fb->ram->func->calc) {struct nvkm_ram *ram = fb->ram;drm/nouveau/nvkm/subdev/pci/base.c +2
-0@@ -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, suspend);return 0 ; }drm/nouveau/nvkm/subdev/pci/pcie.c +19
-2@@ -23,6 +23,8 @@*/ #include "priv.h" +#include <core/option.h> +static char *nvkm_pcie_speeds[] = {"2.5GT/s" ,"5.0GT/s" ,@@ -106,11 +108,25 @@ nvkm_pcie_init(struct nvkm_pci *pci) pci->func->pcie.init (pci);if (pci->pcie.speed !=-1 ) -nvkm_pcie_set_link (pci, pci->pcie.speed, pci->pcie.width); +nvkm_pcie_set_link (pci, pci->pcie.speed, + pci->pcie.width, false);return 0 ; } +int +nvkm_pcie_fini (struct nvkm_pci *pci,bool suspend) +{ +struct nvkm_device *device = pci->subdev.device; +if (!device->has_runpm || !suspend) +return 0 ; + +if (!nvkm_boolopt (device->cfgopt,"NvRunpmWorkaround" , true)) +return 0 ; + +return nvkm_pcie_set_link (pci,NVKM_PCIE_SPEED_8_0 ,16 , false); +} +void nvkm_pcie_force_aspm_off (struct nvkm_pci *pci,bool status) {@@ -120,7 +136,8 @@ nvkm_pcie_force_aspm_off(struct nvkm_pci *pci, bool status) }int -nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width) +nvkm_pcie_set_link (struct nvkm_pci *pci,enum nvkm_pcie_speed speed,u8 width, +bool save){
drm/nouveau/nvkm/subdev/pci/pcie.c +4
-2struct nvkm_subdev *subdev = &pci->subdev;enum nvkm_pcie_speed cur_speed, max_speed;@@ -154,8 +171,10 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width) speed = max_speed; } - pci->pcie.speed = speed; - pci->pcie.width = width; +if (save) { + pci->pcie.speed = speed; + pci->pcie.width = width; + }if (speed == cur_speed) {drm/nouveau/nvkm/subdev/pci/pcie.c +0
-0nvkm_debug (subdev,"requested matches current speed\n" );drm/nouveau/nvkm/subdev/pci/priv.h +1
-0@@ -63,4 +63,5 @@ int gk104_pcie_version_supported(struct nvkm_pci *);int nvkm_pcie_oneinit (struct nvkm_pci *);int nvkm_pcie_init (struct nvkm_pci *); +int nvkm_pcie_fini (struct nvkm_pci *,bool suspend);#endif
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH v4 4/4 drm: abort runtime suspend if we hit an error
In reply to a message not in the archive--- drm/nouveau/nouveau_drm.c | 5 +++++ 1 file changed, 5 insertions(+)
drm/nouveau/nouveau_drm.c +5 -0
@@ -911,6 +911,7 @@ nouveau_pmops_runtime_suspend(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct nouveau_drm *drm =nouveau_drm (drm_dev);int ret;if (!nouveau_pmops_runtime ()) {
@@ -920,6 +921,10 @@ nouveau_pmops_runtime_suspend(struct device *dev)nouveau_switcheroo_optimus_dsm (); ret =nouveau_do_suspend (drm_dev, true); +if (ret) { +NV_ERROR (drm,"suspend failed with: %d\n" , ret); +return ret; + }pci_save_state (pdev);pci_disable_device (pdev);pci_ignore_hotplug (pdev);
Signature · 6 lines
2.21.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau