linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* RE: Request_irq fails for IRQ2
@ 2011-10-03 14:27 smitha.vanga
  2011-10-03 17:24 ` Scott Wood
  2011-10-04  9:25 ` Vijay Nikam
  0 siblings, 2 replies; 10+ messages in thread
From: smitha.vanga @ 2011-10-03 14:27 UTC (permalink / raw)
  To: scottwood; +Cc: linuxppc-dev

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


Hi Scott,

 I try to request an IRQ (IRQ2 and IRQ3 which are ineterrupt no 20 and 21 in mpc8247)in my driver . The
Call fails in setup_irq in Manage.c at /kernel/irq.

Setup _irq returns -ENOSYS

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


I found that I need to pass the virtual interrupt number instead of hardware interrupt number.
So I added below piece of code

Below is the call to request irq in my driver.

virq = irq_create_mapping(NULL, CPLD1_INTERRUPT);




   if ((ret = request_irq(virq,cpld_irq_handler, 0, GPIO_CHAR_PATH, NULL))!=0)
   {
      printk(KERN_ERR "gpio_init: Could not grab IRQ line for CPLD ret = %d\n",ret);
          goto err1;
   }


Now it fails in irq_create_mapping   with NO_IRQ error.

if (controller == NULL)
                host = irq_default_host;
else
                host = irq_find_host(controller);
if (host == NULL) {
                printk(KERN_WARNING "irq: no irq host found for %s !\n",
                       controller->full_name);
                return NO_IRQ;
        }


I just don't know what I should pass for host , also when I pass NULL for host . I see the default host is NULL..
Could you please help me. My project delivery is near , I need  help soon.


Regards,
Smitha



Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com

[-- Attachment #2: Type: text/html, Size: 5718 bytes --]

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

* Re: Request_irq fails for IRQ2
  2011-10-03 14:27 Request_irq fails for IRQ2 smitha.vanga
@ 2011-10-03 17:24 ` Scott Wood
  2011-10-04  6:15   ` smitha.vanga
                     ` (2 more replies)
  2011-10-04  9:25 ` Vijay Nikam
  1 sibling, 3 replies; 10+ messages in thread
From: Scott Wood @ 2011-10-03 17:24 UTC (permalink / raw)
  To: smitha.vanga; +Cc: linuxppc-dev

On 10/03/2011 09:27 AM, smitha.vanga@wipro.com wrote:
> I just don't know what I should pass for host , also when I pass NULL
> for host . I see the default host is NULL..
> Could you please help me. My project delivery is near , I need  help soon.

Ideally you should just use the device tree to describe this device,
then you wouldn't have to deal with finding the pointer to the controller.

Otherwise, modify the cpm2_pic driver to either call
irq_set_default_host() (in which case NULL should work) or to make
cpm2_pic_host non-static (in which case you should pass that).

-Scott

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

* RE: Request_irq fails for IRQ2
  2011-10-03 17:24 ` Scott Wood
@ 2011-10-04  6:15   ` smitha.vanga
  2011-10-04 11:21   ` smitha.vanga
  2011-10-04 13:55   ` smitha.vanga
  2 siblings, 0 replies; 10+ messages in thread
From: smitha.vanga @ 2011-10-04  6:15 UTC (permalink / raw)
  To: scottwood; +Cc: linuxppc-dev

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

Hi Scott,

Thank you. But I am not very clear where exactly I need to call the irq_set_default_host().
And also for the second fix I did not understand or to make cpm2_pic_host non-static (in which case you should pass that).
in th previous mail what exactlyy you mean.

Thanks & Regards,

Smitha


Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com

[-- Attachment #2: Type: text/html, Size: 1791 bytes --]

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

* Re: Request_irq fails for IRQ2
  2011-10-03 14:27 Request_irq fails for IRQ2 smitha.vanga
  2011-10-03 17:24 ` Scott Wood
@ 2011-10-04  9:25 ` Vijay Nikam
  1 sibling, 0 replies; 10+ messages in thread
From: Vijay Nikam @ 2011-10-04  9:25 UTC (permalink / raw)
  To: smitha.vanga; +Cc: scottwood, linuxppc-dev

Smitha,

Do you have the entry of this device node in your DTS file?
if yes, then is the device is getting registered properly?

If you are writing platform driver then you can use 'platform_get_irq'
it returns the irq number,
which you can pass in the 'request_irq'. If it is a simple character
driver then to determine the
virtual irq number you can use 'ioremap', in this call you can pass
the HW IRQ number e.g. 20
and then pass in the 'request_irq'.

But in both cases you have to have this device node in your device
tree and should be registered,
otherwise it should be returning error and no virtual irq will be allocated=
.

As per your return value it seems the device node is not getting
registered, perhaps the entry is
missing in DTS file. Try with just ioremap and see if virtual irq is
returned properly.

Kind Regards,
Vijay Nikam

On Mon, Oct 3, 2011 at 7:57 PM,  <smitha.vanga@wipro.com> wrote:
>
> Hi Scott,
>
> I try to request an IRQ (IRQ2 and IRQ3 which are ineterrupt no 20 and 21 =
in
> mpc8247)in my driver . The
> Call fails in setup_irq in Manage.c at /kernel/irq.
>
> Setup _irq returns -ENOSYS
>
> if (desc->irq_data.chip =3D=3D &no_irq_chip)
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return -ENOSYS;
>
>
> I found that I need to pass the virtual interrupt number instead of hardw=
are
> interrupt number.
> So I added below piece of code
>
> Below is the call to request irq in my driver.
>
> virq =3D irq_create_mapping(NULL, CPLD1_INTERRUPT);
>
>
>
>
> =A0=A0 if ((ret =3D request_irq(virq,cpld_irq_handler, 0, GPIO_CHAR_PATH,
> NULL))!=3D0)
> =A0=A0 {
> =A0=A0=A0=A0=A0 printk(KERN_ERR "gpio_init: Could not grab IRQ line for C=
PLD ret =3D
> %d\n",ret);
> =A0=A0=A0=A0=A0=A0=A0 =A0 goto err1;
> =A0=A0 }
>
>
> Now it fails in irq_create_mapping=A0=A0 with NO_IRQ error.
>
> if (controller =3D=3D NULL)
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 host =3D irq_default_host;
> else
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 host =3D irq_find_host(cont=
roller);
> if (host =3D=3D NULL) {
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 printk(KERN_WARNING "irq: n=
o irq host found for %s !\n",
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0 controll=
er->full_name);
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return NO_IRQ;
> =A0=A0=A0=A0=A0=A0=A0 }
>
>
> I just don't know what I should pass for host , also when I pass NULL for
> host . I see the default host is NULL..
> Could you please help me. My project delivery is near , I need=A0 help so=
on.
>
>
> Regards,
> Smitha
>
>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments =
to
> this message are intended for the exclusive use of the addressee(s) and m=
ay
> contain proprietary, confidential or privileged information. If you are n=
ot
> the intended recipient, you should not disseminate, distribute or copy th=
is
> e-mail. Please notify the sender immediately and destroy all copies of th=
is
> message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient sho=
uld
> check this email and any attachments for the presence of viruses. The
> company accepts no liability for any damage caused by any virus transmitt=
ed
> by this email.
>
> www.wipro.com
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>

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

* RE: Request_irq fails for IRQ2
  2011-10-03 17:24 ` Scott Wood
  2011-10-04  6:15   ` smitha.vanga
@ 2011-10-04 11:21   ` smitha.vanga
  2011-10-04 15:30     ` Scott Wood
  2011-10-09  7:07     ` Benjamin Herrenschmidt
  2011-10-04 13:55   ` smitha.vanga
  2 siblings, 2 replies; 10+ messages in thread
From: smitha.vanga @ 2011-10-04 11:21 UTC (permalink / raw)
  To: scottwood; +Cc: linuxppc-dev

Hi Scott,

I am able to register the IRQ now once I add the call irq_set_default_host i=
n cpm2_pic.
But when I call enable_irq the code throws the below warning and gives excep=
tion in enable irq at 
spin_unlock_irqrestore(&desc->lock, flags); in enable_irq.


printk(KERN_WARNING "Unbalanced enable for IRQ %d\n", irq);

Regards,
Smitha
Please do not print this email unless it is absolutely necessary. =0A=
=0A=
The information contained in this electronic message and any attachments to=
 this message are intended for the exclusive use of the addressee(s) and may=
 contain proprietary, confidential or privileged information. If you are not=
 the intended recipient, you should not disseminate, distribute or copy this=
 e-mail. Please notify the sender immediately and destroy all copies of this=
 message and any attachments. =0A=
=0A=
WARNING: Computer viruses can be transmitted via email. The recipient should=
 check this email and any attachments for the presence of viruses. The compa=
ny accepts no liability for any damage caused by any virus transmitted by th=
is email. =0A=
=0A=
www.wipro.com

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

* RE: Request_irq fails for IRQ2
  2011-10-03 17:24 ` Scott Wood
  2011-10-04  6:15   ` smitha.vanga
  2011-10-04 11:21   ` smitha.vanga
@ 2011-10-04 13:55   ` smitha.vanga
  2011-10-09  7:11     ` Benjamin Herrenschmidt
  2 siblings, 1 reply; 10+ messages in thread
From: smitha.vanga @ 2011-10-04 13:55 UTC (permalink / raw)
  To: scottwood; +Cc: linuxppc-dev

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


Hi Scoot,

When I try to use a atomic varaible in my ISR  I see a kernel crash . with mesage BUG: scheduling while atomic:


Below is the code :
My ISR

irqreturn_t cpld_irq_handler(int irq, void * dev_id, struct pt_regs *regs)

{

wake_up(&cpld_intr_wait);

atomic_inc(&cpld_intr_data); /* incrementing this will indicate the poll() that the interrupt is occured */

return 0;

}

DRIVER_INIT
static int __init gpio_init(void)
{
        int ret = 0;
        int virq;


    atomic_set(&cpld_intr_data, 0);                     /* initialize the Interrupt indicator */
    init_waitqueue_head(&cpld_intr_wait);               /* Initialize the wait queue */

    virq = irq_create_mapping(NULL, CPLD1_INTERRUPT);


   if ((ret = request_irq(virq,cpld_irq_handler, 0, GPIO_CHAR_PATH, NULL))!=0)
   {
      printk(KERN_ERR "gpio_init: Could not grab IRQ line for CPLD ret = %d\n",ret);
          goto err1;
   }


        if((s_nGPIOMajor = register_chrdev(MPC8247_DEVICE_MAJOR_NUM, GPIO_CHAR_PATH, &gpio_fops))<0)
        {
                GPIO_DBG2("GPIO_DRIVER  : unable to get major %d\n", s_nGPIOMajor);
                return s_nGPIOMajor;

        }else{
                GPIO_DBG2("GPIO_DRIVER  : major = %x\n", s_nGPIOMajor );
        }

        return 0;

}



Regards,
Smitha

Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com

[-- Attachment #2: Type: text/html, Size: 4372 bytes --]

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

* Re: Request_irq fails for IRQ2
  2011-10-04 11:21   ` smitha.vanga
@ 2011-10-04 15:30     ` Scott Wood
  2011-10-09  7:07     ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 10+ messages in thread
From: Scott Wood @ 2011-10-04 15:30 UTC (permalink / raw)
  To: smitha.vanga; +Cc: linuxppc-dev

On 10/04/2011 06:21 AM, smitha.vanga@wipro.com wrote:
> Hi Scott,
> 
> I am able to register the IRQ now once I add the call irq_set_default_host in cpm2_pic.
> But when I call enable_irq the code throws the below warning and gives exception in enable irq at 
> spin_unlock_irqrestore(&desc->lock, flags); in enable_irq.
> 
> 
> printk(KERN_WARNING "Unbalanced enable for IRQ %d\n", irq);

The IRQ is automatically enabled when you request it.  Only call
enable_irq() if you previously called disable_irq().

-Scott

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

* RE: Request_irq fails for IRQ2
  2011-10-04 11:21   ` smitha.vanga
  2011-10-04 15:30     ` Scott Wood
@ 2011-10-09  7:07     ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2011-10-09  7:07 UTC (permalink / raw)
  To: smitha.vanga; +Cc: scottwood, linuxppc-dev

On Tue, 2011-10-04 at 11:21 +0000, smitha.vanga@wipro.com wrote:
> Hi Scott,
> 
> I am able to register the IRQ now once I add the call irq_set_default_host in cpm2_pic.

This is a band-aid at best and will probably not be accepted upstream.

You should -really- describe your interrupt in the device-tree instead.

Ben.


> But when I call enable_irq the code throws the below warning and gives exception in enable irq at 
> spin_unlock_irqrestore(&desc->lock, flags); in enable_irq.
> 
> 
> printk(KERN_WARNING "Unbalanced enable for IRQ %d\n", irq);
> 
> Regards,
> Smitha
> Please do not print this email unless it is absolutely necessary. 
> 
> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 
> 
> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 
> 
> www.wipro.com
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* RE: Request_irq fails for IRQ2
  2011-10-04 13:55   ` smitha.vanga
@ 2011-10-09  7:11     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2011-10-09  7:11 UTC (permalink / raw)
  To: smitha.vanga; +Cc: scottwood, linuxppc-dev

On Tue, 2011-10-04 at 13:55 +0000, smitha.vanga@wipro.com wrote:
> 
> Hi Scoot,
> 
> When I try to use a atomic varaible in my ISR  I see a kernel crash .
> with mesage BUG: scheduling while atomic:
> 
> 
> 
> Below is the code :
> My ISR
> 
> irqreturn_t cpld_irq_handler(int irq, void * dev_id, struct pt_regs
> *regs)
> 
> {
> 
> wake_up(&cpld_intr_wait);
> 
> atomic_inc(&cpld_intr_data); /* incrementing this will indicate the
> poll() that the interrupt is occured */
> 
> return 0;
> 
> }

This is of course completely racy, you should do the increment -before-
you wake up. I suppose you aren't SMP at the moment but even then, if
you ever switch for example to threaded interrupts or use RT it will
potentially break.
> 
> DRIVER_INIT
> static int __init gpio_init(void)
> {
>         int ret = 0;
>         int virq;
> 
>        
>     atomic_set(&cpld_intr_data, 0);                     /* initialize
> the Interrupt indicator */
>     init_waitqueue_head(&cpld_intr_wait);               /* Initialize
> the wait queue */
> 
>     virq = irq_create_mapping(NULL, CPLD1_INTERRUPT);

See comments earlier about using the device-tree here.
>               
>    if ((ret = request_irq(virq,cpld_irq_handler, 0, GPIO_CHAR_PATH,
> NULL))!=0)
>    {
>       printk(KERN_ERR "gpio_init: Could not grab IRQ line for CPLD ret
> = %d\n",ret);
>           goto err1;
>    }
>   
>  
>         if((s_nGPIOMajor = register_chrdev(MPC8247_DEVICE_MAJOR_NUM,
> GPIO_CHAR_PATH, &gpio_fops))<0)
>         {
>                 GPIO_DBG2("GPIO_DRIVER  : unable to get major %d\n",
> s_nGPIOMajor);
>                 return s_nGPIOMajor;
>                
>         }else{
>                 GPIO_DBG2("GPIO_DRIVER  : major = %x\n", s_nGPIOMajor
> );
>         }

coding style FAIL

>         return 0;
>     
> } 

I don't see anything that does your scheduling while atomic here,
probably a bug in your poll implementation but it's not here.

Oh and stop sending that crap:

> Regards,
> Smitha
> 
> Please do not print this email unless it is absolutely necessary. 
> 
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> addressee(s) and may contain proprietary, confidential or privileged
> information. If you are not the intended recipient, you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately and destroy all copies of this message and any
> attachments. 
> 
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of
> viruses. The company accepts no liability for any damage caused by any
> virus transmitted by this email. 

It's a complete nonsense on a public mailing list

Ben.

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

* Request_irq fails for IRQ2
  2011-08-26 20:08 Kernel boot up Scott Wood
@ 2011-10-03 12:31 ` smitha.vanga
  0 siblings, 0 replies; 10+ messages in thread
From: smitha.vanga @ 2011-10-03 12:31 UTC (permalink / raw)
  To: scottwood; +Cc: linuxppc-dev

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


Hi Scott,

 I try to request an IRQ (IRQ2 and IRQ3 which are ineterrupt no 20 and 21 in mpc8247)in my driver . The
Call fails in setup_irq in Manage.c at /kernel/irq.

Setup _irq returns -ENOSYS

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

I just want to know why it fails. Below is the call to request irq in my driver.


#define CPLD1_INTERRUPT  20
if (request_irq(CPLD1_INTERRUPT,cpld_irq_handler, 0, GPIO_CHAR_PATH, NULL))
   {
      printk(KERN_ERR "gpio_init: Could not grab IRQ line for CPLD\n");
          goto err1;
   }

Regards,
Smitha



Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com

[-- Attachment #2: Type: text/html, Size: 2609 bytes --]

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

end of thread, other threads:[~2011-10-09  7:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-03 14:27 Request_irq fails for IRQ2 smitha.vanga
2011-10-03 17:24 ` Scott Wood
2011-10-04  6:15   ` smitha.vanga
2011-10-04 11:21   ` smitha.vanga
2011-10-04 15:30     ` Scott Wood
2011-10-09  7:07     ` Benjamin Herrenschmidt
2011-10-04 13:55   ` smitha.vanga
2011-10-09  7:11     ` Benjamin Herrenschmidt
2011-10-04  9:25 ` Vijay Nikam
  -- strict thread matches above, loose matches on Subject: below --
2011-08-26 20:08 Kernel boot up Scott Wood
2011-10-03 12:31 ` Request_irq fails for IRQ2 smitha.vanga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).