Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/31754 )
Change subject: arch/x86: Optimise PCI IO config accessor ......................................................................
arch/x86: Optimise PCI IO config accessor
By design only 'reg' parameter can have the two least- significant bits set. As 'reg' is often a constant, '0xCFC + (reg & 3)' resolves to an immediate value already at buildtime, unlike (addr & 3) which depends of a constant (but non-immediate) value of 'dev' in ramstage.
Change-Id: I6e729fe800c92b1ce4994ad2b4203072fa75a958 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/31754 Reviewed-by: Nico Huber nico.h@gmx.de Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/arch/x86/include/arch/pci_io_cfg.h 1 file changed, 4 insertions(+), 4 deletions(-)
Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
diff --git a/src/arch/x86/include/arch/pci_io_cfg.h b/src/arch/x86/include/arch/pci_io_cfg.h index 317c50a..6c88b3c 100644 --- a/src/arch/x86/include/arch/pci_io_cfg.h +++ b/src/arch/x86/include/arch/pci_io_cfg.h @@ -34,7 +34,7 @@ { uint32_t addr = pci_io_encode_addr(dev, reg); outl(0x80000000 | (addr & ~3), 0xCF8); - return inb(0xCFC + (addr & 3)); + return inb(0xCFC + (reg & 3)); }
static __always_inline @@ -42,7 +42,7 @@ { uint32_t addr = pci_io_encode_addr(dev, reg); outl(0x80000000 | (addr & ~3), 0xCF8); - return inw(0xCFC + (addr & 2)); + return inw(0xCFC + (reg & 2)); }
static __always_inline @@ -58,7 +58,7 @@ { uint32_t addr = pci_io_encode_addr(dev, reg); outl(0x80000000 | (addr & ~3), 0xCF8); - outb(value, 0xCFC + (addr & 3)); + outb(value, 0xCFC + (reg & 3)); }
static __always_inline @@ -66,7 +66,7 @@ { uint32_t addr = pci_io_encode_addr(dev, reg); outl(0x80000000 | (addr & ~3), 0xCF8); - outw(value, 0xCFC + (addr & 2)); + outw(value, 0xCFC + (reg & 2)); }
static __always_inline