Skip to contentSkip to conversation

n_tracerouter and n_tracesink ldisc additions.

PATCH In review [email protected] 3 participants 6 messages Apr 22, 2011 – May 5, 2011 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 n_tracerouter and n_tracesink ldisc additions.

From: J Freyensee <[email protected]>

The n_tracerouter and n_tracesink line discpline drivers use the Linux tty line discpline framework to route trace data coming from a tty port (say UART for example) to the trace sink line discipline driver and to another tty port(say USB). Those these two line discipline drivers can be used together, independently from pti.c, they are part of the original implementation solution of the MIPI P1149.7, compact JTAG, PTI solution for Intel mobile platforms starting with the Medfield platform.

---
 drivers/tty/Kconfig         |   31 ++++++
 drivers/tty/Makefile        |    2 +
 drivers/tty/n_tracerouter.c |  243 ++++++++++++++++++++++++++++++++++++++++++
 drivers/tty/n_tracesink.c   |  246 +++++++++++++++++++++++++++++++++++++++++++
 drivers/tty/n_tracesink.h   |   36 +++++++
 include/linux/tty.h         |    2 +
 6 files changed, 560 insertions(+), 0 deletions(-)
 create mode 100644 drivers/tty/n_tracerouter.c
 create mode 100644 drivers/tty/n_tracesink.c
 create mode 100644 drivers/tty/n_tracesink.h
drivers/tty/Kconfig +31 -0
index 3fd7199..2e5f2f2 100644
@@ -319,3 +319,34 @@ config N_GSM
 	  This line discipline provides support for the GSM MUX protocol and
 	  presents the mux as a set of 61 individual tty devices.
 
+config TRACE_ROUTER
+	tristate "Trace data router for MIPI P1149.7 cJTAG standard"
+	depends on TRACE_SINK
+	default n
+	help
+	  The trace router uses the Linux tty line discipline framework to
+	  route trace data coming from a tty port (say UART for example) to
+	  the trace sink line discipline driver and to another tty port(say 
+	  USB). This is part of a solution for the MIPI P1149.7, compact JTAG,
+	  standard, which is for debugging mobile devices. The PTI driver in
+	  drivers/misc/pti.c defines the majority of this MIPI solution.
+
+	  You should select this driver if the target kernel is meant for
+	  a mobile device containing a modem.  Then you will need to select
+	  "Trace data sink for MIPI P1149.7 cJTAG standard" line discipline
+	  driver.
+
+config TRACE_SINK
+	tristate "Trace data sink for MIPI P1149.7 cJTAG standard"
+	default n
+	help
+	  The trace sink uses the Linux line discipline framework to receive
+	  trace data coming from the trace router line discipline driver
+	  to a user-defined tty port target, like USB.
+	  This is to provide a way to extract modem trace data on
+	  devices that do not have a PTI HW module, or just need modem
+	  trace data to come out of a different HW output port.
+	  This is part of a solution for the P1149.7, compact JTAG, standard.
+
+	  If you select this option, you need to select
+	  "Trace data router for MIPI P1149.7 cJTAG standard".
drivers/tty/Makefile +2 -0
index 690522f..ea89b0b 100644
@@ -6,6 +6,8 @@ obj-$(CONFIG_AUDIT)		+= tty_audit.o
 obj-$(CONFIG_MAGIC_SYSRQ)	+= sysrq.o
 obj-$(CONFIG_N_HDLC)		+= n_hdlc.o
 obj-$(CONFIG_N_GSM)		+= n_gsm.o
+obj-$(CONFIG_TRACE_ROUTER)	+= n_tracerouter.o
+obj-$(CONFIG_TRACE_SINK)	+= n_tracesink.o
 obj-$(CONFIG_R3964)		+= n_r3964.o
 
 obj-y				+= vt/
drivers/tty/n_tracerouter.c new file +243 -0

243 lines not on this page · raw message

