From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751287AbcEFESi (ORCPT ); Fri, 6 May 2016 00:18:38 -0400 Received: from mail-yw0-f195.google.com ([209.85.161.195]:33634 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750997AbcEFESg (ORCPT ); Fri, 6 May 2016 00:18:36 -0400 MIME-Version: 1.0 In-Reply-To: References: <1460074573-7481-5-git-send-email-yinghai@kernel.org> <20160422204920.GA17215@localhost> <20160428135607.GA12470@localhost> <1462322260.30470.76.camel@kernel.crashing.org> <20160504012531.GB17170@localhost> <20160504151722.GA22051@localhost> <1462485774.20290.34.camel@kernel.crashing.org> Date: Thu, 5 May 2016 21:18:35 -0700 X-Google-Sender-Auth: YykFOBlWjdUADypPbH6RBzBMFzc Message-ID: Subject: Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address to resource From: Yinghai Lu To: Benjamin Herrenschmidt Cc: Bjorn Helgaas , David Miller , Bjorn Helgaas , Linus Torvalds , Wei Yang , TJ , Yijing Wang , Khalid Aziz , "linux-pci@vger.kernel.org" , Linux Kernel Mailing List , Michael Ellerman Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 5, 2016 at 5:56 PM, Yinghai Lu wrote: > On Thu, May 5, 2016 at 3:02 PM, Benjamin Herrenschmidt > wrote: >> 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). > > That is interesting. Any reason for that ? > > why just cpu_addr in resource directly ? Never mind, I figured it out. sparc64 could use cpu_addr to access io_port directly. powerpc64 need to ioremap cpu_addr to virt then use that ioport. so ioremap early and use virt address as resource value. otherwise every outb in powerpc64 will need iormap and access then unmap. Thanks Yinghai