1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-30 08:32:52 +08:00

Update scripts to use setpci built-in bit masking

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich 2022-04-19 23:18:50 -07:00
parent 984aefe508
commit ffc0a70c40
4 changed files with 15 additions and 35 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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..."

View File

@ -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