Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3533010pxb; Mon, 4 Apr 2022 20:12:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgZ0ve/4UgVUcEoyQJ+mAwlBodHT1pR3E5f1v8LaDn1PlpFCIWhATGoeL+JSSen4GWIxsO X-Received: by 2002:a63:8441:0:b0:398:5cf2:20c0 with SMTP id k62-20020a638441000000b003985cf220c0mr1045748pgd.591.1649128336933; Mon, 04 Apr 2022 20:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649128336; cv=none; d=google.com; s=arc-20160816; b=1KQmo2WJqe0rkRqFLYH7+2SAUOJdQf8+mOt/hB/yphIaccAJQ0dUQwQ8cKVXAKUKu/ TYW/pozYsMjz+xHzEeLxJgQKvsAqW10A+jVJ9eQ6y+IhhXBU1YEec9ErrwVuXRCRt1Pm ZsdQf8CcXpxTtta5a/sdXdalmz3TFCx6uIgMUxbjmwJjAxPpew4tWIJAwBven2VBjRxf 17DlVMzAU9oGq/WpOcp8sKu4RfDg+VYZeLLs68fe5V0vHO/+Q8Qi3L3WTR/wZuKdyxPe VAfMHvniCEIWQeHFmPc0cZTT3jDtV1KsJyBI2tZTUb2wJiKwDR3x4I/19u3eH+UMFBDi N63w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=al3GRS4W19TserlTBaR+TlbQYhZ4Wh6rw62nhoq598Q=; b=tyTosMbRIKkrNQGQlMVagW/Ckp7u3qLl8gRrcf4bNUtIyzleqQt6tm6DqbMArWCI2U KKKwPR4UwLAIUB2pTpt5c5XbfRVj41DzILTGuSedwt4gKHMU+GqfgZ2BiaQJi+2cQSKT pjPIs150BIbcZrIMAgjD6lGu2zfsTWdkFB0vj5aE5mR8qUojeqos5L/1yZjkAjm58sq/ IF2LbzsuyEk3Z/KtbMnOujWkLAv2FoujKPrarpITOWo9WrSk/VER7GEhxV7+N9AVukOv aSh/d5pgzF2J+4s18tzT5E8USLwqLNNzJGaXZBUeHhepIlduqHGL7IMJ3NY4AX18Deb9 Hk4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v17-20020a056a00149100b004fa6cbcbbf0si12362411pfu.235.2022.04.04.20.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AE4FC411EFD; Mon, 4 Apr 2022 18:12:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343516AbiDAGo5 (ORCPT + 99 others); Fri, 1 Apr 2022 02:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344052AbiDAGni (ORCPT ); Fri, 1 Apr 2022 02:43:38 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD12B264F49 for ; Thu, 31 Mar 2022 23:40:17 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1naAx7-0000ea-3L; Fri, 01 Apr 2022 08:40:09 +0200 Received: from ore by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1naAx4-0004ye-Vn; Fri, 01 Apr 2022 08:40:06 +0200 Date: Fri, 1 Apr 2022 08:40:06 +0200 From: Oleksij Rempel To: Andrew Lunn Cc: "huangguangbin (A)" , davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lipeng321@huawei.com, chenhao288@hisilicon.com Subject: Re: [PATCH] net: phy: genphy_loopback: fix loopback failed when speed is unknown Message-ID: <20220401064006.GB4449@pengutronix.de> References: <20220331114819.14929-1-huangguangbin2@huawei.com> <130bb780-0dc1-3819-8f6d-f2daf4d9ece9@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 08:36:47 up 1 day, 19:06, 41 users, load average: 0.05, 0.08, 0.07 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 31, 2022 at 04:26:47PM +0200, Andrew Lunn wrote: > > In this case, as speed and duplex both are unknown, ctl is just set to 0x4000. > > However, the follow code sets mask to ~0 for function phy_modify(): > > int genphy_loopback(struct phy_device *phydev, bool enable) > > { > > if (enable) { > > ... > > phy_modify(phydev, MII_BMCR, ~0, ctl); > > ... > > } > > so all other bits of BMCR will be cleared and just set bit 14, I use phy trace to > > prove that: > > > > $ cat /sys/kernel/debug/tracing/trace > > # tracer: nop > > # > > # entries-in-buffer/entries-written: 923/923 #P:128 > > # > > # _-----=> irqs-off/BH-disabled > > # / _----=> need-resched > > # | / _---=> hardirq/softirq > > # || / _--=> preempt-depth > > # ||| / _-=> migrate-disable > > # |||| / delay > > # TASK-PID CPU# ||||| TIMESTAMP FUNCTION > > # | | | ||||| | | > > kworker/u257:2-694 [015] ..... 209.263912: mdio_access: mii-0000:bd:00.1 read phy:0x03 reg:0x00 val:0x1040 > > kworker/u257:2-694 [015] ..... 209.263951: mdio_access: mii-0000:bd:00.1 read phy:0x03 reg:0x01 val:0x7989 > > kworker/u257:2-694 [015] ..... 209.263990: mdio_access: mii-0000:bd:00.1 read phy:0x03 reg:0x01 val:0x7989 > > kworker/u257:2-694 [015] ..... 209.264028: mdio_access: mii-0000:bd:00.1 read phy:0x03 reg:0x09 val:0x0200 > > kworker/u257:2-694 [015] ..... 209.264067: mdio_access: mii-0000:bd:00.1 read phy:0x03 reg:0x0a val:0x0000 > > ethtool-1148 [007] ..... 209.665693: mdio_access: mii-0000:bd:00.1 read phy:0x03 reg:0x00 val:0x1040 > > ethtool-1148 [007] ..... 209.665706: mdio_access: mii-0000:bd:00.1 write phy:0x03 reg:0x00 val:0x1840 > > ethtool-1148 [007] ..... 210.588139: mdio_access: mii-0000:bd:00.1 read phy:0x03 reg:0x00 val:0x1840 > > ethtool-1148 [007] ..... 210.588152: mdio_access: mii-0000:bd:00.1 write phy:0x03 reg:0x00 val:0x1040 > > ethtool-1148 [007] ..... 210.615900: mdio_access: mii-0000:bd:00.1 read phy:0x03 reg:0x00 val:0x1040 > > ethtool-1148 [007] ..... 210.615912: mdio_access: mii-0000:bd:00.1 write phy:0x03 reg:0x00 val:0x4000 //here just set bit 14 > > > > So phy speed will be set to 10M in this case, if previous speed of > > device before going down is 10M, loopback test is pass. Only > > previous speed is 100M or 1000M, loopback test is failed. > > O.K. So it should be set into 10M half duplex. But why does this cause > it not to loopback packets? Does the PHY you are using not actually > support 10 Half? Why does it need to be the same speed as when the > link was up? And why does it actually set LSTATUS indicating there is > link? > > Is this a generic problem, all PHYs are like this, or is this specific > to the PHY you are using? Maybe this PHY needs its own loopback > function because it does something odd? It looks for me like attempt to fix loopback test for setup without active link partner. Correct? Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |