Commit Graph

17 Commits

Author SHA1 Message Date
Adrian Hunter 48ec00ac89 [MTD] mtdoops: fix a bit of spin lock usage
- do not leave spin lock locked
- initialise spin lock

Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2009-03-20 18:39:25 +00:00
Adrian Hunter e2a0f25b4f [MTD] mtdoops: allow MTD selection by name
MTD's have both an index number and a name.  Formerly,
the MTD selected for mtdoops was done only by index
number.  With this patch, a name can be used instead.

For example, the kernel command line:

	console=ttyMTD5

selects MTD 5 for mtdoops.  But now this is also possible:

	console=ttyMTD,log

which selects the MTD named "log" for mtdoops.

This has the advantage that partitions can be added or
removed that would affect the MTD index number but not the
name, without having to then change the kernel command line.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Acked-by: Richard Purdie <rpurdie@linux.intel.com>
Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2009-03-20 18:38:58 +00:00
Adrian Hunter 69423d99fc [MTD] update internal API to support 64-bit device size
MTD internal API presently uses 32-bit values to represent
device size.  This patch updates them to 64-bits but leaves
the external API unchanged.  Extending the external API
is a separate issue for several reasons.  First, no one
needs it at the moment.  Secondly, whether the implementation
is done with IOCTLs, sysfs or both is still debated.  Thirdly
external API changes require the internal API to be accepted
first.

Note that although the MTD API will be able to support 64-bit
device sizes, existing drivers do not and are not required
to do so, although NAND base has been updated.

In general, changing from 32-bit to 64-bit values cause little
or no changes to the majority of the code with the following
exceptions:
    	- printk message formats
    	- division and modulus of 64-bit values
    	- NAND base support
	- 32-bit local variables used by mtdpart and mtdconcat
	- naughtily assuming one structure maps to another
	in MEMERASE ioctl

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2008-12-10 13:37:21 +00:00
Richard Purdie 43b5693d40 [MTD] mtdoops: Fix a bug where block may not be erased
This makes the driver erase a block when it doesn't find any
existing saved log messages which is safer than assuming the
flash was already erased.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2008-10-18 11:51:48 +01:00
Richard Purdie f0482ee366 [MTD] mtdoops: Add a magic number to logged kernel oops
Add a magic number to logged kernel oops messages so that they
can be more accurately detected rather than just having to rely
on the sequence number. This also allows easier detection of
saved crashes by userspace.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2008-10-18 11:51:27 +01:00
Richard Purdie ecd5b31023 [MTD] mtdoops: Fix an off by one error
Fix an off by one error in the mtdoops driver

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2008-10-18 11:51:13 +01:00
Adrian Bunk 7903cbabcb [MTD] mtdoops.c: make struct oops_cxt static again
struct oops_cxt needlessly became global.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-04-22 12:35:34 +01:00
David Woodhouse f9f7dd2223 [MTD] Fix mtdoops.c compilation
drivers/mtd/mtdoops.c: In function ‘mtdoops_console_sync’:
drivers/mtd/mtdoops.c:329: error: implicit declaration of function ‘in_interrupt’

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-02-07 10:50:57 +00:00
Richard Purdie 621e4f8e9b [MTD] mtdoops: Use the panic_write function when present
When the MTD provides a panic_write function, use it.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-02-07 10:31:04 +00:00
Richard Purdie 79dcd8e9e1 [MTD] mtdoops: Various minor cleanups
Various minor cleaups to mtdoops:
  * Don't support the mtd->erasesize < OOPS_PAGE_SIZE case
  * Tweak printks and make the device mtdoops connects to more visible
  * CON_PRINTBUFFER flag is uneeded

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-02-03 18:19:24 +11:00
Richard Purdie 47c152b88c [MTD] mtdoops: Ensure sequential write to the buffer
Add a spinlock to ensure writes to the mtdoops buffer memory are
sequential and don't race.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-02-03 18:18:58 +11:00
Richard Purdie 6ce0a856c1 [MTD] mtdoops: Perform write operations in a workqueue
Writing to the flash needs to be done in a workqueue. The console
write functions may be called in any context which can lead to
lockups otherwise.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-02-03 18:14:41 +11:00
Richard Purdie 2986bd2a33 [MTD] mtdoops: Add further error return code checking
Add further error return code checks to the mtdoops driver.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-02-03 18:14:35 +11:00
Peter Korsgaard 235d6200ea [MTD] mtdoops cleanup
Use memcpy instead of open coding a copy loop.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-12-03 14:00:16 +00:00
Andrew Morton 68d09b1b67 [MTD] mtdoops printk warning fixes
drivers/mtd/mtdoops.c: In function 'mtdoops_inc_counter':
drivers/mtd/mtdoops.c:109: warning: format '%d' expects type 'int', but argument 3 has type 'size_t'
drivers/mtd/mtdoops.c: In function 'mtdoops_console_sync':
drivers/mtd/mtdoops.c:277: warning: format '%d' expects type 'int', but argument 3 has type 'size_t'

someone buy Dave an x86_64 box.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-08-22 12:43:13 +01:00
Richard Purdie 8691a729a2 [MTD] Add sync/unblank function to mtdoops
mtdoops wasn't ensuring data was flushed to flash in crash situations
after recent changes in mainline kernels as tracking the
oops_in_progress variable was no longer enough. We can use the "unblank"
console call as a sync call to tell us to write out the buffer though.

Therefore add a sync function to mtdoops and call this when console
unblank events occur.

Signed-off-by: Richard Purdie <rpurdie@openedhand.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-07-11 14:57:17 +01:00
Richard Purdie 4b23aff083 [MTD] oops and panic message logging to MTD device
Kernel oops and panic messages are invaluable when debugging crashes.
These messages often don't make it to flash based logging methods (say a
syslog on jffs2) due to the overheads involved in writing to flash.

This patch allows you to turn an MTD partition into a circular log
buffer where kernel oops and panic messages are written to. The messages
are obtained by registering a console driver and checking
oops_in_progress. Erases are performed in advance to maximise the
chances of a saving messages.

To activate it, add console=ttyMTDx to the kernel commandline (where x
is the mtd device number to use).

Signed-off-by: Richard Purdie <rpurdie@openedhand.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-06-28 20:18:02 +01:00