Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1101555rwb; Wed, 9 Nov 2022 12:54:38 -0800 (PST) X-Google-Smtp-Source: AMsMyM5cXl54fT3s84598ek8W/GWJScXsGcJmPPxle2e5QDHMy98cwpzio8tDv/JtCEtFJF9GMG3 X-Received: by 2002:a17:902:e84a:b0:186:b8ff:c698 with SMTP id t10-20020a170902e84a00b00186b8ffc698mr62462246plg.143.1668027278745; Wed, 09 Nov 2022 12:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668027278; cv=none; d=google.com; s=arc-20160816; b=baHrCoyAJF3r8Cfy0O+OP/TvJgS9fPmUVs0y6Mvpa5ZvJg6IIP2lYsPQp0+ocMv+R6 sqwoUAK0p9M0N3dS6ewjhAk1KxYnIgCtayzXjzJP8isJMXnn9slQPckhK18J+uBrm3gz qfU8Zhl+IR5KUUI+exiiiE6dDLa0pJyUyOOHhPEgtfseuKF6WhvRtdaO2f9MRNwdX7Iq bRyesujNa1S8Q42sbO1iTmfYEfml+L0yrvGNh8qE1ejK7mcJNratNTq6C8WfjZatAiRw 23ADWtbHL56OgSyAiZeHYnbyn/wRPsFR1G6YEKnuryqiXypiRb4XmClmHoXm5wHvtO0F QGNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=HMexBlxBxOfaLRccW2JVyrflm9G7r7sk5hRAu9Qd8Xw=; b=k3r3B9eEz0D0vznUMo/zz+99wltYGRG45qMgtdi4lZfSUQGuDJMR+GawkJ0rwaXwmO dITSjnnd88rCGZpg6mIMmPGwCjjGm2cGAxpWG2wpVDX7QuOozpao4FKzbTCekvIX6tqG 2OoHKyCpfsf08EFmtgY9QBO8FEI6+UAmLQgebGynU7z1FqsmGvH3T1VMmGvSb+lcJxYF CrAtLeX5jGZNpUMBcINMRdIoDphGIWPfU+B3WFiRR0yDHOpG/c/yach4E5JutkyPvZlG zMQ0MIyUXxNZbMtjafQiS4gLW5hyhcyFFKEllLBOAPRrZcEC8NDlKh201/hyDvZFEU0W fZeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lNabaBwB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a056a00244b00b0056ca7c10cf2si19578972pfj.251.2022.11.09.12.54.22; Wed, 09 Nov 2022 12:54:38 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=lNabaBwB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229578AbiKIUth (ORCPT + 99 others); Wed, 9 Nov 2022 15:49:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbiKIUtf (ORCPT ); Wed, 9 Nov 2022 15:49:35 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0D62CCA1; Wed, 9 Nov 2022 12:49:34 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id r12so27861670lfp.1; Wed, 09 Nov 2022 12:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HMexBlxBxOfaLRccW2JVyrflm9G7r7sk5hRAu9Qd8Xw=; b=lNabaBwBDx8wdVGBNgTi9QC7ZUqI1PcJvBPYkx5jrHBUeWhiNinibODdCdAobmUQsp xX/EDJFbuhFE0m9R3ZyxxJXaocdRM7BwV3OHrhEH4ZSJqWDNDOEU8kAbOzh/Qw7grLtQ 2VDPcwgFBJlvk/MF2Lnt+TlB52oW2yPF+Vp1shEB5BicSyRVPfzlC4gUEX28a9jJuS+Y d+T7DDTc2OqSBIJGkr5q0G8dv1mquMEhGbGaEc2Nh8qp8YP5Uy4OV4SOR5jlHVbQa9K6 DAoNKZkghLTa/oh6kaqdgzRmhd5vhM3Rdc49nb3dyQ/j38+8IIdKnkLLrf6EU0jumPbf kxFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HMexBlxBxOfaLRccW2JVyrflm9G7r7sk5hRAu9Qd8Xw=; b=hmXfG7zO5G3AE1a/88yUfPlcFgRq+ZLpYReqFMqK+apTHNqV6qd9lwK1A0SzgJ99Rr 18138jciOMSDPi3MhAtX1xd7hC9pt20/eK8GtspM4Bt5NRGgUBnO2N5dZjC3gM/uodOi 2EZP+NF4DYMaSvC0ExRtbtXekGeDdg8EbpOV7VhrCsJ7kHOWVuSRAAUuPNsT2T6gnoRB aM9XvrdZKgLrZTYMSEi2sUo11ZyGKCUp60ovgR35e8BPUcMfQ02guqa/dXp5uIW45zfU 6YJa/WwxnxVaJsuToDQKebllhlNN0w3U5U7s81ydlL4g39dEug+II/EXT2an/7z9bljj tT4g== X-Gm-Message-State: ACrzQf2u3sovvnXh9m0ioSg6EKeNVaqBlIfXpKCfSzhGpov7SB0dqUG4 aiJjWakEh7dHhng7lgqdml3HVS9WU1EDlSlG04A= X-Received: by 2002:a19:6554:0:b0:4a2:be5c:688f with SMTP id c20-20020a196554000000b004a2be5c688fmr775793lfj.121.1668026972441; Wed, 09 Nov 2022 12:49:32 -0800 (PST) MIME-Version: 1.0 References: <20221029202454.25651-1-swyterzone@gmail.com> <20221029202454.25651-3-swyterzone@gmail.com> In-Reply-To: <20221029202454.25651-3-swyterzone@gmail.com> From: Luiz Augusto von Dentz Date: Wed, 9 Nov 2022 12:49:20 -0800 Message-ID: Subject: Re: [PATCH 3/3] Bluetooth: btusb: Add a parameter to let users disable the fake CSR force-suspend hack To: Ismael Ferreras Morezuelas Cc: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, luiz.von.dentz@intel.com, quic_zijuhu@quicinc.com, hdegoede@redhat.com, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Hi Ismael, On Sat, Oct 29, 2022 at 1:25 PM Ismael Ferreras Morezuelas wrote: > > A few users have reported that their cloned Chinese dongle doesn't > work well with the hack Hans de Goede added, that tries this > off-on mechanism as a way to unfreeze them. > > It's still more than worthwhile to have it, as in the vast majority > of cases it either completely brings dongles to life or just resets > them harmlessly as it already happens during normal USB operation. > > This is nothing new and the controllers are expected to behave > correctly. But yeah, go figure. :) > > For that unhappy minority we can easily handle this edge case by letting > users disable it via our =C2=ABbtusb.disable_fake_csr_forcesuspend_hack= =3D1=C2=BB kernel option. Don't really like the idea of adding module parameter for device specific problem. > I believe this is the most generic way of doing it, given the constraints > and by still having a good out-of-the-box experience. > > No clone left behind. > > Cc: stable@vger.kernel.org > Cc: Hans de Goede > Signed-off-by: Ismael Ferreras Morezuelas > --- > drivers/bluetooth/btusb.c | 31 +++++++++++++++++++------------ > 1 file changed, 19 insertions(+), 12 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index 8f34bf195bae..d31d4f925463 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -34,6 +34,7 @@ static bool force_scofix; > static bool enable_autosuspend =3D IS_ENABLED(CONFIG_BT_HCIBTUSB_AUTOSUS= PEND); > static bool enable_poll_sync =3D IS_ENABLED(CONFIG_BT_HCIBTUSB_POLL_SYNC= ); > static bool reset =3D true; > +static bool disable_fake_csr_forcesuspend_hack; > > static struct usb_driver btusb_driver; > > @@ -2171,7 +2172,7 @@ static int btusb_setup_csr(struct hci_dev *hdev) > is_fake =3D true; > > if (is_fake) { > - bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; add= ing workarounds and force-suspending once..."); > + bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; add= ing workarounds..."); > > /* Generally these clones have big discrepancies between > * advertised features and what's actually supported. > @@ -2215,21 +2216,24 @@ static int btusb_setup_csr(struct hci_dev *hdev) > * apply this initialization quirk to every controller th= at gets here, > * it should be harmless. The alternative is to not work = at all. > */ > - pm_runtime_allow(&data->udev->dev); > + if (!disable_fake_csr_forcesuspend_hack) { > + bt_dev_warn(hdev, "CSR: Unbranded CSR clone detec= ted; force-suspending once..."); > + pm_runtime_allow(&data->udev->dev); > > - ret =3D pm_runtime_suspend(&data->udev->dev); > - if (ret >=3D 0) > - msleep(200); > - else > - bt_dev_warn(hdev, "CSR: Couldn't suspend the devi= ce for our Barrot 8041a02 receive-issue workaround"); > + ret =3D pm_runtime_suspend(&data->udev->dev); > + if (ret >=3D 0) > + msleep(200); > + else > + bt_dev_warn(hdev, "CSR: Couldn't suspend = the device for our Barrot 8041a02 receive-issue workaround"); Is this specific to Barrot 8041a02? Why don't we add a quirk then? > - pm_runtime_forbid(&data->udev->dev); > + pm_runtime_forbid(&data->udev->dev); > > - device_set_wakeup_capable(&data->udev->dev, false); > + device_set_wakeup_capable(&data->udev->dev, false= ); > > - /* Re-enable autosuspend if this was requested */ > - if (enable_autosuspend) > - usb_enable_autosuspend(data->udev); > + /* Re-enable autosuspend if this was requested */ > + if (enable_autosuspend) > + usb_enable_autosuspend(data->udev); > + } > } > > kfree_skb(skb); > @@ -4312,6 +4316,9 @@ MODULE_PARM_DESC(enable_autosuspend, "Enable USB au= tosuspend by default"); > module_param(reset, bool, 0644); > MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); > > +module_param(disable_fake_csr_forcesuspend_hack, bool, 0644); > +MODULE_PARM_DESC(disable_fake_csr_forcesuspend_hack, "Don't indiscrimina= tely force-suspend Chinese-cloned CSR dongles trying to unfreeze them"); > + > MODULE_AUTHOR("Marcel Holtmann "); > MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION); > MODULE_VERSION(VERSION); > -- > 2.38.1 > --=20 Luiz Augusto von Dentz