From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 141A0C64E75 for ; Fri, 27 Nov 2020 12:20:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1997208D5 for ; Fri, 27 Nov 2020 12:20:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728177AbgK0MU3 convert rfc822-to-8bit (ORCPT ); Fri, 27 Nov 2020 07:20:29 -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-Google-Smtp-Source: ABdhPJyOBowy9IJi0/7OpQ1/omr4WS/MyPdQJSxY2m0LG0Nwtlwb0ImygarwrGxChNbnyIpsUl/q6Q== 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