From patchwork Wed May 4 05:08:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 9009591 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 75283BF29F for ; Wed, 4 May 2016 05:08:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8258A20374 for ; Wed, 4 May 2016 05:08:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F05620328 for ; Wed, 4 May 2016 05:08:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750993AbcEDFIJ (ORCPT ); Wed, 4 May 2016 01:08:09 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:32935 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750791AbcEDFIJ (ORCPT ); Wed, 4 May 2016 01:08:09 -0400 Received: by mail-yw0-f196.google.com with SMTP id y6so5290860ywe.0; Tue, 03 May 2016 22:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=royD13ZK4gCp3pNkHx7O5aBW2ZMYz3VOyTKEgsGy2L4=; b=FkNjTfxnz5E8dbWXfe7+w/vvLcUNa7ohSmwImq+kexOW56vAhOlBgbshxhnwprpeRY hytEwdwhZmWNTOJNoR3FX+pPpRwlMAqZDYMBdAtpoffFUzKqk0Rl5wSmNzSuDeuGjB4f oMxuUgy7ugaXjXOixCLLDznMaXvRat99zqMEks+HzAoz1/6p/hpTbztUBgbfyI4oYkHJ tNdOS8Xzhbwnn57DVazz2xVocbeMsFw6QwO7PMChPYaJY7Vl9Pxblmyj3WWQeMU5XMrP VONRoIwJzzF7qTYtw6Zn1AVtvBG8TBQffsPdkPwJB4U/VauZFFlOMOTWQ/9VDfc9oICI P3xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=royD13ZK4gCp3pNkHx7O5aBW2ZMYz3VOyTKEgsGy2L4=; b=QlVJxLm+ddYTHD2p5HFE4nNWDg+My0yLuW4yIkRxEY+L3X7vt4QvfzVg1baXp02Z2J 7t7oEQfHb58MXCoK27AoiZZpCiwQuvoVssJqzKEUMkWWQ8Ez46tsDvVJNAeTGEN1hK22 JCBDXS5wxaHn/DK8mUsfGx7qqhrln28hcJt0PKuK+/goJqW+QnnGtbcVB8P45hllBAs3 O0b4lBBLfNVgKedTppxcTeaObxU9FCVeLTvHcQTlVAjyHROqD5eIOT5SCsslWOmjgZFk Hx0BEDpF9mrpiA6EgMSDy47vQxz17BEflLqo4ZlbtFAeoaFOisL/ozzOm7rvfCDSXy8y jrFA== X-Gm-Message-State: AOPr4FXnPFH8ek0K0O7aWKBIBVeT/xq5Z0dmvkM9DXWOfg7W5xgEriNtMTdz5rqAzGjAmUAGpN8EQ2B3Y1B8gg== MIME-Version: 1.0 X-Received: by 10.176.2.235 with SMTP id 98mr3755434uah.86.1462338487812; Tue, 03 May 2016 22:08:07 -0700 (PDT) Received: by 10.103.125.216 with HTTP; Tue, 3 May 2016 22:08:07 -0700 (PDT) In-Reply-To: <20160504012531.GB17170@localhost> References: <1460074573-7481-1-git-send-email-yinghai@kernel.org> <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> Date: Tue, 3 May 2016 22:08:07 -0700 X-Google-Sender-Auth: 2rd4OD6tcx97AlW7MkW1tHne1Uo Message-ID: Subject: Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address to resource From: Yinghai Lu To: Bjorn Helgaas Cc: Benjamin Herrenschmidt , Bjorn Helgaas , David Miller , Linus Torvalds , Wei Yang , TJ , Yijing Wang , Khalid Aziz , "linux-pci@vger.kernel.org" , Linux Kernel Mailing List , Michael Ellerman Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, May 3, 2016 at 6:25 PM, Bjorn Helgaas wrote: > On Wed, May 04, 2016 at 10:37:40AM +1000, Benjamin Herrenschmidt wrote: >> >> The problem tends to be old Xserver expectations... >> >> That stuff has been a can of worms over the years and we did things in >> the kernel to work around X limitations. I'm not that keen on touching >> /proc at all in that regard. Leave it there do what it does today, it's >> a user visible ABI, don't change it. > > I did not propose changing any user-visible ABI. To recap what I did > propose: I want to avoid introduce one strange pci_user_to_resource. > > - The sysfs path uses offsets between 0 and BAR size on all arches. > It uses pci_resource_to_user() today, but I think it should not. > > - The procfs path uses offsets of resource values (CPU physical > addresses) on most architectures, but uses something else, e.g., > BAR values, on others. pci_resource_to_user() does this > translation. The procfs path does not use pci_resource_to_user() > today, but I think it should. current powerpc pci_resource_to_user is strange: it will return resource start for io mem. but will return BAR (?) start for io port. sparc pci_resource_to_user does return BAR value for iomem. > > - This implies that pci_mmap_page_range() should deal with resource > values (CPU physical addresses), and proc_bus_pci_mmap() should do > any necessary arch-specific translation from BAR values to > resource values. so will need one different version pci_user_to_resource. and can not use pcibios_bus_to_resource directly, and will be another mess. Can you reconsider to keep the pci_mmap_page_range still use BAR value and only touch pci_mmap_fits() ? like i suggested before, and it does not conflict with the patchset. Subject: [PATCH] PCI: Fix pci_mmap_fits() with proc interface Passed value is user address, so need to compare it with user addr that is converted from dev resource. Signed-off-by: Yinghai Lu --- drivers/pci/pci-sysfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/pci/pci-sysfs.c =================================================================== --- linux-2.6.orig/drivers/pci/pci-sysfs.c +++ linux-2.6/drivers/pci/pci-sysfs.c @@ -969,15 +969,19 @@ void pci_remove_legacy_files(struct pci_ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma, enum pci_mmap_api mmap_api) { - unsigned long nr, start, size, pci_start; + unsigned long nr, start, size; + resource_size_t pci_start = 0, pci_end; if (pci_resource_len(pdev, resno) == 0) return 0; nr = vma_pages(vma); start = vma->vm_pgoff; size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1; - pci_start = (mmap_api == PCI_MMAP_PROCFS) ? - pci_resource_start(pdev, resno) >> PAGE_SHIFT : 0; + if (mmap_api == PCI_MMAP_PROCFS) { + pci_resource_to_user(pdev, resno, &pdev->resource[resno], + &pci_start, &pci_end); + pci_start >>= PAGE_SHIFT; + } if (start >= pci_start && start < pci_start + size && start + nr <= pci_start + size) return 1;