diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-08-31 18:55:10 -0400 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2018-09-18 05:13:14 -0400 |
commit | 6e5da6f7d82474e94c2d4a38cf9ca4edbb3e03a0 (patch) | |
tree | 3839092f405814849f33da32c7037e69d15bba5f /drivers/pci/controller | |
parent | 0ee2c1f2429f74328c82ea559b127c96d5224ccd (diff) |
PCI: qcom: Fix error handling in runtime PM support
The driver does not cope with the fact that probe can fail in a number
of cases after enabling runtime PM on the device; this results in
warnings about "Unbalanced pm_runtime_enable". Furthermore if probe
fails after invoking qcom_pcie_host_init() the power-domain will be left
referenced.
As it is not possible for the error handling in qcom_pcie_host_init() to
handle errors happening after returning from that function the
pm_runtime_get_sync() is moved to qcom_pcie_probe() as well.
Fixes: 854b69efbdd2 ("PCI: qcom: add runtime pm support to pcie_port")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Stanimir Varbanov <svarbanov@mm-sol.com>
Diffstat (limited to 'drivers/pci/controller')
-rw-r--r-- | drivers/pci/controller/dwc/pcie-qcom.c | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 4352c1cb926d..d185ea5fe996 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c | |||
@@ -1089,7 +1089,6 @@ static int qcom_pcie_host_init(struct pcie_port *pp) | |||
1089 | struct qcom_pcie *pcie = to_qcom_pcie(pci); | 1089 | struct qcom_pcie *pcie = to_qcom_pcie(pci); |
1090 | int ret; | 1090 | int ret; |
1091 | 1091 | ||
1092 | pm_runtime_get_sync(pci->dev); | ||
1093 | qcom_ep_reset_assert(pcie); | 1092 | qcom_ep_reset_assert(pcie); |
1094 | 1093 | ||
1095 | ret = pcie->ops->init(pcie); | 1094 | ret = pcie->ops->init(pcie); |
@@ -1126,7 +1125,6 @@ err_disable_phy: | |||
1126 | phy_power_off(pcie->phy); | 1125 | phy_power_off(pcie->phy); |
1127 | err_deinit: | 1126 | err_deinit: |
1128 | pcie->ops->deinit(pcie); | 1127 | pcie->ops->deinit(pcie); |
1129 | pm_runtime_put(pci->dev); | ||
1130 | 1128 | ||
1131 | return ret; | 1129 | return ret; |
1132 | } | 1130 | } |
@@ -1216,6 +1214,12 @@ static int qcom_pcie_probe(struct platform_device *pdev) | |||
1216 | return -ENOMEM; | 1214 | return -ENOMEM; |
1217 | 1215 | ||
1218 | pm_runtime_enable(dev); | 1216 | pm_runtime_enable(dev); |
1217 | ret = pm_runtime_get_sync(dev); | ||
1218 | if (ret < 0) { | ||
1219 | pm_runtime_disable(dev); | ||
1220 | return ret; | ||
1221 | } | ||
1222 | |||
1219 | pci->dev = dev; | 1223 | pci->dev = dev; |
1220 | pci->ops = &dw_pcie_ops; | 1224 | pci->ops = &dw_pcie_ops; |
1221 | pp = &pci->pp; | 1225 | pp = &pci->pp; |
@@ -1225,44 +1229,56 @@ static int qcom_pcie_probe(struct platform_device *pdev) | |||
1225 | pcie->ops = of_device_get_match_data(dev); | 1229 | pcie->ops = of_device_get_match_data(dev); |
1226 | 1230 | ||
1227 | pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW); | 1231 | pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW); |
1228 | if (IS_ERR(pcie->reset)) | 1232 | if (IS_ERR(pcie->reset)) { |
1229 | return PTR_ERR(pcie->reset); | 1233 | ret = PTR_ERR(pcie->reset); |
1234 | goto err_pm_runtime_put; | ||
1235 | } | ||
1230 | 1236 | ||
1231 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "parf"); | 1237 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "parf"); |
1232 | pcie->parf = devm_ioremap_resource(dev, res); | 1238 | pcie->parf = devm_ioremap_resource(dev, res); |
1233 | if (IS_ERR(pcie->parf)) | 1239 | if (IS_ERR(pcie->parf)) { |
1234 | return PTR_ERR(pcie->parf); | 1240 | ret = PTR_ERR(pcie->parf); |
1241 | goto err_pm_runtime_put; | ||
1242 | } | ||
1235 | 1243 | ||
1236 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); | 1244 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); |
1237 | pci->dbi_base = devm_pci_remap_cfg_resource(dev, res); | 1245 | pci->dbi_base = devm_pci_remap_cfg_resource(dev, res); |
1238 | if (IS_ERR(pci->dbi_base)) | 1246 | if (IS_ERR(pci->dbi_base)) { |
1239 | return PTR_ERR(pci->dbi_base); | 1247 | ret = PTR_ERR(pci->dbi_base); |
1248 | goto err_pm_runtime_put; | ||
1249 | } | ||
1240 | 1250 | ||
1241 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi"); | 1251 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi"); |
1242 | pcie->elbi = devm_ioremap_resource(dev, res); | 1252 | pcie->elbi = devm_ioremap_resource(dev, res); |
1243 | if (IS_ERR(pcie->elbi)) | 1253 | if (IS_ERR(pcie->elbi)) { |
1244 | return PTR_ERR(pcie->elbi); | 1254 | ret = PTR_ERR(pcie->elbi); |
1255 | goto err_pm_runtime_put; | ||
1256 | } | ||
1245 | 1257 | ||
1246 | pcie->phy = devm_phy_optional_get(dev, "pciephy"); | 1258 | pcie->phy = devm_phy_optional_get(dev, "pciephy"); |
1247 | if (IS_ERR(pcie->phy)) | 1259 | if (IS_ERR(pcie->phy)) { |
1248 | return PTR_ERR(pcie->phy); | 1260 | ret = PTR_ERR(pcie->phy); |
1261 | goto err_pm_runtime_put; | ||
1262 | } | ||
1249 | 1263 | ||
1250 | ret = pcie->ops->get_resources(pcie); | 1264 | ret = pcie->ops->get_resources(pcie); |
1251 | if (ret) | 1265 | if (ret) |
1252 | return ret; | 1266 | goto err_pm_runtime_put; |
1253 | 1267 | ||
1254 | pp->ops = &qcom_pcie_dw_ops; | 1268 | pp->ops = &qcom_pcie_dw_ops; |
1255 | 1269 | ||
1256 | if (IS_ENABLED(CONFIG_PCI_MSI)) { | 1270 | if (IS_ENABLED(CONFIG_PCI_MSI)) { |
1257 | pp->msi_irq = platform_get_irq_byname(pdev, "msi"); | 1271 | pp->msi_irq = platform_get_irq_byname(pdev, "msi"); |
1258 | if (pp->msi_irq < 0) | 1272 | if (pp->msi_irq < 0) { |
1259 | return pp->msi_irq; | 1273 | ret = pp->msi_irq; |
1274 | goto err_pm_runtime_put; | ||
1275 | } | ||
1260 | } | 1276 | } |
1261 | 1277 | ||
1262 | ret = phy_init(pcie->phy); | 1278 | ret = phy_init(pcie->phy); |
1263 | if (ret) { | 1279 | if (ret) { |
1264 | pm_runtime_disable(&pdev->dev); | 1280 | pm_runtime_disable(&pdev->dev); |
1265 | return ret; | 1281 | goto err_pm_runtime_put; |
1266 | } | 1282 | } |
1267 | 1283 | ||
1268 | platform_set_drvdata(pdev, pcie); | 1284 | platform_set_drvdata(pdev, pcie); |
@@ -1271,10 +1287,16 @@ static int qcom_pcie_probe(struct platform_device *pdev) | |||
1271 | if (ret) { | 1287 | if (ret) { |
1272 | dev_err(dev, "cannot initialize host\n"); | 1288 | dev_err(dev, "cannot initialize host\n"); |
1273 | pm_runtime_disable(&pdev->dev); | 1289 | pm_runtime_disable(&pdev->dev); |
1274 | return ret; | 1290 | goto err_pm_runtime_put; |
1275 | } | 1291 | } |
1276 | 1292 | ||
1277 | return 0; | 1293 | return 0; |
1294 | |||
1295 | err_pm_runtime_put: | ||
1296 | pm_runtime_put(dev); | ||
1297 | pm_runtime_disable(dev); | ||
1298 | |||
1299 | return ret; | ||
1278 | } | 1300 | } |
1279 | 1301 | ||
1280 | static const struct of_device_id qcom_pcie_match[] = { | 1302 | static const struct of_device_id qcom_pcie_match[] = { |