Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/4] serial: imx: Remove unneeded '#ifdef CONFIG_OF'
From: Fabio Estevam @ 2012-06-15 17:23 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kernel, shawn.guo, marex, Fabio Estevam, Greg Kroah-Hartman,
	Alan Cox, linux-serial

CONFIG_OF is always selected for imx SoCs so it is safe
to drop the '#ifdef CONFIG_OF'.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Cox <alan@linux.intel.com>
Cc: <linux-serial@vger.kernel.org>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/tty/serial/imx.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 0af4eec..4bfa95d 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1399,7 +1399,6 @@ static int serial_imx_resume(struct platform_device *dev)
 	return 0;
 }
 
-#ifdef CONFIG_OF
 /*
  * This function returns 1 iff pdev isn't a device instatiated by dt, 0 iff it
  * could successfully get all information from dt or a negative errno.
@@ -1433,13 +1432,6 @@ static int serial_imx_probe_dt(struct imx_port *sport,
 
 	return 0;
 }
-#else
-static inline int serial_imx_probe_dt(struct imx_port *sport,
-		struct platform_device *pdev)
-{
-	return 1;
-}
-#endif
 
 static void serial_imx_probe_pdata(struct imx_port *sport,
 		struct platform_device *pdev)
-- 
1.7.1



^ permalink raw reply related

* Re: [PATCH 1/4] serial: imx: Remove unneeded '#ifdef CONFIG_OF'
From: Fabio Estevam @ 2012-06-15 18:33 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: linux-arm-kernel, marex, linux-serial, Greg Kroah-Hartman, kernel,
	shawn.guo, Alan Cox
In-Reply-To: <1339780987-11063-1-git-send-email-fabio.estevam@freescale.com>

On Fri, Jun 15, 2012 at 2:23 PM, Fabio Estevam
<fabio.estevam@freescale.com> wrote:
> CONFIG_OF is always selected for imx SoCs so it is safe
> to drop the '#ifdef CONFIG_OF'.
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: <linux-serial@vger.kernel.org>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Please discard this series.

^ permalink raw reply

* Re: [PATCH v3 2/2] serial: mxs-auart: Allow device tree probing
From: Shawn Guo @ 2012-06-16  1:59 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Fabio Estevam, marex, snijsure, rob.herring, Grant Likely, kernel,
	linux-serial, matt, linux-arm-kernel, Alan Cox
In-Reply-To: <CAOMZO5BB5G5gvbcqDa2uB3hR-_o7XpcgXR9Ha+Xd7ZLpCqaOVw@mail.gmail.com>

On Fri, Jun 15, 2012 at 01:11:12PM -0300, Fabio Estevam wrote:
> On Fri, Jun 15, 2012 at 1:06 PM, Shawn Guo <shawn.guo@linaro.org> wrote:
> 
> >> +MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);
> > ...
> >> +             .id_table = mxs_auart_devtype,
> >
> > I do not think we need these.
> 
> WIthout this, the non-dt kernel does not probe correctly.

Are you sure about that?  I just tried to removed those and still
saw the following with non-DT boot.

[    0.810000] mxs-auart.0: ttyAPP0 at MMIO 0x8006a000 (irq = 112) is a mxs-auar t.0
[    0.820000] mxs-auart mxs-auart.0: Found APPUART 3.1.0
[    0.830000] mxs-auart.3: ttyAPP3 at MMIO 0x80070000 (irq = 115) is a mxs-auar t.3
[    0.840000] mxs-auart mxs-auart.3: Found APPUART 3.1.0

-- 
Regards,
Shawn

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v3 2/2] serial: mxs-auart: Allow device tree probing
From: Shawn Guo @ 2012-06-16  2:01 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Fabio Estevam, Fabio Estevam, snijsure, rob.herring, Grant Likely,
	kernel, linux-serial, matt, linux-arm-kernel, Alan Cox
In-Reply-To: <201206151900.21740.marex@denx.de>

On Fri, Jun 15, 2012 at 07:00:21PM +0200, Marek Vasut wrote:
> But we don't care if the non-DT case gets broken anyway *. It's unsupported and 
> will be removed.
> 
We have to care about non-DT case before all those non-DT users (board
files) get removed from the tree.

-- 
Regards,
Shawn


^ permalink raw reply

* hey, My name is Winnie:)
From: Winnie Musial @ 2012-06-16  9:59 UTC (permalink / raw)
  To: danceaddict165@yahoo.com

What's up cutie! 
Let's get to know each other. My name is Winnie, there's so much I can tell you;)
I saw ur pictures and I consider u to be pretty.
Really hope to hear from u soon ))

^ permalink raw reply

* [RFC 00/10] fblog: framebuffer kernel log driver
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann

Hi

As some might know I am working on making CONFIG_VT obsolete. But as a developer
it is often useful to have a kernel-log on the screen during boot to debug many
common kernel(-config) errors. However, without CONFIG_VT we cannot use the
VGA/framebbufer consoles either. Therefore, I am working on a small driver
called "fblog".

This driver simply writes the kernel log to all connected framebuffers. It works
similar to fbcon but removes all the complexity of the virtual terminals. There
is a sysfs attribute called "active" that allows to enable/disable fblog so
user-space can start an xserver or similar.

The main purpose is debugging kernel boot problems. Therefore, it is not
optimized for speed and I tried keeping it simple. I splitted the patches
into 10 small chunks to make review easier.

I would be glad if someone could review this and tell me whether this is
something we could include in mainline or not.


There are still some issues but apart from them it works fine on my
machine (x86):
  - I register the fblog device during module_init and need to call
    module_get(). However, this means it is impossible to call "rmmod fblog" as
    fblog has a reference to itself. Using "rmmod -f fblog" works fine but is a
    bit ugly. Is there a nice way to fix this? Otherwise I would need to call
    device_get() in module_exit() if there is a pending user of the fblog-device
    even though I unregistered it.
  - I redraw all framebuffers while holding the console-lock. This may slow down
    machines with more than 2 framebuffers (like 10 or 20). However, as this is
    supposed to be a debug driver, I think I can ignore this? If someone wants
    to improve the redraw logic to avoid redrawing the whole screen all the
    time, I would be glad to include it in this patchset :)
  - I am really no expert regarding the framebuffer subsystem. So I would
    appreciate it if someone could comment whether I need to handle the events
    in a different way or whether it is ok the way it is now.

I run this on my machine with CONFIG_VT=n and it works quite nice. If someone
wants to test it, this also works with CONFIG_VT=y and x11 running. Just load
the driver from your xserver and it will redraw the screen with the console.
Switching VTs back and forth will make the xserver redraw the whole screen
again. You need to remove "depends on !VT" of course.

Thanks and regards
David

David Herrmann (10):
  fblog: new framebuffer kernel log dummy driver
  fblog: implement buffer management
  fblog: register framebuffer objects
  fblog: implement fblog_redraw()
  fblog: add framebuffer helpers
  fblog: allow enabling/disabling fblog on runtime
  fblog: forward kernel log messages to all framebuffers
  fblog: react on framebuffer events
  fblog: register all handlers on module-init
  fblog: add "activate" module parameter

 Documentation/ABI/testing/sysfs-fblog |    9 +
 drivers/video/Kconfig                 |    5 +-
 drivers/video/Makefile                |    2 +-
 drivers/video/console/Kconfig         |   37 +-
 drivers/video/console/Makefile        |    1 +
 drivers/video/console/fblog.c         |  694 +++++++++++++++++++++++++++++++++
 6 files changed, 735 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-fblog
 create mode 100644 drivers/video/console/fblog.c

-- 
1.7.10.4

^ permalink raw reply

* [PATCH 01/10] fblog: new framebuffer kernel log dummy driver
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

Fblog displays all kernel log messages on all connected framebuffers. It
replaces fbcon when CONFIG_VT=n is selected. Its main purpose is to debug
boot problems by displaying the whole boot log on the screen. This patch
provides the first dummy module-init/deinit functions.

As is uses all the font and fb functions I placed it in
drivers/video/console. However, this means that we need to move the check
for CONFIG_VT in Makefile/Kconfig from drivers/video into
drivers/video/console as fblog does not depend on CONFIG_VT.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/Kconfig          |    5 +---
 drivers/video/Makefile         |    2 +-
 drivers/video/console/Kconfig  |   37 +++++++++++++++++++++------
 drivers/video/console/Makefile |    1 +
 drivers/video/console/fblog.c  |   55 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 87 insertions(+), 13 deletions(-)
 create mode 100644 drivers/video/console/fblog.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 0217f74..e8fd53d 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2448,10 +2448,7 @@ source "drivers/video/omap/Kconfig"
 source "drivers/video/omap2/Kconfig"
 source "drivers/video/exynos/Kconfig"
 source "drivers/video/backlight/Kconfig"
-
-if VT
-	source "drivers/video/console/Kconfig"
-endif
+source "drivers/video/console/Kconfig"
 
 if FB || SGI_NEWPORT_CONSOLE
 	source "drivers/video/logo/Kconfig"
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index ee8dafb..9f8a7f0 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -11,7 +11,7 @@ fb-y                              := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
                                      modedb.o fbcvt.o
 fb-objs                           := $(fb-y)
 
-obj-$(CONFIG_VT)		  += console/
+obj-y				  += console/
 obj-$(CONFIG_LOGO)		  += logo/
 obj-y				  += backlight/
 
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index c2d11fe..cfee482 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -6,7 +6,7 @@ menu "Console display driver support"
 
 config VGA_CONSOLE
 	bool "VGA text console" if EXPERT || !X86
-	depends on !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !SUPERH && !BLACKFIN && !AVR32 && !MN10300 && (!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER)
+	depends on VT && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !SUPERH && !BLACKFIN && !AVR32 && !MN10300 && (!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER)
 	default y
 	help
 	  Saying Y here will allow you to use Linux in text mode through a
@@ -45,7 +45,7 @@ config VGACON_SOFT_SCROLLBACK_SIZE
 	 screenfuls of scrollback buffer
 
 config MDA_CONSOLE
-	depends on !M68K && !PARISC && ISA
+	depends on VT && !M68K && !PARISC && ISA
 	tristate "MDA text console (dual-headed) (EXPERIMENTAL)"
 	---help---
 	  Say Y here if you have an old MDA or monochrome Hercules graphics
@@ -61,14 +61,14 @@ config MDA_CONSOLE
 
 config SGI_NEWPORT_CONSOLE
         tristate "SGI Newport Console support"
-        depends on SGI_IP22 
+        depends on VT && SGI_IP22
         help
           Say Y here if you want the console on the Newport aka XL graphics
           card of your Indy.  Most people say Y here.
 
 config DUMMY_CONSOLE
 	bool
-	depends on VGA_CONSOLE!=y || SGI_NEWPORT_CONSOLE!=y 
+	depends on VT && (VGA_CONSOLE!=y || SGI_NEWPORT_CONSOLE!=y)
 	default y
 
 config DUMMY_CONSOLE_COLUMNS
@@ -89,7 +89,7 @@ config DUMMY_CONSOLE_ROWS
 
 config FRAMEBUFFER_CONSOLE
 	tristate "Framebuffer Console support"
-	depends on FB
+	depends on VT && FB
 	select CRC32
 	help
 	  Low-level framebuffer-based console driver.
@@ -122,16 +122,37 @@ config FRAMEBUFFER_CONSOLE_ROTATION
 
 config STI_CONSOLE
         bool "STI text console"
-        depends on PARISC
+        depends on VT && PARISC
         default y
         help
           The STI console is the builtin display/keyboard on HP-PARISC
           machines.  Say Y here to build support for it into your kernel.
           The alternative is to use your primary serial port as a console.
 
+config FBLOG
+	tristate "Framebuffer Kernel Log Driver"
+	depends on !VT && FB
+	default n
+	help
+	  This driver displays all kernel log messages on all connected
+	  framebuffers. It is mutually exclusive with CONFIG_FRAMEBUFFER_CONSOLE
+	  and CONFIG_VT. It was mainly created for debugging purposes when
+	  CONFIG_VT is not selected but you still want kernel boot messages on
+	  the screen.
+
+	  This driver overwrites all other graphics output on the framebuffer as
+	  long as it is active so the kernel log will always be visible. You
+	  need to disable this driver via sysfs to be able to start another
+	  graphics application.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called fblog.
+
 config FONTS
 	bool "Select compiled-in fonts"
-	depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
+	depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE || FBLOG
 	help
 	  Say Y here if you would like to use fonts other than the default
 	  your frame buffer console usually use.
@@ -158,7 +179,7 @@ config FONT_8x8
 
 config FONT_8x16
 	bool "VGA 8x16 font" if FONTS
-	depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE || STI_CONSOLE || USB_SISUSBVGA_CON
+	depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE || STI_CONSOLE || USB_SISUSBVGA_CON || FBLOG
 	default y if !SPARC && !FONTS
 	help
 	  This is the "high resolution" font for the VGA frame buffer (the one
diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
index a862e91..f608c97 100644
--- a/drivers/video/console/Makefile
+++ b/drivers/video/console/Makefile
@@ -20,6 +20,7 @@ font-objs += $(font-objs-y)
 
 # Each configuration option enables a list of files.
 
+obj-$(CONFIG_FBLOG)               += fblog.o font.o
 obj-$(CONFIG_DUMMY_CONSOLE)       += dummycon.o
 obj-$(CONFIG_SGI_NEWPORT_CONSOLE) += newport_con.o font.o
 obj-$(CONFIG_STI_CONSOLE)         += sticon.o sticore.o font.o
diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
new file mode 100644
index 0000000..ea83643
--- /dev/null
+++ b/drivers/video/console/fblog.c
@@ -0,0 +1,55 @@
+/*
+ * Framebuffer Kernel Log Driver
+ * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+/*
+ * Framebuffer Kernel Log
+ * This driver prints the kernel log to all connected display devices. It
+ * replaces CONFIG_VT and cannot run simultaneously with it. It does not provide
+ * any virtual-terminal, though. It should only be used to get kernel boot
+ * messages to debug kernel errors.
+ * Hence, this driver is neither optimized for speed, nor does it provide any
+ * fancy features like colored text output. After booting is done, the init
+ * process should set /sys/class/graphics/fblog/active to 0 which disables this
+ * driver and you can start using the graphics devices. During shutdown, you can
+ * set this to 1 to get log messages again.
+ * This driver forcibly writes to the framebuffer while active, therefore, you
+ * cannot run other graphics applications simultaneously.
+ *
+ * fblog_redraw_line() is heavily based on the fbcon driver. See bitblit.c for
+ * the original implementation copyrighted by:
+ *     Copyright (C) 2004 Antonino Daplas <adaplas@pol.net>
+ *
+ * Please note that nearly all functions here must be called with console_lock
+ * held. This way, we have no locking problems and do not need special
+ * synchronization.
+ */
+
+#include <linux/atomic.h>
+#include <linux/console.h>
+#include <linux/fb.h>
+#include <linux/font.h>
+#include <linux/module.h>
+
+static int __init fblog_init(void)
+{
+	return 0;
+}
+
+static void __exit fblog_exit(void)
+{
+}
+
+module_init(fblog_init);
+module_exit(fblog_exit);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("David Herrmann <dh.herrmann@googlemail.com>");
+MODULE_DESCRIPTION("Framebuffer Kernel Log Driver");
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 02/10] fblog: implement buffer management
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

