From 02aa678d4ca2e968207f7208e30e4f0d8155b12d Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Mon, 1 Oct 2018 10:10:09 +0900 Subject: [PATCH] Fix interrupt handling. --- chopstx.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/chopstx.c b/chopstx.c index 051b3cb..ce57312 100644 --- a/chopstx.c +++ b/chopstx.c @@ -969,6 +969,7 @@ chx_cond_hook (struct chx_px *px, struct chx_poll_head *pd) { /* Condition doesn't met. * Register the proxy to wait for the condition. */ + pc->ready = 0; chx_cpu_sched_lock (); chx_spin_lock (&pc->cond->lock); ll_prio_enqueue ((struct chx_pq *)px, &pc->cond->q); @@ -1012,10 +1013,19 @@ chx_intr_hook (struct chx_px *px, struct chx_poll_head *pd) chopstx_testcancel (); chx_cpu_sched_lock (); px->v = intr->irq_num; - chx_spin_lock (&q_intr.lock); - ll_prio_enqueue ((struct chx_pq *)px, &q_intr.q); - chx_enable_intr (intr->irq_num); - chx_spin_unlock (&q_intr.lock); + if (intr->ready) + { + chx_spin_lock (&px->lock); + (*px->counter_p)++; + chx_spin_unlock (&px->lock); + } + else + { + chx_spin_lock (&q_intr.lock); + ll_prio_enqueue ((struct chx_pq *)px, &q_intr.q); + chx_enable_intr (intr->irq_num); + chx_spin_unlock (&q_intr.lock); + } chx_cpu_sched_unlock (); } @@ -1047,7 +1057,10 @@ chopstx_intr_done (chopstx_intr_t *intr) chx_dmb (); if (intr->ready) - chx_clr_intr (intr->irq_num); + { + chx_clr_intr (intr->irq_num); + intr->ready = 0; + } } @@ -1215,6 +1228,7 @@ chx_join_hook (struct chx_px *px, struct chx_poll_head *pd) { /* Not yet exited. * Register the proxy to wait for TP's exit. */ + pj->ready = 0; px->v = (uintptr_t)tp; chx_spin_lock (&q_join.lock); ll_prio_enqueue ((struct chx_pq *)px, &q_join.q); @@ -1358,7 +1372,6 @@ chopstx_poll (uint32_t *usec_p, int n, struct chx_poll_head *const pd_array[]) for (i = 0; i < n; i++) { pd = pd_array[i]; - pd->ready = 0; px[i].ready_p = &pd->ready; if (pd->type == CHOPSTX_POLL_COND) chx_cond_hook (&px[i], pd);