drivers: nvme: Add precheck and delay for CQE pending status.
authorKevin.xie <kevin.xie@starfivetech.com>
Thu, 24 Nov 2022 08:59:12 +0000 (16:59 +0800)
committerKevin.xie <kevin.xie@starfivetech.com>
Thu, 24 Nov 2022 10:44:58 +0000 (18:44 +0800)
To workaroud the NVMe I/O timeout problem in bootup S10udev case
which caused by the CQE update lantancy.

Signed-off-by: Kevin.xie <kevin.xie@starfivetech.com>
drivers/nvme/host/pci.c

index 149ecf7..f9321fa 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/io-64-nonatomic-hi-lo.h>
 #include <linux/sed-opal.h>
 #include <linux/pci-p2pdma.h>
+#include <linux/delay.h>
 
 #include "trace.h"
 #include "nvme.h"
@@ -1042,6 +1043,15 @@ static inline int nvme_process_cq(struct nvme_queue *nvmeq)
 {
        int found = 0;
 
+       /*
+        * In some cases, such as udev trigger, cqe status may update
+        * a little bit later than MSI, which cause an irq handle missing.
+        * To workaound, here we will prefetch the status first, and wait
+        * 1us if we get nothing.
+        */
+       if (!nvme_cqe_pending(nvmeq))
+               udelay(1);
+
        while (nvme_cqe_pending(nvmeq)) {
                found++;
                /*