Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: rockchip-dwc: Reset core at driver probe

The PCIe controller is in an unknown state at driver probe. This can
lead to undesireable effects when the driver attempts to configure the
controller.

Prevent issues in the future by resetting the core during probe.

Link: https://lore.kernel.org/r/20220429123832.2376381-3-pgwipeout@gmail.com
Tested-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

authored by

Peter Geis and committed by
Lorenzo Pieralisi
431e7d2e 931262e6

+10 -13
+10 -13
drivers/pci/controller/dwc/pcie-dw-rockchip.c
··· 152 152 if (IS_ERR(rockchip->rst_gpio)) 153 153 return PTR_ERR(rockchip->rst_gpio); 154 154 155 + rockchip->rst = devm_reset_control_array_get_exclusive(&pdev->dev); 156 + if (IS_ERR(rockchip->rst)) 157 + return dev_err_probe(&pdev->dev, PTR_ERR(rockchip->rst), 158 + "failed to get reset lines\n"); 159 + 155 160 return 0; 156 161 } 157 162 ··· 187 182 phy_power_off(rockchip->phy); 188 183 } 189 184 190 - static int rockchip_pcie_reset_control_release(struct rockchip_pcie *rockchip) 191 - { 192 - struct device *dev = rockchip->pci.dev; 193 - 194 - rockchip->rst = devm_reset_control_array_get_exclusive(dev); 195 - if (IS_ERR(rockchip->rst)) 196 - return dev_err_probe(dev, PTR_ERR(rockchip->rst), 197 - "failed to get reset lines\n"); 198 - 199 - return reset_control_deassert(rockchip->rst); 200 - } 201 - 202 185 static const struct dw_pcie_ops dw_pcie_ops = { 203 186 .link_up = rockchip_pcie_link_up, 204 187 .start_link = rockchip_pcie_start_link, ··· 215 222 if (ret) 216 223 return ret; 217 224 225 + ret = reset_control_assert(rockchip->rst); 226 + if (ret) 227 + return ret; 228 + 218 229 /* DON'T MOVE ME: must be enable before PHY init */ 219 230 rockchip->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3"); 220 231 if (IS_ERR(rockchip->vpcie3v3)) { ··· 238 241 if (ret) 239 242 goto disable_regulator; 240 243 241 - ret = rockchip_pcie_reset_control_release(rockchip); 244 + ret = reset_control_deassert(rockchip->rst); 242 245 if (ret) 243 246 goto deinit_phy; 244 247