All of lore.kernel.org
 help / color / mirror / Atom feed
* Micron qspi nor flash and UBIFS
@ 2016-09-01  8:35 Andras Szemzo
  2016-09-01  9:10 ` Richard Weinberger
  0 siblings, 1 reply; 10+ messages in thread
From: Andras Szemzo @ 2016-09-01  8:35 UTC (permalink / raw)
  To: linux-mtd

Hi,

I try to use the atmel QSPI controller with a Micron N25Q512 64MB qspi flash with 4.8.0-rc2 kernel.
The driver seems working, mtd_tests runs without error. 

(The QSPI clock is 75MHz, the read speed is not the best btw.)

~ # modprobe mtd_speedtest dev=0
[  113.310000] mtd_speedtest: not NAND flash, assume page size is 512 bytes.
[  113.320000] mtd_speedtest: MTD device size 4194304, eraseblock size 65536, page size 512, count of eraseblocks 64, pages per eraseblock 128, OOB size 0
[  158.360000] mtd_speedtest: testing eraseblock write speed
[  169.040000] mtd_speedtest: eraseblock write speed is 383 KiB/s
[  169.040000] mtd_speedtest: testing eraseblock read speed
[  169.500000] mtd_speedtest: eraseblock read speed is 9061 KiB/s
[  214.610000] mtd_speedtest: testing page write speed
[  225.420000] mtd_speedtest: page write speed is 378 KiB/s
[  225.430000] mtd_speedtest: testing page read speed
[  225.990000] mtd_speedtest: page read speed is 7380 KiB/s


My problem is I got warning at ubimkvol, and at every reboot.
After boot, read/write works fine without error.

The situation is the same when i try to mount jffs2 formatted partition instead of ubifs. 

 Is there anything what I missed?

Thanks,
Andras


~ # mtdinfo -a
...
mtd2
Name:                           qspi-rootfs
Type:                           nor
Eraseblock size:                65536 bytes, 64.0 KiB
Amount of eraseblocks:          958 (62783488 bytes, 59.9 MiB)
Minimum input/output unit size: 1 byte
Sub-page size:                  1 byte
Character device major/minor:   90:4
Bad blocks are allowed:         false
Device is writable:             true

 
~ # ubiformat /dev/mtd2
ubiformat: mtd2 (nor), size 62783488 bytes (59.9 MiB), 958 eraseblocks of 65536 bytes (64.0 KiB), min. I/O size 1 bytes
libscan: scanning eraseblock 957 -- 100 % complete  
ubiformat: formatting eraseblock 957 -- 100 % complete


~ # ubiattach -m 2 /dev/ubi_ctrl 
ubi0: default fastmap pool size: 45
ubi0: default fastmap WL pool size: 22
ubi0: attaching mtd2
ubi0: scanning is finished
ubi0: attached mtd2 (name "qspi-rootfs", size 59 MiB)
ubi0: PEB size: 65536 bytes (64 KiB), LEB size: 65408 bytes
ubi0: min./max. I/O unit sizes: 1/256, sub-page size 1
ubi0: VID header offset: 64 (aligned 64), data offset: 128
ubi0: good PEBs: 958, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 581993421
ubi0: available PEBs: 952, total reserved PEBs: 6, PEBs reserved for bad PEB handling: 0
ubi0: background thread "ubi_bgt0d" started, PID 96
UBI device number 0, total 958 LEBs (62660864 bytes, 59.8 MiB), available 952 LEBs (62268416 bytes, 59.4 MiB), LEB size 65408 bytes (63.9 KiB)


~ # ubimkvol -N rootfs -m /dev/ubi0 
Set volume size to 62268416
------------[ cut here ]------------
WARNING: CPU: 0 PID: 97 at drivers/mtd/spi-nor/spi-nor.c:1177 0x70126acd
Writing at offset 64 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
Modules linked in:
CPU: 0 PID: 97 Comm: ubimkvol Not tainted 4.8.0-rc2 #46
Hardware name: Atmel SAMx7
Function entered at [<7000c539>] from [<7000b30b>]
Function entered at [<7000b30b>] from [<7000eff5>]
Function entered at [<7000eff5>] from [<7000f03b>]
Function entered at [<7000f03b>] from [<70126acd>]
Function entered at [<70126acd>] from [<701231d3>]
Function entered at [<701231d3>] from [<7012135b>]
Function entered at [<7012135b>] from [<7012ee33>]
Function entered at [<7012ee33>] from [<7012f1b3>]
Function entered at [<7012f1b3>] from [<7012d79f>]
Function entered at [<7012d79f>] from [<70127c73>]
Function entered at [<70127c73>] from [<701280ad>]
Function entered at [<701280ad>] from [<70129123>]
Function entered at [<70129123>] from [<7012b331>]
Function entered at [<7012b331>] from [<7005b733>]
Function entered at [<7005b733>] from [<7005bbed>]
Function entered at [<7005bbed>] from [<7005bc2f>]
Function entered at [<7005bc2f>] from [<70009b01>]
---[ end trace 2135654054bc77cf ]---
Volume ID 0, size 952 LEBs (62268416 bytes, 59.4 MiB), LEB size 65408 bytes (63.9 KiB), dynamic, name "rootfs", alignment 1


~ # mount -t ubifs ubi0:rootfs /mnt
UBIFS (ubi0:0): default file-system created
UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 99
UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS (ubi0:0): LEB size: 65408 bytes (63 KiB), min./max. I/O unit sizes: 8 bytes/256 bytes
UBIFS (ubi0:0): FS size: 61614336 bytes (58 MiB, 942 LEBs), journal size 3074176 bytes (2 MiB, 47 LEBs)
UBIFS (ubi0:0): reserved for root: 2910196 bytes (2841 KiB)
UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID C08619AC-1227-4D3B-884F-7E5677BE00AB, small LPT model


Booting Linux on physical CPU 0x0
...
Kernel command line: console=ttyS1,115200 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs rw init=/linuxrc
...
atmel_qspi 4007c000.qspi: n25q512ax3 (65536 Kbytes)
3 ofpart partitions found on MTD device 4007c000.qspi
Creating 3 MTD partitions on "4007c000.qspi":
0x000000000000-0x000000400000 : "qspi-linux-kernel"
0x000000400000-0x000000420000 : "qspi-device-tree"
0x000000420000-0x000004000000 : "qspi-rootfs"
...
ubi0: default fastmap WL pool size: 22
ubi0: attaching mtd2
ubi0: scanning is finished
ubi0: attached mtd2 (name "qspi-rootfs", size 59 MiB)
ubi0: PEB size: 65536 bytes (64 KiB), LEB size: 65408 bytes
ubi0: min./max. I/O unit sizes: 1/256, sub-page size 1
ubi0: VID header offset: 64 (aligned 64), data offset: 128
ubi0: good PEBs: 958, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 581993421
ubi0: available PEBs: 0, total reserved PEBs: 958, PEBs reserved for bad PEB handling: 0
ubi0: background thread "ubi_bgt0d" started, PID 45
at91_rtc 400e1860.rtc: setting system clock to 2012-01-01 00:04:28 UTC (1325376268)
UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 46
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at drivers/mtd/spi-nor/spi-nor.c:1177 0x70126acd
Writing at offset 128 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.8.0-rc2 #46
Hardware name: Atmel SAMx7
Function entered at [<7000c539>] from [<7000b30b>]
Function entered at [<7000b30b>] from [<7000eff5>]
Function entered at [<7000eff5>] from [<7000f03b>]
Function entered at [<7000f03b>] from [<70126acd>]
Function entered at [<70126acd>] from [<701231d3>]
Function entered at [<701231d3>] from [<7012135b>]
Function entered at [<7012135b>] from [<7012ee33>]
Function entered at [<7012ee33>] from [<7012cd37>]
Function entered at [<7012cd37>] from [<7012c101>]
Function entered at [<7012c101>] from [<7009cacd>]
Function entered at [<7009cacd>] from [<7009db23>]
Function entered at [<7009db23>] from [<700a1675>]
Function entered at [<700a1675>] from [<7009b37b>]
Function entered at [<7009b37b>] from [<700543e9>]
Function entered at [<700543e9>] from [<7006306b>]
Function entered at [<7006306b>] from [<700652b9>]
Function entered at [<700652b9>] from [<7006561b>]
Function entered at [<7006561b>] from [<7025a875>]
Function entered at [<7025a875>] from [<7025aa55>]
Function entered at [<7025aa55>] from [<7025a6d5>]
Function entered at [<7025a6d5>] from [<701c53af>]
Function entered at [<701c53af>] from [<70009bc9>]
---[ end trace 893b280fb022d9bd ]---
UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS (ubi0:0): LEB size: 65408 bytes (63 KiB), min./max. I/O unit sizes: 8 bytes/256 bytes
UBIFS (ubi0:0): FS size: 61614336 bytes (58 MiB, 942 LEBs), journal size 3074176 bytes (2 MiB, 47 LEBs)
UBIFS (ubi0:0): reserved for root: 2910196 bytes (2841 KiB)
UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID C08619AC-1227-4D3B-884F-7E5677BE00AB, small LPT model
VFS: Mounted root (ubifs filesystem) on device 0:12.

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-01  8:35 Micron qspi nor flash and UBIFS Andras Szemzo
@ 2016-09-01  9:10 ` Richard Weinberger
  2016-09-01  9:37   ` Andras Szemzo
  2016-09-01 10:07   ` Andras Szemzo
  0 siblings, 2 replies; 10+ messages in thread