Each available framebuffer can have a different font and buffer size
inside of fblog. Therefore, we need to remember all the log messages that
are currently printed on screen. We save them as an array of lines which
can be rotated and traversed very fast.

This also implements a very trivial way of resizing the buffer but still
keeping the content. As there is no need to improve this for speed, we can
keep it this way.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/console/fblog.c |  126 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)

diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index ea83643..1504ba9 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -39,6 +39,132 @@
 #include <linux/font.h>
 #include <linux/module.h>
 
+/**
+ * struct fblog_buf: Console text buffer
+ *
+ * Each framebuffer has its own text buffer which contains all characters that
+ * are currently printed on screen. The buffers might have different sizes and
+ * can be resized during runtime. When the buffer content changes, we redraw the
+ * screen.
+ *
+ * width: Width of buffer in characters
+ * height: Height of buffer in characters
+ * lines: Array of lines
+ * pos_x: Cursor x-position
+ * pos_y: Cursor y-position
+ */
+struct fblog_buf {
+	size_t width;
+	size_t height;
+	char **lines;
+	size_t pos_x;
+	size_t pos_y;
+};
+
+static void fblog_buf_resize(struct fblog_buf *buf, size_t width,
+			     size_t height)
+{
+	char **lines = NULL;
+	size_t i, j, minw, minh;
+
+	if (buf->height == height && buf->width == width)
+		return;
+
+	if (width && height) {
+		lines = kzalloc(height * sizeof(char*), GFP_KERNEL);
+		if (!lines)
+			return;
+
+		for (i = 0; i < height; ++i) {
+			lines[i] = kzalloc(width * sizeof(char), GFP_KERNEL);
+			if (!lines[i]) {
+				while (i--)
+					kfree(lines[i]);
+				return;
+			}
+		}
+
+		/* copy old lines */
+		minw = min(width, buf->width);
+		minh = min(height, buf->height);
+		if (height >= buf->height)
+			i = 0;
+		else
+			i = buf->height - height;
+
+		for (j = 0; j < minh; ++i, ++j)
+			memcpy(lines[j], buf->lines[i], minw * sizeof(char));
+	} else {
+		width = 0;
+		height = 0;
+	}
+
+	for (i = 0; i < buf->height; ++i)
+		kfree(buf->lines[i]);
+	kfree(buf->lines);
+
+	buf->lines = lines;
+	buf->width = width;
+	buf->height = height;
+}
+
+static void fblog_buf_init(struct fblog_buf *buf)
+{
+	fblog_buf_resize(buf, 80, 24);
+}
+
+static void fblog_buf_deinit(struct fblog_buf *buf)
+{
+	fblog_buf_resize(buf, 0, 0);
+}
+
+static void fblog_buf_rotate(struct fblog_buf *buf)
+{
+	char *line;
+
+	if (!buf->height)
+		return;
+
+	line = buf->lines[0];
+	memset(line, 0, sizeof(char) * buf->width);
+
+	memmove(buf->lines, &buf->lines[1], sizeof(char*) * (buf->height - 1));
+	buf->lines[buf->height - 1] = line;
+}
+
+static void fblog_buf_write(struct fblog_buf *buf, const char *str, size_t len)
+{
+	char c;
+
+	if (!buf->height)
+		return;
+
+	while (len--) {
+		c = *str++;
+
+		if (c == '\n') {
+			buf->pos_x = 0;
+			if (++buf->pos_y >= buf->height) {
+				buf->pos_y = buf->height - 1;
+				fblog_buf_rotate(buf);
+			}
+		} else if (c == 0) {
+			/* ignore */
+		} else {
+			if (buf->pos_x >= buf->width) {
+				buf->pos_x = 0;
+				++buf->pos_y;
+			}
+			if (buf->pos_y >= buf->height) {
+				buf->pos_y = buf->height - 1;
+				fblog_buf_rotate(buf);
+			}
+
+			buf->lines[buf->pos_y][buf->pos_x++] = c;
+		}
+	}
+}
+
 static int __init fblog_init(void)
 {
 	return 0;
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 03/10] fblog: register framebuffer objects
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

