sonic-buildimage/device
Ikki Zhu db12b8c9c0
dx010 fix possible cpld race read issue (#15339)
#### Why I did it
fix possible cpld race read issue between watchdog and reboot cause process

##### Work item tracking
- Microsoft ADO **(number only)**:

#### How I did it
Use flock to limit parallel access to cpld sys file

#### How to verify it
It can be simulate and verified with following python script

```python3
import signal
import subprocess
import threading

exit_flag = False

def run_command(cmd):
    status = True
    result = ""
    try:
        p = subprocess.Popen(
            cmd, shell=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        raw_data, err = p.communicate()
        if err == '':
            result = raw_data.strip()
    except:
        status = False
    return status, result

def get_cpld_reg_value(getreg_path, register):
    #cmd = "echo {1} > {0}; cat {0}".format(getreg_path, register)
    cmd = "flock {0} -c 'echo {1} > {0}; cat {0}'".format(getreg_path,
register)
    status, result = run_command(cmd)
    return result if status else None

def cpld_read(thread_num, cpld_reg):
    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}")

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',))
    t2 = threading.Thread(target=cpld_read, args=(2, '0x141',))
    t1.start()
    t2.start()
    t1.join()
    t2.join()
```
2023-06-20 16:21:08 -07:00
..
accton [202012][BRCM TH3] Add SOC properties to prevent FDB events during warmboot (#9761) 2022-01-14 14:44:43 -08:00
alphanetworks [sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926) 2020-11-25 10:28:36 -08:00
arista Fix content of platform.json for DCS-7050CX3-32S (#13659) 2023-02-08 12:01:07 -08:00
barefoot updated platform info for device x86_64-accton_wedge100bf_32x-r0 (#8918) 2021-10-12 14:16:27 -07:00
broadcom/x86_64-bcm_xlr-r0 [202012] Disable ALPM distributed hitbit thread that is used for debug purpose only but interfered with Other functional operations (#9190) 2021-11-08 11:50:44 -08:00
celestica dx010 fix possible cpld race read issue (#15339) 2023-06-20 16:21:08 -07:00
centec [sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926) 2020-11-25 10:28:36 -08:00
cig [sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926) 2020-11-25 10:28:36 -08:00
common [202012] [qos] Update RDMA-CENTRIC lossy profile to use static threshold for Th devices (#14398) 2023-03-24 10:41:48 -07:00
dell [202012] [Profile separation] MMU infrastructure update for TD2 (#12739) 2022-11-29 12:53:58 -08:00
delta [202012][BRCM TH3] Add SOC properties to prevent FDB events during warmboot (#9761) 2022-01-14 14:44:43 -08:00
facebook/x86_64-facebook_wedge100-r0 In SAI 3.5 by default we are supporting 256 Group with 64 Memeber each. (#5400) 2020-09-22 11:21:12 -07:00
ingrasys [sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926) 2020-11-25 10:28:36 -08:00
inventec [BCM Config] Update TD3 bcm.config files to use ISSU capable premium CANCUN 6.4.1 (#6651) 2021-02-05 16:11:59 -08:00
juniper [platform] Update QSFP method name 'parse_qsfp_dom_capability' -> 'parse_dom_capability' (#6695) 2021-02-05 15:48:30 -08:00
marvell [sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926) 2020-11-25 10:28:36 -08:00
mellanox [202012][mellanox]Fix lpmode set when logical port is larger than 64 (#14137) 2023-03-09 00:04:09 +02:00
mitac/x86_64-mitac_ly1200_b32h0_c3-r0 [sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926) 2020-11-25 10:28:36 -08:00
nokia/armhf-nokia_ixs7215_52x-r0 [Nokia ixs7215] change var/log size to 4GB (#11122) 2022-06-14 09:02:14 -07:00
pegatron/x86_64-pegatron_porsche-r0 [sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926) 2020-11-25 10:28:36 -08:00
quanta [202012][BRCM TH3] Add SOC properties to prevent FDB events during warmboot (#9761) 2022-01-14 14:44:43 -08:00
virtual/x86_64-kvm_x86_64-r0 fix build error (#9902) 2022-02-03 08:52:29 +05:30
wnc/x86_64-wnc_osw1800-r0 [sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926) 2020-11-25 10:28:36 -08:00