From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751874AbdFTDGN (ORCPT ); Mon, 19 Jun 2017 23:06:13 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:7910 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750960AbdFTDGM (ORCPT ); Mon, 19 Jun 2017 23:06:12 -0400 Subject: Re: [PATCH NET] net/hns:bugfix of ethtool -t phy self_test To: Florian Fainelli , CC: , , , , , , , , , , , , , , Andrew Lunn References: <1497605091-94725-1-git-send-email-linyunsheng@huawei.com> <7500513f-e263-838c-12a1-4343f7281f1a@gmail.com> From: l00371289 Message-ID: <08ef77fc-29ab-8262-2126-c547960d5628@huawei.com> Date: Tue, 20 Jun 2017 11:05:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <7500513f-e263-838c-12a1-4343f7281f1a@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.74.190.125] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0208.5948911D.0030,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 79d1c646dd72e5c9909f6790615cfee2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi, Florian On 2017/6/20 5:00, Florian Fainelli wrote: > On 06/16/2017 02:24 AM, Lin Yun Sheng wrote: >> This patch fixes the phy loopback self_test failed issue. when >> Marvell Phy Module is loaded, it will powerdown fiber when doing >> phy loopback self test, which cause phy loopback self_test fail. >> >> Signed-off-by: Lin Yun Sheng >> --- >> drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 16 ++++++++++++++-- >> 1 file changed, 14 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c >> index b8fab14..e95795b 100644 >> --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c >> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c >> @@ -288,9 +288,15 @@ static int hns_nic_config_phy_loopback(struct phy_device *phy_dev, u8 en) > > The question really is, why is not this properly integrated into the PHY > driver and PHYLIB such that the only thing the Ethernet MAC driver has > to call is a function of the PHY driver putting it in self-test? Do you meaning calling phy_dev->drv->resume and phy_dev->drv->suspend function? I tried it, but it failed. if that is what you mean, I will look into it why it fail. Thanks for your reply. Best regards YunSheng Lin > >> >> /* Force 1000M Link, Default is 0x0200 */ >> phy_write(phy_dev, 7, 0x20C); >> - phy_write(phy_dev, HNS_PHY_PAGE_REG, 0); >> >> - /* Enable PHY loop-back */ >> + /* Powerup Fiber */ >> + phy_write(phy_dev, HNS_PHY_PAGE_REG, 1); >> + val = phy_read(phy_dev, COPPER_CONTROL_REG); >> + val &= ~PHY_POWER_DOWN; >> + phy_write(phy_dev, COPPER_CONTROL_REG, val); >> + >> + /* Enable Phy Loopback */ >> + phy_write(phy_dev, HNS_PHY_PAGE_REG, 0); >> val = phy_read(phy_dev, COPPER_CONTROL_REG); >> val |= PHY_LOOP_BACK; >> val &= ~PHY_POWER_DOWN; >> @@ -299,6 +305,12 @@ static int hns_nic_config_phy_loopback(struct phy_device *phy_dev, u8 en) >> phy_write(phy_dev, HNS_PHY_PAGE_REG, 0xFA); >> phy_write(phy_dev, 1, 0x400); >> phy_write(phy_dev, 7, 0x200); >> + >> + phy_write(phy_dev, HNS_PHY_PAGE_REG, 1); >> + val = phy_read(phy_dev, COPPER_CONTROL_REG); >> + val |= PHY_POWER_DOWN; >> + phy_write(phy_dev, COPPER_CONTROL_REG, val); >> + >> phy_write(phy_dev, HNS_PHY_PAGE_REG, 0); >> phy_write(phy_dev, 9, 0xF00); >> >> > >