We register each available framebuffer in the system with the fblog driver
so we always know all active devices. We directly open the fb-driver,
initialize the buffer and load a font so we are ready for drawing
operations. If a device cannot be opened, we mark it as dead and ignore it
in all other functions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/console/fblog.c |  108 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)

diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index 1504ba9..8038dcc 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -39,6 +39,14 @@
 #include <linux/font.h>
 #include <linux/module.h>
 
+#define FBLOG_STR(x) x, sizeof(x) - 1
+
+enum fblog_flags {
+	FBLOG_KILLED,
+	FBLOG_SUSPENDED,
+	FBLOG_BLANKED,
+};
+
 /**
  * struct fblog_buf: Console text buffer
  *
@@ -61,6 +69,30 @@ struct fblog_buf {
 	size_t pos_y;
 };
 
+/**
+ * struct fblog_fb: Framebuffer object
+ *
+ * For each framebuffer we register this object. It contains all data we need to
+ * display the console log on it. The index of a framebuffer in registered_fb[]
+ * is the same as in fblog_fbs[]. So the following must always be true if the
+ * pointers are non-NULL:
+ *     registered_fb[idx] == fblog_fbs[idx]->info
+ *     fblog_fbs[idx]->info->node == idx
+ *
+ * flags: Framebuffer flags (see fblog_flags)
+ * info: Pointer to the associated framebuffer device
+ * font: Currently used font
+ * buf: Console text buffer
+ */
+struct fblog_fb {
+	unsigned long flags;
+	struct fb_info *info;
+	const struct font_desc *font;
+	struct fblog_buf buf;
+};
+
+static struct fblog_fb *fblog_fbs[FB_MAX];
+
 static void fblog_buf_resize(struct fblog_buf *buf, size_t width,
 			     size_t height)
 {
@@ -165,6 +197,82 @@ static void fblog_buf_write(struct fblog_buf *buf, const char *str, size_t len)
 	}
 }
 
+static struct fblog_fb *fblog_info2fb(struct fb_info *info)
+{
+	if (!info || info->node < 0 || info->node >= FB_MAX ||
+	    !registered_fb[info->node])
+		return NULL;
+
+	return fblog_fbs[info->node];
+}
+
+static void fblog_register(struct fb_info *info)
+{
+	struct fblog_fb *fb;
+	struct fb_var_screeninfo var;
+	const struct fb_videomode *mode;
+	unsigned int width, height;
+
+	if (!info || info->node < 0 || info->node >= FB_MAX)
+		return;
+	if (!registered_fb[info->node] || fblog_fbs[info->node])
+		return;
+
+	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+	if (!fb)
+		return;
+
+	fblog_fbs[info->node] = fb;
+	fb->info = info;
+	fblog_buf_init(&fb->buf);
+	fblog_buf_write(&fb->buf, FBLOG_STR("Framebuffer log initialized\n"));
+
+	if (!try_module_get(info->fbops->owner))
+		goto out_killed;
+	if (info->fbops->fb_open && info->fbops->fb_open(info, 0))
+		goto out_unref;
+
+	var = info->var;
+	mode = fb_find_best_mode(&var, &info->modelist);
+	var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
+	fb_set_var(info, &var);
+
+	fb->font = get_default_font(info->var.xres, info->var.yres,
+				    info->pixmap.blit_x,
+				    info->pixmap.blit_y);
+	if (fb->font) {
+		width = info->var.xres / fb->font->width;
+		height = info->var.yres / fb->font->height;
+		fblog_buf_resize(&fb->buf, width, height);
+	}
+
+	return;
+
+out_unref:
+	module_put(info->fbops->owner);
+out_killed:
+	set_bit(FBLOG_KILLED, &fb->flags);
+}
+
+static void fblog_unregister(struct fblog_fb *fb)
+{
+	struct fb_info *info;
+
+	if (!fb)
+		return;
+
+	info = fb->info;
+	if (!test_bit(FBLOG_KILLED, &fb->flags)) {
+		if (info->fbops->fb_release)
+			info->fbops->fb_release(info, 0);
+		module_put(info->fbops->owner);
+	}
+
+	fblog_buf_deinit(&fb->buf);
+	fblog_fbs[info->node] = NULL;
+	kfree(fb);
+}
+
 static int __init fblog_init(void)
 {
 	return 0;
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 04/10] fblog: implement fblog_redraw()
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

This mostly copies the functionality from drivers/video/console/bitblit.c
so we can draw the console content on all available framebuffers.

All speed optimizations have been removed for simplicity. The original
code depends heavily on CONFIG_VT so we cannot share the codebase here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/console/fblog.c |  126 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)

diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index 8038dcc..e790971 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -197,6 +197,131 @@ static void fblog_buf_write(struct fblog_buf *buf, const char *str, size_t len)
 	}
 }
 
