-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add pcie-check service to check PCIe devices at boot #4771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
736e2e1
95bc36b
c938619
a6fa285
d9ca93b
365552b
78604b9
09472f7
d7f2d50
f096d2c
1604ef8
c406a26
61eb853
a25a5a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [Unit] | ||
| Description=Start the pcie-check.service in 10 seconds after boot | ||
|
|
||
| [Timer] | ||
| OnBootSec=10sec | ||
| Unit=pcie-check.service | ||
|
|
||
| [Install] | ||
| WantedBy=timers.target | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [Unit] | ||
| Description=Check the PCIe device presence and status | ||
| After=rc.local.service | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=/usr/bin/pcie-check.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #! /bin/bash | ||
| ## Check the platform PCIe device presence and status | ||
|
|
||
| VERBOSE="no" | ||
| RESULTS="PCIe Device Checking All Test" | ||
| PCIE_CHK_CMD=`sudo pcieutil pcie-check |grep "$RESULTS"` | ||
|
||
| EXPECTED="PCIe Device Checking All Test ----------->>> PASSED" | ||
| MAX_WAIT_TIMEOUT=15 | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| function debug() | ||
| { | ||
| /usr/bin/logger "$0 : $1" | ||
| if [[ x"${VERBOSE}" == x"yes" ]]; then | ||
| echo "$(date) $0: $1" | ||
| fi | ||
| } | ||
|
|
||
| function check_and_rescan_pcie_devices() | ||
| { | ||
| PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform` | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if [ ! -f /usr/share/sonic/device/$PLATFORM/plugins/pcie.yaml ]; then | ||
| debug "pcie.yaml does not exist! can't check pcie status!" | ||
| exit | ||
| fi | ||
|
|
||
| begin=$SECONDS | ||
| end=`expr $begin + $MAX_WAIT_TIMEOUT` | ||
| rescan_time=$((MAX_WAIT_TIMEOUT/2)) | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| rescan_time=`expr $begin + $rescan_time` | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| while true | ||
| do | ||
| now=$SECONDS | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if [[ $now -gt $end ]]; then | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| break | ||
| fi | ||
|
|
||
| if [ "$PCIE_CHK_CMD" = "$EXPECTED" ]; then | ||
| redis-cli -n 6 SET "PCIE_STATUS|PCIE_DEVICES" "PASSED" | ||
| debug "PCIe check passed" | ||
| exit | ||
| else | ||
| debug "sleep 0.1 seconds" | ||
| sleep 0.1 | ||
| fi | ||
|
|
||
| if [ $now -gt $rescan_time ]; then | ||
| debug "PCIe check failed, try pci bus rescan" | ||
| echo 1 > /sys/bus/pci/rescan | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here rescan is instantiated for all-devices. (sys/bus/pci/rescan). Rescan should be device specific.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed offline. For now, we will rescan the entire bus. Rescanning individual devices will be a future enhancement. |
||
| rescan_time=$end | ||
| fi | ||
|
|
||
| done | ||
| debug "PCIe check failed" | ||
| redis-cli -n 6 SET "PCIE_STATUS|PCIE_DEVICES" "FAILED" | ||
| } | ||
|
|
||
| check_and_rescan_pcie_devices | ||
Uh oh!
There was an error while loading. Please reload this page.