Skip to contentSkip to conversation

TTY fix-ups for "TTY improve n_gsm support" series

PATCH New Gregory CLEMENT 1 participant 8 messages May 18, 2020 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

cover TTY fix-ups for "TTY improve n_gsm support" series

Hello,

Jiri found issues or things to improve in the v2 of the series "TTY improve n_gsm support". However it was already applied. So this series implements the needed changes.

For the second patch, as the commit "tty: n_gsm: Fix waking up upper tty layer when room available" was not yet in mainline, it has no SHA-1 ID yet. That's why I reference the same commit that the one fixed by "TTY improve n_gsm support", as they should be applied in the same order in stable branch than in mainline.

Gregory

Gregory CLEMENT (2):
tty: n_gsm: Remove unnecessary test in gsm_print_packet()
tty: n_gsm: Fix bogus i++ in gsm_data_kick

 drivers/tty/n_gsm.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/3 tty: n_gsm: Improve debug output

Use appropriate print helpers for debug messages.

---
 drivers/tty/n_gsm.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/tty/n_gsm.c +2 -12
index d77ed82a4840..67c8f8173023 100644
@@ -504,18 +504,8 @@ static void gsm_print_packet(const char *hdr, int addr, int cr,
 	else
 		pr_cont("(F)");
 
-	if (dlen) {
-		int ct = 0;
-		while (dlen--) {
-			if (ct % 8 == 0) {
-				pr_cont("\n");
-				pr_debug("    ");
-			}
-			pr_cont("%02X ", *data++);
-			ct++;
-		}
-	}
-	pr_cont("\n");
+	if (dlen)
+		print_hex_dump_bytes("", DUMP_PREFIX_NONE, data, dlen);
 }
 
 
Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 2/3 tty: n_gsm: Fix SOF skipping

In reply to Gregory CLEMENT

For at least some modems like the TELIT LE910, skipping SOF makes transfers blocking indefinitely after a short amount of data transferred.

Given the small improvement provided by skipping the SOF (just one byte on about 100 bytes), it seems better to completely remove this "feature" than make it optional.

Fixes e1eaea46bb40 ("tty: n_gsm line discipline")
---
 drivers/tty/n_gsm.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/tty/n_gsm.c +1 -7
index 67c8f8173023..d8d196645500 100644
@@ -667,7 +667,6 @@ static void gsm_data_kick(struct gsm_mux *gsm)
 {
 	struct gsm_msg *msg, *nmsg;
 	int len;
-	int skip_sof = 0;
 
 	list_for_each_entry_safe(msg, nmsg, &gsm->tx_list, list) {
 		if (gsm->constipated && msg->addr)
@@ -689,15 +688,10 @@ static void gsm_data_kick(struct gsm_mux *gsm)
 			print_hex_dump_bytes("gsm_data_kick: ",
 					     DUMP_PREFIX_OFFSET,
 					     gsm->txframe, len);
-
-		if (gsm->output(gsm, gsm->txframe + skip_sof,
-						len - skip_sof) < 0)
+		if (gsm->output(gsm, gsm->txframe, len) < 0)
 			break;
 		/* FIXME: Can eliminate one SOF in many more cases */
 		gsm->tx_bytes -= msg->len;
-		/* For a burst of frames skip the extra SOF within the
-		   burst */
-		skip_sof = 1;
 
 		list_del(&msg->list);
 		kfree(msg);
Signature · 1 line
2.26.2
#3 lore raw

PATCH v2 3/3 tty: n_gsm: Fix waking up upper tty layer when room available

In reply to Gregory CLEMENT

Warn the upper layer when n_gms is ready to receive data again. Without this the associated virtual tty remains blocked indefinitely.

Fixes e1eaea46bb40 ("tty: n_gsm line discipline")
---
 drivers/tty/n_gsm.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/tty/n_gsm.c +22 -4
index d8d196645500..69200bd411f7 100644
@@ -663,7 +663,7 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
  *	FIXME: lock against link layer control transmissions
  */
 
-static void gsm_data_kick(struct gsm_mux *gsm)
+static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)
 {
 	struct gsm_msg *msg, *nmsg;
 	int len;
@@ -695,6 +695,24 @@ static void gsm_data_kick(struct gsm_mux *gsm)
 
 		list_del(&msg->list);
 		kfree(msg);
+
+		if (dlci) {
+			tty_port_tty_wakeup(&dlci->port);
+		} else {
+			int i = 0;
+
+			for (i = 0; i < NUM_DLCI; i++) {
+				struct gsm_dlci *dlci;
+
+				dlci = gsm->dlci[i];
+				if (dlci == NULL) {
+					i++;
+					continue;
+				}
+
+				tty_port_tty_wakeup(&dlci->port);
+			}
+		}
 	}
 }
 
@@ -746,7 +764,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
 	/* Add to the actual output queue */
 	list_add_tail(&msg->list, &gsm->tx_list);
 	gsm->tx_bytes += msg->len;
-	gsm_data_kick(gsm);
+	gsm_data_kick(gsm, dlci);
 }
 
 /**
@@ -1207,7 +1225,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
 		gsm_control_reply(gsm, CMD_FCON, NULL, 0);
 		/* Kick the link in case it is idling */
 		spin_lock_irqsave(&gsm->tx_lock, flags);