+static void fblog_redraw_aligned(struct fblog_fb *fb, const char *s, u32 cnt,
+				 u32 d_pitch, u32 s_pitch, u32 cellsize,
+				 struct fb_image *image, u8 *dst)
+{
+	struct fb_info *info = fb->info;
+	const struct font_desc *font = fb->font;
+	u32 idx = font->width >> 3;
+	u8 *src;
+
+	while (cnt--) {
+		src = (void*)(font->data + (*s++ & 0xff) * cellsize);
+		fb_pad_aligned_buffer(dst, d_pitch, src, idx, image->height);
+		dst += s_pitch;
+	}
+
+	info->fbops->fb_imageblit(info, image);
+}
+
+static void fblog_redraw_unaligned(struct fblog_fb *fb, const char *s, u32 cnt,
+				   u32 d_pitch, u32 s_pitch, u32 cellsize,
+				   struct fb_image *image, u8 *dst)
+{
+	struct fb_info *info = fb->info;
+	const struct font_desc *font = fb->font;
+	u32 shift_low = 0, mod = font->width % 8;
+	u32 shift_high = 8;
+	u32 idx = font->width >> 3;
+	u8 *src;
+
+	while (cnt--) {
+		src = (void*)(font->data + (*s++ & 0xff) * cellsize);
+		fb_pad_unaligned_buffer(dst, d_pitch, src, idx,
+					image->height, shift_high,
+					shift_low, mod);
+		shift_low += mod;
+		dst += (shift_low >= 8) ? s_pitch : s_pitch - 1;
+		shift_low &= 7;
+		shift_high = 8 - shift_low;
+	}
+
+	info->fbops->fb_imageblit(info, image);
+}
+
+static void fblog_redraw_line(struct fblog_fb *fb, size_t line,
+			      const char *str, size_t len)
+{
+	struct fb_info *info = fb->info;
+	const struct font_desc *font = fb->font;
+	struct fb_image image;
+	u32 width = DIV_ROUND_UP(font->width, 8);
+	u32 cellsize = width * font->height;
+	u32 maxcnt = info->pixmap.size / cellsize;
+	u32 scan_align = info->pixmap.scan_align - 1;
+	u32 buf_align = info->pixmap.buf_align - 1;
+	u32 mod = font->width % 8;
+	u32 cnt, pitch, size;
+	u8 *dst;
+
+	image.fg_color = 7;
+	image.bg_color = 0;
+	image.dx = 0;
+	image.dy = line * font->height;
+	image.height = font->height;
+	image.depth = 1;
+
+	while (len) {
+		if (len > maxcnt)
+			cnt = maxcnt;
+		else
+			cnt = len;
+
+		image.width = font->width * cnt;
+		pitch = DIV_ROUND_UP(image.width, 8) + scan_align;
+		pitch &= ~scan_align;
+		size = pitch * image.height + buf_align;
+		size &= ~buf_align;
+		dst = fb_get_buffer_offset(info, &info->pixmap, size);
+		image.data = dst;
+
+		if (!mod)
+			fblog_redraw_aligned(fb, str, cnt, pitch, width,
+					     cellsize, &image, dst);
+		else
+			fblog_redraw_unaligned(fb, str, cnt, pitch, width,
+					       cellsize, &image, dst);
+
+		image.dx += cnt * font->width;
+		len -= cnt;
+		str += cnt;
+	}
+}
+
+static void fblog_redraw_clear(struct fblog_fb *fb)
+{
+	struct fb_fillrect region;
+	struct fb_info *info = fb->info;
+
+	region.color = 0;
+	region.dx = 0;
+	region.dy = 0;
+	region.width = info->var.xres;
+	region.height = info->var.yres;
+	region.rop = ROP_COPY;
+
+	info->fbops->fb_fillrect(info, &region);
+}
+
+static void fblog_redraw(struct fblog_fb *fb)
+{
+	size_t i, len;
+
+	if (!fb || !fb->font || test_bit(FBLOG_KILLED, &fb->flags) ||
+	    test_bit(FBLOG_SUSPENDED, &fb->flags) ||
+	    test_bit(FBLOG_BLANKED, &fb->flags))
+		return;
+
+	fblog_redraw_clear(fb);
+
+	for (i = 0; i < fb->buf.height; ++i) {
+		len = strnlen(fb->buf.lines[i], fb->buf.width);
+		if (len)
+			fblog_redraw_line(fb, i, fb->buf.lines[i], len);
+	}
+}
+
 static struct fblog_fb *fblog_info2fb(struct fb_info *info)
 {
 	if (!info || info->node < 0 || info->node >= FB_MAX ||
@@ -244,6 +369,7 @@ static void fblog_register(struct fb_info *info)
 		width = info->var.xres / fb->font->width;
 		height = info->var.yres / fb->font->height;
 		fblog_buf_resize(&fb->buf, width, height);
+		fblog_redraw(fb);
 	}
 
 	return;
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 05/10] fblog: add framebuffer helpers
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

These helpers scan the system for all available framebuffers and register
or unregister them. This is needed during startup and stopping fblog so we
are aware of all connected displays.

The third helper handles mode changes by rescanning the mode and adjusting
the buffer size.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/console/fblog.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index e790971..7d4032e 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -399,6 +399,35 @@ static void fblog_unregister(struct fblog_fb *fb)
 	kfree(fb);
 }
 
+static void fblog_register_all(void)
+{
+	int i;
+
+	for (i = 0; i < FB_MAX; ++i)
+		fblog_register(registered_fb[i]);
+}
+
+static void fblog_unregister_all(void)
+{
+	int i;
+
+	for (i = 0; i < FB_MAX; ++i)
+		fblog_unregister(fblog_info2fb(registered_fb[i]));
+}
+
+static void fblog_refresh(struct fblog_fb *fb)
+{
+	unsigned int width, height;
+
+	if (!fb || !fb->font)
+		return;
+
+	width = fb->info->var.xres / fb->font->width;
+	height = fb->info->var.yres / fb->font->height;
+	fblog_buf_resize(&fb->buf, width, height);
+	fblog_redraw(fb);
+}
+
 static int __init fblog_init(void)
 {
 	return 0;
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 06/10] fblog: allow enabling/disabling fblog on runtime
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

A sysfs file called "active" can be used to enable and disable fblog on
runtime. For example, the init-process can run "echo '0' >.../active"
after booting the system. This will allow other applications like X11 to
use the graphics subsystem. During shutdown, we can write '1' to get
system messages again.

When disabling fblog, we remove all framebuffers and will prevent new
hotplugged framebuffers from being added. When enabling fblog again, we
rescan the system for all framebuffers and resume operating.

The sysfs file is not registered, yet, as we do not have a "struct device"
yet. This will follow shortly, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 Documentation/ABI/testing/sysfs-fblog |    9 ++++++
 drivers/video/console/fblog.c         |   49 +++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-fblog

diff --git a/Documentation/ABI/testing/sysfs-fblog b/Documentation/ABI/testing/sysfs-fblog
new file mode 100644
index 0000000..596393c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-fblog
@@ -0,0 +1,9 @@
+What:		/sys/class/graphics/fblog/active
+Date:		June 2012
+KernelVersion:	3.6
+Contact:	David Herrmann <dh.herrmann@googlemail.com>
+Description:	Enable/Disable fblog. When setting this to 0, fblog will stop
+		writing to framebuffers and other applications can use the
+		graphics subsystem. When setting this to 1, fblog will rescan
+		the system for all framebuffers and resume drawing the kernel
+		log onto all framebuffers.
diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index 7d4032e..9b05c56 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -92,6 +92,7 @@ struct fblog_fb {
 };
 
 static struct fblog_fb *fblog_fbs[FB_MAX];
+static atomic_t fblog_active;
 
 static void fblog_buf_resize(struct fblog_buf *buf, size_t width,
 			     size_t height)
@@ -338,6 +339,8 @@ static void fblog_register(struct fb_info *info)
 	const struct fb_videomode *mode;
 	unsigned int width, height;
 
+	if (!atomic_read(&fblog_active))
+		return;
 	if (!info || info->node < 0 || info->node >= FB_MAX)
 		return;
 	if (!registered_fb[info->node] || fblog_fbs[info->node])
