staging: Android updates (take 2)
cover staging: Android updates (take 2)
Hi Greg,
Once again, here's the Android updates to the staging-next tree
so they can be queued for 3.4. This time w/ commit style changes you requested I've pulled these from the common/android-3.3 branch, and made only some minor changes to keep everything in the staging dir and to avoid compile issues on x86.
The patches can be browsed over here:
http://git.linaro.org/gitweb?p=people/jstultz/android-dev.git;a=shortlog;h=refs/heads/dev/android-staging-updates
thanks
-john
Colin Cross (9):
android: ram_console: move footer strings
android: ram_console: drop early buffer support
android: ram_console: drop verbose ram_console support
android: ram_console: split out persistent ram
android: persistent_ram: refactor ecc support
android: persistent_ram: handle reserving and mapping memory
android: persistent_ram: make persistent_ram_write atomic
android: persistent_ram: add notrace to persistent_ram_write
android: staging: ram_console: fix crash in ram_console_late_init
Dima Zavin (1):
android: ram_console: set CON_ANYTIME console flag
Nick Kralevich (1):
android: ram_console: honor dmesg_restrict
drivers/staging/android/Kconfig | 60 +---- drivers/staging/android/Makefile | 1 + drivers/staging/android/persistent_ram.c | 470 ++++++++++++++++++++++++++++++ drivers/staging/android/persistent_ram.h | 78 +++++ drivers/staging/android/ram_console.c | 412 +++++--------------------- 5 files changed, 629 insertions(+), 392 deletions(-) create mode 100644 drivers/staging/android/persistent_ram.c create mode 100644 drivers/staging/android/persistent_ram.h
Signature · 1 line
1.7.3.2.146.gca209
PATCH 1/11 android: ram_console: set CON_ANYTIME console flag
From: Dima Zavin <[email protected]>
We want to ensure that we get all the console messages, even ones that occur while the printing CPU is not yet online.
--- drivers/staging/android/ram_console.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/android/ram_console.c +1 -1
@@ -143,7 +143,7 @@ ram_console_write(struct console *console, const char *s, unsigned int count)static struct console ram_console = { .name ="ram" , .write = ram_console_write, - .flags =CON_PRINTBUFFER |CON_ENABLED , + .flags =CON_PRINTBUFFER |CON_ENABLED |CON_ANYTIME , .index =-1 , };
Signature · 1 line
1.7.3.2.146.gca209
PATCH 2/11 android: ram_console: move footer strings
In reply to John StultzFrom: Colin Cross <[email protected]>
Don't store the bootinfo string and the ecc status string with the recovered old log data. This will simplify refactoring the persistent ram code out of the ram console code later.
--- drivers/staging/android/ram_console.c | 115 +++++++++++++++++++------------- 1 files changed, 68 insertions(+), 47 deletions(-)
drivers/staging/android/ram_console.c +68 -47
@@ -42,6 +42,8 @@ static char __initdata#endif static char *ram_console_old_log;static size_t ram_console_old_log_size; +static const char *bootinfo; +static size_t bootinfo_size;static struct ram_console_buffer *ram_console_buffer;static size_t ram_console_buffer_size;
@@ -156,20 +158,13 @@ void ram_console_enable_console(int enabled) }static void __init -ram_console_save_old (struct ram_console_buffer *buffer,const char *bootinfo, -char *dest) +ram_console_save_old (struct ram_console_buffer *buffer,char *dest) {size_t old_log_size = buffer->size; -size_t bootinfo_size =0 ; -size_t total_size = old_log_size; -char *ptr; -const char *bootinfo_label ="Boot info:\n" ;#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION uint8_t *block;uint8_t *par; -char strbuf[80 ]; -int strbuf_len =0 ; block = buffer->data; par = ram_console_par_buffer;
@@ -195,24 +190,10 @@ ram_console_save_old(struct ram_console_buffer *buffer, const char *bootinfo, block +=ECC_BLOCK_SIZE ; par += ECC_SIZE; } -if (ram_console_corrected_bytes || ram_console_bad_blocks) - strbuf_len =snprintf (strbuf,sizeof (strbuf), -"\n%d Corrected bytes, %d unrecoverable blocks\n" , - ram_console_corrected_bytes, ram_console_bad_blocks); -else - strbuf_len =snprintf (strbuf,sizeof (strbuf), -"\nNo errors detected\n" ); -if (strbuf_len >=sizeof (strbuf)) - strbuf_len =sizeof (strbuf) -1 ; - total_size += strbuf_len;#endif -if (bootinfo) - bootinfo_size =strlen (bootinfo) +strlen (bootinfo_label); - total_size += bootinfo_size; -if (dest ==NULL ) { - dest =kmalloc (total_size,GFP_KERNEL ); + dest =kmalloc (old_log_size,GFP_KERNEL );if (dest ==NULL ) {printk (KERN_ERR "ram_console: failed to allocate buffer\n" );
@@ -221,27 +202,15 @@ ram_console_save_old(struct ram_console_buffer *buffer, const char *bootinfo, } ram_console_old_log = dest; - ram_console_old_log_size = total_size; + ram_console_old_log_size = old_log_size;memcpy (ram_console_old_log, &buffer->data[buffer->start], buffer->size - buffer->start);memcpy (ram_console_old_log + buffer->size - buffer->start, &buffer->data[0 ], buffer->start); - ptr = ram_console_old_log + old_log_size; -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION -memcpy (ptr, strbuf, strbuf_len); - ptr += strbuf_len; -#endif -if (bootinfo) { -memcpy (ptr, bootinfo_label,strlen (bootinfo_label)); - ptr +=strlen (bootinfo_label); -memcpy (ptr, bootinfo, bootinfo_size); - ptr += bootinfo_size; - } }static int __init ram_console_init (struct ram_console_buffer *buffer, -size_t buffer_size,const char *bootinfo, -char *old_buf) +size_t buffer_size,char *old_buf) {#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION int numerr;
@@ -308,7 +277,7 @@ static int __init ram_console_init(struct ram_console_buffer *buffer,printk (KERN_INFO "ram_console: found existing buffer, " "size %d, start %d\n" , buffer->size, buffer->start); -ram_console_save_old (buffer, bootinfo, old_buf); +ram_console_save_old (buffer, old_buf); } }else { printk(KERN_INFO "ram_console: no valid data in buffer "
@@ -326,6 +295,24 @@ static int __init ram_console_init(struct ram_console_buffer *buffer,return 0 ; } +static ssize_t ram_console_ecc_string (char *str,size_t len) +{ +#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION +ssize_t ret; + +if (ram_console_corrected_bytes || ram_console_bad_blocks) + ret =snprintf (str, len,"" +"\n%d Corrected bytes, %d unrecoverable blocks\n" , + ram_console_corrected_bytes, ram_console_bad_blocks); +else + ret =snprintf (str, len,"\nNo errors detected\n" ); + +return ret; +#else +return 0 ; +#endif +} +#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT static int __init ram_console_early_init (void ) {
@@ -342,7 +329,6 @@ static int ram_console_driver_probe(struct platform_device *pdev)size_t start;size_t buffer_size;void *buffer; -const char *bootinfo =NULL ;struct ram_console_platform_data *pdata = pdev->dev.platform_data; if (res == NULL || pdev->num_resources != 1 ||
@@ -361,10 +347,13 @@ static int ram_console_driver_probe(struct platform_device *pdev)return -ENOMEM ; } -if (pdata) - bootinfo = pdata->bootinfo; +if (pdata) { + bootinfo =kstrdup (pdata->bootinfo,GFP_KERNEL ); +if (bootinfo) + bootinfo_size =strlen (bootinfo); + } -return ram_console_init (buffer, buffer_size, bootinfo,NULL /* allocate */ ); +return ram_console_init (buffer, buffer_size,NULL /* allocate */ ); }static struct platform_driver ram_console_driver = {
@@ -387,14 +376,46 @@ static ssize_t ram_console_read_old(struct file *file, char __user *buf, {loff_t pos = *offset;ssize_t count; +char *str; +int ret; + +/* Main last_kmsg log */ +if (pos < ram_console_old_log_size) { + count =min (len, (size_t )(ram_console_old_log_size - pos)); +if (copy_to_user (buf, ram_console_old_log + pos, count)) +return -EFAULT ; + goto out; + } -if (pos >= ram_console_old_log_size) -return 0 ; +/* ECC correction notice */ + pos -= ram_console_old_log_size; + count =ram_console_ecc_string (NULL ,0 ); +if (pos < count) { + str =kmalloc (count,GFP_KERNEL ); +if (!str) +return -ENOMEM ; +ram_console_ecc_string (str, count +1 ); + count =min (len, (size_t )(count - pos)); + ret =copy_to_user (buf, str + pos, count); +kfree (str); +if (ret) +return -EFAULT ; + goto out; + } - count =min (len, (size_t )(ram_console_old_log_size - pos)); -if (copy_to_user (buf, ram_console_old_log + pos, count)) -return -EFAULT ; +/* Boot info passed through pdata */ + pos -= count; +if (pos < bootinfo_size) { + count =min (len, (size_t )(bootinfo_size - pos)); +if (copy_to_user (buf, bootinfo + pos, count)) +return -EFAULT ; + goto out; + } + +/* EOF */ +return 0 ; +out: *offset += count;return count; }
Signature · 1 line
1.7.3.2.146.gca209
PATCH 3/11 android: ram_console: drop early buffer support
In reply to John StultzFrom: Colin Cross <[email protected]>
Early ramconsole is not very useful, an early crash will prevent getting the logged data out on the next boot, and CONFIG_DEBUG_LL=y will get the same information. Drop it to simplify a future refactoring.
--- drivers/staging/android/Kconfig | 16 ---------------- drivers/staging/android/ram_console.c | 29 ----------------------------- 2 files changed, 0 insertions(+), 45 deletions(-)
drivers/staging/android/Kconfig +0 -16
@@ -39,7 +39,6 @@ menuconfig ANDROID_RAM_CONSOLE_ERROR_CORRECTION bool "Android RAM Console Enable error correction" default n depends on ANDROID_RAM_CONSOLE - depends on !ANDROID_RAM_CONSOLE_EARLY_INIT select REED_SOLOMON select REED_SOLOMON_ENC8 select REED_SOLOMON_DEC8
@@ -70,21 +69,6 @@ config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_POLYNOMIAL endif # ANDROID_RAM_CONSOLE_ERROR_CORRECTION -config ANDROID_RAM_CONSOLE_EARLY_INIT - bool "Start Android RAM console early" - default n - depends on ANDROID_RAM_CONSOLE - -config ANDROID_RAM_CONSOLE_EARLY_ADDR - hex "Android RAM console virtual address" - default 0 - depends on ANDROID_RAM_CONSOLE_EARLY_INIT - -config ANDROID_RAM_CONSOLE_EARLY_SIZE - hex "Android RAM console buffer size" - default 0 - depends on ANDROID_RAM_CONSOLE_EARLY_INIT - config ANDROID_TIMED_OUTPUT bool "Timed output class driver" default y
drivers/staging/android/ram_console.c +0 -29
@@ -36,10 +36,6 @@ struct ram_console_buffer {#define RAM_CONSOLE_SIG (0x43474244)/* DBGC */ -#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT -static char __initdata - ram_console_old_log_init_buffer[CONFIG_ANDROID_RAM_CONSOLE_EARLY_SIZE ]; -#endif static char *ram_console_old_log;static size_t ram_console_old_log_size;static const char *bootinfo;
@@ -313,16 +309,6 @@ static ssize_t ram_console_ecc_string(char *str, size_t len)#endif } -#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT -static int __init ram_console_early_init (void ) -{ -return ram_console_init ((struct ram_console_buffer *) -CONFIG_ANDROID_RAM_CONSOLE_EARLY_ADDR , -CONFIG_ANDROID_RAM_CONSOLE_EARLY_SIZE , -NULL , - ram_console_old_log_init_buffer); -} -#else static int ram_console_driver_probe (struct platform_device *pdev) {struct resource *res = pdev->resource;
@@ -369,7 +355,6 @@ static int __init ram_console_module_init(void) err =platform_driver_register (&ram_console_driver);return err; } -#endif static ssize_t ram_console_read_old (struct file *file,char __user *buf,size_t len,loff_t *offset)
@@ -431,16 +416,6 @@ static int __init ram_console_late_init(void)if (ram_console_old_log ==NULL )return 0 ; -#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT - ram_console_old_log =kmemdup (ram_console_old_log_init_buffer, - ram_console_old_log_size,GFP_KERNEL ); -if (ram_console_old_log ==NULL ) { -printk (KERN_ERR -"ram_console: failed to allocate buffer for old log\n" ); - ram_console_old_log_size =0 ; -return 0 ; - } -#endif entry =create_proc_entry ("last_kmsg" ,S_IFREG |S_IRUGO ,NULL );if (!entry) {printk (KERN_ERR "ram_console: failed to create proc entry\n" );
@@ -454,10 +429,6 @@ static int __init ram_console_late_init(void)return 0 ; } -#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT -console_initcall (ram_console_early_init); -#else postcore_initcall (ram_console_module_init); -#endif late_initcall (ram_console_late_init);
Signature · 1 line
1.7.3.2.146.gca209
PATCH 4/11 android: ram_console: drop verbose ram_console support
In reply to John StultzFrom: Colin Cross <[email protected]>
Equivalent functionality can be obtained with loglevel=15
--- drivers/staging/android/Kconfig | 5 ----- drivers/staging/android/ram_console.c | 3 --- 2 files changed, 0 insertions(+), 8 deletions(-)
drivers/staging/android/Kconfig +0 -5
@@ -30,11 +30,6 @@ config ANDROID_RAM_CONSOLE depends on !S390 && !UML default n -config ANDROID_RAM_CONSOLE_ENABLE_VERBOSE - bool "Enable verbose console messages on Android RAM console" - default y - depends on ANDROID_RAM_CONSOLE - menuconfig ANDROID_RAM_CONSOLE_ERROR_CORRECTION bool "Android RAM Console Enable error correction" default n
drivers/staging/android/ram_console.c +0 -3
@@ -285,9 +285,6 @@ static int __init ram_console_init(struct ram_console_buffer *buffer, buffer->size =0 ;register_console (&ram_console); -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ENABLE_VERBOSE -console_verbose (); -#endif return 0 ; }
Signature · 1 line
1.7.3.2.146.gca209
PATCH 5/11 android: ram_console: split out persistent ram
In reply to John StultzFrom: Colin Cross <[email protected]>
Split ram_console into two halves.
persistent_ram is a set of apis that handle a block of memory that does not get erased across a reboot. It provides functions to fill it as a single buffer or a ring buffer, and to extract the old data after a reboot. It handles ecc on the data to correct bit errors introduced during reboot.
ram_console is now a small wrapper around persistent_ram that feeds console data into the ringbuffer, and exports the old data to /proc/last_kmsg after a reboot.
--- drivers/staging/android/Kconfig | 6 +- drivers/staging/android/Makefile | 1 + drivers/staging/android/persistent_ram.c | 302 +++++++++++++++++++++++++++++ drivers/staging/android/persistent_ram.h | 52 +++++ drivers/staging/android/ram_console.c | 309 ++++-------------------------- 5 files changed, 396 insertions(+), 274 deletions(-) create mode 100644 drivers/staging/android/persistent_ram.c create mode 100644 drivers/staging/android/persistent_ram.h
drivers/staging/android/Kconfig +5 -1
@@ -25,15 +25,19 @@ config ANDROID_LOGGER tristate "Android log driver" default n +config ANDROID_PERSISTENT_RAM + bool + config ANDROID_RAM_CONSOLE bool "Android RAM buffer console" depends on !S390 && !UML + select ANDROID_PERSISTENT_RAM default n menuconfig ANDROID_RAM_CONSOLE_ERROR_CORRECTION bool "Android RAM Console Enable error correction" default n - depends on ANDROID_RAM_CONSOLE + depends on ANDROID_PERSISTENT_RAM select REED_SOLOMON select REED_SOLOMON_ENC8 select REED_SOLOMON_DEC8
drivers/staging/android/Makefile +1 -0
@@ -1,6 +1,7 @@ obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOGGER) += logger.o +obj-$(CONFIG_ANDROID_PERSISTENT_RAM) += persistent_ram.o obj-$(CONFIG_ANDROID_RAM_CONSOLE) += ram_console.o obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o obj-$(CONFIG_ANDROID_TIMED_GPIO) += timed_gpio.o
drivers/staging/android/persistent_ram.c new file +302 -0
302 lines not on this page · raw message
drivers/staging/android/persistent_ram.h new file +52 -0
52 lines not on this page · raw message
drivers/staging/android/ram_console.c +36 -273
382 lines not on this page · raw message
Signature · 1 line
1.7.3.2.146.gca209
Greg KH
maintainerRe: [PATCH 05/11] android: ram_console: split out persistent ram
Quoted 9 lines · John Stultz
From: Colin Cross <[email protected]>
Split
ram_consoleinto two halves.
persistent_ramis a set of apis that handle a block of memory that does not get erased across a reboot. It provides functions to fill it as a single buffer or a ring buffer, and to extract the old data after a reboot. It handles ecc on the data to correct bit errors introduced during reboot.
That's a nice idea, but why are you rolling your own interface here and not using the built-in one that the kernel already provides? Is there something lacking with what we have today that requires you to create something different? If so, why not just modify the existing interface to make it work for you, that way the tools already created will work automatically, and you will not have problems later ripping this out and porting it to the in-kernel api.
Because of this, sorry, I can't take the rest of these patches in this series. If the 10th or 11th ones are needed, care to refresh it against my tree and resend it so that I can take it?
thanks,
greg k-h
Re: [PATCH 05/11] android: ram_console: split out persistent ram
Quoted 11 lines · Greg KH
Quoted 9 lines · John Stultz
From: Colin Cross <[email protected]>
Split
ram_consoleinto two halves.
persistent_ramis a set of apis that handle a block of memory that does not get erased across a reboot. It provides functions to fill it as a single buffer or a ring buffer, and to extract the old data after a reboot. It handles ecc on the data to correct bit errors introduced during reboot.
Quoted 7 lines
That's a nice idea, but why are you rolling your own interface here and not using the built-in one that the kernel already provides? Is there something lacking with what we have today that requires you to create something different? If so, why not just modify the existing interface to make it work for you, that way the tools already created will work automatically, and you will not have problems later ripping this out and porting it to the in-kernel api.
What interface are you referring to, pstore? As I explained in the email John quoted to you, pstore would be a client of this, and ramconsole could be moved on top of pstore. This patch is just a refactoring that splits ramconsole and the persistent storage apart without significantly changing the api between them, and only makes it easier to insert pstore between them. As for tools, we've had tools that use ram_console since 2008.
Greg KH
maintainerRe: [PATCH 05/11] android: ram_console: split out persistent ram
Quoted 20 lines · Colin Cross
Quoted 11 lines · Greg KH
Quoted 9 lines · John Stultz
From: Colin Cross <[email protected]>
Split
ram_consoleinto two halves.
persistent_ramis a set of apis that handle a block of memory that does not get erased across a reboot. It provides functions to fill it as a single buffer or a ring buffer, and to extract the old data after a reboot. It handles ecc on the data to correct bit errors introduced during reboot.Quoted 7 lines
That's a nice idea, but why are you rolling your own interface here and not using the built-in one that the kernel already provides? Is there something lacking with what we have today that requires you to create something different? If so, why not just modify the existing interface to make it work for you, that way the tools already created will work automatically, and you will not have problems later ripping this out and porting it to the in-kernel api.
Quoted 1 line
What interface are you referring to, pstore?
Yes.
Quoted 1 line
As I explained in the email John quoted to you,
Wait, what email? Did I miss a response here? Have a message-id: I can search for?
Quoted 2 lines
pstore would be a client of this, and ramconsole could be moved on top of pstore.
Ok, as long as that is the end goal, that's fine, it was not obvious that this was the case at all, hence my confusion.
Quoted 3 lines
This patch is just a refactoring that splits ramconsole and the persistent storage apart without significantly changing the api between them, and only makes it easier to insert pstore between them.
That's good to hear, I'll go queue them up then, thanks for clearing this up.
greg k-h
Re: [PATCH 05/11] android: ram_console: split out persistent ram
Quoted 21 lines · Greg KH
Quoted 20 lines · Colin Cross
Quoted 18 lines · Greg KH
Quoted 9 lines · John Stultz
From: Colin Cross <[email protected]>
Split
ram_consoleinto two halves.
persistent_ramis a set of apis that handle a block of memory that does not get erased across a reboot. It provides functions to fill it as a single buffer or a ring buffer, and to extract the old data after a reboot. It handles ecc on the data to correct bit errors introduced during reboot.That's a nice idea, but why are you rolling your own interface here and not using the built-in one that the kernel already provides? Is there something lacking with what we have today that requires you to create something different? If so, why not just modify the existing interface to make it work for you, that way the tools already created will work automatically, and you will not have problems later ripping this out and porting it to the in-kernel api.
Quoted 8 lines
Quoted 1 line
What interface are you referring to, pstore?
Yes.
Quoted 1 line
As I explained in the email John quoted to you,
Wait, what email? Did I miss a response here? Have a message-id: I can search for?
Message ID 1331160054.2191.202.camel@work-vm
Quoted 14 lines
Quoted 2 lines
pstore would be a client of this, and ramconsole could be moved on top of pstore.
Ok, as long as that is the end goal, that's fine, it was not obvious that this was the case at all, hence my confusion.
Quoted 3 lines
This patch is just a refactoring that splits ramconsole and the persistent storage apart without significantly changing the api between them, and only makes it easier to insert pstore between them.
That's good to hear, I'll go queue them up then, thanks for clearing this up.
greg k-h
Greg KH
maintainerRe: [PATCH 05/11] android: ram_console: split out persistent ram
Quoted 24 lines · Colin Cross
Quoted 23 lines · Greg KH
Quoted 21 lines · Colin Cross
Quoted 11 lines · Greg KH
Quoted 9 lines · John Stultz
From: Colin Cross <[email protected]>
Split
ram_consoleinto two halves.
persistent_ramis a set of apis that handle a block of memory that does not get erased across a reboot. It provides functions to fill it as a single buffer or a ring buffer, and to extract the old data after a reboot. It handles ecc on the data to correct bit errors introduced during reboot.Quoted 7 lines
That's a nice idea, but why are you rolling your own interface here and not using the built-in one that the kernel already provides? Is there something lacking with what we have today that requires you to create something different? If so, why not just modify the existing interface to make it work for you, that way the tools already created will work automatically, and you will not have problems later ripping this out and porting it to the in-kernel api.
What interface are you referring to, pstore?
Quoted 8 lines
Quoted 6 lines
Yes.
Quoted 1 line
As I explained in the email John quoted to you,
Wait, what email? Did I miss a response here? Have a message-id: I can search for?
Message ID 1331160054.2191.202.camel@work-vm
Odd, that message id never got to me :(
Re: [PATCH 05/11] android: ram_console: split out persistent ram
In reply to Greg KHQuoted 3 lines · Greg KH
Because of this, sorry, I can't take the rest of these patches in this series. If the 10th or 11th ones are needed, care to refresh it against my tree and resend it so that I can take it?
10/11 depends on the patches you didn't take, so it gets dropped as well.
11/11 should still apply, and shouldn't need to be refreshed. Would you mind applying it, or do you really want it send it on its own?
thanks
-john
Greg KH
maintainerRe: [PATCH 05/11] android: ram_console: split out persistent ram
Quoted 9 lines · John Stultz
Quoted 3 lines · Greg KH
Because of this, sorry, I can't take the rest of these patches in this series. If the 10th or 11th ones are needed, care to refresh it against my tree and resend it so that I can take it?
10/11 depends on the patches you didn't take, so it gets dropped as well.
11/11 should still apply, and shouldn't need to be refreshed.
It applied with a ton of fuzz, so I wasn't sure about it.
Quoted 2 lines
Would you mind applying it, or do you really want it send it on its own?
I'll go queue up all of these now that I understand pstore is the goal here. That's what I was worried about.
thanks,
greg k-h
PATCH 6/11 android: persistent_ram: refactor ecc support
In reply to John StultzFrom: Colin Cross <[email protected]>
Remove CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION and related
#ifdefs. Also allow persistent ram zones without ecc enabled.
For some use cases, like the data portion of the upcoming persistent_vars patches, or a persistent ftrace ringbuffer, ecc on every update is too expensive.
--- drivers/staging/android/Kconfig | 37 +----- drivers/staging/android/persistent_ram.c | 239 ++++++++++++++++-------------- drivers/staging/android/persistent_ram.h | 12 +- drivers/staging/android/ram_console.c | 2 +- 4 files changed, 143 insertions(+), 147 deletions(-)
drivers/staging/android/Kconfig +3 -34
@@ -27,6 +27,9 @@ config ANDROID_LOGGER config ANDROID_PERSISTENT_RAM bool + select REED_SOLOMON + select REED_SOLOMON_ENC8 + select REED_SOLOMON_DEC8 config ANDROID_RAM_CONSOLE bool "Android RAM buffer console"
@@ -34,40 +37,6 @@ config ANDROID_RAM_CONSOLE select ANDROID_PERSISTENT_RAM default n -menuconfig ANDROID_RAM_CONSOLE_ERROR_CORRECTION - bool "Android RAM Console Enable error correction" - default n - depends on ANDROID_PERSISTENT_RAM - select REED_SOLOMON - select REED_SOLOMON_ENC8 - select REED_SOLOMON_DEC8 - -if ANDROID_RAM_CONSOLE_ERROR_CORRECTION - -config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_DATA_SIZE - int "Android RAM Console Data data size" - default 128 - help - Must be a power of 2. - -config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_ECC_SIZE - int "Android RAM Console ECC size" - default 16 - -config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE - int "Android RAM Console Symbol size" - default 8 - -config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_POLYNOMIAL - hex "Android RAM Console Polynomial" - default 0x19 if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 4) - default 0x29 if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 5) - default 0x61 if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 6) - default 0x89 if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 7) - default 0x11d if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 8) - -endif # ANDROID_RAM_CONSOLE_ERROR_CORRECTION - config ANDROID_TIMED_OUTPUT bool "Timed output class driver" default y
drivers/staging/android/persistent_ram.c +130 -109
340 lines not on this page · raw message
drivers/staging/android/persistent_ram.h +9 -3
@@ -24,13 +24,19 @@ struct persistent_ram_zone {struct list_head node;struct persistent_ram_buffer *buffer;size_t buffer_size; -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION + +/* ECC correction */ +bool ecc;char *par_buffer;char *par_header;struct rs_control *rs_decoder;int corrected_bytes;int bad_blocks; -#endif +int ecc_block_size; +int ecc_size; +int ecc_symsize; +int ecc_poly; +char *old_log;size_t old_log_size;size_t old_log_footer_size;
@@ -38,7 +44,7 @@ struct persistent_ram_zone { };int persistent_ram_init_ringbuffer (struct persistent_ram_zone *prz, -void __iomem *buffer,size_t buffer_size); +void __iomem *buffer,size_t buffer_size,bool ecc);int persistent_ram_write (struct persistent_ram_zone *prz,const void *s,unsigned int count);
drivers/staging/android/ram_console.c +1 -1
@@ -76,7 +76,7 @@ static int ram_console_driver_probe(struct platform_device *pdev) } ret =persistent_ram_init_ringbuffer (&ram_console_zone, buffer, - buffer_size); + buffer_size, true);if (ret) goto err;
Signature · 1 line
1.7.3.2.146.gca209
PATCH 7/11 android: persistent_ram: handle reserving and mapping memory
In reply to John StultzFrom: Colin Cross <[email protected]>
Replace the ioremapped memory passed in from the drivers with a memblock_reserve and vmap. Adds a new function, persistent_ram_early_init, designed to be called from the machine init_early callback, that calls memblock_remove and saves the provided persistent ram area layout.
Drivers only pass in their struct device * and ecc settings. Locating and mapping the memory is now handled entirely within persistent_ram.
Also, convert ram_console to the new persistent_ram_init parameters that only take a struct device * and ecc settings.
[jstultz: Fix pr_info casting issues on 64bit, folded two patches as the build breaks if they are apart. Also replaced phys_to_page() w/ pfn_to_page(addr>>PAGE_SHIFT), as phys_to_page is only on a few arches.]
--- drivers/staging/android/persistent_ram.c | 139 ++++++++++++++++++++++++------ drivers/staging/android/persistent_ram.h | 24 +++++- drivers/staging/android/ram_console.c | 42 ++------- 3 files changed, 144 insertions(+), 61 deletions(-)
drivers/staging/android/persistent_ram.c +112 -27
@@ -12,12 +12,17 @@* */ +#include <linux/device.h> +#include <linux/err.h> #include <linux/errno.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/io.h> +#include <linux/list.h> +#include <linux/memblock.h> #include <linux/rslib.h> #include <linux/slab.h> +#include <linux/vmalloc.h> #include "persistent_ram.h" struct persistent_ram_buffer {
@@ -29,7 +34,7 @@ struct persistent_ram_buffer {#define PERSISTENT_RAM_SIG (0x43474244)/* DBGC */ -static LIST_HEAD (zone_list); +static __initdata LIST_HEAD (persistent_ram_list);static void persistent_ram_encode_rs8 (struct persistent_ram_zone *prz,uint8_t *data,size_t len,uint8_t *ecc)
@@ -270,54 +275,134 @@ void persistent_ram_free_old(struct persistent_ram_zone *prz) prz->old_log_size =0 ; } -static int __init __persistent_ram_init (struct persistent_ram_zone *prz, -void __iomem *mem,size_t buffer_size,bool ecc) +static int persistent_ram_buffer_map (phys_addr_t start,phys_addr_t size, +struct persistent_ram_zone *prz) { -struct persistent_ram_buffer *buffer = mem; +struct page **pages; +phys_addr_t page_start; +unsigned int page_count; +pgprot_t prot; +unsigned int i; + + page_start = start -offset_in_page (start); + page_count =DIV_ROUND_UP (size +offset_in_page (start),PAGE_SIZE ); + + prot =pgprot_noncached (PAGE_KERNEL ); + + pages =kmalloc (sizeof (struct page *) * page_count,GFP_KERNEL ); +if (!pages) { +pr_err ("%s: Failed to allocate array for %u pages\n" , __func__, + page_count); +return -ENOMEM ; + } + +for (i =0 ; i < page_count; i++) { +phys_addr_t addr = page_start + i *PAGE_SIZE ; + pages[i] =pfn_to_page (addr >>PAGE_SHIFT ); + } + prz->vaddr =vmap (pages, page_count,VM_MAP , prot); +kfree (pages); +if (!prz->vaddr) { +pr_err ("%s: Failed to map %u pages\n" , __func__, page_count); +return -ENOMEM ; + } + + prz->buffer = prz->vaddr +offset_in_page (start); + prz->buffer_size = size -sizeof (struct persistent_ram_buffer ); + +return 0 ; +} + +static int __init persistent_ram_buffer_init (const char *name, +struct persistent_ram_zone *prz) +{ +int i; +struct persistent_ram *ram; +struct persistent_ram_descriptor *desc; +phys_addr_t start; + +list_for_each_entry (ram, &persistent_ram_list, node) { + start = ram->start; +for (i =0 ; i < ram->num_descs; i++) { + desc = &ram->descs[i]; +if (!strcmp (desc->name, name)) +return persistent_ram_buffer_map (start, + desc->size, prz); + start += desc->size; + } + } + +return -EINVAL ; +} + +static __init +struct persistent_ram_zone *__persistent_ram_init (struct device *dev,bool ecc) +{ +struct persistent_ram_zone *prz;int ret; -INIT_LIST_HEAD (&prz->node); + prz =kzalloc (sizeof (struct persistent_ram_zone ),GFP_KERNEL ); +if (!prz) { +pr_err ("persistent_ram: failed to allocate persistent ram zone\n" ); +return ERR_PTR (-ENOMEM ); + } - prz->buffer = buffer; - prz->buffer_size = buffer_size -sizeof (struct persistent_ram_buffer ); +INIT_LIST_HEAD (&prz->node); -if (prz->buffer_size > buffer_size) { -pr_err ("persistent_ram: buffer %p, invalid size %zu, datasize %zu\n" , - buffer, buffer_size, prz->buffer_size); -return -EINVAL ; + ret =persistent_ram_buffer_init (dev_name (dev), prz); +if (ret) { +pr_err ("persistent_ram: failed to initialize buffer\n" ); +return ERR_PTR (ret); } prz->ecc = ecc; - ret =persistent_ram_init_ecc (prz, buffer_size); + ret =persistent_ram_init_ecc (prz, prz->buffer_size);if (ret) -return ret; +return ERR_PTR (ret); -if (buffer->sig ==PERSISTENT_RAM_SIG ) { -if (buffer->size > prz->buffer_size - || buffer->start > buffer->size) +if (prz->buffer->sig ==PERSISTENT_RAM_SIG ) { +if (prz->buffer->size > prz->buffer_size + || prz->buffer->start > prz->buffer->size)pr_info ("persistent_ram: found existing invalid buffer, size %d, start %d\n" , - buffer->size, buffer->start); + prz->buffer->size, prz->buffer->start);else {pr_info ("persistent_ram: found existing buffer, size %d, start %d\n" , - buffer->size, buffer->start); + prz->buffer->size, prz->buffer->start);persistent_ram_save_old (prz); } }else {pr_info ("persistent_ram: no valid data in buffer (sig = 0x%08x)\n" , - buffer->sig); + prz->buffer->sig); } - buffer->sig =PERSISTENT_RAM_SIG ; - buffer->start =0 ; - buffer->size =0 ; + prz->buffer->sig =PERSISTENT_RAM_SIG ; + prz->buffer->start =0 ; + prz->buffer->size =0 ; -list_add_tail (&prz->node, &zone_list); +return prz; +} -return 0 ; +struct persistent_ram_zone *__init +persistent_ram_init_ringbuffer (struct device *dev,bool ecc) +{ +return __persistent_ram_init (dev, ecc); } -int __init persistent_ram_init_ringbuffer (struct persistent_ram_zone *prz, -void __iomem *mem,size_t buffer_size,bool ecc) +int __init persistent_ram_early_init (struct persistent_ram *ram) { -return __persistent_ram_init (prz, mem, buffer_size, true); +int ret; + + ret =memblock_reserve (ram->start, ram->size); +if (ret) { +pr_err ("Failed to reserve persistent memory from %08lx-%08lx\n" , + (long )ram->start, (long )(ram->start + ram->size -1 )); +return ret; + } + +list_add_tail (&ram->node, &persistent_ram_list); + +pr_info ("Initialized persistent memory from %08lx-%08lx\n" , + (long )ram->start, (long )(ram->start + ram->size -1 )); + +return 0 ; }
drivers/staging/android/persistent_ram.h +22 -2
@@ -15,13 +15,31 @@ #ifndef __LINUX_PERSISTENT_RAM_H__ #define __LINUX_PERSISTENT_RAM_H__ +#include <linux/device.h> #include <linux/kernel.h> +#include <linux/list.h> #include <linux/types.h> struct persistent_ram_buffer; +struct persistent_ram_descriptor { + const char *name; + phys_addr_t size; +}; + +struct persistent_ram { + phys_addr_t start; + phys_addr_t size; + + int num_descs; + struct persistent_ram_descriptor *descs; + + struct list_head node; +}; + struct persistent_ram_zone { struct list_head node; + void *vaddr; struct persistent_ram_buffer *buffer; size_t buffer_size;
@@ -43,8 +61,10 @@ struct persistent_ram_zone {bool early; }; -int persistent_ram_init_ringbuffer (struct persistent_ram_zone *prz, -void __iomem *buffer,size_t buffer_size,bool ecc); +int persistent_ram_early_init (struct persistent_ram *ram); + +struct persistent_ram_zone *persistent_ram_init_ringbuffer (struct device *dev, +bool ecc);int persistent_ram_write (struct persistent_ram_zone *prz,const void *s,unsigned int count);
drivers/staging/android/ram_console.c +10 -32
78 lines not on this page · raw message
Signature · 1 line
1.7.3.2.146.gca209
PATCH 8/11 android: persistent_ram: make persistent_ram_write atomic
In reply to John StultzFrom: Colin Cross <[email protected]>
Allow persistent_ram_write to be called on multiple cpus at the same time, as long as ecc is not in use. Uses atomics for the buffer->start and buffer->size counters.
--- drivers/staging/android/persistent_ram.c | 140 +++++++++++++++++++++-------- 1 files changed, 101 insertions(+), 39 deletions(-)
drivers/staging/android/persistent_ram.c +101 -39
@@ -27,8 +27,8 @@struct persistent_ram_buffer {uint32_t sig; -uint32_t start; -uint32_t size; +atomic_t start; +atomic_t size;uint8_t data[0 ]; };
@@ -36,6 +36,66 @@ struct persistent_ram_buffer {static __initdata LIST_HEAD (persistent_ram_list); +static inline size_t buffer_size (struct persistent_ram_zone *prz) +{ +return atomic_read (&prz->buffer->size); +} + +static inline size_t buffer_start (struct persistent_ram_zone *prz) +{ +return atomic_read (&prz->buffer->start); +} + +/* increase and wrap the start pointer, returning the old value */ +static inline size_t buffer_start_add (struct persistent_ram_zone *prz,size_t a) +{ +int old; +int new; + +do { + old =atomic_read (&prz->buffer->start); + new = old + a; +while (unlikely (new > prz->buffer_size)) + new -= prz->buffer_size; + }while (atomic_cmpxchg (&prz->buffer->start, old, new) != old); + +return old; +} + +/* increase the size counter until it hits the max size */ +static inline void buffer_size_add (struct persistent_ram_zone *prz,size_t a) +{ +size_t old; +size_t new; + +if (atomic_read (&prz->buffer->size) == prz->buffer_size) +return ; + +do { + old =atomic_read (&prz->buffer->size); + new = old + a; +if (new > prz->buffer_size) + new = prz->buffer_size; + }while (atomic_cmpxchg (&prz->buffer->size, old, new) != old); +} + +/* increase the size counter, retuning an error if it hits the max size */ +static inline ssize_t buffer_size_add_clamp (struct persistent_ram_zone *prz, +size_t a) +{ +size_t old; +size_t new; + +do { + old =atomic_read (&prz->buffer->size); + new = old + a; +if (new > prz->buffer_size) +return -ENOMEM ; + }while (atomic_cmpxchg (&prz->buffer->size, old, new) != old); + +return 0 ; +} +static void persistent_ram_encode_rs8 (struct persistent_ram_zone *prz,uint8_t *data,size_t len,uint8_t *ecc) {
@@ -62,7 +122,7 @@ static int persistent_ram_decode_rs8(struct persistent_ram_zone *prz, }static void persistent_ram_update_ecc (struct persistent_ram_zone *prz, -unsigned int count) +unsigned int start,unsigned int count) {struct persistent_ram_buffer *buffer = prz->buffer;uint8_t *buffer_end = buffer->data + prz->buffer_size;
@@ -75,16 +135,16 @@ static void persistent_ram_update_ecc(struct persistent_ram_zone *prz,if (!prz->ecc)return ; - block = buffer->data + (buffer->start & ~(ecc_block_size -1 )); - par = prz->par_buffer + - (buffer->start / ecc_block_size) * prz->ecc_size; + block = buffer->data + (start & ~(ecc_block_size -1 )); + par = prz->par_buffer + (start / ecc_block_size) * prz->ecc_size; +do {if (block + ecc_block_size > buffer_end) size = buffer_end - block;persistent_ram_encode_rs8 (prz, block, size, par); block += ecc_block_size; par += ecc_size; - }while (block < buffer->data + buffer->start + count); + }while (block < buffer->data + start + count); }static void persistent_ram_update_header_ecc (struct persistent_ram_zone *prz)
@@ -109,7 +169,7 @@ static void persistent_ram_ecc_old(struct persistent_ram_zone *prz) block = buffer->data; par = prz->par_buffer; -while (block < buffer->data + buffer->size) { +while (block < buffer->data +buffer_size (prz)) {int numerr;int size = prz->ecc_block_size;if (block + size > buffer->data + prz->buffer_size)
@@ -199,34 +259,33 @@ ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz, }static void persistent_ram_update (struct persistent_ram_zone *prz, -const void *s,unsigned int count) +const void *s,unsigned int start,unsigned int count) {struct persistent_ram_buffer *buffer = prz->buffer; -memcpy (buffer->data + buffer->start, s, count); -persistent_ram_update_ecc (prz, count); +memcpy (buffer->data + start, s, count); +persistent_ram_update_ecc (prz, start, count); }static void __init persistent_ram_save_old (struct persistent_ram_zone *prz) {struct persistent_ram_buffer *buffer = prz->buffer; -size_t old_log_size = buffer->size; +size_t size =buffer_size (prz); +size_t start =buffer_start (prz);char *dest;persistent_ram_ecc_old (prz); - dest =kmalloc (old_log_size,GFP_KERNEL ); + dest =kmalloc (size,GFP_KERNEL );if (dest ==NULL ) {pr_err ("persistent_ram: failed to allocate buffer\n" );return ; } prz->old_log = dest; - prz->old_log_size = old_log_size; -memcpy (prz->old_log, - &buffer->data[buffer->start], buffer->size - buffer->start); -memcpy (prz->old_log + buffer->size - buffer->start, - &buffer->data[0 ], buffer->start); + prz->old_log_size = size; +memcpy (prz->old_log, &buffer->data[start], size - start); +memcpy (prz->old_log + size - start, &buffer->data[0 ], start); } int persistent_ram_write(struct persistent_ram_zone *prz,
@@ -234,25 +293,26 @@ int persistent_ram_write(struct persistent_ram_zone *prz, {int rem;int c = count; -struct persistent_ram_buffer *buffer = prz->buffer; +size_t start; -if (c > prz->buffer_size) { +if (unlikely (c > prz->buffer_size)) { s += c - prz->buffer_size; c = prz->buffer_size; } - rem = prz->buffer_size - buffer->start; -if (rem < c) { -persistent_ram_update (prz, s, rem); + +buffer_size_add_clamp (prz, c); + + start =buffer_start_add (prz, c); + + rem = prz->buffer_size - start; +if (unlikely (rem < c)) { +persistent_ram_update (prz, s, start, rem); s += rem; c -= rem; - buffer->start =0 ; - buffer->size = prz->buffer_size; + start =0 ; } -persistent_ram_update (prz, s, c); +persistent_ram_update (prz, s, start, c); - buffer->start += c; -if (buffer->size < prz->buffer_size) - buffer->size += c;persistent_ram_update_header_ecc (prz);return count;
@@ -361,23 +421,25 @@ struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)return ERR_PTR (ret);if (prz->buffer->sig ==PERSISTENT_RAM_SIG ) { -if (prz->buffer->size > prz->buffer_size - || prz->buffer->start > prz->buffer->size) -pr_info ("persistent_ram: found existing invalid buffer, size %d, start %d\n" , - prz->buffer->size, prz->buffer->start); +if (buffer_size (prz) > prz->buffer_size || +buffer_start (prz) >buffer_size (prz)) +pr_info ("persistent_ram: found existing invalid buffer," +" size %ld, start %ld\n" , +buffer_size (prz),buffer_start (prz));else { -pr_info ("persistent_ram: found existing buffer, size %d, start %d\n" , - prz->buffer->size, prz->buffer->start); +pr_info ("persistent_ram: found existing buffer," +" size %ld, start %ld\n" , +buffer_size (prz),buffer_start (prz));persistent_ram_save_old (prz); } }else { -pr_info ("persistent_ram: no valid data in buffer (sig = 0x%08x)\n" , - prz->buffer->sig); +pr_info ("persistent_ram: no valid data in buffer" +" (sig = 0x%08x)\n" , prz->buffer->sig); } prz->buffer->sig =PERSISTENT_RAM_SIG ; - prz->buffer->start =0 ; - prz->buffer->size =0 ; +atomic_set (&prz->buffer->start,0 ); +atomic_set (&prz->buffer->size,0 );return prz; }
Signature · 1 line
1.7.3.2.146.gca209
PATCH 9/11 android: persistent_ram: add notrace to persistent_ram_write
In reply to John StultzFrom: Colin Cross <[email protected]>
Add the notrace attribute to persistent_ram_write and the non-ecc functions that it calls to allow persistent_ram to be used for ftracing (only when ecc is disabled).
--- drivers/staging/android/persistent_ram.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/android/persistent_ram.c +4 -4
@@ -96,7 +96,7 @@ static inline ssize_t buffer_size_add_clamp(struct persistent_ram_zone *prz,return 0 ; } -static void persistent_ram_encode_rs8 (struct persistent_ram_zone *prz, +static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz,uint8_t *data,size_t len,uint8_t *ecc) {int i;
@@ -121,7 +121,7 @@ static int persistent_ram_decode_rs8(struct persistent_ram_zone *prz, NULL, 0, NULL, 0, NULL); } -static void persistent_ram_update_ecc (struct persistent_ram_zone *prz, +static void notrace persistent_ram_update_ecc(struct persistent_ram_zone *prz,unsigned int start,unsigned int count) {struct persistent_ram_buffer *buffer = prz->buffer;
@@ -258,7 +258,7 @@ ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,return ret; } -static void persistent_ram_update (struct persistent_ram_zone *prz, +static void notrace persistent_ram_update(struct persistent_ram_zone *prz,const void *s,unsigned int start,unsigned int count) {struct persistent_ram_buffer *buffer = prz->buffer;
@@ -288,7 +288,7 @@ persistent_ram_save_old(struct persistent_ram_zone *prz)memcpy (prz->old_log + size - start, &buffer->data[0 ], start); } -int persistent_ram_write (struct persistent_ram_zone *prz, +int notrace persistent_ram_write(struct persistent_ram_zone *prz,const void *s,unsigned int count) {int rem;
Signature · 1 line
1.7.3.2.146.gca209
PATCH 10/11 android: staging: ram_console: fix crash in ram_console_late_init
In reply to John StultzFrom: Colin Cross <[email protected]>
If the persistent ram buffer is not available, ram_console_late_init would crash when dereferencing ram_console_zone. Return early if ram console was not initialized.
--- drivers/staging/android/ram_console.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/staging/android/ram_console.c +3 -0
@@ -150,6 +150,9 @@ static int __init ram_console_late_init(void)struct proc_dir_entry *entry;struct persistent_ram_zone *prz = ram_console_zone; +if (!prz) +return 0 ; +if (persistent_ram_old_size (prz) ==0 )return 0 ;
Signature · 1 line
1.7.3.2.146.gca209
PATCH 11/11 android: ram_console: honor dmesg_restrict
In reply to John StultzFrom: Nick Kralevich <[email protected]>
The Linux kernel has a setting called dmesg_restrict. When true, only processes with CAP_SYSLOG can view the kernel dmesg logs. This helps prevent leaking of kernel information into user space.
On Android, it's possible to bypass these restrictions by viewing /proc/last_kmsg.
This change makes /proc/last_kmsg require the same permissions as dmesg.
--- drivers/staging/android/ram_console.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/staging/android/ram_console.c +3 -0
@@ -99,6 +99,9 @@ static ssize_t ram_console_read_old(struct file *file, char __user *buf,char *str;int ret; +if (dmesg_restrict && !capable (CAP_SYSLOG )) +return -EPERM ; +/* Main last_kmsg log */ if (pos < old_log_size) { count =min (len, (size_t )(old_log_size - pos));
Signature · 1 line
1.7.3.2.146.gca209
Greg KH
maintainerQuoted 6 lines · John Stultz
Hi Greg,
Once again, here's the Android updates to the staging-next tree
so they can be queued for 3.4. This time w/ commit style changes you requested I've pulled these from the common/android-3.3 branch, and made only some minor changes to keep everything in the staging dir and to avoid compile issues on x86.
I took the first 4, as I explain in the 5th patch, I can't take that one, given that you are recreating existing apis we already have.
thanks,
greg k-h
PATCH 1/1 staging: ram_console: Fix section mismatches
In reply to John StultzWARNING: vmlinux.o(.text+0x25d5fc): Section mismatch in reference from the function ram_console_driver_probe() to the function .init.text:ram_console_init()
The function ram_console_driver_probe() references
the function __init ram_console_init().
This is often because ram_console_driver_probe lacks a __init annotation or the annotation of ram_console_init is wrong.
Mark ram_console_driver_probe() as __devinit because it's a probe function and propagate the __devinit markings to the __init functions the probe calls.
---
Can we merge this patch too? Maybe we can get rid of the lateinit call too?
drivers/staging/android/ram_console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/android/ram_console.c +3 -3
@@ -153,7 +153,7 @@ void ram_console_enable_console(int enabled) ram_console.flags &= ~CON_ENABLED ; } -static void __init +static void __devinit ram_console_save_old (struct ram_console_buffer *buffer,char *dest) {size_t old_log_size = buffer->size;
@@ -205,7 +205,7 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest) &buffer->data[0], buffer->start); } -static int __init ram_console_init (struct ram_console_buffer *buffer, +static int __devinit ram_console_init (struct ram_console_buffer *buffer,size_t buffer_size,char *old_buf) {#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
@@ -306,7 +306,7 @@ static ssize_t ram_console_ecc_string(char *str, size_t len)#endif } -static int ram_console_driver_probe (struct platform_device *pdev) +static int __devinit ram_console_driver_probe (struct platform_device *pdev) {struct resource *res = pdev->resource;size_t start;
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Greg KH
maintainerRe: [PATCH] staging: ram_console: Fix section mismatches
Quoted 11 lines · Stephen Boyd
WARNING:
vmlinux.o(.text+0x25d5fc): Section mismatch in reference from the functionram_console_driver_probe()to the function .init.text:ram_console_init()
The functionram_console_driver_probe()references
the function__initram_console_init().
This is often becauseram_console_driver_probelacks a__initannotation or the annotation ofram_console_initis wrong.Mark
ram_console_driver_probe()as__devinitbecause it's a probe function and propagate the__devinitmarkings to the__initfunctions the probe calls.
What .config configuration causes this to happen? I don't see this here in my builds, what am I doing wrong?
thanks,
greg k-h
Re: [PATCH] staging: ram_console: Fix section mismatches
Quoted 9 lines · Greg KH
Quoted 8 lines · Stephen Boyd
WARNING:
vmlinux.o(.text+0x25d5fc): Section mismatch in reference from the functionram_console_driver_probe()to the function .init.text:ram_console_init()
The functionram_console_driver_probe()references
the function__initram_console_init().
This is often becauseram_console_driver_probelacks a__initannotation or the annotation ofram_console_initis wrong.
Quoted 6 lines
Quoted 3 lines
Mark
ram_console_driver_probe()as__devinitbecause it's a probe function and propagate the__devinitmarkings to the__initfunctions the probe calls.What .config configuration causes this to happen? I don't see this here in my builds, what am I doing wrong?
#
# Android
#CONFIG_ANDROID=y
# CONFIG_ANDROID_BINDER_IPC is not set
# CONFIG_ASHMEM is not set
# CONFIG_ANDROID_LOGGER is not set CONFIG_ANDROID_RAM_CONSOLE=y
# CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION is not set # CONFIG_ANDROID_TIMED_OUTPUT is not set
# CONFIG_ANDROID_LOW_MEMORY_KILLER is not set
# CONFIG_ANDROID_SWITCH is not set
# CONFIG_PHONE is not set
Perhaps you're missing this patch if you're on an ARM compiler?
6e2e340 (ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers, 2012-02-14)
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Greg KH
maintainerRe: [PATCH] staging: ram_console: Fix section mismatches
Quoted 32 lines · Stephen Boyd
Quoted 9 lines · Greg KH
Quoted 8 lines · Stephen Boyd
WARNING:
vmlinux.o(.text+0x25d5fc): Section mismatch in reference from the functionram_console_driver_probe()to the function .init.text:ram_console_init()
The functionram_console_driver_probe()references
the function__initram_console_init().
This is often becauseram_console_driver_probelacks a__initannotation or the annotation ofram_console_initis wrong.Quoted 6 lines
Quoted 3 lines
Mark
ram_console_driver_probe()as__devinitbecause it's a probe function and propagate the__devinitmarkings to the__initfunctions the probe calls.What .config configuration causes this to happen? I don't see this here in my builds, what am I doing wrong?
#
# Android
#CONFIG_ANDROID=y
#CONFIG_ANDROID_BINDER_IPCis not set
#CONFIG_ASHMEMis not set
#CONFIG_ANDROID_LOGGERis not setCONFIG_ANDROID_RAM_CONSOLE=y
#CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTIONis not set #CONFIG_ANDROID_TIMED_OUTPUTis not set
#CONFIG_ANDROID_LOW_MEMORY_KILLERis not set
#CONFIG_ANDROID_SWITCHis not set
#CONFIG_PHONEis not set
Quoted 4 lines
Perhaps you're missing this patch if you're on an ARM compiler?
6e2e340 (ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers, 2012-02-14)
Nope, I'm building this on x86-64 which warns on this type of thing all the time.
My .config looks like this:
#
# Android
#CONFIG_ANDROID=yCONFIG_ANDROID_BINDER_IPC=yCONFIG_ASHMEM=yCONFIG_ANDROID_LOGGER=mCONFIG_ANDROID_PERSISTENT_RAM=yCONFIG_ANDROID_RAM_CONSOLE=yCONFIG_ANDROID_TIMED_OUTPUT=y
# CONFIG_ANDROID_TIMED_GPIO is not setCONFIG_ANDROID_LOW_MEMORY_KILLER=yCONFIG_ANDROID_SWITCH=mCONFIG_ANDROID_SWITCH_GPIO=mCONFIG_ANDROID_INTF_ALARM=yCONFIG_ANDROID_INTF_ALARM_DEV=yCONFIG_ANDROID_ALARM_OLDDRV_COMPAT=y
And I can't duplicate this at all. Could the recent fixes that John sent me be the reason? Or something else?
thanks,
greg k-h
Re: [PATCH] staging: ram_console: Fix section mismatches
Quoted 59 lines · Greg KH
Quoted 31 lines · Stephen Boyd
Quoted 9 lines · Greg KH
Quoted 8 lines · Stephen Boyd
WARNING:
vmlinux.o(.text+0x25d5fc): Section mismatch in reference from the functionram_console_driver_probe()to the function .init.text:ram_console_init()
The functionram_console_driver_probe()references
the function__initram_console_init().
This is often becauseram_console_driver_probelacks a__initannotation or the annotation ofram_console_initis wrong.Quoted 6 lines
Quoted 3 lines
Mark
ram_console_driver_probe()as__devinitbecause it's a probe function and propagate the__devinitmarkings to the__initfunctions the probe calls.What .config configuration causes this to happen? I don't see this here in my builds, what am I doing wrong?
#
# Android
#CONFIG_ANDROID=y
#CONFIG_ANDROID_BINDER_IPCis not set
#CONFIG_ASHMEMis not set
#CONFIG_ANDROID_LOGGERis not setCONFIG_ANDROID_RAM_CONSOLE=y
#CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTIONis not set #CONFIG_ANDROID_TIMED_OUTPUTis not set
#CONFIG_ANDROID_LOW_MEMORY_KILLERis not set
#CONFIG_ANDROID_SWITCHis not set
#CONFIG_PHONEis not setQuoted 4 lines
Perhaps you're missing this patch if you're on an ARM compiler?
6e2e340 (ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers, 2012-02-14)
Nope, I'm building this on x86-64 which warns on this type of thing all the time.
My .config looks like this:
#
# Android
#CONFIG_ANDROID=yCONFIG_ANDROID_BINDER_IPC=yCONFIG_ASHMEM=yCONFIG_ANDROID_LOGGER=mCONFIG_ANDROID_PERSISTENT_RAM=yCONFIG_ANDROID_RAM_CONSOLE=yCONFIG_ANDROID_TIMED_OUTPUT=y
#CONFIG_ANDROID_TIMED_GPIOis not setCONFIG_ANDROID_LOW_MEMORY_KILLER=yCONFIG_ANDROID_SWITCH=mCONFIG_ANDROID_SWITCH_GPIO=mCONFIG_ANDROID_INTF_ALARM=yCONFIG_ANDROID_INTF_ALARM_DEV=yCONFIG_ANDROID_ALARM_OLDDRV_COMPAT=y
Quoted 3 lines
And I can't duplicate this at all. Could the recent fixes that John sent me be the reason? Or something else?
This patch is based on your staging-next branch at c5ee121 (staging:
android: ram_console: drop verbose ram_console support, 2012-03-07). It applied that ARM patch on top because I'm compiling with ARM.
It looks like aggressive inlining by the x86 compiler hides this from you. I see that if I mark ram_console_init() as noinline
drivers/staging/android/ram_console.c +1 -1
@@ -205,7 +205,7 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest) &buffer->data[0], buffer->start); } -static int __init ram_console_init (struct ram_console_buffer *buffer, +static noinline int __init ram_console_init(struct ram_console_buffer *buffer,size_t buffer_size,char *old_buf) {#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
then I see the section mismatch when compiling on x86. Otherwise I don't see anything. Is there a bug in the section mismatch detection with respect to compiler inlining?
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Greg KH
maintainerRe: [PATCH] staging: ram_console: Fix section mismatches
Quoted 60 lines · Stephen Boyd
Quoted 59 lines · Greg KH
Quoted 31 lines · Stephen Boyd
Quoted 9 lines · Greg KH
Quoted 8 lines · Stephen Boyd
WARNING:
vmlinux.o(.text+0x25d5fc): Section mismatch in reference from the functionram_console_driver_probe()to the function .init.text:ram_console_init()
The functionram_console_driver_probe()references
the function__initram_console_init().
This is often becauseram_console_driver_probelacks a__initannotation or the annotation ofram_console_initis wrong.Quoted 6 lines
Quoted 3 lines
Mark
ram_console_driver_probe()as__devinitbecause it's a probe function and propagate the__devinitmarkings to the__initfunctions the probe calls.What .config configuration causes this to happen? I don't see this here in my builds, what am I doing wrong?
#
# Android
#CONFIG_ANDROID=y
#CONFIG_ANDROID_BINDER_IPCis not set
#CONFIG_ASHMEMis not set
#CONFIG_ANDROID_LOGGERis not setCONFIG_ANDROID_RAM_CONSOLE=y
#CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTIONis not set #CONFIG_ANDROID_TIMED_OUTPUTis not set
#CONFIG_ANDROID_LOW_MEMORY_KILLERis not set
#CONFIG_ANDROID_SWITCHis not set
#CONFIG_PHONEis not setQuoted 4 lines
Perhaps you're missing this patch if you're on an ARM compiler?
6e2e340 (ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers, 2012-02-14)
Nope, I'm building this on x86-64 which warns on this type of thing all the time.
My .config looks like this:
#
# Android
#CONFIG_ANDROID=yCONFIG_ANDROID_BINDER_IPC=yCONFIG_ASHMEM=yCONFIG_ANDROID_LOGGER=mCONFIG_ANDROID_PERSISTENT_RAM=yCONFIG_ANDROID_RAM_CONSOLE=yCONFIG_ANDROID_TIMED_OUTPUT=y
#CONFIG_ANDROID_TIMED_GPIOis not setCONFIG_ANDROID_LOW_MEMORY_KILLER=yCONFIG_ANDROID_SWITCH=mCONFIG_ANDROID_SWITCH_GPIO=mCONFIG_ANDROID_INTF_ALARM=yCONFIG_ANDROID_INTF_ALARM_DEV=yCONFIG_ANDROID_ALARM_OLDDRV_COMPAT=y
Quoted 7 lines
Quoted 3 lines
And I can't duplicate this at all. Could the recent fixes that John sent me be the reason? Or something else?
This patch is based on your staging-next branch at c5ee121 (staging:
android:ram_console: drop verboseram_consolesupport, 2012-03-07). It applied that ARM patch on top because I'm compiling with ARM.
The ram_console just got reworked a bunch by the patches I applied a few hours ago (and you had responded to that thread), so even if I wanted to take your patch, I can't :)
Care to redo it if it is needed after the rework that just happened?
Quoted 18 lines
It looks like aggressive inlining by the x86 compiler hides this from you. I see that if I mark
ram_console_init()as noinlinedrivers/staging/android/ram_console.c +1
-1@@ -205,7 +205,7 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest) &buffer->data[0], buffer->start); } -static int __init ram_console_init (struct ram_console_buffer *buffer, +static noinline int __init ram_console_init(struct ram_console_buffer *buffer,size_t buffer_size,char *old_buf) {#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
Quoted 3 lines
then I see the section mismatch when compiling on x86. Otherwise I don't see anything. Is there a bug in the section mismatch detection with respect to compiler inlining?
Possibly, but probably not, if the code is inlined, then there is no error happening, so there's nothing to detect, right?
thanks,
greg k-h
Re: [PATCH] staging: ram_console: Fix section mismatches
Quoted 64 lines · Greg KH
Quoted 63 lines · Stephen Boyd
Quoted 62 lines · Greg KH
Quoted 31 lines · Stephen Boyd
Quoted 9 lines · Greg KH
Quoted 8 lines · Stephen Boyd
WARNING:
vmlinux.o(.text+0x25d5fc): Section mismatch in reference from the functionram_console_driver_probe()to the function .init.text:ram_console_init()
The functionram_console_driver_probe()references
the function__initram_console_init().
This is often becauseram_console_driver_probelacks a__initannotation or the annotation ofram_console_initis wrong.Quoted 6 lines
Quoted 3 lines
Mark
ram_console_driver_probe()as__devinitbecause it's a probe function and propagate the__devinitmarkings to the__initfunctions the probe calls.What .config configuration causes this to happen? I don't see this here in my builds, what am I doing wrong?
#
# Android
#CONFIG_ANDROID=y
#CONFIG_ANDROID_BINDER_IPCis not set
#CONFIG_ASHMEMis not set
#CONFIG_ANDROID_LOGGERis not setCONFIG_ANDROID_RAM_CONSOLE=y
#CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTIONis not set #CONFIG_ANDROID_TIMED_OUTPUTis not set
#CONFIG_ANDROID_LOW_MEMORY_KILLERis not set
#CONFIG_ANDROID_SWITCHis not set
#CONFIG_PHONEis not setQuoted 4 lines
Perhaps you're missing this patch if you're on an ARM compiler?
6e2e340 (ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers, 2012-02-14)
Nope, I'm building this on x86-64 which warns on this type of thing all the time.
My .config looks like this:
#
# Android
#CONFIG_ANDROID=yCONFIG_ANDROID_BINDER_IPC=yCONFIG_ASHMEM=yCONFIG_ANDROID_LOGGER=mCONFIG_ANDROID_PERSISTENT_RAM=yCONFIG_ANDROID_RAM_CONSOLE=yCONFIG_ANDROID_TIMED_OUTPUT=y
#CONFIG_ANDROID_TIMED_GPIOis not setCONFIG_ANDROID_LOW_MEMORY_KILLER=yCONFIG_ANDROID_SWITCH=mCONFIG_ANDROID_SWITCH_GPIO=mCONFIG_ANDROID_INTF_ALARM=yCONFIG_ANDROID_INTF_ALARM_DEV=yCONFIG_ANDROID_ALARM_OLDDRV_COMPAT=yAnd I can't duplicate this at all. Could the recent fixes that John sent me be the reason? Or something else?
Quoted 9 lines
Quoted 3 lines
This patch is based on your staging-next branch at c5ee121 (staging:
android:ram_console: drop verboseram_consolesupport, 2012-03-07). It applied that ARM patch on top because I'm compiling with ARM.The
ram_consolejust got reworked a bunch by the patches I applied a few hours ago (and you had responded to that thread), so even if I wanted to take your patch, I can't :)Care to redo it if it is needed after the rework that just happened?
Sure. Now it looks like:
WARNING: vmlinux.o(.text+0xfcf6e): Section mismatch in reference from the function ram_console_driver_probe() to the function .init.text:persistent_ram_init_ringbuffer()
The function ram_console_driver_probe() references
the function __init persistent_ram_init_ringbuffer().
This is often because ram_console_driver_probe lacks a __init annotation or the annotation of persistent_ram_init_ringbuffer is wrong.
I think this wants to use platform_driver_probe() so I've changed the patch.
Quoted 18 lines
Quoted 18 lines
It looks like aggressive inlining by the x86 compiler hides this from you. I see that if I mark
ram_console_init()as noinlinedrivers/staging/android/ram_console.c +1
-1@@ -205,7 +205,7 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest) &buffer->data[0], buffer->start); } -static int __init ram_console_init (struct ram_console_buffer *buffer, +static noinline int __init ram_console_init(struct ram_console_buffer *buffer,size_t buffer_size,char *old_buf) {#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
Quoted 5 lines
Quoted 3 lines
then I see the section mismatch when compiling on x86. Otherwise I don't see anything. Is there a bug in the section mismatch detection with respect to compiler inlining?
Possibly, but probably not, if the code is inlined, then there is no error happening, so there's nothing to detect, right?
Presumably the person writing the driver wanted this function thrown away after kernel init but now it's not being thrown away because it got inlined into a function that isn't marked correctly. That sounds like some type of bug to me either in someone's brain or in some random compiler. But I suppose you're talking about section mismatch detection having a bug and I agree it's probably impossible to catch this case when all we have to work with is the compiler's output.
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 1/1 staging: ram_console: Fix section mismatches
In reply to Greg KHWARNING: vmlinux.o(.text+0xfcf6e): Section mismatch in reference from the function ram_console_driver_probe() to the function .init.text:persistent_ram_init_ringbuffer()
The function ram_console_driver_probe() references
the function __init persistent_ram_init_ringbuffer(). This is often because ram_console_driver_probe lacks a __init annotation or the annotation of persistent_ram_init_ringbuffer is wrong.
Move this driver to platform_driver_probe() because ram console devices aren't going to be added and removed at runtime. Also shorten the probe function name since driver is redundant and makes the function name long.
--- drivers/staging/android/ram_console.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/android/ram_console.c +2 -5
@@ -50,7 +50,7 @@ void ram_console_enable_console(int enabled) ram_console.flags &= ~CON_ENABLED ; } -static int ram_console_driver_probe (struct platform_device *pdev) +static int __init ram_console_probe (struct platform_device *pdev) {struct ram_console_platform_data *pdata = pdev->dev.platform_data;struct persistent_ram_zone *prz;
@@ -75,7 +75,6 @@ static int ram_console_driver_probe(struct platform_device *pdev) }static struct platform_driver ram_console_driver = { - .probe = ram_console_driver_probe, .driver = { .name ="ram_console" , },
@@ -83,9 +82,7 @@ static struct platform_driver ram_console_driver = {static int __init ram_console_module_init (void ) { -int err; - err =platform_driver_register (&ram_console_driver); -return err; +return platform_driver_probe (&ram_console_driver, ram_console_probe); } static ssize_t ram_console_read_old(struct file *file, char __user *buf,
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.