[PATCH v6 11/11] misc: pci_endpoint_test: Add LS1088a in pci_device_id table
Add LS1088a in pci_device_id table so that pci-epf-test can be used for testing PCIe EP in LS1088a. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. v4: - Use a maco to define the LS1088a device ID. v5: - No change. v6: - No change. drivers/misc/pci_endpoint_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index a5e3170..72d694f 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -65,6 +65,7 @@ #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 #define PCI_DEVICE_ID_TI_AM654 0xb00c +#define PCI_DEVICE_ID_LS1088A 0x80c0 #define is_am654_pci_dev(pdev) \ ((pdev)->device == PCI_DEVICE_ID_TI_AM654) @@ -793,6 +794,7 @@ static const struct pci_device_id pci_endpoint_test_tbl[] = { { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_LS1088A) }, { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), .driver_data = (kernel_ulong_t)_data -- 2.9.5
[PATCH v6 10/11] arm64: dts: layerscape: Add PCIe EP node for ls1088a
Add PCIe EP node for ls1088a to support EP mode. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - Remove the pf-offset proparty. v3: - No change. v4: - No change. v5: - No change. v6: - No change. arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 ++ 1 file changed, 31 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi index ec6013a..cb0805b 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi @@ -497,6 +497,17 @@ status = "disabled"; }; + pcie_ep@340 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0340 0x0 0x0010 + 0x20 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <24>; + num-ob-windows = <128>; + max-functions = /bits/ 8 <2>; + status = "disabled"; + }; + pcie@350 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0350 0x0 0x0010 /* controller registers */ @@ -522,6 +533,16 @@ status = "disabled"; }; + pcie_ep@350 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0350 0x0 0x0010 + 0x28 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + pcie@360 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0360 0x0 0x0010 /* controller registers */ @@ -547,6 +568,16 @@ status = "disabled"; }; + pcie_ep@360 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0360 0x0 0x0010 + 0x30 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + smmu: iommu@500 { compatible = "arm,mmu-500"; reg = <0 0x500 0 0x80>; -- 2.9.5
[PATCH v6 09/11] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
Add PCIe EP mode support for ls1088a and ls2088a, there are some difference between LS1 and LS2 platform, so refactor the code of the EP driver. Signed-off-by: Xiaowei Bao --- v2: - This is a new patch for supporting the ls1088a and ls2088a platform. v3: - Adjust the some struct assignment order in probe function. v4: - No change. v5: - No change. v6: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 72 +++--- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index bfab1c6..84206f2 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -20,27 +20,29 @@ #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ -struct ls_pcie_ep { - struct dw_pcie *pci; - struct pci_epc_features *ls_epc; +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) + +struct ls_pcie_ep_drvdata { + u32 func_offset; + const struct dw_pcie_ep_ops *ops; + const struct dw_pcie_ops*dw_pcie_ops; }; -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) +struct ls_pcie_ep { + struct dw_pcie *pci; + struct pci_epc_features *ls_epc; + const struct ls_pcie_ep_drvdata *drvdata; +}; static int ls_pcie_establish_link(struct dw_pcie *pci) { return 0; } -static const struct dw_pcie_ops ls_pcie_ep_ops = { +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { .start_link = ls_pcie_establish_link, }; -static const struct of_device_id ls_pcie_ep_of_match[] = { - { .compatible = "fsl,ls-pcie-ep",}, - { }, -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { @@ -87,10 +89,39 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, } } -static const struct dw_pcie_ep_ops pcie_ep_ops = { +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep, + u8 func_no) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + WARN_ON(func_no && !pcie->drvdata->func_offset); + return pcie->drvdata->func_offset * func_no; +} + +static const struct dw_pcie_ep_ops ls_pcie_ep_ops = { .ep_init = ls_pcie_ep_init, .raise_irq = ls_pcie_ep_raise_irq, .get_features = ls_pcie_ep_get_features, + .func_conf_select = ls_pcie_ep_func_conf_select, +}; + +static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = { + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct ls_pcie_ep_drvdata ls2_ep_drvdata = { + .func_offset = 0x2, + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct of_device_id ls_pcie_ep_of_match[] = { + { .compatible = "fsl,ls1046a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls1088a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls2088a-pcie-ep", .data = _ep_drvdata }, + { }, }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, @@ -103,7 +134,7 @@ static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, int ret; ep = >ep; - ep->ops = _ep_ops; + ep->ops = pcie->drvdata->ops; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); if (!res) @@ -142,20 +173,23 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!ls_epc) return -ENOMEM; - dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); - if (IS_ERR(pci->dbi_base)) - return PTR_ERR(pci->dbi_base); + pcie->drvdata = of_device_get_match_data(dev); - pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; pci->dev = dev; - pci->ops = _pcie_ep_ops; - pcie->pci = pci; + pci->ops = pcie->drvdata->dw_pcie_ops; ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + pcie->pci = pci; pcie->ls_epc = ls_epc; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); + pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); + if (IS_ERR(pci->dbi_base)) + return PTR_ERR(pci->dbi_base); + + pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v6 08/11] PCI: layerscape: Modify the MSIX to the doorbell mode
dw_pcie_ep_raise_msix_irq was never called in the exisitng driver before, because the ls1046a platform don't support the MSIX feature and msix_capable was always set to false. Now that add the ls1088a platform with MSIX support, use the doorbell method to support the MSIX feature. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change v3: - Modify the commit message make it clearly. v4: - No change v5: - Modify the commit message. v6: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 9601f9c..bfab1c6 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -79,7 +79,8 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, case PCI_EPC_IRQ_MSI: return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); case PCI_EPC_IRQ_MSIX: - return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num); + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, + interrupt_num); default: dev_err(pci->dev, "UNKNOWN IRQ type\n"); return -EINVAL; -- 2.9.5
[PATCH v6 07/11] PCI: layerscape: Modify the way of getting capability with different PEX
The different PCIe controller in one board may be have different capability of MSI or MSIX, so change the way of getting the MSI capability, make it more flexible. Signed-off-by: Xiaowei Bao --- v2: - Remove the repeated assignment code. v3: - Use ep_func msi_cap and msix_cap to decide the msi_capable and msix_capable of pci_epc_features struct. v4: - No change. v5: - No change. v6: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 31 +++--- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 0691d9a..9601f9c 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -22,6 +22,7 @@ struct ls_pcie_ep { struct dw_pcie *pci; + struct pci_epc_features *ls_epc; }; #define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) @@ -40,26 +41,31 @@ static const struct of_device_id ls_pcie_ep_of_match[] = { { }, }; -static const struct pci_epc_features ls_pcie_epc_features = { - .linkup_notifier = false, - .msi_capable = true, - .msix_capable = false, - .bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { - return _pcie_epc_features; + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + return pcie->ls_epc; } static void ls_pcie_ep_init(struct dw_pcie_ep *ep) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + struct dw_pcie_ep_func *ep_func; enum pci_barno bar; + ep_func = dw_pcie_ep_get_func_from_ep(ep, 0); + if (!ep_func) + return; + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) dw_pcie_ep_reset_bar(pci, bar); + + pcie->ls_epc->msi_capable = ep_func->msi_cap ? true : false; + pcie->ls_epc->msix_capable = ep_func->msix_cap ? true : false; } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, @@ -119,6 +125,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) struct device *dev = >dev; struct dw_pcie *pci; struct ls_pcie_ep *pcie; + struct pci_epc_features *ls_epc; struct resource *dbi_base; int ret; @@ -130,6 +137,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!pci) return -ENOMEM; + ls_epc = devm_kzalloc(dev, sizeof(*ls_epc), GFP_KERNEL); + if (!ls_epc) + return -ENOMEM; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); if (IS_ERR(pci->dbi_base)) @@ -140,6 +151,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) pci->ops = _pcie_ep_ops; pcie->pci = pci; + ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + + pcie->ls_epc = ls_epc; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v6 06/11] PCI: layerscape: Fix some format issue of the code
Fix some format issue of the code in EP driver. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. v4: - No change. v5: - No change. v6: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 0d151ce..0691d9a 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -63,7 +63,7 @@ static void ls_pcie_ep_init(struct dw_pcie_ep *ep) } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, - enum pci_epc_irq_type type, u16 interrupt_num) + enum pci_epc_irq_type type, u16 interrupt_num) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); @@ -87,7 +87,7 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = { }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, - struct platform_device *pdev) +struct platform_device *pdev) { struct dw_pcie *pci = pcie->pci; struct device *dev = pci->dev; -- 2.9.5
[PATCH v6 05/11] dt-bindings: pci: layerscape-pci: Add compatible strings for ls1088a and ls2088a
Add compatible strings for ls1088a and ls2088a. Signed-off-by: Xiaowei Bao Acked-by: Rob Herring --- v2: - No change. v3: - Use one valid combination of compatible strings. v4: - Add the comma between the two compatible. v5: - No change. v6: - No change. Documentation/devicetree/bindings/pci/layerscape-pci.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt b/Documentation/devicetree/bindings/pci/layerscape-pci.txt index 99a386e..daa99f7 100644 --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt @@ -24,6 +24,8 @@ Required properties: "fsl,ls1028a-pcie" EP mode: "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" + "fsl,ls1088a-pcie-ep", "fsl,ls-pcie-ep" + "fsl,ls2088a-pcie-ep", "fsl,ls-pcie-ep" - reg: base addresses and lengths of the PCIe controller register blocks. - interrupts: A list of interrupt outputs of the controller. Must contain an entry for each entry in the interrupt-names property. -- 2.9.5
[PATCH v6 04/11] PCI: designware-ep: Modify MSI and MSIX CAP way of finding
Each PF of EP device should have it's own MSI or MSIX capabitily struct, so create a dw_pcie_ep_func struct and remove the msi_cap and msix_cap to this struct from dw_pcie_ep, and manage the PFs with a list. Signed-off-by: Xiaowei Bao --- v3: - This is a new patch, to fix the issue of MSI and MSIX CAP way of finding. v4: - Correct some word of commit message. v5: - No change. v6: - Fix up the compile error. drivers/pci/controller/dwc/pcie-designware-ep.c | 135 +--- drivers/pci/controller/dwc/pcie-designware.h| 18 +++- 2 files changed, 134 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 933bb89..fb915f2 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -19,6 +19,19 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) pci_epc_linkup(epc); } +struct dw_pcie_ep_func * +dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no) +{ + struct dw_pcie_ep_func *ep_func; + + list_for_each_entry(ep_func, >func_list, list) { + if (ep_func->func_no == func_no) + return ep_func; + } + + return NULL; +} + static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no) { unsigned int func_offset = 0; @@ -59,6 +72,47 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } +static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no, + u8 cap_ptr, u8 cap) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + u8 cap_id, next_cap_ptr; + u16 reg; + + if (!cap_ptr) + return 0; + + func_offset = dw_pcie_ep_func_select(ep, func_no); + + reg = dw_pcie_readw_dbi(pci, func_offset + cap_ptr); + cap_id = (reg & 0x00ff); + + if (cap_id > PCI_CAP_ID_MAX) + return 0; + + if (cap_id == cap) + return cap_ptr; + + next_cap_ptr = (reg & 0xff00) >> 8; + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); +} + +static u8 dw_pcie_ep_find_capability(struct dw_pcie_ep *ep, u8 func_no, u8 cap) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + u8 next_cap_ptr; + u16 reg; + + func_offset = dw_pcie_ep_func_select(ep, func_no); + + reg = dw_pcie_readw_dbi(pci, func_offset + PCI_CAPABILITY_LIST); + next_cap_ptr = (reg & 0x00ff); + + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); +} + static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, struct pci_epf_header *hdr) { @@ -246,13 +300,18 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; - if (!ep->msi_cap) + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; + + if (!ep_func->msi_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS; + reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS; val = dw_pcie_readw_dbi(pci, reg); if (!(val & PCI_MSI_FLAGS_ENABLE)) return -EINVAL; @@ -268,13 +327,18 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; + + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; - if (!ep->msi_cap) + if (!ep_func->msi_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS; + reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS; val = dw_pcie_readw_dbi(pci, reg); val &= ~PCI_MSI_FLAGS_QMASK; val |= (interrupts << 1) & PCI_MSI_FLAGS_QMASK; @@ -291,13 +355,18 @@ static int dw_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; + + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; - if (!ep->msix_cap) + if (!ep_func->msix_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no
[PATCH v6 03/11] PCI: designware-ep: Move the function of getting MSI capability forward
Move the function of getting MSI capability to the front of init function, because the init function of the EP platform driver will use the return value by the function of getting MSI capability. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. v4: - No change. v5: - No change. v6: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 44ece33..933bb89 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -632,6 +632,10 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) if (ret < 0) epc->max_functions = 1; + ep->msi_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); + + ep->msix_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSIX); + if (ep->ops->ep_init) ep->ops->ep_init(ep); @@ -648,9 +652,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) dev_err(dev, "Failed to reserve memory for MSI/MSI-X\n"); return -ENOMEM; } - ep->msi_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); - - ep->msix_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSIX); offset = dw_pcie_ep_find_ext_capability(pci, PCI_EXT_CAP_ID_REBAR); if (offset) { -- 2.9.5
[PATCH v6 01/11] PCI: designware-ep: Add multiple PFs support for DWC
Add multiple PFs support for DWC, due to different PF have different config space, we use func_conf_select callback function to access the different PF's config space, the different chip company need to implement this callback function when use the DWC IP core and intend to support multiple PFs feature. Signed-off-by: Xiaowei Bao Acked-by: Gustavo Pimentel --- v2: - Remove duplicate redundant code. - Reimplement the PF config space access way. v3: - Integrate duplicate code for func_select. - Move PCIE_ATU_FUNC_NUM(pf) (pf << 20) to ((pf) << 20). - Add the comments for func_conf_select function. v4: - Correct the commit message. v5: - No change. v6: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 123 drivers/pci/controller/dwc/pcie-designware.c| 59 drivers/pci/controller/dwc/pcie-designware.h| 18 +++- 3 files changed, 142 insertions(+), 58 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index cfeccd7..58d8556 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -19,12 +19,26 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) pci_epc_linkup(epc); } -static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar, - int flags) +static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no) +{ + unsigned int func_offset = 0; + + if (ep->ops->func_conf_select) + func_offset = ep->ops->func_conf_select(ep, func_no); + + return func_offset; +} + +static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no, + enum pci_barno bar, int flags) { u32 reg; + unsigned int func_offset = 0; + struct dw_pcie_ep *ep = >ep; + + func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = PCI_BASE_ADDRESS_0 + (4 * bar); + reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar); dw_pcie_dbi_ro_wr_en(pci); dw_pcie_writel_dbi2(pci, reg, 0x0); dw_pcie_writel_dbi(pci, reg, 0x0); @@ -37,7 +51,12 @@ static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar, void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { - __dw_pcie_ep_reset_bar(pci, bar, 0); + u8 func_no, funcs; + + funcs = pci->ep.epc->max_functions; + + for (func_no = 0; func_no < funcs; func_no++) + __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, @@ -45,28 +64,31 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, { struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + + func_offset = dw_pcie_ep_func_select(ep, func_no); dw_pcie_dbi_ro_wr_en(pci); - dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, hdr->vendorid); - dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, hdr->deviceid); - dw_pcie_writeb_dbi(pci, PCI_REVISION_ID, hdr->revid); - dw_pcie_writeb_dbi(pci, PCI_CLASS_PROG, hdr->progif_code); - dw_pcie_writew_dbi(pci, PCI_CLASS_DEVICE, + dw_pcie_writew_dbi(pci, func_offset + PCI_VENDOR_ID, hdr->vendorid); + dw_pcie_writew_dbi(pci, func_offset + PCI_DEVICE_ID, hdr->deviceid); + dw_pcie_writeb_dbi(pci, func_offset + PCI_REVISION_ID, hdr->revid); + dw_pcie_writeb_dbi(pci, func_offset + PCI_CLASS_PROG, hdr->progif_code); + dw_pcie_writew_dbi(pci, func_offset + PCI_CLASS_DEVICE, hdr->subclass_code | hdr->baseclass_code << 8); - dw_pcie_writeb_dbi(pci, PCI_CACHE_LINE_SIZE, + dw_pcie_writeb_dbi(pci, func_offset + PCI_CACHE_LINE_SIZE, hdr->cache_line_size); - dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_VENDOR_ID, + dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_VENDOR_ID, hdr->subsys_vendor_id); - dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_ID, hdr->subsys_id); - dw_pcie_writeb_dbi(pci, PCI_INTERRUPT_PIN, + dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_ID, hdr->subsys_id); + dw_pcie_writeb_dbi(pci, func_offset + PCI_INTERRUPT_PIN, hdr->interrupt_pin); dw_pcie_dbi_ro_wr_dis(pci); return 0; } -static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar, - dma_addr_t cpu_addr, +static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no, + enum pci_barno bar, dma_addr_t cpu_addr, enum dw_pcie_as_type as_type) { int ret; @@ -79,7 +101,7 @@ static int dw_pcie_ep
[PATCH v6 02/11] PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode
Add the doorbell mode of MSI-X in DWC EP driver. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - Remove the macro of no used. v3: - No change. v4: - Modify the commit message. v5: - No change. v6: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 14 ++ drivers/pci/controller/dwc/pcie-designware.h| 12 2 files changed, 26 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 58d8556..44ece33 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -449,6 +449,20 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no, + u16 interrupt_num) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + u32 msg_data; + + msg_data = (func_no << PCIE_MSIX_DOORBELL_PF_SHIFT) | + (interrupt_num - 1); + + dw_pcie_writel_dbi(pci, PCIE_MSIX_DOORBELL, msg_data); + + return 0; +} + int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, u16 interrupt_num) { diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 00d2d31..cb32afa 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -97,6 +97,9 @@ #define PCIE_MISC_CONTROL_1_OFF0x8BC #define PCIE_DBI_RO_WR_EN BIT(0) +#define PCIE_MSIX_DOORBELL 0x948 +#define PCIE_MSIX_DOORBELL_PF_SHIFT24 + #define PCIE_PL_CHK_REG_CONTROL_STATUS 0xB20 #define PCIE_PL_CHK_REG_CHK_REG_START BIT(0) #define PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS BIT(1) @@ -431,6 +434,8 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, u8 interrupt_num); int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, u16 interrupt_num); +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no, + u16 interrupt_num); void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar); #else static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) @@ -463,6 +468,13 @@ static inline int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +static inline int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, +u8 func_no, +u16 interrupt_num) +{ + return 0; +} + static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { } -- 2.9.5
[PATCH v6 00/11] Add the multiple PF support for DWC and Layerscape
Add the PCIe EP multiple PF support for DWC and Layerscape, add the doorbell MSIX function for DWC, use list to manage the PF of one PCIe controller, and refactor the Layerscape EP driver due to some platforms difference. Xiaowei Bao (11): PCI: designware-ep: Add multiple PFs support for DWC PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode PCI: designware-ep: Move the function of getting MSI capability forward PCI: designware-ep: Modify MSI and MSIX CAP way of finding dt-bindings: pci: layerscape-pci: Add compatible strings for ls1088a and ls2088a PCI: layerscape: Fix some format issue of the code PCI: layerscape: Modify the way of getting capability with different PEX PCI: layerscape: Modify the MSIX to the doorbell mode PCI: layerscape: Add EP mode support for ls1088a and ls2088a arm64: dts: layerscape: Add PCIe EP node for ls1088a misc: pci_endpoint_test: Add LS1088a in pci_device_id table .../devicetree/bindings/pci/layerscape-pci.txt | 2 + arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 +++ drivers/misc/pci_endpoint_test.c | 2 + drivers/pci/controller/dwc/pci-layerscape-ep.c | 100 ++-- drivers/pci/controller/dwc/pcie-designware-ep.c| 255 + drivers/pci/controller/dwc/pcie-designware.c | 59 +++-- drivers/pci/controller/dwc/pcie-designware.h | 48 +++- 7 files changed, 404 insertions(+), 93 deletions(-) -- 2.9.5
[PATCH v5 01/11] PCI: designware-ep: Add multiple PFs support for DWC
Add multiple PFs support for DWC, due to different PF have different config space, we use func_conf_select callback function to access the different PF's config space, the different chip company need to implement this callback function when use the DWC IP core and intend to support multiple PFs feature. Signed-off-by: Xiaowei Bao Acked-by: Gustavo Pimentel --- v2: - Remove duplicate redundant code. - Reimplement the PF config space access way. v3: - Integrate duplicate code for func_select. - Move PCIE_ATU_FUNC_NUM(pf) (pf << 20) to ((pf) << 20). - Add the comments for func_conf_select function. v4: - Correct the commit message. v5: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 123 drivers/pci/controller/dwc/pcie-designware.c| 59 drivers/pci/controller/dwc/pcie-designware.h| 18 +++- 3 files changed, 142 insertions(+), 58 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index cfeccd7..58d8556 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -19,12 +19,26 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) pci_epc_linkup(epc); } -static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar, - int flags) +static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no) +{ + unsigned int func_offset = 0; + + if (ep->ops->func_conf_select) + func_offset = ep->ops->func_conf_select(ep, func_no); + + return func_offset; +} + +static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no, + enum pci_barno bar, int flags) { u32 reg; + unsigned int func_offset = 0; + struct dw_pcie_ep *ep = >ep; + + func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = PCI_BASE_ADDRESS_0 + (4 * bar); + reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar); dw_pcie_dbi_ro_wr_en(pci); dw_pcie_writel_dbi2(pci, reg, 0x0); dw_pcie_writel_dbi(pci, reg, 0x0); @@ -37,7 +51,12 @@ static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar, void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { - __dw_pcie_ep_reset_bar(pci, bar, 0); + u8 func_no, funcs; + + funcs = pci->ep.epc->max_functions; + + for (func_no = 0; func_no < funcs; func_no++) + __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, @@ -45,28 +64,31 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, { struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + + func_offset = dw_pcie_ep_func_select(ep, func_no); dw_pcie_dbi_ro_wr_en(pci); - dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, hdr->vendorid); - dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, hdr->deviceid); - dw_pcie_writeb_dbi(pci, PCI_REVISION_ID, hdr->revid); - dw_pcie_writeb_dbi(pci, PCI_CLASS_PROG, hdr->progif_code); - dw_pcie_writew_dbi(pci, PCI_CLASS_DEVICE, + dw_pcie_writew_dbi(pci, func_offset + PCI_VENDOR_ID, hdr->vendorid); + dw_pcie_writew_dbi(pci, func_offset + PCI_DEVICE_ID, hdr->deviceid); + dw_pcie_writeb_dbi(pci, func_offset + PCI_REVISION_ID, hdr->revid); + dw_pcie_writeb_dbi(pci, func_offset + PCI_CLASS_PROG, hdr->progif_code); + dw_pcie_writew_dbi(pci, func_offset + PCI_CLASS_DEVICE, hdr->subclass_code | hdr->baseclass_code << 8); - dw_pcie_writeb_dbi(pci, PCI_CACHE_LINE_SIZE, + dw_pcie_writeb_dbi(pci, func_offset + PCI_CACHE_LINE_SIZE, hdr->cache_line_size); - dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_VENDOR_ID, + dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_VENDOR_ID, hdr->subsys_vendor_id); - dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_ID, hdr->subsys_id); - dw_pcie_writeb_dbi(pci, PCI_INTERRUPT_PIN, + dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_ID, hdr->subsys_id); + dw_pcie_writeb_dbi(pci, func_offset + PCI_INTERRUPT_PIN, hdr->interrupt_pin); dw_pcie_dbi_ro_wr_dis(pci); return 0; } -static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar, - dma_addr_t cpu_addr, +static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no, + enum pci_barno bar, dma_addr_t cpu_addr, enum dw_pcie_as_type as_type) { int ret; @@ -79,7 +101,7 @@ static int dw_pcie_ep_inbound_atu(struct dw_pc
[PATCH v5 03/11] PCI: designware-ep: Move the function of getting MSI capability forward
Move the function of getting MSI capability to the front of init function, because the init function of the EP platform driver will use the return value by the function of getting MSI capability. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. v4: - No change. v5: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 44ece33..933bb89 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -632,6 +632,10 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) if (ret < 0) epc->max_functions = 1; + ep->msi_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); + + ep->msix_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSIX); + if (ep->ops->ep_init) ep->ops->ep_init(ep); @@ -648,9 +652,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) dev_err(dev, "Failed to reserve memory for MSI/MSI-X\n"); return -ENOMEM; } - ep->msi_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); - - ep->msix_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSIX); offset = dw_pcie_ep_find_ext_capability(pci, PCI_EXT_CAP_ID_REBAR); if (offset) { -- 2.9.5
[PATCH v5 11/11] misc: pci_endpoint_test: Add LS1088a in pci_device_id table
Add LS1088a in pci_device_id table so that pci-epf-test can be used for testing PCIe EP in LS1088a. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. v4: - Use a maco to define the LS1088a device ID. v5: - No change. drivers/misc/pci_endpoint_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index a5e3170..72d694f 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -65,6 +65,7 @@ #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 #define PCI_DEVICE_ID_TI_AM654 0xb00c +#define PCI_DEVICE_ID_LS1088A 0x80c0 #define is_am654_pci_dev(pdev) \ ((pdev)->device == PCI_DEVICE_ID_TI_AM654) @@ -793,6 +794,7 @@ static const struct pci_device_id pci_endpoint_test_tbl[] = { { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_LS1088A) }, { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), .driver_data = (kernel_ulong_t)_data -- 2.9.5
[PATCH v5 02/11] PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode
Add the doorbell mode of MSI-X in DWC EP driver. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - Remove the macro of no used. v3: - No change. v4: - Modify the commit message. v5: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 14 ++ drivers/pci/controller/dwc/pcie-designware.h| 12 2 files changed, 26 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 58d8556..44ece33 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -449,6 +449,20 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no, + u16 interrupt_num) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + u32 msg_data; + + msg_data = (func_no << PCIE_MSIX_DOORBELL_PF_SHIFT) | + (interrupt_num - 1); + + dw_pcie_writel_dbi(pci, PCIE_MSIX_DOORBELL, msg_data); + + return 0; +} + int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, u16 interrupt_num) { diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 00d2d31..cb32afa 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -97,6 +97,9 @@ #define PCIE_MISC_CONTROL_1_OFF0x8BC #define PCIE_DBI_RO_WR_EN BIT(0) +#define PCIE_MSIX_DOORBELL 0x948 +#define PCIE_MSIX_DOORBELL_PF_SHIFT24 + #define PCIE_PL_CHK_REG_CONTROL_STATUS 0xB20 #define PCIE_PL_CHK_REG_CHK_REG_START BIT(0) #define PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS BIT(1) @@ -431,6 +434,8 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, u8 interrupt_num); int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, u16 interrupt_num); +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no, + u16 interrupt_num); void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar); #else static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) @@ -463,6 +468,13 @@ static inline int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +static inline int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, +u8 func_no, +u16 interrupt_num) +{ + return 0; +} + static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { } -- 2.9.5
[PATCH v5 04/11] PCI: designware-ep: Modify MSI and MSIX CAP way of finding
Each PF of EP device should have it's own MSI or MSIX capabitily struct, so create a dw_pcie_ep_func struct and remove the msi_cap and msix_cap to this struct from dw_pcie_ep, and manage the PFs with a list. Signed-off-by: Xiaowei Bao --- v3: - This is a new patch, to fix the issue of MSI and MSIX CAP way of finding. v4: - Correct some word of commit message. v5: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 135 +--- drivers/pci/controller/dwc/pcie-designware.h| 18 +++- 2 files changed, 134 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 933bb89..fb915f2 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -19,6 +19,19 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) pci_epc_linkup(epc); } +struct dw_pcie_ep_func * +dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no) +{ + struct dw_pcie_ep_func *ep_func; + + list_for_each_entry(ep_func, >func_list, list) { + if (ep_func->func_no == func_no) + return ep_func; + } + + return NULL; +} + static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no) { unsigned int func_offset = 0; @@ -59,6 +72,47 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } +static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no, + u8 cap_ptr, u8 cap) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + u8 cap_id, next_cap_ptr; + u16 reg; + + if (!cap_ptr) + return 0; + + func_offset = dw_pcie_ep_func_select(ep, func_no); + + reg = dw_pcie_readw_dbi(pci, func_offset + cap_ptr); + cap_id = (reg & 0x00ff); + + if (cap_id > PCI_CAP_ID_MAX) + return 0; + + if (cap_id == cap) + return cap_ptr; + + next_cap_ptr = (reg & 0xff00) >> 8; + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); +} + +static u8 dw_pcie_ep_find_capability(struct dw_pcie_ep *ep, u8 func_no, u8 cap) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + u8 next_cap_ptr; + u16 reg; + + func_offset = dw_pcie_ep_func_select(ep, func_no); + + reg = dw_pcie_readw_dbi(pci, func_offset + PCI_CAPABILITY_LIST); + next_cap_ptr = (reg & 0x00ff); + + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); +} + static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, struct pci_epf_header *hdr) { @@ -246,13 +300,18 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; - if (!ep->msi_cap) + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; + + if (!ep_func->msi_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS; + reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS; val = dw_pcie_readw_dbi(pci, reg); if (!(val & PCI_MSI_FLAGS_ENABLE)) return -EINVAL; @@ -268,13 +327,18 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; + + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; - if (!ep->msi_cap) + if (!ep_func->msi_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS; + reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS; val = dw_pcie_readw_dbi(pci, reg); val &= ~PCI_MSI_FLAGS_QMASK; val |= (interrupts << 1) & PCI_MSI_FLAGS_QMASK; @@ -291,13 +355,18 @@ static int dw_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; + + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; - if (!ep->msix_cap) + if (!ep_func->msix_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msix_cap
[PATCH v5 06/11] PCI: layerscape: Fix some format issue of the code
Fix some format issue of the code in EP driver. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. v4: - No change. v5: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 0d151ce..0691d9a 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -63,7 +63,7 @@ static void ls_pcie_ep_init(struct dw_pcie_ep *ep) } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, - enum pci_epc_irq_type type, u16 interrupt_num) + enum pci_epc_irq_type type, u16 interrupt_num) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); @@ -87,7 +87,7 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = { }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, - struct platform_device *pdev) +struct platform_device *pdev) { struct dw_pcie *pci = pcie->pci; struct device *dev = pci->dev; -- 2.9.5
[PATCH v4 00/11] Add the multiple PF support for DWC and Layerscape
Add the PCIe EP multiple PF support for DWC and Layerscape, add the doorbell MSIX function for DWC, use list to manage the PF of one PCIe controller, and refactor the Layerscape EP driver due to some platforms difference. Xiaowei Bao (11): PCI: designware-ep: Add multiple PFs support for DWC PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode PCI: designware-ep: Move the function of getting MSI capability forward PCI: designware-ep: Modify MSI and MSIX CAP way of finding dt-bindings: pci: layerscape-pci: Add compatible strings for ls1088a and ls2088a PCI: layerscape: Fix some format issue of the code PCI: layerscape: Modify the way of getting capability with different PEX PCI: layerscape: Modify the MSIX to the doorbell mode PCI: layerscape: Add EP mode support for ls1088a and ls2088a arm64: dts: layerscape: Add PCIe EP node for ls1088a misc: pci_endpoint_test: Add LS1088a in pci_device_id table .../devicetree/bindings/pci/layerscape-pci.txt | 2 + arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 +++ drivers/misc/pci_endpoint_test.c | 2 + drivers/pci/controller/dwc/pci-layerscape-ep.c | 100 ++-- drivers/pci/controller/dwc/pcie-designware-ep.c| 255 + drivers/pci/controller/dwc/pcie-designware.c | 59 +++-- drivers/pci/controller/dwc/pcie-designware.h | 48 +++- 7 files changed, 404 insertions(+), 93 deletions(-) -- 2.9.5
[PATCH v5 05/11] dt-bindings: pci: layerscape-pci: Add compatible strings for ls1088a and ls2088a
Add compatible strings for ls1088a and ls2088a. Signed-off-by: Xiaowei Bao Acked-by: Rob Herring --- v2: - No change. v3: - Use one valid combination of compatible strings. v4: - Add the comma between the two compatible. v5: - No change. Documentation/devicetree/bindings/pci/layerscape-pci.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt b/Documentation/devicetree/bindings/pci/layerscape-pci.txt index 99a386e..daa99f7 100644 --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt @@ -24,6 +24,8 @@ Required properties: "fsl,ls1028a-pcie" EP mode: "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" + "fsl,ls1088a-pcie-ep", "fsl,ls-pcie-ep" + "fsl,ls2088a-pcie-ep", "fsl,ls-pcie-ep" - reg: base addresses and lengths of the PCIe controller register blocks. - interrupts: A list of interrupt outputs of the controller. Must contain an entry for each entry in the interrupt-names property. -- 2.9.5
[PATCH v5 10/11] arm64: dts: layerscape: Add PCIe EP node for ls1088a
Add PCIe EP node for ls1088a to support EP mode. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - Remove the pf-offset proparty. v3: - No change. v4: - No change. v5: - No change. arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 ++ 1 file changed, 31 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi index ec6013a..cb0805b 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi @@ -497,6 +497,17 @@ status = "disabled"; }; + pcie_ep@340 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0340 0x0 0x0010 + 0x20 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <24>; + num-ob-windows = <128>; + max-functions = /bits/ 8 <2>; + status = "disabled"; + }; + pcie@350 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0350 0x0 0x0010 /* controller registers */ @@ -522,6 +533,16 @@ status = "disabled"; }; + pcie_ep@350 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0350 0x0 0x0010 + 0x28 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + pcie@360 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0360 0x0 0x0010 /* controller registers */ @@ -547,6 +568,16 @@ status = "disabled"; }; + pcie_ep@360 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0360 0x0 0x0010 + 0x30 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + smmu: iommu@500 { compatible = "arm,mmu-500"; reg = <0 0x500 0 0x80>; -- 2.9.5
[PATCH v5 07/11] PCI: layerscape: Modify the way of getting capability with different PEX
The different PCIe controller in one board may be have different capability of MSI or MSIX, so change the way of getting the MSI capability, make it more flexible. Signed-off-by: Xiaowei Bao --- v2: - Remove the repeated assignment code. v3: - Use ep_func msi_cap and msix_cap to decide the msi_capable and msix_capable of pci_epc_features struct. v4: - No change. v5: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 31 +++--- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 0691d9a..9601f9c 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -22,6 +22,7 @@ struct ls_pcie_ep { struct dw_pcie *pci; + struct pci_epc_features *ls_epc; }; #define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) @@ -40,26 +41,31 @@ static const struct of_device_id ls_pcie_ep_of_match[] = { { }, }; -static const struct pci_epc_features ls_pcie_epc_features = { - .linkup_notifier = false, - .msi_capable = true, - .msix_capable = false, - .bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { - return _pcie_epc_features; + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + return pcie->ls_epc; } static void ls_pcie_ep_init(struct dw_pcie_ep *ep) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + struct dw_pcie_ep_func *ep_func; enum pci_barno bar; + ep_func = dw_pcie_ep_get_func_from_ep(ep, 0); + if (!ep_func) + return; + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) dw_pcie_ep_reset_bar(pci, bar); + + pcie->ls_epc->msi_capable = ep_func->msi_cap ? true : false; + pcie->ls_epc->msix_capable = ep_func->msix_cap ? true : false; } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, @@ -119,6 +125,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) struct device *dev = >dev; struct dw_pcie *pci; struct ls_pcie_ep *pcie; + struct pci_epc_features *ls_epc; struct resource *dbi_base; int ret; @@ -130,6 +137,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!pci) return -ENOMEM; + ls_epc = devm_kzalloc(dev, sizeof(*ls_epc), GFP_KERNEL); + if (!ls_epc) + return -ENOMEM; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); if (IS_ERR(pci->dbi_base)) @@ -140,6 +151,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) pci->ops = _pcie_ep_ops; pcie->pci = pci; + ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + + pcie->ls_epc = ls_epc; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v5 09/11] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
Add PCIe EP mode support for ls1088a and ls2088a, there are some difference between LS1 and LS2 platform, so refactor the code of the EP driver. Signed-off-by: Xiaowei Bao --- v2: - This is a new patch for supporting the ls1088a and ls2088a platform. v3: - Adjust the some struct assignment order in probe function. v4: - No change. v5: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 72 +++--- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index bfab1c6..84206f2 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -20,27 +20,29 @@ #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ -struct ls_pcie_ep { - struct dw_pcie *pci; - struct pci_epc_features *ls_epc; +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) + +struct ls_pcie_ep_drvdata { + u32 func_offset; + const struct dw_pcie_ep_ops *ops; + const struct dw_pcie_ops*dw_pcie_ops; }; -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) +struct ls_pcie_ep { + struct dw_pcie *pci; + struct pci_epc_features *ls_epc; + const struct ls_pcie_ep_drvdata *drvdata; +}; static int ls_pcie_establish_link(struct dw_pcie *pci) { return 0; } -static const struct dw_pcie_ops ls_pcie_ep_ops = { +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { .start_link = ls_pcie_establish_link, }; -static const struct of_device_id ls_pcie_ep_of_match[] = { - { .compatible = "fsl,ls-pcie-ep",}, - { }, -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { @@ -87,10 +89,39 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, } } -static const struct dw_pcie_ep_ops pcie_ep_ops = { +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep, + u8 func_no) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + WARN_ON(func_no && !pcie->drvdata->func_offset); + return pcie->drvdata->func_offset * func_no; +} + +static const struct dw_pcie_ep_ops ls_pcie_ep_ops = { .ep_init = ls_pcie_ep_init, .raise_irq = ls_pcie_ep_raise_irq, .get_features = ls_pcie_ep_get_features, + .func_conf_select = ls_pcie_ep_func_conf_select, +}; + +static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = { + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct ls_pcie_ep_drvdata ls2_ep_drvdata = { + .func_offset = 0x2, + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct of_device_id ls_pcie_ep_of_match[] = { + { .compatible = "fsl,ls1046a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls1088a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls2088a-pcie-ep", .data = _ep_drvdata }, + { }, }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, @@ -103,7 +134,7 @@ static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, int ret; ep = >ep; - ep->ops = _ep_ops; + ep->ops = pcie->drvdata->ops; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); if (!res) @@ -142,20 +173,23 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!ls_epc) return -ENOMEM; - dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); - if (IS_ERR(pci->dbi_base)) - return PTR_ERR(pci->dbi_base); + pcie->drvdata = of_device_get_match_data(dev); - pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; pci->dev = dev; - pci->ops = _pcie_ep_ops; - pcie->pci = pci; + pci->ops = pcie->drvdata->dw_pcie_ops; ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + pcie->pci = pci; pcie->ls_epc = ls_epc; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); + pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); + if (IS_ERR(pci->dbi_base)) + return PTR_ERR(pci->dbi_base); + + pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v5 08/11] PCI: layerscape: Modify the MSIX to the doorbell mode
dw_pcie_ep_raise_msix_irq was never called in the exisitng driver before, because the ls1046a platform don't support the MSIX feature and msix_capable was always set to false. Now that add the ls1088a platform with MSIX support, use the doorbell method to support the MSIX feature. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change v3: - Modify the commit message make it clearly. v4: - No change v5: - Modify the commit message. drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 9601f9c..bfab1c6 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -79,7 +79,8 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, case PCI_EPC_IRQ_MSI: return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); case PCI_EPC_IRQ_MSIX: - return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num); + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, + interrupt_num); default: dev_err(pci->dev, "UNKNOWN IRQ type\n"); return -EINVAL; -- 2.9.5
RE: [PATCH v4 00/11] Add the multiple PF support for DWC and Layerscape
> -Original Message- > From: Lorenzo Pieralisi > Sent: 2020年2月28日 19:30 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; M.h. Lian > ; Mingkai Hu ; Roy Zang > ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; Andrew Murray > > Subject: Re: [PATCH v4 00/11] Add the multiple PF support for DWC and > Layerscape > > On Tue, Sep 24, 2019 at 10:18:38AM +0800, Xiaowei Bao wrote: > > Add the PCIe EP multiple PF support for DWC and Layerscape, add the > > doorbell MSIX function for DWC, use list to manage the PF of one PCIe > > controller, and refactor the Layerscape EP driver due to some > > platforms difference. > > > > Xiaowei Bao (11): > > PCI: designware-ep: Add multiple PFs support for DWC > > PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode > > PCI: designware-ep: Move the function of getting MSI capability > > forward > > PCI: designware-ep: Modify MSI and MSIX CAP way of finding > > dt-bindings: pci: layerscape-pci: add compatible strings for ls1088a > > and ls2088a > > PCI: layerscape: Fix some format issue of the code > > PCI: layerscape: Modify the way of getting capability with different > > PEX > > PCI: layerscape: Modify the MSIX to the doorbell mode > > PCI: layerscape: Add EP mode support for ls1088a and ls2088a > > arm64: dts: layerscape: Add PCIe EP node for ls1088a > > misc: pci_endpoint_test: Add LS1088a in pci_device_id table > > > > .../devicetree/bindings/pci/layerscape-pci.txt | 2 + > > arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 +++ > > drivers/misc/pci_endpoint_test.c | 2 + > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 100 ++-- > > drivers/pci/controller/dwc/pcie-designware-ep.c| 255 > + > > drivers/pci/controller/dwc/pcie-designware.c | 59 +++-- > > drivers/pci/controller/dwc/pcie-designware.h | 48 +++- > > 7 files changed, 404 insertions(+), 93 deletions(-) > > Hi, > > are you resending this patchset ? I would also like Andrew and Kishon to have > a look and ACK relevant code before merging it. Thank you for following these patches, I have replay the email to Kishon, and I will decide whether to resend the sets patches based on his comments. Thanks Xiaowei > Thanks, > Lorenzo
RE: [PATCH v4 08/11] PCI: layerscape: Modify the MSIX to the doorbell mode
> -Original Message- > From: Kishon Vijay Abraham I > Sent: 2020年2月28日 19:41 > To: Xiaowei Bao ; robh...@kernel.org; > mark.rutl...@arm.com; shawn...@kernel.org; Leo Li > ; lorenzo.pieral...@arm.com; M.h. Lian > ; Mingkai Hu ; Roy Zang > ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; andrew.mur...@arm.com; > linux-...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v4 08/11] PCI: layerscape: Modify the MSIX to the > doorbell mode > > Hi Xiaowei, > > On 24/09/19 7:48 am, Xiaowei Bao wrote: > > dw_pcie_ep_raise_msix_irq was never called in the exisitng driver > > before, because the ls1046a platform don't support the MSIX feature > > and msix_capable was always set to false. > > Now that add the ls1088a platform with MSIX support, but the existing > > dw_pcie_ep_raise_msix_irq doesn't work, so use the doorbell method to > > support the MSIX feature. > > > It does work after [1]. So the commit message might not be exactly true. Got it, I will verify it with your patch, do you mean that I should correct the commit message? I think we can reserve my MSI-X patch, this patch can provide another MSI-X trigger way, and this way is clearly stated in the DWC manual, thanks, please give your comments. Thanks Xiaowei > > [1] -> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.ke > rnel.org%2Fr%2F20200225081703.8857-1-kishon%40ti.comdata=02% > 7C01%7Cxiaowei.bao%40nxp.com%7C84191df0cd09451ef3e608d7bc427745 > %7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637184865969684 > 169sdata=K9fvbpQ4xuuZKhWT6UV2M4SVyHxQ3LjpuJQztktLaRI%3D& > amp;reserved=0 > > Thanks > Kishon > > > > > Signed-off-by: Xiaowei Bao > > Reviewed-by: Andrew Murray > > --- > > v2: > > - No change > > v3: > > - Modify the commit message make it clearly. > > v4: > > - No change > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > index 1e07287..5f0cb99 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > @@ -79,7 +79,8 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, > u8 func_no, > > case PCI_EPC_IRQ_MSI: > > return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); > > case PCI_EPC_IRQ_MSIX: > > - return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num); > > + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, > > + interrupt_num); > > default: > > dev_err(pci->dev, "UNKNOWN IRQ type\n"); > > return -EINVAL; > >
RE: [PATCH v6 1/3] dt-bindings: pci: layerscape-pci: add compatible strings "fsl,ls1028a-pcie"
> -Original Message- > From: Lorenzo Pieralisi > Sent: 2019年11月7日 0:10 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; M.h. Lian ; Mingkai Hu > ; Roy Zang ; > linux-...@vger.kernel.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > linuxppc-dev@lists.ozlabs.org; bhelg...@google.com; Z.q. Hou > > Subject: Re: [PATCH v6 1/3] dt-bindings: pci: layerscape-pci: add compatible > strings "fsl,ls1028a-pcie" > > On Mon, Sep 02, 2019 at 11:43:17AM +0800, Xiaowei Bao wrote: > > Add the PCIe compatible string for LS1028A > > Sentences must be terminated with a period. > > > Signed-off-by: Xiaowei Bao > > Signed-off-by: Hou Zhiqiang > > Reviewed-by: Rob Herring > > --- > > v2: > > - No change. > > v3: > > - No change. > > v4: > > - No change. > > v5: > > - No change. > > v6: > > - No change. > > > > Documentation/devicetree/bindings/pci/layerscape-pci.txt | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt > b/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > index e20ceaa..99a386e 100644 > > --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > @@ -21,6 +21,7 @@ Required properties: > > "fsl,ls1046a-pcie" > > "fsl,ls1043a-pcie" > > "fsl,ls1012a-pcie" > > +"fsl,ls1028a-pcie" > >EP mode: > > "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" > > - reg: base addresses and lengths of the PCIe controller register blocks. > > I have applied this series to pci/layerscape, thanks. Thank you for your corrections and comments, I will pay attention to the details and quality of each patch in the future. > > Lorenzo
RE: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the doorbell way
> -Original Message- > From: Gustavo Pimentel > Sent: 2019年11月6日 17:40 > To: Kishon Vijay Abraham I ; Andrew Murray > ; Xiaowei Bao ; > gustavo.pimen...@synopsys.com > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > linux-...@vger.kernel.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > linuxppc-dev@lists.ozlabs.org > Subject: RE: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the > doorbell way > > On Thu, Aug 29, 2019 at 6:13:18, Kishon Vijay Abraham I > wrote: > > Hi, this email slip away from my attention... > > > Gustavo, > > > > On 27/08/19 6:55 PM, Andrew Murray wrote: > > > On Sat, Aug 24, 2019 at 12:08:40AM +, Xiaowei Bao wrote: > > >> > > >> > > >>> -Original Message- > > >>> From: Andrew Murray > > >>> Sent: 2019年8月23日 21:58 > > >>> To: Xiaowei Bao > > >>> Cc: bhelg...@google.com; robh...@kernel.org; > mark.rutl...@arm.com; > > >>> shawn...@kernel.org; Leo Li ; kis...@ti.com; > > >>> lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; > M.h. > > >>> Lian ; Mingkai Hu ; > Roy > > >>> Zang ; jingooh...@gmail.com; > > >>> gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > >>> devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > >>> linux-arm-ker...@lists.infradead.org; > > >>> linuxppc-dev@lists.ozlabs.org > > >>> Subject: Re: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to > > >>> the doorbell way > > >>> > > >>> On Thu, Aug 22, 2019 at 07:22:39PM +0800, Xiaowei Bao wrote: > > >>>> The layerscape platform use the doorbell way to trigger MSIX > > >>>> interrupt in EP mode. > > >>>> > > >>> > > >>> I have no problems with this patch, however... > > >>> > > >>> Are you able to add to this message a reason for why you are > > >>> making this change? Did dw_pcie_ep_raise_msix_irq not work when > > >>> func_no != 0? Or did it work yet dw_pcie_ep_raise_msix_irq_doorbell is > more efficient? > > >> > > >> The fact is that, this driver is verified in ls1046a platform of > > >> NXP before, and ls1046a don't support MSIX feature, so I set the > > >> msix_capable of pci_epc_features struct is false, but in other > > >> platform, e.g. ls1088a, it support the MSIX feature, I verified the MSIX > feature in ls1088a, it is not OK, so I changed to another way. Thanks. > > > > > > Right, so the existing pci-layerscape-ep.c driver never supported > > > MSIX yet it erroneously had a switch case statement to call > > > dw_pcie_ep_raise_msix_irq which would never get used. > > > > > > Now that we're adding a platform with MSIX support the existing > > > dw_pcie_ep_raise_msix_irq doesn't work (for this platform) so we are > > > adding a different method. > > > > Gustavo, can you confirm dw_pcie_ep_raise_msix_irq() works for > > designware as it didn't work for both me and Xiaowei? > > When I implemented the dw_pcie_ep_raise_msix_irq(), the implementation > was working quite fine on DesignWare solution. Otherwise, I wouldn't submit > it to the kernel. > From what I have seen and if I recall well, Xiaowei implementation was done > having PF's configurated on his solution, which is a configuration that I > don't > have in my solution, I believe this could be the missing piece that differs > between our 2 implementations. > > Since patch submission into the kernel related to msix feature on pcitest > tool, I > didn't touch or re-tested the msix feature by lack of time (other projects > requires my full attention for now). However is on my roadmap to came back > to add some other features on DesignWare eDMA driver and I can do at that > time some tests to see if the > dw_pcie_ep_raise_msix_irq_doorbell() is compatible or not with my solution. > If so, I can do some patch to simplify and use the > dw_pcie_ep_raise_msix_irq_doorbell() if it still works as expected like on > dw_pcie_ep_raise_msix_irq(). Agree? > Thanks Gustavo, it looks well for me. Thanks Xiaowei > Gustavo > > > > > Thanks > > Kishon >
RE: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the doorbell way
> -Original Message- > From: Lorenzo Pieralisi > Sent: 2019年11月5日 20:38 > To: Kishon Vijay Abraham I > Cc: Andrew Murray ; Xiaowei Bao > ; gustavo.pimen...@synopsys.com; > bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > linux-...@vger.kernel.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the > doorbell way > > On Thu, Aug 29, 2019 at 10:43:18AM +0530, Kishon Vijay Abraham I wrote: > > Gustavo, > > > > On 27/08/19 6:55 PM, Andrew Murray wrote: > > > On Sat, Aug 24, 2019 at 12:08:40AM +, Xiaowei Bao wrote: > > >> > > >> > > >>> -Original Message- > > >>> From: Andrew Murray > > >>> Sent: 2019年8月23日 21:58 > > >>> To: Xiaowei Bao > > >>> Cc: bhelg...@google.com; robh...@kernel.org; > mark.rutl...@arm.com; > > >>> shawn...@kernel.org; Leo Li ; kis...@ti.com; > > >>> lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; > M.h. > > >>> Lian ; Mingkai Hu ; > Roy > > >>> Zang ; jingooh...@gmail.com; > > >>> gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > >>> devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > >>> linux-arm-ker...@lists.infradead.org; > > >>> linuxppc-dev@lists.ozlabs.org > > >>> Subject: Re: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to > > >>> the doorbell way > > >>> > > >>> On Thu, Aug 22, 2019 at 07:22:39PM +0800, Xiaowei Bao wrote: > > >>>> The layerscape platform use the doorbell way to trigger MSIX > > >>>> interrupt in EP mode. > > >>>> > > >>> > > >>> I have no problems with this patch, however... > > >>> > > >>> Are you able to add to this message a reason for why you are > > >>> making this change? Did dw_pcie_ep_raise_msix_irq not work when > > >>> func_no != 0? Or did it work yet dw_pcie_ep_raise_msix_irq_doorbell is > more efficient? > > >> > > >> The fact is that, this driver is verified in ls1046a platform of > > >> NXP before, and ls1046a don't support MSIX feature, so I set the > > >> msix_capable of pci_epc_features struct is false, but in other > > >> platform, e.g. ls1088a, it support the MSIX feature, I verified the MSIX > feature in ls1088a, it is not OK, so I changed to another way. Thanks. > > > > > > Right, so the existing pci-layerscape-ep.c driver never supported > > > MSIX yet it erroneously had a switch case statement to call > > > dw_pcie_ep_raise_msix_irq which would never get used. > > > > > > Now that we're adding a platform with MSIX support the existing > > > dw_pcie_ep_raise_msix_irq doesn't work (for this platform) so we are > > > adding a different method. > > > > Gustavo, can you confirm dw_pcie_ep_raise_msix_irq() works for > > designware as it didn't work for both me and Xiaowei? > > This question needs an answer. This question have answered by Gustavo in "[PATCH v3 08/11] PCI: layerscape: Modify the MSIX to the doorbell mode", please refer to the comments, due to add a new patch for this sets of patch, this patch number changed from 07/10 of v2 to 08/11 of v3, sorry for causing your confuse. Thanks Xiaowei > > Thanks, > Lorenzo
RE: [PATCH v6 3/3] PCI: layerscape: Add LS1028a support
> -Original Message- > From: Lorenzo Pieralisi > Sent: 2019年11月5日 20:33 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; M.h. Lian ; Mingkai Hu > ; Roy Zang ; > linux-...@vger.kernel.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > linuxppc-dev@lists.ozlabs.org; bhelg...@google.com; Z.q. Hou > > Subject: Re: [PATCH v6 3/3] PCI: layerscape: Add LS1028a support > > On Mon, Sep 02, 2019 at 11:43:19AM +0800, Xiaowei Bao wrote: > > Add support for the LS1028a PCIe controller. > > > > Signed-off-by: Xiaowei Bao > > Signed-off-by: Hou Zhiqiang > > --- > > v2: > > - No change. > > v3: > > - Reuse the ls2088 driver data structurt. > > v4: > > - No change. > > v5: > > - No change. > > v6: > > - No change. > > > > drivers/pci/controller/dwc/pci-layerscape.c | 1 + > > 1 file changed, 1 insertion(+) > > I have not seen any comment on any layerscape driver patches coming from > the maintainers as listed in the MAINTAINERS file (and CCed in this series). > > I request maintainers ACK on these patches and I expect them to start > reviewing your code if they want to be still considered maintainers for this > driver. > > The changes look OK minus Shawn's remark on compatible string that was > ignored. Hi Lorenzo, Thanks for your comments. In fact, the patches have reviewed in our internal mail list, after the review by Minghuan and Mingkai, I will send these patches to opensource, they will give the ACK when these patches seems is OK and no comments on this. Thanks Xiaowei > > Thanks, > Lorenzo > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape.c > > b/drivers/pci/controller/dwc/pci-layerscape.c > > index 3a5fa26..f24f79a 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape.c > > @@ -263,6 +263,7 @@ static const struct ls_pcie_drvdata ls2088_drvdata > > = { static const struct of_device_id ls_pcie_of_match[] = { > > { .compatible = "fsl,ls1012a-pcie", .data = _drvdata }, > > { .compatible = "fsl,ls1021a-pcie", .data = _drvdata }, > > + { .compatible = "fsl,ls1028a-pcie", .data = _drvdata }, > > { .compatible = "fsl,ls1043a-pcie", .data = _drvdata }, > > { .compatible = "fsl,ls1046a-pcie", .data = _drvdata }, > > { .compatible = "fsl,ls2080a-pcie", .data = _drvdata }, > > -- > > 2.9.5 > >
RE: [PATCH v6 3/3] PCI: layerscape: Add LS1028a support
> -Original Message- > From: Shawn Guo > Sent: 2019年10月3日 17:11 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; Leo Li > ; M.h. Lian ; Mingkai Hu > ; Roy Zang ; > lorenzo.pieral...@arm.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > bhelg...@google.com; Z.q. Hou > Subject: Re: [PATCH v6 3/3] PCI: layerscape: Add LS1028a support > > On Mon, Sep 02, 2019 at 11:43:19AM +0800, Xiaowei Bao wrote: > > Add support for the LS1028a PCIe controller. > > > > Signed-off-by: Xiaowei Bao > > Signed-off-by: Hou Zhiqiang > > --- > > v2: > > - No change. > > v3: > > - Reuse the ls2088 driver data structurt. > > v4: > > - No change. > > v5: > > - No change. > > v6: > > - No change. > > > > drivers/pci/controller/dwc/pci-layerscape.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape.c > > b/drivers/pci/controller/dwc/pci-layerscape.c > > index 3a5fa26..f24f79a 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape.c > > @@ -263,6 +263,7 @@ static const struct ls_pcie_drvdata ls2088_drvdata > > = { static const struct of_device_id ls_pcie_of_match[] = { > > { .compatible = "fsl,ls1012a-pcie", .data = _drvdata }, > > { .compatible = "fsl,ls1021a-pcie", .data = _drvdata }, > > + { .compatible = "fsl,ls1028a-pcie", .data = _drvdata }, > > I think you can save this driver change by using "fsl,ls2088a-pcie" as > compatible fallback like below. > > compatible = "fsl,ls1028a-pcie", "fsl,ls2088a-pcie"; Yes, it is ok to do so, but according to the previous code, I think add a new compatible " fsl,ls1028a-pcie " to driver is better. Thanks Xiaowei > > Shawn > > > { .compatible = "fsl,ls1043a-pcie", .data = _drvdata }, > > { .compatible = "fsl,ls1046a-pcie", .data = _drvdata }, > > { .compatible = "fsl,ls2080a-pcie", .data = _drvdata }, > > -- > > 2.9.5 > >
RE: [PATCH v4 11/11] misc: pci_endpoint_test: Add LS1088a in pci_device_id table
> -Original Message- > From: Andrew Murray > Sent: 2019年9月30日 22:57 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v4 11/11] misc: pci_endpoint_test: Add LS1088a in > pci_device_id table > > On Tue, Sep 24, 2019 at 10:18:49AM +0800, Xiaowei Bao wrote: > > Add LS1088a in pci_device_id table so that pci-epf-test can be used > > for testing PCIe EP in LS1088a. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - No change. > > v3: > > - No change. > > v4: > > - Use a maco to define the LS1088a device ID. > > > > drivers/misc/pci_endpoint_test.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/misc/pci_endpoint_test.c > > b/drivers/misc/pci_endpoint_test.c > > index 6e208a0..8c222a6 100644 > > --- a/drivers/misc/pci_endpoint_test.c > > +++ b/drivers/misc/pci_endpoint_test.c > > @@ -65,6 +65,7 @@ > > #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 > > > > #define PCI_DEVICE_ID_TI_AM654 0xb00c > > +#define PCI_DEVICE_ID_LS1088A 0x80c0 > > Reviewed-by: Andrew Murray Thanks Andrew. > > > > > #define is_am654_pci_dev(pdev) \ > > ((pdev)->device == PCI_DEVICE_ID_TI_AM654) @@ -793,6 +794,7 > @@ > > static const struct pci_device_id pci_endpoint_test_tbl[] = { > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, > > { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, > > + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_LS1088A) }, > > { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), > > .driver_data = (kernel_ulong_t)_data > > -- > > 2.9.5 > >
[PATCH v4 11/11] misc: pci_endpoint_test: Add LS1088a in pci_device_id table
Add LS1088a in pci_device_id table so that pci-epf-test can be used for testing PCIe EP in LS1088a. Signed-off-by: Xiaowei Bao --- v2: - No change. v3: - No change. v4: - Use a maco to define the LS1088a device ID. drivers/misc/pci_endpoint_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 6e208a0..8c222a6 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -65,6 +65,7 @@ #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 #define PCI_DEVICE_ID_TI_AM654 0xb00c +#define PCI_DEVICE_ID_LS1088A 0x80c0 #define is_am654_pci_dev(pdev) \ ((pdev)->device == PCI_DEVICE_ID_TI_AM654) @@ -793,6 +794,7 @@ static const struct pci_device_id pci_endpoint_test_tbl[] = { { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_LS1088A) }, { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), .driver_data = (kernel_ulong_t)_data -- 2.9.5
[PATCH v4 09/11] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
Add PCIe EP mode support for ls1088a and ls2088a, there are some difference between LS1 and LS2 platform, so refactor the code of the EP driver. Signed-off-by: Xiaowei Bao --- v2: - This is a new patch for supporting the ls1088a and ls2088a platform. v3: - Adjust the some struct assignment order in probe function. v4: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 72 +++--- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 5f0cb99..723bbe5 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -20,27 +20,29 @@ #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ -struct ls_pcie_ep { - struct dw_pcie *pci; - struct pci_epc_features *ls_epc; +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) + +struct ls_pcie_ep_drvdata { + u32 func_offset; + const struct dw_pcie_ep_ops *ops; + const struct dw_pcie_ops*dw_pcie_ops; }; -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) +struct ls_pcie_ep { + struct dw_pcie *pci; + struct pci_epc_features *ls_epc; + const struct ls_pcie_ep_drvdata *drvdata; +}; static int ls_pcie_establish_link(struct dw_pcie *pci) { return 0; } -static const struct dw_pcie_ops ls_pcie_ep_ops = { +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { .start_link = ls_pcie_establish_link, }; -static const struct of_device_id ls_pcie_ep_of_match[] = { - { .compatible = "fsl,ls-pcie-ep",}, - { }, -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { @@ -87,10 +89,39 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, } } -static const struct dw_pcie_ep_ops pcie_ep_ops = { +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep, + u8 func_no) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + WARN_ON(func_no && !pcie->drvdata->func_offset); + return pcie->drvdata->func_offset * func_no; +} + +static const struct dw_pcie_ep_ops ls_pcie_ep_ops = { .ep_init = ls_pcie_ep_init, .raise_irq = ls_pcie_ep_raise_irq, .get_features = ls_pcie_ep_get_features, + .func_conf_select = ls_pcie_ep_func_conf_select, +}; + +static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = { + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct ls_pcie_ep_drvdata ls2_ep_drvdata = { + .func_offset = 0x2, + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct of_device_id ls_pcie_ep_of_match[] = { + { .compatible = "fsl,ls1046a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls1088a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls2088a-pcie-ep", .data = _ep_drvdata }, + { }, }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, @@ -103,7 +134,7 @@ static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, int ret; ep = >ep; - ep->ops = _ep_ops; + ep->ops = pcie->drvdata->ops; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); if (!res) @@ -142,20 +173,23 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!ls_epc) return -ENOMEM; - dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); - if (IS_ERR(pci->dbi_base)) - return PTR_ERR(pci->dbi_base); + pcie->drvdata = of_device_get_match_data(dev); - pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; pci->dev = dev; - pci->ops = _pcie_ep_ops; - pcie->pci = pci; + pci->ops = pcie->drvdata->dw_pcie_ops; ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + pcie->pci = pci; pcie->ls_epc = ls_epc; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); + pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); + if (IS_ERR(pci->dbi_base)) + return PTR_ERR(pci->dbi_base); + + pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v4 10/11] arm64: dts: layerscape: Add PCIe EP node for ls1088a
Add PCIe EP node for ls1088a to support EP mode. Signed-off-by: Xiaowei Bao --- v2: - Remove the pf-offset proparty. v3: - No change. v4: - No change. arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 ++ 1 file changed, 31 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi index c676d07..da246ab 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi @@ -483,6 +483,17 @@ status = "disabled"; }; + pcie_ep@340 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0340 0x0 0x0010 + 0x20 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <24>; + num-ob-windows = <128>; + max-functions = /bits/ 8 <2>; + status = "disabled"; + }; + pcie@350 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0350 0x0 0x0010 /* controller registers */ @@ -508,6 +519,16 @@ status = "disabled"; }; + pcie_ep@350 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0350 0x0 0x0010 + 0x28 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + pcie@360 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0360 0x0 0x0010 /* controller registers */ @@ -533,6 +554,16 @@ status = "disabled"; }; + pcie_ep@360 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0360 0x0 0x0010 + 0x30 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + smmu: iommu@500 { compatible = "arm,mmu-500"; reg = <0 0x500 0 0x80>; -- 2.9.5
[PATCH v4 07/11] PCI: layerscape: Modify the way of getting capability with different PEX
The different PCIe controller in one board may be have different capability of MSI or MSIX, so change the way of getting the MSI capability, make it more flexible. Signed-off-by: Xiaowei Bao --- v2: - Remove the repeated assignment code. v3: - Use ep_func msi_cap and msix_cap to decide the msi_capable and msix_capable of pci_epc_features struct. v4: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 31 +++--- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index a9c552e..1e07287 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -22,6 +22,7 @@ struct ls_pcie_ep { struct dw_pcie *pci; + struct pci_epc_features *ls_epc; }; #define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) @@ -40,26 +41,31 @@ static const struct of_device_id ls_pcie_ep_of_match[] = { { }, }; -static const struct pci_epc_features ls_pcie_epc_features = { - .linkup_notifier = false, - .msi_capable = true, - .msix_capable = false, - .bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { - return _pcie_epc_features; + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + return pcie->ls_epc; } static void ls_pcie_ep_init(struct dw_pcie_ep *ep) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + struct dw_pcie_ep_func *ep_func; enum pci_barno bar; + ep_func = dw_pcie_ep_get_func_from_ep(ep, 0); + if (!ep_func) + return; + for (bar = BAR_0; bar <= BAR_5; bar++) dw_pcie_ep_reset_bar(pci, bar); + + pcie->ls_epc->msi_capable = ep_func->msi_cap ? true : false; + pcie->ls_epc->msix_capable = ep_func->msix_cap ? true : false; } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, @@ -119,6 +125,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) struct device *dev = >dev; struct dw_pcie *pci; struct ls_pcie_ep *pcie; + struct pci_epc_features *ls_epc; struct resource *dbi_base; int ret; @@ -130,6 +137,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!pci) return -ENOMEM; + ls_epc = devm_kzalloc(dev, sizeof(*ls_epc), GFP_KERNEL); + if (!ls_epc) + return -ENOMEM; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); if (IS_ERR(pci->dbi_base)) @@ -140,6 +151,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) pci->ops = _pcie_ep_ops; pcie->pci = pci; + ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + + pcie->ls_epc = ls_epc; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v4 08/11] PCI: layerscape: Modify the MSIX to the doorbell mode
dw_pcie_ep_raise_msix_irq was never called in the exisitng driver before, because the ls1046a platform don't support the MSIX feature and msix_capable was always set to false. Now that add the ls1088a platform with MSIX support, but the existing dw_pcie_ep_raise_msix_irq doesn't work, so use the doorbell method to support the MSIX feature. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change v3: - Modify the commit message make it clearly. v4: - No change drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 1e07287..5f0cb99 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -79,7 +79,8 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, case PCI_EPC_IRQ_MSI: return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); case PCI_EPC_IRQ_MSIX: - return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num); + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, + interrupt_num); default: dev_err(pci->dev, "UNKNOWN IRQ type\n"); return -EINVAL; -- 2.9.5
[PATCH v4 06/11] PCI: layerscape: Fix some format issue of the code
Fix some format issue of the code in EP driver. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. v4: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index ca9aa45..a9c552e 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -63,7 +63,7 @@ static void ls_pcie_ep_init(struct dw_pcie_ep *ep) } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, - enum pci_epc_irq_type type, u16 interrupt_num) + enum pci_epc_irq_type type, u16 interrupt_num) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); @@ -87,7 +87,7 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = { }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, - struct platform_device *pdev) +struct platform_device *pdev) { struct dw_pcie *pci = pcie->pci; struct device *dev = pci->dev; -- 2.9.5
[PATCH v4 05/11] dt-bindings: pci: layerscape-pci: Add compatible strings for ls1088a and ls2088a
Add compatible strings for ls1088a and ls2088a. Signed-off-by: Xiaowei Bao --- v2: - No change. v3: - Use one valid combination of compatible strings. v4: - Add the comma between the two compatible. Documentation/devicetree/bindings/pci/layerscape-pci.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt b/Documentation/devicetree/bindings/pci/layerscape-pci.txt index e20ceaa..3717e3d 100644 --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt @@ -23,6 +23,8 @@ Required properties: "fsl,ls1012a-pcie" EP mode: "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" + "fsl,ls1088a-pcie-ep", "fsl,ls-pcie-ep" + "fsl,ls2088a-pcie-ep", "fsl,ls-pcie-ep" - reg: base addresses and lengths of the PCIe controller register blocks. - interrupts: A list of interrupt outputs of the controller. Must contain an entry for each entry in the interrupt-names property. -- 2.9.5
[PATCH v4 02/11] PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode
Add the doorbell mode of MSI-X in DWC EP driver. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - Remove the macro of no used. v3: - No change. v4: - Modify the commit message. drivers/pci/controller/dwc/pcie-designware-ep.c | 14 ++ drivers/pci/controller/dwc/pcie-designware.h| 12 2 files changed, 26 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index eb851c2..55b23ce 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -449,6 +449,20 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no, + u16 interrupt_num) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + u32 msg_data; + + msg_data = (func_no << PCIE_MSIX_DOORBELL_PF_SHIFT) | + (interrupt_num - 1); + + dw_pcie_writel_dbi(pci, PCIE_MSIX_DOORBELL, msg_data); + + return 0; +} + int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, u16 interrupt_num) { diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 6aca0bb..56789be 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -88,6 +88,9 @@ #define PCIE_MISC_CONTROL_1_OFF0x8BC #define PCIE_DBI_RO_WR_EN BIT(0) +#define PCIE_MSIX_DOORBELL 0x948 +#define PCIE_MSIX_DOORBELL_PF_SHIFT24 + #define PCIE_PL_CHK_REG_CONTROL_STATUS 0xB20 #define PCIE_PL_CHK_REG_CHK_REG_START BIT(0) #define PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS BIT(1) @@ -419,6 +422,8 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, u8 interrupt_num); int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, u16 interrupt_num); +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no, + u16 interrupt_num); void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar); #else static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) @@ -451,6 +456,13 @@ static inline int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +static inline int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, +u8 func_no, +u16 interrupt_num) +{ + return 0; +} + static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { } -- 2.9.5
[PATCH v4 04/11] PCI: designware-ep: Modify MSI and MSIX CAP way of finding
Each PF of EP device should have it's own MSI or MSIX capabitily struct, so create a dw_pcie_ep_func struct and remove the msi_cap and msix_cap to this struct from dw_pcie_ep, and manage the PFs with a list. Signed-off-by: Xiaowei Bao --- v3: - This is a new patch, to fix the issue of MSI and MSIX CAP way of finding. v4: - Correct some word of commit message. drivers/pci/controller/dwc/pcie-designware-ep.c | 135 +--- drivers/pci/controller/dwc/pcie-designware.h| 18 +++- 2 files changed, 134 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index c3bc7bd..144eb12 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -19,6 +19,19 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) pci_epc_linkup(epc); } +struct dw_pcie_ep_func * +dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no) +{ + struct dw_pcie_ep_func *ep_func; + + list_for_each_entry(ep_func, >func_list, list) { + if (ep_func->func_no == func_no) + return ep_func; + } + + return NULL; +} + static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no) { unsigned int func_offset = 0; @@ -59,6 +72,47 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } +static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no, + u8 cap_ptr, u8 cap) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + u8 cap_id, next_cap_ptr; + u16 reg; + + if (!cap_ptr) + return 0; + + func_offset = dw_pcie_ep_func_select(ep, func_no); + + reg = dw_pcie_readw_dbi(pci, func_offset + cap_ptr); + cap_id = (reg & 0x00ff); + + if (cap_id > PCI_CAP_ID_MAX) + return 0; + + if (cap_id == cap) + return cap_ptr; + + next_cap_ptr = (reg & 0xff00) >> 8; + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); +} + +static u8 dw_pcie_ep_find_capability(struct dw_pcie_ep *ep, u8 func_no, u8 cap) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + u8 next_cap_ptr; + u16 reg; + + func_offset = dw_pcie_ep_func_select(ep, func_no); + + reg = dw_pcie_readw_dbi(pci, func_offset + PCI_CAPABILITY_LIST); + next_cap_ptr = (reg & 0x00ff); + + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); +} + static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, struct pci_epf_header *hdr) { @@ -246,13 +300,18 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; - if (!ep->msi_cap) + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; + + if (!ep_func->msi_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS; + reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS; val = dw_pcie_readw_dbi(pci, reg); if (!(val & PCI_MSI_FLAGS_ENABLE)) return -EINVAL; @@ -268,13 +327,18 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; + + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; - if (!ep->msi_cap) + if (!ep_func->msi_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS; + reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS; val = dw_pcie_readw_dbi(pci, reg); val &= ~PCI_MSI_FLAGS_QMASK; val |= (interrupts << 1) & PCI_MSI_FLAGS_QMASK; @@ -291,13 +355,18 @@ static int dw_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; + + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; - if (!ep->msix_cap) + if (!ep_func->msix_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msix_cap + func_offset +
[PATCH v4 03/11] PCI: designware-ep: Move the function of getting MSI capability forward
Move the function of getting MSI capability to the front of init function, because the init function of the EP platform driver will use the return value by the function of getting MSI capability. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. v4: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 55b23ce..c3bc7bd 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -624,6 +624,10 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) if (ret < 0) epc->max_functions = 1; + ep->msi_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); + + ep->msix_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSIX); + if (ep->ops->ep_init) ep->ops->ep_init(ep); @@ -640,9 +644,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) dev_err(dev, "Failed to reserve memory for MSI/MSI-X\n"); return -ENOMEM; } - ep->msi_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); - - ep->msix_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSIX); offset = dw_pcie_ep_find_ext_capability(pci, PCI_EXT_CAP_ID_REBAR); if (offset) { -- 2.9.5
[PATCH v4 01/11] PCI: designware-ep: Add multiple PFs support for DWC
Add multiple PFs support for DWC, due to different PF have different config space, we use func_conf_select callback function to access the different PF's config space, the different chip company need to implement this callback function when use the DWC IP core and intend to support multiple PFs feature. Signed-off-by: Xiaowei Bao --- v2: - Remove duplicate redundant code. - Reimplement the PF config space access way. v3: - Integrate duplicate code for func_select. - Move PCIE_ATU_FUNC_NUM(pf) (pf << 20) to ((pf) << 20). - Add the comments for func_conf_select function. v4: - Correct the commit message. drivers/pci/controller/dwc/pcie-designware-ep.c | 123 drivers/pci/controller/dwc/pcie-designware.c| 59 drivers/pci/controller/dwc/pcie-designware.h| 18 +++- 3 files changed, 142 insertions(+), 58 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 65f4792..eb851c2 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -19,12 +19,26 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) pci_epc_linkup(epc); } -static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar, - int flags) +static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no) +{ + unsigned int func_offset = 0; + + if (ep->ops->func_conf_select) + func_offset = ep->ops->func_conf_select(ep, func_no); + + return func_offset; +} + +static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no, + enum pci_barno bar, int flags) { u32 reg; + unsigned int func_offset = 0; + struct dw_pcie_ep *ep = >ep; + + func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = PCI_BASE_ADDRESS_0 + (4 * bar); + reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar); dw_pcie_dbi_ro_wr_en(pci); dw_pcie_writel_dbi2(pci, reg, 0x0); dw_pcie_writel_dbi(pci, reg, 0x0); @@ -37,7 +51,12 @@ static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar, void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { - __dw_pcie_ep_reset_bar(pci, bar, 0); + u8 func_no, funcs; + + funcs = pci->ep.epc->max_functions; + + for (func_no = 0; func_no < funcs; func_no++) + __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, @@ -45,28 +64,31 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, { struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + + func_offset = dw_pcie_ep_func_select(ep, func_no); dw_pcie_dbi_ro_wr_en(pci); - dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, hdr->vendorid); - dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, hdr->deviceid); - dw_pcie_writeb_dbi(pci, PCI_REVISION_ID, hdr->revid); - dw_pcie_writeb_dbi(pci, PCI_CLASS_PROG, hdr->progif_code); - dw_pcie_writew_dbi(pci, PCI_CLASS_DEVICE, + dw_pcie_writew_dbi(pci, func_offset + PCI_VENDOR_ID, hdr->vendorid); + dw_pcie_writew_dbi(pci, func_offset + PCI_DEVICE_ID, hdr->deviceid); + dw_pcie_writeb_dbi(pci, func_offset + PCI_REVISION_ID, hdr->revid); + dw_pcie_writeb_dbi(pci, func_offset + PCI_CLASS_PROG, hdr->progif_code); + dw_pcie_writew_dbi(pci, func_offset + PCI_CLASS_DEVICE, hdr->subclass_code | hdr->baseclass_code << 8); - dw_pcie_writeb_dbi(pci, PCI_CACHE_LINE_SIZE, + dw_pcie_writeb_dbi(pci, func_offset + PCI_CACHE_LINE_SIZE, hdr->cache_line_size); - dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_VENDOR_ID, + dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_VENDOR_ID, hdr->subsys_vendor_id); - dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_ID, hdr->subsys_id); - dw_pcie_writeb_dbi(pci, PCI_INTERRUPT_PIN, + dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_ID, hdr->subsys_id); + dw_pcie_writeb_dbi(pci, func_offset + PCI_INTERRUPT_PIN, hdr->interrupt_pin); dw_pcie_dbi_ro_wr_dis(pci); return 0; } -static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar, - dma_addr_t cpu_addr, +static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no, + enum pci_barno bar, dma_addr_t cpu_addr, enum dw_pcie_as_type as_type) { int ret; @@ -79,7 +101,7 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar,
[PATCH v4 00/11] Add the multiple PF support for DWC and Layerscape
Add the PCIe EP multiple PF support for DWC and Layerscape, add the doorbell MSIX function for DWC, use list to manage the PF of one PCIe controller, and refactor the Layerscape EP driver due to some platforms difference. Xiaowei Bao (11): PCI: designware-ep: Add multiple PFs support for DWC PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode PCI: designware-ep: Move the function of getting MSI capability forward PCI: designware-ep: Modify MSI and MSIX CAP way of finding dt-bindings: pci: layerscape-pci: add compatible strings for ls1088a and ls2088a PCI: layerscape: Fix some format issue of the code PCI: layerscape: Modify the way of getting capability with different PEX PCI: layerscape: Modify the MSIX to the doorbell mode PCI: layerscape: Add EP mode support for ls1088a and ls2088a arm64: dts: layerscape: Add PCIe EP node for ls1088a misc: pci_endpoint_test: Add LS1088a in pci_device_id table .../devicetree/bindings/pci/layerscape-pci.txt | 2 + arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 +++ drivers/misc/pci_endpoint_test.c | 2 + drivers/pci/controller/dwc/pci-layerscape-ep.c | 100 ++-- drivers/pci/controller/dwc/pcie-designware-ep.c| 255 + drivers/pci/controller/dwc/pcie-designware.c | 59 +++-- drivers/pci/controller/dwc/pcie-designware.h | 48 +++- 7 files changed, 404 insertions(+), 93 deletions(-) -- 2.9.5
RE: [PATCH v3 09/11] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年9月16日 22:38 > To: Xiaowei Bao ; robh...@kernel.org > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 09/11] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > On Sat, Sep 14, 2019 at 04:10:22AM +, Xiaowei Bao wrote: > > > > > > > -Original Message- > > > From: Andrew Murray > > > Sent: 2019年9月12日 20:50 > > > To: Xiaowei Bao > > > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; > > > Leo Li ; kis...@ti.com; lorenzo.pieral...@arm.com; > M.h. > > > Lian ; Mingkai Hu ; Roy > > > Zang ; jingooh...@gmail.com; > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > > > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > > > > > Subject: Re: [PATCH v3 09/11] PCI: layerscape: Add EP mode support > > > for ls1088a and ls2088a > > > > > > On Tue, Sep 03, 2019 at 01:47:36AM +, Xiaowei Bao wrote: > > > > > > > > > > > > > -Original Message- > > > > > From: Andrew Murray > > > > > Sent: 2019年9月2日 20:46 > > > > > To: Xiaowei Bao > > > > > Cc: robh...@kernel.org; mark.rutl...@arm.com; > > > > > shawn...@kernel.org; Leo Li ; kis...@ti.com; > > > > > lorenzo.pieral...@arm.com; > > > M.h. > > > > > Lian ; Mingkai Hu ; > > > > > Roy Zang ; jingooh...@gmail.com; > > > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > > > linux-arm-ker...@lists.infradead.org; > > > > > linuxppc-dev@lists.ozlabs.org; a...@arndb.de; > > > > > gre...@linuxfoundation.org; Z.q. Hou > > > > > Subject: Re: [PATCH v3 09/11] PCI: layerscape: Add EP mode > > > > > support for ls1088a and ls2088a > > > > > > > > > > On Mon, Sep 02, 2019 at 11:17:14AM +0800, Xiaowei Bao wrote: > > > > > > Add PCIe EP mode support for ls1088a and ls2088a, there are > > > > > > some difference between LS1 and LS2 platform, so refactor the > > > > > > code of the EP driver. > > > > > > > > > > > > Signed-off-by: Xiaowei Bao > > > > > > --- > > > > > > v2: > > > > > > - This is a new patch for supporting the ls1088a and ls2088a > platform. > > > > > > v3: > > > > > > - Adjust the some struct assignment order in probe function. > > > > > > > > > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 72 > > > > > > +++--- > > > > > > 1 file changed, 53 insertions(+), 19 deletions(-) > > > > > > > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > > > index 5f0cb99..723bbe5 100644 > > > > > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > > > @@ -20,27 +20,29 @@ > > > > > > > > > > > > #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ > > > > > > > > > > > > -struct ls_pcie_ep { > > > > > > - struct dw_pcie *pci; > > > > > > - struct pci_epc_features *ls_epc; > > > > > > +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > > > > > + > > > > > > +struct ls_pcie_ep_drvdata { > > > > > > + u32 func_offset; > > > > > > + const struct dw_pcie_ep_ops *ops; > > > > > > + const struct dw_pcie_ops*dw_pcie_ops; > > > > > > }; > >
RE: [PATCH v3 08/11] PCI: layerscape: Modify the MSIX to the doorbell mode
> -Original Message- > From: Gustavo Pimentel > Sent: 2019年9月12日 19:24 > To: Andrew Murray ; Xiaowei Bao > > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: RE: [PATCH v3 08/11] PCI: layerscape: Modify the MSIX to the > doorbell mode > > Hi, > > Sorry for the delay I was in parental leave and I'm still trying not to drown > in > the mailing list emails... > > On Mon, Sep 2, 2019 at 13:1:47, Andrew Murray > wrote: > > > On Mon, Sep 02, 2019 at 11:17:13AM +0800, Xiaowei Bao wrote: > > > dw_pcie_ep_raise_msix_irq was never called in the exisitng driver > > > before, because the ls1046a platform don't support the MSIX feature > > > and msix_capable was always set to false. > > > Now that add the ls1088a platform with MSIX support, but the > > > existing dw_pcie_ep_raise_msix_irq doesn't work, so use the doorbell > > > method to support the MSIX feature. > > Hum... the implementation of msix implementation did work on my use case, > however, at the time the setup used for developing and testing the > implementation only had one PF (by default 0). Perhaps this could was is > causing the different behavior between our setups. > > You have more than one PF, right? Yes, I have two PFs. Thanks Xiaowei > > If I remember correctly, msix feature support entered on kernel 4.19 version > and it worked quite well at the time, but I didn't test since there (I've to > manage time to be able to retest it again), I'm didn't seen any patch that > could interfere with this. > > Regards, > Gustavo > > > > > > > > Signed-off-by: Xiaowei Bao > > > > Reviewed-by: Andrew Murray > > > > > --- > > > v2: > > > - No change > > > v3: > > > - Modify the commit message make it clearly. > > > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > index 1e07287..5f0cb99 100644 > > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > @@ -79,7 +79,8 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep > *ep, u8 func_no, > > > case PCI_EPC_IRQ_MSI: > > > return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); > > > case PCI_EPC_IRQ_MSIX: > > > - return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num); > > > + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, > > > + interrupt_num); > > > default: > > > dev_err(pci->dev, "UNKNOWN IRQ type\n"); > > > return -EINVAL; > > > -- > > > 2.9.5 > > > >
RE: [PATCH v3 10/11] arm64: dts: layerscape: Add PCIe EP node for ls1088a
> -Original Message- > From: Andrew Murray > Sent: 2019年9月12日 21:02 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 10/11] arm64: dts: layerscape: Add PCIe EP node for > ls1088a > > On Tue, Sep 03, 2019 at 02:01:32AM +, Xiaowei Bao wrote: > > > > > > > -Original Message- > > > From: Andrew Murray > > > Sent: 2019年9月2日 21:06 > > > To: Xiaowei Bao > > > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; > > > Leo Li ; kis...@ti.com; lorenzo.pieral...@arm.com; > M.h. > > > Lian ; Mingkai Hu ; Roy > > > Zang ; jingooh...@gmail.com; > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > > > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > > > > > Subject: Re: [PATCH v3 10/11] arm64: dts: layerscape: Add PCIe EP > > > node for ls1088a > > > > > > On Mon, Sep 02, 2019 at 11:17:15AM +0800, Xiaowei Bao wrote: > > > > Add PCIe EP node for ls1088a to support EP mode. > > > > > > > > Signed-off-by: Xiaowei Bao > > > > --- > > > > v2: > > > > - Remove the pf-offset proparty. > > > > v3: > > > > - No change. > > > > > > > > arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 > > > ++ > > > > 1 file changed, 31 insertions(+) > > > > > > > > diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi > > > b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi > > > > index c676d07..da246ab 100644 > > > > --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi > > > > +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi > > > > @@ -483,6 +483,17 @@ > > > > status = "disabled"; > > > > }; > > > > > > > > + pcie_ep@340 { > > > > + compatible = > > > > "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; > > > > > > Here you specify a fallback "fsl,ls-pcie-ep" that is removed by this > > > series. > > > > > > Besides that, this looks OK. > > > > As explained, the "fsl,ls-pcie-ep" is needed, due to the u-boot will > > fixup the status property base on this compatible, I think we reserve > > this compatible is helpfully, if delate this compatible, I have to modify > > the > code of bootloader. > > I assume you mean that u-boot fixes up "fsl,ls-pcie-ep" *only* for ls1046a > devices? No, all Layerscape platform of NXP. > > Thanks, > > Andrew Murray > > > > > Thanks > > XIaowei > > > > > > > > Thanks, > > > > > > Andrew Murray > > > > > > > + reg = <0x00 0x0340 0x0 0x0010 > > > > + 0x20 0x 0x8 0x>; > > > > + reg-names = "regs", "addr_space"; > > > > + num-ib-windows = <24>; > > > > + num-ob-windows = <128>; > > > > + max-functions = /bits/ 8 <2>; > > > > + status = "disabled"; > > > > + }; > > > > + > > > > pcie@350 { > > > > compatible = "fsl,ls1088a-pcie"; > > > > reg = <0x00 0x0350 0x0 0x0010 /* > > > > controller > > > registers */ > > > > @@ -508,6 +519,16 @@ > > > > status = "disabled"; > > > > }; > > > > > > > > + pcie_ep@350 { > > > > + compatible = > > > > "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep
RE: [PATCH v3 11/11] misc: pci_endpoint_test: Add LS1088a in pci_device_id table
> -Original Message- > From: Andrew Murray > Sent: 2019年9月12日 21:00 > To: Xiaowei Bao ; helg...@kernel.org > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 11/11] misc: pci_endpoint_test: Add LS1088a in > pci_device_id table > > On Tue, Sep 03, 2019 at 01:52:30AM +, Xiaowei Bao wrote: > > > > > > > -Original Message- > > > From: Andrew Murray > > > Sent: 2019年9月2日 20:55 > > > To: Xiaowei Bao > > > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; > > > Leo Li ; kis...@ti.com; lorenzo.pieral...@arm.com; > M.h. > > > Lian ; Mingkai Hu ; Roy > > > Zang ; jingooh...@gmail.com; > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > > > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > > > > > Subject: Re: [PATCH v3 11/11] misc: pci_endpoint_test: Add LS1088a > > > in pci_device_id table > > > > > > On Mon, Sep 02, 2019 at 11:17:16AM +0800, Xiaowei Bao wrote: > > > > Add LS1088a in pci_device_id table so that pci-epf-test can be > > > > used for testing PCIe EP in LS1088a. > > > > > > > > Signed-off-by: Xiaowei Bao > > > > --- > > > > v2: > > > > - No change. > > > > v3: > > > > - No change. > > > > > > > > drivers/misc/pci_endpoint_test.c | 1 + > > > > 1 file changed, 1 insertion(+) > > > > > > > > diff --git a/drivers/misc/pci_endpoint_test.c > > > > b/drivers/misc/pci_endpoint_test.c > > > > index 6e208a0..d531951 100644 > > > > --- a/drivers/misc/pci_endpoint_test.c > > > > +++ b/drivers/misc/pci_endpoint_test.c > > > > @@ -793,6 +793,7 @@ static const struct pci_device_id > > > pci_endpoint_test_tbl[] = { > > > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, > > > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, > > > > { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, > > > > + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x80c0) }, > > > > > > The Freescale PCI devices are the only devices in this table that > > > don't have a define for their device ID. I think a define should be > > > created for both of the device IDs above. > > > > OK, but I only define in this file, I am not sure this can define in > > include/linux/pci_ids.h file > > This file seems a little inconsistent... > > - Two of the TI device IDs are defined in pci_ids.h and only used in > pci_endpoint_test.c > - One of the TI device IDs are defined in pci_endpoint_test.c and only used > there > - The Freescale device ID is hardcoded and only used in pci_endpoint_test.c > > The header in pci_ids.h has a comment suggestion definitions are only added > where used in multiple files - yet I don't think this holds true. Thanks Andrew. > > Bjorn - do you have a suggestion? > > Thanks, > > Andrew Murray > > > > > Thanks > > Xiaowei > > > > > > > > Thanks, > > > > > > Andrew Murray > > > > > > > { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, > > > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), > > > > .driver_data = (kernel_ulong_t)_data > > > > -- > > > > 2.9.5 > > > >
RE: [PATCH v3 09/11] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年9月12日 20:50 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 09/11] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > On Tue, Sep 03, 2019 at 01:47:36AM +, Xiaowei Bao wrote: > > > > > > > -Original Message- > > > From: Andrew Murray > > > Sent: 2019年9月2日 20:46 > > > To: Xiaowei Bao > > > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; > > > Leo Li ; kis...@ti.com; lorenzo.pieral...@arm.com; > M.h. > > > Lian ; Mingkai Hu ; Roy > > > Zang ; jingooh...@gmail.com; > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > > > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > > > > > Subject: Re: [PATCH v3 09/11] PCI: layerscape: Add EP mode support > > > for ls1088a and ls2088a > > > > > > On Mon, Sep 02, 2019 at 11:17:14AM +0800, Xiaowei Bao wrote: > > > > Add PCIe EP mode support for ls1088a and ls2088a, there are some > > > > difference between LS1 and LS2 platform, so refactor the code of > > > > the EP driver. > > > > > > > > Signed-off-by: Xiaowei Bao > > > > --- > > > > v2: > > > > - This is a new patch for supporting the ls1088a and ls2088a platform. > > > > v3: > > > > - Adjust the some struct assignment order in probe function. > > > > > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 72 > > > > +++--- > > > > 1 file changed, 53 insertions(+), 19 deletions(-) > > > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > index 5f0cb99..723bbe5 100644 > > > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > @@ -20,27 +20,29 @@ > > > > > > > > #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ > > > > > > > > -struct ls_pcie_ep { > > > > - struct dw_pcie *pci; > > > > - struct pci_epc_features *ls_epc; > > > > +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > > > + > > > > +struct ls_pcie_ep_drvdata { > > > > + u32 func_offset; > > > > + const struct dw_pcie_ep_ops *ops; > > > > + const struct dw_pcie_ops*dw_pcie_ops; > > > > }; > > > > > > > > -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > > > +struct ls_pcie_ep { > > > > + struct dw_pcie *pci; > > > > + struct pci_epc_features *ls_epc; > > > > + const struct ls_pcie_ep_drvdata *drvdata; }; > > > > > > > > static int ls_pcie_establish_link(struct dw_pcie *pci) { > > > > return 0; > > > > } > > > > > > > > -static const struct dw_pcie_ops ls_pcie_ep_ops = { > > > > +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { > > > > .start_link = ls_pcie_establish_link, }; > > > > > > > > -static const struct of_device_id ls_pcie_ep_of_match[] = { > > > > - { .compatible = "fsl,ls-pcie-ep",}, > > > > - { }, > > > > -}; > > > > - > > > > static const struct pci_epc_features* > > > > ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { @@ -87,10 +89,39 > > > > @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, > > > > } > > > > } > > > > > > > > -static const struct dw_pcie_ep_ops pcie_ep_ops = { > > > > +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep > *ep, > > > &g
RE: [PATCH v3 01/11] PCI: designware-ep: Add multiple PFs support for DWC
> -Original Message- > From: Andrew Murray > Sent: 2019年9月3日 0:26 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > gre...@linuxfoundation.org; Z.q. Hou ; > a...@arndb.de > Subject: Re: [PATCH v3 01/11] PCI: designware-ep: Add multiple PFs support > for DWC > > On Mon, Sep 02, 2019 at 11:17:06AM +0800, Xiaowei Bao wrote: > > Add multiple PFs support for DWC, different PF have different config > > space we use pf-offset property which get from the DTS to access the > > different pF > > This needs to be updated as this no longer comes from the DT. Yes, thanks Thanks Xiaowei > > > config space. > > > > Signed-off-by: Xiaowei Bao > > > We're assuming: > > - The offset address (func_offset) between PF's in the memory map can be >different between different DWC implementations. And also that it's >possible for DWC implementations to address PFs without using an offset. > > - The current approach is preferable to adding DWC EP driver callbacks >for writing to the EP config space (e.g. a variant of dw_pcie_writew_dbi >that takes a func number). Even if use the a variant of dw_pcie_writew_dbi, we also need a offset value form different platform, due to the different platform may be have different implement about this, so I am not sure how to implement the variant of dw_pcie_writew_dbi? > > I'm keen to hear feedback from Jingoo/Gustavo on this. OK, expect the feedback. Thanks Xiaowei > > Thanks, > > Andrew Murray > > > --- > > v2: > > - Remove duplicate redundant code. > > - Reimplement the PF config space access way. > > v3: > > - Integrate duplicate code for func_select. > > - Move PCIE_ATU_FUNC_NUM(pf) (pf << 20) to ((pf) << 20). > > - Add the comments for func_conf_select function. > > > > drivers/pci/controller/dwc/pcie-designware-ep.c | 123 > > > drivers/pci/controller/dwc/pcie-designware.c| 59 > > drivers/pci/controller/dwc/pcie-designware.h| 18 +++- > > 3 files changed, 142 insertions(+), 58 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c > > b/drivers/pci/controller/dwc/pcie-designware-ep.c > > index 65f4792..eb851c2 100644 > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > > @@ -19,12 +19,26 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) > > pci_epc_linkup(epc); > > } > > > > -static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno > bar, > > - int flags) > > +static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 > > +func_no) { > > + unsigned int func_offset = 0; > > + > > + if (ep->ops->func_conf_select) > > + func_offset = ep->ops->func_conf_select(ep, func_no); > > + > > + return func_offset; > > +} > > + > > +static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no, > > + enum pci_barno bar, int flags) > > { > > u32 reg; > > + unsigned int func_offset = 0; > > + struct dw_pcie_ep *ep = >ep; > > + > > + func_offset = dw_pcie_ep_func_select(ep, func_no); > > > > - reg = PCI_BASE_ADDRESS_0 + (4 * bar); > > + reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar); > > dw_pcie_dbi_ro_wr_en(pci); > > dw_pcie_writel_dbi2(pci, reg, 0x0); > > dw_pcie_writel_dbi(pci, reg, 0x0); > > @@ -37,7 +51,12 @@ static void __dw_pcie_ep_reset_bar(struct dw_pcie > > *pci, enum pci_barno bar, > > > > void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { > > - __dw_pcie_ep_reset_bar(pci, bar, 0); > > + u8 func_no, funcs; > > + > > + funcs = pci->ep.epc->max_functions; > > + > > + for (func_no = 0; func_no < funcs; func_no++) > > + __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); > > } > > > > static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, > > @@ -45,28 +64,31 @@ static int dw_pcie_ep_write_header(struct pci_epc > > *epc, u8 func_no, { > > struct dw_pcie_ep *ep = epc_get_drvdata(epc); > > st
RE: [PATCH v3 04/11] PCI: designware-ep: Modify MSI and MSIX CAP way of finding
> -Original Message- > From: Andrew Murray > Sent: 2019年9月2日 23:07 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 04/11] PCI: designware-ep: Modify MSI and MSIX CAP > way of finding > > On Mon, Sep 02, 2019 at 11:17:09AM +0800, Xiaowei Bao wrote: > > Each PF of EP device should have it's own MSI or MSIX capabitily > > struct, so create a dw_pcie_ep_func struct and remover the msi_cap > > remover? Sorry. ^_^ > > > and msix_cap to this struce, and manage the PFs with a list. > > struce? > > > > > Signed-off-by: Xiaowei Bao > > --- > > v1: > > - This is a new patch, to fix the issue of MSI and MSIX CAP way of > >finding. > > v2: > > - No change. > > v3: > > - No change. > > This makes it look like you introduced the patch in v1 and haven't changed it > since. > > I think it's more common to have a history like this: > > --- > v3: > - Introduced new patch, to fix the issue of MSI and MSIX CAP way of >finding. OK, thanks, I am not clear the rules, thanks a lot for your help. Thanks Xiaowei > > > > > > drivers/pci/controller/dwc/pcie-designware-ep.c | 135 > +--- > > drivers/pci/controller/dwc/pcie-designware.h| 18 +++- > > 2 files changed, 134 insertions(+), 19 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c > > b/drivers/pci/controller/dwc/pcie-designware-ep.c > > index c3bc7bd..144eb12 100644 > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > > @@ -19,6 +19,19 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) > > pci_epc_linkup(epc); > > } > > > > +struct dw_pcie_ep_func * > > +dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no) { > > + struct dw_pcie_ep_func *ep_func; > > + > > + list_for_each_entry(ep_func, >func_list, list) { > > + if (ep_func->func_no == func_no) > > + return ep_func; > > + } > > + > > + return NULL; > > +} > > + > > static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 > > func_no) { > > unsigned int func_offset = 0; > > @@ -59,6 +72,47 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, > enum pci_barno bar) > > __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } > > > > +static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 > func_no, > > + u8 cap_ptr, u8 cap) > > +{ > > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + unsigned int func_offset = 0; > > + u8 cap_id, next_cap_ptr; > > + u16 reg; > > + > > + if (!cap_ptr) > > + return 0; > > + > > + func_offset = dw_pcie_ep_func_select(ep, func_no); > > + > > + reg = dw_pcie_readw_dbi(pci, func_offset + cap_ptr); > > + cap_id = (reg & 0x00ff); > > + > > + if (cap_id > PCI_CAP_ID_MAX) > > + return 0; > > + > > + if (cap_id == cap) > > + return cap_ptr; > > + > > + next_cap_ptr = (reg & 0xff00) >> 8; > > + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); } > > Which tree have you based this patchset on? v5.3-rc3 and pci/dwc both > already have this function (without the func_no). See beb4641a787d > ("PCI: dwc: Add MSI-X callbacks handler"). There is a commit 7a6854f68 in the latest kernel. Thanks Xiaowei > > > + > > +static u8 dw_pcie_ep_find_capability(struct dw_pcie_ep *ep, u8 > > +func_no, u8 cap) { > > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + unsigned int func_offset = 0; > > + u8 next_cap_ptr; > > + u16 reg; > > + > > + func_offset = dw_pcie_ep_func_select(ep, func_no); > > + > > + reg = dw_pcie_readw_dbi(pci, func_offset + PCI_CAPABILITY_LIST); > > + next_cap_ptr = (reg & 0x00ff); > > + > > + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); } > > + > > static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, > >
RE: [PATCH v3 07/11] PCI: layerscape: Modify the way of getting capability with different PEX
> -Original Message- > From: Andrew Murray > Sent: 2019年9月2日 21:38 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 07/11] PCI: layerscape: Modify the way of getting > capability with different PEX > > On Mon, Sep 02, 2019 at 11:17:12AM +0800, Xiaowei Bao wrote: > > The different PCIe controller in one board may be have different > > capability of MSI or MSIX, so change the way of getting the MSI > > capability, make it more flexible. > > > > Signed-off-by: Xiaowei Bao > > Please see the comments I just made to Kishon's feedback in the thread for > this patch in series v2. I have reply the comments in series v2, expect Kishon's feedback. Thanks Xiaowei > > Thanks, > > Andrew Murray > > > --- > > v2: > > - Remove the repeated assignment code. > > v3: > > - Use ep_func msi_cap and msix_cap to decide the msi_capable and > >msix_capable of pci_epc_features struct. > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 31 > > +++--- > > 1 file changed, 23 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > index a9c552e..1e07287 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > @@ -22,6 +22,7 @@ > > > > struct ls_pcie_ep { > > struct dw_pcie *pci; > > + struct pci_epc_features *ls_epc; > > }; > > > > #define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > @@ -40,26 +41,31 @@ static const struct of_device_id > ls_pcie_ep_of_match[] = { > > { }, > > }; > > > > -static const struct pci_epc_features ls_pcie_epc_features = { > > - .linkup_notifier = false, > > - .msi_capable = true, > > - .msix_capable = false, > > - .bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), > > -}; > > - > > static const struct pci_epc_features* ls_pcie_ep_get_features(struct > > dw_pcie_ep *ep) { > > - return _pcie_epc_features; > > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > > + > > + return pcie->ls_epc; > > } > > > > static void ls_pcie_ep_init(struct dw_pcie_ep *ep) { > > struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > > + struct dw_pcie_ep_func *ep_func; > > enum pci_barno bar; > > > > + ep_func = dw_pcie_ep_get_func_from_ep(ep, 0); > > + if (!ep_func) > > + return; > > + > > for (bar = BAR_0; bar <= BAR_5; bar++) > > dw_pcie_ep_reset_bar(pci, bar); > > + > > + pcie->ls_epc->msi_capable = ep_func->msi_cap ? true : false; > > + pcie->ls_epc->msix_capable = ep_func->msix_cap ? true : false; > > } > > > > static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, @@ > > -119,6 +125,7 @@ static int __init ls_pcie_ep_probe(struct platform_device > *pdev) > > struct device *dev = >dev; > > struct dw_pcie *pci; > > struct ls_pcie_ep *pcie; > > + struct pci_epc_features *ls_epc; > > struct resource *dbi_base; > > int ret; > > > > @@ -130,6 +137,10 @@ static int __init ls_pcie_ep_probe(struct > platform_device *pdev) > > if (!pci) > > return -ENOMEM; > > > > + ls_epc = devm_kzalloc(dev, sizeof(*ls_epc), GFP_KERNEL); > > + if (!ls_epc) > > + return -ENOMEM; > > + > > dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, > "regs"); > > pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); > > if (IS_ERR(pci->dbi_base)) > > @@ -140,6 +151,10 @@ static int __init ls_pcie_ep_probe(struct > platform_device *pdev) > > pci->ops = _pcie_ep_ops; > > pcie->pci = pci; > > > > + ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), > > + > > + pcie->ls_epc = ls_epc; > > + > > platform_set_drvdata(pdev, pcie); > > > > ret = ls_add_pcie_ep(pcie, pdev); > > -- > > 2.9.5 > >
RE: [PATCH v2 06/10] PCI: layerscape: Modify the way of getting capability with different PEX
> -Original Message- > From: Andrew Murray > Sent: 2019年9月2日 21:37 > To: Xiaowei Bao > Cc: Kishon Vijay Abraham I ; bhelg...@google.com; > robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo Li > ; lorenzo.pieral...@arm.co > ; a...@arndb.de; gre...@linuxfoundation.org; > M.h. Lian ; Mingkai Hu ; > Roy Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 06/10] PCI: layerscape: Modify the way of getting > capability with different PEX > > On Fri, Aug 23, 2019 at 04:13:30AM +, Xiaowei Bao wrote: > > > > > > > -Original Message- > > > From: Kishon Vijay Abraham I > > > Sent: 2019年8月23日 11:40 > > > To: Xiaowei Bao ; bhelg...@google.com; > > > robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > > > robh+Li > > > ; lorenzo.pieral...@arm.co > > > ; a...@arndb.de; > > > gre...@linuxfoundation.org; M.h. Lian ; > > > Mingkai Hu ; Roy Zang ; > > > jingooh...@gmail.com; gustavo.pimen...@synopsys.com; > > > linux-...@vger.kernel.org; devicet...@vger.kernel.org; > > > linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > > > linuxppc-dev@lists.ozlabs.org; andrew.mur...@arm.com > > > Subject: Re: [PATCH v2 06/10] PCI: layerscape: Modify the way of > > > getting capability with different PEX > > > > > > Hi, > > > > > > (Fixed Lorenzo's email address. All the patches in the series have > > > wrong email > > > id) > > > > > > On 23/08/19 8:09 AM, Xiaowei Bao wrote: > > > > > > > > > > > >> -Original Message- > > > >> From: Kishon Vijay Abraham I > > > >> Sent: 2019年8月22日 19:44 > > > >> To: Xiaowei Bao ; bhelg...@google.com; > > > >> robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; > > > >> robh+Leo > > > Li > > > >> ; lorenzo.pieral...@arm.co; a...@arndb.de; > > > >> gre...@linuxfoundation.org; M.h. Lian ; > > > >> Mingkai Hu ; Roy Zang ; > > > >> jingooh...@gmail.com; gustavo.pimen...@synopsys.com; > > > >> linux-...@vger.kernel.org; devicet...@vger.kernel.org; > > > >> linux-ker...@vger.kernel.org; > > > >> linux-arm-ker...@lists.infradead.org; > > > >> linuxppc-dev@lists.ozlabs.org; andrew.mur...@arm.com > > > >> Subject: Re: [PATCH v2 06/10] PCI: layerscape: Modify the way of > > > >> getting capability with different PEX > > > >> > > > >> Hi, > > > >> > > > >> On 22/08/19 4:52 PM, Xiaowei Bao wrote: > > > >>> The different PCIe controller in one board may be have different > > > >>> capability of MSI or MSIX, so change the way of getting the MSI > > > >>> capability, make it more flexible. > > > >> > > > >> please use different pci_epc_features table for different boards. > > > > Thanks, I think that it will be more flexible to dynamically get > > > > MSI or MSIX capability, Thus, we will not need to define the > > > > pci_epc_feature for > > > different boards. > > > > > > Is the restriction because you cannot have different compatible for > > > different boards? > > Sorry, I am not very clear what your mean, I think even if I use the > > same compatible with different boards, each boards will enter the > > probe function, in there I will get the MSI or MSIX PCIe capability of > > the current controller in this board. Why do I need to define the > pci_epc_feature for different boards? > > At present you determine how to set the [msi,msix]_capable flags of > pci_epc_features based on reading the function capabilities at probe time. > Instead of doing this, is it possible that you can determine the flags based > on > the compatible type alone? For example, is the MSI/MSIX capability the same > for all fsl,ls2088a-pcie-ep devices? > > If it isn't *necessary* to probe for this information at probe time, then you > could instead create a static pci_epc_features structure and assign it to > something in your drvdata. This may provide some benefits. > > The dw_pcie_ep_get_features function would then look like: > > static const struct pci_epc_features* > ls_pcie_ep_get_features(struct dw_pcie_ep *ep) {
RE: [PATCH v3 10/11] arm64: dts: layerscape: Add PCIe EP node for ls1088a
> -Original Message- > From: Andrew Murray > Sent: 2019年9月2日 21:06 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 10/11] arm64: dts: layerscape: Add PCIe EP node for > ls1088a > > On Mon, Sep 02, 2019 at 11:17:15AM +0800, Xiaowei Bao wrote: > > Add PCIe EP node for ls1088a to support EP mode. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - Remove the pf-offset proparty. > > v3: > > - No change. > > > > arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 > ++ > > 1 file changed, 31 insertions(+) > > > > diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi > b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi > > index c676d07..da246ab 100644 > > --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi > > +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi > > @@ -483,6 +483,17 @@ > > status = "disabled"; > > }; > > > > + pcie_ep@340 { > > + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; > > Here you specify a fallback "fsl,ls-pcie-ep" that is removed by this series. > > Besides that, this looks OK. As explained, the "fsl,ls-pcie-ep" is needed, due to the u-boot will fixup the status property base on this compatible, I think we reserve this compatible is helpfully, if delate this compatible, I have to modify the code of bootloader. Thanks XIaowei > > Thanks, > > Andrew Murray > > > + reg = <0x00 0x0340 0x0 0x0010 > > + 0x20 0x 0x8 0x>; > > + reg-names = "regs", "addr_space"; > > + num-ib-windows = <24>; > > + num-ob-windows = <128>; > > + max-functions = /bits/ 8 <2>; > > + status = "disabled"; > > + }; > > + > > pcie@350 { > > compatible = "fsl,ls1088a-pcie"; > > reg = <0x00 0x0350 0x0 0x0010 /* controller > registers */ > > @@ -508,6 +519,16 @@ > > status = "disabled"; > > }; > > > > + pcie_ep@350 { > > + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; > > + reg = <0x00 0x0350 0x0 0x0010 > > + 0x28 0x 0x8 0x>; > > + reg-names = "regs", "addr_space"; > > + num-ib-windows = <6>; > > + num-ob-windows = <8>; > > + status = "disabled"; > > + }; > > + > > pcie@360 { > > compatible = "fsl,ls1088a-pcie"; > > reg = <0x00 0x0360 0x0 0x0010 /* controller > registers */ > > @@ -533,6 +554,16 @@ > > status = "disabled"; > > }; > > > > + pcie_ep@360 { > > + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; > > + reg = <0x00 0x0360 0x0 0x0010 > > + 0x30 0x 0x8 0x>; > > + reg-names = "regs", "addr_space"; > > + num-ib-windows = <6>; > > + num-ob-windows = <8>; > > + status = "disabled"; > > + }; > > + > > smmu: iommu@500 { > > compatible = "arm,mmu-500"; > > reg = <0 0x500 0 0x80>; > > -- > > 2.9.5 > >
RE: [PATCH v3 11/11] misc: pci_endpoint_test: Add LS1088a in pci_device_id table
> -Original Message- > From: Andrew Murray > Sent: 2019年9月2日 20:55 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 11/11] misc: pci_endpoint_test: Add LS1088a in > pci_device_id table > > On Mon, Sep 02, 2019 at 11:17:16AM +0800, Xiaowei Bao wrote: > > Add LS1088a in pci_device_id table so that pci-epf-test can be used > > for testing PCIe EP in LS1088a. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - No change. > > v3: > > - No change. > > > > drivers/misc/pci_endpoint_test.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/misc/pci_endpoint_test.c > > b/drivers/misc/pci_endpoint_test.c > > index 6e208a0..d531951 100644 > > --- a/drivers/misc/pci_endpoint_test.c > > +++ b/drivers/misc/pci_endpoint_test.c > > @@ -793,6 +793,7 @@ static const struct pci_device_id > pci_endpoint_test_tbl[] = { > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, > > { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, > > + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x80c0) }, > > The Freescale PCI devices are the only devices in this table that don't have a > define for their device ID. I think a define should be created for both of the > device IDs above. OK, but I only define in this file, I am not sure this can define in include/linux/pci_ids.h file Thanks Xiaowei > > Thanks, > > Andrew Murray > > > { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, > > { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), > > .driver_data = (kernel_ulong_t)_data > > -- > > 2.9.5 > >
RE: [PATCH v3 09/11] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年9月2日 20:46 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 09/11] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > On Mon, Sep 02, 2019 at 11:17:14AM +0800, Xiaowei Bao wrote: > > Add PCIe EP mode support for ls1088a and ls2088a, there are some > > difference between LS1 and LS2 platform, so refactor the code of the > > EP driver. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - This is a new patch for supporting the ls1088a and ls2088a platform. > > v3: > > - Adjust the some struct assignment order in probe function. > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 72 > > +++--- > > 1 file changed, 53 insertions(+), 19 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > index 5f0cb99..723bbe5 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > @@ -20,27 +20,29 @@ > > > > #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ > > > > -struct ls_pcie_ep { > > - struct dw_pcie *pci; > > - struct pci_epc_features *ls_epc; > > +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > + > > +struct ls_pcie_ep_drvdata { > > + u32 func_offset; > > + const struct dw_pcie_ep_ops *ops; > > + const struct dw_pcie_ops*dw_pcie_ops; > > }; > > > > -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > +struct ls_pcie_ep { > > + struct dw_pcie *pci; > > + struct pci_epc_features *ls_epc; > > + const struct ls_pcie_ep_drvdata *drvdata; }; > > > > static int ls_pcie_establish_link(struct dw_pcie *pci) { > > return 0; > > } > > > > -static const struct dw_pcie_ops ls_pcie_ep_ops = { > > +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { > > .start_link = ls_pcie_establish_link, }; > > > > -static const struct of_device_id ls_pcie_ep_of_match[] = { > > - { .compatible = "fsl,ls-pcie-ep",}, > > - { }, > > -}; > > - > > static const struct pci_epc_features* ls_pcie_ep_get_features(struct > > dw_pcie_ep *ep) { @@ -87,10 +89,39 @@ static int > > ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, > > } > > } > > > > -static const struct dw_pcie_ep_ops pcie_ep_ops = { > > +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep, > > + u8 func_no) > > +{ > > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > > + > > + WARN_ON(func_no && !pcie->drvdata->func_offset); > > + return pcie->drvdata->func_offset * func_no; } > > + > > +static const struct dw_pcie_ep_ops ls_pcie_ep_ops = { > > .ep_init = ls_pcie_ep_init, > > .raise_irq = ls_pcie_ep_raise_irq, > > .get_features = ls_pcie_ep_get_features, > > + .func_conf_select = ls_pcie_ep_func_conf_select, }; > > + > > +static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = { > > + .ops = _pcie_ep_ops, > > + .dw_pcie_ops = _ls_pcie_ep_ops, > > +}; > > + > > +static const struct ls_pcie_ep_drvdata ls2_ep_drvdata = { > > + .func_offset = 0x2, > > + .ops = _pcie_ep_ops, > > + .dw_pcie_ops = _ls_pcie_ep_ops, > > +}; > > + > > +static const struct of_device_id ls_pcie_ep_of_match[] = { > > + { .compatible = "fsl,ls1046a-pcie-ep", .data = _ep_drvdata }, > > + { .compatible = "fsl,ls1088a-pcie-ep", .data = _ep_drvdata }, > > + { .compatible = "fsl,ls2088a-pcie-ep", .data = _ep_drvdata }, > > + { }, > > This removes support for "fsl,ls-pcie-ep" - was that intentional? If you do > plan > to drop it please make sure you explain why in the commit message. See also > my comments in your dt-binding patch. In fact, the u-bo
RE: [PATCH v3 05/11] dt-bindings: pci: layerscape-pci: add compatible strings for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年9月2日 20:32 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > Subject: Re: [PATCH v3 05/11] dt-bindings: pci: layerscape-pci: add compatible > strings for ls1088a and ls2088a > > On Mon, Sep 02, 2019 at 11:17:10AM +0800, Xiaowei Bao wrote: > > Add compatible strings for ls1088a and ls2088a. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - No change. > > v3: > > - Use one valid combination of compatible strings. > > > > Documentation/devicetree/bindings/pci/layerscape-pci.txt | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > b/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > index e20ceaa..762ae41 100644 > > --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > @@ -22,7 +22,9 @@ Required properties: > > "fsl,ls1043a-pcie" > > "fsl,ls1012a-pcie" > >EP mode: > > - "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" > > + "fsl,ls1046a-pcie-ep" "fsl,ls-pcie-ep" > > + "fsl,ls1088a-pcie-ep" "fsl,ls-pcie-ep" > > + "fsl,ls2088a-pcie-ep" "fsl,ls-pcie-ep" > > This isn't consistent with "[PATCH v3 09/11] PCI: layerscape: Add EP mode..." > as that patch drops the fallback "fsl,ls-pcie-ep". Either the fallback must be > preserved in the driver, or you need to drop it here. > > What if there are existing users that depend on the fallback? > > (I'm also not sure if that comma should have been dropped). Hi Andrew, Thanks for your comments, I lose the comma. Thanks Xiaowei > > Thanks, > > Andrew Murray > > > - reg: base addresses and lengths of the PCIe controller register blocks. > > - interrupts: A list of interrupt outputs of the controller. Must contain > > an > >entry for each entry in the interrupt-names property. > > -- > > 2.9.5 > >
RE: [PATCH v3 00/11] *** SUBJECT HERE ***
> -Original Message- > From: Z.q. Hou > Sent: 2019年9月2日 11:52 > To: Xiaowei Bao ; robh...@kernel.org; > mark.rutl...@arm.com; shawn...@kernel.org; Leo Li > ; kis...@ti.com; lorenzo.pieral...@arm.com; M.h. Lian > ; Mingkai Hu ; Roy Zang > ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Cc: a...@arndb.de; gre...@linuxfoundation.org; Xiaowei Bao > > Subject: RE: [PATCH v3 00/11] *** SUBJECT HERE *** > > Xiaowei, > > > -Original Message- > > From: Xiaowei Bao > > Sent: 2019年9月2日 11:17 > > To: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; > Leo > > Li ; kis...@ti.com; lorenzo.pieral...@arm.com; > > M.h. Lian ; Mingkai Hu ; > > Roy Zang ; jingooh...@gmail.com; > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > > Cc: a...@arndb.de; gre...@linuxfoundation.org; Z.q. Hou > > ; Xiaowei Bao > > Subject: [PATCH v3 00/11] *** SUBJECT HERE *** > > > > *** BLURB HERE *** > > Add subject and blurb for this series. OK, thanks. > > Thanks, > Zhiqiang > > > > > Xiaowei Bao (11): > > PCI: designware-ep: Add multiple PFs support for DWC > > PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode > > PCI: designware-ep: Move the function of getting MSI capability > > forward > > PCI: designware-ep: Modify MSI and MSIX CAP way of finding > > dt-bindings: pci: layerscape-pci: add compatible strings for ls1088a > > and ls2088a > > PCI: layerscape: Fix some format issue of the code > > PCI: layerscape: Modify the way of getting capability with different > > PEX > > PCI: layerscape: Modify the MSIX to the doorbell mode > > PCI: layerscape: Add EP mode support for ls1088a and ls2088a > > arm64: dts: layerscape: Add PCIe EP node for ls1088a > > misc: pci_endpoint_test: Add LS1088a in pci_device_id table > > > > .../devicetree/bindings/pci/layerscape-pci.txt | 4 +- > > arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 +++ > > drivers/misc/pci_endpoint_test.c | 1 + > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 100 ++-- > > drivers/pci/controller/dwc/pcie-designware-ep.c| 255 > > + > > drivers/pci/controller/dwc/pcie-designware.c | 59 +++-- > > drivers/pci/controller/dwc/pcie-designware.h | 48 +++- > > 7 files changed, 404 insertions(+), 94 deletions(-) > > > > -- > > 2.9.5
[PATCH v6 3/3] PCI: layerscape: Add LS1028a support
Add support for the LS1028a PCIe controller. Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang --- v2: - No change. v3: - Reuse the ls2088 driver data structurt. v4: - No change. v5: - No change. v6: - No change. drivers/pci/controller/dwc/pci-layerscape.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index 3a5fa26..f24f79a 100644 --- a/drivers/pci/controller/dwc/pci-layerscape.c +++ b/drivers/pci/controller/dwc/pci-layerscape.c @@ -263,6 +263,7 @@ static const struct ls_pcie_drvdata ls2088_drvdata = { static const struct of_device_id ls_pcie_of_match[] = { { .compatible = "fsl,ls1012a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1021a-pcie", .data = _drvdata }, + { .compatible = "fsl,ls1028a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1043a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1046a-pcie", .data = _drvdata }, { .compatible = "fsl,ls2080a-pcie", .data = _drvdata }, -- 2.9.5
[PATCH v6 2/3] arm64: dts: ls1028a: Add PCIe controller DT nodes
LS1028a implements 2 PCIe 3.0 controllers. Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang --- v2: - Fix up the legacy INTx allocate failed issue. v3: - No change. v4: - Remove the num-lanes property. v5: - Add the num-viewport property. v6: - move num-viewport to 8. arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 52 ++ 1 file changed, 52 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi index 72b9a75..c043b1d 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi @@ -625,6 +625,58 @@ }; }; + pcie@340 { + compatible = "fsl,ls1028a-pcie"; + reg = <0x00 0x0340 0x0 0x0010 /* controller registers */ + 0x80 0x 0x0 0x2000>; /* configuration space */ + reg-names = "regs", "config"; + interrupts = , /* PME interrupt */ +; /* aer interrupt */ + interrupt-names = "pme", "aer"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + dma-coherent; + num-viewport = <8>; + bus-range = <0x0 0xff>; + ranges = <0x8100 0x0 0x 0x80 0x0001 0x0 0x0001 /* downstream I/O */ + 0x8200 0x0 0x4000 0x80 0x4000 0x0 0x4000>; /* non-prefetchable memory */ + msi-parent = <>; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = < 0 0 1 0 0 GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 2 0 0 GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 3 0 0 GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 4 0 0 GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + + pcie@350 { + compatible = "fsl,ls1028a-pcie"; + reg = <0x00 0x0350 0x0 0x0010 /* controller registers */ + 0x88 0x 0x0 0x2000>; /* configuration space */ + reg-names = "regs", "config"; + interrupts = , +; + interrupt-names = "pme", "aer"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + dma-coherent; + num-viewport = <8>; + bus-range = <0x0 0xff>; + ranges = <0x8100 0x0 0x 0x88 0x0001 0x0 0x0001 /* downstream I/O */ + 0x8200 0x0 0x4000 0x88 0x4000 0x0 0x4000>; /* non-prefetchable memory */ + msi-parent = <>; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = < 0 0 1 0 0 GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 2 0 0 GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 3 0 0 GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 4 0 0 GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + pcie@1f000 { /* Integrated Endpoint Root Complex */ compatible = "pci-host-ecam-generic"; reg = <0x01 0xf000 0x0 0x10>; -- 2.9.5
[PATCH v6 1/3] dt-bindings: pci: layerscape-pci: add compatible strings "fsl, ls1028a-pcie"
Add the PCIe compatible string for LS1028A Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang Reviewed-by: Rob Herring --- v2: - No change. v3: - No change. v4: - No change. v5: - No change. v6: - No change. Documentation/devicetree/bindings/pci/layerscape-pci.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt b/Documentation/devicetree/bindings/pci/layerscape-pci.txt index e20ceaa..99a386e 100644 --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt @@ -21,6 +21,7 @@ Required properties: "fsl,ls1046a-pcie" "fsl,ls1043a-pcie" "fsl,ls1012a-pcie" +"fsl,ls1028a-pcie" EP mode: "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" - reg: base addresses and lengths of the PCIe controller register blocks. -- 2.9.5
[PATCH v3 11/11] misc: pci_endpoint_test: Add LS1088a in pci_device_id table
Add LS1088a in pci_device_id table so that pci-epf-test can be used for testing PCIe EP in LS1088a. Signed-off-by: Xiaowei Bao --- v2: - No change. v3: - No change. drivers/misc/pci_endpoint_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 6e208a0..d531951 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -793,6 +793,7 @@ static const struct pci_device_id pci_endpoint_test_tbl[] = { { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x80c0) }, { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), .driver_data = (kernel_ulong_t)_data -- 2.9.5
[PATCH v3 10/11] arm64: dts: layerscape: Add PCIe EP node for ls1088a
Add PCIe EP node for ls1088a to support EP mode. Signed-off-by: Xiaowei Bao --- v2: - Remove the pf-offset proparty. v3: - No change. arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 ++ 1 file changed, 31 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi index c676d07..da246ab 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi @@ -483,6 +483,17 @@ status = "disabled"; }; + pcie_ep@340 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0340 0x0 0x0010 + 0x20 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <24>; + num-ob-windows = <128>; + max-functions = /bits/ 8 <2>; + status = "disabled"; + }; + pcie@350 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0350 0x0 0x0010 /* controller registers */ @@ -508,6 +519,16 @@ status = "disabled"; }; + pcie_ep@350 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0350 0x0 0x0010 + 0x28 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + pcie@360 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0360 0x0 0x0010 /* controller registers */ @@ -533,6 +554,16 @@ status = "disabled"; }; + pcie_ep@360 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0360 0x0 0x0010 + 0x30 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + smmu: iommu@500 { compatible = "arm,mmu-500"; reg = <0 0x500 0 0x80>; -- 2.9.5
[PATCH v3 09/11] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
Add PCIe EP mode support for ls1088a and ls2088a, there are some difference between LS1 and LS2 platform, so refactor the code of the EP driver. Signed-off-by: Xiaowei Bao --- v2: - This is a new patch for supporting the ls1088a and ls2088a platform. v3: - Adjust the some struct assignment order in probe function. drivers/pci/controller/dwc/pci-layerscape-ep.c | 72 +++--- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 5f0cb99..723bbe5 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -20,27 +20,29 @@ #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ -struct ls_pcie_ep { - struct dw_pcie *pci; - struct pci_epc_features *ls_epc; +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) + +struct ls_pcie_ep_drvdata { + u32 func_offset; + const struct dw_pcie_ep_ops *ops; + const struct dw_pcie_ops*dw_pcie_ops; }; -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) +struct ls_pcie_ep { + struct dw_pcie *pci; + struct pci_epc_features *ls_epc; + const struct ls_pcie_ep_drvdata *drvdata; +}; static int ls_pcie_establish_link(struct dw_pcie *pci) { return 0; } -static const struct dw_pcie_ops ls_pcie_ep_ops = { +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { .start_link = ls_pcie_establish_link, }; -static const struct of_device_id ls_pcie_ep_of_match[] = { - { .compatible = "fsl,ls-pcie-ep",}, - { }, -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { @@ -87,10 +89,39 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, } } -static const struct dw_pcie_ep_ops pcie_ep_ops = { +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep, + u8 func_no) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + WARN_ON(func_no && !pcie->drvdata->func_offset); + return pcie->drvdata->func_offset * func_no; +} + +static const struct dw_pcie_ep_ops ls_pcie_ep_ops = { .ep_init = ls_pcie_ep_init, .raise_irq = ls_pcie_ep_raise_irq, .get_features = ls_pcie_ep_get_features, + .func_conf_select = ls_pcie_ep_func_conf_select, +}; + +static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = { + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct ls_pcie_ep_drvdata ls2_ep_drvdata = { + .func_offset = 0x2, + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct of_device_id ls_pcie_ep_of_match[] = { + { .compatible = "fsl,ls1046a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls1088a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls2088a-pcie-ep", .data = _ep_drvdata }, + { }, }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, @@ -103,7 +134,7 @@ static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, int ret; ep = >ep; - ep->ops = _ep_ops; + ep->ops = pcie->drvdata->ops; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); if (!res) @@ -142,20 +173,23 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!ls_epc) return -ENOMEM; - dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); - if (IS_ERR(pci->dbi_base)) - return PTR_ERR(pci->dbi_base); + pcie->drvdata = of_device_get_match_data(dev); - pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; pci->dev = dev; - pci->ops = _pcie_ep_ops; - pcie->pci = pci; + pci->ops = pcie->drvdata->dw_pcie_ops; ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + pcie->pci = pci; pcie->ls_epc = ls_epc; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); + pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); + if (IS_ERR(pci->dbi_base)) + return PTR_ERR(pci->dbi_base); + + pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v3 08/11] PCI: layerscape: Modify the MSIX to the doorbell mode
dw_pcie_ep_raise_msix_irq was never called in the exisitng driver before, because the ls1046a platform don't support the MSIX feature and msix_capable was always set to false. Now that add the ls1088a platform with MSIX support, but the existing dw_pcie_ep_raise_msix_irq doesn't work, so use the doorbell method to support the MSIX feature. Signed-off-by: Xiaowei Bao --- v2: - No change v3: - Modify the commit message make it clearly. drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 1e07287..5f0cb99 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -79,7 +79,8 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, case PCI_EPC_IRQ_MSI: return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); case PCI_EPC_IRQ_MSIX: - return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num); + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, + interrupt_num); default: dev_err(pci->dev, "UNKNOWN IRQ type\n"); return -EINVAL; -- 2.9.5
[PATCH v3 07/11] PCI: layerscape: Modify the way of getting capability with different PEX
The different PCIe controller in one board may be have different capability of MSI or MSIX, so change the way of getting the MSI capability, make it more flexible. Signed-off-by: Xiaowei Bao --- v2: - Remove the repeated assignment code. v3: - Use ep_func msi_cap and msix_cap to decide the msi_capable and msix_capable of pci_epc_features struct. drivers/pci/controller/dwc/pci-layerscape-ep.c | 31 +++--- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index a9c552e..1e07287 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -22,6 +22,7 @@ struct ls_pcie_ep { struct dw_pcie *pci; + struct pci_epc_features *ls_epc; }; #define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) @@ -40,26 +41,31 @@ static const struct of_device_id ls_pcie_ep_of_match[] = { { }, }; -static const struct pci_epc_features ls_pcie_epc_features = { - .linkup_notifier = false, - .msi_capable = true, - .msix_capable = false, - .bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { - return _pcie_epc_features; + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + return pcie->ls_epc; } static void ls_pcie_ep_init(struct dw_pcie_ep *ep) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + struct dw_pcie_ep_func *ep_func; enum pci_barno bar; + ep_func = dw_pcie_ep_get_func_from_ep(ep, 0); + if (!ep_func) + return; + for (bar = BAR_0; bar <= BAR_5; bar++) dw_pcie_ep_reset_bar(pci, bar); + + pcie->ls_epc->msi_capable = ep_func->msi_cap ? true : false; + pcie->ls_epc->msix_capable = ep_func->msix_cap ? true : false; } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, @@ -119,6 +125,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) struct device *dev = >dev; struct dw_pcie *pci; struct ls_pcie_ep *pcie; + struct pci_epc_features *ls_epc; struct resource *dbi_base; int ret; @@ -130,6 +137,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!pci) return -ENOMEM; + ls_epc = devm_kzalloc(dev, sizeof(*ls_epc), GFP_KERNEL); + if (!ls_epc) + return -ENOMEM; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); if (IS_ERR(pci->dbi_base)) @@ -140,6 +151,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) pci->ops = _pcie_ep_ops; pcie->pci = pci; + ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + + pcie->ls_epc = ls_epc; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v3 06/11] PCI: layerscape: Fix some format issue of the code
Fix some format issue of the code in EP driver. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index ca9aa45..a9c552e 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -63,7 +63,7 @@ static void ls_pcie_ep_init(struct dw_pcie_ep *ep) } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, - enum pci_epc_irq_type type, u16 interrupt_num) + enum pci_epc_irq_type type, u16 interrupt_num) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); @@ -87,7 +87,7 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = { }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, - struct platform_device *pdev) +struct platform_device *pdev) { struct dw_pcie *pci = pcie->pci; struct device *dev = pci->dev; -- 2.9.5
[PATCH v3 05/11] dt-bindings: pci: layerscape-pci: add compatible strings for ls1088a and ls2088a
Add compatible strings for ls1088a and ls2088a. Signed-off-by: Xiaowei Bao --- v2: - No change. v3: - Use one valid combination of compatible strings. Documentation/devicetree/bindings/pci/layerscape-pci.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt b/Documentation/devicetree/bindings/pci/layerscape-pci.txt index e20ceaa..762ae41 100644 --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt @@ -22,7 +22,9 @@ Required properties: "fsl,ls1043a-pcie" "fsl,ls1012a-pcie" EP mode: - "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" + "fsl,ls1046a-pcie-ep" "fsl,ls-pcie-ep" + "fsl,ls1088a-pcie-ep" "fsl,ls-pcie-ep" + "fsl,ls2088a-pcie-ep" "fsl,ls-pcie-ep" - reg: base addresses and lengths of the PCIe controller register blocks. - interrupts: A list of interrupt outputs of the controller. Must contain an entry for each entry in the interrupt-names property. -- 2.9.5
[PATCH v3 04/11] PCI: designware-ep: Modify MSI and MSIX CAP way of finding
Each PF of EP device should have it's own MSI or MSIX capabitily struct, so create a dw_pcie_ep_func struct and remover the msi_cap and msix_cap to this struce, and manage the PFs with a list. Signed-off-by: Xiaowei Bao --- v1: - This is a new patch, to fix the issue of MSI and MSIX CAP way of finding. v2: - No change. v3: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 135 +--- drivers/pci/controller/dwc/pcie-designware.h| 18 +++- 2 files changed, 134 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index c3bc7bd..144eb12 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -19,6 +19,19 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) pci_epc_linkup(epc); } +struct dw_pcie_ep_func * +dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no) +{ + struct dw_pcie_ep_func *ep_func; + + list_for_each_entry(ep_func, >func_list, list) { + if (ep_func->func_no == func_no) + return ep_func; + } + + return NULL; +} + static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no) { unsigned int func_offset = 0; @@ -59,6 +72,47 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } +static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no, + u8 cap_ptr, u8 cap) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + u8 cap_id, next_cap_ptr; + u16 reg; + + if (!cap_ptr) + return 0; + + func_offset = dw_pcie_ep_func_select(ep, func_no); + + reg = dw_pcie_readw_dbi(pci, func_offset + cap_ptr); + cap_id = (reg & 0x00ff); + + if (cap_id > PCI_CAP_ID_MAX) + return 0; + + if (cap_id == cap) + return cap_ptr; + + next_cap_ptr = (reg & 0xff00) >> 8; + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); +} + +static u8 dw_pcie_ep_find_capability(struct dw_pcie_ep *ep, u8 func_no, u8 cap) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + u8 next_cap_ptr; + u16 reg; + + func_offset = dw_pcie_ep_func_select(ep, func_no); + + reg = dw_pcie_readw_dbi(pci, func_offset + PCI_CAPABILITY_LIST); + next_cap_ptr = (reg & 0x00ff); + + return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap); +} + static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, struct pci_epf_header *hdr) { @@ -246,13 +300,18 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; - if (!ep->msi_cap) + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; + + if (!ep_func->msi_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS; + reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS; val = dw_pcie_readw_dbi(pci, reg); if (!(val & PCI_MSI_FLAGS_ENABLE)) return -EINVAL; @@ -268,13 +327,18 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; + + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; - if (!ep->msi_cap) + if (!ep_func->msi_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS; + reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS; val = dw_pcie_readw_dbi(pci, reg); val &= ~PCI_MSI_FLAGS_QMASK; val |= (interrupts << 1) & PCI_MSI_FLAGS_QMASK; @@ -291,13 +355,18 @@ static int dw_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 val, reg; unsigned int func_offset = 0; + struct dw_pcie_ep_func *ep_func; + + ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no); + if (!ep_func) + return -EINVAL; - if (!ep->msix_cap) + if (!ep_func->msix_cap) return -EINVAL; func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = ep->msix_cap + func_offset + PCI_MSIX_FLAG
[PATCH v3 03/11] PCI: designware-ep: Move the function of getting MSI capability forward
Move the function of getting MSI capability to the front of init function, because the init function of the EP platform driver will use the return value by the function of getting MSI capability. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - No change. v3: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 55b23ce..c3bc7bd 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -624,6 +624,10 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) if (ret < 0) epc->max_functions = 1; + ep->msi_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); + + ep->msix_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSIX); + if (ep->ops->ep_init) ep->ops->ep_init(ep); @@ -640,9 +644,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) dev_err(dev, "Failed to reserve memory for MSI/MSI-X\n"); return -ENOMEM; } - ep->msi_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); - - ep->msix_cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSIX); offset = dw_pcie_ep_find_ext_capability(pci, PCI_EXT_CAP_ID_REBAR); if (offset) { -- 2.9.5
[PATCH v3 01/11] PCI: designware-ep: Add multiple PFs support for DWC
Add multiple PFs support for DWC, different PF have different config space we use pf-offset property which get from the DTS to access the different pF config space. Signed-off-by: Xiaowei Bao --- v2: - Remove duplicate redundant code. - Reimplement the PF config space access way. v3: - Integrate duplicate code for func_select. - Move PCIE_ATU_FUNC_NUM(pf) (pf << 20) to ((pf) << 20). - Add the comments for func_conf_select function. drivers/pci/controller/dwc/pcie-designware-ep.c | 123 drivers/pci/controller/dwc/pcie-designware.c| 59 drivers/pci/controller/dwc/pcie-designware.h| 18 +++- 3 files changed, 142 insertions(+), 58 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 65f4792..eb851c2 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -19,12 +19,26 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) pci_epc_linkup(epc); } -static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar, - int flags) +static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no) +{ + unsigned int func_offset = 0; + + if (ep->ops->func_conf_select) + func_offset = ep->ops->func_conf_select(ep, func_no); + + return func_offset; +} + +static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no, + enum pci_barno bar, int flags) { u32 reg; + unsigned int func_offset = 0; + struct dw_pcie_ep *ep = >ep; + + func_offset = dw_pcie_ep_func_select(ep, func_no); - reg = PCI_BASE_ADDRESS_0 + (4 * bar); + reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar); dw_pcie_dbi_ro_wr_en(pci); dw_pcie_writel_dbi2(pci, reg, 0x0); dw_pcie_writel_dbi(pci, reg, 0x0); @@ -37,7 +51,12 @@ static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar, void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { - __dw_pcie_ep_reset_bar(pci, bar, 0); + u8 func_no, funcs; + + funcs = pci->ep.epc->max_functions; + + for (func_no = 0; func_no < funcs; func_no++) + __dw_pcie_ep_reset_bar(pci, func_no, bar, 0); } static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, @@ -45,28 +64,31 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, { struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + unsigned int func_offset = 0; + + func_offset = dw_pcie_ep_func_select(ep, func_no); dw_pcie_dbi_ro_wr_en(pci); - dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, hdr->vendorid); - dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, hdr->deviceid); - dw_pcie_writeb_dbi(pci, PCI_REVISION_ID, hdr->revid); - dw_pcie_writeb_dbi(pci, PCI_CLASS_PROG, hdr->progif_code); - dw_pcie_writew_dbi(pci, PCI_CLASS_DEVICE, + dw_pcie_writew_dbi(pci, func_offset + PCI_VENDOR_ID, hdr->vendorid); + dw_pcie_writew_dbi(pci, func_offset + PCI_DEVICE_ID, hdr->deviceid); + dw_pcie_writeb_dbi(pci, func_offset + PCI_REVISION_ID, hdr->revid); + dw_pcie_writeb_dbi(pci, func_offset + PCI_CLASS_PROG, hdr->progif_code); + dw_pcie_writew_dbi(pci, func_offset + PCI_CLASS_DEVICE, hdr->subclass_code | hdr->baseclass_code << 8); - dw_pcie_writeb_dbi(pci, PCI_CACHE_LINE_SIZE, + dw_pcie_writeb_dbi(pci, func_offset + PCI_CACHE_LINE_SIZE, hdr->cache_line_size); - dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_VENDOR_ID, + dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_VENDOR_ID, hdr->subsys_vendor_id); - dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_ID, hdr->subsys_id); - dw_pcie_writeb_dbi(pci, PCI_INTERRUPT_PIN, + dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_ID, hdr->subsys_id); + dw_pcie_writeb_dbi(pci, func_offset + PCI_INTERRUPT_PIN, hdr->interrupt_pin); dw_pcie_dbi_ro_wr_dis(pci); return 0; } -static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar, - dma_addr_t cpu_addr, +static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no, + enum pci_barno bar, dma_addr_t cpu_addr, enum dw_pcie_as_type as_type) { int ret; @@ -79,7 +101,7 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar, return -EINVAL; } - ret = dw_pcie_prog_inbound_atu(pci, free_win, bar, cpu_addr, + ret = dw_pcie_prog_inbound_atu(pci, func_no, free_w
[PATCH v3 02/11] PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode
Add the doorbell mode of MSI-X in EP mode. Signed-off-by: Xiaowei Bao Reviewed-by: Andrew Murray --- v2: - Remove the macro of no used. v3: - No change. drivers/pci/controller/dwc/pcie-designware-ep.c | 14 ++ drivers/pci/controller/dwc/pcie-designware.h| 12 2 files changed, 26 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index eb851c2..55b23ce 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -449,6 +449,20 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no, + u16 interrupt_num) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + u32 msg_data; + + msg_data = (func_no << PCIE_MSIX_DOORBELL_PF_SHIFT) | + (interrupt_num - 1); + + dw_pcie_writel_dbi(pci, PCIE_MSIX_DOORBELL, msg_data); + + return 0; +} + int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, u16 interrupt_num) { diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 6aca0bb..56789be 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -88,6 +88,9 @@ #define PCIE_MISC_CONTROL_1_OFF0x8BC #define PCIE_DBI_RO_WR_EN BIT(0) +#define PCIE_MSIX_DOORBELL 0x948 +#define PCIE_MSIX_DOORBELL_PF_SHIFT24 + #define PCIE_PL_CHK_REG_CONTROL_STATUS 0xB20 #define PCIE_PL_CHK_REG_CHK_REG_START BIT(0) #define PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS BIT(1) @@ -419,6 +422,8 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, u8 interrupt_num); int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, u16 interrupt_num); +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no, + u16 interrupt_num); void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar); #else static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) @@ -451,6 +456,13 @@ static inline int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +static inline int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, +u8 func_no, +u16 interrupt_num) +{ + return 0; +} + static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { } -- 2.9.5
[PATCH v3 00/11] *** SUBJECT HERE ***
*** BLURB HERE *** Xiaowei Bao (11): PCI: designware-ep: Add multiple PFs support for DWC PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode PCI: designware-ep: Move the function of getting MSI capability forward PCI: designware-ep: Modify MSI and MSIX CAP way of finding dt-bindings: pci: layerscape-pci: add compatible strings for ls1088a and ls2088a PCI: layerscape: Fix some format issue of the code PCI: layerscape: Modify the way of getting capability with different PEX PCI: layerscape: Modify the MSIX to the doorbell mode PCI: layerscape: Add EP mode support for ls1088a and ls2088a arm64: dts: layerscape: Add PCIe EP node for ls1088a misc: pci_endpoint_test: Add LS1088a in pci_device_id table .../devicetree/bindings/pci/layerscape-pci.txt | 4 +- arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 +++ drivers/misc/pci_endpoint_test.c | 1 + drivers/pci/controller/dwc/pci-layerscape-ep.c | 100 ++-- drivers/pci/controller/dwc/pcie-designware-ep.c| 255 + drivers/pci/controller/dwc/pcie-designware.c | 59 +++-- drivers/pci/controller/dwc/pcie-designware.h | 48 +++- 7 files changed, 404 insertions(+), 94 deletions(-) -- 2.9.5
[PATCH v5 1/3] dt-bindings: pci: layerscape-pci: add compatible strings "fsl, ls1028a-pcie"
Add the PCIe compatible string for LS1028A Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang Reviewed-by: Rob Herring --- v2: - No change. v3: - No change. v4: - No change. v5: - No change. Documentation/devicetree/bindings/pci/layerscape-pci.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt b/Documentation/devicetree/bindings/pci/layerscape-pci.txt index e20ceaa..99a386e 100644 --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt @@ -21,6 +21,7 @@ Required properties: "fsl,ls1046a-pcie" "fsl,ls1043a-pcie" "fsl,ls1012a-pcie" +"fsl,ls1028a-pcie" EP mode: "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" - reg: base addresses and lengths of the PCIe controller register blocks. -- 2.9.5
[PATCH v5 2/3] arm64: dts: ls1028a: Add PCIe controller DT nodes
LS1028a implements 2 PCIe 3.0 controllers. Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang --- v2: - Fix up the legacy INTx allocate failed issue. v3: - No change. v4: - Remove the num-lanes property. v5: - Add the num-viewport property. arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 52 ++ 1 file changed, 52 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi index 72b9a75..c043b1d 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi @@ -625,6 +625,58 @@ }; }; + pcie@340 { + compatible = "fsl,ls1028a-pcie"; + reg = <0x00 0x0340 0x0 0x0010 /* controller registers */ + 0x80 0x 0x0 0x2000>; /* configuration space */ + reg-names = "regs", "config"; + interrupts = , /* PME interrupt */ +; /* aer interrupt */ + interrupt-names = "pme", "aer"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + dma-coherent; + num-viewport = <6>; + bus-range = <0x0 0xff>; + ranges = <0x8100 0x0 0x 0x80 0x0001 0x0 0x0001 /* downstream I/O */ + 0x8200 0x0 0x4000 0x80 0x4000 0x0 0x4000>; /* non-prefetchable memory */ + msi-parent = <>; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = < 0 0 1 0 0 GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 2 0 0 GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 3 0 0 GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 4 0 0 GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + + pcie@350 { + compatible = "fsl,ls1028a-pcie"; + reg = <0x00 0x0350 0x0 0x0010 /* controller registers */ + 0x88 0x 0x0 0x2000>; /* configuration space */ + reg-names = "regs", "config"; + interrupts = , +; + interrupt-names = "pme", "aer"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + dma-coherent; + num-viewport = <6>; + bus-range = <0x0 0xff>; + ranges = <0x8100 0x0 0x 0x88 0x0001 0x0 0x0001 /* downstream I/O */ + 0x8200 0x0 0x4000 0x88 0x4000 0x0 0x4000>; /* non-prefetchable memory */ + msi-parent = <>; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = < 0 0 1 0 0 GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 2 0 0 GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 3 0 0 GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 4 0 0 GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + pcie@1f000 { /* Integrated Endpoint Root Complex */ compatible = "pci-host-ecam-generic"; reg = <0x01 0xf000 0x0 0x10>; -- 2.9.5
[PATCH v5 3/3] PCI: layerscape: Add LS1028a support
Add support for the LS1028a PCIe controller. Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang --- v2: - No change. v3: - Reuse the ls2088 driver data structurt. v4: - No change. v5: - No change. drivers/pci/controller/dwc/pci-layerscape.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index 3a5fa26..f24f79a 100644 --- a/drivers/pci/controller/dwc/pci-layerscape.c +++ b/drivers/pci/controller/dwc/pci-layerscape.c @@ -263,6 +263,7 @@ static const struct ls_pcie_drvdata ls2088_drvdata = { static const struct of_device_id ls_pcie_of_match[] = { { .compatible = "fsl,ls1012a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1021a-pcie", .data = _drvdata }, + { .compatible = "fsl,ls1028a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1043a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1046a-pcie", .data = _drvdata }, { .compatible = "fsl,ls2080a-pcie", .data = _drvdata }, -- 2.9.5
RE: [PATCH v2 04/10] dt-bindings: pci: layerscape-pci: add compatible strings for ls1088a and ls2088a
> -Original Message- > From: Rob Herring > Sent: 2019年8月28日 6:26 > To: Xiaowei Bao > Cc: bhelg...@google.com; mark.rutl...@arm.com; shawn...@kernel.org; > Leo Li ; kis...@ti.com; lorenzo.pieral...@arm.co; > a...@arndb.de; gre...@linuxfoundation.org; M.h. Lian > ; Mingkai Hu ; Roy Zang > ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > andrew.mur...@arm.com > Subject: Re: [PATCH v2 04/10] dt-bindings: pci: layerscape-pci: add compatible > strings for ls1088a and ls2088a > > On Thu, Aug 22, 2019 at 07:22:36PM +0800, Xiaowei Bao wrote: > > Add compatible strings for ls1088a and ls2088a. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - No change. > > > > Documentation/devicetree/bindings/pci/layerscape-pci.txt | 5 - > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > b/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > index e20ceaa..16f592e 100644 > > --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > @@ -22,7 +22,10 @@ Required properties: > > "fsl,ls1043a-pcie" > > "fsl,ls1012a-pcie" > >EP mode: > > - "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" > > + "fsl,ls-pcie-ep" > > Wasn't this a fallback? Each line should be one valid combination of > compatible strings. Thanks, got it, I will modify it in next version patch. Thanks Xiaowei > > > + "fsl,ls1046a-pcie-ep" > > + "fsl,ls1088a-pcie-ep" > > + "fsl,ls2088a-pcie-ep" > > - reg: base addresses and lengths of the PCIe controller register blocks. > > - interrupts: A list of interrupt outputs of the controller. Must contain > > an > >entry for each entry in the interrupt-names property. > > -- > > 2.9.5 > >
RE: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年8月28日 17:01 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > On Wed, Aug 28, 2019 at 04:29:32AM +, Xiaowei Bao wrote: > > > > > > > -Original Message----- > > > From: Andrew Murray > > > Sent: 2019年8月27日 21:34 > > > To: Xiaowei Bao > > > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > > > shawn...@kernel.org; Leo Li ; kis...@ti.com; > > > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; > M.h. > > > Lian ; Mingkai Hu ; Roy > > > Zang ; jingooh...@gmail.com; > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > > > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support > > > for ls1088a and ls2088a > > > > > > On Mon, Aug 26, 2019 at 09:49:35AM +, Xiaowei Bao wrote: > > > > > > > > > > > > > -Original Message- > > > > > From: Andrew Murray > > > > > Sent: 2019年8月23日 22:28 > > > > > To: Xiaowei Bao > > > > > Cc: bhelg...@google.com; robh...@kernel.org; > > > > > mark.rutl...@arm.com; shawn...@kernel.org; Leo Li > > > > > ; kis...@ti.com; lorenzo.pieral...@arm.co; > > > > > a...@arndb.de; gre...@linuxfoundation.org; > > > M.h. > > > > > Lian ; Mingkai Hu ; > > > > > Roy Zang ; jingooh...@gmail.com; > > > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > > > linux-arm-ker...@lists.infradead.org; > > > > > linuxppc-dev@lists.ozlabs.org > > > > > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode > > > > > support for ls1088a and ls2088a > > > > > > > > > > On Thu, Aug 22, 2019 at 07:22:40PM +0800, Xiaowei Bao wrote: > > > > > > Add PCIe EP mode support for ls1088a and ls2088a, there are > > > > > > some difference between LS1 and LS2 platform, so refactor the > > > > > > code of the EP driver. > > > > > > > > > > > > Signed-off-by: Xiaowei Bao > > > > > > --- > > > > > > v2: > > > > > > - New mechanism for layerscape EP driver. > > > > > > > > > > Was there a v1 of this patch? > > > > > > > > > > > > > > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 76 > > > > > > -- > > > > > > 1 file changed, 58 insertions(+), 18 deletions(-) > > > > > > > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > > > index 7ca5fe8..2a66f07 100644 > > > > > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > > > @@ -20,27 +20,29 @@ > > > > > > > > > > > > #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ > > > > > > > > > > > > -struct ls_pcie_ep { > > > > > > - struct dw_pcie *pci; > > > > > > - struct pci_epc_features *ls_epc; > > > > > > +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > > > > > + > > > > > > +struct ls_pcie_ep_drvdata { > > > > > > + u32 func_offset; > > > > > > + const struct dw_pcie_ep_ops *ops; > > > > > > + const struct dw_pcie_ops*dw_pcie_ops; > > > > > > }; > > > > > > > > > > > > -#define to_ls_
RE: [PATCH v2 01/10] PCI: designware-ep: Add multiple PFs support for DWC
> -Original Message- > From: Andrew Murray > Sent: 2019年8月27日 21:11 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 01/10] PCI: designware-ep: Add multiple PFs support > for DWC > > On Fri, Aug 23, 2019 at 11:50:20PM +, Xiaowei Bao wrote: > > > > > > > -Original Message----- > > > From: Andrew Murray > > > Sent: 2019年8月23日 21:25 > > > To: Xiaowei Bao > > > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > > > shawn...@kernel.org; Leo Li ; kis...@ti.com; > > > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; > M.h. > > > Lian ; Mingkai Hu ; Roy > > > Zang ; jingooh...@gmail.com; > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > > > Subject: Re: [PATCH v2 01/10] PCI: designware-ep: Add multiple PFs > > > support for DWC > > > > > > On Thu, Aug 22, 2019 at 07:22:33PM +0800, Xiaowei Bao wrote: > > > > Add multiple PFs support for DWC, different PF have different > > > > config space we use pf-offset property which get from the DTS to > > > > access the different pF config space. > > > > > > It looks like you're missing a --cover-letter again. > > > > > > > > > > > Signed-off-by: Xiaowei Bao > > > > --- > > > > v2: > > > > - Remove duplicate redundant code. > > > > - Reimplement the PF config space access way. > > > > > > > > drivers/pci/controller/dwc/pcie-designware-ep.c | 122 > > > > > > > drivers/pci/controller/dwc/pcie-designware.c| 59 > > > > > drivers/pci/controller/dwc/pcie-designware.h| 11 ++- > > > > 3 files changed, 134 insertions(+), 58 deletions(-) > > > > > > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c > > > > b/drivers/pci/controller/dwc/pcie-designware-ep.c > > > > index 2bf5a35..3e2b740 100644 > > > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > > > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > > > > @@ -19,12 +19,17 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep > *ep) > > > > pci_epc_linkup(epc); > > > > } > > > > > > > > -static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum > > > > pci_barno > > > bar, > > > > - int flags) > > > > +static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no, > > > > + enum pci_barno bar, int flags) > > > > { > > > > u32 reg; > > > > + unsigned int func_offset = 0; > > > > + struct dw_pcie_ep *ep = >ep; > > > > > > > > - reg = PCI_BASE_ADDRESS_0 + (4 * bar); > > > > + if (ep->ops->func_conf_select) > > > > + func_offset = ep->ops->func_conf_select(ep, func_no); > > > > + > > > > + reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar); > > > > > > This pattern of checking if func_conf_select exists and using it to > > > get an offset is repeated a lot throughout this file. You could move > > > this functionality into a new function (similar to dw_pcie_read_dbi > > > etc). Or perhaps a new variant of dw_pcie_writel_ should be created that > writes takes a func_no argument. > > > > Thanks for your comments, I thought about this method before, but > > there is a issue about the method of access the different func config > > space, due to our platform use this method that different func have > > different offset from dbi_base to access the different config space, > > but others platform maybe use the way that write a register to > > implement different func config space access, so I think reserve a > > callback function > > My point here was really to move out duplic
RE: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年8月27日 21:34 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > On Mon, Aug 26, 2019 at 09:49:35AM +, Xiaowei Bao wrote: > > > > > > > -Original Message----- > > > From: Andrew Murray > > > Sent: 2019年8月23日 22:28 > > > To: Xiaowei Bao > > > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > > > shawn...@kernel.org; Leo Li ; kis...@ti.com; > > > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; > M.h. > > > Lian ; Mingkai Hu ; Roy > > > Zang ; jingooh...@gmail.com; > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > > > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support > > > for ls1088a and ls2088a > > > > > > On Thu, Aug 22, 2019 at 07:22:40PM +0800, Xiaowei Bao wrote: > > > > Add PCIe EP mode support for ls1088a and ls2088a, there are some > > > > difference between LS1 and LS2 platform, so refactor the code of > > > > the EP driver. > > > > > > > > Signed-off-by: Xiaowei Bao > > > > --- > > > > v2: > > > > - New mechanism for layerscape EP driver. > > > > > > Was there a v1 of this patch? > > > > > > > > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 76 > > > > -- > > > > 1 file changed, 58 insertions(+), 18 deletions(-) > > > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > index 7ca5fe8..2a66f07 100644 > > > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > @@ -20,27 +20,29 @@ > > > > > > > > #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ > > > > > > > > -struct ls_pcie_ep { > > > > - struct dw_pcie *pci; > > > > - struct pci_epc_features *ls_epc; > > > > +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > > > + > > > > +struct ls_pcie_ep_drvdata { > > > > + u32 func_offset; > > > > + const struct dw_pcie_ep_ops *ops; > > > > + const struct dw_pcie_ops*dw_pcie_ops; > > > > }; > > > > > > > > -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > > > +struct ls_pcie_ep { > > > > + struct dw_pcie *pci; > > > > + struct pci_epc_features *ls_epc; > > > > + const struct ls_pcie_ep_drvdata *drvdata; }; > > > > > > > > static int ls_pcie_establish_link(struct dw_pcie *pci) { > > > > return 0; > > > > } > > > > > > > > -static const struct dw_pcie_ops ls_pcie_ep_ops = { > > > > +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { > > > > .start_link = ls_pcie_establish_link, }; > > > > > > > > -static const struct of_device_id ls_pcie_ep_of_match[] = { > > > > - { .compatible = "fsl,ls-pcie-ep",}, > > > > - { }, > > > > -}; > > > > - > > > > static const struct pci_epc_features* > > > > ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { @@ -82,10 +84,44 > > > > @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, > > > > } > > > > } > > > > > > > > -static const struct dw_pcie_ep_ops pcie_ep_ops = { > > > > +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep > *ep, > > > > + u8 func_no) >
RE: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年8月27日 22:49 > To: Xiaowei Bao > Cc: christophe leroy ; mark.rutl...@arm.com; Roy > Zang ; lorenzo.pieral...@arm.co; a...@arndb.de; > devicet...@vger.kernel.org; gre...@linuxfoundation.org; > linuxppc-dev@lists.ozlabs.org; linux-...@vger.kernel.org; > linux-ker...@vger.kernel.org; kis...@ti.com; M.h. Lian > ; robh...@kernel.org; > gustavo.pimen...@synopsys.com; jingooh...@gmail.com; > bhelg...@google.com; Leo Li ; shawn...@kernel.org; > Mingkai Hu ; linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > On Sun, Aug 25, 2019 at 03:07:32AM +, Xiaowei Bao wrote: > > > > > > > -Original Message----- > > > From: christophe leroy > > > Sent: 2019年8月24日 14:45 > > > To: Xiaowei Bao ; Andrew Murray > > > > > > Cc: mark.rutl...@arm.com; Roy Zang ; > > > lorenzo.pieral...@arm.co; a...@arndb.de; devicet...@vger.kernel.org; > > > gre...@linuxfoundation.org; linuxppc-dev@lists.ozlabs.org; > > > linux-...@vger.kernel.org; linux-ker...@vger.kernel.org; kis...@ti.com; > M.h. > > > Lian ; robh...@kernel.org; > > > gustavo.pimen...@synopsys.com; jingooh...@gmail.com; > > > bhelg...@google.com; Leo Li ; > > > shawn...@kernel.org; Mingkai Hu ; > > > linux-arm-ker...@lists.infradead.org > > > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support > > > for ls1088a and ls2088a > > > > > > > > > > > > Le 24/08/2019 à 02:18, Xiaowei Bao a écrit : > > > > > > > > > > > >> -Original Message- > > > >> From: Andrew Murray > > > >> Sent: 2019年8月23日 22:28 > > > >> To: Xiaowei Bao > > > >> Cc: bhelg...@google.com; robh...@kernel.org; > > > >> mark.rutl...@arm.com; shawn...@kernel.org; Leo Li > > > >> ; kis...@ti.com; lorenzo.pieral...@arm.co; > > > >> a...@arndb.de; gre...@linuxfoundation.org; > > > M.h. > > > >> Lian ; Mingkai Hu ; > > > >> Roy Zang ; jingooh...@gmail.com; > > > >> gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > >> devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > >> linux-arm-ker...@lists.infradead.org; > > > >> linuxppc-dev@lists.ozlabs.org > > > >> Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode > > > >> support for ls1088a and ls2088a > > > >> > > > >> On Thu, Aug 22, 2019 at 07:22:40PM +0800, Xiaowei Bao wrote: > > > >>> Add PCIe EP mode support for ls1088a and ls2088a, there are some > > > >>> difference between LS1 and LS2 platform, so refactor the code of > > > >>> the EP driver. > > > >>> > > > >>> Signed-off-by: Xiaowei Bao > > > >>> --- > > > >>> v2: > > > >>> - New mechanism for layerscape EP driver. > > > >> > > > >> Was there a v1 of this patch? > > > > > > > > Yes, but I don't know how to comments, ^_^ > > > > > > As far as I can see, in the previous version of the series > > > (https://patch > > > > work.ozlabs.org%2Fproject%2Flinuxppc-dev%2Flist%2F%3Fseries%3D125315 > > > %26state%3D*data=02%7C01%7Cxiaowei.bao%40nxp.com%7C1b > efe9 > > > > a67c8046f9535e08d7285eaab6%7C686ea1d3bc2b4c6fa92cd99c5c301635% > > > > 7C0%7C0%7C637022259387139020sdata=p4wbycd04Z7qRUfAoZtwc > > > UP7pR%2FuA3%2FjVcWMz6YyQVQ%3Dreserved=0), > > > the 8/10 was something completely different, and I can't find any > > > other patch in the series that could have been the v1 of this patch. > > > > Thanks, I will correct it to v1 in next version patch. > > I think you numbered it correctly (so please leave it as v2, referring to the > patch series revision) - I got confused trying to find a previous version of > this > patch. > > Perhaps in the future when new patches are introduced in a series you can > indicate that in the description patch revision history (e.g. introduced in > v2). OK, thanks for your help, I will update it in the next version patch. Thanks Xiaowei > > Thanks, > > Andrew Murray > > > > > > > > > Christophe > > > > > > > > > > >> > > > >>> > > > >>> drivers/pci/controller/dwc/pci-layerscape-ep.c |
RE: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the doorbell way
> -Original Message- > From: Andrew Murray > Sent: 2019年8月27日 21:25 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the > doorbell way > > On Sat, Aug 24, 2019 at 12:08:40AM +, Xiaowei Bao wrote: > > > > > > > -Original Message----- > > > From: Andrew Murray > > > Sent: 2019年8月23日 21:58 > > > To: Xiaowei Bao > > > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > > > shawn...@kernel.org; Leo Li ; kis...@ti.com; > > > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; > M.h. > > > Lian ; Mingkai Hu ; Roy > > > Zang ; jingooh...@gmail.com; > > > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > > > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > > > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > > > Subject: Re: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to > > > the doorbell way > > > > > > On Thu, Aug 22, 2019 at 07:22:39PM +0800, Xiaowei Bao wrote: > > > > The layerscape platform use the doorbell way to trigger MSIX > > > > interrupt in EP mode. > > > > > > > > > > I have no problems with this patch, however... > > > > > > Are you able to add to this message a reason for why you are making > > > this change? Did dw_pcie_ep_raise_msix_irq not work when func_no != > > > 0? Or did it work yet dw_pcie_ep_raise_msix_irq_doorbell is more > efficient? > > > > The fact is that, this driver is verified in ls1046a platform of NXP > > before, and ls1046a don't support MSIX feature, so I set the > > msix_capable of pci_epc_features struct is false, but in other > > platform, e.g. ls1088a, it support the MSIX feature, I verified the MSIX > feature in ls1088a, it is not OK, so I changed to another way. Thanks. > > Right, so the existing pci-layerscape-ep.c driver never supported MSIX yet it > erroneously had a switch case statement to call dw_pcie_ep_raise_msix_irq > which would never get used. > > Now that we're adding a platform with MSIX support the existing > dw_pcie_ep_raise_msix_irq doesn't work (for this platform) so we are adding > a different method. > > Given that dw_pcie_ep_raise_msix_irq is used by pcie-designware-plat.c we > can assume this function at least works for it's use case. > > Please update the commit message - It would be helpful to suggest that > dw_pcie_ep_raise_msix_irq was never called in the exisitng driver because > msix_capable was always set to false. Agree, this is much clearer, I will modify the commit message in the next version patch, thanks a lot. > > Thanks, > > Andrew Murray > > > > > > > > > Thanks, > > > > > > Andrew Murray > > > > > > > Signed-off-by: Xiaowei Bao > > > > --- > > > > v2: > > > > - No change. > > > > > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > index 8461f62..7ca5fe8 100644 > > > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > > > @@ -74,7 +74,8 @@ static int ls_pcie_ep_raise_irq(struct > > > > dw_pcie_ep *ep, > > > u8 func_no, > > > > case PCI_EPC_IRQ_MSI: > > > > return dw_pcie_ep_raise_msi_irq(ep, func_no, > > > > interrupt_num); > > > > case PCI_EPC_IRQ_MSIX: > > > > - return dw_pcie_ep_raise_msix_irq(ep, func_no, > interrupt_num); > > > > + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, > > > > + > > > > interrupt_num); > > > > default: > > > > dev_err(pci->dev, "UNKNOWN IRQ type\n"); > > > > return -EINVAL; > > > > -- > > > > 2.9.5 > > > >
RE: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年8月23日 22:28 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > On Thu, Aug 22, 2019 at 07:22:40PM +0800, Xiaowei Bao wrote: > > Add PCIe EP mode support for ls1088a and ls2088a, there are some > > difference between LS1 and LS2 platform, so refactor the code of the > > EP driver. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - New mechanism for layerscape EP driver. > > Was there a v1 of this patch? > > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 76 > > -- > > 1 file changed, 58 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > index 7ca5fe8..2a66f07 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > @@ -20,27 +20,29 @@ > > > > #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ > > > > -struct ls_pcie_ep { > > - struct dw_pcie *pci; > > - struct pci_epc_features *ls_epc; > > +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > + > > +struct ls_pcie_ep_drvdata { > > + u32 func_offset; > > + const struct dw_pcie_ep_ops *ops; > > + const struct dw_pcie_ops*dw_pcie_ops; > > }; > > > > -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > +struct ls_pcie_ep { > > + struct dw_pcie *pci; > > + struct pci_epc_features *ls_epc; > > + const struct ls_pcie_ep_drvdata *drvdata; }; > > > > static int ls_pcie_establish_link(struct dw_pcie *pci) { > > return 0; > > } > > > > -static const struct dw_pcie_ops ls_pcie_ep_ops = { > > +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { > > .start_link = ls_pcie_establish_link, }; > > > > -static const struct of_device_id ls_pcie_ep_of_match[] = { > > - { .compatible = "fsl,ls-pcie-ep",}, > > - { }, > > -}; > > - > > static const struct pci_epc_features* ls_pcie_ep_get_features(struct > > dw_pcie_ep *ep) { @@ -82,10 +84,44 @@ static int > > ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, > > } > > } > > > > -static const struct dw_pcie_ep_ops pcie_ep_ops = { > > +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep, > > + u8 func_no) > > +{ > > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > > + u8 header_type; > > + > > + header_type = ioread8(pci->dbi_base + PCI_HEADER_TYPE); > > + > > + if (header_type & (1 << 7)) > > + return pcie->drvdata->func_offset * func_no; > > + else > > + return 0; > > It looks like there isn't a PCI define for multi function, the nearest I > could find > was PCI_HEADER_TYPE_MULTIDEVICE in hotplug/ibmphp.h. A comment > above the test might be helpful to explain the test. OK, I will add a comment above this code. > > As the ls_pcie_ep_drvdata structures are static, the unset .func_offset will > be > initialised to 0, so you could just drop the test above. Due to the different PCIe controller have different property, e.g. PCIe controller1 support multiple function feature, but PCIe controller2 don't support this feature, so I need to check which controller support it and return the correct offset value, but each board only have one ls_pcie_ep_drvdata, ^_^. > > However something to the effect of the following may help spot > misconfiguration: > > WARN_ON(func_no && !pcie->drvdata->func_offset); return > pcie->drvdata->func_offset * func_no; > > The WARN is probably quite useful as if you are attempting to use non-zero > functions and func_offset isn't set - then things may appear to work normally > but actually will break horribly. As disc
RE: [PATCH v4 1/3] dt-bindings: pci: layerscape-pci: add compatible strings "fsl,ls1028a-pcie"
> -Original Message- > From: Lorenzo Pieralisi > Sent: 2019年8月23日 22:05 > To: Xiaowei Bao > Cc: robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li ; M.h. Lian ; Mingkai Hu > ; Roy Zang ; > linux-...@vger.kernel.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > linuxppc-dev@lists.ozlabs.org; Z.q. Hou ; > bhelg...@google.com > Subject: Re: [PATCH v4 1/3] dt-bindings: pci: layerscape-pci: add compatible > strings "fsl,ls1028a-pcie" > > On Fri, Aug 23, 2019 at 04:26:41PM +0800, Xiaowei Bao wrote: > > Add the PCIe compatible string for LS1028A > > > > Signed-off-by: Xiaowei Bao > > Signed-off-by: Hou Zhiqiang > > Reviewed-by: Rob Herring > > --- > > v2: > > - No change. > > v3: > > - No change. > > v4: > > - No change. > > > > Documentation/devicetree/bindings/pci/layerscape-pci.txt | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt > b/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > index e20ceaa..99a386e 100644 > > --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt > > @@ -21,6 +21,7 @@ Required properties: > > "fsl,ls1046a-pcie" > > "fsl,ls1043a-pcie" > > "fsl,ls1012a-pcie" > > +"fsl,ls1028a-pcie" > >EP mode: > > "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" > > - reg: base addresses and lengths of the PCIe controller register blocks. > > This series does not apply to v5.3-rc1, what is it based on ? these set patches base on v5.3-rc3, thanks. > > Lorenzo
RE: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: christophe leroy > Sent: 2019年8月24日 14:45 > To: Xiaowei Bao ; Andrew Murray > > Cc: mark.rutl...@arm.com; Roy Zang ; > lorenzo.pieral...@arm.co; a...@arndb.de; devicet...@vger.kernel.org; > gre...@linuxfoundation.org; linuxppc-dev@lists.ozlabs.org; > linux-...@vger.kernel.org; linux-ker...@vger.kernel.org; kis...@ti.com; M.h. > Lian ; robh...@kernel.org; > gustavo.pimen...@synopsys.com; jingooh...@gmail.com; > bhelg...@google.com; Leo Li ; shawn...@kernel.org; > Mingkai Hu ; linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > > > Le 24/08/2019 à 02:18, Xiaowei Bao a écrit : > > > > > >> -Original Message----- > >> From: Andrew Murray > >> Sent: 2019年8月23日 22:28 > >> To: Xiaowei Bao > >> Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > >> shawn...@kernel.org; Leo Li ; kis...@ti.com; > >> lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; > M.h. > >> Lian ; Mingkai Hu ; Roy > >> Zang ; jingooh...@gmail.com; > >> gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > >> devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > >> linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > >> Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support > >> for ls1088a and ls2088a > >> > >> On Thu, Aug 22, 2019 at 07:22:40PM +0800, Xiaowei Bao wrote: > >>> Add PCIe EP mode support for ls1088a and ls2088a, there are some > >>> difference between LS1 and LS2 platform, so refactor the code of the > >>> EP driver. > >>> > >>> Signed-off-by: Xiaowei Bao > >>> --- > >>> v2: > >>> - New mechanism for layerscape EP driver. > >> > >> Was there a v1 of this patch? > > > > Yes, but I don't know how to comments, ^_^ > > As far as I can see, in the previous version of the series > (https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatch > work.ozlabs.org%2Fproject%2Flinuxppc-dev%2Flist%2F%3Fseries%3D125315 > %26state%3D*data=02%7C01%7Cxiaowei.bao%40nxp.com%7C1befe9 > a67c8046f9535e08d7285eaab6%7C686ea1d3bc2b4c6fa92cd99c5c301635% > 7C0%7C0%7C637022259387139020sdata=p4wbycd04Z7qRUfAoZtwc > UP7pR%2FuA3%2FjVcWMz6YyQVQ%3Dreserved=0), > the 8/10 was something completely different, and I can't find any other patch > in the series that could have been the v1 of this patch. Thanks, I will correct it to v1 in next version patch. > > Christophe > > > > >> > >>> > >>> drivers/pci/controller/dwc/pci-layerscape-ep.c | 76 > >>> -- > >>> 1 file changed, 58 insertions(+), 18 deletions(-) > >>> > >>> diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > >>> b/drivers/pci/controller/dwc/pci-layerscape-ep.c > >>> index 7ca5fe8..2a66f07 100644 > >>> --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > >>> +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > >>> @@ -20,27 +20,29 @@ > >>> > >>> #define PCIE_DBI2_OFFSET0x1000 /* DBI2 base address*/ > >>> > >>> -struct ls_pcie_ep { > >>> - struct dw_pcie *pci; > >>> - struct pci_epc_features *ls_epc; > >>> +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > >>> + > >>> +struct ls_pcie_ep_drvdata { > >>> + u32 func_offset; > >>> + const struct dw_pcie_ep_ops *ops; > >>> + const struct dw_pcie_ops*dw_pcie_ops; > >>> }; > >>> > >>> -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > >>> +struct ls_pcie_ep { > >>> + struct dw_pcie *pci; > >>> + struct pci_epc_features *ls_epc; > >>> + const struct ls_pcie_ep_drvdata *drvdata; }; > >>> > >>> static int ls_pcie_establish_link(struct dw_pcie *pci) { > >>> return 0; > >>> } > >>> > >>> -static const struct dw_pcie_ops ls_pcie_ep_ops = { > >>> +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { > >>> .start_link = ls_pcie_establish_link, }; > >>> > >>> -static const struct of_device_id ls_pcie_ep_of_match[] = { > >>> - { .compatible = "fsl,ls-pcie-ep",}, > &g
RE: [PATCH v2 03/10] PCI: designware-ep: Move the function of getting MSI capability forward
> -Original Message- > From: Andrew Murray > Sent: 2019年8月23日 21:39 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 03/10] PCI: designware-ep: Move the function of > getting MSI capability forward > > On Thu, Aug 22, 2019 at 07:22:35PM +0800, Xiaowei Bao wrote: > > Move the function of getting MSI capability to the front of init > > function, because the init function of the EP platform driver will use > > the return value by the function of getting MSI capability. > > > > Signed-off-by: Xiaowei Bao > > Reviewed-by: Andrew Murray Thanks a lot, I think move this to ep_init is better. > > > --- > > v2: > > - No change. > > > > drivers/pci/controller/dwc/pcie-designware-ep.c | 7 --- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c > > b/drivers/pci/controller/dwc/pcie-designware-ep.c > > index b8388f8..0a6c199 100644 > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > > @@ -656,6 +656,10 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) > > if (ret < 0) > > epc->max_functions = 1; > > > > + ep->msi_cap = dw_pcie_ep_find_capability(pci, PCI_CAP_ID_MSI); > > + > > + ep->msix_cap = dw_pcie_ep_find_capability(pci, PCI_CAP_ID_MSIX); > > + > > if (ep->ops->ep_init) > > ep->ops->ep_init(ep); > > > > @@ -672,9 +676,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) > > dev_err(dev, "Failed to reserve memory for MSI/MSI-X\n"); > > return -ENOMEM; > > } > > - ep->msi_cap = dw_pcie_ep_find_capability(pci, PCI_CAP_ID_MSI); > > - > > - ep->msix_cap = dw_pcie_ep_find_capability(pci, PCI_CAP_ID_MSIX); > > > > offset = dw_pcie_ep_find_ext_capability(pci, PCI_EXT_CAP_ID_REBAR); > > if (offset) { > > -- > > 2.9.5 > >
RE: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
> -Original Message- > From: Andrew Murray > Sent: 2019年8月23日 22:28 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 08/10] PCI: layerscape: Add EP mode support for > ls1088a and ls2088a > > On Thu, Aug 22, 2019 at 07:22:40PM +0800, Xiaowei Bao wrote: > > Add PCIe EP mode support for ls1088a and ls2088a, there are some > > difference between LS1 and LS2 platform, so refactor the code of the > > EP driver. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - New mechanism for layerscape EP driver. > > Was there a v1 of this patch? Yes, but I don't know how to comments, ^_^ > > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 76 > > -- > > 1 file changed, 58 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > index 7ca5fe8..2a66f07 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > @@ -20,27 +20,29 @@ > > > > #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ > > > > -struct ls_pcie_ep { > > - struct dw_pcie *pci; > > - struct pci_epc_features *ls_epc; > > +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > + > > +struct ls_pcie_ep_drvdata { > > + u32 func_offset; > > + const struct dw_pcie_ep_ops *ops; > > + const struct dw_pcie_ops*dw_pcie_ops; > > }; > > > > -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > +struct ls_pcie_ep { > > + struct dw_pcie *pci; > > + struct pci_epc_features *ls_epc; > > + const struct ls_pcie_ep_drvdata *drvdata; }; > > > > static int ls_pcie_establish_link(struct dw_pcie *pci) { > > return 0; > > } > > > > -static const struct dw_pcie_ops ls_pcie_ep_ops = { > > +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { > > .start_link = ls_pcie_establish_link, }; > > > > -static const struct of_device_id ls_pcie_ep_of_match[] = { > > - { .compatible = "fsl,ls-pcie-ep",}, > > - { }, > > -}; > > - > > static const struct pci_epc_features* ls_pcie_ep_get_features(struct > > dw_pcie_ep *ep) { @@ -82,10 +84,44 @@ static int > > ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, > > } > > } > > > > -static const struct dw_pcie_ep_ops pcie_ep_ops = { > > +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep, > > + u8 func_no) > > +{ > > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > > + u8 header_type; > > + > > + header_type = ioread8(pci->dbi_base + PCI_HEADER_TYPE); > > + > > + if (header_type & (1 << 7)) > > + return pcie->drvdata->func_offset * func_no; > > + else > > + return 0; > > It looks like there isn't a PCI define for multi function, the nearest I > could find > was PCI_HEADER_TYPE_MULTIDEVICE in hotplug/ibmphp.h. A comment > above the test might be helpful to explain the test. Yes, I have not find the PCI_HEADER_TYPE_MULTIDEVICE define. OK, I will add The comments in next version patch. > > As the ls_pcie_ep_drvdata structures are static, the unset .func_offset will > be > initialised to 0, so you could just drop the test above. OK, thanks > > However something to the effect of the following may help spot > misconfiguration: > > WARN_ON(func_no && !pcie->drvdata->func_offset); return > pcie->drvdata->func_offset * func_no; Thanks a lot, this looks better. > > The WARN is probably quite useful as if you are attempting to use non-zero > functions and func_offset isn't set - then things may appear to work normally > but actually will break horribly. got it, thanks. > > Thanks, > > Andrew Murray > > > +} > > + > > +static const struct dw_pcie_ep_ops ls_pcie_ep_ops = { > >
RE: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the doorbell way
> -Original Message- > From: Andrew Murray > Sent: 2019年8月23日 21:58 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the > doorbell way > > On Thu, Aug 22, 2019 at 07:22:39PM +0800, Xiaowei Bao wrote: > > The layerscape platform use the doorbell way to trigger MSIX interrupt > > in EP mode. > > > > I have no problems with this patch, however... > > Are you able to add to this message a reason for why you are making this > change? Did dw_pcie_ep_raise_msix_irq not work when func_no != 0? Or did > it work yet dw_pcie_ep_raise_msix_irq_doorbell is more efficient? The fact is that, this driver is verified in ls1046a platform of NXP before, and ls1046a don't support MSIX feature, so I set the msix_capable of pci_epc_features struct is false, but in other platform, e.g. ls1088a, it support the MSIX feature, I verified the MSIX feature in ls1088a, it is not OK, so I changed to another way. Thanks. > > Thanks, > > Andrew Murray > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - No change. > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > index 8461f62..7ca5fe8 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > @@ -74,7 +74,8 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, > u8 func_no, > > case PCI_EPC_IRQ_MSI: > > return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); > > case PCI_EPC_IRQ_MSIX: > > - return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num); > > + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, > > + interrupt_num); > > default: > > dev_err(pci->dev, "UNKNOWN IRQ type\n"); > > return -EINVAL; > > -- > > 2.9.5 > >
RE: [PATCH v2 05/10] PCI: layerscape: Fix some format issue of the code
> -Original Message- > From: Andrew Murray > Sent: 2019年8月23日 21:45 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 05/10] PCI: layerscape: Fix some format issue of the > code > > On Thu, Aug 22, 2019 at 07:22:37PM +0800, Xiaowei Bao wrote: > > Fix some format issue of the code in EP driver. > > > > Signed-off-by: Xiaowei Bao > > Reviewed-by: Andrew Murray Thanks. > > > > --- > > v2: > > - No change. > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > index be61d96..4e92a95 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > @@ -62,7 +62,7 @@ static void ls_pcie_ep_init(struct dw_pcie_ep *ep) > > } > > > > static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, > > - enum pci_epc_irq_type type, u16 interrupt_num) > > + enum pci_epc_irq_type type, u16 interrupt_num) > > { > > struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > > > @@ -86,7 +86,7 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = { > > }; > > > > static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, > > - struct platform_device *pdev) > > +struct platform_device *pdev) > > { > > struct dw_pcie *pci = pcie->pci; > > struct device *dev = pci->dev; > > -- > > 2.9.5 > >
RE: [PATCH v2 02/10] PCI: designware-ep: Add the doorbell mode of MSI-X in EP mode
> -Original Message- > From: Andrew Murray > Sent: 2019年8月23日 21:36 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 02/10] PCI: designware-ep: Add the doorbell mode of > MSI-X in EP mode > > On Thu, Aug 22, 2019 at 07:22:34PM +0800, Xiaowei Bao wrote: > > Add the doorbell mode of MSI-X in EP mode. > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - Remove the macro of no used. > > > > drivers/pci/controller/dwc/pcie-designware-ep.c | 14 ++ > > drivers/pci/controller/dwc/pcie-designware.h| 12 > > 2 files changed, 26 insertions(+) > > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c > > b/drivers/pci/controller/dwc/pcie-designware-ep.c > > index 3e2b740..b8388f8 100644 > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > > @@ -480,6 +480,20 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep > *ep, u8 func_no, > > return 0; > > } > > > > +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 > func_no, > > + u16 interrupt_num) > > +{ > > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + u32 msg_data; > > + > > + msg_data = (func_no << PCIE_MSIX_DOORBELL_PF_SHIFT) | > > + (interrupt_num - 1); > > + > > + dw_pcie_writel_dbi(pci, PCIE_MSIX_DOORBELL, msg_data); > > + > > + return 0; > > +} > > + > > int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, > > u16 interrupt_num) > > { > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h > > b/drivers/pci/controller/dwc/pcie-designware.h > > index a0fdbf7..895a9ef 100644 > > --- a/drivers/pci/controller/dwc/pcie-designware.h > > +++ b/drivers/pci/controller/dwc/pcie-designware.h > > @@ -88,6 +88,9 @@ > > #define PCIE_MISC_CONTROL_1_OFF0x8BC > > #define PCIE_DBI_RO_WR_EN BIT(0) > > > > +#define PCIE_MSIX_DOORBELL 0x948 > > +#define PCIE_MSIX_DOORBELL_PF_SHIFT24 > > + > > /* > > * iATU Unroll-specific register definitions > > * From 4.80 core version the address translation will be made by > > unroll @@ -400,6 +403,8 @@ int dw_pcie_ep_raise_msi_irq(struct > dw_pcie_ep *ep, u8 func_no, > > u8 interrupt_num); > > int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, > > u16 interrupt_num); > > +int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 > func_no, > > + u16 interrupt_num); > > void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar); > > #else static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) @@ > > -432,6 +437,13 @@ static inline int dw_pcie_ep_raise_msix_irq(struct > dw_pcie_ep *ep, u8 func_no, > > return 0; > > } > > > > +static inline int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep > *ep, > > +u8 func_no, > > +u16 interrupt_num) > > +{ > > + return 0; > > +} > > + > > Looks OK to me. > > Reviewed-by: Andrew Murray Thanks a lot. > > > static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum > > pci_barno bar) { } > > -- > > 2.9.5 > >
RE: [PATCH v2 01/10] PCI: designware-ep: Add multiple PFs support for DWC
> -Original Message- > From: Andrew Murray > Sent: 2019年8月23日 21:25 > To: Xiaowei Bao > Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.co; a...@arndb.de; gre...@linuxfoundation.org; M.h. > Lian ; Mingkai Hu ; Roy > Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org > Subject: Re: [PATCH v2 01/10] PCI: designware-ep: Add multiple PFs support > for DWC > > On Thu, Aug 22, 2019 at 07:22:33PM +0800, Xiaowei Bao wrote: > > Add multiple PFs support for DWC, different PF have different config > > space we use pf-offset property which get from the DTS to access the > > different pF config space. > > It looks like you're missing a --cover-letter again. > > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - Remove duplicate redundant code. > > - Reimplement the PF config space access way. > > > > drivers/pci/controller/dwc/pcie-designware-ep.c | 122 > > > drivers/pci/controller/dwc/pcie-designware.c| 59 > > drivers/pci/controller/dwc/pcie-designware.h| 11 ++- > > 3 files changed, 134 insertions(+), 58 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c > > b/drivers/pci/controller/dwc/pcie-designware-ep.c > > index 2bf5a35..3e2b740 100644 > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > > @@ -19,12 +19,17 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) > > pci_epc_linkup(epc); > > } > > > > -static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno > bar, > > - int flags) > > +static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no, > > + enum pci_barno bar, int flags) > > { > > u32 reg; > > + unsigned int func_offset = 0; > > + struct dw_pcie_ep *ep = >ep; > > > > - reg = PCI_BASE_ADDRESS_0 + (4 * bar); > > + if (ep->ops->func_conf_select) > > + func_offset = ep->ops->func_conf_select(ep, func_no); > > + > > + reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar); > > This pattern of checking if func_conf_select exists and using it to get an > offset > is repeated a lot throughout this file. You could move this functionality > into a > new function (similar to dw_pcie_read_dbi etc). Or perhaps a new variant of > dw_pcie_writel_ should be created that writes takes a func_no argument. Thanks for your comments, I thought about this method before, but there is a issue about the method of access the different func config space, due to our platform use this method that different func have different offset from dbi_base to access the different config space, but others platform maybe use the way that write a register to implement different func config space access, so I think reserve a callback function to different platform to implement the own method, my point is that, if use register method they can implement the code in this function and return offset is 0, if use offset method, they can return the offset value which can be use by dw_pcie_ep driver. > > > > dw_pcie_dbi_ro_wr_en(pci); > > dw_pcie_writel_dbi2(pci, reg, 0x0); > > dw_pcie_writel_dbi(pci, reg, 0x0); > > > > @@ -235,7 +257,7 @@ static int dw_pcie_ep_map_addr(struct pci_epc > *epc, u8 func_no, > > struct dw_pcie_ep *ep = epc_get_drvdata(epc); > > struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > > > - ret = dw_pcie_ep_outbound_atu(ep, addr, pci_addr, size); > > + ret = dw_pcie_ep_outbound_atu(ep, func_no, addr, pci_addr, size); > > if (ret) { > > dev_err(pci->dev, "Failed to enable address\n"); > > return ret; > > @@ -249,11 +271,15 @@ static int dw_pcie_ep_get_msi(struct pci_epc > *epc, u8 func_no) > > struct dw_pcie_ep *ep = epc_get_drvdata(epc); > > struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > u32 val, reg; > > + unsigned int func_offset = 0; > > + > > + if (ep->ops->func_conf_select) > > + func_offset = ep->ops->func_conf_select(ep, func_no); > > > > if (!ep->msi_cap) > > return -EINVAL; > > > > - reg = ep->msi_cap + PCI_MSI_FLAGS; > > + reg = ep->msi_cap + func_offs
[PATCH v4 2/3] arm64: dts: ls1028a: Add PCIe controller DT nodes
LS1028a implements 2 PCIe 3.0 controllers. Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang --- v2: - Fix up the legacy INTx allocate failed issue. v3: - No change. v4: - Remove the num-lanes proparty. depends on: https://patchwork.kernel.org/project/linux-pci/list/?series=162215 arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 50 ++ 1 file changed, 50 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi index 72b9a75..a25f9d9 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi @@ -625,6 +625,56 @@ }; }; + pcie@340 { + compatible = "fsl,ls1028a-pcie"; + reg = <0x00 0x0340 0x0 0x0010 /* controller registers */ + 0x80 0x 0x0 0x2000>; /* configuration space */ + reg-names = "regs", "config"; + interrupts = , /* PME interrupt */ +; /* aer interrupt */ + interrupt-names = "pme", "aer"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + dma-coherent; + bus-range = <0x0 0xff>; + ranges = <0x8100 0x0 0x 0x80 0x0001 0x0 0x0001 /* downstream I/O */ + 0x8200 0x0 0x4000 0x80 0x4000 0x0 0x4000>; /* non-prefetchable memory */ + msi-parent = <>; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = < 0 0 1 0 0 GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 2 0 0 GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 3 0 0 GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 4 0 0 GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + + pcie@350 { + compatible = "fsl,ls1028a-pcie"; + reg = <0x00 0x0350 0x0 0x0010 /* controller registers */ + 0x88 0x 0x0 0x2000>; /* configuration space */ + reg-names = "regs", "config"; + interrupts = , +; + interrupt-names = "pme", "aer"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + dma-coherent; + bus-range = <0x0 0xff>; + ranges = <0x8100 0x0 0x 0x88 0x0001 0x0 0x0001 /* downstream I/O */ + 0x8200 0x0 0x4000 0x88 0x4000 0x0 0x4000>; /* non-prefetchable memory */ + msi-parent = <>; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = < 0 0 1 0 0 GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 2 0 0 GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 3 0 0 GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>, + < 0 0 4 0 0 GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + pcie@1f000 { /* Integrated Endpoint Root Complex */ compatible = "pci-host-ecam-generic"; reg = <0x01 0xf000 0x0 0x10>; -- 2.9.5
[PATCH v4 3/3] PCI: layerscape: Add LS1028a support
Add support for the LS1028a PCIe controller. Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang --- v2: - No change. v3: - Reuse the ls2088 driver data structurt. v4: - No change. drivers/pci/controller/dwc/pci-layerscape.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index 3a5fa26..f24f79a 100644 --- a/drivers/pci/controller/dwc/pci-layerscape.c +++ b/drivers/pci/controller/dwc/pci-layerscape.c @@ -263,6 +263,7 @@ static const struct ls_pcie_drvdata ls2088_drvdata = { static const struct of_device_id ls_pcie_of_match[] = { { .compatible = "fsl,ls1012a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1021a-pcie", .data = _drvdata }, + { .compatible = "fsl,ls1028a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1043a-pcie", .data = _drvdata }, { .compatible = "fsl,ls1046a-pcie", .data = _drvdata }, { .compatible = "fsl,ls2080a-pcie", .data = _drvdata }, -- 2.9.5
[PATCH v4 1/3] dt-bindings: pci: layerscape-pci: add compatible strings "fsl, ls1028a-pcie"
Add the PCIe compatible string for LS1028A Signed-off-by: Xiaowei Bao Signed-off-by: Hou Zhiqiang Reviewed-by: Rob Herring --- v2: - No change. v3: - No change. v4: - No change. Documentation/devicetree/bindings/pci/layerscape-pci.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt b/Documentation/devicetree/bindings/pci/layerscape-pci.txt index e20ceaa..99a386e 100644 --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt @@ -21,6 +21,7 @@ Required properties: "fsl,ls1046a-pcie" "fsl,ls1043a-pcie" "fsl,ls1012a-pcie" +"fsl,ls1028a-pcie" EP mode: "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep" - reg: base addresses and lengths of the PCIe controller register blocks. -- 2.9.5
RE: [PATCH v2 06/10] PCI: layerscape: Modify the way of getting capability with different PEX
> -Original Message- > From: Kishon Vijay Abraham I > Sent: 2019年8月23日 11:40 > To: Xiaowei Bao ; bhelg...@google.com; > robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo Li > ; lorenzo.pieral...@arm.co > ; a...@arndb.de; gre...@linuxfoundation.org; > M.h. Lian ; Mingkai Hu ; > Roy Zang ; jingooh...@gmail.com; > gustavo.pimen...@synopsys.com; linux-...@vger.kernel.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; > andrew.mur...@arm.com > Subject: Re: [PATCH v2 06/10] PCI: layerscape: Modify the way of getting > capability with different PEX > > Hi, > > (Fixed Lorenzo's email address. All the patches in the series have wrong email > id) > > On 23/08/19 8:09 AM, Xiaowei Bao wrote: > > > > > >> -Original Message----- > >> From: Kishon Vijay Abraham I > >> Sent: 2019年8月22日 19:44 > >> To: Xiaowei Bao ; bhelg...@google.com; > >> robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo > Li > >> ; lorenzo.pieral...@arm.co; a...@arndb.de; > >> gre...@linuxfoundation.org; M.h. Lian ; > >> Mingkai Hu ; Roy Zang ; > >> jingooh...@gmail.com; gustavo.pimen...@synopsys.com; > >> linux-...@vger.kernel.org; devicet...@vger.kernel.org; > >> linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > >> linuxppc-dev@lists.ozlabs.org; andrew.mur...@arm.com > >> Subject: Re: [PATCH v2 06/10] PCI: layerscape: Modify the way of > >> getting capability with different PEX > >> > >> Hi, > >> > >> On 22/08/19 4:52 PM, Xiaowei Bao wrote: > >>> The different PCIe controller in one board may be have different > >>> capability of MSI or MSIX, so change the way of getting the MSI > >>> capability, make it more flexible. > >> > >> please use different pci_epc_features table for different boards. > > Thanks, I think that it will be more flexible to dynamically get MSI > > or MSIX capability, Thus, we will not need to define the pci_epc_feature for > different boards. > > Is the restriction because you cannot have different compatible for different > boards? Sorry, I am not very clear what your mean, I think even if I use the same compatible with different boards, each boards will enter the probe function, in there I will get the MSI or MSIX PCIe capability of the current controller in this board. Why do I need to define the pci_epc_feature for different boards? > > Thanks > Kishon > > >> > >> Thanks > >> Kishon > >>> > >>> Signed-off-by: Xiaowei Bao > >>> --- > >>> v2: > >>> - Remove the repeated assignment code. > >>> > >>> drivers/pci/controller/dwc/pci-layerscape-ep.c | 26 > >>> +++--- > >>> 1 file changed, 19 insertions(+), 7 deletions(-) > >>> > >>> diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > >>> b/drivers/pci/controller/dwc/pci-layerscape-ep.c > >>> index 4e92a95..8461f62 100644 > >>> --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > >>> +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > >>> @@ -22,6 +22,7 @@ > >>> > >>> struct ls_pcie_ep { > >>> struct dw_pcie *pci; > >>> + struct pci_epc_features *ls_epc; > >>> }; > >>> > >>> #define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > >>> @@ -40,25 +41,26 @@ static const struct of_device_id > >> ls_pcie_ep_of_match[] = { > >>> { }, > >>> }; > >>> > >>> -static const struct pci_epc_features ls_pcie_epc_features = { > >>> - .linkup_notifier = false, > >>> - .msi_capable = true, > >>> - .msix_capable = false, > >>> -}; > >>> - > >>> static const struct pci_epc_features* > >>> ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { > >>> - return _pcie_epc_features; > >>> + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > >>> + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > >>> + > >>> + return pcie->ls_epc; > >>> } > >>> > >>> static void ls_pcie_ep_init(struct dw_pcie_ep *ep) { > >>> struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > >>> + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > >>> enum pci_barno bar; > >>> > >>> for (bar = BAR_0
RE: [PATCH v2 06/10] PCI: layerscape: Modify the way of getting capability with different PEX
> -Original Message- > From: Kishon Vijay Abraham I > Sent: 2019年8月22日 19:44 > To: Xiaowei Bao ; bhelg...@google.com; > robh...@kernel.org; mark.rutl...@arm.com; shawn...@kernel.org; Leo Li > ; lorenzo.pieral...@arm.co; a...@arndb.de; > gre...@linuxfoundation.org; M.h. Lian ; Mingkai > Hu ; Roy Zang ; > jingooh...@gmail.com; gustavo.pimen...@synopsys.com; > linux-...@vger.kernel.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > linuxppc-dev@lists.ozlabs.org; andrew.mur...@arm.com > Subject: Re: [PATCH v2 06/10] PCI: layerscape: Modify the way of getting > capability with different PEX > > Hi, > > On 22/08/19 4:52 PM, Xiaowei Bao wrote: > > The different PCIe controller in one board may be have different > > capability of MSI or MSIX, so change the way of getting the MSI > > capability, make it more flexible. > > please use different pci_epc_features table for different boards. Thanks, I think that it will be more flexible to dynamically get MSI or MSIX capability, Thus, we will not need to define the pci_epc_feature for different boards. > > Thanks > Kishon > > > > Signed-off-by: Xiaowei Bao > > --- > > v2: > > - Remove the repeated assignment code. > > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 26 > > +++--- > > 1 file changed, 19 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > index 4e92a95..8461f62 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > > @@ -22,6 +22,7 @@ > > > > struct ls_pcie_ep { > > struct dw_pcie *pci; > > + struct pci_epc_features *ls_epc; > > }; > > > > #define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) > > @@ -40,25 +41,26 @@ static const struct of_device_id > ls_pcie_ep_of_match[] = { > > { }, > > }; > > > > -static const struct pci_epc_features ls_pcie_epc_features = { > > - .linkup_notifier = false, > > - .msi_capable = true, > > - .msix_capable = false, > > -}; > > - > > static const struct pci_epc_features* ls_pcie_ep_get_features(struct > > dw_pcie_ep *ep) { > > - return _pcie_epc_features; > > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > > + > > + return pcie->ls_epc; > > } > > > > static void ls_pcie_ep_init(struct dw_pcie_ep *ep) { > > struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); > > enum pci_barno bar; > > > > for (bar = BAR_0; bar <= BAR_5; bar++) > > dw_pcie_ep_reset_bar(pci, bar); > > + > > + pcie->ls_epc->msi_capable = ep->msi_cap ? true : false; > > + pcie->ls_epc->msix_capable = ep->msix_cap ? true : false; > > } > > > > static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, @@ > > -118,6 +120,7 @@ static int __init ls_pcie_ep_probe(struct platform_device > *pdev) > > struct device *dev = >dev; > > struct dw_pcie *pci; > > struct ls_pcie_ep *pcie; > > + struct pci_epc_features *ls_epc; > > struct resource *dbi_base; > > int ret; > > > > @@ -129,6 +132,10 @@ static int __init ls_pcie_ep_probe(struct > platform_device *pdev) > > if (!pci) > > return -ENOMEM; > > > > + ls_epc = devm_kzalloc(dev, sizeof(*ls_epc), GFP_KERNEL); > > + if (!ls_epc) > > + return -ENOMEM; > > + > > dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, > "regs"); > > pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); > > if (IS_ERR(pci->dbi_base)) > > @@ -139,6 +146,11 @@ static int __init ls_pcie_ep_probe(struct > platform_device *pdev) > > pci->ops = _pcie_ep_ops; > > pcie->pci = pci; > > > > + ls_epc->linkup_notifier = false, > > + ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), > > + > > + pcie->ls_epc = ls_epc; > > + > > platform_set_drvdata(pdev, pcie); > > > > ret = ls_add_pcie_ep(pcie, pdev); > >
[PATCH v2 10/10] misc: pci_endpoint_test: Add LS1088a in pci_device_id table
Add LS1088a in pci_device_id table so that pci-epf-test can be used for testing PCIe EP in LS1088a. Signed-off-by: Xiaowei Bao --- v2: - No change. drivers/misc/pci_endpoint_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 6e208a0..d531951 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -793,6 +793,7 @@ static const struct pci_device_id pci_endpoint_test_tbl[] = { { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x80c0) }, { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), .driver_data = (kernel_ulong_t)_data -- 2.9.5
[PATCH v2 09/10] arm64: dts: layerscape: Add PCIe EP node for ls1088a
Add PCIe EP node for ls1088a to support EP mode. Signed-off-by: Xiaowei Bao --- v2: - Remove the pf-offset proparty. arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 31 ++ 1 file changed, 31 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi index dfbead4..79109ad 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi @@ -471,6 +471,17 @@ status = "disabled"; }; + pcie_ep@340 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0340 0x0 0x0010 + 0x20 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <24>; + num-ob-windows = <128>; + max-functions = /bits/ 8 <2>; + status = "disabled"; + }; + pcie@350 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0350 0x0 0x0010 /* controller registers */ @@ -497,6 +508,16 @@ status = "disabled"; }; + pcie_ep@350 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0350 0x0 0x0010 + 0x28 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + pcie@360 { compatible = "fsl,ls1088a-pcie"; reg = <0x00 0x0360 0x0 0x0010 /* controller registers */ @@ -523,6 +544,16 @@ status = "disabled"; }; + pcie_ep@360 { + compatible = "fsl,ls1088a-pcie-ep","fsl,ls-pcie-ep"; + reg = <0x00 0x0360 0x0 0x0010 + 0x30 0x 0x8 0x>; + reg-names = "regs", "addr_space"; + num-ib-windows = <6>; + num-ob-windows = <8>; + status = "disabled"; + }; + smmu: iommu@500 { compatible = "arm,mmu-500"; reg = <0 0x500 0 0x80>; -- 2.9.5
[PATCH v2 08/10] PCI: layerscape: Add EP mode support for ls1088a and ls2088a
Add PCIe EP mode support for ls1088a and ls2088a, there are some difference between LS1 and LS2 platform, so refactor the code of the EP driver. Signed-off-by: Xiaowei Bao --- v2: - New mechanism for layerscape EP driver. drivers/pci/controller/dwc/pci-layerscape-ep.c | 76 -- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 7ca5fe8..2a66f07 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -20,27 +20,29 @@ #define PCIE_DBI2_OFFSET 0x1000 /* DBI2 base address*/ -struct ls_pcie_ep { - struct dw_pcie *pci; - struct pci_epc_features *ls_epc; +#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) + +struct ls_pcie_ep_drvdata { + u32 func_offset; + const struct dw_pcie_ep_ops *ops; + const struct dw_pcie_ops*dw_pcie_ops; }; -#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) +struct ls_pcie_ep { + struct dw_pcie *pci; + struct pci_epc_features *ls_epc; + const struct ls_pcie_ep_drvdata *drvdata; +}; static int ls_pcie_establish_link(struct dw_pcie *pci) { return 0; } -static const struct dw_pcie_ops ls_pcie_ep_ops = { +static const struct dw_pcie_ops dw_ls_pcie_ep_ops = { .start_link = ls_pcie_establish_link, }; -static const struct of_device_id ls_pcie_ep_of_match[] = { - { .compatible = "fsl,ls-pcie-ep",}, - { }, -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { @@ -82,10 +84,44 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, } } -static const struct dw_pcie_ep_ops pcie_ep_ops = { +static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep, + u8 func_no) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + u8 header_type; + + header_type = ioread8(pci->dbi_base + PCI_HEADER_TYPE); + + if (header_type & (1 << 7)) + return pcie->drvdata->func_offset * func_no; + else + return 0; +} + +static const struct dw_pcie_ep_ops ls_pcie_ep_ops = { .ep_init = ls_pcie_ep_init, .raise_irq = ls_pcie_ep_raise_irq, .get_features = ls_pcie_ep_get_features, + .func_conf_select = ls_pcie_ep_func_conf_select, +}; + +static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = { + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct ls_pcie_ep_drvdata ls2_ep_drvdata = { + .func_offset = 0x2, + .ops = _pcie_ep_ops, + .dw_pcie_ops = _ls_pcie_ep_ops, +}; + +static const struct of_device_id ls_pcie_ep_of_match[] = { + { .compatible = "fsl,ls1046a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls1088a-pcie-ep", .data = _ep_drvdata }, + { .compatible = "fsl,ls2088a-pcie-ep", .data = _ep_drvdata }, + { }, }; static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, @@ -98,7 +134,7 @@ static int __init ls_add_pcie_ep(struct ls_pcie_ep *pcie, int ret; ep = >ep; - ep->ops = _ep_ops; + ep->ops = pcie->drvdata->ops; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); if (!res) @@ -137,14 +173,11 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!ls_epc) return -ENOMEM; - dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); - if (IS_ERR(pci->dbi_base)) - return PTR_ERR(pci->dbi_base); + pcie->drvdata = of_device_get_match_data(dev); - pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; pci->dev = dev; - pci->ops = _pcie_ep_ops; + pci->ops = pcie->drvdata->dw_pcie_ops; + pcie->pci = pci; ls_epc->linkup_notifier = false, @@ -152,6 +185,13 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) pcie->ls_epc = ls_epc; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); + pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); + if (IS_ERR(pci->dbi_base)) + return PTR_ERR(pci->dbi_base); + + pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_OFFSET; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5
[PATCH v2 07/10] PCI: layerscape: Modify the MSIX to the doorbell way
The layerscape platform use the doorbell way to trigger MSIX interrupt in EP mode. Signed-off-by: Xiaowei Bao --- v2: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 8461f62..7ca5fe8 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -74,7 +74,8 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, case PCI_EPC_IRQ_MSI: return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); case PCI_EPC_IRQ_MSIX: - return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num); + return dw_pcie_ep_raise_msix_irq_doorbell(ep, func_no, + interrupt_num); default: dev_err(pci->dev, "UNKNOWN IRQ type\n"); return -EINVAL; -- 2.9.5