From patchwork Sat Jul 13 21:08:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 11043133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A3A96C5 for ; Sat, 13 Jul 2019 21:09:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E7F42821F for ; Sat, 13 Jul 2019 21:09:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B736282EC; Sat, 13 Jul 2019 21:09:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B35F2821F for ; Sat, 13 Jul 2019 21:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbfGMVI7 (ORCPT ); Sat, 13 Jul 2019 17:08:59 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:37654 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727553AbfGMVI7 (ORCPT ); Sat, 13 Jul 2019 17:08:59 -0400 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23992479AbfGMVIzSG7pN (ORCPT + 1 other); Sat, 13 Jul 2019 23:08:55 +0200 Date: Sat, 13 Jul 2019 23:08:53 +0200 From: Ladislav Michl To: linux-usb@vger.kernel.org, linux-serial@vger.kernel.org Cc: Felipe Balbi , Greg Kroah-Hartman , =?iso-8859-2?q?Micha=B3_Mi?= =?iso-8859-2?q?ros=B3aw?= Subject: [PATCH v2 0/5] usb: gadget: u_serial: Fix and cleanup Message-ID: <20190713210853.GA25753@lenoch> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Following patchset makes console work (patch 1 and 4) for an AT91SAM9G20 board connected to xhci_hcd and does some cleanup. Tested with "console=ttyS0,115200n8 console=ttyGS0" on kernel command line and following inittab: console::respawn:/sbin/getty -L 115200 ttyS0 vt100 console::respawn:/sbin/getty -L 115200 ttyGS0 vt100 However there is an issue remaining: Disconnect triggers WARN_ON in gs_close: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 501 at drivers/usb/gadget/function/u_serial.c:706 gs_close+0x3c/0x1e4 Modules linked in: CPU: 0 PID: 501 Comm: getty Not tainted 5.2.0-rc7 #44 Hardware name: Atmel AT91SAM9 [] (unwind_backtrace) from [] (show_stack+0x10/0x18) [] (show_stack) from [] (dump_stack+0x18/0x24) [] (dump_stack) from [] (__warn+0xcc/0xe4) [] (__warn) from [] (warn_slowpath_null+0x38/0x48) [] (warn_slowpath_null) from [] (gs_close+0x3c/0x1e4) [] (gs_close) from [] (tty_release+0x1d4/0x460) [] (tty_release) from [] (__fput+0xe4/0x1b0) [] (__fput) from [] (task_work_run+0x8c/0xa8) [] (task_work_run) from [] (do_exit+0x354/0x814) [] (do_exit) from [] (do_group_exit+0x54/0xb8) [] (do_group_exit) from [] (get_signal+0x18c/0x658) [] (get_signal) from [] (do_work_pending+0xe0/0x44c) [] (do_work_pending) from [] (slow_work_pending+0xc/0x20) Exception stack(0xc3797fb0 to 0xc3797ff8) 7fa0: 00000000 beb87d0c 00000001 00000000 7fc0: 0009a150 00000000 00099c04 00000003 0009a198 0007e049 00099bd4 0009a1e4 7fe0: b6e3f000 beb87cd8 00018210 b6dbcc40 60000010 00000000 ---[ end trace 70af570fde0de49b ]--- Explanation lives in drivers/tty/serial/ip22zilog.c at line 751 (see also __tty_hangup), but naive approach adding if (test_bit(TTY_HUPPING, &tty->flags)) return 0; at the beginning of gs_close does not work as this way port->port.count never drops back to zero. Ideas welcome. Btw, it would seem nicer to have single output kfifo for both kernel console and tty, but that involves greater changes and I'd like to have driver working in stable as well. Changes: - v2: Fixed locking, patches splitted, starving write fixed. Ladislav Michl (5): usb: gadget: u_serial: Fix console_req complete event race usb: gadget: u_serial: Remove console specific alloc/free req functions usb: gadget: u_serial: Fix console_req access race usb: gadget: u_serial: Fix starving write usb: gadget: u_serial: Use bool for req_busy drivers/usb/gadget/function/u_serial.c | 120 +++++++++++-------------- 1 file changed, 51 insertions(+), 69 deletions(-) Tested-by: Ladislav Michl