From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754951AbdFXDl2 (ORCPT ); Fri, 23 Jun 2017 23:41:28 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:8788 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753313AbdFXDl0 (ORCPT ); Fri, 23 Jun 2017 23:41:26 -0400 Subject: Re: [PATCH NET v3 1/2] net: phy: Add phy loopback support in net phy framework To: Andrew Lunn CC: , , , , , , , , , , , , , References: <1498211042-240816-1-git-send-email-linyunsheng@huawei.com> <1498211042-240816-2-git-send-email-linyunsheng@huawei.com> <20170624031231.GG4875@lunn.ch> From: Yunsheng Lin Message-ID: <0fa5d2df-741e-06ba-96f3-567f47f82e3e@huawei.com> Date: Sat, 24 Jun 2017 11:40:52 +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: <20170624031231.GG4875@lunn.ch> 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.0A020205.594DDF52.007E,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: 728008ba16140aa6834b8789e822b6e1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Andrew On 2017/6/24 11:12, Andrew Lunn wrote: >> +int phy_loopback(struct phy_device *phydev, bool enable) >> +{ >> + struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); >> + int ret = 0; >> + >> + if (enable && phydev->loopback_enabled) >> + return -EBUSY; >> + >> + if (!enable && !phydev->loopback_enabled) >> + return -EINVAL; >> + >> + if (phydev->drv && phydrv->set_loopback) >> + ret = phydrv->set_loopback(phydev, enable); > > else > ret = -EOPNOTSUPP; > >> + >> + if (ret) >> + return ret; >> + >> + phydev->loopback_enabled = enable; >> + >> + return 0; >> +} >> +EXPORT_SYMBOL(phy_loopback); > > One of the comments we made of the PHY code in the hns driver is that > its locking is completely broken. You have made the same error > here. The core needs to hold the mutex while calling into the PHY > driver. Do you mean hns_nic_config_phy_loopback need to hold the mutex while calling phy_loopback? and other place that calling phy_* function? Best Regards Yunsheng Lin