Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp590647lqm; Wed, 1 May 2024 09:35:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWY/kbnLrEjGsQpIojWicWfWeSDGSIZAFRODkCXBuBDO0rxm6LMOvsXaC01av8Gh4909nKR29L92uX26lPn7IcPol1xdrYRuF29LytZ0Q== X-Google-Smtp-Source: AGHT+IGwYO3OfxKfi4GwnHZVPUZXv/s/wvJM4JQmylwgtq0DYLMSUhwF6zomElAtaQctlEInKnrp X-Received: by 2002:a05:6358:5285:b0:18f:8613:12b8 with SMTP id g5-20020a056358528500b0018f861312b8mr4362645rwa.5.1714581304610; Wed, 01 May 2024 09:35:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714581304; cv=pass; d=google.com; s=arc-20160816; b=r4uBECiRFD4CDCz1p0lcYzWQn/lN9hJibGP4MWALwO+kzoEWwV9/gl67I5vHAebW6j 1AIWR2iA7uM7keCeEtQs5bje7rdnEQeaK+C+8QleGFJtW7i53nZNU1J2a77jy0OEFzOu sTBidj8CrqWSR/YAj4Igl6eo0y2XXH5Ltk1BLxsiO2lT8Ea3Cihx5b6opXftY+AbOuo8 /VcW7iQ5ZTKkLnHahzTHpEy6hwdw6+3BAdPgNc62+0EHLAR6nmWnoAnimgA/Y/qzsS+Y tMkpZFiqtieV7EzFSobEaBuwXTCMyuJ5fgFwlDbKyL+1FmUfIOXG0h6xZ6apT7U9RtE6 5rJA== 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=X5m5Ft8ibLTazqZcd0FT8Mzs4EFYTDmw9YeSBSiXSp0=; fh=bD+NDVb9IN2jCE4Lu44e4PeesNLPTGMnDgVIXAz9utM=; b=rgkScfY7wWLeyaDcqBMkVJ1qRr7bvbpp4vDox7pUUqGzaTXNGLprMIBbfCjN6j56ov jsDwEq32Ryauny/SVZ07C9kk5mGLMKRz8H4kDJyVITIvIw2HPiCGB37Qj212kJFV8OdN FC2vHL4JupFUorHCRw6Ggu2NIAkfC6QxIXPsISRgmpt/kkwTicE9SPfxK2C4Ia+Ow6Rz R9WnMEjKgvJDw0ofsStG8Nd5WENyDewzigms4+kKVCBk8shd5b5y7H1hhW7d7qnwy9Gw 2pxpigjBP4Tf7mLoasuklzBVHFicE+grRa6AToJxUbhAZs25rV6GrR9/qBqj5SQ+eEfD 5CVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WXkDwuwU; 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-bluetooth+bounces-4231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4231-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e26-20020a65689a000000b005dbd83521fasi23145859pgt.883.2024.05.01.09.35.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 09:35:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WXkDwuwU; 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-bluetooth+bounces-4231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4231-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 4E07A281A65 for ; Wed, 1 May 2024 16:35:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 792C2D2F5; Wed, 1 May 2024 16:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="WXkDwuwU" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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 4328CC125 for ; Wed, 1 May 2024 16:34:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714581295; cv=none; b=jqDaah23gW+2q6A/SnbnfByO2T9lIWvUrnZF8nuX4kPMDgHYTuaVaXwOiux3eAPp4mUKIPrAL/c3Vy1+l993+q9muU2756yj0GSKCedUyuoK9tjCspyiRUCoCE7UappD9Dseb3JYVB8zBvCSggmA8oGoS7EuGm0/rtpCbirZN5Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714581295; c=relaxed/simple; bh=HLRpuJW4wpmvXc3cjO2hjEdv0yZ1MmbzHnWkQZqqRVg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WSt6cJjf/xdOn1wUtSMHLl+4+jEYswY7hW7xmIRkdLqu+EqFGhS2yA0MC+FC+4ymjUJ3tArm32AYozr8E4wGvI2A0/U/FexcFM+If8rHDNVD05CH5XNMDO2w1Fub1VvF7V5RKlkLapXm1y+zBv5uZI0vX1RQZFBoBR6R13K/jf4= 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=WXkDwuwU; arc=none smtp.client-ip=209.85.128.174 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-yw1-f174.google.com with SMTP id 00721157ae682-61df903aa05so15545257b3.3 for ; Wed, 01 May 2024 09:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714581293; x=1715186093; 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=X5m5Ft8ibLTazqZcd0FT8Mzs4EFYTDmw9YeSBSiXSp0=; b=WXkDwuwUFO20A0Qc2vzR7wjtnt54keY6Qcz3o7UvFHxZm4VdiH0kSVQzQMPjGASwKi zYFMQnikA0Jh4nGvTa+qcOzqlPKApAlsNtkT6xrSuoBysHTtf6Fh/H9ZQQ0nsd6ycr/w bo5MMWeNzay1Cm0ogv27zf3u9F3kfwguJX70I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714581293; x=1715186093; 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=X5m5Ft8ibLTazqZcd0FT8Mzs4EFYTDmw9YeSBSiXSp0=; b=BBHRWUdRMBCDt89QevXoWcqQWVRa7GrP3ktU2cjryKrntUsvsYOxycEgxpHal18w0F TOuJ/gWbHMHxBJaQWKTf/s0gx5qSnd+Ug4Gn5+IQ0EPlvr50FPfQoX3WmwGgTzjwHrgy DiB+Xs7hv2htvjzFTtgLfxVhPlGlJ7o9s3ZwSt4r7jh51JutKSQUgFTHstek/1YTRGB0 I7+LV1wNsIGbK311tkPa7+vIzlOiYo2B8UR6aIjl1+ptbCUC/icx3G/SDXiA9r/tSBl1 zns7wHgltOw4ctBrav+ZNacvEjMLNQtdPkedkwtvh+Y/0iAOkYlD0kaF52NcXqHeKXtd MTXQ== X-Forwarded-Encrypted: i=1; AJvYcCVCBqtSYOVoB1oC7VIGVwK6rew+KIduUPYl/X9+Vi7p57O2kkgQ3pOhKZIGawCDhOIeWUk8IRHDZjkcq77Xnb2hDTQGYEnkd3+u+YQZU+aZ X-Gm-Message-State: AOJu0YwUwYAM9PVugEVSBqkYcLCeHkdLbjfdTf1wOiDmzgIsrj9lCkxO Wv+6vIWgoqNd4J5Fo1y5Psfuq5GnxFEonB1qXeHZxvEBs4RqzotMhXn6PqoAa7aS2sUeT1DpFEh om3gSdbK3vTxaRzdCQmIF8haPRCAlnTwYzYoe X-Received: by 2002:a81:4c86:0:b0:617:cc94:31bf with SMTP id z128-20020a814c86000000b00617cc9431bfmr3068340ywa.50.1714581293231; Wed, 01 May 2024 09:34:53 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-bluetooth@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: Wed, 1 May 2024 09:34:41 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: btusb: Add debugfs to force toggling remote wakeup To: Luiz Augusto von Dentz Cc: Archie Pusaka , 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 Tue, Apr 30, 2024 at 9:46=E2=80=AFAM Luiz Augusto von Dentz wrote: > > Hi Abhishek, > > On Fri, Apr 26, 2024 at 1:04=E2=80=AFPM Abhishek Pandit-Subedi > wrote: > > > > On Fri, Apr 26, 2024 at 2:08=E2=80=AFAM 'Archie Pusaka' via ChromeOS Bl= uetooth > > 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_interfac= e *intf, > > > > > > > > > > debugfs_create_file("force_poll_sync", 0644, hdev->debugf= s, data, > > > > > &force_poll_sync_fops); > > > > > + debugfs_create_bool("force_enable_remote_wake", 0644, hde= v->debugfs, > > > > > + &data->force_enable_remote_wake); > > > > > + debugfs_create_bool("force_disable_remote_wake", 0644, hd= ev->debugfs, > > > > > + &data->force_disable_remote_wake); > > > > > > > > > > return 0; > > > > > > > > > > @@ -4702,6 +4709,18 @@ static int btusb_suspend(struct usb_interf= ace *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, &d= ata->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, &d= ata->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 settin= g: > > > > > > > > https://github.com/bluez/bluez/blob/master/doc/org.bluez.Device.rst= #boolean-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 tr= ue. > > 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= ) > > Got it, but the suggestion was to instead of using > force_enable_remote_wake, which is sort of non-standard, why don't > Chrome OS simply use rkill interface to tell the driver to shutdown? > On resume then you can just unblock via rfkill that should have the > same result as using force_enable_remote_wake, well except if there is > a bug in the driver that is not handling rfkill as a 'global > shutdown', but then you need to fix the driver not introduce yet > another debugfs entry to bypass it. Did you mean `force_disable_remote_wake`? rfkill will work for that around system suspend. We preferred not to do it because we don't use userspace suspend signals with Bluez today (preferring the kernel suspend notifier). `force_enable_remote_wake` still needs debugfs as rfkill can't force an interface to stay awake as far as I know. > > > 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 Gr= oups "ChromeOS Bluetooth Upstreaming" group. > > > To unsubscribe from this group and stop receiving emails from it, sen= d an email to chromeos-bluetooth-upstreaming+unsubscribe@chromium.org. > > > To post to this group, send email to chromeos-bluetooth-upstreaming@c= hromium.org. > > > To view this discussion on the web visit https://groups.google.com/a/= chromium.org/d/msgid/chromeos-bluetooth-upstreaming/CAJQfnxHUW%2BMdJUp9VCrF= 2Nq_-JZrd7mKBR9NdDoo0SOvgH5WUQ%40mail.gmail.com. > > > > -- > Luiz Augusto von Dentz