All of lore.kernel.org
 help / color / mirror / Atom feed
* request_irq return errno 38
@ 2009-02-11  8:43 Vijay Nikam
  2009-02-11  9:15 ` Michael Ellerman
  0 siblings, 1 reply; 11+ messages in thread
From: Vijay Nikam @ 2009-02-11  8:43 UTC (permalink / raw)
  To: linuxppc-dev

Hello All,

I have mpc8313erdb evaluation board and currently I am writing GPIO
driver. Actually it is just simple test driver.

I did the irq_request in the driver init function, as request_irq
returns zero (0) if successful, otherwise -1 on error and errno
indicates the error. But when I load or insert the module using insmod
request_irq return with Return Value -38. I checked in errno.h file in
asm-generic and 38 means ENOSYS - Function not implemented.
Following is irq_request code:
----------------------
ret = request_irq(74, interrupt_handler, SA_INTERRUPT | SA_SHIRQ ,
"gpio", &mydev);
if(ret)
    printk(KERN_INFO "Error in request_irq, value return = %d \n", ret);
----------------------
NOTE: 74 is the Interrupt ID Number for GPIO Interrupt. this
information is from Processor User Manual.

Following is the handler:
---------------------
static int interrupt_handler(int irqn, void *dev_id)
{
    printk(KERN_INFO "Enter in interrupt handler\n");
    return IRQ_HANDLED;
}
--------------------

Usually request_irq return EBUSY, EINVAL but in my case it returns
ENOSYS (errno 38). I tried to look information for this errno in
interrupt context but could not able to find anything useful or
understable. Could anyone please let me know why this specific errno
38 generated in request_irq ? ? ? and what are the possiblities for
resolving this error ? ?  ?

Kindly please acknowledge ... thank you ...

Kind Regards,
Vijay Nikam

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-11  8:43 request_irq return errno 38 Vijay Nikam
@ 2009-02-11  9:15 ` Michael Ellerman
  2009-02-11  9:41   ` Vijay Nikam
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Ellerman @ 2009-02-11  9:15 UTC (permalink / raw)
  To: Vijay Nikam; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 2209 bytes --]

On Wed, 2009-02-11 at 14:13 +0530, Vijay Nikam wrote:
> Hello All,
> 
> I have mpc8313erdb evaluation board and currently I am writing GPIO
> driver. Actually it is just simple test driver.
> 
> I did the irq_request in the driver init function, as request_irq
> returns zero (0) if successful, otherwise -1 on error and errno
> indicates the error. But when I load or insert the module using insmod
> request_irq return with Return Value -38. I checked in errno.h file in
> asm-generic and 38 means ENOSYS - Function not implemented.
> Following is irq_request code:
> ----------------------
> ret = request_irq(74, interrupt_handler, SA_INTERRUPT | SA_SHIRQ ,
> "gpio", &mydev);
> if(ret)
>     printk(KERN_INFO "Error in request_irq, value return = %d \n", ret);
> ----------------------
> NOTE: 74 is the Interrupt ID Number for GPIO Interrupt. this
> information is from Processor User Manual.
> 
> Following is the handler:
> ---------------------
> static int interrupt_handler(int irqn, void *dev_id)
> {
>     printk(KERN_INFO "Enter in interrupt handler\n");
>     return IRQ_HANDLED;
> }
> --------------------
> 
> Usually request_irq return EBUSY, EINVAL but in my case it returns
> ENOSYS (errno 38). I tried to look information for this errno in
> interrupt context but could not able to find anything useful or
> understable. Could anyone please let me know why this specific errno
> 38 generated in request_irq ? ? ? and what are the possiblities for
> resolving this error ? ?  ?

You don't mention what kernel version you're using. But you might be
hitting the check in __setup_irq():

        if (desc->chip == &no_irq_chip)
                return -ENOSYS;


That would make sense because you're trying to map a raw irq number,
which doesn't work. You first need to call irq_create_mapping(), like:

int virq;
virq = irq_create_mapping(NULL, 74);
rc = request_irq(virq, ...);


cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-11  9:15 ` Michael Ellerman
@ 2009-02-11  9:41   ` Vijay Nikam
  2009-02-11  9:54     ` Michael Ellerman
  0 siblings, 1 reply; 11+ messages in thread
