From patchwork Wed Jul 12 15:07:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 119234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1222586vqm; Wed, 12 Jul 2023 08:17:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFlfr+epQ1eq52nndeqOkZmbjA4Lzm4vBjr1owgfJsEQaTz3DjYjv45436jWMAE0o7GdLMv X-Received: by 2002:adf:fc4f:0:b0:313:e8bf:a6f with SMTP id e15-20020adffc4f000000b00313e8bf0a6fmr22003958wrs.23.1689175038301; Wed, 12 Jul 2023 08:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689175038; cv=none; d=google.com; s=arc-20160816; b=rqrBTTO3gsjimypvbuPz3ejj7hYSeilPrJ2dMtawi7w/+zObuhFup5AR/6+KpjxFxL NfFD87UPnNzoreOuvfl+EFPoBcObM9d1nAVJngowv/hkz+B5xUIL+WwWxCJIxq3SHrSx j6/2f7yjLwygqOyNr+YWLCqvqC1h3yxll4Io+C463pzq3Ik6uKAgoi7iwxmZERAhWSWW wgZ7r+bFoFLLP0XAmx9Kh0W8fn/px+G8jJFtoLK+r8R70e0iPkgNoeMlDeyEfwDZxZ1t iXwAce1cyCshw2ocQya0yXVC6AXzrK4O2Z1aqrspLtV2bQrckkKiPmWLSsjCGnojf90B pB3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=NsQ7ZPZz2XdBmiFQKCVVqy77wFFWaaGgZMUVXn5ZZuo=; fh=iCOcDVYygcUt3nx67Q2pFMpkgstG/nFvtDYAC1AAD60=; b=rBjR5ZJ3+dFKUfn0ZYoYB70aHss40BnqNoDtz/aeQdwk8QuYed0DAdWglDt8Ky2bgL koaBOGR+1Iuz7I7NBkOH9oVIb6kDAIfcQ478FZcjhmcycA5VW3Zb2Auowd9GAuAVZMpb xTl8lozFkWMzCOdnvsSjtSAymbXHna/nRH/GxmyMVP2WuCh2N38/Tdwf08JpGiiy1RoM puF6ffDZ/u1YGS1qhg9wB+pni4tgv0OjchmT4jPHbAG4d0gonIpheyYHSrvMi91Bh9Gv nY5/Mn3Iy6GYQi/efO4bWaSN3EE+9Ykuhpq1HV+fNSeN6RMNkFP3zG73pJlW70GOvDgi idJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kn5CtpvC; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y8-20020aa7ccc8000000b0051ddbdeb0c7si5039207edt.350.2023.07.12.08.16.53; Wed, 12 Jul 2023 08:17:18 -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=@kernel.org header.s=k20201202 header.b=kn5CtpvC; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233338AbjGLPIZ (ORCPT + 99 others); Wed, 12 Jul 2023 11:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233324AbjGLPHy (ORCPT ); Wed, 12 Jul 2023 11:07:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F6EC1FCB for ; Wed, 12 Jul 2023 08:07:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1286361866 for ; Wed, 12 Jul 2023 15:07:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58C87C4339A; Wed, 12 Jul 2023 15:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689174465; bh=9aHlE7am87TlqLD7Xuy3Eq66iXaKh9SMMvVijAYss5s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kn5CtpvCv3Ea+BXNJIwGn6UeL6bfcvX21Vm6sDfAYIm9vD+bin8qSfiK495Q0i8PF Nr4cStIqbOGjKcrbEUyiW8qNB8FgXoh8HG0+KePvtOrBDS7K6ej+JXWFFlOkxMdNAK PExpypinNJBbD1wG5XfwQIqR3HqwYFIiGjohpnj8QXbiFfCbwez5hnoXfYBHs2IX6o n2Bl0dxfpoygrj6YPxpMNUKf/kTzNaFAXSciNaPjhcqDFO/PvKdOHGBChWu3ZqPVWY qYY/jnW9s89LmqAFxTtnNYuy/P0c8zmm1+ZqACIUWexZTZPDyNASd4DNdDjJzGh7Q1 NGopup2O28XuA== From: Michael Walle Date: Wed, 12 Jul 2023 17:07:04 +0200 Subject: [PATCH net-next v3 04/11] net: phy: make the "prevent_c45_scan" a property of the MII bus MIME-Version: 1.0 Message-Id: <20230620-feature-c45-over-c22-v3-4-9eb37edf7be0@kernel.org> References: <20230620-feature-c45-over-c22-v3-0-9eb37edf7be0@kernel.org> In-Reply-To: <20230620-feature-c45-over-c22-v3-0-9eb37edf7be0@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, Simon Horman , Michael Walle X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771228404976500123 X-GMAIL-MSGID: 1771228404976500123 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 Reviewed-by: Andrew Lunn --- v3: - add missing EXPORT_SYMBOL_GPL() for mdiobus_scan_for_broken_c45_access() --- drivers/net/phy/mdio_bus.c | 18 +++++++++--------- include/linux/phy.h | 5 +++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index a31eb1204f63..29ad9302fe11 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,11 +628,13 @@ 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; } +EXPORT_SYMBOL_GPL(mdiobus_scan_for_broken_c45_access); /** * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus @@ -652,7 +654,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 +725,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 fb7481715c3b..cd67887a7289 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