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);