LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
LinkBack Search this Thread
Old 02-02-2011, 05:06 AM   #1
sankar2078
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Rep: Reputation: 0
Kernel panic - not syncing: softlockup: hung tasks


I am working on at91sam9260 controller and i am using 2.6.30 kernel for that. I have downloaded ADC driver code in net and i am using the same thing in my kernel. while i am trying to call read function from user space it is giving panic. And that is consistently giving that problem. Please help me to resolve this the problem. The following Error i am getting:


BUG: soft lockup - CPU#0 stuck for 61s! [adc:393]
Modules linked in:

Pid: 393, comm: adc
CPU: 0 Not tainted (2.6.30 #8)
PC is at at91adc_read+0x38/0x90
LR is at vfs_read+0xb8/0x148
pc : [<c01f3294>] lr : [<c00a2a4c>] psr: 40000013
sp : c3a5df38 ip : c3a5df50 fp : c3a5df4c
r10: 00900003 r9 : c3a5c000 r8 : c00266b0
r7 : 00000002 r6 : c3a5df78 r5 : be96be3e r4 : c3a2f920
r3 : 000c0000 r2 : c493a000 r1 : c036a914 r0 : be96be3e
Flags: nZcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 0005317f Table: 23a3c000 DAC: 00000015
[<c0027480>] (show_regs+0x0/0x54) from [<c0065da4>] (softlockup_tick+0x10c/0x154)
r4:c3a5c000
[<c0065c98>] (softlockup_tick+0x0/0x154) from [<c0049224>] (run_local_timers+0x20/0x24)
[<c0049204>] (run_local_timers+0x0/0x24) from [<c0049258>] (update_process_times+0x30/0x60)
[<c0049228>] (update_process_times+0x0/0x60) from [<c005dd80>] (tick_periodic+0x98/0xb4)
r5:00000256 r4:04c4b400
[<c005dce8>] (tick_periodic+0x0/0xb4) from [<c005ddbc>] (tick_handle_periodic+0x20/0xf0)
r6:c0334b58 r5:00000013 r4:c031408c
[<c005dd9c>] (tick_handle_periodic+0x0/0xf0) from [<c01ecd90>] (ch2_irq+0x2c/0x34)
[<c01ecd64>] (ch2_irq+0x0/0x34) from [<c00664d8>] (handle_IRQ_event+0x90/0x1b4)
[<c0066448>] (handle_IRQ_event+0x0/0x1b4) from [<c00686ec>] (handle_level_irq+0xd8/0xf0)
[<c0068614>] (handle_level_irq+0x0/0xf0) from [<c0025058>] (_text+0x58/0x7c)
r5:00000000 r4:00000013
[<c0025000>] (_text+0x0/0x7c) from [<c0025a98>] (__irq_svc+0x38/0x80)
Exception stack(0xc3a5def0 to 0xc3a5df38)
dee0: be96be3e c036a914 c493a000 000c0000
df00: c3a2f920 be96be3e c3a5df78 00000002 c00266b0 c3a5c000 00900003 c3a5df4c
df20: c3a5df50 c3a5df38 c00a2a4c c01f3294 40000013 ffffffff
r5:fefff000 r4:ffffffff
[<c01f325c>] (at91adc_read+0x0/0x90) from [<c00a2a4c>] (vfs_read+0xb8/0x148)
[<c00a2994>] (vfs_read+0x0/0x148) from [<c00a2d88>] (sys_read+0x48/0x74)
r7:00000003 r6:c3a2f920 r5:00000000 r4:00000000
[<c00a2d40>] (sys_read+0x0/0x74) from [<c0025e40>] (ret_fast_syscall+0x0/0x2c)
r6:00000001 r5:be96bec4 r4:00000007
Kernel panic - not syncing: softlockup: hung tasks
[<c002bfb0>] (unwind_backtrace+0x0/0xe4) from [<c002a39c>] (dump_stack+0x1c/0x20)
[<c002a39c>] (dump_stack+0x1c/0x20) from [<c003f0e0>] (panic+0x50/0x124)
[<c003f0e0>] (panic+0x50/0x124) from [<c0065dc4>] (softlockup_tick+0x12c/0x154)
[<c0065dc4>] (softlockup_tick+0x12c/0x154) from [<c0049224>] (run_local_timers+0x20/0x24)
[<c0049224>] (run_local_timers+0x20/0x24) from [<c0049258>] (update_process_times+0x30/0x60)
[<c0049258>] (update_process_times+0x30/0x60) from [<c005dd80>] (tick_periodic+0x98/0xb4)
[<c005dd80>] (tick_periodic+0x98/0xb4) from [<c005ddbc>] (tick_handle_periodic+0x20/0xf0)
[<c005ddbc>] (tick_handle_periodic+0x20/0xf0) from [<c01ecd90>] (ch2_irq+0x2c/0x34)
[<c01ecd90>] (ch2_irq+0x2c/0x34) from [<c00664d8>] (handle_IRQ_event+0x90/0x1b4)
[<c00664d8>] (handle_IRQ_event+0x90/0x1b4) from [<c00686ec>] (handle_level_irq+0xd8/0xf0)
[<c00686ec>] (handle_level_irq+0xd8/0xf0) from [<c0025058>] (_text+0x58/0x7c)
[<c0025058>] (_text+0x58/0x7c) from [<c0025a98>] (__irq_svc+0x38/0x80)
Exception stack(0xc3a5def0 to 0xc3a5df38)
dee0: be96be3e c036a914 c493a000 000c0000
df00: c3a2f920 be96be3e c3a5df78 00000002 c00266b0 c3a5c000 00900003 c3a5df4c
df20: c3a5df50 c3a5df38 c00a2a4c c01f3294 40000013 ffffffff
[<c0025a98>] (__irq_svc+0x38/0x80) from [<c00a2a4c>] (vfs_read+0xb8/0x148)
 
Old 02-03-2011, 02:20 PM   #2
nini09
Member
 
Registered: Apr 2009
Posts: 920

Rep: Reputation: 67
Is ADC driver initialization OK?
 
Old 02-03-2011, 11:28 PM   #3
sankar2078
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Yeah... ADC initialization is ok... And that reading is reading ADC value correctly... but after reading so many times its giving this panic which is not consistent aslo. Do you want ADC driver code also???
 
Old 02-04-2011, 03:08 PM   #4
nini09
Member
 
Registered: Apr 2009
Posts: 920

Rep: Reputation: 67
Why do your ADC driver need spinlock? It can be got rid of.
 
Old 02-07-2011, 01:51 AM   #5
sankar2078
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 0
I am not using spinlock anywhere... i will post my code also... please have a look and tell me the solution...

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/clk.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <mach/at91_adc.h>
#include <asm/gpio.h>
#include <linux/cdev.h>


int at91adc_devno;
struct cdev at91adc_cdev;
struct file_operations at91adc_fops;

void __iomem *at91adc_base;
struct clk *at91adc_clk;


/*****************************************************************************************
| Module initialization: Allocate device numbers, register device, setup ADC and timer |
| counter registers for 100 msec periodic sampling. |
*****************************************************************************************/
static int __init at91adc_init(void)
//int init_module(void)
{
int ret;

// Dynamically allocate major number and minor number
ret = alloc_chrdev_region(&at91adc_devno,0,1, "at91_adc");// pointer to where the device number t
//be stored,first minor number requested,number of devices,device name
if (ret < 0)
{
printk(KERN_INFO "at91adc: Device number allocation failed\n");
ret = -ENODEV;
}

// Initialize cdev structure.
cdev_init(&at91adc_cdev,&at91adc_fops); // pointer to the cdev structure, pointer to the file
//operations structure.
at91adc_cdev.owner = THIS_MODULE;
at91adc_cdev.ops = &at91adc_fops;

// Register the device with kernel
ret = cdev_add(&at91adc_cdev,at91adc_devno,1); // pointer to the initialized cdev structure,
//device number allocated,number of devices

if (ret != 0)
{
printk(KERN_INFO "at91adc: Device registration failed\n");
ret = -ECANCELED;
}

// Character device driver initialization complete. Do device specific initialization now.

// Initialize ADC. The following two lines set the appropriate PMC bit
// for the ADC. Easier than mapping PMC registers and then setting the bit.
at91adc_clk = clk_get(NULL, "adc_clk"); // Device pointer - not required.Clock name.
clk_enable(at91adc_clk);
// Map ADC registers to the current address space.
at91adc_base = ioremap_nocache(AT91SAM9260_BASE_ADC, 64);// Physical address,Number of bytes to be mapped.

if (at91adc_base == NULL)
{
printk(KERN_INFO "at91adc: ADC memory mapping failed\n");
ret = -EACCES;
}

// MUX GPIO pins for ADC (peripheral A) operation
//at91_set_A_periph(AT91_PIN_PC1, 0);

// Reset the ADC
iowrite32(AT91_ADC_SWRST, (at91adc_base + AT91_ADC_CR));

// Enable both ADC channels
iowrite32((AT91_ADC_CH(1) ), (at91adc_base + AT91_ADC_CHER));

// Configure ADC mode register.
// From table 43-31 in page #775 and page#741 of AT91SAM9260 user manual:
// Maximum ADC clock frequency = 5MHz = MCK / ((PRESCAL+1) * 2)
// PRESCAL = ((MCK / 5MHz) / 2) -1 = ((100MHz / 5MHz)/2)-1) = 9
// Maximum startup time = 15uS = (STARTUP+1)*8/ADC_CLOCK
// STARTUP = ((15uS*ADC_CLOK)/8)-1 = ((15uS*5MHz)/8)-1 = 9
// Minimum hold time = 1.2uS = (SHTIM+1)/ADC_CLOCK
// SHTIM = (1.2uS*ADC_CLOCK)-1 = (1.2uS*5MHz)-1 = 5, Use 9 to ensure 2uS hold time.
// Enable sleep mode and hardware trigger from TIOA output from TC0.
iowrite32((AT91_ADC_SHTIM_(9) | AT91_ADC_STARTUP_(9) | AT91_ADC_PRESCAL_(9) |
AT91_ADC_SLEEP | AT91_ADC_TRGEN), (at91adc_base + AT91_ADC_MR));


//printk(KERN_INFO "at91adc: ADC Loaded module\n");
return 0;
}

void cleanup_module(void)
{
// Reset PMC bit for ADC and TC0
clk_disable(at91adc_clk);

// Private data for shared interrupts

// Unmap ADC and TC0 register map.
iounmap(at91adc_base);

// Free kernel memory allocated
//kfree(at91adc_pbuf1);

// Free device number allocated.
unregister_chrdev_region(at91adc_devno, 1); // allocated device number, number of devices

//printk(KERN_INFO "at91adc: Unloaded ADC module\n");
}

/*****************************************************************************************
| Module open: |
*****************************************************************************************/
static int at91adc_open (struct inode *inode, struct file *filp)
{
//printk(KERN_INFO "at91adc: Open func ADC module\n");
return 0;
}

/*****************************************************************************************
| Module close: |
*****************************************************************************************/
static int at91adc_release (struct inode *inode, struct file *filp)
{
//printk(KERN_INFO "at91adc: Release func ADC module\n");
return 0;
}

/*****************************************************************************************
| Module read: Return last READ_SAMPLES samples from ADC chan 0 or 1 depending on the |
| minor number. |
*****************************************************************************************/
static ssize_t at91adc_read (struct file *filp, char __iomem *buf, size_t bufsize, loff_t *f_pos)
{
unsigned short val;
// Latch the index of the latest data
iowrite32(AT91_ADC_START, (at91adc_base + AT91_ADC_CR));
while ((ioread32(at91adc_base + AT91_ADC_SR) & AT91_ADC_DRDY) == 0) cpu_relax();
val = ioread32(at91adc_base + AT91_ADC_CHR(1));

if (copy_to_user(buf, &val, sizeof(unsigned short)) != 0) return -EFAULT;
return 2;
}

struct file_operations at91adc_fops = {
.owner = THIS_MODULE,
.open = at91adc_open,
.read = at91adc_read,
.release = at91adc_release,
};

module_init(at91adc_init);
module_exit(cleanup_module);

MODULE_AUTHOR("GOWREE SANKAR");
MODULE_DESCRIPTION("Initialize and read AT91SAM9260 ADC channels");
MODULE_LICENSE("GPL");
 
Old 02-07-2011, 02:22 PM   #6
nini09
Member
 
Registered: Apr 2009
Posts: 920

Rep: Reputation: 67
Based on the crash information, ADC read routine hold some resource ISR need it.
 
Old 02-07-2011, 04:28 PM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 10,894
Blog Entries: 1

Rep: Reputation: 1308Reputation: 1308Reputation: 1308Reputation: 1308Reputation: 1308Reputation: 1308Reputation: 1308Reputation: 1308Reputation: 1308Reputation: 1308
Hi,
@OP
Welcome to LQ!

You should use the vbcode tags whenever posting long lists. This will make your posts cleaner therefore easier to read.

You can find the # and quote at the top of the reply window.
 
Old 02-07-2011, 11:16 PM   #8
sankar2078
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Hi... If don't mind please modify the code to work with ISR. and to resolve this panic. i am not able to do that.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel panic - not syncing luzyS Linux - Newbie 1 04-12-2008 07:50 AM
kernel panic - not syncing kgandhi5 Linux - Newbie 5 12-08-2007 09:48 PM
Kernel panic - not syncing! XPisbetterthanVista Linux - Software 12 10-17-2007 03:40 AM
Kernel Panic - Not Syncing! XPisbetterthanVista Linux - Newbie 2 08-20-2007 12:10 AM
Kernel panic not syncing n6rob Linux - General 3 02-15-2006 06:13 AM


All times are GMT -5. The time now is 07:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration