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]

 



On Sun, Oct 03, 2021 at 07:35:41AM +0530, Ajay Garg wrote:
> > Yes.  You should not need to use virt_to_phys() for PCI MMIO
> > addresses.
> 
> Hmm, the thing that started it all :P
> 
> > This path is IN the picture.  This is exactly the path used by drivers
> > doing MMIO accesses.
> >
> > The CPU does a load from a virtual address (0xffffa0c6c02eb000).  The
> > MMU translates that virtual address to a physical address
> > (0xe2c20000).
> 
> Hmm, so I guess the core takeaway is that the virtual-address <=>
> physical-address mapping is indeed happening as envisioned. It's just
> that there is no programmatic way to prove/display the mapped physical
> address, in the case of PCI-MMIO transfers (as virt_to_phys() is not
> usable in this case).

  bar0_ptr = pci_iomap(ptr, 0, pci_resource_len(ptr, 0));

  printk("Base physical-address (form-1) = [%lx]\n", dev->resource[0].start);
  printk("Base physical-address (form-2) = [%lx]\n", virt_to_phys(bar0_ptr));

  Base physical-address (form-1) = [e2c20000]
  Base physical-address (form-2) = [12e6002eb000]

Despite the fact that you shouldn't *need* to use virt_to_phys()
because drivers use virtual addresses to do MMIO, it *does* seem like
form-1 and form-2 should be the same since form-2 is basically the
result of:

  virt_to_phys(ioremap(form-1))

I can't explain the difference.



[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