Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1581303rdb; Sat, 2 Dec 2023 01:21:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzo6+pB44aI4GmjOc747hdN6S/hqwI19JsvdTBHH9ZxaGP/G+Z30+qkyDkfzWWIkUKIawE X-Received: by 2002:a6b:ec19:0:b0:7b0:ae77:36ec with SMTP id c25-20020a6bec19000000b007b0ae7736ecmr1097880ioh.9.1701508884938; Sat, 02 Dec 2023 01:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701508884; cv=none; d=google.com; s=arc-20160816; b=SlgFwEVMyNiygKKxa4D/hruXe83a3+95cJdzStAQTHWrPCg64M/tkYjgb3+/i+FLAT iHLKpjZlgMkYcktd8QoO9AR9mM4Lw83wHp6C4UINImTTQ3O7nPFcPRudAvUzXDNO74qw pEF/ShrgqlsoJDRGN6qJfXjN0baTCdQz/BnzUjd16pLwjXYp142402CTv3MZ510SiS+7 xR0vfXzhA1LFXClsnvuYWoWXiEgPyMpDaPlSBvPfaLLxmiJtQAIvPE1YVKWVFEHJljS4 1xCA8746TQ6eWGg/EWTZGwQcIq35Hj3cxei3+vmVihyY/OvhQmHuHxWqAaCly4BGxFPh Lm4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ljdt96q37XyVBUeAeout9zjcuiFhMzg+dq/n/3z9e7Y=; fh=2YntdpZEYJawT8Yq88zuELoI69uSIbF3d+O3p+oHGGc=; b=P2kWuiTO5LljNnhRKtOfUaBl0UDLypPec3ESVkNzMhff7eHVxdPTlezoktTb+jY+G/ YeR66Z7ZJIYXGnzWnRTar8OI0YKeaHlwjAymlZnjqry1nLgkW/VqslijFh8nSEsSXCts NOCkREIqaCK6YN1RaKUYZb0QMN5mRSLlV6Om3xJT/IqDnfqB4rIXx2yjthqROW1XbBJB f8NEOTBaHz4bE635iUYjtAV98aCRZzg2GMUMyxL4+c4KHJxJvXGeccaW8thNPhYhCM7h 8VoOwipcuuK0VdSg9oURI6W+9MOWEM0oGcAkp3GAcY9/GEHhmvEA8GfHWcdCapKRcoi5 bdpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=XTTKhK1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id kb8-20020a17090ae7c800b00280072b397csi7500437pjb.30.2023.12.02.01.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 01:21:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=XTTKhK1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B0E4280274B5; Sat, 2 Dec 2023 01:21:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230234AbjLBJSz (ORCPT + 99 others); Sat, 2 Dec 2023 04:18:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjLBJSz (ORCPT ); Sat, 2 Dec 2023 04:18:55 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A757D129; Sat, 2 Dec 2023 01:18:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ljdt96q37XyVBUeAeout9zjcuiFhMzg+dq/n/3z9e7Y=; b=XTTKhK1YAoO7AlNGjg5fgWTvo0 zMJxAcHQ2r4rsk13rXeKMGQxO7EWXFGh4eSt88bgBNTzrhfCO0A0hWMG2rlalewo3a8WQ4ZXvIhd7 lSNaWFOSEOT31hNRg9vZ1N4Ap+WOfkmlAObR2+Qcz8RyNtNohxpBYomByfs0J4TtrfenRinuhvzRT TlbDrFhebOynKq3mQnV4m8GFwJrU6kJ7IoA/KfkklQpTLfM9ANK7TnkTiLGhP67uXgG35Y2nKuXfP hMOs6EnGoNY2ZF/diOqnIYz/yjxrC/zPcjP5QitBv9FkabwllV5WjgGtxip8KaFe/HCnVfXTB1rIh BMM0JE7Q==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:33552) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r9M95-0003yM-0T; Sat, 02 Dec 2023 09:18:43 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r9M94-0006xE-Nf; Sat, 02 Dec 2023 09:18:42 +0000 Date: Sat, 2 Dec 2023 09:18:42 +0000 From: "Russell King (Oracle)" To: Daniel Golle Cc: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Marek =?iso-8859-1?Q?Beh=FAn?= , Pali =?iso-8859-1?Q?Roh=E1r?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Woudstra , John Crispin Subject: Re: [PATCH net] net: phylink: set phy_state interface when attaching SFP Message-ID: References: <8abed37d01d427bf9d27a157860c54375c994ea1.1700887953.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 02 Dec 2023 01:21:21 -0800 (PST) On Fri, Dec 01, 2023 at 06:19:20PM +0000, Daniel Golle wrote: > On Sat, Nov 25, 2023 at 08:28:20AM +0000, Russell King (Oracle) wrote: > > On Sat, Nov 25, 2023 at 04:56:20AM +0000, Daniel Golle wrote: > > > Assume 'usxgmii' being set as initial interface mode in DTS. Now plug > > > a 2.5GBase-T SFP module with exposed PHY. Currently this results in > > > a rather bizare situation: > > > > > > RTL8221B-VB-CG 2.5Gbps PHY (C45) i2c:sfp1-wan:11: rtl822x_c45_get_features: supported=00,00000000,00008000,000080ef > > > mtk_soc_eth 15100000.ethernet eth2: requesting link mode phy/2500base-x with support 00,00000000,00008000,0000e0ef > > > mtk_soc_eth 15100000.ethernet eth2: switched to phy/2500base-x link mode <<< !!!!!! > > > mtk_soc_eth 15100000.ethernet eth2: major config usxgmii <<< !!!!!! > > > mtk_soc_eth 15100000.ethernet eth2: phylink_mac_config: mode=phy/usxgmii/none adv=00,00000000,00000000,00000000 pause=00 > > > mtk_soc_eth 15100000.ethernet eth2: PHY [i2c:sfp1-wan:11] driver [RTL8221B-VB-CG 2.5Gbps PHY (C45)] (irq=POLL) > > > mtk_soc_eth 15100000.ethernet eth2: phy: 2500base-x setting supported 00,00000000,00008000,0000e0ef advertising 00,00000000,00008000,0000e0ef > > > > > > Then the link seemingly comes up (but is dead) because no subsequent > > > call to phylink_major_config actually configured MAC and PCS for > > > 2500base-x mode. > > > > > > This is because phylink_mac_initial_config() considers > > > pl->phy_state.interface if in MLO_AN_PHY mode while > > > phylink_sfp_set_config() only sets pl->link_config.interface. > > > > > > Also set pl->phy_state.interface in phylink_sfp_set_config(). > > > > Does it _actually_ matter? > > It does matter, I'm suggesting this change because the SFP module > won't work without it. > > > When the PHY's link comes up, doesn't it get sorted out for the real > > mode that will be used? > > That does happen once the interface mode *changes* to anything else, > than 2500M/Full and the PHY driver sets state->interface to SGMII. > However, initially it does *not* happen, probably because phylink > ends up believing MAC and PCS are already operating in 2500base-x > mode (but that's not the case). > > Previously (eg. with the BananaPi R3) this has not been a problem > because the default interface mode defined in device tree anyway has > also been 2500base-x. Now that I'm testing the same module with the > R4 which uses usxgmii by default the problem surfaced. Okay, I think what we have here is an ordering issue in phylink_sfp_connect_phy(). phylink_bringup_phy() will set phy_state.interface, but that happens after the major config has happened. With a built-in PHY, the sequence would be: - connect to PHY (which calls phylink_bringup_phy()) - phylink_start() (which calls phylink_major_config()) whereas in this case we have the reverse. That needs to be sorted. I can't do that over this weekend, but if you remind me I'll look at it next week. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!