Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3083391ybt; Mon, 29 Jun 2020 14:55:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmwi5oWp98brt99fhmGfB5ppfRFa+075nIPE2JZxUJ7eTV0KUjO8/K/w7UknOq3OPNvrd5 X-Received: by 2002:a05:6402:16db:: with SMTP id r27mr20239577edx.139.1593467738831; Mon, 29 Jun 2020 14:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593467738; cv=none; d=google.com; s=arc-20160816; b=HSschSvIJPnohFw2YbjcwB3jok80PKNCRAzDKZeOAFY1ycvItcIFjU9ANeXN550AE0 LbEj2NQgOwDyLdlnxvsz8KMGFmrgf2U/u5VvzwfY/Zr/UyZ2PnESmK6x7TKG4v3Y8tQD 6ztzMfyIwfL/+T/UqDJsYN5N/0PT0mSozB+iBTIKxjIB+OwJd8i3JcRoVv3sQMj6ovxr wEJOsVz1Mgzyx1k2iWbdoqzuZ2cML8uxUCSQQFn1Ccudbn0KumYm7ZGaoOWU8MORN5sF 0fzF4inMu0e63rrT8NLhVejX2E1+4XCAjoC/Ugb71D+2K1xCtghmAoGu1PmfxKfjH79+ KN6w== 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=mtlBFlh2o04RpD3X6q3z9q0AAcbcnFqENMpGMZDmz9I=; b=ebWwKI/qtm/pwSeaBzzogmPAn5WawN91d2+cK3QTs2P0aq8K5l9gZYnx1GycdlCxND QxDApNYY5ufJjFAnum2zjT7ni2TtDaHd/oZUNpeAZT1YfMioexK6WIe/AltLGaaPoY1H ZKSznDTPLNWQQD/waqmRtVcTvitzX5+pwuCuLMOphNKWGeS73iHvAdK+kydXUqefN5y0 j4Lt0BP/09jnWAs55sFOsGDXWxPwJQjTn5eW9nom48TQGBmh8V1dNm2wW+40BEDepL3u npKd+JefmwVV9cxdoQ037rzq/LxJ8/rgZF4WdyUY3z/ocyhe7MrlXN5x/o02c/2TfD4v y5Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yz63zDOC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y19si520215eje.56.2020.06.29.14.55.15; Mon, 29 Jun 2020 14:55:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yz63zDOC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1732822AbgF2Vxm (ORCPT + 99 others); Mon, 29 Jun 2020 17:53:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:56784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbgF2Sfe (ORCPT ); Mon, 29 Jun 2020 14:35:34 -0400 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 03FF92417E; Mon, 29 Jun 2020 15:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593443949; bh=sO2xBJT9t+KEVHko+8omTjreYu5x0FMEHORvarc5ou0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yz63zDOCutQh4/WGEzsPmK8qNDvLW9u8DZRifDflkHDD/bUMA/cmocsgdTalXfk5q QjkbGsPXZkHuDyg2exaCvHVIop2NbwGA+FU7rUNJTLUffzlGVu8RE1a2TEzfAa/ODl 8ACfG+8RMPdis6dzUfesaqsxCWpBL/2wowTC2lFQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dejin Zheng , Kevin Groeneveld , Andrew Lunn , "David S . Miller" , Greg Kroah-Hartman Subject: [PATCH 5.7 051/265] net: phy: smsc: fix printing too many logs Date: Mon, 29 Jun 2020 11:14:44 -0400 Message-Id: <20200629151818.2493727-52-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629151818.2493727-1-sashal@kernel.org> References: <20200629151818.2493727-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.7.7-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.7.7-rc1 X-KernelTest-Deadline: 2020-07-01T15:14+00:00 X-stable: review 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: Dejin Zheng [ Upstream commit 6d61f483f148b856d47a6c96d5d84054d5a9f849 ] Commit 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout() to simplify the code") will print a lot of logs as follows when Ethernet cable is not connected: [ 4.473105] SMSC LAN8710/LAN8720 2188000.ethernet-1:00: lan87xx_read_status failed: -110 When wait 640 ms for check ENERGYON bit, the timeout should not be regarded as an actual error and an error message also should not be printed. due to a hardware bug in LAN87XX device, it leads to unstable detection of plugging in Ethernet cable when LAN87xx is in Energy Detect Power-Down mode. the workaround for it involves, when the link is down, and at each read_status() call: - disable EDPD mode, forcing the PHY out of low-power mode - waiting 640ms to see if we have any energy detected from the media - re-enable entry to EDPD mode This is presumably enough to allow the PHY to notice that a cable is connected, and resume normal operations to negotiate with the partner. The problem is that when no media is detected, the 640ms wait times out and this commit was modified to prints an error message. it is an inappropriate conversion by used phy_read_poll_timeout() to introduce this bug. so fix this issue by use read_poll_timeout() to replace phy_read_poll_timeout(). Fixes: 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout() to simplify the code") Reported-by: Kevin Groeneveld Signed-off-by: Dejin Zheng Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/smsc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c index 93da7d3d0954c..74568ae161253 100644 --- a/drivers/net/phy/smsc.c +++ b/drivers/net/phy/smsc.c @@ -122,10 +122,13 @@ static int lan87xx_read_status(struct phy_device *phydev) if (rc < 0) return rc; - /* Wait max 640 ms to detect energy */ - phy_read_poll_timeout(phydev, MII_LAN83C185_CTRL_STATUS, rc, - rc & MII_LAN83C185_ENERGYON, 10000, - 640000, true); + /* Wait max 640 ms to detect energy and the timeout is not + * an actual error. + */ + read_poll_timeout(phy_read, rc, + rc & MII_LAN83C185_ENERGYON || rc < 0, + 10000, 640000, true, phydev, + MII_LAN83C185_CTRL_STATUS); if (rc < 0) return rc; -- 2.25.1