08 Oct, 2020

1 commit

  • * tag 'v5.4.70': (3051 commits)
    Linux 5.4.70
    netfilter: ctnetlink: add a range check for l3/l4 protonum
    ep_create_wakeup_source(): dentry name can change under you...
    ...

    Conflicts:
    arch/arm/mach-imx/pm-imx6.c
    arch/arm64/boot/dts/freescale/imx8mm-evk.dts
    arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts
    drivers/crypto/caam/caamalg.c
    drivers/gpu/drm/imx/dw_hdmi-imx.c
    drivers/gpu/drm/imx/imx-ldb.c
    drivers/gpu/drm/imx/ipuv3/ipuv3-crtc.c
    drivers/mmc/host/sdhci-esdhc-imx.c
    drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
    drivers/net/ethernet/freescale/enetc/enetc.c
    drivers/net/ethernet/freescale/enetc/enetc_pf.c
    drivers/thermal/imx_thermal.c
    drivers/usb/cdns3/ep0.c
    drivers/xen/swiotlb-xen.c
    sound/soc/fsl/fsl_esai.c
    sound/soc/fsl/fsl_sai.c

    Signed-off-by: Jason Liu

    Jason Liu
     

01 Oct, 2020

7 commits

  • [ Upstream commit 7d31676a8d91dd18e08853efd1cb26961a38c6a6 ]

    Some variants of the samsung tty driver can pick which clock
    to use for their baud rate generation. In the DT conversion,
    a default clock was selected to be used if a specific one wasn't
    assigned and then a comparison of which clock rate worked better
    was done. Unfortunately, the comparison was implemented in such
    a way that only the default clock was ever actually compared.
    Fix this by iterating through all possible clocks, except when a
    specific clock has already been picked via clk_sel (which is
    only possible via board files).

    Signed-off-by: Jonathan Bakker
    Reviewed-by: Krzysztof Kozlowski
    Link: https://lore.kernel.org/r/BN6PR04MB06604E63833EA41837EBF77BA3A30@BN6PR04MB0660.namprd04.prod.outlook.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Jonathan Bakker
     
  • [ Upstream commit ff62255a2a5c1228a28f2bb063646f948115a309 ]

    Fix to return negative error code -ENOMEM from the error handling
    case instead of 0, as done elsewhere in this function.

    Signed-off-by: Wei Yongjun
    Link: https://lore.kernel.org/r/20200427122415.47416-1-weiyongjun1@huawei.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Wei Yongjun
     
  • [ Upstream commit 42e11948ddf68b9f799cad8c0ddeab0a39da33e8 ]

    On some platforms, the log is corrupted while console is being
    registered. It is observed that when set_termios is called, there
    are still some bytes in the FIFO to be transmitted.

    So, wait for tx_empty inside cdns_uart_console_setup before calling
    set_termios.

    Signed-off-by: Raviteja Narayanam
    Reviewed-by: Shubhrajyoti Datta
    Link: https://lore.kernel.org/r/1586413563-29125-2-git-send-email-raviteja.narayanam@xilinx.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Raviteja Narayanam
     
  • [ Upstream commit 7cf4df30a98175033e9849f7f16c46e96ba47f41 ]

    Terminate and flush DMA internal buffers, before pushing RX data to
    higher layer. Otherwise, this will lead to data corruption, as driver
    would end up pushing stale buffer data to higher layer while actual data
    is still stuck inside DMA hardware and has yet not arrived at the
    memory.
    While at that, replace deprecated dmaengine_terminate_all() with
    dmaengine_terminate_async().

    Signed-off-by: Vignesh Raghavendra
    Link: https://lore.kernel.org/r/20200319110344.21348-2-vigneshr@ti.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Vignesh Raghavendra
     
  • [ Upstream commit 4ce35a3617c0ac758c61122b2218b6c8c9ac9398 ]

    When booting j721e the following bug is printed:

    [ 1.154821] BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
    [ 1.154827] in_atomic(): 0, irqs_disabled(): 128, non_block: 0, pid: 12, name: kworker/0:1
    [ 1.154832] 3 locks held by kworker/0:1/12:
    [ 1.154836] #0: ffff000840030728 ((wq_completion)events){+.+.}, at: process_one_work+0x1d4/0x6e8
    [ 1.154852] #1: ffff80001214fdd8 (deferred_probe_work){+.+.}, at: process_one_work+0x1d4/0x6e8
    [ 1.154860] #2: ffff00084060b170 (&dev->mutex){....}, at: __device_attach+0x38/0x138
    [ 1.154872] irq event stamp: 63096
    [ 1.154881] hardirqs last enabled at (63095): [] _raw_spin_unlock_irqrestore+0x70/0x78
    [ 1.154887] hardirqs last disabled at (63096): [] _raw_spin_lock_irqsave+0x28/0x80
    [ 1.154893] softirqs last enabled at (62254): [] _stext+0x488/0x564
    [ 1.154899] softirqs last disabled at (62247): [] irq_exit+0x114/0x140
    [ 1.154906] CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.6.0-rc6-next-20200318-00094-g45e4089b0bd3 #221
    [ 1.154911] Hardware name: Texas Instruments K3 J721E SoC (DT)
    [ 1.154917] Workqueue: events deferred_probe_work_func
    [ 1.154923] Call trace:
    [ 1.154928] dump_backtrace+0x0/0x190
    [ 1.154933] show_stack+0x14/0x20
    [ 1.154940] dump_stack+0xe0/0x148
    [ 1.154946] ___might_sleep+0x150/0x1f0
    [ 1.154952] __might_sleep+0x4c/0x80
    [ 1.154957] wait_for_completion_timeout+0x40/0x140
    [ 1.154964] ti_sci_set_device_state+0xa0/0x158
    [ 1.154969] ti_sci_cmd_get_device_exclusive+0x14/0x20
    [ 1.154977] ti_sci_dev_start+0x34/0x50
    [ 1.154984] genpd_runtime_resume+0x78/0x1f8
    [ 1.154991] __rpm_callback+0x3c/0x140
    [ 1.154996] rpm_callback+0x20/0x80
    [ 1.155001] rpm_resume+0x568/0x758
    [ 1.155007] __pm_runtime_resume+0x44/0xb0
    [ 1.155013] omap8250_probe+0x2b4/0x508
    [ 1.155019] platform_drv_probe+0x50/0xa0
    [ 1.155023] really_probe+0xd4/0x318
    [ 1.155028] driver_probe_device+0x54/0xe8
    [ 1.155033] __device_attach_driver+0x80/0xb8
    [ 1.155039] bus_for_each_drv+0x74/0xc0
    [ 1.155044] __device_attach+0xdc/0x138
    [ 1.155049] device_initial_probe+0x10/0x18
    [ 1.155053] bus_probe_device+0x98/0xa0
    [ 1.155058] deferred_probe_work_func+0x74/0xb0
    [ 1.155063] process_one_work+0x280/0x6e8
    [ 1.155068] worker_thread+0x48/0x430
    [ 1.155073] kthread+0x108/0x138
    [ 1.155079] ret_from_fork+0x10/0x18

    To fix the bug we need to first call pm_runtime_enable() prior to any
    pm_runtime calls.

    Reported-by: Tomi Valkeinen
    Signed-off-by: Peter Ujfalusi
    Link: https://lore.kernel.org/r/20200320125200.6772-1-peter.ujfalusi@ti.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Peter Ujfalusi
     
  • [ Upstream commit f19c3f6c8109b8bab000afd35580929958e087a9 ]

    When port's throttle callback is called, it should stop pushing any more
    data into TTY buffer to avoid buffer overflow. This means driver has to
    stop HW from receiving more data and assert the HW flow control. For
    UARTs with auto HW flow control (such as 8250_omap) manual assertion of
    flow control line is not possible and only way is to allow RX FIFO to
    fill up, thus trigger auto HW flow control logic.

    Therefore make sure that 8250 generic IRQ handler does not drain data
    when port is stopped (i.e UART_LSR_DR is unset in read_status_mask). Not
    servicing, RX FIFO would trigger auto HW flow control when FIFO
    occupancy reaches preset threshold, thus halting RX.
    Since, error conditions in UART_LSR register are cleared just by reading
    the register, data has to be drained in case there are FIFO errors, else
    error information will lost.

    Signed-off-by: Vignesh Raghavendra
    Link: https://lore.kernel.org/r/20200319103230.16867-2-vigneshr@ti.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Vignesh Raghavendra
     
  • [ Upstream commit 4cbd7814bbd595061fcb6d6355d63f04179161cd ]

    SiFive's UART has a software controller clock divider that produces the
    final baud rate clock. Whenever the clock that drives the UART is
    changed this divider must be updated accordingly, and given that these
    two events are controlled by software they cannot be done atomically.
    During the period between updating the UART's driving clock and internal
    divider the UART will transmit a different baud rate than what the user
    has configured, which will probably result in a corrupted transmission
    stream.

    The SiFive UART has a FIFO, but due to an issue with the programming
    interface there is no way to directly determine when the UART has
    finished transmitting. We're essentially restricted to dead reckoning
    in order to figure that out: we can use the FIFO's TX busy register to
    figure out when the last frame has begun transmission and just delay for
    a long enough that the last frame is guaranteed to get out.

    As far as the actual implementation goes: I've modified the existing
    existing clock notifier function to drain both the FIFO and the shift
    register in on PRE_RATE_CHANGE. As far as I know there is no hardware
    flow control in this UART, so there's no good way to ask the other end
    to stop transmission while we can't receive (inserting software flow
    control messages seems like a bad idea here).

    Signed-off-by: Palmer Dabbelt
    Tested-by: Yash Shah
    Link: https://lore.kernel.org/r/20200307042637.83728-1-palmer@dabbelt.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Palmer Dabbelt
     

27 Sep, 2020

1 commit


23 Sep, 2020

1 commit

  • commit 3c5a87be170aba8ac40982182f812dcff6ed1ad1 upstream.

    These serial ports are exposed by the OOB-management-engine on
    RealManage-enabled network cards (e.g. AMD DASH enabled systems using
    Realtek cards).

    Because these have 3 BARs, they fail the "num_iomem TAbort+ SERR-
    Cc: stable
    Link: https://lore.kernel.org/r/20200914173628.GA22508@yamamaya.is-a-geek.org
    Signed-off-by: Greg Kroah-Hartman

    Tobias Diedrich
     

10 Sep, 2020

1 commit

  • [ Upstream commit 975efc66d4e654207c17f939eb737ac591ac38fe ]

    When booting with heavily modularized config, the serial console
    may not be able to load until after init when modules that
    satisfy needed dependencies have time to load.

    Unfortunately, as qcom_geni_console_setup is marked as __init,
    the function may have been freed before we get to run it,
    causing boot time crashes such as:

    [ 6.469057] Unable to handle kernel paging request at virtual address ffffffe645d4e6cc
    [ 6.481623] Mem abort info:
    [ 6.484466] ESR = 0x86000007
    [ 6.487557] EC = 0x21: IABT (current EL), IL = 32 bits
    [ 6.492929] SET = 0, FnV = 0g
    [ 6.496016] EA = 0, S1PTW = 0
    [ 6.499202] swapper pgtable: 4k pages, 39-bit VAs, pgdp=000000008151e000
    [ 6.501286] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2
    [ 6.505977] [ffffffe645d4e6cc] pgd=000000017df9f003, p4d=000000017df9f003, pud=000000017df9f003, pmd=000000017df9c003, pte=0000000000000000
    [ 6.505990] Internal error: Oops: 86000007 [#1] PREEMPT SMP
    [ 6.505995] Modules linked in: zl10353 zl10039 zl10036 zd1301_demod xc5000 xc4000 ves1x93 ves1820 tuner_xc2028 tuner_simple tuner_types tua9001 tua6100 1
    [ 6.506152] isl6405
    [ 6.518104] ufshcd-qcom 1d84000.ufshc: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0
    [ 6.530549] horus3a helene fc2580 fc0013 fc0012 fc0011 ec100 e4000 dvb_pll ds3000 drxk drxd drx39xyj dib9000 dib8000 dib7000p dib7000m dib3000mc dibx003
    [ 6.624271] CPU: 7 PID: 148 Comm: kworker/7:2 Tainted: G W 5.8.0-mainline-12021-g6defd37ba1cd #3455
    [ 6.624273] Hardware name: Thundercomm Dragonboard 845c (DT)
    [ 6.624290] Workqueue: events deferred_probe_work_func
    [ 6.624296] pstate: 40c00005 (nZcv daif +PAN +UAO BTYPE=--)
    [ 6.624307] pc : qcom_geni_console_setup+0x0/0x110
    [ 6.624316] lr : try_enable_new_console+0xa0/0x140
    [ 6.624318] sp : ffffffc010843a30
    [ 6.624320] x29: ffffffc010843a30 x28: ffffffe645c3e7d0
    [ 6.624325] x27: ffffff80f8022180 x26: ffffffc010843b28
    [ 6.637937] x25: 0000000000000000 x24: ffffffe6462a2000
    [ 6.637941] x23: ffffffe646398000 x22: 0000000000000000
    [ 6.637945] x21: 0000000000000000 x20: ffffffe6462a5ce8
    [ 6.637952] x19: ffffffe646398e38 x18: ffffffffffffffff
    [ 6.680296] x17: 0000000000000000 x16: ffffffe64492b900
    [ 6.680300] x15: ffffffe6461e9d08 x14: 69202930203d2064
    [ 6.680305] x13: 7561625f65736162 x12: 202c363331203d20
    [ 6.696434] x11: 0000000000000030 x10: 0101010101010101
    [ 6.696438] x9 : 4d4d20746120304d x8 : 7f7f7f7f7f7f7f7f
    [ 6.707249] x7 : feff4c524c787373 x6 : 0000000000008080
    [ 6.707253] x5 : 0000000000000000 x4 : 8080000000000000
    [ 6.707257] x3 : 0000000000000000 x2 : ffffffe645d4e6cc
    [ 6.744223] qcom_geni_serial 898000.serial: dev_pm_opp_set_rate: failed to find OPP for freq 102400000 (-34)
    [ 6.744966] x1 : fffffffefe74e174 x0 : ffffffe6462a5ce8
    [ 6.753580] qcom_geni_serial 898000.serial: dev_pm_opp_set_rate: failed to find OPP for freq 102400000 (-34)
    [ 6.761634] Call trace:
    [ 6.761639] qcom_geni_console_setup+0x0/0x110
    [ 6.761645] register_console+0x29c/0x2f8
    [ 6.767981] Bluetooth: hci0: Frame reassembly failed (-84)
    [ 6.775252] uart_add_one_port+0x438/0x500
    [ 6.775258] qcom_geni_serial_probe+0x2c4/0x4a8
    [ 6.775266] platform_drv_probe+0x58/0xa8
    [ 6.855359] really_probe+0xec/0x398
    [ 6.855362] driver_probe_device+0x5c/0xb8
    [ 6.855367] __device_attach_driver+0x98/0xb8
    [ 7.184945] bus_for_each_drv+0x74/0xd8
    [ 7.188825] __device_attach+0xec/0x148
    [ 7.192705] device_initial_probe+0x24/0x30
    [ 7.196937] bus_probe_device+0x9c/0xa8
    [ 7.200816] deferred_probe_work_func+0x7c/0xb8
    [ 7.205398] process_one_work+0x20c/0x4b0
    [ 7.209456] worker_thread+0x48/0x460
    [ 7.213157] kthread+0x14c/0x158
    [ 7.216432] ret_from_fork+0x10/0x18
    [ 7.220049] Code: bad PC value
    [ 7.223139] ---[ end trace 73f3b21e251d5a70 ]---

    Thus this patch removes the __init avoiding crash in such
    configs.

    Cc: Andy Gross
    Cc: Jiri Slaby
    Cc: Saravana Kannan
    Cc: Todd Kjos
    Cc: Amit Pundir
    Cc: linux-arm-msm@vger.kernel.org
    Cc: linux-serial@vger.kernel.org
    Suggested-by: Saravana Kannan
    Signed-off-by: John Stultz
    Reviewed-by: Bjorn Andersson
    Link: https://lore.kernel.org/r/20200811025044.70626-1-john.stultz@linaro.org
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    John Stultz
     

03 Sep, 2020

8 commits

  • commit 205d300aea75623e1ae4aa43e0d265ab9cf195fd upstream.

    We have a number of "uart.port->desc.lock vs desc.lock->uart.port"
    lockdep reports coming from 8250 driver; this causes a bit of trouble
    to people, so let's fix it.

    The problem is reverse lock order in two different call paths:

    chain #1:

    serial8250_do_startup()
    spin_lock_irqsave(&port->lock);
    disable_irq_nosync(port->irq);
    raw_spin_lock_irqsave(&desc->lock)

    chain #2:

    __report_bad_irq()
    raw_spin_lock_irqsave(&desc->lock)
    for_each_action_of_desc()
    printk()
    spin_lock_irqsave(&port->lock);

    Fix this by changing the order of locks in serial8250_do_startup():
    do disable_irq_nosync() first, which grabs desc->lock, and grab
    uart->port after that, so that chain #1 and chain #2 have same lock
    order.

    Full lockdep splat:

    ======================================================
    WARNING: possible circular locking dependency detected
    5.4.39 #55 Not tainted
    ======================================================

    swapper/0/0 is trying to acquire lock:
    ffffffffab65b6c0 (console_owner){-...}, at: console_lock_spinning_enable+0x31/0x57

    but task is already holding lock:
    ffff88810a8e34c0 (&irq_desc_lock_class){-.-.}, at: __report_bad_irq+0x5b/0xba

    which lock already depends on the new lock.

    the existing dependency chain (in reverse order) is:

    -> #2 (&irq_desc_lock_class){-.-.}:
    _raw_spin_lock_irqsave+0x61/0x8d
    __irq_get_desc_lock+0x65/0x89
    __disable_irq_nosync+0x3b/0x93
    serial8250_do_startup+0x451/0x75c
    uart_startup+0x1b4/0x2ff
    uart_port_activate+0x73/0xa0
    tty_port_open+0xae/0x10a
    uart_open+0x1b/0x26
    tty_open+0x24d/0x3a0
    chrdev_open+0xd5/0x1cc
    do_dentry_open+0x299/0x3c8
    path_openat+0x434/0x1100
    do_filp_open+0x9b/0x10a
    do_sys_open+0x15f/0x3d7
    kernel_init_freeable+0x157/0x1dd
    kernel_init+0xe/0x105
    ret_from_fork+0x27/0x50

    -> #1 (&port_lock_key){-.-.}:
    _raw_spin_lock_irqsave+0x61/0x8d
    serial8250_console_write+0xa7/0x2a0
    console_unlock+0x3b7/0x528
    vprintk_emit+0x111/0x17f
    printk+0x59/0x73
    register_console+0x336/0x3a4
    uart_add_one_port+0x51b/0x5be
    serial8250_register_8250_port+0x454/0x55e
    dw8250_probe+0x4dc/0x5b9
    platform_drv_probe+0x67/0x8b
    really_probe+0x14a/0x422
    driver_probe_device+0x66/0x130
    device_driver_attach+0x42/0x5b
    __driver_attach+0xca/0x139
    bus_for_each_dev+0x97/0xc9
    bus_add_driver+0x12b/0x228
    driver_register+0x64/0xed
    do_one_initcall+0x20c/0x4a6
    do_initcall_level+0xb5/0xc5
    do_basic_setup+0x4c/0x58
    kernel_init_freeable+0x13f/0x1dd
    kernel_init+0xe/0x105
    ret_from_fork+0x27/0x50

    -> #0 (console_owner){-...}:
    __lock_acquire+0x118d/0x2714
    lock_acquire+0x203/0x258
    console_lock_spinning_enable+0x51/0x57
    console_unlock+0x25d/0x528
    vprintk_emit+0x111/0x17f
    printk+0x59/0x73
    __report_bad_irq+0xa3/0xba
    note_interrupt+0x19a/0x1d6
    handle_irq_event_percpu+0x57/0x79
    handle_irq_event+0x36/0x55
    handle_fasteoi_irq+0xc2/0x18a
    do_IRQ+0xb3/0x157
    ret_from_intr+0x0/0x1d
    cpuidle_enter_state+0x12f/0x1fd
    cpuidle_enter+0x2e/0x3d
    do_idle+0x1ce/0x2ce
    cpu_startup_entry+0x1d/0x1f
    start_kernel+0x406/0x46a
    secondary_startup_64+0xa4/0xb0

    other info that might help us debug this:

    Chain exists of:
    console_owner --> &port_lock_key --> &irq_desc_lock_class

    Possible unsafe locking scenario:

    CPU0 CPU1
    ---- ----
    lock(&irq_desc_lock_class);
    lock(&port_lock_key);
    lock(&irq_desc_lock_class);
    lock(console_owner);

    *** DEADLOCK ***

    2 locks held by swapper/0/0:
    #0: ffff88810a8e34c0 (&irq_desc_lock_class){-.-.}, at: __report_bad_irq+0x5b/0xba
    #1: ffffffffab65b5c0 (console_lock){+.+.}, at: console_trylock_spinning+0x20/0x181

    stack backtrace:
    CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.39 #55
    Hardware name: XXXXXX
    Call Trace:

    dump_stack+0xbf/0x133
    ? print_circular_bug+0xd6/0xe9
    check_noncircular+0x1b9/0x1c3
    __lock_acquire+0x118d/0x2714
    lock_acquire+0x203/0x258
    ? console_lock_spinning_enable+0x31/0x57
    console_lock_spinning_enable+0x51/0x57
    ? console_lock_spinning_enable+0x31/0x57
    console_unlock+0x25d/0x528
    ? console_trylock+0x18/0x4e
    vprintk_emit+0x111/0x17f
    ? lock_acquire+0x203/0x258
    printk+0x59/0x73
    __report_bad_irq+0xa3/0xba
    note_interrupt+0x19a/0x1d6
    handle_irq_event_percpu+0x57/0x79
    handle_irq_event+0x36/0x55
    handle_fasteoi_irq+0xc2/0x18a
    do_IRQ+0xb3/0x157
    common_interrupt+0xf/0xf

    Signed-off-by: Sergey Senozhatsky
    Fixes: 768aec0b5bcc ("serial: 8250: fix shared interrupts issues with SMP and RT kernels")
    Reported-by: Guenter Roeck
    Reported-by: Raul Rangel
    BugLink: https://bugs.chromium.org/p/chromium/issues/detail?id=1114800
    Link: https://lore.kernel.org/lkml/CAHQZ30BnfX+gxjPm1DUd5psOTqbyDh4EJE=2=VAMW_VDafctkA@mail.gmail.com/T/#u
    Reviewed-by: Andy Shevchenko
    Reviewed-by: Guenter Roeck
    Tested-by: Guenter Roeck
    Cc: stable
    Link: https://lore.kernel.org/r/20200817022646.1484638-1-sergey.senozhatsky@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Sergey Senozhatsky
     
  • commit c6b9e95dde7b54e6a53c47241201ab5a4035c320 upstream.

    The following in 8250_exar.c line 589 is used to determine the number
    of ports for each Exar board:

    nr_ports = board->num_ports ? board->num_ports : pcidev->device & 0x0f;

    If the number of ports a card has is not explicitly specified, it defaults
    to the rightmost 4 bits of the PCI device ID. This is prone to error since
    not all PCI device IDs contain a number which corresponds to the number of
    ports that card provides.

    This particular case involves COMMTECH_4222PCIE, COMMTECH_4224PCIE and
    COMMTECH_4228PCIE cards with device IDs 0x0022, 0x0020 and 0x0021.
    Currently the multiport cards receive 2, 0 and 1 port instead of 2, 4 and
    8 ports respectively.

    To fix this, each Commtech Fastcom PCIe card is given a struct where the
    number of ports is explicitly specified. This ensures 'board->num_ports'
    is used instead of the default 'pcidev->device & 0x0f'.

    Fixes: d0aeaa83f0b0 ("serial: exar: split out the exar code from 8250_pci")
    Signed-off-by: Valmer Huhn
    Tested-by: Valmer Huhn
    Cc: stable
    Link: https://lore.kernel.org/r/20200813165255.GC345440@icarus.concurrent-rt.com
    Signed-off-by: Greg Kroah-Hartman

    Valmer Huhn
     
  • commit fdf16d78941b4f380753053d229955baddd00712 upstream.

    stm32_init_port() of the stm32-usart may trigger a warning in
    platform_get_irq() when the device tree specifies no wakeup interrupt.

    The wakeup interrupt is usually a board-specific GPIO and the driver
    functions correctly in its absence. The mainline stm32mp151.dtsi does
    not specify it, so all mainline device trees trigger an unnecessary
    kernel warning. Use of platform_get_irq_optional() avoids this.

    Fixes: 2c58e56096dd ("serial: stm32: fix the get_irq error case")
    Signed-off-by: Holger Assmann
    Cc: stable
    Link: https://lore.kernel.org/r/20200813152757.32751-1-h.assmann@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Holger Assmann
     
  • commit 89efbe70b27dd325d8a8c177743a26b885f7faec upstream.

    pl011_probe() calls pl011_setup_port() to reserve an amba_ports[] entry,
    then calls pl011_register_port() to register the uart driver with the
    tty layer.

    If registration of the uart driver fails, the amba_ports[] entry is not
    released. If this happens 14 times (value of UART_NR macro), then all
    amba_ports[] entries will have been leaked and driver probing is no
    longer possible. (To be fair, that can only happen if the DeviceTree
    doesn't contain alias IDs since they cause the same entry to be used for
    a given port.) Fix it.

    Fixes: ef2889f7ffee ("serial: pl011: Move uart_register_driver call to device")
    Signed-off-by: Lukas Wunner
    Cc: stable@vger.kernel.org # v3.15+
    Cc: Tushar Behera
    Link: https://lore.kernel.org/r/138f8c15afb2f184d8102583f8301575566064a6.1597316167.git.lukas@wunner.de
    Signed-off-by: Greg Kroah-Hartman

    Lukas Wunner
     
  • commit 27afac93e3bd7fa89749cf11da5d86ac9cde4dba upstream.

    If probing of a pl011 gets deferred until after free_initmem(), an oops
    ensues because pl011_console_match() is called which has been freed.

    Fix by removing the __init attribute from the function and those it
    calls.

    Commit 10879ae5f12e ("serial: pl011: add console matching function")
    introduced pl011_console_match() not just for early consoles but
    regular preferred consoles, such as those added by acpi_parse_spcr().
    Regular consoles may be registered after free_initmem() for various
    reasons, one being deferred probing, another being dynamic enablement
    of serial ports using a DeviceTree overlay.

    Thus, pl011_console_match() must not be declared __init and the
    functions it calls mustn't either.

    Stack trace for posterity:

    Unable to handle kernel paging request at virtual address 80c38b58
    Internal error: Oops: 8000000d [#1] PREEMPT SMP ARM
    PC is at pl011_console_match+0x0/0xfc
    LR is at register_console+0x150/0x468
    [] (register_console)
    [] (uart_add_one_port)
    [] (pl011_register_port)
    [] (pl011_probe)
    [] (amba_probe)
    [] (really_probe)
    [] (driver_probe_device)
    [] (__device_attach_driver)
    [] (bus_for_each_drv)
    [] (__device_attach)
    [] (device_initial_probe)
    [] (bus_probe_device)
    [] (deferred_probe_work_func)

    Fixes: 10879ae5f12e ("serial: pl011: add console matching function")
    Signed-off-by: Lukas Wunner
    Cc: stable@vger.kernel.org # v4.10+
    Cc: Aleksey Makarov
    Cc: Peter Hurley
    Cc: Russell King
    Cc: Christopher Covington
    Link: https://lore.kernel.org/r/f827ff09da55b8c57d316a1b008a137677b58921.1597315557.git.lukas@wunner.de
    Signed-off-by: Greg Kroah-Hartman

    Lukas Wunner
     
  • commit 8c6c378b0cbe0c9f1390986b5f8ffb5f6ff7593b upstream.

    In few older Samsung SoCs like s3c2410, s3c2412
    and s3c2440, UART IP is having 2 interrupt lines.
    However, in other SoCs like s3c6400, s5pv210,
    exynos5433, and exynos4210 UART is having only 1
    interrupt line. Due to this, "platform_get_irq(platdev, 1)"
    call in the driver gives the following false-positive error:
    "IRQ index 1 not found" on newer SoC's.

    This patch adds the condition to check for Tx interrupt
    only for the those SoC's which have 2 interrupt lines.

    Tested-by: Alim Akhtar
    Tested-by: Marek Szyprowski
    Reviewed-by: Krzysztof Kozlowski
    Reviewed-by: Alim Akhtar
    Signed-off-by: Tamseel Shams
    Cc: stable
    Link: https://lore.kernel.org/r/20200810030021.45348-1-m.shams@samsung.com
    Signed-off-by: Greg Kroah-Hartman

    Tamseel Shams
     
  • commit bc5269ca765057a1b762e79a1cfd267cd7bf1c46 upstream.

    vc_resize() can return with an error after failure. Change VT_RESIZEX ioctl
    to save struct vc_data values that are modified and restore the original
    values in case of error.

    Signed-off-by: George Kennedy
    Cc: stable
    Reported-by: syzbot+38a3699c7eaf165b97a6@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/1596213192-6635-2-git-send-email-george.kennedy@oracle.com
    Signed-off-by: Greg Kroah-Hartman

    George Kennedy
     
  • commit f8d1653daec02315e06d30246cff4af72e76e54e upstream.

    syzbot is reporting UAF bug in set_origin() from vc_do_resize() [1], for
    vc_do_resize() calls kfree(vc->vc_screenbuf) before calling set_origin().

    Unfortunately, in set_origin(), vc->vc_sw->con_set_origin() might access
    vc->vc_pos when scroll is involved in order to manipulate cursor, but
    vc->vc_pos refers already released vc->vc_screenbuf until vc->vc_pos gets
    updated based on the result of vc->vc_sw->con_set_origin().

    Preserving old buffer and tolerating outdated vc members until set_origin()
    completes would be easier than preventing vc->vc_sw->con_set_origin() from
    accessing outdated vc members.

    [1] https://syzkaller.appspot.com/bug?id=6649da2081e2ebdc65c0642c214b27fe91099db3

    Reported-by: syzbot
    Signed-off-by: Tetsuo Handa
    Cc: stable
    Link: https://lore.kernel.org/r/1596034621-4714-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp
    Signed-off-by: Greg Kroah-Hartman

    Tetsuo Handa
     

29 Jul, 2020

6 commits

  • commit ce684552a266cb1c7cc2f7e623f38567adec6653 upstream.

    syzbot is reporting general protection fault in do_con_write() [1] caused
    by vc->vc_screenbuf == ZERO_SIZE_PTR caused by vc->vc_screenbuf_size == 0
    caused by vc->vc_cols == vc->vc_rows == vc->vc_size_row == 0 caused by
    fb_set_var() from ioctl(FBIOPUT_VSCREENINFO) on /dev/fb0 , for
    gotoxy(vc, 0, 0) from reset_terminal() from vc_init() from vc_allocate()
    from con_install() from tty_init_dev() from tty_open() on such console
    causes vc->vc_pos == 0x10000000e due to
    ((unsigned long) ZERO_SIZE_PTR) + -1U * 0 + (-1U << 1).

    I don't think that a console with 0 column or 0 row makes sense. And it
    seems that vc_do_resize() does not intend to allow resizing a console to
    0 column or 0 row due to

    new_cols = (cols ? cols : vc->vc_cols);
    new_rows = (lines ? lines : vc->vc_rows);

    exception.

    Theoretically, cols and rows can be any range as long as
    0 < cols * rows * 2 vc_size_row = vc->vc_cols << 1;
    vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;

    in visual_init() and kzalloc(vc->vc_screenbuf_size) in vc_allocate().

    Since we can detect cols == 0 or rows == 0 via screenbuf_size = 0 in
    visual_init(), we can reject kzalloc(0). Then, vc_allocate() will return
    an error, and con_write() will not be called on a console with 0 column
    or 0 row.

    We need to make sure that integer overflow in visual_init() won't happen.
    Since vc_do_resize() restricts cols
    Signed-off-by: Tetsuo Handa
    Cc: stable
    Link: https://lore.kernel.org/r/20200712111013.11881-1-penguin-kernel@I-love.SAKURA.ne.jp
    Signed-off-by: Greg Kroah-Hartman

    Tetsuo Handa
     
  • commit 551e553f0d4ab623e2a6f424ab5834f9c7b5229c upstream.

    Commit 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250
    port") fixed limits of a baud rate setting for a generic 8250 port.
    In other words since that commit the baud rate has been permitted to be
    within [uartclk / 16 / UART_DIV_MAX; uartclk / 16], which is absolutely
    normal for a standard 8250 UART port. But there are custom 8250 ports,
    which provide extended baud rate limits. In particular the Mediatek 8250
    port can work with baud rates up to "uartclk" speed.

    Normally that and any other peculiarity is supposed to be handled in a
    custom set_termios() callback implemented in the vendor-specific
    8250-port glue-driver. Currently that is how it's done for the most of
    the vendor-specific 8250 ports, but for some reason for Mediatek a
    solution has been spread out to both the glue-driver and to the generic
    8250-port code. Due to that a bug has been introduced, which permitted the
    extended baud rate limit for all even for standard 8250-ports. The bug
    has been fixed by the commit 7b668c064ec3 ("serial: 8250: Fix max baud
    limit in generic 8250 port") by narrowing the baud rates limit back down to
    the normal bounds. Unfortunately by doing so we also broke the
    Mediatek-specific extended bauds feature.

    A fix of the problem described above is twofold. First since we can't get
    back the extended baud rate limits feature to the generic set_termios()
    function and that method supports only a standard baud rates range, the
    requested baud rate must be locally stored before calling it and then
    restored back to the new termios structure after the generic set_termios()
    finished its magic business. By doing so we still use the
    serial8250_do_set_termios() method to set the LCR/MCR/FCR/etc. registers,
    while the extended baud rate setting procedure will be performed later in
    the custom Mediatek-specific set_termios() callback. Second since a true
    baud rate is now fully calculated in the custom set_termios() method we
    need to locally update the port timeout by calling the
    uart_update_timeout() function. After the fixes described above are
    implemented in the 8250_mtk.c driver, the Mediatek 8250-port should
    get back to normally working with extended baud rates.

    Link: https://lore.kernel.org/linux-serial/20200701211337.3027448-1-danielwinkler@google.com

    Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 port")
    Reported-by: Daniel Winkler
    Signed-off-by: Serge Semin
    Cc: stable
    Tested-by: Claire Chang
    Link: https://lore.kernel.org/r/20200714124113.20918-1-Sergey.Semin@baikalelectronics.ru
    Signed-off-by: Greg Kroah-Hartman

    Serge Semin
     
  • commit f4c23a140d80ef5e6d3d1f8f57007649014b60fa upstream.

    I got null-ptr-deref in serial8250_start_tx():

    [ 78.114630] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
    [ 78.123778] Mem abort info:
    [ 78.126560] ESR = 0x86000007
    [ 78.129603] EC = 0x21: IABT (current EL), IL = 32 bits
    [ 78.134891] SET = 0, FnV = 0
    [ 78.137933] EA = 0, S1PTW = 0
    [ 78.141064] user pgtable: 64k pages, 48-bit VAs, pgdp=00000027d41a8600
    [ 78.147562] [0000000000000000] pgd=00000027893f0003, p4d=00000027893f0003, pud=00000027893f0003, pmd=00000027c9a20003, pte=0000000000000000
    [ 78.160029] Internal error: Oops: 86000007 [#1] SMP
    [ 78.164886] Modules linked in: sunrpc vfat fat aes_ce_blk crypto_simd cryptd aes_ce_cipher crct10dif_ce ghash_ce sha2_ce sha256_arm64 sha1_ce ses enclosure sg sbsa_gwdt ipmi_ssif spi_dw_mmio sch_fq_codel vhost_net tun vhost vhost_iotlb tap ip_tables ext4 mbcache jbd2 ahci hisi_sas_v3_hw libahci hisi_sas_main libsas hns3 scsi_transport_sas hclge libata megaraid_sas ipmi_si hnae3 ipmi_devintf ipmi_msghandler br_netfilter bridge stp llc nvme nvme_core xt_sctp sctp libcrc32c dm_mod nbd
    [ 78.207383] CPU: 11 PID: 23258 Comm: null-ptr Not tainted 5.8.0-rc6+ #48
    [ 78.214056] Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V3.B210.01 03/12/2020
    [ 78.222888] pstate: 80400089 (Nzcv daIf +PAN -UAO BTYPE=--)
    [ 78.228435] pc : 0x0
    [ 78.230618] lr : serial8250_start_tx+0x160/0x260
    [ 78.235215] sp : ffff800062eefb80
    [ 78.238517] x29: ffff800062eefb80 x28: 0000000000000fff
    [ 78.243807] x27: ffff800062eefd80 x26: ffff202fd83b3000
    [ 78.249098] x25: ffff800062eefd80 x24: ffff202fd83b3000
    [ 78.254388] x23: ffff002fc5e50be8 x22: 0000000000000002
    [ 78.259679] x21: 0000000000000001 x20: 0000000000000000
    [ 78.264969] x19: ffffa688827eecc8 x18: 0000000000000000
    [ 78.270259] x17: 0000000000000000 x16: 0000000000000000
    [ 78.275550] x15: ffffa68881bc67a8 x14: 00000000000002e6
    [ 78.280841] x13: ffffa68881bc67a8 x12: 000000000000c539
    [ 78.286131] x11: d37a6f4de9bd37a7 x10: ffffa68881cccff0
    [ 78.291421] x9 : ffffa68881bc6000 x8 : ffffa688819daa88
    [ 78.296711] x7 : ffffa688822a0f20 x6 : ffffa688819e0000
    [ 78.302002] x5 : ffff800062eef9d0 x4 : ffffa68881e707a8
    [ 78.307292] x3 : 0000000000000000 x2 : 0000000000000002
    [ 78.312582] x1 : 0000000000000001 x0 : ffffa688827eecc8
    [ 78.317873] Call trace:
    [ 78.320312] 0x0
    [ 78.322147] __uart_start.isra.9+0x64/0x78
    [ 78.326229] uart_start+0xb8/0x1c8
    [ 78.329620] uart_flush_chars+0x24/0x30
    [ 78.333442] n_tty_receive_buf_common+0x7b0/0xc30
    [ 78.338128] n_tty_receive_buf+0x44/0x2c8
    [ 78.342122] tty_ioctl+0x348/0x11f8
    [ 78.345599] ksys_ioctl+0xd8/0xf8
    [ 78.348903] __arm64_sys_ioctl+0x2c/0xc8
    [ 78.352812] el0_svc_common.constprop.2+0x88/0x1b0
    [ 78.357583] do_el0_svc+0x44/0xd0
    [ 78.360887] el0_sync_handler+0x14c/0x1d0
    [ 78.364880] el0_sync+0x140/0x180
    [ 78.368185] Code: bad PC value

    SERIAL_PORT_DFNS is not defined on each arch, if it's not defined,
    serial8250_set_defaults() won't be called in serial8250_isa_init_ports(),
    so the p->serial_in pointer won't be initialized, and it leads a null-ptr-deref.
    Fix this problem by calling serial8250_set_defaults() after init uart port.

    Signed-off-by: Yang Yingliang
    Cc: stable
    Link: https://lore.kernel.org/r/20200721143852.4058352-1-yangyingliang@huawei.com
    Signed-off-by: Greg Kroah-Hartman

    Yang Yingliang
     
  • commit b374c562ee7ab3f3a1daf959c01868bae761571c upstream.

    Commit 33ae787b74fc ("serial: tegra: add support to ignore read") added
    support for dropping input in case CREAD isn't set, but for PIO the
    ignore_status_mask wasn't checked until after the character had been
    put in the receive buffer.

    Note that the NULL tty-port test is bogus and will be removed by a
    follow-on patch.

    Fixes: 33ae787b74fc ("serial: tegra: add support to ignore read")
    Cc: stable # 5.4
    Cc: Shardar Shariff Md
    Cc: Krishna Yarlagadda
    Signed-off-by: Johan Hovold
    Acked-by: Thierry Reding
    Link: https://lore.kernel.org/r/20200710135947.2737-2-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Johan Hovold
     
  • commit 22a82fa7d6c3e16d56a036b1fa697a39b954adf0 upstream.

    The problems started with the revert (18cc7ac8a28e28). The
    cdns_uart_console.index is statically assigned -1. When the port is
    registered, Linux assigns consecutive numbers to it. It turned out that
    when using ttyPS1 as console, the index is not updated as we are reusing
    the same cdns_uart_console instance for multiple ports. When registering
    ttyPS0, it gets updated from -1 to 0, but when registering ttyPS1, it
    already is 0 and not updated.

    That led to 2ae11c46d5fdc4. It assigns the index prior to registering
    the uart_driver once. Unfortunately, that ended up breaking the
    situation where the probe order does not match the id order. When using
    the same device tree for both uboot and linux, it is important that the
    serial0 alias points to the console. So some boards reverse those
    aliases. This was reported by Jan Kiszka. The proposed fix was reverting
    the index assignment and going back to the previous iteration.

    However such a reversed assignement (serial0 -> uart1, serial1 -> uart0)
    was already partially broken by the revert (18cc7ac8a28e28). While the
    ttyPS device works, the kmsg connection is already broken and kernel
    messages go missing. Reverting the id assignment does not fix this.

    >From the xilinx_uartps driver pov (after reverting the refactoring
    commits), there can be only one console. This manifests in static
    variables console_pprt and cdns_uart_console. These variables are not
    properly linked and can go out of sync. The cdns_uart_console.index is
    important for uart_add_one_port. We call that function for each port -
    one of which hopefully is the console. If it isn't, the CON_ENABLED flag
    is not set and console_port is cleared. The next cdns_uart_probe call
    then tries to register the next port using that same cdns_uart_console.

    It is important that console_port and cdns_uart_console (and its index
    in particular) stay in sync. The index assignment implemented by
    Shubhrajyoti Datta is correct in principle. It just may have to happen a
    second time if the first cdns_uart_probe call didn't encounter the
    console device. And we shouldn't change the index once the console uart
    is registered.

    Reported-by: Shubhrajyoti Datta
    Reported-by: Jan Kiszka
    Link: https://lore.kernel.org/linux-serial/f4092727-d8f5-5f91-2c9f-76643aace993@siemens.com/
    Fixes: 18cc7ac8a28e28 ("Revert "serial: uartps: Register own uart console and driver structures"")
    Fixes: 2ae11c46d5fdc4 ("tty: xilinx_uartps: Fix missing id assignment to the console")
    Fixes: 76ed2e10579671 ("Revert "tty: xilinx_uartps: Fix missing id assignment to the console"")
    Signed-off-by: Helmut Grohne
    Cc: stable
    Link: https://lore.kernel.org/r/20200713073227.GA3805@laureti-dev
    Signed-off-by: Greg Kroah-Hartman

    Helmut Grohne
     
  • [ Upstream commit 5fdbe136ae19ab751daaa4d08d9a42f3e30d17f9 ]

    Sealevel XR17V35X based devices are inoperable on kernel versions
    4.11 and above due to a change in the GPIO preconfiguration introduced in
    commit
    7dea8165f1d. This patch fixes this by preconfiguring the GPIO on Sealevel
    cards to the value (0x00) used prior to commit 7dea8165f1d

    With GPIOs preconfigured as per commit 7dea8165f1d all ports on
    Sealevel XR17V35X based devices become stuck in high impedance
    mode, regardless of dip-switch or software configuration. This
    causes the device to become effectively unusable. This patch (in
    various forms) has been distributed to our customers and no issues
    related to it have been reported.

    Fixes: 7dea8165f1d6 ("serial: exar: Preconfigure xr17v35x MPIOs as output")
    Signed-off-by: Matthew Howell
    Link: https://lore.kernel.org/r/alpine.DEB.2.21.2007221605270.13247@tstest-VirtualBox
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Matthew Howell
     

22 Jul, 2020

2 commits

  • commit d8edf8eb5f6e921fe6389f96d2cd05862730a6ff upstream.

    This driver calls ioremap() in probe, but it misses calling iounmap() in
    probe's error handler and remove.
    Add the missed calls to fix it.

    Fixes: 47d37d6f94cc ("serial: Add auart driver for i.MX23/28")
    Signed-off-by: Chuhong Yuan
    Cc: stable
    Link: https://lore.kernel.org/r/20200709135608.68290-1-hslester96@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Chuhong Yuan
     
  • commit 76ed2e105796710cf5b8a4ba43c81eceed948b70 upstream.

    This reverts commit 2ae11c46d5fdc46cb396e35911c713d271056d35.

    It turned out to break the ultra96-rev1, e.g., which uses uart1 as
    serial0 (and stdout-path = "serial0:115200n8").

    Fixes: 2ae11c46d5fd ("tty: xilinx_uartps: Fix missing id assignment to the console")
    Cc: stable
    Signed-off-by: Jan Kiszka
    Reviewed-by: Michal Simek
    Tested-by: Michal Simek
    Link: https://lore.kernel.org/r/f4092727-d8f5-5f91-2c9f-76643aace993@siemens.com
    Signed-off-by: Greg Kroah-Hartman

    Jan Kiszka
     

01 Jul, 2020

1 commit

  • commit cf9c94456ebafc6d75a834e58dfdc8ae71a3acbc upstream.

    This reverts commit e2bd1dcbe1aa34ff5570b3427c530e4332ecf0fe.

    In discussion on the mailing list, it has been determined that this is
    not the correct type of fix for this issue. Revert it so that we can do
    this correctly.

    Reported-by: Jiri Slaby
    Reported-by: Greg Kroah-Hartman
    Link: https://lore.kernel.org/r/20200428032601.22127-1-rananta@codeaurora.org
    Cc: Raghavendra Rao Ananta
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

24 Jun, 2020

6 commits

  • [ Upstream commit 4dd31f1ffec6c370c3c2e0c605628bf5e16d5c46 ]

    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")
    Signed-off-by: Gregory CLEMENT
    Link: https://lore.kernel.org/r/20200518084517.2173242-3-gregory.clement@bootlin.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Gregory CLEMENT
     
  • [ Upstream commit 01dbb362f0a114fbce19c8abe4cd6f4710e934d5 ]

    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")
    Signed-off-by: Gregory CLEMENT
    Link: https://lore.kernel.org/r/20200512115323.1447922-4-gregory.clement@bootlin.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Gregory CLEMENT
     
  • [ Upstream commit 84d6f81c1fb58b56eba81ff0a36cf31946064b40 ]

    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")
    Signed-off-by: Gregory CLEMENT
    Link: https://lore.kernel.org/r/20200512115323.1447922-3-gregory.clement@bootlin.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Gregory CLEMENT
     
  • [ Upstream commit 8508f4cba308f785b2fd4b8c38849c117b407297 ]

    Valentine reported seeing:

    [ 3.626638] INFO: trying to register non-static key.
    [ 3.626639] the code is fine but needs lockdep annotation.
    [ 3.626640] turning off the locking correctness validator.
    [ 3.626644] CPU: 7 PID: 51 Comm: kworker/7:1 Not tainted 5.7.0-rc2-00115-g8c2e9790f196 #116
    [ 3.626646] Hardware name: HiKey960 (DT)
    [ 3.626656] Workqueue: events deferred_probe_work_func
    [ 3.632476] sd 0:0:0:0: [sda] Optimal transfer size 8192 bytes not a multiple of physical block size (16384 bytes)
    [ 3.640220] Call trace:
    [ 3.640225] dump_backtrace+0x0/0x1b8
    [ 3.640227] show_stack+0x20/0x30
    [ 3.640230] dump_stack+0xec/0x158
    [ 3.640234] register_lock_class+0x598/0x5c0
    [ 3.640235] __lock_acquire+0x80/0x16c0
    [ 3.640236] lock_acquire+0xf4/0x4a0
    [ 3.640241] _raw_spin_lock_irqsave+0x70/0xa8
    [ 3.640245] uart_add_one_port+0x388/0x4b8
    [ 3.640248] pl011_register_port+0x70/0xf0
    [ 3.640250] pl011_probe+0x184/0x1b8
    [ 3.640254] amba_probe+0xdc/0x180
    [ 3.640256] really_probe+0xe0/0x338
    [ 3.640257] driver_probe_device+0x60/0xf8
    [ 3.640259] __device_attach_driver+0x8c/0xd0
    [ 3.640260] bus_for_each_drv+0x84/0xd8
    [ 3.640261] __device_attach+0xe4/0x140
    [ 3.640263] device_initial_probe+0x1c/0x28
    [ 3.640265] bus_probe_device+0xa4/0xb0
    [ 3.640266] deferred_probe_work_func+0x7c/0xb8
    [ 3.640269] process_one_work+0x2c0/0x768
    [ 3.640271] worker_thread+0x4c/0x498
    [ 3.640272] kthread+0x14c/0x158
    [ 3.640275] ret_from_fork+0x10/0x1c

    Which seems to be due to the fact that after allocating the uap
    structure, nothing initializes the spinlock.

    Its a little confusing, as uart_port_spin_lock_init() is one
    place where the lock is supposed to be initialized, but it has
    an exception for the case where the port is a console.

    This makes it seem like a deeper fix is needed to properly
    register the console, but I'm not sure what that entails, and
    Andy suggested that this approach is less invasive.

    Thus, this patch resolves the issue by initializing the spinlock
    in the driver, and resolves the resulting warning.

    Cc: Andy Shevchenko
    Cc: Russell King
    Cc: Jiri Slaby
    Cc: linux-serial@vger.kernel.org
    Reported-by: Valentin Schneider
    Reviewed-by: Andy Shevchenko
    Signed-off-by: John Stultz
    Reviewed-and-tested-by: Valentin Schneider
    Link: https://lore.kernel.org/r/20200428184050.6501-1-john.stultz@linaro.org
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    John Stultz
     
  • [ Upstream commit e2bd1dcbe1aa34ff5570b3427c530e4332ecf0fe ]

    Potentially, hvc_open() can be called in parallel when two tasks calls
    open() on /dev/hvcX. In such a scenario, if the hp->ops->notifier_add()
    callback in the function fails, where it sets the tty->driver_data to
    NULL, the parallel hvc_open() can see this NULL and cause a memory abort.
    Hence, serialize hvc_open and check if tty->private_data is NULL before
    proceeding ahead.

    The issue can be easily reproduced by launching two tasks simultaneously
    that does nothing but open() and close() on /dev/hvcX.
    For example:
    $ ./simple_open_close /dev/hvc0 & ./simple_open_close /dev/hvc0 &

    Signed-off-by: Raghavendra Rao Ananta
    Link: https://lore.kernel.org/r/20200428032601.22127-1-rananta@codeaurora.org
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Raghavendra Rao Ananta
     
  • [ Upstream commit 7b668c064ec33f3d687c3a413d05e355172e6c92 ]

    Standard 8250 UART ports are designed in a way so they can communicate
    with baud rates up to 1/16 of a reference frequency. It's expected from
    most of the currently supported UART controllers. That's why the former
    version of serial8250_get_baud_rate() method called uart_get_baud_rate()
    with min and max baud rates passed as (port->uartclk / 16 / UART_DIV_MAX)
    and ((port->uartclk + tolerance) / 16) respectively. Doing otherwise, like
    it was suggested in commit ("serial: 8250_mtk: support big baud rate."),
    caused acceptance of bauds, which was higher than the normal UART
    controllers actually supported. As a result if some user-space program
    requested to set a baud greater than (uartclk / 16) it would have been
    permitted without truncation, but then serial8250_get_divisor(baud)
    (which calls uart_get_divisor() to get the reference clock divisor) would
    have returned a zero divisor. Setting zero divisor will cause an
    unpredictable effect varying from chip to chip. In case of DW APB UART the
    communications just stop.

    Lets fix this problem by getting back the limitation of (uartclk +
    tolerance) / 16 maximum baud supported by the generic 8250 port. Mediatek
    8250 UART ports driver developer shouldn't have touched it in the first
    place notably seeing he already provided a custom version of set_termios()
    callback in that glue-driver which took into account the extended baud
    rate values and accordingly updated the standard and vendor-specific
    divisor latch registers anyway.

    Fixes: 81bb549fdf14 ("serial: 8250_mtk: support big baud rate.")
    Signed-off-by: Serge Semin
    Cc: Alexey Malahov
    Cc: Thomas Bogendoerfer
    Cc: Paul Burton
    Cc: Ralf Baechle
    Cc: Arnd Bergmann
    Cc: Long Cheng
    Cc: Andy Shevchenko
    Cc: Maxime Ripard
    Cc: Catalin Marinas
    Cc: Will Deacon
    Cc: Russell King
    Cc: linux-mips@vger.kernel.org
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-mediatek@lists.infradead.org
    Link: https://lore.kernel.org/r/20200506233136.11842-2-Sergey.Semin@baikalelectronics.ru
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Serge Semin
     

22 Jun, 2020

3 commits

  • commit e0a851fe6b9b619527bd928aa93caaddd003f70c upstream.

    If the call to uart_add_one_port() in serial8250_register_8250_port()
    fails, a half-initialized entry in the serial_8250ports[] array is left
    behind.

    A subsequent reprobe of the same serial port causes that entry to be
    reused. Because uart->port.dev is set, uart_remove_one_port() is called
    for the half-initialized entry and bails out with an error message:

    bcm2835-aux-uart 3f215040.serial: Removing wrong port: (null) != (ptrval)

    The same happens on failure of mctrl_gpio_init() since commit
    4a96895f74c9 ("tty/serial/8250: use mctrl_gpio helpers").

    Fix by zeroing the uart->port.dev pointer in the probe error path.

    The bug was introduced in v2.6.10 by historical commit befff6f5bf5f
    ("[SERIAL] Add new port registration/unregistration functions."):
    https://git.kernel.org/tglx/history/c/befff6f5bf5f

    The commit added an unconditional call to uart_remove_one_port() in
    serial8250_register_port(). In v3.7, commit 835d844d1a28 ("8250_pnp:
    do pnp probe before legacy probe") made that call conditional on
    uart->port.dev which allows me to fix the issue by zeroing that pointer
    in the error path. Thus, the present commit will fix the problem as far
    back as v3.7 whereas still older versions need to also cherry-pick
    835d844d1a28.

    Fixes: 835d844d1a28 ("8250_pnp: do pnp probe before legacy probe")
    Signed-off-by: Lukas Wunner
    Cc: stable@vger.kernel.org # v2.6.10
    Cc: stable@vger.kernel.org # v2.6.10: 835d844d1a28: 8250_pnp: do pnp probe before legacy
    Reviewed-by: Andy Shevchenko
    Link: https://lore.kernel.org/r/b4a072013ee1a1d13ee06b4325afb19bda57ca1b.1589285873.git.lukas@wunner.de
    Signed-off-by: Greg Kroah-Hartman

    Lukas Wunner
     
  • [ Upstream commit 62a7f3009a460001eb46984395280dd900bc4ef4 ]

    Move the IDs to pci_ids.h so it can be used by next patch.

    Link: https://lore.kernel.org/r/20200508065343.32751-1-kai.heng.feng@canonical.com
    Signed-off-by: Kai-Heng Feng
    Signed-off-by: Bjorn Helgaas
    Acked-by: Greg Kroah-Hartman
    Cc: stable@vger.kernel.org
    Signed-off-by: Sasha Levin

    Kai-Heng Feng
     
  • [ Upstream commit 68e55f61c13842baf825958129698c5371db432c ]

    If you build CONFIG_KGDB_SERIAL_CONSOLE into the kernel then you
    should be able to have KGDB init itself at bootup by specifying the
    "kgdboc=..." kernel command line parameter. This has worked OK for me
    for many years, but on a new device I switched to it stopped working.

    The problem is that on this new device the serial driver gets its
    probe deferred. Now when kgdb initializes it can't find the tty
    driver and when it gives up it never tries again.

    We could try to find ways to move up the initialization of the serial
    driver and such a thing might be worthwhile, but it's nice to be
    robust against serial drivers that load late. We could move kgdb to
    init itself later but that penalizes our ability to debug early boot
    code on systems where the driver inits early. We could roll our own
    system of detecting when new tty drivers get loaded and then use that
    to figure out when kgdb can init, but that's ugly.

    Instead, let's jump on the -EPROBE_DEFER bandwagon. We'll create a
    singleton instance of a "kgdboc" platform device. If we can't find
    our tty device when the singleton "kgdboc" probes we'll return
    -EPROBE_DEFER which means that the system will call us back later to
    try again when the tty device might be there.

    We won't fully transition all of the kgdboc to a platform device
    because early kgdb initialization (via the "ekgdboc" kernel command
    line parameter) still runs before the platform device has been
    created. The kgdb platform device is merely used as a convenient way
    to hook into the system's normal probe deferral mechanisms.

    As part of this, we'll ever-so-slightly change how the "kgdboc=..."
    kernel command line parameter works. Previously if you booted up and
    kgdb couldn't find the tty driver then later reading
    '/sys/module/kgdboc/parameters/kgdboc' would return a blank string.
    Now kgdb will keep track of the string that came as part of the
    command line and give it back to you. It's expected that this should
    be an OK change.

    Signed-off-by: Douglas Anderson
    Reviewed-by: Greg Kroah-Hartman
    Reviewed-by: Daniel Thompson
    Link: https://lore.kernel.org/r/20200507130644.v4.3.I4a493cfb0f9f740ce8fd2ab58e62dc92d18fed30@changeid
    [daniel.thompson@linaro.org: Make config_mutex static]
    Signed-off-by: Daniel Thompson
    Signed-off-by: Sasha Levin

    Douglas Anderson
     

19 Jun, 2020

1 commit

  • * tag 'v5.4.47': (2193 commits)
    Linux 5.4.47
    KVM: arm64: Save the host's PtrAuth keys in non-preemptible context
    KVM: arm64: Synchronize sysreg state on injecting an AArch32 exception
    ...

    Conflicts:
    arch/arm/boot/dts/imx6qdl.dtsi
    arch/arm/mach-imx/Kconfig
    arch/arm/mach-imx/common.h
    arch/arm/mach-imx/suspend-imx6.S
    arch/arm64/boot/dts/freescale/imx8qxp-mek.dts
    arch/powerpc/include/asm/cacheflush.h
    drivers/cpufreq/imx6q-cpufreq.c
    drivers/dma/imx-sdma.c
    drivers/edac/synopsys_edac.c
    drivers/firmware/imx/imx-scu.c
    drivers/net/ethernet/freescale/fec.h
    drivers/net/ethernet/freescale/fec_main.c
    drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
    drivers/net/phy/phy_device.c
    drivers/perf/fsl_imx8_ddr_perf.c
    drivers/usb/cdns3/gadget.c
    drivers/usb/dwc3/gadget.c
    include/uapi/linux/dma-buf.h

    Signed-off-by: Jason Liu

    Jason Liu
     

11 Jun, 2020

2 commits

  • commit 24eb2377f977fe06d84fca558f891f95bc28a449 upstream.

    hvc_open sets tty->driver_data to NULL when open fails at some point.
    Typically, the failure happens in hp->ops->notifier_add(). If there is
    a racing process which tries to open such mangled tty, which was not
    closed yet, the process will crash in hvc_open as tty->driver_data is
    NULL.

    All this happens because close wants to know whether open failed or not.
    But ->open should not NULL this and other tty fields for ->close to be
    happy. ->open should call tty_port_set_initialized(true) and close
    should check by tty_port_initialized() instead. So do this properly in
    this driver.

    So this patch removes these from ->open:
    * tty_port_tty_set(&hp->port, NULL). This happens on last close.
    * tty->driver_data = NULL. Dtto.
    * tty_port_put(&hp->port). This happens in shutdown and until now, this
    must have been causing a reference underflow, if I am not missing
    something.

    Signed-off-by: Jiri Slaby
    Cc: stable
    Reported-and-tested-by: Raghavendra
    Link: https://lore.kernel.org/r/20200526145632.13879-1-jslaby@suse.cz
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • commit b86dab054059b970111b5516ae548efaae5b3aae upstream.

    When k_ascii is invoked several times in a row there is a potential for
    signed integer overflow:

    UBSAN: Undefined behaviour in drivers/tty/vt/keyboard.c:888:19 signed integer overflow:
    10 * 1111111111 cannot be represented in type 'int'
    CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.6.11 #1
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
    Call Trace:

    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0xce/0x128 lib/dump_stack.c:118
    ubsan_epilogue+0xe/0x30 lib/ubsan.c:154
    handle_overflow+0xdc/0xf0 lib/ubsan.c:184
    __ubsan_handle_mul_overflow+0x2a/0x40 lib/ubsan.c:205
    k_ascii+0xbf/0xd0 drivers/tty/vt/keyboard.c:888
    kbd_keycode drivers/tty/vt/keyboard.c:1477 [inline]
    kbd_event+0x888/0x3be0 drivers/tty/vt/keyboard.c:1495

    While it can be worked around by using check_mul_overflow()/
    check_add_overflow(), it is better to introduce a separate flag to
    signal that number pad is being used to compose a symbol, and
    change type of the accumulator from signed to unsigned, thus
    avoiding undefined behavior when it overflows.

    Reported-by: Kyungtae Kim
    Signed-off-by: Dmitry Torokhov
    Cc: stable
    Link: https://lore.kernel.org/r/20200525232740.GA262061@dtor-ws
    Signed-off-by: Greg Kroah-Hartman

    Dmitry Torokhov