@@ -428,6 +431,52 @@ static void fblog_refresh(struct fblog_fb *fb)
 	fblog_redraw(fb);
 }
 
+static void fblog_activate(void)
+{
+	if (atomic_read(&fblog_active))
+		return;
+
+	atomic_set(&fblog_active, 1);
+	fblog_register_all();
+}
+
+static void fblog_deactivate(void)
+{
+	if (!atomic_read(&fblog_active))
+		return;
+
+	atomic_set(&fblog_active, 0);
+	fblog_unregister_all();
+}
+
+static ssize_t fblog_dev_active_show(struct device *dev,
+				     struct device_attribute *attr,
+				     char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&fblog_active));
+}
+
+static ssize_t fblog_dev_active_store(struct device *dev,
+				      struct device_attribute *attr,
+				      const char *buf,
+				      size_t count)
+{
+	unsigned long num;
+
+	num = simple_strtoul(buf, NULL, 10);
+	console_lock();
+	if (num)
+		fblog_activate();
+	else
+		fblog_deactivate();
+	console_unlock();
+
+	return count;
+}
+
+static DEVICE_ATTR(active, S_IRUGO | S_IWUSR | S_IWGRP, fblog_dev_active_show,
+		   fblog_dev_active_store);
+
 static int __init fblog_init(void)
 {
 	return 0;
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 07/10] fblog: forward kernel log messages to all framebuffers
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

This provides a console-driver that forwards all log messages to all
framebuffers and redraws them.

To avoid redrawing multiple times in short intervals, we could use a
work-queue here by simply pushing the task onto the system work-queue.
However, fblog is not performance critical and only used for debugging so
we avoid the complexity for now. This may change in the future, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/console/fblog.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index 9b05c56..5297eca 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -449,6 +449,25 @@ static void fblog_deactivate(void)
 	fblog_unregister_all();
 }
 
+static void fblog_con_write(struct console *con, const char *buf,
+			    unsigned int len)
+{
+	int i;
+
+	for (i = 0; i < FB_MAX; ++i) {
+		if (fblog_fbs[i]) {
+			fblog_buf_write(&fblog_fbs[i]->buf, buf, len);
+			fblog_redraw(fblog_fbs[i]);
+		}
+	}
+}
+
+static struct console fblog_con_driver = {
+	.name = "fblog",
+	.write = fblog_con_write,
+	.flags = CON_PRINTBUFFER | CON_ENABLED,
+};
+
 static ssize_t fblog_dev_active_show(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf)
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 08/10] fblog: react on framebuffer events
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

This provides an fb-notifier object that can be registered with the
framebuffer subsystem. We are then notified about events on all
framebuffers.
Most of the events are only of interest for fbcon so we can safely ignore
them. However, we need to handle REGISTERED/UNBIND to add new framebbufers
and we need to react on mode-changes (probably triggered by user-space).

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/console/fblog.c |  113 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 113 insertions(+)

diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index 5297eca..79bfbcc 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -449,6 +449,119 @@ static void fblog_deactivate(void)
 	fblog_unregister_all();
 }
 
+static int fblog_event(struct notifier_block *self, unsigned long action,
+		       void *data)
+{
+	struct fb_event *event = data;
+	struct fb_info *info = event->info;
+	struct fblog_fb *fb = fblog_info2fb(info);
+	int *blank;
+
+	if (action == FB_EVENT_FB_REGISTERED) {
+		/* This is called when a low-level system driver registers a new
+		 * framebuffer. The registration lock is held but the console
+		 * lock might not be held when this is called (really?). */
+		fblog_register(info);
+		return 0;
+	}
+
+	if (!fb)
+		return 0;
+
+	switch(action) {
+	case FB_EVENT_FB_UNREGISTERED:
+		/* This is called when a low-level system driver unregisters a
+		 * framebuffer. The registration lock is held but the console
+		 * lock might not be held (really?). */
+		/* ignore; see UNBIND */
+		break;
+	case FB_EVENT_FB_UNBIND:
+		/* Called directly before unregistering an FB. The FB is still
+		 * valid here and the registration lock is held but the console
+		 * lock might not be held (really?). */
+		fblog_unregister(fb);
+		break;
+	case FB_EVENT_SUSPEND:
+		/* This is called when the low-level display driver suspends the
+		 * video system. We should not access the video system while it
+		 * is suspended. This is called with the console lock held. */
+		set_bit(FBLOG_SUSPENDED, &fb->flags);
+		break;
+	case FB_EVENT_RESUME:
+		/* This is called when the low-level display driver resumes
+		 * operating. It is called with the console lock held. */
+		clear_bit(FBLOG_SUSPENDED, &fb->flags);
+		break;
+	case FB_EVENT_MODE_DELETE:
+		/* This is sent when a video mode is removed. The current video
+		 * mode is never removed! The console lock is held while this is
+		 * called. */
+		/* fallthrough */
+	case FB_EVENT_NEW_MODELIST:
+		/* This is sent when the modelist got changed. The console-lock
+		 * is held and we should reset the mode. */
+		/* fallthrough */
+	case FB_EVENT_MODE_CHANGE_ALL:
+		/* This is the same as below but notifies us that the user used
+		 * the FB_ACTIVATE_ALL flag when setting the video mode. */
+		/* fallthrough */
+	case FB_EVENT_MODE_CHANGE:
+		/* This is called when the _user_ changes the video mode via
+		 * ioctls. It is not sent, when the kernel changes the mode
+		 * internally. This callback is called inside fb_set_var() so
+		 * the console lock is held. */
+		fblog_refresh(fb);
+		break;
+	case FB_EVENT_BLANK:
+		/* This gets called _after_ the framebuffer was successfully
+		 * blanked. The console-lock is always held while fb_blank is
+		 * called and during this callback. */
+		blank = (int*)event->data;
+		if (*blank == FB_BLANK_UNBLANK)
+			clear_bit(FBLOG_BLANKED, &fb->flags);
+		else
+			set_bit(FBLOG_BLANKED, &fb->flags);
+		break;
+	case FB_EVENT_GET_REQ:
+		/* When fb_set_var() is called, this callback is called to get
+		 * our display requirements. They are then compared with the
+		 * display properties and only if they fulfill the requirements,
+		 * the new mode is activated. The console-lock should be held
+		 * while calling fb_set_var() so we can assume it is locked
+		 * here. */
+		/* ignore */
+		break;
+	case FB_EVENT_CONBLANK:
+		/* This is sent by fbcon when doing a fake blank. That
+		 * is, blanking the screen when the fb driver failed to perform
+		 * an fb_blank(). It simply writes empty lines to the screen.
+		 * We are not interested in this signal. We should also never
+		 * run together with fbcon so this should never be catched. */
+		/* ignore */
+		break;
+	case FB_EVENT_GET_CONSOLE_MAP:
+		/* fallthrough */
+	case FB_EVENT_SET_CONSOLE_MAP:
+		/* Is there any reason why we should support this? We
+		 * ignore it as we consider ourself not to be the classic linux
+		 * console. Hence, this request is not targeted at us. */
+		/* ignore */
+		break;
+	case FB_EVENT_REMAP_ALL_CONSOLE:
+		/* What are we supposed to do here? Do we have to remap
+		 * the primary device to the framebuffer given by \info? Like
+		 * above we currently ignore it for the same reasons. */
+		/* ignore */
+		break;
+	}
+
+	return 0;
+}
+
+static struct notifier_block fblog_notifier = {
+	.notifier_call = fblog_event,
+};
+
 static void fblog_con_write(struct console *con, const char *buf,
 			    unsigned int len)
 {
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 09/10] fblog: register all handlers on module-init
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

We now create a new "fblog" device when initializing the fblog module. We
register the "active" sysfs-file with it so user-space can now access
fblog. We also register the framebuffer-notifier and console-handler so
fblog is ready to go.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/console/fblog.c |   59 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index 79bfbcc..9d3b072 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -92,6 +92,7 @@ struct fblog_fb {
 };
 
 static struct fblog_fb *fblog_fbs[FB_MAX];
