mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
PCI: apple: Initialize pcie->nvecs before use
[ Upstream commitd8650c0c2a] The apple_pcie_setup_port() function computes ilog2(pcie->nvecs) to set up the number of MSIs available for each port. However, it's called before apple_msi_init(), which initializes pcie->nvecs. Luckily, pcie->nvecs is part of kzalloc()-ed structure and, as such, initialized as zero. ilog2(0) happens to be 0xffffffff which then simply configures more MSIs in hardware than we have. This doesn't break anything because we never hand out those vectors. Thus, swap the order of the two calls so that the correctly initialized value is then used. [kwilczynski: commit log] Link: https://lore.kernel.org/linux-pci/20230311133453.63246-1-sven@svenpeter.dev Fixes:476c41ed45("PCI: apple: Implement MSI support") Signed-off-by: Sven Peter <sven@svenpeter.dev> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Reviewed-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7618133eda
commit
c53d53006d
@@ -783,6 +783,10 @@ static int apple_pcie_init(struct pci_config_window *cfg)
|
|||||||
cfg->priv = pcie;
|
cfg->priv = pcie;
|
||||||
INIT_LIST_HEAD(&pcie->ports);
|
INIT_LIST_HEAD(&pcie->ports);
|
||||||
|
|
||||||
|
ret = apple_msi_init(pcie);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
for_each_child_of_node(dev->of_node, of_port) {
|
for_each_child_of_node(dev->of_node, of_port) {
|
||||||
ret = apple_pcie_setup_port(pcie, of_port);
|
ret = apple_pcie_setup_port(pcie, of_port);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@@ -792,7 +796,7 @@ static int apple_pcie_init(struct pci_config_window *cfg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return apple_msi_init(pcie);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int apple_pcie_probe(struct platform_device *pdev)
|
static int apple_pcie_probe(struct platform_device *pdev)
|
||||||
|
|||||||
Reference in New Issue
Block a user