From 3651aa64b48d46fa8572a94b23c291d81e9d84ea Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Mon, 16 May 2016 20:37:33 +0900
Subject: ll_dequeue for PX only when not ready

---
 chopstx.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/chopstx.c b/chopstx.c
index 36eb0ea..8ff244a 100644
--- a/chopstx.c
+++ b/chopstx.c
@@ -1857,23 +1857,26 @@ chopstx_poll (uint32_t *usec_p, int n, ...)
   for (i = 0; i < n; i++)
     {
       pd = va_arg (ap, struct chx_poll_head *);
+
+      chx_cpu_sched_lock ();
+      chx_spin_lock (&px[i].lock);
       if (pd->type == CHOPSTX_POLL_INTR)
 	{
 	  struct chx_intr *intr = (struct chx_intr *)pd;
 
-	  chx_cpu_sched_lock ();
-	  chx_spin_lock (&q_intr.lock);
 	  if (intr->ready)
 	    chx_clr_intr (intr->irq_num);
 	  else
-	    chx_disable_intr (intr->irq_num);
-	  chx_spin_unlock (&q_intr.lock);
-	  chx_cpu_sched_unlock ();
+	    {
+	      ll_dequeue ((struct chx_pq *)&px[i]);
+	      chx_disable_intr (intr->irq_num);
+	    }
+	}
+      else
+	{
+	  if (pd->ready == 0)
+	    ll_dequeue ((struct chx_pq *)&px[i]);
 	}
-
-      chx_cpu_sched_lock ();
-      chx_spin_lock (&px[i].lock);
-      ll_dequeue ((struct chx_pq *)&px[i]);
       chx_spin_unlock (&px[i].lock);
       chx_cpu_sched_unlock ();
     }
-- 
cgit v1.2.3