Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2927952ybg; Sat, 6 Jun 2020 06:00:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ7v6kbl18mDl5eDunWZPp9eN8jPICZJdsdfeDCAHkp1CaYuMiqnD3BkhiM6gGgQ6j2Ijf X-Received: by 2002:a17:906:ccd5:: with SMTP id ot21mr12904502ejb.508.1591448451238; Sat, 06 Jun 2020 06:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591448451; cv=none; d=google.com; s=arc-20160816; b=tkaagYpRb+nbDARn2dd12uD6ONOJJJ2li5FfQKgoIwuY5Ucpk0tzbbowWpls26Sw+q mviDcC6sKlIwN18LPiVrtRA3Xk/dI1uJzwcHE0JTCjGNBZhAYP90PPv1TdereWG2zdCb nc9/Q8wJ0PjOZd/W3jy9VeXC+sV5EtZ5SFF0+2ROHh5nKGYo2z8cHiNXuoIkDrEZwnav P8ARMu0Za4eU09JEykjPIT5fgjJb8tgKmDXnUwMASIdok/QpwIn9TqavdzzxjWMLHER3 /dm26mPsxvs/lusOwveAkKqoYsumuTo4RcCt3nVTEj65G5+ad9j/DR1pjllSM/R+Zx1x MfIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=L0dPa4WboKgSG/BnSettdX0rSi6ZEV66DQzLoB4TqbA=; b=qClYOULsKah+LiaBk7oAEBfq4AmMqcbmOmGi4kGNihAlzMRtT4gPC3EdsK6zw0fkn9 10IDe+s3+N2Js4UrPoxC0r7XlFsHX/k3wxeXz6J/kDvK8G/jp4NW0Yk7u3E2tsQDgb29 5evkGYbStOeF2qkLXb+ObD8ABj8aoxuF2luKqkXlKpMf/QCpHEcXdMklM1SDJ2bZUOad dWoURnO1F2bTcYRAUInMG982vMRSxpqphZZhPh9k7lGAFKqeLxv/eRJeahMOpOHt8+8r LsEhxZ6mzdNAyV+cVCrCPGrH5G9yeh3IyOiKfX6v6W1yNpVUDFUeNCNmIBv/7Vse4sLe e9GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fVIsCFJL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f15si5557147edu.193.2020.06.06.06.00.25; Sat, 06 Jun 2020 06:00:51 -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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fVIsCFJL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728838AbgFFM6J (ORCPT + 99 others); Sat, 6 Jun 2020 08:58:09 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:42538 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgFFM6J (ORCPT ); Sat, 6 Jun 2020 08:58:09 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1591448288; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=L0dPa4WboKgSG/BnSettdX0rSi6ZEV66DQzLoB4TqbA=; b=fVIsCFJLySHLa1bmpkrfiq3DAUoR5QG6D8B8t6ci9JVvAasnLHD5vQ9imOv1NxX8oozqmdcJ GfgqMUmwBc/KC408fC1z80gV2ZLjYmlyLxFHGF4wCqvV1iszg8CTupMEeYEC1WSTReN04AZl D1GoqDaHUVtZ7d/5NQ6t+zArt9w= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-west-2.postgun.com with SMTP id 5edb92d8b2f512dd9d5705bc (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 06 Jun 2020 12:58:00 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id D4F1BC43391; Sat, 6 Jun 2020 12:57:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: bgodavar) by smtp.codeaurora.org (Postfix) with ESMTPSA id 42C22C433CA; Sat, 6 Jun 2020 12:57:59 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 06 Jun 2020 18:27:59 +0530 From: bgodavar@codeaurora.org To: Matthias Kaehlcke Cc: Marcel Holtmann , Johan Hedberg , linux-bluetooth@vger.kernel.org, Rocky Liao , Zijun Hu , linux-kernel@vger.kernel.org, Abhishek Pandit-Subedi , Claire Chang , hemantg@codeaurora.org Subject: Re: [PATCH 2/3] Bluetooth: hci_qca: Skip serdev wait when no transfer is pending In-Reply-To: <20200605114552.2.I2a095adb2a9a98b15c11d7310db142b27f8cab28@changeid> References: <20200605184611.252218-1-mka@chromium.org> <20200605114552.2.I2a095adb2a9a98b15c11d7310db142b27f8cab28@changeid> Message-ID: X-Sender: bgodavar@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi matthias, On 2020-06-06 00:16, Matthias Kaehlcke wrote: > qca_suspend() calls serdev_device_wait_until_sent() regardless of > whether a transfer is pending. While it does no active harm since > the function should return immediately it makes the code more > confusing. Add a flag to track whether a transfer is pending and > only call serdev_device_wait_until_sent() is needed. > > Signed-off-by: Matthias Kaehlcke > --- > > drivers/bluetooth/hci_qca.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index b1d82d32892e9..90ffd8ca1fb0d 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -2050,6 +2050,7 @@ static int __maybe_unused qca_suspend(struct > device *dev) > struct hci_uart *hu = &qcadev->serdev_hu; > struct qca_data *qca = hu->priv; > unsigned long flags; > + bool tx_pending = false; > int ret = 0; > u8 cmd; > > @@ -2083,6 +2084,7 @@ static int __maybe_unused qca_suspend(struct > device *dev) > > qca->tx_ibs_state = HCI_IBS_TX_ASLEEP; > qca->ibs_sent_slps++; > + tx_pending = true; > break; > > case HCI_IBS_TX_ASLEEP: > @@ -2099,8 +2101,10 @@ static int __maybe_unused qca_suspend(struct > device *dev) > if (ret < 0) > goto error; > > - serdev_device_wait_until_sent(hu->serdev, > - msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS)); > + if (tx_pending) { [Bala]: Good idea why don't we move this call to switch case under HCI_IBS_TX_AWAKE https://elixir.bootlin.com/linux/latest/source/drivers/bluetooth/hci_qca.c#L1994 i.e. i would recommend below sequence 1. Send SLEEP BYTE 2. wait for some time to write SLEEP Byte on Tx line 3. call for Tx clock off qca_wq_serial_tx_clock_vote_off > + serdev_device_wait_until_sent(hu->serdev, > + msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS)); > + } > > /* Wait for HCI_IBS_SLEEP_IND sent by device to indicate its Tx is > going > * to sleep, so that the packet does not wake the system later.