Skip to content

Commit

Permalink
fix(dracut-functions.sh): convert mmcblk to the real kernel module name
Browse files Browse the repository at this point in the history
In some x86_64 platforms such as Intel Elkhartlake, an issue of missing
necessary modules due to udevadm drivers field unmatch the real kernel module
name is found:

  $ udevadm info -a /dev/block/179:1

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/mmc_host/mmc0/mmc0:0001':
    KERNELS=="mmc0:0001"
    SUBSYSTEMS=="mmc"
    DRIVERS=="mmcblk"
    ....

The DRIVERS field, aka mmcblk will be given to instmods to install the
corresponding mmc_block.ko kernel module. However mmc_block.ko cannot be
selected by string mmcblk, as a result, mmc_block.ko cannot be installed
in hostonly-mode strict, which will fail to bootup the machine such as in
kdump cases:

  $ /usr/lib/dracut/dracut-install -D /var/tmp --kerneldir /lib/modules/$(uname -r)/ -m mmcblk
  dracut-install: Failed to find module 'mmcblk'

In this patch, we will convert the string mmcblk to mmc_block, so the
kernel module can be successfully loaded.

Signed-off-by: Tao Liu <ltao@redhat.com>
  • Loading branch information
liutgnu authored and johannbg committed Apr 14, 2023
1 parent 297525c commit a62e895
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion dracut-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,30 @@ block_is_netdevice() {
block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1"
}
# convert the driver name given by udevadm to the corresponding kernel module name
get_module_name() {
local dev_driver
while read -r dev_driver; do
case "$dev_driver" in
mmcblk)
echo "mmc_block"
;;
*)
echo "$dev_driver"
;;
esac
done
}
# get the corresponding kernel modules of a /sys/class/*/* or/dev/* device
get_dev_module() {
local dev_attr_walk
local dev_drivers
local dev_paths
dev_attr_walk=$(udevadm info -a "$1")
dev_drivers=$(echo "$dev_attr_walk" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p')
dev_drivers=$(echo "$dev_attr_walk" \
| sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p' \
| get_module_name)
# also return modalias info from sysfs paths parsed by udevadm
dev_paths=$(echo "$dev_attr_walk" | sed -n 's/.*\(\/devices\/.*\)'\'':/\1/p')
Expand Down Expand Up @@ -1017,6 +1034,7 @@ get_dev_module() {
[[ -n $dev_drivers && ${dev_drivers: -1} != $'\n' ]] && dev_drivers+=$'\n'
dev_drivers+=$(udevadm info -a "$dev_vpath/$dev_link" \
| sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p' \
| get_module_name \
| grep -v -e pcieport)
done
fi
Expand Down

0 comments on commit a62e895

Please sign in to comment.