Skip to content

Commit c5a2791

Browse files
SeppoTakalogregkh
authored andcommitted
tty: n_gsm: Don't block input queue by waiting MSC
[ Upstream commit 3cf0b3c ] Currently gsm_queue() processes incoming frames and when opening a DLC channel it calls gsm_dlci_open() which calls gsm_modem_update(). If basic mode is used it calls gsm_modem_upd_via_msc() and it cannot block the input queue by waiting the response to come into the same input queue. Instead allow sending Modem Status Command without waiting for remote end to respond. Define a new function gsm_modem_send_initial_msc() for this purpose. As MSC is only valid for basic encoding, it does not do anything for advanced or when convergence layer type 2 is used. Fixes: 4847380 ("tty: n_gsm: fix missing update of modem controls after DLCI open") Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no> Link: https://lore.kernel.org/r/20250827123221.1148666-1-seppo.takalo@nordicsemi.no Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bd72b64 commit c5a2791

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

drivers/tty/n_gsm.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ static int gsm_send_packet(struct gsm_mux *gsm, struct gsm_msg *msg);
461461
static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr);
462462
static void gsmld_write_trigger(struct gsm_mux *gsm);
463463
static void gsmld_write_task(struct work_struct *work);
464+
static int gsm_modem_send_initial_msc(struct gsm_dlci *dlci);
464465

465466
/**
466467
* gsm_fcs_add - update FCS
@@ -2174,7 +2175,7 @@ static void gsm_dlci_open(struct gsm_dlci *dlci)
21742175
pr_debug("DLCI %d goes open.\n", dlci->addr);
21752176
/* Send current modem state */
21762177
if (dlci->addr) {
2177-
gsm_modem_update(dlci, 0);
2178+
gsm_modem_send_initial_msc(dlci);
21782179
} else {
21792180
/* Start keep-alive control */
21802181
gsm->ka_num = 0;
@@ -4161,6 +4162,28 @@ static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk)
41614162
return gsm_control_wait(dlci->gsm, ctrl);
41624163
}
41634164

4165+
/**
4166+
* gsm_modem_send_initial_msc - Send initial modem status message
4167+
*
4168+
* @dlci channel
4169+
*
4170+
* Send an initial MSC message after DLCI open to set the initial
4171+
* modem status lines. This is only done for basic mode.
4172+
* Does not wait for a response as we cannot block the input queue
4173+
* processing.
4174+
*/
4175+
static int gsm_modem_send_initial_msc(struct gsm_dlci *dlci)
4176+
{
4177+
u8 modembits[2];
4178+
4179+
if (dlci->adaption != 1 || dlci->gsm->encoding != GSM_BASIC_OPT)
4180+
return 0;
4181+
4182+
modembits[0] = (dlci->addr << 2) | 2 | EA; /* DLCI, Valid, EA */
4183+
modembits[1] = (gsm_encode_modem(dlci) << 1) | EA;
4184+
return gsm_control_command(dlci->gsm, CMD_MSC, (const u8 *)&modembits, 2);
4185+
}
4186+
41644187
/**
41654188
* gsm_modem_update - send modem status line state
41664189
* @dlci: channel

0 commit comments

Comments
 (0)