Common: modify the behavior of setting GPIO value#509
Closed
DelphineChiu wants to merge 1 commit into
Closed
Conversation
Summery: - If we want to set value of BIC GPIO via BMC, IPMI command handler will set GPIO direction to output firstly, and then set value. This is dangerous because the default direction of some GPIOs may be input. If user use the command of setting value, handler should only change value. Test plan: - Build code: Pass - Set GPIO value: Pass Log: 1. Set value of GPIO which default direction is output. root@bmc-oob:~# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R 51 FM_JTAG_TCK_MUX_SEL_R: 0 root@bmc-oob:~# bic-util slot1 --set_gpio 51 1 slot 1: setting [51]FM_JTAG_TCK_MUX_SEL_R to 1 root@bmc-oob:~# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R 51 FM_JTAG_TCK_MUX_SEL_R: 1 root@bmc-oob:~# bic-util slot1 --set_gpio 51 0 slot 1: setting [51]FM_JTAG_TCK_MUX_SEL_R to 0 root@bmc-oob:~# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R 51 FM_JTAG_TCK_MUX_SEL_R: 0 2. Set value of GPIO which default direction is input. - Before modify root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 1 root@bmc-oob:~# bic-util slot1 --set_gpio 15 0 slot 1: setting [15]PWRGD_SYS_PWROK to 0 root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 0 root@bmc-oob:~# bic-util slot1 --set_gpio 15 1 slot 1: setting [15]PWRGD_SYS_PWROK to 1 root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 1 - After moddify root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 1 root@bmc-oob:~# bic-util slot1 --set_gpio 15 0 slot 1: setting [15]PWRGD_SYS_PWROK to 0 root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 1
GoldenBug
approved these changes
Aug 24, 2022
Contributor
|
@GoldenBug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
IreneLin988
pushed a commit
to IreneLin988/OpenBIC
that referenced
this pull request
Aug 29, 2022
Summary: Summery: - If we want to set value of BIC GPIO via BMC, IPMI command handler will set GPIO direction to output firstly, and then set value. This is dangerous because the default direction of some GPIOs may be input. If user use the command of setting value, handler should only change value. Pull Request resolved: facebook#509 Test Plan: - Build code: Pass - Set GPIO value: Pass Log: 1. Set value of GPIO which default direction is output. root@bmc-oob:~# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R 51 FM_JTAG_TCK_MUX_SEL_R: 0 root@bmc-oob:~# bic-util slot1 --set_gpio 51 1 slot 1: setting [51]FM_JTAG_TCK_MUX_SEL_R to 1 root@bmc-oob:~# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R 51 FM_JTAG_TCK_MUX_SEL_R: 1 root@bmc-oob:~# bic-util slot1 --set_gpio 51 0 slot 1: setting [51]FM_JTAG_TCK_MUX_SEL_R to 0 root@bmc-oob:~# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R 51 FM_JTAG_TCK_MUX_SEL_R: 0 2. Set value of GPIO which default direction is input. - Before modify root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 1 root@bmc-oob:~# bic-util slot1 --set_gpio 15 0 slot 1: setting [15]PWRGD_SYS_PWROK to 0 root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 0 root@bmc-oob:~# bic-util slot1 --set_gpio 15 1 slot 1: setting [15]PWRGD_SYS_PWROK to 1 root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 1 - After moddify root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 1 root@bmc-oob:~# bic-util slot1 --set_gpio 15 0 slot 1: setting [15]PWRGD_SYS_PWROK to 0 root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK 15 PWRGD_SYS_PWROK: 1 Reviewed By: garnermic Differential Revision: D38988982 Pulled By: GoldenBug fbshipit-source-id: 28bfa20c132282aab9f56e1eb48dd8800a47a3dc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summery:
This is dangerous because the default direction of some GPIOs may be input.
If user use the command of setting value, handler should only change value.
Test plan:
Log:
Set value of GPIO which default direction is output.
root@bmc-oob:
# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R# bic-util slot1 --set_gpio 51 151 FM_JTAG_TCK_MUX_SEL_R: 0
root@bmc-oob:
slot 1: setting [51]FM_JTAG_TCK_MUX_SEL_R to 1
root@bmc-oob:
# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R# bic-util slot1 --set_gpio 51 051 FM_JTAG_TCK_MUX_SEL_R: 1
root@bmc-oob:
slot 1: setting [51]FM_JTAG_TCK_MUX_SEL_R to 0
root@bmc-oob:~# bic-util slot1 --get_gpio | grep FM_JTAG_TCK_MUX_SEL_R
51 FM_JTAG_TCK_MUX_SEL_R: 0
Set value of GPIO which default direction is input.
Before modify
root@bmc-oob:
# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK# bic-util slot1 --set_gpio 15 015 PWRGD_SYS_PWROK: 1
root@bmc-oob:
slot 1: setting [15]PWRGD_SYS_PWROK to 0
root@bmc-oob:
# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK# bic-util slot1 --set_gpio 15 115 PWRGD_SYS_PWROK: 0
root@bmc-oob:
slot 1: setting [15]PWRGD_SYS_PWROK to 1
root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK
15 PWRGD_SYS_PWROK: 1
After moddify
root@bmc-oob:
# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK# bic-util slot1 --set_gpio 15 015 PWRGD_SYS_PWROK: 1
root@bmc-oob:
slot 1: setting [15]PWRGD_SYS_PWROK to 0
root@bmc-oob:~# bic-util slot1 --get_gpio | grep PWRGD_SYS_PWROK
15 PWRGD_SYS_PWROK: 1