1. 01 7月, 2012 2 次提交
    • R
      PM / Domains: Do not stop devices after restoring their states · 80de3d7f
      Rafael J. Wysocki 提交于
      While resuming a device belonging to a PM domain,
      pm_genpd_runtime_resume() calls __pm_genpd_restore_device() to
      restore its state, if necessary.  The latter starts the device,
      using genpd_start_dev(), restores its state, using
      genpd_restore_dev(), and then stops it, using genpd_stop_dev().
      However, this last operation is not necessary, because the
      device is supposed to be operational after pm_genpd_runtime_resume()
      has returned and because of it pm_genpd_runtime_resume() has to
      call genpd_start_dev() once again for the "restored" device, which
      is inefficient.
      
      To make things more efficient, remove the call to genpd_stop_dev()
      from __pm_genpd_restore_device() and the direct call to
      genpd_start_dev() from pm_genpd_runtime_resume().  [Of course,
      genpd_start_dev() still has to be called by it for devices with the
      power.irq_safe flag set, because __pm_genpd_restore_device() is not
      executed for them.]
      
      This change has been tested on the SH7372 Mackerel board.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      80de3d7f
    • R
      PM / Domains: Use subsystem runtime suspend/resume callbacks by default · 0b589741
      Rafael J. Wysocki 提交于
      Currently, the default "save state" and "restore state" routines
      for generic PM domains, pm_genpd_default_save_state() and
      pm_genpd_default_restore_state(), respectively, only use runtime PM
      callbacks provided by device drivers, but in general those callbacks
      need not provide the entire necessary functionality.  Namely, in
      general it may be necessary to execute subsystem (i.e. device type,
      device class or bus type) callbacks that will carry out all of the
      necessary operations.
      
      For this reason, modify pm_genpd_default_save_state() and
      pm_genpd_default_restore_state() to execute subsystem callbacks,
      if they are provided, and fall back to driver callbacks otherwise.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0b589741
  2. 25 6月, 2012 1 次提交
  3. 14 6月, 2012 1 次提交
  4. 08 6月, 2012 1 次提交
  5. 03 6月, 2012 2 次提交
  6. 30 5月, 2012 3 次提交
  7. 25 5月, 2012 3 次提交
    • S
      dma-buf: minor documentation fixes. · 12c4727e
      Sumit Semwal 提交于
      Some minor inline documentation fixes for gaps resulting from new patches.
      Signed-off-by: NSumit Semwal <sumit.semwal@ti.com>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      12c4727e
    • D
      dma-buf: add vmap interface · 98f86c9e
      Dave Airlie 提交于
      The main requirement I have for this interface is for scanning out
      using the USB gpu devices. Since these devices have to read the
      framebuffer on updates and linearly compress it, using kmaps
      is a major overhead for every update.
      
      v2: fix warn issues pointed out by Sylwester Nawrocki.
      
      v3: fix compile !CONFIG_DMA_SHARED_BUFFER and add _GPL for now
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      Reviewed-by: NRob Clark <rob.clark@linaro.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      98f86c9e
    • D
      dma-buf: mmap support · 4c78513e
      Daniel Vetter 提交于
      Compared to Rob Clark's RFC I've ditched the prepare/finish hooks
      and corresponding ioctls on the dma_buf file. The major reason for
      that is that many people seem to be under the impression that this is
      also for synchronization with outstanding asynchronous processsing.
      I'm pretty massively opposed to this because:
      
      - It boils down reinventing a new rather general-purpose userspace
        synchronization interface. If we look at things like futexes, this
        is hard to get right.
      - Furthermore a lot of kernel code has to interact with this
        synchronization primitive. This smells a look like the dri1 hw_lock,
        a horror show I prefer not to reinvent.
      - Even more fun is that multiple different subsystems would interact
        here, so we have plenty of opportunities to create funny deadlock
        scenarios.
      
      I think synchronization is a wholesale different problem from data
      sharing and should be tackled as an orthogonal problem.
      
      Now we could demand that prepare/finish may only ensure cache
      coherency (as Rob intended), but that runs up into the next problem:
      We not only need mmap support to facilitate sw-only processing nodes
      in a pipeline (without jumping through hoops by importing the dma_buf
      into some sw-access only importer), which allows for a nicer
      ION->dma-buf upgrade path for existing Android userspace. We also need
      mmap support for existing importing subsystems to support existing
      userspace libraries. And a loot of these subsystems are expected to
      export coherent userspace mappings.
      
      So prepare/finish can only ever be optional and the exporter /needs/
      to support coherent mappings. Given that mmap access is always
      somewhat fallback-y in nature I've decided to drop this optimization,
      instead of just making it optional. If we demonstrate a clear need for
      this, supported by benchmark results, we can always add it in again
      later as an optional extension.
      
      Other differences compared to Rob's RFC is the above mentioned support
      for mapping a dma-buf through facilities provided by the importer.
      Which results in mmap support no longer being optional.
      
      Note that this dma-buf mmap patch does _not_ support every possible
      insanity an existing subsystem could pull of with mmap: Because it
      does not allow to intercept pagefaults and shoot down ptes importing
      subsystems can't add some magic of their own at these points (e.g. to
      automatically synchronize with outstanding rendering or set up some
      special resources). I've done a cursory read through a few mmap
      implementions of various subsytems and I'm hopeful that we can avoid
      this (and the complexity it'd bring with it).
      
      Additonally I've extended the documentation a bit to explain the hows
      and whys of this mmap extension.
      
      In case we ever want to add support for explicitly cache maneged
      userspace mmap with a prepare/finish ioctl pair, we could specify that
      userspace needs to mmap a different part of the dma_buf, e.g. the
      range starting at dma_buf->size up to dma_buf->size*2. This works
      because the size of a dma_buf is invariant over it's lifetime. The
      exporter would obviously need to fall back to coherent mappings for
      both ranges if a legacy clients maps the coherent range and the
      architecture cannot suppor conflicting caching policies. Also, this
      would obviously be optional and userspace needs to be able to fall
      back to coherent mappings.
      
      v2:
      - Spelling fixes from Rob Clark.
      - Compile fix for !DMA_BUF from Rob Clark.
      - Extend commit message to explain how explicitly cache managed mmap
        support could be added later.
      - Extend the documentation with implementations notes for exporters
        that need to manually fake coherency.
      
      v3:
      - dma_buf pointer initialization goof-up noticed by Rebecca Schultz
        Zavin.
      
      Cc: Rob Clark <rob.clark@linaro.org>
      Cc: Rebecca Schultz Zavin <rebecca@android.com>
      Acked-by: NRob Clark <rob.clark@linaro.org>
      Signed-Off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      4c78513e
  8. 23 5月, 2012 1 次提交
  9. 21 5月, 2012 2 次提交
  10. 19 5月, 2012 1 次提交
    • R
      PM / Domains: Make it possible to add devices to inactive domains · ca1d72f0
      Rafael J. Wysocki 提交于
      The generic PM domains core code currently requires domains to be in
      the "power on" state for adding devices to them, but this limitation
      turns out to be inconvenient in some situations, so remove it.
      
      For this purpose, make __pm_genpd_add_device() set the device's
      need_restore flag if the domain is in the "power off" state, so that
      the device's "restore state" (usually .runtime_resume()) callback
      is executed when it is resumed after the domain has been turned on.
      If the domain is in the "power on" state, the device's need_restore
      flag will be cleared by __pm_genpd_add_device(), so that its "save
      state" (usually .runtime_suspend()) callback is executed when the
      domain is about to be turned off.  However, since that default
      behavior need not be always desirable, add a helper function
      pm_genpd_dev_need_restore() allowing a device's need_restore flag
      to be set/unset at any time.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      ca1d72f0
  11. 18 5月, 2012 1 次提交
  12. 17 5月, 2012 1 次提交
    • P
      sched: Remove stale power aware scheduling remnants and dysfunctional knobs · 8e7fbcbc
      Peter Zijlstra 提交于
      It's been broken forever (i.e. it's not scheduling in a power
      aware fashion), as reported by Suresh and others sending
      patches, and nobody cares enough to fix it properly ...
      so remove it to make space free for something better.
      
      There's various problems with the code as it stands today, first
      and foremost the user interface which is bound to topology
      levels and has multiple values per level. This results in a
      state explosion which the administrator or distro needs to
      master and almost nobody does.
      
      Furthermore large configuration state spaces aren't good, it
      means the thing doesn't just work right because it's either
      under so many impossibe to meet constraints, or even if
      there's an achievable state workloads have to be aware of
      it precisely and can never meet it for dynamic workloads.
      
      So pushing this kind of decision to user-space was a bad idea
      even with a single knob - it's exponentially worse with knobs
      on every node of the topology.
      
      There is a proposal to replace the user interface with a single
      3 state knob:
      
       sched_balance_policy := { performance, power, auto }
      
      where 'auto' would be the preferred default which looks at things
      like Battery/AC mode and possible cpufreq state or whatever the hw
      exposes to show us power use expectations - but there's been no
      progress on it in the past many months.
      
      Aside from that, the actual implementation of the various knobs
      is known to be broken. There have been sporadic attempts at
      fixing things but these always stop short of reaching a mergable
      state.
      
      Therefore this wholesale removal with the hopes of spurring
      people who care to come forward once again and work on a
      coherent replacement.
      Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Suresh Siddha <suresh.b.siddha@intel.com>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Link: http://lkml.kernel.org/r/1326104915.2442.53.camel@twinsSigned-off-by: NIngo Molnar <mingo@kernel.org>
      8e7fbcbc
  13. 15 5月, 2012 1 次提交
  14. 14 5月, 2012 3 次提交
  15. 12 5月, 2012 2 次提交
    • R
      PM / Domains: Fix computation of maximum domain off time · b723b0eb
      Rafael J. Wysocki 提交于
      The default domain power off governor function for generic PM
      domains, default_power_down_ok(), may violate subdomain maximum
      off time limit by allowing the master domain to be off for too
      long.  Namely, it only finds the minium of all device maximum
      off times over the domain's devices and uses that to compute the
      domain's maximum off time, but it should do the same for the
      subdomains.
      
      Fix this problem by modifying default_power_down_ok() to compute
      the given domain's maximum off time as the difference between the
      minimum off time over all devices and subdomains in the domain and
      its power on latency.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      b723b0eb
    • H
      PM / Domains: Fix link checking when add subdomain · 4fcac10d
      Huang Ying 提交于
      Current pm_genpd_add_subdomain() will allow duplicated link between
      master and slave domain.  This patch fixed it.
      
      Because when current pm_genpd_add_subdomain() checks whether the link
      between the master and slave generic PM domain already exists,
      slave_links instead of master_links of master domain is used.
      Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      4fcac10d
  16. 09 5月, 2012 2 次提交
    • L
      regmap: fix possible memory corruption in regmap_bulk_read() · 6560ffd1
      Laxman Dewangan 提交于
      The function regmap_bulk_read() calls the regmap_read() for
      each register if set of register has volatile and cache is
      enabled. In this case, last few register read makes the memory
      corruption if the register size is not the size of unsigned int.
      The regam_read() takes argument as unsigned int for returning
      value and it update the value as
      	*val = map->format.parse_val(map->work_buf);
      This causes complete 4 bytes (size of unsigned int) to get written.
      Now if client pass the memory pointer for value which is equal to the
      required size of register count in regmap_bulk_read() then last few
      register read actually update the memory beyond passed pointer size.
      
      Avoid this by using local variable for read and then do memcpy()
      for actual byte copy to passed pointer based on register size.
      
      I allocated one pointer ptr and take first 16 bytes dump of that
      pointer then call regmap_bulk_read() with pointer which is just
      on top of this allocated pointer and register count of 128. Here
      register size is 1 byte.
      The memory trace of last 5 register read are as follows:
      
      [    5.438589] regmap_bulk_read after regamp_read() for register 122
      [    5.447421] 0xef993c20 0xef993c00 0x00000000 0x00000001
      [    5.467535] regmap_bulk_read after regamp_read() for register 123
      [    5.476374] 0xef993c20 0xef993c00 0x00000000 0x00000001
      [    5.496425] regmap_bulk_read after regamp_read() for register 124
      [    5.505260] 0xef993c20 0xef993c00 0x00000000 0x00000001
      [    5.525372] regmap_bulk_read after regamp_read() for register 125
      [    5.534205] 0xef993c00 0xef993c00 0x00000000 0x00000001
      [    5.554258] regmap_bulk_read after regamp_read() for register 126
      [    5.563100] 0xef990000 0xef993c00 0x00000000 0x00000001
      [    5.554258] regmap_bulk_read after regamp_read() for register 127
      [    5.587108] 0xef000000 0xef993c00 0x00000000 0x00000001
      
      Here it is observed that the memory content at first word started changing
      on last 3 regmap_read() and so corruption happened.
      Signed-off-by: NLaxman Dewangan <ldewangan@nvidia.com>
      Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      6560ffd1
    • M
      regmap: Implement dev_get_regmap() · 72b39f6f
      Mark Brown 提交于
      Use devres to implement dev_get_regmap(). This should mean that in almost
      all cases devices wishing to take advantage of framework features based on
      regmap shouldn't need to explicitly pass the regmap into the framework.
      This simplifies device setup a bit.
      Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      72b39f6f
  17. 08 5月, 2012 1 次提交
  18. 06 5月, 2012 2 次提交
    • R
      PM / Domains: Cache device stop and domain power off governor results, v3 · 6ff7bb0d
      Rafael J. Wysocki 提交于
      The results of the default device stop and domain power off governor
      functions for generic PM domains, default_stop_ok() and
      default_power_down_ok(), depend only on the timing data of devices,
      which are static, and on their PM QoS constraints.  Thus, in theory,
      these functions only need to carry out their computations, which may
      be time consuming in general, when it is known that the PM QoS
      constraint of at least one of the devices in question has changed.
      
      Use the PM QoS notifiers of devices to implement that.  First,
      introduce new fields, constraint_changed and max_off_time_changed,
      into struct gpd_timing_data and struct generic_pm_domain,
      respectively, and register a PM QoS notifier function when adding
      a device into a domain that will set those fields to 'true' whenever
      the device's PM QoS constraint is modified.  Second, make
      default_stop_ok() and default_power_down_ok() use those fields to
      decide whether or not to carry out their computations from scratch.
      
      The device and PM domain hierarchies are taken into account in that
      and the expense is that the changes of PM QoS constraints of
      suspended devices will not be taken into account immediately, which
      isn't guaranteed anyway in general.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      6ff7bb0d
    • R
      PM / Domains: Make device removal more straightforward · efa69025
      Rafael J. Wysocki 提交于
      The removal of a device from a PM domain doesn't have to browse
      the domain's device list, because it can check directly if the
      device belongs to the given domain.  Moreover, it should clear
      the domain_data pointer in dev->power.subsys_data, because
      dev_pm_put_subsys_data(dev) may not remove dev->power.subsys_data
      and the stale domain data pointer may cause problems to happen.
      
      Rework pm_genpd_remove_device() taking the above observations into
      account.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      efa69025
  19. 05 5月, 2012 2 次提交
  20. 02 5月, 2012 8 次提交
    • R
      PM / QoS: Create device constraints objects on notifier registration · 23e0fc5a
      Rafael J. Wysocki 提交于
      The current behavior of dev_pm_qos_add_notifier() makes device PM QoS
      notifiers less than useful.  Namely, it silently returns success when
      called before any PM QoS constraints are added for the device, so the
      caller will assume that the notifier has been registered, but when
      someone actually adds some nontrivial constraints for the device
      eventually, the previous callers of dev_pm_qos_add_notifier()
      will not know about that and their notifier routines will not be
      executed (contrary to their expectations).
      
      To address this problem make dev_pm_qos_add_notifier() create the
      constraints object for the device if it is not present when the
      routine is called.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by : markgross <markgross@thegnar.org>
      23e0fc5a
    • R
      PM / Runtime: Remove device fields related to suspend time, v2 · 76e267d8
      Rafael J. Wysocki 提交于
      After the previous changes in default_stop_ok() and
      default_power_down_ok() for PM domains, there are two fields in
      struct dev_pm_info that aren't necessary any more,  suspend_time
      and max_time_suspended_ns.
      
      Remove those fields along with all of the code that accesses them,
      which simplifies the runtime PM framework quite a bit.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      76e267d8
    • R
      PM / Domains: Rework default domain power off governor function, v2 · dd8683e9
      Rafael J. Wysocki 提交于
      The existing default domain power down governor function for PM
      domains, default_power_down_ok(), is supposed to check whether or not
      the PM QoS latency constraints of the devices in the domain will be
      violated if the domain is turned off by pm_genpd_poweroff().
      However, the computations carried out by it don't reflect the
      definition of the PM QoS latency constrait in
      Documentation/ABI/testing/sysfs-devices-power.
      
      Make default_power_down_ok() follow the definition of the PM QoS
      latency constrait.  In particular, make it only take latencies into
      account, because it doesn't matter how much time has elapsed since
      the domain's devices were suspended for the computation.
      
      Remove the break_even_ns and power_off_time fields from
      struct generic_pm_domain, because they are not necessary any more.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      dd8683e9
    • R
      PM / Domains: Rework default device stop governor function, v2 · a5bef810
      Rafael J. Wysocki 提交于
      The existing default device stop governor function for PM domains,
      default_stop_ok(), is supposed to check whether or not the device's
      PM QoS latency constraint will be violated if the device is stopped
      by pm_genpd_runtime_suspend().  However, the computations carried out
      by it don't reflect the definition of the PM QoS latency constrait in
      Documentation/ABI/testing/sysfs-devices-power.
      
      Make default_stop_ok() follow the definition of the PM QoS latency
      constrait.  In particular, make it take the device's start and stop
      latencies correctly.
      
      Add a new field, effective_constraint_ns, to struct gpd_timing_data
      and use it to store the difference between the device's PM QoS
      constraint and its resume latency for use by the device's parent
      (the effective_constraint_ns values for the children are used for
      computing the parent's one along with its PM QoS constraint).
      
      Remove the break_even_ns field from struct gpd_timing_data, because
      it's not used any more.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      a5bef810
    • R
      PM / Sleep: Add user space interface for manipulating wakeup sources, v3 · b86ff982
      Rafael J. Wysocki 提交于
      Android allows user space to manipulate wakelocks using two
      sysfs file located in /sys/power/, wake_lock and wake_unlock.
      Writing a wakelock name and optionally a timeout to the wake_lock
      file causes the wakelock whose name was written to be acquired (it
      is created before is necessary), optionally with the given timeout.
      Writing the name of a wakelock to wake_unlock causes that wakelock
      to be released.
      
      Implement an analogous interface for user space using wakeup sources.
      Add the /sys/power/wake_lock and /sys/power/wake_unlock files
      allowing user space to create, activate and deactivate wakeup
      sources, such that writing a name and optionally a timeout to
      wake_lock causes the wakeup source of that name to be activated,
      optionally with the given timeout.  If that wakeup source doesn't
      exist, it will be created and then activated.  Writing a name to
      wake_unlock causes the wakeup source of that name, if there is one,
      to be deactivated.  Wakeup sources created with the help of
      wake_lock that haven't been used for more than 5 minutes are garbage
      collected and destroyed.  Moreover, there can be only WL_NUMBER_LIMIT
      wakeup sources created with the help of wake_lock present at a time.
      
      The data type used to track wakeup sources created by user space is
      called "struct wakelock" to indicate the origins of this feature.
      
      This version of the patch includes an rbtree manipulation fix from John Stultz.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NNeilBrown <neilb@suse.de>
      b86ff982
    • R
      PM / Sleep: Add "prevent autosleep time" statistics to wakeup sources · 55850945
      Rafael J. Wysocki 提交于
      Android uses one wakelock statistics that is only necessary for
      opportunistic sleep.  Namely, the prevent_suspend_time field
      accumulates the total time the given wakelock has been locked
      while "automatic suspend" was enabled.  Add an analogous field,
      prevent_sleep_time, to wakeup sources and make it behave in a similar
      way.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55850945
    • R
      PM / Sleep: Implement opportunistic sleep, v2 · 7483b4a4
      Rafael J. Wysocki 提交于
      Introduce a mechanism by which the kernel can trigger global
      transitions to a sleep state chosen by user space if there are no
      active wakeup sources.
      
      It consists of a new sysfs attribute, /sys/power/autosleep, that
      can be written one of the strings returned by reads from
      /sys/power/state, an ordered workqueue and a work item carrying out
      the "suspend" operations.  If a string representing the system's
      sleep state is written to /sys/power/autosleep, the work item
      triggering transitions to that state is queued up and it requeues
      itself after every execution until user space writes "off" to
      /sys/power/autosleep.
      
      That work item enables the detection of wakeup events using the
      functions already defined in drivers/base/power/wakeup.c (with one
      small modification) and calls either pm_suspend(), or hibernate() to
      put the system into a sleep state.  If a wakeup event is reported
      while the transition is in progress, it will abort the transition and
      the "system suspend" work item will be queued up again.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NNeilBrown <neilb@suse.de>
      7483b4a4
    • A
      PM / Sleep: Add wakeup_source_activate and wakeup_source_deactivate tracepoints · 6791e36c
      Arve Hjønnevåg 提交于
      Add tracepoints to wakeup_source_activate and wakeup_source_deactivate.
      Useful for checking that specific wakeup sources overlap as expected.
      Signed-off-by: NArve Hjønnevåg <arve@android.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      6791e36c