Received: by 10.213.65.68 with SMTP id h4csp509507imn; Fri, 16 Mar 2018 09:56:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELuozPQKXHJZbN615mM8wHEMmfyBRTFDTz3RZXsAXugfAOzl/+dBS42mtTxh0tWtiiw9jRsS X-Received: by 10.99.183.15 with SMTP id t15mr2029823pgf.416.1521219373741; Fri, 16 Mar 2018 09:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521219373; cv=none; d=google.com; s=arc-20160816; b=LoIW+oJLRBxtzaDAA1z5Tz4LRR4Xe/yjH7R8r71Zqzn73OKkmr86uTklF5T8hNZWIH AEorqO5kzfvA2nsgNCA8W5NzRfLTrgaD7dhfAYYUd+7V20U0/D5m4EO/4r8PUvmZGZ/i IJoHJfRvKK4sjzhwMFJUiRS+LSTYZr5NIho4zWxcuJZdKBLLQBlF6mN5pNoFuAWr4jDF +TAzAjPZ8B38OEpnA1qfHsQAq8HGVbg1ZKm2HeNrgYUUrtqr6xbyxQ5Ku9BBOhzS3/1u z6XA+C2SG+jNSOF1rfDSc9zYOwy1fYAsehJLE8qjOx8fBQaY1hhmu02gUqHI0uZJH56z zY6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=j+72SpJmeOv8iKnqp+/QlzEImMJDREbTKJudetPyQx4=; b=n83vxtiwK1MnGbhG7tsPEzX9fUUUs63cbD7xMkWHaShzrpi2aeDDTqDwI9tBTGjDNE 2Ux6IZhJS8xkaz5ovH/QfV8eBhOpNSiASdujImMOqcTJUi+PHT5Afx+5xNAY9AmVhSdj Yu3EqJogJqxetV34hckhNOT8nkQnJvmVY/pGH+hlyTvBd0JskXwjRB5233p5742tJG/a BLlEA6h+Sxs7Kni8j9B3pqzq2llmfswy2rWAHcTtojwHV8eicOtVg02rTk3jlRZhQSSL ka4Z46P4gA0XI9Gn3L42fwYNLw4rVYaRjE9cetiAiE7chuCvHx4agno/7Z+dCqPNgQ63 G9Ew== 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 q87si5713456pfa.385.2018.03.16.09.55.59; Fri, 16 Mar 2018 09:56:13 -0700 (PDT) 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 S933889AbeCPPeI (ORCPT + 99 others); Fri, 16 Mar 2018 11:34:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39264 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933878AbeCPPeD (ORCPT ); Fri, 16 Mar 2018 11:34:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 59C39DB8; Fri, 16 Mar 2018 15:34:02 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Russell King , Andrew Lunn , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 001/109] [PATCH] net: phy: fix resume handling Date: Fri, 16 Mar 2018 16:22:30 +0100 Message-Id: <20180316152329.909955433@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Russell King [ Upstream commit f5e64032a799d4f54decc7eb6aafcdffb67f9ad9 ] When a PHY has the BMCR_PDOWN bit set, it may decide to ignore writes to other registers, or reset the registers to power-on defaults. Micrel PHYs do this for their interrupt registers. The current structure of phylib tries to enable interrupts before resuming (and releasing) the BMCR_PDOWN bit. This fails, causing Micrel PHYs to stop working after a suspend/resume sequence if they are using interrupts. Fix this by ensuring that the PHY driver resume methods do not take the phydev->lock mutex themselves, but the callers of phy_resume() take that lock. This then allows us to move the call to phy_resume() before we enable interrupts in phy_start(). Signed-off-by: Russell King Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/at803x.c | 4 ---- drivers/net/phy/phy.c | 9 +++------ drivers/net/phy/phy_device.c | 10 ++++++---- 3 files changed, 9 insertions(+), 14 deletions(-) --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -239,14 +239,10 @@ static int at803x_resume(struct phy_devi { int value; - mutex_lock(&phydev->lock); - value = phy_read(phydev, MII_BMCR); value &= ~(BMCR_PDOWN | BMCR_ISOLATE); phy_write(phydev, MII_BMCR, value); - mutex_unlock(&phydev->lock); - return 0; } --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -828,7 +828,6 @@ EXPORT_SYMBOL(phy_stop); */ void phy_start(struct phy_device *phydev) { - bool do_resume = false; int err = 0; mutex_lock(&phydev->lock); @@ -841,6 +840,9 @@ void phy_start(struct phy_device *phydev phydev->state = PHY_UP; break; case PHY_HALTED: + /* if phy was suspended, bring the physical link up again */ + phy_resume(phydev); + /* make sure interrupts are re-enabled for the PHY */ if (phy_interrupt_is_valid(phydev)) { err = phy_enable_interrupts(phydev); @@ -849,17 +851,12 @@ void phy_start(struct phy_device *phydev } phydev->state = PHY_RESUMING; - do_resume = true; break; default: break; } mutex_unlock(&phydev->lock); - /* if phy was suspended, bring the physical link up again */ - if (do_resume) - phy_resume(phydev); - phy_trigger_machine(phydev, true); } EXPORT_SYMBOL(phy_start); --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -135,7 +135,9 @@ static int mdio_bus_phy_resume(struct de if (!mdio_bus_phy_may_suspend(phydev)) goto no_resume; + mutex_lock(&phydev->lock); ret = phy_resume(phydev); + mutex_unlock(&phydev->lock); if (ret < 0) return ret; @@ -1026,7 +1028,9 @@ int phy_attach_direct(struct net_device if (err) goto error; + mutex_lock(&phydev->lock); phy_resume(phydev); + mutex_unlock(&phydev->lock); phy_led_triggers_register(phydev); return err; @@ -1157,6 +1161,8 @@ int phy_resume(struct phy_device *phydev struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); int ret = 0; + WARN_ON(!mutex_is_locked(&phydev->lock)); + if (phydev->drv && phydrv->resume) ret = phydrv->resume(phydev); @@ -1639,13 +1645,9 @@ int genphy_resume(struct phy_device *phy { int value; - mutex_lock(&phydev->lock); - value = phy_read(phydev, MII_BMCR); phy_write(phydev, MII_BMCR, value & ~BMCR_PDOWN); - mutex_unlock(&phydev->lock); - return 0; } EXPORT_SYMBOL(genphy_resume);