From patchwork Wed Nov 10 04:10:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12611337 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27784C433EF for ; Wed, 10 Nov 2021 04:10:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1D2A6117A for ; Wed, 10 Nov 2021 04:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbhKJENB (ORCPT ); Tue, 9 Nov 2021 23:13:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:53550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbhKJENB (ORCPT ); Tue, 9 Nov 2021 23:13:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64AC261175; Wed, 10 Nov 2021 04:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636517414; bh=lGWXUPNYIop3Kr0Hyv5xk+Yma0Bq3F+ZWD02gZT6s9M=; h=From:To:Cc:Subject:Date:From; b=rXnxQpM08iAGGY5v4FYLJVA4YeRjagf9ceTaHWNZfbodJBu4Cr16hFoP9PlaQ7B+K jw5rlWr68kqB+IiSaLCAogTMWMSmjuJkyt5hNULUeCigHMqUeDl4+Le+sLZbSKtCBY 445iXeS0x3Iu+hslNNnbr4f+/3xAvfusfPXqlTWDA2OE8oPGPrsbdO/fDBwtBOu127 IrLYAj9sZuX8DP58exQsdrqT2TxU1o9+OTUgUKlQkmzmQtvcyefzd9RJ0s4iYr5lBQ KrRVQiYe7k74yjGVIB2XLaUTZMXYETfmmM1bAemdHKJdhix9eEcGiVrkOrR+Dpg/Cp xZlBcbpiO+qag== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org, Andrew Lunn Cc: Jakub Kicinski , David Miller , Russell King , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH net 1/3] net: dsa: mv88e6xxx: Fix forcing speed & duplex when changing to 2500base-x mode Date: Wed, 10 Nov 2021 05:10:08 +0100 Message-Id: <20211110041010.2402-1-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Commit 64d47d50be7a ("net: dsa: mv88e6xxx: configure interface settings in mac_config") removed forcing of speed and duplex from mv88e6xxx_mac_config(), where the link is forced down, and left it only in mv88e6xxx_mac_link_up(), by which time link is unforced. It seems that in 2500base-x (at least on 88E6190), if the link is not forced down, the forcing of new settings for speed and duplex doesn't take. Fix this by forcing link down. Fixes: 64d47d50be7a ("net: dsa: mv88e6xxx: configure interface settings in mac_config") Signed-off-by: Marek Behún --- drivers/net/dsa/mv88e6xxx/chip.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index f00cbf5753b9..ddb13cecb3ac 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -785,12 +785,17 @@ static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port, if ((!mv88e6xxx_phy_is_internal(ds, port) && !mv88e6xxx_port_ppu_updates(chip, port)) || mode == MLO_AN_FIXED) { - /* FIXME: for an automedia port, should we force the link - * down here - what if the link comes up due to "other" media - * while we're bringing the port up, how is the exclusivity - * handled in the Marvell hardware? E.g. port 2 on 88E6390 - * shared between internal PHY and Serdes. + /* FIXME: we need to force the link down here, otherwise the + * forcing of link speed and duplex by .port_set_speed_duplex() + * doesn't work for some modes. + * But what if the link comes up due to "other" media while + * we're bringing the port up, how is the exclusivity handled in + * the Marvell hardware? E.g. port 2 on 88E6390 shared between + * internal PHY and Serdes. */ + if (ops->port_sync_link) + err = ops->port_sync_link(chip, port, mode, false); + err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed, duplex); if (err) From patchwork Wed Nov 10 04:10:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12611339 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA4D0C433FE for ; Wed, 10 Nov 2021 04:10:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6355461186 for ; Wed, 10 Nov 2021 04:10:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbhKJENF (ORCPT ); Tue, 9 Nov 2021 23:13:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:53584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbhKJENC (ORCPT ); Tue, 9 Nov 2021 23:13:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EA2CA61184; Wed, 10 Nov 2021 04:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636517416; bh=G+6fVK7jAdXV3OQ+8vLKg8mn15HTfheweA4+GGlagMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjMaZsw+Q1ZkaLcoDz6CsorLkHSYpgJfJQvw7YpIt5+TpgvZuxkrX4ctXSG3YyuCO K45Flo34BNnM7fbt2kmwpi7fCvxuwWRPPUuCQVDg97vzRzXXTfMChjmbt8DzskTLCm hHktSvQFsQfYMo1W2mQ7GMl2hZHlG43tykIYG/+qXHP+lomoMs8aVfj3xLIgt/wQai Sso/dEKGUECE+T/SyhZSFy4npCOnrxQL/vDUVTMfU+k2zRi6WUsF/y1gcQbCn9swIx F0rdgiHx1i0vHbEy7e6jBPrWv71zAtMjISkasvaCaHECcLizFDv56sICrv2i+Yg22+ cFdA2BSYP42tA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org, Andrew Lunn Cc: Jakub Kicinski , David Miller , Russell King , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH net 2/3] net: dsa: mv88e6xxx: Fix reading sgmii link status register Date: Wed, 10 Nov 2021 05:10:09 +0100 Message-Id: <20211110041010.2402-2-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211110041010.2402-1-kabel@kernel.org> References: <20211110041010.2402-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The documentation says this about the SerDes PHY register 4.2001.2: This register bit indicates when link was lost since the last read. For the current link status, read this register back-to-back. Thus we need to read it twice to get the current value of the register. The wrong value is read when phylink requests change from sgmii to 2500base-x mode, and link won't come up. This fixes the bug. Fixes: a5a6858b793f ("net: dsa: mv88e6xxx: extend phylink to Serdes PHYs") Signed-off-by: Marek Behún --- drivers/net/dsa/mv88e6xxx/serdes.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c index 6ea003678798..bc198ef06745 100644 --- a/drivers/net/dsa/mv88e6xxx/serdes.c +++ b/drivers/net/dsa/mv88e6xxx/serdes.c @@ -1041,15 +1041,25 @@ static void mv88e6390_serdes_irq_link_sgmii(struct mv88e6xxx_chip *chip, u16 bmsr; int err; - /* If the link has dropped, we want to know about it. */ + /* If the link has dropped, we want to know about it. + * This register bit indicates when link was lost since the last read. + * We need to read it twice to get the current value. + */ err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS, MV88E6390_SGMII_BMSR, &bmsr); - if (err) { - dev_err(chip->dev, "can't read Serdes BMSR: %d\n", err); - return; - } + if (err) + goto err; + + err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS, + MV88E6390_SGMII_BMSR, &bmsr); + if (err) + goto err; dsa_port_phylink_mac_change(chip->ds, port, !!(bmsr & BMSR_LSTATUS)); + + return; +err: + dev_err(chip->dev, "can't read Serdes BMSR: %d\n", err); } static void mv88e6393x_serdes_irq_link_10g(struct mv88e6xxx_chip *chip, From patchwork Wed Nov 10 04:10:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12611341 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D825BC433F5 for ; Wed, 10 Nov 2021 04:10:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B93A9611F2 for ; Wed, 10 Nov 2021 04:10:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbhKJENF (ORCPT ); Tue, 9 Nov 2021 23:13:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:53604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230273AbhKJENE (ORCPT ); Tue, 9 Nov 2021 23:13:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A6DE61205; Wed, 10 Nov 2021 04:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636517417; bh=JbPK3ZzTwJbosw9+kprP7aEFh6+mLFQltJbH+Ts3Tm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lrHxYxvnP6rtr98EbJ7CoqO0AcpEPBDJsz5qdCSf2r+siI9anUaoCUMXXib1NvGtf 5UaQvPXeXBCryhJ1eKIDMMX9y/tZQ1M9QX8qGHpYoE+a2To2owCShZ0KwPvAdEMQ2Q d05UYske7Owy9dLXFIfCVn6YnreyWlY73CJEjpVfwLQQ2/l5XQ5yV/mP8i3ubKOTE7 FqXN5yTc7DAvLpE9N8O4bqGYtRJPL06tWfzbLAugYtDEyDj2KG6QAYIGzT3vswdLfd tc5cVQwfXCoKTVc8zVPwveADfIXnfqhNBgba3xHpGzDsM2L6Q3fUiXwO7642qGYwmK HrriNpxoESS8w== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org, Andrew Lunn Cc: Jakub Kicinski , David Miller , Russell King , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH net 3/3] net: dsa: mv88e6xxx: Link in pcs_get_state() even if LP has AN disabled Date: Wed, 10 Nov 2021 05:10:10 +0100 Message-Id: <20211110041010.2402-3-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211110041010.2402-1-kabel@kernel.org> References: <20211110041010.2402-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Function mv88e6xxx_serdes_pcs_get_state() currently does not report link up if AN is not complete. This is in contrast to for example the mvneta's mvneta_mac_pcs_get_state() implementation, where link is simply taken from link bit. For 1000base-x and 2500base-x modes, it is possible that the link partner has autonegotiation disabled. In this case we get zero in the SPD_DPL_VALID and we won't link, even if we can. An example of such link partner is Marvell 88X3310 PHY, when put into the mode where host interface changes between 10gbase-r, 5gbase-r, 2500base-x and sgmii according to copper speed. The 88X3310 does not enable AN in 2500base-x, and so SerDes on mv88e6xxx currently does not link with it. Fix this. Fixes: a5a6858b793f ("net: dsa: mv88e6xxx: extend phylink to Serdes PHYs") Signed-off-by: Marek Behún --- drivers/net/dsa/mv88e6xxx/serdes.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c index bc198ef06745..dd3fba7aab99 100644 --- a/drivers/net/dsa/mv88e6xxx/serdes.c +++ b/drivers/net/dsa/mv88e6xxx/serdes.c @@ -53,8 +53,11 @@ static int mv88e6xxx_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, u16 status, u16 lpa, struct phylink_link_state *state) { - if (status & MV88E6390_SGMII_PHY_STATUS_SPD_DPL_VALID) { - state->link = !!(status & MV88E6390_SGMII_PHY_STATUS_LINK); + state->link = !!(status & MV88E6390_SGMII_PHY_STATUS_LINK); + state->an_complete = !!(status & + MV88E6390_SGMII_PHY_STATUS_SPD_DPL_VALID); + + if (state->an_complete) { state->duplex = status & MV88E6390_SGMII_PHY_STATUS_DUPLEX_FULL ? DUPLEX_FULL : DUPLEX_HALF; @@ -81,8 +84,13 @@ static int mv88e6xxx_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, dev_err(chip->dev, "invalid PHY speed\n"); return -EINVAL; } - } else { - state->link = false; + } else if (state->link && + state->interface != PHY_INTERFACE_MODE_SGMII) { + state->duplex = DUPLEX_FULL; + if (state->interface == PHY_INTERFACE_MODE_2500BASEX) + state->speed = SPEED_2500; + else + state->speed = SPEED_1000; } if (state->interface == PHY_INTERFACE_MODE_2500BASEX)