1. Apr 03, 2023
  2. Mar 30, 2023
  3. Mar 28, 2023
  4. Mar 24, 2023
  5. Mar 23, 2023
  6. Mar 21, 2023
    • Mark Brown's avatar
      regulator: Set PROBE_PREFER_ASYNCHRONOUS for · 02ce28bc
      Mark Brown authored
      Merge series from Douglas Anderson <dianders@chromium.org>:
      
      This series directly follows from the discussion when I tried to turn
      on PROBE_PREFER_ASYNCHRONOUS just for the fixed-regulator [1] and
      attempts to switch everything in drivers/regulator over to async
      probe.
      
      Like the similar patch series I did for the MMC subsystem a few years
      ago [2], I've split this patch series into batches corresponding to
      drivers corresponding to actively maintained stable kernel trees with
      the idea to break the patch series up somewhat.
      
      Most of the description of this series is contained in the first patch
      of the series and then the further patches simply refer back to the
      first one. The logic and reasoning behind all the patches is exactly
      the same.
      
      As talked about in the first patch, it wouldn't be at all shocking if
      this broke someone. Hopefully this doesn't cause too much of a
      problem. Most of the problems expected would be real underlying bugs
      that already existed and were just tickled by this change. If you're
      facing a problem, it's fairly easy to force individual drivers back to
      "synchronous" probing while the problem is tracked down and fixed.
      
      I am opting _not_ to CC every single person involved in each of these
      regulators on this patch series because I suspect that the mailing
      lists couldn't handle CCing that many people. This should be on LKML
      so hopefully people can find it there and respond to it that
      way. Anyone who responds will get CCed on future versions, if there
      are any.
      
      For reference, the ugly script I used is here:
        import os
        import re
      
        for filename in os.listdir("."):
            found_subsys = False
            found_driver = False
            output = []
            for line in open(filename, "r").readlines():
                if "struct platform_driver" in line or \
                   "struct i2c_driver" in line or \
                   "struct spmi_driver" in line or \
                   "struct spi_driver" in line:
                    found_subsys = True
                if found_subsys and re.search(r"\t\.driver\s*=\s*{", line):
                    found_driver = True
                    found_subsys = False
                mo = re.search(r"(\s*)\.name(\s*)=", line)
                if found_driver and mo:
                    if not line.endswith(",\n"):
                        line = line[:-1] + ",\n"
                    output.append(line)
      
                    if mo.group(2) == " ":
                        space = " "
                    elif mo.group(2) == "\t":
                        # Best we can do
                        space = " "
                    elif mo.group(2).startswith("\t"):
                        # Guess that removing one tab is right
                        space = mo.group(2)[1:]
                    else:
                        # Guess it's all spaces
                        space = mo.group(2)[7:] + " "
      
                    output.append("%s.probe_type%s= PROBE_PREFER_ASYNCHRONOUS,\n" % (mo.group(1), space))
                    found_driver = False
                else:
                    output.append(line)
      
            open(filename, "w").write("".join(output))
      
      I manually split drivers up into groups based on the kernel they were
      introduced in.
      
      I've run a compile test against "allyesconfig" on amd64, arm32, and
      arm64 with this and confirmed it compiled. I've booted this on a
      sc7180-trogdor-lazor board and confirmed it booted OK and got the boot
      speed improvements I expected and that dmesg was as expected.
      
      [1] https://lore.kernel.org/r/06db017f-e985-4434-8d1d-02ca2100cca0@sirena.org.uk
      [2] https://lore.kernel.org/r/20200903232441.2694866-1-dianders@chromium.org/
      
      Douglas Anderson (7):
        regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in
          4.14
        regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 4.14 and
          4.19
        regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 4.19 and
          5.4
        regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 5.4 and
          5.10
        regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 5.10 and
          5.15
        regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 5.15 and
          6.1
        regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that are newer
          than 6.1
      
       drivers/regulator/88pg86x.c                    | 1 +
       drivers/regulator/88pm800-regulator.c          | 1 +
       drivers/regulator/88pm8607.c                   | 1 +
       drivers/regulator/aat2870-regulator.c          | 1 +
       drivers/regulator/ab8500-ext.c                 | 1 +
       drivers/regulator/ab8500.c                     | 1 +
       drivers/regulator/act8865-regulator.c          | 1 +
       drivers/regulator/act8945a-regulator.c         | 1 +
       drivers/regulator/ad5398.c                     | 1 +
       drivers/regulator/anatop-regulator.c           | 1 +
       drivers/regulator/arizona-ldo1.c               | 2 ++
       drivers/regulator/arizona-micsupp.c            | 2 ++
       drivers/regulator/as3711-regulator.c           | 1 +
       drivers/regulator/as3722-regulator.c           | 1 +
       drivers/regulator/atc260x-regulator.c          | 1 +
       drivers/regulator/axp20x-regulator.c           | 1 +
       drivers/regulator/bcm590xx-regulator.c         | 1 +
       drivers/regulator/bd71815-regulator.c          | 1 +
       drivers/regulator/bd71828-regulator.c          | 3 ++-
       drivers/regulator/bd718x7-regulator.c          | 1 +
       drivers/regulator/bd9571mwv-regulator.c        | 1 +
       drivers/regulator/bd9576-regulator.c           | 1 +
       drivers/regulator/cpcap-regulator.c            | 1 +
       drivers/regulator/cros-ec-regulator.c          | 1 +
       drivers/regulator/da903x-regulator.c           | 1 +
       drivers/regulator/da9052-regulator.c           | 1 +
       drivers/regulator/da9055-regulator.c           | 1 +
       drivers/regulator/da9062-regulator.c           | 1 +
       drivers/regulator/da9063-regulator.c           | 1 +
       drivers/regulator/da9121-regulator.c           | 1 +
       drivers/regulator/da9210-regulator.c           | 1 +
       drivers/regulator/da9211-regulator.c           | 1 +
       drivers/regulator/db8500-prcmu.c               | 1 +
       drivers/regulator/dummy.c                      | 1 +
       drivers/regulator/fan53555.c                   | 1 +
       drivers/regulator/fan53880.c                   | 1 +
       drivers/regulator/fixed.c                      | 1 +
       drivers/regulator/gpio-regulator.c             | 1 +
       drivers/regulator/hi6421-regulator.c           | 1 +
       drivers/regulator/hi6421v530-regulator.c       | 1 +
       drivers/regulator/hi6421v600-regulator.c       | 1 +
       drivers/regulator/hi655x-regulator.c           | 1 +
       drivers/regulator/isl6271a-regulator.c         | 1 +
       drivers/regulator/isl9305.c                    | 1 +
       drivers/regulator/lm363x-regulator.c           | 1 +
       drivers/regulator/lochnagar-regulator.c        | 1 +
       drivers/regulator/lp3971.c                     | 1 +
       drivers/regulator/lp3972.c                     | 1 +
       drivers/regulator/lp872x.c                     | 1 +
       drivers/regulator/lp873x-regulator.c           | 1 +
       drivers/regulator/lp8755.c                     | 1 +
       drivers/regulator/lp87565-regulator.c          | 1 +
       drivers/regulator/lp8788-buck.c                | 1 +
       drivers/regulator/lp8788-ldo.c                 | 2 ++
       drivers/regulator/ltc3589.c                    | 1 +
       drivers/regulator/ltc3676.c                    | 1 +
       drivers/regulator/max14577-regulator.c         | 1 +
       drivers/regulator/max1586.c                    | 1 +
       drivers/regulator/max20086-regulator.c         | 1 +
       drivers/regulator/max20411-regulator.c         | 1 +
       drivers/regulator/max597x-regulator.c          | 1 +
       drivers/regulator/max77620-regulator.c         | 1 +
       drivers/regulator/max77650-regulator.c         | 1 +
       drivers/regulator/max77686-regulator.c         | 1 +
       drivers/regulator/max77693-regulator.c         | 1 +
       drivers/regulator/max77802-regulator.c         | 1 +
       drivers/regulator/max77826-regulator.c         | 1 +
       drivers/regulator/max8649.c                    | 1 +
       drivers/regulator/max8660.c                    | 1 +
       drivers/regulator/max8893.c                    | 1 +
       drivers/regulator/max8907-regulator.c          | 1 +
       drivers/regulator/max8925-regulator.c          | 1 +
       drivers/regulator/max8952.c                    | 1 +
       drivers/regulator/max8973-regulator.c          | 1 +
       drivers/regulator/max8997-regulator.c          | 1 +
       drivers/regulator/max8998.c                    | 1 +
       drivers/regulator/mc13783-regulator.c          | 1 +
       drivers/regulator/mc13892-regulator.c          | 1 +
       drivers/regulator/mcp16502.c                   | 1 +
       drivers/regulator/mp5416.c                     | 1 +
       drivers/regulator/mp8859.c                     | 1 +
       drivers/regulator/mp886x.c                     | 1 +
       drivers/regulator/mpq7920.c                    | 1 +
       drivers/regulator/mt6311-regulator.c           | 1 +
       drivers/regulator/mt6315-regulator.c           | 1 +
       drivers/regulator/mt6323-regulator.c           | 1 +
       drivers/regulator/mt6331-regulator.c           | 1 +
       drivers/regulator/mt6332-regulator.c           | 1 +
       drivers/regulator/mt6357-regulator.c           | 1 +
       drivers/regulator/mt6358-regulator.c           | 1 +
       drivers/regulator/mt6359-regulator.c           | 1 +
       drivers/regulator/mt6360-regulator.c           | 1 +
       drivers/regulator/mt6370-regulator.c           | 1 +
       drivers/regulator/mt6380-regulator.c           | 1 +
       drivers/regulator/mt6397-regulator.c           | 1 +
       drivers/regulator/mtk-dvfsrc-regulator.c       | 1 +
       drivers/regulator/palmas-regulator.c           | 1 +
       drivers/regulator/pbias-regulator.c            | 1 +
       drivers/regulator/pca9450-regulator.c          | 1 +
       drivers/regulator/pcap-regulator.c             | 1 +
       drivers/regulator/pcf50633-regulator.c         | 1 +
       drivers/regulator/pf8x00-regulator.c           | 1 +
       drivers/regulator/pfuze100-regulator.c         | 1 +
       drivers/regulator/pv88060-regulator.c          | 1 +
       drivers/regulator/pv88080-regulator.c          | 1 +
       drivers/regulator/pv88090-regulator.c          | 1 +
       drivers/regulator/pwm-regulator.c              | 1 +
       drivers/regulator/qcom-labibb-regulator.c      | 1 +
       drivers/regulator/qcom-rpmh-regulator.c        | 1 +
       drivers/regulator/qcom_rpm-regulator.c         | 1 +
       drivers/regulator/qcom_smd-regulator.c         | 1 +
       drivers/regulator/qcom_spmi-regulator.c        | 1 +
       drivers/regulator/qcom_usb_vbus-regulator.c    | 1 +
       drivers/regulator/rc5t583-regulator.c          | 1 +
       drivers/regulator/rk808-regulator.c            | 3 ++-
       drivers/regulator/rn5t618-regulator.c          | 1 +
       drivers/regulator/rpi-panel-attiny-regulator.c | 1 +
       drivers/regulator/rt4801-regulator.c           | 1 +
       drivers/regulator/rt4831-regulator.c           | 1 +
       drivers/regulator/rt5033-regulator.c           | 1 +
       drivers/regulator/rt5120-regulator.c           | 1 +
       drivers/regulator/rt5190a-regulator.c          | 1 +
       drivers/regulator/rt5739.c                     | 1 +
       drivers/regulator/rt5759-regulator.c           | 1 +
       drivers/regulator/rt6160-regulator.c           | 1 +
       drivers/regulator/rt6190-regulator.c           | 1 +
       drivers/regulator/rt6245-regulator.c           | 1 +
       drivers/regulator/rtmv20-regulator.c           | 1 +
       drivers/regulator/rtq2134-regulator.c          | 1 +
       drivers/regulator/rtq6752-regulator.c          | 1 +
       drivers/regulator/s2mpa01.c                    | 1 +
       drivers/regulator/s2mps11.c                    | 1 +
       drivers/regulator/s5m8767.c                    | 1 +
       drivers/regulator/sc2731-regulator.c           | 1 +
       drivers/regulator/sky81452-regulator.c         | 1 +
       drivers/regulator/slg51000-regulator.c         | 1 +
       drivers/regulator/sm5703-regulator.c           | 1 +
       drivers/regulator/stm32-booster.c              | 1 +
       drivers/regulator/stm32-pwr.c                  | 1 +
       drivers/regulator/stm32-vrefbuf.c              | 1 +
       drivers/regulator/stpmic1_regulator.c          | 1 +
       drivers/regulator/stw481x-vmmc.c               | 1 +
       drivers/regulator/sy7636a-regulator.c          | 1 +
       drivers/regulator/sy8106a-regulator.c          | 1 +
       drivers/regulator/sy8824x.c                    | 1 +
       drivers/regulator/sy8827n.c                    | 1 +
       drivers/regulator/ti-abb-regulator.c           | 1 +
       drivers/regulator/tps51632-regulator.c         | 1 +
       drivers/regulator/tps6105x-regulator.c         | 1 +
       drivers/regulator/tps62360-regulator.c         | 1 +
       drivers/regulator/tps6286x-regulator.c         | 1 +
       drivers/regulator/tps65023-regulator.c         | 1 +
       drivers/regulator/tps6507x-regulator.c         | 1 +
       drivers/regulator/tps65086-regulator.c         | 1 +
       drivers/regulator/tps65090-regulator.c         | 1 +
       drivers/regulator/tps65132-regulator.c         | 1 +
       drivers/regulator/tps65217-regulator.c         | 1 +
       drivers/regulator/tps65218-regulator.c         | 1 +
       drivers/regulator/tps65219-regulator.c         | 1 +
       drivers/regulator/tps6524x-regulator.c         | 1 +
       drivers/regulator/tps6586x-regulator.c         | 1 +
       drivers/regulator/tps65910-regulator.c         | 1 +
       drivers/regulator/tps65912-regulator.c         | 1 +
       drivers/regulator/tps68470-regulator.c         | 1 +
       drivers/regulator/twl-regulator.c              | 1 +
       drivers/regulator/twl6030-regulator.c          | 1 +
       drivers/regulator/uniphier-regulator.c         | 1 +
       drivers/regulator/userspace-consumer.c         | 1 +
       drivers/regulator/vctrl-regulator.c            | 1 +
       drivers/regulator/vexpress-regulator.c         | 1 +
       drivers/regulator/virtual.c                    | 1 +
       drivers/regulator/vqmmc-ipq4019-regulator.c    | 1 +
       drivers/regulator/wm831x-dcdc.c                | 4 ++++
       drivers/regulator/wm831x-isink.c               | 1 +
       drivers/regulator/wm831x-ldo.c                 | 3 +++
       drivers/regulator/wm8350-regulator.c           | 1 +
       drivers/regulator/wm8400-regulator.c           | 1 +
       drivers/regulator/wm8994-regulator.c           | 1 +
       178 files changed, 188 insertions(+), 2 deletions(-)
      
      --
      2.40.0.rc1.284.g88254d51c5-goog
      02ce28bc
  7. Mar 20, 2023
  8. Mar 14, 2023
    • Douglas Anderson's avatar
      regulator: core: Shorten off-on-delay-us for always-on/boot-on by time since booted · 691c1fcd
      Douglas Anderson authored
      This is very close to a straight revert of commit 218320fe
      ("regulator: core: Fix off-on-delay-us for always-on/boot-on
      regulators"). We've identified that patch as causing a boot speed
      regression on sc7180-trogdor boards. While boot speed certainly isn't
      more important than making sure that power sequencing is correct,
      looking closely at the original change it doesn't seem to have been
      fully justified. It mentions "cycling issues" without describing
      exactly what the issues were. That means it's possible that the
      cycling issues were really a problem that should be fixed in a
      different way.
      
      Let's take a careful look at how we should handle regulators that have
      an off-on-delay and that are boot-on or always-on. Linux currently
      doesn't have any way to identify whether a GPIO regulator was already
      on when the kernel booted. That means that when the kernel boots we
      probe a regulator, see that it wants boot-on / always-on we, and then
      turn the regulator on. We could be in one of two cases when we do
      this:
      
      a) The regulator might have been left on by the bootloader and we're
         ensuring that it stays on.
      b) The regulator might have been left off by the bootloader and we're
         just now turning it on.
      
      For case a) we definitely don't need any sort of delay. For case b) we
      _might_ need some delay in case the bootloader turned the regulator
      off _right_ before booting the kernel. To get the proper delay for
      case b) then we can just assume a `last_off` of 0, which is what it
      gets initialized to by default.
      
      As per above, we can't tell whether we're in case a) or case b) so
      we'll assume the longer delay (case b). This basically puts the code
      to how it was before commit 218320fe ("regulator: core: Fix
      off-on-delay-us for always-on/boot-on regulators"). However, we add
      one important change: we make sure that the delay is actually honored
      if `last_off` is 0. Though the original "cycling issues" cited were
      vague, I'm hopeful that this important extra change will be enough to
      fix the issues that the initial commit mentioned.
      
      With this fix, I've confined that on a sc7180-trogdor board the delay
      at boot goes down from 500 ms to ~250 ms. That's not as good as the 0
      ms that we had prior to commit 218320fe ("regulator: core: Fix
      off-on-delay-us for always-on/boot-on regulators"), but it's probably
      safer because we don't know if the bootloader turned the regulator off
      right before booting.
      
      One note is that it's possible that we could be in a state that's not
      a) or b) if there are other issues in the kernel. The only one I can
      think of is related to pinctrl. If the pinctrl driver being used on a
      board isn't careful about avoiding glitches when setting up a pin then
      it's possible that setting up a pin could cause the regulator to "turn
      off" briefly immediately before the regulator probes. If this is
      indeed causing problems then the pinctrl driver should be fixed,
      perhaps in a similar way to what was done in commit d21f4b7f
      ("pinctrl: qcom: Avoid glitching lines when we first mux to output")
      
      Fixes: 218320fe
      
       ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators")
      Cc: Christian Kohlschütter <christian@kohlschutter.com>
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Link: https://lore.kernel.org/r/20230313111806.1.I2eaad872be0932a805c239a7c7a102233fb0b03b@changeid
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      691c1fcd
  9. Mar 13, 2023
  10. Mar 12, 2023
  11. Mar 11, 2023