+static struct device *fblog_device;
 static atomic_t fblog_active;
 
 static void fblog_buf_resize(struct fblog_buf *buf, size_t width,
@@ -609,13 +610,71 @@ static ssize_t fblog_dev_active_store(struct device *dev,
 static DEVICE_ATTR(active, S_IRUGO | S_IWUSR | S_IWGRP, fblog_dev_active_show,
 		   fblog_dev_active_store);
 
+static void fblog_dev_release(struct device *dev)
+{
+	kfree(dev);
+	module_put(THIS_MODULE);
+}
+
 static int __init fblog_init(void)
 {
+	int ret;
+
+	fblog_device = kzalloc(sizeof(*fblog_device), GFP_KERNEL);
+	if (!fblog_device) {
+		pr_err("fblog: cannot allocate device\n");
+		ret = -ENOMEM;
+		goto err_out;
+	}
+
+	__module_get(THIS_MODULE);
+	device_initialize(fblog_device);
+	fblog_device->class = fb_class;
+	fblog_device->release = fblog_dev_release;
+	dev_set_name(fblog_device, "fblog");
+
+	ret = device_add(fblog_device);
+	if (ret) {
+		pr_err("fblog: cannot add device\n");
+		goto err_dev;
+	}
+
+	ret = fb_register_client(&fblog_notifier);
+	if (ret) {
+		pr_err("fblog: cannot register framebuffer notifier\n");
+		goto err_dev_rm;
+	}
+
+	ret = device_create_file(fblog_device, &dev_attr_active);
+	if (ret) {
+		pr_err("fblog: cannot create sysfs entry\n");
+		goto err_fb;
+	}
+
+	register_console(&fblog_con_driver);
+
 	return 0;
+
+err_fb:
+	fb_unregister_client(&fblog_notifier);
+err_dev_rm:
+	device_del(fblog_device);
+err_dev:
+	put_device(fblog_device);
+err_out:
+	return ret;
 }
 
 static void __exit fblog_exit(void)
 {
+	unregister_console(&fblog_con_driver);
+	device_remove_file(fblog_device, &dev_attr_active);
+	device_del(fblog_device);
+	fb_unregister_client(&fblog_notifier);
+	console_lock();
+	fblog_deactivate();
+	console_unlock();
+	put_device(fblog_device);
 }
 
 module_init(fblog_init);
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 10/10] fblog: add "activate" module parameter
From: David Herrmann @ 2012-06-16 22:04 UTC (permalink / raw)
  To: linux-serial
  Cc: Florian Tobias Schandinat, linux-fbdev, linux-kernel,
	Greg Kroah-Hartman, David Herrmann
In-Reply-To: <1339884266-9201-1-git-send-email-dh.herrmann@googlemail.com>

This new parameter controls whether fblog is automatically activated when
it is loaded. This defaults to "true".

We can now compile with CONFIG_VT=n and CONFIG_FBLOG=y and control fblog
with fblog.activate=0/1 on the kernel command line to enable/disable
debugging.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/video/console/fblog.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
index 9d3b072..cabc550 100644
--- a/drivers/video/console/fblog.c
+++ b/drivers/video/console/fblog.c
@@ -94,6 +94,7 @@ struct fblog_fb {
 static struct fblog_fb *fblog_fbs[FB_MAX];
 static struct device *fblog_device;
 static atomic_t fblog_active;
+static bool activate = 1;
 
 static void fblog_buf_resize(struct fblog_buf *buf, size_t width,
 			     size_t height)
@@ -653,6 +654,12 @@ static int __init fblog_init(void)
 
 	register_console(&fblog_con_driver);
 
+	if (activate) {
+		console_lock();
+		fblog_activate();
+		console_unlock();
+	}
+
 	return 0;
 
 err_fb:
@@ -677,6 +684,9 @@ static void __exit fblog_exit(void)
 	put_device(fblog_device);
 }
 
+module_param(activate, bool, S_IRUGO);
+MODULE_PARM_DESC(activate, "Activate fblog by default");
+
 module_init(fblog_init);
 module_exit(fblog_exit);
 MODULE_LICENSE("GPL");
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH 04/10] fblog: implement fblog_redraw()
From: Alan Cox @ 2012-06-16 22:35 UTC (permalink / raw)
  To: David Herrmann
  Cc: linux-serial, Florian Tobias Schandinat, linux-fbdev,
	linux-kernel, Greg Kroah-Hartman
In-Reply-To: <1339884266-9201-5-git-send-email-dh.herrmann@googlemail.com>

On Sun, 17 Jun 2012 00:04:20 +0200
David Herrmann <dh.herrmann@googlemail.com> wrote:

> This mostly copies the functionality from drivers/video/console/bitblit.c
> so we can draw the console content on all available framebuffers.
> 
> All speed optimizations have been removed for simplicity. The original
> code depends heavily on CONFIG_VT so we cannot share the codebase here.

No. That means we've got two sets of code to maintain not one. Fix the
dependancy.

Pull the relevant subset of struct vc_data into another struct
Make struct vc_data be

struct vc_data {
	struct vc_whatever
	rest
}

Alan

^ permalink raw reply

* Re: [PATCH 05/10] fblog: add framebuffer helpers
From: Bruno Prémont @ 2012-06-16 22:33 UTC (permalink / raw)
  To: David Herrmann
  Cc: linux-serial, Florian Tobias Schandinat, linux-fbdev,
	linux-kernel, Greg Kroah-Hartman
In-Reply-To: <1339884266-9201-6-git-send-email-dh.herrmann@googlemail.com>

On Sun, 17 June 2012 David Herrmann <dh.herrmann@googlemail.com> wrote:
> These helpers scan the system for all available framebuffers and register
> or unregister them. This is needed during startup and stopping fblog so we
> are aware of all connected displays.
> 
> The third helper handles mode changes by rescanning the mode and adjusting
> the buffer size.
> 
> Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
> ---
>  drivers/video/console/fblog.c |   29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
> index e790971..7d4032e 100644
> --- a/drivers/video/console/fblog.c
> +++ b/drivers/video/console/fblog.c
> @@ -399,6 +399,35 @@ static void fblog_unregister(struct fblog_fb *fb)
>  	kfree(fb);
>  }
>  
> +static void fblog_register_all(void)
> +{
> +	int i;
> +
> +	for (i = 0; i < FB_MAX; ++i)
> +		fblog_register(registered_fb[i]);

You should take registration_lock mutex for accessing registered_fb[],
even better would be to make use of get_fb_info() and put_fb_info()

> +}
> +
> +static void fblog_unregister_all(void)
> +{
> +	int i;
> +
> +	for (i = 0; i < FB_MAX; ++i)
> +		fblog_unregister(fblog_info2fb(registered_fb[i]));

Same here.

Though for unregistering I'm wondering why you still scan through
registered_fb[], you should just scan your fblog_fbs[] array!

But here again, make sure to have proper locking to not get races with
registration of new framebuffers or removal of existing ones via
notifications.

> +}
> +
> +static void fblog_refresh(struct fblog_fb *fb)
> +{
> +	unsigned int width, height;
> +
> +	if (!fb || !fb->font)
> +		return;
> +
> +	width = fb->info->var.xres / fb->font->width;
> +	height = fb->info->var.yres / fb->font->height;
> +	fblog_buf_resize(&fb->buf, width, height);
> +	fblog_redraw(fb);
> +}
> +

All these new functions are still unused, for easier following of your
patch series it would be nice to have them connected when they are
introduced as otherwise on has to search all following patches for
finding possible users.

>  static int __init fblog_init(void)
>  {
>  	return 0;

Bruno

^ permalink raw reply

* [PATCH 2/2] serial/amba-pl011: fix ages old copy-paste errors
From: Linus Walleij @ 2012-06-17 13:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-serial; +Cc: linux-arm-kernel, Linus Walleij

From: Linus Walleij <linus.walleij@linaro.org>

The PL011 driver has a number of symbols referring to "pl01x"
(probably once shared with the pl010 driver) and some even named
"pl010" (probably a pure copy-paste artifact). Lets name all
local static functions with the prefix pl011_* for clarity.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/tty/serial/amba-pl011.c |   34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 3ce984f..5aa080a 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1215,14 +1215,14 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
 	return IRQ_RETVAL(handled);
 }
 