From: Vijay Nikam @ 2009-02-11  9:41 UTC (permalink / raw)
  To: michael; +Cc: linuxppc-dev

Thanks for your prompt reply ...

I am using kernel version 2.6.20 ...

May I know what raw IRQ means ? ? ? and what is the reason I cant map
raw_irq_number ???

Kindly please acknowledge ... thank you ...

Kind Regards,
Vijay Nikam

On 2/11/09, Michael Ellerman <michael@ellerman.id.au> wrote:
> On Wed, 2009-02-11 at 14:13 +0530, Vijay Nikam wrote:
> > Hello All,
> >
> > I have mpc8313erdb evaluation board and currently I am writing GPIO
> > driver. Actually it is just simple test driver.
> >
> > I did the irq_request in the driver init function, as request_irq
> > returns zero (0) if successful, otherwise -1 on error and errno
> > indicates the error. But when I load or insert the module using insmod
> > request_irq return with Return Value -38. I checked in errno.h file in
> > asm-generic and 38 means ENOSYS - Function not implemented.
> > Following is irq_request code:
> > ----------------------
> > ret = request_irq(74, interrupt_handler, SA_INTERRUPT | SA_SHIRQ ,
> > "gpio", &mydev);
> > if(ret)
> >     printk(KERN_INFO "Error in request_irq, value return = %d \n", ret);
> > ----------------------
> > NOTE: 74 is the Interrupt ID Number for GPIO Interrupt. this
> > information is from Processor User Manual.
> >
> > Following is the handler:
> > ---------------------
> > static int interrupt_handler(int irqn, void *dev_id)
> > {
> >     printk(KERN_INFO "Enter in interrupt handler\n");
> >     return IRQ_HANDLED;
> > }
> > --------------------
> >
> > Usually request_irq return EBUSY, EINVAL but in my case it returns
> > ENOSYS (errno 38). I tried to look information for this errno in
> > interrupt context but could not able to find anything useful or
> > understable. Could anyone please let me know why this specific errno
> > 38 generated in request_irq ? ? ? and what are the possiblities for
> > resolving this error ? ?  ?
>
> You don't mention what kernel version you're using. But you might be
> hitting the check in __setup_irq():
>
>        if (desc->chip == &no_irq_chip)
>                return -ENOSYS;
>
>
> That would make sense because you're trying to map a raw irq number,
> which doesn't work. You first need to call irq_create_mapping(), like:
>
> int virq;
> virq = irq_create_mapping(NULL, 74);
> rc = request_irq(virq, ...);
>
>
> cheers
>
> --
> Michael Ellerman
> OzLabs, IBM Australia Development Lab
>
> wwweb: http://michael.ellerman.id.au
> phone:  +61 2 6212 1183  (tie line 70 21183)
>
> We do not inherit the earth from our ancestors,
> we borrow it from our children. - S.M.A.R.T Person
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-11  9:41   ` Vijay Nikam
@ 2009-02-11  9:54     ` Michael Ellerman
  2009-02-11 10:13       ` Vijay Nikam
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Ellerman @ 2009-02-11  9:54 UTC (permalink / raw)
  To: Vijay Nikam; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 789 bytes --]

On Wed, 2009-02-11 at 15:11 +0530, Vijay Nikam wrote:
> Thanks for your prompt reply ...
> 
> I am using kernel version 2.6.20 ...

OK, that kernel has the irq remapping stuff.

> May I know what raw IRQ means ? ? ? and what is the reason I cant map
> raw_irq_number ???

Sorry, that's not the best terminology.

I guess the right name is hardware irq number.

You can't map it because the kernel keeps a mapping between hardware irq
numbers and virtual irq numbers. request_irq() expects a virtual irq
number.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-11  9:54     ` Michael Ellerman
@ 2009-02-11 10:13       ` Vijay Nikam
  2009-02-11 22:35         ` Brad Boyer
  2009-02-11 22:48         ` Scott Wood
  0 siblings, 2 replies; 11+ messages in thread
From: Vijay Nikam @ 2009-02-11 10:13 UTC (permalink / raw)
  To: michael; +Cc: linuxppc-dev

Ok ... so that means if I am writing driver for any device I need to
take care of this mapping ? ? ? I mean I should use virq ? ? ?

I read in LDD book, they give directly irq no. they have given
parallel port example, here they have set or said irq no. defaults to
7 and they have not done any irq_mapping so what is the difference ? ?
? I mean how I should know when to use irq_mapping and when not ? ? ?

Also is it some difference between writng drivers on embedded Linux
level and Linux PC (i386) ? ? ?

Sorry for perhaps these basic questions as kind of new to Linux kernel
programming ... :-)

Kindly please acknowledge ... thank you ...

Kind Regards,
Vijay Nikam


On 2/11/09, Michael Ellerman <michael@ellerman.id.au> wrote:
> On Wed, 2009-02-11 at 15:11 +0530, Vijay Nikam wrote:
> > Thanks for your prompt reply ...
> >
> > I am using kernel version 2.6.20 ...
>
> OK, that kernel has the irq remapping stuff.
>
> > May I know what raw IRQ means ? ? ? and what is the reason I cant map
> > raw_irq_number ???
>
> Sorry, that's not the best terminology.
>
> I guess the right name is hardware irq number.
>
> You can't map it because the kernel keeps a mapping between hardware irq
> numbers and virtual irq numbers. request_irq() expects a virtual irq
> number.
>
> cheers
>
> --
> Michael Ellerman
> OzLabs, IBM Australia Development Lab
>
> wwweb: http://michael.ellerman.id.au
> phone:  +61 2 6212 1183  (tie line 70 21183)
>
> We do not inherit the earth from our ancestors,
> we borrow it from our children. - S.M.A.R.T Person
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-11 10:13       ` Vijay Nikam
@ 2009-02-11 22:35         ` Brad Boyer
  2009-02-12  6:01           ` Benjamin Herrenschmidt
  2009-02-12 10:51           ` Vijay Nikam
  2009-02-11 22:48         ` Scott Wood
  1 sibling, 2 replies; 11+ messages in thread