From: Richard Weinberger @ 2016-09-01  9:10 UTC (permalink / raw)
  To: Andras Szemzo; +Cc: linux-mtd

Andras,

On Thu, Sep 1, 2016 at 10:35 AM, Andras Szemzo <szemzo.andras@gmail.com> wrote:
> Hi,
>
> I try to use the atmel QSPI controller with a Micron N25Q512 64MB qspi flash with 4.8.0-rc2 kernel.
> The driver seems working, mtd_tests runs without error.
>
> (The QSPI clock is 75MHz, the read speed is not the best btw.)
>
> ~ # modprobe mtd_speedtest dev=0
> [  113.310000] mtd_speedtest: not NAND flash, assume page size is 512 bytes.
> [  113.320000] mtd_speedtest: MTD device size 4194304, eraseblock size 65536, page size 512, count of eraseblocks 64, pages per eraseblock 128, OOB size 0
> [  158.360000] mtd_speedtest: testing eraseblock write speed
> [  169.040000] mtd_speedtest: eraseblock write speed is 383 KiB/s
> [  169.040000] mtd_speedtest: testing eraseblock read speed
> [  169.500000] mtd_speedtest: eraseblock read speed is 9061 KiB/s
> [  214.610000] mtd_speedtest: testing page write speed
> [  225.420000] mtd_speedtest: page write speed is 378 KiB/s
> [  225.430000] mtd_speedtest: testing page read speed
> [  225.990000] mtd_speedtest: page read speed is 7380 KiB/s
>
>
> My problem is I got warning at ubimkvol, and at every reboot.
> After boot, read/write works fine without error.
>
> The situation is the same when i try to mount jffs2 formatted partition instead of ubifs.
>
>  Is there anything what I missed?

Not sure, need more info first.
Can you add some debug prints to figure where exactly the write happens?

>
> Thanks,
> Andras
>
>
> ~ # mtdinfo -a
> ...
> mtd2
> Name:                           qspi-rootfs
> Type:                           nor
> Eraseblock size:                65536 bytes, 64.0 KiB
> Amount of eraseblocks:          958 (62783488 bytes, 59.9 MiB)
> Minimum input/output unit size: 1 byte
> Sub-page size:                  1 byte
> Character device major/minor:   90:4
> Bad blocks are allowed:         false
> Device is writable:             true
>
>
> ~ # ubiformat /dev/mtd2
> ubiformat: mtd2 (nor), size 62783488 bytes (59.9 MiB), 958 eraseblocks of 65536 bytes (64.0 KiB), min. I/O size 1 bytes
> libscan: scanning eraseblock 957 -- 100 % complete
> ubiformat: formatting eraseblock 957 -- 100 % complete
>
>
> ~ # ubiattach -m 2 /dev/ubi_ctrl
> ubi0: default fastmap pool size: 45
> ubi0: default fastmap WL pool size: 22
> ubi0: attaching mtd2
> ubi0: scanning is finished
> ubi0: attached mtd2 (name "qspi-rootfs", size 59 MiB)
> ubi0: PEB size: 65536 bytes (64 KiB), LEB size: 65408 bytes
> ubi0: min./max. I/O unit sizes: 1/256, sub-page size 1
> ubi0: VID header offset: 64 (aligned 64), data offset: 128
> ubi0: good PEBs: 958, bad PEBs: 0, corrupted PEBs: 0
> ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
> ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 581993421
> ubi0: available PEBs: 952, total reserved PEBs: 6, PEBs reserved for bad PEB handling: 0
> ubi0: background thread "ubi_bgt0d" started, PID 96
> UBI device number 0, total 958 LEBs (62660864 bytes, 59.8 MiB), available 952 LEBs (62268416 bytes, 59.4 MiB), LEB size 65408 bytes (63.9 KiB)
>
>
> ~ # ubimkvol -N rootfs -m /dev/ubi0
> Set volume size to 62268416
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 97 at drivers/mtd/spi-nor/spi-nor.c:1177 0x70126acd
> Writing at offset 64 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
> Modules linked in:
> CPU: 0 PID: 97 Comm: ubimkvol Not tainted 4.8.0-rc2 #46
> Hardware name: Atmel SAMx7
> Function entered at [<7000c539>] from [<7000b30b>]
> Function entered at [<7000b30b>] from [<7000eff5>]
> Function entered at [<7000eff5>] from [<7000f03b>]
> Function entered at [<7000f03b>] from [<70126acd>]
> Function entered at [<70126acd>] from [<701231d3>]
> Function entered at [<701231d3>] from [<7012135b>]
> Function entered at [<7012135b>] from [<7012ee33>]
> Function entered at [<7012ee33>] from [<7012f1b3>]
> Function entered at [<7012f1b3>] from [<7012d79f>]
> Function entered at [<7012d79f>] from [<70127c73>]
> Function entered at [<70127c73>] from [<701280ad>]
> Function entered at [<701280ad>] from [<70129123>]
> Function entered at [<70129123>] from [<7012b331>]
> Function entered at [<7012b331>] from [<7005b733>]
> Function entered at [<7005b733>] from [<7005bbed>]
> Function entered at [<7005bbed>] from [<7005bc2f>]
> Function entered at [<7005bc2f>] from [<70009b01>]

Can you please resolve this addresses or re-try using a kernel with
debug symbols available?
I'd like to see which UBI function triggers this exactly.

-- 
Thanks,
//richard

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-01  9:10 ` Richard Weinberger
@ 2016-09-01  9:37   ` Andras Szemzo
  2016-09-01 10:23     ` Richard Weinberger
  2016-09-01 10:07   ` Andras Szemzo
  1 sibling, 1 reply; 10+ messages in thread
From: Andras Szemzo @ 2016-09-01  9:37 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd

Hi Richard,

>> ------------[ cut here ]------------
>> WARNING: CPU: 0 PID: 97 at drivers/mtd/spi-nor/spi-nor.c:1177 0x70126acd
>> Writing at offset 64 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
>> Modules linked in:
>> CPU: 0 PID: 97 Comm: ubimkvol Not tainted 4.8.0-rc2 #46
>> Hardware name: Atmel SAMx7
>> Function entered at [<7000c539>] from [<7000b30b>]
>> Function entered at [<7000b30b>] from [<7000eff5>]
>> Function entered at [<7000eff5>] from [<7000f03b>]
>> Function entered at [<7000f03b>] from [<70126acd>]
>> Function entered at [<70126acd>] from [<701231d3>]
>> Function entered at [<701231d3>] from [<7012135b>]
>> Function entered at [<7012135b>] from [<7012ee33>]
>> Function entered at [<7012ee33>] from [<7012f1b3>]
>> Function entered at [<7012f1b3>] from [<7012d79f>]
>> Function entered at [<7012d79f>] from [<70127c73>]
>> Function entered at [<70127c73>] from [<701280ad>]
>> Function entered at [<701280ad>] from [<70129123>]
>> Function entered at [<70129123>] from [<7012b331>]
>> Function entered at [<7012b331>] from [<7005b733>]
>> Function entered at [<7005b733>] from [<7005bbed>]
>> Function entered at [<7005bbed>] from [<7005bc2f>]
>> Function entered at [<7005bc2f>] from [<70009b01>]
> 
> Can you please resolve this addresses or re-try using a kernel with
> debug symbols available?
> I'd like to see which UBI function triggers this exactly.

Sure, here is the warning with symbols:


UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 47
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at drivers/mtd/spi-nor/spi-nor.c:1177 spi_nor_write+0x57/0xea
Writing at offset 128 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.8.0-rc2 #49
Hardware name: Atmel SAMx7
[<7000c5d9>] (unwind_backtrace) from [<7000b3ab>] (show_stack+0xb/0xc)
[<7000b3ab>] (show_stack) from [<7000f095>] (__warn+0x89/0xb0)
[<7000f095>] (__warn) from [<7000f0db>] (warn_slowpath_fmt+0x1f/0x28)
[<7000f0db>] (warn_slowpath_fmt) from [<70127e8d>] (spi_nor_write+0x57/0xea)
[<70127e8d>] (spi_nor_write) from [<70124593>] (part_write+0x27/0x2a)
[<70124593>] (part_write) from [<70122717>] (mtd_write+0x53/0x68)
[<70122717>] (mtd_write) from [<701301f3>] (ubi_io_write+0x23f/0x410)
[<701301f3>] (ubi_io_write) from [<7012e0f7>] (ubi_eba_write_leb+0x77/0x5fc)
[<7012e0f7>] (ubi_eba_write_leb) from [<7012d4c1>] (ubi_leb_write+0x71/0x8a)
[<7012d4c1>] (ubi_leb_write) from [<7009dd9d>] (ubifs_leb_write+0x65/0xb4)
[<7009dd9d>] (ubifs_leb_write) from [<7009edf3>] (ubifs_write_node+0xf7/0x124)
[<7009edf3>] (ubifs_write_node) from [<700a2945>] (ubifs_write_master+0x91/0xc8)
[<700a2945>] (ubifs_write_master) from [<7009c64f>] (ubifs_mount+0xebf/0x1020)
[<7009c64f>] (ubifs_mount) from [<700555e9>] (mount_fs+0x9/0x60)
[<700555e9>] (mount_fs) from [<7006427b>] (vfs_kern_mount+0x33/0xc0)
[<7006427b>] (vfs_kern_mount) from [<700664c9>] (do_mount+0x599/0x788)
[<700664c9>] (do_mount) from [<7006682b>] (SyS_mount+0x4f/0x6a)
[<7006682b>] (SyS_mount) from [<702cd8d1>] (mount_block_root+0xa9/0x1e8)
[<702cd8d1>] (mount_block_root) from [<702cdab1>] (prepare_namespace+0x4d/0xf0)
[<702cdab1>] (prepare_namespace) from [<702cd731>] (kernel_init_freeable+0x105/0x14c)
[<702cd731>] (kernel_init_freeable) from [<701c67db>] (kernel_init+0x7/0xa0)
[<701c67db>] (kernel_init) from [<70009c49>] (ret_from_fork+0x11/0x28)
---[ end trace 2e116942d019d348 ]---
UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS (ubi0:0): LEB size: 65408 bytes (63 KiB), min./max. I/O unit sizes: 8 bytes/256 bytes
UBIFS (ubi0:0): FS size: 61614336 bytes (58 MiB, 942 LEBs), journal size 3074176 bytes (2 MiB, 47 LEBs)
UBIFS (ubi0:0): reserved for root: 2910196 bytes (2841 KiB)
UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID C08619AC-1227-4D3B-884F-7E5677BE00AB, small LPT model
VFS: Mounted root (ubifs filesystem) on device 0:12.

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-01  9:10 ` Richard Weinberger
  2016-09-01  9:37   ` Andras Szemzo
