Skip to content

Commit 7a13e83

Browse files
committed
Merge branch 'pci/controller/stm32'
- Fix a race between link training and endpoint register initialization (Christian Bruel) - Align endpoint allocations to match the ATU requirements (Christian Bruel) - Add #includes to avoid depending on 'proxy' headers (Andy Shevchenko) * pci/controller/stm32: PCI: stm32: Don't use 'proxy' headers PCI: stm32: Fix EP page_size alignment PCI: stm32: Fix LTSSM EP race with start link
2 parents 388f9a6 + cfa3c76 commit 7a13e83

3 files changed

Lines changed: 27 additions & 33 deletions

File tree

drivers/pci/controller/dwc/pcie-stm32-ep.c

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88

99
#include <linux/clk.h>
10+
#include <linux/gpio/consumer.h>
1011
#include <linux/mfd/syscon.h>
1112
#include <linux/of_platform.h>
12-
#include <linux/of_gpio.h>
1313
#include <linux/phy/phy.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/pm_runtime.h>
@@ -37,36 +37,9 @@ static void stm32_pcie_ep_init(struct dw_pcie_ep *ep)
3737
dw_pcie_ep_reset_bar(pci, bar);
3838
}
3939

40-
static int stm32_pcie_enable_link(struct dw_pcie *pci)
41-
{
42-
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
43-
44-
regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
45-
STM32MP25_PCIECR_LTSSM_EN,
46-
STM32MP25_PCIECR_LTSSM_EN);
47-
48-
return dw_pcie_wait_for_link(pci);
49-
}
50-
51-
static void stm32_pcie_disable_link(struct dw_pcie *pci)
52-
{
53-
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
54-
55-
regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR, STM32MP25_PCIECR_LTSSM_EN, 0);
56-
}
57-
5840
static int stm32_pcie_start_link(struct dw_pcie *pci)
5941
{
6042
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
61-
int ret;
62-
63-
dev_dbg(pci->dev, "Enable link\n");
64-
65-
ret = stm32_pcie_enable_link(pci);
66-
if (ret) {
67-
dev_err(pci->dev, "PCIe cannot establish link: %d\n", ret);
68-
return ret;
69-
}
7043

7144
enable_irq(stm32_pcie->perst_irq);
7245

@@ -77,11 +50,7 @@ static void stm32_pcie_stop_link(struct dw_pcie *pci)
7750
{
7851
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
7952

80-
dev_dbg(pci->dev, "Disable link\n");
81-
8253
disable_irq(stm32_pcie->perst_irq);
83-
84-
stm32_pcie_disable_link(pci);
8554
}
8655

8756
static int stm32_pcie_raise_irq(struct dw_pcie_ep *ep, u8 func_no,
@@ -152,6 +121,9 @@ static void stm32_pcie_perst_assert(struct dw_pcie *pci)
152121

153122
dev_dbg(dev, "PERST asserted by host\n");
154123

124+
regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
125+
STM32MP25_PCIECR_LTSSM_EN, 0);
126+
155127
pci_epc_deinit_notify(ep->epc);
156128

157129
stm32_pcie_disable_resources(stm32_pcie);
@@ -192,6 +164,11 @@ static void stm32_pcie_perst_deassert(struct dw_pcie *pci)
192164

193165
pci_epc_init_notify(ep->epc);
194166

167+
/* Enable link training */
168+
regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
169+
STM32MP25_PCIECR_LTSSM_EN,
170+
STM32MP25_PCIECR_LTSSM_EN);
171+
195172
return;
196173

197174
err_disable_resources:
@@ -237,6 +214,8 @@ static int stm32_add_pcie_ep(struct stm32_pcie *stm32_pcie,
237214

238215
ep->ops = &stm32_pcie_ep_ops;
239216

217+
ep->page_size = stm32_pcie_epc_features.align;
218+
240219
ret = dw_pcie_ep_init(ep);
241220
if (ret) {
242221
dev_err(dev, "Failed to initialize ep: %d\n", ret);

drivers/pci/controller/dwc/pcie-stm32.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,30 @@
77
*/
88

99
#include <linux/clk.h>
10+
#include <linux/delay.h>
11+
#include <linux/device.h>
12+
#include <linux/err.h>
13+
#include <linux/gpio/consumer.h>
14+
#include <linux/irq.h>
1015
#include <linux/mfd/syscon.h>
16+
#include <linux/mod_devicetable.h>
17+
#include <linux/module.h>
18+
#include <linux/of.h>
1119
#include <linux/of_platform.h>
1220
#include <linux/phy/phy.h>
1321
#include <linux/pinctrl/consumer.h>
1422
#include <linux/platform_device.h>
23+
#include <linux/pm.h>
1524
#include <linux/pm_runtime.h>
1625
#include <linux/pm_wakeirq.h>
1726
#include <linux/regmap.h>
1827
#include <linux/reset.h>
28+
#include <linux/stddef.h>
29+
30+
#include "../../pci.h"
31+
1932
#include "pcie-designware.h"
2033
#include "pcie-stm32.h"
21-
#include "../../pci.h"
2234

2335
struct stm32_pcie {
2436
struct dw_pcie pci;

drivers/pci/controller/dwc/pcie-stm32.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* Author: Christian Bruel <christian.bruel@foss.st.com>
77
*/
88

9+
#include <linux/bits.h>
10+
#include <linux/device.h>
11+
912
#define to_stm32_pcie(x) dev_get_drvdata((x)->dev)
1013

1114
#define STM32MP25_PCIECR_TYPE_MASK GENMASK(11, 8)

0 commit comments

Comments
 (0)