We start with the Arch Wiki docs: https://wiki.archlinux.org/title/Kernel/Arch_build_system
Basics:
pacman -S devtools base-devel pacman-contrib
mkdir ~/build
cd ~/build
pkgctl repo clone --protocol=https linux
Modify the name:
vi linux/PKGBUILD
# change to custom
pkgbase=linux-custom
# remove $pkgbase-docs
pkgname=("$pkgbase" "$pkgbase-headers")
# add your patch to source
source= (
...
lhl-nvme.patch # this is the root linux/ folder
)
# run this after editing config
updpkgsums
Be sure to make your patches. This was a bit of a bear for me, the directsion https://wiki.archlinux.org/title/Kernel/Arch_build_system#Updating weren’t quite right, so I just sort of winged it. Ran a diff separately and then made sure the paths were correct.
❯ more lhl-nvme.patch
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3ec38e2b9173..ab2583cb42aa 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2409,6 +2409,8 @@
timeout = NVME_CAP_TIMEOUT(ctrl->cap);
}
+ dev_info(ctrl->device, "[PATCH] nvme core got timeout %u\n",timeout);
+
ctrl->ctrl_config |= (NVME_CTRL_PAGE_SHIFT - 12) << NVME_CC_MPS_SHIFT;
ctrl->ctrl_config |= NVME_CC_AMS_RR | NVME_CC_SHN_NONE;
ctrl->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;
@@ -2421,12 +2423,14 @@
if (ret)
return ret;
+ dev_info(ctrl->device, "[PATCH] nvme_wait_ready now wait for %u, previously %u\n",(timeout + 1) * 2, (timeout + 1)/2);
+
ctrl->ctrl_config |= NVME_CC_ENABLE;
ret = ctrl->ops->reg_write32(ctrl, NVME_REG_CC, ctrl->ctrl_config);
if (ret)
return ret;
return nvme_wait_ready(ctrl, NVME_CSTS_RDY, NVME_CSTS_RDY,
- (timeout + 1) / 2, "initialisation");
+ (timeout + 1) * 2, "initialisation");
}
EXPORT_SYMBOL_GPL(nvme_enable_ctrl);
I needed to compile a custom kernel for a new system that is using a MAXIO MAP1602 controller that doesn’t reliably detect on boot.
This is sadly still not fixed in 6.5.0:
- https://lore.kernel.org/lkml/MEAP282MB0391131326CF9E3BD5C26FD0B338A@MEAP282MB0391.AUSP282.PROD.OUTLOOK.COM/T/#m1479c113b4c4c4422f42d3104cc6044bf6732a8e
- https://g0v.social/@felixonmars/110985711307087668
Faster Kernels
Using modprobed-db to compile only used kernel modules:
https://wiki.archlinux.org/title/Modprobed-db
- mount all filesystems
- insert all removable media
- attach all devices
- encryption
- qemu
- sensors
Run modprobed-db store or enable the modprobed-db.service
Also add:
cifs
efivarfs
ext4
fat
isofs
loop
usbhid
usb_storage
vfat
The use make localmodconfig in PKGBUILD:
make LSMOD=$HOME/.config/modprobed.db localmodconfig