@ 2016-09-01 10:07   ` Andras Szemzo
  1 sibling, 0 replies; 10+ messages in thread
From: Andras Szemzo @ 2016-09-01 10:07 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd

Hi,

> Not sure, need more info first.
> Can you add some debug prints to figure where exactly the write happens?
> 

Maybe these debug infos will be helpfull.

ubi0: default fastmap pool size: 45
ubi0: default fastmap WL pool size: 22
ubi0: attaching mtd2
UBI DBG gen (pid 1): sizeof(struct ubi_ainf_peb) 48
UBI DBG gen (pid 1): sizeof(struct ubi_wl_entry) 20
UBI DBG gen (pid 1): min_io_size      1
UBI DBG gen (pid 1): max_write_size   256
UBI DBG gen (pid 1): hdrs_min_io_size 1
UBI DBG gen (pid 1): ec_hdr_alsize    64
UBI DBG gen (pid 1): vid_hdr_alsize   64
UBI DBG gen (pid 1): vid_hdr_offset   64
UBI DBG gen (pid 1): vid_hdr_aloffset 64
UBI DBG gen (pid 1): vid_hdr_shift    0
UBI DBG gen (pid 1): leb_start        128
UBI DBG gen (pid 1): max_erroneous    95
UBI DBG gen (pid 1): process PEB 0
UBI DBG bld (pid 1): scan PEB 0
UBI DBG io (pid 1): read EC header from PEB 0
UBI DBG io (pid 1): read 64 bytes from PEB 0:0
UBI DBG io (pid 1): read VID header from PEB 0
UBI DBG io (pid 1): read 64 bytes from PEB 0:64
UBI DBG bld (pid 1): no VID header found at PEB 0, only 0xFF bytes
UBI DBG bld (pid 1): add to free: PEB 0, EC 1
UBI DBG gen (pid 1): process PEB 1
UBI DBG bld (pid 1): scan PEB 1
UBI DBG io (pid 1): read EC header from PEB 1
UBI DBG io (pid 1): read 64 bytes from PEB 1:0
UBI DBG io (pid 1): read VID header from PEB 1
UBI DBG io (pid 1): read 64 bytes from PEB 1:64
UBI DBG bld (pid 1): no VID header found at PEB 1, only 0xFF bytes
UBI DBG bld (pid 1): add to free: PEB 1, EC 1
...
UBI DBG gen (pid 1): process PEB 957
UBI DBG bld (pid 1): scan PEB 957
UBI DBG io (pid 1): read EC header from PEB 957
UBI DBG io (pid 1): read 64 bytes from PEB 957:0
UBI DBG io (pid 1): read VID header from PEB 957
UBI DBG io (pid 1): read 64 bytes from PEB 957:64
UBI DBG bld (pid 1): no VID header found at PEB 957, only 0xFF bytes
UBI DBG bld (pid 1): add to free: PEB 957, EC 0
ubi0: scanning is finished
UBI DBG gen (pid 1): max. sequence number:       108
UBI DBG gen (pid 1): check layout volume
UBI DBG io (pid 1): read 22016 bytes from PEB 257:128
UBI DBG io (pid 1): read 22016 bytes from PEB 258:128
UBI DBG wl (pid 1): add PEB 257 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 258 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 303 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 304 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 305 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 287 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 302 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 306 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 307 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 288 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 341 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 342 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 346 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 344 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 259 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 347 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 350 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 349 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 348 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 351 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 354 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 353 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 352 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 355 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 358 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 357 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 356 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 359 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 362 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 361 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 360 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 363 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 366 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 365 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 364 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 367 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 370 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 369 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 368 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 371 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 374 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 373 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 372 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 260 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 282 EC 0 to the used tree
UBI DBG wl (pid 1): add PEB 266 EC 0 to the used tree
UBI DBG wl (pid 1): found 958 PEBs
UBI DBG eba (pid 1): initialize EBA sub-system
UBI DBG eba (pid 1): EBA sub-system is initialized
UBI DBG gen (pid 1): ubi0 major is 251
UBI DBG gen (pid 1): add volume 0
ubi0: attached mtd2 (name "qspi-rootfs", size 59 MiB)
ubi0: PEB size: 65536 bytes (64 KiB), LEB size: 65408 bytes
ubi0: min./max. I/O unit sizes: 1/256, sub-page size 1
ubi0: VID header offset: 64 (aligned 64), data offset: 128
ubi0: good PEBs: 958, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 581993421
ubi0: available PEBs: 0, total reserved PEBs: 958, PEBs reserved for bad PEB handling: 0
ubi0: background thread "ubi_bgt0d" started, PID 46
at91_rtc 400e1860.rtc: setting system clock to 2012-01-01 00:00:05 UTC (1325376005)
UBI DBG gen (pid 1): open volume ubi0:rootfs, mode 1
UBI DBG gen (pid 1): open device 0, volume rootfs, mode 1
UBI DBG gen (pid 1): open device 0, volume 0, mode 1
UBI DBG gen (pid 1): open device 0, volume 0, mode 2
UBI DBG gen (pid 1): test LEB 0:0
UBI DBG gen (pid 1): read 4096 bytes from LEB 0:0:0
UBI DBG eba (pid 1): read 4096 bytes from offset 0 of LEB 0:0, PEB 303
UBI DBG io (pid 1): read 4096 bytes from PEB 303:128
UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 47
UBI DBG gen (pid 1): read 65408 bytes from LEB 0:1:0
UBI DBG eba (pid 1): read 65408 bytes from offset 0 of LEB 0:1, PEB 304
UBI DBG io (pid 1): read 65408 bytes from PEB 304:128
UBI DBG gen (pid 1): read 65408 bytes from LEB 0:2:0
UBI DBG eba (pid 1): read 65408 bytes from offset 0 of LEB 0:2, PEB 305
UBI DBG io (pid 1): read 65408 bytes from PEB 305:128
UBI DBG gen (pid 1): read 68 bytes from LEB 0:13:192
UBI DBG eba (pid 1): read 68 bytes from offset 192 of LEB 0:13, PEB 288
UBI DBG io (pid 1): read 68 bytes from PEB 288:320
UBI DBG gen (pid 1): read 11 bytes from LEB 0:6:9032
UBI DBG eba (pid 1): read 11 bytes from offset 9032 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 11 bytes from PEB 302:9160
UBI DBG gen (pid 1): unmap LEB 0:7
UBI DBG gen (pid 1): write 512 bytes to LEB 0:1:23040
UBI DBG eba (pid 1): write 512 bytes at offset 23040 of LEB 0:1, PEB 304
UBI DBG io (pid 1): write 512 bytes to PEB 304:23168
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at drivers/mtd/spi-nor/spi-nor.c:1177 spi_nor_write+0x57/0xea
Writing at offset 128 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.8.0-rc2 #53
Hardware name: Atmel SAMx7
[<7000c5d9>] (unwind_backtrace) from [<7000b3ab>] (show_stack+0xb/0xc)
[<7000b3ab>] (show_stack) from [<7000f095>] (__warn+0x89/0xb0)
[<7000f095>] (__warn) from [<7000f0db>] (warn_slowpath_fmt+0x1f/0x28)
[<7000f0db>] (warn_slowpath_fmt) from [<70127e8d>] (spi_nor_write+0x57/0xea)
[<70127e8d>] (spi_nor_write) from [<70124593>] (part_write+0x27/0x2a)
[<70124593>] (part_write) from [<70122717>] (mtd_write+0x53/0x68)
[<70122717>] (mtd_write) from [<70130d6b>] (ubi_io_write+0x263/0x448)
[<70130d6b>] (ubi_io_write) from [<7012e9b5>] (ubi_eba_write_leb+0x99/0x638)
[<7012e9b5>] (ubi_eba_write_leb) from [<7012dbeb>] (ubi_leb_write+0x9b/0xbc)
[<7012dbeb>] (ubi_leb_write) from [<7009dd9d>] (ubifs_leb_write+0x65/0xb4)
[<7009dd9d>] (ubifs_leb_write) from [<7009edf3>] (ubifs_write_node+0xf7/0x124)
[<7009edf3>] (ubifs_write_node) from [<700a2945>] (ubifs_write_master+0x91/0xc8)
[<700a2945>] (ubifs_write_master) from [<7009c64f>] (ubifs_mount+0xebf/0x1020)
[<7009c64f>] (ubifs_mount) from [<700555e9>] (mount_fs+0x9/0x60)
[<700555e9>] (mount_fs) from [<7006427b>] (vfs_kern_mount+0x33/0xc0)
[<7006427b>] (vfs_kern_mount) from [<700664c9>] (do_mount+0x599/0x788)
[<700664c9>] (do_mount) from [<7006682b>] (SyS_mount+0x4f/0x6a)
[<7006682b>] (SyS_mount) from [<702d08d1>] (mount_block_root+0xa9/0x1e8)
[<702d08d1>] (mount_block_root) from [<702d0ab1>] (prepare_namespace+0x4d/0xf0)
[<702d0ab1>] (prepare_namespace) from [<702d0731>] (kernel_init_freeable+0x105/0x14c)
[<702d0731>] (kernel_init_freeable) from [<701c7c6b>] (kernel_init+0x7/0xa0)
[<701c7c6b>] (kernel_init) from [<70009c49>] (ret_from_fork+0x11/0x28)
---[ end trace 03245f884d3f082f ]---
UBI DBG gen (pid 1): write 512 bytes to LEB 0:2:23040
UBI DBG eba (pid 1): write 512 bytes at offset 23040 of LEB 0:2, PEB 305
UBI DBG io (pid 1): write 512 bytes to PEB 305:23168
UBI DBG gen (pid 1): read 12 bytes from LEB 0:6:9163
UBI DBG eba (pid 1): read 12 bytes from offset 9163 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 12 bytes from PEB 302:9291
UBI DBG gen (pid 1): read 12 bytes from LEB 0:6:9151
UBI DBG eba (pid 1): read 12 bytes from offset 9151 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 12 bytes from PEB 302:9279
UBI DBG gen (pid 1): read 12 bytes from LEB 0:6:9099
UBI DBG eba (pid 1): read 12 bytes from offset 9099 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 12 bytes from PEB 302:9227
UBI DBG gen (pid 1): read 12 bytes from LEB 0:6:9059
UBI DBG eba (pid 1): read 12 bytes from offset 9059 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 12 bytes from PEB 302:9187
UBI DBG gen (pid 1): read 16 bytes from LEB 0:6:9043
UBI DBG eba (pid 1): read 16 bytes from offset 9043 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 16 bytes from PEB 302:9171
UBI DBG gen (pid 1): read 65408 bytes from LEB 0:4:0
UBI DBG eba (pid 1): read 65408 bytes from offset 0 of LEB 0:4, PEB 287
UBI DBG io (pid 1): read 65408 bytes from PEB 287:128
UBI DBG gen (pid 1): read 65408 bytes from LEB 0:5:0
UBI DBG eba (pid 1): read 65408 bytes from offset 0 of LEB 0:5 (unmapped)
UBI DBG gen (pid 1): read 34024 bytes from LEB 0:49:31384
UBI DBG eba (pid 1): read 34024 bytes from offset 31384 of LEB 0:49, PEB 259
UBI DBG io (pid 1): read 34024 bytes from PEB 259:31512
UBI DBG gen (pid 1): read 61064 bytes from LEB 0:79:4344
UBI DBG eba (pid 1): read 61064 bytes from offset 4344 of LEB 0:79, PEB 282
UBI DBG io (pid 1): read 61064 bytes from PEB 282:4472
UBI DBG gen (pid 1): read 12 bytes from LEB 0:6:9087
UBI DBG eba (pid 1): read 12 bytes from offset 9087 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 12 bytes from PEB 302:9215
UBI DBG gen (pid 1): read 16 bytes from LEB 0:6:9071
UBI DBG eba (pid 1): read 16 bytes from offset 9071 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 16 bytes from PEB 302:9199
UBI DBG gen (pid 1): read 12 bytes from LEB 0:6:9139
UBI DBG eba (pid 1): read 12 bytes from offset 9139 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 12 bytes from PEB 302:9267
UBI DBG gen (pid 1): read 12 bytes from LEB 0:6:9127
UBI DBG eba (pid 1): read 12 bytes from offset 9127 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 12 bytes from PEB 302:9255
UBI DBG gen (pid 1): read 16 bytes from LEB 0:6:9111
UBI DBG eba (pid 1): read 16 bytes from offset 9111 of LEB 0:6, PEB 302
UBI DBG io (pid 1): read 16 bytes from PEB 302:9239
UBI DBG gen (pid 1): unmap LEB 0:8
UBI DBG gen (pid 1): unmap LEB 0:9
UBI DBG gen (pid 1): unmap LEB 0:81
UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS (ubi0:0): LEB size: 65408 bytes (63 KiB), min./max. I/O unit sizes: 8 bytes/256 bytes
UBIFS (ubi0:0): FS size: 61614336 bytes (58 MiB, 942 LEBs), journal size 3074176 bytes (2 MiB, 47 LEBs)
UBIFS (ubi0:0): reserved for root: 2910196 bytes (2841 KiB)
UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID C08619AC-1227-4D3B-884F-7E5677BE00AB, small LPT model

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-01  9:37   ` Andras Szemzo
@ 2016-09-01 10:23     ` Richard Weinberger
  2016-09-02  6:31       ` Andras Szemzo
                         ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Richard Weinberger @ 2016-09-01 10:23 UTC (permalink / raw)
  To: Andras Szemzo; +Cc: linux-mtd, hramrach, computersforpeace, cyrille.pitchen