-		gsm_data_kick(gsm);
+		gsm_data_kick(gsm, NULL);
 		spin_unlock_irqrestore(&gsm->tx_lock, flags);
 		break;
 	case CMD_FCOFF:
@@ -2529,7 +2547,7 @@ static void gsmld_write_wakeup(struct tty_struct *tty)
 	/* Queue poll */
 	clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
 	spin_lock_irqsave(&gsm->tx_lock, flags);
-	gsm_data_kick(gsm);
+	gsm_data_kick(gsm, NULL);
 	if (gsm->tx_bytes < TX_THRESH_LO) {
 		gsm_dlci_data_sweep(gsm);
 	}
Signature · 1 line
2.26.2
#4 lore raw

PATCH 1/2 tty: n_gsm: Remove unnecessary test in gsm_print_packet()

In reply to Gregory CLEMENT

If the length is zero then the print_hex_dump_bytes won't output anything, so testing the length before the call is unnecessary.

---
 drivers/tty/n_gsm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/n_gsm.c +1 -2
index 69200bd411f7..4465dd04fead 100644
@@ -504,8 +504,7 @@ static void gsm_print_packet(const char *hdr, int addr, int cr,
 	else
 		pr_cont("(F)");
 
-	if (dlen)
-		print_hex_dump_bytes("", DUMP_PREFIX_NONE, data, dlen);
+	print_hex_dump_bytes("", DUMP_PREFIX_NONE, data, dlen);
 }
 
 
Signature · 1 line
2.26.2
#5 lore raw

PATCH 2/2 tty: n_gsm: Fix bogus i++ in gsm_data_kick

In reply to Gregory CLEMENT

When submitting the previous fix "tty: n_gsm: Fix waking up upper tty layer when room available". It was suggested to switch from a while to a for loop, but when doing it, there was a remaining bogus i++.

This patch removes this i++ and also reorganizes the code making it more compact.

Fixes e1eaea46bb40 ("tty: n_gsm line discipline")
---
 drivers/tty/n_gsm.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/tty/n_gsm.c +3 -11
index 4465dd04fead..0a29a94ec438 100644
@@ -700,17 +700,9 @@ static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)
 		} else {
 			int i = 0;
 
-			for (i = 0; i < NUM_DLCI; i++) {
-				struct gsm_dlci *dlci;
-
-				dlci = gsm->dlci[i];
-				if (dlci == NULL) {
-					i++;
-					continue;
-				}
-
-				tty_port_tty_wakeup(&dlci->port);
-			}
+			for (i = 0; i < NUM_DLCI; i++)
+				if (gsm->dlci[i])
+					tty_port_tty_wakeup(&gsm->dlci[i]->port);
 		}
 	}
 }
Signature · 1 line
2.26.2
#6 lore raw

v2 cover TTY improve n_gsm support

In reply to Gregory CLEMENT

Hello,

This series is the second version of patch improving n_gms support especially with TELIT LE910. However the fix should benefit to any modem supporting cmux.

The first patch is just about improving debugging output.

The second one removes a tty optimization which make the LE910 hang.

The last one fixes an issue observed on the LE910 but should benefit to all the modem. We observed that pretty quickly the transfer done using the virtual tty were blocked. We found that it was due of a wakeup to the real tty. Without this fix, the real tty wait for indefinitely.

Thanks to Jiri Slaby for the review.

Changelog:
v1 -> v2:
- don't replace the pr_info by pr_debug
- remove the superfluous printk("\n");
- use --follow option with git log to find the original commit to fix
- use tty_port_tty_wakeup
- use 'for' loop instead of 'while'

Gregory

Gregory CLEMENT (3):
tty: n_gsm: Improve debug output
tty: n_gsm: Fix SOF skipping
tty: n_gsm: Fix waking up upper tty layer when room available

 drivers/tty/n_gsm.c | 48 +++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 23 deletions(-)
Signature · 1 line
2.26.2
#7 lore raw

Re: [PATCH v2 0/3] TTY improve n_gsm support

Hello,

Quoted 5 lines

Hello,

This series is the second version of patch improving n_gms support especially with TELIT LE910. However the fix should benefit to any modem supporting cmux.

You can just ignore the emails from this point, I forgot to remove the remaining .patch!

Sorry for the noise

Gregory

Quoted 34 lines

The first patch is just about improving debugging output.

The second one removes a tty optimization which make the LE910 hang.

The last one fixes an issue observed on the LE910 but should benefit to all the modem. We observed that pretty quickly the transfer done using the virtual tty were blocked. We found that it was due of a wakeup to the real tty. Without this fix, the real tty wait for indefinitely.

Thanks to Jiri Slaby for the review.

Changelog:
v1 -> v2:
- don't replace the pr_info by pr_debug
- remove the superfluous printk("\n");
- use --follow option with git log to find the original commit to fix
- use tty_port_tty_wakeup
- use 'for' loop instead of 'while'

Gregory

Gregory CLEMENT (3):
tty: n_gsm: Improve debug output
tty: n_gsm: Fix SOF skipping
tty: n_gsm: Fix waking up upper tty layer when room available

 drivers/tty/n_gsm.c | 48 +++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 23 deletions(-)
Signature · 1 line
2.26.2
Signature · 3 lines
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com