Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw-mgmt: scripts: Fix creation and removal of psuN_i2c_bus files #1554

Open
wants to merge 1 commit into
base: V.7.0040.3000_BR
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wonder if we can receive such event with comex_i2c_bus.
Maybe this check is not required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was copied from hw-management-thermal-events.sh It was added by Vadim in this commit: be275d9. There are many places where comex_i2c_bus is checked

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