Skip to contentSkip to conversation

Initial power management vbios parsing, voltage & clock setting to nouveau.

RFC In review Martin Peres 4 participants 7 messages Sep 15, 2010 – Sep 20, 2010 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 Initial power management vbios parsing, voltage & clock setting to nouveau.

Hi folks,

I've been messing with PM management for a few days and I've accumulated an interesting volume of code.

I am now interested in comments on the overall architecture. For example, in this patch, I implement a proposition on how to split nouveau_bios.c I would really like you to comment. I have also introduced nouveau_pm.[hc] along with vbios/vbios_pm.[ch].

Another thing I would be interested in is the vbios parsing testing.
At the moment, it should work from nv40 to at least nv96 but it has really been tested only on an nv86 and an nv96. I'm expecting a lot of bug report.

Power mode setting is _not recommended for anything other than dev testing_.
There is still work to be done:
- Clock & voltage: It needs testing.
- Memory timings: It is being REed by RSpliet (please help him, he should be able to provide directions).
- Fan control: I have no information on this.

Despite these lacks, you should be able to safely try to downclock your card though. That's good news for laptop users, isn't it?

Please acknowledge that this work is almost entirely based on others's RE work and documentation work. Xexaxo's work has been impressive. RSpliet is also to be thanked as he is working on getting memory timing support. Darktama has also done some nice RE, we'll see how to merge his work. My work here has just been to implement the docs.

On a side note, I would like to say I will be out for 5 days to the XDS 2010. So, if you have questions I should discuss with some devs there, feel free to ask.

Best regards,

Martin Peres (aka mupuf), an happy new nouveau dev

---- How to help for the vbios parsing ?----
Thanks for wanting to help :)

First, grab the patch I've joined to this mail. It should cleanly apply on nouveau's master branch. Compile, Install & Reboot.

$ cat /sys/class/drm/card0/device/pm_status
and compare the values to
# nvclock -i

If it differs, please follow the instructions here:
http://nouveau.freedesktop.org/wiki/PowerManagementDumps
If it works, then, you may want to try changing the clocks.

---- How to test clock/voltage setting ?----
Do not attempt anything if the vbios parsing is wrong, really. If it did work as intended, you can continue.

** Warning ** Do not try to upclock your card, nothing good will happen.
While playing with clocks, always check the
current temperature

First, kill X (for safety reasons).
Then look for the wanted mode by doing:

$ cat /sys/class/drm/card0/device/pm_mode

It should give you a result like:
--- PM Modes ---
0: core 169 MHz/shader 338 MHz/memory 100 MHz/1150 mV
*1: core 275 MHz/shader 550 MHz/memory 301 MHz/1150 mV
2: core 400 MHz/shader 800 MHz/memory 600 MHz/1200 mV

The * means it is the currently used mode (it may also not be detected).

In this example, you should only stay between mode 0 and 1. To set the wanted PM mode, please do so:

# echo 0 > /sys/class/drm/card0/device/pm_mode
The command above will change the mode to the first mode.

There is another file for voltage control at /sys/class/drm/card0/device/pm_voltage that works the exact same way as pm_mode.

The other sysfs entries (temperature related) should be useless to you as they are just here for future work).

You're done, have fun.

From 38aba214268ecd0263b2a49af0698d84f6a364e6 Mon Sep 17 00:00:00 2001
From: Martin Peres <[email protected]>
Date: Wed, 15 Sep 2010 12:59:00 +0200
Subject: [PATCH] Add initial power management vbios parsing, voltage & clock setting to nouveau.
It is not intented to be used by end-users (if it should be used at all),
this commit is meant for devs to check the actual work and comment on it.

So, you may wondering what I'm asking you. I simply ask you to check the code and see if you could improve this design.
Also, you can try:

$ cat /sys/class/drm/card0/device/pm_status
and comparing it to "# nvclock -i".
If it doesn't match, please provide us with power management dumps & kernel logs:
http://nouveau.freedesktop.org/wiki/PowerManagementDumps
If it does match, report your success story also :)

Known issues: As no memory timing parsing/get/set is implemented yet (RSPliet has been working on it but it is not complete yet), your card will likely hang if you upclock the memory. Lowering the clocks should work fine though:
echo 0 > /sys/class/drm/card0/device/pm_mode

WARNING: Use at your own risks. Please stop your machine after having fun with this and reboot it after a minute in order to flush everything in the card. Keep in mind how experimental it is ;)

Ack: Most of this work is based on xexaxo's documentation work and useful advices.

