Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3941965pxb; Tue, 2 Mar 2021 02:31:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxykisi4qkP0245aL6kceFXjSwEm+C+PoOfvDKZz9Rrazkhv/CpIlm5pFjroUMyf90HTGm6 X-Received: by 2002:a17:906:b6cc:: with SMTP id ec12mr20079893ejb.520.1614681106515; Tue, 02 Mar 2021 02:31:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614681106; cv=none; d=google.com; s=arc-20160816; b=lfNi2VUulaCvsk6RPkT8iE12Hjshne7dhiIF0ZAKDGm4hliZEG3jxTC3l9sqCDqbNG UudYj7hst/06r+vr2Y92Ob4u+kzjcHEtNm4i91vXxUL/OEuCUpm1RyE8KGPoQx7kCZyy Ug2ImuIxfB0icW4I1OMMuYkTiOKjvbV6IzuVdlOQ3KE0xfRD24fZ48NWlANaKIHkEcNb vdyLbyms0G1YZdSm/rrsPnKETVSBvtmVLM26iIDd6knRMtuT68gKyhMEZQD3HqVzYDBn 6CDt9JLc5MRY8J6IQZ2JJyPpTw2DKwZIXZzrqxMv1wdwpnTLa91MuD+BvmclfoTLFmmb VKtw== 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=fHTN/jGyaBHc5GPpAQNX3yCPRSvC/6ZJNs7f4DCXhio=; b=u5/JpJ2sqNdQhiDm+DyN35UYNgLQq1d71GbzEIgR1DMbESY9g7kx4qv0ONBt56AxVF a/OQU5HvV2yPm8fC7UPAxHHipM27q4L8F1c4mK9PyqKh65Tdt/JxBU6nx9MMxrWfTQYM Lb3Bkj31BzllUaFf0GhUOmRuhJQ4nSyM/7C+YFfXApz1w/+8NJZpA6ZEmJ92xsZmTKKp wSsf1ssspSXeVYw94CQpZeoiIHJJDwCLLhv550aGA+p9KuYHhZtM+OUuuGanmFdh1C7x De5QpPeAVRdsR7YUt3bZCiAcTjxtcRWv5suwam46etTYZBvT7LSAJI3YqxHJ1Hq2apfe LTPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2kuYialB; 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 d17si12385575edv.53.2021.03.02.02.31.23; Tue, 02 Mar 2021 02:31:46 -0800 (PST) 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=2kuYialB; 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 S240571AbhCBBos (ORCPT + 99 others); Mon, 1 Mar 2021 20:44:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:45284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237977AbhCATVq (ORCPT ); Mon, 1 Mar 2021 14:21:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6A50E64E89; Mon, 1 Mar 2021 16:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616707; bh=98jUuO5EMRRRwpjDpF/0kba61Dl4ZHvka5ovo3+mnbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2kuYialBkPeqeYVZuTQs7d1jXp9x038L2raWxvJbmN56kMbuoQiBiEoZlke6ocqGn /giJoq539A89ycuBOlDFMOcC1FrSn+aDucNk3n8FaelgYHdWgdoPld06Qn5pCBS7Jw TzRmAdYQk/k0xl5uxei7SB7RrrPZj3INCVl7SmwE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sudheesh Mavila , Shyam Sundar S K , Tom Lendacky , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 068/247] net: amd-xgbe: Reset the PHY rx data path when mailbox command timeout Date: Mon, 1 Mar 2021 17:11:28 +0100 Message-Id: <20210301161035.008512545@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@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: Shyam Sundar S K [ Upstream commit 30b7edc82ec82578f4f5e6706766f0a9535617d3 ] Sometimes mailbox commands timeout when the RX data path becomes unresponsive. This prevents the submission of new mailbox commands to DXIO. This patch identifies the timeout and resets the RX data path so that the next message can be submitted properly. Fixes: 549b32af9f7c ("amd-xgbe: Simplify mailbox interface rate change code") Co-developed-by: Sudheesh Mavila Signed-off-by: Sudheesh Mavila Signed-off-by: Shyam Sundar S K Acked-by: Tom Lendacky Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/amd/xgbe/xgbe-common.h | 14 +++++++++++ drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 28 ++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h index b40d4377cc71d..b2cd3bdba9f89 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h +++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h @@ -1279,10 +1279,18 @@ #define MDIO_PMA_10GBR_FECCTRL 0x00ab #endif +#ifndef MDIO_PMA_RX_CTRL1 +#define MDIO_PMA_RX_CTRL1 0x8051 +#endif + #ifndef MDIO_PCS_DIG_CTRL #define MDIO_PCS_DIG_CTRL 0x8000 #endif +#ifndef MDIO_PCS_DIGITAL_STAT +#define MDIO_PCS_DIGITAL_STAT 0x8010 +#endif + #ifndef MDIO_AN_XNP #define MDIO_AN_XNP 0x0016 #endif @@ -1358,6 +1366,8 @@ #define XGBE_KR_TRAINING_ENABLE BIT(1) #define XGBE_PCS_CL37_BP BIT(12) +#define XGBE_PCS_PSEQ_STATE_MASK 0x1c +#define XGBE_PCS_PSEQ_STATE_POWER_GOOD 0x10 #define XGBE_AN_CL37_INT_CMPLT BIT(0) #define XGBE_AN_CL37_INT_MASK 0x01 @@ -1375,6 +1385,10 @@ #define XGBE_PMA_CDR_TRACK_EN_OFF 0x00 #define XGBE_PMA_CDR_TRACK_EN_ON 0x01 +#define XGBE_PMA_RX_RST_0_MASK BIT(4) +#define XGBE_PMA_RX_RST_0_RESET_ON 0x10 +#define XGBE_PMA_RX_RST_0_RESET_OFF 0x00 + /* Bit setting and getting macros * The get macro will extract the current bit field value from within * the variable diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c index 3ceb4f95ca7ca..828d12bf523fe 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c @@ -1942,6 +1942,27 @@ static void xgbe_phy_set_redrv_mode(struct xgbe_prv_data *pdata) xgbe_phy_put_comm_ownership(pdata); } +static void xgbe_phy_rx_reset(struct xgbe_prv_data *pdata) +{ + int reg; + + reg = XMDIO_READ_BITS(pdata, MDIO_MMD_PCS, MDIO_PCS_DIGITAL_STAT, + XGBE_PCS_PSEQ_STATE_MASK); + if (reg == XGBE_PCS_PSEQ_STATE_POWER_GOOD) { + /* Mailbox command timed out, reset of RX block is required. + * This can be done by asseting the reset bit and wait for + * its compeletion. + */ + XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, + XGBE_PMA_RX_RST_0_MASK, XGBE_PMA_RX_RST_0_RESET_ON); + ndelay(20); + XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, + XGBE_PMA_RX_RST_0_MASK, XGBE_PMA_RX_RST_0_RESET_OFF); + usleep_range(40, 50); + netif_err(pdata, link, pdata->netdev, "firmware mailbox reset performed\n"); + } +} + static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, unsigned int cmd, unsigned int sub_cmd) { @@ -1949,9 +1970,11 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, unsigned int wait; /* Log if a previous command did not complete */ - if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) + if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) { netif_dbg(pdata, link, pdata->netdev, "firmware mailbox not ready for command\n"); + xgbe_phy_rx_reset(pdata); + } /* Construct the command */ XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, cmd); @@ -1973,6 +1996,9 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, netif_dbg(pdata, link, pdata->netdev, "firmware mailbox command did not complete\n"); + + /* Reset on error */ + xgbe_phy_rx_reset(pdata); } static void xgbe_phy_rrc(struct xgbe_prv_data *pdata) -- 2.27.0