From patchwork Wed Dec 19 02:01:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 154222 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4405979ljp; Tue, 18 Dec 2018 18:01:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/X/KoH3mi+iutxLy+V2ieAaerZYXKchKceJkSAT7xRRjV1K2fXoBeg7UYhNWgBLjOTPQTF8 X-Received: by 2002:a62:7504:: with SMTP id q4mr18377502pfc.180.1545184903537; Tue, 18 Dec 2018 18:01:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545184903; cv=none; d=google.com; s=arc-20160816; b=D50Rh7E8dfHePexHJtPs+2HKEXHMgwMXx174YkpfSk9DMRC+89U5pzrgecsXO8yWmR kZ8Rfif+04XPCEBPOYQbRA4Jc0JRbN1uqzdvLJRkeOr6C5jDcc5eOY2aTruR+Y1NbhvJ B4VC7XFIfteMl8HZ3mu3xTwiIkhUg7ulMD8vSi2CP0Y18odid/TFYe5BctNwTSz3Tdk+ EimB73LuS2REAjj2MwEsrv3hjS4BEnbf1wT1sK6pTxoECY8YvzcoQjIOlA3DPLK2dYMN 4YQQvucMZgWTgRlg0Vtrrbmwr00mTkwZhjYfJouqCccF5vyKyi2eB70w2mkaqIgXbYkU Igmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=zUm4OzhSX9+ERNVQi1K5mdq2AsWHZJSSCpp5uh93+5U=; b=Xni0HzcV4PdLhVPPwmrdpxCgXQKagV4UuHvB+a+HfIoNAFQYZk8q7WVLVZ3K3IHveZ 2xeRike+iqOme3Tz+hV3ugaWvnFvnGD6t/X6WfcdyzhXb+K77Y9Ek8/rxmvbBISlNc+O TqrkmnzyuLsMD3TgG5KHI6LntG13qCsbRF6VNE5BPRs6HSFNT4FbIIIVEtOYiyUPzGOI kcYZRpjpUnabUMq8TotM137+KcinNpsMJW3lzV9rNNyerBxprCZMLZkK7cgW+yeosp3U MfS9A1lIkkyMduKpJZzIlqpAlJnttpjvselp3mni73VPXLpJ+Eh/pXEPKetg7HuJx0xR +3hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i66si6540458pfb.91.2018.12.18.18.01.42; Tue, 18 Dec 2018 18:01:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727963AbeLSCBk (ORCPT + 31 others); Tue, 18 Dec 2018 21:01:40 -0500 Received: from mx.socionext.com ([202.248.49.38]:13840 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727321AbeLSCBk (ORCPT ); Tue, 18 Dec 2018 21:01:40 -0500 Received: from unknown (HELO iyokan-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 19 Dec 2018 11:01:38 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by iyokan-ex.css.socionext.com (Postfix) with ESMTP id 8729960062; Wed, 19 Dec 2018 11:01:38 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Wed, 19 Dec 2018 11:01:38 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id 1731E1A03A2; Wed, 19 Dec 2018 11:01:38 +0900 (JST) From: Kunihiko Hayashi To: Heiner Kallweit , Andrew Lunn , Florian Fainelli Cc: "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH net v2] net: phy: Fix the issue that netif always links up after resuming Date: Wed, 19 Dec 2018 11:01:14 +0900 Message-Id: <1545184874-7078-1-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Even though the link is down before entering hibernation, there is an issue that the network interface always links up after resuming from hibernation. If the link is still down before enabling the network interface, and after resuming from hibernation, the phydev->state is forcibly set to PHY_UP in mdio_bus_phy_restore(), and the link becomes up. In suspend sequence, only if the PHY is attached, mdio_bus_phy_suspend() calls phy_stop_machine(), and mdio_bus_phy_resume() calls phy_start_machine(). In resume sequence, it's enough to do the same as mdio_bus_phy_resume() because the state has been preserved. This patch fixes the issue by calling phy_start_machine() in mdio_bus_phy_restore() in the same way as mdio_bus_phy_resume(). Fixes: bc87922ff59d ("phy: Move PHY PM operations into phy_device") Suggested-by: Heiner Kallweit Signed-off-by: Kunihiko Hayashi --- drivers/net/phy/phy_device.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) This patch is based on the RFC patch discussion [1]. [1] https://www.spinics.net/lists/netdev/msg537326.html Changes since v1: - Add "Fixes:" line -- 2.7.4 diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 7d5d698..3685be4 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -315,11 +315,8 @@ static int mdio_bus_phy_restore(struct device *dev) if (ret < 0) return ret; - /* The PHY needs to renegotiate. */ - phydev->link = 0; - phydev->state = PHY_UP; - - phy_start_machine(phydev); + if (phydev->attached_dev && phydev->adjust_link) + phy_start_machine(phydev); return 0; }