Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1709570ybb; Sat, 11 Apr 2020 09:54:28 -0700 (PDT) X-Google-Smtp-Source: APiQypIR0uGrWLu31ox/S60PGiyQXARmxweWQ8L8N7upRLohXo2W5nJhqXURnHAmuAeE5D1PC73H X-Received: by 2002:a05:620a:10a8:: with SMTP id h8mr9414260qkk.215.1586624068268; Sat, 11 Apr 2020 09:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586624068; cv=none; d=google.com; s=arc-20160816; b=nvLNqAoHrFywTYm10Lmce8WB+3j8hdnCXX577FpoOWiM7BBptvGzQ+apywdn2yuQpy IRRMfMmruwzom9pmk5aRuZunjBzduJ7Lyhc3mbN2Jp1qrjX4dd/Dz2/T6KdoYSoq1IEI 46fEX0PQUwj9orOFU3eIfMgY1Rk7HEqMUbA/+qcsxw/ey+e3ayGpbv1R8wXdtvIYLh68 fSgxPxZs97cn13VMgkQC5GyUQA+7R7weDq0PpykJFb0NHox/wXUUXZbkSpIbhSrXKvTX z3u9I/YLtlDDpXh3W7xj/00hJ1gbRaQ6kNd7XT66VGJQsO6lDNQylY0v/4Z3LAdk0TcV yrfg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=jZBDMo4ZDtBc5dBRTHb4bv9HXY1GC/SNmnqUr4mAXIE=; b=UdkPFH/2qqfTPpg3j0JvkXEWAzRX20LauFfvucUWURqNq/TIxvJob7pVQ5rpZ6I78u WqWHfNw7eQs5PzKj7RzvQEhKCWP1UCCY8AjXQLS9GgrsRwvhgRfA3HA8Rsf7rsCHzfJ0 vHlIbxZ0N8H2WhC20pT/c7iO0KVWW7VFeQhb2DdJmaLZluiAuJ4YXZiGwhFwjNKKRbo4 YKuNbhYKhYQwHLu33WvXYlRgFbZkXRXvuxxUdm29PjxA/VK4WcxuJaIAcCVvbMTNR19Q X+aLIvuBUv4blhahsmyTxjc2TghAkPFED8Eu1Oa5Cxfup+6H2Out23IV1OB6W986Ppy5 8nVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqgruber.com header.s=mail header.b=v7Jv0UJV; 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=pqgruber.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si3310780qke.55.2020.04.11.09.54.13; Sat, 11 Apr 2020 09:54:28 -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; dkim=pass header.i=@pqgruber.com header.s=mail header.b=v7Jv0UJV; 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=pqgruber.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbgDKQxB (ORCPT + 99 others); Sat, 11 Apr 2020 12:53:01 -0400 Received: from mail.pqgruber.com ([52.59.78.55]:47606 "EHLO mail.pqgruber.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbgDKQxB (ORCPT ); Sat, 11 Apr 2020 12:53:01 -0400 Received: from workstation.tuxnet (213-47-165-233.cable.dynamic.surfer.at [213.47.165.233]) by mail.pqgruber.com (Postfix) with ESMTPSA id B8ADDC72B3E; Sat, 11 Apr 2020 18:52:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqgruber.com; s=mail; t=1586623980; bh=jZBDMo4ZDtBc5dBRTHb4bv9HXY1GC/SNmnqUr4mAXIE=; h=From:To:Cc:Subject:Date:From; b=v7Jv0UJVhAabBoB7iLeJ2ThRVyNePCE9Ob18zso+SaVFnpG+YoFBadPWnvK9fEIgN lCC6HBAyIuM7ufrkHdAr12bVwGupE/Cf6SmFzfysxcWe7Zb38qECd+e2O24oIRMmGS 79xT877W8bhlt5EUROM25AbxHjmNszb7YetBXcQQ= From: Clemens Gruber To: netdev@vger.kernel.org Cc: Russell King , Andrew Lunn , Florian Fainelli , Heiner Kallweit , "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org, Clemens Gruber Subject: [PATCH v2] net: phy: marvell: Fix pause frame negotiation Date: Sat, 11 Apr 2020 18:51:25 +0200 Message-Id: <20200411165125.1091-1-clemens.gruber@pqgruber.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The negotiation of flow control / pause frame modes was broken since commit fcf1f59afc67 ("net: phy: marvell: rearrange to use genphy_read_lpa()") moved the setting of phydev->duplex below the phy_resolve_aneg_pause call. Due to a check of DUPLEX_FULL in that function, phydev->pause was no longer set. Fix it by moving the parsing of the status variable before the blocks dealing with the pause frames. As the Marvell 88E1510 datasheet does not specify the timing between the link status and the "Speed and Duplex Resolved" bit, we have to force the link down as long as the resolved bit is not set, to avoid reporting link up before we even have valid Speed/Duplex. Tested with a Marvell 88E1510 (RGMII to Copper/1000Base-T) Fixes: fcf1f59afc67 ("net: phy: marvell: rearrange to use genphy_read_lpa()") Signed-off-by: Clemens Gruber --- Changes since v1: - Force link to 0 if resolved bit is not set as suggested by Russell King drivers/net/phy/marvell.c | 46 ++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 9a8badafea8a..561df5e33f65 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -1278,6 +1278,30 @@ static int marvell_read_status_page_an(struct phy_device *phydev, int lpa; int err; + if (!(status & MII_M1011_PHY_STATUS_RESOLVED)) { + phydev->link = 0; + return 0; + } + + if (status & MII_M1011_PHY_STATUS_FULLDUPLEX) + phydev->duplex = DUPLEX_FULL; + else + phydev->duplex = DUPLEX_HALF; + + switch (status & MII_M1011_PHY_STATUS_SPD_MASK) { + case MII_M1011_PHY_STATUS_1000: + phydev->speed = SPEED_1000; + break; + + case MII_M1011_PHY_STATUS_100: + phydev->speed = SPEED_100; + break; + + default: + phydev->speed = SPEED_10; + break; + } + if (!fiber) { err = genphy_read_lpa(phydev); if (err < 0) @@ -1306,28 +1330,6 @@ static int marvell_read_status_page_an(struct phy_device *phydev, } } - if (!(status & MII_M1011_PHY_STATUS_RESOLVED)) - return 0; - - if (status & MII_M1011_PHY_STATUS_FULLDUPLEX) - phydev->duplex = DUPLEX_FULL; - else - phydev->duplex = DUPLEX_HALF; - - switch (status & MII_M1011_PHY_STATUS_SPD_MASK) { - case MII_M1011_PHY_STATUS_1000: - phydev->speed = SPEED_1000; - break; - - case MII_M1011_PHY_STATUS_100: - phydev->speed = SPEED_100; - break; - - default: - phydev->speed = SPEED_10; - break; - } - return 0; } -- 2.26.0