From dc64193a62f7387363ea01dccdac16bb1fd6d551 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 26 Aug 2023 19:49:51 +0000 Subject: [PATCH] moby: generalize sun4i init failure to displayManager *and* greetd --- hosts/by-name/moby/default.nix | 40 ------------------------------- hosts/by-name/moby/kernel.nix | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/hosts/by-name/moby/default.nix b/hosts/by-name/moby/default.nix index 65244730..46c86ebc 100644 --- a/hosts/by-name/moby/default.nix +++ b/hosts/by-name/moby/default.nix @@ -132,44 +132,4 @@ ''; hardware.opengl.driSupport = true; - - services.xserver.displayManager.job.preStart = let - dmesg = "${pkgs.util-linux}/bin/dmesg"; - grep = "${pkgs.gnugrep}/bin/grep"; - modprobe = "${pkgs.kmod}/bin/modprobe"; - in '' - # common boot failure: - # blank screen (no backlight even), with the following log: - # ```syslog - # sun8i-dw-hdmi 1ee0000.hdmi: Couldn't get the HDMI PHY - # ... - # sun4i-drm display-engine: Couldn't bind all pipelines components - # ... - # sun8i-dw-hdmi: probe of 1ee0000.hdmi failed with error -17 - # ``` - # - # in particular, that `probe ... failed` occurs *only* on failed boots - # (the other messages might sometimes occur even on successful runs?) - # - # reloading the sun8i hdmi driver usually gets the screen on, showing boot text. - # then restarting display-manager.service gets us to the login. - # - # NB: the above log is default level. though less specific, there's a `err` level message that also signals this: - # sun4i-drm display-engine: failed to bind 1ee0000.hdmi (ops sun8i_dw_hdmi_ops [sun8i_drm_hdmi]): -17 - # NB: this is the most common, but not the only, failure mode for `display-manager`. - # another error seems characterized by these dmesg logs, in which reprobing sun8i_drm_hdmi does not fix: - # ```syslog - # sun6i-mipi-dsi 1ca0000.dsi: Couldn't get the MIPI D-PHY - # sun4i-drm display-engine: Couldn't bind all pipelines components - # sun6i-mipi-dsi 1ca0000.dsi: Couldn't register our component - # ``` - - if (${dmesg} --kernel --level err --color=never --notime | ${grep} -q 'sun4i-drm display-engine: failed to bind 1ee0000.hdmi') - then - echo "reprobing sun8i_drm_hdmi" - # if a command here fails it errors the whole service, so prefer to log instead - ${modprobe} -r sun8i_drm_hdmi || echo "failed to unload sun8i_drm_hdmi" - ${modprobe} sun8i_drm_hdmi || echo "failed to load sub8i_drm_hdmi" - fi - ''; } diff --git a/hosts/by-name/moby/kernel.nix b/hosts/by-name/moby/kernel.nix index ec540cb5..dcb03979 100644 --- a/hosts/by-name/moby/kernel.nix +++ b/hosts/by-name/moby/kernel.nix @@ -1,4 +1,44 @@ { pkgs, ... }: +let + dmesg = "${pkgs.util-linux}/bin/dmesg"; + grep = "${pkgs.gnugrep}/bin/grep"; + modprobe = "${pkgs.kmod}/bin/modprobe"; + ensureHWReady = '' + # common boot failure: + # blank screen (no backlight even), with the following log: + # ```syslog + # sun8i-dw-hdmi 1ee0000.hdmi: Couldn't get the HDMI PHY + # ... + # sun4i-drm display-engine: Couldn't bind all pipelines components + # ... + # sun8i-dw-hdmi: probe of 1ee0000.hdmi failed with error -17 + # ``` + # + # in particular, that `probe ... failed` occurs *only* on failed boots + # (the other messages might sometimes occur even on successful runs?) + # + # reloading the sun8i hdmi driver usually gets the screen on, showing boot text. + # then restarting display-manager.service gets us to the login. + # + # NB: the above log is default level. though less specific, there's a `err` level message that also signals this: + # sun4i-drm display-engine: failed to bind 1ee0000.hdmi (ops sun8i_dw_hdmi_ops [sun8i_drm_hdmi]): -17 + # NB: this is the most common, but not the only, failure mode for `display-manager`. + # another error seems characterized by these dmesg logs, in which reprobing sun8i_drm_hdmi does not fix: + # ```syslog + # sun6i-mipi-dsi 1ca0000.dsi: Couldn't get the MIPI D-PHY + # sun4i-drm display-engine: Couldn't bind all pipelines components + # sun6i-mipi-dsi 1ca0000.dsi: Couldn't register our component + # ``` + + if (${dmesg} --kernel --level err --color=never --notime | ${grep} -q 'sun4i-drm display-engine: failed to bind 1ee0000.hdmi') + then + echo "reprobing sun8i_drm_hdmi" + # if a command here fails it errors the whole service, so prefer to log instead + ${modprobe} -r sun8i_drm_hdmi || echo "failed to unload sun8i_drm_hdmi" + ${modprobe} sun8i_drm_hdmi || echo "failed to load sub8i_drm_hdmi" + fi + ''; +in { boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux-megous; # boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux-manjaro; @@ -25,4 +65,7 @@ target = "Image.gz"; # <-- compress the kernel image # target = "zImage"; # <-- confuses other parts of nixos :-( }; + + services.xserver.displayManager.job.preStart = ensureHWReady; + systemd.services.greetd.preStart = ensureHWReady; }