From patchwork Tue Sep 24 21:46:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159667 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9D5417D4 for ; Tue, 24 Sep 2019 21:46:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 84DB6217D9 for ; Tue, 24 Sep 2019 21:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361595; bh=3BsfJ7I+5YYL4kFCCW6XZrDG2C2uYZN8VcC8UQqAfcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pwc1O0qJwRaV6d8NBWsaxKjH7k4MfO0Dm8PigpcTly618R/z2triiw830rhOPBbdd VffU4s8bg8MqNq+yHKVayZrOafRyDskfB734ovZsKTQcguEvjnzavfi/zJxJ2Tg5Ty gAjxmzhV2694dnPzVwIAPmuLNLrYljzr6wW4/DlQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728813AbfIXVqf (ORCPT ); Tue, 24 Sep 2019 17:46:35 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:40501 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730387AbfIXVqe (ORCPT ); Tue, 24 Sep 2019 17:46:34 -0400 Received: by mail-oi1-f195.google.com with SMTP id k9so3056330oib.7 for ; Tue, 24 Sep 2019 14:46:34 -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=mj2cHfPK1Lg/i3xyl7unPwCDQ0FPsiiGlXxaMpguDq4=; b=WWqXMK+hntEY0D00cceGO59w8ixciz59MtP3p4zdGSi8fsNYKW6WLyf9jGyyMFMIiH Yn76BKGgKMlIqvXrumSIKjfqOTrk7RXo8gjPtKV1c51GptieE80fvwkenOeSMEooWET9 hMRvmfsAJXv+5idzSnddtT4RHPNHNIMVr4j6gvpQuRoqd3zM6upSGhCkLPZr/RGC43gQ uwGPnvFRCuGILUs/FQovvYHU3cu5HTLOSiQKm+LXC1Xf/NxcfuL/qvpEHzbt/OCm9G0d vw4sUCrAFnm/adekL5OAU4GHIbwgwWoZnOrl+baZb9233ybqTAUwkuR03ddfwv8rregS jC1A== X-Gm-Message-State: APjAAAVWc4O6lxAaoR/PapVn4gVPCth52BwSX+dfVxr2BAmE4Un4NaGm zPL+pNxM8eTcyjp9N0RFcgi8xT8= X-Google-Smtp-Source: APXvYqzJ4oTIA1/Jq8Esdkdrq7dZsqt1eEao9dTNXYBUMMxJ++4DN0aBrQ0da6ZPPMILRTn37hQf4Q== X-Received: by 2002:a05:6808:647:: with SMTP id z7mr2028480oih.16.1569361593520; Tue, 24 Sep 2019 14:46:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:32 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org, Thomas Petazzoni Subject: [PATCH 01/11] PCI: aardvark: Use pci_parse_request_of_pci_ranges() Date: Tue, 24 Sep 2019 16:46:20 -0500 Message-Id: <20190924214630.12817-2-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Convert aardvark to use the common pci_parse_request_of_pci_ranges(). Cc: Thomas Petazzoni Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring Tested-by: Thomas Petazzoni Reviewed-by: Andrew Murray --- drivers/pci/controller/pci-aardvark.c | 58 ++------------------------- 1 file changed, 4 insertions(+), 54 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index fc0fe4d4de49..ff3af3d34028 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -910,63 +910,11 @@ static irqreturn_t advk_pcie_irq_handler(int irq, void *arg) return IRQ_HANDLED; } -static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie) -{ - int err, res_valid = 0; - struct device *dev = &pcie->pdev->dev; - struct resource_entry *win, *tmp; - resource_size_t iobase; - - INIT_LIST_HEAD(&pcie->resources); - - err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &pcie->resources, &iobase); - if (err) - return err; - - err = devm_request_pci_bus_resources(dev, &pcie->resources); - if (err) - goto out_release_res; - - resource_list_for_each_entry_safe(win, tmp, &pcie->resources) { - struct resource *res = win->res; - - switch (resource_type(res)) { - case IORESOURCE_IO: - err = devm_pci_remap_iospace(dev, res, iobase); - if (err) { - dev_warn(dev, "error %d: failed to map resource %pR\n", - err, res); - resource_list_destroy_entry(win); - } - break; - case IORESOURCE_MEM: - res_valid |= !(res->flags & IORESOURCE_PREFETCH); - break; - case IORESOURCE_BUS: - pcie->root_bus_nr = res->start; - break; - } - } - - if (!res_valid) { - dev_err(dev, "non-prefetchable memory resource required\n"); - err = -EINVAL; - goto out_release_res; - } - - return 0; - -out_release_res: - pci_free_resource_list(&pcie->resources); - return err; -} - static int advk_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct advk_pcie *pcie; - struct resource *res; + struct resource *res, *bus; struct pci_host_bridge *bridge; int ret, irq; @@ -991,11 +939,13 @@ static int advk_pcie_probe(struct platform_device *pdev) return ret; } - ret = advk_pcie_parse_request_of_pci_ranges(pcie); + ret = pci_parse_request_of_pci_ranges(dev, &pcie->resources, + &bus); if (ret) { dev_err(dev, "Failed to parse resources\n"); return ret; } + pcie->root_bus_nr = bus->start; advk_pcie_setup_hw(pcie); From patchwork Tue Sep 24 21:46:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159669 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFFC81709 for ; Tue, 24 Sep 2019 21:46:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D6AC21655 for ; Tue, 24 Sep 2019 21:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361596; bh=368JKVJPcae31YALsLz9ho9G/JxGd9Jp5q4pO44NdUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=WktqWBmYpwn9nto5JJvW7h1nWT4ZF3ZkbiDjGgaOXfDxyoWO6TGJhrRD/J9nhsAqT x/U+PyrjH4pNtQDcS6P9P0iuAsn8/QSHzHD/k3fDNY/fYyq0vhE5D0UOUTSFdfbpib CaVqH2Lmr5qZbs7i0ST9vbzv5rKuTKXgxtJpy6R4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731622AbfIXVqg (ORCPT ); Tue, 24 Sep 2019 17:46:36 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:40501 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730387AbfIXVqf (ORCPT ); Tue, 24 Sep 2019 17:46:35 -0400 Received: by mail-oi1-f194.google.com with SMTP id k9so3056368oib.7 for ; Tue, 24 Sep 2019 14:46:35 -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=//h/OxzQrbFvZbG2t2Yg6Jg8Wa0hSEoVjKepOuIzhVo=; b=QdcNRWOmikEB0WXQrUJJW3rqj+5d6D5iePotMbL1tGj1d62H5MIx72H3hvHpz5Qn9r HnTbG7zZqz4/rBvoNr7giMgG15ljX1kSFABRRHc5FjQoc9aBaDH3Cr2L2tTjRngPC30p oA5VTFgQyF1FQOAQGic5WvfzvhMpCMBMWDBrqOgbnKdEC8LXIqXxygCFFsbPvTbeiiKK MlyP7vj6sHsDiHQcbsNQXLUXhwSS6KeNCO6S4IP0w4XnTvdGoOqXwiWRo45P5lpwQsbw nfgCJdNMeRBgdP1NZEGj2x7CWueeVvbmFBme2Vf2s1qHrdlEX1RX0uDdlUvgL0lBekv/ mxzQ== X-Gm-Message-State: APjAAAVrUagDAB28zUYPEY3LvtKjcf4abO6npHUDOOtmggDqZsfnFP9N 2EWD+3begwiiQ4CBEklNbDUiuTs= X-Google-Smtp-Source: APXvYqxl9MzHk9KICSl5mCZBeGMuFnuTeQOIA/uFntXG9yZg7dp6GjNzV/dG2YNqwJRwgtOUA/zTQQ== X-Received: by 2002:a54:4105:: with SMTP id l5mr2014401oic.2.1569361594676; Tue, 24 Sep 2019 14:46:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:33 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org, Ley Foon Tan , rfi@lists.rocketboards.org Subject: [PATCH 02/11] PCI: altera: Use pci_parse_request_of_pci_ranges() Date: Tue, 24 Sep 2019 16:46:21 -0500 Message-Id: <20190924214630.12817-3-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Convert altera host bridge to use the common pci_parse_request_of_pci_ranges(). Cc: Ley Foon Tan Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: rfi@lists.rocketboards.org Signed-off-by: Rob Herring --- drivers/pci/controller/pcie-altera.c | 38 ++-------------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c index d2497ca43828..2ed00babff5a 100644 --- a/drivers/pci/controller/pcie-altera.c +++ b/drivers/pci/controller/pcie-altera.c @@ -670,39 +670,6 @@ static void altera_pcie_isr(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static int altera_pcie_parse_request_of_pci_ranges(struct altera_pcie *pcie) -{ - int err, res_valid = 0; - struct device *dev = &pcie->pdev->dev; - struct resource_entry *win; - - err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &pcie->resources, NULL); - if (err) - return err; - - err = devm_request_pci_bus_resources(dev, &pcie->resources); - if (err) - goto out_release_res; - - resource_list_for_each_entry(win, &pcie->resources) { - struct resource *res = win->res; - - if (resource_type(res) == IORESOURCE_MEM) - res_valid |= !(res->flags & IORESOURCE_PREFETCH); - } - - if (res_valid) - return 0; - - dev_err(dev, "non-prefetchable memory resource required\n"); - err = -EINVAL; - -out_release_res: - pci_free_resource_list(&pcie->resources); - return err; -} - static int altera_pcie_init_irq_domain(struct altera_pcie *pcie) { struct device *dev = &pcie->pdev->dev; @@ -833,9 +800,8 @@ static int altera_pcie_probe(struct platform_device *pdev) return ret; } - INIT_LIST_HEAD(&pcie->resources); - - ret = altera_pcie_parse_request_of_pci_ranges(pcie); + ret = pci_parse_request_of_pci_ranges(dev, &pcie->resources, + NULL); if (ret) { dev_err(dev, "Failed add resources\n"); return ret; From patchwork Tue Sep 24 21:46:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159673 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D40B017D4 for ; Tue, 24 Sep 2019 21:46:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ACE1B21655 for ; Tue, 24 Sep 2019 21:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361598; bh=AbCKjE5uyeTBvLhgYJXdd40Ck8F7P/Vg3O5Jw4X1SqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QI8/+QQ8vhDn/K45lTQA+mSu8MbedkR3GGkd0uQclC5aG6TI14kV1ZxsSQ60RULF8 aNu/2cOyRz0p6ZR8B92wWGorM/LV1m1LLbduirnKomU/yJYGdogoYeg8cDkMkH/hkE A6FSaWuDt9v7SclmyiEZnuRlOTGJPo8RKsmfN9KA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388161AbfIXVqi (ORCPT ); Tue, 24 Sep 2019 17:46:38 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:41525 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731709AbfIXVqi (ORCPT ); Tue, 24 Sep 2019 17:46:38 -0400 Received: by mail-oi1-f194.google.com with SMTP id w17so3057387oiw.8 for ; Tue, 24 Sep 2019 14:46:36 -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=/wVIw1f2smG+KiMsq60d1sORCIiJA/kLz197I7JlBzY=; b=WNuiHIZ15rsx6rXeIOOOqQnIQVY8jSisbSsMIa4Qfxo9y1AM3bQ3unrMog23BRJ12M /AZN7Y4/ETLFNgVNJvbPCgTStrJp3yRJMiFITC/UqD59fyCJFkl33IfpQwFUXmGNzOL6 Md7L7rGA6ZXDEuMs1uvL408PfmWWJ6P6aWC/qb6elvh2k4z2TZsaXDrORx83ia0Ru3ia QHnxiXp0Fg3OwmF5k8pLQSLH1XZb92MMD2MiosuCc+BPH/wFrSCOArpgp8+6AuSL+1T2 Lfu/N5HowCq345daTj4CUYrLvh037POJaylsJmQ+EdEQyUV9Slk33P5FqwUaS82JS4Tz pvUQ== X-Gm-Message-State: APjAAAVDjx3mhFta0v3FURnhT/9EcOcCTIn0aTksDxyaEQTHw5AMF9zU v4pUFopGkgL9uaIV3YxDRpWOW7c= X-Google-Smtp-Source: APXvYqzgYNEE3gUf+o08Ng0AlLUa3mPB8wGVERLGSanOdvwRKgqozOW0fsc0NAwikm4smG7KH7Xr/Q== X-Received: by 2002:aca:5ac4:: with SMTP id o187mr1987548oib.116.1569361595731; Tue, 24 Sep 2019 14:46:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:35 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org, Ryder Lee , Matthias Brugger , linux-mediatek@lists.infradead.org Subject: [PATCH 03/11] PCI: mediatek: Use pci_parse_request_of_pci_ranges() Date: Tue, 24 Sep 2019 16:46:22 -0500 Message-Id: <20190924214630.12817-4-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Convert Mediatek host bridge to use the common pci_parse_request_of_pci_ranges(). Cc: Ryder Lee Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Matthias Brugger Cc: linux-mediatek@lists.infradead.org Signed-off-by: Rob Herring Reviewed-by: Andrew murray --- drivers/pci/controller/pcie-mediatek.c | 47 ++++++++++---------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 80601e1b939e..cea4112b5309 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -211,7 +211,6 @@ struct mtk_pcie { void __iomem *base; struct clk *free_ck; - struct resource mem; struct list_head ports; const struct mtk_pcie_soc *soc; unsigned int busnr; @@ -658,11 +657,23 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port, static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) { struct mtk_pcie *pcie = port->pcie; - struct resource *mem = &pcie->mem; + struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); + struct resource *mem = NULL; + struct resource_entry *entry; const struct mtk_pcie_soc *soc = port->pcie->soc; u32 val; int err; + resource_list_for_each_entry(entry, &host->windows) { + if (resource_type(entry->res) != IORESOURCE_MEM) + continue; + + mem = entry->res; + break; + } + if (!mem) + return -EINVAL; + /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */ if (pcie->base) { val = readl(pcie->base + PCIE_SYS_CFG_V2); @@ -1017,39 +1028,15 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie) struct mtk_pcie_port *port, *tmp; struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); struct list_head *windows = &host->windows; - struct resource_entry *win, *tmp_win; - resource_size_t io_base; + struct resource *bus; int err; - err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - windows, &io_base); + err = pci_parse_request_of_pci_ranges(dev, windows, + &bus); if (err) return err; - err = devm_request_pci_bus_resources(dev, windows); - if (err < 0) - return err; - - /* Get the I/O and memory ranges from DT */ - resource_list_for_each_entry_safe(win, tmp_win, windows) { - switch (resource_type(win->res)) { - case IORESOURCE_IO: - err = devm_pci_remap_iospace(dev, win->res, io_base); - if (err) { - dev_warn(dev, "error %d: failed to map resource %pR\n", - err, win->res); - resource_list_destroy_entry(win); - } - break; - case IORESOURCE_MEM: - memcpy(&pcie->mem, win->res, sizeof(*win->res)); - pcie->mem.name = "non-prefetchable"; - break; - case IORESOURCE_BUS: - pcie->busnr = win->res->start; - break; - } - } + pcie->busnr = bus->start; for_each_available_child_of_node(node, child) { int slot; From patchwork Tue Sep 24 21:46:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159671 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 941B914ED for ; Tue, 24 Sep 2019 21:46:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 680A6214DA for ; Tue, 24 Sep 2019 21:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361598; bh=Ir0tSYpz47qQnRyzsESTzvWyyLk42H6e4lYTo7bz25w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rpjlhg2EgfouTYvmtsDSoCiPNep1SvKDPL+NA2ESvXd3bQ584QpOAuVEfqQLEDxsD O9a2h6qlceIAkblLcDNhi+JTOpTY/ytt1vxkiZCiy5h58OGDDWXrbajscOhvexj8nQ EyvnE1O+crkO1hkYYPvQrfZYlGsSuQdZzhJSlMZo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731714AbfIXVqh (ORCPT ); Tue, 24 Sep 2019 17:46:37 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:46651 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730387AbfIXVqh (ORCPT ); Tue, 24 Sep 2019 17:46:37 -0400 Received: by mail-ot1-f68.google.com with SMTP id f21so2876244otl.13 for ; Tue, 24 Sep 2019 14:46:37 -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=nUMQJjbKdzG8fJovseyEjJTdZDpiXcUeaTLwPOLfwVY=; b=RQuMKbyqXLEgRcmiPO6t/OJEcUnzJPvGH91v4LKVvt9lBHYy5CYNDmBVMF40QWLlh7 GFpSsrkTs/9Jf0Wy+j/6nic2plSUhBqbIZW2EOj8nVksFldXewcopITQ05F9Njt+dbH3 l9Vs+glOvB7CjcP1Pp4VddjQboWQq8kUCZiaO6pvRZ7IPGUNMFzgSQGWFq6OMuCeHPBe QBmKbZReZUqgH3viI8k01oHEgHmq/oxfSDWxiGAvpeOdOA1Hh7E9B5iVmumR+AYZcBbK RqoYJV+q+YqU22W6KXFj6LU8w3in7BK6xRa7AHSgZeIwtnxTwgIc6S7O61kPfpWhBJdF nObA== X-Gm-Message-State: APjAAAU5AdbuNAr6ZXQKL+n3zto4R7Md9VQP6zK98byjohge5cLyLok6 eXvWpSKE7Y7+F1jTcNJYkqlIjuE= X-Google-Smtp-Source: APXvYqyg7yvUFOkUsVxlA7key/e9KBKgkSIx3+rHguO4P9+U7CNTQzvdx4bwLQPOpg+DK1Jj4MZmnw== X-Received: by 2002:a9d:6c4d:: with SMTP id g13mr3465796otq.95.1569361596591; Tue, 24 Sep 2019 14:46:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:36 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH 04/11] PCI: versatile: Enable COMPILE_TEST Date: Tue, 24 Sep 2019 16:46:23 -0500 Message-Id: <20190924214630.12817-5-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Since commit a574795bc383 ("PCI: generic,versatile: Remove unused pci_sys_data structures") the build dependency on ARM is gone, so let's enable COMPILE_TEST for versatile. Signed-off-by: Rob Herring Reviewed-by: Andrew Murray --- drivers/pci/controller/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig index fe9f9f13ce11..14836229357e 100644 --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig @@ -135,7 +135,7 @@ config PCI_V3_SEMI config PCI_VERSATILE bool "ARM Versatile PB PCI controller" - depends on ARCH_VERSATILE + depends on ARCH_VERSATILE || COMPILE_TEST config PCIE_IPROC tristate From patchwork Tue Sep 24 21:46:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159675 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24B7E1709 for ; Tue, 24 Sep 2019 21:46:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02D71214DA for ; Tue, 24 Sep 2019 21:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361600; bh=kDhUSy+NoDxxNSRlcy40uwKtHrcGrKUp5JYokPQleig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mxvmvm/dNy/7liIlNLTYb5SnLR3BFgkQ45PVGWiTXG3QL9LP1uCnaDf3ui7Ad0Gur lzPm/izQjy07hEeWEiy2EfiFquNwejSg7wjglcmQHUIavRf4tKz5kp9g1LXPRO1Fgs 09vNec5mcYxGa8v3JYozzykPwAriGFtB+5+4sYwI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394047AbfIXVqj (ORCPT ); Tue, 24 Sep 2019 17:46:39 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:34149 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388524AbfIXVqj (ORCPT ); Tue, 24 Sep 2019 17:46:39 -0400 Received: by mail-oi1-f196.google.com with SMTP id 83so3067903oii.1 for ; Tue, 24 Sep 2019 14:46:38 -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=JFGVP1gTb36lMoxSPHjuhPE/KeYNGUEeUXlv9JWR1dI=; b=t+9Il7XrKSmtyqMrEl4UTFcIGVYtzCkqN7mSNqWxPfF9lM38jqud2mYI5P2UquTXg1 FOlKs5w1IVhd/orTepaz7hKY+iI5UBDNV/D5rHciu05SgZNs3BOJsimBRONtirdyp4Ya A6DZ2FP3f4bFT73bEWfORSmRMU/yuvgQvJPkeDxw0kEIRKpiASVSpmR05T4+VmbcraOq +iZWUnue5czVXp3gTwoxMQDoeiKMmKb5u0IoOxjjKYCqiDbpOtrj/N/2uEj26sQVFZuW VbDYKfOd2Kw98NK9yHn1gEEIZhJ5vCuiL35YNCUexypGGlxfaUFGzv6jkY4So1Ev+PXY CikQ== X-Gm-Message-State: APjAAAWeqkT91uEd/ShyJ7aygo2zUNfMKg9FeTIUV6Z5Ola8xtzGK54c kw/ZwDzf5sckeY8ob5P2Fo5SzOE= X-Google-Smtp-Source: APXvYqxzmL05Q/VVNyaKHOpBcnC2Byr6GGa7fArDJxSh7BTq5kENGbIQ1jSGPDjT/+961bZtkS/6nQ== X-Received: by 2002:aca:5254:: with SMTP id g81mr2094149oib.67.1569361597595; Tue, 24 Sep 2019 14:46:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:36 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH 05/11] PCI: versatile: Use pci_parse_request_of_pci_ranges() Date: Tue, 24 Sep 2019 16:46:24 -0500 Message-Id: <20190924214630.12817-6-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Convert ARM Versatile host bridge to use the common pci_parse_request_of_pci_ranges(). Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring Reviewed-by: Andrew Murray --- drivers/pci/controller/pci-versatile.c | 62 +++++--------------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/drivers/pci/controller/pci-versatile.c b/drivers/pci/controller/pci-versatile.c index f59ad2728c0b..237b1abb26f2 100644 --- a/drivers/pci/controller/pci-versatile.c +++ b/drivers/pci/controller/pci-versatile.c @@ -62,60 +62,12 @@ static struct pci_ops pci_versatile_ops = { .write = pci_generic_config_write, }; -static int versatile_pci_parse_request_of_pci_ranges(struct device *dev, - struct list_head *res) -{ - int err, mem = 1, res_valid = 0; - resource_size_t iobase; - struct resource_entry *win, *tmp; - - err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, res, &iobase); - if (err) - return err; - - err = devm_request_pci_bus_resources(dev, res); - if (err) - goto out_release_res; - - resource_list_for_each_entry_safe(win, tmp, res) { - struct resource *res = win->res; - - switch (resource_type(res)) { - case IORESOURCE_IO: - err = devm_pci_remap_iospace(dev, res, iobase); - if (err) { - dev_warn(dev, "error %d: failed to map resource %pR\n", - err, res); - resource_list_destroy_entry(win); - } - break; - case IORESOURCE_MEM: - res_valid |= !(res->flags & IORESOURCE_PREFETCH); - - writel(res->start >> 28, PCI_IMAP(mem)); - writel(PHYS_OFFSET >> 28, PCI_SMAP(mem)); - mem++; - - break; - } - } - - if (res_valid) - return 0; - - dev_err(dev, "non-prefetchable memory resource required\n"); - err = -EINVAL; - -out_release_res: - pci_free_resource_list(res); - return err; -} - static int versatile_pci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; - int ret, i, myslot = -1; + struct resource_entry *entry; + int ret, i, myslot = -1, mem = 0; u32 val; void __iomem *local_pci_cfg_base; struct pci_bus *bus, *child; @@ -141,10 +93,18 @@ static int versatile_pci_probe(struct platform_device *pdev) if (IS_ERR(versatile_cfg_base[1])) return PTR_ERR(versatile_cfg_base[1]); - ret = versatile_pci_parse_request_of_pci_ranges(dev, &pci_res); + ret = pci_parse_request_of_pci_ranges(dev, &pci_res, NULL); if (ret) return ret; + resource_list_for_each_entry(entry, &pci_res) { + if (resource_type(entry->res) == IORESOURCE_MEM) { + writel(entry->res->start >> 28, PCI_IMAP(mem)); + writel(PHYS_OFFSET >> 28, PCI_SMAP(mem)); + mem++; + } + } + /* * We need to discover the PCI core first to configure itself * before the main PCI probing is performed From patchwork Tue Sep 24 21:46:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159681 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E0601800 for ; Tue, 24 Sep 2019 21:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B41521655 for ; Tue, 24 Sep 2019 21:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361602; bh=0LcT+0PGsHr4ZHhbwt6VvYrA2psYP10+I2+t1la6QIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=W9guLK/FSYRl5vuj2T+x8acyNNE8Ej5R7wkNIt80rk3B6EC4+Aw3qfkWHWknCoIv7 h3ns4wwom4yxBoZeHIwtJOgGkSuiqLzFx0kAVde9nSDx2Js4Q2BORfUEYaAujoEIMS 1fi7sWcIxbyCgm51FgbryE09veSHPK2rgIAvYyTg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394267AbfIXVql (ORCPT ); Tue, 24 Sep 2019 17:46:41 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:43426 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388524AbfIXVql (ORCPT ); Tue, 24 Sep 2019 17:46:41 -0400 Received: by mail-oi1-f194.google.com with SMTP id t84so3042302oih.10; Tue, 24 Sep 2019 14:46:40 -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=NoeAS779Z7n+6bw4b58c1x/JgogGZV7oOEiXSfojCsM=; b=T7ovEIXdVY09AkE2NOvyoystac8CwLrB/zPJodIhOPqTDHWmge7p7GTxqfL8/+NrPP Bz+56rLEdq6OIoiDDnyE7uyJr5AdADpNyMqWIgwqhlxlRCeeG8qyZquxbyO0DzkqnGrm uHw00UEeIvajisDd5SxPmK/htnACjoyqAg0uzq0DXorJTNUTiQqQ+DUXtzAAr4dCZjPo EL85TAeesRO4d45qqmwSdJm1bxMJ1S2rZRMufjFzQp/TnHd1q+ArzCvIhh56pr4+g+o+ 4sX0djL8NFseydwyDVJI2rNpb0SWi6bakgv0Javwg8JjLMuzz1jZNp3CMDl57nnjaTvL 2hjA== X-Gm-Message-State: APjAAAV/AKWOKnqB7hl4Cd2SAQe0bQCTLV2B4j6iUV21RpHMxuhvlYPY D8x7eYNtzvUxE208flt2LhpW0+A= X-Google-Smtp-Source: APXvYqxdAPeGtkEzrkp60jWMj/G0sVTCH/6vT1EK9Awn+6rp6xQIJmnnnBtehNhsOnyt3SkFcaTbLg== X-Received: by 2002:aca:1a16:: with SMTP id a22mr2013528oia.49.1569361599819; Tue, 24 Sep 2019 14:46:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:39 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org, Jingoo Han , Gustavo Pimentel , Thomas Petazzoni , Will Deacon , Linus Walleij , Toan Le , Ley Foon Tan , Tom Joseph , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Ryder Lee , Karthikeyan Mitran , Hou Zhiqiang , Simon Horman , Shawn Lin , Heiko Stuebner , Michal Simek , rfi@lists.rocketboards.org, linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH 06/11] PCI: of: Add inbound resource parsing to helpers Date: Tue, 24 Sep 2019 16:46:25 -0500 Message-Id: <20190924214630.12817-7-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Extend devm_of_pci_get_host_bridge_resources() and pci_parse_request_of_pci_ranges() helpers to also parse the inbound addresses from DT 'dma-ranges' and populate a resource list with the translated addresses. This will help ensure 'dma-ranges' is always parsed in a consistent way. Cc: Jingoo Han Cc: Gustavo Pimentel Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Thomas Petazzoni Cc: Will Deacon Cc: Linus Walleij Cc: Toan Le Cc: Ley Foon Tan Cc: Tom Joseph Cc: Ray Jui Cc: Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com Cc: Ryder Lee Cc: Karthikeyan Mitran Cc: Hou Zhiqiang Cc: Simon Horman Cc: Shawn Lin Cc: Heiko Stuebner Cc: Michal Simek Cc: rfi@lists.rocketboards.org Cc: linux-mediatek@lists.infradead.org Cc: linux-renesas-soc@vger.kernel.org Cc: linux-rockchip@lists.infradead.org Signed-off-by: Rob Herring Tested-by: Thomas Petazzoni Reviewed-by: Andrew Murray Acked-by: Gustavo Pimentel Acked-by: Jingoo Han Acked-by: Jingoo Han --- .../pci/controller/dwc/pcie-designware-host.c | 3 +- drivers/pci/controller/pci-aardvark.c | 2 +- drivers/pci/controller/pci-ftpci100.c | 3 +- drivers/pci/controller/pci-host-common.c | 2 +- drivers/pci/controller/pci-v3-semi.c | 2 +- drivers/pci/controller/pci-versatile.c | 2 +- drivers/pci/controller/pci-xgene.c | 1 + drivers/pci/controller/pcie-altera.c | 2 +- drivers/pci/controller/pcie-cadence-host.c | 2 +- drivers/pci/controller/pcie-iproc-platform.c | 1 + drivers/pci/controller/pcie-mediatek.c | 2 +- drivers/pci/controller/pcie-mobiveil.c | 4 +- drivers/pci/controller/pcie-rcar.c | 3 +- drivers/pci/controller/pcie-rockchip-host.c | 3 +- drivers/pci/controller/pcie-xilinx-nwl.c | 2 +- drivers/pci/controller/pcie-xilinx.c | 2 +- drivers/pci/of.c | 44 ++++++++++++++++++- drivers/pci/pci.h | 8 +++- include/linux/pci.h | 2 + 19 files changed, 72 insertions(+), 18 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index f93252d0da5b..0743ae64bb0f 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -342,7 +342,8 @@ int dw_pcie_host_init(struct pcie_port *pp) return -ENOMEM; ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &bridge->windows, &pp->io_base); + &bridge->windows, &bridge->dma_ranges, + &pp->io_base); if (ret) return ret; diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index ff3af3d34028..c00b391529f3 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -940,7 +940,7 @@ static int advk_pcie_probe(struct platform_device *pdev) } ret = pci_parse_request_of_pci_ranges(dev, &pcie->resources, - &bus); + &bridge->dma_ranges, &bus); if (ret) { dev_err(dev, "Failed to parse resources\n"); return ret; diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index bf5ece5d9291..3e07a8203736 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c @@ -481,7 +481,8 @@ static int faraday_pci_probe(struct platform_device *pdev) return PTR_ERR(p->base); ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &res, &io_base); + &res, &host->dma_ranges, + &io_base); if (ret) return ret; diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c index c742881b5061..183381c19ee8 100644 --- a/drivers/pci/controller/pci-host-common.c +++ b/drivers/pci/controller/pci-host-common.c @@ -27,7 +27,7 @@ static struct pci_config_window *gen_pci_init(struct device *dev, struct pci_config_window *cfg; /* Parse our PCI ranges and request their resources */ - err = pci_parse_request_of_pci_ranges(dev, resources, &bus_range); + err = pci_parse_request_of_pci_ranges(dev, resources, NULL, &bus_range); if (err) return ERR_PTR(err); diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c index d219404bad92..090df766faf9 100644 --- a/drivers/pci/controller/pci-v3-semi.c +++ b/drivers/pci/controller/pci-v3-semi.c @@ -794,7 +794,7 @@ static int v3_pci_probe(struct platform_device *pdev) return PTR_ERR(v3->config_base); ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res, - &io_base); + &host->dma_ranges, &io_base); if (ret) return ret; diff --git a/drivers/pci/controller/pci-versatile.c b/drivers/pci/controller/pci-versatile.c index 237b1abb26f2..211159f54b4a 100644 --- a/drivers/pci/controller/pci-versatile.c +++ b/drivers/pci/controller/pci-versatile.c @@ -93,7 +93,7 @@ static int versatile_pci_probe(struct platform_device *pdev) if (IS_ERR(versatile_cfg_base[1])) return PTR_ERR(versatile_cfg_base[1]); - ret = pci_parse_request_of_pci_ranges(dev, &pci_res, NULL); + ret = pci_parse_request_of_pci_ranges(dev, &pci_res, NULL, NULL); if (ret) return ret; diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index ffda3e8b4742..11f27c42c06a 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -635,6 +635,7 @@ static int xgene_pcie_probe(struct platform_device *pdev) return ret; ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res, + &bridge->dma_ranges, &iobase); if (ret) return ret; diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c index 2ed00babff5a..fde6a3b16fb9 100644 --- a/drivers/pci/controller/pcie-altera.c +++ b/drivers/pci/controller/pcie-altera.c @@ -801,7 +801,7 @@ static int altera_pcie_probe(struct platform_device *pdev) } ret = pci_parse_request_of_pci_ranges(dev, &pcie->resources, - NULL); + &bridge->dma_ranges, NULL); if (ret) { dev_err(dev, "Failed add resources\n"); return ret; diff --git a/drivers/pci/controller/pcie-cadence-host.c b/drivers/pci/controller/pcie-cadence-host.c index 97e251090b4f..a8f7a6284c3e 100644 --- a/drivers/pci/controller/pcie-cadence-host.c +++ b/drivers/pci/controller/pcie-cadence-host.c @@ -211,7 +211,7 @@ static int cdns_pcie_host_init(struct device *dev, int err; /* Parse our PCI ranges and request their resources */ - err = pci_parse_request_of_pci_ranges(dev, resources, &bus_range); + err = pci_parse_request_of_pci_ranges(dev, resources, NULL, &bus_range); if (err) return err; diff --git a/drivers/pci/controller/pcie-iproc-platform.c b/drivers/pci/controller/pcie-iproc-platform.c index 5a3550b6bb29..62eee2d17f43 100644 --- a/drivers/pci/controller/pcie-iproc-platform.c +++ b/drivers/pci/controller/pcie-iproc-platform.c @@ -101,6 +101,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) } ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &resources, + &bridge->dma_ranges, &iobase); if (ret) { dev_err(dev, "unable to get PCI host bridge resources\n"); diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index cea4112b5309..f3996eed152d 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -1032,7 +1032,7 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie) int err; err = pci_parse_request_of_pci_ranges(dev, windows, - &bus); + &host->dma_ranges, &bus); if (err) return err; diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c index 672e633601c7..93064faaa656 100644 --- a/drivers/pci/controller/pcie-mobiveil.c +++ b/drivers/pci/controller/pcie-mobiveil.c @@ -875,7 +875,9 @@ static int mobiveil_pcie_probe(struct platform_device *pdev) /* parse the host bridge base addresses from the device tree file */ ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &pcie->resources, &iobase); + &pcie->resources, + &bridge->dma_ranges, + &iobase); if (ret) { dev_err(dev, "Getting bridge resources failed\n"); return ret; diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index f6a669a9af41..b8d6e86a5539 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -1138,7 +1138,8 @@ static int rcar_pcie_probe(struct platform_device *pdev) pcie->dev = dev; platform_set_drvdata(pdev, pcie); - err = pci_parse_request_of_pci_ranges(dev, &pcie->resources, NULL); + err = pci_parse_request_of_pci_ranges(dev, &pcie->resources, + &bridge->dma_ranges, NULL); if (err) goto err_free_bridge; diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index 8d20f1793a61..093b816b9dc9 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -996,7 +996,8 @@ static int rockchip_pcie_probe(struct platform_device *pdev) goto err_deinit_port; err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &res, &io_base); + &res, &bridge->dma_ranges, + &io_base); if (err) goto err_remove_irq_domain; diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c index 45c0f344ccd1..5c9132a02d15 100644 --- a/drivers/pci/controller/pcie-xilinx-nwl.c +++ b/drivers/pci/controller/pcie-xilinx-nwl.c @@ -846,7 +846,7 @@ static int nwl_pcie_probe(struct platform_device *pdev) } err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res, - &iobase); + &bridge->dma_ranges, &iobase); if (err) { dev_err(dev, "Getting bridge resources failed\n"); return err; diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c index 5bf3af3b28e6..a95faca30291 100644 --- a/drivers/pci/controller/pcie-xilinx.c +++ b/drivers/pci/controller/pcie-xilinx.c @@ -648,7 +648,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev) } err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res, - &iobase); + &bridge->dma_ranges, &iobase); if (err) { dev_err(dev, "Getting bridge resources failed\n"); return err; diff --git a/drivers/pci/of.c b/drivers/pci/of.c index bc7b27a28795..8d31e078461f 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -257,7 +257,9 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only); */ int devm_of_pci_get_host_bridge_resources(struct device *dev, unsigned char busno, unsigned char bus_max, - struct list_head *resources, resource_size_t *io_base) + struct list_head *resources, + struct list_head *ib_resources, + resource_size_t *io_base) { struct device_node *dev_node = dev->of_node; struct resource *res, tmp_res; @@ -340,6 +342,42 @@ int devm_of_pci_get_host_bridge_resources(struct device *dev, pci_add_resource_offset(resources, res, res->start - range.pci_addr); } + /* Check for dma-ranges property */ + if (!ib_resources) + return 0; + err = of_pci_dma_range_parser_init(&parser, dev_node); + if (err) + return 0; + + dev_dbg(dev, "Parsing dma-ranges property...\n"); + for_each_of_pci_range(&parser, &range) { + /* + * If we failed translation or got a zero-sized region + * then skip this range + */ + if (((range.flags & IORESOURCE_TYPE_BITS) != IORESOURCE_MEM) || + range.cpu_addr == OF_BAD_ADDR || range.size == 0) + continue; + + dev_info(dev, "IB MEM %#010llx..%#010llx -> %#010llx\n", + range.cpu_addr, + range.cpu_addr + range.size - 1, range.pci_addr); + + + err = of_pci_range_to_resource(&range, dev_node, &tmp_res); + if (err) + continue; + + res = devm_kmemdup(dev, &tmp_res, sizeof(tmp_res), GFP_KERNEL); + if (!res) { + err = -ENOMEM; + goto failed; + } + + pci_add_resource_offset(ib_resources, res, + res->start - range.pci_addr); + } + return 0; failed: @@ -482,6 +520,7 @@ EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci); int pci_parse_request_of_pci_ranges(struct device *dev, struct list_head *resources, + struct list_head *ib_resources, struct resource **bus_range) { int err, res_valid = 0; @@ -489,8 +528,9 @@ int pci_parse_request_of_pci_ranges(struct device *dev, struct resource_entry *win, *tmp; INIT_LIST_HEAD(resources); + INIT_LIST_HEAD(ib_resources); err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, resources, - &iobase); + ib_resources, &iobase); if (err) return err; diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index d22d1b807701..790458953c54 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -582,11 +582,15 @@ of_pci_get_max_link_speed(struct device_node *node) #if defined(CONFIG_OF_ADDRESS) int devm_of_pci_get_host_bridge_resources(struct device *dev, unsigned char busno, unsigned char bus_max, - struct list_head *resources, resource_size_t *io_base); + struct list_head *resources, + struct list_head *ib_resources, + resource_size_t *io_base); #else static inline int devm_of_pci_get_host_bridge_resources(struct device *dev, unsigned char busno, unsigned char bus_max, - struct list_head *resources, resource_size_t *io_base) + struct list_head *resources, + struct list_head *ib_resources, + resource_size_t *io_base); { return -EINVAL; } diff --git a/include/linux/pci.h b/include/linux/pci.h index 82e4cd1b7ac3..d57389b86f92 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2312,6 +2312,7 @@ void pci_release_bus_of_node(struct pci_bus *bus); struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus); int pci_parse_request_of_pci_ranges(struct device *dev, struct list_head *resources, + struct list_head *ib_resources, struct resource **bus_range); /* Arch may override this (weak) */ @@ -2326,6 +2327,7 @@ static inline struct irq_domain * pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; } static inline int pci_parse_request_of_pci_ranges(struct device *dev, struct list_head *resources, + struct list_head *ib_resources, struct resource **bus_range) { return -EINVAL; From patchwork Tue Sep 24 21:46:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159683 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D49971709 for ; Tue, 24 Sep 2019 21:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEC3120872 for ; Tue, 24 Sep 2019 21:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361602; bh=D4GILb9IpPbGJ11fmmsWv7i75YHy9g/gp+vOz23RA/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=R29v9fzT3Xo4dBME3JhEb6Wo/WkjmDDf057/mz8LshzxbTu/dMHqPYxB4dmXmV/AO sg+BwafOGrdLf0ifd+zwnhFWBDH2By6QMgDuWW0cApdkEcQJlMh31m7ZaIuvc/T136 c/0cJ+0sadP9iurfBJyGOtIC0HK+FL92jRx+a0OI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388524AbfIXVqm (ORCPT ); Tue, 24 Sep 2019 17:46:42 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:37393 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388104AbfIXVqm (ORCPT ); Tue, 24 Sep 2019 17:46:42 -0400 Received: by mail-oi1-f194.google.com with SMTP id i16so3068348oie.4 for ; Tue, 24 Sep 2019 14:46:41 -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=q6NzmoyzjZeLo4J8UGvzKGgfTn+zvwBNbZJNczmh+D4=; b=V/wAUiy5JsEnIReOBQgBta+HM5wU7ZQTEeb9iST3kNyFz2XiuL030H7RW5C3t6z3Oi nHOfg/ijRJSWkT2lgzf0dlqyLiq0pK9pyDxrlhDcbcjFhUHrqQrX1/puTuQD+vv5DSwF atlyZBvcO6jVZnCpueLhFU46EQLbq+1DENn2AOeK2xa1JSU7MsK69txhFPoNo16eT7qe b9PqraR/RojMm1AOIrSHkc3As1kSqK5H7LWDuRvjr74n3LjQlNsRbSvsybrKK9769vNQ 8JIMY+CEfUNpoxHAGpxbqOc/4cpa00PYOXMoeoN8kZ9YltnAvdIJ9tDjDYXx/zWlKjnR q4qw== X-Gm-Message-State: APjAAAU0rXTnWrPAMtQjS4G7px1m+EG4QY0Ly8T4GCCSNY8vlDRynPRw 50eiEmcmILb93J9L9Rwu6eR+/xI= X-Google-Smtp-Source: APXvYqxm493Rq9Q/JW6/m50nT3yGQOwZBnFUFyrFNDpiyWem3q6ykJqiXpDHGYmF2uopiFy/5olkYQ== X-Received: by 2002:aca:a9c3:: with SMTP id s186mr2088694oie.60.1569361601218; Tue, 24 Sep 2019 14:46:41 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:40 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH 07/11] PCI: ftpci100: Use inbound resources for setup Date: Tue, 24 Sep 2019 16:46:26 -0500 Message-Id: <20190924214630.12817-8-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now that the helpers provide the inbound resources in the host bridge 'dma_ranges' resource list, convert Faraday ftpci100 host bridge to use the resource list to setup the inbound addresses. Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring Reviewed-by: Andrew Murray --- drivers/pci/controller/pci-ftpci100.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index 3e07a8203736..e37a33ad77d9 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c @@ -375,12 +375,11 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) return 0; } -static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, - struct device_node *np) +static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p) { - struct of_pci_range range; - struct of_pci_range_parser parser; struct device *dev = p->dev; + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(p); + struct resource_entry *entry; u32 confreg[3] = { FARADAY_PCI_MEM1_BASE_SIZE, FARADAY_PCI_MEM2_BASE_SIZE, @@ -389,19 +388,12 @@ static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, int i = 0; u32 val; - if (of_pci_dma_range_parser_init(&parser, np)) { - dev_err(dev, "missing dma-ranges property\n"); - return -EINVAL; - } - - /* - * Get the dma-ranges from the device tree - */ - for_each_of_pci_range(&parser, &range) { - u64 end = range.pci_addr + range.size - 1; + resource_list_for_each_entry(entry, &bridge->dma_ranges) { + u64 pci_addr = entry->res->start - entry->offset; + u64 end = entry->res->end - entry->offset; int ret; - ret = faraday_res_to_memcfg(range.pci_addr, range.size, &val); + ret = faraday_res_to_memcfg(pci_addr, resource_size(entry->res), &val); if (ret) { dev_err(dev, "DMA range %d: illegal MEM resource size\n", i); @@ -409,7 +401,7 @@ static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, } dev_info(dev, "DMA MEM%d BASE: 0x%016llx -> 0x%016llx config %08x\n", - i + 1, range.pci_addr, end, val); + i + 1, pci_addr, end, val); if (i <= 2) { faraday_raw_pci_write_config(p, 0, 0, confreg[i], 4, val); @@ -566,7 +558,7 @@ static int faraday_pci_probe(struct platform_device *pdev) cur_bus_speed = PCI_SPEED_66MHz; } - ret = faraday_pci_parse_map_dma_ranges(p, dev->of_node); + ret = faraday_pci_parse_map_dma_ranges(p); if (ret) return ret; From patchwork Tue Sep 24 21:46:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159685 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 663C31709 for ; Tue, 24 Sep 2019 21:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 447C121655 for ; Tue, 24 Sep 2019 21:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361604; bh=G4Ya0eTXy4UbYqZX6UX4WSydzq0U+zIJsUBWsWmCuzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fhAoIqCzz3339REGHr6sVzfIPgYzt0uQMK6lUAl6uiGho+IvO7ojTEap1zC2BBA4T GJfCDc1lbsxgltWZPafx0e2QES4wIpbI6VW+xfA8uEtfh4n6rLmvdM125KGuZQPfgY n8pGii+cZRsHQ6QjxysgDX2hUmk3C9ix/7w8vhaA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388104AbfIXVqn (ORCPT ); Tue, 24 Sep 2019 17:46:43 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:34558 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387795AbfIXVqn (ORCPT ); Tue, 24 Sep 2019 17:46:43 -0400 Received: by mail-ot1-f66.google.com with SMTP id m19so2922749otp.1 for ; Tue, 24 Sep 2019 14:46:42 -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=R72LtM4E+GnBMU5nTAg71RpvVo88KSBCCvKVk+mAsE4=; b=F1vMIh4J5OlfxliJTIZfnyzI04K/1WihC3Dx46z8DSCpBih50LsVteAuLm7izPmW2p 9WrIhgjfFa4+BkCwq/59UgqUuQjMjTiVgy5nfPaklQI/0H5fiyAxrmrxtWdMQ8XIiR6u l4KQw3O7wdhj9QoYXXhY5sUSwBcQsPed6rfNbnCe4pt2B09Alr1x3Gmob/i1jdc2BS+l yMC1CCCiNkekUtHM7HQu62AEe+oXMH2A0nqIn/MLlLkxmNuwjM5HcqGkFOB+2q6qN13z NPwfuVqqfQ1Bvx+KyY50B8CtTnszbvyuIio74k21AAmjJvBejqwP7l0rnIC63h5hBqGL QHMg== X-Gm-Message-State: APjAAAXvG6THC5RfVQssI2TRtKVMzaPZJeG+4DvHXvMmSiH83lICFS59 iEwCGIhG5YCmXdv4tSS+VZzsyYM= X-Google-Smtp-Source: APXvYqyPqqpzNQEFkC2p81nNKbbCveYcrUusLyGhhXWYHdVYOPjcgLX4O1oSMVrbeveb57HBIMCi5g== X-Received: by 2002:a9d:7d12:: with SMTP id v18mr3837684otn.216.1569361602266; Tue, 24 Sep 2019 14:46:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:41 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 08/11] PCI: v3-semi: Use inbound resources for setup Date: Tue, 24 Sep 2019 16:46:27 -0500 Message-Id: <20190924214630.12817-9-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now that the helpers provide the inbound resources in the host bridge 'dma_ranges' resource list, convert the v3-semi host bridge to use the resource list to setup the inbound addresses. Cc: Linus Walleij Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring Reviewed-by: Andrew Murray Reviewed-by: Linus Walleij --- drivers/pci/controller/pci-v3-semi.c | 38 ++++++++++++---------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c index 090df766faf9..122b695da591 100644 --- a/drivers/pci/controller/pci-v3-semi.c +++ b/drivers/pci/controller/pci-v3-semi.c @@ -613,28 +613,30 @@ static int v3_pci_setup_resource(struct v3_pci *v3, } static int v3_get_dma_range_config(struct v3_pci *v3, - struct of_pci_range *range, + struct resource_entry *entry, u32 *pci_base, u32 *pci_map) { struct device *dev = v3->dev; - u64 cpu_end = range->cpu_addr + range->size - 1; - u64 pci_end = range->pci_addr + range->size - 1; + u64 cpu_addr = entry->res->start; + u64 cpu_end = entry->res->end; + u64 pci_end = cpu_end - entry->offset; + u64 pci_addr = entry->res->start - entry->offset; u32 val; - if (range->pci_addr & ~V3_PCI_BASE_M_ADR_BASE) { + if (pci_addr & ~V3_PCI_BASE_M_ADR_BASE) { dev_err(dev, "illegal range, only PCI bits 31..20 allowed\n"); return -EINVAL; } - val = ((u32)range->pci_addr) & V3_PCI_BASE_M_ADR_BASE; + val = ((u32)pci_addr) & V3_PCI_BASE_M_ADR_BASE; *pci_base = val; - if (range->cpu_addr & ~V3_PCI_MAP_M_MAP_ADR) { + if (cpu_addr & ~V3_PCI_MAP_M_MAP_ADR) { dev_err(dev, "illegal range, only CPU bits 31..20 allowed\n"); return -EINVAL; } - val = ((u32)range->cpu_addr) & V3_PCI_MAP_M_MAP_ADR; + val = ((u32)cpu_addr) & V3_PCI_MAP_M_MAP_ADR; - switch (range->size) { + switch (resource_size(entry->res)) { case SZ_1M: val |= V3_LB_BASE_ADR_SIZE_1MB; break; @@ -682,8 +684,8 @@ static int v3_get_dma_range_config(struct v3_pci *v3, dev_dbg(dev, "DMA MEM CPU: 0x%016llx -> 0x%016llx => " "PCI: 0x%016llx -> 0x%016llx base %08x map %08x\n", - range->cpu_addr, cpu_end, - range->pci_addr, pci_end, + cpu_addr, cpu_end, + pci_addr, pci_end, *pci_base, *pci_map); return 0; @@ -692,24 +694,16 @@ static int v3_get_dma_range_config(struct v3_pci *v3, static int v3_pci_parse_map_dma_ranges(struct v3_pci *v3, struct device_node *np) { - struct of_pci_range range; - struct of_pci_range_parser parser; + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(v3); struct device *dev = v3->dev; + struct resource_entry *entry; int i = 0; - if (of_pci_dma_range_parser_init(&parser, np)) { - dev_err(dev, "missing dma-ranges property\n"); - return -EINVAL; - } - - /* - * Get the dma-ranges from the device tree - */ - for_each_of_pci_range(&parser, &range) { + resource_list_for_each_entry(entry, &bridge->dma_ranges) { int ret; u32 pci_base, pci_map; - ret = v3_get_dma_range_config(v3, &range, &pci_base, &pci_map); + ret = v3_get_dma_range_config(v3, entry, &pci_base, &pci_map); if (ret) return ret; From patchwork Tue Sep 24 21:46:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159687 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 99AE914ED for ; Tue, 24 Sep 2019 21:46:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76C1F214DA for ; Tue, 24 Sep 2019 21:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361605; bh=t4iSL0Pg2P/4OwY4/GW87mdeDzYyVClS8KOu6IIpNRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=W/27v2lym0oOJzvjGSArLf5yoFClLy7mgEgcrKImzbXNOZ83cyg7sAbFeBCMufn/d A8jW8i6xvawCs1HwCvOv40HSoomAQwMGWFLlxtCdzXZuRuaLbN+MwWyd1jsyf8r3/0 NeKNCONZnWP5aziG27qghyWWn18BH1i8dz81Nne8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394973AbfIXVqp (ORCPT ); Tue, 24 Sep 2019 17:46:45 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:46656 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387795AbfIXVqo (ORCPT ); Tue, 24 Sep 2019 17:46:44 -0400 Received: by mail-ot1-f65.google.com with SMTP id f21so2876469otl.13 for ; Tue, 24 Sep 2019 14:46:44 -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=kzT1dQZKS9nlLNEXmzKDWhGBgjG065SiJgY5/7PYzKk=; b=S44yKy2/sw1IJpTjtyJytVNMk8jthNtexxrLpSiDLDEXWJYVAVc9mDo0S00/dIx+oU dIqEvQUflhsz1R7VUhGN56E7o1m2ZFaoYMEfdoTx+ZxKuBDjxZ2v2vfUIhoFBOzlNNH2 LSSm6nGgFyBAi+cZJ/gqlAHeNVdm9N7mBcTBuQS5bAcvZQPALI1u1YZlPHe0SULWHHO7 o5muBrC03SHXXYod4+hL6Yc80Sk60rwzW/jg271TzARkfbVQ8y/FSOvui6luDy8O21Lm gbXbgCZGfqnGRlT8ITPPUgrlyIYZBM4o62+vKNSnpgQCgKO22uDAIikrNFxGRnsXee0+ 3Q5w== X-Gm-Message-State: APjAAAUER180i7HbT3NIYf9mows7oHKlJ0HDEFwBtRai+iDrLP/rZU3N YGvWFJOIKETqcGNO69Bq7fWGAtY= X-Google-Smtp-Source: APXvYqxhl4TZRZyV/C1WBQs2FRtHj7Tr/BevDyc8y4ZafJ5qNeW5H0lpHfwkunz0YbNPf7SswH9New== X-Received: by 2002:a05:6830:1e31:: with SMTP id t17mr3477636otr.201.1569361603571; Tue, 24 Sep 2019 14:46:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:42 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org, Toan Le Subject: [PATCH 09/11] PCI: xgene: Use inbound resources for setup Date: Tue, 24 Sep 2019 16:46:28 -0500 Message-Id: <20190924214630.12817-10-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now that the helpers provide the inbound resources in the host bridge 'dma_ranges' resource list, convert the Xgene host bridge to use the resource list to setup the inbound addresses. Cc: Toan Le Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring Reviewed-by: Andrew Murray --- drivers/pci/controller/pci-xgene.c | 32 ++++++++++-------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index 11f27c42c06a..09c913b12ebc 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -485,27 +485,27 @@ static int xgene_pcie_select_ib_reg(u8 *ib_reg_mask, u64 size) } static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port, - struct of_pci_range *range, u8 *ib_reg_mask) + struct resource_entry *entry, u8 *ib_reg_mask) { void __iomem *cfg_base = port->cfg_base; struct device *dev = port->dev; void *bar_addr; u32 pim_reg; - u64 cpu_addr = range->cpu_addr; - u64 pci_addr = range->pci_addr; - u64 size = range->size; + u64 cpu_addr = entry->res->start; + u64 pci_addr = cpu_addr - entry->offset; + u64 size = resource_size(entry->res); u64 mask = ~(size - 1) | EN_REG; u32 flags = PCI_BASE_ADDRESS_MEM_TYPE_64; u32 bar_low; int region; - region = xgene_pcie_select_ib_reg(ib_reg_mask, range->size); + region = xgene_pcie_select_ib_reg(ib_reg_mask, size); if (region < 0) { dev_warn(dev, "invalid pcie dma-range config\n"); return; } - if (range->flags & IORESOURCE_PREFETCH) + if (entry->res->flags & IORESOURCE_PREFETCH) flags |= PCI_BASE_ADDRESS_MEM_PREFETCH; bar_low = pcie_bar_low_val((u32)cpu_addr, flags); @@ -536,25 +536,13 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port, static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port) { - struct device_node *np = port->node; - struct of_pci_range range; - struct of_pci_range_parser parser; - struct device *dev = port->dev; + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port); + struct resource_entry *entry; u8 ib_reg_mask = 0; - if (of_pci_dma_range_parser_init(&parser, np)) { - dev_err(dev, "missing dma-ranges property\n"); - return -EINVAL; - } - - /* Get the dma-ranges from DT */ - for_each_of_pci_range(&parser, &range) { - u64 end = range.cpu_addr + range.size - 1; + resource_list_for_each_entry(entry, &bridge->dma_ranges) + xgene_pcie_setup_ib_reg(port, entry, &ib_reg_mask); - dev_dbg(dev, "0x%08x 0x%016llx..0x%016llx -> 0x%016llx\n", - range.flags, range.cpu_addr, end, range.pci_addr); - xgene_pcie_setup_ib_reg(port, &range, &ib_reg_mask); - } return 0; } From patchwork Tue Sep 24 21:46:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159689 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0A1914ED for ; Tue, 24 Sep 2019 21:46:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF72320872 for ; Tue, 24 Sep 2019 21:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361606; bh=ND0N4swuzFJJwX8/fJ2F5YJODk9wqnn7YppWxtaVzOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0/wE1zg4MeF9AqFIJMRetN9zWggIa2lHOxHi+1tNUl1Fat/beaTkip3Anf/AaGWis 6LshX4gPJYxE5nn2icpxMa/H7hyZcD5tR4rPVHap8kN11XEtNTvdtmSUGq0T6OP2+k Dr3ZpvTmK6x6cBU8TYVJv58S6VcsMEaMjFfE1sgM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395534AbfIXVqq (ORCPT ); Tue, 24 Sep 2019 17:46:46 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:46659 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387795AbfIXVqq (ORCPT ); Tue, 24 Sep 2019 17:46:46 -0400 Received: by mail-ot1-f67.google.com with SMTP id f21so2876510otl.13 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=C4LaYiapB+gGYlHY8zndnFvU0UTfw+W6GZdT4C5FIv6jTzEIxxdtOGpQaORmeQKNzQ fPYSRNEgIBZZGS28rAEiLANNR8BQrlwGf51+Oi+vqStpGtBosSlM4CW28ozD3/7zXsnp WsfTKS+Tfy7TcB/Q0AfMYBXtyIK5ewwv3T8Owlc3B8Hp6GfMvyqjVtUDXqPUdR1q/Hqm 76ZJRb6FzWOeZI7V4cM65NSwAm76pkaWeS022W3trNy9asoA1T1lgeETQfiON5er3OaF mWTVUFuSomRjgObkXH4bW1e/jJModCgHHqUjFFKNhQZIatrgYZXhfy9HXwCubHmalHPe YVog== X-Gm-Message-State: APjAAAXSIWh3OdSvQ2Tvufhmvi/DMU8oaVziD/fkPkDOePWw9zS+aUvJ d/xFn6sjTypTBYiuXaMC8ZxeQcI= 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 Cc: linux-arm-kernel@lists.infradead.org, Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com 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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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 Reviewed-by: Andrew Murray --- 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; } From patchwork Tue Sep 24 21:46:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11159691 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0F7714ED for ; Tue, 24 Sep 2019 21:46:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F759214DA for ; Tue, 24 Sep 2019 21:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569361607; bh=AfpMwz8ts+uJ52fKFMKPQjLWa8R7Nz/n+NsKUeo3wJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KbSS522wUDPy8Pw1AWUlW/fLwxRv12pUCDDcZUkselU4mRzT3LebWMMlqKgLqDQmA 9Ly0VFQtPdaM6nxxoYkHOUJvNLj3qiGwrplz5v/BVV8jRCdYuicj+HZcfCklBPudbk TaxwYI73+PEc774wdu5tKF3RYKwxSPYwuNHQ8Rzs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387795AbfIXVqr (ORCPT ); Tue, 24 Sep 2019 17:46:47 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:41538 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395520AbfIXVqq (ORCPT ); Tue, 24 Sep 2019 17:46:46 -0400 Received: by mail-oi1-f193.google.com with SMTP id w17so3057693oiw.8 for ; Tue, 24 Sep 2019 14:46:46 -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=KRER0q+mlfhxTDAY0c1+VI59pLZZnQ9VLJY13cVFl4Y=; b=ufUySC78f2+FEjkqy/AeP7YGhlFv2bRrZ+VvA4Ihpc7761r672JTV2cpDt7b020IsT OeJXb0RD2LvQnkxsqBvq+IN6NXaPoQ/21DGeE9JJpSOvn69yZF6R805wsYYIrmIcacLW /fKdApFp58yhR53gg44V79aobbbgnsMay/liDk4hD8wQfiZ8WtCRicLsIEWVOlfMhhoR Mo4lBREp0MQ4qBTGe3ZNsITv0C4s5DdgN5ol+rhKQ2GBLi97Gw1N3o+92oYIYkSz0DgL 9ID1HS7e49KTVA5CmnQXntWgOrqmv1m/OrV4nTxJei2xVIqwWB/AdZN5RZQJL/LlahW0 UDDw== X-Gm-Message-State: APjAAAV8uYPUPj33EZSvFJ2Ga3Mdg9kKSJAo2Pu4R8KviUUz9DtRevMV 4jzaNgyiFQTTO7GLTkI0dxDx6HA= X-Google-Smtp-Source: APXvYqwgBp3XW5k0bjqWkMtbPmB+OzYYsn1F2SbpReTHH0zYcIqCKZJ2yQ8jgdcCRG2eP6rhB+Z3YQ== X-Received: by 2002:aca:df88:: with SMTP id w130mr2172805oig.0.1569361605620; Tue, 24 Sep 2019 14:46:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 14:46:45 -0700 (PDT) From: Rob Herring To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org, Simon Horman Subject: [PATCH 11/11] PCI: rcar: Use inbound resources for setup Date: Tue, 24 Sep 2019 16:46:30 -0500 Message-Id: <20190924214630.12817-12-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now that the helpers provide the inbound resources in the host bridge 'dma_ranges' resource list, convert Renesas R-Car PCIe host bridge to use the resource list to setup the inbound addresses. Cc: Simon Horman Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring --- drivers/pci/controller/pcie-rcar.c | 45 +++++++++++------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index b8d6e86a5539..453c931aaf77 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -1014,16 +1014,16 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie) } static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, - struct of_pci_range *range, + struct resource_entry *entry, int *index) { - u64 restype = range->flags; - u64 cpu_addr = range->cpu_addr; - u64 cpu_end = range->cpu_addr + range->size; - u64 pci_addr = range->pci_addr; + u64 restype = entry->res->flags; + u64 cpu_addr = entry->res->start; + u64 cpu_end = entry->res->end; + u64 pci_addr = entry->res->start - entry->offset; u32 flags = LAM_64BIT | LAR_ENABLE; u64 mask; - u64 size; + u64 size = resource_size(entry->res); int idx = *index; if (restype & IORESOURCE_PREFETCH) @@ -1037,9 +1037,7 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, unsigned long nr_zeros = __ffs64(cpu_addr); u64 alignment = 1ULL << nr_zeros; - size = min(range->size, alignment); - } else { - size = range->size; + size = min(size, alignment); } /* Hardware supports max 4GiB inbound region */ size = min(size, 1ULL << 32); @@ -1078,30 +1076,19 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, return 0; } -static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie, - struct device_node *np) +static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie) { - struct of_pci_range range; - struct of_pci_range_parser parser; - int index = 0; - int err; - - if (of_pci_dma_range_parser_init(&parser, np)) - return -EINVAL; - - /* Get the dma-ranges from DT */ - for_each_of_pci_range(&parser, &range) { - u64 end = range.cpu_addr + range.size - 1; - - dev_dbg(pcie->dev, "0x%08x 0x%016llx..0x%016llx -> 0x%016llx\n", - range.flags, range.cpu_addr, end, range.pci_addr); + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); + struct resource_entry *entry; + int index = 0, err = 0; - err = rcar_pcie_inbound_ranges(pcie, &range, &index); + resource_list_for_each_entry(entry, &bridge->dma_ranges) { + err = rcar_pcie_inbound_ranges(pcie, entry, &index); if (err) - return err; + break; } - return 0; + return err; } static const struct of_device_id rcar_pcie_of_match[] = { @@ -1162,7 +1149,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) goto err_unmap_msi_irqs; } - err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node); + err = rcar_pcie_parse_map_dma_ranges(pcie); if (err) goto err_clk_disable;