1. 21 6月, 2021 1 次提交
  2. 23 4月, 2021 1 次提交
    • V
      regulator: core: Fix off_on_delay handling · a8ce7bd8
      Vincent Whitchurch 提交于
      The jiffies-based off_on_delay implementation has a couple of problems
      that cause it to sometimes not actually delay for the required time:
      
       (1) If, for example, the off_on_delay time is equivalent to one jiffy,
           and the ->last_off_jiffy is set just before a new jiffy starts,
           then _regulator_do_enable() does not wait at all since it checks
           using time_before().
      
       (2) When jiffies overflows, the value of "remaining" becomes higher
           than "max_delay" and the code simply proceeds without waiting.
      
      Fix these problems by changing it to use ktime_t instead.
      
      [Note that since jiffies doesn't start at zero but at INITIAL_JIFFIES
       ("-5 minutes"), (2) above also led to the code not delaying if
       the first regulator_enable() is called when the ->last_off_jiffy is not
       initialised, such as for regulators with ->constraints->boot_on set.
       It's not clear to me if this was intended or not, but I've preserved
       this behaviour explicitly with the check for a non-zero ->last_off.]
      Signed-off-by: NVincent Whitchurch <vincent.whitchurch@axis.com>
      Link: https://lore.kernel.org/r/20210423114524.26414-1-vincent.whitchurch@axis.comSigned-off-by: NMark Brown <broonie@kernel.org>
      a8ce7bd8
  3. 22 4月, 2021 1 次提交
  4. 21 4月, 2021 2 次提交
  5. 25 1月, 2021 1 次提交
    • H
      regulator: core: Avoid debugfs: Directory ... already present! error · dbe954d8
      Hans de Goede 提交于
      Sometimes regulator_get() gets called twice for the same supply on the
      same device. This may happen e.g. when a framework / library is used
      which uses the regulator; and the driver itself also needs to enable
      the regulator in some cases where the framework will not enable it.
      
      Commit ff268b56 ("regulator: core: Don't spew backtraces on
      duplicate sysfs") already takes care of the backtrace which would
      trigger when creating a duplicate consumer symlink under
      /sys/class/regulator/regulator.%d in this scenario.
      
      Commit c33d4423 ("debugfs: make error message a bit more verbose")
      causes a new error to get logged in this scenario:
      
      [   26.938425] debugfs: Directory 'wm5102-codec-MICVDD' with parent 'spi-WM510204:00-MICVDD' already present!
      
      There is no _nowarn variant of debugfs_create_dir(), but we can detect
      and avoid this problem by checking the return value of the earlier
      sysfs_create_link_nowarn() call.
      
      Add a check for the earlier sysfs_create_link_nowarn() failing with
      -EEXIST and skip the debugfs_create_dir() call in that case, avoiding
      this error getting logged.
      
      Fixes: c33d4423 ("debugfs: make error message a bit more verbose")
      Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Reviewed-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
      Link: https://lore.kernel.org/r/20210122183250.370571-1-hdegoede@redhat.comSigned-off-by: NMark Brown <broonie@kernel.org>
      dbe954d8
  6. 23 1月, 2021 1 次提交
  7. 22 1月, 2021 1 次提交
  8. 09 1月, 2021 1 次提交
    • D
      regulator: core: avoid regulator_resolve_supply() race condition · eaa7995c
      David Collins 提交于
      The final step in regulator_register() is to call
      regulator_resolve_supply() for each registered regulator
      (including the one in the process of being registered).  The
      regulator_resolve_supply() function first checks if rdev->supply
      is NULL, then it performs various steps to try to find the supply.
      If successful, rdev->supply is set inside of set_supply().
      
      This procedure can encounter a race condition if two concurrent
      tasks call regulator_register() near to each other on separate CPUs
      and one of the regulators has rdev->supply_name specified.  There
      is currently nothing guaranteeing atomicity between the rdev->supply
      check and set steps.  Thus, both tasks can observe rdev->supply==NULL
      in their regulator_resolve_supply() calls.  This then results in
      both creating a struct regulator for the supply.  One ends up
      actually stored in rdev->supply and the other is lost (though still
      present in the supply's consumer_list).
      
      Here is a kernel log snippet showing the issue:
      
      [   12.421768] gpu_cc_gx_gdsc: supplied by pm8350_s5_level
      [   12.425854] gpu_cc_gx_gdsc: supplied by pm8350_s5_level
      [   12.429064] debugfs: Directory 'regulator.4-SUPPLY' with parent
                     '17a00000.rsc:rpmh-regulator-gfxlvl-pm8350_s5_level'
                     already present!
      
      Avoid this race condition by holding the rdev->mutex lock inside
      of regulator_resolve_supply() while checking and setting
      rdev->supply.
      Signed-off-by: NDavid Collins <collinsd@codeaurora.org>
      Link: https://lore.kernel.org/r/1610068562-4410-1-git-send-email-collinsd@codeaurora.orgSigned-off-by: NMark Brown <broonie@kernel.org>
      eaa7995c
  9. 04 1月, 2021 1 次提交
  10. 26 11月, 2020 1 次提交
  11. 14 11月, 2020 3 次提交
  12. 13 11月, 2020 3 次提交
  13. 11 11月, 2020 1 次提交
  14. 03 11月, 2020 1 次提交
  15. 29 10月, 2020 1 次提交
  16. 05 10月, 2020 1 次提交
  17. 02 10月, 2020 1 次提交
    • A
      regulator: core: Enlarge max OF property name length to 64 chars · e9bb4a06
      AngeloGioacchino Del Regno 提交于
      Some regulator drivers may be defining very long names: this is the
      case with the qcom_smd and qcom_spmi regulators, where we need to
      parse the regulator parents from DT.
      
      For clarity, this is an example:
      { "l13a", QCOM_SMD_RPM_LDOA, 13, &pm660_ht_lvpldo,
        "vdd_l8_l9_l10_l11_l12_l13_l14" },
      pm660-regulators {
      	...
      	vdd_l8_l9_l10_l11_l12_l13_l14-supply = <&vreg_s4a_2p04>
      	...
      };
      Now, with a 32 characters limit, the function is trying to parse,
      exactly, "vdd_l8_l9_l10_l11_l12_l13_l14-s" (32 chars) instead of
      the right one, which is 37 chars long in this specific case.
      
      ... And this is not only the case with PM660/PM660L, but also with
      PMA8084, PM8916, PM8950 and others that are not implemented yet.
      
      The length of 64 chars was chosen based on the longest parsed property
      name that I could find, which is in PM8916, and would be 53 characters
      long.
      At that point, rounding that to 64 looked like being the best idea.
      Signed-off-by: NAngeloGioacchino Del Regno <kholk11@gmail.com>
      Link: https://lore.kernel.org/r/20200926125549.13191-2-kholk11@gmail.comSigned-off-by: NMark Brown <broonie@kernel.org>
      e9bb4a06
  18. 29 9月, 2020 3 次提交
  19. 22 9月, 2020 2 次提交
  20. 08 9月, 2020 1 次提交
  21. 01 9月, 2020 1 次提交
  22. 24 8月, 2020 1 次提交
  23. 19 8月, 2020 2 次提交
  24. 17 8月, 2020 7 次提交
  25. 24 7月, 2020 1 次提交
    • V
      regulator: fix memory leak on error path of regulator_register() · 9177514c
      Vladimir Zapolskiy 提交于
      The change corrects registration and deregistration on error path
      of a regulator, the problem was manifested by a reported memory
      leak on deferred probe:
      
          as3722-regulator as3722-regulator: regulator 13 register failed -517
      
          # cat /sys/kernel/debug/kmemleak
          unreferenced object 0xecc43740 (size 64):
            comm "swapper/0", pid 1, jiffies 4294937640 (age 712.880s)
            hex dump (first 32 bytes):
              72 65 67 75 6c 61 74 6f 72 2e 32 34 00 5a 5a 5a  regulator.24.ZZZ
              5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a  ZZZZZZZZZZZZZZZZ
            backtrace:
              [<0c4c3d1c>] __kmalloc_track_caller+0x15c/0x2c0
              [<40c0ad48>] kvasprintf+0x64/0xd4
              [<109abd29>] kvasprintf_const+0x70/0x84
              [<c4215946>] kobject_set_name_vargs+0x34/0xa8
              [<62282ea2>] dev_set_name+0x40/0x64
              [<a39b6757>] regulator_register+0x3a4/0x1344
              [<16a9543f>] devm_regulator_register+0x4c/0x84
              [<51a4c6a1>] as3722_regulator_probe+0x294/0x754
              ...
      
      The memory leak problem was introduced as a side ef another fix in
      regulator_register() error path, I believe that the proper fix is
      to decouple device_register() function into its two compounds and
      initialize a struct device before assigning any values to its fields
      and then using it before actual registration of a device happens.
      
      This lets to call put_device() safely after initialization, and, since
      now a release callback is called, kfree(rdev->constraints) shall be
      removed to exclude a double free condition.
      
      Fixes: a3cde953 ("regulator: core: fix regulator_register() error paths to properly release rdev")
      Signed-off-by: NVladimir Zapolskiy <vz@mleia.com>
      Cc: Wen Yang <wenyang@linux.alibaba.com>
      Link: https://lore.kernel.org/r/20200724005013.23278-1-vz@mleia.comSigned-off-by: NMark Brown <broonie@kernel.org>
      9177514c