]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bus: mhi: host: pci_generic: Round up nr_irqs to power of two
authorJavier Achirica <jachirica@gmail.com>
Fri, 3 Apr 2026 10:30:03 +0000 (12:30 +0200)
committerManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Tue, 12 May 2026 14:27:13 +0000 (19:57 +0530)
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@gmail.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/CACixm21q7b_diEx5COZxVZm9EhZ0hnakM_WBjEWcCsznfWeniw@mail.gmail.com
drivers/bus/mhi/host/pci_generic.c

index 750da3dbb4c6e2146c776083639a1c14efa97da1..7efcbcf5a59e5bd0f1af2af472cf067b0ac7a9e2 100644 (file)
@@ -1189,7 +1189,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);