Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4662694rwb; Tue, 8 Aug 2023 11:42:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoABpvRUyxcUL1n+DAurKY96s+UVadckOeIAfUuxcJtJ9FP9Zu1vvbNHX6bne1iBLLBIM+ X-Received: by 2002:a17:907:78da:b0:965:fb87:4215 with SMTP id kv26-20020a17090778da00b00965fb874215mr391557ejc.15.1691520152228; Tue, 08 Aug 2023 11:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520152; cv=none; d=google.com; s=arc-20160816; b=gY9w56Owsa1in9njY6mn4smvKzKwfOIOwnKFR62p2S/ThZEmAqac+P+DxePX+wCGNV RnlHCn3tJIJH3PBEOYxRkMeaGbkGpEunY7VFBBS0bgsq+kSsuAKNeRkUi4J+KgkZ1Ra1 AfhzFlcZgVew4V7aptkKjvq/5lcdUJ/jo/0v2SHLQhAuBP0igXXkMjunuxpBeQynbMm8 bq6jm/aDiF51u4QAMyIfwt+WScagHM6Yn1qB4rix1TtzXqsjdHcf3f1zXQauOrtpZNid gZrp0LySySrDHPTAOS4Aym/AzVjNjFstE05/kHh28NbsY7xCb5c+gTAexd8h2lz7aoMb g5Vw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Lr8QH1hJKMAeMGOo0M5b1qGrUuXmYrB7fQhjBLGi+k0=; fh=B/7igMmPjJGb60crZxMEqqTCB150f9RrtMczA6fDqyY=; b=D09DdAy3jE7l/H2MCL/OwySSUxnnPfGevjN/lac+q4n8oN/0ldkfOD3pF4avS+T4So v9hYMbSjHT8b2wARRunrDqWpZ6Sf0/KEw0JdLYVuwuiFhrpUOda723FX5t9QH5HZRpKp U/HPGFz/guGuBREnwuS0ulmiLFZaGC6x04VZXA9tYltpTeYcIrg2w4V6uJDg3tRy+ihr G+YCfVyaIc1ZwjPHYI5LaLli9nxy69BYfJs9fvCULuCgFvAGdTS79EIDGHEjULsRFjOI XZ1N8wQwPjWBd/TdxoBjo+Wky1KZ1HQxdYh44QTaVmt6QIJut4buKuNV0nVUYyMnEXNg gigw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hS8SmJzW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jj27-20020a170907985b00b0099cd6660994si3559037ejc.116.2023.08.08.11.42.07; Tue, 08 Aug 2023 11:42:32 -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=@redhat.com header.s=mimecast20190719 header.b=hS8SmJzW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232030AbjHHQJ5 (ORCPT + 99 others); Tue, 8 Aug 2023 12:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbjHHQIW (ORCPT ); Tue, 8 Aug 2023 12:08:22 -0400 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 C8855769D for ; Tue, 8 Aug 2023 08:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691509542; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Lr8QH1hJKMAeMGOo0M5b1qGrUuXmYrB7fQhjBLGi+k0=; b=hS8SmJzWdL1TtS4tCBU18Fi8JOWmwixfEOoH8fBeuCastwR9RwVUzpweEJ4CBzm3TjjGpV JgVoR6cARaf4puEcMTwdcNeeAsq/OsbJx1WzfXWgxvcgi3eVxBmMXSS92ytQmNEWrYc8DJ XhYcCiccot6kDlNNrJ49sCvIfF5Nvug= 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-381-CxHyW0BJOBGYZvKLEVvoFQ-1; Tue, 08 Aug 2023 10:44:19 -0400 X-MC-Unique: CxHyW0BJOBGYZvKLEVvoFQ-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4100bd13cb7so19780961cf.1 for ; Tue, 08 Aug 2023 07:44:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691505859; x=1692110659; h=in-reply-to:content-transfer-encoding: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=Lr8QH1hJKMAeMGOo0M5b1qGrUuXmYrB7fQhjBLGi+k0=; b=CH0PrJTE5Gb4SbvITCMDwbC+6ANKKm8/0BdfAq1N+snTTdTL3u9ViQlZynhmuvdGxc 88zveJlR4TiyT3ZyCCBi/wCPRx1hyNytS8RLqWL1LvClfklqMW7HWB4Ve9gkjQ0Gq48F cpCg2IPbBbwhjM5e52Da42UCMdFXDobGaTxxMwBYrKUgf7pCZa/pCwE3bxmIrPZOWx4d Fe6fsl9/thsHMk2lhwf48+txi1dT3fCOjcJJQtF8p8k3DwFJ5g/4je1l5ZF/WcONQGMX D1lo12B5WlhkjM72yiLRozqyn+gNdY7KNzfgC5Mmz9xbn7p/CkvPKdJBrUv3o9yt+I7n sO8A== X-Gm-Message-State: AOJu0YyP9rMcm4OdHJnxpBlzgOXI2akSg86HgkxqG8G9HoKbXFiEJ0dW v/PIWNfifgToQTRGWZ8fxTF9IzhSiizt8yA+5IH7hs23gyYDfYMUBASzIebaKby4op45vdtgi2D 186yNPkSJem48YT+3AlTj2WN8 X-Received: by 2002:ac8:5902:0:b0:40f:f44f:7f79 with SMTP id 2-20020ac85902000000b0040ff44f7f79mr2455qty.16.1691505859185; Tue, 08 Aug 2023 07:44:19 -0700 (PDT) X-Received: by 2002:ac8:5902:0:b0:40f:f44f:7f79 with SMTP id 2-20020ac85902000000b0040ff44f7f79mr2428qty.16.1691505858889; Tue, 08 Aug 2023 07:44:18 -0700 (PDT) Received: from fedora ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id l5-20020ac84a85000000b0040fdf9a53e6sm3397095qtq.82.2023.08.08.07.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 07:44:18 -0700 (PDT) Date: Tue, 8 Aug 2023 09:44:16 -0500 From: Andrew Halaney To: Bartosz Golaszewski Cc: Andrew Lunn , "Russell King (Oracle)" , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Torgue , Jose Abreu , Maxime Coquelin , 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 Subject: Re: [PATCH 0/2] net: stmmac: allow sharing MDIO lines Message-ID: References: <20230807193102.6374-1-brgl@bgdev.pl> <54421791-75fa-4ed3-8432-e21184556cde@lunn.ch> <65b53003-23cf-40fa-b9d7-f0dbb45a4cb2@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, 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 08, 2023 at 04:30:05PM +0200, Bartosz Golaszewski wrote: > On Tue, Aug 8, 2023 at 4:25 PM Andrew Lunn 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 some 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. > > > > I hope not. That would be very broken. As Russell pointed out, MDIO is > > not multi-master. You need to check with the hardware designer if the > > schematics are not clear. > > Sorry, it was not very clear. It's the case that two MDIO masters > share the MDC and data lines. I'll make the water muddier (hopefully clearer?). I have access to the board schematic (not SIP/SOM stuff though), but that should help here. MAC0 owns its own MDIO bus (we'll call it MDIO0). It is pinmuxed to gpio8/gpio9 for mdc/mdio. MAC1 owns its own bus (MDIO1) which is pinmuxed to gpio21/22. On MDIO0 there are two SGMII ethernet phys. One is connected to MAC0, one is connected to MAC1. MDIO1 is not connected to anything on the board. So there is only one MDIO master, MAC0 on MDIO0, and it manages the ethernet phy for both MAC0/MAC1. Does that make sense? I don't think from a hardware design standpoint this is violating anything, it isn't a multimaster setup on MDIO. > > > > > > 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? > > > > unbinding is not a normal operation. So i would just live with it, and > > if root decides to shoot herself in the foot, that is her choice. > > > > I disagree. Unbinding is very much a normal operation. Less so for > platform devices but still, it is there for a reason and should be > expected to work correctly. Or at the very least not crash and burn > the system. > > On the other hand, I like your approach because I may get away without > having to fix it. But if I were to fix it - I would reference the MDIO > bus from the secondary mac by phandle and count its references before > dropping it. :) > > Bartosz >