From patchwork Fri Mar 1 10:43:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTCB2aWEgQjQgUmVsYXk=?= X-Patchwork-Id: 208767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp990690dyb; Fri, 1 Mar 2024 02:45:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXsbZQ+N2FI5I7rwmWlcmTz7pw3e1gfAZXkLH2UtDK1+kETTfziV/xE9+t52MtcgigyjDRPGBtA/IN7qI8lJWHWBavsJw== X-Google-Smtp-Source: AGHT+IFxqvx9akfJz0okE4NYrBfjc7SuGhwwLLyGejrO8+EykVFhju3jXWVw9CNpJv2tzLjRfhj3 X-Received: by 2002:a17:90a:3004:b0:299:6389:2961 with SMTP id g4-20020a17090a300400b0029963892961mr1215796pjb.13.1709289936645; Fri, 01 Mar 2024 02:45:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709289936; cv=pass; d=google.com; s=arc-20160816; b=rg/HdwqRbdhLe4iaTR2plwCpgn9I/8iHni7HNfy589WHeDJRCQ7ffj6CLKj4cOIfYg pTCJsL2fFAkNqZ8zDaD7DE4B5bVHZ6q8J1g1+LTuYNoHIsfVebdEhwvlzgbpbyXjxNFz +r0X+oEYXVhNzOoQC/vzXydORO+r/zrAFMOZlAQG8Ilm+QJpGpgbf0pMLOWHXoIpUU0e fFGMSwS7mnxa1jy2Pw4XtFoiJAekhgv5VjY//NCR7/Dh8SD+C7/jimh1oDhDJIrfCWqi CnG00DcYozfaVADIPOD3TLIENJiJhNVPKWOBFZCZK54gs9sfYDisxpX/q8H2lPvn0ij0 zrZQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88276-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id pv13-20020a17090b3c8d00b0029b2c7b7b9asi131894pjb.120.2024.03.01.02.45.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:45:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88276-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88276-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 77E9E283BF6 for ; Fri, 1 Mar 2024 10:45:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5397370ADB; Fri, 1 Mar 2024 10:43:05 +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 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?b?QXLEsW7DpyDDnE5BTA==?= 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: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792320404861638388 X-GMAIL-MSGID: 1792320404861638388 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);