From patchwork Wed Oct 15 12:03:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 38779 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8DBA520C4E for ; Wed, 15 Oct 2014 12:03:24 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf759156wiw.11 for ; Wed, 15 Oct 2014 05:03:23 -0700 (PDT) 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:content-type :content-transfer-encoding; bh=IvndKooF7bApvVtuE01IisvhuuTvCHkW5DqmKIUUBnM=; b=CYif04U8ReqKrEYfKhXGRJGI+x1XwpysPDxVo3X1fIGx6Y9S6HaKYKtUiUmogZAdLp KDw6reyUVjtR7jx018j2reX9fWn1lnzPpx4ggCO7kKK/s4Q6udoAV80bs3WwxvyMJRel d6yMlSpzDWYqtZc+NEntp9oU4gKVfNbAY7ROHZrcT8HcXW+wRbLTAcNdKiHop3dbxNn+ 1HOf2xglM7Dtxt7sPzvYRTJ0Klp8qQNoMhMVKjE9Rf7JNBK0WdhKk85v5RemyAIiMcU4 wS2qIU8wQk9l/OEYwgmR5hGfFgav9R79z/E9IRVe6WUxDOoR3zha2/Zj+jQsR8rcx0o5 /wCg== X-Gm-Message-State: ALoCoQn2hAe2A2DZkSjAcpF308K2K2+KcSRYFqTBzt64ONWMZEo5d5VGw6nKxKGsyEXJleLk7DFt X-Received: by 10.180.94.2 with SMTP id cy2mr2340360wib.1.1413374603704; Wed, 15 Oct 2014 05:03:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.74 with SMTP id a10ls48513laa.82.gmail; Wed, 15 Oct 2014 05:03:23 -0700 (PDT) X-Received: by 10.112.56.171 with SMTP id b11mr11709974lbq.65.1413374603378; Wed, 15 Oct 2014 05:03:23 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by mx.google.com with ESMTPS id u7si30267027lau.44.2014.10.15.05.03.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Oct 2014 05:03:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id mc6so910111lab.16 for ; Wed, 15 Oct 2014 05:03:22 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr11607812laz.27.1413374602539; Wed, 15 Oct 2014 05:03:22 -0700 (PDT) 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.84.229 with SMTP id c5csp578887lbz; Wed, 15 Oct 2014 05:03:21 -0700 (PDT) X-Received: by 10.66.184.76 with SMTP id es12mr11413383pac.3.1413374600867; Wed, 15 Oct 2014 05:03:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb9si15650979pdb.107.2014.10.15.05.03.20 for ; Wed, 15 Oct 2014 05:03:20 -0700 (PDT) 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 S1752560AbaJOMDQ (ORCPT + 27 others); Wed, 15 Oct 2014 08:03:16 -0400 Received: from service87.mimecast.com ([91.220.42.44]:55464 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752073AbaJOMDN (ORCPT ); Wed, 15 Oct 2014 08:03:13 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 15 Oct 2014 13:03:11 +0100 Received: from red-moon.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 15 Oct 2014 13:03:08 +0100 From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Russell King , LAKML , Linux PCI Subject: [PATCH RFC 2/2] arm: kernel: fix pci_mmap_page_range() offset calculation Date: Wed, 15 Oct 2014 13:03:41 +0100 Message-Id: <1413374624-30066-2-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1413374624-30066-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1413374624-30066-1-git-send-email-lorenzo.pieralisi@arm.com> X-OriginalArrivalTime: 15 Oct 2014 12:03:08.0915 (UTC) FILETIME=[FC500430:01CFE86F] X-MC-Unique: 114101513031113701 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.43 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 (ie BARs) which represent CPU physical addresses (fixed-up using BUS to CPU address conversions) not PCI bus addresses. On platforms where the mapping between CPU and BUS address is not a 1:1 mapping this 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;