From patchwork Tue Dec 18 07:57:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 154117 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3403396ljp; Mon, 17 Dec 2018 23:57:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/VM+VLQDQjFhFvpNHLC1yIuZOND4VIk33N8l713WpuJfvknZJIUCsAY0OeZ70Vegys7yl/w X-Received: by 2002:a62:a510:: with SMTP id v16mr15652080pfm.18.1545119856214; Mon, 17 Dec 2018 23:57:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545119856; cv=none; d=google.com; s=arc-20160816; b=q5oBp5wFCfjhb3NXxfa7KUzErDpemuQmyuHX/uS6RMj6sbQKrprwgmM8g1qJKM2LGq NPdOcwACsBKMFJA2W54HeZ4nTKbSJmvb0Ae1eVoaRcn3Iv9MMW3KuWgGjRoooI51E0GA q6pEJyWz91oh/VzIFwfgV499OMK/fyJTVnw+Hwxx0lHLFPzwlB+ruC4iY8+k1d4sLZZt ovMzJOSGCtr/tBcmjDxoix5YMMPonX+nRlJ8E57NVwJnXpVMNtkWUDEiS0h6FJC56yDe 1urKeSq4PnHRP02eiNphiDi9AMyZk1waDuZH2XycVs2ArZYatP58Ibg3+K+G1C8v83nC A67w== 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=BIx9hA2zj3vai1Z5GvP4namXqSVfCcmuU7QFyxtAWZg=; b=p0nH/LpBNWAyZFHSUkrCCdfOBNFXfAXhlqtYnyCgBP8SoJBxa7NzpI7sWLd0Vl8uuF 6aOruQ0BCVLkS9TMPhszsjfCI7zbB17W97pIC+MBBixCfJa328B64wV/F9BLIM6bTimz YuM6n5jz8/LD+CD31yJMPCTPzQgZ1+7hGsQAzbw2tTYsR6jNcVLLgGq1GBgjRKTzQ18e TjTIdmrj2X9YenBze5kHU6QyCZbtRGOo0N+QEWyID4O6+Fmw0upT7ipS/kfZ8DeWOcNS 5+lTy+jpvrIEDhab15QkOXIrxWKZ8h9SbwzoR0HFWuwwlzWvvcFZHcXqfPJJ8F92niOg QTuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 91si12795758ply.222.2018.12.17.23.57.35; Mon, 17 Dec 2018 23:57:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbeLRH5d (ORCPT + 10 others); Tue, 18 Dec 2018 02:57:33 -0500 Received: from mx.socionext.com ([202.248.49.38]:4468 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726505AbeLRH5c (ORCPT ); Tue, 18 Dec 2018 02:57:32 -0500 Received: from unknown (HELO kinkan-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 18 Dec 2018 16:57:29 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by kinkan-ex.css.socionext.com (Postfix) with ESMTP id 1B796180097; Tue, 18 Dec 2018 16:57:30 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Tue, 18 Dec 2018 16:57:30 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id 686BD1A1235; Tue, 18 Dec 2018 16:57:29 +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] net: phy: Fix the issue that netif always links up after resuming Date: Tue, 18 Dec 2018 16:57:04 +0900 Message-Id: <1545119824-30380-1-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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(). 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 -- 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; }