From bf078825d137b0e1a1ec02ddd4e6d08670a6783c Mon Sep 17 00:00:00 2001 From: George Hung Date: Fri, 11 Jun 2021 13:23:25 +0800 Subject: meta-quanta: gbs: Modified pid sensor type from margin to temp - Remove read-margin-temp files and codes - Modified sensor type in pid json to temp setpoint set to target temp Kp set to Kp * scalar Ki set to Ki * scalar - Pre-detect nvme present status in fan-table-init.sh, and delete settings if nvme present is false. Signed-off-by: George Hung Change-Id: Iba4ac164a7a39ca1be109301402911d432294997 --- .../fans/phosphor-pid-control/fan-table-init.sh | 69 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) (limited to 'meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh') diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh index 9617d0da4..5ceac7ea5 100644 --- a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh @@ -15,13 +15,74 @@ mapper wait /xyz/openbmc_project/sensors/fan_tach/fb_fan2 Fan_0_To_4_Hwmon="$(ls /sys/devices/platform/ahb/ahb\:*/*pwm-fan-controller/hwmon/)" if [[ "$Fan_0_To_4_Hwmon" != "" ]]; then - sed -i "s/@Fan_0_To_4_Hwmon@/$Fan_0_To_4_Hwmon/g" $TEMP_FILE + sed -i "s/@Fan_0_To_4_Hwmon@/$Fan_0_To_4_Hwmon/g" $TEMP_FILE fi +presentGpio=() +presentState=() +gpioPath="/sys/class/gpio/gpio" +if [[ -f "/etc/nvme/nvme_config.json" ]]; then + presentGpio=($(cat /etc/nvme/nvme_config.json | grep NVMeDrivePresentPin \ + | awk '{print $2}' | cut -d "," -f 0)) +fi + +nvmePath="/xyz/openbmc_project/sensors/temperature/nvme" +nvmeInventoryPath="/xyz/openbmc_project/inventory/system/chassis/motherboard/nvme" +# Get and Set WCTEMP +for ((i = 0; i < 16; i++)); do + name="@WCTemp$(printf "%02d" $i)@" + wcTemp=72000 + + if [[ -d "${gpioPath}${presentGpio[i]}" ]] && + [[ "$(cat ${gpioPath}${presentGpio[i]}/value)" == "0" ]]; then + presentState[i]="true" + else + presentState[i]="false" + fi + + if [[ "${presentState[i]}" == "true" ]]; then + actualWCTemp=0 + for ((j = 0; j < 3; j++)); do + actualWCTemp="$( + busctl get-property xyz.openbmc_project.nvme.manager \ + ${nvmePath}${i} \ + xyz.openbmc_project.Sensor.Threshold.Critical \ + CriticalHigh | awk '{print $2}' + )" + if [[ "${actualWCTemp}" -ne 0 ]]; then + break + fi + + echo "${nvmePath}${i} WCTemp was read to be 0, retrying after 1 sec sleep" + sleep 1 + done + + if [[ "${actualWCTemp}" -ne 0 ]]; then + wcTemp="$(echo "${actualWCTemp} -7" | awk '{printf $1 + $2}')" + else + echo "${nvmePath}${i} WCTemp was read to be 0, using default WCTemp: ${wcTemp}" + fi + fi + + sed -i "s/$name/${wcTemp}/g" "$TEMP_FILE" + + if [[ "${presentState[i]}" == "false" ]]; then + sensorPath="${nvmePath}${i}" + pathLine=$(grep -nw "$sensorPath" "$TEMP_FILE" | awk -F ':' '{print $1}') + sed -i "$TEMP_FILE" -re "$((pathLine - 3)),$((pathLine + 6))d" + if [ $i -eq 15 ]; then + sed -i "$((pathLine - 4))s/,//" "$TEMP_FILE" + fi + + listLine=$(grep -n "\"name\": \"nvme${i}\"" "$TEMP_FILE" | awk -F ':' '{print $1}') + sed -i "$TEMP_FILE" -re "$((listLine - 1)),$((listLine + 21))d" + if [ $i -eq 15 ]; then + sed -i "$((listLine - 2))s/,//" "$TEMP_FILE" + fi + fi +done + # Use shell parameter expansion to trim the ".in" suffix mv "$TEMP_FILE" "${FAN_TABLE_FILE_IN%".in"}" -# start read margin temp wait -/usr/bin/read-margin-temp-wait.sh & - exit 0 -- cgit v1.2.3