--- zzzz-none-000/linux-4.19.183/drivers/pci/pcie/aspm.c 2021-03-24 10:07:39.000000000 +0000 +++ bcm63-7530ax-756/linux-4.19.183/drivers/pci/pcie/aspm.c 2023-06-28 08:54:19.000000000 +0000 @@ -96,6 +96,10 @@ #define POLICY_PERFORMANCE 1 /* high performance */ #define POLICY_POWERSAVE 2 /* high power saving */ #define POLICY_POWER_SUPERSAVE 3 /* possibly even more power saving */ +#if defined(CONFIG_BCM_KF_POWER_SAVE) +#define POLICY_L0SPOWERSAVE 4 /* Only do L0S */ +#define POLICY_L1POWERSAVE 5 /* Typically same savings as L1+L0s */ +#endif #ifdef CONFIG_PCIEASPM_PERFORMANCE static int aspm_policy = POLICY_PERFORMANCE; @@ -112,6 +116,11 @@ [POLICY_PERFORMANCE] = "performance", [POLICY_POWERSAVE] = "powersave", [POLICY_POWER_SUPERSAVE] = "powersupersave" +#if defined(CONFIG_BCM_KF_POWER_SAVE) + , + [POLICY_L0SPOWERSAVE] = "l0s_powersave", + [POLICY_L1POWERSAVE] = "l1_powersave", +#endif }; #define LINK_RETRAIN_TIMEOUT HZ @@ -128,6 +137,14 @@ case POLICY_POWER_SUPERSAVE: /* Enable Everything */ return ASPM_STATE_ALL; +#if defined(CONFIG_BCM_KF_POWER_SAVE) + case POLICY_L0SPOWERSAVE: + /* Enable ASPM L0s */ + return ASPM_STATE_L0S; + case POLICY_L1POWERSAVE: + /* Enable ASPM L1 */ + return ASPM_STATE_L1; +#endif case POLICY_DEFAULT: return link->aspm_default; } @@ -138,10 +155,16 @@ { switch (aspm_policy) { case POLICY_PERFORMANCE: +#if defined(CONFIG_BCM_KF_POWER_SAVE) + case POLICY_L0SPOWERSAVE: +#endif /* Disable ASPM and Clock PM */ return 0; case POLICY_POWERSAVE: case POLICY_POWER_SUPERSAVE: +#if defined(CONFIG_BCM_KF_POWER_SAVE) + case POLICY_L1POWERSAVE: +#endif /* Enable Clock PM */ return 1; case POLICY_DEFAULT: @@ -199,8 +222,13 @@ } link->clkpm_enabled = enabled; link->clkpm_default = enabled; +#if defined(CONFIG_BCM_KF_POWER_SAVE) + // Do not enable clkpm for the moment + link->clkpm_capable = 0; +#else link->clkpm_capable = capable; link->clkpm_disable = blacklist ? 1 : 0; +#endif } static bool pcie_retrain_link(struct pcie_link_state *link) @@ -849,6 +877,25 @@ pci_info(child, "disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n"); return -EINVAL; } +#if defined(CONFIG_BCM_KF_POWER_SAVE) + // Only enable ASPM where thoroughly tested + dev_printk(KERN_DEBUG, &pdev->dev, "Checking PCIe ASPM for vendor %x device %x\n", child->vendor, child->device); + if ((child->vendor == 0x14e4) && + (child->device != 0x4365) && // 4365 + (child->device != 0x4366) && // 4366 + (child->device != 0xaa90) && // 4366E + (child->device != 0xaa92) && // 4365E + (child->device != 0x4360) && // 4360 + (child->device != 0x43a0) && // 4360 + (child->device != 0x43a1) && // 4360 + (child->device != 0x43a2) && // 4360 + (child->device != 0x43a9) && // 43217 + (child->device != 0xa8db)) // 43217-43227 + { + dev_printk(KERN_DEBUG, &pdev->dev, "Disabling PCIe ASPM for vendor %x device %x\n", child->vendor, child->device); + return -EINVAL; + } +#endif } return 0; }