linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: hvc: don't allocate a buffer for console print on stack
@ 2017-02-17 20:42 Jan Dakinevich
  2017-03-17  5:09 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Dakinevich @ 2017-02-17 20:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Jan Dakinevich, Peter Hurley,
	Dan Carpenter, Arnd Bergmann, Amit Shah, virtualization,
	linuxppc-dev, linux-kernel

The buffer is used by virtio console driver as DMA buffer. Since v4.9
(if VMAP_STACK is enabled) we shouldn't use the stack for DMA.

Signed-off-by: Jan Dakinevich <jan.dakinevich@gmail.com>
---
 drivers/tty/hvc/hvc_console.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 9b5c0fb..1ce6aaf 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -143,10 +143,15 @@ static struct hvc_struct *hvc_get_by_index(int index)
 static void hvc_console_print(struct console *co, const char *b,
 			      unsigned count)
 {
-	char c[N_OUTBUF] __ALIGNED__;
 	unsigned i = 0, n = 0;
 	int r, donecr = 0, index = co->index;
 
+	/*
+	 * Access to the buffer is serialized by console_sem in caller code from
+	 * kernel/printk/printk.c
+	 */
+	static char c[N_OUTBUF] __ALIGNED__;
+
 	/* Console access attempt outside of acceptable console range. */
 	if (index >= MAX_NR_HVC_CONSOLES)
 		return;
-- 
1.9.1

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

* Re: [PATCH] tty: hvc: don't allocate a buffer for console print on stack
  2017-02-17 20:42 [PATCH] tty: hvc: don't allocate a buffer for console print on stack Jan Dakinevich
@ 2017-03-17  5:09 ` Greg Kroah-Hartman
  2017-03-20 15:55   ` Jan Dakinevich
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-03-17  5:09 UTC (permalink / raw)
  To: Jan Dakinevich
  Cc: Jiri Slaby, Peter Hurley, Dan Carpenter, Arnd Bergmann,
	Amit Shah, virtualization, linuxppc-dev, linux-kernel

On Fri, Feb 17, 2017 at 11:42:45PM +0300, Jan Dakinevich wrote:
> The buffer is used by virtio console driver as DMA buffer. Since v4.9
> (if VMAP_STACK is enabled) we shouldn't use the stack for DMA.

You shouldn't use 'static' data either, that's not always guaranteed to
be DMA-able, right?

> 
> Signed-off-by: Jan Dakinevich <jan.dakinevich@gmail.com>
> ---
>  drivers/tty/hvc/hvc_console.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
> index 9b5c0fb..1ce6aaf 100644
> --- a/drivers/tty/hvc/hvc_console.c
> +++ b/drivers/tty/hvc/hvc_console.c
> @@ -143,10 +143,15 @@ static struct hvc_struct *hvc_get_by_index(int index)
>  static void hvc_console_print(struct console *co, const char *b,
>  			      unsigned count)
>  {
> -	char c[N_OUTBUF] __ALIGNED__;
>  	unsigned i = 0, n = 0;
>  	int r, donecr = 0, index = co->index;
>  
> +	/*
> +	 * Access to the buffer is serialized by console_sem in caller code from
> +	 * kernel/printk/printk.c
> +	 */
> +	static char c[N_OUTBUF] __ALIGNED__;

What about allocating it dynamically?  That's the correct thing to do.

thanks,

greg k-h

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

* Re: [PATCH] tty: hvc: don't allocate a buffer for console print on stack
  2017-03-17  5:09 ` Greg Kroah-Hartman
@ 2017-03-20 15:55   ` Jan Dakinevich
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Dakinevich @ 2017-03-20 15:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Peter Hurley, Dan Carpenter, Arnd Bergmann,
	Amit Shah, virtualization, linuxppc-dev, linux-kernel

> You shouldn't use 'static' data either, that's not always guaranteed to
> be DMA-able, right?

I naively thought all 'static' data was linked into .data and the
section was always kmapped.

> What about allocating it dynamically?  That's the correct thing to do.

Yep, the solution was more welcomed and happened earlier:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c4baad50297d84bde1a7ad45e50c73adae4a2192

On 03/17/2017 08:09 AM, Greg Kroah-Hartman wrote:
> On Fri, Feb 17, 2017 at 11:42:45PM +0300, Jan Dakinevich wrote:
>> The buffer is used by virtio console driver as DMA buffer. Since v4.9
>> (if VMAP_STACK is enabled) we shouldn't use the stack for DMA.
> 
> You shouldn't use 'static' data either, that's not always guaranteed to
> be DMA-able, right?
> 
>>
>> Signed-off-by: Jan Dakinevich <jan.dakinevich@gmail.com>
>> ---
>>  drivers/tty/hvc/hvc_console.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
>> index 9b5c0fb..1ce6aaf 100644
>> --- a/drivers/tty/hvc/hvc_console.c
>> +++ b/drivers/tty/hvc/hvc_console.c
>> @@ -143,10 +143,15 @@ static struct hvc_struct *hvc_get_by_index(int index)
>>  static void hvc_console_print(struct console *co, const char *b,
>>  			      unsigned count)
>>  {
>> -	char c[N_OUTBUF] __ALIGNED__;
>>  	unsigned i = 0, n = 0;
>>  	int r, donecr = 0, index = co->index;
>>  
>> +	/*
>> +	 * Access to the buffer is serialized by console_sem in caller code from
>> +	 * kernel/printk/printk.c
>> +	 */
>> +	static char c[N_OUTBUF] __ALIGNED__;
> 
> What about allocating it dynamically?  That's the correct thing to do.
> 
> thanks,
> 
> greg k-h
> 

-- 
Best regards
Jan Dakinevich

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

end of thread, other threads:[~2017-03-20 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17 20:42 [PATCH] tty: hvc: don't allocate a buffer for console print on stack Jan Dakinevich
2017-03-17  5:09 ` Greg Kroah-Hartman
2017-03-20 15:55   ` Jan Dakinevich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).