Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1993410rdb; Thu, 7 Dec 2023 15:07:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGd4ntraZV+iPUSHxUryQ0WfU7ldXGMceyEYrbq6CikS8i1idZ/xIN1fdyJeyADeiBupScF X-Received: by 2002:a05:6a00:1889:b0:6ce:725f:7d9d with SMTP id x9-20020a056a00188900b006ce725f7d9dmr3683429pfh.14.1701990470039; Thu, 07 Dec 2023 15:07:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701990470; cv=none; d=google.com; s=arc-20160816; b=EQ7uzA4nzypw/ra+PwK6qVCek6FGUspRx2fSQXoG1WFEiMmzzHDB1XtZQoOVyKyWuU 30y2Ymghch3mp3WEjje28M4zgau1ElIBZ8ltFea/MS8S+o5BnWnEKEdJE8vfIPxBe9mz rXIPfwCcWaSqFoCGx5Jkl2ocgnC71UqZTiqW7hWQJPcjtod8tBhtUXbNVgcxIOQrQUVX BTw0zgdJHj+iiLzMageUj7ORFwASbHahYUJoWfCtlSGXq9vCG31Q42znGIH0XL45gJ8z Pw9xwlUFsDxbJf7n7uaKAGbH0RG3XjDy5HhoJyEW9qsA4yJdMqKjFv+pAX8HWqW+SsTJ NyVw== 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=jVM1WmJwjQIszb+XLXzan7QiLivbxv0y5A1QhrsixGY=; fh=s9xxWyJgYnGtTDImjKNbcvkIu/702tunpmaRHpiIVaE=; b=tfzICvywDg5a8+ryolEtR8y4B+m/ToTrxcxaPHUfBGVLW5NBQW/u2WQnnIyrQdgE0Z aON4I5WR50klQhIcBauEY2STUppCKqMw33kj2v7jePLNyQblzkcayDiRTHlguU6raN6S 7AJic7PRTlx81LWWrqgDZe2TQjjxf/YXr7aKoyJ9/VfqnTe6DFUEqzb64U1P3v1ahnlJ 0/2orYLiWbVNKt+rxoeCZS2tpoHIu+54UbgbrloKaMQDOF4wUStirGjZZZyaQ5r5D3d0 p6EmZj0jCGql4JYPc2bMZSMhXpRBxStMw4551UtIE8V/Np/R2vVA9oRn/Vx7p4YkiVUJ VFfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CvyKPJcD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bq6-20020a056a02044600b005c660ba30afsi434939pgb.475.2023.12.07.15.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 15:07:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CvyKPJcD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 63F078149701; Thu, 7 Dec 2023 15:07:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444110AbjLGXHb (ORCPT + 99 others); Thu, 7 Dec 2023 18:07:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232476AbjLGXH0 (ORCPT ); Thu, 7 Dec 2023 18:07:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C951710 for ; Thu, 7 Dec 2023 15:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701990450; 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=jVM1WmJwjQIszb+XLXzan7QiLivbxv0y5A1QhrsixGY=; b=CvyKPJcD3GBjwcui2Ijk0kvJ2V+47M2DpYeBD5vZJnHiFQIWv64D4MA/QNhqY+eAZqZpX/ 0YRLQz7UHj1tUZT6GPh9z+vsDf3tJ3OXcWjpapbUMW/77riCrceJbOa+LEF6CT/e6Z6Mcy Z5+SfS4glykTGpxpcM94r40cD5c9p8Y= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-8kNBQv11PkiX0xbrHk0Euw-1; Thu, 07 Dec 2023 18:07:27 -0500 X-MC-Unique: 8kNBQv11PkiX0xbrHk0Euw-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4257b29b96aso17774731cf.3 for ; Thu, 07 Dec 2023 15:07:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701990447; x=1702595247; 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=jVM1WmJwjQIszb+XLXzan7QiLivbxv0y5A1QhrsixGY=; b=jkvv9Nq/f2BtbUTIrtI2TRJZIiU0IkoyUw7owuiITqHZ3Z9T4JJfhIUE9xUE6Qp0qA +5ySu9QXbefY+zuCqTkSHJ8ZXWKHcHo0DIVu4TfwTsL+Lh5FmsoElX4LvnW0NRJgZCJD CZwJkXJu7qCLdOtVXTviXBEfbAwQl1iUU6kUMnbH4B0o3PAYc+BUaGKGQscisAmzfNMS JtbJ1cuYtE5qNO9M1EKYbTxflO36mCe6BsR/CTulere774TZFqJ8OgW842ORh+O9h63J ZmYx7WnAco8qp9ZR1PgfD1S7KqpSIOvtXJGblwA7YSO6e1wFVNPs+0TFGwpv+13W0lZz B0ew== X-Gm-Message-State: AOJu0YzQt+VoY9wWgWQxWHunDygXw3t7Hxp85uL6f75J9CWWOdtSl6Sl sXTfIvC5tP5b1A6VGjxLsvRq2EBiniCpv8yxTS0mIiKMIX+lZHtLIbfd03+mR2wZvgjRlyWW7+a uxdNCVeEoPYeZcIiSBhywqV0d X-Received: by 2002:a05:622a:1a0c:b0:417:fd7e:2154 with SMTP id f12-20020a05622a1a0c00b00417fd7e2154mr4335058qtb.9.1701990447263; Thu, 07 Dec 2023 15:07:27 -0800 (PST) X-Received: by 2002:a05:622a:1a0c:b0:417:fd7e:2154 with SMTP id f12-20020a05622a1a0c00b00417fd7e2154mr4335040qtb.9.1701990447010; Thu, 07 Dec 2023 15:07:27 -0800 (PST) Received: from fedora ([2600:1700:1ff0:d0e0::47]) by smtp.gmail.com with ESMTPSA id t18-20020ac865d2000000b00423829b6d91sm294156qto.8.2023.12.07.15.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 15:07:26 -0800 (PST) Date: Thu, 7 Dec 2023 17:07:24 -0600 From: Andrew Halaney To: Serge Semin 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 Subject: Re: [PATCH net-next v3] net: stmmac: don't create a MDIO bus if unnecessary Message-ID: References: <20231207-stmmac-no-mdio-node-v3-1-34b870f2bafb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 15:07:47 -0800 (PST) On Fri, Dec 08, 2023 at 01:16:12AM +0300, Serge Semin wrote: > On Thu, Dec 07, 2023 at 03:12:40PM -0600, Andrew Halaney wrote: > > The stmmac_dt_phy() function, which parses the devicetree node of the > > MAC and ultimately causes MDIO bus allocation, misinterprets what > > fixed-link means in relation to the MAC's MDIO bus. This results in > > a MDIO bus being created in situations it need not be. > > > > Currently a MDIO bus is created if the description is either: > > > > 1. Not fixed-link > > 2. fixed-link but contains a MDIO bus as well > > > > The "1" case above isn't always accurate. If there's a phy-handle, > > it could be referencing a phy on another MDIO controller's bus[1]. In > > this case currently the MAC will make a MDIO bus and scan it all > > anyways unnecessarily. > > > > There's also a lot of upstream devicetrees[2] that expect a MDIO bus to > > be created and scanned for a phy. This case can also be inferred from > > the platform description by not having a phy-handle && not being > > fixed-link. This hits case "1" in the current driver's logic. > > > > Let's improve the logic to create a MDIO bus if either: > > > > > - Devicetree contains a MDIO bus > > - !fixed-link && !phy-handle (legacy handling) > > If what you suggest here is a free from regressions semantics change > (really hope it is) I will be with both my hands for it. This will > solve the problem we have with one of our device which doesn't have > SMA interface (hardware designers decided to save ~4K gates of the > chip area) but has a PHY externally attached to the DW XGMAC<->XPCS > interface. PHY is accessible via a GPIO-based MDIO bus. BTW having no > SMA interface available on a DW *MAC device but creating the MDIO-bus > on top of the non-existent SMA CSRs anyway causes having _32_ dummy > PHYs created with zero IDs. I hope it is regression free! I have tested both the [1] and [2] cases (I hacked up the devicetree for [1] to make it look like [2]) without any issue. Sorry, I don't have any docs for stmmac hardware so this might be answered in there (or just common net knowledge that I can't find online)... what's SMA stand for? I assume it's the MDIO interface. I agree though, if you have a phy-handle and no mdio node in your devicetree this patch series should bail out without registering a bus in stmmac_mdio_register(). > > > > > Below upstream devicetree snippets can be found that explain some of > > the cases above more concretely. > > - if (mdio) { > > - plat->mdio_bus_data = > > - devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data), > > - GFP_KERNEL); > > > + /* Legacy devicetrees allowed for no MDIO bus description and expect > > + * the bus to be scanned for devices. If there's no phy or fixed-link > > + * described assume this is the case since there must be something > > + * connected to the MAC. > > + */ > > + legacy_mdio = !of_phy_is_fixed_link(np) && !plat->phy_node; > > + if (legacy_mdio) > > + dev_info(dev, "Deprecated MDIO bus assumption used\n"); > > + > > + if (plat->mdio_node || legacy_mdio) { > > + plat->mdio_bus_data = devm_kzalloc(dev, > > Special thanks for adding the comment above this code. It will really > save time of figuring out why MDIO-bus needs to be created anyway. > > > + sizeof(struct stmmac_mdio_bus_data), > > Should v4 is required I would suggest to change this to > sizeof(*plat->mdio_bus_data). > > Anyway feel free to add: > Reviewed-by: Serge Semin > > -Serge(y) Sure I will spin v4 to pick that up, thanks for catching it. I'll also improve the motivation in the commit message a hair more per Andrew Lunn's request over here on v2 (and will hold off a little bit just to make sure reviews come in before a respin): https://lore.kernel.org/netdev/e64b14c3-4b80-4120-8cc4-9baa40cdcb75@lunn.ch/ Thanks, Andrew