Only program a BAR as a 64-bit MEM BAR if it really is a 64-bit MEM BAR. Fixes an issue with the CMD646 IDE controller under NetBSD.
Improve some debug/info messages. Signed-off-by: Jason Thorpe <thor...@me.com> --- pci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pci.c b/pci.c index ba05adb..5e9c906 100644 --- a/pci.c +++ b/pci.c @@ -84,7 +84,7 @@ pci_setup_device(int bdf, uint32_t *p_io_base, uint32_t *p_mem_base) device_id = pci_config_readw(bdf, PCI_DEVICE_ID); class_id = pci_config_readw(bdf, PCI_CLASS_DEVICE); - printf("PCI: %02x:%02x:%x class %04x id %04x:%04x\r\n", + printf("PCI: %d:%d:%d class %04x id %04x:%04x\r\n", PCI_BUS(bdf), PCI_SLOT(bdf), PCI_FUNC(bdf), class_id, vendor_id, device_id); @@ -118,9 +118,10 @@ pci_setup_device(int bdf, uint32_t *p_io_base, uint32_t *p_mem_base) *p_base = addr + size; pci_config_writel(bdf, ofs, addr); - printf("PCI: region %d: %08x\r\n", region, addr); + printf("PCI: region %d (BAR %02x): %08x\r\n", region, ofs, addr); - if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) + if ((old & PCI_BASE_ADDRESS_SPACE_IO) == 0 && + (old & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) { pci_config_writel(bdf, ofs + 4, 0); -- 2.30.2