Andras,

On 01.09.2016 11:37, Andras Szemzo wrote:
> UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 47
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 1 at drivers/mtd/spi-nor/spi-nor.c:1177 spi_nor_write+0x57/0xea
> Writing at offset 128 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper Not tainted 4.8.0-rc2 #49
> Hardware name: Atmel SAMx7
> [<7000c5d9>] (unwind_backtrace) from [<7000b3ab>] (show_stack+0xb/0xc)
> [<7000b3ab>] (show_stack) from [<7000f095>] (__warn+0x89/0xb0)
> [<7000f095>] (__warn) from [<7000f0db>] (warn_slowpath_fmt+0x1f/0x28)
> [<7000f0db>] (warn_slowpath_fmt) from [<70127e8d>] (spi_nor_write+0x57/0xea)
> [<70127e8d>] (spi_nor_write) from [<70124593>] (part_write+0x27/0x2a)
> [<70124593>] (part_write) from [<70122717>] (mtd_write+0x53/0x68)
> [<70122717>] (mtd_write) from [<701301f3>] (ubi_io_write+0x23f/0x410)
> [<701301f3>] (ubi_io_write) from [<7012e0f7>] (ubi_eba_write_leb+0x77/0x5fc)
> [<7012e0f7>] (ubi_eba_write_leb) from [<7012d4c1>] (ubi_leb_write+0x71/0x8a)
> [<7012d4c1>] (ubi_leb_write) from [<7009dd9d>] (ubifs_leb_write+0x65/0xb4)
> [<7009dd9d>] (ubifs_leb_write) from [<7009edf3>] (ubifs_write_node+0xf7/0x124)
> [<7009edf3>] (ubifs_write_node) from [<700a2945>] (ubifs_write_master+0x91/0xc8)
> [<700a2945>] (ubifs_write_master) from [<7009c64f>] (ubifs_mount+0xebf/0x1020)
> [<7009c64f>] (ubifs_mount) from [<700555e9>] (mount_fs+0x9/0x60)
> [<700555e9>] (mount_fs) from [<7006427b>] (vfs_kern_mount+0x33/0xc0)
> [<7006427b>] (vfs_kern_mount) from [<700664c9>] (do_mount+0x599/0x788)
> [<700664c9>] (do_mount) from [<7006682b>] (SyS_mount+0x4f/0x6a)
> [<7006682b>] (SyS_mount) from [<702cd8d1>] (mount_block_root+0xa9/0x1e8)
> [<702cd8d1>] (mount_block_root) from [<702cdab1>] (prepare_namespace+0x4d/0xf0)
> [<702cdab1>] (prepare_namespace) from [<702cd731>] (kernel_init_freeable+0x105/0x14c)
> [<702cd731>] (kernel_init_freeable) from [<701c67db>] (kernel_init+0x7/0xa0)
> [<701c67db>] (kernel_init) from [<70009c49>] (ret_from_fork+0x11/0x28)

