Message ID | 20230622103107.1760280-1-florian.fainelli@broadcom.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:7691:b0:132:7a2a:f0f2 with SMTP id e17csp686012rwg; Thu, 22 Jun 2023 04:21:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7tYroMBb13/urQisPtkwg/t0WRMJpUlKcovQVF4gfOJtlkGXohKRMn6bpAHU2z1x2Jty0d X-Received: by 2002:a92:d4ce:0:b0:331:1f0e:79b8 with SMTP id o14-20020a92d4ce000000b003311f0e79b8mr14132468ilm.0.1687432905886; Thu, 22 Jun 2023 04:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687432905; cv=none; d=google.com; s=arc-20160816; b=kQChgm2pc+e2TlGwAK1B5OxPs+yj3j2XEHmaSmmjT+4zNDg4S3EAOL1aeODDVY0LyS d2QWhHOzjfAwTWJ2SxLULNIiEha8CL1hayla86ezYlYLiEqpejzM/ZxvYcL/Ajsl6g4W zl6UqimU6OBMKQ+3sPpeDMjF4ljqH2qV+D1lwMEsJHR6z3Ee78sA9iDDP/LevrrqXkNm KHT3SSKeBBgbnx300kEoZfh4mIPRm5gl1jHmLFr4VpVi9BujpImkY146Xf/8j5zj2X2f SkIYEa+lbq1aHYJZtAyy5xDawuZLehE8jvG9NgFsCGPIDW4WSpyHo3tuEO+UXCVbJFjk 9T0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=foVc1CaHvJWWF2807OT0ruI45g584l0UQjwVI9YJr7Y=; b=FDMxTVpG2UdCrFfl6+z+7uMo4PCWKUrav0VX0CdscGrh9GxrDtuyWFs9oIgggXZW9W CDVfcai+hltzbqWA9GBsNiSilmSfCU8LuwnQnL/6/HMSMDIhzQb4j5vI8GkbybN9vfv3 6OnFrwV8f0rCQVGJ70zeOx433r4z06nnYsAwR9Vc6dxJBUs2S6uZvh9PHKz/+uhVhe8f qj3HTxIsDknj+WH+s8l/JJm19h6s3s3phQVvqqTKnuy+dcnPVJUVEMRQ6cQwGTlQLs5O i8oVwrfzLQ7dshpeezcOmediKYU9WLsGgRnC/+zmXdvI+Dn6x9ZC2gBdvaEZW9Ipbol/ QwoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=L2S10xXw; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a63ab0f000000b0053b0da378edsi1157250pgf.789.2023.06.22.04.21.31; Thu, 22 Jun 2023 04:21:45 -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=@broadcom.com header.s=google header.b=L2S10xXw; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230499AbjFVKb2 (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Thu, 22 Jun 2023 06:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbjFVKb0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Jun 2023 06:31:26 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33DA6107 for <linux-kernel@vger.kernel.org>; Thu, 22 Jun 2023 03:31:24 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id 6a1803df08f44-6300f6ab032so46901226d6.2 for <linux-kernel@vger.kernel.org>; Thu, 22 Jun 2023 03:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1687429884; x=1690021884; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=foVc1CaHvJWWF2807OT0ruI45g584l0UQjwVI9YJr7Y=; b=L2S10xXwb8EEYxYcDE+wI+bbNoZNYLGeWJEyhNWXBpuR7+7mufm+JRvn/S6E8Idl/P WTGBYTZ7TqIAJKLrBOYnBaPo5MBk2IzMQZT8rPdx6hp/9z59W2zt3gqsUUsyyp6LhtYa EuU7xUpJPe26kou3k4ypKZ82y2t0xYHz+OFPE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687429884; x=1690021884; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=foVc1CaHvJWWF2807OT0ruI45g584l0UQjwVI9YJr7Y=; b=DDtzP6MuqKmKdekaVabw6iSTP9QGqkZE963qcmegTYrJL95zM4a6WwPoxxX2qiFqZL NQF60GlnCBY91BvjuQi4xAySB9EYd1fY5PGfEJmuSDFjksTeIgRiAP7cRspZIExjHxBD BVZqdnyOYdRAzdXplJEmstyGYanjubfsWG3GbAs9hTJuuQyXjg0JxZUR+EKU4MY0KysY hVzHiy4nhQunyJYUXL2jmkxVPd0oBayI6uC5bLDWfRYm4AaxPxqfZOeAaKPDG6vRDNww kOjHDJbvWokUqnbfMMDhZwPiKNjEUsh88+Iea3Dhdykrv3+YvUdIJccLyvX2UZqQQUZo 5cIQ== X-Gm-Message-State: AC+VfDzDtEBUNVSx5fsx+vPCkepuJntNbJLAbyF52vXcCtCN5fR5qixk FFyn99Jb0fburkhB3UNIPhEEDw== X-Received: by 2002:a05:6214:1c85:b0:623:8494:9946 with SMTP id ib5-20020a0562141c8500b0062384949946mr18779649qvb.45.1687429883773; Thu, 22 Jun 2023 03:31:23 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id g13-20020a0ce4cd000000b00631f40503cbsm3660627qvm.12.2023.06.22.03.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 03:31:22 -0700 (PDT) From: Florian Fainelli <florian.fainelli@broadcom.com> To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, ansuelsmth@gmail.com, rmk+kernel@armlinux.org.uk, Florian Fainelli <florian.fainelli@broadcom.com>, Doug Berger <opendmb@gmail.com>, Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, linux-kernel@vger.kernel.org (open list) Subject: [PATCH net] net: bcmgenet: Ensure MDIO unregistration has clocks enabled Date: Thu, 22 Jun 2023 03:31:07 -0700 Message-Id: <20230622103107.1760280-1-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000d2c03405feb56221" X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MIME_NO_TEXT, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769401646574392359?= X-GMAIL-MSGID: =?utf-8?q?1769401646574392359?= |
Series |
[net] net: bcmgenet: Ensure MDIO unregistration has clocks enabled
|
|
Commit Message
Florian Fainelli
June 22, 2023, 10:31 a.m. UTC
With support for Ethernet PHY LEDs having been added, while
unregistering a MDIO bus and its child device liks PHYs there may be
"late" accesses to the MDIO bus. One typical use case is setting the PHY
LEDs brightness to OFF for instance.
We need to ensure that the MDIO bus controller remains entirely
functional since it runs off the main GENET adapter clock.
Link: https://lore.kernel.org/all/20230617155500.4005881-1-andrew@lunn.ch/
Fixes: 9a4e79697009 ("net: bcmgenet: utilize generic Broadcom UniMAC MDIO controller driver")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Thu, Jun 22, 2023 at 03:31:07AM -0700, Florian Fainelli wrote: > With support for Ethernet PHY LEDs having been added, while > unregistering a MDIO bus and its child device liks PHYs there may be > "late" accesses to the MDIO bus. One typical use case is setting the PHY > LEDs brightness to OFF for instance. > > We need to ensure that the MDIO bus controller remains entirely > functional since it runs off the main GENET adapter clock. So this clock is enabled in bcmgenet_open() and disabled in bcmgenet_close(). The assumption being, the MDIO bus is only used when the interface is up. How does this work when there is an MDIO based switch attached? I had similar problems with the FEC and mv88e6xxx. DSA would try to talk to the switch with the master interface down, and MDIO would time out. I needed to add runtime PM support to the MDIO bus ops. Andrew
On 6/22/2023 4:36 PM, Andrew Lunn wrote: > On Thu, Jun 22, 2023 at 03:31:07AM -0700, Florian Fainelli wrote: >> With support for Ethernet PHY LEDs having been added, while >> unregistering a MDIO bus and its child device liks PHYs there may be >> "late" accesses to the MDIO bus. One typical use case is setting the PHY >> LEDs brightness to OFF for instance. >> >> We need to ensure that the MDIO bus controller remains entirely >> functional since it runs off the main GENET adapter clock. > > So this clock is enabled in bcmgenet_open() and disabled in > bcmgenet_close(). The assumption being, the MDIO bus is only used when > the interface is up. > > How does this work when there is an MDIO based switch attached? I had > similar problems with the FEC and mv88e6xxx. DSA would try to talk to > the switch with the master interface down, and MDIO would time out. I > needed to add runtime PM support to the MDIO bus ops. We do not have that configuration to support today, and given the way that we do register the MDIO bus, it could actually be a bit challenging to support DSA here, I might still have a board around to test, one day. Passing the clock to the MDIO driver does require quite a bit of restructuring in the driver such that the clock is only acquired around mii_bus::write and read operations, otherwise the clock remains constantly enabled, even if the network device is brought down, which burns power unnecessarily. Since this is a fix, I went with the more targeted approach here.
> Since this is a fix, I went with the more targeted approach here. Yes, this is fine for stable. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew
Hello: This patch was applied to netdev/net.git (main) by Jakub Kicinski <kuba@kernel.org>: On Thu, 22 Jun 2023 03:31:07 -0700 you wrote: > With support for Ethernet PHY LEDs having been added, while > unregistering a MDIO bus and its child device liks PHYs there may be > "late" accesses to the MDIO bus. One typical use case is setting the PHY > LEDs brightness to OFF for instance. > > We need to ensure that the MDIO bus controller remains entirely > functional since it runs off the main GENET adapter clock. > > [...] Here is the summary with links: - [net] net: bcmgenet: Ensure MDIO unregistration has clocks enabled https://git.kernel.org/netdev/net/c/1b5ea7ffb7a3 You are awesome, thank you!
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index be042905ada2..c1d670c92958 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -668,5 +668,7 @@ void bcmgenet_mii_exit(struct net_device *dev) if (of_phy_is_fixed_link(dn)) of_phy_deregister_fixed_link(dn); of_node_put(priv->phy_dn); + clk_prepare_enable(priv->clk); platform_device_unregister(priv->mii_pdev); + clk_disable_unprepare(priv->clk); }