1. 28 7月, 2022 3 次提交
  2. 19 7月, 2022 1 次提交
  3. 16 7月, 2022 1 次提交
  4. 14 7月, 2022 13 次提交
  5. 08 7月, 2022 8 次提交
  6. 01 7月, 2022 9 次提交
    • D
      tty: n_gsm: fix resource allocation order in gsm_activate_mux() · 73496604
      Daniel Starke 提交于
      Within gsm_activate_mux() all timers and locks are initiated before the
      actual resource for the control channel is allocated. This can lead to race
      conditions.
      
      Allocate the control channel DLCI object first to avoid race conditions.
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701122332.2039-2-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73496604
    • D
      tty: n_gsm: fix deadlock and link starvation in outgoing data path · 0af02167
      Daniel Starke 提交于
      The current implementation queues up new control and user packets as needed
      and processes this queue down to the ldisc in the same code path.
      That means that the upper and the lower layer are hard coupled in the code.
      Due to this deadlocks can happen as seen below while transmitting data,
      especially during ldisc congestion. Furthermore, the data channels starve
      the control channel on high transmission load on the ldisc.
      
      Introduce an additional control channel data queue to prevent timeouts and
      link hangups during ldisc congestion. This is being processed before the
      user channel data queue in gsm_data_kick(), i.e. with the highest priority.
      Put the queue to ldisc data path into a workqueue and trigger it whenever
      new data has been put into the transmission queue. Change
      gsm_dlci_data_sweep() accordingly to fill up the transmission queue until
      TX_THRESH_HI. This solves the locking issue, keeps latency low and provides
      good performance on high data load.
      Note that now all packets from a DLCI are removed from the internal queue
      if the associated DLCI was closed. This ensures that no data is sent by the
      introduced write task to an already closed DLCI.
      
      BUG: spinlock recursion on CPU#0, test_v24_loop/124
       lock: serial8250_ports+0x3a8/0x7500, .magic: dead4ead, .owner: test_v24_loop/124, .owner_cpu: 0
      CPU: 0 PID: 124 Comm: test_v24_loop Tainted: G           O      5.18.0-rc2 #3
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
      Call Trace:
       <IRQ>
       dump_stack_lvl+0x34/0x44
       do_raw_spin_lock+0x76/0xa0
       _raw_spin_lock_irqsave+0x72/0x80
       uart_write_room+0x3b/0xc0
       gsm_data_kick+0x14b/0x240 [n_gsm]
       gsmld_write_wakeup+0x35/0x70 [n_gsm]
       tty_wakeup+0x53/0x60
       tty_port_default_wakeup+0x1b/0x30
       serial8250_tx_chars+0x12f/0x220
       serial8250_handle_irq.part.0+0xfe/0x150
       serial8250_default_handle_irq+0x48/0x80
       serial8250_interrupt+0x56/0xa0
       __handle_irq_event_percpu+0x78/0x1f0
       handle_irq_event+0x34/0x70
       handle_fasteoi_irq+0x90/0x1e0
       __common_interrupt+0x69/0x100
       common_interrupt+0x48/0xc0
       asm_common_interrupt+0x1e/0x40
      RIP: 0010:__do_softirq+0x83/0x34e
      Code: 2a 0a ff 0f b7 ed c7 44 24 10 0a 00 00 00 48 c7 c7 51 2a 64 82 e8 2d
      e2 d5 ff 65 66 c7 05 83 af 1e 7e 00 00 fb b8 ff ff ff ff <49> c7 c2 40 61
      80 82 0f bc c5 41 89 c4 41 83 c4 01 0f 84 e6 00 00
      RSP: 0018:ffffc90000003f98 EFLAGS: 00000286
      RAX: 00000000ffffffff RBX: 0000000000000000 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: ffffffff82642a51 RDI: ffffffff825bb5e7
      RBP: 0000000000000200 R08: 00000008de3271a8 R09: 0000000000000000
      R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
      R13: 0000000000000030 R14: 0000000000000000 R15: 0000000000000000
       ? __do_softirq+0x73/0x34e
       irq_exit_rcu+0xb5/0x100
       common_interrupt+0xa4/0xc0
       </IRQ>
       <TASK>
       asm_common_interrupt+0x1e/0x40
      RIP: 0010:_raw_spin_unlock_irqrestore+0x2e/0x50
      Code: 00 55 48 89 fd 48 83 c7 18 53 48 89 f3 48 8b 74 24 10 e8 85 28 36 ff
      48 89 ef e8 cd 58 36 ff 80 e7 02 74 01 fb bf 01 00 00 00 <e8> 3d 97 33 ff
      65 8b 05 96 23 2b 7e 85 c0 74 03 5b 5d c3 0f 1f 44
      RSP: 0018:ffffc9000020fd08 EFLAGS: 00000202
      RAX: 0000000000000000 RBX: 0000000000000246 RCX: 0000000000000000
      RDX: 0000000000000004 RSI: ffffffff8257fd74 RDI: 0000000000000001
      RBP: ffff8880057de3a0 R08: 00000008de233000 R09: 0000000000000000
      R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
      R13: 0000000000000100 R14: 0000000000000202 R15: ffff8880057df0b8
       ? _raw_spin_unlock_irqrestore+0x23/0x50
       gsmtty_write+0x65/0x80 [n_gsm]
       n_tty_write+0x33f/0x530
       ? swake_up_all+0xe0/0xe0
       file_tty_write.constprop.0+0x1b1/0x320
       ? n_tty_flush_buffer+0xb0/0xb0
       new_sync_write+0x10c/0x190
       vfs_write+0x282/0x310
       ksys_write+0x68/0xe0
       do_syscall_64+0x3b/0x90
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f3e5e35c15c
      Code: 8b 7c 24 08 89 c5 e8 c5 ff ff ff 89 ef 89 44 24 08 e8 58 bc 02 00 8b
      44 24 08 48 83 c4 10 5d c3 48 63 ff b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff
      ff 76 10 48 8b 15 fd fc 05 00 f7 d8 64 89 02 48 83
      RSP: 002b:00007ffcee77cd18 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 00007ffcee77cd70 RCX: 00007f3e5e35c15c
      RDX: 0000000000000100 RSI: 00007ffcee77cd90 RDI: 0000000000000003
      RBP: 0000000000000100 R08: 0000000000000000 R09: 7efefefefefefeff
      R10: 00007f3e5e3bddeb R11: 0000000000000246 R12: 00007ffcee77ce8f
      R13: 0000000000000001 R14: 000056214404e010 R15: 00007ffcee77cd90
       </TASK>
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701122332.2039-1-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0af02167
    • D
      tty: n_gsm: fix race condition in gsmld_write() · 32dd59f9
      Daniel Starke 提交于
      The function may be used by the user directly and also by the n_gsm
      internal functions. They can lead into a race condition which results in
      interleaved frames if both are writing at the same time. The receiving side
      is not able to decode those interleaved frames correctly.
      
      Add a lock around the low side tty write to avoid race conditions and frame
      interleaving between user originated writes and n_gsm writes.
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701061652.39604-9-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      32dd59f9
    • D
      tty: n_gsm: fix packet re-transmission without open control channel · 4fae831b
      Daniel Starke 提交于
      In the current implementation control packets are re-transmitted even if
      the control channel closed down during T2. This is wrong.
      Check whether the control channel is open before re-transmitting any
      packets. Note that control channel open/close is handled by T1 and not T2
      and remains unaffected by this.
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701061652.39604-7-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fae831b
    • D
      tty: n_gsm: fix non flow control frames during mux flow off · bec02248
      Daniel Starke 提交于
      n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
      See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
      The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
      the newer 27.010 here. Chapter 5.4.6.3.6 states that FCoff stops the
      transmission on all channels except the control channel. This is already
      implemented in gsm_data_kick(). However, chapter 5.4.8.1 explains that this
      shall result in the same behavior as software flow control on the ldisc in
      advanced option mode. That means only flow control frames shall be sent
      during flow off. The current implementation does not consider this case.
      
      Change gsm_data_kick() to send only flow control frames if constipated to
      abide the standard. gsm_read_ea_val() and gsm_is_flow_ctrl_msg() are
      introduced as helper functions for this.
      It is planned to use gsm_read_ea_val() in later code cleanups for other
      functions, too.
      
      Fixes: c01af4fe ("n_gsm : Flow control handling in Mux driver")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701061652.39604-5-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bec02248
    • D
      tty: n_gsm: fix missing timer to handle stalled links · c568f708
      Daniel Starke 提交于
      The current implementation does not handle the situation that no data is in
      the internal queue and needs to be sent out while the user tty fifo is
      full.
      Add a timer that moves more data from user tty down to the internal queue
      which is then serialized on the ldisc. This timer is triggered if no data
      was moved from a user tty to the internal queue within 10 * T1.
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701061652.39604-4-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c568f708
    • D
      tty: n_gsm: fix wrong queuing behavior in gsm_dlci_data_output() · 556fc8ac
      Daniel Starke 提交于
      1) The function drains the fifo for the given user tty/DLCI without
      considering 'TX_THRESH_HI' and different to gsm_dlci_data_output_framed(),
      which moves only one packet from the user side to the internal transmission
      queue. We can only handle one packet at a time here if we want to allow
      DLCI priority handling in gsm_dlci_data_sweep() to avoid link starvation.
      2) Furthermore, the additional header octet from convergence layer type 2
      is not counted against MTU. It is part of the UI/UIH frame message which
      needs to be limited to MTU. Hence, it is wrong not to consider this octet.
      3) Finally, the waiting user tty is not informed about freed space in its
      send queue.
      
      Take at most one packet worth of data out of the DLCI fifo to fix 1).
      Limit the max user data size per packet to MTU - 1 in case of convergence
      layer type 2 to leave space for the control signal octet which is added in
      the later part of the function. This fixes 2).
      Add tty_port_tty_wakeup() to wake up the user tty if new write space has
      been made available to fix 3).
      
      Fixes: 268e526b ("tty/n_gsm: avoid fifo overflow in gsm_dlci_data_output")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701061652.39604-3-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      556fc8ac
    • D
      tty: n_gsm: fix tty registration before control channel open · 01aecd91
      Daniel Starke 提交于
      The current implementation registers/deregisters the user ttys at mux
      attach/detach. That means that the user devices are available before any
      control channel is open. However, user channel initialization requires an
      open control channel. Furthermore, the user is not informed if the mux
      restarts due to configuration changes.
      Put the registration/deregistration procedure into separate function to
      improve readability.
      Move registration to mux activation and deregistration to mux cleanup to
      keep the user devices only open as long as a control channel exists. The
      user will be informed via the device driver if the mux was reconfigured in
      a way that required a mux re-activation.
      This makes it necessary to add T2 initialization to gsmld_open() for the
      ldisc open code path (not the reconfiguration code path) to avoid deletion
      of an uninitialized T2 at mux cleanup.
      
      Fixes: d50f6dca ("tty: n_gsm: expose gsmtty device nodes at ldisc open time")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701061652.39604-2-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      01aecd91
    • D
      tty: n_gsm: fix user open not possible at responder until initiator open · ac77f007
      Daniel Starke 提交于
      After setting up the control channel on both sides the responder side may
      want to open a virtual tty to listen on until the initiator starts an
      application on a user channel. The current implementation allows the
      open() but no other operation, like termios. These fail with EINVAL.
      The responder sided application has no means to detect an open by the
      initiator sided application this way. And the initiator sided applications
      usually expect the responder sided application to listen on the user
      channel upon open.
      Set the user channel into half-open state on responder side once a user
      application opens the virtual tty to allow IO operations on it.
      Furthermore, keep the user channel constipated until the initiator side
      opens it to give the responder sided application the chance to detect the
      new connection and to avoid data loss if the responder sided application
      starts sending before the user channel is open.
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: NDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220701061652.39604-1-daniel.starke@siemens.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac77f007
  7. 30 6月, 2022 5 次提交