]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vdpa/octeon_ep: fix IRQ-to-ring mapping in interrupt handler
authorSrujana Challa <schalla@marvell.com>
Tue, 24 Feb 2026 09:52:26 +0000 (15:22 +0530)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 10 Jun 2026 06:17:00 +0000 (02:17 -0400)
Look up the IRQ index in oct_hw->irqs instead of assuming
irq - irqs[0]. This supports non-contiguous IRQ numbers and
avoids incorrect ring indexing when irqs[0] is not the base.

Fixes: 26f8ce06af64 ("vdpa/octeon_ep: enable support for multiple interrupts per device")
Signed-off-by: Srujana Challa <schalla@marvell.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260224095226.1001151-5-schalla@marvell.com>

drivers/vdpa/octeon_ep/octep_vdpa_main.c

index 5b9d7663237694b4b6237b1326b0fbfe650949bf..5b35993750f57f2a170daa3fa973e26749b6763c 100644 (file)
@@ -77,7 +77,7 @@ static irqreturn_t octep_vdpa_dev_event_handler(int irq, void *data)
 static irqreturn_t octep_vdpa_intr_handler(int irq, void *data)
 {
        struct octep_hw *oct_hw = data;
-       int i;
+       int i, start_ring_idx = -1;
 
        /* Each device has multiple interrupts (nb_irqs) shared among rings
         * (nr_vring). Device interrupts are mapped to the rings in a
@@ -90,7 +90,16 @@ static irqreturn_t octep_vdpa_intr_handler(int irq, void *data)
         * 7 -> 7, 15, 23, 31, 39, 47, 55, 63;
         */
 
-       for (i = irq - oct_hw->irqs[0]; i < oct_hw->nr_vring; i += oct_hw->nb_irqs) {
+       for (i = 0; i < oct_hw->nb_irqs; i++) {
+               if (oct_hw->irqs[i] == irq) {
+                       start_ring_idx = i;
+                       break;
+               }
+       }
+       if (start_ring_idx == -1)
+               return IRQ_NONE;
+
+       for (i = start_ring_idx; i < oct_hw->nr_vring; i += oct_hw->nb_irqs) {
                if (ioread8(oct_hw->vqs[i].cb_notify_addr)) {
                        /* Acknowledge the per ring notification to the device */
                        iowrite8(0, oct_hw->vqs[i].cb_notify_addr);