1

Debian bookworm, kernel 6.8.0-rc5, kmod version 30

I'm working with a constrained system and need to unbind some unused PCIe ports to free up IRQs for downstream devices before they load. I am using an install command in modprobe.d/mpt3sas.conf (then rebuilding with update-initramfs -u)

softdep mpt3sas pre: i40e
install mpt3sas /bin/sh /usr/bin/unbind_pcieport.sh; /sbin/modprobe --ignore-install mpt3sas $CMDLINE_OPTS

but unbind_pcieport.sh doesn't fire. I've included echos in unbind_pcieport.sh, outputting to a log file, but no log file is ever created, indicating the script is not running at all.

The unbinding works as expected if I put everything inside mpt3sas.conf like this:

install mpt3sas echo "0000:02:08.0" > /sys/bus/pci/drivers/pcieport/unbind; echo "0000:02:09.0" > /sys/bus/pci/drivers/pcieport/unbind; echo "0000:02:0a.0" > /sys/bus/pci/drivers/pcieport/unbind; /sbin/modprobe --ignore-install mpt3sas $CMDLINE_OPTS

but I'd like to have some logic in my script and it's just cleaner to not have it all in one line of the .conf

This is the script body:

#!/bin/sh
# Space-separated list of PCI devices to unbind
PCI_DEVICES="0000:02:08.0 0000:02:09.0 0000:02:0a.0"
# Unbind each specified device if it exists
for DEVICE in $PCI_DEVICES; do
    if [ -e "/sys/bus/pci/drivers/pcieport/$DEVICE" ]; then
        echo "$DEVICE" > /sys/bus/pci/drivers/pcieport/unbind
        echo "Unbound $DEVICE from pcieport driver"
    else
        echo "$DEVICE not found or already unbound"
    fi
done

I've tried using /bin/bash instead of sh, and omitting /bin/bash in the .conf and just using "unbind_pcieport.sh" (with the script in $PATH)

The .sh script is world executable and readable

EDIT: Loking through the modprobe manual I haven't found why my script isn't executing, but I did find that you can break lines with \, so I at least cleaned up the working mpt3sas.conf for now:

softdep mpt3sas pre: i40e
install mpt3sas \
echo "0000:02:08.0" > /sys/bus/pci/drivers/pcieport/unbind;\
echo "0000:02:09.0" > /sys/bus/pci/drivers/pcieport/unbind;\
echo "0000:02:0a.0" > /sys/bus/pci/drivers/pcieport/unbind;\
/sbin/modprobe --ignore-install mpt3sas $CMDLINE_OPTS
2
  • One thought is that mpt3sas is loaded before switching root, and while the modprobe.d conf may have been included in the initramfs (because you triggered a regeneration of that after you have the file created under /etc/modprobe.d/ (of the real root), yet you forgot to / didn't realize you need to also add /usr/bin/unbind_pcieport.sh to the initramfs (like by some means make the initramfs generator of your system include the file when it does its work). Commented Oct 27, 2024 at 19:11
  • 1
    @TomYan you are correct I did not include my .sh script in my initramfs. I will look into how to do that. It's a SoC board and it just died on me the same day I made this post. I have another on order and will update asap Commented Oct 28, 2024 at 3:37

2 Answers 2

1

@TomYan was correct in his comment, I needed to add my script to the initramfs.

I created /etc/initramfs-tools/hooks/unbind_pcieport

#!/bin/sh
PREREQ=""

prereqs() { echo "$PREREQ"; }
case $1 in
    prereqs) prereqs; exit 0 ;;
esac

. /usr/share/initramfs-tools/hook-functions

mkdir -p ${DESTDIR}/usr/bin || true
cp -pnL /usr/bin/unbind_pcieport.sh ${DESTDIR}/usr/bin/unbind_pcieport.sh
chmod +x ${DESTDIR}/usr/bin/unbind_pcieport.sh

Then /etc/modprobe.d/mpt3sas.conf looks like this

softdep mpt3sas pre: i40e
install mpt3sas /bin/sh /usr/bin/unbind_pcieport.sh; /sbin/modprobe --ignore-install mpt3sas $CMDLINE_OPTS

After update-initramfs -u and a reboot it works!

0

IMHO

install mpt3sas \

doesn't match because of destination is not specified also, ";" at EOL is needed

1
  • That section works, so I don't know what this answer is saying Commented Oct 28, 2024 at 2:22

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.