Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4586337rwb; Tue, 8 Aug 2023 10:31:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMJHz35mQkALkBPrbWDHCkKaN+kXhjw91C7Ts3vqrCb7Bo9tkW8SzcRvuAYNVgnLQ5v5ov X-Received: by 2002:a2e:b0cd:0:b0:2b6:af60:6342 with SMTP id g13-20020a2eb0cd000000b002b6af606342mr139590ljl.40.1691515898589; Tue, 08 Aug 2023 10:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691515898; cv=none; d=google.com; s=arc-20160816; b=W4fjr6NUU08fRsZSxUrDkAI89cRCP8pCQ5xNDzn85aP0P/c4EwNljcW5MtbGOgsQHH k07pMrzEN64DHhYrsLfgj7iFzA79KGYaTtAAilqoac0xbaNkiHZvpmE6Vw5AtSlTm93J MK01K42yvVd+KIaltCN4oBIwc5e3Diyj0UkD55JLkdSaZoIuHdAowGx674liGjaBHP44 fh2JpS9cuTWj1eogjjfG5AESfc8tJzYOVbut1rmKUOna2VCNkGP99tjMHa3vufwL9Eh1 FUsAivjVlf5FNFzzTAHAW6hjCZ9trVzFWAlW76WQH3qcGnhb6qmtv2y09f/5Qtgrkfxp ga6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=vgs4Fm92pOwgiTtgi3t0TURwZ645hXw810Qm9YB3fW0=; fh=2h6Cp1xb4sbzQbZ8EwBeiCTD5A2NsDtnm/yOBxJFpwY=; b=oSwO9PUgHuv5DDaFbMr8l2U3oiIRD1EtiXzbVXLvKOwF/W3MmfJGkEDdUT7TetVvrX naiuu6N3WxuEv+wgIaQkYlcDxjLitcAYx7jM1FyZ0bQFeRSMcN03XJQzAr6vkU9FTlOC sViB/Rg4RWOcluZN8mSKS/HqtF9W2AuTKJgndrXyGtqxDsLPANiJl4y1ussh1uLInHRy O3frGDsFkYvyA/0185fXyESEXzcF24Bj5aGoLxPp0z04Jvt8TWXisoaSZlvEQsUQKjlz Dr2K2um2D+YC7hK/PeH5J3hZUUrVj3oMlzVY6WZG+5HUIZDE/JLtD2UCyU99kjnx/RwV 1kLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=1zWyWbnB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a1709065a9300b00987d66e6d26si7952801ejq.250.2023.08.08.10.31.14; Tue, 08 Aug 2023 10:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=1zWyWbnB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234446AbjHHRVJ (ORCPT + 99 others); Tue, 8 Aug 2023 13:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234228AbjHHRUs (ORCPT ); Tue, 8 Aug 2023 13:20:48 -0400 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB84783EA for ; Tue, 8 Aug 2023 09:08:28 -0700 (PDT) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-5861116fd74so56188017b3.0 for ; Tue, 08 Aug 2023 09:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1691510880; x=1692115680; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vgs4Fm92pOwgiTtgi3t0TURwZ645hXw810Qm9YB3fW0=; b=1zWyWbnBevP6AnHvWYDpz4fJJdYAMoauIzciKtQnY6PlehU2/ShRLFy26ni3eWxPJL Sz0gYFhnaOWI6iN93LDJbs5W5ROTqKNFy8SnJG3U3ByIgIC/iAYvobjthTq1mVbzkZn5 GWu79Tnot5+yMgONDB1oup8BhRJ2zsiqH4tw7AiAYJpUk+MZfO1X0GXF7CRMkKpw/GJh 4JzJRwnF/DiFMv1tkbu9WVXSI8AxU196bKO5T7zipAFfDFy7DMtFbXU0PWZoSqaYGz8o rCJpENlhq7XYfgBiGiF7Ss2oeFo0gy1XNlFt02JFyD1/tbES/U7CcsVn0I0NCJ8XKO4o UeBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691510880; x=1692115680; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vgs4Fm92pOwgiTtgi3t0TURwZ645hXw810Qm9YB3fW0=; b=PJqMCGPAFjiNwby6442y/d/AyP1cj6MxHL5Vlr02fSOmmczD/ZlkWTYCqaebmNpVB8 nIOcp6+ETSoj8p+orYjrXgO9gn4R+PQpc8TZH+dBJvkDAHGIbFxuRaLBSAsnIHbxYZY9 GEBSAe7zB9d4KAHwiVS7bBi8M77cPsQVmVL8r/saVnv/ohcBWx/eiprv0+wvc4uGm15D /DUMnnvYaPfY+WtjWGdPSvwgwdYW6AqXdNLTHPKOlMOU9VuEs0a3xfWgNkz8QfcXUWmB qJVlexN/fGFwbV+0eb8dThyaVLMdmrxQ9OpunAfZTMcqBttAYejGIQOcVByHHsDBJ0Ry MTBQ== X-Gm-Message-State: AOJu0YxDNw2+UxROQRQmZqRnYYhPniB7Cs8SXoNz+hnZ32jcbnMGNwYE IIMaQr9/a4H4jrRJ1t37FI0FrKxSpEei48bb+FoHDCcuYMPZ8OMiwPQ= X-Received: by 2002:a05:6358:c19:b0:139:e3a4:7095 with SMTP id f25-20020a0563580c1900b00139e3a47095mr14782675rwj.7.1691503762572; Tue, 08 Aug 2023 07:09:22 -0700 (PDT) MIME-Version: 1.0 References: <20230807193102.6374-1-brgl@bgdev.pl> <54421791-75fa-4ed3-8432-e21184556cde@lunn.ch> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 8 Aug 2023 16:09:11 +0200 Message-ID: Subject: Re: [PATCH 0/2] net: stmmac: allow sharing MDIO lines To: "Russell King (Oracle)" Cc: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Andrew Halaney , Alex Elder , Srini Kandagatla , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Tue, Aug 8, 2023 at 3:26=E2=80=AFPM Russell King (Oracle) wrote: > > On Tue, Aug 08, 2023 at 10:13:09AM +0200, Bartosz Golaszewski wrote: > > Ok so upon some further investigation, the actual culprit is in stmmac > > platform code - it always tries to register an MDIO bus - independent > > of whether there is an actual mdio child node - unless the MAC is > > marked explicitly as having a fixed-link. > > > > When I fixed that, MAC1's probe is correctly deferred until MAC0 has > > created the MDIO bus. > > > > Even so, isn't it useful to actually reference the shared MDIO bus in s= ome way? > > > > If the schematics look something like this: > > > > -------- ------- > > | MAC0 |--MDIO-----| PHY | > > -------- | | ------- > > | | > > -------- | | ------- > > | MAC1 |-- ----| PHY | > > -------- ------- > > > > Then it would make sense to model it on the device tree? > > So I think what you're saying is that MAC0 and MAC1's have MDIO bus > masters, and the hardware designer decided to tie both together to > a single set of clock and data lines, which then go to two PHYs. The schematics I have are not very clear on that, but now that you mention this, it's most likely the case. > > In that case, I would strongly advise only registering one MDIO bus, > and avoid registering the second one - thereby preventing any issues > caused by both MDIO bus masters trying to talk at the same time. > I sent a patch for that earlier today. > The PHYs should be populated in firmware on just one of the buses. > > You will also need to ensure that whatever registers the bus does > make sure that the clocks necessary for communicating on the bus > are under control of the MDIO bus code and not the ethernet MAC > code. We've run into problems in the past where this has not been > the case, and it means - taking your example above - that when MAC1 > wants to talk to its PHY, if MAC0 isn't alive it can't. Good point, but it's worse than that: when MAC0 is unbound, it will unregister the MDIO bus and destroy all PHY devices. These are not refcounted so they will literally go from under MAC1. Not sure how this can be dealt with? > > So just be aware of the clocking situation and make sure that your > MDIO bus code is managing the clocks necessary for the MDIO bus > master to work. Doesn't seem like stmmac is ready for it as it is now so this is going to be fun... Bartosz > > In regard to sharing of the MDIO bus signals between two bus > masters, I do not believe that is permissible - there's no > collision detection in hardware like there is on I=E6=B6=8E. So > having two MDIO bus masters talking at the same time would > end up corrupting the MDC (clock) and MDIO (data) signals if > both were active at the same time. >