Dmitry Adamushko wrote:
Hi,

the following question/suggestion :

it could be good to eliminate the use of rthal_critical_enter/exit()
from rthal_irq_request() if it's not
strictly necessary.


the proposal :

int rthal_irq_request (unsigned irq,
                       rthal_irq_handler_t handler,
                       rthal_irq_ackfn_t ackfn,
                       void *cookie)
{
-    unsigned long flags;
    int err = 0;

    if (handler == NULL || irq >= IPIPE_NR_IRQS)
        return -EINVAL;

-    flags = rthal_critical_enter(NULL);
-
-    if (rthal_irq_handler(&rthal_domain, irq) != NULL)
-       {
-       err = -EBUSY;
-       goto unlock_and_exit;
-       }
-
    err = rthal_virtualize_irq(&rthal_domain,
                               irq,
                               handler,
                               cookie,
                               ackfn,
-                              IPIPE_DYNAMIC_MASK);
+                               IPIPE_DYNAMIC_MASK|IPIPE_EXCLUSIVE_MASK);

- unlock_and_exit:
-
-    rthal_critical_exit(flags);
-
    return err;
}

IPIPE_EXCLUSIVE_MASK causes a -EBUZY error to be returned by
ipipe_virtualize_irq() when
handler != NULL and the current ipd->irqs[irq].handler != NULL.


Sounds reasonable. Using the synchronized inter-processor lock is most often a bad idea except in very specific initialization/shutdown stuff at Adeos level anyway, and this does introduce deadlock issues at Xenomai level when inadvertently using it with the nklock held, so let's get rid of this. In the rthal_irq_request() case, it's even useless indeed.

(IPIPE_EXCLUSIVE_MASK is actually not used at the moment anywere,
though ipipe_catch_event() is mentioned in comments).


The existing flag was aimed to implement self-directed events, but I eventually this support differently, so we can recycle it safely.

Another variant :

ipipe_virtualize_irq() should always return -EBUZY when handler !=
NULL and the current ipd->irqs[irq].handler != NULL,
not taking into account the IPIPE_EXCLUSIVE_FLAG.



<snip>

--
Best regards,
Dmitry Adamushko



--

Philippe.

_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to