Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2454808rdb; Fri, 8 Dec 2023 08:34:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwhcv7x8gisAv5nBHcSYKL7m2OOdLhFcmwMro/5+gicCmSBPdj2uFA4PG+Sz6ArZGJ0BFr X-Received: by 2002:a05:6e02:1445:b0:35d:59a2:332f with SMTP id p5-20020a056e02144500b0035d59a2332fmr496120ilo.51.1702053240869; Fri, 08 Dec 2023 08:34:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702053240; cv=none; d=google.com; s=arc-20160816; b=m87bo0Abx3TZ3cAs358xFh8AOHG0OZ2catq8gPQXxCaxgEBaxTCBCJMiA2iRuDvAz9 vMPK/P7s9Rmh6qp5srR3XmWFSseKnMPlCjtdjjDxusgXWZ3NBxQb1mPSUVd/A3dbAvzI pwHaFGyNH5NYghOkljjY4/LcDhHwT4NJRQM/MSjIjXW9fg2+5aFGWjzO83E9+CevrwCN vCZpVVOKDtttRtYQijr0fzPvyJmakBkqBvtRRuk1JHZdf6dvyMz2j2TiWjEFsegOnF0W TPH8kc8+XZeIe6kPdVCTB3YAO4Hwn9zWMFX57nwrKCAadh4d9GBN3t/yXqUhDawVFOol J5og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hXw0XZZEim7nEEhz34fa5B4jxIHSBv8a2Eg+0Dnfzpg=; fh=RtfNWxJERPTyR6mrqug+LxurdxtBm2PCAWSdZgWG5FY=; b=Mha/+WKIEjIyYP3TY54G66OV6Sl8xV1p0QLTYUFpzPL/irkYvWgEnq96ou0oqEwG3Y UbuONXi/SVF92t4+5HRpJ+asOEP5DKqQ+QQzaRgirTB9SqtSjEtwa+lk8pxmFj9/4Ris 2GDMyaH2J8eLZIkBrG9lyv8vAGfY4WxQ7C7nTFRbwSPRPZWfi5KYtnmo9EPrFfLgNdKh 5j+9zG14v9RQO2tRez9kfIlic1e0xoeHW/uUw8yVGgTkpzSKuaKITTM7ZHq6AxU6H1nW ip2NWzX+AHuny8CxBct1YAk+fmyL5Abang+EKsUphsr8sHsi8Ev8kl3NIgGQ25mk9fTQ Gm/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KyAoYNhX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id r3-20020a655083000000b005c689021580si1792088pgp.543.2023.12.08.08.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:34:00 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KyAoYNhX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0D9B881BFB95; Fri, 8 Dec 2023 08:33:58 -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 S1573921AbjLHQdo (ORCPT + 99 others); Fri, 8 Dec 2023 11:33:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573889AbjLHQdm (ORCPT ); Fri, 8 Dec 2023 11:33:42 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FE54199B for ; Fri, 8 Dec 2023 08:33:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702053226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hXw0XZZEim7nEEhz34fa5B4jxIHSBv8a2Eg+0Dnfzpg=; b=KyAoYNhXVJUv7MC4P6NNRagRGkmvQ7J4Jocst9wPoBkgjWO6NO6iIGb/iRGDG++m9UJ0xR QPUyU2AjkkxAxRdNlAFNw6gKH+rbgDFUropulT70wRpu4oAkrQbQ+lLRfGa6g81gQwCbWs s/fwfpvSNca/vzNs9bxd8ww3nKfIknQ= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-S33djehZO6ab79BmDdkZRA-1; Fri, 08 Dec 2023 11:33:44 -0500 X-MC-Unique: S33djehZO6ab79BmDdkZRA-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-4259aafd543so14193331cf.3 for ; Fri, 08 Dec 2023 08:33:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702053224; x=1702658024; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hXw0XZZEim7nEEhz34fa5B4jxIHSBv8a2Eg+0Dnfzpg=; b=FEwxRXVnxK1L90K6HCuWlEsFu6miU3EcG/L5l0yy632fAATpCtG/y0z0aoOXN50CKa oh9yZWo00+nuxDv421hDhF/9SqkAIE4Sr4EWikXREYNUnA1NWuZnXP4n8OMDseZGo9Nr YNkpsb6DZjg+k2A92wCMgzL5W2dM+m5dfauHy8yJIDp9TDxqxYUQ8WOP/j1Tyhebe9PC MCbbM27wlkQSoHY6uj4iDDF2DS3Gy8Nh0mKMfQ13+3BM/ogh50HMN9+2LUgsRNH4K3QA la9/qyuHl4KmmGV632EdIzEkowNq+1ikzg116cdGZJvILWy9rMyrU4Ggzzg6gOlH1jzQ ZZKg== X-Gm-Message-State: AOJu0Yzf/Aij9Gp+9UDR4loflB1SIvb9hZlvob69VA8aPuJ5zUW6d7/Y xSKSQ+89eosLS199bJacKrmLTvRSFwGb2p5qcDRNSckfPtOoJLYE3BRdlunb2R3UWgixclFkJNF c80pKNN3UgqnB3KfoDIXl2Nt7 X-Received: by 2002:ac8:5f8f:0:b0:423:b118:100a with SMTP id j15-20020ac85f8f000000b00423b118100amr397492qta.1.1702053224383; Fri, 08 Dec 2023 08:33:44 -0800 (PST) X-Received: by 2002:ac8:5f8f:0:b0:423:b118:100a with SMTP id j15-20020ac85f8f000000b00423b118100amr397476qta.1.1702053224087; Fri, 08 Dec 2023 08:33:44 -0800 (PST) Received: from fedora ([2600:1700:1ff0:d0e0::47]) by smtp.gmail.com with ESMTPSA id p20-20020ac87414000000b00423dfab8fc3sm929789qtq.32.2023.12.08.08.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:33:43 -0800 (PST) Date: Fri, 8 Dec 2023 10:33:41 -0600 From: Andrew Halaney To: Andrew Lunn Cc: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , Serge Semin Subject: Re: [PATCH net-next v2] net: stmmac: don't create a MDIO bus if unnecessary Message-ID: References: <20231206-stmmac-no-mdio-node-v2-1-333cae49b1ca@redhat.com> <9eddb32d-c798-4e1b-b0ea-c44d31cc29bf@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9eddb32d-c798-4e1b-b0ea-c44d31cc29bf@lunn.ch> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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]); Fri, 08 Dec 2023 08:33:58 -0800 (PST) On Fri, Dec 08, 2023 at 02:14:41PM +0100, Andrew Lunn wrote: > > I know you said the standard is to make the MDIO bus unconditionally, but > > to me that feels like a waste, and describing say an empty MDIO bus > > (which would set the phy_mask for us eventually and not scan a > > bunch of phys, untested but I think that would work) seems like a bad > > description in the devicetree (I could definitely see describing an > > empty MDIO bus getting NACKed, but that's a guess). > > DT describes the hardware. The MDIO bus master exists. So typically > the SoC .dtsi file would include it in the Ethernet node. At the SoC > level it is empty, unless there is an integrated PHY in the SoC. The > board .dts file then adds any PHYs to the node which the board > actually has. > > So i doubt adding an empty MDIO node to the SoC .dtsi file will get > NACKed, it correctly describes the hardware. Agreed, thanks for helping me consider all the cases. In my particular example it would make sense to have SoC dtsi describe the mdio bus, leave it disabled, and boards enable it and describe components as necessary. So you have let's say these 8 abbreviated cases: Case 1 (MDIO bus used with phy on bus connected to MAC): ethernet { status = "okay"; phy-handle = <&phy0>; phy-mode = "rgmii"; mdio { status = "okay"; phy0: phy@0 { }; }; }; Case 2 (MDIO bus used but MAC's connect fixed-link): ethernet { status = "okay"; phy-mode = "rgmii"; fixed-link { }; mdio { status = "okay"; switch/unrelated-phy { }; }; }; Case 3 (MDIO bus used but MAC's connected to another bus's phy): ethernet { status = "okay"; phy-handle = <&phy1>; phy-mode = "rgmii"; mdio { status = "okay"; switch/unrelated-phy { }; }; }; Case 4 (MDIO bus disabled/unused, connected fixed-link): ethernet { status = "okay"; phy-mode = "rgmii"; fixed-link { }; mdio { status = "disabled"; }; }; Case 5 (MDIO bus disabled/unused, connected to another bus's phy): ethernet { status = "okay"; phy-handle = <&phy1>; phy-mode = "rgmii"; mdio { status = "disabled"; }; }; Case 6 (MDIO bus not described, connected fixed-link): ethernet { status = "okay"; phy-mode = "rgmii"; fixed-link { }; }; Case 7 (MDIO bus not described, connected to a different bus's phy): ethernet { status = "okay"; phy-handle = <&phy1>; phy-mode = "rgmii"; }; Case 8 (MDIO bus not described, but phy on MDIO bus is connected to MAC, legacy description[2] in my commit message): ethernet { status = "okay"; }; If we look at the logic in stmmac today about how to handle the MDIO bus, you've got basically: if !fixed-link || mdio_node_present() of_mdiobus_register(np) Applying current stmmac logic to our cases... Case 1 (MDIO bus used with phy on bus connected to MAC): MDIO bus made, no unnecessary scanning Case 2 (MDIO bus used but MAC's fixed-link): MDIO bus made, no unnecessary scanning Case 3 (MDIO bus used but MAC's connected to another bus's phy): MDIO bus made, no unnecessary scanning Case 4 (MDIO bus disabled/unused, connected fixed-link): MDIO bus attempted to be made, fails -ENODEV due to disabled and stmmac returns -ENODEV from probe too Case 5 (MDIO bus disabled/unused, connected to another bus's phy): MDIO bus attempted to be made, fails -ENODEV due to disabled and stmmac returns -ENODEV from probe too Case 6 (MDIO bus not described, connected fixed-link): MDIO bus not created Case 7 (MDIO bus not described, connected to a different bus's phy): MDIO bus created, but the whole bus is scanned Case 8 (MDIO bus not described, but phy on MDIO bus is connected to MAC, legacy description[2] in my commit message): MDIO bus created, the whole bus is scanned and the undescribed but necessary phy is found The things I note of interest are cases 4, 5, 7, 8. Cases 4/5 are a bug in stmmac IMO, which breaks the devicetree description you mentioned as ideal in my case. Case 7 is the one I'm currently working with, and the devicetree can be updated to match case 5, but right now case 7 makes a bus and scans it needlessly which isn't great. It _sounds_ like to me Serge knows of stmmac variants that also *do not* have an MDIO controller, so they'd fall in this case too and really shouldn't create a bus. Case 8 is the legacy one that I wish didn't exist, but it does, and for that reason we should continue to make a bus and scan the whole thing if we can't figure out what the MAC's connected to. So in my opinion there's 3 changes I want to make based on all the use cases I could think of: 1. This patch, which improves the stmmac logic and stops making a bus for case 7 2. A new patch to gracefully handle cases 4/5, where currently if the MDIO bus is disabled in the devicetree, as it should be, stmmac handles -ENODEV from of_mdiobus_register() as a failure instead of gracefully continuing knowing this is fine and dandy. 3. Clean up the sa8775p dts to have the MDIO bus described in the SoC dtsi and left disabled instead of undescribed (a more accurate hardware description). Please let me know if you see any holes in my logic, hopefully the wall of text is useful in explaining how I got here. Thanks, Andrew