From: Brad Boyer @ 2009-02-11 22:35 UTC (permalink / raw)
  To: Vijay Nikam; +Cc: linuxppc-dev

On Wed, Feb 11, 2009 at 03:43:26PM +0530, Vijay Nikam wrote:
> I read in LDD book, they give directly irq no. they have given
> parallel port example, here they have set or said irq no. defaults to
> 7 and they have not done any irq_mapping so what is the difference ? ?
> ? I mean how I should know when to use irq_mapping and when not ? ? ?
> 
> Also is it some difference between writng drivers on embedded Linux
> level and Linux PC (i386) ? ? ?

The basic request_irq() function is generic, but the value of the
arguments (especially the number for the IRQ line) is architecture
specific in many ways. This is one difference between the i386 code
and the powerpc code inside Linux. Most i386 hardware is standard
PC hardware with very clearly defined interrupt sources. Because of
this, the mapping from the numeric IRQ value to a real hardware
interrupt source is defined pretty clearly. The powerpc architecture
code has to support almost arbitrarily complex hardware, and the
embedded world is the source of most of the complexity. Because of
this, the powerpc code has to dynamically allocate those numeric
IRQ sources and tie them to a specific hardware interrupt. There
is functionality to take the information from your device tree and
convert it to a virtual IRQ. That happens automatically for some types
of devices like PCI cards, but your driver may have to do that mapping
itself in other cases. I believe the appropriate API for this is the
function irq_of_parse_and_map(). It takes a device node and index into
the interrupt list for that device and gives a virtual IRQ number.

	Brad Boyer
	flar@allandria.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-11 10:13       ` Vijay Nikam
  2009-02-11 22:35         ` Brad Boyer
