Message ID | 20230425054429.3956535-2-s-vadapalli@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3192015vqo; Mon, 24 Apr 2023 22:50:58 -0700 (PDT) X-Google-Smtp-Source: AKy350buwqtln/j3TWvrtaXA8sI3U9rSs8ix2H8mNcCjgCOUR+8yuWarM+u2xRGBIoc9QAL/jDIz X-Received: by 2002:a05:6a00:21cf:b0:63a:65a9:10db with SMTP id t15-20020a056a0021cf00b0063a65a910dbmr22987747pfj.7.1682401858660; Mon, 24 Apr 2023 22:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682401858; cv=none; d=google.com; s=arc-20160816; b=A4O20XTVtzwUEu+eoNa/hZMVZAnyb8DdrR5chrikdQ3MtJp/tRlP+FJMqt1W3nScBT pj+d18la1QDcukeVNzU56i9gGqMp9fHBUn6eGSaaZsDarWjd70KvaWkO5a2TaMa8XnpU jddpVv/QABplF9r1bxkqbyT9hPx4JmltdCm5NRtsUtvriEPUpQFCdRYoEcAniN3RUVei orJ0kbvn4igjbaDFdUCYxqZN4gnO5b7hlwxbkQKjdgushIBnF9fo8Q6Qm7SxxWB086/s De+ofNGoyvDNMltkXEJQ60XQWWSaMi2M1vx3yGk9DCRwZsodfhCChMGdw5kP95u4+8T6 Hw9g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ubG6hdaNwuct5+wLN4lzFka6yc1X3H82cDBK9I9zdzE=; b=m7yLcueZsTS0BrEYCfSNTE1gvlDjDmw17T7O6SXpNGDQ+jVkEDY/W1mc/S3+ZoK50z rN1BpB1nBX6HTPNao6PxrLUPgpLxMEoiOODd72ZgtNkeysZF80Ci0FAqPYNWFO+JSVKF LGAdwWDZjzWqlUHvXaiAf1NYgmym2fkLuEdxLA3EoaYRYyC4cPQrzfLqp9wHAvJqhw9S gWcpC+/AnyHDOi/i1qyDCHMZ0zgMrk0AreP5CnAAG7CuejkEF1Idpt8SEIgt1YNoK2q0 NubWmHXRzjVxzxAU/zPzsH2xmgTnQkrv1lNV1b5AOyAOANCIEJQDESC/pyLo1yxx/kUW 0G3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MaruJQXh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c66-20020a621c45000000b0063b86d1e1dfsi12471875pfc.109.2023.04.24.22.50.45; Mon, 24 Apr 2023 22:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MaruJQXh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233167AbjDYFpN (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Tue, 25 Apr 2023 01:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233346AbjDYFpH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Apr 2023 01:45:07 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99AD8693; Mon, 24 Apr 2023 22:45:02 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33P5icUB070100; Tue, 25 Apr 2023 00:44:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1682401478; bh=ubG6hdaNwuct5+wLN4lzFka6yc1X3H82cDBK9I9zdzE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=MaruJQXhA2LQceHPz5ct3gypNn8jcswkA8KwlsRkOjRqaOE6FxWhK9dzzr8qOURcd LNQKPIRR5DAO0tWnrT4s+7zHLJuanoQRhlxBAuNLPnY8t6eR7BJDbbI36sFdQUw4Y1 +EYKw5asToDJsYOvJdXdNL8ztDowiPxd0xc1kNFM= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33P5icCE025786 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 25 Apr 2023 00:44:38 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 25 Apr 2023 00:44:37 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 25 Apr 2023 00:44:37 -0500 Received: from uda0492258.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33P5iURo124283; Tue, 25 Apr 2023 00:44:34 -0500 From: Siddharth Vadapalli <s-vadapalli@ti.com> To: <andrew@lunn.ch>, <hkallweit1@gmail.com>, <linux@armlinux.org.uk>, <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com> CC: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <srk@ti.com>, <s-vadapalli@ti.com> Subject: [RFC PATCH 1/2] net: phy: dp83867: add w/a for packet errors seen with short cables Date: Tue, 25 Apr 2023 11:14:28 +0530 Message-ID: <20230425054429.3956535-2-s-vadapalli@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230425054429.3956535-1-s-vadapalli@ti.com> References: <20230425054429.3956535-1-s-vadapalli@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764126211531922154?= X-GMAIL-MSGID: =?utf-8?q?1764126211531922154?= |
Series |
DP83867/DP83869 Ethernet PHY workaround/fix
|
|
Commit Message
Siddharth Vadapalli
April 25, 2023, 5:44 a.m. UTC
From: Grygorii Strashko <grygorii.strashko@ti.com> Introduce the W/A for packet errors seen with short cables (<1m) between two DP83867 PHYs. The W/A recommended by DM requires FFE Equalizer Configuration tuning by writing value 0x0E81 to DSP_FFE_CFG register (0x012C), surrounded by hard and soft resets as follows: write_reg(0x001F, 0x8000); //hard reset write_reg(DSP_FFE_CFG, 0x0E81); write_reg(0x001F, 0x4000); //soft reset Since DP83867 PHY DM says "Changing this register to 0x0E81, will not affect Long Cable performance.", enable the W/A by default. Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> --- drivers/net/phy/dp83867.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
Comments
On Tue, Apr 25, 2023 at 11:14:28AM +0530, Siddharth Vadapalli wrote: > From: Grygorii Strashko <grygorii.strashko@ti.com> > > Introduce the W/A for packet errors seen with short cables (<1m) between > two DP83867 PHYs. > > The W/A recommended by DM requires FFE Equalizer Configuration tuning by > writing value 0x0E81 to DSP_FFE_CFG register (0x012C), surrounded by hard > and soft resets as follows: > > write_reg(0x001F, 0x8000); //hard reset > write_reg(DSP_FFE_CFG, 0x0E81); > write_reg(0x001F, 0x4000); //soft reset > > Since DP83867 PHY DM says "Changing this register to 0x0E81, will not > affect Long Cable performance.", enable the W/A by default. > > Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> > Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html Please set the tree in the Subject line to be net. Please also add a Fixes: tag, probably for the patch which added this driver. > --- > drivers/net/phy/dp83867.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c > index 5821f04c69dc..ba60cf35872e 100644 > --- a/drivers/net/phy/dp83867.c > +++ b/drivers/net/phy/dp83867.c > @@ -42,6 +42,7 @@ > #define DP83867_STRAP_STS1 0x006E > #define DP83867_STRAP_STS2 0x006f > #define DP83867_RGMIIDCTL 0x0086 > +#define DP83867_DSP_FFE_CFG 0X012C > #define DP83867_RXFCFG 0x0134 > #define DP83867_RXFPMD1 0x0136 > #define DP83867_RXFPMD2 0x0137 > @@ -934,8 +935,20 @@ static int dp83867_phy_reset(struct phy_device *phydev) > > usleep_range(10, 20); > > - return phy_modify(phydev, MII_DP83867_PHYCTRL, > + err = phy_modify(phydev, MII_DP83867_PHYCTRL, > DP83867_PHYCR_FORCE_LINK_GOOD, 0); > + if (err < 0) > + return err; > + > + phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_DSP_FFE_CFG, 0X0E81); Maybe check the return code for errors? Andrew
On 25/04/23 17:35, Andrew Lunn wrote: > On Tue, Apr 25, 2023 at 11:14:28AM +0530, Siddharth Vadapalli wrote: >> From: Grygorii Strashko <grygorii.strashko@ti.com> >> >> Introduce the W/A for packet errors seen with short cables (<1m) between >> two DP83867 PHYs. >> >> The W/A recommended by DM requires FFE Equalizer Configuration tuning by >> writing value 0x0E81 to DSP_FFE_CFG register (0x012C), surrounded by hard >> and soft resets as follows: >> >> write_reg(0x001F, 0x8000); //hard reset >> write_reg(DSP_FFE_CFG, 0x0E81); >> write_reg(0x001F, 0x4000); //soft reset >> >> Since DP83867 PHY DM says "Changing this register to 0x0E81, will not >> affect Long Cable performance.", enable the W/A by default. >> >> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> >> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> > > https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html > > Please set the tree in the Subject line to be net. > Please also add a Fixes: tag, probably for the patch which added this driver. I will update the subject to "RFC PATCH net" and also add the "Fixes" tag in the v2 series. > > > > >> --- >> drivers/net/phy/dp83867.c | 15 ++++++++++++++- >> 1 file changed, 14 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c >> index 5821f04c69dc..ba60cf35872e 100644 >> --- a/drivers/net/phy/dp83867.c >> +++ b/drivers/net/phy/dp83867.c >> @@ -42,6 +42,7 @@ >> #define DP83867_STRAP_STS1 0x006E >> #define DP83867_STRAP_STS2 0x006f >> #define DP83867_RGMIIDCTL 0x0086 >> +#define DP83867_DSP_FFE_CFG 0X012C >> #define DP83867_RXFCFG 0x0134 >> #define DP83867_RXFPMD1 0x0136 >> #define DP83867_RXFPMD2 0x0137 >> @@ -934,8 +935,20 @@ static int dp83867_phy_reset(struct phy_device *phydev) >> >> usleep_range(10, 20); >> >> - return phy_modify(phydev, MII_DP83867_PHYCTRL, >> + err = phy_modify(phydev, MII_DP83867_PHYCTRL, >> DP83867_PHYCR_FORCE_LINK_GOOD, 0); >> + if (err < 0) >> + return err; >> + >> + phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_DSP_FFE_CFG, 0X0E81); > > Maybe check the return code for errors? The return value of phy_write_mmd() doesn't have to be checked since it will be zero for the following reasons: The dp83867 driver does not have a custom .write_mmd method. Also, the dp83867 phy does not support clause 45. Due to this, within __phy_write_mmd(), the ELSE statement will be executed, which results in the return value being zero. > > Andrew
> >> @@ -934,8 +935,20 @@ static int dp83867_phy_reset(struct phy_device *phydev) > >> > >> usleep_range(10, 20); > >> > >> - return phy_modify(phydev, MII_DP83867_PHYCTRL, > >> + err = phy_modify(phydev, MII_DP83867_PHYCTRL, > >> DP83867_PHYCR_FORCE_LINK_GOOD, 0); > >> + if (err < 0) > >> + return err; > >> + > >> + phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_DSP_FFE_CFG, 0X0E81); > > > > Maybe check the return code for errors? > > The return value of phy_write_mmd() doesn't have to be checked since it will be > zero for the following reasons: > The dp83867 driver does not have a custom .write_mmd method. Also, the dp83867 > phy does not support clause 45. Due to this, within __phy_write_mmd(), the ELSE > statement will be executed, which results in the return value being zero. Interesting. I would actually say __phy_write_mmd() is broken, and should be returning what __mdiobus_write() returns. You should assume it will get fixed, and check the return value. And it does no harm to check the return value. Andrew
On 26/04/23 18:06, Andrew Lunn wrote: >>>> @@ -934,8 +935,20 @@ static int dp83867_phy_reset(struct phy_device *phydev) >>>> >>>> usleep_range(10, 20); >>>> >>>> - return phy_modify(phydev, MII_DP83867_PHYCTRL, >>>> + err = phy_modify(phydev, MII_DP83867_PHYCTRL, >>>> DP83867_PHYCR_FORCE_LINK_GOOD, 0); >>>> + if (err < 0) >>>> + return err; >>>> + >>>> + phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_DSP_FFE_CFG, 0X0E81); >>> >>> Maybe check the return code for errors? >> >> The return value of phy_write_mmd() doesn't have to be checked since it will be >> zero for the following reasons: >> The dp83867 driver does not have a custom .write_mmd method. Also, the dp83867 >> phy does not support clause 45. Due to this, within __phy_write_mmd(), the ELSE >> statement will be executed, which results in the return value being zero. > > Interesting. > > I would actually say __phy_write_mmd() is broken, and should be > returning what __mdiobus_write() returns. > > You should assume it will get fixed, and check the return value. And > it does no harm to check the return value. Thank you for clarifying. The reasoning behind the initial patch not checking the return value was: At all invocations of phy_write_mmd() in the dp83867 driver, at no place is the return value checked, which led me to analyze why that was the case. I noticed that it was due to the return value being guaranteed to be zero for this particular driver. Since the existing __phy_write_mmd() implementation is broken as pointed out by you, I will update this patch to check the return value. Also, I will probably add a cleanup patch as well, to fix this at all other invocations of phy_write_mmd() in the driver.
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 5821f04c69dc..ba60cf35872e 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -42,6 +42,7 @@ #define DP83867_STRAP_STS1 0x006E #define DP83867_STRAP_STS2 0x006f #define DP83867_RGMIIDCTL 0x0086 +#define DP83867_DSP_FFE_CFG 0X012C #define DP83867_RXFCFG 0x0134 #define DP83867_RXFPMD1 0x0136 #define DP83867_RXFPMD2 0x0137 @@ -934,8 +935,20 @@ static int dp83867_phy_reset(struct phy_device *phydev) usleep_range(10, 20); - return phy_modify(phydev, MII_DP83867_PHYCTRL, + err = phy_modify(phydev, MII_DP83867_PHYCTRL, DP83867_PHYCR_FORCE_LINK_GOOD, 0); + if (err < 0) + return err; + + phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_DSP_FFE_CFG, 0X0E81); + + err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESTART); + if (err < 0) + return err; + + usleep_range(10, 20); + + return 0; } static void dp83867_link_change_notify(struct phy_device *phydev)