drivers/tty/n_tracesink.c new file +246 -0

246 lines not on this page · raw message

drivers/tty/n_tracesink.h new file +36 -0
new file mode 100644
index 0000000..a68bb44
@@ -0,0 +1,36 @@
+/*
+ *  n_tracesink.h - Kernel driver API to route trace data in kernel space.
+ *
+ *  Copyright (C) Intel 2011
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2
+ *  as published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * The PTI (Parallel Trace Interface) driver directs trace data routed from
+ * various parts in the system out through the Intel Penwell PTI port and
+ * out of the mobile device for analysis with a debugging tool
+ * (Lauterbach, Fido). This is part of a solution for the MIPI P1149.7,
+ * compact JTAG, standard.
+ *
+ * This header file is used by n_tracerouter to be able to send the
+ * data of it's tty port to the tty port this module sits.  This
+ * mechanism can also be used independent of the PTI module.
+ *
+ */
+
+#ifndef N_TRACESINK_H_
+#define N_TRACESINK_H_
+
+void n_tracesink_datadrain(u8 *buf, int count);
+
+#endif
include/linux/tty.h +2 -0
index 9f469c7..fbf17de 100644
@@ -50,6 +50,8 @@
 #define N_CAIF		20      /* CAIF protocol for talking to modems */
 #define N_GSM0710	21	/* GSM 0710 Mux */
 #define N_TI_WL		22	/* for TI's WL BT, FM, GPS combo chips */
+#define N_TRACESINK	23	/* Trace data routing for MIPI P1149.7 */
+#define N_TRACEROUTER	24	/* Trace data routing for MIPI P1149.7 */
 
 /*
  * This character is the same as _POSIX_VDISABLE: it cannot be used as
Signature · 1 line
1.7.2.3
#1 lore raw
Quoted 12 lines · On Fri, 22 Apr 2011, [email protected] wrote:

From: J Freyensee <[email protected]>

The n_tracerouter and n_tracesink line discpline drivers use the Linux tty line discpline framework to route trace data coming from a tty port (say UART for example) to the trace sink line discipline driver and to another tty port(say USB). Those these two line discipline drivers can be used together, independently from pti.c, they are part of the original implementation solution of the MIPI P1149.7, compact JTAG, PTI solution for Intel mobile platforms starting with the Medfield platform.

Quoted 1 line

A few minor comments can be found below.

...

drivers/tty/n_tracesink.c line 82

Quoted 9 lines
drivers/tty/n_tracesink.c new file +9 -0
+static int n_tracesink_open(struct tty_struct *tty)
+{
+	int retval = -EEXIST;
+
+	mutex_lock(&writelock);
+	if (this_tty == NULL) {
+
+		this_tty = tty_kref_get(tty);
+

pointless blank line. I'd suggest removing it.

...

drivers/tty/n_tracesink.c line 85

Quoted 3 lines
drivers/tty/n_tracesink.c new file +3 -0
+		if (this_tty == NULL)
+			retval = -EFAULT;
+		else {

If one branch requires braces, both should have them

        } else {

...

drivers/tty/n_tracesink.c line 112

Quoted 11 lines
drivers/tty/n_tracesink.c new file +11 -0
+static void n_tracesink_close(struct tty_struct *tty)
+{
+
+	mutex_lock(&writelock);
+	tty_driver_flush_buffer(tty);
+	tty_kref_put(this_tty);
+	this_tty = NULL;
+	tty->disc_data = NULL;
+	mutex_unlock(&writelock);
+
+}

pointless blank line at end of function. Remove it.

drivers/tty/n_tracesink.c line 223

Quoted 12 lines
drivers/tty/n_tracesink.c new file +12 -0
+static int __init n_tracesink_init(void)
+{
+	int retval;
+
+	/* Note N_TRACESINK is defined in linux/tty.h */
+	retval = tty_register_ldisc(N_TRACESINK, &tty_n_tracesink);
+
+	if (retval < 0)
+		pr_err("%s: Registration failed: %d\n", __func__, retval);
+
+	return retval;
+}

