Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp205352lqg; Fri, 1 Mar 2024 02:45:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV3/0F7b8UP6uoMgM9jtlYeZP4Tkl2mW23zEV2FuyFHEAjRLaiAREEvOYly4HKQ3Dz+1mXC/77/iCtNLovG6kNwcPGhMhm7IlXoU/7q5g== X-Google-Smtp-Source: AGHT+IFHB4pG8pnWyfpsRQbEqtNmNIAMB+YzPV9dnowviWvj6748o6N9ZxWPmIzvAlWRC3cl8noy X-Received: by 2002:a05:6870:7b4f:b0:220:c105:73fc with SMTP id ji15-20020a0568707b4f00b00220c10573fcmr682681oab.52.1709289939361; Fri, 01 Mar 2024 02:45:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709289939; cv=pass; d=google.com; s=arc-20160816; b=DSP4Tpwq8+YtpYiu9gFDZtV7PQV2mC7D1tguE2L4wABcB1IzxDaR8nvxmPlUjY4Xvs Jy6Dc8HHFVrdG24mvLuKP66qF4nLpGV3iaTmM1F6uMqwN6FVq9QHjt5ZFtNq+OA8uyiH r0TliUp2twRQ17gJTLGt3LIXaOEQ397nxflXA8gh3xoEkePdVr1aHifRYd81LSzjrWII B2jiJ+ByVuyyS8lI5qoqTfxYZuSFt03LkcoIRCEQg58geM1gqvH/10hnzh+4303J73D5 CtVmA/QK4m17ccqOzuKBXDPX8VWn2knoQErzHJcZ9ieLreN2lsPS6qq0Detw/u5y7fDg aFNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=fj8a0YcRXjwwoVuxtWZa7leH8QPCDc+QQ3OI36VOixE=; fh=xNlE86XmqkSplYYMvvd74gD/RbF2aUqtHPBgVCVc3H8=; b=rGTisl9aLSBk/k2Uk+cVCDuy3dTdanN5xphxkrf/51DevcwTOhhHZPta0rTpoKObNK c2oAeHndYDNSSg44EfnPoNtsd0A8ieB1+BBkLz0IhXa6+tjbpVfWsrYYWJU2ts2rggwt N3nVBTdmjH3tBNz3SCy/cepu6w7IqRY40aLVbS4w1SNzSbVax5OD+m7xNrtpKq+EX+6L Gb/3EW4p1LmxOwQEc30QkT8Tal5TtNblv6Cqam9tDPaqU78Mwm9wpxeNdAwHExQgy8fw mNNS5L/jSHfoOQOh3ZoFIAWfiXYyI/q8BdIMRyAdGs3Huaniei2mP+pFF/mjn/YJqEFT 5u1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q6ytghsN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88276-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 21-20020a630b15000000b005cfda2f8f08si3181052pgl.452.2024.03.01.02.45.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:45:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88276-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q6ytghsN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88276-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 07932B242B2 for ; Fri, 1 Mar 2024 10:45:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 587936F079; Fri, 1 Mar 2024 10:43:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q6ytghsN" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64AC56BFA8; Fri, 1 Mar 2024 10:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709289779; cv=none; b=liHqFI30MjCwRfrCFyuj3tjsPJHwi3fB4iyPZI/1TQuvp3rRFJLuDpsqTSaYSeEh/Y7aMv5wNp6HyYjMfTJcJKl0mUz8dDw0vFvZ4AZYSGsXYHRtei23/Uet0HJLMZzY3SlKZFP/ZYb6RYOFkIosRWs4K8nTJnWy2WR7+3g6rIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709289779; c=relaxed/simple; bh=9OAw1+rum7epPqDadmyP8sgcI2N4oduq36yqdy67hu0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KJ9VoI4HnpRk7FnD95C51KiML8ZMcvx4bkn8M7fTAEX/F7kF8dshjD7ubIZmJPaW9RZi0xhV0tA2PfJ/IrFOWuLEElMySuKpEUTqeGvJRaFKDAzOIdnWk2U7Xlawwz+vZ2t0uOuLoHtHnArCjyFNoIZQ4ZMEfOlKJFTi0VipSFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q6ytghsN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 23052C43399; Fri, 1 Mar 2024 10:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709289779; bh=9OAw1+rum7epPqDadmyP8sgcI2N4oduq36yqdy67hu0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Q6ytghsNRg8TjKbIqvx5vqLAdWrDW0Gy+9JujyLZr81xADgRM8+2WSmV5ipMMJMaW W/0LDzR7AfAU56JPTDwdYHFq3uc7f+V2MputpyhNzIO3Q4WU/K0U2jCZ187kuYITvs TLgQc6ZR8dwec5PrN5zn7Vm5DgU3PSM+YqioNKHXO2rlS7lfwwtcBKpP1liRvm6bBR 2oz86kTazcxneqbmvceETJiib14hPeuqBccDO38JKa+Amd1aeiw9iE2/v+aHWNKVpg VG4HQ73zJGSVqexIjIZjlRxjtBIgZVLEegeL/o7a2Drp6uY0HOQcNYlUGZPvwVXU0y WtnAPI/XyT5/g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1246DC54E55; Fri, 1 Mar 2024 10:42:59 +0000 (UTC) From: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= via B4 Relay Date: Fri, 01 Mar 2024 12:43:04 +0200 Subject: [PATCH net-next v3 8/9] net: dsa: mt7530: sort link settings ops and force link down on all ports Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240301-for-netnext-mt7530-improvements-3-v3-8-449f4f166454@arinc9.com> References: <20240301-for-netnext-mt7530-improvements-3-v3-0-449f4f166454@arinc9.com> In-Reply-To: <20240301-for-netnext-mt7530-improvements-3-v3-0-449f4f166454@arinc9.com> To: Daniel Golle , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Cc: mithat.guner@xeront.com, erkin.bozoglu@xeront.com, Bartel Eerdekens , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, =?utf-8?q?Ar=C4=B1n=C3=A7_=C3=9CNAL?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1709289776; l=2434; i=arinc.unal@arinc9.com; s=arinc9-Xeront; h=from:subject:message-id; bh=Lk4340C7GwrRpdUGlGvETd3f0JsF8UjRCdCF02XBua4=; b=UFudaq/QD+WxDRhDFOF14id6HYvCGEsmKQCDhlW4fp3Ns3/BchHbNue0R2ECqZJDdK0eCfeVT zR5NRb3Y2HeCfkGFSPZDRnPbva00Cun3Ki9O89cEU4ZvtTVlM/aEDBu X-Developer-Key: i=arinc.unal@arinc9.com; a=ed25519; pk=z49tLn29CyiL4uwBTrqH9HO1Wu3sZIuRp4DaLZvtP9M= X-Endpoint-Received: by B4 Relay for arinc.unal@arinc9.com/arinc9-Xeront with auth_id=137 X-Original-From: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= Reply-To: From: Arınç ÜNAL port_enable and port_disable clears the link settings. Move that to mt7530_setup() and mt7531_setup_common() which set up the switches. This way, the link settings are cleared on all ports at setup, and then only once with phylink_mac_link_down() when a link goes down. Enable force mode at setup to apply the force part of the link settings. This ensures that disabled ports will have their link down. Suggested-by: Vladimir Oltean Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 5c8ad41ce8cd..91d927bb49f7 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1018,7 +1018,6 @@ mt7530_port_enable(struct dsa_switch *ds, int port, priv->ports[port].enable = true; mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, priv->ports[port].pm); - mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK); mutex_unlock(&priv->reg_mutex); @@ -1038,7 +1037,6 @@ mt7530_port_disable(struct dsa_switch *ds, int port) priv->ports[port].enable = false; mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, PCR_MATRIX_CLR); - mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK); mutex_unlock(&priv->reg_mutex); } @@ -2257,6 +2255,12 @@ mt7530_setup(struct dsa_switch *ds) mt7530_mib_reset(ds); for (i = 0; i < MT7530_NUM_PORTS; i++) { + /* Clear link settings and enable force mode to force link down + * on all ports until they're enabled later. + */ + mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK | + PMCR_FORCE_MODE, PMCR_FORCE_MODE); + /* Disable forwarding by default on all ports */ mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK, PCR_MATRIX_CLR); @@ -2359,6 +2363,12 @@ mt7531_setup_common(struct dsa_switch *ds) UNU_FFP_MASK); for (i = 0; i < MT7530_NUM_PORTS; i++) { + /* Clear link settings and enable force mode to force link down + * on all ports until they're enabled later. + */ + mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK | + MT7531_FORCE_MODE, MT7531_FORCE_MODE); + /* Disable forwarding by default on all ports */ mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK, PCR_MATRIX_CLR); -- 2.40.1