From patchwork Fri Jun 23 10:29:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 13290307 X-Patchwork-Delegate: kuba@kernel.org 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 09B928BF5 for ; Fri, 23 Jun 2023 10:29:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99EE3C43391; Fri, 23 Jun 2023 10:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687516178; bh=UYZUmCUG6Xzc7GFPwcyPMr7KaNM/T/mzCRnwUpgMqIo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vM0BLBkK1qYdn9gOMmCqu8TmveJYxYF8Qz5PL9sng1jk+gB3zqFZMhLffjYkprNrd nn0Nxikr78IjN0CsNZGEi9URT/at1SPUj0Ya5P9AAXzPBw6YLtrAQYmMHbQ/YQNhR/ VL7Ih4nfg+OaqCVGNl49FR6cUfC/HkLnLqckeR5oNSSoVxeVSmYzAdt37Tb/CFFTNA Si2ys2zP54jJdcXPu04yVIC4oclxO/bJp2MzlFXzGeWhzibe81S4ZjMBrbcgmbL1/J KVGNxDyvCQBD8vDfSb8ylHgntcr8dipyAvwmVAFmQ98+Zx0Xwpt24x62FTBbUDZqVs ICFsWoQ+P6cdw== From: Michael Walle Date: Fri, 23 Jun 2023 12:29:14 +0200 Subject: [PATCH net-next v2 05/10] net: phy: make the "prevent_c45_scan" a property of the MII bus Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230620-feature-c45-over-c22-v2-5-def0ab9ccee2@kernel.org> References: <20230620-feature-c45-over-c22-v2-0-def0ab9ccee2@kernel.org> In-Reply-To: <20230620-feature-c45-over-c22-v2-0-def0ab9ccee2@kernel.org> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yisen Zhuang , Salil Mehta , Florian Fainelli , Broadcom internal kernel review list , =?utf-8?q?Marek_Beh=C3=BAn?= , Xu Liang Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle X-Mailer: b4 0.12.2 X-Patchwork-Delegate: kuba@kernel.org The blacklist will also be used elsewhere in the kernel, e.g. in the DT scanning code. Make it a property of mii_bus and export the function. Signed-off-by: Michael Walle --- drivers/net/phy/mdio_bus.c | 17 ++++++++--------- include/linux/phy.h | 5 +++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index a31eb1204f63..00b25f6803bc 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -613,9 +613,9 @@ static int mdiobus_scan_bus_c45(struct mii_bus *bus) * stomping over the true devices reply, to performing a write to * themselves which was intended for another device. Now that C22 * devices have been found, see if any of them are bad for C45, and if we - * should skip the C45 scan. + * should prohibit any C45 transactions. */ -static bool mdiobus_prevent_c45_scan(struct mii_bus *bus) +void mdiobus_scan_for_broken_c45_access(struct mii_bus *bus) { int i; @@ -628,10 +628,11 @@ static bool mdiobus_prevent_c45_scan(struct mii_bus *bus) continue; oui = phydev->phy_id >> 10; - if (oui == MICREL_OUI) - return true; + if (oui == MICREL_OUI) { + bus->prevent_c45_access = true; + break; + } } - return false; } /** @@ -652,7 +653,6 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) { struct mdio_device *mdiodev; struct gpio_desc *gpiod; - bool prevent_c45_scan; int i, err; if (!bus || !bus->name) @@ -724,9 +724,8 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) goto error; } - prevent_c45_scan = mdiobus_prevent_c45_scan(bus); - - if (!prevent_c45_scan && bus->read_c45) { + mdiobus_scan_for_broken_c45_access(bus); + if (!bus->prevent_c45_access && bus->read_c45) { err = mdiobus_scan_bus_c45(bus); if (err) goto error; diff --git a/include/linux/phy.h b/include/linux/phy.h index 12679bbd4b91..a7aff91f4eb0 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -410,6 +410,9 @@ struct mii_bus { /** @phy_ignore_ta_mask: PHY addresses to ignore the TA/read failure */ u32 phy_ignore_ta_mask; + /** @prevent_c45_access: Don't do any C45 transactions on the bus */ + unsigned prevent_c45_access:1; + /** * @irq: An array of interrupts, each PHY's interrupt at the index * matching its address @@ -462,6 +465,8 @@ static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev) struct mii_bus *mdio_find_bus(const char *mdio_name); struct phy_device *mdiobus_scan_c22(struct mii_bus *bus, int addr); +void mdiobus_scan_for_broken_c45_access(struct mii_bus *bus); + #define PHY_INTERRUPT_DISABLED false #define PHY_INTERRUPT_ENABLED true