Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3514271pxf; Mon, 15 Mar 2021 11:13:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyctBA9kEaplaIS8JB81+orSbzD1cOBqIqi6Z5WuEch9SfW/23auE/QRC6jxQt/tNFTR7v4 X-Received: by 2002:a05:6402:304b:: with SMTP id bu11mr30450786edb.157.1615832025048; Mon, 15 Mar 2021 11:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832025; cv=none; d=google.com; s=arc-20160816; b=ZnEcSuCCKoVl268WWofUZst/5Z4pDqSQcWe/RrMjTE8IGT9cCJ8smT5Lj+cAzSZWjU PjA7WmIf1HvNTAHOVKLf0aFur4uxU9Naq9+SZAF7EpRbzsOV2Ip2KOvTnuaZkwtI5Tm7 vYXN46o8MT9I2xSVoPF4rRu4QDlIjfpomoRyx6yZRz5lvbjJaapTRaZwi1JgYNYu77fZ mQIt1Hd31eOGvIM3HkxEzMTVJaP0tGlhb8xm8rs9fVx/HhE0Z6E+RXoY8T9kcbF58aph sfwuFIwhTZtW/3awHGGeIHAWJKWys9qSBClfilXEnD6VzoPDXVLgM6bCr+MsoTzgq1yh /Oog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XvmPR0KTN8yhCO+I6rP1l3W7BZqkf+4yWF+U8E9T4sg=; b=KlfwFbyvfBym3l4bEruF9PR194nf4qc/k9qWQTMFjR4U3+w2LNhYoeUuRE03ztaAxd BVCB2RtYcerY4VvFRe4ksuw88bsWtA75B1bWwNXEMD36yO7gTuPUWFCzDTcsXWdn/M5X 6vqdTwcKnkmN4u1hYH1g79/WumQhIvPMzn/VFad4bZ6kTsKEvKTqwYugubltOOerWtq8 4CgN6fMewzDzFlxBJNtURLwpGy9FRI3RKEvcciPwomDDCQDLAJ2rBXEVWMvUSL+deMFK fcK8ogqOVtwECBHzr2a5HfVbBZBIu1XnvZpyui540R4Zg6gX3QO3OitlEOoqsXG/Uhr+ UGOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fObfanAk; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si12123823ejs.556.2021.03.15.11.13.23; Mon, 15 Mar 2021 11:13:45 -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=@linuxfoundation.org header.s=korg header.b=fObfanAk; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235924AbhCOOL5 (ORCPT + 99 others); Mon, 15 Mar 2021 10:11:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232078AbhCON5o (ORCPT ); Mon, 15 Mar 2021 09:57:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA61264F00; Mon, 15 Mar 2021 13:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816663; bh=4Nkiujrb4DTKuM4K+DB/6rrb2FhW7Y8VQGEnIoBHqy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fObfanAkLuYnsHrVRvfCAp2tVUcGqywl90MK5xPCu2X1JOqfQO/BJWEbdASK0tbEc //L99e+7sNj5L9vDdgdJ28DRn3hEn1lNfF7bqYL0BjodrOzKNHck48q5x5vQMnVzYi uAFcXDAv1ZjV5cCVdOLLBppik8xoT31km5TH9AqY= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Andrew Lunn , Russell King , Vladimir Oltean , "David S. Miller" Subject: [PATCH 5.10 041/290] net: enetc: force the RGMII speed and duplex instead of operating in inband mode Date: Mon, 15 Mar 2021 14:52:14 +0100 Message-Id: <20210315135543.317947345@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Vladimir Oltean commit c76a97218dcbb2cb7cec1404ace43ef96c87d874 upstream. The ENETC port 0 MAC supports in-band status signaling coming from a PHY when operating in RGMII mode, and this feature is enabled by default. It has been reported that RGMII is broken in fixed-link, and that is not surprising considering the fact that no PHY is attached to the MAC in that case, but a switch. This brings us to the topic of the patch: the enetc driver should have not enabled the optional in-band status signaling for RGMII unconditionally, but should have forced the speed and duplex to what was resolved by phylink. Note that phylink does not accept the RGMII modes as valid for in-band signaling, and these operate a bit differently than 1000base-x and SGMII (notably there is no clause 37 state machine so no ACK required from the MAC, instead the PHY sends extra code words on RXD[3:0] whenever it is not transmitting something else, so it should be safe to leave a PHY with this option unconditionally enabled even if we ignore it). The spec talks about this here: https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/138/RGMIIv1_5F00_3.pdf Fixes: 71b77a7a27a3 ("enetc: Migrate to PHYLINK and PCS_LYNX") Cc: Florian Fainelli Cc: Andrew Lunn Cc: Russell King Signed-off-by: Vladimir Oltean Acked-by: Russell King Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/freescale/enetc/enetc_hw.h | 13 ++++- drivers/net/ethernet/freescale/enetc/enetc_pf.c | 53 ++++++++++++++++++++---- 2 files changed, 56 insertions(+), 10 deletions(-) --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -238,10 +238,17 @@ enum enetc_bdr_type {TX, RX}; #define ENETC_PM_IMDIO_BASE 0x8030 #define ENETC_PM0_IF_MODE 0x8300 -#define ENETC_PMO_IFM_RG BIT(2) +#define ENETC_PM0_IFM_RG BIT(2) #define ENETC_PM0_IFM_RLP (BIT(5) | BIT(11)) -#define ENETC_PM0_IFM_RGAUTO (BIT(15) | ENETC_PMO_IFM_RG | BIT(1)) -#define ENETC_PM0_IFM_XGMII BIT(12) +#define ENETC_PM0_IFM_EN_AUTO BIT(15) +#define ENETC_PM0_IFM_SSP_MASK GENMASK(14, 13) +#define ENETC_PM0_IFM_SSP_1000 (2 << 13) +#define ENETC_PM0_IFM_SSP_100 (0 << 13) +#define ENETC_PM0_IFM_SSP_10 (1 << 13) +#define ENETC_PM0_IFM_FULL_DPX BIT(12) +#define ENETC_PM0_IFM_IFMODE_MASK GENMASK(1, 0) +#define ENETC_PM0_IFM_IFMODE_XGMII 0 +#define ENETC_PM0_IFM_IFMODE_GMII 2 #define ENETC_PSIDCAPR 0x1b08 #define ENETC_PSIDCAPR_MSK GENMASK(15, 0) #define ENETC_PSFCAPR 0x1b18 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -315,7 +315,7 @@ static void enetc_set_loopback(struct ne u32 reg; reg = enetc_port_rd(hw, ENETC_PM0_IF_MODE); - if (reg & ENETC_PMO_IFM_RG) { + if (reg & ENETC_PM0_IFM_RG) { /* RGMII mode */ reg = (reg & ~ENETC_PM0_IFM_RLP) | (en ? ENETC_PM0_IFM_RLP : 0); @@ -494,13 +494,20 @@ static void enetc_configure_port_mac(str static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode) { - /* set auto-speed for RGMII */ - if (enetc_port_rd(hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG || - phy_interface_mode_is_rgmii(phy_mode)) - enetc_port_wr(hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_RGAUTO); + u32 val; + + if (phy_interface_mode_is_rgmii(phy_mode)) { + val = enetc_port_rd(hw, ENETC_PM0_IF_MODE); + val &= ~ENETC_PM0_IFM_EN_AUTO; + val &= ENETC_PM0_IFM_IFMODE_MASK; + val |= ENETC_PM0_IFM_IFMODE_GMII | ENETC_PM0_IFM_RG; + enetc_port_wr(hw, ENETC_PM0_IF_MODE, val); + } - if (phy_mode == PHY_INTERFACE_MODE_USXGMII) - enetc_port_wr(hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII); + if (phy_mode == PHY_INTERFACE_MODE_USXGMII) { + val = ENETC_PM0_IFM_FULL_DPX | ENETC_PM0_IFM_IFMODE_XGMII; + enetc_port_wr(hw, ENETC_PM0_IF_MODE, val); + } } static void enetc_mac_enable(struct enetc_hw *hw, bool en) @@ -939,6 +946,34 @@ static void enetc_pl_mac_config(struct p phylink_set_pcs(priv->phylink, &pf->pcs->pcs); } +static void enetc_force_rgmii_mac(struct enetc_hw *hw, int speed, int duplex) +{ + u32 old_val, val; + + old_val = val = enetc_port_rd(hw, ENETC_PM0_IF_MODE); + + if (speed == SPEED_1000) { + val &= ~ENETC_PM0_IFM_SSP_MASK; + val |= ENETC_PM0_IFM_SSP_1000; + } else if (speed == SPEED_100) { + val &= ~ENETC_PM0_IFM_SSP_MASK; + val |= ENETC_PM0_IFM_SSP_100; + } else if (speed == SPEED_10) { + val &= ~ENETC_PM0_IFM_SSP_MASK; + val |= ENETC_PM0_IFM_SSP_10; + } + + if (duplex == DUPLEX_FULL) + val |= ENETC_PM0_IFM_FULL_DPX; + else + val &= ~ENETC_PM0_IFM_FULL_DPX; + + if (val == old_val) + return; + + enetc_port_wr(hw, ENETC_PM0_IF_MODE, val); +} + static void enetc_pl_mac_link_up(struct phylink_config *config, struct phy_device *phy, unsigned int mode, phy_interface_t interface, int speed, @@ -951,6 +986,10 @@ static void enetc_pl_mac_link_up(struct if (priv->active_offloads & ENETC_F_QBV) enetc_sched_speed_set(priv, speed); + if (!phylink_autoneg_inband(mode) && + phy_interface_mode_is_rgmii(interface)) + enetc_force_rgmii_mac(&pf->si->hw, speed, duplex); + enetc_mac_enable(&pf->si->hw, true); }