[PATCH AUTOSEL 6.18] bus: mhi: host: pci_generic: Round up nr_irqs to power of two
From: Sasha Levin
Date: Mon Aug 31 2026 - 14:52:14 EST
From: Javier Achirica <jachirica@xxxxxxxxx>
[ Upstream commit 86f6dc05ea051fa03ebc03174bc00f734593465d ]
When an MHI device uses standard MSI, the PCI core requires the allocated
number of vectors to be a strict power of two. But devices will only ask
for the irqs they need, so they might not be properly aligned.
Make sure a power-of-2 number of vectors is requested.
Signed-off-by: Javier Achirica <jachirica@xxxxxxxxx>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxxxxxxxx>
Link: https://patch.msgid.link/CACixm21q7b_diEx5COZxVZm9EhZ0hnakM_WBjEWcCsznfWeniw@xxxxxxxxxxxxxx
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
LLM Generated explanations, may be completely bogus:
The background history search finished, but it wasn’t useful: it used
`git log -S "mhi_pci_get_irqs" --all`, which is slow and returned
unrelated commits (mptcp, SMC, xfs), not the MHI driver introduction.
>From the earlier analysis (without `--all`), `git blame` on the IRQ
allocation lines shows they’ve been in
`drivers/bus/mhi/host/pci_generic.c` since the `6bda50f4333fa` baseline
in this 6.18.43 tree — so the bug has been present since that code
landed here.
**Verdict for 6.18.y: YES** — real SDX55 modem failure on MSI,
maintainer-approved one-line fix, buggy code confirmed present in this
tree.
drivers/bus/mhi/host/pci_generic.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
index 646f3bcdc636a..a5b47728f9aba 100644
--- a/drivers/bus/mhi/host/pci_generic.c
+++ b/drivers/bus/mhi/host/pci_generic.c
@@ -1139,7 +1139,8 @@ static int mhi_pci_get_irqs(struct mhi_controller *mhi_cntrl,
*/
mhi_cntrl->nr_irqs = 1 + mhi_cntrl_config->num_events;
- nr_vectors = pci_alloc_irq_vectors(pdev, 1, mhi_cntrl->nr_irqs, PCI_IRQ_MSIX | PCI_IRQ_MSI);
+ nr_vectors = pci_alloc_irq_vectors(pdev, 1, roundup_pow_of_two(mhi_cntrl->nr_irqs),
+ PCI_IRQ_MSIX | PCI_IRQ_MSI);
if (nr_vectors < 0) {
dev_err(&pdev->dev, "Error allocating MSI vectors %d\n",
nr_vectors);
--
2.53.0