Received: by 10.223.164.202 with SMTP id h10csp351012wrb; Fri, 17 Nov 2017 01:33:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMa3fu6SkhKLcUwWBxQ0Fj47zz4E0O9grdBClD2D/0KxlAeauY3IuiDVOZ9XUe4UFauoMiKl X-Received: by 10.84.178.131 with SMTP id z3mr4580391plb.165.1510911196934; Fri, 17 Nov 2017 01:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510911196; cv=none; d=google.com; s=arc-20160816; b=PQXl1w3RTHfIIDH0hz7zWYCUD4ACp2CwrOgSoUFVq0fchhrqe3CP88b7hOiwBd4N5S TMn5OBLruvJA+0I6uPL/P5ReZlBE82McB93jPqi4EmutalXLBrBwXpAYrWM0wGVLull5 xuC3ktr34E0yEBvO4J6XeilQf/ZiMjXv0NmgsakY+ZuTvTSIknMVBaIVrIoA43oeCipd TXroxMZb3LoAwscbIylj8dUpawDit+BFcew4L7BabLDvcnpiQSFykM7lYwp7cIV4oAg4 XCcJQQXD3nF+/XbQ6E6hGQ2rbgnRET/PD85t4/MKgX+MOe2iAl7sHySXG0DzbbOZdgpm rhow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:references :content-transfer-encoding:mime-version:subject:date:from :in-reply-to:message-id:arc-authentication-results; bh=q8m3f8ZzefIJzsE7z9WuOOcmNkuT0qI1RgreW7Y86I4=; b=ooLd8NL4IVwQk00d61ZVkXBEIvLdgeX71ezPccb8GlFQ6jKCTLaZLBA0NXKklaSfC1 qsIoZ+mLgIcc5u95odxmORunpMTm/yc4nKJ6HHJECCtouoaUDFyUr9bgifSuZt+3vaVD MdLK9zK8Zvy2rFRA1OzpV3Xt1t0aTlVcfkSPbrZoHgqVRfBVPhRsFe6TK/zDYWD4Yk6f lzhgwSTw3QRPD+UbtxpchVUa+VZzT7Mq8322WX6wi+SSd124ggEQNRNL+F/1UOqRyn1t b4H5UdyZ22OCcXqhOz6yz/mOobbCSafcOinKricEeHUaXSwoftmPYNehkjMvSjOF96T9 aCqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 197si2387993pgg.741.2017.11.17.01.33.03; Fri, 17 Nov 2017 01:33:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726AbdKPXzM (ORCPT + 92 others); Thu, 16 Nov 2017 18:55:12 -0500 Received: from bmailout1.hostsharing.net ([83.223.95.100]:47651 "EHLO bmailout1.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752378AbdKPXyz (ORCPT ); Thu, 16 Nov 2017 18:54:55 -0500 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id 78AF8300002C5; Fri, 17 Nov 2017 00:54:53 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 3F35638EF1; Fri, 17 Nov 2017 00:54:53 +0100 (CET) Message-Id: In-Reply-To: From: Lukas Wunner Date: Fri, 17 Nov 2017 00:54:53 +0100 Subject: [PATCH] Bluetooth: hci_serdev: Init hci_uart proto_lock to avoid oops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit References: <20171116213045.GA17506@wunner.de> <20171116214504.GB17506@wunner.de> To: Marcel Holtmann , Gustavo@h08.hostsharing.net, "Padovan , Johan Hovold Cc: Ronald Tschalaer , Sumit Semwal , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, John Stultz Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org John Stultz reports a boot time crash with the HiKey board (which uses hci_serdev) occurring in hci_uart_tx_wakeup(). That function is contained in hci_ldisc.c, but also called from the newer hci_serdev.c. It acquires the proto_lock in struct hci_uart and it turns out that we forgot to init the lock in the serdev code path, thus causing the crash. John bisected the crash to commit 67d2f8781b9f ("Bluetooth: hci_ldisc: Allow sleeping while proto locks are held"), but the issue was present before and the commit merely exposed it. (Perhaps by luck, the crash did not occur with rwlocks.) Init the proto_lock in the serdev code path to avoid the oops. Stack trace for posterity: Unable to handle kernel read from unreadable memory at 406f127000 [000000406f127000] user address but active_mm is swapper Internal error: Oops: 96000005 [#1] PREEMPT SMP Hardware name: HiKey Development Board (DT) Call trace: hci_uart_tx_wakeup+0x38/0x148 hci_uart_send_frame+0x28/0x38 hci_send_frame+0x64/0xc0 hci_cmd_work+0x98/0x110 process_one_work+0x134/0x330 worker_thread+0x130/0x468 kthread+0xf8/0x128 ret_from_fork+0x10/0x18 Link: https://lkml.org/lkml/2017/11/15/908 Reported-and-tested-by: John Stultz Cc: Ronald Tschalär Cc: Rob Herring Cc: Sumit Semwal Signed-off-by: Lukas Wunner --- @Rob (and everyone else): I'm not sure if this is in fact the correct approach, or if we should instead duplicate hci_uart_tx_wakeup() in hci_serdev.c (sans locking?), much as we've duplicated a lot of other functions there. Let me know what your preference is. Thanks! drivers/bluetooth/hci_serdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 71664b2..e0e6461 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -303,6 +303,7 @@ int hci_uart_register_device(struct hci_uart *hu, hci_set_drvdata(hdev, hu); INIT_WORK(&hu->write_work, hci_uart_write_work); + percpu_init_rwsem(&hu->proto_lock); /* Only when vendor specific setup callback is provided, consider * the manufacturer information valid. This avoids filling in the -- 2.11.0 From 1586220161628999746@xxx Fri Dec 08 12:50:28 +0000 2017 X-GM-THRID: 1586220161628999746 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread