Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp429808imu; Wed, 12 Dec 2018 20:40:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/VOh8xt1piMwSeuUBeWMdnif6qc+5WeA2rypoeJ8kKK6sgglloPwY6dWCzt5Z5xss/47gsM X-Received: by 2002:a62:cd44:: with SMTP id o65mr22624606pfg.222.1544676035252; Wed, 12 Dec 2018 20:40:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544676035; cv=none; d=google.com; s=arc-20160816; b=GYXlpmoUr2B0F3lxuzyBEjijDZBTWoSqfKWE4zPVxRwqTwnZGtFLP5Vmyq3OKn/NpK 5ANmNQ35S49XtWvqampLHyJg6++b0TqK2d4l5+RbQuTFqL3/zBFrUwVjwzoYm73y/DoG AdCXrPWdoJLW6XxW4hXpxvJydGG6NkVJu76yF5zbWX31VdO3RKYv0REhUmQ49fM0v42o bxu8nd13y9RTMWUkAck4Wc0Q49gJdN1UEimfNbzZ7wqVf2R9ycw9NFwhD4PQ2wAs9Lj5 MSENuY5dwz7DyZBEb+aplM8/NZhBdHU0bf1V0SaEjhp13RAGIAsFkTZpza1HO/8HaTd8 QC2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/Ji8mdlAyHQUniyld30wve5gjFhAO6KA5puU/zedEPY=; b=YKAMZ3ukn2KxF5PpvCYvZcq5NFqksPqRXVOaK9PAsks3ALW2T8/Ic7EzT3ILBCg0eC Fwzpaq86DC/UkBebPDpbmIFZj7LkI1HPGBGAvkQl1NQP6PLM3J+UIR5UEu9UZ2nVYqEW 9ILCJ5Sydk9UNidRH3Vj0pceLCqQvEwAyQVsoiwQIk9NjACFiue9Qy2ngfvc6d0yP30G A0QNKSX+b4KzmsnHnz8LP7LZFZj8aQnSDl5ucSAozUf321/yH/wl2EV7vRCf3tSLmlGR U6Z0wvz0GZ7TMZJdSp49/15mV1Ld3I+ImW+yz9x8vH6+4piHp71J1412YJ9vFpmlR2hE uvhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wg939yaV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d189si708652pfa.70.2018.12.12.20.40.20; Wed, 12 Dec 2018 20:40:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=wg939yaV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729142AbeLMEck (ORCPT + 99 others); Wed, 12 Dec 2018 23:32:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:45528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729124AbeLMEci (ORCPT ); Wed, 12 Dec 2018 23:32:38 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E00520672; Thu, 13 Dec 2018 04:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544675558; bh=Fbdm6Zplnk5m05qwSynJi1a8Kux/1urgBp/+uD0rqBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wg939yaVW+SMsOZ1IUtWFKJ6UsgUUV0trJJq8zuTu9KCHa9nkVCsAJKj/jwN3k4H2 5wBLWOsgLaSxKnC9L23Boz5QJfpQKkq9vcl8/1AxzsRKr5dm5IQlUmeUvhus2+8zs3 I77iJ4rwMrrdCh8YZEPcN7w3+f8konNEKafNnrMo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yoshihiro Shimoda , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 21/34] net: phy: Fix not to call phy_resume() if PHY is not attached Date: Wed, 12 Dec 2018 23:31:47 -0500 Message-Id: <20181213043200.76295-21-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181213043200.76295-1-sashal@kernel.org> References: <20181213043200.76295-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yoshihiro Shimoda [ Upstream commit ef1b5bf506b1f0ee3edc98533e1f3ecb105eb46a ] This patch fixes an issue that mdio_bus_phy_resume() doesn't call phy_resume() if the PHY is not attached. Fixes: 803dd9c77ac3 ("net: phy: avoid suspending twice a PHY") Signed-off-by: Yoshihiro Shimoda Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/phy_device.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f04be9e8980f..b518fa12fb98 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -80,7 +80,7 @@ static LIST_HEAD(phy_fixup_list); static DEFINE_MUTEX(phy_fixup_lock); #ifdef CONFIG_PM -static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) +static bool mdio_bus_phy_may_suspend(struct phy_device *phydev, bool suspend) { struct device_driver *drv = phydev->mdio.dev.driver; struct phy_driver *phydrv = to_phy_driver(drv); @@ -92,10 +92,11 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) /* PHY not attached? May suspend if the PHY has not already been * suspended as part of a prior call to phy_disconnect() -> * phy_detach() -> phy_suspend() because the parent netdev might be the - * MDIO bus driver and clock gated at this point. + * MDIO bus driver and clock gated at this point. Also may resume if + * PHY is not attached. */ if (!netdev) - return !phydev->suspended; + return suspend ? !phydev->suspended : phydev->suspended; /* Don't suspend PHY if the attached netdev parent may wakeup. * The parent may point to a PCI device, as in tg3 driver. @@ -125,7 +126,7 @@ static int mdio_bus_phy_suspend(struct device *dev) if (phydev->attached_dev && phydev->adjust_link) phy_stop_machine(phydev); - if (!mdio_bus_phy_may_suspend(phydev)) + if (!mdio_bus_phy_may_suspend(phydev, true)) return 0; return phy_suspend(phydev); @@ -136,7 +137,7 @@ static int mdio_bus_phy_resume(struct device *dev) struct phy_device *phydev = to_phy_device(dev); int ret; - if (!mdio_bus_phy_may_suspend(phydev)) + if (!mdio_bus_phy_may_suspend(phydev, false)) goto no_resume; ret = phy_resume(phydev); -- 2.19.1