This proves my assumption.
spi-nor.c warns as soon you write with an offset to a page.
So, it will warn for *every* non-trivial user.

The warning is also rather new, CC'ing patch authors.

commit e5d05cbd6d8b01f08c95c427a36c66aac769af4f
Author: Michal Suchanek <hramrach@gmail.com>
Date:   Thu May 5 17:31:54 2016 -0700

    mtd: spi-nor: simplify write loop

    The spi-nor write loop assumes that what is passed to the hardware
    driver write() is what gets written.

    When write() writes less than page size at once data is dropped on the
    floor. Check the amount of data writen and exit if it does not match
    requested amount.

    Signed-off-by: Michal Suchanek <hramrach@gmail.com>
    Signed-off-by: Brian Norris <computersforpeace@gmail.com>
    Tested-by Cyrille Pitchen <cyrille.pitchen@atmel.com>
    Acked-by: Michal Suchanek <hramrach@gmail.com>
    Tested-by: Michal Suchanek <hramrach@gmail.com>


Guys, this patch is odd in multiple ways.
1. Patch description does not match the code. It does *not* just simplify the write loop.
   It also introduces a new scary WARN_ON_ONCE(). Unless I miss something it will trigger
   for every write with an offset. So, you rule out any filesystem on top of SPI-NOR.
   What's the deal?
2. The SOB chain is strange. Michal, you authored this patch, right?
   Why did you add an Acked-by and Tested-by tag too?

Thanks,
//richard

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-01 10:23     ` Richard Weinberger
@ 2016-09-02  6:31       ` Andras Szemzo
  2016-09-20 15:23       ` Richard Weinberger
  2016-09-21  9:51       ` Cyrille Pitchen
  2 siblings, 0 replies; 10+ messages in thread
From: Andras Szemzo @ 2016-09-02  6:31 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd

Hi Richard,

> This proves my assumption.
> spi-nor.c warns as soon you write with an offset to a page.
> So, it will warn for *every* non-trivial user.

Thanks for your very quick help!

Andras

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-01 10:23     ` Richard Weinberger
  2016-09-02  6:31       ` Andras Szemzo
@ 2016-09-20 15:23       ` Richard Weinberger
  2016-09-21  9:51       ` Cyrille Pitchen
  2 siblings, 0 replies; 10+ messages in thread
From: Richard Weinberger @ 2016-09-20 15:23 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Andras Szemzo, Brian Norris, cyrille.pitchen, Michal Suchanek, linux-mtd

Ping?

