Hi
I am getting kernel oops because of i2c_master_send function when i call tsc2007_wq_function function with schedule_work(&work), but when i directly call same function in timer function, it is working but in this case "BUG: scheduling while atomic: swapper" warning occurs and linux is crashing.
if "&normal_i2c" causes this problem which is in "static DECLARE_WORK(work, (void (*)(void *))tsc2007_wq_function, &normal_i2c)" has anybody got any idea what to write instead of it.
static unsigned int short normal_i2c[] = { 0x48, I2C_CLIENT_END };
I2C_CLIENT_INSMOD_1 (tsc2007);
static void tsc2007_wq_function(void *);
static DECLARE_WORK(work, (void (*)(void *))tsc2007_wq_function, &normal_i2c);
static void tsc2007_wq_function(void *arg)
{
struct tsc2007_data *data = (struct tsc2007_data *)arg;
struct i2c_client *client = &data->client;
u16 x_value = 0;
u16 y_value = 0;
u8 measure_y = TSC2007_CMD (MEAS_YPOS, data->pd, data->m);
u8 measure_x = TSC2007_CMD (MEAS_XPOS, data->pd, data->m);
data->kernel_x = 0;
data->kernel_y = 0;
i2c_master_send (client,&measure_y, BYTES_TO_TX);
i2c_master_recv (client,(u8 *)&y_value, BYTES_TO_RX);
i2c_master_send (client,&measure_x, BYTES_TO_TX);
i2c_master_recv (client,(u8 *)&x_value, BYTES_TO_RX);
if (data->m == M_12BIT){
data->kernel_y = (((be16_to_cpu (y_value)) >> 4) & VALUE_MASK);
data->kernel_x = (((be16_to_cpu (x_value)) >> 4) & VALUE_MASK);
}
else if (data->m == M_8BIT){
data->kernel_y = y_value;
data->kernel_x = x_value;
}
}
////////kernel oops message/////////
# ts_test
[ 26.710000] Unable to handle kernel paging request at virtual address 00bbe59f
[ 26.710000] pgd = c49d0000
[ 26.720000] [00bbe59f] *pgd=00000000
[ 26.720000] Internal error: Oops: 1 [#1]
[ 26.720000] Modules linked in:
[ 26.720000] CPU: 0
[ 26.720000] PC is at i2c_transfer+0x18/0xe8
[ 26.720000] LR is at i2c_master_send+0x44/0x54
[ 26.720000] pc : [<c024aa5c>] lr : [<c024b630>] Not tainted
[ 26.720000] sp : c0581eb8 ip : c0581ee8 fp : c0581ee4
[ 26.720000] r10: c03e5f9c r9 : c028e108 r8 : 00000000
[ 26.720000] r7 : c03e5e00 r6 : 000001b6 r5 : 000001b4 r4 : fffefffe
[ 26.720000] r3 : 00bbe59f r2 : 00000001 r1 : c0581eec r0 : fffefffe
[ 26.720000] Flags: nZCv IRQs on FIQs on Mode SVC_32 Segment kernel
[ 26.720000] Control: 5317F
[ 26.720000] Table: 849D0000 DAC: 00000017
[ 26.720000] Process events/0 (pid: 12, stack limit = 0xc0580258)
[ 26.720000] Stack: (0xc0581eb8 to 0xc0582000)
[ 26.720000] 1ea0: c053eeb0 00000001
[ 26.720000] 1ec0: 000001b4 000001b6 c03e5e00 00000000 c028e108 c03e5f9c c0581f0c c0581ee8
[ 26.720000] 1ee0: c024b630 c024aa54 c055d040 0000fffe c0580001 c0581f17 c005f9d0 c03e5f9c
[ 26.720000] 1f00: c0581f34 c0581f10 c028e174 c024b5fc 00009dc8 d0c00000 00000000 80000013
[ 26.720000] 1f20: c05366a0 c0580000 c0581f6c c0581f38 c00625a4 c028e118 c05366b8 c05366a8
[ 26.720000] 1f40: 00000002 00000000 c05366a8 c0580000 c05366a0 c05366b0 00000002 c0581f84
[ 26.720000] 1f60: c0581fcc c0581f70 c0062dac c00624d4 00000001 00000000 c0049c08 00010000
[ 26.720000] 1f80: 00000000 00000000 c055d040 c004b200 00100100 00200200 ffffffff ffffffff
[ 26.720000] 1fa0: 00000000 c05366a0 c0580000 c0062ca4 c0551ee0 00000000 00000000 00000000
[ 26.720000] 1fc0: c0581ff4 c0581fd0 c0065d10 c0062cb4 ffffffff ffffffff 00000000 00000000
[ 26.720000] 1fe0: 00000000 00000000 00000000 c0581ff8 c0052a74 c0065c38 00000000 4800133a
[ 26.720000] Backtrace:
[ 26.720000] [<c024aa44>] (i2c_transfer+0x0/0xe8) from [<c024b630>] (i2c_master_send+0x44/0x54)
[ 26.720000] [<c024b5ec>] (i2c_master_send+0x0/0x54) from [<c028e174>] (tsc2007_wq_function+0x6c/0x104)
[ 26.720000] r4 = C03E5F9C
[ 26.720000] [<c028e108>] (tsc2007_wq_function+0x0/0x104) from [<c00625a4>] (run_workqueue+0xe0/0x170)
[ 26.720000] r6 = C0580000 r5 = C05366A0 r4 = 80000013
[ 26.720000] [<c00624c4>] (run_workqueue+0x0/0x170) from [<c0062dac>] (worker_thread+0x108/0x144)
[ 26.720000] [<c0062ca4>] (worker_thread+0x0/0x144) from [<c0065d10>] (kthread+0xe8/0x128)
[ 26.720000] [<c0065c28>] (kthread+0x0/0x128) from [<c0052a74>] (do_exit+0x0/0x9cc)
[ 26.720000] r7 = 00000000 r6 = 00000000 r5 = 00000000 r4 = 00000000
[ 26.720000] Code: e24cb004 e24dd004 e590300c e1a04000 (e5933000)
[ 26.720000] <7>evbug.c: Event. Dev: <NULL>, Type: 1, Code: 330, Value: 0
[ 27.930000] evbug.c: Event. Dev: <NULL>, Type: 3, Code: 24, Value: 0
[ 27.940000] evbug.c: Event. Dev: <NULL>, Type: 0, Code: 0, Value: 0
946684823.822249: 269 -19110 7500
946684825.041995: 269 -19110 0