From 4e75a31e98d2219c1deb450fc90ecd98ced83b58 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sun, 13 Sep 2020 23:26:21 -0400 Subject: [PATCH] linux: configure aarch64 contiguous memory allocator via kernel config As per the in-line comment, this is where distros should configure it. Not via kernel command line parameters. As found by looking at the implementation, while exploring the cause of a bug on the Raspberry Pi 4, it was found that `cma=` on the command line parameters will overwrite the values a device tree will have configured for a given platform. With this, the more recent 5.4 vendor kernel boots just fine on the Raspberry Pi 4 using our common configuration. --- nixos/modules/installer/cd-dvd/sd-image-aarch64.nix | 3 +-- pkgs/os-specific/linux/kernel/common-config.nix | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix b/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix index e73bc5a22e0..e4ec2d6240d 100644 --- a/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix +++ b/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix @@ -17,8 +17,7 @@ # The serial ports listed here are: # - ttyS0: for Tegra (Jetson TX1) # - ttyAMA0: for QEMU's -machine virt - # Also increase the amount of CMA to ensure the virtual console on the RPi3 works. - boot.kernelParams = ["cma=32M" "console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0"]; + boot.kernelParams = ["console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0"]; boot.initrd.availableKernelModules = [ # Allows early (earlier) modesetting for the Raspberry Pi diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index 47e49dbe01d..2f81444f78f 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -819,6 +819,12 @@ let # See comments on https://github.com/NixOS/nixpkgs/commit/9b67ea9106102d882f53d62890468071900b9647 CRYPTO_AEGIS128_SIMD = whenAtLeast "5.4" no; + + # Distros should configure the default as a kernel option. + # We previously defined it on the kernel command line as cma= + # The kernel command line will override a platform-specific configuration from its device tree. + # https://github.com/torvalds/linux/blob/856deb866d16e29bd65952e0289066f6078af773/kernel/dma/contiguous.c#L35-L44 + CMA_SIZE_MBYTES = freeform "32"; }; }; in