From patchwork Tue Mar 14 18:26:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 69781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1923358wrd; Tue, 14 Mar 2023 11:44:04 -0700 (PDT) X-Google-Smtp-Source: AK7set/+oqJbm54eItId330WY7fe8BHJf0JetApECv3/NGJ6Lj1gNnUbfhkNJupQC3+ymo4lWQPi X-Received: by 2002:a05:6a20:7f98:b0:d4:e38b:b2ab with SMTP id d24-20020a056a207f9800b000d4e38bb2abmr7195933pzj.22.1678819443758; Tue, 14 Mar 2023 11:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678819443; cv=none; d=google.com; s=arc-20160816; b=efkjbQSYvEpOkBfYorNX95VG8/aacYQoNuvchMph/OVKZuqa7AzxHRWS++jVKoH45b 95mcBQhKteNBQ9C2RSahSmpb07z+xpZY0NqVwyetpgu+FpYxtz1M/6EHwGwjn6q+7T7n McoP2ajXaBeYgAqvsizvclDhNuJ4UwggfsYo2NX+gxOmHOFsMrM6vQ8pr/5Gh2wmKLFB uARjzBku+f523yvYocY0jy2SSYlZWzTF+v+Mx0ynXjpjV94sD2xMxSXu79orIP31i2Pq 6tosZVzoBMevRsTcHS/6s4fP+HKsGc16Nw84JTW0TaIAqxBRv1TA5s7OH3Fc3NPpGbze JPNQ== 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=XjgfVrrzqzZG1qqVxNM9bM9LJAcqmVcDeMqlw6Kxzgg=; b=Ary3O/y34pQFaHRhDyP3C1oCfinWXipQz7T8ma5oKsaSz4nuinwpNYXG6PmsJhnZ4s JgXTeK8GBld6bV2YoqJvsByZWTm5ZQGl0UdgTkiby7Y7hvj5nbzHEz2FDSGZsODHy5sJ BfG72/FS8itduvD6z5nKLyhuJ0VJTlS+ICEFqQQsiCrDsbNoNdhFmdfEam38mX3Roddv Ny7bTfU2qCKW2RhtiFIrOcbMCQ+SfvKBXJO9a80x0iQoJhfEnHaFqUKNNL5c5grjKVEi BLQy173YNnY+fBxzfD3MPH3obe6oEB3uhX7JaW+WEEO1FaV5NXPid2Rh8yukj7ROYOqh rOKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aD6NxyzR; 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 130-20020a630288000000b004fc27d88c6fsi2690395pgc.592.2023.03.14.11.43.51; Tue, 14 Mar 2023 11:44:03 -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=@gmail.com header.s=20210112 header.b=aD6NxyzR; 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 S230270AbjCNS2p (ORCPT + 99 others); Tue, 14 Mar 2023 14:28:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbjCNS2j (ORCPT ); Tue, 14 Mar 2023 14:28:39 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3365B4F79; Tue, 14 Mar 2023 11:28:06 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id c8-20020a05600c0ac800b003ed2f97a63eso942826wmr.3; Tue, 14 Mar 2023 11:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678818484; 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=XjgfVrrzqzZG1qqVxNM9bM9LJAcqmVcDeMqlw6Kxzgg=; b=aD6NxyzRFngsopmrdASrjcU0vQ8iim1I31ReP2hBX64zvFL5W8+0S7zrnVxPbAnEaX Vhzz+MWrztqfY2vG1x3xG7FIhapwhI2uaRKkquK/I83zcvipG4qmbZtHnYDCQBg9ygzW 3vhlxjngcI3YTG/L9G15ZICGiPcTGnVj4acsgCAu+453FOiOUUtWy89QMAOsKeSVPArc JwOwOIr5usvQJG46BS1K62oecZmSFvnovQT6XxZoAvxPd0a7tHz8328alimpTnC9oPo+ ZYvdFhgEZEr1UyNuC/v2/0dEz3g7l3qE4Hqq3Rwc4/EnXWZMrM/SkQ31bW8ck8xIefCO AAnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678818484; 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=XjgfVrrzqzZG1qqVxNM9bM9LJAcqmVcDeMqlw6Kxzgg=; b=hZpxweL9G+97Fzif5dqcrCRazqzD+WiYhW0PftKYhQFl54kHAuUoVLKWXla5UjbxEo L3Th6icHMtaovek/+GOlYH5DG+CnWlqYXOn+mWPCpFx4WOQE+ka1koCop65UALJD70PM pSQAbp791dEhq8DXh4m9jGGJ7W2OOXA45hkGdIAvw+INBnN40RUF9Aon42LPQYrsxLZo mMUX5IG9Gq6h/rdrDobjPx2An+vGvZebQ9MFXNDhGwYRXvzi9ZKfg4SZmPSgdiA7hUhy tum7Mf3ZiIpfcgVczfv6ZMy4twVrENRLtVrrXuSElJcVm4QQpfpcvo+hGfgE9IoNs1R9 YSYw== X-Gm-Message-State: AO0yUKUZ9ymoweuJD+I75RGPgMU7yVn2alqf182E3xaYIe7IoG9AaKQI gnHb0a6FgZkuDDHnOtkuSqg= X-Received: by 2002:a05:600c:19d4:b0:3ed:22b3:627a with SMTP id u20-20020a05600c19d400b003ed22b3627amr8505728wmq.1.1678818483993; Tue, 14 Mar 2023 11:28:03 -0700 (PDT) Received: from mars.. ([2a02:168:6806:0:5862:40de:7045:5e1b]) by smtp.gmail.com with ESMTPSA id u7-20020a7bc047000000b003e206cc7237sm3443490wmc.24.2023.03.14.11.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 11:28:03 -0700 (PDT) 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 v3 2/4] net: dsa: mv88e6xxx: re-order functions Date: Tue, 14 Mar 2023 19:26:57 +0100 Message-Id: <20230314182659.63686-3-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314182659.63686-1-klaus.kudielka@gmail.com> References: <20230314182659.63686-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?1760369777055804517?= X-GMAIL-MSGID: =?utf-8?q?1760369777055804517?= 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 --- v2: No change v3: 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 Tue Mar 14 18:26:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 69760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1918343wrd; Tue, 14 Mar 2023 11:32:10 -0700 (PDT) X-Google-Smtp-Source: AK7set9BCpk9PcdVa7KaFr8jaw0FjgVuBA20awhra4H/1BT6j95nLY7j+RFIYgyz1oTgeibjcqF/ X-Received: by 2002:aa7:8893:0:b0:625:5b43:9098 with SMTP id z19-20020aa78893000000b006255b439098mr4326258pfe.3.1678818730613; Tue, 14 Mar 2023 11:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678818730; cv=none; d=google.com; s=arc-20160816; b=NgQqiCpE/vS4qXF8/mUpn7oiJlP1hjjPty3WNTRVbEB0UyFLjrrihgLnrawXqAHh0o HJ0OUysuwr6GtUi3Kt0bfnl50P+kZsE+cRLy8N0Ka+Yjr5yYMrdzgSfDhKJ2YtrL1YxC gC4Yd4h44y7xpdECmynfdxQ/wK+qNmTN6e8fTklFq7uw9yb12mWGvq/rnLRAo1aJYoRa ckjrXo5E/oEErwO0TIvaJACiqAMOvXerb2BdncXn1Nc9g2owB+CQrL8jTyrjsw/MNqPP xN9Fm2UKE3EAJjKHHYN4fE1vAafLHzW6jwbsuqLd+G9ZEcJeWxzLTNqBBcqu7y1ByB5c /LBA== 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=mejdm1PVBamcQlmV+ZPGdHyY8u7PvL3G0WvxDB+iTUc=; b=YJWoqBQtc0bK0Z1TTnHVqakwzvocSsQzJAwNT7Oj0TTut9M135rE/PkOanJH9Dfg2F 6GdnkR+Rj6qQResc+LVuF7KZjnMdASL8h4584zvcXULnxIsqbiWFwRbSoq2uNvmZnXDV Q2E309E0asVOAGfqtZHevrYDjtdLo3wWunOQgCoULvIRunLrT45LpIUXmKW4tLWhn7tu 3CJNcIRUjy+eaid4+nXKGrlZWtAPn8a/wkbqQCLrF2v8JjrvzGQaz3mCrK0So1i1EtbO irSZCYsU/sdnC2qeUbMsjox+qTCX+O8OM4VooxWWaUwLBjczIExp3SjYkQDpU7E862ei o8hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Dz4Fq0Sk; 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 b17-20020aa78ed1000000b005e2c94ead4csi2656249pfr.121.2023.03.14.11.31.54; Tue, 14 Mar 2023 11:32:10 -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=@gmail.com header.s=20210112 header.b=Dz4Fq0Sk; 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 S230309AbjCNS2s (ORCPT + 99 others); Tue, 14 Mar 2023 14:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbjCNS2l (ORCPT ); Tue, 14 Mar 2023 14:28:41 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25E36B4207; Tue, 14 Mar 2023 11:28:12 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id az3-20020a05600c600300b003ed2920d585so3924391wmb.2; Tue, 14 Mar 2023 11:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678818486; 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=mejdm1PVBamcQlmV+ZPGdHyY8u7PvL3G0WvxDB+iTUc=; b=Dz4Fq0SkB1GGcjIAK2UqKsToHpEYEeivigC6CUyH97xIUBKHtFiWyNinxazqWqPI01 iu+mXB0EDIhFonLyk06xP6H1yeo+1z9JGdzbFh/aEJcqpvw4eVr6D6C7+bMWxhHWq5bk 6XlMDxLRJUjRhpsFhCEf2wTGr/fR93B/rPTk8khEdeY9ZQYGN251zUB7FqlldNfeHjL1 hJQiLB2sP0oKmycpsW+kffpm0yrTz87ngB+7y22Fm4aOXlLjhYfz7vfY4pr7GKchsQkr I2g6QUfspicJOa2sQ8Q+IvMhowz2MFSkICPBRMjllPc+DDPz5IvKWpomtZMNu7g15W6o nNDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678818486; 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=mejdm1PVBamcQlmV+ZPGdHyY8u7PvL3G0WvxDB+iTUc=; b=y4ZSifVMI8vXaNi7JjKQ48PCtxYPahGvngz9DTqwDJ75KQGAWd5kerXxCkW+fTkd0m DAx67ZjFoEv3BjFv5dCHY61+Xkof++2Du6m+PfhYS05RJ+W/NUwXDaEOK7wFYuDlCgGa JyPQVvIgjDeJiZ5CJbsOcLQVaRHtnUerrteVUlHZwFj5+8ovE8Oh6Ir7uemTjUxkUxfl Ny+w1azS/Vjv1Rz5fNzr/ysdheayZaLjc8jVzLjCGTKD55K7sDc9WEntHGI8S8Sq/Bga 0zJYIhwvZpwQwYBv2Uwg7RaMrYr6uTopBFeMj+eL5+7W1tchoflXr79DWLGUZvkH38Hl zRZg== X-Gm-Message-State: AO0yUKUjKzh6jcQkeHiPqOp+iiVEAmfy0SguAvvLVIyMtcXSsaOqxP2e QXJuXs/jIt7AQtx3co+QxOo= X-Received: by 2002:a05:600c:4693:b0:3dc:4b87:a570 with SMTP id p19-20020a05600c469300b003dc4b87a570mr16917460wmo.35.1678818486569; Tue, 14 Mar 2023 11:28:06 -0700 (PDT) Received: from mars.. ([2a02:168:6806:0:5862:40de:7045:5e1b]) by smtp.gmail.com with ESMTPSA id u7-20020a7bc047000000b003e206cc7237sm3443490wmc.24.2023.03.14.11.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 11:28:06 -0700 (PDT) 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 v3 3/4] net: dsa: mv88e6xxx: move call to mv88e6xxx_mdios_register() Date: Tue, 14 Mar 2023 19:26:58 +0100 Message-Id: <20230314182659.63686-4-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314182659.63686-1-klaus.kudielka@gmail.com> References: <20230314182659.63686-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?1760369029403259436?= X-GMAIL-MSGID: =?utf-8?q?1760369029403259436?= 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 Reviewed-by: Andrew Lunn --- v2: Extend the cleanup in mv88e6xxx_setup() to remove the mdio bus on failure v3: No change 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 Tue Mar 14 18:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 69761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1918416wrd; Tue, 14 Mar 2023 11:32:18 -0700 (PDT) X-Google-Smtp-Source: AK7set/A9ENGKJCiWTQmov+kaBXvuGUh3j95rMRlOJR4clHklJ5W+3qaDc1hDb1280YdXaOYRr9f X-Received: by 2002:a05:6a20:3d15:b0:d5:58df:fbaa with SMTP id y21-20020a056a203d1500b000d558dffbaamr4065782pzi.12.1678818738545; Tue, 14 Mar 2023 11:32:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678818738; cv=none; d=google.com; s=arc-20160816; b=Vwh6oCZjyE1qyLZMUpyWjAIJMiLy+PuFdZyxHCEaqGM8rjapva/2+g5eACGky0fyMD VZoTWe2Otl7WY0wkWa5qC86x+zg7L8WIdH+3h1fuRgr0F37kQrqpaA63OkO9pGVfWqTk R7DfKPv3KpIu3yVMYy8DA1SSJkwU0W7cQhDkLOZuklap68c0TQyUGc3vcJsIqSU6Hukq LeDgWrvs2khc3udc0QeuXSBQFgZjdebUJ40cjGmPRGGP+Cl/50ZgxNRbmkjV5/tvrmIO FKUK5yB8ICr34+eZAsQ8fV1NBzsMXAVX27yD8FurmGPVjlMnNMvwraV4TbGLHZEFQXgR nGmw== 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=uCZkrMLZx8ZVMQLFuANkNwADh4tGUpOBmEXyzie1B/E=; b=bG9FgzCcG+f63VlfIyNKbfLFpSZLfUMn3nVdeZ/yi5IIz0DFKcw+cubiMemW4Ov1r6 WTykxJ06VA/xzyVkeOcAFONx1pgHRw/j4eVdYMy5D8HW/3j7syFpfdSicGrTZfnPZaJr 8WXuLmRdFWNSSC+MikuDg1b81IYv8NCGKA/N2rBnuX4uZFWThcgVXzOccNPZSDEeKgu2 6SdONf9kHHzkR8abpo0IQfudjXtPVtD2bC9BYy+4TD4nra8WRIZvKT3Kb395yn+vU1nU S2qAlXxL3vx0i8SIDXiBI3mdZIGhCvDjOPNMhmyiP55hJl8uNDUJVvdJqiJrX2gued/D OZFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UarJ3AuQ; 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 l8-20020a635b48000000b004fb93a4016asi2786670pgm.483.2023.03.14.11.32.02; Tue, 14 Mar 2023 11:32: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=@gmail.com header.s=20210112 header.b=UarJ3AuQ; 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 S230304AbjCNS2v (ORCPT + 99 others); Tue, 14 Mar 2023 14:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbjCNS2m (ORCPT ); Tue, 14 Mar 2023 14:28:42 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA824B4215; Tue, 14 Mar 2023 11:28:13 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id fm20-20020a05600c0c1400b003ead37e6588so13812723wmb.5; Tue, 14 Mar 2023 11:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678818490; 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=uCZkrMLZx8ZVMQLFuANkNwADh4tGUpOBmEXyzie1B/E=; b=UarJ3AuQtgdT97POi2QL4jhEBe0WUGNTBL9LOFoKiy5WPNaL6vER6d6ibVrQIAmjlL DDfARMnIDTGFvCAd3DqhXAe44PBm5frJHA1s0/zqr+zMAbeDcpXvibgSPlpM5/rZgKSR iUIQKlOp3QIwPt0NS0vQ7szqSi5vvFkA6Uh53hal4F1lYAGBJ/QBvDwWoccPpAuIW2Vm NC4/EjVYiVKw4RC43f9xGHFi8/wDFWL//QIW5JoVAJgnCndFqwaHEAHJFBn5CYlamf28 13IqIpbvm7Jmty7Yl8l2xmSjX4s1qpnQt2Zek9q1Rq4orLMVHqjHdXxkiYrRy7iH6Asx wC1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678818490; 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=uCZkrMLZx8ZVMQLFuANkNwADh4tGUpOBmEXyzie1B/E=; b=YCSTzlN3x+wdVjSCfHWU8RO8bl0y8REJJl/+4cZW4Bjokj5TFk+h2/uT7bI63dNxHp CcJlF5ykbHwI83w4LXLFfis9x9f254D7y9ylx1/v976L+xme/3kSYj8RJOmPZswqFCGx SB70saJfdaOHC8gUPqudIeiEJfe0nJmYQCRC20wPffbcwwDN4iukj0un1A7j/WGfRzat GP1VnAEBsEvjpuSixZwrHrJ6bogm+Rc0ujboB/7XNPkvlkhaZzFjskkAKy6qYe/gcyeK dO4W4A+YRyFVOKs3RjIjaw6ahZSHlOkQpB6DuaA2pZlv288JwqpnEk1/dS1It+PY1qUl p6Jg== X-Gm-Message-State: AO0yUKXxyH3YaLyGstSXJO33/wE/MCJeB+cpQJLCmt4gJL6zR2/hSdNu VX0KwG389+8/2Lt3L3P9iRA= X-Received: by 2002:a05:600c:3c89:b0:3eb:38e6:f659 with SMTP id bg9-20020a05600c3c8900b003eb38e6f659mr15820259wmb.15.1678818490700; Tue, 14 Mar 2023 11:28:10 -0700 (PDT) Received: from mars.. ([2a02:168:6806:0:5862:40de:7045:5e1b]) by smtp.gmail.com with ESMTPSA id u7-20020a7bc047000000b003e206cc7237sm3443490wmc.24.2023.03.14.11.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 11:28:10 -0700 (PDT) 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 v3 4/4] net: dsa: mv88e6xxx: mask apparently non-existing phys during probing Date: Tue, 14 Mar 2023 19:26:59 +0100 Message-Id: <20230314182659.63686-5-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314182659.63686-1-klaus.kudielka@gmail.com> References: <20230314182659.63686-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?1760369037445546464?= X-GMAIL-MSGID: =?utf-8?q?1760369037445546464?= 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 Reviewed-by: Andrew Lunn --- v2: Patch is new v3: No change 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);