Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for ga403 #1255

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ See code for all available configurations.
| [Asus ROG Zephyrus G14 GA402](asus/zephyrus/ga402) | `<nixos-hardware/asus/zephyrus/ga402>` |
| [Asus ROG Zephyrus G14 GA402X\* (2023)](asus/zephyrus/ga402x/amdgpu) | `<nixos-hardware/asus/zephyrus/ga402x/amdgpu>` |
| [Asus ROG Zephyrus G14 GA402X\* (2023)](asus/zephyrus/ga402x/nvidia) | `<nixos-hardware/asus/zephyrus/ga402x/nvidia>` |
| [Asus ROG Zephyrus G14 GA403 (2024)](asus/zephyrus/ga403) | `<nixos-hardware/asus/zephyrus/ga403>` |
| [Asus ROG Zephyrus G15 GA502](asus/zephyrus/ga502) | `<nixos-hardware/asus/zephyrus/ga502>` |
| [Asus ROG Zephyrus G15 GA503](asus/zephyrus/ga503) | `<nixos-hardware/asus/zephyrus/ga503>` |
| [Asus ROG Zephyrus G16 GU605MY](asus/zephyrus/gu605my) | `<nixos-hardware/asus/zephyrus/gu605my>` |
Expand Down
93 changes: 93 additions & 0 deletions asus/zephyrus/ga403/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
config,
pkgs,
lib,
...
}:

let
inherit (lib)
mkDefault
mkForce
;
in
{

imports = [
../../../common/cpu/amd
../../../common/cpu/amd/pstate.nix
../../../common/gpu/amd
../../../common/pc/laptop
../../../common/pc/ssd
../../../common/gpu/nvidia/prime.nix
../../../common/gpu/nvidia/ada-lovelace
];

config = {
# Configure basic system settings:
boot = {
# Note: it seems being on the latest kernel is important for CPPC to work, which is required for the amd_pstate
# https://bugzilla.kernel.org/show_bug.cgi?id=218686
kernelPackages = mkDefault pkgs.linuxPackages_latest;
kernelModules = [ "kvm-amd" ];
kernelParams = [
"mem_sleep_default=deep"
"pcie_aspm.policy=powersupersave"
];
};

services = {
asusd = {
enable = mkDefault true;
enableUserService = mkDefault true;
};

supergfxd.enable = mkDefault true;
};

# Enable the Nvidia card, as well as Prime and Offload: NVIDIA GeForce RTX 4060 Mobile
boot.blacklistedKernelModules = [ "nouveau" ];

services.xserver.videoDrivers = mkForce [
"amdgpu"
"nvidia"
];

hardware = {
amdgpu.initrd.enable = mkDefault true;

nvidia = {
modesetting.enable = true;
nvidiaSettings = mkDefault true;

prime = {
offload = {
enable = mkDefault true;
enableOffloadCmd = mkDefault true;
};
amdgpuBusId = "PCI:101:0:0";
nvidiaBusId = "PCI:1:0:0";
};

powerManagement = {
enable = true;
finegrained = true;
};
};
};
# Meditek doesn't seem to be quite sensitive enough on the default roaming settings:
# https://wiki.archlinux.org/title/Wpa_supplicant#Roaming
# https://wiki.archlinux.org/title/Iwd#iwd_keeps_roaming
#
# But NixOS doesn't have the tweaks for IWD, yet.
networking.wireless.iwd.settings =
lib.mkIf (config.networking.wireless.iwd.enable && config.networking.wireless.scanOnLowSignal)
{
General = {
RoamThreshold = -75;
RoamThreshold5G = -80;
RoamRetryInterval = 20;
};
};
};
}
18 changes: 18 additions & 0 deletions common/gpu/nvidia/ada-lovelace/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,22 @@ in

# enable the open source drivers if the package supports it
hardware.nvidia.open = lib.mkOverride 990 (nvidiaPackage ? open && nvidiaPackage ? firmware);

# nvidia's hibernate, suspend, and resume services are not normally triggered on suspend-then-hibernate and hybrid-hibernate
Copy link
Member

@Mic92 Mic92 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something the service should do in general or just for this gpu generation?

Copy link
Author

@Mydien27 Mydien27 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that has to do with nvidia's services to suspend and resume the graphics card. If you read the service file from the driver, you will notice it triggers on the normal suspend/hibernate/resume systemd services, but not the "special" ones such as suspend-then-hibernate or hybrid-sleep. The normal options will work, but this causes the card to fail in the special modes with:
PM: pci_pm_suspend(): nv_pmops_suspend+0x0/0x30 [nvidia] returns -5
PM: dpm_run_callback(): pci_pm_suspend+0x0/0x170 returns -5
nvidia 0000:07:00.0: PM: failed to suspend: error -5
PM: Some devices failed to suspend, or early wake event detected

See here for issue discussion: https://forums.developer.nvidia.com/t/nvidia-laptop-unable-to-suspend/221788/10
See here for solution: https://forums.developer.nvidia.com/t/systemds-suspend-then-hibernate-not-working-in-nvidia-optimus-laptop/213690

I was hesitant to add it to the common/gpu/nvidia/default.nix since I did not want to break something I was unaware of. I believe I have read it is not an issue on older nvidia GPUs. However, I know this is an issue with the nvidia services, not just the Zephyrus and have had similar problems on my Surface Book 3 (1660 Ti Max-Q). Perhaps it should live in common/gpu/nvidia/default.nix and check the driver version or as an option with a default of false?

systemd.services = {
nvidia-hibernate = {
before = [ "systemd-suspend-then-hibernate.service" ];
wantedBy = [ "suspend-then-hibernate.target" ];
};

nvidia-suspend = {
before = [ "systemd-hybrid-sleep.service" ];
wantedBy = [ "hybrid-sleep.target" ];
};

nvidia-resume = {
after = [ "systemd-suspend-then-hibernate.service" "systemd-hybrid-sleep.service" ];
wantedBy = [ "post-resume.target" ];
};
};
}
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
asus-zephyrus-ga402x = import ./asus/zephyrus/ga402x;
asus-zephyrus-ga402x-amdgpu = import ./asus/zephyrus/ga402x/amdgpu;
asus-zephyrus-ga402x-nvidia = import ./asus/zephyrus/ga402x/nvidia;
asus-zephyrus-ga403 = import ./asus/zephyrus/ga403;
Mic92 marked this conversation as resolved.
Show resolved Hide resolved
asus-zephyrus-ga502 = import ./asus/zephyrus/ga502;
asus-zephyrus-ga503 = import ./asus/zephyrus/ga503;
asus-zephyrus-gu603h = import ./asus/zephyrus/gu603h;
Expand Down
Loading