Announcement

Collapse
No announcement yet.

In-Kernel Power Management For ATI KMS

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by Zajec View Post
    As soon as these patches hit drm-next, I'm going to continue my work and prepare something really useful. Unfortunately the most complicated part is still ahead of us: determining which power state should be used in current moment. It needs measuring current load and some smart (and lucky) choosing mode. Remember that every mode has engine clock, memory clock and voltage. We have to somehow calculate all of that.
    I'm not the expert, but tell my why is important for driver to choose the best power state to be used in current moment? Isn't just possible to make some file, such as /sys/*/radeon/power_state which will control the current power state? I mean: if I write into terminal:
    cat /sys/*/radeon/power_state
    it should print something like the following:
    Current power state: 2 (x MHz Core Clock, y MHz Memory Clock)
    And I could change the power state by entering e.g.: echo 1 > /sys/*/radeon/power_state
    And available power states for current graphics card would be available in another file, e.g. /sys/*/radeon/power_states, which would be readonly.

    In that case, determining which power state should be used in current moment could be left to the higher-level programs, e.g. PowerDevil, laptop-mode, or some custom user scripts.

    Is it possible to enable this way of switching power states in radeon driver? In this way works the iwl3945 drivers's power management (of course iwl3945 is the WiFi driver, and I'm just curious if it's possible to create the similar power management architecture for graphics driver as is for wifi driver?)

    Thank you in advance for your answers.

    Comment


    • #17
      Originally posted by DoDoENT View Post
      I'm not the expert, but tell my why is important for driver to choose the best power state to be used in current moment? Isn't just possible to make some file, such as /sys/*/radeon/power_state which will control the current power state? I mean: if I write into terminal:
      cat /sys/*/radeon/power_state
      it should print something like the following:
      Current power state: 2 (x MHz Core Clock, y MHz Memory Clock)
      And I could change the power state by entering e.g.: echo 1 > /sys/*/radeon/power_state
      And available power states for current graphics card would be available in another file, e.g. /sys/*/radeon/power_states, which would be readonly.

      In that case, determining which power state should be used in current moment could be left to the higher-level programs, e.g. PowerDevil, laptop-mode, or some custom user scripts.

      Is it possible to enable this way of switching power states in radeon driver? In this way works the iwl3945 drivers's power management (of course iwl3945 is the WiFi driver, and I'm just curious if it's possible to create the similar power management architecture for graphics driver as is for wifi driver?)

      Thank you in advance for your answers.
      What you talk about is userspace power management. This can be eventually introduced, but can not be the only solution.

      Userspace just can not know about everything that happens in GPU. It has only some basic idea about current load (amount of apps, maybe Xv and 3D detecting). That's not enought. Only kernel side can have full view on load.

      However as I said, we will want to introduce something you proposed anyway. For example in case of using battery power we don't know if user still prefers performance, or long battery life.

      For some additional details you may also check discussion on dri-devel: http://sourceforge.net/mailarchive/m...mail.gmail.com

      Comment


      • #18
        What Zajec said

        Doing simple power management in userspace is no problem, but doing the kind of aggressive real-time power management that you need for best battery life on a laptop either requires the decision making code to be in the kernel or a protocol to be defined that passes all the information up to userspace so that information can be accumulated and decisions made there.

        It doesn't really matter where the other than (a) it's easier for userspace code to have access to user inputs etc,, (b) all the information comes from the kernel and decisions end up in the kernel so doing the first implementation *in* the kernel is probably less work unless all of the necessary user/kernel protocols already exist (which they might, of course).
        Last edited by bridgman; 09-12-2009, 03:45 PM.

        Comment


        • #19
          Originally posted by bridgman View Post
          Actually a very good question.

          In principle, yes the hardware could be completely self sufficient for power management.

          In practice, however, making the right power management decisions usually requires knowledge outside what the GPU or CPU has available. As an off-the-top-of-my-head example, you want to power down the 3D engine very aggressively when there is no drawing activity, but if your game stalls while swapping in a big texture you probably would *not* want to power down the 3D engine in that case. That decision heuristic would require that power management for the GPU be cognizant of disk activity.

          The preferred approach for managing power is also changing over time, with a slight trend from "run the hardware as slowly as possible while maintaining acceptable performance" to "run at full speed, get the work done fast and then switch everything off as quickly as possible until more work comes along". As you can imagine, it helps a lot of the CPU and GPU power management follow the same approach

          When setting memory clocks you need to make some pretty complex bandwidth and latency calculations in order to make sure that the display fifos don't get starved for data when the 3D engine is drawing into the same memory. One implication of this is that the minimum memory clock setting is a function of engine clock, drawing activity, number of active displays, depth / resolution / refresh rate.

          Since changing clocks takes a non-trivial amount of time (you need to let the PLLs in the clock generators settle at the new frequency after changing dividers) you need to include recent behaviour trends in the decision-making logic, not just what is happening at this instant, in order to avoid too-frequent changes with the associated waste of power and time. All of this can be done in hardware but you can see how quickly the complexity can grow.

          Anyways, bottom line is getting the very best power efficiency always seems to require making decisions using more information than what is available to each individual device, ie shifting from focusing on device power management to focusing on platform power management.
          Okay that's just crazy the things that is going one behind the scene

          I assume what you just described is the most advanced and probably the latest to get implemented?

          So KMS is power management's hook into the 3D engine/OpenGL*?

          I assume 3D engine and OpenGL is the same...?

          Comment


          • #20
            Originally posted by bridgman View Post
            What Zajec said

            Doing simple power management in userspace is no problem, but doing the kind of aggressive real-time power management that you need for best battery life on a laptop either requires the decision making code to be in the kernel or a protocol to be defined that passes all the information up to userspace so that information can be accumulated and decisions made there.

            It doesn't really matter where the other than (a) it's easier for userspace code to have access to user inputs etc,, (b) all the information comes from the kernel and decisions end up in the kernel so doing the first implementation *in* the kernel is probably less work unless all of the necessary user/kernel protocols already exist (which they might, of course).
            I understand.

            But how about enabling just userspace power state switching by the time Fedora 12 ships? It would mean a lot to advanced users which would like to have at least some power management (better that than none). I know this wouldn't offer the best battery life for laptops, but it will increase it... at least as it was while I was using fglrx (the difference is approx. 35-40 minutes).

            Comment


            • #21
              Louise;

              the KMS drm driver is important in two ways :

              1. As you say, it provides the "hook" into all 3D engine use, both from the OpenGL driver (the obvious user of the 3D engine) and the X driver (which uses the 3D engine for EXA and Xv as well). It also provides access to display / modesetting info in the same driver, ie it brings all of the required information together in one place.

              2. Some of the registers which control GPIO and I2C lines for reading and writing fan/temp controllers and voltage control are also used by modesetting for reading EDID information, so modesetting and power management need to be in the same driver. Unfortunately that needs to be the drm driver, since changing clocks on the fly requires that the driver also block any use of drawing engines, which can only be done in the drm driver (since direct rendered 3D doesn't go through the userspace X driver).

              DoDoENT;

              The problem with doing dynamic PM in the userspace driver is that the userspace driver can't block drawing calls from 3D. Bad things can happen if the drawing engine is running at the same time you are reprogramming the clock generator for the engine. Doing dynamic PM in the drm means that drawing operations can be temporarily stopped and the drawing engine quiesced before changing the clock.
              Last edited by bridgman; 09-12-2009, 05:04 PM.

              Comment


              • #22
                Originally posted by bridgman View Post
                Louise;

                the KMS drm driver is important in two ways :

                1. As you say, it provides the "hook" into all 3D engine use, both from the OpenGL driver (the obvious user of the 3D engine) and the X driver (which uses the 3D engine for EXA and Xv as well). It also provides access to display / modesetting info in the same driver, ie it brings all of the required information together in one place.

                2. Some of the registers which control GPIO and I2C lines for reading and writing fan/temp controllers and voltage control are also used by modesetting for reading EDID information, so modesetting and power management need to be in the same driver. Unfortunately that needs to be the drm driver, since changing clocks on the fly requires that the driver also block any use of drawing engines, which can only be done in the drm driver (since direct rendered 3D doesn't go through the userspace X driver).
                Very interesting all the things that KMS can be used for!

                Comment


                • #23
                  Originally posted by bridgman View Post
                  DoDoENT;

                  The problem with doing dynamic PM in the userspace driver is that the userspace driver can't block drawing calls from 3D. Bad things can happen if the drawing engine is running at the same time you are reprogramming the clock generator for the engine. Doing dynamic PM in the drm means that drawing operations can be temporarily stopped and the drawing engine quiesced before changing the clock.
                  I see. So the AI in the driver is required after all, and it should make decision based on the user preferences from the userspace (i.e. does the user want max performance or max powersave).

                  What I have in mind is not dynamic PM from userspace, but static instead. The user would set a request that from now on, he wants maximum performance, as he (or she) is going to play a game. Then, the PM AI would make decisions which would offer best performance, but not the best power saving. And if the user sets request for maximum power saving, the PM AI should make decisions which would offer the least performance, but best power saving. And finally, the user would have the option to set a request for smart power saving, which would then do what you've told - it would make smart decisions which will optimize the ratio between performance and power saving based on some data it collects. This third part would be the most difficult to make as it requires relatively complex AI algorithms, but even first two parts will make a lot of people happy (including me ).

                  Just to make myself clear: I would like to have the famous aticonfig --set-powerstate feature in the radeon driver: when I issued "aticonfig --set-powerstate=1", I got 3 hours of battery life with awful graphics performance (but good enough to do some simple jobs), and when I issued "aticonfig --set-powerstate=3", I got less than 1 hour of battery life, but I could play nexuiz with high details in high resolution without any problems. This is what I find very useful, and it doesn't look like it requires any complex AI PM algorithms.

                  Comment


                  • #24
                    What do you think about creating something like /sys/class/gpu/ with engine_clock, memory_clock and voltage? Example:
                    Code:
                    $ cat /sys/class/gpu/engine_clock
                    management: auto
                    300000 KHz
                    
                    $ echo maximum > /sys/class/gpu/engine_clock
                    $ cat /sys/class/gpu/engine_clock
                    management: static
                    680000 KHz
                    
                    $ echo minimum > /sys/class/gpu/engine_clock
                    $ cat /sys/class/gpu/engine_clock
                    management: static
                    110000 KHz
                    
                    $ echo 50000 > /sys/class/gpu/engine_clock
                    $ cat /sys/class/gpu/engine_clock
                    management: static
                    110000 KHz
                    
                    $ echo 250000 > /sys/class/gpu/engine_clock
                    $ cat /sys/class/gpu/engine_clock
                    management: static
                    250000 KHz
                    
                    $ echo auto > /sys/class/gpu/engine_clock
                    $ cat /sys/class/gpu/engine_clock
                    management: auto
                    320000 KHz
                    ?

                    Comment


                    • #25
                      Originally posted by Zajec View Post
                      What do you think about creating something like /sys/class/gpu/ with engine_clock, memory_clock and voltage? Example:
                      Code:
                      $ cat /sys/class/gpu/engine_clock
                      management: auto
                      300000 KHz
                      
                      $ echo maximum > /sys/class/gpu/engine_clock
                      $ cat /sys/class/gpu/engine_clock
                      management: static
                      680000 KHz
                      
                      $ echo minimum > /sys/class/gpu/engine_clock
                      $ cat /sys/class/gpu/engine_clock
                      management: static
                      110000 KHz
                      
                      $ echo 50000 > /sys/class/gpu/engine_clock
                      $ cat /sys/class/gpu/engine_clock
                      management: static
                      110000 KHz
                      
                      $ echo 250000 > /sys/class/gpu/engine_clock
                      $ cat /sys/class/gpu/engine_clock
                      management: static
                      250000 KHz
                      
                      $ echo auto > /sys/class/gpu/engine_clock
                      $ cat /sys/class/gpu/engine_clock
                      management: auto
                      320000 KHz
                      ?
                      We would still need UI for that like gnome-applet or plasma widget.

                      Comment


                      • #26
                        Originally posted by DoDoENT View Post
                        I see. So the AI in the driver is required after all, and it should make decision based on the user preferences from the userspace (i.e. does the user want max performance or max powersave).

                        What I have in mind is not dynamic PM from userspace, but static instead. The user would set a request that from now on, he wants maximum performance, as he (or she) is going to play a game. Then, the PM AI would make decisions which would offer best performance, but not the best power saving. And if the user sets request for maximum power saving, the PM AI should make decisions which would offer the least performance, but best power saving. And finally, the user would have the option to set a request for smart power saving, which would then do what you've told - it would make smart decisions which will optimize the ratio between performance and power saving based on some data it collects. This third part would be the most difficult to make as it requires relatively complex AI algorithms, but even first two parts will make a lot of people happy (including me ).

                        Just to make myself clear: I would like to have the famous aticonfig --set-powerstate feature in the radeon driver: when I issued "aticonfig --set-powerstate=1", I got 3 hours of battery life with awful graphics performance (but good enough to do some simple jobs), and when I issued "aticonfig --set-powerstate=3", I got less than 1 hour of battery life, but I could play nexuiz with high details in high resolution without any problems. This is what I find very useful, and it doesn't look like it requires any complex AI PM algorithms.
                        I think we don't need any more complex algorithm for smart than cpufreq has. It is just a bit harder to calculate load level for GPU.

                        Comment


                        • #27
                          Originally posted by suokko View Post
                          We would still need UI for that like gnome-applet or plasma widget.
                          Sure, that should eventually be last step.

                          Comment


                          • #28
                            Originally posted by Zajec View Post
                            What do you think about creating something like /sys/class/gpu/ with engine_clock, memory_clock and voltage? Example:
                            Code:
                            $ cat /sys/class/gpu/engine_clock
                            management: auto
                            300000 KHz
                            
                            $ echo maximum > /sys/class/gpu/engine_clock
                            $ cat /sys/class/gpu/engine_clock
                            management: static
                            680000 KHz
                            
                            $ echo minimum > /sys/class/gpu/engine_clock
                            $ cat /sys/class/gpu/engine_clock
                            management: static
                            110000 KHz
                            
                            $ echo 50000 > /sys/class/gpu/engine_clock
                            $ cat /sys/class/gpu/engine_clock
                            management: static
                            110000 KHz
                            
                            $ echo 250000 > /sys/class/gpu/engine_clock
                            $ cat /sys/class/gpu/engine_clock
                            management: static
                            250000 KHz
                            
                            $ echo auto > /sys/class/gpu/engine_clock
                            $ cat /sys/class/gpu/engine_clock
                            management: auto
                            320000 KHz
                            ?
                            Exactly my idea!

                            Comment


                            • #29
                              Originally posted by suokko View Post
                              We would still need UI for that like gnome-applet or plasma widget.
                              That's not difficult. I mean: That's _really_ not difficult.

                              Comment


                              • #30
                                Originally posted by suokko View Post
                                I think we don't need any more complex algorithm for smart than cpufreq has. It is just a bit harder to calculate load level for GPU.
                                So, which information does the driver have for calculating the GPU load?

                                Comment

                                Working...
                                X