9fcbd5ed1d
Why I did it fix possible cpld race read issue between watchdog and reboot cause process How I did it Use fcntl.flock to limit parallel access to cpld sys file How to verify it It can be simulated and verified with following python script ``` python3 import fcntl import signal import threading exit_flag = False def get_cpld_reg_value(getreg_path, register): file = open(getreg_path, 'w+') # Acquire an exclusive lock on the file fcntl.flock(file, fcntl.LOCK_EX) try: file.write(register + '\n') file.flush() # Seek to the beginning of the file file.seek(0) # Read the content of the file result = file.readline().strip() finally: # Release the lock and close the file fcntl.flock(file, fcntl.LOCK_UN) file.close() return result def cpld_read(thread_num, cpld_reg, expect_val): while not exit_flag: val = get_cpld_reg_value("/sys/devices/platform/dx010_cpld/getreg", cpld_reg) #print(f"Thread {thread_num}: get cpld reg {cpld_reg}, value {val}") if val != expect_val: print(f"Thread {thread_num}: get cpld reg {cpld_reg}, value {val}, expect_val {expect_val}") def signal_handler(sig, frame): global exit_flag print("Ctrl+C detected. Quitting...") exit_flag = True if __name__ == '__main__': # Register the signal handler for Ctrl+C signal.signal(signal.SIGINT, signal_handler) t1 = threading.Thread(target=cpld_read, args=(1, '0x103', '0x11',)) t2 = threading.Thread(target=cpld_read, args=(2, '0x141', '0x00',)) t1.start() t2.start() t1.join() t2.join() ``` |
||
---|---|---|
.. | ||
Celestica-DX010-C32 | ||
Celestica-DX010-D48C8 | ||
led-code | ||
plugins | ||
Seastone-DX010 | ||
Seastone-DX010-10-50 | ||
Seastone-DX010-25-50 | ||
Seastone-DX010-50 | ||
Seastone-DX010-50-40 | ||
Seastone-DX010-50-50-40 | ||
sonic_platform | ||
default_sku | ||
fancontrol-B2F | ||
fancontrol-F2B | ||
installer.conf | ||
led_proc_init.soc | ||
pcie.yaml | ||
platform_asic | ||
platform_components.json | ||
platform.json | ||
pmon_daemon_control.json | ||
sensors.conf | ||
system_health_monitoring_config.json | ||
th-seastone-dx010-config-flex-all.bcm | ||
thermal_overload_control.sh | ||
thermal_policy.json |