How about shortening is a bit - like this?

static int __init n_tracesink_init(void)

{
     /* Note N_TRACESINK is defined in linux/tty.h */
     int retval = tty_register_ldisc(N_TRACESINK, &tty_n_tracesink);
     
     if (retval < 0)
             pr_err("%s: Registration failed: %d\n", __func__, retval);
             
     return retval;
}

...

drivers/tty/n_tracesink.c line 238

Quoted 9 lines
drivers/tty/n_tracesink.c new file +9 -0
+static void __exit n_tracesink_exit(void)
+{
+	int retval;
+
+	retval = tty_unregister_ldisc(N_TRACESINK);
+
+	if (retval < 0)
+		pr_err("%s: Unregistration failed: %d\n", __func__,  retval);
+}

How about:

static void __exit n_tracesink_exit(void)

{
     int retval = tty_unregister_ldisc(N_TRACESINK);
     
     if (retval < 0)
             pr_err("%s: Unregistration failed: %d\n", __func__,  retval);
}

...

include/linux/tty.h line 55

Quoted 9 lines
include/linux/tty.h +2 -0
@@ -50,6 +50,8 @@
 #define N_CAIF		20      /* CAIF protocol for talking to modems */
 #define N_GSM0710	21	/* GSM 0710 Mux */
 #define N_TI_WL		22	/* for TI's WL BT, FM, GPS combo chips */
+#define N_TRACESINK	23	/* Trace data routing for MIPI P1149.7 */
+#define N_TRACEROUTER	24	/* Trace data routing for MIPI P1149.7 */
 

Lining up those defines would be nice :)

Signature · 3 lines
Jesper Juhl <[email protected]>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
#2 lore raw
Quoted 11 lines · Jesper Juhl

include/linux/tty.h line 55

Quoted 9 lines
include/linux/tty.h +2 -0
@@ -50,6 +50,8 @@
 #define N_CAIF		20      /* CAIF protocol for talking to modems */
 #define N_GSM0710	21	/* GSM 0710 Mux */
 #define N_TI_WL		22	/* for TI's WL BT, FM, GPS combo chips */
+#define N_TRACESINK	23	/* Trace data routing for MIPI P1149.7 */
+#define N_TRACEROUTER	24	/* Trace data routing for MIPI P1149.7 */
 

Lining up those defines would be nice :)

They are lined up in the original file just fine.

thanks,

greg k-h

#3 lore raw
Quoted 13 lines · Greg KH
Quoted 11 lines · Jesper Juhl

include/linux/tty.h line 55

Quoted 9 lines
include/linux/tty.h +2 -0
@@ -50,6 +50,8 @@
 #define N_CAIF		20      /* CAIF protocol for talking to modems */
 #define N_GSM0710	21	/* GSM 0710 Mux */
 #define N_TI_WL		22	/* for TI's WL BT, FM, GPS combo chips */
+#define N_TRACESINK	23	/* Trace data routing for MIPI P1149.7 */
+#define N_TRACEROUTER	24	/* Trace data routing for MIPI P1149.7 */
 

Lining up those defines would be nice :)

Quoted 2 lines

They are lined up in the original file just fine.

Ok, then my email client is messing things up for me.

Signature · 3 lines
Jesper Juhl <[email protected]>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
#4 lore raw
In reply to Jesper Juhl

Thanks for the feedback. I've been out on business and will go through the comments when I can.

Jay

Quoted 122 lines · Jesper Juhl
Quoted 12 lines · On Fri, 22 Apr 2011, [email protected] wrote:

From: J Freyensee <[email protected]>

The n_tracerouter and n_tracesink line discpline drivers use the Linux tty line discpline framework to route trace data coming from a tty port (say UART for example) to the trace sink line discipline driver and to another tty port(say USB). Those these two line discipline drivers can be used together, independently from pti.c, they are part of the original implementation solution of the MIPI P1149.7, compact JTAG, PTI solution for Intel mobile platforms starting with the Medfield platform.

