Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp110705lqg; Fri, 26 Apr 2024 10:04:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUlMc6k3MfXe8GnniCzZxEm6/J+E0LEks4ekPkpOp/m7uCCOuMb0LNk9m3EtBB16d5BHykfFIlDhK9hTQLXIyedCdWxiwY8Qs5KyW+kXg== X-Google-Smtp-Source: AGHT+IEISu8njYuYrUXoje8HkR+msJoX5cvb0eG7hFwz0aJJJ7t5+4hsIuBY/ps3kOF2x/y+TJZf X-Received: by 2002:a05:6a20:dd93:b0:1a7:23c0:24e7 with SMTP id kw19-20020a056a20dd9300b001a723c024e7mr2885620pzb.42.1714151070368; Fri, 26 Apr 2024 10:04:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714151070; cv=pass; d=google.com; s=arc-20160816; b=MfDabrXsHt+2EkgOg8QewlfGRLI9Qx4kOgzOIM22F1GSnIWg2z+AwGnvEnPtqJ0l+D DqeytRl8xBUu/lYDMaP/P1jfRyiEofRcAYPORUrpX07T84ksXPvDIKKXv9JMW4FThAOs 5zavizdYHLv19le7uoncdgRweFvpsar3MYi9mrFt+6C+WoVzH3tGiJeB25G8b9WhwNMf Lzn7IPmBvpmdyYXa8wOMj7futPIN3q/ha1++3hR8u3zapxj+XFvBw//mD8tAmib/VmWj BxWISy4QjsMqwomAinerpOiyfm+r8k+DU+LHG3WC8yC6vK7fCCoF64dfpA63RcTn2IFV +NJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=O73neaw7snadd4AQtFov3VpyQLi3ArC1cYm4eGifaug=; fh=APfYKxtLspkcfMPkYgPPw02dGUS2D7b7+RFkyFqsHjQ=; b=TUd9iGj8t+FePsF9duDtmjJa3ERW3zuhZzI0cMqSZL3a6lPvXKrNuAunuG56QuEZ/6 5KTC7vzX7dbJskrELceVxuHb+iUXHiAOnE7EjB4GTbgMmBg/iJ3iL83erbCelSEk7RMM Q8oAVLXKEbrmLMz2NNO2ymDRgKONmJd3LA+ZjFP7P69zbHVfwK9ClQw6W5nWHZtvUJ4i COPG1xlMzvs7PFns4dofRmf6ninscTP2n3awIJ1SllDc4yvV/0MCZJxIVjGXWik3C68l 16h5IEtdhYbM98cgBQVBF+/2tbtmiTlVwyYYM2jy1Qg7FJPGBMRY6qANgxXcE+Y5wtY0 fgnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RZCu09z0; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-160443-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160443-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q8-20020a656848000000b005f76fa38b0asi15458811pgt.345.2024.04.26.10.04.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 10:04:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160443-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RZCu09z0; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-160443-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160443-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E7AC12810D1 for ; Fri, 26 Apr 2024 17:04:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5428815AACD; Fri, 26 Apr 2024 17:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="RZCu09z0" Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFBD215B579 for ; Fri, 26 Apr 2024 17:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714151058; cv=none; b=mbCzRgRB6C1+H5Jg8iTswmBGwhhOBlNfY4AZwW9FBqCuGTVD71QFoZpmoQOIjY63GvEN9H+ZR83+RsBqxgRR58pz5A6tzLwNBAE4agn4/WDGfTHLri/VNXH3LTeLisXGnSnClZcPa8Wm8uygFep/AMWbEV/CVKeip1My/6FnZTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714151058; c=relaxed/simple; bh=FJjXIczJaw2fI8RrGmhS8e8S0A1Jj3c6aMXGB/NNg+c=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=t1+67v7WNUBgHajm+9ak8GWRpjgRm887nMjBrL3MiS10kcq5um+0KaCzz/+BPpVzumNfFB735FTeBlC3d8tygNBtrdPoOqUw50p0jsl0ja+WkZlyaGd6cmKpAI9bOkEEgnmSWwQ8dDyTr/CJcoX4Oc1Vx9lXPCcJ7jVV1t9TIZ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=RZCu09z0; arc=none smtp.client-ip=209.85.161.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5aa241232faso1732349eaf.0 for ; Fri, 26 Apr 2024 10:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714151055; x=1714755855; darn=vger.kernel.org; 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=O73neaw7snadd4AQtFov3VpyQLi3ArC1cYm4eGifaug=; b=RZCu09z0Pr95xc53EWSwLi7OhsgEpMbL0adykk2b7pZPCTbax6p0m90huwZtUY/mgH uaqx/CNG/3uR7doMSkc7jPvioNqrQJIAQ7eUxQAuGYpm0Fr8qtg27F3w3Dx1SKMQGfDf zulRdJhijtEJblCwJ7eT4iTfRp4Yypwlp9zJo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714151055; x=1714755855; 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=O73neaw7snadd4AQtFov3VpyQLi3ArC1cYm4eGifaug=; b=XcgIPrdR6YTGFXrLA0jTB1jmNx3Q8A6C51zDvxU31rYq4YYmK22DB1RZKNOpqvjNd0 IHaG73sYpKQj5MiauKfxYQz1gn7wg9SES2WyfhU9ONgr3jb1+u8esy38j32JQRgzGYLD eGRU5muSgf3AjdDdWG6z8y6MZ+47CzZbynCCeJtdaeR1xB37jccEN8+LtFWNZFnJB74T 7Mdq2wUNn7sWCPirAggQ1ZpO5VBARbr2MmFJYB0R1XUxYOcFruQph6I+/MKz/Bj/fX57 wrZBHx3hivkT9Rg5qzXFWttesN4/tciISjIebJ1AA+d9S+jljEGqyyiifqH5c3c8HdY8 JtzA== X-Forwarded-Encrypted: i=1; AJvYcCVtoP2akjWPIycE3cRcdu0NnA5oPrOPyPmCnsfBnIMw+xdn0Ly/KioUtwW9Xlqmo9/zzqYUEfCljxeIykUdPat/SyJra2+NWZ/RXWLf X-Gm-Message-State: AOJu0YzoBu7lObKHax5N7+SGTxladrd6nFQOXgFUgLgs+xENNYlgpoMv fcBLMfHmxjOpbPS4E1EaHuxCP7KPMQa2p4dlWdVG0zHst5j3mzbjhQX48sygn1sS98HgDNzGPqN sdxlsiZr/fPzuzVOMVxZ6DO4Auch69OHy/TRf X-Received: by 2002:a05:6358:438e:b0:17f:56be:8c95 with SMTP id x14-20020a056358438e00b0017f56be8c95mr3840486rwc.25.1714151054780; Fri, 26 Apr 2024 10:04:14 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240422152500.1.I8939e49084a6fef78496eb73edafdf3c2c4afbf4@changeid> In-Reply-To: From: Abhishek Pandit-Subedi Date: Fri, 26 Apr 2024 10:04:03 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: btusb: Add debugfs to force toggling remote wakeup To: Archie Pusaka Cc: Luiz Augusto von Dentz , linux-bluetooth , Johan Hedberg , Marcel Holtmann , CrosBT Upstreaming , Archie Pusaka , Abhishek Pandit-Subedi , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 26, 2024 at 2:08=E2=80=AFAM 'Archie Pusaka' via ChromeOS Blueto= oth Upstreaming wrote: > > Hi Luiz, > > On Thu, 25 Apr 2024 at 03:05, Luiz Augusto von Dentz > wrote: > > > > Hi Archie, > > > > On Mon, Apr 22, 2024 at 3:25=E2=80=AFAM Archie Pusaka wrote: > > > > > > From: Archie Pusaka > > > > > > Sometimes we want the controller to not wake the host up, e.g. to > > > save the battery. Add some debugfs knobs to force the wake by BT > > > behavior. > > > > > > Signed-off-by: Archie Pusaka > > > Reviewed-by: Abhishek Pandit-Subedi > > > > > > --- > > > > > > drivers/bluetooth/btusb.c | 19 +++++++++++++++++++ > > > 1 file changed, 19 insertions(+) > > > > > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > > > index 8bede0a335668..846b15fc3c04c 100644 > > > --- a/drivers/bluetooth/btusb.c > > > +++ b/drivers/bluetooth/btusb.c > > > @@ -873,6 +873,9 @@ struct btusb_data { > > > unsigned cmd_timeout_cnt; > > > > > > struct qca_dump_info qca_dump; > > > + > > > + bool force_enable_remote_wake; > > > + bool force_disable_remote_wake; > > > }; > > > > > > static void btusb_reset(struct hci_dev *hdev) > > > @@ -4596,6 +4599,10 @@ static int btusb_probe(struct usb_interface *i= ntf, > > > > > > debugfs_create_file("force_poll_sync", 0644, hdev->debugfs, d= ata, > > > &force_poll_sync_fops); > > > + debugfs_create_bool("force_enable_remote_wake", 0644, hdev->d= ebugfs, > > > + &data->force_enable_remote_wake); > > > + debugfs_create_bool("force_disable_remote_wake", 0644, hdev->= debugfs, > > > + &data->force_disable_remote_wake); > > > > > > return 0; > > > > > > @@ -4702,6 +4709,18 @@ static int btusb_suspend(struct usb_interface = *intf, pm_message_t message) > > > } > > > } > > > > > > + if (!PMSG_IS_AUTO(message)) { > > > + if (data->force_enable_remote_wake) { > > > + data->udev->do_remote_wakeup =3D 1; > > > + if (test_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data-= >flags)) > > > + data->udev->reset_resume =3D 0; > > > + } else if (data->force_disable_remote_wake) { > > > + data->udev->do_remote_wakeup =3D 0; > > > + if (test_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data-= >flags)) > > > + data->udev->reset_resume =3D 1; > > > + } > > > + } > > > + > > > return 0; > > > } > > > > > > -- > > > 2.44.0.769.g3c40516874-goog > > > > There is a D-Bus interface available to overwrite the wakeup setting: > > > > https://github.com/bluez/bluez/blob/master/doc/org.bluez.Device.rst#boo= lean-wakeallowed-readwrite > > > > Or do you want a master switch for it? On the other hand aren't we > > getting into the rfkill area if you really want to switch off radio > > activity while suspended? That seems like a better idea then just > > disable remote wakeup. This DBUS api is different from the quirk this is introducing. The `Wake Allowed` field in D-bus controls whether we add the address to the Classic Event Filter (HIDP) or LE Filter Accept List (HOGP) but not whether we allow wake at the transport level (which is why hdev->wakeup exists). This change specifically addresses a quirk with Realtek chipsets: RTL8822/RTL8852 will do "global shutdown" and power off Bluetooth if USB Remote Wake bit is not set. The USB remote_wake bit is normally set by the USB stack based on whether device_may_wakeup(udev) =3D=3D true. This means that RTL88x2 will lose power around suspend/resume if there are no wake capable devices connected. ChromeOS decided to use idle power and resume-time to determine whether to allow remote wake or not for these chipsets and we want to move this control to userspace so that we don't have to hold CHROMIUM patches in the kernel applying this policy (we want udev rules instead). RTL8852 gets force enabled remote wake because the RESET_RESUME behavior of this chip would otherwise increase our resume time >1s which breaks one of our platform requirements. The end-goal of these changes: * We detect RTL8822 or RTL8852 with udev and apply the right policy. * RTL8822 gets force_disable_remote_wake (idle power consumption too high otherwise) * RTL8852 gets force_enable_remote_wake (resume time too long otherwise) Hope this provides enough context for why this change is necessary. > > Yes, the initial idea was a master switch. > Thanks for your suggestions. > Let me discuss it with Abhishek. > > > > -- > > Luiz Augusto von Dentz > > Thanks, > Archie > > -- > You received this message because you are subscribed to the Google Groups= "ChromeOS Bluetooth Upstreaming" group. > To unsubscribe from this group and stop receiving emails from it, send an= email to chromeos-bluetooth-upstreaming+unsubscribe@chromium.org. > To post to this group, send email to chromeos-bluetooth-upstreaming@chrom= ium.org. > To view this discussion on the web visit https://groups.google.com/a/chro= mium.org/d/msgid/chromeos-bluetooth-upstreaming/CAJQfnxHUW%2BMdJUp9VCrF2Nq_= -JZrd7mKBR9NdDoo0SOvgH5WUQ%40mail.gmail.com.