Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2890176rdb; Mon, 12 Feb 2024 23:29:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXdpJOHRDbQZLEqU7AvY7k0fvBBGAPg6BrwHcPTIVU0KqE1o3S1JBgZMiet0d0S9BeVZ7PM0WeoWaGkSfynccg1LzNObSpJTYy/ZSmGhQ== X-Google-Smtp-Source: AGHT+IHYpeoY39y2DCAqCIACUvAQracNv5nUNCLj6EbmBjVBivJk+ma4Hx6O9XeUE1utfO7pPvcw X-Received: by 2002:a05:6a21:169b:b0:19e:b6e9:883d with SMTP id np27-20020a056a21169b00b0019eb6e9883dmr2103917pzb.18.1707809376134; Mon, 12 Feb 2024 23:29:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707809376; cv=pass; d=google.com; s=arc-20160816; b=y/RqlB4OuDUGP4u/QFtbgpE2OarN7UtltQMVeY5sVGWGAk3TDt4jgQbo/2DaKBqKvd EIgi9c1RWhA8iZW2auGuhssIdjjbXwlILK3iNPxY41f2oZepbqrF2zg/xA/uAi0Eseji Uu1915oCT8PveDdApF4sf1NDfEp8rtJIacU/Sr+W2+oy0QQRiR7eKw2X5wgo1snaaHve cJ/qqRNBna+WSIN4nFV5aiuOp+AigkX5YxG6ESkeCMrTYnWmpgDovIbLihgDuMGM2Bkc HNM00wRdThnLiI9wpKzGh08q86pblufJN5reWC2QDCUaKJVESsxwwx0Ids+ALjGuzX5J FWLQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=13vZ8AhN0QU7mFg8b4TXvQpvgbf8ygWnhtYqMDG7ADY=; fh=jOXLIPGXOL20FgDRlemvBL7lv94bn4hlUsmCHqtZELk=; b=pNXUpfqQosacj/OOkI/qWpSYLBZ9EsSKxjQv8TQXveN95WOqq/qaHegNh4F+I2blwk GvdKBq+0ZacT2tGB+0o5321S18PQtibWo+26RXdA1Tpm4iDfdYW/BGDtYHtQr6LXfcZI EgRKsVglg/sF6NRDnFaic3/3d6PpGb6ssciCvUalx5VXv5pLITZSJCokBeUJO/2Mva3k euMIzL+z+OOfYNEZgi3bgNN/kQEuQRTQf99yfQnwM+4UqM+egFJox+RXEhhG2UH8iz0Z bKBUr6o7Gbf598hn85hOWuImvPCfrXFBnPscTw+U+HicJ7lh7JfyUQ5P80xSbLyh5yMj B4Lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=od4RxfPD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63045-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXk+Oaw03jVgiIndLs/tzndeo3oCwbwCspR9HX8qiYA7M8bgRA/zICN5CZUinJlDBt5Qmatwbd054VmqvVutqdKBMAeerJJMZeGU21SUg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q24-20020a638c58000000b005dc1b5b386asi1629216pgn.339.2024.02.12.23.29.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 23:29:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63045-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=od4RxfPD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63045-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4EABD282E79 for ; Tue, 13 Feb 2024 07:29:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94610175AB; Tue, 13 Feb 2024 07:29:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="od4RxfPD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97DE617566; Tue, 13 Feb 2024 07:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707809359; cv=none; b=ZU1vKPPhi3emw4iG1C1/eSNM6f0RVZP7wOZuoStvFG2hyJrX42rmsoh2zkX7vinwzBqZfHLY+QtSYseXPof9rP3R7/WJgs5GcmKuGGT6vb6qD5w2jltfBLo5DVXvq1mZWhitL5zJjrLq5FjiwvsjJzaJ5npXCoN+xPUDm6jyTu4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707809359; c=relaxed/simple; bh=JDucEHydWXrSLUzuo2FD0MxyrhZzIoiGXp3GsPpCJRs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=NoWQROs3yc/qISf0NDLyNT2RHQZHU2H2lIBctl7cCKuKSG2sfzGQu2sHjfIRwc8NyJqSiTIvjXS/3VsklliO/9Nx0iFCHJk9+ndlZMgfTH/MPneDKrrx+0cFCOwIFgR3qrqSLJ6QEVq8Bg65AEymVAIQIGqSDwMpNTDrK0PXu60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=od4RxfPD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 1AE27C433F1; Tue, 13 Feb 2024 07:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707809359; bh=JDucEHydWXrSLUzuo2FD0MxyrhZzIoiGXp3GsPpCJRs=; h=From:Date:Subject:To:Cc:Reply-To:From; b=od4RxfPD9pFzMJie+sZrC/bwzACrs3e3hhPbZm2omcg6x0GgKb1hBxR5YHj9RbtbC y8ObjrPHUQum4uFG5AXC4S/4u9OuSIXemHjUu2KClHWBbGHUKRZ3euzOzQXCtIJ484 jInraV0nel15LFgiTg57Zzw07JEfoG8BZF8gdjium6n33o0DFO8E+wDA46lKzexeDv n1GPXw0CcYJ+aINpgrFfshU88F56jGCUIOfFfgaRIxnE2JuXuX61y0kFTObMXcpBGw wuQlLlLmZUntIwD9M0Hg68yuBe9oCZZsLbSY1EJ3xv8oMxpX1jr7t6aKnJmpGu/Ekt 4XMK0Yvg++d4Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0853AC48260; Tue, 13 Feb 2024 07:29:19 +0000 (UTC) From: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= via B4 Relay Date: Tue, 13 Feb 2024 10:29:05 +0300 Subject: [PATCH net-next v2] net: dsa: remove OF-based MDIO bus registration from DSA core Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240213-for-netnext-dsa-mdio-bus-v2-1-0ff6f4823a9e@arinc9.com> X-B4-Tracking: v=1; b=H4sIAEAay2UC/yWNzQ6CMBCEX4Xs2SWl5ad48j0MhwqLbCKtaYFgC O9urbf5MvlmDgjkmQJcswM8bRzY2QjykkE/Gfsk5CEySCFLUSiBo/NoabG0LzgEg/PADh9rwFo 2vSgbQVoriPrb08h7mr5DNPCnQBebicPi/Cd9bkXq//NSikqpUud1pVss0Hi2fb5a87ql2Oa9m 6E7z/ML1dL4grgAAAA= To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: mithat.guner@xeront.com, erkin.bozoglu@xeront.com, Luiz Angelo Daros de Luca , =?utf-8?q?Alvin_=C5=A0ipraga?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Ar=C4=B1n=C3=A7_=C3=9CNAL?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1707809354; l=4698; i=arinc.unal@arinc9.com; s=arinc9-patatt; h=from:subject:message-id; bh=FQVu4SdlGCbVhlJyCOryP4ivDPy0SI6ZNNcbaFbu7M0=; b=FBdXqqaV0vEKXzhXwwhzwHIG9P6X2VZ1lJ3hEQcD0rAhBYuWM0nf8ZjiLytG+tTVXc8bbAHN7 u1G4tKR/i4YCZNhxGmuqgAgGAJVxHmYM814pW+T6NThhfNzT6DzChrp X-Developer-Key: i=arinc.unal@arinc9.com; a=ed25519; pk=VmvgMWwm73yVIrlyJYvGtnXkQJy9CvbaeEqPQO9Z4kA= X-Endpoint-Received: by B4 Relay for arinc.unal@arinc9.com/arinc9-patatt with auth_id=115 X-Original-From: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= Reply-To: From: Arınç ÜNAL The code block under the "!ds->user_mii_bus && ds->ops->phy_read" check under dsa_switch_setup() populates ds->user_mii_bus. The use of ds->user_mii_bus is inappropriate when the MDIO bus of the switch is described on the device tree [1]. For this reason, use this code block only for switches [with MDIO bus] probed on platform_data, and OF which the switch MDIO bus isn't described on the device tree. Therefore, remove OF-based MDIO bus registration as it's useless for these cases. These subdrivers which control switches [with MDIO bus] probed on OF, will lose the ability to register the MDIO bus OF-based: drivers/net/dsa/b53/b53_common.c drivers/net/dsa/lan9303-core.c drivers/net/dsa/vitesse-vsc73xx-core.c These subdrivers let the DSA core driver register the bus: - ds->ops->phy_read() and ds->ops->phy_write() are present. - ds->user_mii_bus is not populated. The commit fe7324b93222 ("net: dsa: OF-ware slave_mii_bus") which brought OF-based MDIO bus registration on the DSA core driver is reasonably recent and, in this time frame, there have been no device trees in the Linux repository that started describing the MDIO bus, or dt-bindings defining the MDIO bus for the switches these subdrivers control. So I don't expect any devices to be affected. The logic we encourage is that all subdrivers should register the switch MDIO bus on their own [2]. And, for subdrivers which control switches [with MDIO bus] probed on OF, this logic must be followed to support all cases properly: No switch MDIO bus defined: Populate ds->user_mii_bus, register the MDIO bus, set the interrupts for PHYs if "interrupt-controller" is defined at the switch node. This case should only be covered for the switches which their dt-bindings documentation didn't document the MDIO bus from the start. This is to keep supporting the device trees that do not describe the MDIO bus on the device tree but the MDIO bus is being used nonetheless. Switch MDIO bus defined: Don't populate ds->user_mii_bus, register the MDIO bus, set the interrupts for PHYs if ["interrupt-controller" is defined at the switch node and "interrupts" is defined at the PHY nodes under the switch MDIO bus node]. Switch MDIO bus defined but explicitly disabled: If the device tree says status = "disabled" for the MDIO bus, we shouldn't need an MDIO bus at all. Instead, just exit as early as possible and do not call any MDIO API. After all subdrivers that control switches with MDIO buses are made to register the MDIO buses on their own, we will be able to get rid of dsa_switch_ops :: phy_read() and :: phy_write(), and the code block for registering the MDIO bus on the DSA core driver. Link: https://lore.kernel.org/netdev/20231213120656.x46fyad6ls7sqyzv@skbuf/ [1] Link: https://lore.kernel.org/netdev/20240103184459.dcbh57wdnlox6w7d@skbuf/ [2] Suggested-by: Luiz Angelo Daros de Luca Acked-by: Luiz Angelo Daros de Luca Signed-off-by: Arınç ÜNAL --- Changes in v2: - Remove mention to drivers/net/dsa/realtek/realtek-mdio.c as it now registers the MDIO bus OF-based on its own, and now under drivers/net/dsa/realtek/rtl83xx.c. I've waited until this happened because if this patch was applied beforehand, there would be no way to set IRQs on PHYs as the subdriver doesn't do that for the MDIO bus registered non-OF-based. - Link to v1: https://lore.kernel.org/r/20240122053348.6589-1-arinc.unal@arinc9.com --- net/dsa/dsa.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index ac7be864e80d..09d2f5d4b3dd 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -626,7 +625,6 @@ static void dsa_switch_teardown_tag_protocol(struct dsa_switch *ds) static int dsa_switch_setup(struct dsa_switch *ds) { - struct device_node *dn; int err; if (ds->setup) @@ -666,10 +664,7 @@ static int dsa_switch_setup(struct dsa_switch *ds) dsa_user_mii_bus_init(ds); - dn = of_get_child_by_name(ds->dev->of_node, "mdio"); - - err = of_mdiobus_register(ds->user_mii_bus, dn); - of_node_put(dn); + err = mdiobus_register(ds->user_mii_bus); if (err < 0) goto free_user_mii_bus; } --- base-commit: 4acf4e62cd572b0c806035046b3698f5585ab821 change-id: 20240130-for-netnext-dsa-mdio-bus-627c0470e883 Best regards, -- Arınç ÜNAL