@ 2009-02-11 22:48         ` Scott Wood
  1 sibling, 0 replies; 11+ messages in thread
From: Scott Wood @ 2009-02-11 22:48 UTC (permalink / raw)
  To: Vijay Nikam; +Cc: linuxppc-dev

On Wed, Feb 11, 2009 at 03:43:26PM +0530, Vijay Nikam wrote:
> Ok ... so that means if I am writing driver for any device I need to
> take care of this mapping ? ? ? I mean I should use virq ? ? ?
> 
> I read in LDD book,

The problem with dead-tree books on a volatile subject is they quickly
get out of date.

> they give directly irq no. they have given parallel port example, here
> they have set or said irq no. defaults to 7 and they have not done any
> irq_mapping so what is the difference ? ? ? I mean how I should know
> when to use irq_mapping and when not ? ? ?

That's for legacy ISA interrupts.  On powerpc, you generally will want to
get the interrupt from the device tree using irq_of_parse_and_map().

-Scott

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-11 22:35         ` Brad Boyer
@ 2009-02-12  6:01           ` Benjamin Herrenschmidt
  2009-02-12 10:51           ` Vijay Nikam
  1 sibling, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2009-02-12  6:01 UTC (permalink / raw)
  To: Brad Boyer; +Cc: Vijay Nikam, linuxppc-dev

On Wed, 2009-02-11 at 14:35 -0800, Brad Boyer wrote:
> On Wed, Feb 11, 2009 at 03:43:26PM +0530, Vijay Nikam wrote:
> > I read in LDD book, they give directly irq no. they have given
> > parallel port example, here they have set or said irq no. defaults to
> > 7 and they have not done any irq_mapping so what is the difference ? ?
> > ? I mean how I should know when to use irq_mapping and when not ? ? ?
> > 
> > Also is it some difference between writng drivers on embedded Linux
> > level and Linux PC (i386) ? ? ?
> 
> The basic request_irq() function is generic, but the value of the
> arguments (especially the number for the IRQ line) is architecture
> specific in many ways. This is one difference between the i386 code
> and the powerpc code inside Linux. Most i386 hardware is standard
> PC hardware with very clearly defined interrupt sources. 

In fact, not even clearly anymore :-) IE, there are still some legacy
interrupts at fixed numbers but most things are remapped on x86 too
nowadays when using IO_APICs, the kernel obtains numbers from ACPI,
remaps them etc...

What saves x86 is that anything other than legacy ISA uses PCI nowadays
and thus that remapping is invisible to PCI drivers (as it is on
powerpc). The problem only bites with other bus types more common on
embedded hardware, as you mention further down.

> Because of
> this, the mapping from the numeric IRQ value to a real hardware
> interrupt source is defined pretty clearly. The powerpc architecture
> code has to support almost arbitrarily complex hardware, and the
> embedded world is the source of most of the complexity. Because of
> this, the powerpc code has to dynamically allocate those numeric
> IRQ sources and tie them to a specific hardware interrupt. There
> is functionality to take the information from your device tree and
> convert it to a virtual IRQ. That happens automatically for some types
> of devices like PCI cards, but your driver may have to do that mapping
> itself in other cases. I believe the appropriate API for this is the
> function irq_of_parse_and_map(). It takes a device node and index into
> the interrupt list for that device and gives a virtual IRQ number.

Cheers,
Ben.

> 	Brad Boyer
> 	flar@allandria.com
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-11 22:35         ` Brad Boyer
  2009-02-12  6:01           ` Benjamin Herrenschmidt
@ 2009-02-12 10:51           ` Vijay Nikam
  2009-02-12 16:39             ` Timur Tabi
  1 sibling, 1 reply; 11+ messages in thread
From: Vijay Nikam @ 2009-02-12 10:51 UTC (permalink / raw)
  To: Brad Boyer, scottwood, linuxppc-dev

Thanks for your replies ...

I checked the irq.c and irq.h and found the prototype of
irq_of_parse_and_map() and found from the comment that it is a wrapper
function contains a chain of irq_map_one() and irq_create_mapping()
...

It means that I can use irq_create_mapping() to know the virq also the
same suggessted by michael ... what is the difference between these
two i.e. irq_create_mapping() and irq_of_parse_and_map() ... I mean in
usage what could be the difference ? ? ?

