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