From patchwork Sat Mar 11 09:41:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 68048 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp219295wrd; Sat, 11 Mar 2023 02:37:44 -0800 (PST) X-Google-Smtp-Source: AK7set8wBPMhrRFgZVKXzzotvA/lYXavj/nqW0gK2dg71Z6295SyrQHqPHxnBX0TpniLQy0VuQH0 X-Received: by 2002:a05:6a21:9998:b0:d3:73be:3ea2 with SMTP id ve24-20020a056a21999800b000d373be3ea2mr1761717pzb.36.1678531063932; Sat, 11 Mar 2023 02:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678531063; cv=none; d=google.com; s=arc-20160816; b=Ng1bh5LPe+X5ufZjyffQchLdE6V/bYbxWJ+onHth8kzROaXpmKNP/pUdyQhfhWHEBp GKIWKPfn7ZdQasszNoOLU6pA97CReNC2ztmQp31qjR+mNTkIgPiV5ZhcYLiIBAd0Ld7j vmp1yyYfA70bpaZppC/1a/rHlbsjushuKOXQt0OQAhz7y3tDoluahY8E9ZAQ4gmw33hg BuED+VAH97aCZCUJMSLWA0EPcG9eB7OlgE65v0hubzrnaCxW2oHNnViJv1FthlmuZtmP 0kSqI91nr7b+vw3cKBlyoXT0GTMZ2Lo5wEq0Nlw7fHd9IlWMxedyydcXAZOgQjKbf8Bo BMJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=icwaBQpU3isAjPs0PsIO348TEf2ba5GwNw/8dGnNFhE=; b=QNOOHyEtYmFkCL3QOSV1SVzqehdBJYMPPH4xsPFnGFrfXeHQNB+E8ru54BKYfS7sdd wgBrFVn32RPXnf9gr/kLiP0U9Jf14t3qLNhpXxWMdAK2tbIg5IQMjJRYUq2K25gD7LGj yYKWU9JJleqZpNEQEC/3x+xEAHLMhGlLsAJOHcr5sGhwnavavjMGLmRGVn6cdpkniDit Z2VuF9KBzek74HTitDIpQBBr9LNLENMvxizAJONlnIbgoWIVHK0mJPQQvay0B0KcvlWd ujSLtlXrmMpc+AyfOszhUIh6oFRfXWVlQCv3TMVGxakKm55WbMCKjSwq2usA1OVFjj9C OfbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qUkJFQhX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h20-20020a63df54000000b004ce0ead7aabsi1975084pgj.302.2023.03.11.02.37.31; Sat, 11 Mar 2023 02:37:43 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=qUkJFQhX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231307AbjCKJnS (ORCPT + 99 others); Sat, 11 Mar 2023 04:43:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbjCKJmw (ORCPT ); Sat, 11 Mar 2023 04:42:52 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 545FB13F56F; Sat, 11 Mar 2023 01:42:27 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id p23-20020a05600c1d9700b003ead4835046so5737925wms.0; Sat, 11 Mar 2023 01:42:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678527745; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=icwaBQpU3isAjPs0PsIO348TEf2ba5GwNw/8dGnNFhE=; b=qUkJFQhX+1tkimfn/9AuCcQEbxUco93VmE7zMDsKgjC4YW3RnDGfj4S15KCBCIAlJl PW5oY8M+rOQzZWBFfBI1cCrmvXzjcX+49F5nPPc8fcLZr+K1TrZpuOa1ROacTiTc7CRu c3ebxVPL70gXWLx93TOr2ya44yDeGWpMgTI4fyE1Gz/ZKQV8/pq1o7Tp/iA/Qau9kJ62 IbMv8uYRQdJJ5saj3+vKeCkVSUmzHSRZPglA48iMVeDBlVKaaXP3jVjlFwv/2XcI70v8 v6boWVSXc6RQoaTRrMMSpUwvIVHNJjvEb7BG6YzJRrSL+PzUz7h6QkM1MDJlM4xjXsSZ zRRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678527745; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=icwaBQpU3isAjPs0PsIO348TEf2ba5GwNw/8dGnNFhE=; b=eTwfKIdRel7sGFxwJb0cxuGtXt7GcmQx1l9QDSTtFC3P7bWR+C/GTwcuKqI8Zq47Dy N5BuGF/gs4k6JTH850N7LDLRE2rmdhDvoslmNPKJRju07SYGynzGda6lEew4hL2RUDMK mG1iD5xLGM7/vL2ZEZ3H7lZccmREUuRPv8i6mEs4xx/7qrpGOWhqfW1VVFRXf3Si7I/o LyYk6hv84kD7MwbP/jFfYVbsQHpgvOQHo26Q0H9Dp4pcRe0W1GjYxVf10BACCspQWUJ6 TcE6ojZVVr6sOwWCVJfVYvLY1GwxNN8lgj8vQG00QhdNhWQYfDzTll7Crp+AXzyyhhJw a3jQ== X-Gm-Message-State: AO0yUKU365xVOF/aKun09jMaF1/bcrHH7/t0hA1dZW8y2OfgSgTMbTMJ 4DKdzH+JFDn/sqMMwmlYB4A= X-Received: by 2002:a05:600c:1c96:b0:3eb:3300:1d13 with SMTP id k22-20020a05600c1c9600b003eb33001d13mr5135569wms.14.1678527745499; Sat, 11 Mar 2023 01:42:25 -0800 (PST) Received: from mars.. ([2a02:168:6806:0:c51d:786:86a8:fd19]) by smtp.gmail.com with ESMTPSA id n19-20020a1c7213000000b003eb39e60ec9sm2275043wmc.36.2023.03.11.01.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 01:42:25 -0800 (PST) From: Klaus Kudielka To: Andrew Lunn Cc: Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Klaus Kudielka Subject: [PATCH 1/2] net: dsa: mv88e6xxx: re-order functions Date: Sat, 11 Mar 2023 10:41:40 +0100 Message-Id: <20230311094141.34578-1-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760067388979380741?= X-GMAIL-MSGID: =?utf-8?q?1760067388979380741?= Move mv88e6xxx_setup() below mv88e6xxx_mdios_register(), so that we are able to call the latter one from here. Do the same thing for the inverse functions. Signed-off-by: Klaus Kudielka Reviewed-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.c | 358 +++++++++++++++---------------- 1 file changed, 179 insertions(+), 179 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 0a5d6c7bb1..496015baac 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3672,185 +3672,6 @@ static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip) return mv88e6xxx_software_reset(chip); } -static void mv88e6xxx_teardown(struct dsa_switch *ds) -{ - mv88e6xxx_teardown_devlink_params(ds); - dsa_devlink_resources_unregister(ds); - mv88e6xxx_teardown_devlink_regions_global(ds); -} - -static int mv88e6xxx_setup(struct dsa_switch *ds) -{ - struct mv88e6xxx_chip *chip = ds->priv; - u8 cmode; - int err; - int i; - - chip->ds = ds; - ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); - - /* Since virtual bridges are mapped in the PVT, the number we support - * depends on the physical switch topology. We need to let DSA figure - * that out and therefore we cannot set this at dsa_register_switch() - * time. - */ - if (mv88e6xxx_has_pvt(chip)) - ds->max_num_bridges = MV88E6XXX_MAX_PVT_SWITCHES - - ds->dst->last_switch - 1; - - mv88e6xxx_reg_lock(chip); - - if (chip->info->ops->setup_errata) { - err = chip->info->ops->setup_errata(chip); - if (err) - goto unlock; - } - - /* Cache the cmode of each port. */ - for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { - if (chip->info->ops->port_get_cmode) { - err = chip->info->ops->port_get_cmode(chip, i, &cmode); - if (err) - goto unlock; - - chip->ports[i].cmode = cmode; - } - } - - err = mv88e6xxx_vtu_setup(chip); - if (err) - goto unlock; - - /* Must be called after mv88e6xxx_vtu_setup (which flushes the - * VTU, thereby also flushing the STU). - */ - err = mv88e6xxx_stu_setup(chip); - if (err) - goto unlock; - - /* Setup Switch Port Registers */ - for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { - if (dsa_is_unused_port(ds, i)) - continue; - - /* Prevent the use of an invalid port. */ - if (mv88e6xxx_is_invalid_port(chip, i)) { - dev_err(chip->dev, "port %d is invalid\n", i); - err = -EINVAL; - goto unlock; - } - - err = mv88e6xxx_setup_port(chip, i); - if (err) - goto unlock; - } - - err = mv88e6xxx_irl_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_mac_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_phy_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_pvt_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_atu_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_broadcast_setup(chip, 0); - if (err) - goto unlock; - - err = mv88e6xxx_pot_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_rmu_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_rsvd2cpu_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_trunk_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_devmap_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_pri_setup(chip); - if (err) - goto unlock; - - /* Setup PTP Hardware Clock and timestamping */ - if (chip->info->ptp_support) { - err = mv88e6xxx_ptp_setup(chip); - if (err) - goto unlock; - - err = mv88e6xxx_hwtstamp_setup(chip); - if (err) - goto unlock; - } - - err = mv88e6xxx_stats_setup(chip); - if (err) - goto unlock; - -unlock: - mv88e6xxx_reg_unlock(chip); - - if (err) - return err; - - /* Have to be called without holding the register lock, since - * they take the devlink lock, and we later take the locks in - * the reverse order when getting/setting parameters or - * resource occupancy. - */ - err = mv88e6xxx_setup_devlink_resources(ds); - if (err) - return err; - - err = mv88e6xxx_setup_devlink_params(ds); - if (err) - goto out_resources; - - err = mv88e6xxx_setup_devlink_regions_global(ds); - if (err) - goto out_params; - - return 0; - -out_params: - mv88e6xxx_teardown_devlink_params(ds); -out_resources: - dsa_devlink_resources_unregister(ds); - - return err; -} - -static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port) -{ - return mv88e6xxx_setup_devlink_regions_port(ds, port); -} - -static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port) -{ - mv88e6xxx_teardown_devlink_regions_port(ds, port); -} - /* prod_id for switch families which do not have a PHY model number */ static const u16 family_prod_id_table[] = { [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, @@ -4054,6 +3875,185 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, return 0; } +static void mv88e6xxx_teardown(struct dsa_switch *ds) +{ + mv88e6xxx_teardown_devlink_params(ds); + dsa_devlink_resources_unregister(ds); + mv88e6xxx_teardown_devlink_regions_global(ds); +} + +static int mv88e6xxx_setup(struct dsa_switch *ds) +{ + struct mv88e6xxx_chip *chip = ds->priv; + u8 cmode; + int err; + int i; + + chip->ds = ds; + ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); + + /* Since virtual bridges are mapped in the PVT, the number we support + * depends on the physical switch topology. We need to let DSA figure + * that out and therefore we cannot set this at dsa_register_switch() + * time. + */ + if (mv88e6xxx_has_pvt(chip)) + ds->max_num_bridges = MV88E6XXX_MAX_PVT_SWITCHES - + ds->dst->last_switch - 1; + + mv88e6xxx_reg_lock(chip); + + if (chip->info->ops->setup_errata) { + err = chip->info->ops->setup_errata(chip); + if (err) + goto unlock; + } + + /* Cache the cmode of each port. */ + for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { + if (chip->info->ops->port_get_cmode) { + err = chip->info->ops->port_get_cmode(chip, i, &cmode); + if (err) + goto unlock; + + chip->ports[i].cmode = cmode; + } + } + + err = mv88e6xxx_vtu_setup(chip); + if (err) + goto unlock; + + /* Must be called after mv88e6xxx_vtu_setup (which flushes the + * VTU, thereby also flushing the STU). + */ + err = mv88e6xxx_stu_setup(chip); + if (err) + goto unlock; + + /* Setup Switch Port Registers */ + for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { + if (dsa_is_unused_port(ds, i)) + continue; + + /* Prevent the use of an invalid port. */ + if (mv88e6xxx_is_invalid_port(chip, i)) { + dev_err(chip->dev, "port %d is invalid\n", i); + err = -EINVAL; + goto unlock; + } + + err = mv88e6xxx_setup_port(chip, i); + if (err) + goto unlock; + } + + err = mv88e6xxx_irl_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_mac_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_phy_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_pvt_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_atu_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_broadcast_setup(chip, 0); + if (err) + goto unlock; + + err = mv88e6xxx_pot_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_rmu_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_rsvd2cpu_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_trunk_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_devmap_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_pri_setup(chip); + if (err) + goto unlock; + + /* Setup PTP Hardware Clock and timestamping */ + if (chip->info->ptp_support) { + err = mv88e6xxx_ptp_setup(chip); + if (err) + goto unlock; + + err = mv88e6xxx_hwtstamp_setup(chip); + if (err) + goto unlock; + } + + err = mv88e6xxx_stats_setup(chip); + if (err) + goto unlock; + +unlock: + mv88e6xxx_reg_unlock(chip); + + if (err) + return err; + + /* Have to be called without holding the register lock, since + * they take the devlink lock, and we later take the locks in + * the reverse order when getting/setting parameters or + * resource occupancy. + */ + err = mv88e6xxx_setup_devlink_resources(ds); + if (err) + return err; + + err = mv88e6xxx_setup_devlink_params(ds); + if (err) + goto out_resources; + + err = mv88e6xxx_setup_devlink_regions_global(ds); + if (err) + goto out_params; + + return 0; + +out_params: + mv88e6xxx_teardown_devlink_params(ds); +out_resources: + dsa_devlink_resources_unregister(ds); + + return err; +} + +static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port) +{ + return mv88e6xxx_setup_devlink_regions_port(ds, port); +} + +static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port) +{ + mv88e6xxx_teardown_devlink_regions_port(ds, port); +} + static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) { struct mv88e6xxx_chip *chip = ds->priv; From patchwork Sat Mar 11 09:41:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 68047 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp214529wrd; Sat, 11 Mar 2023 02:22:16 -0800 (PST) X-Google-Smtp-Source: AK7set8huU7bAfI5HJcyYQi8W4jso9sQucPbTuPrC5ABV1UxuKKe+9D6gwSJtM347k3sw/j5A5me X-Received: by 2002:a17:90b:2241:b0:237:29b1:1893 with SMTP id hk1-20020a17090b224100b0023729b11893mr28655511pjb.46.1678530136215; Sat, 11 Mar 2023 02:22:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678530136; cv=none; d=google.com; s=arc-20160816; b=WwQs5HCjybHriKWqLOKk7r/g+cvAC39RPBoMLmFPJIO2paas82BwXO8iNNbFhCfZaw yZUCTFa4WWADGDcY2qoOQ1sf9iZ7X/fC995Bk4/deRpeEODJUbmNuxORTyRumgAPAEAR /XpmlZqulRsBAEm7SrRhwXHafcTwyjHaglj0oOxV6noSw88lmcm7dsOaOc594MTIBOCu rXQMs5xnBr+SBT2aDskmlH3GgwCXqdNl5xhZ/9hs1fhdRO8UMUT26p/nGIegT3ZERnGT fiAQ55i7g9ut7sfUStCDmHbGI0hpV7bU3I813WHObFDSxrC8DWDavWNyt0CcgtcJIp/F 2hcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pTRSyVCFXv4DeTX1dIB8XAxlhgF6IWiFZQle1EOSkfQ=; b=AozZEf1ZFtD4gdNHW1HnsGmg+vReQBxZpS+3OyEfLPliAyoS99Mzpl1a92GXYlMNkq joCIlwxfIK/AIQAWq1tJWYXIZ3ZsFwwG4qDn0ppfIKycBsLhBMjdr/13hYLMzVWDO9Al awVdA+JAHLrBCiRBcBsELOAqHsh6KkDXQiLpNoWd5rlJPJRTtuIUeElvlbHAgxbf6DnI YJKwIEFdT/QQ2Y4XLEzAZYugEbMpiTbj8CUp4xb62E3pRgXy7/D3pDYX7Gv1Rc9LmYg3 cafvB+2f3d0Che2/wXJF4xLAQQv09hl0uWalavQAqAqugtGrmeLwrsgj1zxplTDUyQE7 frMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZyE8ZcS+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np13-20020a17090b4c4d00b00235be0405bfsi2041458pjb.34.2023.03.11.02.22.01; Sat, 11 Mar 2023 02:22:16 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=ZyE8ZcS+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231324AbjCKJnd (ORCPT + 99 others); Sat, 11 Mar 2023 04:43:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231270AbjCKJm7 (ORCPT ); Sat, 11 Mar 2023 04:42:59 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C9714051C; Sat, 11 Mar 2023 01:42:32 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id j3so4912075wms.2; Sat, 11 Mar 2023 01:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678527751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pTRSyVCFXv4DeTX1dIB8XAxlhgF6IWiFZQle1EOSkfQ=; b=ZyE8ZcS+xA4PQEXEm2Gl34kdOyE0631m3uRzyzWkOK8N/XzU8ZC57FjbzwoTZDZ6l5 uiuUfNuGdxfsRK2hEsOx+agMk2kPwPXC2cQ2mxud5+x1+laoLG2DbUIgvp3sPETIMM5M c6oJfV/qlZG4vYHr1t73LO/SA5BMiWlZQItt1coQcJZmuogZR+djN4J7cKzVdmG16vcO 5s3f0nmTfniFHgidCk4w113qsszYnJ98umwuiOdTI5+G0fMb0Jbe8Khez4LZQLxDL3jx J7iRuRwKOWAY7H7lb0VsYJEjcJr7r9Za73UD75/3b8TAMtoG0WvOMZuomeNwxBEkEpQ9 +t3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678527751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pTRSyVCFXv4DeTX1dIB8XAxlhgF6IWiFZQle1EOSkfQ=; b=wZczZpAp5EDLkVeOEiXBwthytV1pGVbssFS2TIN4c1Z8LpULffGn35hRMZSKRHYobK xHz3ZtsfV9H0hLD1MFhac+4to68a825zWEaHNIyvztulFNYxW8g/ZmGQAUSrfC/MmbkK J7tQvqxd9leJo5D6ESrLJdJsBus1y5dClCXbvvZg6iYr3Y5RXpzLZz+015sEKQ0rcIyb 9maHeZ8HPV/zbchXg9UeJ68R0iLCgcNQv3CMBVXkCbLC1WcumvjyizDI5Un1tdx47qrV hSXKLlR2oLcQiX7lY4AXyfumqB1L6KZ/o7IVmMgakF356O5dmiWwssug3HgeMmr5L4Oo 8i+A== X-Gm-Message-State: AO0yUKVAXYDpbzL0mNTnMvhBtMVB1SRfIUXemfye/kNp/nUnglzjsjRr qlEeFNiCLntiUXYnSTmtXRE= X-Received: by 2002:a05:600c:548a:b0:3df:e21f:d705 with SMTP id iv10-20020a05600c548a00b003dfe21fd705mr5135223wmb.28.1678527751147; Sat, 11 Mar 2023 01:42:31 -0800 (PST) Received: from mars.. ([2a02:168:6806:0:c51d:786:86a8:fd19]) by smtp.gmail.com with ESMTPSA id n19-20020a1c7213000000b003eb39e60ec9sm2275043wmc.36.2023.03.11.01.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 01:42:31 -0800 (PST) From: Klaus Kudielka To: Andrew Lunn Cc: Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Klaus Kudielka Subject: [PATCH 2/2] net: dsa: mv88e6xxx: move call to mv88e6xxx_mdios_register() Date: Sat, 11 Mar 2023 10:41:41 +0100 Message-Id: <20230311094141.34578-2-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230311094141.34578-1-klaus.kudielka@gmail.com> References: <20230311094141.34578-1-klaus.kudielka@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760066416297925121?= X-GMAIL-MSGID: =?utf-8?q?1760066416297925121?= From commit 1a136ca2e089 ("net: mdio: scan bus based on bus capabilities for C22 and C45") onwards, mdiobus_scan_bus_c45() is being called on buses with MDIOBUS_NO_CAP. On a Turris Omnia (Armada 385, 88E6176 switch), this causes a significant increase of boot time, from 1.6 seconds, to 6.3 seconds. The boot time stated here is until start of /init. Further testing revealed that the C45 scan is indeed expensive (around 2.7 seconds, due to a huge number of bus transactions), and called twice. It was suggested, to call mv88e6xxx_mdios_register() at the beginning of mv88e6xxx_setup(), and mv88e6xxx_mdios_unregister() at the end of mv88e6xxx_teardown(). This is accomplished by this patch. Testing on the Turris Omnia revealed, that this improves the situation. Now mdiobus_scan_bus_c45() is called only once, ending up in a boot time of 4.3 seconds. Link: https://lore.kernel.org/lkml/449bde236c08d5ab5e54abd73b645d8b29955894.camel@gmail.com/ Suggested-by: Andrew Lunn Tested-by: Klaus Kudielka Signed-off-by: Klaus Kudielka --- drivers/net/dsa/mv88e6xxx/chip.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 496015baac..8c0fa4cfcd 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3840,9 +3840,9 @@ static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) } } -static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, - struct device_node *np) +static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip) { + struct device_node *np = chip->dev->of_node; struct device_node *child; int err; @@ -3877,9 +3877,12 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, static void mv88e6xxx_teardown(struct dsa_switch *ds) { + struct mv88e6xxx_chip *chip = ds->priv; + mv88e6xxx_teardown_devlink_params(ds); dsa_devlink_resources_unregister(ds); mv88e6xxx_teardown_devlink_regions_global(ds); + mv88e6xxx_mdios_unregister(chip); } static int mv88e6xxx_setup(struct dsa_switch *ds) @@ -3889,6 +3892,10 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) int err; int i; + err = mv88e6xxx_mdios_register(chip); + if (err) + return err; + chip->ds = ds; ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); @@ -7220,18 +7227,12 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev) if (err) goto out_g1_atu_prob_irq; - err = mv88e6xxx_mdios_register(chip, np); - if (err) - goto out_g1_vtu_prob_irq; - err = mv88e6xxx_register_switch(chip); if (err) - goto out_mdio; + goto out_g1_vtu_prob_irq; return 0; -out_mdio: - mv88e6xxx_mdios_unregister(chip); out_g1_vtu_prob_irq: mv88e6xxx_g1_vtu_prob_irq_free(chip); out_g1_atu_prob_irq: @@ -7268,7 +7269,6 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev) mv88e6xxx_phy_destroy(chip); mv88e6xxx_unregister_switch(chip); - mv88e6xxx_mdios_unregister(chip); mv88e6xxx_g1_vtu_prob_irq_free(chip); mv88e6xxx_g1_atu_prob_irq_free(chip);