From patchwork Mon Oct 28 16:32:32 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: 11215855 X-Patchwork-Delegate: geert@linux-m68k.org 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 0D576112B for ; Mon, 28 Oct 2019 16:33:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEC17217D6 for ; Mon, 28 Oct 2019 16:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280382; bh=p7QMFCGdunWrZcw57C9Y1vl4ihSEqVW9tS+voq5Xz2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=WLVbAkA2rz3xosCCJ3viBIEg2BAx16HyC8gtJ+CfPBxR9dD+xi+Ox4uKEt2UTHcrh QjZw9163Ws10HzExeXHPwHN8Bv2PbJMPHB03gg0J70WFgIHGLf7Q0Qqxzf1BktSP3v MT3B21SFUwBv+tZWt2yGeG2w0Uw4ft8cOsOTCzV8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732691AbfJ1QdC (ORCPT ); Mon, 28 Oct 2019 12:33:02 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:41389 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdC (ORCPT ); Mon, 28 Oct 2019 12:33:02 -0400 Received: by mail-oi1-f194.google.com with SMTP id g81so6399413oib.8; Mon, 28 Oct 2019 09:33:01 -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=Ly9SwwfQU77PS/De9nePQz9/hgu0i/2+0AP8IGmXD3o=; b=E4EL88dFKu3hNE3PiY3hx79WoH+Zk7+YuRD5T8HVBKY1kJ1nuHVWPUfv+MaVgmJPCN DJ9TcdJ4uO0l2A4rLEPE7YNqasbSxkYM6n905MZW98Z91u80RIIzOigju8p8GxEysVFt jsztL2P0Ec/GMLJjKv8eaPKjdyCr1ewjCBov7pQf5s5t6rd+UndxNtmlQVUuENmls2qJ hyY05QP+hCePW6tIxYfhc3NUnh5GJIOpKAnz8IEuSnf1RT16dbofJeL/X4KQPRVnmg46 FbFWVA5IxIMbEhBiHqI1ccVMqXnb63pX9qSgL6ewt+I3DHKgMZd93qnfCzkvnPKN4k9a dlIA== X-Gm-Message-State: APjAAAXbU4Gvbc2zogzSmobIDxgL4hkOtI/lnPzDHomxawsAJS2Y7O4+ 7oVDXSEIiuB/g1H1i4S2iw== X-Google-Smtp-Source: APXvYqz7AvFVl42WcaIBsnF/FBWNvONUeq6ow/pzPzHbo/QsqT4JbiucFb+B7zhfVTYFjNW6To0vKg== X-Received: by 2002:aca:1e0c:: with SMTP id m12mr168280oic.18.1572280381198; Mon, 28 Oct 2019 09:33:01 -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 e186sm354991oia.47.2019.10.28.09.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:00 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 01/25] resource: Add a resource_list_first_type helper Date: Mon, 28 Oct 2019 11:32:32 -0500 Message-Id: <20191028163256.8004-2-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org A common pattern is looping over a resource_list just to get a matching entry with a specific type. Add resource_list_first_type() helper which implements this. Signed-off-by: Rob Herring --- v3: - Rename resource_list_get_entry_of_type to resource_list_first_type include/linux/resource_ext.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.20.1 diff --git a/include/linux/resource_ext.h b/include/linux/resource_ext.h index 06da59b23b79..ff0339df56af 100644 --- a/include/linux/resource_ext.h +++ b/include/linux/resource_ext.h @@ -66,4 +66,16 @@ resource_list_destroy_entry(struct resource_entry *entry) #define resource_list_for_each_entry_safe(entry, tmp, list) \ list_for_each_entry_safe((entry), (tmp), (list), node) +static inline struct resource_entry * +resource_list_first_type(struct list_head *list, unsigned long type) +{ + struct resource_entry *entry; + + resource_list_for_each_entry(entry, list) { + if (resource_type(entry->res) == type) + return entry; + } + return NULL; +} + #endif /* _LINUX_RESOURCE_EXT_H */ From patchwork Mon Oct 28 16:32:33 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: 11215861 X-Patchwork-Delegate: geert@linux-m68k.org 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 7E8A915AB for ; Mon, 28 Oct 2019 16:33:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D24B21783 for ; Mon, 28 Oct 2019 16:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280385; bh=CBoaIPNpvw7jMqNDowMOSwmBc+py10IvcKNExodvt6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uhLY2FUWI69Gz+eFqZAvlpLJbBLSCOtb5BmGgOa6tBfR54FFga2LYUlNbBqqrBSYB B8mrSPugE8qeYIe6e03QvfW9mB9DmyexDBppWOwf0GHhx2ZSCrgsHye9PQhG++dEui 8xNgQ1SST+4deA0QUUw6jAnbEAI7MdYVH5S9lFyg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732939AbfJ1QdF (ORCPT ); Mon, 28 Oct 2019 12:33:05 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:40140 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdE (ORCPT ); Mon, 28 Oct 2019 12:33:04 -0400 Received: by mail-oi1-f193.google.com with SMTP id r27so228794oij.7; Mon, 28 Oct 2019 09:33:03 -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=j3Ah2aSYwS6QKWxODjjePSbvkaLsSgyNAd22qZoET50=; b=n38zr9xaRKZugpH2aX0lfR6TKORg1G4uBUb8RnzJQrRgDGdiGStjMY9lMHtN+33N7z 8VhDp/7fhCco9ijUsEjmTswnTFz4rlCP0GuksBiJNhuw+qp+9AfYi3fe/eNrL2pSKeag rs0tyFfSdwbxDSuZJCmXPOgM1rTqiOJtt/HiwPM2B9y5EjKCedJ//m1vCFxH1EE/vGFr JhkYEBEGg+p5QgXjOWFGTSALGbZ8VYkWadLUdGsLbYxQDI7K4HO0jJPeMTm6ZwCogxMg Kgklkn7mrKQr6YonHh01l8VZoKvHYBlRekLeYKj8KToiEfxpBexw2JYhqjO6HMmZbY1x 0hOg== X-Gm-Message-State: APjAAAUx0X1mplzbtg0pNljWfvdQFtV7NTxPnSp0izMNmIFWRjmjAA1L 8s6aUvj5wOzhMGRvOPq7rQ== X-Google-Smtp-Source: APXvYqwuOiD/nmPOHXYnO+kSRC+y2SQfGQt3XIG25A6vcuKK0nySh6ol8d3kQ/rCmlmUWRTvYzgC5g== X-Received: by 2002:a54:4601:: with SMTP id p1mr106186oip.113.1572280383192; Mon, 28 Oct 2019 09:33:03 -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 e186sm354991oia.47.2019.10.28.09.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:02 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 02/25] PCI: Export pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:33 -0500 Message-Id: <20191028163256.8004-3-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org pci_parse_request_of_pci_ranges() is missing a module export, so add it. Cc: Bjorn Helgaas Reviewed-by: Andrew Murray Signed-off-by: Rob Herring --- drivers/pci/of.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 36891e7deee3..f3da49a31db4 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -530,6 +530,7 @@ int pci_parse_request_of_pci_ranges(struct device *dev, pci_free_resource_list(resources); return err; } +EXPORT_SYMBOL_GPL(pci_parse_request_of_pci_ranges); #endif /* CONFIG_PCI */ From patchwork Mon Oct 28 16:32:34 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: 11215865 X-Patchwork-Delegate: geert@linux-m68k.org 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 DA9F1112B for ; Mon, 28 Oct 2019 16:33:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9869217D6 for ; Mon, 28 Oct 2019 16:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280386; bh=wjOgXaStTAtbMw6yoJaqMlTPwZ2OskfJjCwfzlDIVBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YaoaOBXnMC2dPPKcCXCufawCPeP85Hg+6X/sfzgJMV6Wmq/zj1bW572pw1O5wji5V 267YU54Uh9Gx++fcXZKlhh+VYjSjTh2mqNRyTLxITWDjqu/dnnR6KLI+yvhRomZBsZ hLBh3R+tGpodwlYf7CZnk2qDlOmISA7prbwo5f+8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732942AbfJ1QdG (ORCPT ); Mon, 28 Oct 2019 12:33:06 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:41392 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdG (ORCPT ); Mon, 28 Oct 2019 12:33:06 -0400 Received: by mail-oi1-f193.google.com with SMTP id g81so6399615oib.8; Mon, 28 Oct 2019 09:33:05 -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=Y8FNka9VqW+GuyHhrg3YYeRr9rwrH+ifXsb5oKqpMlo=; b=quOp+Wj+X/WnwH/353nM+Hv6mTyrNSmGLT3+gh3mTwiAZnzczGMR1NaZQigTqj3VH7 dcVMtwC1zY2Rjrx//AvDR2jOg7+c+Dqx6QhiNgl8MaoPV8sKjmHSKNpQzlj0KC+iJhh3 Q2pV0fXSfdD7OkGyHwpVYuGAHM+vEGeHz4W6v+G49dP6+ZrpPdKXjx9k/1nfnshgStaK cC0CP/ih+6dxfO4GBBIphed7GeJshH+/G3SI1+0ScBlY68YKFZ24t524X5y/mVlEiFOZ QwfZ4tMtJ7eL+KJRL5PnYG+/nfPcDrPVQOC6xF5oBELpEpZ2kClitUkMeJnEweL0C1vs dXSA== X-Gm-Message-State: APjAAAWwXBuTy/VQ8DkWgLrzkkUo2JW1zUN3Gp6Ki99X+/qOBrht8D0t gmVI5BKqMdc5mBJDbX98QQ== X-Google-Smtp-Source: APXvYqyUIRHPK2FSnzpcsAJEGlsEmDJCiz/greX4s1l3COXvilcvI5rrPN21yJJxsAwhuvZFPOfz2Q== X-Received: by 2002:a05:6808:ab1:: with SMTP id r17mr118801oij.75.1572280385099; Mon, 28 Oct 2019 09:33:05 -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 e186sm354991oia.47.2019.10.28.09.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:04 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 03/25] PCI: aardvark: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:34 -0500 Message-Id: <20191028163256.8004-4-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert aardvark to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Tested-by: Thomas Petazzoni Reviewed-by: Andrew Murray Signed-off-by: Rob Herring --- v2: - Remove the temporary list --- drivers/pci/controller/pci-aardvark.c | 60 ++------------------------- 1 file changed, 4 insertions(+), 56 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index fc0fe4d4de49..9cbeba507f0c 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -186,7 +186,6 @@ struct advk_pcie { struct platform_device *pdev; void __iomem *base; - struct list_head resources; struct irq_domain *irq_domain; struct irq_chip irq_chip; struct irq_domain *msi_domain; @@ -910,63 +909,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 +938,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, &bridge->windows, + &bus); if (ret) { dev_err(dev, "Failed to parse resources\n"); return ret; } + pcie->root_bus_nr = bus->start; advk_pcie_setup_hw(pcie); @@ -1014,7 +963,6 @@ static int advk_pcie_probe(struct platform_device *pdev) return ret; } - list_splice_init(&pcie->resources, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr = 0; From patchwork Mon Oct 28 16:32:35 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: 11215869 X-Patchwork-Delegate: geert@linux-m68k.org 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 3AA8D112B for ; Mon, 28 Oct 2019 16:33:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19720218AC for ; Mon, 28 Oct 2019 16:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280389; bh=bWTCM6lzBqYqUpY1eN93s/ptVwH0wxQgM6SLt7Ty440=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0hDNn6ZD8SEihtnrEckWi7nTxsaimkT0QSQEwWGKb6F4WhZbr67gnqclTrLP5MCKE qPGaB8HHPeVQq+HYzv7eHBPTdlRnHo/meGYTxkI6Z/9jMhKev8VtCpoXbhD2vBRLJw 5sS7m7z268CNSHiSgze53Qz+n6YYKzTP1TOrZuX4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732976AbfJ1QdI (ORCPT ); Mon, 28 Oct 2019 12:33:08 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:37013 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdI (ORCPT ); Mon, 28 Oct 2019 12:33:08 -0400 Received: by mail-oi1-f193.google.com with SMTP id y194so1822446oie.4; Mon, 28 Oct 2019 09:33:08 -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=k2xpUbChHFjHyLZeTvcqjOOLjHW6EiB7rU1pguJS2Eg=; b=r9TTe8iQM2Y2K+5+c1im6s2qjoTvjmw/AW67bIsWp2GoaOVQWkGQVc56XIm/UZBFKD 8gYg/WCflTASK9gK9D276gXmS6gCokb8yznE/svFM5p/hMhf+ziv6VhGB4okQnyGYpev 1doj0BJcSIFlbrvuX8QFsnz9X1tYerl6zdpUHLrY769rh0PP9h/pZw2j5Ie7XgymuMgY Y/b9l5ebI4Mb14Uccncz9iIKQADozXW92mAdOU+pQzIvnLnsWA87zc5QUuA2n4l8UOxK GDs+56XQtl35VUz+kVDSBOlaxyMWelv9FeEfSDqZqtvQf0DZ2HHls89rjh26lML2GHHu xhig== X-Gm-Message-State: APjAAAXac+peCtkcOBZinMkNAKmwFw7HWbwSG+VErNnLaSBi5xKCtQXN iOgTRvo0nl8d9AkAZUNEhIRdyTQ= X-Google-Smtp-Source: APXvYqxZ8ey0YEh8bAOZGGeVRLpA2ZABAh6GC8RKam9rkxWgH4qFebetMS5T/qIzXrvDlJgloyLHhA== X-Received: by 2002:a05:6808:1c7:: with SMTP id x7mr122892oic.67.1572280387584; Mon, 28 Oct 2019 09:33:07 -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 e186sm354991oia.47.2019.10.28.09.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:06 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 04/25] PCI: altera: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:35 -0500 Message-Id: <20191028163256.8004-5-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert altera host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. If an I/O range is present, then it will now be mapped. It's expected that h/w which doesn't support I/O range will not define one. Cc: Ley Foon Tan Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: rfi@lists.rocketboards.org Reviewed-by: Andrew Murray Signed-off-by: Rob Herring --- v2: - Remove temporary resource list --- drivers/pci/controller/pcie-altera.c | 41 ++-------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c index d2497ca43828..ba025efeae28 100644 --- a/drivers/pci/controller/pcie-altera.c +++ b/drivers/pci/controller/pcie-altera.c @@ -92,7 +92,6 @@ struct altera_pcie { u8 root_bus_nr; struct irq_domain *irq_domain; struct resource bus_range; - struct list_head resources; const struct altera_pcie_data *pcie_data; }; @@ -670,39 +669,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 +799,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, &bridge->windows, + NULL); if (ret) { dev_err(dev, "Failed add resources\n"); return ret; @@ -853,7 +818,6 @@ static int altera_pcie_probe(struct platform_device *pdev) cra_writel(pcie, P2A_INT_ENA_ALL, P2A_INT_ENABLE); altera_pcie_host_init(pcie); - list_splice_init(&pcie->resources, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr = pcie->root_bus_nr; @@ -884,7 +848,6 @@ static int altera_pcie_remove(struct platform_device *pdev) pci_stop_root_bus(bridge->bus); pci_remove_root_bus(bridge->bus); - pci_free_resource_list(&pcie->resources); altera_pcie_irq_teardown(pcie); return 0; From patchwork Mon Oct 28 16:32:36 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: 11215873 X-Patchwork-Delegate: geert@linux-m68k.org 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 A9C9214E5 for ; Mon, 28 Oct 2019 16:33:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89621217D6 for ; Mon, 28 Oct 2019 16:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280392; bh=MWRiI4U3ryNMDK9X+JIOmKIbxSrWcYsQs5BI0RlQtLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=X3SXuQBS2e1o7Oj7XNXgaonFOtvCzpgJGCpL1YTLUVpRPHedCSOHHSkh+LplYVJEe o/odoDiHA3Cb6uGH4HSTvxpVvaN7pzlQ7Rbucb6rEmFk9W3b1wV+FooyJUtWv6R1rg gKAjMzswSNbsB5mhWHQehOFdxqB3nidvJybZzTys= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732980AbfJ1QdM (ORCPT ); Mon, 28 Oct 2019 12:33:12 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:40547 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdM (ORCPT ); Mon, 28 Oct 2019 12:33:12 -0400 Received: by mail-ot1-f66.google.com with SMTP id d8so7160131otc.7; Mon, 28 Oct 2019 09:33:11 -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=/baIkufFp5mlTrEe7IeynKuDaRx91+3hOWgRDUhWFkU=; b=hIOcsE67OKf4cc/bV6KNN2hhWpEjJRzdubQ3ML9c6qStu84Vez/s3VJAfXd/j5VX/N 3qX7nXFNCPDfekk4/FKUmoXdCyYrIe7wHc4uzmNY8WHMZDtq0Yw8nmhcgFMKVycfICkh 6AE1lQH7zSUBWSRvbcU03zGqEhaAc0A9Osuf0k8bF9XmSPS2FAha73hoxmWih3mpvKDL FZKVvV3IXcoUIqBU8v/hBiGz0SZSW6DvfCka3mw34n6A3WGn27pM05XzqK9Faz0k/poq EGdBUFvIlkEzg5l6n0PeuLJvtwgIVU6m216Cz3BjwFEs9Z0ob1pN29J/58xEy1i88Y2Q vZYw== X-Gm-Message-State: APjAAAX9Ax8ENUTbZ/Yf2i9mKZ3u/4CaCHJiNrSGZfDpvzejICQnfeo0 yRv9rND6HlB6BwiiQxqTQA== X-Google-Smtp-Source: APXvYqx+LIHYOqhOeHGYYTJWv4RVEy0aq3Lc+2gCsX7tadvpjU/gR9g+Z64Jn7VX8cIew+VZHzINfQ== X-Received: by 2002:a9d:4a9c:: with SMTP id i28mr13723432otf.169.1572280390819; Mon, 28 Oct 2019 09:33:10 -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 e186sm354991oia.47.2019.10.28.09.33.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:08 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 05/25] PCI: dwc: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:36 -0500 Message-Id: <20191028163256.8004-6-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the Designware host bridge to use the common pci_parse_request_of_pci_ranges(). Cc: Jingoo Han Cc: Gustavo Pimentel Cc: Lorenzo Pieralisi Cc: Andrew Murray Cc: Bjorn Helgaas Signed-off-by: Rob Herring --- .../pci/controller/dwc/pcie-designware-host.c | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 0f36a926059a..aeec8b65eb97 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -319,7 +319,7 @@ int dw_pcie_host_init(struct pcie_port *pp) struct device *dev = pci->dev; struct device_node *np = dev->of_node; struct platform_device *pdev = to_platform_device(dev); - struct resource_entry *win, *tmp; + struct resource_entry *win; struct pci_bus *child; struct pci_host_bridge *bridge; struct resource *cfg_res; @@ -342,31 +342,19 @@ int dw_pcie_host_init(struct pcie_port *pp) if (!bridge) return -ENOMEM; - ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &bridge->windows, &pp->io_base); - if (ret) - return ret; - - ret = devm_request_pci_bus_resources(dev, &bridge->windows); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); if (ret) return ret; /* Get the I/O and memory ranges from DT */ - resource_list_for_each_entry_safe(win, tmp, &bridge->windows) { + resource_list_for_each_entry(win, &bridge->windows) { switch (resource_type(win->res)) { case IORESOURCE_IO: - ret = devm_pci_remap_iospace(dev, win->res, - pp->io_base); - if (ret) { - dev_warn(dev, "Error %d: failed to map resource %pR\n", - ret, win->res); - resource_list_destroy_entry(win); - } else { - pp->io = win->res; - pp->io->name = "I/O"; - pp->io_size = resource_size(pp->io); - pp->io_bus_addr = pp->io->start - win->offset; - } + pp->io = win->res; + pp->io->name = "I/O"; + pp->io_size = resource_size(pp->io); + pp->io_bus_addr = pp->io->start - win->offset; + pp->io_base = pci_pio_to_address(pp->io->start); break; case IORESOURCE_MEM: pp->mem = win->res; From patchwork Mon Oct 28 16:32:37 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: 11215877 X-Patchwork-Delegate: geert@linux-m68k.org 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 A8168112B for ; Mon, 28 Oct 2019 16:33:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86FFC21783 for ; Mon, 28 Oct 2019 16:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280394; bh=dS4n6CynrIXPFBhhRc05NaVJSDLD6hCtFxVLRDtFz0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BI+8wtPct72aR7WSbNxUF563d8xuYKtTIsbGWzB44bqau4hbia+y9PC+6HpzhD19v NoD2cCBIAtqmifmzMgBWr5Pojzny7CA7ZzRk4wFemBvpe7PUwVYsYm3lBEAQ0gomuI iBPy4IX0s2r37ni1PEzl98Vj23/k2yPPu36D8plc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732983AbfJ1QdO (ORCPT ); Mon, 28 Oct 2019 12:33:14 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:37294 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdO (ORCPT ); Mon, 28 Oct 2019 12:33:14 -0400 Received: by mail-ot1-f66.google.com with SMTP id 53so7175096otv.4; Mon, 28 Oct 2019 09:33:13 -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=t7u4vSL0DP54jAwq/M7JASt/IhO5e5uqSLWCi0kiWfU=; b=aTLWCJBDyEOPqGoHFBk1nLnQBtxRoq733j7APdUJbg8p+vKnoyoe4UvnQBjIsF5Ogo mMV74RBzWv/UMvkBvAZr4PjUnNZ3W3OMieDhqMaCf+Z2p4l6eDskA2xexyyMIlr+XNbl 39I6kOOwlWwYF67IHeO11tdVDpLXhxRpam5TdOIgS0BH6t+dwGA6oY5Tbsba9q+6WXeP m9LMyNzFhyl8JAPTS5ktVct61yHUto7DP5GhMAZO8rtXrqlagS8/KSKThiCnLJLcKOPM Xsk81uTZmsf/Jp8Nddsa5A4EFOQgtQ6WdNu2wFMRigy/Bkz6vaD6WyvrSRwi2wIWD1J1 F1/g== X-Gm-Message-State: APjAAAWU38S4wipN5X6j7ZInSXC1B/sG6udy9S86q7lGmkGqgD2yB4wO JsqbbMfky89i8sZCdgx3zA== X-Google-Smtp-Source: APXvYqySAp0eSGQqHJLCI+ocWp45cw+8XpbJ73Hq5r/2RLRIlfj8dRzgqT5GxLaG1O+5Nr5aFn7huw== X-Received: by 2002:a9d:12f0:: with SMTP id g103mr8868885otg.219.1572280392987; Mon, 28 Oct 2019 09:33:12 -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 e186sm354991oia.47.2019.10.28.09.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:12 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 06/25] PCI: faraday: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:37 -0500 Message-Id: <20191028163256.8004-7-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the Faraday host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Reviewed-by: Andrew Murray Signed-off-by: Rob Herring Acked-by: Linus Walleij --- v2: - Remove temporary resource list --- drivers/pci/controller/pci-ftpci100.c | 51 ++++++--------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index bf5ece5d9291..75603348b88a 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c @@ -430,10 +430,8 @@ static int faraday_pci_probe(struct platform_device *pdev) const struct faraday_pci_variant *variant = of_device_get_match_data(dev); struct resource *regs; - resource_size_t io_base; struct resource_entry *win; struct faraday_pci *p; - struct resource *mem; struct resource *io; struct pci_host_bridge *host; struct clk *clk; @@ -441,7 +439,6 @@ static int faraday_pci_probe(struct platform_device *pdev) unsigned char cur_bus_speed = PCI_SPEED_33MHz; int ret; u32 val; - LIST_HEAD(res); host = devm_pci_alloc_host_bridge(dev, sizeof(*p)); if (!host) @@ -480,44 +477,20 @@ static int faraday_pci_probe(struct platform_device *pdev) if (IS_ERR(p->base)) return PTR_ERR(p->base); - ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &res, &io_base); + ret = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL); if (ret) return ret; - ret = devm_request_pci_bus_resources(dev, &res); - if (ret) - return ret; - - /* Get the I/O and memory ranges from DT */ - resource_list_for_each_entry(win, &res) { - switch (resource_type(win->res)) { - case IORESOURCE_IO: - io = win->res; - io->name = "Gemini PCI I/O"; - if (!faraday_res_to_memcfg(io->start - win->offset, - resource_size(io), &val)) { - /* setup I/O space size */ - writel(val, p->base + PCI_IOSIZE); - } else { - dev_err(dev, "illegal IO mem size\n"); - return -EINVAL; - } - ret = devm_pci_remap_iospace(dev, io, io_base); - if (ret) { - dev_warn(dev, "error %d: failed to map resource %pR\n", - ret, io); - continue; - } - break; - case IORESOURCE_MEM: - mem = win->res; - mem->name = "Gemini PCI MEM"; - break; - case IORESOURCE_BUS: - break; - default: - break; + win = resource_list_first_type(&host->windows, IORESOURCE_IO); + if (win) { + io = win->res; + if (!faraday_res_to_memcfg(io->start - win->offset, + resource_size(io), &val)) { + /* setup I/O space size */ + writel(val, p->base + PCI_IOSIZE); + } else { + dev_err(dev, "illegal IO mem size\n"); + return -EINVAL; } } @@ -569,7 +542,6 @@ static int faraday_pci_probe(struct platform_device *pdev) if (ret) return ret; - list_splice_init(&res, &host->windows); ret = pci_scan_root_bus_bridge(host); if (ret) { dev_err(dev, "failed to scan host: %d\n", ret); @@ -581,7 +553,6 @@ static int faraday_pci_probe(struct platform_device *pdev) pci_bus_assign_resources(p->bus); pci_bus_add_devices(p->bus); - pci_free_resource_list(&res); return 0; } From patchwork Mon Oct 28 16:32:38 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: 11215881 X-Patchwork-Delegate: geert@linux-m68k.org 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 91B3915AB for ; Mon, 28 Oct 2019 16:33:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7053D21783 for ; Mon, 28 Oct 2019 16:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280396; bh=3yur8OkwHVSAWDlo7ZPggQVUJ2T55/f0kNsJE4b/Ta0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EqQfcSeWkCw69s4tQ8Kn8/SvAP2pHZOG5h+cYPMw28EMeklYcnGRtReA+sdSfwXuZ zmH0aJvxFSgOM+SnKDrXYmdVm1t75f1Tzr7P/lj3KYGENEOuWrzqoV43pH4ksq2dBq gYcIHD7XrZqVBbd6VL4XITEDwjWfHOOTCGS5hW4I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732989AbfJ1QdQ (ORCPT ); Mon, 28 Oct 2019 12:33:16 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:46655 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdQ (ORCPT ); Mon, 28 Oct 2019 12:33:16 -0400 Received: by mail-oi1-f194.google.com with SMTP id c2so6374691oic.13; Mon, 28 Oct 2019 09:33:15 -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=YIfpHXHDoS6BpoLM/5OtgGD1veZ0kiS1z+l67O5mhv0=; b=stzsuHe0hPWnVaIAsKn2V+F0fPyQG0OsT9ESdLuEXD9EvkfFGrMp1tExIVWfoHsuyS Cz6Rsqr37WOMy7+FA0/3dlpQgegXOobsx1Kb33iUKQmBuuxxWVaLoSGMszthaF3vdD6f aG2ombLVT4xf1PXRCDacLMvGadfIT2zOt3wVyHvJ0MFrGhsa/TJqaeM2a3kuozahWrYa nHtS/f+qntrT9PSjUpoSrKyjjxIlPE/bvqKLL0KOt5aDUKJwPHBRgLJfAb3RtteS/rNb BPB2WPeGkMv0wRk7F1d6DOcMsg+tW6axxB4yQHcJ6pRbOy7CLwD4/KPlPM+8TtlPBOSO BkPw== X-Gm-Message-State: APjAAAVeuMpXhuq0F9ibUKqJif9vaOK+AAhQQfIGQ3ZLZEy43ony2jT0 uNHZkxFhPCuH2ftFoXg+hQ== X-Google-Smtp-Source: APXvYqwiII4tT6mUV/WZPdOOYCJP3razv09fHNkFp9JLAVkZPyu7pCRKafjRWtkftQVgR7SzFninKQ== X-Received: by 2002:aca:494e:: with SMTP id w75mr95048oia.159.1572280394774; Mon, 28 Oct 2019 09:33:14 -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 e186sm354991oia.47.2019.10.28.09.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:14 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 07/25] PCI: iproc: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:38 -0500 Message-Id: <20191028163256.8004-8-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the iProc host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list, so just use bridge->windows directly. Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Ray Jui Cc: Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com Reviewed-by: Andrew Murray Signed-off-by: Rob Herring --- drivers/pci/controller/pcie-iproc-platform.c | 8 ++------ drivers/pci/controller/pcie-iproc.c | 5 ----- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc-platform.c b/drivers/pci/controller/pcie-iproc-platform.c index 9ee6200a66f4..375d815f7301 100644 --- a/drivers/pci/controller/pcie-iproc-platform.c +++ b/drivers/pci/controller/pcie-iproc-platform.c @@ -43,8 +43,6 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) struct iproc_pcie *pcie; struct device_node *np = dev->of_node; struct resource reg; - resource_size_t iobase = 0; - LIST_HEAD(resources); struct pci_host_bridge *bridge; int ret; @@ -97,8 +95,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) if (IS_ERR(pcie->phy)) return PTR_ERR(pcie->phy); - ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &resources, - &iobase); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); if (ret) { dev_err(dev, "unable to get PCI host bridge resources\n"); return ret; @@ -113,10 +110,9 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) pcie->map_irq = of_irq_parse_and_map_pci; } - ret = iproc_pcie_setup(pcie, &resources); + ret = iproc_pcie_setup(pcie, &bridge->windows); if (ret) { dev_err(dev, "PCIe controller setup failed\n"); - pci_free_resource_list(&resources); return ret; } diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index 2d457bfdaf66..223335ee791a 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -1498,10 +1498,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) return ret; } - ret = devm_request_pci_bus_resources(dev, res); - if (ret) - return ret; - ret = phy_init(pcie->phy); if (ret) { dev_err(dev, "unable to initialize PCIe PHY\n"); @@ -1543,7 +1539,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) if (iproc_pcie_msi_enable(pcie)) dev_info(dev, "not using iProc MSI\n"); - list_splice_init(res, &host->windows); host->busnr = 0; host->dev.parent = dev; host->ops = &iproc_pcie_ops; From patchwork Mon Oct 28 16:32:39 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: 11215885 X-Patchwork-Delegate: geert@linux-m68k.org 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 3B50B112B for ; Mon, 28 Oct 2019 16:33:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1946320717 for ; Mon, 28 Oct 2019 16:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280398; bh=IMSr0RyS9+WQjEjlN7b4FvbrGHhi/z/rsDLJ9jsYUpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dNHYsD9aGchuqIzq5doINayfDzs1KtY3arqC5jM80dd5e7jHR8VfjEOI8NHncYRbc foLUK/Kq9C0gaDl1hFLNpnMJUYnnhp0mW361dcR2GqoYgX3Tfg7Jet9SPLsitpWGVu BYoz7k2ZyabzWHgT6brpSvbVaIngzxfb2kHARJas= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733003AbfJ1QdR (ORCPT ); Mon, 28 Oct 2019 12:33:17 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:43694 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdR (ORCPT ); Mon, 28 Oct 2019 12:33:17 -0400 Received: by mail-ot1-f67.google.com with SMTP id b19so4818117otq.10; Mon, 28 Oct 2019 09:33:17 -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=nW63jMBvuV1jC5LkGgClq/3WYdWidZxNV+2Nh/Z21ew=; b=f6XhQb2bSUfm18KtdF56KNSGD+GSK3K1d917LJxutPKxPEdy//xh1lrlFdjw5vlqoa 6Nf5qxaG/q8fZFHTGaoEjSjTReI+MK/TD0nWDmmnjxlKSN5FxYrALrNjhuwMJg2KG2hG bEelCgHDfiNn5OO6+13gl8GanxG2KhIZ9yde9+AhNRZDsFoxCX8dNvuiiOtTdHDU0qbE QDlM9tltmudzpG04uWqwgqOINZqXdgWyVuVUzjAgfayw+2yFFCYRB6rESthPKuxjjfIr vmVqxNYr8bwR5T/uJBUKh5ORQhWyKIM4mzPe5s3YLBtKedllgJDewO7H2qHSPZtpN/sE lzqg== X-Gm-Message-State: APjAAAXgC33ew7oTd9qQCJglazvYM7yoOJPXxqlgLcmoCwMi3KgYB1/D LU2a9GQ2RwpmhJpQP/+05g== X-Google-Smtp-Source: APXvYqxhr3QGGC8pHRguZ0KGcav4CFccx7LcyeEsqrM8IAog45S1MROIl6X64sUTv9Rs+FE/3FigSg== X-Received: by 2002:a05:6830:1695:: with SMTP id k21mr11501497otr.339.1572280396672; Mon, 28 Oct 2019 09:33:16 -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 e186sm354991oia.47.2019.10.28.09.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:16 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 08/25] PCI: mediatek: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:39 -0500 Message-Id: <20191028163256.8004-9-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Andrew Murray Signed-off-by: Rob Herring --- v2: - Use resource_list_get_entry_of_type --- drivers/pci/controller/pcie-mediatek.c | 43 ++++++++------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 626a7c352dfd..d9206a3cd56b 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -216,7 +216,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; @@ -661,11 +660,19 @@ 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; + entry = resource_list_first_type(&host->windows, IORESOURCE_MEM); + if (entry) + mem = entry->res; + 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); @@ -1023,39 +1030,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 Mon Oct 28 16:32:40 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: 11215889 X-Patchwork-Delegate: geert@linux-m68k.org 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 DD4D0112B for ; Mon, 28 Oct 2019 16:33:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC8EF21744 for ; Mon, 28 Oct 2019 16:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280405; bh=PjVSZr4+LdZPTMnRnHfY4lW+YoqQ56WIPrBcw6/Ji+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zL5k/pHVquWcviJUfCQza+wuxW9ieqUZTeqkamcT4f+c6QA6uVVOggKRzjz8wB7EK lZPAP0KX6T5MnwrQ2oyA+7Yp9s/4LPNpH6Mrucq9y0NpsXyY5A1YuEHCi7Ww64plGl DPSA/b7OB70vlWBvmxMOSze2qKpB+eAQRrHgNWhk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733039AbfJ1QdZ (ORCPT ); Mon, 28 Oct 2019 12:33:25 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:38602 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdZ (ORCPT ); Mon, 28 Oct 2019 12:33:25 -0400 Received: by mail-ot1-f68.google.com with SMTP id r14so2410533otn.5; Mon, 28 Oct 2019 09:33:23 -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=jpXNezTP5UvZxbHA0+iXw/Wyg2v2rsj1FOMQAqAf0GA=; b=YSCbvu6Iw14o7dN6JJ6bXZLXrFQFFw1OW1a6+obZZHunlx7fqTolBGHvFO1jTpnDjW QFFEssGvGI9KwUBnrhCYPEJi1CxqcXDh7JRcfzM8/0XfbGJjokbK0A2fDQmlG95bwjGI h4efSEzxONGpss3LaRLJJDznPABFov28E2Y/k76Jm3b/jBWZf2zLHqyxXZ6dfD2fl3AR GYuHzZI81Y9YQdv25P0KTeTBAxdsA2wnm8Fon0z3El59/4nqF/IXsJnSo3Wp/UAIQU1o +u5OEWZNeMuu28q7DycIHLh0xsS73ar2jG1lFKxkmbe3CXHBG1ROz4U4UYWB5ihS4CO1 QuEQ== X-Gm-Message-State: APjAAAWyG9O/+5Z0NyES7K66UdQ1kZJ/WVo5XHeTXtoHzx1Ebbrk1fqK fIkg8SHJf8NmVQwG+nUY4g== X-Google-Smtp-Source: APXvYqyZIopRAOsgl1zOiXPaW3NtAzvxCuMWMSKxbNh5hFsWDE5ZO6FPWFVruCMbxopnZvC3XLssnA== X-Received: by 2002:a9d:66e:: with SMTP id 101mr14345496otn.51.1572280403122; Mon, 28 Oct 2019 09:33:23 -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 e186sm354991oia.47.2019.10.28.09.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:18 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 09/25] PCI: mobiveil: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:40 -0500 Message-Id: <20191028163256.8004-10-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the Mobiveil host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Cc: Karthikeyan Mitran Cc: Hou Zhiqiang Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Reviewed-by: Andrew Murray Signed-off-by: Rob Herring Reviewed-by: Hou Zhiqiang --- drivers/pci/controller/pcie-mobiveil.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c index a45a6447b01d..4eab8624ce4d 100644 --- a/drivers/pci/controller/pcie-mobiveil.c +++ b/drivers/pci/controller/pcie-mobiveil.c @@ -140,7 +140,6 @@ struct mobiveil_msi { /* MSI information */ struct mobiveil_pcie { struct platform_device *pdev; - struct list_head resources; void __iomem *config_axi_slave_base; /* endpoint config base */ void __iomem *csr_axi_slave_base; /* root port config base */ void __iomem *apb_csr_base; /* MSI register base */ @@ -575,6 +574,7 @@ static void mobiveil_pcie_enable_msi(struct mobiveil_pcie *pcie) static int mobiveil_host_init(struct mobiveil_pcie *pcie) { + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); u32 value, pab_ctrl, type; struct resource_entry *win; @@ -631,7 +631,7 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie) program_ib_windows(pcie, WIN_NUM_0, 0, 0, MEM_WINDOW_TYPE, IB_WIN_SIZE); /* Get the I/O and memory ranges from DT */ - resource_list_for_each_entry(win, &pcie->resources) { + resource_list_for_each_entry(win, &bridge->windows) { if (resource_type(win->res) == IORESOURCE_MEM) type = MEM_WINDOW_TYPE; else if (resource_type(win->res) == IORESOURCE_IO) @@ -857,7 +857,6 @@ static int mobiveil_pcie_probe(struct platform_device *pdev) struct pci_bus *child; struct pci_host_bridge *bridge; struct device *dev = &pdev->dev; - resource_size_t iobase; int ret; /* allocate the PCIe port */ @@ -875,11 +874,8 @@ static int mobiveil_pcie_probe(struct platform_device *pdev) return ret; } - INIT_LIST_HEAD(&pcie->resources); - /* 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); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); if (ret) { dev_err(dev, "Getting bridge resources failed\n"); return ret; @@ -892,24 +888,19 @@ static int mobiveil_pcie_probe(struct platform_device *pdev) ret = mobiveil_host_init(pcie); if (ret) { dev_err(dev, "Failed to initialize host\n"); - goto error; + return ret; } /* initialize the IRQ domains */ ret = mobiveil_pcie_init_irq_domain(pcie); if (ret) { dev_err(dev, "Failed creating IRQ Domain\n"); - goto error; + return ret; } irq_set_chained_handler_and_data(pcie->irq, mobiveil_pcie_isr, pcie); - ret = devm_request_pci_bus_resources(dev, &pcie->resources); - if (ret) - goto error; - /* Initialize bridge */ - list_splice_init(&pcie->resources, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr = pcie->root_bus_nr; @@ -920,13 +911,13 @@ static int mobiveil_pcie_probe(struct platform_device *pdev) ret = mobiveil_bringup_link(pcie); if (ret) { dev_info(dev, "link bring-up failed\n"); - goto error; + return ret; } /* setup the kernel resources for the newly added PCIe root bus */ ret = pci_scan_root_bus_bridge(bridge); if (ret) - goto error; + return ret; bus = bridge->bus; @@ -936,9 +927,6 @@ static int mobiveil_pcie_probe(struct platform_device *pdev) pci_bus_add_devices(bus); return 0; -error: - pci_free_resource_list(&pcie->resources); - return ret; } static const struct of_device_id mobiveil_pcie_of_match[] = { From patchwork Mon Oct 28 16:32:41 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: 11215895 X-Patchwork-Delegate: geert@linux-m68k.org 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 7AF0715AB for ; Mon, 28 Oct 2019 16:33:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A28421783 for ; Mon, 28 Oct 2019 16:33:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280407; bh=tAAPNJlYS0DDhh98DvqvVX5PV7L7vIdQ4vqDZURslzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1ijWxpuxRUcKew/E6KLmEWhYWwHh/G6tPb/s1w6WN8P2jdQI/VAf6LX4vAHCA4CKC hj8dIA6CNtX9jEvEpzouOcgfRg1y37tz/A8Vxo9Gi8oyh6ACmE/1S6ECqgOwj9oyx1 NU5XtasStOUbJDRKqJTIXVuyU32gaNcDK3oVlTtE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390952AbfJ1Qd1 (ORCPT ); Mon, 28 Oct 2019 12:33:27 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:39713 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1Qd0 (ORCPT ); Mon, 28 Oct 2019 12:33:26 -0400 Received: by mail-ot1-f67.google.com with SMTP id t8so1057690otl.6; Mon, 28 Oct 2019 09:33:26 -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=UQELiRn8smL2MOEFvRnPKMmMFHFucEfGLFrEDxdYNq4=; b=UVdpvwy+o9xJXYZXPnPG1X5M5KxjVypDZemg7Dmiyt4Wvp1GGGBKLxIOga8SX8WK7C gnSD/JImbkPnQD8kxrosxpnOImFfkK/l2RFLzeC+dSdzeeUCHOfqaphOoVBKw06VJimW +rSxJXeWNV3fvt6WrEAoQshRJ9Kf0/wFqIIbgxM8m/58bYT4+glQVjq+Vdj6MxpAzFFo /+p7TsPYnrgXF/3/FhIsDabywbTFus+nDKp53r/8SRmJOIzwlRWyaPGgaC5Ckt42z7cu eS4e29V3IIh4RxKLgysTL+G66tSGTax87DoP8zeiUS74g8c7+WqfQYgLiNEGXZ/LOZZG Pheg== X-Gm-Message-State: APjAAAULjLJGjf8o4eFSS4PyG3XNCBGT3bnysUsA7zhSfunIqI5etKl/ pYjwaMl7axIs2G4/fxJMpw== X-Google-Smtp-Source: APXvYqxANS1ZRPDmSCLwaC+UqaafEyt/CiqCsmPHYvwIXbkeNI6RQdz0pkv8fwvcQOzI5WjkAX10Vw== X-Received: by 2002:a9d:7cc6:: with SMTP id r6mr1731281otn.235.1572280405492; Mon, 28 Oct 2019 09:33:25 -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 e186sm354991oia.47.2019.10.28.09.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:24 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 10/25] PCI: rockchip: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:41 -0500 Message-Id: <20191028163256.8004-11-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the Rockchip host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Cc: Shawn Lin Cc: Lorenzo Pieralisi Cc: Andrew Murray Cc: Bjorn Helgaas Cc: Heiko Stuebner Cc: linux-rockchip@lists.infradead.org Signed-off-by: Rob Herring --- drivers/pci/controller/pcie-rockchip-host.c | 36 ++++----------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index ef8e677ce9d1..8d2e6f2e141e 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -950,14 +950,10 @@ static int rockchip_pcie_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct pci_bus *bus, *child; struct pci_host_bridge *bridge; + struct resource *bus_res; struct resource_entry *win; - resource_size_t io_base; - struct resource *mem; - struct resource *io; int err; - LIST_HEAD(res); - if (!dev->of_node) return -ENODEV; @@ -995,29 +991,20 @@ static int rockchip_pcie_probe(struct platform_device *pdev) if (err < 0) goto err_deinit_port; - err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &res, &io_base); + err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, &bus_res); if (err) goto err_remove_irq_domain; - err = devm_request_pci_bus_resources(dev, &res); - if (err) - goto err_free_res; + rockchip->root_bus_nr = bus_res->start; /* Get the I/O and memory ranges from DT */ - resource_list_for_each_entry(win, &res) { + resource_list_for_each_entry(win, &bridge->windows) { switch (resource_type(win->res)) { case IORESOURCE_IO: io = win->res; io->name = "I/O"; rockchip->io_size = resource_size(io); rockchip->io_bus_addr = io->start - win->offset; - err = pci_remap_iospace(io, io_base); - if (err) { - dev_warn(dev, "error %d: failed to map resource %pR\n", - err, io); - continue; - } rockchip->io = io; break; case IORESOURCE_MEM: @@ -1026,9 +1013,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) rockchip->mem_size = resource_size(mem); rockchip->mem_bus_addr = mem->start - win->offset; break; - case IORESOURCE_BUS: - rockchip->root_bus_nr = win->res->start; - break; default: continue; } @@ -1036,15 +1020,14 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err = rockchip_pcie_cfg_atu(rockchip); if (err) - goto err_unmap_iospace; + goto err_remove_irq_domain; rockchip->msg_region = devm_ioremap(dev, rockchip->msg_bus_addr, SZ_1M); if (!rockchip->msg_region) { err = -ENOMEM; - goto err_unmap_iospace; + goto err_remove_irq_domain; } - list_splice_init(&res, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = rockchip; bridge->busnr = 0; @@ -1054,7 +1037,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err = pci_scan_root_bus_bridge(bridge); if (err < 0) - goto err_unmap_iospace; + goto err_remove_irq_domain; bus = bridge->bus; @@ -1068,10 +1051,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) pci_bus_add_devices(bus); return 0; -err_unmap_iospace: - pci_unmap_iospace(rockchip->io); -err_free_res: - pci_free_resource_list(&res); err_remove_irq_domain: irq_domain_remove(rockchip->irq_domain); err_deinit_port: @@ -1097,7 +1076,6 @@ static int rockchip_pcie_remove(struct platform_device *pdev) pci_stop_root_bus(rockchip->root_bus); pci_remove_root_bus(rockchip->root_bus); - pci_unmap_iospace(rockchip->io); irq_domain_remove(rockchip->irq_domain); rockchip_pcie_deinit_phys(rockchip); From patchwork Mon Oct 28 16:32:42 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: 11215899 X-Patchwork-Delegate: geert@linux-m68k.org 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 9B9DE112B for ; Mon, 28 Oct 2019 16:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79DE8217D6 for ; Mon, 28 Oct 2019 16:33:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280411; bh=4tljSz6Cttha9yUxptATUyJwV2x2mQBrbEuOarwNpC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HsA3YN3hLi2P9KFrceCIXvoe4QfjTGdcs+vKK4+3fjtj9NWjuc2plB5fLRTlvmUx8 NzxERt3zPYT47Pz8TmS1G2CFi7D9kBdEPkIu3RW49T6RzRWsAA1KlTs2AgGgLFQMUP cDT367knT5fD+npnJfXTnCeiGd4YCOiy9/93DhWs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390977AbfJ1Qdb (ORCPT ); Mon, 28 Oct 2019 12:33:31 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:43711 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1Qdb (ORCPT ); Mon, 28 Oct 2019 12:33:31 -0400 Received: by mail-ot1-f67.google.com with SMTP id b19so4818710otq.10; Mon, 28 Oct 2019 09:33:29 -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=iYotT8vplUpPAxDBkQ4PaMlGqTylW6sNvKndwgHpCIU=; b=OHrOy/A11V6ZOaf4fadHDh57LDaKgD1clilROMrWOPe70OeMgFPqTryvWyDt8upMnL 5WZSSsvxzLclhHJtdqygenZ3WynSGFkFKMQHGif90kxsI1ICzRqIGFocFLmbojZUUmcN 0CHWd4CHn/Wwq2lAkLVR/gEU6UOPuf8Vcne3bUGPLRt7A0PwwRi6IHN+0801vkEY48/l esd+Ww2gNDin7YzMuW0cdKwtZ3Ou01G8TMZCawCHfGt+2Wg5NEDhDQlaaH+ReR2w2Qz6 aWBjcJJPouEKbr8J9DTjs4Zloi4kvIT0fprhCzvCS2DLN9FrZZkFS+LL5GFX6jGTnLBe 49XA== X-Gm-Message-State: APjAAAW3glbnCEbHtwK7jkhxocN4XIIe0FdXU60xk1dGwLaiQXvQMjEz LJwg2iVgBI91qaCB7egnjJNZsuA= X-Google-Smtp-Source: APXvYqy+uBASJDG3rPdo2O4wCkiHo4NzLsXE1unvcdols14xzwz4puZsL1iBoWYniAt7v02TGXZGNw== X-Received: by 2002:a9d:3e53:: with SMTP id h19mr8986935otg.98.1572280408846; Mon, 28 Oct 2019 09:33:28 -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 e186sm354991oia.47.2019.10.28.09.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:26 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 11/25] PCI: rockchip: Drop storing driver private outbound resource data Date: Mon, 28 Oct 2019 11:32:42 -0500 Message-Id: <20191028163256.8004-12-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The Rockchip host bridge driver doesn't need to store outboard resources in its private struct as they are already stored in struct pci_host_bridge. Cc: Shawn Lin Cc: Lorenzo Pieralisi Cc: Andrew Murray Cc: Bjorn Helgaas Cc: Heiko Stuebner Cc: linux-rockchip@lists.infradead.org Signed-off-by: Rob Herring --- drivers/pci/controller/pcie-rockchip-host.c | 54 +++++++++------------ drivers/pci/controller/pcie-rockchip.h | 5 -- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index 8d2e6f2e141e..f375e55ea02e 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -806,19 +806,28 @@ static int rockchip_pcie_prog_ib_atu(struct rockchip_pcie *rockchip, static int rockchip_pcie_cfg_atu(struct rockchip_pcie *rockchip) { struct device *dev = rockchip->dev; + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(rockchip); + struct resource_entry *entry; + u64 pci_addr, size; int offset; int err; int reg_no; rockchip_pcie_cfg_configuration_accesses(rockchip, AXI_WRAPPER_TYPE0_CFG); + entry = resource_list_first_type(&bridge->windows, IORESOURCE_MEM); + if (!entry) + return -ENODEV; + + size = resource_size(entry->res); + pci_addr = entry->res->start - entry->offset; + rockchip->msg_bus_addr = pci_addr; - for (reg_no = 0; reg_no < (rockchip->mem_size >> 20); reg_no++) { + for (reg_no = 0; reg_no < (size >> 20); reg_no++) { err = rockchip_pcie_prog_ob_atu(rockchip, reg_no + 1, AXI_WRAPPER_MEM_WRITE, 20 - 1, - rockchip->mem_bus_addr + - (reg_no << 20), + pci_addr + (reg_no << 20), 0); if (err) { dev_err(dev, "program RC mem outbound ATU failed\n"); @@ -832,14 +841,20 @@ static int rockchip_pcie_cfg_atu(struct rockchip_pcie *rockchip) return err; } - offset = rockchip->mem_size >> 20; - for (reg_no = 0; reg_no < (rockchip->io_size >> 20); reg_no++) { + entry = resource_list_first_type(&bridge->windows, IORESOURCE_IO); + if (!entry) + return -ENODEV; + + size = resource_size(entry->res); + pci_addr = entry->res->start - entry->offset; + + offset = size >> 20; + for (reg_no = 0; reg_no < (size >> 20); reg_no++) { err = rockchip_pcie_prog_ob_atu(rockchip, reg_no + 1 + offset, AXI_WRAPPER_IO_WRITE, 20 - 1, - rockchip->io_bus_addr + - (reg_no << 20), + pci_addr + (reg_no << 20), 0); if (err) { dev_err(dev, "program RC io outbound ATU failed\n"); @@ -852,8 +867,7 @@ static int rockchip_pcie_cfg_atu(struct rockchip_pcie *rockchip) AXI_WRAPPER_NOR_MSG, 20 - 1, 0, 0); - rockchip->msg_bus_addr = rockchip->mem_bus_addr + - ((reg_no + offset) << 20); + rockchip->msg_bus_addr += ((reg_no + offset) << 20); return err; } @@ -951,7 +965,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) struct pci_bus *bus, *child; struct pci_host_bridge *bridge; struct resource *bus_res; - struct resource_entry *win; int err; if (!dev->of_node) @@ -997,27 +1010,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) rockchip->root_bus_nr = bus_res->start; - /* Get the I/O and memory ranges from DT */ - resource_list_for_each_entry(win, &bridge->windows) { - switch (resource_type(win->res)) { - case IORESOURCE_IO: - io = win->res; - io->name = "I/O"; - rockchip->io_size = resource_size(io); - rockchip->io_bus_addr = io->start - win->offset; - rockchip->io = io; - break; - case IORESOURCE_MEM: - mem = win->res; - mem->name = "MEM"; - rockchip->mem_size = resource_size(mem); - rockchip->mem_bus_addr = mem->start - win->offset; - break; - default: - continue; - } - } - err = rockchip_pcie_cfg_atu(rockchip); if (err) goto err_remove_irq_domain; diff --git a/drivers/pci/controller/pcie-rockchip.h b/drivers/pci/controller/pcie-rockchip.h index 8e87a059ce73..bef42a803b56 100644 --- a/drivers/pci/controller/pcie-rockchip.h +++ b/drivers/pci/controller/pcie-rockchip.h @@ -304,13 +304,8 @@ struct rockchip_pcie { struct irq_domain *irq_domain; int offset; struct pci_bus *root_bus; - struct resource *io; - phys_addr_t io_bus_addr; - u32 io_size; void __iomem *msg_region; - u32 mem_size; phys_addr_t msg_bus_addr; - phys_addr_t mem_bus_addr; bool is_rc; struct resource *mem_res; }; From patchwork Mon Oct 28 16:32:43 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: 11215905 X-Patchwork-Delegate: geert@linux-m68k.org 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 109F615AB for ; Mon, 28 Oct 2019 16:33:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E320321744 for ; Mon, 28 Oct 2019 16:33:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280413; bh=A4hW5EFnuavIhuNVbfQNKc6v8KyKkpk0J9Ki/goHbD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nFtp3ye3/4lCcax20FWPuMrMoixxcYQU1DGuCOcqUUi6N4YXHuCrQrG5IclWP2s3f Sl1b9maxZIbrTiGzf9w2uMEwqTaR87SlT0D6GnKycTGjbLN+QYJpr5cVamMP96mzjz vTHkaRHBGOjbKYadLfK9xBFpOF0tXX5gz3qB3xbY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391003AbfJ1Qdc (ORCPT ); Mon, 28 Oct 2019 12:33:32 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:40578 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1Qdc (ORCPT ); Mon, 28 Oct 2019 12:33:32 -0400 Received: by mail-ot1-f68.google.com with SMTP id d8so7161239otc.7; Mon, 28 Oct 2019 09:33:31 -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=mxMsu5buQ7iHumyqQOK7pePSEYHVrJpDScdqrZRoUwA=; b=eSRpAyN4ijakW4DI9taAz4SeK5h/wZDh5vsH61Jxl/BURZuh6q9FrIgofiHb2cgyOX YV9gE+r5vjp8vpQOoocIr2MIfOm3EbfoqfKzfonVOiEt2//dP8wUFxFUEO3ICwFk0Bs3 lM84V/wn616CS73lvHsfqUuJrBCsr80U+zgZW9tP2d+g/4ESTqQwDORXtbtvXqEkGRXk RuyXRwUQtd+1QCCGYmqifYydw0NOd+dzAf2s2soQ2mY5b2ciNdIYYnKnyXN+p7dqvJH2 zzDylGDCJW723SvzQgdZVpPUJjAs90LjmVOiY3GYMy96K06hySf1hx+7m5IHpbEYmDFx 2sZQ== X-Gm-Message-State: APjAAAW2F2a+VaaF8q16E9xSFVglJz/PKUS3wPhb30Ui2PivvDb4oM2E X+JCZX1qMP9+6oNOZ7W16Q== X-Google-Smtp-Source: APXvYqxOkIeS4BmL7xvWW0X3OFJHqHE79e6/UgYAXh9+BdleE4h11RfX6HaRFlUyGOi9IbQqg7eeRw== X-Received: by 2002:a9d:4616:: with SMTP id y22mr13799435ote.319.1572280411103; Mon, 28 Oct 2019 09:33:31 -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 e186sm354991oia.47.2019.10.28.09.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:30 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 12/25] PCI: v3-semi: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:43 -0500 Message-Id: <20191028163256.8004-13-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert V3 host bridge to use the common pci_parse_request_of_pci_ranges(). Cc: Lorenzo Pieralisi Cc: Andrew Murray Cc: Bjorn Helgaas Acked-by: Linus Walleij Signed-off-by: Rob Herring --- drivers/pci/controller/pci-v3-semi.c | 35 +++++----------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c index d219404bad92..96677520f6c1 100644 --- a/drivers/pci/controller/pci-v3-semi.c +++ b/drivers/pci/controller/pci-v3-semi.c @@ -241,10 +241,8 @@ struct v3_pci { void __iomem *config_base; struct pci_bus *bus; u32 config_mem; - u32 io_mem; u32 non_pre_mem; u32 pre_mem; - phys_addr_t io_bus_addr; phys_addr_t non_pre_bus_addr; phys_addr_t pre_bus_addr; struct regmap *map; @@ -520,35 +518,22 @@ static int v3_integrator_init(struct v3_pci *v3) } static int v3_pci_setup_resource(struct v3_pci *v3, - resource_size_t io_base, struct pci_host_bridge *host, struct resource_entry *win) { struct device *dev = v3->dev; struct resource *mem; struct resource *io; - int ret; switch (resource_type(win->res)) { case IORESOURCE_IO: io = win->res; - io->name = "V3 PCI I/O"; - v3->io_mem = io_base; - v3->io_bus_addr = io->start - win->offset; - dev_dbg(dev, "I/O window %pR, bus addr %pap\n", - io, &v3->io_bus_addr); - ret = devm_pci_remap_iospace(dev, io, io_base); - if (ret) { - dev_warn(dev, - "error %d: failed to map resource %pR\n", - ret, io); - return ret; - } + /* Setup window 2 - PCI I/O */ - writel(v3_addr_to_lb_base2(v3->io_mem) | + writel(v3_addr_to_lb_base2(pci_pio_to_address(io->start)) | V3_LB_BASE2_ENABLE, v3->base + V3_LB_BASE2); - writew(v3_addr_to_lb_map2(v3->io_bus_addr), + writew(v3_addr_to_lb_map2(io->start - win->offset), v3->base + V3_LB_MAP2); break; case IORESOURCE_MEM: @@ -732,7 +717,6 @@ static int v3_pci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - resource_size_t io_base; struct resource *regs; struct resource_entry *win; struct v3_pci *v3; @@ -741,7 +725,6 @@ static int v3_pci_probe(struct platform_device *pdev) u16 val; int irq; int ret; - LIST_HEAD(res); host = pci_alloc_host_bridge(sizeof(*v3)); if (!host) @@ -793,12 +776,7 @@ static int v3_pci_probe(struct platform_device *pdev) if (IS_ERR(v3->config_base)) return PTR_ERR(v3->config_base); - ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res, - &io_base); - if (ret) - return ret; - - ret = devm_request_pci_bus_resources(dev, &res); + ret = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL); if (ret) return ret; @@ -852,8 +830,8 @@ static int v3_pci_probe(struct platform_device *pdev) writew(val, v3->base + V3_PCI_CMD); /* Get the I/O and memory ranges from DT */ - resource_list_for_each_entry(win, &res) { - ret = v3_pci_setup_resource(v3, io_base, host, win); + resource_list_for_each_entry(win, &host->windows) { + ret = v3_pci_setup_resource(v3, host, win); if (ret) { dev_err(dev, "error setting up resources\n"); return ret; @@ -931,7 +909,6 @@ static int v3_pci_probe(struct platform_device *pdev) val |= V3_SYSTEM_M_LOCK; writew(val, v3->base + V3_SYSTEM); - list_splice_init(&res, &host->windows); ret = pci_scan_root_bus_bridge(host); if (ret) { dev_err(dev, "failed to register host: %d\n", ret); From patchwork Mon Oct 28 16:32:44 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: 11215911 X-Patchwork-Delegate: geert@linux-m68k.org 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 A192D112B for ; Mon, 28 Oct 2019 16:33:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7633E20717 for ; Mon, 28 Oct 2019 16:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280415; bh=k3cQBblYJI8iKFm+Gvau7B81PRNZI/26LkGIH4QjILU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hK7Ighh0wjfmj8J25GDzrlK1Ut+B6RcAeUkvfRhdcpaSz4XQBceENcmnw+6h4HDaD 7uqEgIUHZdtdCfuf2qdYnhJdD54Fz64uyS89SSWT6+lvceFGila5KyiiQuf4m9P1uR ejE1zEGUtMwzvIWnJJvF1HkiJKAeBMM8EBk+tV9k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391004AbfJ1Qdf (ORCPT ); Mon, 28 Oct 2019 12:33:35 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:41902 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1Qdf (ORCPT ); Mon, 28 Oct 2019 12:33:35 -0400 Received: by mail-ot1-f68.google.com with SMTP id 94so7158346oty.8; Mon, 28 Oct 2019 09:33:33 -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=CisDLS5VrA+U+bZNmYu5E2eTsV9z7wFBG7PuQ0y9mkk=; b=rDqZ9iSP8Pw74IhX51q/bDopZbFBlnL9NPwbP12FJGfVnqU6BOQUPWx34YSttkfPNH 7q/W54RbsHUBb+Rz4rWFk7Hbz0F9ugrGe/EDPtmukl42Sn16XXjNew9zqO1ijW6rd6d7 6Xok5YpKVrtTVIipdjBGubwbafSUR41pQ0V7oJyLBUGDdxpGL877Fh6sVh2pfxErUzJr R2FikklGw/ZVMVJG9iC0+zziCuZBSKzYDbK0G9NuSMi8STm/Pel/DbgrIxw9RECuJZ3m YKy1Xc71QEn5EsxY0M2stU7u2IC42Rv7UjzEnS8YmrjhqjwN/Vd/0wa50rmJD1B8naTD jDoQ== X-Gm-Message-State: APjAAAWppNx8J6i4PMEPFIaRV0I8B5cE1Fm3gUktTFgQmskUmfZVC8Sg YsTioAoke4KNjReCh9LTVA== X-Google-Smtp-Source: APXvYqwper22ZlXJg5DpAImWRJ7XDe4KFfYVSvi7Voqzg2ZZ1EXILmDbsGSK9WJ1OuRTtjJ3T24mQQ== X-Received: by 2002:a9d:6c57:: with SMTP id g23mr463092otq.149.1572280413138; Mon, 28 Oct 2019 09:33: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 e186sm354991oia.47.2019.10.28.09.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:32 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 13/25] PCI: xgene: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:44 -0500 Message-Id: <20191028163256.8004-14-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the xgene host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Cc: Toan Le Cc: Lorenzo Pieralisi Cc: Andrew Murray Cc: Bjorn Helgaas Signed-off-by: Rob Herring --- drivers/pci/controller/pci-xgene.c | 39 +++++++++--------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index ffda3e8b4742..7d0f0395a479 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -405,15 +405,13 @@ static void xgene_pcie_setup_cfg_reg(struct xgene_pcie_port *port) xgene_pcie_writel(port, CFGCTL, EN_REG); } -static int xgene_pcie_map_ranges(struct xgene_pcie_port *port, - struct list_head *res, - resource_size_t io_base) +static int xgene_pcie_map_ranges(struct xgene_pcie_port *port) { + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port); struct resource_entry *window; struct device *dev = port->dev; - int ret; - resource_list_for_each_entry(window, res) { + resource_list_for_each_entry(window, &bridge->windows) { struct resource *res = window->res; u64 restype = resource_type(res); @@ -421,11 +419,9 @@ static int xgene_pcie_map_ranges(struct xgene_pcie_port *port, switch (restype) { case IORESOURCE_IO: - xgene_pcie_setup_ob_reg(port, res, OMR3BARL, io_base, + xgene_pcie_setup_ob_reg(port, res, OMR3BARL, + pci_pio_to_address(res->start), res->start - window->offset); - ret = devm_pci_remap_iospace(dev, res, io_base); - if (ret < 0) - return ret; break; case IORESOURCE_MEM: if (res->flags & IORESOURCE_PREFETCH) @@ -567,8 +563,7 @@ static void xgene_pcie_clear_config(struct xgene_pcie_port *port) xgene_pcie_writel(port, i, 0); } -static int xgene_pcie_setup(struct xgene_pcie_port *port, struct list_head *res, - resource_size_t io_base) +static int xgene_pcie_setup(struct xgene_pcie_port *port) { struct device *dev = port->dev; u32 val, lanes = 0, speed = 0; @@ -580,7 +575,7 @@ static int xgene_pcie_setup(struct xgene_pcie_port *port, struct list_head *res, val = (XGENE_PCIE_DEVICEID << 16) | XGENE_PCIE_VENDORID; xgene_pcie_writel(port, BRIDGE_CFG_0, val); - ret = xgene_pcie_map_ranges(port, res, io_base); + ret = xgene_pcie_map_ranges(port); if (ret) return ret; @@ -607,11 +602,9 @@ static int xgene_pcie_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *dn = dev->of_node; struct xgene_pcie_port *port; - resource_size_t iobase = 0; struct pci_bus *bus, *child; struct pci_host_bridge *bridge; int ret; - LIST_HEAD(res); bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port)); if (!bridge) @@ -634,20 +627,14 @@ static int xgene_pcie_probe(struct platform_device *pdev) if (ret) return ret; - ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res, - &iobase); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); if (ret) return ret; - ret = devm_request_pci_bus_resources(dev, &res); - if (ret) - goto error; - - ret = xgene_pcie_setup(port, &res, iobase); + ret = xgene_pcie_setup(port); if (ret) - goto error; + return ret; - list_splice_init(&res, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = port; bridge->busnr = 0; @@ -657,7 +644,7 @@ static int xgene_pcie_probe(struct platform_device *pdev) ret = pci_scan_root_bus_bridge(bridge); if (ret < 0) - goto error; + return ret; bus = bridge->bus; @@ -666,10 +653,6 @@ static int xgene_pcie_probe(struct platform_device *pdev) pcie_bus_configure_settings(child); pci_bus_add_devices(bus); return 0; - -error: - pci_free_resource_list(&res); - return ret; } static const struct of_device_id xgene_pcie_match_table[] = { From patchwork Mon Oct 28 16:32:45 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: 11215917 X-Patchwork-Delegate: geert@linux-m68k.org 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 E874B15AB for ; Mon, 28 Oct 2019 16:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6E3220717 for ; Mon, 28 Oct 2019 16:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280417; bh=lhX8l72ISVPAssUM4Q9z3AvElpBRYVor+7qQ7hYQ08s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=VFiV1cSilZ9yGyuFrCscJmXqUrZWALjwTk80oi01Pr8YBOqEGAd7Bi1JF4qKEFYeq PXfPKPegq3y/RLl35XevSb5Ax9LkGP1lGJZ+E3xKp1++qQkkS1arHQ29Jh64yJB+ue x6zL+rLnxjDPknbQMMZX4NHQWFCSUvD+7WLiN00Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391036AbfJ1Qdg (ORCPT ); Mon, 28 Oct 2019 12:33:36 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:33009 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1Qdg (ORCPT ); Mon, 28 Oct 2019 12:33:36 -0400 Received: by mail-oi1-f193.google.com with SMTP id m193so1931284oig.0; Mon, 28 Oct 2019 09:33: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=o+Nu5yrVJjsG4TTQSGHiVlpfm5ZyTifg0RmA51gaOc0=; b=bA+iRtM18Eq/0MlY0qvzFEAqnlxrFPCzt1aGv+XQJG3Z3WGKAe5WFWNG3bnmOscc8o AjXXz04wwEPpp12wYQVTdYaSLDvQY2v/iiXvZVdJblKqnIgmTWvB7lfJ5QpQTYBq0bB8 vcbI2Ea2/FLRq6nRIf3TVuTqL9e/Ln2jgefzn0R4Y6sIXzfwiu7xJiLLvuFdVIgBVEpl PBg/7UvKwo9jx1WG6KOS74tt9WIAfm5sh6ZcEZjBHqi4AGZeUoFIXuOxC2VTnh7GK9Y8 6dRAzh22dwywZWhsj9UxxZEHyozA4hr/QcU/8mnE4r6E2Uyr7unsg3LcUIQ9x59/hvd1 KKkA== X-Gm-Message-State: APjAAAWNwrUrBRtJwYT3Ms7DMdr+fUQevazUzhSh1SrBihPn0rERKPq+ ocnFksbKfnA04X6cpazbDA== X-Google-Smtp-Source: APXvYqxZLTR5wVAhoLt1SmTt4eoDfXlOKWV5o+tkbeIOsDVOrc+wq0rFYNtuDO1eJW+OcmohkZZkqQ== X-Received: by 2002:aca:5015:: with SMTP id e21mr140283oib.174.1572280415373; Mon, 28 Oct 2019 09:33: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 e186sm354991oia.47.2019.10.28.09.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:34 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 14/25] PCI: xilinx: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:45 -0500 Message-Id: <20191028163256.8004-15-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the Xilinx host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Cc: Lorenzo Pieralisi Cc: Andrew Murray Cc: Bjorn Helgaas Cc: Michal Simek Signed-off-by: Rob Herring --- drivers/pci/controller/pcie-xilinx.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c index 5bf3af3b28e6..257702288787 100644 --- a/drivers/pci/controller/pcie-xilinx.c +++ b/drivers/pci/controller/pcie-xilinx.c @@ -619,8 +619,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev) struct pci_bus *bus, *child; struct pci_host_bridge *bridge; int err; - resource_size_t iobase = 0; - LIST_HEAD(res); if (!dev->of_node) return -ENODEV; @@ -647,19 +645,12 @@ static int xilinx_pcie_probe(struct platform_device *pdev) return err; } - err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res, - &iobase); + err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); if (err) { dev_err(dev, "Getting bridge resources failed\n"); return err; } - err = devm_request_pci_bus_resources(dev, &res); - if (err) - goto error; - - - list_splice_init(&res, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = port; bridge->busnr = 0; @@ -673,7 +664,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev) #endif err = pci_scan_root_bus_bridge(bridge); if (err < 0) - goto error; + return err; bus = bridge->bus; @@ -682,10 +673,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev) pcie_bus_configure_settings(child); pci_bus_add_devices(bus); return 0; - -error: - pci_free_resource_list(&res); - return err; } static const struct of_device_id xilinx_pcie_of_match[] = { From patchwork Mon Oct 28 16:32:46 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: 11215919 X-Patchwork-Delegate: geert@linux-m68k.org 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 D297E14E5 for ; Mon, 28 Oct 2019 16:33:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0ADF20717 for ; Mon, 28 Oct 2019 16:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280418; bh=Nx5uHHUvXC8zW0LZve6ApVMx76nau3D//qJbH6ltAL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QVEnTySDQD+1ZpOasyUG7LfUp2HYAJ0wYTL46gC7C4XHax3yfRIfdj9nmUw0n+Xth YU8QwOf0yOv5aLnoHl1IA+ozUNWIxsPQ695Cd7ldI/FcAtLwi+e1XXNJraAeKMxmzs sxeUTEHou/aEAZCAcaQoEJQM7RGYZrGSDwK9XOgk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391038AbfJ1Qdi (ORCPT ); Mon, 28 Oct 2019 12:33:38 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:33012 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1Qdi (ORCPT ); Mon, 28 Oct 2019 12:33:38 -0400 Received: by mail-oi1-f193.google.com with SMTP id m193so1931379oig.0; Mon, 28 Oct 2019 09:33: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=n3y2Ka8WRhcKcfj2aX8DHqGH9IJEnrEYNwvqAJMp1K8=; b=nqGaMMXM5mcQosT4bggQ0BwLi/hCPm/F8T6CI60qExWsIJamtT3f8L10peM93C619z Wp5tF+xocmbCftnGKpU2JufImhKva/3ieRWuCpSBg5RQNONFGtkB4ItGV18MTCteNnuD a+A15x41kfEil4lsQNLMRa/iEo+2YHcV0iWmJ9dNe4+89kNqwoC3jgKl8EtadctIQXCc FH+q20MIPwY4WhKEvipOxU/J3LUTr7EPwcATUzvOAVwx3FvOJIFDh/3Ftqbh2Pn9BfGt I6BvW7l0wqzsx6+iD1MNcfAXeAV5XGS/SXNemgfqwohn1Dglp1Xb99TmVtJjXuzOV/Pu 2Y1w== X-Gm-Message-State: APjAAAWnibYjgEYr9EBvWbJzrdYAyuO9sMUwBcwHRGJVsxP+S5mObYtW HR0mJmWeBrzxM1F3UqW5VA== X-Google-Smtp-Source: APXvYqz8N1xGkSsjPvO3LqrYhKkvX8lmGh2l+7Jzyk4LSNNz1GUewrj62TSLCJt13u7SybQIhsO2YA== X-Received: by 2002:aca:1e0c:: with SMTP id m12mr170767oic.18.1572280417514; Mon, 28 Oct 2019 09:33: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 e186sm354991oia.47.2019.10.28.09.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:36 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 15/25] PCI: xilinx-nwl: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:46 -0500 Message-Id: <20191028163256.8004-16-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the xilinx-nwl host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Cc: Lorenzo Pieralisi Cc: Andrew Murray Cc: Bjorn Helgaas Cc: Michal Simek Signed-off-by: Rob Herring --- drivers/pci/controller/pcie-xilinx-nwl.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c index 45c0f344ccd1..e135a4b60489 100644 --- a/drivers/pci/controller/pcie-xilinx-nwl.c +++ b/drivers/pci/controller/pcie-xilinx-nwl.c @@ -821,8 +821,6 @@ static int nwl_pcie_probe(struct platform_device *pdev) struct pci_bus *child; struct pci_host_bridge *bridge; int err; - resource_size_t iobase = 0; - LIST_HEAD(res); bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); if (!bridge) @@ -845,24 +843,18 @@ static int nwl_pcie_probe(struct platform_device *pdev) return err; } - err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res, - &iobase); + err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); if (err) { dev_err(dev, "Getting bridge resources failed\n"); return err; } - err = devm_request_pci_bus_resources(dev, &res); - if (err) - goto error; - err = nwl_pcie_init_irq_domain(pcie); if (err) { dev_err(dev, "Failed creating IRQ Domain\n"); - goto error; + return err; } - list_splice_init(&res, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr = pcie->root_busno; @@ -874,13 +866,13 @@ static int nwl_pcie_probe(struct platform_device *pdev) err = nwl_pcie_enable_msi(pcie); if (err < 0) { dev_err(dev, "failed to enable MSI support: %d\n", err); - goto error; + return err; } } err = pci_scan_root_bus_bridge(bridge); if (err) - goto error; + return err; bus = bridge->bus; @@ -889,10 +881,6 @@ static int nwl_pcie_probe(struct platform_device *pdev) pcie_bus_configure_settings(child); pci_bus_add_devices(bus); return 0; - -error: - pci_free_resource_list(&res); - return err; } static struct platform_driver nwl_pcie_driver = { From patchwork Mon Oct 28 16:32:47 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: 11215923 X-Patchwork-Delegate: geert@linux-m68k.org 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 16ABF15AB for ; Mon, 28 Oct 2019 16:33:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8CFE20717 for ; Mon, 28 Oct 2019 16:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280421; bh=kd48EXX2o14ExrQ9E4d+0Ks7tqU94yMfIuuzzZyvMVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Zhz2bI0JvyXdSMfB91aeeVTewIfVX/kpmY2TND/iGHRca0I2OPy5Tw5QuHYkHMIF6 KQQSdbMDuQWJJDfWgrInZ0d16XUcR0RLw7JKPMncTl17q3snkDrQJrz1qtkb3Q0h2g 6UDZ6eDwfcD7h/O5c/y8SZ0G4VI9W1zgkoqODFOo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391040AbfJ1Qdk (ORCPT ); Mon, 28 Oct 2019 12:33:40 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:36223 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1Qdk (ORCPT ); Mon, 28 Oct 2019 12:33:40 -0400 Received: by mail-oi1-f194.google.com with SMTP id j7so6416359oib.3; Mon, 28 Oct 2019 09:33:39 -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=XywxT9T0e0+FybaV43vak1KY/CRf/N9np0EBtvYRcMA=; b=EyaGnDpdIhEXK+Ev/FNZ7ZJd4w17nO1Uos2hrZlEYD9jsNbTLvBEU0L9Ddw744Ee/3 DZ91H7y91m8bN0ADUMY5XdiNVKWHbD1PgsE/n6iDD3C23IIAi4IK8/hjzCSjPuWb22Ib 0f5ylBLdMy56WC0MpUa1nPotkxb2pVyUcocGeLNoTTXYZc7dI9IwPfGZqAit9fkA/nHw JfoOvCuaAz7lZV8zuYcVV8/GdmLO3SyjL33qKYiMozhbcZBXxUVq/oHHxUeMAIyB3m8u tVDPlz364S+y9cUzlaeRmVtdBXt1Iv4+eZu0w2eEDDtEqSJd6DGTWISAiu5w5mIg/pXH 95pg== X-Gm-Message-State: APjAAAUWPEEUjXszY/9YY7s2ixbT+LlNoYJfL/FP/tuxrSSh/7MfpRaT lc8X+ENHai7hKNw3qIgezQ== X-Google-Smtp-Source: APXvYqyShSuAsZJCcAzu7l8pHQLrW9ipkAinBjLrW2jh1IsJtYa0AM8h36pePN7rT7LnX4C6RtGhHw== X-Received: by 2002:a54:4601:: with SMTP id p1mr108616oip.113.1572280419352; Mon, 28 Oct 2019 09:33: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 e186sm354991oia.47.2019.10.28.09.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:38 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 16/25] PCI: versatile: Use pci_parse_request_of_pci_ranges() Date: Mon, 28 Oct 2019 11:32:47 -0500 Message-Id: <20191028163256.8004-17-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert ARM Versatile host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Acked-by: Linus Walleij Signed-off-by: Rob Herring --- v2: - Fix 'mem' initial value to 1 - Remove temporary resource list --- drivers/pci/controller/pci-versatile.c | 64 +++++--------------------- 1 file changed, 11 insertions(+), 53 deletions(-) diff --git a/drivers/pci/controller/pci-versatile.c b/drivers/pci/controller/pci-versatile.c index f59ad2728c0b..18697f2ea345 100644 --- a/drivers/pci/controller/pci-versatile.c +++ b/drivers/pci/controller/pci-versatile.c @@ -62,65 +62,16 @@ 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 = 1; u32 val; void __iomem *local_pci_cfg_base; struct pci_bus *bus, *child; struct pci_host_bridge *bridge; - LIST_HEAD(pci_res); bridge = devm_pci_alloc_host_bridge(dev, 0); if (!bridge) @@ -141,10 +92,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, &bridge->windows, NULL); if (ret) return ret; + resource_list_for_each_entry(entry, &bridge->windows) { + 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 @@ -197,7 +156,6 @@ static int versatile_pci_probe(struct platform_device *pdev) pci_add_flags(PCI_ENABLE_PROC_DOMAINS); pci_add_flags(PCI_REASSIGN_ALL_BUS); - list_splice_init(&pci_res, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = NULL; bridge->busnr = 0; From patchwork Mon Oct 28 16:32:48 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: 11215927 X-Patchwork-Delegate: geert@linux-m68k.org 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 5F4611390 for ; Mon, 28 Oct 2019 16:33:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D95A20717 for ; Mon, 28 Oct 2019 16:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280423; bh=LZOKSNNwVUrE5nTp3UDQX3AURPVZhpvO501G9BH0ZT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=G+SnVmr1U/eiLnClT0snqOlUdyX7dvxcYTu7PctONaQj1+KsEkGgEUQNM7ek9yhe4 VT/g2zr6a/mtWxFlC0I4ACTL/dVNi49mtqNEYyVNy90Z5VUSRzIfFVte5cuXey7r1k QHOx/9bMGgvbNS/gvvJYwWOEsnxBAhFEewhnnnbg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391041AbfJ1Qdn (ORCPT ); Mon, 28 Oct 2019 12:33:43 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:45970 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1Qdm (ORCPT ); Mon, 28 Oct 2019 12:33:42 -0400 Received: by mail-oi1-f193.google.com with SMTP id k2so1286405oij.12; Mon, 28 Oct 2019 09:33: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=gXFj97mkbGwNy9HcITgsXlHzoihDJWyxuLbZMG3bMrk=; b=AbLBebpL7oUHwFjivY0wy182SRR3iFiem9N/daj6okX6CFNpRJAgM4w26Oq5jw/cY9 NwDrpGCOaUBHC3YndbKkL2l9AK0hisuxI2wLLtVqvib/3TQLyuByr/PliDbv+g6V8gbJ wt930pJX0fdI5k9/MWXzqJb/GIEDousbEHCMnHNqVH63wKG1FOiTqujHBrWiIbXnj1E1 EoOl2jyk6V+Aai29eDus2Epzdy6iLUNe/0Dj438QtkvmMEuIKFqcjxRreiPEe6BbSXEu DtO0nByYAFb74/ULhG6ch1xeShDALw2uhG52I4qpefO7X+5mafdYi8J7A4k+uZ+Hv0Ot iBdQ== X-Gm-Message-State: APjAAAXF7bm0qGYAVVucm7Qm7fcSWclhyIvbdscg395MnIh7GzCEg458 xG5Rx9M/F9l+VqsCjhPAxg== X-Google-Smtp-Source: APXvYqyAyPrUKbfPJy6jun7gPAIEO0JEPIYDjbds2nS284G2YkNImID/wTHAeVHyFp19AQ13lX76hg== X-Received: by 2002:aca:1a0b:: with SMTP id a11mr149284oia.138.1572280421584; Mon, 28 Oct 2019 09:33: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 e186sm354991oia.47.2019.10.28.09.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:40 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 17/25] PCI: versatile: Remove usage of PHYS_OFFSET Date: Mon, 28 Oct 2019 11:32:48 -0500 Message-Id: <20191028163256.8004-18-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org PHYS_OFFSET is not universally defined on all arches and using it prevents enabling COMPILE_TEST. PAGE_OFFSET and __pa() are always available, so use them to get the physical start of memory address. This should have probably used 'dma-ranges' to get the address, but we don't want to force a DT update to do that. At least in QEMU, the SMAP registers have no effect (or perhaps the only value that is handled is 0). Cc: Lorenzo Pieralisi Cc: Andrew Murray Cc: Bjorn Helgaas Acked-by: Linus Walleij Signed-off-by: Rob Herring --- drivers/pci/controller/pci-versatile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pci-versatile.c b/drivers/pci/controller/pci-versatile.c index 18697f2ea345..eae1b859990b 100644 --- a/drivers/pci/controller/pci-versatile.c +++ b/drivers/pci/controller/pci-versatile.c @@ -99,7 +99,7 @@ static int versatile_pci_probe(struct platform_device *pdev) resource_list_for_each_entry(entry, &bridge->windows) { if (resource_type(entry->res) == IORESOURCE_MEM) { writel(entry->res->start >> 28, PCI_IMAP(mem)); - writel(PHYS_OFFSET >> 28, PCI_SMAP(mem)); + writel(__pa(PAGE_OFFSET) >> 28, PCI_SMAP(mem)); mem++; } } @@ -136,9 +136,9 @@ static int versatile_pci_probe(struct platform_device *pdev) /* * Configure the PCI inbound memory windows to be 1:1 mapped to SDRAM */ - writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_0); - writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_1); - writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2); + writel(__pa(PAGE_OFFSET), local_pci_cfg_base + PCI_BASE_ADDRESS_0); + writel(__pa(PAGE_OFFSET), local_pci_cfg_base + PCI_BASE_ADDRESS_1); + writel(__pa(PAGE_OFFSET), local_pci_cfg_base + PCI_BASE_ADDRESS_2); /* * For many years the kernel and QEMU were symbiotically buggy From patchwork Mon Oct 28 16:32:49 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: 11215931 X-Patchwork-Delegate: geert@linux-m68k.org 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 746DF1390 for ; Mon, 28 Oct 2019 16:33:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5302520717 for ; Mon, 28 Oct 2019 16:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280427; bh=Ru9L3C8Iexie6aE0OpVYEqvPbNs8VGX3Pts8OUxTDpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UieRIz5WI9gU944y3xCh1BmOq4+mKe7pvi68LGPDhx/4I68Xg58dMVC3HrZ/GSs2i NkpW4Ab+P/uXj9SnN0nU9tAP4W6+krbvDXVDKBzgxvxIIxbaKPWMSTUHVQiIy/m/Dc lCaSgzKUpoT/StLRDMW219PiSfyggHNoe1r78C3c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732992AbfJ1Qdr (ORCPT ); Mon, 28 Oct 2019 12:33:47 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:41916 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391042AbfJ1Qdq (ORCPT ); Mon, 28 Oct 2019 12:33:46 -0400 Received: by mail-ot1-f68.google.com with SMTP id 94so7158952oty.8; Mon, 28 Oct 2019 09:33: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=2sCm5472cF93KvMaJ0/jgH3kNxAHKfGtxH8J6nHodQ0=; b=li1Yh0kr3Lwj5X/+Yew+8AIysgS83Fod8n/Suc/6KEgeMmyk+Fp35riW+1an9dFGLj BJuMbKxwFigCAA9V2TXB7DYzxlLESPrshSbTvJyUHMPp3ld6ygGWH4+gZKR5Xp/bshGv KupfOg8oYiYlGFq37l8c9pPVoFu5Lxpwunscmc5e5GRME1f1PqSiDBqAiYfg6QAMBvVi p69WzGlxT/xyvKGQUrIHoRqXtfacRo2HV0SdNuj4RO8Ga5VHsiAiJEWOJl/kKaKOoAbq s5+bgyqJboFd2UcXHRSc9JuyCR6VPOT2oyxJahcUG6ph3Xiyh+oCYonUoWJP20Lt+DK4 O3zQ== X-Gm-Message-State: APjAAAWY3JfcNKiuzLKrV7LB6ArkTqPSohPagBdgjJ78hpDj011EnVpp D3fwlXyO39OA18HNqQAPfg== X-Google-Smtp-Source: APXvYqy/Xq0iUAE5skdxW7RQgS/cS0GZT0jx1F5IzTA54s6xqljQwh3to6yMnbySIthX+LfaHcMHpQ== X-Received: by 2002:a9d:ef0:: with SMTP id 103mr14011546otj.2.1572280425906; Mon, 28 Oct 2019 09:33: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 e186sm354991oia.47.2019.10.28.09.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:44 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 18/25] PCI: versatile: Enable COMPILE_TEST Date: Mon, 28 Oct 2019 11:32:49 -0500 Message-Id: <20191028163256.8004-19-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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. Reviewed-by: Andrew Murray Acked-by: Linus Walleij Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring --- 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 70e078238899..f5de9119e8d3 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 Mon Oct 28 16:32:50 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: 11215939 X-Patchwork-Delegate: geert@linux-m68k.org 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 5168D1390 for ; Mon, 28 Oct 2019 16:33:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C90221744 for ; Mon, 28 Oct 2019 16:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280430; bh=pwz6ZBY3/oejalziroV3TSEs0l8aPiqQkGdENFqKXdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jTxzfOCcQj2sTGSXio6LQ4bxUE4h/5vAchU6gIoiMUAr2tAr0Zpj379/kR0xKT3Ep i46dJitvOSVRT772m/nWoFvfnU5BbFyReNod7h5Z0riINAvyg5WxPsrcNqBaB+xzwJ dAM6Oyx9MsopmxODGnv1XQ9KJ7z7d9wADMNf/tH0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730772AbfJ1Qdt (ORCPT ); Mon, 28 Oct 2019 12:33:49 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:33868 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbfJ1Qdt (ORCPT ); Mon, 28 Oct 2019 12:33:49 -0400 Received: by mail-oi1-f195.google.com with SMTP id 83so6433971oii.1; Mon, 28 Oct 2019 09:33:48 -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=JzDbuy0Sgmg3tS/Mxoo6IoJJaqmVRcZ7SmnNTiDCSXs=; b=Dj0dh3jUsUnbVBShrrYyzP57sy8IHfbPq45g3GGAJ1uFKKbBWCRvg05u9IOhaOBkOC tgkjM5D3tWnXCiNKbtQc86LN/df1P+4x2bJtbYmT46/rvlT8uvd+mNbPMC4mYp7/iubX PHNCwIskI6JTWndC0MSoVE7FW7NAtzF1KHGUjemsSowzEKJjnIgL5gz/fQ3bmBiUs2Pz +oH8dwZm/eO/1ppDtYg80wQOcK01B/yyoY7l5kko9cqsvoHynoRJSZsr/tg0S/vvXZYx lHUJ+GlYzt4Utd0Fb/ODjMbHpw+GkHDvtOH7q/JUAx3kTKsyE5eCGfjd/AQebDTF2pfq 72ew== X-Gm-Message-State: APjAAAWdjghRQ5CrmigSQ3+226n1Lz1sxjdPjNFOuVCOgLt2ePO8Qspf x14EGmHE2ttmk0uhrtbnqw== X-Google-Smtp-Source: APXvYqxjZ86EF5ENX1qxqv4r8RFy167sfCoUNad5A8eEC7IynI2p2QH1vPu67Ozco9Q77Zs6VaNCAg== X-Received: by 2002:aca:ad52:: with SMTP id w79mr100832oie.149.1572280428058; Mon, 28 Oct 2019 09:33:48 -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 e186sm354991oia.47.2019.10.28.09.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:47 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 19/25] PCI: of: Add inbound resource parsing to helpers Date: Mon, 28 Oct 2019 11:32:50 -0500 Message-Id: <20191028163256.8004-20-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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 Tested-by: Thomas Petazzoni # for AArdvark Reviewed-by: Andrew Murray Acked-by: Gustavo Pimentel Signed-off-by: Rob Herring Acked-by: Bjorn Helgaas --- v2: - Fix crash in INIT_LIST_HEAD when ib_resources is NULL --- .../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 | 3 +- drivers/pci/controller/pci-versatile.c | 3 +- drivers/pci/controller/pci-xgene.c | 3 +- drivers/pci/controller/pcie-altera.c | 2 +- drivers/pci/controller/pcie-cadence-host.c | 2 +- drivers/pci/controller/pcie-iproc-platform.c | 3 +- drivers/pci/controller/pcie-mediatek.c | 2 +- drivers/pci/controller/pcie-mobiveil.c | 3 +- drivers/pci/controller/pcie-rcar.c | 3 +- drivers/pci/controller/pcie-rockchip-host.c | 3 +- drivers/pci/controller/pcie-xilinx-nwl.c | 3 +- drivers/pci/controller/pcie-xilinx.c | 3 +- drivers/pci/of.c | 45 ++++++++++++++++++- drivers/pci/pci.h | 8 +++- include/linux/pci.h | 9 ++-- 19 files changed, 82 insertions(+), 23 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index aeec8b65eb97..f7b1d80c4a0a 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) if (!bridge) return -ENOMEM; - ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, + &bridge->dma_ranges, NULL); if (ret) return ret; diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 9cbeba507f0c..b34eaa2cd762 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -939,7 +939,7 @@ static int advk_pcie_probe(struct platform_device *pdev) } ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, - &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 75603348b88a..66288b94e92d 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c @@ -477,7 +477,8 @@ static int faraday_pci_probe(struct platform_device *pdev) if (IS_ERR(p->base)) return PTR_ERR(p->base); - ret = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL); + ret = pci_parse_request_of_pci_ranges(dev, &host->windows, + &host->dma_ranges, NULL); if (ret) return ret; diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c index c8cb9c5188a4..250a3fc80ec6 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 96677520f6c1..2209c7671115 100644 --- a/drivers/pci/controller/pci-v3-semi.c +++ b/drivers/pci/controller/pci-v3-semi.c @@ -776,7 +776,8 @@ static int v3_pci_probe(struct platform_device *pdev) if (IS_ERR(v3->config_base)) return PTR_ERR(v3->config_base); - ret = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL); + ret = pci_parse_request_of_pci_ranges(dev, &host->windows, + &host->dma_ranges, NULL); if (ret) return ret; diff --git a/drivers/pci/controller/pci-versatile.c b/drivers/pci/controller/pci-versatile.c index eae1b859990b..b911359b6d81 100644 --- a/drivers/pci/controller/pci-versatile.c +++ b/drivers/pci/controller/pci-versatile.c @@ -92,7 +92,8 @@ 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, &bridge->windows, NULL); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, + NULL, NULL); if (ret) return ret; diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index 7d0f0395a479..9408269d943d 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -627,7 +627,8 @@ static int xgene_pcie_probe(struct platform_device *pdev) if (ret) return ret; - ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, + &bridge->dma_ranges, NULL); if (ret) return ret; diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c index ba025efeae28..b447c3e4abad 100644 --- a/drivers/pci/controller/pcie-altera.c +++ b/drivers/pci/controller/pcie-altera.c @@ -800,7 +800,7 @@ static int altera_pcie_probe(struct platform_device *pdev) } ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, - 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 375d815f7301..ff0a81a632a1 100644 --- a/drivers/pci/controller/pcie-iproc-platform.c +++ b/drivers/pci/controller/pcie-iproc-platform.c @@ -95,7 +95,8 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) if (IS_ERR(pcie->phy)) return PTR_ERR(pcie->phy); - ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, + &bridge->dma_ranges, NULL); if (ret) { dev_err(dev, "unable to get PCI host bridge resources\n"); return ret; diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index d9206a3cd56b..cb982891b22b 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -1034,7 +1034,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 4eab8624ce4d..257ba49c177c 100644 --- a/drivers/pci/controller/pcie-mobiveil.c +++ b/drivers/pci/controller/pcie-mobiveil.c @@ -875,7 +875,8 @@ static int mobiveil_pcie_probe(struct platform_device *pdev) } /* parse the host bridge base addresses from the device tree file */ - ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); + ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, + &bridge->dma_ranges, NULL); 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 f375e55ea02e..ee83f8494ee9 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -1004,7 +1004,8 @@ static int rockchip_pcie_probe(struct platform_device *pdev) if (err < 0) goto err_deinit_port; - err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, &bus_res); + err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, + &bridge->dma_ranges, &bus_res); 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 e135a4b60489..9bd1427f2fd6 100644 --- a/drivers/pci/controller/pcie-xilinx-nwl.c +++ b/drivers/pci/controller/pcie-xilinx-nwl.c @@ -843,7 +843,8 @@ static int nwl_pcie_probe(struct platform_device *pdev) return err; } - err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); + err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, + &bridge->dma_ranges, NULL); 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 257702288787..98e55297815b 100644 --- a/drivers/pci/controller/pcie-xilinx.c +++ b/drivers/pci/controller/pcie-xilinx.c @@ -645,7 +645,8 @@ static int xilinx_pcie_probe(struct platform_device *pdev) return err; } - err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL); + err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, + &bridge->dma_ranges, NULL); 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 f3da49a31db4..0b1e4623dfcf 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,10 @@ int pci_parse_request_of_pci_ranges(struct device *dev, struct resource_entry *win, *tmp; INIT_LIST_HEAD(resources); + if (ib_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 3f6947ee3324..6692c4fe4290 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -633,11 +633,15 @@ static inline void pci_release_bus_of_node(struct pci_bus *bus) { } #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 f9088c89a534..5cb94916eaa1 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2278,6 +2278,7 @@ struct irq_domain; 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) */ @@ -2286,9 +2287,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus); #else /* CONFIG_OF */ 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 resource **bus_range) +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 Mon Oct 28 16:32:51 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: 11215943 X-Patchwork-Delegate: geert@linux-m68k.org 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 93B021390 for ; Mon, 28 Oct 2019 16:33:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7267121744 for ; Mon, 28 Oct 2019 16:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280431; bh=wPbe6PJh8Y7Z4NvMTvtQPNap1eRdhRfg8iJlGqvjuws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ESF6FvUIcvy1d29fsRi1QNdsCOuuCtx4QORel1RrNAsu5Fuc4FwWBJuvN6y0Oq680 Z5ww8gCkZ5KJalt0kQSz8SD+AmOHIQ5fPhurF0PXMqQ3nTO7y+w07xKcjTEnh6QPdP 0NDrBOv1p+ikxDgbbBIAYx+QpHHIRwxRk4ZtYfmg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732288AbfJ1Qdv (ORCPT ); Mon, 28 Oct 2019 12:33:51 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:40606 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbfJ1Qdu (ORCPT ); Mon, 28 Oct 2019 12:33:50 -0400 Received: by mail-ot1-f68.google.com with SMTP id d8so7162183otc.7; Mon, 28 Oct 2019 09:33:50 -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=QU/9wyXAj8Hn9lmmawqTA3HdfmHqtIC+dVHktjAk5bo=; b=PEpGvN0DdjfYjwg1mCKlVb2MbHd4qpvuqBqUF6tswn6C9/vpS7U/vifbjkJN3vhCmh PHXlLrwv1k1SFdbgcD6BtDdjiSMgvkZUrbBdTLL/Une1iE5Jvdp9ZnAki/WnbxmuZHUB d9W+J1WE35Bvu5/I3dGJweXHf5tE2ooZbZrj2wcFkwUWfPxehLb70/0Hw6yfEb+WCvDS /A7A9qVo3NPRKUkwna/v5Q3sXdqLn3EhQbpPmFfcdAJ7HTp0TTxHnuhNfYhVmQkIxMnh qzBCQDxJoh+AWXvrwnQysijtnaOrFiSO5UIQV81gpJ3YBG5dSPoQIcwVGVJOcViBvED+ OjDw== X-Gm-Message-State: APjAAAVVhKZPfwDi4Wmu7YTBA9GG/IZ59RKvsySF7kPE1yrAsgFAsQvS qwvn92zUMKMFhic5CrU1gg== X-Google-Smtp-Source: APXvYqzX2Hu9uOY3jcrsLEYHaEbafPvhljS7PBlsyooLht3SWyOGTn98jF9BU/3i/RKiepgEwvPcpw== X-Received: by 2002:a9d:334:: with SMTP id 49mr13870685otv.15.1572280429878; Mon, 28 Oct 2019 09:33:49 -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 e186sm354991oia.47.2019.10.28.09.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:49 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 20/25] PCI: ftpci100: Use inbound resources for setup Date: Mon, 28 Oct 2019 11:32:51 -0500 Message-Id: <20191028163256.8004-21-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Andrew Murray Acked-by: Linus Walleij Signed-off-by: Rob Herring --- drivers/pci/controller/pci-ftpci100.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index 66288b94e92d..1b67564de7af 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,13 @@ 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 +402,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); @@ -539,7 +532,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 Mon Oct 28 16:32:52 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: 11215947 X-Patchwork-Delegate: geert@linux-m68k.org 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 7A56915AB for ; Mon, 28 Oct 2019 16:33:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 57E5421783 for ; Mon, 28 Oct 2019 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280433; bh=yiyjbhDrIGSaXyqWNKsqbWK9aTO4cOjehsMOBOgY+3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Ksf1J9YGcVb9nmxXWOz7nlEkgoZYMxAcunPENGFrzAO1n5H7F5RO5tPTjBO6CaqtI a/I+xIUcO3Og2zqEkMJDjmMZDqVcxfwiKUkStSvJJsoSjcj4c2hplYs+d0q33lz/MX L/6D37Zm0rPqhomTpCw2ep1j4E2hhUqSO4EqPzYs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732995AbfJ1Qdx (ORCPT ); Mon, 28 Oct 2019 12:33:53 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:35288 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbfJ1Qdw (ORCPT ); Mon, 28 Oct 2019 12:33:52 -0400 Received: by mail-oi1-f194.google.com with SMTP id n16so4147886oig.2; Mon, 28 Oct 2019 09:33:52 -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=9dn1tmxzjQTI9PAUk6uuXXt7CY5FAAIGihQa/Sw5ORA=; b=NvOrcvkHb23eV6h7ZdyRHJY9m7HsvPsutQrd16x0v8kdDpZ4GLC1qVpFcerB4A8fVy BOwtiLL0Gxn3Nj9OTsEhnTBJ9XNIgl0qqbfEKsNeDHIgx4bIX8aFO8G7W7w0Wsr5NIq4 4p510nk6YD7OGqEu+kFKLaGkzghG3dcotRGLx8RnWqS5UkMfVPxupdBUXlcbtKjttXJ5 arLuOEh8hMS5TBHBuxhwRW3WHo3hvzSqsluCdVuUqk+9fBTYS0n7Lyc7El9nqAaB7jmb TUhAPumtA6z7HnGXQQfIrDgCeIam875YP2TG1R1Y2+YWIwzZleUzVFK1o1b+0tS4zEcl YdFw== X-Gm-Message-State: APjAAAX886yglyuuVr14zi8qV2p26LAFc3LiOCavPE6MhOcoWn5wZ76u jsJGCx6ClkAiXSPtFAS04g== X-Google-Smtp-Source: APXvYqy2aOv/BWjh/fOFyROYXfZgl0g1EuXwphc9ldC9o3rRodxdVklAkX2S/p8TYhXvkJEGpP50Kg== X-Received: by 2002:aca:fdc3:: with SMTP id b186mr156065oii.92.1572280431823; Mon, 28 Oct 2019 09:33:51 -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 e186sm354991oia.47.2019.10.28.09.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:51 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 21/25] PCI: v3-semi: Use inbound resources for setup Date: Mon, 28 Oct 2019 11:32:52 -0500 Message-Id: <20191028163256.8004-22-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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: Lorenzo Pieralisi Cc: Bjorn Helgaas Reviewed-by: Andrew Murray Reviewed-by: Linus Walleij Signed-off-by: Rob Herring --- 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 2209c7671115..bd05221f5a22 100644 --- a/drivers/pci/controller/pci-v3-semi.c +++ b/drivers/pci/controller/pci-v3-semi.c @@ -598,28 +598,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; @@ -667,8 +669,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; @@ -677,24 +679,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 Mon Oct 28 16:32:53 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: 11215951 X-Patchwork-Delegate: geert@linux-m68k.org 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 08FD61390 for ; Mon, 28 Oct 2019 16:33:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAAAC21783 for ; Mon, 28 Oct 2019 16:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280435; bh=p4bR+NvKZxNJUPeoCyVeMtgrNnrvESQy6QyWHhvsQU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Z9Gnzo6Llc02al4vIj0L/GHNr73hz8s5pcprHigk4kXm/lgMHdqTan1Pdk1P3J3n7 L3oY2Q99ykGdXn2FN9Ym6oh+ipDz60KGHFk7oc1Mad6ycjKEio3msKN4X79bscD3GB XUKXiEi7UHoRvi3MzjNb9AgpKwDIWKwgSNBRz0QM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391049AbfJ1Qdz (ORCPT ); Mon, 28 Oct 2019 12:33:55 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:37085 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbfJ1Qdz (ORCPT ); Mon, 28 Oct 2019 12:33:55 -0400 Received: by mail-oi1-f195.google.com with SMTP id y194so1824791oie.4; Mon, 28 Oct 2019 09:33:54 -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=AVklfYJFhVbHAQ7UDqJCp1P9Q1jvjrg559mLmYhBVeg=; b=S41ODPUCi8d7z4AWgp/I7ux5hBCysZTpXdTlQLY4YvEFG6oVptgSBSZaMnpbXgyozt qbKZ4QGz1kkV165Q3mzd+NCxAAR4jx/rx5g6JEE6unleTRunGAaJ4tGZKmK2qIv9rTvd Vib5YJ4uomNo6uCWHPR6wtMAu9+1g7j/wFmrbOCYagqk2wQarD7zTpedEEKgTgCoWJSl Eu6/FOu7Mx9GveIafkpQesKKMU7BHXEojl8H2m9pxIZIsogj9BrUaAZsCb72yYToHkkX 14KxmuTgOMAaYfC+tBFJxT7/TvpczbYgrEmi9ZDzBsPjQg+f/CxaJd3/mt3jSX3II+0c tNdQ== X-Gm-Message-State: APjAAAVqzNjTBsbPwJyEQww5Jbl0mNse+QxAmtNjsrmi9Vpj+J2wc6Z9 PG4SvHavQzw/J9n00sCy0w== X-Google-Smtp-Source: APXvYqw/e5snXZYmJHxjv4VSvv1baWUuaK0hcKO+zQhrXL+bKUV/GjVUCsr2B283wl/nYJwT0Z3kkA== X-Received: by 2002:a05:6808:87:: with SMTP id s7mr130407oic.47.1572280434085; Mon, 28 Oct 2019 09:33:54 -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 e186sm354991oia.47.2019.10.28.09.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:53 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 22/25] PCI: xgene: Use inbound resources for setup Date: Mon, 28 Oct 2019 11:32:53 -0500 Message-Id: <20191028163256.8004-23-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Andrew Murray Signed-off-by: Rob Herring --- drivers/pci/controller/pci-xgene.c | 33 ++++++++++-------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index 9408269d943d..de195fd430dc 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -481,27 +481,28 @@ 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); @@ -532,25 +533,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 Mon Oct 28 16:32:54 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: 11215955 X-Patchwork-Delegate: geert@linux-m68k.org 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 103D21668 for ; Mon, 28 Oct 2019 16:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2E0321744 for ; Mon, 28 Oct 2019 16:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280438; bh=ZBZL7/3oxU6Uf8lqO76LGKg80zsslxAmLNSemfngoWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZZKujEqRAnCbaZS89yCxQdXhr7MJU/4HXohdnkYrlD6h3RPYn2WRGkZdirc7Rj364 sgWkyU0aa4JmhWPXsFNgLFexekpDfhC4CIBzxg21WDMNGLeyEeZxg42hkIF4jqe0Ei KKHvUZhM/R3O5taYZgjliC+m1mLpsiUpZV5ts0Q4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391051AbfJ1Qd5 (ORCPT ); Mon, 28 Oct 2019 12:33:57 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:36193 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbfJ1Qd5 (ORCPT ); Mon, 28 Oct 2019 12:33:57 -0400 Received: by mail-ot1-f66.google.com with SMTP id c7so7185813otm.3; Mon, 28 Oct 2019 09:33:56 -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=DUL+m3NhP58NWVgq+Qieb9x0OfdgTK/3u8ZTlPRNpf8=; b=M5zu+zDBcywzsIOBcaU3SNc1/CPj2AI/W+QjLLUHVmEHebApspAAhAis44m5lLE+yF jvRCYd93Q4q92NvKUtNko/rT96lWp+SSMNylaNL6j+GnW0tZH4TGMN5Q46z2+p+LVl0I PT/ZdCDnDjK7oL/KNzh2w1B0fQg6QkbTs8gb7HUhodvGNTnwfpDsvV+m+8r+h+VO7wXF AfCJDfqKXM9s0cn4naKLK3puXYi6kkCbENDeQhvQeLbAknZADw2lw34y5vht3PoFux/S OHw0Kwu/uAAmjyQyJgV226a1nTeSth0brKagKWU+SSTEP9mJvrcTUcw8X2ddz3Ij7RLD pk1Q== X-Gm-Message-State: APjAAAVsUF3r2GSEpueB0DFsfH5Z/urFSbziOsg2vDIuUgpnegqyjgET cczoGC/AfE9TzWJUdqfpfg== X-Google-Smtp-Source: APXvYqyPxtg2swpf530JxdQcsdiawBZNYu+uT+14bkBsB8TaDWNTfBY9ewk7vPf38ETbIHCmQW7g2w== X-Received: by 2002:a9d:1c9c:: with SMTP id l28mr8888143ota.10.1572280435975; Mon, 28 Oct 2019 09:33:55 -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 e186sm354991oia.47.2019.10.28.09.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:55 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 23/25] PCI: iproc: Use inbound resources for setup Date: Mon, 28 Oct 2019 11:32:54 -0500 Message-Id: <20191028163256.8004-24-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Andrew Murray Signed-off-by: Rob Herring --- v2: - Fix iproc_pcie_paxb_v2_msi_steer() to use resource_entry --- drivers/pci/controller/pcie-iproc.c | 77 +++++++---------------------- 1 file changed, 17 insertions(+), 60 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index 223335ee791a..f4d78e66846e 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -1122,15 +1122,16 @@ 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; + u64 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 +1183,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); - - /* Get the dma-ranges from DT */ - ret = of_pci_dma_range_parser_init(&parser, pcie->dev->of_node); - if (ret) - return ret; + struct resource_entry *entry; + int ret = 0; - 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; } @@ -1276,13 +1230,16 @@ static int iproce_pcie_get_msi(struct iproc_pcie *pcie, static int iproc_pcie_paxb_v2_msi_steer(struct iproc_pcie *pcie, u64 msi_addr) { int ret; - struct of_pci_range range; + struct resource_entry entry; + + memset(&entry, 0, sizeof(entry)); + entry.res = &entry.__res; - memset(&range, 0, sizeof(range)); - range.size = SZ_32K; - range.pci_addr = range.cpu_addr = msi_addr & ~(range.size - 1); + msi_addr &= ~(SZ_32K - 1); + entry.res->start = msi_addr; + entry.res->end = msi_addr + SZ_32K - 1; - ret = iproc_pcie_setup_ib(pcie, &range, IPROC_PCIE_IB_MAP_IO); + ret = iproc_pcie_setup_ib(pcie, &entry, IPROC_PCIE_IB_MAP_IO); return ret; } From patchwork Mon Oct 28 16:32:55 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: 11215959 X-Patchwork-Delegate: geert@linux-m68k.org 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 BB7211390 for ; Mon, 28 Oct 2019 16:33:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AD5521744 for ; Mon, 28 Oct 2019 16:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280439; bh=AfpMwz8ts+uJ52fKFMKPQjLWa8R7Nz/n+NsKUeo3wJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CyyaNMvk1zGvsrCZI9SRC5a6up49AzHWBg8LQ9zDvjwzojLINhr//FBBFhOcT62iq 3EQwFed4oZYQtl+5TIpkLTROWn0UpWEuYdKrdKGGpxcnVcEUG1GX7n3C115wgBaTFi whOz94RSoT1nZDEl00OSoakGLw1g5d4kgj7tWD0Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730387AbfJ1Qd7 (ORCPT ); Mon, 28 Oct 2019 12:33:59 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:33882 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbfJ1Qd7 (ORCPT ); Mon, 28 Oct 2019 12:33:59 -0400 Received: by mail-oi1-f194.google.com with SMTP id 83so6434460oii.1; Mon, 28 Oct 2019 09:33:58 -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=AlYJFjD45NJ+DWIZmKmCKB1gBxXnUmx/E0MzTNZiBSwPn9RVZJVEw8+zi+8nXyyVRj mbqqmK3it5406RA4kPIMQMe7E6WArqQq8GsvXFlDxTB5nbbnVjH4x3vai+5McknCgi45 9dZafeCfSFShmaLnQXdUi9/Pl9G8+SlMPd7/KSIqupK/kmhWox+TmJq1Agvi8KSeK96d 6GkpxJncPFTOKMSi3Y1FI2Hh7C+P1oz1usS3wSXpzCieni0j5KD/eNUQeGHRrBK+xBHy /7yHJfXhfzW9E33eAQGyd6LoavSjcifYEWRVk7RZRTRT1BkCoGXEji7jLPN/LPAaNWyc dFaw== X-Gm-Message-State: APjAAAXBa502rxFGf0bzqLBKzkS20SxNMVYJcq2MaIb/3g26IRSZP3f6 tQcTftaN9bncpkm0qBqH0A== X-Google-Smtp-Source: APXvYqzT0VPnOPdPwF3Vz9tQT4AF71pvOJiHKIpOHt2Q3w8psOl69/xNpsNI3ONaaYbY/akHURqGlg== X-Received: by 2002:a05:6808:5cf:: with SMTP id d15mr132310oij.144.1572280437917; Mon, 28 Oct 2019 09:33:57 -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 e186sm354991oia.47.2019.10.28.09.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:57 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 24/25] PCI: rcar: Use inbound resources for setup Date: Mon, 28 Oct 2019 11:32:55 -0500 Message-Id: <20191028163256.8004-25-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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; From patchwork Mon Oct 28 16:32:56 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: 11215963 X-Patchwork-Delegate: geert@linux-m68k.org 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 B21231390 for ; Mon, 28 Oct 2019 16:34:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9078F20717 for ; Mon, 28 Oct 2019 16:34:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572280441; bh=xAMSDHJRu+klrBiWNLGGlkSoErpq59QmcEO+qE7uTrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0QtboBL+Fvjvbi1GnMmS2jA/g9ZbtqSbk/+vEh+XzZHAnd9iF4sOWgQ/n9jkW8c3o fC67D6SZcGZYPi9zLdnM+r8FqSLscLaPOu86JqpeiOcHQS83+GDDorzRcnMKNoSm0m 7xJ/teUmANUhKJ87TsINutvdA95ccVcBoAGk1u6Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391054AbfJ1QeB (ORCPT ); Mon, 28 Oct 2019 12:34:01 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:36203 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbfJ1QeB (ORCPT ); Mon, 28 Oct 2019 12:34:01 -0400 Received: by mail-ot1-f68.google.com with SMTP id c7so7186034otm.3; Mon, 28 Oct 2019 09:34:00 -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=5gD14iI8UpOKj376Bq/txSzTZsSs0VToSMrptEdmjdQ=; b=FXJu07jJTTBXvWYa9yBZ5TzlT+TAQnH9G7/tyeIZQk53OIMC4ISFwjF7VCFVi76LDi NMdp0+mXrEHXIRv83R+XPuBbZ3ixi2cV7suurM4C0DrmKQjtF9HgLUswL/gXlpZESDpZ QgNKjOvVBWeGabp/Bfphf4LMn/w5EEAClQCsEZOYpFfx9SpxxvSWtsJ2bb0WrielsGIx 61ckOTh86bSAP7UPWLShfU06NwZIs2no/7jPGy0OV9ZJVxvqPKWuorbIYOQvIVryP0YM 0IBIVwwWl8l+zvSOKGF0+mbNzPXyfohS+uExCQVjIC1hXZYoJvLlkVazZE6dNopZ6CuI bvwA== X-Gm-Message-State: APjAAAUi9gYkWHsBG1642/LyrBvcW6743Hj5ysMEkRgg5O40Rd/5eMzb YqnBFVXaAYKa4lN0tJStqQ== X-Google-Smtp-Source: APXvYqxwQvVW18ni2MGlR3yza3cM3F7fWkGTz5dS8pb+bIhSeEI2GqTMRaA5bo4tECabCiP8MTGJZA== X-Received: by 2002:a9d:4616:: with SMTP id y22mr13801201ote.319.1572280439895; Mon, 28 Oct 2019 09:33:59 -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 e186sm354991oia.47.2019.10.28.09.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:59 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Christoph Hellwig , Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v3 25/25] PCI: Make devm_of_pci_get_host_bridge_resources() static Date: Mon, 28 Oct 2019 11:32:56 -0500 Message-Id: <20191028163256.8004-26-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Now that all the PCI host drivers are using pci_parse_request_of_pci_ranges(), make devm_of_pci_get_host_bridge_resources() static. Cc: Bjorn Helgaas Signed-off-by: Rob Herring --- drivers/pci/of.c | 5 +---- drivers/pci/pci.h | 17 ----------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 0b1e4623dfcf..00e4b9fcb41d 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -236,7 +236,6 @@ void of_pci_check_probe_only(void) } EXPORT_SYMBOL_GPL(of_pci_check_probe_only); -#if defined(CONFIG_OF_ADDRESS) /** * devm_of_pci_get_host_bridge_resources() - Resource-managed parsing of PCI * host bridge resources from DT @@ -255,7 +254,7 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only); * It returns zero if the range parsing has been successful or a standard error * value if it failed. */ -int devm_of_pci_get_host_bridge_resources(struct device *dev, +static int devm_of_pci_get_host_bridge_resources(struct device *dev, unsigned char busno, unsigned char bus_max, struct list_head *resources, struct list_head *ib_resources, @@ -384,8 +383,6 @@ int devm_of_pci_get_host_bridge_resources(struct device *dev, pci_free_resource_list(resources); return err; } -EXPORT_SYMBOL_GPL(devm_of_pci_get_host_bridge_resources); -#endif /* CONFIG_OF_ADDRESS */ #if IS_ENABLED(CONFIG_OF_IRQ) /** diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 6692c4fe4290..118a4974537b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -630,23 +630,6 @@ static inline void pci_set_bus_of_node(struct pci_bus *bus) { } static inline void pci_release_bus_of_node(struct pci_bus *bus) { } #endif /* CONFIG_OF */ -#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, - 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, - struct list_head *ib_resources, - resource_size_t *io_base) -{ - return -EINVAL; -} -#endif - #ifdef CONFIG_PCIEAER void pci_no_aer(void); void pci_aer_init(struct pci_dev *dev);