On Thu, Sep 1, 2016 at 12:23 PM, Richard Weinberger <richard@nod.at> wrote:
> Andras,
>
> On 01.09.2016 11:37, Andras Szemzo wrote:
>> UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 47
>> ------------[ cut here ]------------
>> WARNING: CPU: 0 PID: 1 at drivers/mtd/spi-nor/spi-nor.c:1177 spi_nor_write+0x57/0xea
>> Writing at offset 128 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
>> Modules linked in:
>> CPU: 0 PID: 1 Comm: swapper Not tainted 4.8.0-rc2 #49
>> Hardware name: Atmel SAMx7
>> [<7000c5d9>] (unwind_backtrace) from [<7000b3ab>] (show_stack+0xb/0xc)
>> [<7000b3ab>] (show_stack) from [<7000f095>] (__warn+0x89/0xb0)
>> [<7000f095>] (__warn) from [<7000f0db>] (warn_slowpath_fmt+0x1f/0x28)
>> [<7000f0db>] (warn_slowpath_fmt) from [<70127e8d>] (spi_nor_write+0x57/0xea)
>> [<70127e8d>] (spi_nor_write) from [<70124593>] (part_write+0x27/0x2a)
>> [<70124593>] (part_write) from [<70122717>] (mtd_write+0x53/0x68)
>> [<70122717>] (mtd_write) from [<701301f3>] (ubi_io_write+0x23f/0x410)
>> [<701301f3>] (ubi_io_write) from [<7012e0f7>] (ubi_eba_write_leb+0x77/0x5fc)
>> [<7012e0f7>] (ubi_eba_write_leb) from [<7012d4c1>] (ubi_leb_write+0x71/0x8a)
>> [<7012d4c1>] (ubi_leb_write) from [<7009dd9d>] (ubifs_leb_write+0x65/0xb4)
>> [<7009dd9d>] (ubifs_leb_write) from [<7009edf3>] (ubifs_write_node+0xf7/0x124)
>> [<7009edf3>] (ubifs_write_node) from [<700a2945>] (ubifs_write_master+0x91/0xc8)
>> [<700a2945>] (ubifs_write_master) from [<7009c64f>] (ubifs_mount+0xebf/0x1020)
>> [<7009c64f>] (ubifs_mount) from [<700555e9>] (mount_fs+0x9/0x60)
>> [<700555e9>] (mount_fs) from [<7006427b>] (vfs_kern_mount+0x33/0xc0)
>> [<7006427b>] (vfs_kern_mount) from [<700664c9>] (do_mount+0x599/0x788)
>> [<700664c9>] (do_mount) from [<7006682b>] (SyS_mount+0x4f/0x6a)
>> [<7006682b>] (SyS_mount) from [<702cd8d1>] (mount_block_root+0xa9/0x1e8)
>> [<702cd8d1>] (mount_block_root) from [<702cdab1>] (prepare_namespace+0x4d/0xf0)
>> [<702cdab1>] (prepare_namespace) from [<702cd731>] (kernel_init_freeable+0x105/0x14c)
>> [<702cd731>] (kernel_init_freeable) from [<701c67db>] (kernel_init+0x7/0xa0)
>> [<701c67db>] (kernel_init) from [<70009c49>] (ret_from_fork+0x11/0x28)
>
> This proves my assumption.
> spi-nor.c warns as soon you write with an offset to a page.
> So, it will warn for *every* non-trivial user.
>
> The warning is also rather new, CC'ing patch authors.
>
> commit e5d05cbd6d8b01f08c95c427a36c66aac769af4f
> Author: Michal Suchanek <hramrach@gmail.com>
> Date:   Thu May 5 17:31:54 2016 -0700
>
>     mtd: spi-nor: simplify write loop
>
>     The spi-nor write loop assumes that what is passed to the hardware
>     driver write() is what gets written.
>
>     When write() writes less than page size at once data is dropped on the
>     floor. Check the amount of data writen and exit if it does not match
>     requested amount.
>
>     Signed-off-by: Michal Suchanek <hramrach@gmail.com>
>     Signed-off-by: Brian Norris <computersforpeace@gmail.com>
>     Tested-by Cyrille Pitchen <cyrille.pitchen@atmel.com>
>     Acked-by: Michal Suchanek <hramrach@gmail.com>
>     Tested-by: Michal Suchanek <hramrach@gmail.com>
>
>
> Guys, this patch is odd in multiple ways.
> 1. Patch description does not match the code. It does *not* just simplify the write loop.
>    It also introduces a new scary WARN_ON_ONCE(). Unless I miss something it will trigger
>    for every write with an offset. So, you rule out any filesystem on top of SPI-NOR.
>    What's the deal?
> 2. The SOB chain is strange. Michal, you authored this patch, right?
>    Why did you add an Acked-by and Tested-by tag too?
>
> Thanks,
> //richard
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/



-- 
Thanks,
//richard

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-01 10:23     ` Richard Weinberger
  2016-09-02  6:31       ` Andras Szemzo
  2016-09-20 15:23       ` Richard Weinberger
@ 2016-09-21  9:51       ` Cyrille Pitchen
  2016-09-21 10:24         ` Richard Weinberger
  2016-09-21 10:29         ` Andras Szemzo
  2 siblings, 2 replies; 10+ messages in thread
From: Cyrille Pitchen @ 2016-09-21  9:51 UTC (permalink / raw)
  To: Richard Weinberger, Andras Szemzo; +Cc: linux-mtd, hramrach, computersforpeace

Hi all,

