From patchwork Sat Mar 11 20:31:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 68191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp444601wrd; Sat, 11 Mar 2023 12:41:33 -0800 (PST) X-Google-Smtp-Source: AK7set8P56C43QG098dYinKHrZ36BWmdrApEuAyBb738xCW48pj8e8/3fOr3icXvGPiCZlfMTFbA X-Received: by 2002:a17:902:ecca:b0:195:e9d4:5380 with SMTP id a10-20020a170902ecca00b00195e9d45380mr37299903plh.56.1678567293678; Sat, 11 Mar 2023 12:41:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678567293; cv=none; d=google.com; s=arc-20160816; b=FA42/6l30dpo8A/CYGBJog11dOixLDnbwq1T1iCGXiBAuh9GpI1vxoZVKUy3QIYzSu EIt65FX5Ne+SepkeDQAn65PoyH7c3lPN6cJuEHO5fudx71hnaYo6il9KJPbI0Fma+vTF beCZJ60fwQQwlyWKR4PAuKyYHcXv9aiizSbZHAuBMkT9ExjBcxNBqeY7tjMPHdUgLZjt FAQTlX+qXNbRXk0H+68fQKgr13rgQdCB+0g0PSlqUDf4iGSJZOBMXQpJjo9Fy8wHtHep ofETXMYxEWIfx5uVxdbD2V1NXjI6y+v9aWmBc/xUqzp+DhuNGb4qIgnDDEPvqsxY+xS/ EMlw== 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=Sa8Viko7R2yiIEdvUmLiKMrQqnXj/8f/7Yb3WNadgBE=; b=L1oCshuY38baET9Kz6MvO8RD9LaCpII5nj7uHluhiGjW1zzmuSvomBfD8X14O2OzZr 5A3L0vv3wCe5CP1bvsA0bNAIS+CUvAGHyKh6sFLxQH/+hgftJrjCgyUbEyX5HzkLqHql 9y0LeP24ClQiIYzjpcIlGQgifythYJaqxrO9n6IQ8GiteCazFTnwXTN++twKaj2jD9Xs KR6H07+sPwSpMponKjx6NTxXHvFYOSBKDMVPLXt74PrS593rqXYGXd5NpPPD0qk/4GMT cgzbkygWrMTiqN2I89XBicfU0WsqdU66M3zqgYLjnu2iaHHU5t2uXgDxgRJLj5uBXJ/n JFkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZEu4wx49; 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 kv4-20020a17090328c400b0019cb3c948d5si2728313plb.540.2023.03.11.12.41.21; Sat, 11 Mar 2023 12:41:33 -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=ZEu4wx49; 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 S229932AbjCKUc1 (ORCPT + 99 others); Sat, 11 Mar 2023 15:32:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbjCKUcW (ORCPT ); Sat, 11 Mar 2023 15:32:22 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B38A6EB80; Sat, 11 Mar 2023 12:32:21 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id bw19so7989807wrb.13; Sat, 11 Mar 2023 12:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678566739; 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=Sa8Viko7R2yiIEdvUmLiKMrQqnXj/8f/7Yb3WNadgBE=; b=ZEu4wx49OgDa69bbgN58Fary1rVTxN2vAfurmq13lyT0q3i7Xv1xq2OLKS283to7/x dGZZN9Ctqx3K+JdBfJJtj/gCrU/mVlpxTnax4p6REToMui6yqvQty5C4bTGYCd+gTOnn M13tSegRVtzUIIFaJCYM3sF0If6Xbmbj4j9/GzpgcjMHjZWNsqYosgILz2e3eqbg5hz6 xez8uLM3P7mePOeP1m44gqCRC12Z8Hk45yaHNUqy5noiNp73nH6mZzdMVnXWuu4aXfGS Ccr/xjMQS7esuKWhmFuyh7a2MjLpglcjTVVWbcJSm5qwmqsnn2pDFfuj7HCxtdRAaC5h WxKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678566739; 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=Sa8Viko7R2yiIEdvUmLiKMrQqnXj/8f/7Yb3WNadgBE=; b=6obxyTZIf+0hFmowDXeOD0hM1QWPcD1vR0TY3AfcNn8pzqsuTnEYpq76B0FYDDsotl zb8jA5sJ7dtWJuUk7+xenBPi85jwuFatuQo7RVU2oGtciHPiudzsK+VljjH3YaNZbDRr H4FIrNtUsSza4WLBQ6CkY2vHP1Og9/FmZIljqrKeZGumdOdiXhULtAyMY55+3RMRSv63 KPSACpcSOsaLXVdV1jrezuygJ6M8O4oVTOJYiL8xy0noaz5/SJ1HmLQ4Udx6/AMRmypd 8CqOeJSZd3zlAKXw6HnO+blo+dsuCJtIq8NpTD9u2MnMj1Ag6waOfYhYGdQJuAzQsMg4 XYaQ== X-Gm-Message-State: AO0yUKWK1NtltPqR9Rf/r5lHGJcXPH2zQS2bLEwgL1AX0XFWaEwhPyWK WfAzc099qS87cHUgzsCU9Y8= X-Received: by 2002:a5d:4289:0:b0:2ce:a250:df68 with SMTP id k9-20020a5d4289000000b002cea250df68mr1693846wrq.28.1678566739370; Sat, 11 Mar 2023 12:32:19 -0800 (PST) Received: from mars.. ([2a02:168:6806:0:cb1:a328:ee29:2bd6]) by smtp.gmail.com with ESMTPSA id t17-20020a05600c451100b003dc434b39c7sm4524319wmo.0.2023.03.11.12.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 12:32:19 -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 net-next v2 1/3] net: dsa: mv88e6xxx: re-order functions Date: Sat, 11 Mar 2023 21:31:30 +0100 Message-Id: <20230311203132.156467-2-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230311203132.156467-1-klaus.kudielka@gmail.com> References: <20230311203132.156467-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?1760105378781456552?= X-GMAIL-MSGID: =?utf-8?q?1760105378781456552?= 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 --- v2: No change 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 20:31:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 68192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp445397wrd; Sat, 11 Mar 2023 12:44:25 -0800 (PST) X-Google-Smtp-Source: AK7set8M8rhS97EwFeuSGVF9mFSBJHibz8XbaipmG5hKJMb4ugdSMSLMToAu6hmi9K+7JglwkCbX X-Received: by 2002:a62:1741:0:b0:5b9:49a5:5ddc with SMTP id 62-20020a621741000000b005b949a55ddcmr23562635pfx.3.1678567464684; Sat, 11 Mar 2023 12:44:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678567464; cv=none; d=google.com; s=arc-20160816; b=0/taJHH+14QWtiadVWiz7tUck2m6H4SnVzN7ppa3YWuoqcLCxVaF/86g4Ai3MGP8Mc Vh2pRZ4UIk9gd0+A8zY2KZLU1xA4q/QSwckutPz+eQkQYfYuX7UvfeCeRTVZoWa0Fev3 2MJ30ZlNolMP1+lJDrTDLC+XJcJwX4LKkPQQuF19QDzrGrZH7p/oha55Zt+OKDTi4j1i G4wTp9B69JpjORtzcwt5+CUdVynzrnY2CimFgKJOqizXdY5o3UHkfF57srJQ8Sys82L1 oHPTcukDq0Eu1iuD8Q53q9bJP8PsqoFClJo2sj6a1qCXCyj+uNJ4C9uHHEl7Dhh+r02g owow== 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=AiLJyC+6k3bEzF5maSzcooJwMJcf3Q5KbHqa7PEiDPg=; b=BglxG2/qZT1hNcH2Q0+N0ZVmHcIh8uyjCmF29OBPmU4mO/QEbaTDXWD4/Z1965qeyW CzaHV+uJfiUWMYyoj2V45AOkOCtFIYmaVo2fAusv1VwxC/LGnA3UG/dV6tmZaoXALkVV BJZIROpKyXFAc7yTYbUH2kzCB4tOi2udT4HCgHrYMmmFSMSjAVZOncK6IpdVMJmdNUgn 6fqQzGkWTSi7y0XWIiQhpWaw8QXNRVVZ0AAEe/niLLV/7aLcrnIOgl/iZKM5lq4Q7gZA LcOzEsD3AuaZU6AnezDciZdRSRtcNR3EwEcCC+8vrazZ4WKJx/eZ/P2cTOe2IYNGOA0X 6o4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RSW7uLyy; 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 s67-20020a632c46000000b0050980af12e2si354175pgs.319.2023.03.11.12.44.10; Sat, 11 Mar 2023 12:44:24 -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=RSW7uLyy; 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 S229957AbjCKUca (ORCPT + 99 others); Sat, 11 Mar 2023 15:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229901AbjCKUcX (ORCPT ); Sat, 11 Mar 2023 15:32:23 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041546EB8B; Sat, 11 Mar 2023 12:32:21 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso8370992wmi.4; Sat, 11 Mar 2023 12:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678566740; 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=AiLJyC+6k3bEzF5maSzcooJwMJcf3Q5KbHqa7PEiDPg=; b=RSW7uLyydfqSkK+kbYZlAGLLiKXymwFmaDXYkCFJ/HanDlB+S7O4TXVpSqXo8wXGzh mv9DqcEpEMJSDhL2zK37QTfTDt0O04R/GUlo17mqW1TGJs5h9ECXYLaCzvEjC1xx1T1w m3KIwTLdunLoaE3+3sygLZ4aqd2PC8dg2Z9hSyzd3Uxu2nKo4T8qyupf4bNvzgPBafCZ AkKfQKapKI1bZV8SvbzkUEkn/cM0TKfkQp8YOQHpppJTVXDhSDb+5iHxoTrtmj33vh4/ I+sKIQqbKpZiJulcOMaB9Elly4BTZoYVzukAj8Od42DV1E0Nc912/fSN4t4W/OOX7cW2 N6kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678566740; 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=AiLJyC+6k3bEzF5maSzcooJwMJcf3Q5KbHqa7PEiDPg=; b=ytvVzYbqeCINWeX5JA04stpuXW2JcU+QJkxDSedCiVlSehoeTtF+Kum+XImkIx1AZx jcFb25zhsF+brtaK6OdqRtY6VLVDynMaxZzRG4QtSFrjDtubADaX1gG+ecLNlXOHZLCI +AXpTghDZ3BXUEYzuZ4vrMOvX1EY4/ILvisH0yIE+UkKQIWvrhsxG4lDs3MjXz2TVrMq NkLmlebEso/PV5w9gTyFFSiF4tc7DTHLSiVYWhCVYCzI2qdQCNUMkuAx7U+sBIq+0uav d1yqID8b57w0aEqlfj8Y3usuK/6Mwnv+V0JzqtbsUQ77PEWE/bq22uf912MqstcPqIsR HeeQ== X-Gm-Message-State: AO0yUKW2G1VrGTgKBh5O7Uwn/TE6wrdzyyrd51BoxBnktK1UnKhmCapL DGRGlOPC7o5lGP2HVKdUHE4= X-Received: by 2002:a05:600c:4e87:b0:3eb:38a2:2bcd with SMTP id f7-20020a05600c4e8700b003eb38a22bcdmr6421236wmq.28.1678566739963; Sat, 11 Mar 2023 12:32:19 -0800 (PST) Received: from mars.. ([2a02:168:6806:0:cb1:a328:ee29:2bd6]) by smtp.gmail.com with ESMTPSA id t17-20020a05600c451100b003dc434b39c7sm4524319wmo.0.2023.03.11.12.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 12:32:19 -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 net-next v2 2/3] net: dsa: mv88e6xxx: move call to mv88e6xxx_mdios_register() Date: Sat, 11 Mar 2023 21:31:31 +0100 Message-Id: <20230311203132.156467-3-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230311203132.156467-1-klaus.kudielka@gmail.com> References: <20230311203132.156467-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?1760105557887161832?= X-GMAIL-MSGID: =?utf-8?q?1760105557887161832?= Call the rather expensive mv88e6xxx_mdios_register() at the beginning of mv88e6xxx_setup(). This avoids the double call via mv88e6xxx_probe() during boot. For symmetry, call mv88e6xxx_mdios_unregister() at the end of mv88e6xxx_teardown(). Link: https://lore.kernel.org/lkml/449bde236c08d5ab5e54abd73b645d8b29955894.camel@gmail.com/ Suggested-by: Andrew Lunn Signed-off-by: Klaus Kudielka Signed-off-by: Vladimir Oltean --- v2: Extend the cleanup in mv88e6xxx_setup() to remove the mdio bus on failure drivers/net/dsa/mv88e6xxx/chip.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 496015baac..29b0f3bb1c 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); @@ -4015,7 +4022,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) mv88e6xxx_reg_unlock(chip); if (err) - return err; + goto out_mdios; /* Have to be called without holding the register lock, since * they take the devlink lock, and we later take the locks in @@ -4024,7 +4031,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) */ err = mv88e6xxx_setup_devlink_resources(ds); if (err) - return err; + goto out_mdios; err = mv88e6xxx_setup_devlink_params(ds); if (err) @@ -4040,6 +4047,8 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) mv88e6xxx_teardown_devlink_params(ds); out_resources: dsa_devlink_resources_unregister(ds); +out_mdios: + mv88e6xxx_mdios_unregister(chip); return err; } @@ -7220,18 +7229,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 +7271,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); From patchwork Sat Mar 11 20:31:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 68193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp445685wrd; Sat, 11 Mar 2023 12:45:26 -0800 (PST) X-Google-Smtp-Source: AK7set+x4S91Glni8ed0oLH3YGZs3vPVDAeMjuEmKdbU1UxrGX8Na6AwCrmZgpBBbCB4cQh/yvKD X-Received: by 2002:a05:6a20:69a6:b0:bf:58d1:cea0 with SMTP id t38-20020a056a2069a600b000bf58d1cea0mr4542188pzk.31.1678567526280; Sat, 11 Mar 2023 12:45:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678567526; cv=none; d=google.com; s=arc-20160816; b=kgN13j4SVVduJhGCoAUS74DQPbJOP76xJm3Tt3R2+jOiBorm/thP8t+YxiCUnlGNMc l108NK1Mn4aQyczsimrlpXRupDFEB+tlQFIdmlwaXRLQ99ulfr2UWqkLbY4KA0ZzPwLn oIsCuHAUnMp1rQL74C+yvf5Oy94aovTpaSmu9puRaevYVLCc42fNO6Zm9Ujurpocbvmr 2+ZrvNzDmHrddMA6akUC1XYyPp4srwotWz0N69jZvQu7xo3xpH3G6gWc9wvICfsEZVn0 7LCK/OvjqpMTcvxVjvhskpUuu9tyP1GTU1/f13dHTJlKpmQ5eOYQsWk6L5YcQshB9hGL Up3A== 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=+0kS7aVJWn2QRxzhK3/aqBqmHgTgSZuYdBYMBRoKq/8=; b=s6r7DzKpcddM0Cs8p8SW19qVF2pjKMJZrzNW6Mh4Hs49dklltQ4qut3z264yMoWCBO Yj/2QVMVlpSn1nAiVt3bIX2kMIj6jst+vq9cRfvQ6zZRkbh0k1gdTxvo0K1GrU7MYjAR 4StDrB3RbWX7I50vWM3K+lPUEtnOAr2USz3Qqp4XLq6NTMGuFZhDb8M5dUB1xsXv9s9W MXHyaHr6zU89VqSvK5BZZ0QBJYhyD0jdWuCXtNgiAhnLnSt9vRt9OUFoI9FWKCwbDVYQ qBtE2IEMffpVInx5GtPiw10kk4qP0+nsKF3Vtzyu8n9eZsDdoFE9RHGIuYB42pQbCS/I +Crw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Des4jwYT; 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 u5-20020a634545000000b00502e76a516csi2641660pgk.500.2023.03.11.12.45.12; Sat, 11 Mar 2023 12:45:26 -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=Des4jwYT; 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 S229945AbjCKUcf (ORCPT + 99 others); Sat, 11 Mar 2023 15:32:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbjCKUcY (ORCPT ); Sat, 11 Mar 2023 15:32:24 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 317D26EBA2; Sat, 11 Mar 2023 12:32:22 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id p16so5520063wmq.5; Sat, 11 Mar 2023 12:32:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678566740; 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=+0kS7aVJWn2QRxzhK3/aqBqmHgTgSZuYdBYMBRoKq/8=; b=Des4jwYTOyK0w+CSUeBjA8GQUVC6GH07szSLdPl5GmR3KoARotp2M+8bDrX7I0/BKw LrzUhIXhlFvyDFfzoOAnrScOyWP37jnULP621Y7hTSEmk38nb9/TpiDgbraLjJogMcy4 iWpZgBLkLrk5pKfKTwY3WYLAIjJrRZm6xgTwlub7rhaPhvX4Hh+P8qYf+6z7OJNQaOUZ xgCE86nMh/sfO6b9VtfrNuuJaZCEMO/xXt7xr0ltz19EYZp3HS+n6gqmEl2mhgOxNDRu 10rgnDv7NhBSZMm8MeSQNRrtqFgJ9IzplnXzEe0HmnzhK1roPqTaKGxdZ3AWBwo+1Z3F f2Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678566740; 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=+0kS7aVJWn2QRxzhK3/aqBqmHgTgSZuYdBYMBRoKq/8=; b=ZytGFteQ6mHyu5Y10Vavk/Kput9+5CLy4rbTR8dEmpPcbC8gs4O7cASqd4weARsY8B OZHvQvdkLqn0zHqcqLW+yhR/ZePobyzJA3h0GTN9bY8wj35rbC0Dv1tOYyEIaf7hEuH3 p1k3R8OhW9zifhn97LjBqiVwaUiMTC9p6a49fZ3hUojzDjYCMw6uW4Q9WJjvl7NOrDjZ +efOtXBlvHKPCdTQ0skPzhA5SaI6PGphfakBp4qq3TPlcXy6mSAS+Wc8VzTS7ZPMH7Ez WX6WWWgqqqXpnpmw82rXN7MPUDOtjabS5C/5zHn0RzBzLh7tlZkP4/NR18J8YRMnQr0p dp1A== X-Gm-Message-State: AO0yUKWrQgMQR5A/mr/FKESa3tULoZNufV+ZtbKWQULT1zckXkkYc3pZ Pq9eoyYnQTQlGiZ3tfZUjIY= X-Received: by 2002:a05:600c:4690:b0:3ea:f6c4:305e with SMTP id p16-20020a05600c469000b003eaf6c4305emr6746861wmo.38.1678566740639; Sat, 11 Mar 2023 12:32:20 -0800 (PST) Received: from mars.. ([2a02:168:6806:0:cb1:a328:ee29:2bd6]) by smtp.gmail.com with ESMTPSA id t17-20020a05600c451100b003dc434b39c7sm4524319wmo.0.2023.03.11.12.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 12:32:20 -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 net-next v2 3/3] net: dsa: mv88e6xxx: mask apparently non-existing phys during probing Date: Sat, 11 Mar 2023 21:31:32 +0100 Message-Id: <20230311203132.156467-4-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230311203132.156467-1-klaus.kudielka@gmail.com> References: <20230311203132.156467-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?1760105622345626057?= X-GMAIL-MSGID: =?utf-8?q?1760105622345626057?= To avoid excessive mdio bus transactions during probing, mask all phy addresses that do not exist (there is a 1:1 mapping between switch port number and phy address). Suggested-by: Andrew Lunn Signed-off-by: Klaus Kudielka --- v2: Patch is new drivers/net/dsa/mv88e6xxx/chip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 29b0f3bb1c..c52798d9ce 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3797,6 +3797,7 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, bus->read_c45 = mv88e6xxx_mdio_read_c45; bus->write_c45 = mv88e6xxx_mdio_write_c45; bus->parent = chip->dev; + bus->phy_mask = GENMASK(31, mv88e6xxx_num_ports(chip)); if (!external) { err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);