Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34003
Change subject: pcengines/apuX: Replace use of dev_find_slot() ......................................................................
pcengines/apuX: Replace use of dev_find_slot()
Find the NIC device based on the PCIe root port function.
Change-Id: Ia8c6e115c9b836ee60862427dfc9d46ca3dd1b69 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/mainboard/pcengines/apu1/mainboard.c M src/mainboard/pcengines/apu2/mainboard.c 2 files changed, 16 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/34003/1
diff --git a/src/mainboard/pcengines/apu1/mainboard.c b/src/mainboard/pcengines/apu1/mainboard.c index e5e30e0..088c839 100644 --- a/src/mainboard/pcengines/apu1/mainboard.c +++ b/src/mainboard/pcengines/apu1/mainboard.c @@ -206,17 +206,23 @@ const char *smbios_mainboard_serial_number(void) { static char serial[10]; - struct device *nic_dev; + struct device *dev; uintptr_t bar18; u32 mac_addr = 0; int i;
- nic_dev = dev_find_slot(1, PCI_DEVFN(0, 0)); - if ((serial[0] != 0) || !nic_dev) + /* Already initialized. */ + if (serial[0] != 0) + return serial; + + dev = pcidev_on_root(4, 0); + if (dev) + dev = pcidev_path_behind(dev->link_list, PCI_DEVFN(0, 0)); + if (!dev) return serial;
/* Read in the last 3 bytes of NIC's MAC address. */ - bar18 = pci_read_config32(nic_dev, 0x18); + bar18 = pci_read_config32(dev, 0x18); bar18 &= 0xFFFFFC00; for (i = 3; i < 6; i++) { mac_addr <<= 8; diff --git a/src/mainboard/pcengines/apu2/mainboard.c b/src/mainboard/pcengines/apu2/mainboard.c index 5a19d20..7dff6b9 100644 --- a/src/mainboard/pcengines/apu2/mainboard.c +++ b/src/mainboard/pcengines/apu2/mainboard.c @@ -197,9 +197,12 @@ struct device *dev; uintptr_t bar10; u32 mac_addr = 0; - u32 bus_no; int i;
+ /* Already initialized. */ + if (serial[0] != 0) + return serial; + /* * In case we have PCIe module connected to mPCIe2 slot, BDF 1:0.0 may * not be a NIC, because mPCIe2 slot is routed to the very first PCIe @@ -208,11 +211,8 @@ * connected. */ dev = pcidev_on_root(2, 2); - if ((serial[0] != 0) || !dev) - return serial; - - bus_no = dev->link_list->secondary; - dev = dev_find_slot(bus_no, PCI_DEVFN(0, 0)); + if (dev) + dev = pcidev_path_behind(dev->link_list, PCI_DEVFN(0, 0)); if (!dev) return serial;
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34003 )
Change subject: pcengines/apuX: Replace use of dev_find_slot() ......................................................................
Patch Set 1: Code-Review+1
(1 comment)
https://review.coreboot.org/#/c/34003/1/src/mainboard/pcengines/apu2/mainboa... File src/mainboard/pcengines/apu2/mainboard.c:
https://review.coreboot.org/#/c/34003/1/src/mainboard/pcengines/apu2/mainboa... PS1, Line 203: : : : : : : Is this comment useful?
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34003 )
Change subject: pcengines/apuX: Replace use of dev_find_slot() ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/#/c/34003/1/src/mainboard/pcengines/apu2/mainboa... File src/mainboard/pcengines/apu2/mainboard.c:
https://review.coreboot.org/#/c/34003/1/src/mainboard/pcengines/apu2/mainboa... PS1, Line 203: : : : : : :
Is this comment useful?
Right.. comment needs a bit of adjustment.
Michał Żygowski has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34003 )
Change subject: pcengines/apuX: Replace use of dev_find_slot() ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/#/c/34003/1/src/mainboard/pcengines/apu2/mainboa... File src/mainboard/pcengines/apu2/mainboard.c:
https://review.coreboot.org/#/c/34003/1/src/mainboard/pcengines/apu2/mainboa... PS1, Line 203: : : : : : :
Right.. comment needs a bit of adjustment.
The commit message in the change that introduced this comment explains well enough what is going on here. IMO we can drop this comment in the patch.
https://review.coreboot.org/c/coreboot/+/29842
Hello Arthur Heymans, build bot (Jenkins), Michał Żygowski,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/34003
to look at the new patch set (#2).
Change subject: pcengines/apuX: Replace use of dev_find_slot() ......................................................................
pcengines/apuX: Replace use of dev_find_slot()
Find the NIC device based on the PCIe root port function.
Change-Id: Ia8c6e115c9b836ee60862427dfc9d46ca3dd1b69 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/mainboard/pcengines/apu1/mainboard.c M src/mainboard/pcengines/apu2/mainboard.c 2 files changed, 15 insertions(+), 16 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/34003/2
Michał Żygowski has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34003 )
Change subject: pcengines/apuX: Replace use of dev_find_slot() ......................................................................
Patch Set 2: Code-Review+2
Kyösti Mälkki has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/34003 )
Change subject: pcengines/apuX: Replace use of dev_find_slot() ......................................................................
pcengines/apuX: Replace use of dev_find_slot()
Find the NIC device based on the PCIe root port function.
Change-Id: Ia8c6e115c9b836ee60862427dfc9d46ca3dd1b69 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/34003 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Michał Żygowski michal.zygowski@3mdeb.com --- M src/mainboard/pcengines/apu1/mainboard.c M src/mainboard/pcengines/apu2/mainboard.c 2 files changed, 15 insertions(+), 16 deletions(-)
Approvals: build bot (Jenkins): Verified Michał Żygowski: Looks good to me, approved
diff --git a/src/mainboard/pcengines/apu1/mainboard.c b/src/mainboard/pcengines/apu1/mainboard.c index e5e30e0..088c839 100644 --- a/src/mainboard/pcengines/apu1/mainboard.c +++ b/src/mainboard/pcengines/apu1/mainboard.c @@ -206,17 +206,23 @@ const char *smbios_mainboard_serial_number(void) { static char serial[10]; - struct device *nic_dev; + struct device *dev; uintptr_t bar18; u32 mac_addr = 0; int i;
- nic_dev = dev_find_slot(1, PCI_DEVFN(0, 0)); - if ((serial[0] != 0) || !nic_dev) + /* Already initialized. */ + if (serial[0] != 0) + return serial; + + dev = pcidev_on_root(4, 0); + if (dev) + dev = pcidev_path_behind(dev->link_list, PCI_DEVFN(0, 0)); + if (!dev) return serial;
/* Read in the last 3 bytes of NIC's MAC address. */ - bar18 = pci_read_config32(nic_dev, 0x18); + bar18 = pci_read_config32(dev, 0x18); bar18 &= 0xFFFFFC00; for (i = 3; i < 6; i++) { mac_addr <<= 8; diff --git a/src/mainboard/pcengines/apu2/mainboard.c b/src/mainboard/pcengines/apu2/mainboard.c index 5a19d20..682120b 100644 --- a/src/mainboard/pcengines/apu2/mainboard.c +++ b/src/mainboard/pcengines/apu2/mainboard.c @@ -197,22 +197,15 @@ struct device *dev; uintptr_t bar10; u32 mac_addr = 0; - u32 bus_no; int i;
- /* - * In case we have PCIe module connected to mPCIe2 slot, BDF 1:0.0 may - * not be a NIC, because mPCIe2 slot is routed to the very first PCIe - * bridge and the first NIC is connected to the second PCIe bridge. - * Read secondary bus number from the PCIe bridge where the first NIC is - * connected. - */ - dev = pcidev_on_root(2, 2); - if ((serial[0] != 0) || !dev) + /* Already initialized. */ + if (serial[0] != 0) return serial;
- bus_no = dev->link_list->secondary; - dev = dev_find_slot(bus_no, PCI_DEVFN(0, 0)); + dev = pcidev_on_root(2, 2); + if (dev) + dev = pcidev_path_behind(dev->link_list, PCI_DEVFN(0, 0)); if (!dev) return serial;