From patchwork Thu Nov 13 11:19:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 40740 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A8C5C240ED for ; Thu, 13 Nov 2014 11:19:39 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf3132507wiv.6 for ; Thu, 13 Nov 2014 03:19:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=p9RKM9Wee424pl++jeyKxaEl7VL3wun15awWRUI+XOk=; b=faD3E1P8golM8R0YplH5RzaT4FsduS515p8KpAx5BdwL/9lj0q/ij/dTAg4oSMkIyt naZ5m3pWSR8njzGF9B5lrk+L+AiEXYUokMxcnGmuO2XrUoPMYgoo7/o/5J/DuiU8hZNw F+7OOHSxfZdo/q5SKAIbdmd2+K+bjtcmMXKYbg3b57AQgv0IC3N4/QgX/DczJdGZW9wB AGRFrLg17eM6uHBSmJ29pX3VB+/5hzkzEyh6BAuMwhgiSjAWNKkT7AWr654CsxpuEiKI 5Lvc0Aoi/G+Kpmy9IBhQJARUmJmz0ATJpn/gFpWecI3n75xhXF6z644xUnNQLyiFJ1yQ gNBg== X-Gm-Message-State: ALoCoQniZo1da9SzNnTpboEEi2Q2yBXf/TkPiNkKEwj0wB5+xgSKhpnvdb6JNxW3NIePakxeLvl3 X-Received: by 10.181.27.135 with SMTP id jg7mr7844145wid.5.1415877578906; Thu, 13 Nov 2014 03:19:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.243.33 with SMTP id wv1ls512732lac.3.gmail; Thu, 13 Nov 2014 03:19:38 -0800 (PST) X-Received: by 10.112.54.229 with SMTP id m5mr1795189lbp.11.1415877578616; Thu, 13 Nov 2014 03:19:38 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id xz9si18292991lbb.126.2014.11.13.03.19.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Nov 2014 03:19:38 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id ge10so12876439lab.22 for ; Thu, 13 Nov 2014 03:19:38 -0800 (PST) X-Received: by 10.152.116.102 with SMTP id jv6mr1851523lab.40.1415877578454; Thu, 13 Nov 2014 03:19:38 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp572751lbc; Thu, 13 Nov 2014 03:19:37 -0800 (PST) X-Received: by 10.68.239.71 with SMTP id vq7mr1709935pbc.155.1415877576649; Thu, 13 Nov 2014 03:19:36 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jd12si25426481pbd.10.2014.11.13.03.19.35 for ; Thu, 13 Nov 2014 03:19:36 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932771AbaKMLTe (ORCPT + 26 others); Thu, 13 Nov 2014 06:19:34 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:57424 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932394AbaKMLTb (ORCPT ); Thu, 13 Nov 2014 06:19:31 -0500 Received: from foss-smtp-na-1.foss.arm.com (unknown [10.80.61.8]) by foss-mx-na.foss.arm.com (Postfix) with ESMTP id B33534E0; Thu, 13 Nov 2014 05:19:22 -0600 (CST) Received: from collaborate-mta1.arm.com (highbank-bc01-b06.austin.arm.com [10.112.81.134]) by foss-smtp-na-1.foss.arm.com (Postfix) with ESMTP id 973BA5FAD7; Thu, 13 Nov 2014 05:19:20 -0600 (CST) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.203.137]) by collaborate-mta1.arm.com (Postfix) with ESMTP id A1CD013F78C; Thu, 13 Nov 2014 05:19:19 -0600 (CST) From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: Lorenzo Pieralisi , Arnd Bergmann , Russell King , LAKML , Linux PCI Subject: [RFC PATCH v3 2/2] arm: kernel: fix pci_mmap_page_range() offset calculation Date: Thu, 13 Nov 2014 11:19:16 +0000 Message-Id: <1415877558-8906-3-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1415877558-8906-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1415877558-8906-1-git-send-email-lorenzo.pieralisi@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lorenzo.pieralisi@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The pci_mmap_page_range() API should be written to expect offset values representing PCI memory resource addresses as seen by user space, through the pci_resource_to_user() API. ARM relies on the standard implementation of pci_resource_to_user() which actually is an identity map and exports to user space PCI memory resources as they are stored in PCI devices resources structures, which represent CPU physical addresses (fixed-up using BUS to CPU address conversions) not PCI bus addresses. Therefore, on ARM platforms where the mapping between CPU and BUS address is not a 1:1 the current pci_mmap_page_range() implementation is erroneous, in that an additional shift is applied to an already fixed-up offset passed from userspace. Hence, this patch removes the mem_offset from the pgoff calculation since the offset as passed from user space already represents the CPU physical address corresponding to the resource to be mapped, ie no additional offset should be applied. Cc: Arnd Bergmann Cc: Russell King Signed-off-by: Lorenzo Pieralisi --- arch/arm/kernel/bios32.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 17a26c1..b56fa2d 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -626,21 +626,15 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, enum pci_mmap_state mmap_state, int write_combine) { - struct pci_sys_data *root = dev->sysdata; - unsigned long phys; - - if (mmap_state == pci_mmap_io) { + if (mmap_state == pci_mmap_io) return -EINVAL; - } else { - phys = vma->vm_pgoff + (root->mem_offset >> PAGE_SHIFT); - } /* * Mark this as IO */ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - if (remap_pfn_range(vma, vma->vm_start, phys, + if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN;