From patchwork Wed May 14 01:40:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 30141 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 03AB320446 for ; Wed, 14 May 2014 01:40:37 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id i57sf4172364yha.8 for ; Tue, 13 May 2014 18:40:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=4kHW4orndXfuz3bH0kHrM8BXxQ7V+sN9jTUMxoa15lU=; b=AEvA6DZwwyHUGnAjAwyNpCQ0unxNM3rktgY+uvrFR3RHrmth/Hg/q4H570GOvfIM8u iLM2C6PQcRAcCvdaa34JZ47k9vU0PSEYQ957LRxNw5iWgmLMUbua+qFpzZcr0YcaX/2u QndntP8EnO0V7yZ4VXoDGGcajhm0T6tPzASe9cuV5kWtSLQaR6QNkuYGbBmTic4zfIDK s8hTsgFrJ1GyYNA7FjTXqUbbT0noXpd3OxEQnLODz+45+U0YLi2lmb3XdgkYW1dHBvjr r3PaxN88noNvtitDsllL99d7aLqEgB7eM1+ze8sdYgLPJ6hHM4TN+kN64CevW4C64Iw4 Tb6Q== X-Gm-Message-State: ALoCoQmMJ8H+JX3F7EQ1RetgJjv52shWQo0iFvh/lT7haacO7E0lrN18nBw1otGYslOjuO97KnWU X-Received: by 10.58.18.200 with SMTP id y8mr309843ved.20.1400031637632; Tue, 13 May 2014 18:40:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.233 with SMTP id l96ls2155000qgl.90.gmail; Tue, 13 May 2014 18:40:37 -0700 (PDT) X-Received: by 10.58.188.14 with SMTP id fw14mr380379vec.14.1400031637545; Tue, 13 May 2014 18:40:37 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id dx1si46937vcb.214.2014.05.13.18.40.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 18:40:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hu19so1561078vcb.34 for ; Tue, 13 May 2014 18:40:37 -0700 (PDT) X-Received: by 10.220.190.197 with SMTP id dj5mr315031vcb.19.1400031637470; Tue, 13 May 2014 18:40:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp194561vcb; Tue, 13 May 2014 18:40:36 -0700 (PDT) X-Received: by 10.69.25.69 with SMTP id io5mr726498pbd.22.1400031636504; Tue, 13 May 2014 18:40:36 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rx8si264044pab.186.2014.05.13.18.40.30; Tue, 13 May 2014 18:40:31 -0700 (PDT) Received-SPF: none (google.com: netdev-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752058AbaENBk2 (ORCPT + 3 others); Tue, 13 May 2014 21:40:28 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:45339 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751871AbaENBk1 (ORCPT ); Tue, 13 May 2014 21:40:27 -0400 Received: by mail-pa0-f50.google.com with SMTP id fb1so976089pad.37 for ; Tue, 13 May 2014 18:40:27 -0700 (PDT) X-Received: by 10.66.102.4 with SMTP id fk4mr559514pab.59.1400031627170; Tue, 13 May 2014 18:40:27 -0700 (PDT) Received: from localhost.localdomain ([60.166.209.254]) by mx.google.com with ESMTPSA id ox3sm356729pbb.88.2014.05.13.18.40.22 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 18:40:26 -0700 (PDT) From: Zhangfei Gao To: sebastian.hesselbarth@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, sergei.shtylyov@cogentembedded.com Cc: netdev@vger.kernel.org, Zhangfei Gao , Jiancheng Xue Subject: [PATCH v1] net: phy: resume phydev when going to RESUMING Date: Wed, 14 May 2014 09:40:16 +0800 Message-Id: <1400031616-19287-1-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1400031098-19072-1-git-send-email-zhangfei.gao@linaro.org> References: <1400031098-19072-1-git-send-email-zhangfei.gao@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhangfei.gao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , With commit be9dad1f9f26604fb ("net: phy: suspend phydev when going to HALTED"), an unused PHY device will be put in a low-power mode using BMCR_PDOWN. Some Ethernet drivers might be calling phy_start() and phy_stop() from ndo_open and ndo_close() respectively, while calling phy_connect() and phy_disconnect() from probe and remove. In such a case, the PHY will be powered down during the phy_stop() call, but will fail to be powered up in phy_start(). This patch fixes this scenario. Signed-off-by: Jiancheng Xue Signed-off-by: Zhangfei Gao --- drivers/net/phy/phy.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 1b6d09a..be5d52e 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -715,7 +715,7 @@ void phy_state_machine(struct work_struct *work) struct delayed_work *dwork = to_delayed_work(work); struct phy_device *phydev = container_of(dwork, struct phy_device, state_queue); - int needs_aneg = 0, do_suspend = 0; + int needs_aneg = 0, do_suspend = 0, do_resume = 0; int err = 0; mutex_lock(&phydev->lock); @@ -865,6 +865,8 @@ void phy_state_machine(struct work_struct *work) } phydev->adjust_link(phydev->attached_dev); } + + do_resume = 1; break; } @@ -876,6 +878,9 @@ void phy_state_machine(struct work_struct *work) if (do_suspend) phy_suspend(phydev); + if (do_resume) + phy_resume(phydev); + if (err < 0) phy_error(phydev);