PCI: dwc: Another round of clean-ups
Subsystems (23)
Rob Herring
reviewerv2 cover PCI: dwc: Another round of clean-ups
Here's another batch of DWC PCI host refactoring. This series primarily moves more of the MSI, link up, and resource handling to the core code. Beyond a couple of minor fixes, new in this version is runtime detection of iATU regions instead of using DT properties.
No doubt I've probably broken something. Please test. I've run this thru kernelci and checked boards with DWC PCI which currently is just Layerscape boards (hint: add boards and/or enable PCI). A git branch is here[1].
This is dependent on "PCI: dwc: Restore ATU memory resource setup to use last entry" which will be in v5.10-rc3.
Rob
[1] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git pci-more-dwc-cleanup
Rob Herring (16):
PCI: dwc: Support multiple ATU memory regions
PCI: dwc/intel-gw: Move ATU offset out of driver match data
PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into
common code
PCI: dwc/intel-gw: Remove some unneeded function wrappers
PCI: dwc: Ensure all outbound ATU windows are reset
PCI: dwc/dra7xx: Use the common MSI irq_chip
PCI: dwc: Drop the .set_num_vectors() host op
PCI: dwc: Move MSI interrupt setup into DWC common code
PCI: dwc: Rework MSI initialization
PCI: dwc: Move link handling into common code
PCI: dwc: Move dw_pcie_msi_init() into core
PCI: dwc: Move dw_pcie_setup_rc() to DWC common code
PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init() Revert "PCI: dwc/keystone: Drop duplicated 'num-viewport'"
PCI: dwc: Move inbound and outbound windows to common struct
PCI: dwc: Detect number of iATU windows
drivers/pci/controller/dwc/pci-dra7xx.c | 141 +----------------- drivers/pci/controller/dwc/pci-exynos.c | 50 ++----- drivers/pci/controller/dwc/pci-imx6.c | 39 +---- drivers/pci/controller/dwc/pci-keystone.c | 79 ++-------- .../pci/controller/dwc/pci-layerscape-ep.c | 37 +---- drivers/pci/controller/dwc/pci-layerscape.c | 67 +-------- drivers/pci/controller/dwc/pci-meson.c | 53 ++----- drivers/pci/controller/dwc/pcie-al.c | 29 +--- drivers/pci/controller/dwc/pcie-armada8k.c | 37 ++--- drivers/pci/controller/dwc/pcie-artpec6.c | 76 +--------- .../pci/controller/dwc/pcie-designware-ep.c | 58 +++---- .../pci/controller/dwc/pcie-designware-host.c | 139 ++++++++++------- .../pci/controller/dwc/pcie-designware-plat.c | 70 +-------- drivers/pci/controller/dwc/pcie-designware.c | 93 +++++++++++- drivers/pci/controller/dwc/pcie-designware.h | 24 +-- drivers/pci/controller/dwc/pcie-histb.c | 37 ++--- drivers/pci/controller/dwc/pcie-intel-gw.c | 67 ++------- drivers/pci/controller/dwc/pcie-kirin.c | 62 +------- drivers/pci/controller/dwc/pcie-qcom.c | 38 +---- drivers/pci/controller/dwc/pcie-spear13xx.c | 62 +++----- drivers/pci/controller/dwc/pcie-tegra194.c | 41 +---- drivers/pci/controller/dwc/pcie-uniphier-ep.c | 38 +---- drivers/pci/controller/dwc/pcie-uniphier.c | 51 +------ 23 files changed, 356 insertions(+), 1032 deletions(-)
--
2.25.1
Rob Herring
reviewerPATCH v2 1/16 PCI: dwc: Support multiple ATU memory regions
The current ATU setup only supports a single memory resource which isn't sufficient if there are also prefetchable memory regions. In order to support multiple memory regions, we need to move away from fixed ATU slots and rework the assignment. As there's always an ATU entry for config space, let's assign index 0 to config space. Then we assign memory resources to index 1 and up. Finally, if we have an I/O region and slots remaining, we assign the I/O region last. If there aren't remaining slots, we keep the same config and I/O space sharing.
--- .../pci/controller/dwc/pcie-designware-host.c | 54 +++++++++++-------- drivers/pci/controller/dwc/pcie-designware.h | 6 +-- 2 files changed, 34 insertions(+), 26 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +32 -22
@@ -464,9 +464,7 @@ static void __iomem *dw_pcie_other_conf_map_bus(struct pci_bus *bus, type =PCIE_ATU_TYPE_CFG1 ; -dw_pcie_prog_outbound_atu (pci,PCIE_ATU_REGION_INDEX1 , - type, pp->cfg0_base, - busdev, pp->cfg0_size); +dw_pcie_prog_outbound_atu (pci,0 , type, pp->cfg0_base, busdev, pp->cfg0_size);return pp->va_cfg0_base + where; }
@@ -480,9 +478,8 @@ static int dw_pcie_rd_other_conf(struct pci_bus *bus, unsigned int devfn, ret =pci_generic_config_read (bus, devfn, where, size, val); -if (!ret && pci->num_viewport <=2 ) -dw_pcie_prog_outbound_atu (pci,PCIE_ATU_REGION_INDEX1 , -PCIE_ATU_TYPE_IO , pp->io_base, +if (!ret && pci->io_cfg_atu_shared) +dw_pcie_prog_outbound_atu (pci,0 ,PCIE_ATU_TYPE_IO , pp->io_base, pp->io_bus_addr, pp->io_size);return ret;
@@ -497,9 +494,8 @@ static int dw_pcie_wr_other_conf(struct pci_bus *bus, unsigned int devfn, ret =pci_generic_config_write (bus, devfn, where, size, val); -if (!ret && pci->num_viewport <=2 ) -dw_pcie_prog_outbound_atu (pci,PCIE_ATU_REGION_INDEX1 , -PCIE_ATU_TYPE_IO , pp->io_base, +if (!ret && pci->io_cfg_atu_shared) +dw_pcie_prog_outbound_atu (pci,0 ,PCIE_ATU_TYPE_IO , pp->io_base, pp->io_bus_addr, pp->io_size);return ret;
@@ -586,21 +582,35 @@ void dw_pcie_setup_rc(struct pcie_port *pp)* ATU, so we should not program the ATU here. */ if (pp->bridge->child_ops == &dw_child_pcie_ops) { -struct resource_entry *tmp, *entry =NULL ; +int atu_idx =0 ; +struct resource_entry *entry;/* Get last memory resource entry */ -resource_list_for_each_entry (tmp, &pp->bridge->windows) -if (resource_type (tmp->res) ==IORESOURCE_MEM ) - entry = tmp; - -dw_pcie_prog_outbound_atu (pci,PCIE_ATU_REGION_INDEX0 , -PCIE_ATU_TYPE_MEM , entry->res->start, - entry->res->start - entry->offset, -resource_size (entry->res)); -if (pci->num_viewport >2 ) -dw_pcie_prog_outbound_atu (pci,PCIE_ATU_REGION_INDEX2 , -PCIE_ATU_TYPE_IO , pp->io_base, - pp->io_bus_addr, pp->io_size); +resource_list_for_each_entry (entry, &pp->bridge->windows) { +if (resource_type (entry->res) !=IORESOURCE_MEM ) +continue ; + +if (pci->num_viewport <= ++atu_idx) +break ; + +dw_pcie_prog_outbound_atu (pci, atu_idx, +PCIE_ATU_TYPE_MEM , entry->res->start, + entry->res->start - entry->offset, +resource_size (entry->res)); + } + +if (pp->io_size) { +if (pci->num_viewport > ++atu_idx) +dw_pcie_prog_outbound_atu (pci, atu_idx, +PCIE_ATU_TYPE_IO , pp->io_base, + pp->io_bus_addr, pp->io_size); +else + pci->io_cfg_atu_shared = true; + } + +if (pci->num_viewport <= atu_idx) +dev_warn (pci->dev,"Resources exceed number of ATU entries (%d)" , + pci->num_viewport); }dw_pcie_writel_dbi (pci,PCI_BASE_ADDRESS_0 ,0 );
drivers/pci/controller/dwc/pcie-designware.h +2 -4
@@ -80,9 +80,6 @@#define PCIE_ATU_VIEWPORT 0x900#define PCIE_ATU_REGION_INBOUND BIT(31)#define PCIE_ATU_REGION_OUTBOUND 0 -#define PCIE_ATU_REGION_INDEX2 0x2 -#define PCIE_ATU_REGION_INDEX1 0x1 -#define PCIE_ATU_REGION_INDEX0 0x0#define PCIE_ATU_CR1 0x904#define PCIE_ATU_TYPE_MEM 0x0#define PCIE_ATU_TYPE_IO 0x2
@@ -266,7 +263,6 @@ struct dw_pcie {/* Used when iatu_unroll_enabled is true */ void __iomem *atu_base;u32 num_viewport; -u8 iatu_unroll_enabled;struct pcie_port pp;struct dw_pcie_ep ep;const struct dw_pcie_ops *ops;
@@ -274,6 +270,8 @@ struct dw_pcie {int num_lanes;int link_gen;u8 n_fts[2 ]; + bool iatu_unroll_enabled: 1; + bool io_cfg_atu_shared: 1; };#define to_dw_pcie_from_pp (port) container_of((port), struct dw_pcie, pp)
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 2/16 PCI: dwc/intel-gw: Move ATU offset out of driver match data
In reply to Rob HerringThe ATU offset should be a register range in DT called 'atu', not driver match data. Any future platforms with a different ATU offset should add it to their DT.
This is also in preparation to do DBI resource setup in the core DWC code, so let's move setting atu_base later in intel_pcie_rc_setup().
--- drivers/pci/controller/dwc/pcie-intel-gw.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-intel-gw.c +7 -6
@@ -58,7 +58,6 @@struct intel_pcie_soc {unsigned int pcie_ver; -unsigned int pcie_atu_offset;u32 num_viewport; };
@@ -155,11 +154,15 @@ static void intel_pcie_init_n_fts(struct dw_pcie *pci)static void intel_pcie_rc_setup (struct intel_pcie_port *lpp) { +struct dw_pcie *pci = &lpp->pci; + + pci->atu_base = pci->dbi_base +0xC0000 ; +intel_pcie_ltssm_disable (lpp);intel_pcie_link_setup (lpp); -intel_pcie_init_n_fts (&lpp->pci); -dw_pcie_setup_rc (&lpp->pci.pp); -dw_pcie_upconfig_setup (&lpp->pci); +intel_pcie_init_n_fts (pci); +dw_pcie_setup_rc (&pci->pp); +dw_pcie_upconfig_setup (pci); }static int intel_pcie_ep_rst_init (struct intel_pcie_port *lpp)
@@ -425,7 +428,6 @@ static const struct dw_pcie_host_ops intel_pcie_dw_ops = {static const struct intel_pcie_soc pcie_data = { .pcie_ver =0x520A , - .pcie_atu_offset =0xC0000 , .num_viewport =3 , };
@@ -461,7 +463,6 @@ static int intel_pcie_probe(struct platform_device *pdev) pci->ops = &intel_pcie_ops; pci->version = data->pcie_ver; - pci->atu_base = pci->dbi_base + data->pcie_atu_offset; pp->ops = &intel_pcie_dw_ops; ret =dw_pcie_host_init (pp);
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 3/16 PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into common code
In reply to Rob HerringMost DWC drivers use the common register resource names "dbi", "dbi2", and "addr_space", so let's move their setup into the DWC common code.
This means 'dbi_base' in particular is setup later, but it looks like no drivers touch DBI registers before dw_pcie_host_init or dw_pcie_ep_init.
---
v2:
- Fix Layerscape EP build error
--- drivers/pci/controller/dwc/pci-dra7xx.c | 8 ---- drivers/pci/controller/dwc/pci-keystone.c | 29 +----------- .../pci/controller/dwc/pci-layerscape-ep.c | 37 +-------------- drivers/pci/controller/dwc/pcie-al.c | 9 +--- drivers/pci/controller/dwc/pcie-artpec6.c | 43 ++---------------- .../pci/controller/dwc/pcie-designware-ep.c | 29 ++++++++++-- .../pci/controller/dwc/pcie-designware-host.c | 7 +++ .../pci/controller/dwc/pcie-designware-plat.c | 45 +------------------ drivers/pci/controller/dwc/pcie-intel-gw.c | 4 -- drivers/pci/controller/dwc/pcie-kirin.c | 5 --- drivers/pci/controller/dwc/pcie-qcom.c | 8 ---- drivers/pci/controller/dwc/pcie-spear13xx.c | 11 +---- drivers/pci/controller/dwc/pcie-tegra194.c | 22 --------- drivers/pci/controller/dwc/pcie-uniphier-ep.c | 38 +--------------- drivers/pci/controller/dwc/pcie-uniphier.c | 6 --- 15 files changed, 47 insertions(+), 254 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +0 -8
@@ -578,7 +578,6 @@ static int __init dra7xx_add_pcie_ep(struct dra7xx_pcie *dra7xx, {int ret;struct dw_pcie_ep *ep; -struct resource *res;struct device *dev = &pdev->dev;struct dw_pcie *pci = dra7xx->pci;
@@ -594,13 +593,6 @@ static int __init dra7xx_add_pcie_ep(struct dra7xx_pcie *dra7xx,if (IS_ERR (pci->dbi_base2))return PTR_ERR (pci->dbi_base2); - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"addr_space" ); -if (!res) -return -EINVAL ; - - ep->phys_base = res->start; - ep->addr_size =resource_size (res); - ret =dw_pcie_ep_init (ep);if (ret) {dev_err (dev,"failed to initialize endpoint\n" );
drivers/pci/controller/dwc/pci-keystone.c +1 -28
@@ -977,33 +977,6 @@ static const struct dw_pcie_ep_ops ks_pcie_am654_ep_ops = { .get_features = &ks_pcie_am654_get_features, }; -static int __init ks_pcie_add_pcie_ep (struct keystone_pcie *ks_pcie, -struct platform_device *pdev) -{ -int ret; -struct dw_pcie_ep *ep; -struct resource *res; -struct device *dev = &pdev->dev; -struct dw_pcie *pci = ks_pcie->pci; - - ep = &pci->ep; - - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"addr_space" ); -if (!res) -return -EINVAL ; - - ep->phys_base = res->start; - ep->addr_size =resource_size (res); - - ret =dw_pcie_ep_init (ep); -if (ret) { -dev_err (dev,"failed to initialize endpoint\n" ); -return ret; - } - -return 0 ; -} -static void ks_pcie_disable_phy (struct keystone_pcie *ks_pcie) {int num_lanes = ks_pcie->num_lanes;
@@ -1313,7 +1286,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev) } pci->ep.ops = ep_ops; - ret =ks_pcie_add_pcie_ep (ks_pcie, pdev); + ret =dw_pcie_ep_init (&pci->ep);if (ret <0 ) goto err_get_sync;break ;
drivers/pci/controller/dwc/pci-layerscape-ep.c +2 -35
@@ -18,8 +18,6 @@#include "pcie-designware.h" -#define PCIE_DBI2_OFFSET 0x1000/* DBI2 base address*/ -#define to_ls_pcie_ep (x) dev_get_drvdata((x)->dev)struct ls_pcie_ep_drvdata {
@@ -124,34 +122,6 @@ static const struct of_device_id ls_pcie_ep_of_match[] = { { }, }; -static int __init ls_add_pcie_ep (struct ls_pcie_ep *pcie, -struct platform_device *pdev) -{ -struct dw_pcie *pci = pcie->pci; -struct device *dev = pci->dev; -struct dw_pcie_ep *ep; -struct resource *res; -int ret; - - ep = &pci->ep; - ep->ops = pcie->drvdata->ops; - - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"addr_space" ); -if (!res) -return -EINVAL ; - - ep->phys_base = res->start; - ep->addr_size =resource_size (res); - - ret =dw_pcie_ep_init (ep); -if (ret) { -dev_err (dev,"failed to initialize endpoint\n" ); -return ret; - } - -return 0 ; -} -static int __init ls_pcie_ep_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -159,7 +129,6 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)struct ls_pcie_ep *pcie;struct pci_epc_features *ls_epc;struct resource *dbi_base; -int ret; pcie =devm_kzalloc (dev,sizeof (*pcie),GFP_KERNEL );if (!pcie)
@@ -188,13 +157,11 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)if (IS_ERR (pci->dbi_base))return PTR_ERR (pci->dbi_base); - pci->dbi_base2 = pci->dbi_base +PCIE_DBI2_OFFSET ; + pci->ep.ops = &ls_pcie_ep_ops;platform_set_drvdata (pdev, pcie); - ret =ls_add_pcie_ep (pcie, pdev); - -return ret; +return dw_pcie_ep_init (&pci->ep); }static struct platform_driver ls_pcie_ep_driver = {
drivers/pci/controller/dwc/pcie-al.c +1 -8
@@ -347,7 +347,6 @@ static int al_pcie_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct resource *controller_res;struct resource *ecam_res; -struct resource *dbi_res;struct al_pcie *al_pcie;struct dw_pcie *pci;
@@ -365,11 +364,6 @@ static int al_pcie_probe(struct platform_device *pdev) al_pcie->pci = pci; al_pcie->dev = dev; - dbi_res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi" ); - pci->dbi_base =devm_pci_remap_cfg_resource (dev, dbi_res); -if (IS_ERR (pci->dbi_base)) -return PTR_ERR (pci->dbi_base); - ecam_res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"config" );if (!ecam_res) {dev_err (dev,"couldn't find 'config' reg in DT\n" );
@@ -386,8 +380,7 @@ static int al_pcie_probe(struct platform_device *pdev)return PTR_ERR (al_pcie->controller_base); } -dev_dbg (dev,"From DT: dbi_base: %pR, controller_base: %pR\n" , - dbi_res, controller_res); +dev_dbg (dev,"From DT: controller_base: %pR\n" , controller_res);platform_set_drvdata (pdev, al_pcie);
drivers/pci/controller/dwc/pcie-artpec6.c +4 -39
61 lines not on this page · raw message
drivers/pci/controller/dwc/pcie-designware-ep.c +26 -3
@@ -7,6 +7,7 @@*/ #include <linux/of.h> +#include <linux/platform_device.h> #include "pcie-designware.h" #include <linux/pci-epc.h>
@@ -676,20 +677,42 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)int ret;void *addr;u8 func_no; +struct resource *res;struct pci_epc *epc;struct dw_pcie *pci =to_dw_pcie_from_ep (ep);struct device *dev = pci->dev; +struct platform_device *pdev =to_platform_device (dev);struct device_node *np = dev->of_node;const struct pci_epc_features *epc_features;struct dw_pcie_ep_func *ep_func;INIT_LIST_HEAD (&ep->func_list); -if (!pci->dbi_base || !pci->dbi_base2) { -dev_err (dev,"dbi_base/dbi_base2 is not populated\n" ); -return -EINVAL ; +if (!pci->dbi_base) { + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi" ); + pci->dbi_base =devm_pci_remap_cfg_resource (dev, res); +if (IS_ERR (pci->dbi_base)) +return PTR_ERR (pci->dbi_base); + } + +if (!pci->dbi_base2) { + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi2" ); +if (!res) + pci->dbi_base2 = pci->dbi_base +SZ_4K ; +else { + pci->dbi_base2 =devm_pci_remap_cfg_resource (dev, res); +if (IS_ERR (pci->dbi_base2)) +return PTR_ERR (pci->dbi_base2); + } } + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"addr_space" ); +if (!res) +return -EINVAL ; + + ep->phys_base = res->start; + ep->addr_size =resource_size (res); + ret =of_property_read_u32 (np,"num-ib-windows" , &ep->num_ib_windows);if (ret <0 ) {dev_err (dev,"Unable to read *num-ib-windows* property\n" );
drivers/pci/controller/dwc/pcie-designware-host.c +7 -0
@@ -310,6 +310,13 @@ int dw_pcie_host_init(struct pcie_port *pp)dev_err (dev,"Missing *config* reg space\n" ); } +if (!pci->dbi_base) { +struct resource *dbi_res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi" ); + pci->dbi_base =devm_pci_remap_cfg_resource (dev, dbi_res); +if (IS_ERR (pci->dbi_base)) +return PTR_ERR (pci->dbi_base); + } + bridge =devm_pci_alloc_host_bridge (dev,0 );if (!bridge)return -ENOMEM ;
drivers/pci/controller/dwc/pcie-designware-plat.c +2 -43
68 lines not on this page · raw message
drivers/pci/controller/dwc/pcie-intel-gw.c +0 -4
@@ -237,10 +237,6 @@ static int intel_pcie_get_resources(struct platform_device *pdev)struct device *dev = pci->dev;int ret; - pci->dbi_base =devm_platform_ioremap_resource_byname (pdev,"dbi" ); -if (IS_ERR (pci->dbi_base)) -return PTR_ERR (pci->dbi_base); - lpp->core_clk =devm_clk_get (dev,NULL );if (IS_ERR (lpp->core_clk)) { ret =PTR_ERR (lpp->core_clk);
drivers/pci/controller/dwc/pcie-kirin.c +0 -5
@@ -157,11 +157,6 @@ static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie,if (IS_ERR (kirin_pcie->phy_base))return PTR_ERR (kirin_pcie->phy_base); - kirin_pcie->pci->dbi_base = -devm_platform_ioremap_resource_byname (pdev,"dbi" ); -if (IS_ERR (kirin_pcie->pci->dbi_base)) -return PTR_ERR (kirin_pcie->pci->dbi_base); - kirin_pcie->crgctrl =syscon_regmap_lookup_by_compatible ("hisilicon,hi3660-crgctrl" );if (IS_ERR (kirin_pcie->crgctrl))
drivers/pci/controller/dwc/pcie-qcom.c +0 -8
@@ -1368,7 +1368,6 @@ static const struct dw_pcie_ops dw_pcie_ops = {static int qcom_pcie_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct resource *res;struct pcie_port *pp;struct dw_pcie *pci;struct qcom_pcie *pcie;
@@ -1407,13 +1406,6 @@ static int qcom_pcie_probe(struct platform_device *pdev) goto err_pm_runtime_put; } - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi" ); - pci->dbi_base =devm_pci_remap_cfg_resource (dev, res); -if (IS_ERR (pci->dbi_base)) { - ret =PTR_ERR (pci->dbi_base); - goto err_pm_runtime_put; - } - pcie->elbi =devm_platform_ioremap_resource_byname (pdev,"elbi" );if (IS_ERR (pcie->elbi)) { ret =PTR_ERR (pcie->elbi);
drivers/pci/controller/dwc/pcie-spear13xx.c +2 -9
@@ -152,6 +152,8 @@ static int spear13xx_pcie_host_init(struct pcie_port *pp)struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct spear13xx_pcie *spear13xx_pcie =to_spear13xx_pcie (pci); + spear13xx_pcie->app_base = pci->dbi_base +0x2000 ; +spear13xx_pcie_establish_link (spear13xx_pcie);spear13xx_pcie_enable_interrupts (spear13xx_pcie);
@@ -203,7 +205,6 @@ static int spear13xx_pcie_probe(struct platform_device *pdev)struct dw_pcie *pci;struct spear13xx_pcie *spear13xx_pcie;struct device_node *np = dev->of_node; -struct resource *dbi_base;int ret; spear13xx_pcie =devm_kzalloc (dev,sizeof (*spear13xx_pcie),GFP_KERNEL );
@@ -242,14 +243,6 @@ static int spear13xx_pcie_probe(struct platform_device *pdev)return ret; } - dbi_base =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi" ); - pci->dbi_base =devm_pci_remap_cfg_resource (dev, dbi_base); -if (IS_ERR (pci->dbi_base)) { - ret =PTR_ERR (pci->dbi_base); - goto fail_clk; - } - spear13xx_pcie->app_base = pci->dbi_base +0x2000 ; -if (of_property_read_bool (np,"st,pcie-is-gen1" )) pci->link_gen =1 ;
drivers/pci/controller/dwc/pcie-tegra194.c +0 -22
@@ -1907,19 +1907,12 @@ static int tegra_pcie_config_ep(struct tegra_pcie_dw *pcie,struct dw_pcie *pci = &pcie->pci;struct device *dev = pcie->dev;struct dw_pcie_ep *ep; -struct resource *res;char *name;int ret; ep = &pci->ep; ep->ops = &pcie_ep_ops; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"addr_space" ); -if (!res) -return -EINVAL ; - - ep->phys_base = res->start; - ep->addr_size =resource_size (res); ep->page_size =SZ_64K ; ret =gpiod_set_debounce (pcie->pex_rst_gpiod,PERST_DEBOUNCE_TIME );
@@ -1982,7 +1975,6 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct resource *atu_dma_res;struct tegra_pcie_dw *pcie; -struct resource *dbi_res;struct pcie_port *pp;struct dw_pcie *pci;struct phy **phys;
@@ -2091,20 +2083,6 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev) pcie->phys = phys; - dbi_res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi" ); -if (!dbi_res) { -dev_err (dev,"Failed to find \"dbi\" region\n" ); -return -ENODEV ; - } - pcie->dbi_res = dbi_res; - - pci->dbi_base =devm_ioremap_resource (dev, dbi_res); -if (IS_ERR (pci->dbi_base)) -return PTR_ERR (pci->dbi_base); - -/* Tegra HW locates DBI2 at a fixed offset from DBI */ - pci->dbi_base2 = pci->dbi_base +0x1000 ; - atu_dma_res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"atu_dma" );if (!atu_dma_res) {
drivers/pci/controller/dwc/pcie-uniphier-ep.c +2 -36
@@ -218,35 +218,6 @@ static const struct dw_pcie_ep_ops uniphier_pcie_ep_ops = { .get_features = uniphier_pcie_get_features, }; -static int uniphier_add_pcie_ep (struct uniphier_pcie_ep_priv *priv, -struct platform_device *pdev) -{ -struct dw_pcie *pci = &priv->pci; -struct dw_pcie_ep *ep = &pci->ep; -struct device *dev = &pdev->dev; -struct resource *res; -int ret; - - ep->ops = &uniphier_pcie_ep_ops; - - pci->dbi_base2 =devm_platform_ioremap_resource_byname (pdev,"dbi2" ); -if (IS_ERR (pci->dbi_base2)) -return PTR_ERR (pci->dbi_base2); - - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"addr_space" ); -if (!res) -return -EINVAL ; - - ep->phys_base = res->start; - ep->addr_size =resource_size (res); - - ret =dw_pcie_ep_init (ep); -if (ret) -dev_err (dev,"Failed to initialize endpoint (%d)\n" , ret); - -return ret; -} -static int uniphier_pcie_ep_enable (struct uniphier_pcie_ep_priv *priv) {int ret;
@@ -300,7 +271,6 @@ static int uniphier_pcie_ep_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct uniphier_pcie_ep_priv *priv; -struct resource *res;int ret; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
@@ -314,11 +284,6 @@ static int uniphier_pcie_ep_probe(struct platform_device *pdev) priv->pci.dev = dev; priv->pci.ops = &dw_pcie_ops; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi" ); - priv->pci.dbi_base =devm_pci_remap_cfg_resource (dev, res); -if (IS_ERR (priv->pci.dbi_base)) -return PTR_ERR (priv->pci.dbi_base); - priv->base =devm_platform_ioremap_resource_byname (pdev,"link" );if (IS_ERR (priv->base))return PTR_ERR (priv->base);
@@ -352,7 +317,8 @@ static int uniphier_pcie_ep_probe(struct platform_device *pdev)if (ret)return ret; -return uniphier_add_pcie_ep (priv, pdev); + priv->pci.ep.ops = &uniphier_pcie_ep_ops; +return dw_pcie_ep_init (&priv->pci.ep); }static const struct pci_epc_features uniphier_pro5_data = {
drivers/pci/controller/dwc/pcie-uniphier.c +0 -6
@@ -400,7 +400,6 @@ static int uniphier_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct uniphier_pcie_priv *priv; -struct resource *res;int ret; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
@@ -410,11 +409,6 @@ static int uniphier_pcie_probe(struct platform_device *pdev) priv->pci.dev = dev; priv->pci.ops = &dw_pcie_ops; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dbi" ); - priv->pci.dbi_base =devm_pci_remap_cfg_resource (dev, res); -if (IS_ERR (priv->pci.dbi_base)) -return PTR_ERR (priv->pci.dbi_base); - priv->base =devm_platform_ioremap_resource_byname (pdev,"link" );if (IS_ERR (priv->base))return PTR_ERR (priv->base);
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 4/16 PCI: dwc/intel-gw: Remove some unneeded function wrappers
In reply to Rob HerringRemove some of the pointless levels of functions that just wrap or group a series of other functions.
--- drivers/pci/controller/dwc/pcie-intel-gw.c | 47 ++++++++-------------- 1 file changed, 16 insertions(+), 31 deletions(-)
drivers/pci/controller/dwc/pcie-intel-gw.c +16 -31
@@ -152,19 +152,6 @@ static void intel_pcie_init_n_fts(struct dw_pcie *pci) pci->n_fts[0 ] =PORT_AFR_N_FTS_GEN12_DFT ; } -static void intel_pcie_rc_setup (struct intel_pcie_port *lpp) -{ -struct dw_pcie *pci = &lpp->pci; - - pci->atu_base = pci->dbi_base +0xC0000 ; - -intel_pcie_ltssm_disable (lpp); -intel_pcie_link_setup (lpp); -intel_pcie_init_n_fts (pci); -dw_pcie_setup_rc (&pci->pp); -dw_pcie_upconfig_setup (pci); -} -static int intel_pcie_ep_rst_init (struct intel_pcie_port *lpp) {struct device *dev = lpp->pci.dev;
@@ -216,14 +203,6 @@ static void intel_pcie_device_rst_deassert(struct intel_pcie_port *lpp)gpiod_set_value_cansleep (lpp->reset_gpio,0 ); } -static int intel_pcie_app_logic_setup (struct intel_pcie_port *lpp) -{ -intel_pcie_device_rst_deassert (lpp); -intel_pcie_ltssm_enable (lpp); - -return dw_pcie_wait_for_link (&lpp->pci); -} -static void intel_pcie_core_irq_disable (struct intel_pcie_port *lpp) {pcie_app_wr (lpp,PCIE_APP_IRNEN ,0 );
@@ -273,11 +252,6 @@ static int intel_pcie_get_resources(struct platform_device *pdev)return 0 ; } -static void intel_pcie_deinit_phy (struct intel_pcie_port *lpp) -{ -phy_exit (lpp->phy); -} -static int intel_pcie_wait_l2 (struct intel_pcie_port *lpp) {u32 value;
@@ -314,6 +288,7 @@ static void intel_pcie_turn_off(struct intel_pcie_port *lpp)static int intel_pcie_host_setup (struct intel_pcie_port *lpp) {int ret; +struct dw_pcie *pci = &lpp->pci;intel_pcie_core_rst_assert (lpp);intel_pcie_device_rst_assert (lpp);
@@ -330,8 +305,18 @@ static int intel_pcie_host_setup(struct intel_pcie_port *lpp) goto clk_err; } -intel_pcie_rc_setup (lpp); - ret =intel_pcie_app_logic_setup (lpp); + pci->atu_base = pci->dbi_base +0xC0000 ; + +intel_pcie_ltssm_disable (lpp); +intel_pcie_link_setup (lpp); +intel_pcie_init_n_fts (pci); +dw_pcie_setup_rc (&pci->pp); +dw_pcie_upconfig_setup (pci); + +intel_pcie_device_rst_deassert (lpp); +intel_pcie_ltssm_enable (lpp); + + ret =dw_pcie_wait_for_link (pci);if (ret) goto app_init_err;
@@ -345,7 +330,7 @@ static int intel_pcie_host_setup(struct intel_pcie_port *lpp)clk_disable_unprepare (lpp->core_clk); clk_err:intel_pcie_core_rst_assert (lpp); -intel_pcie_deinit_phy (lpp); +phy_exit (lpp->phy);return ret; }
@@ -356,7 +341,7 @@ static void __intel_pcie_remove(struct intel_pcie_port *lpp)intel_pcie_turn_off (lpp);clk_disable_unprepare (lpp->core_clk);intel_pcie_core_rst_assert (lpp); -intel_pcie_deinit_phy (lpp); +phy_exit (lpp->phy); }static int intel_pcie_remove (struct platform_device *pdev)
@@ -380,7 +365,7 @@ static int __maybe_unused intel_pcie_suspend_noirq(struct device *dev)if (ret)return ret; -intel_pcie_deinit_phy (lpp); +phy_exit (lpp->phy);clk_disable_unprepare (lpp->core_clk);return ret; }
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 5/16 PCI: dwc: Ensure all outbound ATU windows are reset
In reply to Rob HerringThe Layerscape driver clears the ATU registers which may have been configured by the bootloader. Any driver could have the same issue and doing it for all drivers doesn't hurt, so let's move it into the common DWC code.
--- drivers/pci/controller/dwc/pci-layerscape.c | 14 -------------- drivers/pci/controller/dwc/pcie-designware-host.c | 5 +++++ 2 files changed, 5 insertions(+), 14 deletions(-)
drivers/pci/controller/dwc/pci-layerscape.c +0 -14
@@ -83,14 +83,6 @@ static void ls_pcie_drop_msg_tlp(struct ls_pcie *pcie)iowrite32 (val, pci->dbi_base +PCIE_STRFMR1 ); } -static void ls_pcie_disable_outbound_atus (struct ls_pcie *pcie) -{ -int i; - -for (i =0 ; i <PCIE_IATU_NUM ; i++) -dw_pcie_disable_atu (pcie->pci, i,DW_PCIE_REGION_OUTBOUND ); -} -static int ls1021_pcie_link_up (struct dw_pcie *pci) {u32 state;
@@ -136,12 +128,6 @@ static int ls_pcie_host_init(struct pcie_port *pp)struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct ls_pcie *pcie =to_ls_pcie (pci); -/* -* Disable outbound windows configured by the bootloader to avoid -* one transaction hitting multiple outbound windows. -* dw_pcie_setup_rc() will reconfigure the outbound windows. -*/ -ls_pcie_disable_outbound_atus (pcie);ls_pcie_fix_error_response (pcie);dw_pcie_dbi_ro_wr_en (pci);
drivers/pci/controller/dwc/pcie-designware-host.c +5 -0
@@ -534,6 +534,7 @@ static struct pci_ops dw_pcie_ops = {void dw_pcie_setup_rc (struct pcie_port *pp) { +int i;u32 val, ctrl, num_ctrls;struct dw_pcie *pci =to_dw_pcie_from_pp (pp);
@@ -583,6 +584,10 @@ void dw_pcie_setup_rc(struct pcie_port *pp)PCI_COMMAND_MASTER |PCI_COMMAND_SERR ;dw_pcie_writel_dbi (pci,PCI_COMMAND , val); +/* Ensure all outbound windows are disabled so there are multiple matches */ +for (i =0 ; i < pci->num_viewport; i++) +dw_pcie_disable_atu (pci, i,DW_PCIE_REGION_OUTBOUND ); +/* * If the platform provides its own child bus config accesses, it means * the platform uses its own address translation component rather than
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 6/16 PCI: dwc/dra7xx: Use the common MSI irq_chip
In reply to Rob HerringThe dra7xx MSI irq_chip implementation is identical to the default DWC one. The only difference is the interrupt handler as the MSI interrupt is muxed with other interrupts, but that doesn't affect the irq_chip part of it.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 125 ------------------------ 1 file changed, 125 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +0 -125
@@ -377,133 +377,8 @@ static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp)return 0 ; } -static void dra7xx_pcie_setup_msi_msg (struct irq_data *d,struct msi_msg *msg) -{ -struct pcie_port *pp =irq_data_get_irq_chip_data (d); -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -u64 msi_target; - - msi_target = (u64 )pp->msi_data; - - msg->address_lo =lower_32_bits (msi_target); - msg->address_hi =upper_32_bits (msi_target); - - msg->data = d->hwirq; - -dev_dbg (pci->dev,"msi#%d address_hi %#x address_lo %#x\n" , - (int )d->hwirq, msg->address_hi, msg->address_lo); -} - -static int dra7xx_pcie_msi_set_affinity (struct irq_data *d, -const struct cpumask *mask, -bool force) -{ -return -EINVAL ; -} - -static void dra7xx_pcie_bottom_mask (struct irq_data *d) -{ -struct pcie_port *pp =irq_data_get_irq_chip_data (d); -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -unsigned int res, bit, ctrl; -unsigned long flags; - -raw_spin_lock_irqsave (&pp->lock, flags); - - ctrl = d->hwirq /MAX_MSI_IRQS_PER_CTRL ; - res = ctrl *MSI_REG_CTRL_BLOCK_SIZE ; - bit = d->hwirq %MAX_MSI_IRQS_PER_CTRL ; - - pp->irq_mask[ctrl] |=BIT (bit); -dw_pcie_writel_dbi (pci,PCIE_MSI_INTR0_MASK + res, - pp->irq_mask[ctrl]); - -raw_spin_unlock_irqrestore (&pp->lock, flags); -} - -static void dra7xx_pcie_bottom_unmask (struct irq_data *d) -{ -struct pcie_port *pp =irq_data_get_irq_chip_data (d); -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -unsigned int res, bit, ctrl; -unsigned long flags; - -raw_spin_lock_irqsave (&pp->lock, flags); - - ctrl = d->hwirq /MAX_MSI_IRQS_PER_CTRL ; - res = ctrl *MSI_REG_CTRL_BLOCK_SIZE ; - bit = d->hwirq %MAX_MSI_IRQS_PER_CTRL ; - - pp->irq_mask[ctrl] &= ~BIT (bit); -dw_pcie_writel_dbi (pci,PCIE_MSI_INTR0_MASK + res, - pp->irq_mask[ctrl]); - -raw_spin_unlock_irqrestore (&pp->lock, flags); -} - -static void dra7xx_pcie_bottom_ack (struct irq_data *d) -{ -struct pcie_port *pp =irq_data_get_irq_chip_data (d); -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -unsigned int res, bit, ctrl; - - ctrl = d->hwirq /MAX_MSI_IRQS_PER_CTRL ; - res = ctrl *MSI_REG_CTRL_BLOCK_SIZE ; - bit = d->hwirq %MAX_MSI_IRQS_PER_CTRL ; - -dw_pcie_writel_dbi (pci,PCIE_MSI_INTR0_STATUS + res,BIT (bit)); -} - -static struct irq_chip dra7xx_pci_msi_bottom_irq_chip = { - .name ="DRA7XX-PCI-MSI" , - .irq_ack = dra7xx_pcie_bottom_ack, - .irq_compose_msi_msg = dra7xx_pcie_setup_msi_msg, - .irq_set_affinity = dra7xx_pcie_msi_set_affinity, - .irq_mask = dra7xx_pcie_bottom_mask, - .irq_unmask = dra7xx_pcie_bottom_unmask, -}; - -static int dra7xx_pcie_msi_host_init (struct pcie_port *pp) -{ -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -struct device *dev = pci->dev; -u32 ctrl, num_ctrls; -int ret; - - pp->msi_irq_chip = &dra7xx_pci_msi_bottom_irq_chip; - - num_ctrls = pp->num_vectors /MAX_MSI_IRQS_PER_CTRL ; -/* Initialize IRQ Status array */ -for (ctrl =0 ; ctrl < num_ctrls; ctrl++) { - pp->irq_mask[ctrl] = ~0 ; -dw_pcie_writel_dbi (pci,PCIE_MSI_INTR0_MASK + - (ctrl *MSI_REG_CTRL_BLOCK_SIZE ), - pp->irq_mask[ctrl]); -dw_pcie_writel_dbi (pci,PCIE_MSI_INTR0_ENABLE + - (ctrl *MSI_REG_CTRL_BLOCK_SIZE ), - ~0 ); - } - - ret =dw_pcie_allocate_domains (pp); -if (ret) -return ret; - - pp->msi_data =dma_map_single_attrs (dev, &pp->msi_msg, -sizeof (pp->msi_msg), -DMA_FROM_DEVICE , -DMA_ATTR_SKIP_CPU_SYNC ); - ret =dma_mapping_error (dev, pp->msi_data); -if (ret) { -dev_err (dev,"Failed to map MSI data\n" ); - pp->msi_data =0 ; -dw_pcie_free_msi (pp); - } -return ret; -} -static const struct dw_pcie_host_ops dra7xx_pcie_host_ops = { .host_init = dra7xx_pcie_host_init, - .msi_host_init = dra7xx_pcie_msi_host_init, };static void dra7xx_pcie_ep_init (struct dw_pcie_ep *ep)
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 7/16 PCI: dwc: Drop the .set_num_vectors() host op
In reply to Rob HerringThere's no reason for the .set_num_vectors() host op. Drivers needing a non-default value can just initialize pcie_port.num_vectors directly.
--- .../pci/controller/dwc/pcie-designware-host.c | 19 ++++--------------- .../pci/controller/dwc/pcie-designware-plat.c | 7 +------ drivers/pci/controller/dwc/pcie-designware.h | 1 - drivers/pci/controller/dwc/pcie-tegra194.c | 7 +------ 4 files changed, 6 insertions(+), 28 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +4 -15
@@ -365,22 +365,11 @@ int dw_pcie_host_init(struct pcie_port *pp) pci->link_gen =of_pci_get_max_link_speed (np);if (pci_msi_enabled ()) { -/* -* If a specific SoC driver needs to change the -* default number of vectors, it needs to implement -* the set_num_vectors callback. -*/ -if (!pp->ops->set_num_vectors) { +if (!pp->num_vectors) { pp->num_vectors =MSI_DEF_NUM_VECTORS ; - }else { - pp->ops->set_num_vectors (pp); - -if (pp->num_vectors >MAX_MSI_IRQS || - pp->num_vectors ==0 ) { -dev_err (dev, -"Invalid number of vectors\n" ); -return -EINVAL ; - } + }else if (pp->num_vectors >MAX_MSI_IRQS ) { +dev_err (dev,"Invalid number of vectors\n" ); +return -EINVAL ; }if (!pp->ops->msi_host_init) {
drivers/pci/controller/dwc/pcie-designware-plat.c +1 -6
@@ -44,14 +44,8 @@ static int dw_plat_pcie_host_init(struct pcie_port *pp)return 0 ; } -static void dw_plat_set_num_vectors (struct pcie_port *pp) -{ - pp->num_vectors =MAX_MSI_IRQS ; -} -static const struct dw_pcie_host_ops dw_plat_pcie_host_ops = { .host_init = dw_plat_pcie_host_init, - .set_num_vectors = dw_plat_set_num_vectors, };static int dw_plat_pcie_establish_link (struct dw_pcie *pci)
@@ -128,6 +122,7 @@ static int dw_plat_add_pcie_port(struct dw_plat_pcie *dw_plat_pcie,return pp->msi_irq; } + pp->num_vectors =MAX_MSI_IRQS ; pp->ops = &dw_plat_pcie_host_ops; ret =dw_pcie_host_init (pp);
drivers/pci/controller/dwc/pcie-designware.h +0 -1
@@ -171,7 +171,6 @@ enum dw_pcie_device_mode {struct dw_pcie_host_ops {int (*host_init)(struct pcie_port *pp); -void (*set_num_vectors)(struct pcie_port *pp);int (*msi_host_init)(struct pcie_port *pp); };
drivers/pci/controller/dwc/pcie-tegra194.c +1 -6
@@ -990,11 +990,6 @@ static int tegra_pcie_dw_link_up(struct dw_pcie *pci)return !!(val &PCI_EXP_LNKSTA_DLLLA ); } -static void tegra_pcie_set_msi_vec_num (struct pcie_port *pp) -{ - pp->num_vectors =MAX_MSI_IRQS ; -} -static int tegra_pcie_dw_start_link (struct dw_pcie *pci) {struct tegra_pcie_dw *pcie =to_tegra_pcie (pci);
@@ -1019,7 +1014,6 @@ static const struct dw_pcie_ops tegra_dw_pcie_ops = {static struct dw_pcie_host_ops tegra_pcie_dw_host_ops = { .host_init = tegra_pcie_dw_host_init, - .set_num_vectors = tegra_pcie_set_msi_vec_num, };static void tegra_pcie_disable_phy (struct tegra_pcie_dw *pcie)
@@ -1995,6 +1989,7 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev) pci->n_fts[1 ] =FTS_VAL ; pp = &pci->pp; + pp->num_vectors =MAX_MSI_IRQS ; pcie->dev = &pdev->dev; pcie->mode = (enum dw_pcie_device_mode )data->mode;
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 8/16 PCI: dwc: Move MSI interrupt setup into DWC common code
In reply to Rob HerringPlatforms using the built-in DWC MSI controller all have a dedicated interrupt with "msi" name or at index 0, so let's move setting up the interrupt to the common DWC code.
spear13xx and dra7xx are the 2 oddballs with muxed interrupts, so we need to prevent configuring the MSI interrupt by setting msi_irq to negative.
---
v2:
- Make get_irq optional to avoid error message
--- drivers/pci/controller/dwc/pci-dra7xx.c | 3 +++ drivers/pci/controller/dwc/pci-exynos.c | 6 ----- drivers/pci/controller/dwc/pci-imx6.c | 6 ----- drivers/pci/controller/dwc/pci-meson.c | 6 ----- drivers/pci/controller/dwc/pcie-artpec6.c | 6 ----- .../pci/controller/dwc/pcie-designware-host.c | 11 +++++++++- .../pci/controller/dwc/pcie-designware-plat.c | 6 ----- drivers/pci/controller/dwc/pcie-histb.c | 6 ----- drivers/pci/controller/dwc/pcie-kirin.c | 22 ------------------- drivers/pci/controller/dwc/pcie-qcom.c | 8 ------- drivers/pci/controller/dwc/pcie-spear13xx.c | 1 + drivers/pci/controller/dwc/pcie-tegra194.c | 8 ------- drivers/pci/controller/dwc/pcie-uniphier.c | 6 ----- 13 files changed, 14 insertions(+), 81 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +3 -0
@@ -489,6 +489,9 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,if (pp->irq <0 )return pp->irq; +/* MSI IRQ is muxed */ + pp->msi_irq = -ENODEV ; + ret =dra7xx_pcie_init_irq_domain (pp);if (ret <0 )return ret;
drivers/pci/controller/dwc/pci-exynos.c +0 -6
@@ -415,12 +415,6 @@ static int __init exynos_add_pcie_port(struct exynos_pcie *ep,return ret; } -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =platform_get_irq (pdev,0 ); -if (pp->msi_irq <0 ) -return pp->msi_irq; - } - pp->ops = &exynos_pcie_host_ops; ret =dw_pcie_host_init (pp);
drivers/pci/controller/dwc/pci-imx6.c +0 -6
@@ -853,12 +853,6 @@ static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie,struct device *dev = &pdev->dev;int ret; -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =platform_get_irq_byname (pdev,"msi" ); -if (pp->msi_irq <0 ) -return pp->msi_irq; - } - pp->ops = &imx6_pcie_host_ops; ret =dw_pcie_host_init (pp);
drivers/pci/controller/dwc/pci-meson.c +0 -6
@@ -405,12 +405,6 @@ static int meson_add_pcie_port(struct meson_pcie *mp,struct device *dev = &pdev->dev;int ret; -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =platform_get_irq (pdev,0 ); -if (pp->msi_irq <0 ) -return pp->msi_irq; - } - pp->ops = &meson_pcie_host_ops; ret =dw_pcie_host_init (pp);
drivers/pci/controller/dwc/pcie-artpec6.c +0 -6
@@ -348,12 +348,6 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,struct device *dev = pci->dev;int ret; -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =platform_get_irq_byname (pdev,"msi" ); -if (pp->msi_irq <0 ) -return pp->msi_irq; - } - pp->ops = &artpec6_pcie_host_ops; ret =dw_pcie_host_init (pp);
drivers/pci/controller/dwc/pcie-designware-host.c +10 -1
@@ -373,13 +373,22 @@ int dw_pcie_host_init(struct pcie_port *pp) }if (!pp->ops->msi_host_init) { +if (!pp->msi_irq) { + pp->msi_irq =platform_get_irq_byname_optional (pdev,"msi" ); +if (pp->msi_irq <0 ) { + pp->msi_irq =platform_get_irq (pdev,0 ); +if (pp->msi_irq <0 ) +return pp->msi_irq; + } + } + pp->msi_irq_chip = &dw_pci_msi_bottom_irq_chip; ret =dw_pcie_allocate_domains (pp);if (ret)return ret; -if (pp->msi_irq) +if (pp->msi_irq >0 )irq_set_chained_handler_and_data (pp->msi_irq, dw_chained_msi_isr, pp);
drivers/pci/controller/dwc/pcie-designware-plat.c +0 -6
@@ -116,12 +116,6 @@ static int dw_plat_add_pcie_port(struct dw_plat_pcie *dw_plat_pcie,if (pp->irq <0 )return pp->irq; -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =platform_get_irq (pdev,0 ); -if (pp->msi_irq <0 ) -return pp->msi_irq; - } - pp->num_vectors =MAX_MSI_IRQS ; pp->ops = &dw_plat_pcie_host_ops;
drivers/pci/controller/dwc/pcie-histb.c +0 -6
@@ -400,12 +400,6 @@ static int histb_pcie_probe(struct platform_device *pdev)return PTR_ERR (hipcie->bus_reset); } -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =platform_get_irq_byname (pdev,"msi" ); -if (pp->msi_irq <0 ) -return pp->msi_irq; - } - hipcie->phy =devm_phy_get (dev,"phy" );if (IS_ERR (hipcie->phy)) {dev_info (dev,"no pcie-phy found\n" );
drivers/pci/controller/dwc/pcie-kirin.c +0 -22
@@ -439,31 +439,9 @@ static const struct dw_pcie_host_ops kirin_pcie_host_ops = { .host_init = kirin_pcie_host_init, }; -static int kirin_pcie_add_msi (struct dw_pcie *pci, -struct platform_device *pdev) -{ -int irq; - -if (IS_ENABLED (CONFIG_PCI_MSI )) { - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) -return irq; - - pci->pp.msi_irq = irq; - } - -return 0 ; -} -static int kirin_add_pcie_port (struct dw_pcie *pci,struct platform_device *pdev) { -int ret; - - ret =kirin_pcie_add_msi (pci, pdev); -if (ret) -return ret; - pci->pp.ops = &kirin_pcie_host_ops;return dw_pcie_host_init (&pci->pp);
drivers/pci/controller/dwc/pcie-qcom.c +0 -8
@@ -1424,14 +1424,6 @@ static int qcom_pcie_probe(struct platform_device *pdev) pp->ops = &qcom_pcie_dw_ops; -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =platform_get_irq_byname (pdev,"msi" ); -if (pp->msi_irq <0 ) { - ret = pp->msi_irq; - goto err_pm_runtime_put; - } - } - ret =phy_init (pcie->phy);if (ret) {pm_runtime_disable (&pdev->dev);
drivers/pci/controller/dwc/pcie-spear13xx.c +1 -0
@@ -185,6 +185,7 @@ static int spear13xx_add_pcie_port(struct spear13xx_pcie *spear13xx_pcie, } pp->ops = &spear13xx_pcie_host_ops; + pp->msi_irq = -ENODEV ; ret =dw_pcie_host_init (pp);if (ret) {
drivers/pci/controller/dwc/pcie-tegra194.c +0 -8
@@ -1554,14 +1554,6 @@ static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)char *name;int ret; -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =of_irq_get_byname (dev->of_node,"msi" ); -if (!pp->msi_irq) { -dev_err (dev,"Failed to get MSI interrupt\n" ); -return -ENODEV ; - } - } -pm_runtime_enable (dev); ret =pm_runtime_get_sync (dev);
drivers/pci/controller/dwc/pcie-uniphier.c +0 -6
@@ -341,12 +341,6 @@ static int uniphier_add_pcie_port(struct uniphier_pcie_priv *priv, pp->ops = &uniphier_pcie_host_ops; -if (IS_ENABLED (CONFIG_PCI_MSI )) { - pp->msi_irq =platform_get_irq_byname (pdev,"msi" ); -if (pp->msi_irq <0 ) -return pp->msi_irq; - } - ret =dw_pcie_host_init (pp);if (ret) {dev_err (dev,"Failed to initialize host (%d)\n" , ret);
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 9/16 PCI: dwc: Rework MSI initialization
In reply to Rob HerringThere are 3 possible MSI implementations for the DWC host. The first is using the built-in DWC MSI controller. The 2nd is a custom MSI controller as part of the PCI host (keystone only). The 3rd is an external MSI controller (typically GICv3 ITS). Currently, the last 2 are distinguished with a .msi_host_init() hook with the 3rd option using an empty function. However we can detect the 3rd case with the presence of 'msi-parent' or 'msi-map' properties, so let's do that instead and remove the empty functions.
--- drivers/pci/controller/dwc/pci-keystone.c | 9 ------- drivers/pci/controller/dwc/pci-layerscape.c | 25 ------------------- .../pci/controller/dwc/pcie-designware-host.c | 20 +++++++++------ drivers/pci/controller/dwc/pcie-designware.h | 1 + drivers/pci/controller/dwc/pcie-intel-gw.c | 9 ------- 5 files changed, 13 insertions(+), 51 deletions(-)
drivers/pci/controller/dwc/pci-keystone.c +0 -9
@@ -272,14 +272,6 @@ static void ks_pcie_handle_legacy_irq(struct keystone_pcie *ks_pcie,ks_pcie_app_writel (ks_pcie,IRQ_EOI , offset); } -/* -* Dummy function so that DW core doesn't configure MSI -*/ -static int ks_pcie_am654_msi_host_init (struct pcie_port *pp) -{ -return 0 ; -} -static void ks_pcie_enable_error_irq (struct keystone_pcie *ks_pcie) {ks_pcie_app_writel (ks_pcie,ERR_IRQ_ENABLE_SET ,ERR_IRQ_ALL );
@@ -854,7 +846,6 @@ static const struct dw_pcie_host_ops ks_pcie_host_ops = {static const struct dw_pcie_host_ops ks_pcie_am654_host_ops = { .host_init = ks_pcie_host_init, - .msi_host_init = ks_pcie_am654_msi_host_init, };static irqreturn_t ks_pcie_err_irq_handler (int irq,void *priv)
drivers/pci/controller/dwc/pci-layerscape.c +0 -25
@@ -168,37 +168,12 @@ static int ls1021_pcie_host_init(struct pcie_port *pp)return ls_pcie_host_init (pp); } -static int ls_pcie_msi_host_init (struct pcie_port *pp) -{ -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -struct device *dev = pci->dev; -struct device_node *np = dev->of_node; -struct device_node *msi_node; - -/* -* The MSI domain is set by the generic of_msi_configure(). This -* .msi_host_init() function keeps us from doing the default MSI -* domain setup in dw_pcie_host_init() and also enforces the -* requirement that "msi-parent" exists. -*/ - msi_node =of_parse_phandle (np,"msi-parent" ,0 ); -if (!msi_node) { -dev_err (dev,"failed to find msi-parent\n" ); -return -EINVAL ; - } - -of_node_put (msi_node); -return 0 ; -} -static const struct dw_pcie_host_ops ls1021_pcie_host_ops = { .host_init = ls1021_pcie_host_init, - .msi_host_init = ls_pcie_msi_host_init, };static const struct dw_pcie_host_ops ls_pcie_host_ops = { .host_init = ls_pcie_host_init, - .msi_host_init = ls_pcie_msi_host_init, };static const struct dw_pcie_ops dw_ls1021_pcie_ops = {
drivers/pci/controller/dwc/pcie-designware-host.c +12 -8
@@ -365,6 +365,10 @@ int dw_pcie_host_init(struct pcie_port *pp) pci->link_gen =of_pci_get_max_link_speed (np);if (pci_msi_enabled ()) { + pp->has_msi_ctrl = !(pp->ops->msi_host_init || +of_property_read_bool (np,"msi-parent" ) || +of_property_read_bool (np,"msi-map" )); +if (!pp->num_vectors) { pp->num_vectors =MSI_DEF_NUM_VECTORS ; }else if (pp->num_vectors >MAX_MSI_IRQS ) {
@@ -372,7 +376,11 @@ int dw_pcie_host_init(struct pcie_port *pp)return -EINVAL ; } -if (!pp->ops->msi_host_init) { +if (pp->ops->msi_host_init) { + ret = pp->ops->msi_host_init (pp); +if (ret <0 ) +return ret; + }else if (pp->has_msi_ctrl) {if (!pp->msi_irq) { pp->msi_irq =platform_get_irq_byname_optional (pdev,"msi" );if (pp->msi_irq <0 ) {
@@ -402,10 +410,6 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->msi_data =0 ; goto err_free_msi; } - }else { - ret = pp->ops->msi_host_init (pp); -if (ret <0 ) -return ret; } }
@@ -426,7 +430,7 @@ int dw_pcie_host_init(struct pcie_port *pp)return 0 ; err_free_msi: -if (pci_msi_enabled () && !pp->ops->msi_host_init) +if (pp->has_msi_ctrl)dw_pcie_free_msi (pp);return ret; }
@@ -436,7 +440,7 @@ void dw_pcie_host_deinit(struct pcie_port *pp) {pci_stop_root_bus (pp->bridge->bus);pci_remove_root_bus (pp->bridge->bus); -if (pci_msi_enabled () && !pp->ops->msi_host_init) +if (pp->has_msi_ctrl)dw_pcie_free_msi (pp); }EXPORT_SYMBOL_GPL (dw_pcie_host_deinit);
@@ -544,7 +548,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp)dw_pcie_setup (pci); -if (pci_msi_enabled () && !pp->ops->msi_host_init) { +if (pp->has_msi_ctrl) { num_ctrls = pp->num_vectors /MAX_MSI_IRQS_PER_CTRL ;/* Initialize IRQ Status array */
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -175,6 +175,7 @@ struct dw_pcie_host_ops { };struct pcie_port { +bool has_msi_ctrl:1 ;u64 cfg0_base;void __iomem *va_cfg0_base;u32 cfg0_size;
drivers/pci/controller/dwc/pcie-intel-gw.c +0 -9
@@ -385,14 +385,6 @@ static int intel_pcie_rc_init(struct pcie_port *pp)return intel_pcie_host_setup (lpp); } -/* -* Dummy function so that DW core doesn't configure MSI -*/ -static int intel_pcie_msi_init (struct pcie_port *pp) -{ -return 0 ; -} -static u64 intel_pcie_cpu_addr (struct dw_pcie *pcie,u64 cpu_addr) {return cpu_addr +BUS_IATU_OFFSET ;
@@ -404,7 +396,6 @@ static const struct dw_pcie_ops intel_pcie_ops = {static const struct dw_pcie_host_ops intel_pcie_dw_ops = { .host_init = intel_pcie_rc_init, - .msi_host_init = intel_pcie_msi_init, };static const struct intel_pcie_soc pcie_data = {
Signature · 1 line
2.25.1
Re: [PATCH v2 09/16] PCI: dwc: Rework MSI initialization
Quoted 170 lines · On Thu, 5 Nov 2020 15:11:52 -0600 Rob Herring <[email protected]> wrote:
CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe.
There are 3 possible MSI implementations for the DWC host. The first is using the built-in DWC MSI controller. The 2nd is a custom MSI controller as part of the PCI host (keystone only). The 3rd is an external MSI controller (typically GICv3 ITS). Currently, the last 2 are distinguished with a .msi_host_init() hook with the 3rd option using an empty function. However we can detect the 3rd case with the presence of 'msi-parent' or 'msi-map' properties, so let's do that instead and remove the empty functions.
Cc Murali Karicheri <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Minghuan Lian <[email protected]>Cc Mingkai Hu <[email protected]>Cc Roy Zang <[email protected]>Cc Gustavo Pimentel <[email protected]>Acked-by Jingoo Han <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/pci/controller/dwc/pci-keystone.c | 9 ------- drivers/pci/controller/dwc/pci-layerscape.c | 25 ------------------- .../pci/controller/dwc/pcie-designware-host.c | 20 +++++++++------ drivers/pci/controller/dwc/pcie-designware.h | 1 + drivers/pci/controller/dwc/pcie-intel-gw.c | 9 ------- 5 files changed, 13 insertions(+), 51 deletions(-)drivers/pci/controller/dwc/pci-keystone.c +0
-9@@ -272,14 +272,6 @@ static void ks_pcie_handle_legacy_irq(struct keystone_pcie *ks_pcie,ks_pcie_app_writel (ks_pcie,IRQ_EOI , offset); } -/* -* Dummy function so that DW core doesn't configure MSI -*/ -static int ks_pcie_am654_msi_host_init (struct pcie_port *pp) -{ -return 0 ; -} -static void ks_pcie_enable_error_irq (struct keystone_pcie *ks_pcie) {ks_pcie_app_writel (ks_pcie,ERR_IRQ_ENABLE_SET ,ERR_IRQ_ALL );@@ -854,7 +846,6 @@ static const struct dw_pcie_host_ops ks_pcie_host_ops = {static const struct dw_pcie_host_ops ks_pcie_am654_host_ops = { .host_init = ks_pcie_host_init, - .msi_host_init = ks_pcie_am654_msi_host_init, };static irqreturn_t ks_pcie_err_irq_handler (int irq,void *priv)drivers/pci/controller/dwc/pci-layerscape.c +0
-25@@ -168,37 +168,12 @@ static int ls1021_pcie_host_init(struct pcie_port *pp)return ls_pcie_host_init (pp); } -static int ls_pcie_msi_host_init (struct pcie_port *pp) -{ -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -struct device *dev = pci->dev; -struct device_node *np = dev->of_node; -struct device_node *msi_node; - -/* -* The MSI domain is set by the generic of_msi_configure(). This -* .msi_host_init() function keeps us from doing the default MSI -* domain setup in dw_pcie_host_init() and also enforces the -* requirement that "msi-parent" exists. -*/ - msi_node =of_parse_phandle (np,"msi-parent" ,0 ); -if (!msi_node) { -dev_err (dev,"failed to find msi-parent\n" ); -return -EINVAL ; - } - -of_node_put (msi_node); -return 0 ; -} -static const struct dw_pcie_host_ops ls1021_pcie_host_ops = { .host_init = ls1021_pcie_host_init, - .msi_host_init = ls_pcie_msi_host_init, };static const struct dw_pcie_host_ops ls_pcie_host_ops = { .host_init = ls_pcie_host_init, - .msi_host_init = ls_pcie_msi_host_init, };static const struct dw_pcie_ops dw_ls1021_pcie_ops = {drivers/pci/controller/dwc/pcie-designware-host.c +12
-8@@ -365,6 +365,10 @@ int dw_pcie_host_init(struct pcie_port *pp) pci->link_gen =of_pci_get_max_link_speed (np);if (pci_msi_enabled ()) { + pp->has_msi_ctrl = !(pp->ops->msi_host_init || +of_property_read_bool (np,"msi-parent" ) || +of_property_read_bool (np,"msi-map" )); +if (!pp->num_vectors) { pp->num_vectors =MSI_DEF_NUM_VECTORS ; }else if (pp->num_vectors >MAX_MSI_IRQS ) {@@ -372,7 +376,11 @@ int dw_pcie_host_init(struct pcie_port *pp)return -EINVAL ; } -if (!pp->ops->msi_host_init) { +if (pp->ops->msi_host_init) { + ret = pp->ops->msi_host_init (pp); +if (ret <0 ) +return ret; + }else if (pp->has_msi_ctrl) {if (!pp->msi_irq) { pp->msi_irq =platform_get_irq_byname_optional (pdev,"msi" );if (pp->msi_irq <0 ) {@@ -402,10 +410,6 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->msi_data =0 ; goto err_free_msi; } - }else { - ret = pp->ops->msi_host_init (pp); -if (ret <0 ) -return ret; } }@@ -426,7 +430,7 @@ int dw_pcie_host_init(struct pcie_port *pp)return 0 ; err_free_msi: -if (pci_msi_enabled () && !pp->ops->msi_host_init) +if (pp->has_msi_ctrl)dw_pcie_free_msi (pp);return ret; }@@ -436,7 +440,7 @@ void dw_pcie_host_deinit(struct pcie_port *pp) {pci_stop_root_bus (pp->bridge->bus);pci_remove_root_bus (pp->bridge->bus); -if (pci_msi_enabled () && !pp->ops->msi_host_init) +if (pp->has_msi_ctrl)dw_pcie_free_msi (pp); }EXPORT_SYMBOL_GPL (dw_pcie_host_deinit);@@ -544,7 +548,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp)dw_pcie_setup (pci); -if (pci_msi_enabled () && !pp->ops->msi_host_init) { +if (pp->has_msi_ctrl) { num_ctrls = pp->num_vectors /MAX_MSI_IRQS_PER_CTRL ;/* Initialize IRQ Status array */ drivers/pci/controller/dwc/pcie-designware.h +0
-0
drivers/pci/controller/dwc/pcie-designware.h struct dw_pcie_host_ops { · line 178
Quoted 4 lines
drivers/pci/controller/dwc/pcie-designware.h +1
-0@@ -175,6 +175,7 @@ struct dw_pcie_host_ops { };struct pcie_port { +bool has_msi_ctrl:1 ;
Can we relocate has_msi_ctrl? e.g put it at the end of the pcie_port structure.
Thanks
Quoted 38 lines
drivers/pci/controller/dwc/pcie-designware.h +0
-0u64 cfg0_base;void __iomem *va_cfg0_base;u32 cfg0_size;drivers/pci/controller/dwc/pcie-intel-gw.c +0
-10@@ -385,14 +385,6 @@ static int intel_pcie_rc_init(struct pcie_port *pp)return intel_pcie_host_setup (lpp); } -/* -* Dummy function so that DW core doesn't configure MSI -*/ -static int intel_pcie_msi_init (struct pcie_port *pp) -{ -return 0 ; -} -static u64 intel_pcie_cpu_addr (struct dw_pcie *pcie,u64 cpu_addr) {return cpu_addr +BUS_IATU_OFFSET ;@@ -404,7 +396,6 @@ static const struct dw_pcie_ops intel_pcie_ops = {static const struct dw_pcie_host_ops intel_pcie_dw_ops = { .host_init = intel_pcie_rc_init, - .msi_host_init = intel_pcie_msi_init, };static const struct intel_pcie_soc pcie_data = { --2.25.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
Rob Herring
reviewerPATCH v2 10/16 PCI: dwc: Move link handling into common code
In reply to Rob HerringAll the DWC drivers do link setup and checks at roughly the same time. Let's use the existing .start_link() hook (currently only used in EP mode) and move the link handling to the core code.
The behavior for a link down was inconsistent as some drivers would fail probe in that case while others succeed. Let's standardize this to succeed as there are usecases where devices (and the link) appear later even without hotplug. For example, a reconfigured FPGA device.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 2 - drivers/pci/controller/dwc/pci-exynos.c | 41 +++++++---------- drivers/pci/controller/dwc/pci-imx6.c | 9 ++-- drivers/pci/controller/dwc/pci-keystone.c | 9 ---- drivers/pci/controller/dwc/pci-meson.c | 24 ++++------ drivers/pci/controller/dwc/pcie-armada8k.c | 39 +++++++--------- drivers/pci/controller/dwc/pcie-artpec6.c | 2 - .../pci/controller/dwc/pcie-designware-host.c | 9 ++++ .../pci/controller/dwc/pcie-designware-plat.c | 3 -- drivers/pci/controller/dwc/pcie-histb.c | 34 +++++++------- drivers/pci/controller/dwc/pcie-kirin.c | 23 ++-------- drivers/pci/controller/dwc/pcie-qcom.c | 19 ++------ drivers/pci/controller/dwc/pcie-spear13xx.c | 46 ++++++++----------- drivers/pci/controller/dwc/pcie-tegra194.c | 1 - drivers/pci/controller/dwc/pcie-uniphier.c | 13 ++---- 15 files changed, 103 insertions(+), 171 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +0 -2
@@ -183,8 +183,6 @@ static int dra7xx_pcie_host_init(struct pcie_port *pp)dw_pcie_setup_rc (pp); -dra7xx_pcie_establish_link (pci); -dw_pcie_wait_for_link (pci);dw_pcie_msi_init (pp);dra7xx_pcie_enable_interrupts (dra7xx);
drivers/pci/controller/dwc/pci-exynos.c +17 -24
60 lines not on this page · raw message
drivers/pci/controller/dwc/pci-imx6.c +4 -5
@@ -745,9 +745,9 @@ static void imx6_pcie_ltssm_enable(struct device *dev) } } -static int imx6_pcie_establish_link (struct imx6_pcie *imx6_pcie) +static int imx6_pcie_start_link (struct dw_pcie *pci) { -struct dw_pcie *pci = imx6_pcie->pci; +struct imx6_pcie *imx6_pcie =to_imx6_pcie (pci);struct device *dev = pci->dev;u8 offset =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP );u32 tmp;
@@ -835,7 +835,6 @@ static int imx6_pcie_host_init(struct pcie_port *pp)imx6_pcie_deassert_core_reset (imx6_pcie);imx6_setup_phy_mpll (imx6_pcie);dw_pcie_setup_rc (pp); -imx6_pcie_establish_link (imx6_pcie);dw_pcie_msi_init (pp);return 0 ;
@@ -865,7 +864,7 @@ static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, }static const struct dw_pcie_ops dw_pcie_ops = { -/* No special ops needed, but pcie-designware still expects this struct */ + .start_link = imx6_pcie_start_link, };#ifdef CONFIG_PM_SLEEP
@@ -974,7 +973,7 @@ static int imx6_pcie_resume_noirq(struct device *dev)imx6_pcie_deassert_core_reset (imx6_pcie);dw_pcie_setup_rc (pp); - ret =imx6_pcie_establish_link (imx6_pcie); + ret =imx6_pcie_start_link (imx6_pcie->pci);if (ret <0 )dev_info (dev,"pcie link is down after resume.\n" );
drivers/pci/controller/dwc/pci-keystone.c +0 -9
@@ -511,14 +511,8 @@ static void ks_pcie_stop_link(struct dw_pcie *pci)static int ks_pcie_start_link (struct dw_pcie *pci) {struct keystone_pcie *ks_pcie =to_keystone_pcie (pci); -struct device *dev = pci->dev;u32 val; -if (dw_pcie_link_up (pci)) { -dev_dbg (dev,"link is already up\n" ); -return 0 ; - } -/* Initiate Link Training */ val =ks_pcie_app_readl (ks_pcie,CMD_STATUS );ks_pcie_app_writel (ks_pcie,CMD_STATUS ,LTSSM_EN_VAL | val);
@@ -833,9 +827,6 @@ static int __init ks_pcie_host_init(struct pcie_port *pp) "Asynchronous external abort");#endif -ks_pcie_start_link (pci); -dw_pcie_wait_for_link (pci); -return 0 ; }
drivers/pci/controller/dwc/pci-meson.c +9 -15
@@ -231,7 +231,7 @@ static void meson_pcie_assert_reset(struct meson_pcie *mp)gpiod_set_value_cansleep (mp->reset_gpio,0 ); } -static void meson_pcie_init_dw (struct meson_pcie *mp) +static void meson_pcie_ltssm_enable (struct meson_pcie *mp) {u32 val;
@@ -289,20 +289,14 @@ static void meson_set_max_rd_req_size(struct meson_pcie *mp, int size)dw_pcie_writel_dbi (pci, offset +PCI_EXP_DEVCTL , val); } -static int meson_pcie_establish_link (struct meson_pcie *mp) +static int meson_pcie_start_link (struct dw_pcie *pci) { -struct dw_pcie *pci = &mp->pci; -struct pcie_port *pp = &pci->pp; - -meson_pcie_init_dw (mp); -meson_set_max_payload (mp,MAX_PAYLOAD_SIZE ); -meson_set_max_rd_req_size (mp,MAX_READ_REQ_SIZE ); - -dw_pcie_setup_rc (pp); +struct meson_pcie *mp =to_meson_pcie (pci); +meson_pcie_ltssm_enable (mp);meson_pcie_assert_reset (mp); -return dw_pcie_wait_for_link (pci); +return 0 ; } static int meson_pcie_rd_own_conf(struct pci_bus *bus, u32 devfn,
@@ -380,14 +374,13 @@ static int meson_pcie_host_init(struct pcie_port *pp) {struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct meson_pcie *mp =to_meson_pcie (pci); -int ret; pp->bridge->ops = &meson_pci_ops; - ret =meson_pcie_establish_link (mp); -if (ret) -return ret; +meson_set_max_payload (mp,MAX_PAYLOAD_SIZE ); +meson_set_max_rd_req_size (mp,MAX_READ_REQ_SIZE ); +dw_pcie_setup_rc (pp);dw_pcie_msi_init (pp);return 0 ;
@@ -418,6 +411,7 @@ static int meson_add_pcie_port(struct meson_pcie *mp,static const struct dw_pcie_ops dw_pcie_ops = { .link_up = meson_pcie_link_up, + .start_link = meson_pcie_start_link, };static int meson_pcie_probe (struct platform_device *pdev)
drivers/pci/controller/dwc/pcie-armada8k.c +17 -22
@@ -154,10 +154,24 @@ static int armada8k_pcie_link_up(struct dw_pcie *pci)return 0 ; } -static void armada8k_pcie_establish_link (struct armada8k_pcie *pcie) +static int armada8k_pcie_start_link (struct dw_pcie *pci) +{ +u32 reg; + +/* Start LTSSM */ + reg =dw_pcie_readl_dbi (pci,PCIE_GLOBAL_CONTROL_REG ); + reg |=PCIE_APP_LTSSM_EN ; +dw_pcie_writel_dbi (pci,PCIE_GLOBAL_CONTROL_REG , reg); + +return 0 ; +} + +static int armada8k_pcie_host_init (struct pcie_port *pp) { -struct dw_pcie *pci = pcie->pci;u32 reg; +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); + +dw_pcie_setup_rc (pp);if (!dw_pcie_link_up (pci)) {/* Disable LTSSM state machine to enable configuration */
@@ -193,26 +207,6 @@ static void armada8k_pcie_establish_link(struct armada8k_pcie *pcie)PCIE_INT_C_ASSERT_MASK |PCIE_INT_D_ASSERT_MASK ;dw_pcie_writel_dbi (pci,PCIE_GLOBAL_INT_MASK1_REG , reg); -if (!dw_pcie_link_up (pci)) { -/* Configuration done. Start LTSSM */ - reg =dw_pcie_readl_dbi (pci,PCIE_GLOBAL_CONTROL_REG ); - reg |=PCIE_APP_LTSSM_EN ; -dw_pcie_writel_dbi (pci,PCIE_GLOBAL_CONTROL_REG , reg); - } - -/* Wait until the link becomes active again */ -if (dw_pcie_wait_for_link (pci)) -dev_err (pci->dev,"Link not up after reconfiguration\n" ); -} - -static int armada8k_pcie_host_init (struct pcie_port *pp) -{ -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -struct armada8k_pcie *pcie =to_armada8k_pcie (pci); - -dw_pcie_setup_rc (pp); -armada8k_pcie_establish_link (pcie); -return 0 ; }
@@ -269,6 +263,7 @@ static int armada8k_add_pcie_port(struct armada8k_pcie *pcie,static const struct dw_pcie_ops dw_pcie_ops = { .link_up = armada8k_pcie_link_up, + .start_link = armada8k_pcie_start_link, };static int armada8k_pcie_probe (struct platform_device *pdev)
drivers/pci/controller/dwc/pcie-artpec6.c +0 -2
@@ -329,8 +329,6 @@ static int artpec6_pcie_host_init(struct pcie_port *pp)artpec6_pcie_deassert_core_reset (artpec6_pcie);artpec6_pcie_wait_for_phy (artpec6_pcie);dw_pcie_setup_rc (pp); -artpec6_pcie_establish_link (pci); -dw_pcie_wait_for_link (pci);dw_pcie_msi_init (pp);return 0 ;
drivers/pci/controller/dwc/pcie-designware-host.c +9 -0
@@ -423,6 +423,15 @@ int dw_pcie_host_init(struct pcie_port *pp) goto err_free_msi; } +if (!dw_pcie_link_up (pci) && pci->ops->start_link) { + ret = pci->ops->start_link (pci); +if (ret) + goto err_free_msi; + } + +/* Ignore errors, the link may come up later */ +dw_pcie_wait_for_link (pci); + bridge->sysdata = pp; ret =pci_host_probe (bridge);
drivers/pci/controller/dwc/pcie-designware-plat.c +0 -3
@@ -35,10 +35,7 @@ static const struct of_device_id dw_plat_pcie_of_match[];static int dw_plat_pcie_host_init (struct pcie_port *pp) { -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -dw_pcie_setup_rc (pp); -dw_pcie_wait_for_link (pci);dw_pcie_msi_init (pp);return 0 ;
drivers/pci/controller/dwc/pcie-histb.c +16 -18
@@ -169,39 +169,36 @@ static int histb_pcie_link_up(struct dw_pcie *pci)return 0 ; } -static int histb_pcie_establish_link (struct pcie_port *pp) +static int histb_pcie_start_link (struct dw_pcie *pci) { -struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct histb_pcie *hipcie =to_histb_pcie (pci);u32 regval; -if (dw_pcie_link_up (pci)) { -dev_info (pci->dev,"Link already up\n" ); -return 0 ; - } - -/* PCIe RC work mode */ - regval =histb_pcie_readl (hipcie,PCIE_SYS_CTRL0 ); - regval &= ~PCIE_DEVICE_TYPE_MASK ; - regval |=PCIE_WM_RC ; -histb_pcie_writel (hipcie,PCIE_SYS_CTRL0 , regval); - -/* setup root complex */ -dw_pcie_setup_rc (pp); -/* assert LTSSM enable */ regval =histb_pcie_readl (hipcie,PCIE_SYS_CTRL7 ); regval |=PCIE_APP_LTSSM_ENABLE ;histb_pcie_writel (hipcie,PCIE_SYS_CTRL7 , regval); -return dw_pcie_wait_for_link (pci); +return 0 ; }static int histb_pcie_host_init (struct pcie_port *pp) { +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +struct histb_pcie *hipcie =to_histb_pcie (pci); +u32 regval; + pp->bridge->ops = &histb_pci_ops; -histb_pcie_establish_link (pp); +/* PCIe RC work mode */ + regval =histb_pcie_readl (hipcie,PCIE_SYS_CTRL0 ); + regval &= ~PCIE_DEVICE_TYPE_MASK ; + regval |=PCIE_WM_RC ; +histb_pcie_writel (hipcie,PCIE_SYS_CTRL0 , regval); + +/* setup root complex */ +dw_pcie_setup_rc (pp); +dw_pcie_msi_init (pp);return 0 ;
@@ -300,6 +297,7 @@ static const struct dw_pcie_ops dw_pcie_ops = { .read_dbi = histb_pcie_read_dbi, .write_dbi = histb_pcie_write_dbi, .link_up = histb_pcie_link_up, + .start_link = histb_pcie_start_link, };static int histb_pcie_probe (struct platform_device *pdev)
drivers/pci/controller/dwc/pcie-kirin.c +3 -20
@@ -390,32 +390,14 @@ static int kirin_pcie_link_up(struct dw_pcie *pci)return 0 ; } -static int kirin_pcie_establish_link (struct pcie_port *pp) +static int kirin_pcie_start_link (struct dw_pcie *pci) { -struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct kirin_pcie *kirin_pcie =to_kirin_pcie (pci); -struct device *dev = kirin_pcie->pci->dev; -int count =0 ; - -if (kirin_pcie_link_up (pci)) -return 0 ; - -dw_pcie_setup_rc (pp);/* assert LTSSM enable */ kirin_apb_ctrl_writel (kirin_pcie,PCIE_LTSSM_ENABLE_BIT ,PCIE_APP_LTSSM_ENABLE ); -/* check if the link is up or not */ -while (!kirin_pcie_link_up (pci)) { -usleep_range (LINK_WAIT_MIN ,LINK_WAIT_MAX ); - count++; -if (count ==1000 ) { -dev_err (dev,"Link Fail\n" ); -return -EINVAL ; - } - } -return 0 ; }
@@ -423,7 +405,7 @@ static int kirin_pcie_host_init(struct pcie_port *pp) { pp->bridge->ops = &kirin_pci_ops; -kirin_pcie_establish_link (pp); +dw_pcie_setup_rc (pp);dw_pcie_msi_init (pp);return 0 ;
@@ -433,6 +415,7 @@ static const struct dw_pcie_ops kirin_dw_pcie_ops = { .read_dbi = kirin_pcie_read_dbi, .write_dbi = kirin_pcie_write_dbi, .link_up = kirin_pcie_link_up, + .start_link = kirin_pcie_start_link, };static const struct dw_pcie_host_ops kirin_pcie_host_ops = {
drivers/pci/controller/dwc/pcie-qcom.c +5 -14
@@ -207,18 +207,15 @@ static void qcom_ep_reset_deassert(struct qcom_pcie *pcie)usleep_range (PERST_DELAY_US ,PERST_DELAY_US +500 ); } -static int qcom_pcie_establish_link (struct qcom_pcie *pcie) +static int qcom_pcie_start_link (struct dw_pcie *pci) { -struct dw_pcie *pci = pcie->pci; - -if (dw_pcie_link_up (pci)) -return 0 ; +struct qcom_pcie *pcie =to_qcom_pcie (pci);/* Enable Link Training state machine */ if (pcie->ops->ltssm_enable) pcie->ops->ltssm_enable (pcie); -return dw_pcie_wait_for_link (pci); +return 0 ; }static void qcom_pcie_2_1_0_ltssm_enable (struct qcom_pcie *pcie)
@@ -1288,15 +1285,8 @@ static int qcom_pcie_host_init(struct pcie_port *pp)qcom_ep_reset_deassert (pcie); - ret =qcom_pcie_establish_link (pcie); -if (ret) - goto err; -return 0 ; -err: -qcom_ep_reset_assert (pcie); -if (pcie->ops->post_deinit) - pcie->ops->post_deinit (pcie); + err_disable_phy:phy_power_off (pcie->phy); err_deinit:
@@ -1363,6 +1353,7 @@ static const struct qcom_pcie_ops ops_2_7_0 = {static const struct dw_pcie_ops dw_pcie_ops = { .link_up = qcom_pcie_link_up, + .start_link = qcom_pcie_start_link, };static int qcom_pcie_probe (struct platform_device *pdev)
drivers/pci/controller/dwc/pcie-spear13xx.c +20 -26
75 lines not on this page · raw message
drivers/pci/controller/dwc/pcie-tegra194.c +0 -1
@@ -1549,7 +1549,6 @@ static int tegra_pcie_deinit_controller(struct tegra_pcie_dw *pcie)static int tegra_pcie_config_rp (struct tegra_pcie_dw *pcie) { -struct pcie_port *pp = &pcie->pci.pp;struct device *dev = pcie->dev;char *name;int ret;
drivers/pci/controller/dwc/pcie-uniphier.c +3 -10
@@ -146,16 +146,13 @@ static int uniphier_pcie_link_up(struct dw_pcie *pci)return (val & mask) == mask; } -static int uniphier_pcie_establish_link (struct dw_pcie *pci) +static int uniphier_pcie_start_link (struct dw_pcie *pci) {struct uniphier_pcie_priv *priv =to_uniphier_pcie (pci); -if (dw_pcie_link_up (pci)) -return 0 ; -uniphier_pcie_ltssm_enable (priv, true); -return dw_pcie_wait_for_link (pci); +return 0 ; }static void uniphier_pcie_stop_link (struct dw_pcie *pci)
@@ -318,10 +315,6 @@ static int uniphier_pcie_host_init(struct pcie_port *pp)uniphier_pcie_irq_enable (priv);dw_pcie_setup_rc (pp); - ret =uniphier_pcie_establish_link (pci); -if (ret) -return ret; -dw_pcie_msi_init (pp);return 0 ;
@@ -385,7 +378,7 @@ static int uniphier_pcie_host_enable(struct uniphier_pcie_priv *priv) }static const struct dw_pcie_ops dw_pcie_ops = { - .start_link = uniphier_pcie_establish_link, + .start_link = uniphier_pcie_start_link, .stop_link = uniphier_pcie_stop_link, .link_up = uniphier_pcie_link_up, };
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 11/16 PCI: dwc: Move dw_pcie_msi_init() into core
In reply to Rob HerringThe host drivers which call dw_pcie_msi_init() are all the ones using the built-in MSI controller, so let's move it into the common DWC code.
---
v2:
- Drop now static dw_pcie_msi_init symbol export
--- drivers/pci/controller/dwc/pci-dra7xx.c | 2 -- drivers/pci/controller/dwc/pci-exynos.c | 4 ---- drivers/pci/controller/dwc/pci-imx6.c | 1 - drivers/pci/controller/dwc/pci-meson.c | 1 - drivers/pci/controller/dwc/pcie-artpec6.c | 1 - drivers/pci/controller/dwc/pcie-designware-host.c | 9 +++++---- drivers/pci/controller/dwc/pcie-designware-plat.c | 1 - drivers/pci/controller/dwc/pcie-designware.h | 10 ---------- drivers/pci/controller/dwc/pcie-histb.c | 2 -- drivers/pci/controller/dwc/pcie-kirin.c | 1 - drivers/pci/controller/dwc/pcie-qcom.c | 2 -- drivers/pci/controller/dwc/pcie-spear13xx.c | 6 +----- drivers/pci/controller/dwc/pcie-tegra194.c | 2 -- drivers/pci/controller/dwc/pcie-uniphier.c | 1 - 14 files changed, 6 insertions(+), 37 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +0 -2
@@ -182,8 +182,6 @@ static int dra7xx_pcie_host_init(struct pcie_port *pp)struct dra7xx_pcie *dra7xx =to_dra7xx_pcie (pci);dw_pcie_setup_rc (pp); - -dw_pcie_msi_init (pp);dra7xx_pcie_enable_interrupts (dra7xx);return 0 ;
drivers/pci/controller/dwc/pci-exynos.c +0 -4
@@ -273,12 +273,8 @@ static irqreturn_t exynos_pcie_irq_handler(int irq, void *arg)static void exynos_pcie_msi_init (struct exynos_pcie *ep) { -struct dw_pcie *pci = ep->pci; -struct pcie_port *pp = &pci->pp;u32 val; -dw_pcie_msi_init (pp); -/* enable MSI interrupt */ val =exynos_pcie_readl (ep->mem_res->elbi_base,PCIE_IRQ_EN_LEVEL ); val |=IRQ_MSI_ENABLE ;
drivers/pci/controller/dwc/pci-imx6.c +0 -1
@@ -835,7 +835,6 @@ static int imx6_pcie_host_init(struct pcie_port *pp)imx6_pcie_deassert_core_reset (imx6_pcie);imx6_setup_phy_mpll (imx6_pcie);dw_pcie_setup_rc (pp); -dw_pcie_msi_init (pp);return 0 ; }
drivers/pci/controller/dwc/pci-meson.c +0 -1
@@ -381,7 +381,6 @@ static int meson_pcie_host_init(struct pcie_port *pp)meson_set_max_rd_req_size (mp,MAX_READ_REQ_SIZE );dw_pcie_setup_rc (pp); -dw_pcie_msi_init (pp);return 0 ; }
drivers/pci/controller/dwc/pcie-artpec6.c +0 -1
@@ -329,7 +329,6 @@ static int artpec6_pcie_host_init(struct pcie_port *pp)artpec6_pcie_deassert_core_reset (artpec6_pcie);artpec6_pcie_wait_for_phy (artpec6_pcie);dw_pcie_setup_rc (pp); -dw_pcie_msi_init (pp);return 0 ; }
drivers/pci/controller/dwc/pcie-designware-host.c +5 -4
@@ -256,7 +256,7 @@ int dw_pcie_allocate_domains(struct pcie_port *pp)return 0 ; } -void dw_pcie_free_msi (struct pcie_port *pp) +static void dw_pcie_free_msi (struct pcie_port *pp) {if (pp->msi_irq) {irq_set_chained_handler (pp->msi_irq,NULL );
@@ -275,19 +275,18 @@ void dw_pcie_free_msi(struct pcie_port *pp) } } -void dw_pcie_msi_init (struct pcie_port *pp) +static void dw_pcie_msi_init (struct pcie_port *pp) {struct dw_pcie *pci =to_dw_pcie_from_pp (pp);u64 msi_target = (u64 )pp->msi_data; -if (!IS_ENABLED (CONFIG_PCI_MSI )) +if (!pci_msi_enabled () || !pp->has_msi_ctrl)return ;/* Program the msi_data */ dw_pcie_writel_dbi (pci,PCIE_MSI_ADDR_LO ,lower_32_bits (msi_target));dw_pcie_writel_dbi (pci,PCIE_MSI_ADDR_HI ,upper_32_bits (msi_target)); } -EXPORT_SYMBOL_GPL (dw_pcie_msi_init);int dw_pcie_host_init (struct pcie_port *pp) {
@@ -423,6 +422,8 @@ int dw_pcie_host_init(struct pcie_port *pp) goto err_free_msi; } +dw_pcie_msi_init (pp); +if (!dw_pcie_link_up (pci) && pci->ops->start_link) { ret = pci->ops->start_link (pci);if (ret)
drivers/pci/controller/dwc/pcie-designware-plat.c +0 -1
@@ -36,7 +36,6 @@ static const struct of_device_id dw_plat_pcie_of_match[];static int dw_plat_pcie_host_init (struct pcie_port *pp) {dw_pcie_setup_rc (pp); -dw_pcie_msi_init (pp);return 0 ; }
drivers/pci/controller/dwc/pcie-designware.h +0 -10
@@ -363,8 +363,6 @@ static inline void dw_pcie_dbi_ro_wr_dis(struct dw_pcie *pci)#ifdef CONFIG_PCIE_DW_HOST irqreturn_t dw_handle_msi_irq (struct pcie_port *pp); -void dw_pcie_msi_init (struct pcie_port *pp); -void dw_pcie_free_msi (struct pcie_port *pp);void dw_pcie_setup_rc (struct pcie_port *pp);int dw_pcie_host_init (struct pcie_port *pp);void dw_pcie_host_deinit (struct pcie_port *pp);
@@ -377,14 +375,6 @@ static inline irqreturn_t dw_handle_msi_irq(struct pcie_port *pp)return IRQ_NONE ; } -static inline void dw_pcie_msi_init (struct pcie_port *pp) -{ -} - -static inline void dw_pcie_free_msi (struct pcie_port *pp) -{ -} -static inline void dw_pcie_setup_rc (struct pcie_port *pp) { }
drivers/pci/controller/dwc/pcie-histb.c +0 -2
@@ -199,8 +199,6 @@ static int histb_pcie_host_init(struct pcie_port *pp)/* setup root complex */ dw_pcie_setup_rc (pp); -dw_pcie_msi_init (pp); -return 0 ; }
drivers/pci/controller/dwc/pcie-kirin.c +0 -1
@@ -406,7 +406,6 @@ static int kirin_pcie_host_init(struct pcie_port *pp) pp->bridge->ops = &kirin_pci_ops;dw_pcie_setup_rc (pp); -dw_pcie_msi_init (pp);return 0 ; }
drivers/pci/controller/dwc/pcie-qcom.c +0 -2
@@ -1281,8 +1281,6 @@ static int qcom_pcie_host_init(struct pcie_port *pp) }dw_pcie_setup_rc (pp); -dw_pcie_msi_init (pp); -qcom_ep_reset_deassert (pcie);return 0 ;
drivers/pci/controller/dwc/pcie-spear13xx.c +1 -5
@@ -102,16 +102,12 @@ static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg)static void spear13xx_pcie_enable_interrupts (struct spear13xx_pcie *spear13xx_pcie) { -struct dw_pcie *pci = spear13xx_pcie->pci; -struct pcie_port *pp = &pci->pp;struct pcie_app_reg *app_reg = spear13xx_pcie->app_base;/* Enable MSI interrupt */ -if (IS_ENABLED (CONFIG_PCI_MSI )) { -dw_pcie_msi_init (pp); +if (IS_ENABLED (CONFIG_PCI_MSI ))writel (readl (&app_reg->int_mask) |MSI_CTRL_INT , &app_reg->int_mask); - } }static int spear13xx_pcie_link_up (struct dw_pcie *pci)
drivers/pci/controller/dwc/pcie-tegra194.c +0 -2
@@ -765,8 +765,6 @@ static void tegra_pcie_enable_msi_interrupts(struct pcie_port *pp)struct tegra_pcie_dw *pcie =to_tegra_pcie (pci);u32 val; -dw_pcie_msi_init (pp); -/* Enable MSI interrupt generation */ val =appl_readl (pcie,APPL_INTR_EN_L0_0 ); val |=APPL_INTR_EN_L0_0_SYS_MSI_INTR_EN ;
drivers/pci/controller/dwc/pcie-uniphier.c +0 -1
@@ -315,7 +315,6 @@ static int uniphier_pcie_host_init(struct pcie_port *pp)uniphier_pcie_irq_enable (priv);dw_pcie_setup_rc (pp); -dw_pcie_msi_init (pp);return 0 ; }
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 12/16 PCI: dwc: Move dw_pcie_setup_rc() to DWC common code
In reply to Rob HerringAll RC complex drivers must call dw_pcie_setup_rc(). The ordering of the call shouldn't be too important other than being after any RC resets.
There's a few calls of dw_pcie_setup_rc() left as drivers implementing suspend/resume need it.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 1 - drivers/pci/controller/dwc/pci-exynos.c | 1 - drivers/pci/controller/dwc/pci-imx6.c | 1 - drivers/pci/controller/dwc/pci-keystone.c | 2 -- drivers/pci/controller/dwc/pci-layerscape.c | 2 -- drivers/pci/controller/dwc/pci-meson.c | 2 -- drivers/pci/controller/dwc/pcie-armada8k.c | 2 -- drivers/pci/controller/dwc/pcie-artpec6.c | 1 - drivers/pci/controller/dwc/pcie-designware-host.c | 1 + drivers/pci/controller/dwc/pcie-designware-plat.c | 8 -------- drivers/pci/controller/dwc/pcie-histb.c | 3 --- drivers/pci/controller/dwc/pcie-kirin.c | 2 -- drivers/pci/controller/dwc/pcie-qcom.c | 1 - drivers/pci/controller/dwc/pcie-spear13xx.c | 2 -- drivers/pci/controller/dwc/pcie-uniphier.c | 2 -- 15 files changed, 1 insertion(+), 30 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +0 -1
@@ -181,7 +181,6 @@ static int dra7xx_pcie_host_init(struct pcie_port *pp)struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct dra7xx_pcie *dra7xx =to_dra7xx_pcie (pci); -dw_pcie_setup_rc (pp);dra7xx_pcie_enable_interrupts (dra7xx);return 0 ;
drivers/pci/controller/dwc/pci-exynos.c +0 -1
@@ -372,7 +372,6 @@ static int exynos_pcie_host_init(struct pcie_port *pp)phy_init (ep->phy);exynos_pcie_deassert_core_reset (ep); -dw_pcie_setup_rc (pp);exynos_pcie_assert_reset (ep);exynos_pcie_enable_interrupts (ep);
drivers/pci/controller/dwc/pci-imx6.c +0 -1
@@ -834,7 +834,6 @@ static int imx6_pcie_host_init(struct pcie_port *pp)imx6_pcie_init_phy (imx6_pcie);imx6_pcie_deassert_core_reset (imx6_pcie);imx6_setup_phy_mpll (imx6_pcie); -dw_pcie_setup_rc (pp);return 0 ; }
drivers/pci/controller/dwc/pci-keystone.c +0 -2
@@ -807,8 +807,6 @@ static int __init ks_pcie_host_init(struct pcie_port *pp)if (ret)return ret; -dw_pcie_setup_rc (pp); -ks_pcie_stop_link (pci);ks_pcie_setup_rc_app_regs (ks_pcie); writew(PCI_IO_RANGE_TYPE_32 | (PCI_IO_RANGE_TYPE_32 << 8),
drivers/pci/controller/dwc/pci-layerscape.c +0 -2
@@ -136,8 +136,6 @@ static int ls_pcie_host_init(struct pcie_port *pp)ls_pcie_drop_msg_tlp (pcie); -dw_pcie_setup_rc (pp); -return 0 ; }
drivers/pci/controller/dwc/pci-meson.c +0 -2
@@ -380,8 +380,6 @@ static int meson_pcie_host_init(struct pcie_port *pp)meson_set_max_payload (mp,MAX_PAYLOAD_SIZE );meson_set_max_rd_req_size (mp,MAX_READ_REQ_SIZE ); -dw_pcie_setup_rc (pp); -return 0 ; }
drivers/pci/controller/dwc/pcie-armada8k.c +0 -2
@@ -171,8 +171,6 @@ static int armada8k_pcie_host_init(struct pcie_port *pp)u32 reg;struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -dw_pcie_setup_rc (pp); -if (!dw_pcie_link_up (pci)) {/* Disable LTSSM state machine to enable configuration */ reg =dw_pcie_readl_dbi (pci,PCIE_GLOBAL_CONTROL_REG );
drivers/pci/controller/dwc/pcie-artpec6.c +0 -1
@@ -328,7 +328,6 @@ static int artpec6_pcie_host_init(struct pcie_port *pp)artpec6_pcie_init_phy (artpec6_pcie);artpec6_pcie_deassert_core_reset (artpec6_pcie);artpec6_pcie_wait_for_phy (artpec6_pcie); -dw_pcie_setup_rc (pp);return 0 ; }
drivers/pci/controller/dwc/pcie-designware-host.c +1 -0
@@ -422,6 +422,7 @@ int dw_pcie_host_init(struct pcie_port *pp) goto err_free_msi; } +dw_pcie_setup_rc (pp);dw_pcie_msi_init (pp);if (!dw_pcie_link_up (pci) && pci->ops->start_link) {
drivers/pci/controller/dwc/pcie-designware-plat.c +0 -8
@@ -33,15 +33,7 @@ struct dw_plat_pcie_of_data {static const struct of_device_id dw_plat_pcie_of_match[]; -static int dw_plat_pcie_host_init (struct pcie_port *pp) -{ -dw_pcie_setup_rc (pp); - -return 0 ; -} -static const struct dw_pcie_host_ops dw_plat_pcie_host_ops = { - .host_init = dw_plat_pcie_host_init, };static int dw_plat_pcie_establish_link (struct dw_pcie *pci)
drivers/pci/controller/dwc/pcie-histb.c +0 -3
@@ -196,9 +196,6 @@ static int histb_pcie_host_init(struct pcie_port *pp) regval |=PCIE_WM_RC ;histb_pcie_writel (hipcie,PCIE_SYS_CTRL0 , regval); -/* setup root complex */ -dw_pcie_setup_rc (pp); -return 0 ; }
drivers/pci/controller/dwc/pcie-kirin.c +0 -2
@@ -405,8 +405,6 @@ static int kirin_pcie_host_init(struct pcie_port *pp) { pp->bridge->ops = &kirin_pci_ops; -dw_pcie_setup_rc (pp); -return 0 ; }
drivers/pci/controller/dwc/pcie-qcom.c +0 -1
@@ -1280,7 +1280,6 @@ static int qcom_pcie_host_init(struct pcie_port *pp) goto err_disable_phy; } -dw_pcie_setup_rc (pp);qcom_ep_reset_deassert (pcie);return 0 ;
drivers/pci/controller/dwc/pcie-spear13xx.c +0 -2
@@ -130,8 +130,6 @@ static int spear13xx_pcie_host_init(struct pcie_port *pp) spear13xx_pcie->app_base = pci->dbi_base +0x2000 ; -dw_pcie_setup_rc (pp); -/* * this controller support only 128 bytes read size, however its * default value in capability register is 512 bytes. So force
drivers/pci/controller/dwc/pcie-uniphier.c +0 -2
@@ -314,8 +314,6 @@ static int uniphier_pcie_host_init(struct pcie_port *pp)uniphier_pcie_irq_enable (priv); -dw_pcie_setup_rc (pp); -return 0 ; }
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 13/16 PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init()
In reply to Rob HerringMany calls to dw_pcie_host_init() are in a wrapper function with nothing else now. Let's remove the pointless extra layer.
--- drivers/pci/controller/dwc/pci-imx6.c | 22 ++--------------- drivers/pci/controller/dwc/pci-keystone.c | 19 +-------------- drivers/pci/controller/dwc/pci-layerscape.c | 26 ++------------------- drivers/pci/controller/dwc/pci-meson.c | 22 ++--------------- drivers/pci/controller/dwc/pcie-al.c | 20 ++-------------- drivers/pci/controller/dwc/pcie-artpec6.c | 23 +++--------------- drivers/pci/controller/dwc/pcie-kirin.c | 11 ++------- drivers/pci/controller/dwc/pcie-uniphier.c | 23 +++--------------- 8 files changed, 17 insertions(+), 149 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +2 -20
@@ -842,25 +842,6 @@ static const struct dw_pcie_host_ops imx6_pcie_host_ops = { .host_init = imx6_pcie_host_init, }; -static int imx6_add_pcie_port (struct imx6_pcie *imx6_pcie, -struct platform_device *pdev) -{ -struct dw_pcie *pci = imx6_pcie->pci; -struct pcie_port *pp = &pci->pp; -struct device *dev = &pdev->dev; -int ret; - - pp->ops = &imx6_pcie_host_ops; - - ret =dw_pcie_host_init (pp); -if (ret) { -dev_err (dev,"failed to initialize host\n" ); -return ret; - } - -return 0 ; -} -static const struct dw_pcie_ops dw_pcie_ops = { .start_link = imx6_pcie_start_link, };
@@ -1005,6 +986,7 @@ static int imx6_pcie_probe(struct platform_device *pdev) pci->dev = dev; pci->ops = &dw_pcie_ops; + pci->pp.ops = &imx6_pcie_host_ops; imx6_pcie->pci = pci; imx6_pcie->drvdata =of_device_get_match_data (dev);
@@ -1154,7 +1136,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)if (ret)return ret; - ret =imx6_add_pcie_port (imx6_pcie, pdev); + ret =dw_pcie_host_init (&pci->pp);if (ret <0 )return ret;
drivers/pci/controller/dwc/pci-keystone.c +1 -18
@@ -844,23 +844,6 @@ static irqreturn_t ks_pcie_err_irq_handler(int irq, void *priv)return ks_pcie_handle_error_irq (ks_pcie); } -static int __init ks_pcie_add_pcie_port (struct keystone_pcie *ks_pcie, -struct platform_device *pdev) -{ -struct dw_pcie *pci = ks_pcie->pci; -struct pcie_port *pp = &pci->pp; -struct device *dev = &pdev->dev; -int ret; - - ret =dw_pcie_host_init (pp); -if (ret) { -dev_err (dev,"failed to initialize host\n" ); -return ret; - } - -return 0 ; -} -static void ks_pcie_am654_write_dbi2 (struct dw_pcie *pci,void __iomem *base,u32 reg,size_t size,u32 val) {
@@ -1255,7 +1238,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev) } pci->pp.ops = host_ops; - ret =ks_pcie_add_pcie_port (ks_pcie, pdev); + ret =dw_pcie_host_init (&pci->pp);if (ret <0 ) goto err_get_sync;break ;
drivers/pci/controller/dwc/pci-layerscape.c +2 -24
@@ -232,31 +232,12 @@ static const struct of_device_id ls_pcie_of_match[] = { { }, }; -static int __init ls_add_pcie_port (struct ls_pcie *pcie) -{ -struct dw_pcie *pci = pcie->pci; -struct pcie_port *pp = &pci->pp; -struct device *dev = pci->dev; -int ret; - - pp->ops = pcie->drvdata->ops; - - ret =dw_pcie_host_init (pp); -if (ret) { -dev_err (dev,"failed to initialize host\n" ); -return ret; - } - -return 0 ; -} -static int __init ls_pcie_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct dw_pcie *pci;struct ls_pcie *pcie;struct resource *dbi_base; -int ret; pcie =devm_kzalloc (dev,sizeof (*pcie),GFP_KERNEL );if (!pcie)
@@ -270,6 +251,7 @@ static int __init ls_pcie_probe(struct platform_device *pdev) pci->dev = dev; pci->ops = pcie->drvdata->dw_pcie_ops; + pci->pp.ops = pcie->drvdata->ops; pcie->pci = pci;
@@ -285,11 +267,7 @@ static int __init ls_pcie_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pcie); - ret =ls_add_pcie_port (pcie); -if (ret <0 ) -return ret; - -return 0 ; +return dw_pcie_host_init (&pci->pp); }static struct platform_driver ls_pcie_driver = {
drivers/pci/controller/dwc/pci-meson.c +2 -20
@@ -387,25 +387,6 @@ static const struct dw_pcie_host_ops meson_pcie_host_ops = { .host_init = meson_pcie_host_init, }; -static int meson_add_pcie_port (struct meson_pcie *mp, -struct platform_device *pdev) -{ -struct dw_pcie *pci = &mp->pci; -struct pcie_port *pp = &pci->pp; -struct device *dev = &pdev->dev; -int ret; - - pp->ops = &meson_pcie_host_ops; - - ret =dw_pcie_host_init (pp); -if (ret) { -dev_err (dev,"failed to initialize host\n" ); -return ret; - } - -return 0 ; -} -static const struct dw_pcie_ops dw_pcie_ops = { .link_up = meson_pcie_link_up, .start_link = meson_pcie_start_link,
@@ -425,6 +406,7 @@ static int meson_pcie_probe(struct platform_device *pdev) pci = &mp->pci; pci->dev = dev; pci->ops = &dw_pcie_ops; + pci->pp.ops = &meson_pcie_host_ops; pci->num_lanes =1 ; mp->phy =devm_phy_get (dev,"pcie" );
@@ -471,7 +453,7 @@ static int meson_pcie_probe(struct platform_device *pdev)platform_set_drvdata (pdev, mp); - ret =meson_add_pcie_port (mp, pdev); + ret =dw_pcie_host_init (&pci->pp);if (ret <0 ) {dev_err (dev,"Add PCIe port failed, %d\n" , ret); goto err_phy;
drivers/pci/controller/dwc/pcie-al.c +2 -18
@@ -322,23 +322,6 @@ static const struct dw_pcie_host_ops al_pcie_host_ops = { .host_init = al_pcie_host_init, }; -static int al_add_pcie_port (struct pcie_port *pp, -struct platform_device *pdev) -{ -struct device *dev = &pdev->dev; -int ret; - - pp->ops = &al_pcie_host_ops; - - ret =dw_pcie_host_init (pp); -if (ret) { -dev_err (dev,"failed to initialize host\n" ); -return ret; - } - -return 0 ; -} -static const struct dw_pcie_ops dw_pcie_ops = { };
@@ -360,6 +343,7 @@ static int al_pcie_probe(struct platform_device *pdev) pci->dev = dev; pci->ops = &dw_pcie_ops; + pci->pp.ops = &al_pcie_host_ops; al_pcie->pci = pci; al_pcie->dev = dev;
@@ -384,7 +368,7 @@ static int al_pcie_probe(struct platform_device *pdev)platform_set_drvdata (pdev, al_pcie); -return al_add_pcie_port (&pci->pp, pdev); +return dw_pcie_host_init (&pci->pp); }static const struct of_device_id al_pcie_of_match[] = {
drivers/pci/controller/dwc/pcie-artpec6.c +3 -20
@@ -336,25 +336,6 @@ static const struct dw_pcie_host_ops artpec6_pcie_host_ops = { .host_init = artpec6_pcie_host_init, }; -static int artpec6_add_pcie_port (struct artpec6_pcie *artpec6_pcie, -struct platform_device *pdev) -{ -struct dw_pcie *pci = artpec6_pcie->pci; -struct pcie_port *pp = &pci->pp; -struct device *dev = pci->dev; -int ret; - - pp->ops = &artpec6_pcie_host_ops; - - ret =dw_pcie_host_init (pp); -if (ret) { -dev_err (dev,"failed to initialize host\n" ); -return ret; - } - -return 0 ; -} -static void artpec6_pcie_ep_init (struct dw_pcie_ep *ep) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);
@@ -445,7 +426,9 @@ static int artpec6_pcie_probe(struct platform_device *pdev)if (!IS_ENABLED (CONFIG_PCIE_ARTPEC6_HOST ))return -ENODEV ; - ret =artpec6_add_pcie_port (artpec6_pcie, pdev); + pci->pp.ops = &artpec6_pcie_host_ops; + + ret =dw_pcie_host_init (&pci->pp);if (ret <0 )return ret;break ;
drivers/pci/controller/dwc/pcie-kirin.c +2 -9
@@ -419,14 +419,6 @@ static const struct dw_pcie_host_ops kirin_pcie_host_ops = { .host_init = kirin_pcie_host_init, }; -static int kirin_add_pcie_port (struct dw_pcie *pci, -struct platform_device *pdev) -{ - pci->pp.ops = &kirin_pcie_host_ops; - -return dw_pcie_host_init (&pci->pp); -} -static int kirin_pcie_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -449,6 +441,7 @@ static int kirin_pcie_probe(struct platform_device *pdev) pci->dev = dev; pci->ops = &kirin_dw_pcie_ops; + pci->pp.ops = &kirin_pcie_host_ops; kirin_pcie->pci = pci; ret =kirin_pcie_get_clk (kirin_pcie, pdev);
@@ -474,7 +467,7 @@ static int kirin_pcie_probe(struct platform_device *pdev)platform_set_drvdata (pdev, kirin_pcie); -return kirin_add_pcie_port (pci, pdev); +return dw_pcie_host_init (&pci->pp); }static const struct of_device_id kirin_pcie_match[] = {
drivers/pci/controller/dwc/pcie-uniphier.c +3 -20
@@ -321,25 +321,6 @@ static const struct dw_pcie_host_ops uniphier_pcie_host_ops = { .host_init = uniphier_pcie_host_init, }; -static int uniphier_add_pcie_port (struct uniphier_pcie_priv *priv, -struct platform_device *pdev) -{ -struct dw_pcie *pci = &priv->pci; -struct pcie_port *pp = &pci->pp; -struct device *dev = &pdev->dev; -int ret; - - pp->ops = &uniphier_pcie_host_ops; - - ret =dw_pcie_host_init (pp); -if (ret) { -dev_err (dev,"Failed to initialize host (%d)\n" , ret); -return ret; - } - -return 0 ; -} -static int uniphier_pcie_host_enable (struct uniphier_pcie_priv *priv) {int ret;
@@ -415,7 +396,9 @@ static int uniphier_pcie_probe(struct platform_device *pdev)if (ret)return ret; -return uniphier_add_pcie_port (priv, pdev); + priv->pci.pp.ops = &uniphier_pcie_host_ops; + +return dw_pcie_host_init (&priv->pci.pp); }static const struct of_device_id uniphier_pcie_match[] = {
Signature · 1 line
2.25.1
Rob Herring
reviewerPATCH v2 14/16 Revert "PCI: dwc/keystone: Drop duplicated 'num-viewport'"
In reply to Rob HerringThis reverts commit 421063efaf1e8f2ac6248cca0064e5877e375f87.
In preparation to detect the number of iATU regions instead of using DT properties, we need to keep reading 'num-viewport' for the Keystone driver which doesn't use the iATU in older versions of the IP.
However, note that Keystone has been broken for some time with upstream dts files which don't set 'num-viewports'. The reverted commit did make the property optional, but now it's mandatory again.
---
v2:
- new patch
drivers/pci/controller/dwc/pci-keystone.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-keystone.c +10 -1
@@ -121,6 +121,7 @@ struct keystone_pcie {int msi_host_irq;int num_lanes; +u32 num_viewport;struct phy **phy;struct device_link **link;struct device_node *msi_intc_np;
@@ -386,9 +387,9 @@ static void ks_pcie_clear_dbi_mode(struct keystone_pcie *ks_pcie)static void ks_pcie_setup_rc_app_regs (struct keystone_pcie *ks_pcie) {u32 val; +u32 num_viewport = ks_pcie->num_viewport;struct dw_pcie *pci = ks_pcie->pci;struct pcie_port *pp = &pci->pp; -u32 num_viewport = pci->num_viewport;u64 start, end;struct resource *mem;int i;
@@ -1093,6 +1094,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev)struct resource *res;unsigned int version;void __iomem *base; +u32 num_viewport;struct phy **phy;u32 num_lanes;char name[10 ];
@@ -1224,6 +1226,12 @@ static int __init ks_pcie_probe(struct platform_device *pdev) goto err_get_sync; } + ret =of_property_read_u32 (np,"num-viewport" , &num_viewport); +if (ret <0 ) { +dev_err (dev,"unable to read *num-viewport* property\n" ); + goto err_get_sync; + } +/* * "Power Sequencing and Reset Signal Timings" table in * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 2.0
@@ -1237,6 +1245,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev)gpiod_set_value_cansleep (gpiod,1 ); } + ks_pcie->num_viewport = num_viewport; pci->pp.ops = host_ops; ret =dw_pcie_host_init (&pci->pp);if (ret <0 )
--
2.25.1
Rob Herring
reviewerPATCH v2 15/16 PCI: dwc: Move inbound and outbound windows to common struct
In reply to Rob HerringThe number of inbound and outbound windows are defined by the h/w and apply to both RC and EP modes, so move them to the appropriate struct.
---
v2:
- new patch
.../pci/controller/dwc/pcie-designware-ep.c | 25 ++++++++++--------- drivers/pci/controller/dwc/pcie-designware.h | 4 +-- 2 files changed, 15 insertions(+), 14 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +13 -12
@@ -161,8 +161,8 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no,u32 free_win;struct dw_pcie *pci =to_dw_pcie_from_ep (ep); - free_win =find_first_zero_bit (ep->ib_window_map, ep->num_ib_windows); -if (free_win >= ep->num_ib_windows) { + free_win =find_first_zero_bit (ep->ib_window_map, pci->num_ib_windows); +if (free_win >= pci->num_ib_windows) {dev_err (pci->dev,"No free inbound window\n" );return -EINVAL ; }
@@ -187,8 +187,8 @@ static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, u8 func_no,u32 free_win;struct dw_pcie *pci =to_dw_pcie_from_ep (ep); - free_win =find_first_zero_bit (ep->ob_window_map, ep->num_ob_windows); -if (free_win >= ep->num_ob_windows) { + free_win =find_first_zero_bit (ep->ob_window_map, pci->num_ob_windows); +if (free_win >= pci->num_ob_windows) {dev_err (pci->dev,"No free outbound window\n" );return -EINVAL ; }
@@ -264,8 +264,9 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr, u32 *atu_index) {u32 index; +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); -for (index =0 ; index < ep->num_ob_windows; index++) { +for (index =0 ; index < pci->num_ob_windows; index++) {if (ep->outbound_addr[index] != addr)continue ; *atu_index = index;
@@ -713,41 +714,41 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) ep->phys_base = res->start; ep->addr_size =resource_size (res); - ret =of_property_read_u32 (np,"num-ib-windows" , &ep->num_ib_windows); + ret =of_property_read_u32 (np,"num-ib-windows" , &pci->num_ib_windows);if (ret <0 ) {dev_err (dev,"Unable to read *num-ib-windows* property\n" );return ret; } -if (ep->num_ib_windows >MAX_IATU_IN ) { +if (pci->num_ib_windows >MAX_IATU_IN ) {dev_err (dev,"Invalid *num-ib-windows*\n" );return -EINVAL ; } - ret =of_property_read_u32 (np,"num-ob-windows" , &ep->num_ob_windows); + ret =of_property_read_u32 (np,"num-ob-windows" , &pci->num_ob_windows);if (ret <0 ) {dev_err (dev,"Unable to read *num-ob-windows* property\n" );return ret; } -if (ep->num_ob_windows >MAX_IATU_OUT ) { +if (pci->num_ob_windows >MAX_IATU_OUT ) {dev_err (dev,"Invalid *num-ob-windows*\n" );return -EINVAL ; } ep->ib_window_map =devm_kcalloc (dev, -BITS_TO_LONGS (ep->num_ib_windows), +BITS_TO_LONGS (pci->num_ib_windows),sizeof (long ),GFP_KERNEL );if (!ep->ib_window_map)return -ENOMEM ; ep->ob_window_map =devm_kcalloc (dev, -BITS_TO_LONGS (ep->num_ob_windows), +BITS_TO_LONGS (pci->num_ob_windows),sizeof (long ),GFP_KERNEL );if (!ep->ob_window_map)return -ENOMEM ; - addr =devm_kcalloc (dev, ep->num_ob_windows,sizeof (phys_addr_t), + addr =devm_kcalloc (dev, pci->num_ob_windows,sizeof (phys_addr_t),GFP_KERNEL );if (!addr)return -ENOMEM ;
drivers/pci/controller/dwc/pcie-designware.h +2 -2
@@ -236,8 +236,6 @@ struct dw_pcie_ep {phys_addr_t *outbound_addr;unsigned long *ib_window_map;unsigned long *ob_window_map; -u32 num_ib_windows; -u32 num_ob_windows;void __iomem *msi_mem;phys_addr_t msi_mem_phys;struct pci_epf_bar *epf_bar[PCI_STD_NUM_BARS ];
@@ -263,6 +261,8 @@ struct dw_pcie {/* Used when iatu_unroll_enabled is true */ void __iomem *atu_base;u32 num_viewport; +u32 num_ib_windows; +u32 num_ob_windows;struct pcie_port pp;struct dw_pcie_ep ep;const struct dw_pcie_ops *ops;
--
2.25.1
Rob Herring
reviewerPATCH v2 16/16 PCI: dwc: Detect number of iATU windows
In reply to Rob HerringCurrently the number of inbound and outbound iATU windows are determined from DT properties. Unfortunately, there's 'num-viewport' for RC mode and 'num-ib-windows' and 'num-ob-windows' for EP mode, yet the number of windows is not mode dependent. Also, 'num-viewport' is not clear whether that's inbound, outbound or both. We can probably assume it's outbound windows as that's all RC mode uses.
However, using DT properties isn't really needed as the number of regions can be detected at runtime by poking the iATU registers. The basic algorithm is just writing a target address and reading back what we wrote. In the unrolled ATU case, we have to take care not to go past the mapped region.
With this, we can drop num_viewport in favor of num_ob_windows instead.
---
v2:
- new patch
.../pci/controller/dwc/pcie-designware-ep.c | 20 ---- .../pci/controller/dwc/pcie-designware-host.c | 14 +-- drivers/pci/controller/dwc/pcie-designware.c | 93 +++++++++++++++++-- drivers/pci/controller/dwc/pcie-designware.h | 2 +- drivers/pci/controller/dwc/pcie-intel-gw.c | 8 -- drivers/pci/controller/dwc/pcie-tegra194.c | 1 + 6 files changed, 93 insertions(+), 45 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +0 -20
@@ -714,26 +714,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) ep->phys_base = res->start; ep->addr_size =resource_size (res); - ret =of_property_read_u32 (np,"num-ib-windows" , &pci->num_ib_windows); -if (ret <0 ) { -dev_err (dev,"Unable to read *num-ib-windows* property\n" ); -return ret; - } -if (pci->num_ib_windows >MAX_IATU_IN ) { -dev_err (dev,"Invalid *num-ib-windows*\n" ); -return -EINVAL ; - } - - ret =of_property_read_u32 (np,"num-ob-windows" , &pci->num_ob_windows); -if (ret <0 ) { -dev_err (dev,"Unable to read *num-ob-windows* property\n" ); -return ret; - } -if (pci->num_ob_windows >MAX_IATU_OUT ) { -dev_err (dev,"Invalid *num-ob-windows*\n" ); -return -EINVAL ; - } - ep->ib_window_map = devm_kcalloc(dev, BITS_TO_LONGS(pci->num_ib_windows), sizeof(long),
drivers/pci/controller/dwc/pcie-designware-host.c +5 -9
@@ -356,10 +356,6 @@ int dw_pcie_host_init(struct pcie_port *pp) } } - ret =of_property_read_u32 (np,"num-viewport" , &pci->num_viewport); -if (ret) - pci->num_viewport =2 ; -if (pci->link_gen <1 ) pci->link_gen =of_pci_get_max_link_speed (np);
@@ -598,7 +594,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp)dw_pcie_writel_dbi (pci,PCI_COMMAND , val);/* Ensure all outbound windows are disabled so there are multiple matches */ -for (i =0 ; i < pci->num_viewport; i++) +for (i =0 ; i < pci->num_ob_windows; i++)dw_pcie_disable_atu (pci, i,DW_PCIE_REGION_OUTBOUND );/*
@@ -615,7 +611,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp)if (resource_type (entry->res) !=IORESOURCE_MEM )continue ; -if (pci->num_viewport <= ++atu_idx) +if (pci->num_ob_windows <= ++atu_idx)break ; dw_pcie_prog_outbound_atu(pci, atu_idx,
@@ -625,7 +621,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp) }if (pp->io_size) { -if (pci->num_viewport > ++atu_idx) +if (pci->num_ob_windows > ++atu_idx)dw_pcie_prog_outbound_atu (pci, atu_idx,PCIE_ATU_TYPE_IO , pp->io_base, pp->io_bus_addr, pp->io_size);
@@ -633,9 +629,9 @@ void dw_pcie_setup_rc(struct pcie_port *pp) pci->io_cfg_atu_shared = true; } -if (pci->num_viewport <= atu_idx) +if (pci->num_ob_windows <= atu_idx)dev_warn (pci->dev,"Resources exceed number of ATU entries (%d)" , - pci->num_viewport); + pci->num_ob_windows); }dw_pcie_writel_dbi (pci,PCI_BASE_ADDRESS_0 ,0 );
drivers/pci/controller/dwc/pcie-designware.c +86 -7
107 lines not on this page · raw message
drivers/pci/controller/dwc/pcie-designware.h +1 -1
@@ -260,7 +260,7 @@ struct dw_pcie {void __iomem *dbi_base2;/* Used when iatu_unroll_enabled is true */ void __iomem *atu_base; -u32 num_viewport; +size_t atu_size;u32 num_ib_windows;u32 num_ob_windows;struct pcie_port pp;
drivers/pci/controller/dwc/pcie-intel-gw.c +0 -8
@@ -58,7 +58,6 @@struct intel_pcie_soc {unsigned int pcie_ver; -u32 num_viewport; };struct intel_pcie_port {
@@ -400,7 +399,6 @@ static const struct dw_pcie_host_ops intel_pcie_dw_ops = {static const struct intel_pcie_soc pcie_data = { .pcie_ver =0x520A , - .num_viewport =3 , };static int intel_pcie_probe (struct platform_device *pdev)
@@ -443,12 +441,6 @@ static int intel_pcie_probe(struct platform_device *pdev)return ret; } -/* -* Intel PCIe doesn't configure IO region, so set viewport -* to not perform IO region access. -*/ - pci->num_viewport = data->num_viewport; -return 0 ; }
drivers/pci/controller/dwc/pcie-tegra194.c +1 -0
@@ -2075,6 +2075,7 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev) } pcie->atu_dma_res = atu_dma_res; + pci->atu_size =resource_size (atu_dma_res); pci->atu_base =devm_ioremap_resource (dev, atu_dma_res);if (IS_ERR (pci->atu_base))return PTR_ERR (pci->atu_base);
--
2.25.1
Hi Rob,
Quoted 4 lines · Rob Herring
Here's another batch of DWC PCI host refactoring. This series primarily moves more of the MSI, link up, and resource handling to the core code. Beyond a couple of minor fixes, new in this version is runtime detection of iATU regions instead of using DT properties.
iATU detection seems to work fine with
https://lore.kernel.org/linux-samsung-soc/[email protected]/
on top of your patchset on Samsung Exynos5433 SoC:
exynos-pcie 15700000.pcie: host bridge /soc@0/pcie@15700000 ranges:
exynos-pcie 15700000.pcie: IO 0x000c001000..0x000c010fff -> 0x0000000000
exynos-pcie 15700000.pcie: MEM 0x000c011000..0x000ffffffe -> 0x000c011000
exynos-pcie 15700000.pcie: iATU unroll: disabled
exynos-pcie 15700000.pcie: Detected iATU regions: 3 outbound, 5 inbound exynos-pcie 15700000.pcie: Link up
exynos-pcie 15700000.pcie: PCI host bridge to bus 0000:00
Fell free to add my:
Quoted 56 lines
No doubt I've probably broken something. Please test. I've run this thru kernelci and checked boards with DWC PCI which currently is just Layerscape boards (hint: add boards and/or enable PCI). A git branch is here[1].
This is dependent on "PCI: dwc: Restore ATU memory resource setup to use last entry" which will be in v5.10-rc3.
Rob
[1]
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.gitpci-more-dwc-cleanupRob Herring (16):
PCI: dwc: Support multiple ATU memory regions
PCI: dwc/intel-gw: Move ATU offset out of driver match data
PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into
common code
PCI: dwc/intel-gw: Remove some unneeded function wrappers
PCI: dwc: Ensure all outbound ATU windows are reset
PCI: dwc/dra7xx: Use the common MSIirq_chip
PCI: dwc: Drop the .set_num_vectors() host op
PCI: dwc: Move MSI interrupt setup into DWC common code
PCI: dwc: Rework MSI initialization
PCI: dwc: Move link handling into common code
PCI: dwc: Movedw_pcie_msi_init()into core
PCI: dwc: Movedw_pcie_setup_rc()to DWC common code
PCI: dwc: Remove unnecessary wrappers arounddw_pcie_host_init()Revert "PCI: dwc/keystone: Drop duplicated 'num-viewport'"
PCI: dwc: Move inbound and outbound windows to common struct
PCI: dwc: Detect number of iATU windowsdrivers/pci/controller/dwc/pci-dra7xx.c | 141 +----------------- drivers/pci/controller/dwc/pci-exynos.c | 50 ++----- drivers/pci/controller/dwc/pci-imx6.c | 39 +---- drivers/pci/controller/dwc/pci-keystone.c | 79 ++-------- .../pci/controller/dwc/pci-layerscape-ep.c | 37 +---- drivers/pci/controller/dwc/pci-layerscape.c | 67 +-------- drivers/pci/controller/dwc/pci-meson.c | 53 ++----- drivers/pci/controller/dwc/pcie-al.c | 29 +--- drivers/pci/controller/dwc/pcie-armada8k.c | 37 ++--- drivers/pci/controller/dwc/pcie-artpec6.c | 76 +--------- .../pci/controller/dwc/pcie-designware-ep.c | 58 +++---- .../pci/controller/dwc/pcie-designware-host.c | 139 ++++++++++------- .../pci/controller/dwc/pcie-designware-plat.c | 70 +-------- drivers/pci/controller/dwc/pcie-designware.c | 93 +++++++++++- drivers/pci/controller/dwc/pcie-designware.h | 24 +-- drivers/pci/controller/dwc/pcie-histb.c | 37 ++--- drivers/pci/controller/dwc/pcie-intel-gw.c | 67 ++------- drivers/pci/controller/dwc/pcie-kirin.c | 62 +------- drivers/pci/controller/dwc/pcie-qcom.c | 38 +---- drivers/pci/controller/dwc/pcie-spear13xx.c | 62 +++----- drivers/pci/controller/dwc/pcie-tegra194.c | 41 +---- drivers/pci/controller/dwc/pcie-uniphier-ep.c | 38 +---- drivers/pci/controller/dwc/pcie-uniphier.c | 51 +------ 23 files changed, 356 insertions(+), 1032 deletions(-)
Quoted 3 lines
--
2.25.1
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Lorenzo Pieralisi
AppliedQuoted 11 lines · Rob Herring
Here's another batch of DWC PCI host refactoring. This series primarily moves more of the MSI, link up, and resource handling to the core code. Beyond a couple of minor fixes, new in this version is runtime detection of iATU regions instead of using DT properties.
No doubt I've probably broken something. Please test. I've run this thru kernelci and checked boards with DWC PCI which currently is just Layerscape boards (hint: add boards and/or enable PCI). A git branch is here[1].
[...]
Applied to pci/dwc, thanks!
[01/16] PCI: dwc: Support multiple ATU memory regions
https://git.kernel.org/lpieralisi/pci/c/9f9e59a480 [02/16] PCI: dwc/intel-gw: Move ATU offset out of driver match data https://git.kernel.org/lpieralisi/pci/c/1d567aac46 [03/16] PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into common code https://git.kernel.org/lpieralisi/pci/c/a0fd361db8 [04/16] PCI: dwc/intel-gw: Remove some unneeded function wrappers https://git.kernel.org/lpieralisi/pci/c/1cc9a55999 [05/16] PCI: dwc: Ensure all outbound ATU windows are reset https://git.kernel.org/lpieralisi/pci/c/458ad06c4c [06/16] PCI: dwc/dra7xx: Use the common MSI irq_chip https://git.kernel.org/lpieralisi/pci/c/7f170d35f5 [07/16] PCI: dwc: Drop the .set_num_vectors() host op https://git.kernel.org/lpieralisi/pci/c/331e9bcead [08/16] PCI: dwc: Move MSI interrupt setup into DWC common code https://git.kernel.org/lpieralisi/pci/c/5bcb1757e6 [09/16] PCI: dwc: Rework MSI initialization https://git.kernel.org/lpieralisi/pci/c/f78f02638a [10/16] PCI: dwc: Move link handling into common code https://git.kernel.org/lpieralisi/pci/c/886a9c1347 [11/16] PCI: dwc: Move dw_pcie_msi_init() into core https://git.kernel.org/lpieralisi/pci/c/59fbab1ae4 [12/16] PCI: dwc: Move dw_pcie_setup_rc() to DWC common code https://git.kernel.org/lpieralisi/pci/c/b9ac0f9dc8 [13/16] PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init() https://git.kernel.org/lpieralisi/pci/c/60f5b73fa0 [14/16] Revert "PCI: dwc/keystone: Drop duplicated 'num-viewport'" https://git.kernel.org/lpieralisi/pci/c/fcde397422 [15/16] PCI: dwc: Move inbound and outbound windows to common struct https://git.kernel.org/lpieralisi/pci/c/9ca17af552 [16/16] PCI: dwc: Detect number of iATU windows https://git.kernel.org/lpieralisi/pci/c/281f1f99cf
Thanks,
Lorenzo