-static unsigned int pl01x_tx_empty(struct uart_port *port)
+static unsigned int pl011_tx_empty(struct uart_port *port)
 {
 	struct uart_amba_port *uap = (struct uart_amba_port *)port;
 	unsigned int status = readw(uap->port.membase + UART01x_FR);
 	return status & (UART01x_FR_BUSY|UART01x_FR_TXFF) ? 0 : TIOCSER_TEMT;
 }
 
-static unsigned int pl01x_get_mctrl(struct uart_port *port)
+static unsigned int pl011_get_mctrl(struct uart_port *port)
 {
 	struct uart_amba_port *uap = (struct uart_amba_port *)port;
 	unsigned int result = 0;
@@ -1285,7 +1285,7 @@ static void pl011_break_ctl(struct uart_port *port, int break_state)
 }
 
 #ifdef CONFIG_CONSOLE_POLL
-static int pl010_get_poll_char(struct uart_port *port)
+static int pl011_get_poll_char(struct uart_port *port)
 {
 	struct uart_amba_port *uap = (struct uart_amba_port *)port;
 	unsigned int status;
@@ -1297,7 +1297,7 @@ static int pl010_get_poll_char(struct uart_port *port)
 	return readw(uap->port.membase + UART01x_DR);
 }
 
-static void pl010_put_poll_char(struct uart_port *port,
+static void pl011_put_poll_char(struct uart_port *port,
 			 unsigned char ch)
 {
 	struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@ -1637,7 +1637,7 @@ static const char *pl011_type(struct uart_port *port)
 /*
  * Release the memory region(s) being used by 'port'
  */
-static void pl010_release_port(struct uart_port *port)
+static void pl011_release_port(struct uart_port *port)
 {
 	release_mem_region(port->mapbase, SZ_4K);
 }
@@ -1645,7 +1645,7 @@ static void pl010_release_port(struct uart_port *port)
 /*
  * Request the memory region(s) being used by 'port'
  */
-static int pl010_request_port(struct uart_port *port)
+static int pl011_request_port(struct uart_port *port)
 {
 	return request_mem_region(port->mapbase, SZ_4K, "uart-pl011")
 			!= NULL ? 0 : -EBUSY;
@@ -1654,18 +1654,18 @@ static int pl010_request_port(struct uart_port *port)
 /*
  * Configure/autoconfigure the port.
  */
-static void pl010_config_port(struct uart_port *port, int flags)
+static void pl011_config_port(struct uart_port *port, int flags)
 {
 	if (flags & UART_CONFIG_TYPE) {
 		port->type = PORT_AMBA;
-		pl010_request_port(port);
+		pl011_request_port(port);
 	}
 }
 
 /*
  * verify the new serial_struct (for TIOCSSERIAL).
  */
-static int pl010_verify_port(struct uart_port *port, struct serial_struct *ser)
+static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
 	int ret = 0;
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
@@ -1678,9 +1678,9 @@ static int pl010_verify_port(struct uart_port *port, struct serial_struct *ser)
 }
 
 static struct uart_ops amba_pl011_pops = {
-	.tx_empty	= pl01x_tx_empty,
+	.tx_empty	= pl011_tx_empty,
 	.set_mctrl	= pl011_set_mctrl,
-	.get_mctrl	= pl01x_get_mctrl,
+	.get_mctrl	= pl011_get_mctrl,
 	.stop_tx	= pl011_stop_tx,
 	.start_tx	= pl011_start_tx,
 	.stop_rx	= pl011_stop_rx,
@@ -1691,13 +1691,13 @@ static struct uart_ops amba_pl011_pops = {
 	.flush_buffer	= pl011_dma_flush_buffer,
 	.set_termios	= pl011_set_termios,
 	.type		= pl011_type,
-	.release_port	= pl010_release_port,
-	.request_port	= pl010_request_port,
-	.config_port	= pl010_config_port,
-	.verify_port	= pl010_verify_port,
+	.release_port	= pl011_release_port,
+	.request_port	= pl011_request_port,
+	.config_port	= pl011_config_port,
+	.verify_port	= pl011_verify_port,
 #ifdef CONFIG_CONSOLE_POLL
-	.poll_get_char = pl010_get_poll_char,
-	.poll_put_char = pl010_put_poll_char,
+	.poll_get_char = pl011_get_poll_char,
+	.poll_put_char = pl011_put_poll_char,
 #endif
 };
 
-- 
1.7.9.2


^ permalink raw reply related

* [PATCH 1/2] serial/amba-pl011: use devm_* allocators
From: Linus Walleij @ 2012-06-17 13:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-serial; +Cc: linux-arm-kernel, Linus Walleij

From: Linus Walleij <linus.walleij@linaro.org>

This switches a bunch of allocation and remapping to use the
devm_* garbage collected methods and cleans up the error
path and remove() paths consequently.

devm_ioremap() is only in <linux/io.h> so fix up the
erroneous <asm/*> include as well.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/tty/serial/amba-pl011.c |   20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index c17923e..3ce984f 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -53,8 +53,8 @@
 #include <linux/delay.h>
 #include <linux/types.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/io.h>
 
-#include <asm/io.h>
 #include <asm/sizes.h>
 
 #define UART_NR			14
@@ -1885,22 +1885,24 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
 		goto out;
 	}
 
-	uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
+	uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
+			   GFP_KERNEL);
 	if (uap == NULL) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
-	base = ioremap(dev->res.start, resource_size(&dev->res));
+	base = devm_ioremap(&dev->dev, dev->res.start,
+			    resource_size(&dev->res));
 	if (!base) {
 		ret = -ENOMEM;
-		goto free;
+		goto out;
 	}
 
 	uap->pinctrl = devm_pinctrl_get(&dev->dev);
 	if (IS_ERR(uap->pinctrl)) {
 		ret = PTR_ERR(uap->pinctrl);
-		goto unmap;
+		goto out;
 	}
 	uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
 						 PINCTRL_STATE_DEFAULT);
@@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
 	uap->clk = clk_get(&dev->dev, NULL);
 	if (IS_ERR(uap->clk)) {
 		ret = PTR_ERR(uap->clk);
-		goto unmap;
+		goto out;
 	}
 
 	uap->vendor = vendor;
@@ -1950,10 +1952,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
 		amba_ports[i] = NULL;
 		pl011_dma_remove(uap);
 		clk_put(uap->clk);
- unmap:
-		iounmap(base);
- free:
-		kfree(uap);
 	}
  out:
 	return ret;
@@ -1973,9 +1971,7 @@ static int pl011_remove(struct amba_device *dev)
 			amba_ports[i] = NULL;
 
 	pl011_dma_remove(uap);
-	iounmap(uap->port.membase);
 	clk_put(uap->clk);
-	kfree(uap);
 	return 0;
 }
 
-- 
1.7.9.2


^ permalink raw reply related

* Re: [PATCH 1/2] serial/amba-pl011: use devm_* allocators
From: Fabio Estevam @ 2012-06-17 14:13 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Greg Kroah-Hartman, linux-serial, Linus Walleij, linux-arm-kernel
In-Reply-To: <1339940648-6847-1-git-send-email-linus.walleij@stericsson.com>

On Sun, Jun 17, 2012 at 10:44 AM, Linus Walleij
<linus.walleij@stericsson.com> wrote:

>        uap->pinctrl = devm_pinctrl_get(&dev->dev);
>        if (IS_ERR(uap->pinctrl)) {
>                ret = PTR_ERR(uap->pinctrl);
> -               goto unmap;
> +               goto out;
>        }
>        uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
>                                                 PINCTRL_STATE_DEFAULT);
> @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>        uap->clk = clk_get(&dev->dev, NULL);

Maybe you can use devm_clk_get here too.

^ permalink raw reply

* RE: Questions regarding adding a patch in linux/drivers/char/8250.c
From: Donald @ 2012-06-18  3:07 UTC (permalink / raw)
  To: 'Donald', 'Alan Cox'; +Cc: linux-serial
In-Reply-To: <20120521102848.7bfb49e0@pyramind.ukuu.org.uk>

Hi Alan,

It's been about three weeks since my last email. It's highly appreciated if you could keep me posted for any update regarding the
patch request.

Regards,
Donald

-----Original Message-----
From: Donald [mailto:donald@asix.com.tw] 
Sent: Tuesday, May 29, 2012 4:38 PM
To: 'Alan Cox'
Cc: 'linux-serial@vger.kernel.org'
Subject: RE: Questions regarding adding a patch in linux/drivers/char/8250.c

Hi Alan,

Sorry for my late reply. Below are my answers for your questions in previous emails:

1. Regarding how to detect the presence of the UART devices with this erratum, it's feasible to check the device's vendor
identification, which can be acquired by using " container_of" macro.

2. Regarding doing parity check by software, it's not feasible mainly because that the parity bit will be stripped off by the
hardware, the software can only get the data portion; hence no chance to do parity check.

3. Regarding the performance concern of the proposed software workaround, we had been verified this workaround and didn't see any
performance issue. For example, in a file transfer test at 115200 bps, the performance and CPU utilization rate are almost the same
between test drivers with and without this workaround.

4. Below is the complete patch for your preview, upon your approve, I will submit the formal patch by another email. Thank you for
your help.

drivers/tty/serial/8250/8250.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index 5c27f7e..be493b0 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -38,6 +38,7 @@
 #include <linux/nmi.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <linux/pci.h>
 #ifdef CONFIG_SPARC
 #include <linux/sunserialcore.h>
 #endif
@@ -2238,6 +2239,8 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
 	unsigned long flags;
 	unsigned int baud, quot;
 
+	struct pci_dev *pdev = container_of(port->dev, struct pci_dev, dev);
+
 	switch (termios->c_cflag & CSIZE) {
 	case CS5:
 		cval = UART_LCR_WLEN5;
@@ -2351,6 +2354,13 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
 	if (up->capabilities & UART_CAP_RTOIE)
 		up->ier |= UART_IER_RTOIE;
 
+	if ((termios->c_cflag & PARENB) && (pdev->vendor == 0x9710)) {
+		fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
+		up->ier &= ~UART_IER_RLSI;
+	} else {
+		up->ier |= UART_IER_RLSI;
+	}
+
 	serial_port_out(port, UART_IER, up->ier);
 
 	if (up->capabilities & UART_CAP_EFR) {
--
1.7.7.6

Regards,
Donald

-----Original Message-----
From: Alan Cox [mailto:alan@lxorguk.ukuu.org.uk]
Sent: Monday, May 21, 2012 5:29 PM
To: Donald
Cc: linux-serial@vger.kernel.org
Subject: Re: Questions regarding adding a patch in linux/drivers/char/8250.c

On Mon, 21 May 2012 14:19:34 +0800
"Donald" <donald@asix.com.tw> wrote:

> Hi,
> 
> This is Donald from ASIX Electronics Corp. My company has three PCI to Serial controllers, including MCS9845, MCS9835, and
MCS9820.
> Currently those serial devices using these three chips can directly 
> use the Linux kernel's serial driver in linux/drivers/char/8250.c.
> Recently we find these three chips have a hardware bug relating to parity error count function. We have a software workaround for
this issue. Below for reference is a pseudo code for this workaround.
> 
> serial8250_do_set_termios() {
> 	If ((PID == MCS9845 || PID == MCS935 || PID == MCS9820) && ((termios->c_cflag & PARENB))) {
> 		port->fifosize = 1; /* Change RX FIFO size to 1 byte */
> 		up->ier &= ~UART_IER_RLSI; /* Disable RLSI interrupt */
> 	}	
> }
> 
> Is it possible to add a patch into linux/drivers/char/8250.c for our chips' hardware issue? 

Sure.

The only question I would have is how do we reliably detect the presence of the UART devices with this erratum. Can we do it from
the PCI identifier ?

Alan



^ permalink raw reply

* Re: [PATCH 1/2] serial/amba-pl011: use devm_* allocators
From: Linus Walleij @ 2012-06-18  6:37 UTC (permalink / raw)
  To: Fabio Estevam, Russell King - ARM Linux
  Cc: Linus Walleij, Greg Kroah-Hartman, linux-serial, linux-arm-kernel
In-Reply-To: <CAOMZO5DGxPQyHpPLLJk1P5kmyfB+9jct1rwEZj918wM84ePRKA@mail.gmail.com>

On Sun, Jun 17, 2012 at 4:13 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Sun, Jun 17, 2012 at 10:44 AM, Linus Walleij
> <linus.walleij@stericsson.com> wrote:
>
>>        uap->pinctrl = devm_pinctrl_get(&dev->dev);
>>        if (IS_ERR(uap->pinctrl)) {
>>                ret = PTR_ERR(uap->pinctrl);
>> -               goto unmap;
>> +               goto out;
>>        }
>>        uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
>>                                                 PINCTRL_STATE_DEFAULT);
>> @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>>        uap->clk = clk_get(&dev->dev, NULL);
>
> Maybe you can use devm_clk_get here too.

