Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address to resource

From: Benjamin Herrenschmidt
Date: Thu May 05 2016 - 18:03:46 EST


On Thu, 2016-05-05 at 08:53 -0700, Yinghai Lu wrote:
> For powerpc io port, we still need extra offset from resource address
> to final address.
>
> ÂÂÂÂ resource_size_t offset =
> ÂÂÂÂÂÂÂÂ ((resource_size_t)vma->vm_pgoff) << PAGE_SHIFT;
>
> +ÂÂÂ if (mmap_state == pci_mmap_io) {
> +ÂÂÂÂÂÂÂ struct pci_controller *hose = pci_bus_to_host(dev->bus);
> +
> +ÂÂÂÂÂÂÂ /* hose should never be NULL */
> +ÂÂÂÂÂÂÂ offset += hose->io_base_phys -
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂ ((unsigned long)hose->io_base_virt - _IO_BASE);
> +ÂÂÂ }
>
> ÂÂÂÂ vma->vm_pgoff = offset >> PAGE_SHIFT;
>
> but sparc does not need that trick.

I'm not sure how sparc handles IO space but on powerpc, the IO resource
is not a physical address, it's a virtual address (coming from
ioremap).Â

Cheers,
Ben.