---
 drivers/gpu/drm/nouveau/Makefile         |    2 +-
 drivers/gpu/drm/nouveau/nouveau_bios.c   |   67 +++-
 drivers/gpu/drm/nouveau/nouveau_bios.h   |   41 ++
 drivers/gpu/drm/nouveau/nouveau_biosP.h  |   44 ++
 drivers/gpu/drm/nouveau/nouveau_drv.h    |    2 +
 drivers/gpu/drm/nouveau/nouveau_pm.c     |  677 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/nouveau/nouveau_pm.h     |    9 +
 drivers/gpu/drm/nouveau/nouveau_state.c  |    9 +
 drivers/gpu/drm/nouveau/vbios/vbios_pm.c |  358 ++++++++++++++++
 drivers/gpu/drm/nouveau/vbios/vbios_pm.h |   34 ++
 10 files changed, 1224 insertions(+), 19 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nouveau_biosP.h
 create mode 100644 drivers/gpu/drm/nouveau/nouveau_pm.c
 create mode 100644 drivers/gpu/drm/nouveau/nouveau_pm.h
 create mode 100644 drivers/gpu/drm/nouveau/vbios/vbios_pm.c
 create mode 100644 drivers/gpu/drm/nouveau/vbios/vbios_pm.h
drivers/gpu/drm/nouveau/Makefile +1 -1
index d6cfbf2..ec4b9f4 100644
@@ -23,7 +23,7 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
              nv04_dac.o nv04_dfp.o nv04_tv.o nv17_tv.o nv17_tv_modes.o \
              nv04_crtc.o nv04_display.o nv04_cursor.o nv04_fbcon.o \
              nv10_gpio.o nv50_gpio.o \
-	     nv50_calc.o
+	     nv50_calc.o nouveau_pm.o vbios/vbios_pm.o
 
 nouveau-$(CONFIG_DRM_NOUVEAU_DEBUG) += nouveau_debugfs.o
 nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
drivers/gpu/drm/nouveau/nouveau_bios.c +49 -18

103 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_bios.h +41 -0

53 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_biosP.h new file +44 -0

44 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_drv.h +2 -0
index b7440f8..d7f86bb 100644
@@ -855,6 +855,7 @@ extern struct dcb_connector_table_entry *
 nouveau_bios_connector_entry(struct drm_device *, int index);
 extern int get_pll_limits(struct drm_device *, uint32_t limit_match,
 			  struct pll_lims *);
+extern int setPLL(struct nvbios *bios, uint32_t reg, uint32_t clk);
 extern int nouveau_bios_run_display_table(struct drm_device *,
 					  struct dcb_entry *,
 					  uint32_t script, int pxclk);
@@ -868,6 +869,7 @@ extern int run_tmds_table(struct drm_device *, struct dcb_entry *,
 			  int head, int pxclk);
 extern int call_lvds_script(struct drm_device *, struct dcb_entry *, int head,
 			    enum LVDS_script, int pxclk);
+extern int vbios_parse_pmtable(struct drm_device *dev);
 
 /* nouveau_ttm.c */
 int nouveau_ttm_global_init(struct drm_nouveau_private *);
drivers/gpu/drm/nouveau/nouveau_pm.c new file +677 -0

677 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_pm.h new file +9 -0
new file mode 100644
index 0000000..23ba87f
@@ -0,0 +1,9 @@
+#ifndef __PSCNV_PM_H__
+#define __PSCNV_PM_H__
+
+#include "drm.h"
+
+int nouveau_pm_init(struct drm_device* dev);
+int nouveau_pm_fini(struct drm_device* dev);
+
+#endif
\ No newline at end of file
drivers/gpu/drm/nouveau/nouveau_state.c +9 -0
index be85960..3e1548c 100644
@@ -37,6 +37,7 @@
 #include "nouveau_fbcon.h"
 #include "nouveau_ramht.h"
 #include "nv50_display.h"
+#include "nouveau_pm.h"
 
 static void nouveau_stub_takedown(struct drm_device *dev) {}
 static int nouveau_stub_init(struct drm_device *dev) { return 0; }
@@ -604,6 +605,10 @@ nouveau_card_init(struct drm_device *dev)
 	if (ret)
 		NV_ERROR(dev, "Error %d registering backlight\n", ret);
 
+	if (nouveau_pm_init(dev)) {
+		NV_ERROR(dev, "Failed to initialize power management\n");
+	}
+
 	nouveau_fbcon_init(dev);
 	drm_kms_helper_poll_init(dev);
 	return 0;