Le 01/09/2016 à 12:23, Richard Weinberger a écrit :
> Andras,
> 
> On 01.09.2016 11:37, Andras Szemzo wrote:
>> UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 47
>> ------------[ cut here ]------------
>> WARNING: CPU: 0 PID: 1 at drivers/mtd/spi-nor/spi-nor.c:1177 spi_nor_write+0x57/0xea
>> Writing at offset 128 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
>> Modules linked in:
>> CPU: 0 PID: 1 Comm: swapper Not tainted 4.8.0-rc2 #49
>> Hardware name: Atmel SAMx7
>> [<7000c5d9>] (unwind_backtrace) from [<7000b3ab>] (show_stack+0xb/0xc)
>> [<7000b3ab>] (show_stack) from [<7000f095>] (__warn+0x89/0xb0)
>> [<7000f095>] (__warn) from [<7000f0db>] (warn_slowpath_fmt+0x1f/0x28)
>> [<7000f0db>] (warn_slowpath_fmt) from [<70127e8d>] (spi_nor_write+0x57/0xea)
>> [<70127e8d>] (spi_nor_write) from [<70124593>] (part_write+0x27/0x2a)
>> [<70124593>] (part_write) from [<70122717>] (mtd_write+0x53/0x68)
>> [<70122717>] (mtd_write) from [<701301f3>] (ubi_io_write+0x23f/0x410)
>> [<701301f3>] (ubi_io_write) from [<7012e0f7>] (ubi_eba_write_leb+0x77/0x5fc)
>> [<7012e0f7>] (ubi_eba_write_leb) from [<7012d4c1>] (ubi_leb_write+0x71/0x8a)
>> [<7012d4c1>] (ubi_leb_write) from [<7009dd9d>] (ubifs_leb_write+0x65/0xb4)
>> [<7009dd9d>] (ubifs_leb_write) from [<7009edf3>] (ubifs_write_node+0xf7/0x124)
>> [<7009edf3>] (ubifs_write_node) from [<700a2945>] (ubifs_write_master+0x91/0xc8)
>> [<700a2945>] (ubifs_write_master) from [<7009c64f>] (ubifs_mount+0xebf/0x1020)
>> [<7009c64f>] (ubifs_mount) from [<700555e9>] (mount_fs+0x9/0x60)
>> [<700555e9>] (mount_fs) from [<7006427b>] (vfs_kern_mount+0x33/0xc0)
>> [<7006427b>] (vfs_kern_mount) from [<700664c9>] (do_mount+0x599/0x788)
>> [<700664c9>] (do_mount) from [<7006682b>] (SyS_mount+0x4f/0x6a)
>> [<7006682b>] (SyS_mount) from [<702cd8d1>] (mount_block_root+0xa9/0x1e8)
>> [<702cd8d1>] (mount_block_root) from [<702cdab1>] (prepare_namespace+0x4d/0xf0)
>> [<702cdab1>] (prepare_namespace) from [<702cd731>] (kernel_init_freeable+0x105/0x14c)
>> [<702cd731>] (kernel_init_freeable) from [<701c67db>] (kernel_init+0x7/0xa0)
>> [<701c67db>] (kernel_init) from [<70009c49>] (ret_from_fork+0x11/0x28)
> 
> This proves my assumption.
> spi-nor.c warns as soon you write with an offset to a page.
> So, it will warn for *every* non-trivial user.
> 
> The warning is also rather new, CC'ing patch authors.
> 
> commit e5d05cbd6d8b01f08c95c427a36c66aac769af4f
> Author: Michal Suchanek <hramrach@gmail.com>
> Date:   Thu May 5 17:31:54 2016 -0700
> 
>     mtd: spi-nor: simplify write loop
> 
>     The spi-nor write loop assumes that what is passed to the hardware
>     driver write() is what gets written.
> 
>     When write() writes less than page size at once data is dropped on the
>     floor. Check the amount of data writen and exit if it does not match
>     requested amount.
> 
>     Signed-off-by: Michal Suchanek <hramrach@gmail.com>
>     Signed-off-by: Brian Norris <computersforpeace@gmail.com>
>     Tested-by Cyrille Pitchen <cyrille.pitchen@atmel.com>
>     Acked-by: Michal Suchanek <hramrach@gmail.com>
>     Tested-by: Michal Suchanek <hramrach@gmail.com>
> 
> 
> Guys, this patch is odd in multiple ways.
> 1. Patch description does not match the code. It does *not* just simplify the write loop.
>    It also introduces a new scary WARN_ON_ONCE(). Unless I miss something it will trigger
>    for every write with an offset. So, you rule out any filesystem on top of SPI-NOR.
>    What's the deal?

I've just looked closely to this specific patch in the Michal's series: except
for WARN_ONCE(), the new code seems alright. The new loop is more readable than
it was before and now it also checks the actual amount of written data returned
by the .write() hook to avoid crossing the page boundary during the next
.write() call.

With the old spi_nor_write() implementation:

Inputs:
nor->page_size = 256
to = 0;
len = 0x10000;
ret = nor->page_size;

The old loop:
for (i = ret; i < len; ) {
	page_size = len - 1;
	if (page_size > nor->page_size)
		page_size = nor->page_size;

	[...]
	ret = nor->write(nor, to + i, page_size, buf + i);
	if (ret < 0)
		goto write_err;
	i += ret;
}

If one call of .write() wrote less than nor->page_size, the next call of
.write() tried to write a *full* page at a page unaligned offset, hence
crossing the page boundary. It might be an issue with some memories.
Indeed, crossing the *sector* boundary during a Page Program operation is an
issue with some Micron memories which stack 2 memories in a single package.

So I think we should keep Michal's patch but only remove the WARN_ONCE() as
it seems to be the only regression reported.

Richard, Andras, would it be ok for you?


> 2. The SOB chain is strange. Michal, you authored this patch, right?
>    Why did you add an Acked-by and Tested-by tag too?
> 
> Thanks,
> //richard
> 

Best regards,

Cyrille

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-21  9:51       ` Cyrille Pitchen
@ 2016-09-21 10:24         ` Richard Weinberger
  2016-09-21 10:29         ` Andras Szemzo
  1 sibling, 0 replies; 10+ messages in thread
From: Richard Weinberger @ 2016-09-21 10:24 UTC (permalink / raw)
  To: Cyrille Pitchen, Andras Szemzo; +Cc: linux-mtd, hramrach, computersforpeace

Cyrille,

On 21.09.2016 11:51, Cyrille Pitchen wrote:
> So I think we should keep Michal's patch but only remove the WARN_ONCE() as
> it seems to be the only regression reported.
> 
> Richard, Andras, would it be ok for you?

Perfectly fine by me. :-)
Thanks for looking.

Thanks,
//richard

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

* Re: Micron qspi nor flash and UBIFS
  2016-09-21  9:51       ` Cyrille Pitchen
  2016-09-21 10:24         ` Richard Weinberger
@ 2016-09-21 10:29         ` Andras Szemzo
  1 sibling, 0 replies; 10+ messages in thread
From: Andras Szemzo @ 2016-09-21 10:29 UTC (permalink / raw)
  To: Cyrille Pitchen
  Cc: Richard Weinberger, linux-mtd, hramrach, computersforpeace

Hi,

> Richard, Andras, would it be ok for you?

I’m using it with the WARN_ONCE() removed, without issues since a few days,
so ok.

Regards,
Andras 

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

end of thread, other threads:[~2016-09-21 10:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-01  8:35 Micron qspi nor flash and UBIFS Andras Szemzo
2016-09-01  9:10 ` Richard Weinberger
2016-09-01  9:37   ` Andras Szemzo
2016-09-01 10:23     ` Richard Weinberger
2016-09-02  6:31       ` Andras Szemzo
2016-09-20 15:23       ` Richard Weinberger
2016-09-21  9:51       ` Cyrille Pitchen
2016-09-21 10:24         ` Richard Weinberger
2016-09-21 10:29         ` Andras Szemzo
2016-09-01 10:07   ` Andras Szemzo

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.