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

PCI: dwc: Perform host_init() before registering msi

On the Qualcomm sc8180x platform the bootloader does something related
to PCI that leaves a pending "msi" interrupt, which with the current
ordering often fires before init has a chance to enable the clocks that
are necessary for the interrupt handler to access the hardware.

Move the host_init() call before the registration of the "msi" interrupt
handler to ensure the host driver has a chance to enable the clocks.

The assignment of the bridge's ops and child_ops is moved along, because
at least the TI Keystone driver overwrites these in its host_init
callback.

Link: https://lore.kernel.org/r/20210823154958.305677-1-bjorn.andersson@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>

authored by

Bjorn Andersson and committed by
Lorenzo Pieralisi
7e919677 5b840256

+10 -9
+10 -9
drivers/pci/controller/dwc/pcie-designware-host.c
··· 335 335 if (pci->link_gen < 1) 336 336 pci->link_gen = of_pci_get_max_link_speed(np); 337 337 338 + /* Set default bus ops */ 339 + bridge->ops = &dw_pcie_ops; 340 + bridge->child_ops = &dw_child_pcie_ops; 341 + 342 + if (pp->ops->host_init) { 343 + ret = pp->ops->host_init(pp); 344 + if (ret) 345 + return ret; 346 + } 347 + 338 348 if (pci_msi_enabled()) { 339 349 pp->has_msi_ctrl = !(pp->ops->msi_host_init || 340 350 of_property_read_bool(np, "msi-parent") || ··· 398 388 } 399 389 } 400 390 401 - /* Set default bus ops */ 402 - bridge->ops = &dw_pcie_ops; 403 - bridge->child_ops = &dw_child_pcie_ops; 404 - 405 - if (pp->ops->host_init) { 406 - ret = pp->ops->host_init(pp); 407 - if (ret) 408 - goto err_free_msi; 409 - } 410 391 dw_pcie_iatu_detect(pci); 411 392 412 393 dw_pcie_setup_rc(pp);