From patchwork Tue Jan 7 00:55:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 3445091 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F003FC02DC for ; Tue, 7 Jan 2014 00:59:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 64FE72017A for ; Tue, 7 Jan 2014 00:59:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A48D320117 for ; Tue, 7 Jan 2014 00:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757517AbaAGAzi (ORCPT ); Mon, 6 Jan 2014 19:55:38 -0500 Received: from mail-ie0-f170.google.com ([209.85.223.170]:39500 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757189AbaAGAzg (ORCPT ); Mon, 6 Jan 2014 19:55:36 -0500 Received: by mail-ie0-f170.google.com with SMTP id qd12so19635719ieb.1 for ; Mon, 06 Jan 2014 16:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=ZHoDEBy8CcRrTzpHVR6jXrWKT19F21Cmx0g3Byyxi3Y=; b=TMUgPtLaPD5bqj3NwqN1pLsHsBEMc53ALm3YEPc5G8sUhf1plytNCNX/AyuVWKcITb M50omDzPMkQ36z+o28U3/b9Z/kPRDyXeepU/lIGZEiQc8v7Jxojx0dftPZCzCmaTiskp hKgusdT4W2VIORbvLYDnNOFnKv6Ko6CL0FGbf37KGz6IeAxC28c2afyM/cPxBvTOSVsy tEIFaXIj5SOCPXOjG6f+cjQ1JQuCRRm8wtbwnorYUWmh2t8sHV3KBTdmnIeDDKmWgweU NvVh14nvCE0x8oV+DKZgGm2ggEvmO6IyNQI3fPfDq4xKW3y1myqrrYqpZ/yRf4niy7VE k4Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=ZHoDEBy8CcRrTzpHVR6jXrWKT19F21Cmx0g3Byyxi3Y=; b=CXKMt6ZdYZpIaeidvd5ipt7JSo1l1lrqpVUJyFnGXonkV5AWJQp4bGL03tfnWQVzFc D2SQcDgdGynXqhJXxTJCSy7sDMrhx2CwRm/zuTJjNEsh9krkjgAKi8iphrqRFKzl5VLY LL6kvBLU6SsEAElRC5hXWIeOuPGJhCGik6el7D7bTrVXWQ1Gul2zx52s6CcuVjBdaPKA v98tvaKuMIPbwhRHT7aSBRu8Cs7BUvBBMZ8PBLaF701uVOq74kerPlkKznSjd2a4XCdt ZiRVxf0Dx0jDXOAn5NFFaDKhNuj9Fm2vWFm24ffUt4FmhuDDkX9UfkqGCd52D8UKtck2 wLnw== X-Gm-Message-State: ALoCoQkwv3TYVDd7GF2yQXdhvKTHsYSrmZYdY9ehFvmSYmjZwf/ddEopreYO3wmL4KgJSRUY3jQqlkKt7iEZIyfOhhsYzmHGcsNTTZg2dMlOL/M4H1r4kgt9uIZzyo4fjFXNbzihxSAYmTt9E0ZK0dbkxKCN+MvS0ALxCvISrD5WfGwTmdK2OlSDSJgtrZ7ALX/Y71ZqaNNV7Dfuf9je7tIIC6lY/8+Zvnc9XG5BNRFn9MHbx7naRFE= X-Received: by 10.50.122.38 with SMTP id lp6mr22491530igb.30.1389056135434; Mon, 06 Jan 2014 16:55:35 -0800 (PST) Received: from localhost ([172.29.127.26]) by mx.google.com with ESMTPSA id gc2sm899290igd.6.2014.01.06.16.55.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 06 Jan 2014 16:55:34 -0800 (PST) Subject: [PATCH v7 03/15] PCI: Add pci_bus_address() to get bus address of a BAR To: linux-pci@vger.kernel.org, Daniel Vetter From: Bjorn Helgaas Cc: David Airlie , Yinghai Lu , Guo Chao , linux-kernel@vger.kernel.org Date: Mon, 06 Jan 2014 17:55:33 -0700 Message-ID: <20140107005533.10786.78922.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20140107005003.10786.85164.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20140107005003.10786.85164.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, 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 We store BAR information as a struct resource, which contains the CPU address, not the bus address. Drivers often need the bus address, and there's currently no convenient way to get it, so they often read the BAR directly, or use the resource address (which doesn't work if there's any translation between CPU and bus addresses). Add pci_bus_address() to make this convenient. Signed-off-by: Bjorn Helgaas --- include/linux/pci.h | 8 ++++++++ 1 file changed, 8 insertions(+) -- 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 diff --git a/include/linux/pci.h b/include/linux/pci.h index bf32412704a7..966b286b5d53 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1077,6 +1077,14 @@ int __must_check pci_bus_alloc_resource(struct pci_bus *bus, resource_size_t), void *alignf_data); +static inline dma_addr_t pci_bus_address(struct pci_dev *pdev, int bar) +{ + struct pci_bus_region region; + + pcibios_resource_to_bus(pdev->bus, ®ion, &pdev->resource[bar]); + return region.start; +} + /* Proper probing supporting hot-pluggable devices */ int __must_check __pci_register_driver(struct pci_driver *, struct module *, const char *mod_name);