wake_up_interruptible ?
Hi all!
I've got a kernel module which creates a chrdev. In the read file operation I have a interruptible_sleep_on. Now I want to wake it up from an IPIPE interrupt handler (i.e. unblock the read operation from user-space on the chrdev), but I bet wake_up_interruptible is forbidden in HRT context, isn't it ?
Thanks and best regards,
Hannes.
Hi,
Quoted 6 lines
I've got a kernel module which creates a chrdev. In the read file operation I have a
interruptible_sleep_on. Now I want to wake it up from an IPIPE interrupt handler (i.e. unblock the read operation from user-space on the chrdev), but I betwake_up_interruptibleis forbidden in HRT context, isn't it ?
Why not using a semaphore :
in your read fops function :
down_interruptible(pointer_read_sem);
in your IPIPE interrupt handler:
up(pointer_read_sem);
In an interrupt handler, I think you can use a Linux semaphore. I am quite sure semaphores are used in the Xenomai pipe implementation.
Best regards.
Alexis.
Quoted 14 lines · Alexis Berlemont
Hi,
Quoted 6 lines
I've got a kernel module which creates a chrdev. In the read file operation I have a
interruptible_sleep_on. Now I want to wake it up from an IPIPE interrupt handler (i.e. unblock the read operation from user-space on the chrdev), but I betwake_up_interruptibleis forbidden in HRT context, isn't it ?Why not using a semaphore :
in your read fops function :
Quoted 8 lines
down_interruptible(pointer_read_sem);in your IPIPE interrupt handler:
up(pointer_read_sem);In an interrupt handler, I think you can use a Linux semaphore. I am quite sure semaphores are used in the Xenomai pipe implementation.
For the "up" function to work properly, Linux scheduler data have to be in a consistent state. But with the IPIPE patch, Linux may be preempted by a higher priority domain at any point where hardware interrupts are not disabled, and where scheduler data are not necessarily in a consistent state.
One way to wake up a regular Linux thread from a higher priority domain interrupt handler is to propagate this interrupt after HRT processing in higher priority domains and run wake_up_interruptible from Linux domain interrupt handler.
Signature · 1 line
Gilles Chanteperdrix.
Thank you both Alexis and Gilles!
I think I'll pass on the blocking chrdev for now until I exactly understand what is allowed and what is not within IPIPE.
For now, I'll poll from userspace and see if data is available. I wanted to use the blocking read for notification only anyway.
Thanks again,
Hannes.
Gilles, now I think I've got what you mean.
Something like this ?
inter_domain_irq = ipipe_alloc_virq();
ret = request_irq(inter_domain_irq, linux_handler, SA_INTERRUPT, "virtualIRQ", NULL); enable_irq(inter_domain_irq);
void ipipe_handler(unsigned irq) {
[...]
ipipe_trigger_irq(inter_domain_irq);
[...]
}void linux_handler(void) {
wake_up_interruptible(&skeleton_wait);
}I've tried this, but the linux_handler is never called. I bet I'm missing something very trivial here, but it doesn't come to mind...
On the other hand, if I request_irq() for the parallelport INT and pass that INT from IPIPE to linux, the linux_handler is called. But it doesn't work with a virq.
Thanks and best regards,
Hannes.
Hi,
Sorry for the silly things I said earlier, forgot the most important step :
the soft irq...
Quoted 13 lines
Something like this ?
inter_domain_irq=ipipe_alloc_virq();
ret =request_irq(inter_domain_irq, linux_handler, SA_INTERRUPT, "virtualIRQ", NULL);enable_irq(inter_domain_irq);void ipipe_handler(unsigned irq) { [...] ipipe_trigger_irq(inter_domain_irq); [...] }
Quoted 3 lines
void linux_handler(void) {
wake_up_interruptible(&skeleton_wait);
}I think you should not use request_irq() but ipipe_virtualize_irq() :
inter_domain_irq = ipipe_alloc_virq(); -ret=request_irq(inter_domain_irq,linux_handler,SA_INTERRUPT,"virtualIRQ",NULL);
+ ret = ipipe_virtualize_irq(ipipe_root_domain,
inter_domain_irq, &ipipe_handler, NULL, NULL, IPIPE_HANDLE_MASK);
-enable_irq(inter_domain_irq);
Your function linux_handler will be called in the root domain (Linux) any time you use the function ipipe_trigger_irq(...inter_domain_irq...) in a non Linux domain.
If you want a good example, you can have a look at the function rthal_init() (in xenomai/ksrc/arch/generic/hal.c)
I think you should also double-check what I am saying ;) I am bit tired and .. silly.
Thanks Gilles.
Alexis.
Quoted 20 lines · Hannes Mayer
Gilles, now I think I've got what you mean.
Something like this ?
inter_domain_irq=ipipe_alloc_virq();
ret =request_irq(inter_domain_irq, linux_handler, SA_INTERRUPT, "virtualIRQ", NULL);enable_irq(inter_domain_irq);void ipipe_handler(unsigned irq) { [...] ipipe_trigger_irq(inter_domain_irq); [...] }void linux_handler(void) { wake_up_interruptible(&skeleton_wait); }
Quoted 7 lines
I've tried this, but the
linux_handleris never called. I bet I'm missing something very trivial here, but it doesn't come to mind...On the other hand, if I
request_irq()for the parallelport INT and pass that INT from IPIPE to linux, thelinux_handleris called. But it doesn't work with a virq.
If you have a real irq, you do not need to allocate a virtual irq.
intall an handler in the HRT domain with ipipe_virtualize_irq(), a handler in the Linux domain with request_irq(), and call ipipe_propagate_irq() from within the HRT domain interrupt handler.
Signature · 1 line
Gilles Chanteperdrix.
Quoted 25 lines · Alexis Berlemont
Hi,
Sorry for the silly things I said earlier, forgot the most important step : the soft irq...
Quoted 12 lines
Something like this ?
inter_domain_irq=ipipe_alloc_virq();
ret =request_irq(inter_domain_irq, linux_handler, SA_INTERRUPT, "virtualIRQ", NULL);enable_irq(inter_domain_irq);void ipipe_handler(unsigned irq) { [...] ipipe_trigger_irq(inter_domain_irq); [...] }Quoted 3 lines
void linux_handler(void) { wake_up_interruptible(&skeleton_wait); }I think you should not use
request_irq()butipipe_virtualize_irq():
inter_domain_irq=ipipe_alloc_virq(); -ret=request_irq(inter_domain_irq,linux_handler,SA_INTERRUPT,"virtualIRQ",NULL);
+ ret = ipipe_virtualize_irq(ipipe_root_domain,
Quoted 7 lines
inter_domain_irq, &ipipe_handler, NULL, NULL, IPIPE_HANDLE_MASK);-enable_irq(inter_domain_irq);
Your function
linux_handlerwill be called in the root domain (Linux) any time you use the functionipipe_trigger_irq(...inter_domain_irq...)in a non Linux domain.
Yes, I thought of this too.
I just tried this and it works nicely.
I'm just curious if the wake_up_interruptible in the new ipipe-interrupt handler (linux_handler in the above snippet) will affect HRT in any other ipipe-int-handler in the same domain ?
Thank you very much and best regards,
Hannes.
Gilles Chanteperdrix wrote:
[...]
Quoted 5 lines
If you have a real irq, you do not need to allocate a virtual irq.
intall an handler in the HRT domain with
ipipe_virtualize_irq(), a handler in the Linux domain withrequest_irq(), and callipipe_propagate_irq()from within the HRT domain interrupt handler.
That is solution #2 I already tried and it works :-) But I don't want to block almost all real IRQ's from linux and only propagate when I have data. Instead I prefer to have a more general driver template. But for the private project I'm working on, this solution would be sufficient.
Thank you very much and best regards,
Hannes.
Ciao Gilles! Ciao Alexis!
Just a quick followup:
If I assign an ISR like this
inter_domain_irq = ipipe_alloc_virq(); ipipe_virtualize_irq(ipipe_current_domain, inter_domain_irq,
(ipipe_irq_handler_t)&wake_up_handler,NULL,NULL,IPIPE_DYNAMIC_MASK);
and I have a SYSCALL in the ISR
void wake_up_handler(unsigned irq) {
wake_up_interruptible(&skeleton_wait);
}will that affect other HRT interrupt handlers that *must* remain in HRT ?
Thanks a lot,
Hannes.
Quoted 10 lines · Hannes Mayer
Ciao Gilles! Ciao Alexis!
Just a quick followup:
If I assign an ISR like this
inter_domain_irq=ipipe_alloc_virq(); ipipe_virtualize_irq(ipipe_current_domain,inter_domain_irq,(ipipe_irq_handler_t)&wake_up_handler,NULL,NULL,IPIPE_DYNAMIC_MASK);
Quoted 9 lines
and I have a SYSCALL in the ISR
void wake_up_handler(unsigned irq) { wake_up_interruptible(&skeleton_wait); }will that affect other HRT interrupt handlers that *must* remain in HRT ?
Nope.
Quoted 8 lines
Thanks a lot,
Hannes._______________________________________________
Adeos-main mailing list
[email protected]
https://mail.gna.org/listinfo/adeos-main
Signature · 1 line
Philippe.
Philippe Gerum wrote:
[...]
Quoted 5 lines
Quoted 3 lines
will that affect other HRT interrupt handlers that *must* remain in HRT ?
Nope.
Thanks a lot Philippe!
Best regards,
Hannes.