Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4210795rwb; Tue, 16 Aug 2022 17:08:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR59Yzx45FkAof32NCK9tckhpVwD+VRVZiGMvPq1cvaEpVHQTAPzeAK7Z/UWFUToUuA9YW5/ X-Received: by 2002:a17:903:2342:b0:16e:e279:912e with SMTP id c2-20020a170903234200b0016ee279912emr23506385plh.138.1660694895966; Tue, 16 Aug 2022 17:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660694895; cv=none; d=google.com; s=arc-20160816; b=aahhwgmGoHYt5caCAbQIVFwxnSQuL5oTBU+o+lc3DviOJ+WKNG6KVOfJuLwXtSwPFa /Qe0TD8ABlNqorTOqE+NzLbyzh+5VSREBi53/vgghr+Kvwm85cj8cXD60BtLsDXl74BA QApjEmlzvSOY1GVptMk6q1ixTV9tydd9Hp2qXVq5ElGapz3hs4nqGYN06EYRgLbZFAMR 6VYwr9SanxAhJ+WtXbXjDaRR7j8MLkJEl15UYJ4rkP09y9O0okux1FtuGXQae3jXOFAf xI/5v6YhW/DOOOEl0jb/RYBt94zrsMrj1swLH7perPZjMVKSGUyNrODBFdcqDj3fb/Oi YDEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zcVcSBUYWoFWjcfEXcoAiD7y86Ff1CMvGHRV3ofuKE8=; b=ub2P1OBacSFzybl+emxNNeWaY98KYQHNHjriDfChn7lko92XeqM7biqW05CXkeNWvh o7yAs/FYB1uxY1E40Azzvvez10vOUxn8/L5kxVHmq6fBol35fUhFsmh1tAG3OHSaIzfp 9UOpUwK+n94XvF1bXrAMfAf9PUFk/mV/nHAx+5uLYHs29P+E+0uS+6Eiv96AR4OhrQyc kp2aUrASt/5eq7tkFFPf9HLUqNBov2OCWkKh18MdjjK4zjCZpWxwts+X5CfmernZzqz4 Ibdqyz281erw7vKXEi9ZRNjRTEn1Sxou3Wik9uGgRoUgL/jDALCmSkdCKBHFW3oNlWd+ 6iSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oYPogaVI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 198-20020a6300cf000000b00420bea01408si15744785pga.713.2022.08.16.17.08.03; Tue, 16 Aug 2022 17:08:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@chromium.org header.s=google header.b=oYPogaVI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237848AbiHPX64 (ORCPT + 99 others); Tue, 16 Aug 2022 19:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237810AbiHPX6z (ORCPT ); Tue, 16 Aug 2022 19:58:55 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 717A690C51 for ; Tue, 16 Aug 2022 16:58:54 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id 130so10451357pfy.6 for ; Tue, 16 Aug 2022 16:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=zcVcSBUYWoFWjcfEXcoAiD7y86Ff1CMvGHRV3ofuKE8=; b=oYPogaVIhlWq1V0gz8+5Wzm9ZHEqqbefaHWf0sUHjVAvzPfG6cop6Y0bujJ1uZ3po/ bRT28HyO5U2+6gQFUx6IqHO+ONhxGemJoEO18KdVHOvNDbC8FLzEwf74Ax8Msep2JYgX oTOeFv2cGB9mBZ2jDO2kW5CWBcjj0l+0s6ffk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=zcVcSBUYWoFWjcfEXcoAiD7y86Ff1CMvGHRV3ofuKE8=; b=MdQXQuzKee8H5pmUKNwodHbI1stM94paNG4egk/KRE55CVRpsbqUniJ08BTabsYGdF JJDH/UUBQKpzpi+S6mFJfM4/Z1sujD+hPvb8Ve0W1TSkspi8+4NLI1Kt7oCfXueTIiM3 C+ADc8zzh3/PWHumJs6i7N/IQpdk6nB4xcg4uDC7RFlzPZHXkE/iP732tyss2GWF4FYh CTDVkyYUZ2LQrVRsndExqMW08dZ0FBCxyEZuVpzzqK/p6zv5NE8hdbj1H8Ru7Sh2veYY oFrWuY1s6p0yw3P3zGTvCTnQeaLvK+qakyDwLqA09hH/VY+P8f0JLh8MDuNFGr2meGEj pwcg== X-Gm-Message-State: ACgBeo1jyrpPqnL/2zpWbwu/8K5pk8FUbeRvcPKamQ38Pbxx2HDegM1P /lDIEMajHMqWNqh7zYh1IezLoA== X-Received: by 2002:aa7:96d5:0:b0:52e:e2a:9c79 with SMTP id h21-20020aa796d5000000b0052e0e2a9c79mr23395515pfq.55.1660694333888; Tue, 16 Aug 2022 16:58:53 -0700 (PDT) Received: from localhost ([2620:15c:11a:202:f730:6f91:6154:bee4]) by smtp.gmail.com with UTF8SMTPSA id l7-20020a170903120700b001709e3c750dsm9712094plh.194.2022.08.16.16.58.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Aug 2022 16:58:53 -0700 (PDT) Date: Tue, 16 Aug 2022 16:58:51 -0700 From: Matthias Kaehlcke To: William McVicker Cc: Bjorn Helgaas , kernel-team@android.com, Sajid Dalvi , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] PCI/PM: Switch D3Hot delay to use usleep_range Message-ID: References: <20220811184001.2512121-1-willmcvicker@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On Tue, Aug 16, 2022 at 10:17:31PM +0000, William McVicker wrote: > On 08/16/2022, Matthias Kaehlcke wrote: > > On Thu, Aug 11, 2022 at 06:40:01PM +0000, Will McVicker wrote: > > > From: Sajid Dalvi > > > > > > Since the PCI spec requires a 10ms D3Hot delay (defined by > > > PCI_PM_D3HOT_WAIT) and a few of the PCI quirks update the D3Hot delay up > > > to 20ms, let's switch from msleep to usleep_range to improve the delay > > > accuracy. > > > > > > This patch came from Sajid Dalvi in the Pixel 6 > > > kernel tree [1]. Testing on a Pixel 6, found that the 10ms delay for > > > the Exynos PCIe device was on average delaying for 19ms when the spec > > > requires 10ms. Switching from msleep to uslseep_delay therefore > > > decreases the resume time on a Pixel 6 on average by 9ms. > > > > > > [1] https://android.googlesource.com/kernel/gs/+/18a8cad68d8e6d50f339a716a18295e6d987cee3 > > > > > > Signed-off-by: Sajid Dalvi > > > Signed-off-by: Will McVicker > > > --- > > > drivers/pci/pci.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > > > index 95bc329e74c0..5ae5b3c4dc9b 100644 > > > --- a/drivers/pci/pci.c > > > +++ b/drivers/pci/pci.c > > > @@ -72,7 +72,8 @@ static void pci_dev_d3_sleep(struct pci_dev *dev) > > > delay = pci_pm_d3hot_delay; > > > > > > if (delay) > > > - msleep(delay); > > > + usleep_range(delay * USEC_PER_MSEC, > > > + (delay + 2) * USEC_PER_MSEC); > > > > You could also use fsleep(), which ends up calling usleep_range() > > for (usecs > 10 && usecs <= 20000). > > Thanks for the suggestion. I see fsleep() uses 2 * usec for the upper range > which I think is a bit much for this optimization. The documentation says > in the worse case an interrupt will be triggered for the upper bound, but > I'm not entirely sure how often that'd be. Thoughts? Ah, I misread 'delay + 2' in your patch as 'delay * 2', which would result in the same. Agreed, in the spirit of your optimization it probably doesn't make sense to use fsleep(). The range of 2us is really narroy, you could consider making it something like 10 or 20% of 'delay'.