From patchwork Wed Jun 6 03:50:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Collins X-Patchwork-Id: 163238 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 91D81B70F5 for ; Wed, 6 Jun 2012 14:36:16 +1000 (EST) X-Greylist: delayed 421 seconds by postgrey-1.34 at bilbo; Wed, 06 Jun 2012 13:57:48 EST Received: from exprod6og115.obsmtp.com (exprod6og115.obsmtp.com [64.18.1.35]) by ozlabs.org (Postfix) with SMTP id D31E1B6F9A for ; Wed, 6 Jun 2012 13:57:48 +1000 (EST) Received: from mail-pz0-f41.google.com ([209.85.210.41]) (using TLSv1) by exprod6ob115.postini.com ([64.18.5.12]) with SMTP ID DSNKT87VO+92d+j815LO0jVitLWGf8PGxfhW@postini.com; Tue, 05 Jun 2012 20:57:49 PDT Received: by dakp5 with SMTP id p5so7591122dak.28 for ; Tue, 05 Jun 2012 20:57:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version:x-mailer:x-gm-message-state; bh=2H2citdTjnXcjsm6TDRO9+CthUukM5DHXKG8ntFI81I=; b=m+g2zS4XazFN/YrYSEyUJoFxIhMY9uybEw+sUdj3KHoxQHTT1eJ7OH3pb1Fi0i+Imq a2hkfW9RtTDJaLpKdc8SyCHM8ZB0ErcfpAuChBlWb5I4KYth7tW8Om9LeQG2se93O1ti 5t/FjXK1hfejkoz7m5DurjgV6wB28/i+wLVQ0ChJAkMgL+B6+wMv4sECYtEr42fay15F v3LD3h9ygIIhB3DyllLUoVZwing06D2TAmegnY/9SzWeENSkpqSJL42oJYPJg39IGZGC Xw2AkrLSgAEKBABJYZPfDd4V3eCS/4BlLAIJntEvnZgQ452v8YlK0KcyS1An9+zSnn8c vtBw== Received: by 10.68.240.99 with SMTP id vz3mr53849255pbc.60.1338954644578; Tue, 05 Jun 2012 20:50:44 -0700 (PDT) Received: from [192.168.0.5] (ip68-13-200-36.hr.hr.cox.net. [68.13.200.36]) by mx.google.com with ESMTPS id qc1sm985773pbb.62.2012.06.05.20.50.42 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jun 2012 20:50:44 -0700 (PDT) From: Ben Collins Subject: [PATCH] PPC: PCI: Fix pcibios_io_space_offset() so it works for 32-bit ptr/64-bit rsrcs Date: Tue, 5 Jun 2012 23:50:40 -0400 Message-Id: <4DC27253-67FC-4A55-8C78-7782D9D0CF53@servergy.com> To: linuxppc-dev@lists.ozlabs.org Mime-Version: 1.0 (Apple Message framework v1278) X-Mailer: Apple Mail (2.1278) X-Gm-Message-State: ALoCoQnFhd8lSvgpBPVdVrV3XfhIVFusOtVMEERwzBARc2/OqVoROiqF6iqwBsel4UoR2+4BbWOl X-Mailman-Approved-At: Wed, 06 Jun 2012 14:35:14 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15rc1 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The commit introducing pcibios_io_space_offset() was ignoring 32-bit to 64-bit sign extention, which is the case on ppc32 with 64-bit resource addresses. This only seems to have shown up while running under QEMU for e500mc target. It may or may be suboptimal that QEMU has an IO base address > 32-bits for the e500-pci implementation, but 1) it's still a regression and 2) it's more correct to handle things this way. Signed-off-by: Ben Collins Cc: Benjamin Herrenschmidt Acked-by: Benjamin Herrenschmidt --- arch/powerpc/kernel/pci-common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 8e78e93..be9ced7 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1477,9 +1477,15 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) return pci_enable_resources(dev, mask); } +/* Before assuming too much here, take care to realize that we need sign + * extension from 32-bit pointers to 64-bit resource addresses to work. + */ resource_size_t pcibios_io_space_offset(struct pci_controller *hose) { - return (unsigned long) hose->io_base_virt - _IO_BASE; + long vbase = (long)hose->io_base_virt; + long io_base = _IO_BASE; + + return (resource_size_t)(vbase - io_base); } static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)