sonic-buildimage/device/celestica/x86_64-cel_seastone-r0
Ikki Zhu 9fcbd5ed1d
fix possible cpld race access issue (#15371)
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()
```
2023-06-07 11:29:18 -07:00
..
Celestica-DX010-C32 Enable Dx010 LPM (#12642) 2022-11-09 08:15:41 -08:00
Celestica-DX010-D48C8 Enable Dx010 LPM (#12642) 2022-11-09 08:15:41 -08:00
led-code [Celestica]: Update port led code for seastone-xp (#2476) 2019-01-23 18:44:19 -08:00
plugins [pcie.yaml] Move pcie configuration file path to platform directory (#6475) 2021-02-21 08:27:37 -08:00
Seastone-DX010 [DPB Seastone] On boarding DPB feature to Seastone HWSKUs (#4235) 2020-09-18 15:29:29 -07:00
Seastone-DX010-10-50 [DPB Seastone] On boarding DPB feature to Seastone HWSKUs (#4235) 2020-09-18 15:29:29 -07:00
Seastone-DX010-25-50 [DPB Seastone] On boarding DPB feature to Seastone HWSKUs (#4235) 2020-09-18 15:29:29 -07:00
Seastone-DX010-50 [DPB Seastone] On boarding DPB feature to Seastone HWSKUs (#4235) 2020-09-18 15:29:29 -07:00
Seastone-DX010-50-40 [DPB Seastone] On boarding DPB feature to Seastone HWSKUs (#4235) 2020-09-18 15:29:29 -07:00
Seastone-DX010-50-50-40 [Seastone] Add new HWSKU for 48x50G+8x40G (#4156) 2020-04-04 22:52:34 -07:00
sonic_platform fix possible cpld race access issue (#15371) 2023-06-07 11:29:18 -07:00
default_sku [updategraph] add support to use preset config instead of default minigraph (#2050) 2018-09-21 22:01:10 -07:00
fancontrol-B2F [device/celestica]: Add thermalctld support on DX010 platform APIs (#6089) 2021-01-15 10:20:47 -08:00
fancontrol-F2B [device/celestica]: Add thermalctld support on DX010 platform APIs (#6089) 2021-01-15 10:20:47 -08:00
installer.conf [device/celestica] seastone add gpio_ich driver module blacklist (#2691) 2019-03-25 15:49:35 -07:00
led_proc_init.soc Replace CRLF line endings with LF (#932) 2017-09-01 15:28:46 -07:00
pcie.yaml [pcie.yaml] Move pcie configuration file path to platform directory (#6475) 2021-02-21 08:27:37 -08:00
platform_asic Add platform_asic file to each platform folder in sonic-device-data based package (#8542) 2021-10-08 19:27:48 -07:00
platform_components.json [DX010 platform] fix dx010 platform testcase issues (#13595) 2023-02-09 19:07:13 -08:00
platform.json add psu fans status led available config (#13926) 2023-02-22 10:55:55 -08:00
pmon_daemon_control.json [device/celestica]: Fix xcvrd error (#3979) 2020-01-10 12:50:51 -08:00
sensors.conf [device/celestica]: Implement thermal base API based on the new platform API (#3220) 2019-08-05 09:01:50 -07:00
system_health_monitoring_config.json [Celestica Seastone] fix multi sonic platform issues (#13356) 2023-01-18 16:27:48 -08:00
th-seastone-dx010-config-flex-all.bcm Disable ALPM distributed hitbit thread that is used for debug purpose only but interfered with Other functional operations (#9199) 2021-11-09 07:21:57 -08:00
thermal_overload_control.sh [device/celestica]: Add thermalctld support on DX010 platform APIs (#6089) 2021-01-15 10:20:47 -08:00
thermal_policy.json [device/celestica]: Add thermalctld support on DX010 platform APIs (#6089) 2021-01-15 10:20:47 -08:00