Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp851067pxu; Wed, 2 Dec 2020 05:12:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4E8Gz7o9ytyoM3RGnhfq9US2Bj177hPw6RPW6FWMdLXbkuQ9+sh+K5+OkQo1AKMI78Zik X-Received: by 2002:a17:906:6c94:: with SMTP id s20mr2284568ejr.0.1606914756090; Wed, 02 Dec 2020 05:12:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606914756; cv=none; d=google.com; s=arc-20160816; b=O3fj4tXtDTV4lHAaD6oWWLsXO/SsXmasPz6CRTxnBfVE5sDgti17WSvDMClMkwcifm TfVMYJT1uE2pnU08J4Qdthl5lbDveL16JC+V5Th0K8ykjTPwj+aScKb+AgZYkw9yM5r/ NzNG4C26bfNu2R+GcwVXBJRdnjjO5aW3qiSBN7qFUe1QOBUW/gqGtY0/C/SIBDKQfqy+ 2Y7AyDcG/okQpd9Bh5bWUiUoK3PC3j9lg9a6elgJcr3VMFZFD7aT9MP2U6zb8wsguu6e IFIQN83JG9oMz8cDt535frT2qOZPCav0rWhgtGIHbFPCavrr6bZmVX/s99sDXZirldQh sKCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=rao2kx/nfZ8V47Cp83R3t0mhKlVepC+40z2Jy48ILag=; b=zqjDUsB0XFV99pDzJinG9rq/NVRROXI8iAcRLy20Y1KyUoWt9Vw+nCrI+NfnPaMhzs NNVnYRhBkqwsMdbNAFAdVZgzfiMD5i6AXcAFlux3dvbod4zn99uSJnY7KWqPQByrYe3C DtpIhWi7KwwPk6VAQyLbUTkG+3nbUMiiCXGayNlbnRMN8uzE22d72/ka8BvxO7V9JDvu T57wDFHmcCHcw9pwVCiyyejLwgP2JWjFm80bwysZ3/KcAub96NavaQvkw1czpy2Qewei 7rxKPrw0P789Jb9FjHHWEh/ZkD4FYKe1flB6Iz66jRPBXiqH4b0L6zRIOeNP+VnE1I3l nLCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rk15si844116ejb.170.2020.12.02.05.12.10; Wed, 02 Dec 2020 05:12:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730116AbgLBNHL convert rfc822-to-8bit (ORCPT + 99 others); Wed, 2 Dec 2020 08:07:11 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:40968 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730099AbgLBNHK (ORCPT ); Wed, 2 Dec 2020 08:07:10 -0500 Received: from mail-pf1-f198.google.com ([209.85.210.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kkRpz-00048h-ET for linux-kernel@vger.kernel.org; Wed, 02 Dec 2020 13:06:27 +0000 Received: by mail-pf1-f198.google.com with SMTP id e68so1210485pfe.4 for ; Wed, 02 Dec 2020 05:06:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=GrUGOpTpSp2pqBXebtTh/akmaDHoTwi3ZKp6lCKMafw=; b=WsJ1yXhRWjkYbqtdp7eRos7weL/AkfT4tSEY8yhomInAFWMVdqiiRM8X1bTNgn1rEl 9/GnE7TneewtDcLuZ2X3gGaV+kolUE1OplulEQGAwpQf5AfzY9zhEMqM0ccJgdTcnur8 N6omkZ1RzGnWejZc/didGShTmFH8Lc2BmuRF9oQp7y9e18xYCrIRfsi/tWblxdJgQnPE qT5kJk87tdQp2Y5jtkj+8ALofKfoAKWh0TiR8U88KXPdCEL+8EOXg/Ng+eP0C4/b6+8p +CG7v6snRdALsTxcFE6vGyMqBAdL+tE7VbY0qya9vcQENE0Vt0XqYb8gUqJt0QrH7ziQ 97Pw== X-Gm-Message-State: AOAM531nLa8VXlgmieqCp2GlKG79avq/j7KIqQs/B2WAvS6AEH1jpCuW pkqWuRjDh0Otjz5WOrq0wPZKUl0sOKquNOknwf7cMlWowwvfP7hu59+aZY8778JGwCKvapNU9ZL 18fHQy6d1s3YaZnE+gB2AQibvk9AHbiyuYS1G0zmEzg== X-Received: by 2002:a65:5302:: with SMTP id m2mr2524334pgq.231.1606914385336; Wed, 02 Dec 2020 05:06:25 -0800 (PST) X-Received: by 2002:a65:5302:: with SMTP id m2mr2524290pgq.231.1606914384979; Wed, 02 Dec 2020 05:06:24 -0800 (PST) Received: from [192.168.1.208] (220-133-187-190.HINET-IP.hinet.net. [220.133.187.190]) by smtp.gmail.com with ESMTPSA id b24sm2014203pjq.10.2020.12.02.05.06.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Dec 2020 05:06:24 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.20.0.2.21\)) Subject: Re: [PATCH 1/2][v3] e1000e: Leverage direct_complete to speed up s2ram From: Kai-Heng Feng In-Reply-To: Date: Wed, 2 Dec 2020 21:06:19 +0800 Cc: Jesse Brandeburg , Tony Nguyen , Jakub Kicinski , Paul Menzel , "David S. Miller" , "Rafael J. Wysocki" , Len Brown , "Neftin, Sasha" , "Kirsher, Jeffrey T" , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Brandt, Todd E" Content-Transfer-Encoding: 8BIT Message-Id: References: To: Chen Yu X-Mailer: Apple Mail (2.3654.20.0.2.21) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yu, > On Dec 1, 2020, at 09:21, Chen Yu wrote: > > The NIC is put in runtime suspend status when there is no cable connected. > As a result, it is safe to keep non-wakeup NIC in runtime suspended during > s2ram because the system does not rely on the NIC plug event nor WoL to wake > up the system. Besides that, unlike the s2idle, s2ram does not need to > manipulate S0ix settings during suspend. > > This patch introduces the .prepare() for e1000e so that if the NIC is runtime > suspended the subsequent suspend/resume hooks will be skipped so as to speed > up the s2ram. The pm core will check whether the NIC is a wake up device so > there's no need to check it again in .prepare(). DPM_FLAG_SMART_PREPARE flag > should be set during probe to ask the pci subsystem to honor the driver's > prepare() result. Besides, the NIC remains runtime suspended after resumed > from s2ram as there is no need to resume it. > > Tested on i7-2600K with 82579V NIC > Before the patch: > e1000e 0000:00:19.0: pci_pm_suspend+0x0/0x160 returned 0 after 225146 usecs > e1000e 0000:00:19.0: pci_pm_resume+0x0/0x90 returned 0 after 140588 usecs > > After the patch: > echo disabled > //sys/devices/pci0000\:00/0000\:00\:19.0/power/wakeup > becomes 0 usecs because the hooks will be skipped. > > Suggested-by: Kai-Heng Feng > Signed-off-by: Chen Yu Well, I was intended to send it, but anyway :) > --- > v2: Added test data and some commit log revise(Paul Menzel) > Only skip the suspend/resume if the NIC is not a wake up device specified > by the user(Kai-Heng Feng) > v3: Leverage direct complete mechanism to skip all hooks(Kai-Heng Feng) > --- > drivers/net/ethernet/intel/e1000e/netdev.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c > index b30f00891c03..b210bba3f20a 100644 > --- a/drivers/net/ethernet/intel/e1000e/netdev.c > +++ b/drivers/net/ethernet/intel/e1000e/netdev.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > > #include "e1000.h" > > @@ -6957,6 +6958,12 @@ static int __e1000_resume(struct pci_dev *pdev) > return 0; > } > > +static int e1000e_pm_prepare(struct device *dev) > +{ > + return pm_runtime_suspended(dev) && > + pm_suspend_via_firmware(); > +} > + > static __maybe_unused int e1000e_pm_suspend(struct device *dev) > { > struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev)); > @@ -7665,7 +7672,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > > e1000_print_device_info(adapter); > > - dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NO_DIRECT_COMPLETE); > + dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_SMART_PREPARE); This isn't required for pci_pm_prepare() to use driver's .prepare callback. > > if (pci_dev_run_wake(pdev) && hw->mac.type < e1000_pch_cnp) > pm_runtime_put_noidle(&pdev->dev); > @@ -7890,6 +7897,7 @@ MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); > > static const struct dev_pm_ops e1000_pm_ops = { > #ifdef CONFIG_PM_SLEEP > + .prepare = e1000e_pm_prepare, How do we make sure a link change happened in S3 can be detect after resume, without a .complete callback which ask device to runtime resume? Kai-Heng > .suspend = e1000e_pm_suspend, > .resume = e1000e_pm_resume, > .freeze = e1000e_pm_freeze, > -- > 2.17.1 >