Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi guys. I'm currently trying to test the interrupt line on a PowerPC device. To do this I am creating a module that does a simple printk when the Interrupt is triggered. It cross-compiles without any errors or warnings but the problem I'm encountering is that when I try to do an insmod on the target device there is an error that prevents the module from being loaded. The code for the module is:
PHY: mdio@ffe24000:02 - Link is Up - 1000/Full
testing
int_test: module license 'unspecified' taints kernel.
Disabling lock debugging due to kernel taint
testing
If anyone has come across this before or thinks they know what the cause might be I'd greatly appreciate the help. If I've left any information out just ask.
Thanks a lot.
EDIT: Forgot to mention that the kernel version is "3.0.4+ #14 SMP" on the target board.
Thanks for the reply. The code is getting compiled error free and with regards to the make file I've omitted that and just enter the Linux directory in the terminal. Found that the reason insmod was not loading the module was due to request_irq() returning an error value and not 0. Apparently one of the parameters is invalid so I'm not trying to hunt down the source code for request_irq() to work out exactly what is going on.
static int hi(void)
{
/*printk(KERN_INFO "Hello from hi module.\n");
printk(KERN_INFO "The user space process is '%s'\n", current->comm);
printk(KERN_INFO "The user space PID is %i\n", current->pid);
return 0; // to show a successful load*/
printk("Setting up IRQ5\n");
int error;
static void bye(void)
{
printk(KERN_INFO "Goodbye from hi module.\n");
}
module_init(hi);
module_exit(bye);
MODULE_AUTHOR("Robert P. J. Day");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_VERSION("2:1.0") ;
MODULE_DESCRIPTION("You have to start somewhere.");
So now I can actually see what it is returning. The error number it returns is 22, or an invalid parameter. I am trying to track down where in the Kernel is actually returning this error. So far I know it goes to interrupt.h (http://lxr.free-electrons.com/source...a=powerpc#L129) as I inserted a printk at that point in the code. However I'm still unsuccessful in tracking where it goes after that.
Problem is with the irq number. In case of Powerpc, the irq number should be mapped to a virtual irq and that will be passed to the request_irq(). Generally irq will be specified in the device tree and the function of_irq_to_resource() is called to get the virq for the irq that is taken from the device tree.
Hi everyone. I had a look through the kernel looking for some examples of virtual IRQs and from that edited my code to the following:
Code:
//IRQF_SHARED
#include <linux/module.h> // for all modules
#include <linux/init.h> // for entry/exit macros
#include <linux/kernel.h> // for printk priority macros
#include <asm/current.h> // process information, just for fun
#include <linux/sched.h> // for "struct task_struct"
#include <linux/interrupt.h>
#include <linux/device.h>
static irqreturn_t irq_handl(int irq, void *dev_id)
{
printk("IRQ5 triggered\n");
return IRQ_HANDLED;
}
static int hi(void)
{
/*printk(KERN_INFO "Hello from hi module.\n");
printk(KERN_INFO "The user space process is '%s'\n", current->comm);
printk(KERN_INFO "The user space PID is %i\n", current->pid);
return 0; // to show a successful load*/
printk("Setting up IRQ5\n");
int error;
struct device dev;
int virq;
unsigned long mapIRQ;
mapIRQ = 5;
virq = irq_create_mapping(NULL,mapIRQ);
error = request_irq(virq,
irq_handl,
0,
"Int Test",&dev);
if(error == 0){
printk("0 error returned\n");
return 0;
}
else{
printk("%d\n",error);
return 0;
}
}
static void bye(void)
{
printk(KERN_INFO "Goodbye from hi module.\n");
}
module_init(hi);
module_exit(bye);
MODULE_AUTHOR("Robert P. J. Day");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_VERSION("2:1.0") ;
MODULE_DESCRIPTION("You have to start somewhere.");
So it now compiles and returns what I'm expecting after performing an insmod:
Code:
Setting up IRQ5
This is before calling the request threaded IRQ
0 error returned
I verified that it had been registered by Linux through /proc/interrupts:
However, when I'm testing the pin (by putting a pull-up button combination that asserts a low with a button press) I am not getting the "IRQ5 triggered" message. I was just wondering if anyone could verify that what I've done in my code is correct or, more than likely, wrong. Thanks a lot.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.