Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1143298pxb; Thu, 23 Sep 2021 19:59:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxbYnCeEfLWBM/WU2bxyAB+ynRTN+mqU7h31zAHRPXi6qKR+mCEO1TyFiv3dPvxQVgAskJ X-Received: by 2002:a6b:3c16:: with SMTP id k22mr7050753iob.130.1632452344946; Thu, 23 Sep 2021 19:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632452344; cv=none; d=google.com; s=arc-20160816; b=hR2EplYEYm4G1gVOE6MYzo+g1YmRshNUYRv++0GGP7Xs1WQnGXdxu+06ndefpSEBP2 nUJd+Hww/x2dV83fZJ/gQLgakk8VHa5GDEBz/b1ci7OAkh8HiIfqeGXpeJbAfRTdUYnq 9FCh9AEapA9Lijsg3pgWQvPz0CqUnIIU2hDtzm5gtiMNYJ9ltPlpOdiENkO5KsN0vX4y tFpLYVhpL8urBBQXb3fPqSKOd8is0H53qeqSr3RdvmYwniE3fWiWgvsBGfGjqBiKysrx CxnMDwwudw3QIawyK097DvL1ZPq2CE6BQsAacbSeMKoWs2R84ffDH1MGyv+vs/f1oPX6 BzhQ== 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=yGHXGrdGXxK061QNP8riHSRvPlRLcFCMH+WwFTSwsco=; b=o0uPEQIZ5FNd/aItAH6i2o3+DkktPCFKRN4wondQk4jixGBesD2mn60wUdCLd1JwPW +gUlZo4dNNBA/urihJbw5upiisQ5TzsLVEgUywITl8hag1NxoQwPRPXO6B/G3TRU9Xuk XneBXbrG4iiEW6SrewbwfED+y3LES8INTI4Oyk49DSKYzFtUpBD8haLWaxwJgdGN067Q GzWw31umknpWOIkm9OwQaOi2fNu6XnVqKjxaqbdwYhGmTrpY/VCUWbhk7wkJOsXMhwZn nC5DmrlYknD1qpVUlc+IimZBSo66HZoqaW/f9aebvURcvw3MXwnPyUn4oGF4mUaxE9BQ DCVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hQ5rkBWX; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si8475241ioh.48.2021.09.23.19.58.33; Thu, 23 Sep 2021 19:59:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hQ5rkBWX; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 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 S243930AbhIXC7A (ORCPT + 99 others); Thu, 23 Sep 2021 22:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234930AbhIXC7A (ORCPT ); Thu, 23 Sep 2021 22:59:00 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87B9CC061574 for ; Thu, 23 Sep 2021 19:57:27 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t7so22749604wrw.13 for ; Thu, 23 Sep 2021 19:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yGHXGrdGXxK061QNP8riHSRvPlRLcFCMH+WwFTSwsco=; b=hQ5rkBWXQ7t648EhHaY0OCvGFbhA2bkJm588PLYdWMPXHOHG58EyzfN6zu1zo+XGoO CKM6WyTEtYbHlX8xSa7PGYGK/X9ldHUGR749dJte67eDwrRnVK54SPS/lsnId5HqTV5f WZyAKTI6uI0vrDotKrlHl9eJsXTZgkZU6D69lUsX8qU4yPRkWBuYQYU74Ugg8K1R6V5j 5z1WPHIKsBe5Zb8phN/zThG7Ae9noiZ2Jwuo/c0WHQjJXbyP3keNo7Jb6phmvd6Dsw5i 4e66nBI/LCPYydO+yLfHGawqYnXEInshmO4wDNBFagnxXSSBd7f1nUG3mvkO6ZH2F5M6 zM5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yGHXGrdGXxK061QNP8riHSRvPlRLcFCMH+WwFTSwsco=; b=UT0ort74SKPTjSloQH54s0KrLqVDlzzBuMUngLKZOIfwIBS+6H86CGZo37vodfEDB/ oUqZVOIfzYWiPPkJh2KTdbfw7Egy/AEC5S0S5B2AIVRFZpL+MliFqkqDGCk9JBOyBorO wu13k5tTVGblRF60+1rMwU5PVhcsRTQhR2uW+C3EbW7k2xsZu3dEhG0q66QHCN9o+EzK 3ynBirO8L3PrgY5bbHshggHjBw9AOY09ORR9YmGTB4YToEDluMdxVAHLSySBYaS2tOnH xwXNArnAtkZ5xu+e278Op5x0Z/K6K5PklRC78x7FrBQ0SrM46yDcPl13ieXxTMLdNE5x HIDg== X-Gm-Message-State: AOAM5313v4F9CMxUwnB34aJHN6wgv+4vIwX2cYycczJG9taxa6tSmNfT dNMsT0+CyVZpSCt4iGLSgZ3FF6PenqVum6b1kGTksA== X-Received: by 2002:a7b:c947:: with SMTP id i7mr7574919wml.179.1632452245857; Thu, 23 Sep 2021 19:57:25 -0700 (PDT) MIME-Version: 1.0 References: <20210920125739.111846-1-hdegoede@redhat.com> In-Reply-To: <20210920125739.111846-1-hdegoede@redhat.com> From: Archie Pusaka Date: Fri, 24 Sep 2021 10:57:15 +0800 Message-ID: Subject: Re: [PATCH 5.15 regression fix] Bluetooth: hci_h5: Fix (runtime)suspend issues on RTL8723BS HCIs To: Hans de Goede Cc: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, Archie Pusaka Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Hans, On Mon, 20 Sept 2021 at 20:57, Hans de Goede wrote: > > The recently added H5_WAKEUP_DISABLE h5->flags flag gets checked in > h5_btrtl_open(), but it gets set in h5_serdev_probe() *after* > calling hci_uart_register_device() and thus after h5_btrtl_open() > is called, set this flag earlier. > > Also on devices where suspend/resume involves fully re-probing the HCI, > runtime-pm suspend should not be used, make the runtime-pm setup > conditional on the H5_WAKEUP_DISABLE flag too. > > This fixes the HCI being removed and then re-added every 10 seconds > because it was being reprobed as soon as it was runtime-suspended. > > Cc: Archie Pusaka > Fixes: 66f077dde749 ("Bluetooth: hci_h5: add WAKEUP_DISABLE flag") > Fixes: d9dd833cf6d2 ("Bluetooth: hci_h5: Add runtime suspend") > Signed-off-by: Hans de Goede You are correct, I should have checked H5_WAKEUP_DISABLE before using autosuspend. Reviewed-by: Archie Pusaka > --- > drivers/bluetooth/hci_h5.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) > > diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c > index 0c0dedece59c..59b712742d33 100644 > --- a/drivers/bluetooth/hci_h5.c > +++ b/drivers/bluetooth/hci_h5.c > @@ -846,6 +846,8 @@ static int h5_serdev_probe(struct serdev_device *serdev) > h5->vnd = data->vnd; > } > > + if (data->driver_info & H5_INFO_WAKEUP_DISABLE) > + set_bit(H5_WAKEUP_DISABLE, &h5->flags); > > h5->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); > if (IS_ERR(h5->enable_gpio)) > @@ -860,9 +862,6 @@ static int h5_serdev_probe(struct serdev_device *serdev) > if (err) > return err; > > - if (data->driver_info & H5_INFO_WAKEUP_DISABLE) > - set_bit(H5_WAKEUP_DISABLE, &h5->flags); > - We can simplify by just returning err and not check its value. > return 0; > } > > @@ -962,11 +961,13 @@ static void h5_btrtl_open(struct h5 *h5) > serdev_device_set_parity(h5->hu->serdev, SERDEV_PARITY_EVEN); > serdev_device_set_baudrate(h5->hu->serdev, 115200); > > - pm_runtime_set_active(&h5->hu->serdev->dev); > - pm_runtime_use_autosuspend(&h5->hu->serdev->dev); > - pm_runtime_set_autosuspend_delay(&h5->hu->serdev->dev, > - SUSPEND_TIMEOUT_MS); > - pm_runtime_enable(&h5->hu->serdev->dev); > + if (!test_bit(H5_WAKEUP_DISABLE, &h5->flags)) { > + pm_runtime_set_active(&h5->hu->serdev->dev); > + pm_runtime_use_autosuspend(&h5->hu->serdev->dev); > + pm_runtime_set_autosuspend_delay(&h5->hu->serdev->dev, > + SUSPEND_TIMEOUT_MS); > + pm_runtime_enable(&h5->hu->serdev->dev); > + } > > /* The controller needs up to 500ms to wakeup */ > gpiod_set_value_cansleep(h5->enable_gpio, 1); > @@ -976,7 +977,8 @@ static void h5_btrtl_open(struct h5 *h5) > > static void h5_btrtl_close(struct h5 *h5) > { > - pm_runtime_disable(&h5->hu->serdev->dev); > + if (!test_bit(H5_WAKEUP_DISABLE, &h5->flags)) > + pm_runtime_disable(&h5->hu->serdev->dev); > > gpiod_set_value_cansleep(h5->device_wake_gpio, 0); > gpiod_set_value_cansleep(h5->enable_gpio, 0); > -- > 2.31.1 > Thanks, Archie