Skip to content

Common: modify the behavior of setting GPIO value#509

Closed
DelphineChiu wants to merge 1 commit into
facebook:mainfrom
Wiwynn:Sara/common_correct_set_gpio_value
Closed

Common: modify the behavior of setting GPIO value#509
DelphineChiu wants to merge 1 commit into
facebook:mainfrom
Wiwynn:Sara/common_correct_set_gpio_value

Conversation

@DelphineChiu

Copy link
Copy Markdown

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

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
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 23, 2022
@facebook-github-bot

Copy link
Copy Markdown
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
@SaraSYLin SaraSYLin deleted the Sara/common_correct_set_gpio_value branch September 21, 2022 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

4 participants