Patch "PCI: iproc: Fix multi-MSI base vector number allocation" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    PCI: iproc: Fix multi-MSI base vector number allocation

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pci-iproc-fix-multi-msi-base-vector-number-allocatio.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 06e371cf2085f276da6c6c54977b565e4861684d
Author: Sandor Bodo-Merle <sbodomerle@xxxxxxxxx>
Date:   Tue Jun 22 17:26:29 2021 +0200

    PCI: iproc: Fix multi-MSI base vector number allocation
    
    [ Upstream commit e673d697b9a234fc3544ac240e173cef8c82b349 ]
    
    Commit fc54bae28818 ("PCI: iproc: Allow allocation of multiple MSIs")
    introduced multi-MSI support with a broken allocation mechanism (it failed
    to reserve the proper number of bits from the inner domain).  Natural
    alignment of the base vector number was also not guaranteed.
    
    Link: https://lore.kernel.org/r/20210622152630.40842-1-sbodomerle@xxxxxxxxx
    Fixes: fc54bae28818 ("PCI: iproc: Allow allocation of multiple MSIs")
    Reported-by: Pali Rohár <pali@xxxxxxxxxx>
    Signed-off-by: Sandor Bodo-Merle <sbodomerle@xxxxxxxxx>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx>
    Acked-by: Marc Zyngier <maz@xxxxxxxxxx>
    Acked-by: Pali Rohár <pali@xxxxxxxxxx>
    Acked-by: Ray Jui <ray.jui@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pci/controller/pcie-iproc-msi.c b/drivers/pci/controller/pcie-iproc-msi.c
index f40d17b285c5..b77811dcead1 100644
--- a/drivers/pci/controller/pcie-iproc-msi.c
+++ b/drivers/pci/controller/pcie-iproc-msi.c
@@ -252,18 +252,18 @@ static int iproc_msi_irq_domain_alloc(struct irq_domain *domain,
 
 	mutex_lock(&msi->bitmap_lock);
 
-	/* Allocate 'nr_cpus' number of MSI vectors each time */
-	hwirq = bitmap_find_next_zero_area(msi->bitmap, msi->nr_msi_vecs, 0,
-					   msi->nr_cpus, 0);
-	if (hwirq < msi->nr_msi_vecs) {
-		bitmap_set(msi->bitmap, hwirq, msi->nr_cpus);
-	} else {
-		mutex_unlock(&msi->bitmap_lock);
-		return -ENOSPC;
-	}
+	/*
+	 * Allocate 'nr_irqs' multiplied by 'nr_cpus' number of MSI vectors
+	 * each time
+	 */
+	hwirq = bitmap_find_free_region(msi->bitmap, msi->nr_msi_vecs,
+					order_base_2(msi->nr_cpus * nr_irqs));
 
 	mutex_unlock(&msi->bitmap_lock);
 
+	if (hwirq < 0)
+		return -ENOSPC;
+
 	for (i = 0; i < nr_irqs; i++) {
 		irq_domain_set_info(domain, virq + i, hwirq + i,
 				    &iproc_msi_bottom_irq_chip,
@@ -284,7 +284,8 @@ static void iproc_msi_irq_domain_free(struct irq_domain *domain,
 	mutex_lock(&msi->bitmap_lock);
 
 	hwirq = hwirq_to_canonical_hwirq(msi, data->hwirq);
-	bitmap_clear(msi->bitmap, hwirq, msi->nr_cpus);
+	bitmap_release_region(msi->bitmap, hwirq,
+			      order_base_2(msi->nr_cpus * nr_irqs));
 
 	mutex_unlock(&msi->bitmap_lock);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux