Your GeForce runs AI at half speed. This fixes it for 20/30/40 series cards. Up to 2× FP16 / BF16 / TF32 tensor throughput
C
gpu_unlock: decode PMCSR D0 with a helper
randomizedcoder [email protected]ca78f02c895a
diff --git a/kernel/gpu_unlock/gfw_eval.c b/kernel/gpu_unlock/gfw_eval.cindex d30c860..a72352e 100644--- a/kernel/gpu_unlock/gfw_eval.c+++ b/kernel/gpu_unlock/gfw_eval.c@@ -30,3 +30,8 @@ u16 gpu_unlock_command_restore(u16 original, u16 live)return (live & (u16)~mask) | (original & mask);}++bool gpu_unlock_pmcsr_d0(u16 pmcsr)+{+ return (pmcsr & GU_PCI_PM_CTRL_STATE_MASK) == GU_PCI_PM_STATE_D0;+}diff --git a/kernel/gpu_unlock/gfw_eval.h b/kernel/gpu_unlock/gfw_eval.hindex 81d853c..502315b 100644--- a/kernel/gpu_unlock/gfw_eval.h+++ b/kernel/gpu_unlock/gfw_eval.h@@ -25,6 +25,8 @@ typedef uint32_t u32;#define GU_PCI_COMMAND_IO 0x1u#define GU_PCI_COMMAND_MEMORY 0x2u#define GU_PCI_COMMAND_MASTER 0x4u+#define GU_PCI_PM_CTRL_STATE_MASK 0x3u+#define GU_PCI_PM_STATE_D0 0x0ustruct gpu_unlock_gfw_sample {bool config_ok;@@ -39,4 +41,7 @@ int gpu_unlock_gfw_assess(const struct gpu_unlock_gfw_sample *sample);/* Put memory and bus-master bits back. Leave every other command bit alone. */u16 gpu_unlock_command_restore(u16 original, u16 live);+/* PMCSR reports D0. PCI_D0 is the kernel's pci_power_t, not a PMCSR field. */+bool gpu_unlock_pmcsr_d0(u16 pmcsr);+#endifdiff --git a/kernel/gpu_unlock/unlock_610.c b/kernel/gpu_unlock/unlock_610.cindex 33a005b..8849cd7 100644--- a/kernel/gpu_unlock/unlock_610.c+++ b/kernel/gpu_unlock/unlock_610.c@@ -653,7 +653,7 @@ static int unlock_transaction_claim(struct unlock_transaction_work *work)(work->pdev->current_state != PCI_UNKNOWN || !work->pdev->pm_cap)) ||(work->pdev->pm_cap &&(diag_pci_word(work, false, work->pdev->pm_cap + PCI_PM_CTRL, &pmcsr) ||- (pmcsr & PCI_PM_CTRL_STATE_MASK) != PCI_D0)))+ !gpu_unlock_pmcsr_d0(pmcsr))))return GU_RESULT(-EOPNOTSUPP);if ((work->pdev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET) ||!pci_is_pcie(work->pdev) ||