Skip to content

Commit

Permalink
hw-mgmt: scripts: Fix creation and removal of psuN_i2c_bus files
Browse files Browse the repository at this point in the history
These files are created when PSU cables are plugged in
and removed when PSU cable are plugged out. Instead,
they should be created and removed when PSUs are plugged in
and plugged out respectively. Otherwise there is no way to
distingush between dummy PSU and real PSU that was
disconnected from power.

Bug: 4176785

Signed-off-by: Felix Radensky <[email protected]>
  • Loading branch information
felixradensky committed Jan 16, 2025
1 parent 26bc4ed commit 4f9e9cf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
25 changes: 25 additions & 0 deletions usr/usr/bin/hw-management-chassis-events.sh
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,31 @@ function handle_hotplug_event()
fi
fi
;;
psu*)
psu_name="$attribute"
# SN5600, SN5400 systems have PSU2 with I2C address 0x5a. In udev rules 0x5a corresponds to psu4.
if [[ ( $sku == "HI144" || $sku == "HI147" ) && "$2" == "psu4" ]]; then
psu_name="psu2"
fi
find_i2c_bus
i2c_comex_mon_bus_default=$(< $i2c_comex_mon_bus_default_file)
comex_bus=$((i2c_comex_mon_bus_default+i2c_bus_offset))
busdir=$(echo "$5""$3" |xargs dirname |xargs dirname)
busfolder=$(basename "$busdir")
bus="${busfolder:0:${#busfolder}-5}"
# Verify if this is COMEX device
if [ "$bus" == "$comex_bus" ]; then
return
fi

if [ "$event" -eq 1 ]; then
echo "$bus" > $config_path/"$psu_name"_i2c_bus
else
if [ -e "$config_path"/"$psu_name"_i2c_bus ]; then
rm -f $config_path/"$psu_name"_i2c_bus
fi
fi
;;
*)
;;
esac
Expand Down
5 changes: 0 additions & 5 deletions usr/usr/bin/hw-management-thermal-events.sh
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,6 @@ if [ "$1" == "add" ]; then
# Allow PS controller to stabilize
retry_helper "ls" 0.2 20 "$2 takes too long to init" "$5""$3"/in1_input
sleep 1
# Set I2C bus for psu
echo "$bus" > $config_path/"$psu_name"_i2c_bus
# Set default fan speed
psu_set_fan_speed "$psu_name" $(< $fan_psu_default)
# Add thermal attributes
Expand Down Expand Up @@ -1421,9 +1419,6 @@ else
rm -f "$config_path"/"$psu_name"_power_slope
rm -f "$config_path"/"$psu_name"_power_capacity
fi
if [ -e "$config_path"/"$psu_name"_i2c_bus ]; then
rm -f "$config_path"/"$psu_name"_i2c_bus
fi
fi
if [ "$2" == "sxcore" ]; then
/usr/bin/hw-management.sh chipdown 0 "$4/$5"
Expand Down

0 comments on commit 4f9e9cf

Please sign in to comment.