From ffc0a70c400a8265214081197f5cb1ab3484c732 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Tue, 19 Apr 2022 23:18:50 -0700 Subject: [PATCH] Update scripts to use setpci built-in bit masking Signed-off-by: Alex Forencich --- scripts/pcie_disable_fatal_err.sh | 13 ++++++------- scripts/pcie_ext_tag.sh | 17 ++++------------- scripts/pcie_hot_reset.sh | 10 ++++------ scripts/pcie_set_speed.sh | 10 +--------- 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/scripts/pcie_disable_fatal_err.sh b/scripts/pcie_disable_fatal_err.sh index 968cc71de..c344464b0 100755 --- a/scripts/pcie_disable_fatal_err.sh +++ b/scripts/pcie_disable_fatal_err.sh @@ -25,17 +25,16 @@ fi echo "Disabling fatal error reporting on port $port..." -cmd=$(setpci -s $port COMMAND) - -echo "Command:" $cmd +echo "Command:" $(setpci -s $port COMMAND) # clear SERR bit in command register -setpci -s $port COMMAND=$(printf "%04x" $((0x$cmd & ~0x0100))) +setpci -s $port COMMAND=0000:0100 -ctrl=$(setpci -s $port CAP_EXP+8.w) +echo "Command:" $(setpci -s $port COMMAND) -echo "Device control:" $ctrl +echo "Device control:" $(setpci -s $port CAP_EXP+8.w) # clear fatal error reporting enable bit in device control register -setpci -s $port CAP_EXP+8.w=$(printf "%04x" $((0x$ctrl & ~0x0004))) +setpci -s $port CAP_EXP+8.w=0000:0004 +echo "Device control:" $(setpci -s $port CAP_EXP+8.w) diff --git a/scripts/pcie_ext_tag.sh b/scripts/pcie_ext_tag.sh index 1fcf39e2a..391a07bf6 100755 --- a/scripts/pcie_ext_tag.sh +++ b/scripts/pcie_ext_tag.sh @@ -22,23 +22,14 @@ if [ ! -e "/sys/bus/pci/devices/$dev" ]; then exit 1 fi -ctrl=$(setpci -s $dev CAP_EXP+8.w) +echo "Device control:" $(setpci -s $dev CAP_EXP+8.w) if (($en > 0)); then - echo "Enabling ext tag on $dev..." - - echo "Device control:" $ctrl - - setpci -s $dev CAP_EXP+8.w=$(printf "%04x" $((0x$ctrl | 0x0100))) - + setpci -s $dev CAP_EXP+8.w=0100:0100 else - echo "Disabling ext tag on $dev..." - - echo "Device control:" $ctrl - - setpci -s $dev CAP_EXP+8.w=$(printf "%04x" $((0x$ctrl & ~0x0100))) - + setpci -s $dev CAP_EXP+8.w=0000:0100 fi +echo "Device control:" $(setpci -s $dev CAP_EXP+8.w) diff --git a/scripts/pcie_hot_reset.sh b/scripts/pcie_hot_reset.sh index 18c178f83..0a98da3f5 100755 --- a/scripts/pcie_hot_reset.sh +++ b/scripts/pcie_hot_reset.sh @@ -29,13 +29,11 @@ echo 1 > "/sys/bus/pci/devices/$dev/remove" echo "Performing hot reset of port $port..." -bc=$(setpci -s $port BRIDGE_CONTROL) +echo "Bridge control:" $(setpci -s $port BRIDGE_CONTROL) -echo "Bridge control:" $bc - -setpci -s $port BRIDGE_CONTROL=$(printf "%04x" $((0x$bc | 0x40))) -sleep 0.01 -setpci -s $port BRIDGE_CONTROL=$bc +setpci -s $port BRIDGE_CONTROL=40:40 +sleep 0.5 +setpci -s $port BRIDGE_CONTROL=00:40 sleep 0.5 echo "Rescanning bus..." diff --git a/scripts/pcie_set_speed.sh b/scripts/pcie_set_speed.sh index 5e0ef4b27..ab56d2a06 100755 --- a/scripts/pcie_set_speed.sh +++ b/scripts/pcie_set_speed.sh @@ -60,15 +60,7 @@ setpci -s $dev CAP_EXP+30.L=$lc2n echo "Triggering link retraining..." -lc=$(setpci -s $dev CAP_EXP+10.L) - -echo "Original link control:" $lc - -lcn=$(printf "%08x" $((0x$lc | 0x20))) - -echo "New link control:" $lcn - -setpci -s $dev CAP_EXP+10.L=$lcn +setpci -s $dev CAP_EXP+10.L=20:20 sleep 0.1