Quoted 1 line

A few minor comments can be found below.

...

drivers/tty/n_tracesink.c line 82

Quoted 9 lines
drivers/tty/n_tracesink.c new file +9 -0
+static int n_tracesink_open(struct tty_struct *tty)
+{
+	int retval = -EEXIST;
+
+	mutex_lock(&writelock);
+	if (this_tty == NULL) {
+
+		this_tty = tty_kref_get(tty);
+

pointless blank line. I'd suggest removing it.

...

drivers/tty/n_tracesink.c line 85

Quoted 3 lines
drivers/tty/n_tracesink.c new file +3 -0
+		if (this_tty == NULL)
+			retval = -EFAULT;
+		else {

If one branch requires braces, both should have them

        } else {

...

drivers/tty/n_tracesink.c line 112

Quoted 11 lines
drivers/tty/n_tracesink.c new file +11 -0
+static void n_tracesink_close(struct tty_struct *tty)
+{
+
+	mutex_lock(&writelock);
+	tty_driver_flush_buffer(tty);
+	tty_kref_put(this_tty);
+	this_tty = NULL;
+	tty->disc_data = NULL;
+	mutex_unlock(&writelock);
+
+}

pointless blank line at end of function. Remove it.

drivers/tty/n_tracesink.c line 223

Quoted 12 lines
drivers/tty/n_tracesink.c new file +12 -0
+static int __init n_tracesink_init(void)
+{
+	int retval;
+
+	/* Note N_TRACESINK is defined in linux/tty.h */
+	retval = tty_register_ldisc(N_TRACESINK, &tty_n_tracesink);
+
+	if (retval < 0)
+		pr_err("%s: Registration failed: %d\n", __func__, retval);
+
+	return retval;
+}

How about shortening is a bit - like this?

static int __init n_tracesink_init(void)

{
     /* Note N_TRACESINK is defined in linux/tty.h */
     int retval = tty_register_ldisc(N_TRACESINK, &tty_n_tracesink);
     
     if (retval < 0)
             pr_err("%s: Registration failed: %d\n", __func__, retval);
             
     return retval;
}

...

drivers/tty/n_tracesink.c line 238

Quoted 9 lines
drivers/tty/n_tracesink.c new file +9 -0
+static void __exit n_tracesink_exit(void)
+{
+	int retval;
+
+	retval = tty_unregister_ldisc(N_TRACESINK);
+
+	if (retval < 0)
+		pr_err("%s: Unregistration failed: %d\n", __func__,  retval);
+}

How about:

static void __exit n_tracesink_exit(void)

{
     int retval = tty_unregister_ldisc(N_TRACESINK);
     
     if (retval < 0)
             pr_err("%s: Unregistration failed: %d\n", __func__,  retval);
}

...

include/linux/tty.h line 55

Quoted 9 lines
include/linux/tty.h +2 -0
@@ -50,6 +50,8 @@
 #define N_CAIF		20      /* CAIF protocol for talking to modems */
 #define N_GSM0710	21	/* GSM 0710 Mux */
 #define N_TI_WL		22	/* for TI's WL BT, FM, GPS combo chips */
+#define N_TRACESINK	23	/* Trace data routing for MIPI P1149.7 */
+#define N_TRACEROUTER	24	/* Trace data routing for MIPI P1149.7 */
 

Lining up those defines would be nice :)

#5 lore raw
In reply to Jesper Juhl
Quoted 33 lines · Jesper Juhl
Quoted 12 lines · On Fri, 22 Apr 2011, [email protected] wrote:

From: J Freyensee <[email protected]>

The n_tracerouter and n_tracesink line discpline drivers use the Linux tty line discpline framework to route trace data coming from a tty port (say UART for example) to the trace sink line discipline driver and to another tty port(say USB). Those these two line discipline drivers can be used together, independently from pti.c, they are part of the original implementation solution of the MIPI P1149.7, compact JTAG, PTI solution for Intel mobile platforms starting with the Medfield platform.

Quoted 1 line

A few minor comments can be found below.

...

drivers/tty/n_tracesink.c line 82

Quoted 9 lines
drivers/tty/n_tracesink.c new file +9 -0
+static int n_tracesink_open(struct tty_struct *tty)
+{
+	int retval = -EEXIST;
+
+	mutex_lock(&writelock);
+	if (this_tty == NULL) {
+
+		this_tty = tty_kref_get(tty);
+

pointless blank line. I'd suggest removing it.

Quoted 9 lines

...

drivers/tty/n_tracesink.c line 85

Quoted 3 lines
drivers/tty/n_tracesink.c new file +3 -0
+		if (this_tty == NULL)
+			retval = -EFAULT;
+		else {

If one branch requires braces, both should have them

        } else {

It's not this way because it passed checkpatch.pl. In fact, I believe checkpatch.pl will complain if I add {} to a single if() line.

Quoted 33 lines

...

drivers/tty/n_tracesink.c line 112

Quoted 11 lines
drivers/tty/n_tracesink.c new file +11 -0
+static void n_tracesink_close(struct tty_struct *tty)
+{
+
+	mutex_lock(&writelock);
+	tty_driver_flush_buffer(tty);
+	tty_kref_put(this_tty);
+	this_tty = NULL;
+	tty->disc_data = NULL;
+	mutex_unlock(&writelock);
+
+}

pointless blank line at end of function. Remove it.

drivers/tty/n_tracesink.c line 223

Quoted 12 lines
drivers/tty/n_tracesink.c new file +12 -0
+static int __init n_tracesink_init(void)
+{
+	int retval;
+
+	/* Note N_TRACESINK is defined in linux/tty.h */
+	retval = tty_register_ldisc(N_TRACESINK, &tty_n_tracesink);
+
+	if (retval < 0)
+		pr_err("%s: Registration failed: %d\n", __func__, retval);
+
+	return retval;
+}

How about shortening is a bit - like this?

static int __init n_tracesink_init(void)

Quoted 9 lines
{
     /* Note N_TRACESINK is defined in linux/tty.h */
     int retval = tty_register_ldisc(N_TRACESINK, &tty_n_tracesink);
     
     if (retval < 0)
             pr_err("%s: Registration failed: %d\n", __func__, retval);
             
     return retval;
}

I can make the minor modification.

Quoted 14 lines

...

drivers/tty/n_tracesink.c line 238

Quoted 9 lines
drivers/tty/n_tracesink.c new file +9 -0
+static void __exit n_tracesink_exit(void)
+{
+	int retval;
+
+	retval = tty_unregister_ldisc(N_TRACESINK);
+
+	if (retval < 0)
+		pr_err("%s: Unregistration failed: %d\n", __func__,  retval);
+}

How about:

Quoted 9 lines

static void __exit n_tracesink_exit(void)

{
     int retval = tty_unregister_ldisc(N_TRACESINK);
     
     if (retval < 0)
             pr_err("%s: Unregistration failed: %d\n", __func__,  retval);
}

Dido here.

Quoted 14 lines

...

include/linux/tty.h line 55

Quoted 9 lines
include/linux/tty.h +2 -0
@@ -50,6 +50,8 @@
 #define N_CAIF		20      /* CAIF protocol for talking to modems */
 #define N_GSM0710	21	/* GSM 0710 Mux */
 #define N_TI_WL		22	/* for TI's WL BT, FM, GPS combo chips */
+#define N_TRACESINK	23	/* Trace data routing for MIPI P1149.7 */
+#define N_TRACEROUTER	24	/* Trace data routing for MIPI P1149.7 */
 

Lining up those defines would be nice :)