From patchwork Mon May 22 16:39:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oza Pawandeep X-Patchwork-Id: 9741041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9BD9560388 for ; Mon, 22 May 2017 16:40:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C0E628449 for ; Mon, 22 May 2017 16:40:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E86B2871C; Mon, 22 May 2017 16:40:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E2EC128449 for ; Mon, 22 May 2017 16:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+56ucMWAnWZHRlfmPMyiNIdAIICDSZn+3vv3x246yF0=; b=NU0cM5ZgUtx6e42GdEh3rcE644 0ORysRgMHkGFNaog+CsPtxNnUQo0wje1tnroZvWZdgiOka5Em/Y8nBbV8tIcU/neCw+nK/OuLsRX+ v6NnbLzCb2NoU/BEH6xk3BAGI7xqhzFUJmPqxKqsjS4O/2QBed0NZApGRlnqHcwpoSaGNUEO0DVPn J3R0FDD1qlg4YoPzT/T2Wc/FEBsdL04+XxrWlSum/ZCJTUl5YcseSOpWpscuArzTKmizxM/y83Tks erflFYF9OLBvJvSQOKSFfcx5nyND1ypmhQooN+JfoQ028jIgjkS9dV7Fb6AjiERc53389uMiNL8N7 vKNHKmSA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dCqNz-0002hC-Tv; Mon, 22 May 2017 16:40:47 +0000 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dCqNa-0000yi-Rn for linux-arm-kernel@lists.infradead.org; Mon, 22 May 2017 16:40:28 +0000 Received: by mail-pf0-x232.google.com with SMTP id m17so87442688pfg.3 for ; Mon, 22 May 2017 09:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2WrbP70p8VOLAFQjGJuMMLFnBajAsvloK4122GGYjY0=; b=Z+H91evXGAwZoOXEpPaY9eCEAd78fktkchEEWpnpLaGrWxvMlcOHaX/oUOqAZ1gZ1c vHaoZlNU7vQHImw5upBoLflGItfVs6F7cZwVADJReTH8+5qpfCiai078fUT9Vonuq7pg eQPjugZDD6HYNirUCKqBGK6XXzQRpFffNUwRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2WrbP70p8VOLAFQjGJuMMLFnBajAsvloK4122GGYjY0=; b=K0brqaBEsvMtWhRcNLFD3bBfqLejAwNoQjbCeRMJEleIfIqDq1jKctXqHibAW49Nri BqqjIhRqbNrWIfFITg7rpoYGu6y27QrcNPjG4rffiRxfVsG+TahvZvthyZiYqoGrMl8x YRsImMnOSNoKYJaLhVw7JDs6MlCz0bPVHQwopcz35oZ5bsKPkXrOxLrB3WreUzgpGtBR wf6YfUKj6ayFW9smDJvpYlcDR17KEJJ6WikAfcYJD6JBr6Dt0qCLVMQmFBexfro5WE1p Bz6eaacOcbXsQJ/qlnzCUc5ZHOKBzOVuio9rQIkEkCnsBYlbudsvmW6HCD4D+tQN1BYF w00A== X-Gm-Message-State: AODbwcBMez4yEdqI6XCl0ty6yGnQsnmY1BYSFYHWf8lXAihW6Yaa/TFk U7YavmHQY35hpyDt X-Received: by 10.84.224.1 with SMTP id r1mr29719778plj.78.1495471201832; Mon, 22 May 2017 09:40:01 -0700 (PDT) Received: from anjanavk-OptiPlex-7010.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id x198sm26538853pgx.28.2017.05.22.09.39.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 May 2017 09:40:01 -0700 (PDT) From: Oza Pawandeep To: Joerg Roedel , Robin Murphy Subject: [PATCH v7 2/3] PCI: Add support for PCI inbound windows resources Date: Mon, 22 May 2017 22:09:41 +0530 Message-Id: <1495471182-12490-3-git-send-email-oza.oza@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495471182-12490-1-git-send-email-oza.oza@broadcom.com> References: <1495471182-12490-1-git-send-email-oza.oza@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170522_094023_484200_C45E3479 X-CRM114-Status: GOOD ( 12.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Oza Pawandeep , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, bcm-kernel-feedback-list@broadcom.com, Oza Pawandeep , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for inbound memory window for PCI RC drivers. It defines new function pci_create_root_bus2 which takes inbound resources as an argument and fills in the memory resource to PCI internal host bridge structure as inbound_windows. Legacy RC driver could continue to use pci_create_root_bus, but any RC driver who wants to reseve IOVAS for their inbound memory holes, should use new API pci_create_root_bus2. Signed-off-by: Oza Pawandeep diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 19c8950..a95b9bb 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -531,6 +531,7 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv) return NULL; INIT_LIST_HEAD(&bridge->windows); + INIT_LIST_HEAD(&bridge->inbound_windows); return bridge; } @@ -726,6 +727,7 @@ int pci_register_host_bridge(struct pci_host_bridge *bridge) struct pci_bus *bus, *b; resource_size_t offset; LIST_HEAD(resources); + LIST_HEAD(inbound_resources); struct resource *res; char addr[64], *fmt; const char *name; @@ -739,6 +741,8 @@ int pci_register_host_bridge(struct pci_host_bridge *bridge) /* temporarily move resources off the list */ list_splice_init(&bridge->windows, &resources); + list_splice_init(&bridge->inbound_windows, &inbound_resources); + bus->sysdata = bridge->sysdata; bus->msi = bridge->msi; bus->ops = bridge->ops; @@ -794,6 +798,10 @@ int pci_register_host_bridge(struct pci_host_bridge *bridge) else pr_info("PCI host bridge to bus %s\n", name); + /* Add inbound mem resource. */ + resource_list_for_each_entry_safe(window, n, &inbound_resources) + list_move_tail(&window->node, &bridge->inbound_windows); + /* Add initial resources to the bus */ resource_list_for_each_entry_safe(window, n, &resources) { list_move_tail(&window->node, &bridge->windows); @@ -2300,7 +2308,8 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) static struct pci_bus *pci_create_root_bus_msi(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, - struct list_head *resources, struct msi_controller *msi) + struct list_head *resources, struct list_head *in_res, + struct msi_controller *msi) { int error; struct pci_host_bridge *bridge; @@ -2313,6 +2322,9 @@ static struct pci_bus *pci_create_root_bus_msi(struct device *parent, bridge->dev.release = pci_release_host_bridge_dev; list_splice_init(resources, &bridge->windows); + if (in_res) + list_splice_init(in_res, &bridge->inbound_windows); + bridge->sysdata = sysdata; bridge->busnr = bus; bridge->ops = ops; @@ -2329,11 +2341,20 @@ static struct pci_bus *pci_create_root_bus_msi(struct device *parent, return NULL; } +struct pci_bus *pci_create_root_bus2(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata, struct list_head *resources, + struct list_head *in_res) +{ + return pci_create_root_bus_msi(parent, bus, ops, sysdata, + resources, in_res, NULL); +} +EXPORT_SYMBOL_GPL(pci_create_root_bus2); + struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources) { - return pci_create_root_bus_msi(parent, bus, ops, sysdata, resources, - NULL); + return pci_create_root_bus_msi(parent, bus, ops, sysdata, + resources, NULL, NULL); } EXPORT_SYMBOL_GPL(pci_create_root_bus); @@ -2415,7 +2436,8 @@ struct pci_bus *pci_scan_root_bus_msi(struct device *parent, int bus, break; } - b = pci_create_root_bus_msi(parent, bus, ops, sysdata, resources, msi); + b = pci_create_root_bus_msi(parent, bus, ops, sysdata, + resources, NULL, msi); if (!b) return NULL; diff --git a/include/linux/pci.h b/include/linux/pci.h index 33c2b0b..d2df107 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -432,6 +432,7 @@ struct pci_host_bridge { void *sysdata; int busnr; struct list_head windows; /* resource_entry */ + struct list_head inbound_windows; /* inbound memory */ void (*release_fn)(struct pci_host_bridge *); void *release_data; struct msi_controller *msi;