Fixed S6000 abrupt reboot in 201811 (#6923)

Why I did it
The S6000 devices, the cold reboot is abrupt and it is likely to cause issues which will cause the device to land into EFI shell. Hence the platform reboot will happen after graceful unmount of all the filesystems as in S6100.

How I did it
Moved the platform_reboot to platform_reboot_override and hooked it to the systemd shutdown services as in S6100.
Fixed the "/host unmount failed" issue as well in 201811.

How to verify it
Issue "reboot" command to verify if the reboot is happening gracefully.
This commit is contained in:
rkdevi27 2021-03-13 00:39:54 +05:30 committed by GitHub
parent 2877cc9ff6
commit 6c2fd18f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 99 additions and 63 deletions

View File

@ -1,63 +0,0 @@
#!/usr/bin/env python
import sys
import os
import struct
PORT_RES = '/dev/port'
NVRAM_RES = '/dev/nvram'
COLD_RESET = 0xE # Cold Reset
WARM_RESET = 0x6 # Warm Reset
RESET_REG = 0xCF9
def io_reg_write(resource, offset, val):
fd = os.open(resource, os.O_RDWR)
if fd < 0:
print('file open failed %s" % resource')
return
if os.lseek(fd, offset, os.SEEK_SET) != offset:
print('lseek failed on %s' % resource)
return
ret = os.write(fd, struct.pack('B', val))
if ret != 1:
print('write failed %d' % ret)
return
os.close(fd)
def power_reset(val):
with open('/sys/devices/platform/dell-s6000-cpld.0/power_reset', 'w') as p:
p.write(str(int(val)) + '\n')
p.flush()
def gpio_direction(pin, direction):
kernpath = '/sys/class/gpio/gpio'+str(pin)+'/direction'
with open(('kernpath'), 'w') as p:
p.write(str(direction) + '\n')
p.flush()
def gpio_set(pin, value):
kernpath = '/sys/class/gpio/gpio'+str(pin)+'/value'
with open(('kernpath'), 'w') as p:
p.write(str(int(value)) + '\n')
p.flush()
def gpio_export(value):
with open('/sys/class/gpio/export', 'w') as p:
p.write(str(int(value)) + '\n')
p.flush()
if __name__ == "__main__":
retry_count = 0
io_reg_write(NVRAM_RES, 0x49, COLD_RESET)
while retry_count < 3:
if not os.path.isdir("/sys/class/gpio/gpio10"):
gpio_export(10)
gpio_direction("10", "out")
# Toggle GPIO10 pin (to reset MUX)
gpio_set("10", 1)
gpio_set("10", 0)
power_reset(1)
retry_count += 1
io_reg_write(PORT_RES, RESET_REG, COLD_RESET)

View File

@ -171,6 +171,11 @@ sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/
# Copy syslog override files
sudo mkdir -p $FILESYSTEM_ROOT/etc/systemd/system/syslog.socket.d
sudo cp $IMAGE_CONFIGS/syslog/override.conf $FILESYSTEM_ROOT/etc/systemd/system/syslog.socket.d/override.conf
sudo cp $IMAGE_CONFIGS/syslog/host_umount.sh $FILESYSTEM_ROOT/usr/bin/
# Copy logrotate.d configuration files
sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate.d/

View File

@ -0,0 +1,31 @@
#!/bin/bash
# This script is invoked at the closure of syslog socket during reboot
# This will stop journal services, unmount /var/log and delete loop device
# associated to /host to ensure proper unmount of /host
journal_stop() {
systemctl stop systemd-journald.service
}
delete_loop_device() {
umount /var/log
if [[ $? -ne 0 ]]
then
exit 0
fi
loop_exist=$(losetup -a | grep loop1 | wc -l)
if [ $loop_exist -ne 0 ]; then
losetup -d /dev/loop1
fi
}
case "$1" in
journal_stop|delete_loop_device)
$1
;;
*)
echo "Usage: $0 {journal_stop|delete_loop_device}" >&2
exit 1
;;
esac

View File

@ -0,0 +1,6 @@
[Unit]
After=var-log.mount host.mount local-fs.target
[Socket]
ExecStopPre=/usr/bin/host_umount.sh journal_stop
ExecStopPost=/usr/bin/host_umount.sh delete_loop_device

View File

@ -3,4 +3,7 @@ s6000/scripts/reset-qsfp usr/local/bin
s6000/scripts/set-fan-speed usr/local/bin
s6000/systemd/platform-modules-s6000.service etc/systemd/system
common/io_rd_wr.py usr/local/bin
s6000/scripts/platform_reboot_override usr/share/sonic/device/x86_64-dell_s6000_s1220-r0
s6000/scripts/platform_update_reboot_cause usr/share/sonic/device/x86_64-dell_s6000_s1220-r0
s6000/scripts/override.conf /etc/systemd/system/systemd-reboot.service.d
s6000/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6000_s1220-r0

View File

@ -0,0 +1,3 @@
[Service]
ExecStart=
ExecStart=/usr/share/sonic/device/x86_64-dell_s6000_s1220-r0/platform_reboot_override

View File

@ -0,0 +1,26 @@
#!/usr/bin/env python
import os
import struct
PORT_RES = '/dev/port'
COLD_RESET = 0xE # Cold Reset
WARM_RESET = 0x6 # Warm Reset
RESET_REG = 0xCF9
def io_reg_write(resource, offset, val):
fd = os.open(resource, os.O_RDWR)
if fd < 0:
print('file open failed %s" % resource')
return
if os.lseek(fd, offset, os.SEEK_SET) != offset:
print('lseek failed on %s' % resource)
return
ret = os.write(fd, struct.pack('B', val))
if ret != 1:
print('write failed %d' % ret)
return
os.close(fd)
if __name__ == "__main__":
io_reg_write(PORT_RES, RESET_REG, COLD_RESET)

View File

@ -0,0 +1,25 @@
#!/usr/bin/env python
import os
import struct
NVRAM_RES = '/dev/nvram'
COLD_RESET = 0xE # Cold Reset
WARM_RESET = 0x6 # Warm Reset
def io_reg_write(resource, offset, val):
fd = os.open(resource, os.O_RDWR)
if fd < 0:
print('file open failed %s" % resource')
return
if os.lseek(fd, offset, os.SEEK_SET) != offset:
print('lseek failed on %s' % resource)
return
ret = os.write(fd, struct.pack('B', val))
if ret != 1:
print('write failed %d' % ret)
return
os.close(fd)
if __name__ == "__main__":
io_reg_write(NVRAM_RES, 0x49, COLD_RESET)