@@ -929,6 +934,10 @@ int nouveau_unload(struct drm_device *dev)
 	engine->display.destroy(dev);
 	nouveau_card_takedown(dev);
 
+	if (nouveau_pm_fini(dev)) {
+		NV_ERROR(dev, "Failed to initialize power management\n");
+	}
+
 	iounmap(dev_priv->mmio);
 	iounmap(dev_priv->ramin);
 
drivers/gpu/drm/nouveau/vbios/vbios_pm.c new file +358 -0

358 lines not on this page · raw message

drivers/gpu/drm/nouveau/vbios/vbios_pm.h new file +34 -0
new file mode 100644
index 0000000..dd2ad88
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 Martin Peres.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __VBIOS_PM_H__
+#define __VBIOS_PM_H__
+
+#include "../nouveau_bios.h"
+
+int vbios_parse_pmtable(struct drm_device *dev);
+
+#endif
Signature · 1 line
1.7.2

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 3 lines · Martin Peres

Hi folks,

I've been messing with PM management for a few days and I've accumulated an interesting volume of code.

If you're an end users also feel free to pull the branch directly..

http://github.com/pathscale/pscnv/tree/pm-wip

We're in #pathscale if you need more help or hit bugs..

thanks

./C

ps (Have a great trip Martin and good luck at the conference!)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 10 lines · C. Bergström
Quoted 4 lines · Martin Peres

Hi folks,

I've been messing with PM management for a few days and I've accumulated an interesting volume of code.

If you're an end users also feel free to pull the branch directly..

http://github.com/pathscale/pscnv/tree/pm-wip

We're in #pathscale if you need more help or hit bugs..

Please keep development of nouveau in #nouveau, we're not pscnv..

Ben.

Quoted 10 lines

thanks

./C

ps (Have a great trip Martin and good luck at the conference!)
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

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

#5 lore raw
In reply to a message not in the archive
Quoted 6 lines · C. Bergström

If you're an end users also feel free to pull the branch directly..

http://github.com/pathscale/pscnv/tree/pm-wip

We're in #pathscale if you need more help or hit bugs..

It is not a good idea as libpdrm isn't mainstream yet. As Ben said, it should be developped in nouveau. Pscnv isn't ready for X users yet even though we are working on it.

If people want to, I'll upload a complete kernel somewhere for end users to test. As for the moment, I only need developpers & people who know what they are doing, not end-users.

Anyway, count on me to keep pscnv & nouveau in sync as for power management.

Quoted 6 lines

thanks

./C

ps (Have a great trip Martin and good luck at the conference!)

Thanks :)

#6 lore raw
In reply to a message not in the archive
Quoted 2 lines · Martin Peres

I've been messing with PM management for a few days and I've accumulated an interesting volume of code.

On an only slightly related note, what's the recommended way to read out the temperature of the GPU when using nouveau? (I have a NV4B card, but I think I read this is mostly the same for all NVidias, right?)

Robert Kaiser

#7 lore raw
Quoted 1 line · Robert Kaiser

On an only slightly related note, what's the recommended way to read out the temperature of the GPU when using nouveau? (I have a NV4B card, but I think I read this is mostly the same for all NVidias, right?)

There is no way to get the temperature using nouveau at the moment. This feature should land in nouveau git some time this week.

Reading the temperature is not as straightforward as just reading a register. It works that way on nv84+, for earlier cards, you need to parse the vbios to set-up the sensor and then read the temperature (and change the value with some additional little calcultations). The documentation should be available soon, I'm working on merging all the doc we have.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 6 lines · Martin Peres
Quoted 3 lines · Robert Kaiser

On an only slightly related note, what's the recommended way to read out the temperature of the GPU when using nouveau? (I have a NV4B card, but I think I read this is mostly the same for all NVidias, right?)

There is no way to get the temperature using nouveau at the moment. This feature should land in nouveau git some time this week.

Kewl! You guys are awesome!

Quoted 6 lines

Reading the temperature is not as straightforward as just reading a register. It works that way on nv84+, for earlier cards, you need to parse the vbios to set-up the sensor and then read the temperature (and change the value with some additional little calcultations). The documentation should be available soon, I'm working on merging all the doc we have.

Duh, would have thought they might make that available pretty easily, but good to know you figured it out. I previously had been using nvclock to read it, but I think going through nouveau is nicer (and I know it's pretty hot most of the time as nouveau is not that good on power management as well, good things take time, after all).

Keep up the good work!

Robert Kaiser