If used the irq_of_parse_and_map() then the paraments I need to pass
are device_node *dev and index irq_of_parse_and_map(struct device_node
*dev, int index) ... then how I can pass the required information i.e.
dev and index ? ? ?

Also how I can read the device tree binary file ? ? ?

Kindly please acknowledge ... thank you ...

Kind Regards,
Vijay Nikam

On 2/12/09, Brad Boyer <flar@allandria.com> wrote:
> On Wed, Feb 11, 2009 at 03:43:26PM +0530, Vijay Nikam wrote:
> > I read in LDD book, they give directly irq no. they have given
> > parallel port example, here they have set or said irq no. defaults to
> > 7 and they have not done any irq_mapping so what is the difference ? ?
> > ? I mean how I should know when to use irq_mapping and when not ? ? ?
> >
> > Also is it some difference between writng drivers on embedded Linux
> > level and Linux PC (i386) ? ? ?
>
> The basic request_irq() function is generic, but the value of the
> arguments (especially the number for the IRQ line) is architecture
> specific in many ways. This is one difference between the i386 code
> and the powerpc code inside Linux. Most i386 hardware is standard
> PC hardware with very clearly defined interrupt sources. Because of
> this, the mapping from the numeric IRQ value to a real hardware
> interrupt source is defined pretty clearly. The powerpc architecture
> code has to support almost arbitrarily complex hardware, and the
> embedded world is the source of most of the complexity. Because of
> this, the powerpc code has to dynamically allocate those numeric
> IRQ sources and tie them to a specific hardware interrupt. There
> is functionality to take the information from your device tree and
> convert it to a virtual IRQ. That happens automatically for some types
> of devices like PCI cards, but your driver may have to do that mapping
> itself in other cases. I believe the appropriate API for this is the
> function irq_of_parse_and_map(). It takes a device node and index into
> the interrupt list for that device and gives a virtual IRQ number.
>
>        Brad Boyer
>        flar@allandria.com
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-12 10:51           ` Vijay Nikam
@ 2009-02-12 16:39             ` Timur Tabi
  2009-02-12 22:49               ` David Gibson
  0 siblings, 1 reply; 11+ messages in thread
From: Timur Tabi @ 2009-02-12 16:39 UTC (permalink / raw)
  To: Vijay Nikam; +Cc: scottwood, linuxppc-dev

On Thu, Feb 12, 2009 at 4:51 AM, Vijay Nikam <vijay.t.nikam@gmail.com> wrote:

> Also how I can read the device tree binary file ? ? ?

It would be a lot simpler if you just read the documentation (see
booting-without-of.txt) and looked at other device drivers to see what
they do.

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: request_irq return errno 38
  2009-02-12 16:39             ` Timur Tabi
@ 2009-02-12 22:49               ` David Gibson
  0 siblings, 0 replies; 11+ messages in thread
From: David Gibson @ 2009-02-12 22:49 UTC (permalink / raw)
  To: Timur Tabi; +Cc: scottwood, Vijay Nikam, linuxppc-dev

On Thu, Feb 12, 2009 at 10:39:36AM -0600, Timur Tabi wrote:
> On Thu, Feb 12, 2009 at 4:51 AM, Vijay Nikam <vijay.t.nikam@gmail.com> wrote:
> 
> > Also how I can read the device tree binary file ? ? ?
> 
> It would be a lot simpler if you just read the documentation (see
> booting-without-of.txt) and looked at other device drivers to see what
> they do.

You don't need to directly read the device tree, the provided helper
functions (irq_parse_and_map() and the like) will read the device tree
for you.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-02-12 22:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11  8:43 request_irq return errno 38 Vijay Nikam
2009-02-11  9:15 ` Michael Ellerman
2009-02-11  9:41   ` Vijay Nikam
2009-02-11  9:54     ` Michael Ellerman
2009-02-11 10:13       ` Vijay Nikam
2009-02-11 22:35         ` Brad Boyer
2009-02-12  6:01           ` Benjamin Herrenschmidt
2009-02-12 10:51           ` Vijay Nikam
2009-02-12 16:39             ` Timur Tabi
2009-02-12 22:49               ` David Gibson
2009-02-11 22:48         ` Scott Wood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.