psu-ng: Missing power supply helper

The PowerSupply object will update a power supply to present when the
default value of missing (present=false) changes to present
(present=true). The PowerSupply objects do not know if a missing power
supply is required, so it does not mark power supplies as missing,
unless the present property changes from true to false.

Add a function to the PSUManager for getting required power supplies
that are missing marked as missing in the inventory.

We need the entity-manager configuration information, to know how many
power supplies are required.

Do not skip over power supplies that have no input voltage.

Read the D-Bus Present property to see if it was previously set. If no
read failure is encountered attempting to read that D-Bus property, and
the value returned does not match the value returned by the PowerSupply
object, and the local configuration checking model variable indicates it
is empty, then set the D-Bus Present property to false (missing). This
should fix Present true after it moved. Skip setting to false if
property read failed (never set to true or false).

Call updateMissingPSUs() in initialize() to handle when the process
starts up after entity-manager has already finished adding the
configuration information to D-Bus. Call updateMissingPSUs() after
entity-manager adds interface, possible configuration information.

Tested:
  Rainier 1S4U (simulated):
    Startup with bottom two power supplies present
    Verify presence after BMC_READY
      i2cdetect to scan bus, verify 0x6a and 0x6b.
      D-Bus get-property Present for each supply.
        powersupply0 - not set.
        powersupply1 - not set.
        powersupply2 - Present=true.
        powersupply3 - Present=true.
    Chassison
    Verify no errors for missing power supplies.
    Chassisoff
    Verify no power supply errors....
    Remove powersupply2.
    Reboot BMC (substitute for AC reset)
    Remove powersupply3 during reboot.
    Install powersupply0.
    Install powersupply1.
    Verify at BMC_READY
      No unexpected errors.
      No dumps.
      powersupply0 - Present=true, in bus scan.
      powersupply1 - Present=true, in bus scan.
      powersupply2 - Present=false, NOT in bus scan.
      powersupply3 - Present=false, NOT in bus scan.
    Chassison.
    Verify no errors, same presence and scan results.
    Chassisoff.
    Swap power supplies back
      Remove powersupply0
      Reboot BMC...
      Remove powersupply1
      Install powersupply2
      Install powersupply3
    Verify at BMC_READY
      No unexpected errors.
      No dumps.
      powersupply0 - Present=false, NOT in bus scan.
      powersupply1 - Present=false, NOT in bus scan.
      powersupply2 - Present=true, in bus scan.
      powersupply3 - Present=true, in bus scan.
    Chassison.
    Verify no errors, same presence and scan results.
    Remove powersupply2.
    Install powersupply0.
    Verify change.
      110015F6 with powersupply2 callout
      powersupply2 missing in scan and D-Bus property.
      powersupply0 present in scan and B-Bus property.
    Remove powersupply3.
    Install powersupply1.
    Verify change.
      110015F6 with powersupply3 callout
      powersupply3 missing in scan and D-Bus property.
      powersupply1 present in scan and B-Bus property.
    Remove powersupply0.
    Install powersupply2.
    Verify change.
      110015F6 with powersupply0 callout
      powersupply0 missing in scan and D-Bus property.
      powersupply2 present in scan and B-Bus property.
    Remove powersupply1.
    Install powersupply3.
    Verify change.
      110015F6 with powersupply1 callout
      powersupply1 missing in scan and D-Bus property.
      powersupply3 present in scan and B-Bus property.

  Rainier 2S4U (simulated):
     1. Startup Rainier 2S4U with one power supply.
     2. Verify 3 missing, 1 present, no errors at standby.
     3. Add in 3 missing supplies, verify presence.
     4. Reboot, verify presence, all four should be present.
     5. Chassison.
     6. Verify no errors.
     7. Remove, verify, error, insert, for each supply.
     8. Chassisoff.
     9. Verify no errors.
    10. Verify all four power supplies present.

  Rainier 2S2U (simulated):
     1. Startup Rainier 2S4U with one power supply.
     2. Verify psu0 missing, psu1 present, no errors at standby.
     3. Add in missing psu0, verify presence.
     4. Reboot, verify presence, both should be present (no extras)
     5. Verify all good, then Chassison.
     6. Verify no errors after chassison.
     7. Remove, verify, error, insert, for each supply.
     8. Chassisoff.
     9. Verify no errors.
    10. Verify both power supplies present.
    11. Remove psu1.
    12. Reboot, remove psu0, install psu1 (AC reset due to all remove,
        and install psu1).
    13. Check status...Verify psu0 missing, psu1 present.
    14. Chassison, verify 110015F6...
        # Hit other bug, powersupply2 and powersupply3 missing errors.
    15. Install psu0, verify...
    16. off/on/error check.

