Jump to content

Vrozaksen

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by Vrozaksen

  1. @Louisgaga
    Yes 00:01.0
    There is modified script just for this one:
     

    #!/bin/bash
    ENDPOINT="00:01.0"
    ROOT_COMPLEX="00:01.0"
    
    # Hex  Binary  Meaning
    # -------------------------
    # 0    0b00    L0 only
    # 1    0b01    L0s only
    # 2    0b10    L1 only
    # 3    0b11    L1 and L0s
    ASPM_SETTING=3
    
    function aspm_setting_to_string()
    {
    	case $1 in
    	0)
    		echo -e "\t${BLUE}L0 only${NORMAL}, ${RED}ASPM disabled${NORMAL}"
    		;;
    	1)
    		;;
    	2)
    		echo -e "\t${GREEN}L1 only${NORMAL}"
    		;;
    	3)
    		echo -e "\t${GREEN}L1 and L0s${NORMAL}"
    		;;
    	*)
    		echo -e "\t${RED}Invalid${NORMAL}"
    		;;
    	esac
    }
    
    # Pretty colors
    GREEN="\033[01;32m"
    YELLOW="\033[01;33m"
    NORMAL="\033[00m"
    BLUE="\033[34m"
    RED="\033[31m"
    PURPLE="\033[35m"
    CYAN="\033[36m"
    UNDERLINE="\033[02m"
    
    # we can surely read the spec to get a better value
    MAX_SEARCH=20
    SEARCH_COUNT=1
    ASPM_BYTE_ADDRESS="INVALID"
    
    ROOT_PRESENT=$(lspci | grep -c "$ROOT_COMPLEXT")
    ENDPOINT_PRESENT=$(lspci | grep -c "$ENDPOINT")
    
    if [[ $(id -u) != 0 ]]; then
    	echo "This needs to be run as root"
    	exit 1
    fi
    
    if [[ $ROOT_PRESENT -eq 0 ]]; then
    	echo "Root complex $ROOT_COMPLEX is not present"
    	exit
    fi
    
    if [[ $ENDPOINT_PRESENT -eq 0 ]]; then
    	echo "Endpoint $ENDPOINT is not present"
    	exit
    fi
    
    # XXX: lspci -s some_device_not_existing does not return positive
    # if the device does not exist, fix this upstream
    function device_present()
    {
    
    	PRESENT=$(lspci | grep -c "$1")
    	COMPLAINT="${RED}not present${NORMAL}"
    
    	if [[ $PRESENT -eq 0 ]]; then
    		if [[ $2 != "present" ]]; then
    			COMPLAINT="${RED}disappeared${NORMAL}"
    		fi
    
    		echo -e "Device ${BLUE}${1}${NORMAL} $COMPLAINT" 
    		return 1
    	fi
    	return 0
    }
    
    function find_aspm_byte_address()
    {
    	device_present $ENDPOINT present
    	if [[ $? -ne 0 ]]; then
    		exit
    	fi
    
    	SEARCH=$(setpci -s $1 34.b)
    	# We know on the first search $SEARCH will not be
    	# 10 but this simplifies the implementation.
    	while [[ $SEARCH != 10 && $SEARCH_COUNT -le $MAX_SEARCH ]]; do
    		END_SEARCH=$(setpci -s $1 ${SEARCH}.b)
    
    		# Convert hex digits to uppercase for bc
    		SEARCH_UPPER=$(printf "%X" 0x${SEARCH})
    
    		if [[ $END_SEARCH = 10 ]]; then
    			ASPM_BYTE_ADDRESS=$(echo "obase=16; ibase=16; $SEARCH_UPPER + 10" | bc)
    			break
    		fi
    
    		SEARCH=$(echo "obase=16; ibase=16; $SEARCH + 1" | bc)
    		SEARCH=$(setpci -s $1 ${SEARCH}.b)
    
    		let SEARCH_COUNT=$SEARCH_COUNT+1
    	done
    
    	if [[ $SEARCH_COUNT -ge $MAX_SEARCH ]]; then
    		echo -e "Long loop while looking for ASPM word for $1"
    		return 1
    	fi
    	return 0
    }
    
    function enable_aspm_byte()
    {
    	device_present $1 present
    	if [[ $? -ne 0 ]]; then
    		exit
    	fi
    
    	find_aspm_byte_address $1
    	if [[ $? -ne 0 ]]; then
    		return 1
    	fi
    
    	ASPM_BYTE_HEX=$(setpci -s $1 ${ASPM_BYTE_ADDRESS}.b)
    	ASPM_BYTE_HEX=$(printf "%X" 0x${ASPM_BYTE_HEX})
    	# setpci doesn't support a mask on the query yet, only on the set,
    	# so to verify a setting on a mask we have no other optoin but
    	# to do do this stuff ourselves.
    	DESIRED_ASPM_BYTE_HEX=$(printf "%X" $(( (0x${ASPM_BYTE_HEX} & ~0x7) |0x${ASPM_SETTING})))
    
    	if [[ $ASPM_BYTE_ADDRESS = "INVALID" ]]; then
    		echo -e "No ASPM byte could be found for $(lspci -s $1)"
    		return
    	fi
    
    	echo -e "$(lspci -s $1)"
    	echo -en "\t${YELLOW}0x${ASPM_BYTE_ADDRESS}${NORMAL} : ${CYAN}0x${ASPM_BYTE_HEX}${GREEN} --> ${BLUE}0x${DESIRED_ASPM_BYTE_HEX}${NORMAL} ... "
    
    	device_present $1 present
    	if [[ $? -ne 0 ]]; then
    		exit
    	fi
    
    	# Avoid setting if already set
    	if [[ $ASPM_BYTE_HEX = $DESIRED_ASPM_BYTE_HEX ]]; then
    		echo -e "[${GREEN}SUCESS${NORMAL}] (${GREEN}already set${NORMAL})"
    		aspm_setting_to_string $ASPM_SETTING
    		return 0
    	fi
    
    	# This only writes the last 3 bits
    	setpci -s $1 ${ASPM_BYTE_ADDRESS}.b=${ASPM_SETTING}:3
    
    	sleep 3
    
    	ACTUAL_ASPM_BYTE_HEX=$(setpci -s $1 ${ASPM_BYTE_ADDRESS}.b)
    	ACTUAL_ASPM_BYTE_HEX=$(printf "%X" 0x${ACTUAL_ASPM_BYTE_HEX})
    
    	# Do not retry this if it failed, if it failed to set.
    	# Likey if it failed its a good reason and you should look
    	# into that.
    	if [[ $ACTUAL_ASPM_BYTE_HEX != $DESIRED_ASPM_BYTE_HEX ]]; then
    		echo -e "\t[${RED}FAIL${NORMAL}] (0x${ACTUAL_ASPM_BYTE_HEX})"
    		return 1
    	fi
    
    	echo -e "\t[${GREEN}SUCCESS]${NORMAL}]"
    	aspm_setting_to_string $ASPM_SETTING
    
    	return 0
    }
    
    device_present $ENDPOINT not_sure
    if [[ $? -ne 0 ]]; then
    	exit
    fi
    
    echo -e "${CYAN}Root complex${NORMAL}:"
    ROOT_COMPLEX="00:01.0"
    enable_aspm_byte $ROOT_COMPLEX
    echo
    
    echo -e "${CYAN}Endpoint${NORMAL}:"
    ENDPOINT="00:01.0"
    enable_aspm_byte $ENDPOINT
    echo
    

     

  2. Before:


    So i managed to get this:
    obraz.thumb.png.cb7f532f0a073f1640c02b597433eece.png

     

    00:01.0 now have ASPM Enabled using https://gist.github.com/baybal/b499fc5811a7073df0c03ab8da4be904 

    Still getting only to C3...
    In this post https://libreddit.proxy.vrozaksen.eu/r/homelab/comments/130ly7h/cant_achieve_lower_cstates_stuck_at_c3_despite/

    OP says his issue was on-board network card and AsRock Z390m-itx/ac uses 2 different on-board LAN cards. I211 and I219.
    Maybe one of those cards generates this issue? I can't test that right now, but maybe u got any information about those cards.

    • Like 1
  3. Hi! So i'm using AsRock Z390m-itx/ac.
    For last 2 hours i was trying to reach higher than C3 state, but with no luck.
    Every C-State enabled.

    Every ASPM enabled (first L1 then L0sL1, no difference)
    Audio disabled.

    No pci-e devices. Only ASM1166 on M.2 slot.

    Other parts:
    MOBO: AsRock Z390m-itx/ac
    CPU: i5-9400
    PSU: Corsair RM550x (2018)
    RAM: 2x Corsair Vengeance LPX, DDR4, 8 GB, 3000MHz, CL16

    I was testing with stopped array.
    My go file:

    # -------------------------------------------------
    # Set power-efficient CPU governor
    # -------------------------------------------------
    #/etc/rc.d/rc.cpufreq powersave
    
    # -------------------------------------------------
    # Disable CPU Turbo
    # -------------------------------------------------
    #[[ -f /sys/devices/system/cpu/intel_pstate/no_turbo ]] && echo "1" > /sys/devices/system/cpu/intel_pstate/no_turbo
    #[[ -f /sys/devices/system/cpu/cpufreq/boost ]] && echo "0" > /sys/devices/system/cpu/cpufreq/boost
    
    # -------------------------------------------------
    # Enable power-efficient ethernet
    # -------------------------------------------------
    
    # enable IEEE 802.3az (Energy Efficient Ethernet): Could be incompatible to LACP bonds!
    for i in /sys/class/net/eth?; do dev=$(basename $i); [[ $(echo $(ethtool --show-eee $dev 2> /dev/null) | grep -c "Supported EEE link modes: 1") -eq 1 ]] && ethtool --set-eee $dev eee on; done
    
    # Disable wake on lan
    for i in /sys/class/net/eth?; do ethtool -s  $(basename $i) wol d; done
    
    # -------------------------------------------------
    # powertop tweaks
    # -------------------------------------------------
    
    # Enable SATA link power management
    echo med_power_with_dipm | tee /sys/class/scsi_host/host*/link_power_management_policy
    
    # Runtime PM for I2C Adapter (i915 gmbus dpb)
    echo auto | tee /sys/bus/i2c/devices/i2c-*/device/power/control
    
    # Autosuspend for USB device
    echo auto | tee /sys/bus/usb/devices/*/power/control
    
    # Runtime PM for disk
    echo auto | tee /sys/block/sd*/device/power/control
    
    # Runtime PM for PCI devices
    echo auto | tee /sys/bus/pci/devices/????:??:??.?/power/control
    
    # Runtime PM for ATA devices
    echo auto | tee /sys/bus/pci/devices/????:??:??.?/ata*/power/control
    
    # VM writeback timeout
    for i in /proc/sys/vm/dirty_writeback_centisecs; do
        echo '1500' > $i
    done
    
    echo powersupersave > /sys/module/pcie_aspm/parameters/policy


    image.thumb.png.c01e9ff9fc654302fca116595315c9c4.pngimage.thumb.png.a952ed5502ff2fd9de2a52d048435aac.png

     

    EDIT: After reboot with array started i get 0% everywhere.
    image.thumb.png.4d01c0c7f372954dd13b965f8f09972b.png

  4. Okay after "rebuild" it was good and yesterday it happend again. Using different cables didn't help. Maybe there is HDD connector issue? I bent it little bit to much couple month ago, but everything was looking good. I scratch my head what the issue.

    @Michael_P HDD shows CRC errors, SMART doesn't show anything special. It's still the same drive on different cables.

  5. @up that's what I have setup, this work really good, but then i have to check what Sonarr/Radarr imported, then i can delete it on seedbox manually... I'm looking for script or tool for rTorrent/Syncthing which will delete files on seedbox after successful import to Radarr/Sonarr

     

    Edit:

    I think it's better to use Deluge in this case, i will test it later

    Edit:2

     

    Soo i recommend Transmission (Deluge have crashing problem), everything works great!

×
×
  • Create New...