Tim Wawrzynczak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/52765 )
Change subject: device: Switch pci_dev_is_wake_source to take pci_devfn_t ......................................................................
device: Switch pci_dev_is_wake_source to take pci_devfn_t
With the recent switch to SMM module loader v2, the size of the SMM for module google/volteer increased to above 64K in size, and thus failed to install the permanent SMM handler. Turns out, the devicetree is all pulled into the SMM build because of elog, which calls `pci_dev_is_wake_source`, and is the only user of `struct device` in SMM. Changing this function to take a pci_devfn_t instead allows the linker to remove almost the entire devicetree from SMM (only usage left is when disabling HECI via SMM).
BUG=b:186661594 TEST=Verify loaded program size of `smm.elf` for google/volteer is almost ~50% smaller.
Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org Change-Id: I4c39e5188321c8711d6479b15065e5aaedad8f38 --- M src/device/pci_ops.c M src/drivers/wifi/generic/generic.c M src/include/device/pci_ops.h M src/soc/intel/alderlake/elog.c M src/soc/intel/jasperlake/elog.c M src/soc/intel/tigerlake/elog.c 6 files changed, 15 insertions(+), 59 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/65/52765/1
diff --git a/src/device/pci_ops.c b/src/device/pci_ops.c index aaa9f95..76d5e96 100644 --- a/src/device/pci_ops.c +++ b/src/device/pci_ops.c @@ -79,19 +79,16 @@ die("PCI: dev is NULL!\n"); }
-bool pci_dev_is_wake_source(const struct device *dev) +bool pci_dev_is_wake_source(pci_devfn_t dev) { unsigned int pm_cap; uint16_t pmcs;
- if (dev->path.type != DEVICE_PATH_PCI) - return false; - - pm_cap = pci_find_capability(dev, PCI_CAP_ID_PM); + pm_cap = pci_s_find_capability(dev, PCI_CAP_ID_PM); if (!pm_cap) return false;
- pmcs = pci_s_read_config16(PCI_BDF(dev), pm_cap + PCI_PM_CTRL); + pmcs = pci_s_read_config16(dev, pm_cap + PCI_PM_CTRL);
/* PCI Device is a wake source if PME_ENABLE and PME_STATUS are set in PMCS register. */ return (pmcs & PCI_PM_CTRL_PME_ENABLE) && (pmcs & PCI_PM_CTRL_PME_STATUS); diff --git a/src/drivers/wifi/generic/generic.c b/src/drivers/wifi/generic/generic.c index 5429f6b..1ee7ab2 100644 --- a/src/drivers/wifi/generic/generic.c +++ b/src/drivers/wifi/generic/generic.c @@ -10,7 +10,7 @@
static void wifi_pci_dev_init(struct device *dev) { - if (pci_dev_is_wake_source(dev)) + if (pci_dev_is_wake_source(PCI_BDF(dev))) elog_add_event_wake(ELOG_WAKE_SOURCE_PME_WIFI, 0); }
diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h index 7fe7d42..a167825 100644 --- a/src/include/device/pci_ops.h +++ b/src/include/device/pci_ops.h @@ -215,6 +215,6 @@ * * Returns true if PCI device is wake source, false otherwise. */ -bool pci_dev_is_wake_source(const struct device *dev); +bool pci_dev_is_wake_source(pci_devfn_t dev);
#endif /* PCI_OPS_H */ diff --git a/src/soc/intel/alderlake/elog.c b/src/soc/intel/alderlake/elog.c index 1efba25..4637662 100644 --- a/src/soc/intel/alderlake/elog.c +++ b/src/soc/intel/alderlake/elog.c @@ -48,11 +48,7 @@ };
for (i = 0; i < MIN(CONFIG_MAX_ROOT_PORTS, ARRAY_SIZE(pme_map)); ++i) { - const struct device *dev = pcidev_path_on_root(pme_map[i].devfn); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) + if (pci_dev_is_wake_source(pme_map[i].devfn)) elog_add_event_wake(pme_map[i].wake_source, 0); } } @@ -77,11 +73,7 @@ size_t i;
for (i = 0; i < ARRAY_SIZE(ipme_map); i++) { - const struct device *dev = pcidev_path_on_root(ipme_map[i].devfn); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) { + if (pci_dev_is_wake_source(ipme_map[i].devfn)) { elog_add_event_wake(ipme_map[i].wake_source, 0); dev_found = true; } @@ -89,11 +81,7 @@
/* Check Thunderbolt ports */ for (i = 0; i < NUM_TBT_FUNCTIONS; i++) { - const struct device *dev = pcidev_path_on_root(SA_DEVFN_TBT(i)); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) { + if (pci_dev_is_wake_source(SA_DEVFN_TBT(i))) { elog_add_event_wake(ELOG_WAKE_SOURCE_PME_TBT, i); dev_found = true; } @@ -101,11 +89,7 @@
/* Check DMA devices */ for (i = 0; i < NUM_TCSS_DMA_FUNCTIONS; i++) { - const struct device *dev = pcidev_path_on_root(SA_DEVFN_TCSS_DMA(i)); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) { + if (pci_dev_is_wake_source(SA_DEVFN_TCSS_DMA(i))) { elog_add_event_wake(ELOG_WAKE_SOURCE_PME_TCSS_DMA, i); dev_found = true; } diff --git a/src/soc/intel/jasperlake/elog.c b/src/soc/intel/jasperlake/elog.c index ccf6fd0..4909da4 100644 --- a/src/soc/intel/jasperlake/elog.c +++ b/src/soc/intel/jasperlake/elog.c @@ -48,11 +48,7 @@ };
for (i = 0; i < MIN(CONFIG_MAX_ROOT_PORTS, ARRAY_SIZE(pme_map)); ++i) { - const struct device *dev = pcidev_path_on_root(pme_map[i].devfn); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) + if (pci_dev_is_wake_source(pme_map[i].devfn)) elog_add_event_wake(pme_map[i].wake_source, 0); } } @@ -75,11 +71,7 @@ };
for (i = 0; i < ARRAY_SIZE(ipme_map); i++) { - const struct device *dev = pcidev_path_on_root(ipme_map[i].devfn); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) { + if (pci_dev_is_wake_source(ipme_map[i].devfn)) { elog_add_event_wake(ipme_map[i].wake_source, 0); dev_found = true; } diff --git a/src/soc/intel/tigerlake/elog.c b/src/soc/intel/tigerlake/elog.c index 878959a..3205954 100644 --- a/src/soc/intel/tigerlake/elog.c +++ b/src/soc/intel/tigerlake/elog.c @@ -48,11 +48,7 @@ };
for (i = 0; i < MIN(CONFIG_MAX_ROOT_PORTS, ARRAY_SIZE(pme_map)); ++i) { - const struct device *dev = pcidev_path_on_root(pme_map[i].devfn); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) + if (pci_dev_is_wake_source(pme_map[i].devfn)) elog_add_event_wake(pme_map[i].wake_source, 0); } } @@ -76,12 +72,7 @@ size_t i;
for (i = 0; i < ARRAY_SIZE(ipme_map); i++) { - const struct device *dev = - pcidev_path_on_root(ipme_map[i].devfn); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) { + if (pci_dev_is_wake_source(ipme_map[i].devfn)) { elog_add_event_wake(ipme_map[i].wake_source, 0); dev_found = true; } @@ -89,11 +80,7 @@
/* Check Thunderbolt ports */ for (i = 0; i < NUM_TBT_FUNCTIONS; i++) { - const struct device *dev = pcidev_path_on_root(SA_DEVFN_TBT(i)); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) { + if (pci_dev_is_wake_source(SA_DEVFN_TBT(i))) { elog_add_event_wake(ELOG_WAKE_SOURCE_PME_TBT, i); dev_found = true; } @@ -101,11 +88,7 @@
/* Check DMA devices */ for (i = 0; i < NUM_TCSS_DMA_FUNCTIONS; i++) { - const struct device *dev = pcidev_path_on_root(SA_DEVFN_TCSS_DMA(i)); - if (!dev) - continue; - - if (pci_dev_is_wake_source(dev)) { + if (pci_dev_is_wake_source(SA_DEVFN_TCSS_DMA(i))) { elog_add_event_wake(ELOG_WAKE_SOURCE_PME_TCSS_DMA, i); dev_found = true; }