Skip to contentSkip to conversation

Refuse to load if power cables are not connected

PATCH Superseded Mark Menzynski 3 participants 8 messages Jul 15, 2019 – Jul 16, 2019 4 messages not in the archive

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Refuse to load if power cables are not connected

Trello:
https://trello.com/c/admzDRvd/50-reduce-performance-refuse-to-boot-if-not-all-the-power-connectors-are-plugged

Fixed commit messages.

Mark Menzynski (4):
bios/gpio: sort gpios by values
gpio: fail if gpu external power is missing
gpio: check the gpio function 16 in the power check as well
gpio: check function 76 in the power check as well

 drm/nouveau/include/nvkm/subdev/bios/gpio.h |  5 ++++-
 drm/nouveau/nvkm/subdev/gpio/base.c         | 25 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
Signature · 6 lines
2.21.0

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#2 lore raw

PATCH v2 1/4 bios/gpio: sort gpios by values

In reply to a message not in the archive

One gpio was in wrong place, moved it for better readability.

---
 drm/nouveau/include/nvkm/subdev/bios/gpio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drm/nouveau/include/nvkm/subdev/bios/gpio.h +1 -1
index b71a3555..2f40935f 100644
@@ -3,9 +3,9 @@
 #define __NVBIOS_GPIO_H__
 enum dcb_gpio_func_name {
 	DCB_GPIO_PANEL_POWER = 0x01,
+	DCB_GPIO_FAN = 0x09,
 	DCB_GPIO_TVDAC0 = 0x0c,
 	DCB_GPIO_TVDAC1 = 0x2d,
-	DCB_GPIO_FAN = 0x09,
 	DCB_GPIO_FAN_SENSE = 0x3d,
 	DCB_GPIO_LOGO_LED_PWM = 0x84,
 	DCB_GPIO_UNUSED = 0xff,
Signature · 6 lines
2.21.0

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#3 lore raw

PATCH v2 2/4 gpio: fail if gpu external power is missing

In reply to a message not in the archive

Currently, nouveau doesn't check if GPU is missing power. This patch makes nouveau fail when this happens on latest GPUs.

It checks GPIO function 121 (External Power Emergency), which should detect power problems on GPU initialization.

Tested on TU104, GP106 and GF100.

---
 drm/nouveau/include/nvkm/subdev/bios/gpio.h |  1 +
 drm/nouveau/nvkm/subdev/gpio/base.c         | 23 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
drm/nouveau/include/nvkm/subdev/bios/gpio.h +1 -0
index 2f40935f..a70ec9e8 100644
@@ -7,6 +7,7 @@ enum dcb_gpio_func_name {
 	DCB_GPIO_TVDAC0 = 0x0c,
 	DCB_GPIO_TVDAC1 = 0x2d,
 	DCB_GPIO_FAN_SENSE = 0x3d,
+	DCB_GPIO_EXT_POWER_LOW = 0x79,
 	DCB_GPIO_LOGO_LED_PWM = 0x84,
 	DCB_GPIO_UNUSED = 0xff,
 	DCB_GPIO_VID0 = 0x04,
drm/nouveau/nvkm/subdev/gpio/base.c +23 -0
index 1399d923..c4685807 100644
@@ -182,12 +182,35 @@ static const struct dmi_system_id gpio_reset_ids[] = {
 	{ }
 };
 
+static enum dcb_gpio_func_name power_checks[] = {
+	DCB_GPIO_EXT_POWER_LOW,
+};
+
 static int
 nvkm_gpio_init(struct nvkm_subdev *subdev)
 {
 	struct nvkm_gpio *gpio = nvkm_gpio(subdev);
+	struct dcb_gpio_func func;
+	int ret;
+	int i;
+
 	if (dmi_check_system(gpio_reset_ids))
 		nvkm_gpio_reset(gpio, DCB_GPIO_UNUSED);
+
+	for (i = 0; i < ARRAY_SIZE(power_checks); ++i) {
+		ret = nvkm_gpio_find(gpio, 0, power_checks[i], DCB_GPIO_UNUSED,
+				     &func);
+		if (ret)
+			continue;
+
+		ret = nvkm_gpio_get(gpio, 0, func.func, func.line);
+		if (ret) {
+			nvkm_error(&gpio->subdev,
+				   "not enough power, check GPU power cable\n");
+			return -EINVAL;
+		}
+	}
+
 	return 0;
 }
 
Signature · 6 lines
2.21.0

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#10 lore raw

PATCH v2 3/4 gpio: check the gpio function 16 in the power check as well

In reply to a message not in the archive

Added GPIO is "Thermal and External Power Detect". It's uncertain if this GPIO is set on GPU initialization or only if a change is detected by the GPU at runtime.

This GPIO can be found in Rankine and Curie and rarely on Tesla GPUs VBIOS.

Untested, wrote according to documentation.

---
 drm/nouveau/include/nvkm/subdev/bios/gpio.h | 1 +
 drm/nouveau/nvkm/subdev/gpio/base.c         | 1 +
 2 files changed, 2 insertions(+)
drm/nouveau/include/nvkm/subdev/bios/gpio.h +1 -0
index a70ec9e8..fc2b5fb0 100644
@@ -5,6 +5,7 @@ enum dcb_gpio_func_name {
 	DCB_GPIO_PANEL_POWER = 0x01,
 	DCB_GPIO_FAN = 0x09,
 	DCB_GPIO_TVDAC0 = 0x0c,
+	DCB_GPIO_THERM_EXT_POWER_EVENT = 0x10,
 	DCB_GPIO_TVDAC1 = 0x2d,
 	DCB_GPIO_FAN_SENSE = 0x3d,
 	DCB_GPIO_EXT_POWER_LOW = 0x79,
drm/nouveau/nvkm/subdev/gpio/base.c +1 -0
index c4685807..0c886543 100644
@@ -183,6 +183,7 @@ static const struct dmi_system_id gpio_reset_ids[] = {
 };
 
 static enum dcb_gpio_func_name power_checks[] = {
+	DCB_GPIO_THERM_EXT_POWER_EVENT,
 	DCB_GPIO_EXT_POWER_LOW,
 };
 
Signature · 6 lines
2.21.0

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#11 lore raw

PATCH v2 4/4 gpio: check function 76 in the power check as well

In reply to a message not in the archive

Added GPIO is "Power Alert". It's uncertain if this
GPIO is set on GPU initialization or only if a change is detected by the GPU at runtime.

This GPIO can be found on Tesla and sometimes on Fermi GPUs.

Untested, wrote according to documentation.

---
 drm/nouveau/include/nvkm/subdev/bios/gpio.h | 1 +
 drm/nouveau/nvkm/subdev/gpio/base.c         | 1 +
 2 files changed, 2 insertions(+)
drm/nouveau/include/nvkm/subdev/bios/gpio.h +1 -0
index fc2b5fb0..784c5f22 100644
@@ -8,6 +8,7 @@ enum dcb_gpio_func_name {
 	DCB_GPIO_THERM_EXT_POWER_EVENT = 0x10,
 	DCB_GPIO_TVDAC1 = 0x2d,
 	DCB_GPIO_FAN_SENSE = 0x3d,
+	DCB_GPIO_POWER_ALERT = 0x4c,
 	DCB_GPIO_EXT_POWER_LOW = 0x79,
 	DCB_GPIO_LOGO_LED_PWM = 0x84,
 	DCB_GPIO_UNUSED = 0xff,
drm/nouveau/nvkm/subdev/gpio/base.c +1 -0
index 0c886543..755f016f 100644
@@ -184,6 +184,7 @@ static const struct dmi_system_id gpio_reset_ids[] = {
 
 static enum dcb_gpio_func_name power_checks[] = {
 	DCB_GPIO_THERM_EXT_POWER_EVENT,
+	DCB_GPIO_POWER_ALERT,
 	DCB_GPIO_EXT_POWER_LOW,
 };
 
Signature · 6 lines
2.21.0

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#5 lore raw

Re: [PATCH v2 2/4] gpio: fail if gpu external power is missing

In reply to a message not in the archive

Please add a config override to skip this, since we'll invariably get it wrong for some setup, and should be able to provide users with workarounds while the issue is being worked out.

Quoted 70 lines · Mark Menzynski

Currently, nouveau doesn't check if GPU is missing power. This patch makes nouveau fail when this happens on latest GPUs.

It checks GPIO function 121 (External Power Emergency), which should detect power problems on GPU initialization.

Tested on TU104, GP106 and GF100.

---
 drm/nouveau/include/nvkm/subdev/bios/gpio.h |  1 +
 drm/nouveau/nvkm/subdev/gpio/base.c         | 23 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
drm/nouveau/include/nvkm/subdev/bios/gpio.h +1 -0
index 2f40935f..a70ec9e8 100644
@@ -7,6 +7,7 @@ enum dcb_gpio_func_name {
        DCB_GPIO_TVDAC0 = 0x0c,
        DCB_GPIO_TVDAC1 = 0x2d,
        DCB_GPIO_FAN_SENSE = 0x3d,
+       DCB_GPIO_EXT_POWER_LOW = 0x79,
        DCB_GPIO_LOGO_LED_PWM = 0x84,
        DCB_GPIO_UNUSED = 0xff,
        DCB_GPIO_VID0 = 0x04,
drm/nouveau/nvkm/subdev/gpio/base.c +23 -1
index 1399d923..c4685807 100644
@@ -182,12 +182,35 @@ static const struct dmi_system_id gpio_reset_ids[] = {
        { }
 };
 
+static enum dcb_gpio_func_name power_checks[] = {
+       DCB_GPIO_EXT_POWER_LOW,
+};
+
 static int
 nvkm_gpio_init(struct nvkm_subdev *subdev)
 {
        struct nvkm_gpio *gpio = nvkm_gpio(subdev);
+       struct dcb_gpio_func func;
+       int ret;
+       int i;
+
        if (dmi_check_system(gpio_reset_ids))
                nvkm_gpio_reset(gpio, DCB_GPIO_UNUSED);
+
+       for (i = 0; i < ARRAY_SIZE(power_checks); ++i) {
+               ret = nvkm_gpio_find(gpio, 0, power_checks[i], DCB_GPIO_UNUSED,
+                                    &func);
+               if (ret)
+                       continue;
+
+               ret = nvkm_gpio_get(gpio, 0, func.func, func.line);
+               if (ret) {
+                       nvkm_error(&gpio->subdev,
+                                  "not enough power, check GPU power cable\n");
+                       return -EINVAL;
+               }
+       }
+
        return 0;
 }
 
--

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

#7 lore raw

Re: [PATCH v2 2/4] gpio: fail if gpu external power is missing

In reply to a message not in the archive
Quoted 4 lines · Ilia Mirkin

Please add a config override to skip this, since we'll invariably get it wrong for some setup, and should be able to provide users with workarounds while the issue is being worked out.

Yeah, this makes me nervous as well. In the very least, I'd like a config option, but I'm still wondering if perhaps we shouldn't limit this to a warning (which people tend to report) for a while first too.

Also, what's NV's behaviour here? Do they refuse to load, or do they do something like force the GPU into its lowest pstate?

Ben.

Quoted 72 lines · Mark Menzynski
Quoted 70 lines

Currently, nouveau doesn't check if GPU is missing power. This patch makes nouveau fail when this happens on latest GPUs.

It checks GPIO function 121 (External Power Emergency), which should detect power problems on GPU initialization.

Tested on TU104, GP106 and GF100.

---
 drm/nouveau/include/nvkm/subdev/bios/gpio.h |  1 +
 drm/nouveau/nvkm/subdev/gpio/base.c         | 23 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
drm/nouveau/include/nvkm/subdev/bios/gpio.h +1 -0
index 2f40935f..a70ec9e8 100644
@@ -7,6 +7,7 @@ enum dcb_gpio_func_name {
        DCB_GPIO_TVDAC0 = 0x0c,
        DCB_GPIO_TVDAC1 = 0x2d,
        DCB_GPIO_FAN_SENSE = 0x3d,
+       DCB_GPIO_EXT_POWER_LOW = 0x79,
        DCB_GPIO_LOGO_LED_PWM = 0x84,
        DCB_GPIO_UNUSED = 0xff,
        DCB_GPIO_VID0 = 0x04,
drm/nouveau/nvkm/subdev/gpio/base.c +23 -1
index 1399d923..c4685807 100644
@@ -182,12 +182,35 @@ static const struct dmi_system_id gpio_reset_ids[] = {
        { }
 };
 
+static enum dcb_gpio_func_name power_checks[] = {
+       DCB_GPIO_EXT_POWER_LOW,
+};
+
 static int
 nvkm_gpio_init(struct nvkm_subdev *subdev)
 {
        struct nvkm_gpio *gpio = nvkm_gpio(subdev);
+       struct dcb_gpio_func func;
+       int ret;
+       int i;
+
        if (dmi_check_system(gpio_reset_ids))
                nvkm_gpio_reset(gpio, DCB_GPIO_UNUSED);
+
+       for (i = 0; i < ARRAY_SIZE(power_checks); ++i) {
+               ret = nvkm_gpio_find(gpio, 0, power_checks[i], DCB_GPIO_UNUSED,
+                                    &func);
+               if (ret)
+                       continue;
+
+               ret = nvkm_gpio_get(gpio, 0, func.func, func.line);
+               if (ret) {
+                       nvkm_error(&gpio->subdev,
+                                  "not enough power, check GPU power cable\n");
+                       return -EINVAL;
+               }
+       }
+
        return 0;
 }
 
--

2.21.0

Quoted 8 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

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#9 lore raw

Re: [PATCH v2 2/4] gpio: fail if gpu external power is missing

In reply to a message not in the archive

This is what Nvidia did after using nvidia-smi, which is not very far from what happens now with the patch.

kernel: nvidia-nvlink: Nvlink Core is being initialized, major device number 235
kernel: nvidia 0000:01:00.0: vgaarb: changed VGA decodes:
olddecodes=io+mem,decodes=none:owns=none
kernel: NVRM: loading NVIDIA UNIX x86_64 Kernel Module 430.34 Wed

Jun 26 12:19:48 CDT 2019

kernel: NVRM: GPU 0000:01:00.0: GPU does not have the necessary power cables connected.
kernel: NVRM: GPU 0000:01:00.0: RmInitAdapter failed! (0x25:0x1c:1133)
kernel: NVRM: GPU 0000:01:00.0: rm_init_adapter failed, device minor number 0

Also, when booting, POST refuses to boot if power cables are not connected, but there are scenarios where you don't boot with the Nvidia GPU.
I am not sure about limiting it to warning, it makes sense but I also think it should fail.

But I wanted to ask about the error messages. At this moment, this is current output:

[17383.042727] nouveau 0000:12:00.0: gpio: GPU is missing power, check
its power cables. Boot with nouveau.config=NvPowerChecks=0 to disable.
[17383.042728] nouveau 0000:12:00.0: gpio: init failed, -22
[17383.042986] nouveau 0000:12:00.0: init failed with -22
[17383.042987] nouveau: DRM-master:00000000:00000080: init failed with -22
[17383.042990] nouveau 0000:12:00.0: DRM-master: Device allocation failed: -22
[17383.043458] nouveau: probe of 0000:12:00.0 failed with error -22

Isn't it a wrong place to implement the checks? Maybe I should put it somewhere else?

Quoted 6 lines · Ben Skeggs
Quoted 4 lines · Ilia Mirkin

Please add a config override to skip this, since we'll invariably get it wrong for some setup, and should be able to provide users with workarounds while the issue is being worked out.

Quoted 89 lines

Yeah, this makes me nervous as well. In the very least, I'd like a config option, but I'm still wondering if perhaps we shouldn't limit this to a warning (which people tend to report) for a while first too.

Also, what's NV's behaviour here? Do they refuse to load, or do they do something like force the GPU into its lowest pstate?

Ben.

Quoted 80 lines · Mark Menzynski
Quoted 70 lines

Currently, nouveau doesn't check if GPU is missing power. This patch makes nouveau fail when this happens on latest GPUs.

It checks GPIO function 121 (External Power Emergency), which should detect power problems on GPU initialization.

Tested on TU104, GP106 and GF100.

---
 drm/nouveau/include/nvkm/subdev/bios/gpio.h |  1 +
 drm/nouveau/nvkm/subdev/gpio/base.c         | 23 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
drm/nouveau/include/nvkm/subdev/bios/gpio.h +1 -0
index 2f40935f..a70ec9e8 100644
@@ -7,6 +7,7 @@ enum dcb_gpio_func_name {
        DCB_GPIO_TVDAC0 = 0x0c,
        DCB_GPIO_TVDAC1 = 0x2d,
        DCB_GPIO_FAN_SENSE = 0x3d,
+       DCB_GPIO_EXT_POWER_LOW = 0x79,
        DCB_GPIO_LOGO_LED_PWM = 0x84,
        DCB_GPIO_UNUSED = 0xff,
        DCB_GPIO_VID0 = 0x04,
drm/nouveau/nvkm/subdev/gpio/base.c +23 -1
index 1399d923..c4685807 100644
@@ -182,12 +182,35 @@ static const struct dmi_system_id gpio_reset_ids[] = {
        { }
 };
 
+static enum dcb_gpio_func_name power_checks[] = {
+       DCB_GPIO_EXT_POWER_LOW,
+};
+
 static int
 nvkm_gpio_init(struct nvkm_subdev *subdev)
 {
        struct nvkm_gpio *gpio = nvkm_gpio(subdev);
+       struct dcb_gpio_func func;
+       int ret;
+       int i;
+
        if (dmi_check_system(gpio_reset_ids))
                nvkm_gpio_reset(gpio, DCB_GPIO_UNUSED);
+
+       for (i = 0; i < ARRAY_SIZE(power_checks); ++i) {
+               ret = nvkm_gpio_find(gpio, 0, power_checks[i], DCB_GPIO_UNUSED,
+                                    &func);
+               if (ret)
+                       continue;
+
+               ret = nvkm_gpio_get(gpio, 0, func.func, func.line);
+               if (ret) {
+                       nvkm_error(&gpio->subdev,
+                                  "not enough power, check GPU power cable\n");
+                       return -EINVAL;
+               }
+       }
+
        return 0;
 }
 
--

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

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau