All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Mallon <rmallon@gmail.com>
To: "Murali K. Vemuri" <vemuri.muralikrishna@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: kernel panic with simple driver
Date: Wed, 10 Aug 2011 10:42:35 +1000	[thread overview]
Message-ID: <4E41D3FB.9080802@gmail.com> (raw)
In-Reply-To: <CAME+iufMQT-pWzxgc79NyZq-hW-6QU9FAJd1SV_UR+zR2erPOQ@mail.gmail.com>

On 10/08/11 10:16, Murali K. Vemuri wrote:
> Hello there,
>
> I have a small driver code with which I am randomly receiving kernel
> panic. Can someone help me what is the mistake here?
> The kernel panic is exactly caught to be at "add_timer (&my_timer) ".
> I am able to get the print "Kicking off the timer" when the panic
> happens.

It helps to post the panic message. Its hard to debug problems without them.

Where in add_timer is the panic occurring? It's only two lines, and one 
of those is a BUG_ON. Are you hitting that? The other line is a call to 
mod_timer and dereferences the timer pointer. Is the timer_list struct 
you are passing to add_timer sane?

> Also, I could not observe any specific pattern in which the panic
> occurs. But it is purely random. So far I was able to reproduce the
> panic thrice out of 100+ attempts.

Do you have any concurrent access to the timer? If so you may be racing 
on the between the test of timer_pending and the call to timer_add. In 
general, I think you should call mod_timer rather than add_timer (see 
the documentation in kernel/timer.c).

~Ryan

> In all other attempts, my_dev_ioctl is called correctly and works correctly.
>
> struct timer_list my_timer;
>
> static int my_dev_ioctl(struct inode *inode, struct file *file,
>                  unsigned int cmd, unsigned long arg)
> {
>      switch(cmd)
>      {
>          case MATCH_CASE:
>              if (timer_pending (&my_timer))
>              {
>                  printk(KERN_ERR "Timer currently pending, not adding
> any more\n");
>              }
>              else
>              {
>                  printk(KERN_ERR "Kicking off the timer\n");
>                  add_timer(&my_timer);
>              }
>              break;
>          default:
>              break;
>      }
>      return 0;
> }
>
> static struct miscdevice my_dummy_dev =
> {
>      .minor = MISC_DYNAMIC_MINOR,
>      .name = "dummy_dev",
>      .fops =&my_dev_fops,
> };
>
> static int __init my_dev_init(void)
> {
>      /*initialize some GPIOs */
>      init_timer (&my_timer);
>      my_timer.data = 0;
>      my_timer.expires = jiffies + msecs_to_jiffies(500);
>      my_timer.function = ring_led_detect_timer;
>      misc_register(&mbi5025_dev);
> }
> module_init(my_dev_init);
>
>
> Thanks in advance
> Murali
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


  reply	other threads:[~2011-08-10  0:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-10  0:16 kernel panic with simple driver Murali K. Vemuri
2011-08-10  0:42 ` Ryan Mallon [this message]
2011-08-10  1:33   ` Murali K. Vemuri
2011-08-10  2:16     ` Greg KH
2011-08-10  2:29       ` Murali K. Vemuri
2011-08-10  2:35         ` Ryan Mallon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E41D3FB.9080802@gmail.com \
    --to=rmallon@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vemuri.muralikrishna@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.