Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1296400pxu; Fri, 27 Nov 2020 04:24:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUwJhhigXL/7ML0no7FjGIKtFZa/la/ipwr0TedG2MBQRRMykoRko7Uj9GxPcfdsiTIGtu X-Received: by 2002:a17:906:9452:: with SMTP id z18mr5071089ejx.389.1606479861520; Fri, 27 Nov 2020 04:24:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606479861; cv=none; d=google.com; s=arc-20160816; b=P1Ftjb+QgxLIpmH03V6q4JDkOJ83T0JgzN+/1Q8c9oqP4Fr0O5lyJSWzet4O0NaqO5 Hygk9rrzheueNRZoEHel2oeBUnkAw7XYcY/lvzLHeXPKGByLs2jVzHEjhd9MxS12Ied+ j4UXR2TTTbhh5eB3rXd+Bnye77ZS66TcY0OSejBzh/jDC493wE4Q9DTSJ1w2eM4B5Kww aR/hPkHs5AXr9DC5JS3IEghSLydihISXyLIWY3TtOVaTayL2NnQTt0ej9ZJQsO2bArb6 dFHkdhOHyRwrfS/HZUHtc7qsTZH+FHwuBhf7+mewmd6TshqqwSFLHpXzIm8am4lUQ7pr bocQ== 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=rdm5SzqDxhq96R/S2PTxXd3sKV7dAg62VTKhc8JO8K8=; b=R4Y+LOA+6yiPyb3t3HPRnkC2VX/FoG5AJIYTIBJcxS80W61+4r0IJGsEbdnGWP2rCG 8WhboTdrC3d6jzIhnhnfOSbSA2VKq07AhubmzsBWT8OM8YIM4+hcgvGu7hj3xxLUKCu9 bo76zpz+3G1Q257RXFVvDlGIKRnYFpu3kBSHg+mL3U0KzhiiQnkcgf9woF5U8q1iAY4V 5HQNIsEfHNEaZmxmxFJ40uL4vivfig1l9PED82qZZCDQgCgkCHpfSPeGLiNNAUICbnRc Eeq1GiajKYAVCjN5jV8BOstnhPYr29cc4Z8B6deO8viim9Of7wb5o8cD1AHV3nosQd/5 cSVQ== 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 v9si4989529edb.48.2020.11.27.04.23.56; Fri, 27 Nov 2020 04:24:21 -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 S1728120AbgK0MU2 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 27 Nov 2020 07:20:28 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:46884 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727455AbgK0MU1 (ORCPT ); Fri, 27 Nov 2020 07:20:27 -0500 Received: from mail-pl1-f200.google.com ([209.85.214.200]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kicjg-0003BX-IC for linux-kernel@vger.kernel.org; Fri, 27 Nov 2020 12:20:24 +0000 Received: by mail-pl1-f200.google.com with SMTP id 4so3487103pla.6 for ; Fri, 27 Nov 2020 04:20:24 -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=AD55zNbNN3hSJeVAhPYoSyBdi6S9TrVNi5mGtnE8ZpU=; b=c8/TFsg3gOFrg+zR16urjF6wNzdedxT+I2oeFMuwEKDZcwO9TUgVPINKXKt+pBNrHt OzyvT23WHaDj9fFwsyjO3VinAPoZ/f0fbGWH0FKlECW1qMG8M8ewi80O4NqaKUhMmk9j +eooHW3Ji2XyBEHXXFt4r2JFCmYlhV48uYBmoZG5V168w6lxPGcexzOSkAsic6HZp52y SiUHI2CThWyn5aKxgmQtl8psSm9PHZOwK1KRq0HQ2i/r5kb69J+PZBJKLKSReDH/0Y1J +m8DvjP9SSkmDy1iKe2+KfefjPoCjxDJJSpH7lS3cHePaTwdApXrm22wDL8ek7nTQtjz kakA== X-Gm-Message-State: AOAM531hwOTMExZqPzO86ic+DPsIU3hUik19yDrMs0xhL0RhUnS4oc9L YJ25Ced3rtNveShLKMndeVv9FQBRu08HXH+ftpVL8DSVlk+YBeahj1m5QhzNbdzYbPqdL0xU2/e l1Wm5Oo8OehCXaCgw7VredloQkFCJyAaMa2kyap68xA== X-Received: by 2002:a63:4950:: with SMTP id y16mr5471496pgk.415.1606479622886; Fri, 27 Nov 2020 04:20:22 -0800 (PST) X-Received: by 2002:a63:4950:: with SMTP id y16mr5471472pgk.415.1606479622534; Fri, 27 Nov 2020 04:20:22 -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 o18sm7538151pfp.16.2020.11.27.04.20.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Nov 2020 04:20:21 -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] e1000e: Assign DPM_FLAG_SMART_SUSPEND and DPM_FLAG_MAY_SKIP_RESUME to speed up s2ram From: Kai-Heng Feng In-Reply-To: <20201126144536.GA19171@chenyu-office.sh.intel.com> Date: Fri, 27 Nov 2020 20:20:17 +0800 Cc: "Rafael J. Wysocki" , Len Brown , Tony Nguyen , Jesse Brandeburg , "moderated list:INTEL ETHERNET DRIVERS" , Linux PM list , open list , Sasha Neftin , Jeff Kirsher Content-Transfer-Encoding: 8BIT Message-Id: References: <20201124153221.11265-1-yu.c.chen@intel.com> <8BA4D1E1-DACF-4E84-A5B8-75A7CEA65F98@canonical.com> <20201125103612.GA17700@chenyu-office.sh.intel.com> <20201126111053.GA15841@chenyu-office.sh.intel.com> <43247451-BA44-4958-A921-2BD0FF5FA5BA@canonical.com> <20201126144536.GA19171@chenyu-office.sh.intel.com> 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 > On Nov 26, 2020, at 22:45, Chen Yu wrote: > > On Thu, Nov 26, 2020 at 08:05:02PM +0800, Kai-Heng Feng wrote: >> >> >>> On Nov 26, 2020, at 19:10, Chen Yu wrote: >>> >>> On Thu, Nov 26, 2020 at 02:36:42PM +0800, Kai-Heng Feng wrote: >>>>>> >>>>>> What about plugging ethernet cable and using WoL after system is suspended? >>>>>> Commit "e1000e: Exclude device from suspend direct complete optimization" was to address that scenario. >>> [cut] >>>> >>>> I don't think this is right. >>>> Isn't E1000_WUFC_LNKC already set for runtime suspend? >>>> What if WoL doesn't have it set? >>>> >>> After re-taking a look at your description, please let me elaborate more about the scenario. >>> With this patch applied, and with sysfs wake up disabled, the expected behavior is: >>> >>> 1. If NIC is not runtime suspended: >>> 1.1 s2ram suspend -> wufc will be set to 0(no WoL settings), suspend(), suspend_late(), suspend_noirq() >>> 1.2 s2ram resume -> NIC resumes normaly >>> >>> 2. If NIC is runtime suspended: >>> 2.1 s2ram suspend -> wufc set to E1000_WUFC_LNKC, skip the subsequent suspend callbacks. >> >> Is it safe to keep E1000_WUFC_LNKC enabled here? >> >> From commit 6bf6be1127f7 ("e1000e: Do not wake up the system via WOL if device wakeup is disabled"): >> >> /* Runtime suspend should only enable wakeup for link changes */ >> if (runtime) >> wufc = E1000_WUFC_LNKC; >> else if (device_may_wakeup(&pdev->dev)) >> wufc = adapter->wol; >> else >> wufc = 0; >> >> So it has different wakeup settings for runtime suspend and system suspend, either device_may_wakeup() true or false. > Right. >> Or maybe e1000e devs can confirm E1000_WUFC_LNKC is a safe for system suspend? >> > Does 'safe' here mean waking up the system? > For s2ram, whether the NIC can wake up the system from S3 via cable plug is platform > (BIOS) specific. So the wufc settings here is not directly related to system wake up > via plug event. Thanks for the confirmation. How about a different approach? Simply use direct-complete to let PM core handle the rest: diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index b30f00891c03..1d1424a20733 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" @@ -6868,6 +6869,20 @@ static void e1000e_disable_aspm_locked(struct pci_dev *pdev, u16 state) __e1000e_disable_aspm(pdev, state, 1); } +static int e1000e_pm_prepare(struct device *dev) +{ + return pm_runtime_suspended(dev) && + pm_suspend_via_firmware() && + !device_may_wakeup(dev); +} + +static void e1000e_pm_complete(struct device *dev) +{ + /* Detect link change */ + if (pm_runtime_suspended(dev)) + pm_request_resume(dev); +} + static int e1000e_pm_thaw(struct device *dev) { struct net_device *netdev = dev_get_drvdata(dev); @@ -7665,9 +7680,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); - - if (pci_dev_run_wake(pdev) && hw->mac.type < e1000_pch_cnp) + if (pci_dev_run_wake(pdev)) pm_runtime_put_noidle(&pdev->dev); return 0; @@ -7890,6 +7903,8 @@ MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); static const struct dev_pm_ops e1000_pm_ops = { #ifdef CONFIG_PM_SLEEP + .prepare = e1000e_pm_prepare, + .complete = e1000e_pm_complete, .suspend = e1000e_pm_suspend, .resume = e1000e_pm_resume, .freeze = e1000e_pm_freeze, > thanks, > Chenyu