Change-Id: I4ee12c61e0ec9b105247b4ec40b0925e0af329f4
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
2 files changed
tree: d91912a0bd5a114e6bd50908176cc24825e16fb5
  1. cold-redundancy/
  2. example/
  3. org/
  4. phosphor-power-sequencer/
  5. phosphor-power-supply/
  6. phosphor-regulators/
  7. power-sequencer/
  8. power-supply/
  9. services/
  10. test/
  11. tools/
  12. .clang-format
  13. .gitignore
  14. .shellcheck
  15. argument.hpp
  16. device.hpp
  17. device_monitor.hpp
  18. elog-errors.hpp
  19. file_descriptor.hpp
  20. gpio.cpp
  21. gpio.hpp
  22. LICENSE
  23. MAINTAINERS
  24. meson.build
  25. meson_options.txt
  26. names_values.hpp
  27. OWNERS
  28. pmbus.cpp
  29. pmbus.hpp
  30. README.md
  31. types.hpp
  32. utility.cpp
  33. utility.hpp
README.md

Overview

This repository contains applications for configuring and monitoring devices that deliver power to the system.

  • cold-redundancy: Application that makes power supplies work in Cold Redundancy mode and rotates them at intervals.
  • phosphor-power-sequencer: Applications for configuring and monitoring power sequencer and related devices that support JSON-driven configuration.
  • phosphor-power-supply: Next generation power supply monitoring application.
  • phosphor-regulators: JSON-driven application that configures and monitors voltage regulators.
  • power-sequencer: A power sequencer monitoring application.
  • power-supply: Original power supply monitoring application.
  • tools/power-utils: Power supply utilities.

Build

To build all applications in this repository:

  meson build
  ninja -C build

To clean the repository and remove all build output:

  rm -rf build

You can specify meson options to customize the build process. For example, you can specify:

  • Which applications to build and install.
  • Application-specific configuration data, such as power sequencer type.
  • Whether to build tests.

Power Supply Monitor and Util JSON config

Several applications in this repository require a PSU JSON config to run. The JSON config file provides information for:

  • Where to access the pmbus attributes
  • Which attribute file in pmbus maps to which property and interface in D-Bus
  • Which kernel device directory is used on which PSU

There is an example psu.json to describe the necessary configurations.

  • inventoryPMBusAccessType defines the pmbus access type, which tells the service which sysfs type to use to read the attributes. The possible values are:
    • Base: The base dir, e.g. /sys/bus/i2c/devices/3-0069/
    • Hwmon: The hwmon dir, e.g. /sys/bus/i2c/devices/3-0069/hwmon/hwmonX/
    • Debug: The pmbus debug dir, e.g. /sys/kernel/debug/pmbus/hwmonX/
    • DeviceDebug: The device debug dir, e.g. '/sys/kernel/debug/./`
    • HwmonDeviceDebug: The hwmon device debug dir, e.g. /sys/kernel/debug/pmbus/hwmonX/cffps1/
  • fruConfigs defines the mapping between the attribute file and the FRU inventory interface and property. The configuration example below indicates that the service will read part_number attribute file from a directory specified by the above pmbus access type, and assign to PartNumber property in xyz.openbmc_project.Inventory.Decorator.Asset interface.
      "fruConfigs": [
        {
          "propertyName": "PartNumber",
          "fileName": "part_number",
          "interface": "xyz.openbmc_project.Inventory.Decorator.Asset"
        }
      ]
    
  • psuDevices defines the kernel device dir for each PSU in inventory. The configuration example below indicates that powersupply0's device is located in /sys/bus/i2c/devices/3-0069.
      "psuDevices": {
        "/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0" : "/sys/bus/i2c/devices/3-0069",
      }