Skip to content

Commit 55482b9

Browse files
wensbjorn-helgaas
authored andcommitted
PCI: mediatek-gen3: Disable device if further setup fails
If further setup fails after the device is powered on and link training succeeds, we want to place the device back in a quiescence state to avoid unintended activity and save power. This also helps with power state tracking and balancing once pwrctrl API is integrated. Power down the device in the error paths of mtk_pcie_startup_port() and mtk_pcie_probe(). Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://patch.msgid.link/20260324052002.4072430-7-wenst@chromium.org
1 parent 69b8d3c commit 55482b9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/pci/controller/pcie-mediatek-gen3.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,14 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
555555
dev_err(pcie->dev,
556556
"PCIe link down, current LTSSM state: %s (%#x)\n",
557557
ltssm_state, val);
558-
return err;
558+
goto err_power_down_device;
559559
}
560560

561561
return 0;
562+
563+
err_power_down_device:
564+
mtk_pcie_devices_power_down(pcie);
565+
return err;
562566
}
563567

564568
#define MTK_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
@@ -1218,6 +1222,7 @@ static int mtk_pcie_probe(struct platform_device *pdev)
12181222
return 0;
12191223

12201224
err_power_down_pcie:
1225+
mtk_pcie_devices_power_down(pcie);
12211226
mtk_pcie_power_down(pcie);
12221227
err_tear_down_irq:
12231228
mtk_pcie_irq_teardown(pcie);

0 commit comments

Comments
 (0)