From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68743C432C1 for ; Tue, 24 Sep 2019 21:50:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29B9520872 for ; Tue, 24 Sep 2019 21:50:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Rxk8Tf53" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29B9520872 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=/c2uCpi4oqY/K//D8f8N7BpidZsh73bkNIviu4nCPEc=; b=Rxk8Tf53ZZr4JI V8IdAe/6NETr6ui6XT47riOGjfQz51mFHA4kwZYw14APxIJZBknaGHKykOHp9qAp8khH6cQu/JSpO VlKnhLIeEl9A4k3nvd4v9ts4VVRF+HtnaMwrSVhmLIovXIoCqxNJMwjHRryFv+T8RnJaLNPkRX7Gl TyXoxSM94HTB/oMN7M4d8QQq5Z9fBymmzfMmCJmABg8nPb2zHHqeHtksJYjBGC1wK/EHJlycl7Qn8 38zxEluhVXRBivrON4w8PSjK6aLS4IPWixw+zT5x9FdGP3iP9RapTlfgJ7HV08gqqO+tAzpUHpGjO 1B1BoqbeGkV7+BuRW7uA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iCsh4-00083e-Dp; Tue, 24 Sep 2019 21:49:58 +0000 Received: from mail-ot1-f66.google.com ([209.85.210.66]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iCsdx-0005Wn-En for linux-arm-kernel@lists.infradead.org; Tue, 24 Sep 2019 21:46:47 +0000 Received: by mail-ot1-f66.google.com with SMTP id y39so2900348ota.7 for ; Tue, 24 Sep 2019 14:46:45 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=qyYVfHwqMpUb0dG8xhH3D2wwe8Um8pFX3NIc2wpZXzU=; b=L8ETjmqtcM4yE+jTAMclAjWci5Usl3kSy2qjRfTZWHQ3oMv/P29n10RBtddEYf2guw e6/7XIRHhiBRNZjjMNCm5wYeo/n4M6k9RPKUF3+8+fLByFLj87MgCC2GCbWoGZ3GFYe4 p9LPEb0vpO8FFBo1ex2iDMPr7OhBx0yRAeL3lHNYuPRd4Dz0BZHCtl/XsQrdscecUcHM mk+kb+wAf91dtPrIMI8GJGNCok5vQIVWc57DNC/xarVmSgUKVslJIS9NqMIomNbJMi9z QQPAXJuOz+XaRWFbRflCXkFYdnmtDDMy56lBKFxYGny6T4c9Xcv+3HsNw31fJlBr7X7N NF3Q== X-Gm-Message-State: APjAAAVQz8K9NFhmcmm8rbTkMRvZ7SDEigi7Qw5y8/RTeL4Fv1DfJlvS pGvtCUY4ohjV+77tP4J56w== X-Google-Smtp-Source: APXvYqz17HkSTxsTCEmLThqlQYmUwW3cV2NmGnqT2qALFG4fCCZzK7gcnD0K52XoGWX8p1bNTZ/oyw== X-Received: by 2002:a9d:6084:: with SMTP id m4mr3643597otj.6.1569361604751; Tue, 24 Sep 2019 14:46:44 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id s66sm976787otb.65.2019.09.24.14.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:44 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Subject: [PATCH 10/11] PCI: iproc: Use inbound resources for setup Date: Tue, 24 Sep 2019 16:46:29 -0500 Message-Id: <20190924214630.12817-11-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190924214630.12817-1-robh@kernel.org> References: <20190924214630.12817-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_144645_673278_193EA54C X-CRM114-Status: GOOD ( 15.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ray Jui , bcm-kernel-feedback-list@broadcom.com, Scott Branden , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that the helpers provide the inbound resources in the host bridge 'dma_ranges' resource list, convert Broadcom iProc host bridge to use the resource list to setup the inbound addresses. Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Ray Jui Cc: Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com Signed-off-by: Rob Herring --- drivers/pci/controller/pcie-iproc.c | 63 ++++------------------------- 1 file changed, 8 insertions(+), 55 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index 2d457bfdaf66..9ed181050308 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -1122,15 +1122,15 @@ static int iproc_pcie_ib_write(struct iproc_pcie *pcie, int region_idx, } static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, - struct of_pci_range *range, + struct resource_entry *entry, enum iproc_pcie_ib_map_type type) { struct device *dev = pcie->dev; struct iproc_pcie_ib *ib = &pcie->ib; int ret; unsigned int region_idx, size_idx; - u64 axi_addr = range->cpu_addr, pci_addr = range->pci_addr; - resource_size_t size = range->size; + u64 axi_addr = entry->res->start, pci_addr = entry->res->start - entry->offset; + resource_size_t size = resource_size(entry->res); /* iterate through all IARR mapping regions */ for (region_idx = 0; region_idx < ib->nr_regions; region_idx++) { @@ -1182,66 +1182,19 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, return ret; } -static int iproc_pcie_add_dma_range(struct device *dev, - struct list_head *resources, - struct of_pci_range *range) -{ - struct resource *res; - struct resource_entry *entry, *tmp; - struct list_head *head = resources; - - res = devm_kzalloc(dev, sizeof(struct resource), GFP_KERNEL); - if (!res) - return -ENOMEM; - - resource_list_for_each_entry(tmp, resources) { - if (tmp->res->start < range->cpu_addr) - head = &tmp->node; - } - - res->start = range->cpu_addr; - res->end = res->start + range->size - 1; - - entry = resource_list_create_entry(res, 0); - if (!entry) - return -ENOMEM; - - entry->offset = res->start - range->cpu_addr; - resource_list_add(entry, head); - - return 0; -} - static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie) { struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); - struct of_pci_range range; - struct of_pci_range_parser parser; - int ret; - LIST_HEAD(resources); + struct resource_entry *entry; + int ret = 0; - /* Get the dma-ranges from DT */ - ret = of_pci_dma_range_parser_init(&parser, pcie->dev->of_node); - if (ret) - return ret; - - for_each_of_pci_range(&parser, &range) { - ret = iproc_pcie_add_dma_range(pcie->dev, - &resources, - &range); - if (ret) - goto out; + resource_list_for_each_entry(entry, &host->dma_ranges) { /* Each range entry corresponds to an inbound mapping region */ - ret = iproc_pcie_setup_ib(pcie, &range, IPROC_PCIE_IB_MAP_MEM); + ret = iproc_pcie_setup_ib(pcie, entry, IPROC_PCIE_IB_MAP_MEM); if (ret) - goto out; + break; } - list_splice_init(&resources, &host->dma_ranges); - - return 0; -out: - pci_free_resource_list(&resources); return ret; } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel