From patchwork Wed Apr 23 14:58:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 28908 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1A388203AC for ; Wed, 23 Apr 2014 15:21:30 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf3767482igq.2 for ; Wed, 23 Apr 2014 08:21:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=jlMfL2RDGqQfUizvj+UMkYrlp6/WMxZvMNZAsl3AiqE=; b=AUuxIYjHQFQ1uvEZ/9rVx4SU4zXgDA3H1wyX/HJagqMlbNhL75+bps5jdcLXOMUQdL jo2Uzz4QoozCRJRCSO7ARv4VsaW8if3Kdo8CWCeqLyJ+awhjnAmS/+AnXmU+6qynm9Re Q+2JvDmw3b+6a6BpD8cNZ4WzfQo+ePGasE4uHec2AULekSB1g9bTiYbmxcAgU7VlWb8P jYeO1QjxI6JRKaKTk4biP3v9CQfe4wZz8IHblrU2eUq2VkGW5+oR6PcHI8cW2/krzsL7 X7F9X6pNFcNBCfE/KkOFr0KMZqI8EdlBfbhsfp3ugwl25dTReoGP8n46SFz/kQiqNcVv aVuQ== X-Gm-Message-State: ALoCoQl6Zy4qRQctHe1HckRohFxErZUq/jcqJHdn7/zCx97wxJkcoIjDPniqMqPVKUM1b+nxMIH1 X-Received: by 10.50.254.1 with SMTP id ae1mr1615067igd.6.1398266490389; Wed, 23 Apr 2014 08:21:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.130 with SMTP id b2ls338193qgb.99.gmail; Wed, 23 Apr 2014 08:21:30 -0700 (PDT) X-Received: by 10.221.64.80 with SMTP id xh16mr108953vcb.35.1398266490031; Wed, 23 Apr 2014 08:21:30 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id sq9si228015vdc.17.2014.04.23.08.21.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Apr 2014 08:21:30 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id oy12so1316379veb.4 for ; Wed, 23 Apr 2014 08:21:30 -0700 (PDT) X-Received: by 10.220.191.134 with SMTP id dm6mr42302924vcb.16.1398266489959; Wed, 23 Apr 2014 08:21:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp112193vcb; Wed, 23 Apr 2014 08:21:29 -0700 (PDT) X-Received: by 10.68.216.101 with SMTP id op5mr21016007pbc.148.1398266489258; Wed, 23 Apr 2014 08:21:29 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rb6si803723pab.272.2014.04.23.08.21.28; Wed, 23 Apr 2014 08:21:28 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757571AbaDWPV0 (ORCPT + 9 others); Wed, 23 Apr 2014 11:21:26 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:57221 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757053AbaDWPBL (ORCPT ); Wed, 23 Apr 2014 11:01:11 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3NF10us026182; Wed, 23 Apr 2014 10:01:00 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3NF0xV2021387; Wed, 23 Apr 2014 10:01:00 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 23 Apr 2014 10:00:59 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3NF0w7e027590; Wed, 23 Apr 2014 10:00:59 -0500 From: Felipe Balbi To: Greg KH CC: , , , , , Linux Kernel Mailing List , , , , Linux OMAP Mailing List , Tony Lindgren , Huang Shijie , Felipe Balbi Subject: [PATCH 01/13] tty_ldisc: add more limits to the @write_wakeup Date: Wed, 23 Apr 2014 09:58:25 -0500 Message-ID: <1398265117-11793-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.9.2.459.g68773ac MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Huang Shijie In the uart_handle_cts_change(), uart_write_wakeup() is called after we call @uart_port->ops->start_tx(). The Documentation/serial/driver tells us: ----------------------------------------------- start_tx(port) Start transmitting characters. Locking: port->lock taken. Interrupts: locally disabled. ----------------------------------------------- So when the uart_write_wakeup() is called, the port->lock is taken by the upper. See the following callstack: |_ uart_write_wakeup |_ tty_wakeup |_ ld->ops->write_wakeup With the port->lock held, we call the @write_wakeup. Some implemetation of the @write_wakeup does not notice that the port->lock is held, and it still tries to send data with uart_write() which will try to grab the prot->lock. A dead lock occurs, see the following log caught in the Bluetooth by uart: -------------------------------------------------------------------- BUG: spinlock lockup suspected on CPU#0, swapper/0/0 lock: 0xdc3f4410, .magic: dead4ead, .owner: swapper/0/0, .owner_cpu: 0 CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 3.10.17-16839-ge4a1bef #1320 [<80014cbc>] (unwind_backtrace+0x0/0x138) from [<8001251c>] (show_stack+0x10/0x14) [<8001251c>] (show_stack+0x10/0x14) from [<802816ac>] (do_raw_spin_lock+0x108/0x184) [<802816ac>] (do_raw_spin_lock+0x108/0x184) from [<806a22b0>] (_raw_spin_lock_irqsave+0x54/0x60) [<806a22b0>] (_raw_spin_lock_irqsave+0x54/0x60) from [<802f5754>] (uart_write+0x38/0xe0) [<802f5754>] (uart_write+0x38/0xe0) from [<80455270>] (hci_uart_tx_wakeup+0xa4/0x168) [<80455270>] (hci_uart_tx_wakeup+0xa4/0x168) from [<802dab18>] (tty_wakeup+0x50/0x5c) [<802dab18>] (tty_wakeup+0x50/0x5c) from [<802f81a4>] (imx_rtsint+0x50/0x80) [<802f81a4>] (imx_rtsint+0x50/0x80) from [<802f88f4>] (imx_int+0x158/0x17c) [<802f88f4>] (imx_int+0x158/0x17c) from [<8007abe0>] (handle_irq_event_percpu+0x50/0x194) [<8007abe0>] (handle_irq_event_percpu+0x50/0x194) from [<8007ad60>] (handle_irq_event+0x3c/0x5c) -------------------------------------------------------------------- This patch adds more limits to the @write_wakeup, the one who wants to implemet the @write_wakeup should follow the limits which avoid the deadlock. Signed-off-by: Huang Shijie Signed-off-by: Felipe Balbi --- include/linux/tty_ldisc.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index add26da..00c9d68 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -92,7 +92,10 @@ * This function is called by the low-level tty driver to signal * that line discpline should try to send more characters to the * low-level driver for transmission. If the line discpline does - * not have any more data to send, it can just return. + * not have any more data to send, it can just return. If the line + * discipline does have some data to send, please arise a tasklet + * or workqueue to do the real data transfer. Do not send data in + * this hook, it may leads to a deadlock. * * int (*hangup)(struct tty_struct *) *