That requires all users of the driver to be using CONFIG_CLKDEV, which
I *think* is safe to do, but better check: Russell, do you know if
it's safe to use
this feature from clkdev in the PL011 driver?

It seems so to me and most likely works on the systems I have (Ux500, U300,
Nomadik, Integrator, RealView) but the world of PL011 is so big...

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 14/16] tty: serial: imx: remove the use of MXC_INTERNAL_IRQS
From: Dong Aisheng @ 2012-06-18  8:22 UTC (permalink / raw)
  To: Shawn Guo
  Cc: linux-arm-kernel@lists.infradead.org, Sascha Hauer, Arnd Bergmann,
	Rob Herring, Grant Likely, Dong Aisheng-B29396,
	linux-serial@vger.kernel.org, Greg Kroah-Hartman
In-Reply-To: <1339653587-4832-15-git-send-email-shawn.guo@linaro.org>

On Thu, Jun 14, 2012 at 01:59:45PM +0800, Shawn Guo wrote:
> As the part of the effort to enable SPARE_IRQ for imx platform,
> the macro MXC_INTERNAL_IRQS will be removed.  The imx serial driver
> has a references to it for a decision on flags of request_irq call
> based on rtsirq is beyond MXC_INTERNAL_IRQS.  However the searching
> on imx platform code tells that rtsirq will never be beyond
> MXC_INTERNAL_IRQS.  That said, the check, consequently the reference
> to MXC_INTERNAL_IRQS are not needed, so remove them.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: linux-serial@vger.kernel.org
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Dong Aisheng <dong.aisheng@linaro.org>

Regards
Dong Aisheng


^ permalink raw reply

* [PATCH] drivers/tty/tty_io.c: fix a potential memleak at do_tty_write()
From: Jeff Liu @ 2012-06-18 12:23 UTC (permalink / raw)
  To: linux-serial

Hello,

Looks there is a potential memory leak at drivers/tty/tty_io.c: do_tty_write().
It did allocate a buf_chunk if tty->write_cnt < chunk, however, buf_chunk was not
freed after the writing is done.  Below tiny patch could fix it.

Thanks,
-Jeff


diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index b425c79..f09e73e 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1011,6 +1011,7 @@ static inline ssize_t do_tty_write(
 	size_t count)
 {
 	ssize_t ret, written = 0;
+	unsigned char *buf_chunk = NULL;
 	unsigned int chunk;
 
 	ret = tty_write_lock(tty, file->f_flags & O_NDELAY);
@@ -1041,8 +1042,6 @@ static inline ssize_t do_tty_write(
 
 	/* write_buf/write_cnt is protected by the atomic_write_lock mutex */
 	if (tty->write_cnt < chunk) {
-		unsigned char *buf_chunk;
-
 		if (chunk < 1024)
 			chunk = 1024;
 
@@ -1082,6 +1081,9 @@ static inline ssize_t do_tty_write(
 		inode->i_mtime = current_fs_time(inode->i_sb);
 		ret = written;
 	}
+
+	if (buf_chunk)
+		kfree(buf_chunk);
 out:
 	tty_write_unlock(tty);
 	return ret;

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox