On Sat, 20 Jul 2019, BALATON Zoltan wrote:
based on the above I think the pci-map-in implemented in OpenBIOS's pci driver approximately does what map-in we're missing should do:
https://github.com/openbios/openbios/blob/master/drivers/pci.c#L413
[...]
Or maybe it's easier to just rename pci-map-in in source as it only seems to be used by the vga driver FCode part in drivers/vga.fs (where it is used to map PCI BARs of the card, the same as the ATI ROM is trying to do). So is there a reason this is not yet called map-in but pci-map in?
I've tried renaming pci-map-in to map-in but it does not seem to work for what the ATI FCode is trying to do. I've also enabled PCI debugging options in OpenBIOS and QEMU, here are some logs I got (this is with the pci-set-args patch we talked about earlier plus renaming pci-map-in to map-in in drivers/pci.c):
[Cut some logs of init-ing other PCI cards, similar as below for ati-vga] 3233@1563634437.470612:pci_cfg_read ati-vga 15:0 @0x0 -> 0x1002 3233@1563634437.470616:pci_cfg_read ati-vga 15:0 @0x2 -> 0x5046 3233@1563634437.470619:pci_cfg_read ati-vga 15:0 @0xa -> 0x300 3233@1563634437.470622:pci_cfg_read ati-vga 15:0 @0x9 -> 0x0
0:f.0 - 1002:5046 -
3233@1563634437.470675:pci_cfg_read ati-vga 15:0 @0xe -> 0x0 /pci@f2000000/ATY - 3233@1563634437.471882:pci_cfg_read ati-vga 15:0 @0x3d -> 0x0 3233@1563634437.471886:pci_cfg_read ati-vga 15:0 @0x10 -> 0x8 3233@1563634437.471889:pci_cfg_write ati-vga 15:0 @0x10 <- 0xffffffff 3233@1563634437.471892:pci_cfg_read ati-vga 15:0 @0x10 -> 0xff000008 changing mem_base from 0x80400000 to 0x82000000
Configuring BARs for /pci@f2000000/ATY: reloc 0x81000000 omask 0x8
io_base 0x1000 mem_base 0x82000000 size 0x1000000 3233@1563634437.472242:pci_cfg_write ati-vga 15:0 @0x10 <- 0x81000008 3233@1563634437.472254:pci_cfg_read ati-vga 15:0 @0x14 -> 0x1 3233@1563634437.472257:pci_cfg_write ati-vga 15:0 @0x14 <- 0xffffffff 3233@1563634437.472260:pci_cfg_read ati-vga 15:0 @0x14 -> 0xffffff01
changing io_base from 0x1000 to 0x1100 Configuring BARs for /pci@f2000000/ATY: reloc 0x1000 omask 0x1 io_base
0x1100 mem_base 0x82000000 size 0x100 3233@1563634437.472556:pci_cfg_write ati-vga 15:0 @0x14 <- 0x1001 3233@1563634437.472566:pci_cfg_read ati-vga 15:0 @0x18 -> 0x0 3233@1563634437.472569:pci_cfg_write ati-vga 15:0 @0x18 <- 0xffffffff 3233@1563634437.472571:pci_cfg_read ati-vga 15:0 @0x18 -> 0xffffc000
changing mem_base from 0x82000000 to 0x82010000 Configuring BARs for /pci@f2000000/ATY: reloc 0x82000000 omask 0x0
io_base 0x1100 mem_base 0x82010000 size 0x10000 3233@1563634437.472878:pci_cfg_write ati-vga 15:0 @0x18 <- 0x82000000 3233@1563634437.472881:pci_cfg_read ati-vga 15:0 @0x1c -> 0x0 3233@1563634437.472884:pci_cfg_write ati-vga 15:0 @0x1c <- 0xffffffff 3233@1563634437.472886:pci_cfg_read ati-vga 15:0 @0x1c -> 0x0 3233@1563634437.472889:pci_cfg_read ati-vga 15:0 @0x20 -> 0x0 3233@1563634437.472891:pci_cfg_write ati-vga 15:0 @0x20 <- 0xffffffff 3233@1563634437.472893:pci_cfg_read ati-vga 15:0 @0x20 -> 0x0 3233@1563634437.472896:pci_cfg_read ati-vga 15:0 @0x24 -> 0x0 3233@1563634437.472898:pci_cfg_write ati-vga 15:0 @0x24 <- 0xffffffff 3233@1563634437.472901:pci_cfg_read ati-vga 15:0 @0x24 -> 0x0 3233@1563634437.472903:pci_cfg_read ati-vga 15:0 @0x30 -> 0x0 3233@1563634437.472906:pci_cfg_write ati-vga 15:0 @0x30 <- 0xffffffff 3233@1563634437.472908:pci_cfg_read ati-vga 15:0 @0x30 -> 0xffff0001
changing mem_base from 0x82010000 to 0x82020000 Configuring BARs for /pci@f2000000/ATY: reloc 0x82010000 omask 0x1
io_base 0x1100 mem_base 0x82020000 size 0x10000 3233@1563634437.473236:pci_cfg_write ati-vga 15:0 @0x30 <- 0x82010001 3233@1563634437.473240:pci_cfg_read ati-vga 15:0 @0x4 -> 0x0 3233@1563634437.473242:pci_cfg_write ati-vga 15:0 @0x4 <- 0x3 3233@1563634437.473244:pci_update_mappings_add d=0x55ef8ac6e280 00:0f.0 0,0x81000000+0x1000000 pci_update_mappings: adding bar 0 to unin-pci-mmio @ 0x81000000 3233@1563634437.473322:pci_update_mappings_add d=0x55ef8ac6e280 00:0f.0 1,0x1000+0x100 pci_update_mappings: adding bar 1 to unin-pci-isa-mmio @ 0x1000 3233@1563634437.473409:pci_update_mappings_add d=0x55ef8ac6e280 00:0f.0 2,0x82000000+0x4000 pci_update_mappings: adding bar 2 to unin-pci-mmio @ 0x82000000 3233@1563634437.473531:pci_update_mappings_add d=0x55ef8ac6e280 00:0f.0 6,0x82010000+0x10000 pci_update_mappings: adding bar 6 to unin-pci-mmio @ 0x82010000 3233@1563634437.473639:pci_cfg_read ati-vga 15:0 @0x0 -> 0x1002 3233@1563634437.473643:pci_cfg_read ati-vga 15:0 @0x2 -> 0x5046 3233@1563634437.473645:pci_cfg_read ati-vga 15:0 @0x8 -> 0x0 3233@1563634437.473647:pci_cfg_read ati-vga 15:0 @0x9 -> 0x0 3233@1563634437.473649:pci_cfg_read ati-vga 15:0 @0xa -> 0x300 3233@1563634437.473914:pci_cfg_read ati-vga 15:0 @0x3e -> 0x0 3233@1563634437.474012:pci_cfg_read ati-vga 15:0 @0x3f -> 0x0 3233@1563634437.474146:pci_cfg_read ati-vga 15:0 @0x6 -> 0x0 3233@1563634437.474261:pci_cfg_read ati-vga 15:0 @0x2c -> 0x1af4 3233@1563634437.474380:pci_cfg_read ati-vga 15:0 @0x2e -> 0x1100 3233@1563634437.474515:pci_cfg_read ati-vga 15:0 @0xc -> 0x0
ob_pci_encode_unit space=0 dev=15 fn=0 buf=f
=== CHANGED === package path old=/pci@f2000000/ATY
new=/pci@f2000000/ATY@f
pci_set_reg reg 00007800 00000000 00000000 00000000 00000000 42007810
00000000 00000000 00000000 01000000 01007814 00000000 00000000 00000000 00000100 02007818 00000000 00000000 00000000 00004000 3233@1563634437.593836:pci_cfg_read uni-north-pci 11:0 @0x30 -> 0x0 3233@1563634437.593845:pci_cfg_write uni-north-pci 11:0 @0x0 <- 0x1
ob_pci_decode_unit idx=1fc5a984 ob_pci_decode_unit idx=1fc5a984 addr=00000000 00000000 00007800 ob_pci_bar_map_in idx=1fc5a984 ob_pci_map: phys=0x82000000 size=16384 ob_pci_bar_map_in idx=1fc5a984 ob_pci_map: phys=0x81000000 size=16777216 ob_pci_decode_unit idx=1fc5a984 ob_pci_decode_unit idx=1fc5a984 addr=00000000 00000000 00007800
3233@1563634437.781563:pci_cfg_write uni-north-pci 11:0 @0x1a <- 0x0
bridge /pci@f2000000 PCI bus primary=0 secondary=0 subordinate=0
3233@1563634437.781711:pci_cfg_write uni-north-pci 11:0 @0x22 <- 0x8200 3233@1563634437.781718:pci_cfg_write uni-north-pci 11:0 @0x32 <- 0x0 3233@1563634437.781724:pci_cfg_write uni-north-pci 11:0 @0x1d <- 0x10 3233@1563634437.781729:pci_cfg_read uni-north-pci 11:0 @0x4 -> 0x3
setting bus range for /pci@f2000000 PCI device, package handle fff5b0a8
bus primary=0 secondary=0 subordinate=0
setting up interrupt map for host fff5b0a8 set_property: NULL phandle
============================================================= OpenBIOS 1.1 [Jul 20 2019 14:01] Configuration device id QEMU version 1 machine id 1 CPUs: 1 Memory: 512M UUID: 00000000-0000-0000-0000-000000000000 CPU type PowerPC,G4
milliseconds isn't unique.
ob_pci_decode_unit idx=fff5b130 ob_pci_decode_unit idx=fff5b130 addr=00000000 00000000 00006000 ob_pci_decode_unit idx=1fc5ab54 ob_pci_decode_unit idx=1fc5ab54 addr=00000000 00000000 00006000 ob_pci_encode_unit space=0 dev=13 fn=0 buf=d ob_pci_decode_unit idx=fff5b130 ob_pci_decode_unit idx=fff5b130 addr=00000000 00000000 00006000 ob_pci_decode_unit idx=fff5b130 ob_pci_decode_unit idx=fff5b130 addr=00000000 00000000 00006000 ob_pci_decode_unit idx=1fc5acc0 ob_pci_decode_unit idx=1fc5acc0 addr=00000000 00000000 00006000 ob_pci_decode_unit idx=fff5b130 ob_pci_decode_unit idx=fff5b130 addr=00000000 00000000 00006000 ob_pci_decode_unit idx=1fc5adc8 ob_pci_decode_unit idx=1fc5adc8 addr=00000000 00000000 00006000
Welcome to OpenBIOS v1.1 built on Jul 20 2019 14:01
0 > dev /pci@f2000000/ATY ok 0 > .properties name "ATY" vendor-id 1002 device-id 5046 revision-id 0 class-code 30000 min-grant 0 max-latency 0 devsel-speed 0 subsystem-vendor-id 1af4 subsystem-id 1100 cache-line-size 0 device_type "display" model "ATY Rage128" compatible "VGA" assigned-addresses -- 3c : 42 00 78 10 00 00 00 00 81 00 00 00 00 00 00 00 01 00 00 00 01 00 78 14 00 00 00 00 00 00 10 00 00 00 00 00 00 00 01 00 02 00 78 18 00 00 00 00 82 00 00 00 00 00 00 00 00 00 40 00 reg 00007800 00000000 00000000 00000000 00000000 42007810 00000000 00000000 00000000 01000000 01007814 00000000 00000000 00000000 00000100 02007818 00000000 00000000 00000000 00004000 width 320 height 258 depth 20 linebytes c80 address 81000000 ok 0 > " /pci@f2000000/ATY" open-dev to my-self ok 0 > my-unit ok 3 > . 7800 ok 2 > . 0 ok 1 > . 0 ok 0 > my-address ok 2 > . 0 ok 1 > . 0 ok 0 > my-space . 7800 ok 0 > my-address h# 1000014 my-space + h# 100 ok 4 > .s <4> 0 0 1007814 100 ok 4 > " map-in" $call-parent >> ob_pci_bar_map_in idx=1fc5aef4
ob_pci_map: phys=0x00000000 size=256
ok 1 > . -1 ok 0 >
So the ob_pci_bus_map_in() in drivers/pci.c is called but it does not find the correct phys address to map. This is done in ob_pci_map() where I've added a debug message before of_mem_claim_phys() is called. Before that it has these calls:
pci_decode_pci_addr(ba, &flags, &space_code, &mask);
phys = pci_bus_addr_to_host_addr(space_code, ba & ~mask);
So one of these does not work correctly and cannot find the requested space of the card. Maybe this only works for BARs but we need config space here which is not yet supported? Does the above make sense to anyone or do I have to trace it back myself?
Regards, BALATON Zoltan