Re: None of the virtual/physical/bus address matches the (base) BAR-0 register

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Bjorn, that certainly helped.
Especially, it is nice to see that ptr->resource[0].start does give e2c20000 :)

Also, idiotic of me of making newbie kernel-format-specifier mistakes :-|

So, now the outputs corresponding to

    printk("Base virtual-address = [%lx]\n", bar0_ptr);
    printk("Base physical-address (form-1) = [%lx]\n", dev->resource[0].start);
    printk("Base bus-address = [%lx]\n", pci_bus_address(dev, 0));
    printk("BAR 0: %pR\n", &dev->resource[0]);


are :

    Base virtual-address = [ffffa0c6c02eb000]
    Base physical-address (form-1) = [e2c20000]
    Base bus-address = [e2c20000]
    BAR 0: [mem 0xe2c20000-0xe2c201ff]


All as expected.
Plus, all the lower 12 bits are now same everywhere (due to the 4 KB
page-size alignment in x86, right)?



My major missing understanding regarding this, is that we use the
iowrite*/ioread* functions, using bar0_ptr as the
base-(virtual-)address.
Thus, bar0_ptr *is* very well the kernel-virtual-address, which maps
to some physical-address (hopefully e2c20000), which directly triggers
the write/read with the pci-device.

Right now, the physical-address (form-1) we have printed, is via the
data-structure field.
However, looking from the virtual-address <=> physical-address
translation from the usual memory write/read datapath's perspective, I
am still not able to coalesce things.


In the same run as above, if I add the following statements :

    printk("Base physical-address (form-2) = [%lx]\n", virt_to_phys(bar0_ptr));
    printk("Base physical-address (form-3) = [%lx]\n",
virt_to_phys(*((uint32_t*)bar0_ptr)));
    printk("Base physical-address (form-4) = [%lx]\n",
virt_to_phys(*((uint64_t*)bar0_ptr)));

I get :

    Base physical-address (form-2) = [12e6002eb000]
    Base physical-address (form-3) = [721f4000001e]
    Base physical-address (form-4) = [721f4000001e]


Looking at the function-doc for virt_to_phys(), it states :

########################################################
* This function does not give bus mappings for DMA transfers. In
* almost all conceivable cases a device driver should not be using
* this function
########################################################



So, two queries :

1)
Does the above comment apply here too (in MMIO case)?

2)
If yes, then what is the datapath followed for our case (since
conventional virtual-address <=> physical-address translations via MMU
/ TLB / page-tables is out of the picture I guess)?


Thanks a ton already to everyone, in helping me clearing out my mind.


Thanks and Regards,
Ajay



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux