Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1372558rwe; Thu, 1 Sep 2022 18:00:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR4me4LBliOWQDFEcVEohOrDTiPqrEpOt/oqSTgTmOlWF/i3R70RyV6BRPSnBR1Ka3CnaHR1 X-Received: by 2002:a05:6402:27d2:b0:43e:3ff6:ad58 with SMTP id c18-20020a05640227d200b0043e3ff6ad58mr30302076ede.234.1662080416913; Thu, 01 Sep 2022 18:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662080416; cv=none; d=google.com; s=arc-20160816; b=kBWw1olB2U4l0gDaGWbYOCGumi+kiWuCWDuoev/u7LI4nJ0Q9tCdAu26saJeDyMCBL xuREs4SIZ6QCfRX4gkwd/G7K6pyyPHJNZoYeYADVr7mXPPoz9PPLykPcdQw1fNSB9epj gFIIr2Vk5LgLya7joI9VtNGGfyIcyvgnZs3aGhOQSJLnOtYyVjQ0hp+62IVx0ESj/xHq IZwqmDxGtYz6kZS2uobJYi3E/mJg1x21GnOp8NLkrfMOJnSI2C5qUksWipZhIkk3jiH5 R+DiyRySLJcV77nlX8RneOwW/hth70oHryGFMpCnI9Fmhf6eGBzy9EvZtRU5UKLaf8At Xh2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Z4jZhw7mGJwuXQjUPY9DDPjI76uAYRiiTmD0/hJHRkM=; b=Ugicm0YCDDuPfxyPZ2iKJXlfgJe0Tp3DilpHSVs1ilVDbE2shZIKB8nMVjrD6R34WB 2m2AJM2CVsaQMK2Yu6uL24YGG+e9AgZ72X0X5H1Web5J9W9JIs1wliT+oYYg80bXs19y 7/APKppdtNxLZtRBXXEbH+L/v6Qb1Gi+Hi5ZxGBQuSRJn1mgxr1EOIa9Q3u/BBtsce19 vcdHTq2FuG9Ou/QLUbKsuQ/Eo/XoyJYdHoFAFRgkEgpRUFMeRNsvqOYhi1p2z3PGr0zF t/ZlkAzdZuvKitgPXhGinfWGSoIIs/HCqCjDS5ZCpQsEXx0RvbLSyjaKyFBwbut0AUED 4M+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nIyyFwXz; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc20-20020a1709071c1400b007313314bb73si668661ejc.806.2022.09.01.17.59.36; Thu, 01 Sep 2022 18:00:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nIyyFwXz; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234064AbiIBAyO (ORCPT + 99 others); Thu, 1 Sep 2022 20:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232971AbiIBAyN (ORCPT ); Thu, 1 Sep 2022 20:54:13 -0400 Received: from mail-vs1-xe2e.google.com (mail-vs1-xe2e.google.com [IPv6:2607:f8b0:4864:20::e2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA69390C7C for ; Thu, 1 Sep 2022 17:54:12 -0700 (PDT) Received: by mail-vs1-xe2e.google.com with SMTP id i1so583212vsc.9 for ; Thu, 01 Sep 2022 17:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=Z4jZhw7mGJwuXQjUPY9DDPjI76uAYRiiTmD0/hJHRkM=; b=nIyyFwXzkH01PkquT1Rue1bNSrCVjD98245QZcpk8KOScszIgLbylNpaBS6YJIdqKU FsL0wilrkLm1cskXgcVpKf7/PMkTTrsk9DFvWcoOl3UfIKORtrfnWAWZ0B+MsB3vxnP5 tf5cUegvBBAOZxP2g18E3tNH/y4vZLj9oYlPH9WBzF2/7Yw7C9FUHrCVkglCA+CCgF2G hpoOhk382Kck/l5yOtaVuEQ3LnbDeKIVssUmtras+Tb/lOdozkc2HlH7gT1Q10K7vZeV L7T850wzHs2FGE4KMnUpzLlZUQ/w0A9I07zJ/41S7rBnyTiWpCeh4wpiV+90LuQLXQwB ufIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=Z4jZhw7mGJwuXQjUPY9DDPjI76uAYRiiTmD0/hJHRkM=; b=44SPn/r+sybJARbe3ffORdIL2HniOorSVreF1f66dF4yVzY8abHWLQ9nInCGd1LbL8 4qtraj+AkmOhrBU/PkeZD7r03ac946BCzxs181HjXO6Y8+sKL2hg+NKYgaHLknZ4a2Vr v1mYoX7jnzRHK8l/nXIYuzPy7BxJYj2PqI7HtfZY+KqVy3BC8P8x94yU6FN5SYwA1hVo sE2ZXzwgXScvc/N19dNqJRJsvHgM6TKT0tiE01bmUO4tGT7BQli8JwCG37jvS96BFsGw 3xUJWLjLnAERkDSIpgcfvRbZ2r7NrsuwwCd7BhHcW/z/S3GDVOPuBekM65jwdBbmaQkk MM3Q== X-Gm-Message-State: ACgBeo39VAXT9fbtGhzHhKFQ4dc5Q5aVscsJe0uKzR+QqikOlW5nXJs9 /hyGPe6lxzW8YZupaIeq0VyHXuKeXpKS7AiMWLsC9xbCx19eCQ== X-Received: by 2002:a67:d313:0:b0:390:ee9f:610a with SMTP id a19-20020a67d313000000b00390ee9f610amr6689227vsj.17.1662080051630; Thu, 01 Sep 2022 17:54:11 -0700 (PDT) MIME-Version: 1.0 References: <20220829195805.1.Ic8eabc8ed89a07c3d52726dd017539069faac6c4@changeid> In-Reply-To: <20220829195805.1.Ic8eabc8ed89a07c3d52726dd017539069faac6c4@changeid> From: Abhishek Pandit-Subedi Date: Thu, 1 Sep 2022 17:54:00 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: Call shutdown for HCI_USER_CHANNEL To: linux-bluetooth@vger.kernel.org Cc: Abhishek Pandit-Subedi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Luiz Augusto von Dentz , Marcel Holtmann , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Please avoid merging. After additional testing, I've found a problem with btusb->shutdown not working for Intel controllers. btusb_shutdown_intel uses __hci_sync_cmd(...) to send the command and the command complete will not get captured because it is using hci user channel. We'll need a more invasive change to remove the userchannel flag during close so that the stack can properly clean up. On Mon, Aug 29, 2022 at 7:58 PM Abhishek Pandit-Subedi wrote: > > From: Abhishek Pandit-Subedi > > Some drivers depend on shutdown being called for proper operation. > There's no reason to restrict this from being called when using > HCI_USER_CHANNEL. > > Signed-off-by: Abhishek Pandit-Subedi > --- > This is easy to reproduce on QCA6174-A, which uses the hci_qca driver. > Simply open the socket, bind as userchannel and close again. It will > succeed the first time and fail the second time (because shutdown wasn't > called). A similar bug also occurs with btmtksdio (using MT7921). > > Question for maintainers: What is a driver supposed to be doing during > shutdown? We should add some documentation to `struct hci_dev` to > clarify. > > > net/bluetooth/hci_sync.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c > index e08c0503027d..be78fd708f16 100644 > --- a/net/bluetooth/hci_sync.c > +++ b/net/bluetooth/hci_sync.c > @@ -4680,7 +4680,6 @@ int hci_dev_close_sync(struct hci_dev *hdev) > } > > if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && > - !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && > test_bit(HCI_UP, &hdev->flags)) { > /* Execute vendor specific shutdown routine */ > if (hdev->shutdown) > -- > 2.37.2.672.g94769d06f0-goog >