From patchwork Mon Jul 27 11:05:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 11686739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF9DF13B1 for ; Mon, 27 Jul 2020 11:07:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8710E205CB for ; Mon, 27 Jul 2020 11:07:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="3dYowazh"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=Synaptics.onmicrosoft.com header.i=@Synaptics.onmicrosoft.com header.b="Plq9fiev" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8710E205CB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=synaptics.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=K/KVqSKAFriR6WJrVSh3sM6Tx3871y7hgPx0W16wvZk=; b=3dYowazh7Z5Nx82tLuU8JgZ6O zRWEx/8561541eo5XsIBRoaAyWCWkc89sCREW3ekjl8adSLeSYcxqM3mLp5wGLycW+CAkT+IyysMf bYURSGox9O2zAA03xbXrFaCb4fyFQKfry7k7f/ILo3fF41pShBOO5WAvpSh16QnPmZml7J8ZOq7nB yWnNZWjZe7Pe2Hmp4bq1xCZXX9MgSvoz/qhLuojIqpn25AdJCmR4HKbfGzyK4iaRWBgVZjLClBD1V 70pX5IfzGmDRxQQrJ+/tUaDydShkagMTiY6j9aDHLDxNaDW5dFJ9Ef7saeZ46aEqWUbV2cylGwJnG kv0GdnqyA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k00xF-000102-SA; Mon, 27 Jul 2020 11:06:01 +0000 Received: from mail-bn8nam12on2072.outbound.protection.outlook.com ([40.107.237.72] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k00xC-0000yy-P6 for linux-arm-kernel@lists.infradead.org; Mon, 27 Jul 2020 11:06:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IuTu1OrisARg/xJ7e2jpna6ApWPVpQtkAsDKgqFdqga4hglZu6op3gDe/70Suln6I43nDMVmA+2SnwgCH74t8GDvRTK9hdwmMshJ9Hc0pi5lWdTZbuWXLQQESO4v7xSAj58d1AoutozX3CW5Tww9grC4foKowhrTgYMFgwok0k95VB8rDQf5bjuhD4BxzYOZJVaO74pBuWcOFqUrkpmFZ6dytgjgF7QPjhVMwKVdZrxf9AUQPaSfGehbcRHvp6iO0Bxa+Y7b3PR9Yz9HfI+nAIECM5eFZrL9rWaPjw3+SwZtpwU/hZow1/oqQQMO+7Xnjcp1misme0ZDGK/oxDLgXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I0mJ5fOY5w5YplvJ8PfMzlPu/g0W4Z3tgtxf/esFL/M=; b=bV+DanoWHUNefzO7YbHNFWzwGKgqGn9QYWnBy3ZGrDKuEaYpRiqoGhKHuJgnJKpaMZ3p53dqflpSaafyfYFe/0cwB72hMVkESG+LVRbvxeSG88MTs66SbBE+XOJYm4fwthtNoa1VPTq2Tdrk2wkKODh/QPEdY9zbh63WM1sJqe8/YnUCgoht+FpIgrDe05/bJi+KqMgp5UiTZAMjGF5WCc97ElNupSdiAjt8dHajYJ+NXgEmxAM4q/TJBJJBLswrhf5m3H6cnzDREz4YPPVKebVaUozloqV9+GjXwQl1sM0Ur7EooO5lxCDVvtjTnXWXpVOBRLhFsp+y8ZWH0Pk4iA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I0mJ5fOY5w5YplvJ8PfMzlPu/g0W4Z3tgtxf/esFL/M=; b=Plq9fievo6phw2KZvgBDESbDe52wqj9AoBQCvG6xzOd2QqC1AiFXJV0Tz0bJsb38SGIPhRCsUEEAQ1l63c+X8WT9NRAXYB4qYrk4R5Db/x7Fz0vWExk7XvJ2SXJrkbd5p6w8xJL7c+dtk+Qmu+EHuUaFmJU3BYULSulORUQHhF4= Authentication-Results: st.com; dkim=none (message not signed) header.d=none;st.com; dmarc=none action=none header.from=synaptics.com; Received: from BYAPR03MB3573.namprd03.prod.outlook.com (2603:10b6:a02:ae::15) by BYAPR03MB4198.namprd03.prod.outlook.com (2603:10b6:a03:7e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.21; Mon, 27 Jul 2020 11:05:54 +0000 Received: from BYAPR03MB3573.namprd03.prod.outlook.com ([fe80::b5cc:ca6b:3c25:a99c]) by BYAPR03MB3573.namprd03.prod.outlook.com ([fe80::b5cc:ca6b:3c25:a99c%4]) with mapi id 15.20.3216.033; Mon, 27 Jul 2020 11:05:53 +0000 Date: Mon, 27 Jul 2020 19:05:20 +0800 From: Jisheng Zhang To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Maxime Coquelin , Russell King Subject: [PATCH 5/5] net: stmmac: Speed down the PHY if WoL to save energy Message-ID: <20200727190520.3c07cf41@xhacker.debian> In-Reply-To: <20200727190045.36f247cc@xhacker.debian> References: <20200727190045.36f247cc@xhacker.debian> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-ClientProxiedBy: TY2PR01CA0012.jpnprd01.prod.outlook.com (2603:1096:404:a::24) To BYAPR03MB3573.namprd03.prod.outlook.com (2603:10b6:a02:ae::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from xhacker.debian (124.74.246.114) by TY2PR01CA0012.jpnprd01.prod.outlook.com (2603:1096:404:a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23 via Frontend Transport; Mon, 27 Jul 2020 11:05:50 +0000 X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-Originating-IP: [124.74.246.114] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d5d2d1ba-c36e-46db-6fd2-08d8321d0760 X-MS-TrafficTypeDiagnostic: BYAPR03MB4198: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zSC9B9vVhX6kYEA5qvR2ioC8hPtz9Ck7Hi/zT9gYl/8NuyQ/v/6ZZWu9D+AJ2vvNoVB0nvDc4cNTiRRABAwOcL9jHcYT2Cp/LCo/i5ywgEB/d3E3NHi7A6DYd1xpprGRhG09AQfndcbshFbIRQFd0fqIfP4F4a40bh3Xvo7pCKI92kyvEPhZD+wNtSroBBOHRtpK88FpUtiYvdr1236V2WccPIEo3V7TwsI76T2djMKgmXw13ZqpVDcQ764JQa6FbWJsUBbBwj2Nu/oOGRy/tfjvM6NEdQh9vodn0F+AE5f0iaVDXirtWnfSCMqQO9MA X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR03MB3573.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(39860400002)(366004)(346002)(376002)(396003)(136003)(66946007)(66476007)(66556008)(5660300002)(6506007)(55016002)(86362001)(52116002)(9686003)(8676002)(478600001)(110136005)(7696005)(316002)(1076003)(4326008)(16526019)(8936002)(26005)(956004)(83380400001)(2906002)(6666004)(7416002)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: U9gOipn4XE70Q401JoA2yP1BanG2qA/6l+8h8T/plTJyPUxqayZTe6b5Y3mLUPLYKZOsBgikWCh3hH7w5zofrFJaHiRtTCZVRv7HfuAc9jsPT8alN+iwd5sEFajJkanLrfI3zNCSK/k2RMJK3JSjUiAmuQUPlzytKoWdO0F4Vk2PaCUmLr7pGtSFJkkBAM+0wMjYrkodYy1HNvguaBQwEs3tbvXCq/WY9DmdAr6870sqlSadaPodO3+ZNs3vgOEkZuMk/o0y4DGbQdKwOoaKW4ovHH/Kioc4Euabw0K+myXrSp+qSvZuOxumdCOdlt4WOQNGgb/utO0VajsVMYtO8OT9ihaJDtYV2+yZ70VX7NCYMF/kceRzm2Qfgn2Tz0+FtTdN3/Ni1EBkz5Thnh6xIz449a7ItOcEZG9nWFG9hhRzUad2knl7OTeRBPdxHwf7zK5ZRMBizRLyIRxQutfOicua2vr+GflYr9xFkCz7rg5hY/jveLjHd56pQwBLqMHy X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5d2d1ba-c36e-46db-6fd2-08d8321d0760 X-MS-Exchange-CrossTenant-AuthSource: BYAPR03MB3573.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2020 11:05:53.5594 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zfP9CxjVXZVM0coxsJV+6H25yvuL9PgXyLsOJgc4fgX7nLEE3Ikd5T0ivZYNOUURfpJa4lWe1wS60NS4ztmdLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4198 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200727_070558_943708_EDEB8E15 X-CRM114-Status: GOOD ( 14.13 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.237.72 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.237.72 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When WoL is enabled and the machine is powered off, the PHY remains waiting for wakeup events at max speed, which is a waste of energy. Slow down the PHY speed before stopping the ethernet if WoL is enabled, Signed-off-by: Jisheng Zhang --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 32c0c9647b87..89b2b3472852 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2823,6 +2823,8 @@ static int stmmac_open(struct net_device *dev) stmmac_init_coalesce(priv); phylink_start(priv->phylink); + /* We may have called phylink_speed_down before */ + phylink_speed_up(priv->phylink); /* Request the IRQ lines */ ret = request_irq(dev->irq, stmmac_interrupt, @@ -2896,6 +2898,8 @@ static int stmmac_release(struct net_device *dev) if (priv->eee_enabled) del_timer_sync(&priv->eee_ctrl_timer); + if (device_may_wakeup(priv->device)) + phylink_speed_down(priv->phylink, false); /* Stop and disconnect the PHY */ phylink_stop(priv->phylink); phylink_disconnect_phy(priv->phylink); @@ -5095,6 +5099,8 @@ int stmmac_suspend(struct device *dev) } else { mutex_unlock(&priv->lock); rtnl_lock(); + if (device_may_wakeup(priv->device)) + phylink_speed_down(priv->phylink, false); phylink_stop(priv->phylink); rtnl_unlock(); mutex_lock(&priv->lock); @@ -5207,6 +5213,8 @@ int stmmac_resume(struct device *dev) if (!device_may_wakeup(priv->device) || !priv->plat->pmt) { rtnl_lock(); phylink_start(priv->phylink); + /* We may have called phylink_speed_down before */ + phylink_speed_up(priv->phylink); rtnl_unlock(); }