From 08d1c4dd2b1af7f520bc996c1b445c3f1615500d Mon Sep 17 00:00:00 2001 From: mitchmindtree Date: Sun, 13 Dec 2020 15:09:57 +0100 Subject: [PATCH] Add wink patch for disabling MHI M2 state. Rename firmware. Disabling the MHI M2 state appears to completely resolve issues where enabling the wifi firmware would cause the the whole system to freeze quite frequently. The reason for why this fix works so well is still unknown and under investigation. See some discussion here: http://lists.infradead.org/pipermail/ath11k/2020-December/000876.html Also renames the firmware package to clarify that it is for the wifi driver. This is to avoid confusion with the bluetooth firmware which will be added in an upcoming patch. --- dell/xps/13-9310/default.nix | 14 +++++++++++--- dell/xps/13-9310/disable-mhi-m2.patch | 19 +++++++++++++++++++ ...firmware.nix => qca6390-wifi-firmware.nix} | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 dell/xps/13-9310/disable-mhi-m2.patch rename dell/xps/13-9310/{qca6390-firmware.nix => qca6390-wifi-firmware.nix} (96%) diff --git a/dell/xps/13-9310/default.nix b/dell/xps/13-9310/default.nix index a1fddf0..8cb4dbd 100644 --- a/dell/xps/13-9310/default.nix +++ b/dell/xps/13-9310/default.nix @@ -7,12 +7,12 @@ # TODO: upstream to NixOS/nixpkgs nixpkgs.overlays = [(final: previous: { - qca6390-firmware = final.callPackage ./qca6390-firmware.nix {}; + qca6390-wifi-firmware = final.callPackage ./qca6390-wifi-firmware.nix {}; })]; hardware.firmware = lib.mkBefore [ # Firmware for the AX500 (wi-fi & bluetooth chip). - pkgs.qca6390-firmware + pkgs.qca6390-wifi-firmware ]; # The QCA6390 driver currently requires a specific version of the kernel @@ -212,14 +212,22 @@ }; } - # Patch for crash by w1nk. + # Extra patches by wink. { + # Improves some cases in which races could occur. name = "w1nk-irq-lock-patch"; patch = pkgs.fetchpatch { url = "https://raw.githubusercontent.com/w1nk/ath11k-debug/master/one-irq-manage.patch"; sha256 = "011db3h10smqy0ni0qr9mkyhykf1f3yq6yym6ysbb7jr7l51q0n9"; }; } + { + # System crashes appear to have been caused by MHI state transitions to M2 state. + # Currently under investigation. + # http://lists.infradead.org/pipermail/ath11k/2020-December/000876.html + name = "w1nk-disable-mhi-m2-transition"; + patch = ./disable-mhi-m2.patch; + } ]; } // (args.argsOverride or { })); linux_patched = pkgs.callPackage linux_patched_pkg { }; diff --git a/dell/xps/13-9310/disable-mhi-m2.patch b/dell/xps/13-9310/disable-mhi-m2.patch new file mode 100644 index 0000000..b935c89 --- /dev/null +++ b/dell/xps/13-9310/disable-mhi-m2.patch @@ -0,0 +1,19 @@ +diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c +index 3de7b1639ec6..02882038e4cc 100644 +--- a/drivers/bus/mhi/core/pm.c ++++ b/drivers/bus/mhi/core/pm.c +@@ -55,12 +55,12 @@ static struct mhi_pm_transitions const dev_state_transitions[] = { + }, + { + MHI_PM_M0, +- MHI_PM_M0 | MHI_PM_M2 | MHI_PM_M3_ENTER | ++ MHI_PM_M0 | MHI_PM_M3_ENTER | + MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | + MHI_PM_LD_ERR_FATAL_DETECT | MHI_PM_FW_DL_ERR + }, + { +- MHI_PM_M2, ++ MHI_PM_M0, + MHI_PM_M0 | MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | + MHI_PM_LD_ERR_FATAL_DETECT + }, diff --git a/dell/xps/13-9310/qca6390-firmware.nix b/dell/xps/13-9310/qca6390-wifi-firmware.nix similarity index 96% rename from dell/xps/13-9310/qca6390-firmware.nix rename to dell/xps/13-9310/qca6390-wifi-firmware.nix index f27874c..7e1a756 100644 --- a/dell/xps/13-9310/qca6390-firmware.nix +++ b/dell/xps/13-9310/qca6390-wifi-firmware.nix @@ -3,7 +3,7 @@ { stdenv, fetchFromGitHub }: stdenv.mkDerivation rec { - name = "${target}-firmware-${version}"; + name = "${target}-wifi-firmware-${version}"; version = "${branch}-00042"; branch = "master"; target = "QCA6390";