cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
chaitusvk
Adventurer
Adventurer
295 Views
Registered: ‎02-15-2019

signal from kernel to application

In petalinux i am writing driver for axi counter with interupt .. i am using signal to inform my app that counter value incremented 

 

in irq handler in driver i added 

 

static irqreturn_t mymod_irq(int irq, void *lp)
{
	//printk("mymod interrupt\n");

	struct siginfo info;
    //printk(KERN_INFO "Shared IRQ: Interrupt Occurred");
    
    //Sending signal to app
    memset(&info, 0, sizeof(struct siginfo));
    info.si_signo = SIGETX;
    info.si_code = SI_QUEUE;
    info.si_int = 1;
 
    if (task != NULL) {
        printk(KERN_INFO "Sending signal to app\n");
        if(send_sig_info(SIGETX, &info, task) < 0) {
            printk(KERN_INFO "Unable to send signal\n");
        }
    }

	return IRQ_HANDLED;
}

 

 

i am getting error as shown in send_signal_info 

 Screenshot from 2020-11-27 16-48-48.png 

How to send signals from kernal to userspace

0 Kudos
1 Reply
boba-milk-tea
Visitor
Visitor
97 Views
Registered: ‎12-09-2020

You need to include these in your source <linux/sched/signal.h> and <asm/siginfo.h>

Also typecast to (struct kernel_signinfo *) when calling send_sig_info()

Give this a try:

#include <linux/sched/signal.h>
#include <asm/siginfo.h>

static irqreturn_t mymod_irq(int irq, void *lp){
    //printk("mymod interrupt\n");

    struct siginfo info;
    //printk(KERN_INFO "Shared IRQ: Interrupt Occurred");
    
    //Sending signal to app
    memset(&info, 0, sizeof(struct siginfo));
    info.si_signo = SIGETX;
    info.si_code = SI_QUEUE;
    info.si_int = 1;
 
    if (task != NULL) {
        printk(KERN_INFO "Sending signal to app\n");
        if(send_sig_info(SIGETX, (struct kernel_siginfo *) &info, task) < 0) {
            printk(KERN_INFO "Unable to send signal\n");
        }
    }

	return IRQ_HANDLED;
}
0 Kudos