beagleboard C5 and ubifs LEB size in rowboat 2.6.37 kernel

Hi friends,

Beagleboard C5 uses a 512MB NAND/256MB DDR. It is a Micron
MT29C4G48MAZAPAKQ-5. I think Beagle uses it in a x16 configuration.

The suggestions for how to make a ubifs in the porting guide, (
http://processors.wiki.ti.com/index.php/TI-Android-GingerBread-2.3.4-DevKit-2.1_PortingGuides
) appear to work, ie: it boots. But I was still getting random
problems with ubifs crashing sometime after the first bootup. I found
the root cause for that which turns out to be well documented on the
ubifs FAQ. This was because when you use u-boot nand write to flash
the ubinized image, there are ecc issues with the end blocks and one
would have to use the free space fixups flag to solve that. The
rowboat devkit 2.1 2.6.37 kernel tree didn't have the -F fixup patches
so I pulled those from the ubifs 2.6.37 backport. So that set of
problems is solved. While I was doing this, I noticed something odd.

Here's what mtdinfo says about the UBI:

# cat /proc/mtd
dev: size erasesize name
mtd0: 00080000 00020000 "X-Loader"
mtd1: 001e0000 00020000 "U-Boot"
mtd2: 00020000 00020000 "U-Boot Env"
mtd3: 00500000 00020000 "Kernel"
mtd4: 1f880000 00020000 "File System"

root@localhost:/# mtdinfo /dev/mtd/mtd4 -u
mtd4
Name: File System
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 4036 (529006592 bytes, 504.5 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 512 bytes
OOB size: 64 bytes
Character device major/minor: 90:8
Bad blocks are allowed: true
Device is writable: true
Default UBI VID header offset: 512
Default UBI data offset: 2048
Default UBI LEB size: 129024 bytes, 126.0 KiB
Maximum UBI volumes count: 128

That default LEB size above, 129024 is also consistent with
http://cgit.openembedded.org/cgit.cgi/openembedded/tree/conf/machine/beagleboard.conf
, although that's for C3 so maybe its not right for
MT29C4G48MAZAPAKQ-5.

The porting guide suggests:
./mkfs.ubifs/mkfs.ubifs -F -r ~/nand_work/mtd-utils/myrootfs/ -m 2048
-e 126976 -c 3991 -o ubifs512MB.img

LEB 126976 works but doesn't match up with the mtdinfo output. When I
switched my mkfs.ubifs to LEB 129024, and then reflashed with that, I
got a fatal error from UBI.

[ 8.349395] UBIFS error (pid 1): validate_sb: LEB size mismatch:
129024 in superblock, 126976 real
[ 8.358795] UBIFS error (pid 1): validate_sb: bad superblock, error 1

I was wondering if anyone knew why UBI thinks 126976 is the real LEB size.

The reason I ask is because even after the fixups, I sometimes get odd
kernel panics, eg:
[ 158.403350] Backtrace:
[ 158.405944] [<bf0e3c68>] (PVRSRVProcessQueues+0x0/0x30c [pvrsrvkm])
from [<bf0e2b1c>] (PVRSRVMISR+0x28/0x6c [pvrsrvkm])
[ 158.417205] [<bf0e2af4>] (PVRSRVMISR+0x0/0x6c [pvrsrvkm]) from
[<bf0d8660>] (MISRWrapper+0x14/0x18 [pvrsrvkm])
[ 158.427612] r5:ccce5e00 r4:cf01fb40
[ 158.431365] [<bf0d864c>] (MISRWrapper+0x0/0x18 [pvrsrvkm]) from
[<c008b690>] (process_one_work+0x278/0x3f8)
[ 158.441497] [<c008b418>] (process_one_work+0x0/0x3f8) from
[<c008d4a0>] (worker_thread+0x218/0x410)
[ 158.450927] [<c008d288>] (worker_thread+0x0/0x410) from
[<c0090d24>] (kthread+0x8c/0x94)
[ 158.459350] [<c0090c98>] (kthread+0x0/0x94) from [<c007905c>]
(do_exit+0x0/0x638)
[ 158.467132] r7:00000013 r6:c007905c r5:c0090c98 r4:cf031ec0
[ 158.473052] Code: 9a00000c e5932000 e5931004 e5922000 (e592000c)
[ 158.480804] ---[ end trace 7fd6d610f1331552 ]---
[ 158.485626] Kernel panic - not syncing: Fatal exception

and I was wondering if perhaps I've got something incorrect in my
ubifs setup that could be contributing to this.

Thanks,
jayakumar