From patchwork Wed Nov 28 09:02:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 1004281 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=renesasgroup.onmicrosoft.com header.i=@renesasgroup.onmicrosoft.com header.b="PUKzGyVN"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 434ZRs5c9gz9s6w for ; Wed, 28 Nov 2018 20:02:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727881AbeK1UDk (ORCPT ); Wed, 28 Nov 2018 15:03:40 -0500 Received: from mail-eopbgr1400107.outbound.protection.outlook.com ([40.107.140.107]:25053 "EHLO JPN01-TY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727736AbeK1UDj (ORCPT ); Wed, 28 Nov 2018 15:03:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RZ37Vd7skwAt2pwXjTh+OMrTto9D9o24iDFIY6bxzlM=; b=PUKzGyVNlXUD5cy+sRBX5edHBqza/hk38IQB9foQ2u9Vx7layPyobLDSiSj8ABzG8GVLTIQOPky9IlyN3WxKQI0qRPIDy5eD83YJ6uWMUioTLKUy8lKqIOd3IIbRlmO50rDLZ3LrVLGz/g7IHc1k0QxEAH9gTkj0SAOPPPsYREU= Received: from OSBPR01MB2293.jpnprd01.prod.outlook.com (52.134.243.14) by OSBPR01MB3958.jpnprd01.prod.outlook.com (20.178.98.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Wed, 28 Nov 2018 09:02:42 +0000 Received: from OSBPR01MB2293.jpnprd01.prod.outlook.com ([fe80::c070:7362:375f:74c5]) by OSBPR01MB2293.jpnprd01.prod.outlook.com ([fe80::c070:7362:375f:74c5%4]) with mapi id 15.20.1339.032; Wed, 28 Nov 2018 09:02:42 +0000 From: Yoshihiro Shimoda To: "andrew@lunn.ch" , "f.fainelli@gmail.com" , "davem@davemloft.net" CC: "netdev@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , "devicetree@vger.kernel.org" , Yoshihiro Shimoda Subject: [PATCH v2 1/2] net: phy: Fix not to call phy_resume() if PHY is not attached Thread-Topic: [PATCH v2 1/2] net: phy: Fix not to call phy_resume() if PHY is not attached Thread-Index: AQHUhvkeGQMAOXHapEi1OtIbBuZcWA== Date: Wed, 28 Nov 2018 09:02:41 +0000 Message-ID: <1543395612-5430-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1543395612-5430-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> In-Reply-To: <1543395612-5430-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> Accept-Language: ja-JP, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.9.1 x-clientproxiedby: TYAPR01CA0041.jpnprd01.prod.outlook.com (2603:1096:404:28::29) To OSBPR01MB2293.jpnprd01.prod.outlook.com (2603:1096:603:26::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yoshihiro.shimoda.uh@renesas.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [211.11.155.144] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; OSBPR01MB3958; 20:EJIJc+sQuOWMB7YUFjOs9vsGlRjSmHHJ/RDSWZqr25DcvCvLJEED/o6WQ8qyI/L60LVmhZmkupcHgLJL9H/TBuFOmhU5m+pe4US0/zFQJHXEwkSRQpDsR1ijlJLgCgLMyGIkamO/mvOsTkqO0f3BM8/wsG4WERYQajCqyf7vJ5E= x-ms-office365-filtering-correlation-id: e6243687-0153-4331-8ab4-08d6551040e1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:OSBPR01MB3958; x-ms-traffictypediagnostic: OSBPR01MB3958: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231443)(999002)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:OSBPR01MB3958; BCL:0; PCL:0; RULEID:; SRVR:OSBPR01MB3958; x-forefront-prvs: 0870212862 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(346002)(39860400002)(376002)(136003)(396003)(199004)(189003)(6486002)(99286004)(110136005)(53936002)(2906002)(7736002)(305945005)(97736004)(316002)(66066001)(14454004)(54906003)(4326008)(3846002)(6116002)(107886003)(14444005)(6512007)(50226002)(105586002)(39060400002)(106356001)(76176011)(6436002)(68736007)(26005)(478600001)(2501003)(386003)(476003)(446003)(71190400001)(25786009)(86362001)(186003)(11346002)(2201001)(486006)(71200400001)(2616005)(102836004)(6506007)(5024004)(8676002)(81166006)(5660300001)(8936002)(52116002)(81156014)(256004)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:OSBPR01MB3958; H:OSBPR01MB2293.jpnprd01.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 8DW2uvMA2VZPi0pZ5Vob+MS8MAmlzJJ0cKpvtwL0pwsWm4B/Msm4NLfshERHsX7AHA0awz4UZY6MXFS6oajPVpVN7PW+hR6/3++rwsI6ys78xxYM9JGpiXWllcnTe7r1+o5WwJjkf6T/BUYhY8oASYjkdwOW4zFBMFJ1bbWVETbRgmUCxPsbhWI9jT4ypCkH2FCP70Zxm5+k0MLR0rI+rDLhJ1ZyTTaEHqVIuf3Bvn0csJv3HL1ILyr5oqp4F7b37TbbVR0FIxC5RN5qYUE6P1WTYI+Fq1MuQ9OJY4LCQ75iAofVvZkB7OHc2jdvG4r8pkHc9o4txg03oP0rnXRbVyK7veke0OuQK67C++CwvdA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6243687-0153-4331-8ab4-08d6551040e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2018 09:02:41.7739 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSBPR01MB3958 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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 e06613f..ecf5e3a9 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -227,7 +227,7 @@ static void phy_mdio_device_remove(struct mdio_device *mdiodev) 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); @@ -239,10 +239,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; if (netdev->wol_enabled) return false; @@ -277,7 +278,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); @@ -288,7 +289,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);