Re: atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Boris Brezillon
On Wed, 27 Sep 2017 13:01:51 +0200
Richard Genoud  wrote:

> 2017-09-27 12:15 GMT+02:00 Richard Genoud :
> > 2017-09-27 12:04 GMT+02:00 Boris Brezillon 
> > :  
> >> On Wed, 27 Sep 2017 11:05:57 +0200
> >> Richard Genoud  wrote:
> >>  
> >>> Hi Boris, Nicolas !
> >>>
> >>> Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand 
> >>> driver")
> >>> strange things happen when nand-ecc-strength = <4>; (previously 
> >>> atmel,pmecc-cap).
> >>>
> >>> I first saw that a NULL pointer dereference happened when "udevadm 
> >>> trigger" was launched.
> >>> With strace, I nailed it down to :
> >>>
> >>> sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent
> >>> [   86.696275] Unable to handle kernel NULL pointer dereference at 
> >>> virtual address 0001
> >>> [   86.704285] pgd = c717c000
> >>> [   86.707072] [0001] *pgd=c06d9a70, *pte=, 
> >>> *ppte=
> >>> [   86.713979] Internal error: Oops: 17 [#3] ARM
> >>> [   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
> >>> 4.11.0-rc1-00056-gf88fc122cc34-dirty #75
> >>> [   86.727443] Hardware name: Atmel AT91SAM9
> >>> [   86.731424] task: c7880b60 task.stack: c7884000
> >>> [   86.735926] PC is at strlen+0x14/0x2c
> >>> [   86.739556] LR is at kobject_get_path+0x34/0xac
> >>> [   86.744046] pc : []lr : []psr: 2013
> >>> [   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
> >>> [   86.755439] r10: 0002  r9 :   r8 : c7885f78
> >>> [   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
> >>> [   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
> >>> [   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  
> >>> Segment none
> >>> [   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
> >>> [   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
> >>> [   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
> >>> [   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 
> >>> c79f1000 c7ab2308 c78c2b00
> >>> [   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 
> >>> c0234ffc c00a53b4 0074
> >>> [   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 
> >>> c05b4aa8 081f 0007
> >>> [   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 
> >>> 0007 c7885e54 c7885e48
> >>> [   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 
> >>> c023663c c7885e9c 0002
> >>> [   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 
> >>> c02a5800 c7885e9c c7885e88
> >>> [   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 
> >>> c7885ea0 c01281e4 c0128f8c
> >>> [   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 
> >>> c7215c20 c7885f78 0007
> >>> [   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 
> >>> c01280c8 081f 00107d00
> >>> [   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 
> >>> c7885fac c7885f04 c00091e4
> >>> [   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc 
> >>>  bec504d0 b6e8bbec
> >>> [   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 
> >>> c7885f78 c7885f74 c7885f48
> >>> [   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568  
> >>>  c7215c20 c7215c20
> >>> [   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc 
> >>> c00cb0b0  
> >>> [   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544 
> >>>   c7885fa8
> >>> [   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 
> >>> 00106cf8 0007 
> >>> [   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 
> >>> 0004  000e9124
> >>> [   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 
> >>> 0001  
> >>> [   86.942277] [] (strlen) from [] 
> >>> (kobject_get_path+0x34/0xac)
> >>> [   86.949620] [] (kobject_get_path) from [] 
> >>> (kobject_uevent_env+0xcc/0x4b4)
> >>> [   86.958083] [] (kobject_uevent_env) from [] 
> >>> (kobject_uevent+0x14/0x18)
> >>> [   86.966287] [] (kobject_uevent) from [] 
> >>> (uevent_store+0x44/0x64)
> >>> [   86.973987] [] (uevent_store) from [] 
> >>> (dev_attr_store+0x28/0x34)
> >>> [   86.981672] [] (dev_attr_store) from [] 
> >>> (sysfs_kf_write+0x4c/0x58)
> >>> [   86.989525] [] (sysfs_kf_write) from [] 
> >>> (kernfs_fop_write+0x12c/0x1c4)
> >>> [   86.997737] [] (kernfs_fop_write) from [] 
> >>> (__vfs_write+0x3c/0x11c)
> >>> [   87.005596] [] (__vfs_write) from [] 
> >>> (vfs_write+0xc0/0x164)
> >>> [   87.012855] [] (vfs_write) from [] 
> >>> (SyS_write+0x4c/0x8c)
> >>> [   87.019854] [] (SyS_write) from [] 
> >>> (ret_fast_syscall+0x0/0x38)
> >>> [   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000)
> >>> [   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
> >>> [   

Re: atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Boris Brezillon
On Wed, 27 Sep 2017 13:01:51 +0200
Richard Genoud  wrote:

> 2017-09-27 12:15 GMT+02:00 Richard Genoud :
> > 2017-09-27 12:04 GMT+02:00 Boris Brezillon 
> > :  
> >> On Wed, 27 Sep 2017 11:05:57 +0200
> >> Richard Genoud  wrote:
> >>  
> >>> Hi Boris, Nicolas !
> >>>
> >>> Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand 
> >>> driver")
> >>> strange things happen when nand-ecc-strength = <4>; (previously 
> >>> atmel,pmecc-cap).
> >>>
> >>> I first saw that a NULL pointer dereference happened when "udevadm 
> >>> trigger" was launched.
> >>> With strace, I nailed it down to :
> >>>
> >>> sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent
> >>> [   86.696275] Unable to handle kernel NULL pointer dereference at 
> >>> virtual address 0001
> >>> [   86.704285] pgd = c717c000
> >>> [   86.707072] [0001] *pgd=c06d9a70, *pte=, 
> >>> *ppte=
> >>> [   86.713979] Internal error: Oops: 17 [#3] ARM
> >>> [   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
> >>> 4.11.0-rc1-00056-gf88fc122cc34-dirty #75
> >>> [   86.727443] Hardware name: Atmel AT91SAM9
> >>> [   86.731424] task: c7880b60 task.stack: c7884000
> >>> [   86.735926] PC is at strlen+0x14/0x2c
> >>> [   86.739556] LR is at kobject_get_path+0x34/0xac
> >>> [   86.744046] pc : []lr : []psr: 2013
> >>> [   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
> >>> [   86.755439] r10: 0002  r9 :   r8 : c7885f78
> >>> [   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
> >>> [   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
> >>> [   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  
> >>> Segment none
> >>> [   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
> >>> [   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
> >>> [   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
> >>> [   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 
> >>> c79f1000 c7ab2308 c78c2b00
> >>> [   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 
> >>> c0234ffc c00a53b4 0074
> >>> [   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 
> >>> c05b4aa8 081f 0007
> >>> [   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 
> >>> 0007 c7885e54 c7885e48
> >>> [   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 
> >>> c023663c c7885e9c 0002
> >>> [   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 
> >>> c02a5800 c7885e9c c7885e88
> >>> [   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 
> >>> c7885ea0 c01281e4 c0128f8c
> >>> [   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 
> >>> c7215c20 c7885f78 0007
> >>> [   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 
> >>> c01280c8 081f 00107d00
> >>> [   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 
> >>> c7885fac c7885f04 c00091e4
> >>> [   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc 
> >>>  bec504d0 b6e8bbec
> >>> [   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 
> >>> c7885f78 c7885f74 c7885f48
> >>> [   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568  
> >>>  c7215c20 c7215c20
> >>> [   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc 
> >>> c00cb0b0  
> >>> [   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544 
> >>>   c7885fa8
> >>> [   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 
> >>> 00106cf8 0007 
> >>> [   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 
> >>> 0004  000e9124
> >>> [   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 
> >>> 0001  
> >>> [   86.942277] [] (strlen) from [] 
> >>> (kobject_get_path+0x34/0xac)
> >>> [   86.949620] [] (kobject_get_path) from [] 
> >>> (kobject_uevent_env+0xcc/0x4b4)
> >>> [   86.958083] [] (kobject_uevent_env) from [] 
> >>> (kobject_uevent+0x14/0x18)
> >>> [   86.966287] [] (kobject_uevent) from [] 
> >>> (uevent_store+0x44/0x64)
> >>> [   86.973987] [] (uevent_store) from [] 
> >>> (dev_attr_store+0x28/0x34)
> >>> [   86.981672] [] (dev_attr_store) from [] 
> >>> (sysfs_kf_write+0x4c/0x58)
> >>> [   86.989525] [] (sysfs_kf_write) from [] 
> >>> (kernfs_fop_write+0x12c/0x1c4)
> >>> [   86.997737] [] (kernfs_fop_write) from [] 
> >>> (__vfs_write+0x3c/0x11c)
> >>> [   87.005596] [] (__vfs_write) from [] 
> >>> (vfs_write+0xc0/0x164)
> >>> [   87.012855] [] (vfs_write) from [] 
> >>> (SyS_write+0x4c/0x8c)
> >>> [   87.019854] [] (SyS_write) from [] 
> >>> (ret_fast_syscall+0x0/0x38)
> >>> [   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000)
> >>> [   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
> >>> [   87.039277] Kernel panic - not syncing: Attempted to kill init! 
> >>> exitcode=0x000b
> >>>
> >>> This is fun because 

Re: atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Richard Genoud
2017-09-27 12:15 GMT+02:00 Richard Genoud :
> 2017-09-27 12:04 GMT+02:00 Boris Brezillon 
> :
>> On Wed, 27 Sep 2017 11:05:57 +0200
>> Richard Genoud  wrote:
>>
>>> Hi Boris, Nicolas !
>>>
>>> Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand 
>>> driver")
>>> strange things happen when nand-ecc-strength = <4>; (previously 
>>> atmel,pmecc-cap).
>>>
>>> I first saw that a NULL pointer dereference happened when "udevadm trigger" 
>>> was launched.
>>> With strace, I nailed it down to :
>>>
>>> sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent
>>> [   86.696275] Unable to handle kernel NULL pointer dereference at virtual 
>>> address 0001
>>> [   86.704285] pgd = c717c000
>>> [   86.707072] [0001] *pgd=c06d9a70, *pte=, 
>>> *ppte=
>>> [   86.713979] Internal error: Oops: 17 [#3] ARM
>>> [   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
>>> 4.11.0-rc1-00056-gf88fc122cc34-dirty #75
>>> [   86.727443] Hardware name: Atmel AT91SAM9
>>> [   86.731424] task: c7880b60 task.stack: c7884000
>>> [   86.735926] PC is at strlen+0x14/0x2c
>>> [   86.739556] LR is at kobject_get_path+0x34/0xac
>>> [   86.744046] pc : []lr : []psr: 2013
>>> [   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
>>> [   86.755439] r10: 0002  r9 :   r8 : c7885f78
>>> [   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
>>> [   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
>>> [   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
>>> none
>>> [   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
>>> [   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
>>> [   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
>>> [   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 c79f1000 
>>> c7ab2308 c78c2b00
>>> [   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 c0234ffc 
>>> c00a53b4 0074
>>> [   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 c05b4aa8 
>>> 081f 0007
>>> [   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 0007 
>>> c7885e54 c7885e48
>>> [   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 c023663c 
>>> c7885e9c 0002
>>> [   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 c02a5800 
>>> c7885e9c c7885e88
>>> [   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 c7885ea0 
>>> c01281e4 c0128f8c
>>> [   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 c7215c20 
>>> c7885f78 0007
>>> [   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 c01280c8 
>>> 081f 00107d00
>>> [   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 c7885fac 
>>> c7885f04 c00091e4
>>> [   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc  
>>> bec504d0 b6e8bbec
>>> [   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 c7885f78 
>>> c7885f74 c7885f48
>>> [   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568   
>>> c7215c20 c7215c20
>>> [   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc c00cb0b0 
>>>  
>>> [   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544  
>>>  c7885fa8
>>> [   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 00106cf8 
>>> 0007 
>>> [   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 0004 
>>>  000e9124
>>> [   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 0001 
>>>  
>>> [   86.942277] [] (strlen) from [] 
>>> (kobject_get_path+0x34/0xac)
>>> [   86.949620] [] (kobject_get_path) from [] 
>>> (kobject_uevent_env+0xcc/0x4b4)
>>> [   86.958083] [] (kobject_uevent_env) from [] 
>>> (kobject_uevent+0x14/0x18)
>>> [   86.966287] [] (kobject_uevent) from [] 
>>> (uevent_store+0x44/0x64)
>>> [   86.973987] [] (uevent_store) from [] 
>>> (dev_attr_store+0x28/0x34)
>>> [   86.981672] [] (dev_attr_store) from [] 
>>> (sysfs_kf_write+0x4c/0x58)
>>> [   86.989525] [] (sysfs_kf_write) from [] 
>>> (kernfs_fop_write+0x12c/0x1c4)
>>> [   86.997737] [] (kernfs_fop_write) from [] 
>>> (__vfs_write+0x3c/0x11c)
>>> [   87.005596] [] (__vfs_write) from [] 
>>> (vfs_write+0xc0/0x164)
>>> [   87.012855] [] (vfs_write) from [] 
>>> (SyS_write+0x4c/0x8c)
>>> [   87.019854] [] (SyS_write) from [] 
>>> (ret_fast_syscall+0x0/0x38)
>>> [   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000)
>>> [   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
>>> [   87.039277] Kernel panic - not syncing: Attempted to kill init! 
>>> exitcode=0x000b
>>>
>>> This is fun because it really doesn't seem to have anything to do with 
>>> atmel-nand...
>>>
>>> I first found that on my custom board, built around an at91sam9g35-cm, but 
>>> I managed to trigger it

Re: atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Richard Genoud
2017-09-27 12:15 GMT+02:00 Richard Genoud :
> 2017-09-27 12:04 GMT+02:00 Boris Brezillon 
> :
>> On Wed, 27 Sep 2017 11:05:57 +0200
>> Richard Genoud  wrote:
>>
>>> Hi Boris, Nicolas !
>>>
>>> Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand 
>>> driver")
>>> strange things happen when nand-ecc-strength = <4>; (previously 
>>> atmel,pmecc-cap).
>>>
>>> I first saw that a NULL pointer dereference happened when "udevadm trigger" 
>>> was launched.
>>> With strace, I nailed it down to :
>>>
>>> sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent
>>> [   86.696275] Unable to handle kernel NULL pointer dereference at virtual 
>>> address 0001
>>> [   86.704285] pgd = c717c000
>>> [   86.707072] [0001] *pgd=c06d9a70, *pte=, 
>>> *ppte=
>>> [   86.713979] Internal error: Oops: 17 [#3] ARM
>>> [   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
>>> 4.11.0-rc1-00056-gf88fc122cc34-dirty #75
>>> [   86.727443] Hardware name: Atmel AT91SAM9
>>> [   86.731424] task: c7880b60 task.stack: c7884000
>>> [   86.735926] PC is at strlen+0x14/0x2c
>>> [   86.739556] LR is at kobject_get_path+0x34/0xac
>>> [   86.744046] pc : []lr : []psr: 2013
>>> [   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
>>> [   86.755439] r10: 0002  r9 :   r8 : c7885f78
>>> [   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
>>> [   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
>>> [   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
>>> none
>>> [   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
>>> [   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
>>> [   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
>>> [   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 c79f1000 
>>> c7ab2308 c78c2b00
>>> [   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 c0234ffc 
>>> c00a53b4 0074
>>> [   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 c05b4aa8 
>>> 081f 0007
>>> [   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 0007 
>>> c7885e54 c7885e48
>>> [   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 c023663c 
>>> c7885e9c 0002
>>> [   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 c02a5800 
>>> c7885e9c c7885e88
>>> [   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 c7885ea0 
>>> c01281e4 c0128f8c
>>> [   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 c7215c20 
>>> c7885f78 0007
>>> [   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 c01280c8 
>>> 081f 00107d00
>>> [   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 c7885fac 
>>> c7885f04 c00091e4
>>> [   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc  
>>> bec504d0 b6e8bbec
>>> [   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 c7885f78 
>>> c7885f74 c7885f48
>>> [   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568   
>>> c7215c20 c7215c20
>>> [   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc c00cb0b0 
>>>  
>>> [   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544  
>>>  c7885fa8
>>> [   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 00106cf8 
>>> 0007 
>>> [   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 0004 
>>>  000e9124
>>> [   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 0001 
>>>  
>>> [   86.942277] [] (strlen) from [] 
>>> (kobject_get_path+0x34/0xac)
>>> [   86.949620] [] (kobject_get_path) from [] 
>>> (kobject_uevent_env+0xcc/0x4b4)
>>> [   86.958083] [] (kobject_uevent_env) from [] 
>>> (kobject_uevent+0x14/0x18)
>>> [   86.966287] [] (kobject_uevent) from [] 
>>> (uevent_store+0x44/0x64)
>>> [   86.973987] [] (uevent_store) from [] 
>>> (dev_attr_store+0x28/0x34)
>>> [   86.981672] [] (dev_attr_store) from [] 
>>> (sysfs_kf_write+0x4c/0x58)
>>> [   86.989525] [] (sysfs_kf_write) from [] 
>>> (kernfs_fop_write+0x12c/0x1c4)
>>> [   86.997737] [] (kernfs_fop_write) from [] 
>>> (__vfs_write+0x3c/0x11c)
>>> [   87.005596] [] (__vfs_write) from [] 
>>> (vfs_write+0xc0/0x164)
>>> [   87.012855] [] (vfs_write) from [] 
>>> (SyS_write+0x4c/0x8c)
>>> [   87.019854] [] (SyS_write) from [] 
>>> (ret_fast_syscall+0x0/0x38)
>>> [   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000)
>>> [   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
>>> [   87.039277] Kernel panic - not syncing: Attempted to kill init! 
>>> exitcode=0x000b
>>>
>>> This is fun because it really doesn't seem to have anything to do with 
>>> atmel-nand...
>>>
>>> I first found that on my custom board, built around an at91sam9g35-cm, but 
>>> I managed to trigger it
>>> on an at91sam9g35-ek board, with a 4.13.3 kernel.
>>>
>>> NB: I couldn't trigger this 

Re: atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Richard Genoud
2017-09-27 12:04 GMT+02:00 Boris Brezillon :
> On Wed, 27 Sep 2017 11:05:57 +0200
> Richard Genoud  wrote:
>
>> Hi Boris, Nicolas !
>>
>> Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
>> strange things happen when nand-ecc-strength = <4>; (previously 
>> atmel,pmecc-cap).
>>
>> I first saw that a NULL pointer dereference happened when "udevadm trigger" 
>> was launched.
>> With strace, I nailed it down to :
>>
>> sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent
>> [   86.696275] Unable to handle kernel NULL pointer dereference at virtual 
>> address 0001
>> [   86.704285] pgd = c717c000
>> [   86.707072] [0001] *pgd=c06d9a70, *pte=, 
>> *ppte=
>> [   86.713979] Internal error: Oops: 17 [#3] ARM
>> [   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
>> 4.11.0-rc1-00056-gf88fc122cc34-dirty #75
>> [   86.727443] Hardware name: Atmel AT91SAM9
>> [   86.731424] task: c7880b60 task.stack: c7884000
>> [   86.735926] PC is at strlen+0x14/0x2c
>> [   86.739556] LR is at kobject_get_path+0x34/0xac
>> [   86.744046] pc : []lr : []psr: 2013
>> [   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
>> [   86.755439] r10: 0002  r9 :   r8 : c7885f78
>> [   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
>> [   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
>> [   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
>> none
>> [   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
>> [   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
>> [   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
>> [   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 c79f1000 
>> c7ab2308 c78c2b00
>> [   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 c0234ffc 
>> c00a53b4 0074
>> [   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 c05b4aa8 
>> 081f 0007
>> [   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 0007 
>> c7885e54 c7885e48
>> [   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 c023663c 
>> c7885e9c 0002
>> [   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 c02a5800 
>> c7885e9c c7885e88
>> [   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 c7885ea0 
>> c01281e4 c0128f8c
>> [   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 c7215c20 
>> c7885f78 0007
>> [   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 c01280c8 
>> 081f 00107d00
>> [   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 c7885fac 
>> c7885f04 c00091e4
>> [   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc  
>> bec504d0 b6e8bbec
>> [   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 c7885f78 
>> c7885f74 c7885f48
>> [   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568   
>> c7215c20 c7215c20
>> [   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc c00cb0b0 
>>  
>> [   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544  
>>  c7885fa8
>> [   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 00106cf8 
>> 0007 
>> [   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 0004 
>>  000e9124
>> [   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 0001 
>>  
>> [   86.942277] [] (strlen) from [] 
>> (kobject_get_path+0x34/0xac)
>> [   86.949620] [] (kobject_get_path) from [] 
>> (kobject_uevent_env+0xcc/0x4b4)
>> [   86.958083] [] (kobject_uevent_env) from [] 
>> (kobject_uevent+0x14/0x18)
>> [   86.966287] [] (kobject_uevent) from [] 
>> (uevent_store+0x44/0x64)
>> [   86.973987] [] (uevent_store) from [] 
>> (dev_attr_store+0x28/0x34)
>> [   86.981672] [] (dev_attr_store) from [] 
>> (sysfs_kf_write+0x4c/0x58)
>> [   86.989525] [] (sysfs_kf_write) from [] 
>> (kernfs_fop_write+0x12c/0x1c4)
>> [   86.997737] [] (kernfs_fop_write) from [] 
>> (__vfs_write+0x3c/0x11c)
>> [   87.005596] [] (__vfs_write) from [] 
>> (vfs_write+0xc0/0x164)
>> [   87.012855] [] (vfs_write) from [] 
>> (SyS_write+0x4c/0x8c)
>> [   87.019854] [] (SyS_write) from [] 
>> (ret_fast_syscall+0x0/0x38)
>> [   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000)
>> [   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
>> [   87.039277] Kernel panic - not syncing: Attempted to kill init! 
>> exitcode=0x000b
>>
>> This is fun because it really doesn't seem to have anything to do with 
>> atmel-nand...
>>
>> I first found that on my custom board, built around an at91sam9g35-cm, but I 
>> managed to trigger it
>> on an at91sam9g35-ek board, with a 4.13.3 kernel.
>>
>> NB: I couldn't trigger this with ecc-strength = 2
>>
>> So, here is my configuration:
>> - at91sam9g35-ek board with the image 

Re: atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Richard Genoud
2017-09-27 12:04 GMT+02:00 Boris Brezillon :
> On Wed, 27 Sep 2017 11:05:57 +0200
> Richard Genoud  wrote:
>
>> Hi Boris, Nicolas !
>>
>> Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
>> strange things happen when nand-ecc-strength = <4>; (previously 
>> atmel,pmecc-cap).
>>
>> I first saw that a NULL pointer dereference happened when "udevadm trigger" 
>> was launched.
>> With strace, I nailed it down to :
>>
>> sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent
>> [   86.696275] Unable to handle kernel NULL pointer dereference at virtual 
>> address 0001
>> [   86.704285] pgd = c717c000
>> [   86.707072] [0001] *pgd=c06d9a70, *pte=, 
>> *ppte=
>> [   86.713979] Internal error: Oops: 17 [#3] ARM
>> [   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
>> 4.11.0-rc1-00056-gf88fc122cc34-dirty #75
>> [   86.727443] Hardware name: Atmel AT91SAM9
>> [   86.731424] task: c7880b60 task.stack: c7884000
>> [   86.735926] PC is at strlen+0x14/0x2c
>> [   86.739556] LR is at kobject_get_path+0x34/0xac
>> [   86.744046] pc : []lr : []psr: 2013
>> [   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
>> [   86.755439] r10: 0002  r9 :   r8 : c7885f78
>> [   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
>> [   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
>> [   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
>> none
>> [   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
>> [   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
>> [   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
>> [   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 c79f1000 
>> c7ab2308 c78c2b00
>> [   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 c0234ffc 
>> c00a53b4 0074
>> [   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 c05b4aa8 
>> 081f 0007
>> [   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 0007 
>> c7885e54 c7885e48
>> [   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 c023663c 
>> c7885e9c 0002
>> [   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 c02a5800 
>> c7885e9c c7885e88
>> [   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 c7885ea0 
>> c01281e4 c0128f8c
>> [   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 c7215c20 
>> c7885f78 0007
>> [   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 c01280c8 
>> 081f 00107d00
>> [   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 c7885fac 
>> c7885f04 c00091e4
>> [   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc  
>> bec504d0 b6e8bbec
>> [   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 c7885f78 
>> c7885f74 c7885f48
>> [   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568   
>> c7215c20 c7215c20
>> [   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc c00cb0b0 
>>  
>> [   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544  
>>  c7885fa8
>> [   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 00106cf8 
>> 0007 
>> [   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 0004 
>>  000e9124
>> [   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 0001 
>>  
>> [   86.942277] [] (strlen) from [] 
>> (kobject_get_path+0x34/0xac)
>> [   86.949620] [] (kobject_get_path) from [] 
>> (kobject_uevent_env+0xcc/0x4b4)
>> [   86.958083] [] (kobject_uevent_env) from [] 
>> (kobject_uevent+0x14/0x18)
>> [   86.966287] [] (kobject_uevent) from [] 
>> (uevent_store+0x44/0x64)
>> [   86.973987] [] (uevent_store) from [] 
>> (dev_attr_store+0x28/0x34)
>> [   86.981672] [] (dev_attr_store) from [] 
>> (sysfs_kf_write+0x4c/0x58)
>> [   86.989525] [] (sysfs_kf_write) from [] 
>> (kernfs_fop_write+0x12c/0x1c4)
>> [   86.997737] [] (kernfs_fop_write) from [] 
>> (__vfs_write+0x3c/0x11c)
>> [   87.005596] [] (__vfs_write) from [] 
>> (vfs_write+0xc0/0x164)
>> [   87.012855] [] (vfs_write) from [] 
>> (SyS_write+0x4c/0x8c)
>> [   87.019854] [] (SyS_write) from [] 
>> (ret_fast_syscall+0x0/0x38)
>> [   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000)
>> [   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
>> [   87.039277] Kernel panic - not syncing: Attempted to kill init! 
>> exitcode=0x000b
>>
>> This is fun because it really doesn't seem to have anything to do with 
>> atmel-nand...
>>
>> I first found that on my custom board, built around an at91sam9g35-cm, but I 
>> managed to trigger it
>> on an at91sam9g35-ek board, with a 4.13.3 kernel.
>>
>> NB: I couldn't trigger this with ecc-strength = 2
>>
>> So, here is my configuration:
>> - at91sam9g35-ek board with the image 
>> 

Re: atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Boris Brezillon
On Wed, 27 Sep 2017 11:05:57 +0200
Richard Genoud  wrote:

> Hi Boris, Nicolas !
> 
> Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
> strange things happen when nand-ecc-strength = <4>; (previously 
> atmel,pmecc-cap).
> 
> I first saw that a NULL pointer dereference happened when "udevadm trigger" 
> was launched.
> With strace, I nailed it down to :
> 
> sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent 
> [   86.696275] Unable to handle kernel NULL pointer dereference at virtual 
> address 0001
> [   86.704285] pgd = c717c000
> [   86.707072] [0001] *pgd=c06d9a70, *pte=, *ppte=
> [   86.713979] Internal error: Oops: 17 [#3] ARM
> [   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
> 4.11.0-rc1-00056-gf88fc122cc34-dirty #75
> [   86.727443] Hardware name: Atmel AT91SAM9
> [   86.731424] task: c7880b60 task.stack: c7884000
> [   86.735926] PC is at strlen+0x14/0x2c
> [   86.739556] LR is at kobject_get_path+0x34/0xac
> [   86.744046] pc : []lr : []psr: 2013
> [   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
> [   86.755439] r10: 0002  r9 :   r8 : c7885f78
> [   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
> [   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
> [   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
> none
> [   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
> [   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
> [   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
> [   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 c79f1000 
> c7ab2308 c78c2b00
> [   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 c0234ffc 
> c00a53b4 0074
> [   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 c05b4aa8 
> 081f 0007
> [   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 0007 
> c7885e54 c7885e48
> [   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 c023663c 
> c7885e9c 0002
> [   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 c02a5800 
> c7885e9c c7885e88
> [   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 c7885ea0 
> c01281e4 c0128f8c
> [   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 c7215c20 
> c7885f78 0007
> [   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 c01280c8 
> 081f 00107d00
> [   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 c7885fac 
> c7885f04 c00091e4
> [   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc  
> bec504d0 b6e8bbec
> [   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 c7885f78 
> c7885f74 c7885f48
> [   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568   
> c7215c20 c7215c20
> [   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc c00cb0b0 
>  
> [   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544  
>  c7885fa8
> [   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 00106cf8 
> 0007 
> [   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 0004 
>  000e9124
> [   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 0001 
>  
> [   86.942277] [] (strlen) from [] 
> (kobject_get_path+0x34/0xac)
> [   86.949620] [] (kobject_get_path) from [] 
> (kobject_uevent_env+0xcc/0x4b4)
> [   86.958083] [] (kobject_uevent_env) from [] 
> (kobject_uevent+0x14/0x18)
> [   86.966287] [] (kobject_uevent) from [] 
> (uevent_store+0x44/0x64)
> [   86.973987] [] (uevent_store) from [] 
> (dev_attr_store+0x28/0x34)
> [   86.981672] [] (dev_attr_store) from [] 
> (sysfs_kf_write+0x4c/0x58)
> [   86.989525] [] (sysfs_kf_write) from [] 
> (kernfs_fop_write+0x12c/0x1c4)
> [   86.997737] [] (kernfs_fop_write) from [] 
> (__vfs_write+0x3c/0x11c)
> [   87.005596] [] (__vfs_write) from [] 
> (vfs_write+0xc0/0x164)
> [   87.012855] [] (vfs_write) from [] 
> (SyS_write+0x4c/0x8c)
> [   87.019854] [] (SyS_write) from [] 
> (ret_fast_syscall+0x0/0x38)
> [   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000) 
> [   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
> [   87.039277] Kernel panic - not syncing: Attempted to kill init! 
> exitcode=0x000b
> 
> This is fun because it really doesn't seem to have anything to do with 
> atmel-nand...
> 
> I first found that on my custom board, built around an at91sam9g35-cm, but I 
> managed to trigger it
> on an at91sam9g35-ek board, with a 4.13.3 kernel.
> 
> NB: I couldn't trigger this with ecc-strength = 2
> 
> So, here is my configuration:
> - at91sam9g35-ek board with the image 
> ftp://www.at91.com/pub/demo/linux4sam_5.6/linux4sam-poky-at91sam9x5ek-5.6.zip
> I flashed this image a first time as is, and then I flashed only the rfs with 
> eccType 0xc0902405.
> 

Re: atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Boris Brezillon
On Wed, 27 Sep 2017 11:05:57 +0200
Richard Genoud  wrote:

> Hi Boris, Nicolas !
> 
> Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
> strange things happen when nand-ecc-strength = <4>; (previously 
> atmel,pmecc-cap).
> 
> I first saw that a NULL pointer dereference happened when "udevadm trigger" 
> was launched.
> With strace, I nailed it down to :
> 
> sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent 
> [   86.696275] Unable to handle kernel NULL pointer dereference at virtual 
> address 0001
> [   86.704285] pgd = c717c000
> [   86.707072] [0001] *pgd=c06d9a70, *pte=, *ppte=
> [   86.713979] Internal error: Oops: 17 [#3] ARM
> [   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
> 4.11.0-rc1-00056-gf88fc122cc34-dirty #75
> [   86.727443] Hardware name: Atmel AT91SAM9
> [   86.731424] task: c7880b60 task.stack: c7884000
> [   86.735926] PC is at strlen+0x14/0x2c
> [   86.739556] LR is at kobject_get_path+0x34/0xac
> [   86.744046] pc : []lr : []psr: 2013
> [   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
> [   86.755439] r10: 0002  r9 :   r8 : c7885f78
> [   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
> [   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
> [   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
> none
> [   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
> [   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
> [   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
> [   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 c79f1000 
> c7ab2308 c78c2b00
> [   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 c0234ffc 
> c00a53b4 0074
> [   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 c05b4aa8 
> 081f 0007
> [   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 0007 
> c7885e54 c7885e48
> [   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 c023663c 
> c7885e9c 0002
> [   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 c02a5800 
> c7885e9c c7885e88
> [   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 c7885ea0 
> c01281e4 c0128f8c
> [   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 c7215c20 
> c7885f78 0007
> [   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 c01280c8 
> 081f 00107d00
> [   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 c7885fac 
> c7885f04 c00091e4
> [   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc  
> bec504d0 b6e8bbec
> [   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 c7885f78 
> c7885f74 c7885f48
> [   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568   
> c7215c20 c7215c20
> [   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc c00cb0b0 
>  
> [   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544  
>  c7885fa8
> [   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 00106cf8 
> 0007 
> [   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 0004 
>  000e9124
> [   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 0001 
>  
> [   86.942277] [] (strlen) from [] 
> (kobject_get_path+0x34/0xac)
> [   86.949620] [] (kobject_get_path) from [] 
> (kobject_uevent_env+0xcc/0x4b4)
> [   86.958083] [] (kobject_uevent_env) from [] 
> (kobject_uevent+0x14/0x18)
> [   86.966287] [] (kobject_uevent) from [] 
> (uevent_store+0x44/0x64)
> [   86.973987] [] (uevent_store) from [] 
> (dev_attr_store+0x28/0x34)
> [   86.981672] [] (dev_attr_store) from [] 
> (sysfs_kf_write+0x4c/0x58)
> [   86.989525] [] (sysfs_kf_write) from [] 
> (kernfs_fop_write+0x12c/0x1c4)
> [   86.997737] [] (kernfs_fop_write) from [] 
> (__vfs_write+0x3c/0x11c)
> [   87.005596] [] (__vfs_write) from [] 
> (vfs_write+0xc0/0x164)
> [   87.012855] [] (vfs_write) from [] 
> (SyS_write+0x4c/0x8c)
> [   87.019854] [] (SyS_write) from [] 
> (ret_fast_syscall+0x0/0x38)
> [   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000) 
> [   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
> [   87.039277] Kernel panic - not syncing: Attempted to kill init! 
> exitcode=0x000b
> 
> This is fun because it really doesn't seem to have anything to do with 
> atmel-nand...
> 
> I first found that on my custom board, built around an at91sam9g35-cm, but I 
> managed to trigger it
> on an at91sam9g35-ek board, with a 4.13.3 kernel.
> 
> NB: I couldn't trigger this with ecc-strength = 2
> 
> So, here is my configuration:
> - at91sam9g35-ek board with the image 
> ftp://www.at91.com/pub/demo/linux4sam_5.6/linux4sam-poky-at91sam9x5ek-5.6.zip
> I flashed this image a first time as is, and then I flashed only the rfs with 
> eccType 0xc0902405.
> 
> - Kernel 4.13.3 with the 

atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Richard Genoud
Hi Boris, Nicolas !

Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
strange things happen when nand-ecc-strength = <4>; (previously 
atmel,pmecc-cap).

I first saw that a NULL pointer dereference happened when "udevadm trigger" was 
launched.
With strace, I nailed it down to :

sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent 
[   86.696275] Unable to handle kernel NULL pointer dereference at virtual 
address 0001
[   86.704285] pgd = c717c000
[   86.707072] [0001] *pgd=c06d9a70, *pte=, *ppte=
[   86.713979] Internal error: Oops: 17 [#3] ARM
[   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
4.11.0-rc1-00056-gf88fc122cc34-dirty #75
[   86.727443] Hardware name: Atmel AT91SAM9
[   86.731424] task: c7880b60 task.stack: c7884000
[   86.735926] PC is at strlen+0x14/0x2c
[   86.739556] LR is at kobject_get_path+0x34/0xac
[   86.744046] pc : []lr : []psr: 2013
[   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
[   86.755439] r10: 0002  r9 :   r8 : c7885f78
[   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
[   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
[   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
[   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
[   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
[   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 c79f1000 
c7ab2308 c78c2b00
[   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 c0234ffc 
c00a53b4 0074
[   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 c05b4aa8 
081f 0007
[   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 0007 
c7885e54 c7885e48
[   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 c023663c 
c7885e9c 0002
[   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 c02a5800 
c7885e9c c7885e88
[   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 c7885ea0 
c01281e4 c0128f8c
[   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 c7215c20 
c7885f78 0007
[   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 c01280c8 
081f 00107d00
[   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 c7885fac 
c7885f04 c00091e4
[   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc  
bec504d0 b6e8bbec
[   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 c7885f78 
c7885f74 c7885f48
[   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568   
c7215c20 c7215c20
[   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc c00cb0b0 
 
[   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544  
 c7885fa8
[   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 00106cf8 
0007 
[   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 0004 
 000e9124
[   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 0001 
 
[   86.942277] [] (strlen) from [] 
(kobject_get_path+0x34/0xac)
[   86.949620] [] (kobject_get_path) from [] 
(kobject_uevent_env+0xcc/0x4b4)
[   86.958083] [] (kobject_uevent_env) from [] 
(kobject_uevent+0x14/0x18)
[   86.966287] [] (kobject_uevent) from [] 
(uevent_store+0x44/0x64)
[   86.973987] [] (uevent_store) from [] 
(dev_attr_store+0x28/0x34)
[   86.981672] [] (dev_attr_store) from [] 
(sysfs_kf_write+0x4c/0x58)
[   86.989525] [] (sysfs_kf_write) from [] 
(kernfs_fop_write+0x12c/0x1c4)
[   86.997737] [] (kernfs_fop_write) from [] 
(__vfs_write+0x3c/0x11c)
[   87.005596] [] (__vfs_write) from [] 
(vfs_write+0xc0/0x164)
[   87.012855] [] (vfs_write) from [] (SyS_write+0x4c/0x8c)
[   87.019854] [] (SyS_write) from [] 
(ret_fast_syscall+0x0/0x38)
[   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000) 
[   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
[   87.039277] Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x000b

This is fun because it really doesn't seem to have anything to do with 
atmel-nand...

I first found that on my custom board, built around an at91sam9g35-cm, but I 
managed to trigger it
on an at91sam9g35-ek board, with a 4.13.3 kernel.

NB: I couldn't trigger this with ecc-strength = 2

So, here is my configuration:
- at91sam9g35-ek board with the image 
ftp://www.at91.com/pub/demo/linux4sam_5.6/linux4sam-poky-at91sam9x5ek-5.6.zip
I flashed this image a first time as is, and then I flashed only the rfs with 
eccType 0xc0902405.

- Kernel 4.13.3 with the quick'n dirty patch:
--- a/arch/arm/boot/dts/at91sam9x5cm.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi
@@ -56,7 +56,7 @@
cs-gpios = < 4 GPIO_ACTIVE_HIGH>;
nand-bus-width = <8>;

atmel_nand: kernel panic when ecc_strength==4

2017-09-27 Thread Richard Genoud
Hi Boris, Nicolas !

Since commit f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
strange things happen when nand-ecc-strength = <4>; (previously 
atmel,pmecc-cap).

I first saw that a NULL pointer dereference happened when "udevadm trigger" was 
launched.
With strace, I nailed it down to :

sh-4.3# echo change > /sys/devices/virtual/bdi/mtd-1/uevent 
[   86.696275] Unable to handle kernel NULL pointer dereference at virtual 
address 0001
[   86.704285] pgd = c717c000
[   86.707072] [0001] *pgd=c06d9a70, *pte=, *ppte=
[   86.713979] Internal error: Oops: 17 [#3] ARM
[   86.718306] CPU: 0 PID: 1 Comm: sh Tainted: G  D W   
4.11.0-rc1-00056-gf88fc122cc34-dirty #75
[   86.727443] Hardware name: Atmel AT91SAM9
[   86.731424] task: c7880b60 task.stack: c7884000
[   86.735926] PC is at strlen+0x14/0x2c
[   86.739556] LR is at kobject_get_path+0x34/0xac
[   86.744046] pc : []lr : []psr: 2013
[   86.744046] sp : c7885dc0  ip : c7885dd0  fp : c7885dcc
[   86.755439] r10: 0002  r9 :   r8 : c7885f78
[   86.760627] r7 : 014000c0  r6 : c7ab2308  r5 : 0001  r4 : c7ab2308
[   86.767106] r3 : 0001  r2 : 0001  r1 : 014000c0  r0 : 0001
[   86.773588] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[   86.780672] Control: 0005317f  Table: 2717c000  DAC: 0051
[   86.786372] Process sh (pid: 1, stack limit = 0xc7884190)
[   86.791730] Stack: (0xc7885dc0 to 0xc7886000)
[   86.796075] 5dc0: c7885df4 c7885dd0 c0235020 c023bc04 c0728bf8 c79f1000 
c7ab2308 c78c2b00
[   86.804195] 5de0: c04f4610 c7885f78 c7885e44 c7885df8 c0236244 c0234ffc 
c00a53b4 0074
[   86.812315] 5e00: 00107000 c7885ea8 c7885e64 c05d604b c717b420 c05b4aa8 
081f 0007
[   86.820438] 5e20: c7ab2300 c7199ea0 c79baae0 c7885f78 c7199eb0 0007 
c7885e54 c7885e48
[   86.828559] 5e40: c0236640 c0236188 c7885e74 c7885e58 c02a5834 c023663c 
c7885e9c 0002
[   86.836681] 5e60: c7bf1f50 c79baae0 c7885e84 c7885e78 c02a37b8 c02a5800 
c7885e9c c7885e88
[   86.844801] 5e80: c0128fc8 c02a37a0   c7885ed4 c7885ea0 
c01281e4 c0128f8c
[   86.852922] 5ea0:   c7880b60 c01280b8 00106cf8 c7215c20 
c7885f78 0007
[   86.861045] 5ec0: c7884000 00106cf8 c7885f44 c7885ed8 c00caec0 c01280c8 
081f 00107d00
[   86.869167] 5ee0: c06d0f7c c7885fb0 00053177 1180 0178 c7885fac 
c7885f04 c00091e4
[   86.877288] 5f00: c001128c c000e088 0158 c00cb114 12bc  
bec504d0 b6e8bbec
[   86.885409] 5f20: c7215c20 c7215c20  0007 00106cf8 c7885f78 
c7885f74 c7885f48
[   86.893531] 5f40: c00cb160 c00cae94 c00e6e04 c00e6568   
c7215c20 c7215c20
[   86.901652] 5f60: 0007 00106cf8 c7885fa4 c7885f78 c00cb2dc c00cb0b0 
 
[   86.909773] 5f80: 0007 00106cf8 b6e8dd50 0004 c000a544  
 c7885fa8
[   86.917895] 5fa0: c000a3a0 c00cb2a0 0007 00106cf8 0001 00106cf8 
0007 
[   86.926015] 5fc0: 0007 00106cf8 b6e8dd50 0004 0007 0004 
 000e9124
[   86.934139] 5fe0:  bec50a3c b6db63d0 b6e107ac 6010 0001 
 
[   86.942277] [] (strlen) from [] 
(kobject_get_path+0x34/0xac)
[   86.949620] [] (kobject_get_path) from [] 
(kobject_uevent_env+0xcc/0x4b4)
[   86.958083] [] (kobject_uevent_env) from [] 
(kobject_uevent+0x14/0x18)
[   86.966287] [] (kobject_uevent) from [] 
(uevent_store+0x44/0x64)
[   86.973987] [] (uevent_store) from [] 
(dev_attr_store+0x28/0x34)
[   86.981672] [] (dev_attr_store) from [] 
(sysfs_kf_write+0x4c/0x58)
[   86.989525] [] (sysfs_kf_write) from [] 
(kernfs_fop_write+0x12c/0x1c4)
[   86.997737] [] (kernfs_fop_write) from [] 
(__vfs_write+0x3c/0x11c)
[   87.005596] [] (__vfs_write) from [] 
(vfs_write+0xc0/0x164)
[   87.012855] [] (vfs_write) from [] (SyS_write+0x4c/0x8c)
[   87.019854] [] (SyS_write) from [] 
(ret_fast_syscall+0x0/0x38)
[   87.027364] Code: e92dd800 e24cb004 e1a03000 e1a02003 (e5d21000) 
[   87.033544] ---[ end trace 29af93c3c072b1f4 ]---
[   87.039277] Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x000b

This is fun because it really doesn't seem to have anything to do with 
atmel-nand...

I first found that on my custom board, built around an at91sam9g35-cm, but I 
managed to trigger it
on an at91sam9g35-ek board, with a 4.13.3 kernel.

NB: I couldn't trigger this with ecc-strength = 2

So, here is my configuration:
- at91sam9g35-ek board with the image 
ftp://www.at91.com/pub/demo/linux4sam_5.6/linux4sam-poky-at91sam9x5ek-5.6.zip
I flashed this image a first time as is, and then I flashed only the rfs with 
eccType 0xc0902405.

- Kernel 4.13.3 with the quick'n dirty patch:
--- a/arch/arm/boot/dts/at91sam9x5cm.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi
@@ -56,7 +56,7 @@
cs-gpios = < 4 GPIO_ACTIVE_HIGH>;
nand-bus-width = <8>;