Fix interrupt handling.

This commit is contained in:
NIIBE Yutaka
2018-10-01 10:10:09 +09:00
parent d25cee5040
commit 02aa678d4c

View File

@@ -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);