]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dmaengine: idxd: Refactor halt handler
authorFenghua Yu <fenghua.yu@intel.com>
Fri, 22 Nov 2024 23:30:27 +0000 (15:30 -0800)
committerVinod Koul <vkoul@kernel.org>
Tue, 24 Dec 2024 10:38:04 +0000 (16:08 +0530)
Define a halt handling helper idxd_halt(). Refactor the halt interrupt
handler to call the helper. This will simplify the Function Level
Reset (FLR) code.

No functional change.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20241122233028.2762809-5-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/idxd/irq.c

index fc049c9c9892e66302929afd9b0f99b881feca92..a46e58b756a55818f90b09e3f6c136a6cedd1708 100644 (file)
@@ -383,15 +383,43 @@ static void process_evl_entries(struct idxd_device *idxd)
        mutex_unlock(&evl->lock);
 }
 
+static irqreturn_t idxd_halt(struct idxd_device *idxd)
+{
+       union gensts_reg gensts;
+
+       gensts.bits = ioread32(idxd->reg_base + IDXD_GENSTATS_OFFSET);
+       if (gensts.state == IDXD_DEVICE_STATE_HALT) {
+               idxd->state = IDXD_DEV_HALTED;
+               if (gensts.reset_type == IDXD_DEVICE_RESET_SOFTWARE) {
+                       /*
+                        * If we need a software reset, we will throw the work
+                        * on a system workqueue in order to allow interrupts
+                        * for the device command completions.
+                        */
+                       INIT_WORK(&idxd->work, idxd_device_reinit);
+                       queue_work(idxd->wq, &idxd->work);
+               } else {
+                       idxd->state = IDXD_DEV_HALTED;
+                       idxd_wqs_quiesce(idxd);
+                       idxd_wqs_unmap_portal(idxd);
+                       idxd_device_clear_state(idxd);
+                       dev_err(&idxd->pdev->dev,
+                               "idxd halted, need %s.\n",
+                               gensts.reset_type == IDXD_DEVICE_RESET_FLR ?
+                               "FLR" : "system reset");
+               }
+       }
+
+       return IRQ_HANDLED;
+}
+
 irqreturn_t idxd_misc_thread(int vec, void *data)
 {
        struct idxd_irq_entry *irq_entry = data;
        struct idxd_device *idxd = ie_to_idxd(irq_entry);
        struct device *dev = &idxd->pdev->dev;
-       union gensts_reg gensts;
        u32 val = 0;
        int i;
-       bool err = false;
        u32 cause;
 
        cause = ioread32(idxd->reg_base + IDXD_INTCAUSE_OFFSET);
@@ -401,7 +429,7 @@ irqreturn_t idxd_misc_thread(int vec, void *data)
        iowrite32(cause, idxd->reg_base + IDXD_INTCAUSE_OFFSET);
 
        if (cause & IDXD_INTC_HALT_STATE)
-               goto halt;
+               return idxd_halt(idxd);
 
        if (cause & IDXD_INTC_ERR) {
                spin_lock(&idxd->dev_lock);
@@ -435,7 +463,6 @@ irqreturn_t idxd_misc_thread(int vec, void *data)
                for (i = 0; i < 4; i++)
                        dev_warn_ratelimited(dev, "err[%d]: %#16.16llx\n",
                                             i, idxd->sw_err.bits[i]);
-               err = true;
        }
 
        if (cause & IDXD_INTC_INT_HANDLE_REVOKED) {
@@ -480,34 +507,6 @@ irqreturn_t idxd_misc_thread(int vec, void *data)
                dev_warn_once(dev, "Unexpected interrupt cause bits set: %#x\n",
                              val);
 
-       if (!err)
-               goto out;
-
-halt:
-       gensts.bits = ioread32(idxd->reg_base + IDXD_GENSTATS_OFFSET);
-       if (gensts.state == IDXD_DEVICE_STATE_HALT) {
-               idxd->state = IDXD_DEV_HALTED;
-               if (gensts.reset_type == IDXD_DEVICE_RESET_SOFTWARE) {
-                       /*
-                        * If we need a software reset, we will throw the work
-                        * on a system workqueue in order to allow interrupts
-                        * for the device command completions.
-                        */
-                       INIT_WORK(&idxd->work, idxd_device_reinit);
-                       queue_work(idxd->wq, &idxd->work);
-               } else {
-                       idxd->state = IDXD_DEV_HALTED;
-                       idxd_wqs_quiesce(idxd);
-                       idxd_wqs_unmap_portal(idxd);
-                       idxd_device_clear_state(idxd);
-                       dev_err(&idxd->pdev->dev,
-                               "idxd halted, need %s.\n",
-                               gensts.reset_type == IDXD_DEVICE_RESET_FLR ?
-                               "FLR" : "system reset");
-               }
-       }
-
-out:
        return IRQ_HANDLED;
 }