Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp530104lqt; Fri, 19 Apr 2024 03:11:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVf5gb49NxQmaF/k4a6CT1wW46dCzt6w4iMuwoU0JGhLyr9LLvXeRBhcH023FSN089u2IMCpXl5isKgOTwdhYY151PVlU+2riYlKES3dw== X-Google-Smtp-Source: AGHT+IFXJgOfsPnuoFVDYeRyHCFogeUf9+jP7xCC2kiioML1N1ry33k88qTps/iaNz7Av3Nyjsbd X-Received: by 2002:a05:6870:15:b0:22e:bace:ed96 with SMTP id a21-20020a056870001500b0022ebaceed96mr1331274oaa.15.1713521467725; Fri, 19 Apr 2024 03:11:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713521467; cv=pass; d=google.com; s=arc-20160816; b=FEBkPHGIgZNrT+6hKoHyMdpK9tmgI2eHbEVCglUOkyq+qFW7UFmzd4xGwtkWyzyx1S U0DMCV9UfY/pLDr9oAONgY0NAMQmkf9+p90tvBoMQsXce2C7gJpKvnsPdiMZUhYXjArQ SOxGpL1yfolK20W792owE8pos/7vZREasSHpq/7Y94wdWufcEwwXKORWQQ8sGPz0likM lukHEPu3hvADUjy4005XI9IsbBob23Yu1d5gEW46sr72hgAB/8vgvRFO/a9S11TXLwo2 H0wObKMj/a6b7XEZE4VjeXoCYSdmv4Ih8myJ2VUZGYvJR0ZohMOFXNo/CDdGrpac02t3 0LOg== 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=cAvkvzvAC2Sy/WrwlguS0ZDK4fs2tKHm3AEXuv7ueF4=; fh=U0oULSI5toQXwr8Cib1iIAF99txW9ytx8nrc+ZkpqGc=; b=z2OwJxKcvkU+O1nai6xMe1gd5H6WcKfc3vkD46gVca7E25pW08ijVdmFBvX3J6iDKE CI6tCWgwBj99/wc2ajqDQSjZKzpu3AINWi1H+OkcXtDo9TNNXvIUE1qkRxUvsIFDMOFF KR88v+TiMogkXvgdXRh1bf/4mxSbykRlaLOpu1/lL/yDw0WN0qv/EJieo6xfvxDRE5Yb fvSmDDclcMr3LGQ7J9gE2Eo593XMOi3NzCMgBOU2IA/THL+0g8smPPyv3Fv6kwIaaqni 2pB2zSiViGDIyxdxInV1eNllDZ8pe3N5Km7xiPXqb2q31i13Sj1nJMlcs7VSiJBIYSqX aoeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="o52V/NHw"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-151290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151290-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. [147.75.48.161]) by mx.google.com with ESMTPS id lo21-20020a056a003d1500b006eab2023cfdsi3084402pfb.157.2024.04.19.03.11.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 03:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="o52V/NHw"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-151290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151290-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 840F4B2224A for ; Fri, 19 Apr 2024 10:10:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D69918002F; Fri, 19 Apr 2024 10:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o52V/NHw" 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 C7EDB7D3E6; Fri, 19 Apr 2024 10:09:37 +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=1713521377; cv=none; b=pdyxIRCAzwC3q0E5JP3B6NnoaIZDjqZ0pWbvLIcHaAjXtxBXwkIBnsEQ+/OKy30WNhuVCBu7nznu+Ce+ZV2MoyxDen2KW9anNOHetxZm8sEUhQgwb/yobbYc+olS7+9FXM16WOJ0qoAjjeVss02VAaZ6z7K5IKLu8zMmt67r+rA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713521377; c=relaxed/simple; bh=z4CnLGKrUD1pUXLNlD1qUSpXMrxsT8sEfZkE95NlMB0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eNZinR0N/X8nsvtys9Dtn/5hR10Csddqzph43OQ4MFO5WaJG/Wpkm/guZuYqcTeLaYwPZFkX2BAEGdTQQ87Xp+9T0fVUu9KE3gBFEeA4tXKaIHtASn2kanRBYeARDqFzzrZg3zvTAO/ixVLmertgx3DZkKPCqHPTcbF93AyZZMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o52V/NHw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 77082C2BD11; Fri, 19 Apr 2024 10:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713521377; bh=z4CnLGKrUD1pUXLNlD1qUSpXMrxsT8sEfZkE95NlMB0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=o52V/NHwnruO3z3kJzNA49N2fZRIq4YlI/ultA6zQEl0QwnYJ4hEe1oxhvSLK8KUV 12c2vjVuUD6jqa9ktQPM6JbnECI670JMc0PX5MLKV5uoivrKx6SAMwkmzG5SY1Za00 YLldBadS8Z3gZhkD+ZmUfV30v35DMFzM0r1+wWJjhtoPLxsOB1zzAwx0nnZSlVh1Jr TjxyPlIhxKQVYNCyZCAqW+EfejBTQptnKEPmMhj3VVqXxArt2MTL8A0Th3TDUer96L 09EewhsD9ZC8YOVQqQtTfyM1+1AgsjPy0jiYnAVfwkHHDThksWL26D0nMUO9RQu++a TELIKt/aO0RDw== 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 60D6BC04FFE; Fri, 19 Apr 2024 10:09:37 +0000 (UTC) From: =?utf-8?q?Ar=C4=B1n=C3=A7_=C3=9CNAL_via_B4_Relay?= Date: Fri, 19 Apr 2024 13:09:24 +0300 Subject: [PATCH net-next 01/13] net: dsa: mt7530: disable EEE abilities on failure on MT7531 and MT7988 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: <20240419-for-netnext-mt7530-improvements-4-v1-1-6d852ca79b1d@arinc9.com> References: <20240419-for-netnext-mt7530-improvements-4-v1-0-6d852ca79b1d@arinc9.com> In-Reply-To: <20240419-for-netnext-mt7530-improvements-4-v1-0-6d852ca79b1d@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: Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com, 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=1713521374; l=3406; i=arinc.unal@arinc9.com; s=arinc9-Xeront; h=from:subject:message-id; bh=1dA5Tqo1oiLbTJdCrnbheqEyfiDY3WFrwARn+Ftc72o=; b=UO3hPYTxBJo1mK0GV+DML+3WC507lLVCAZaSDKCUa50HDDTamo4u6Lug3dOxyYxfuxU7+S0nj JyMPdPBjZ7ZDNOx2QVMov1G6N7F5CIQ2nMMXrw5qavBN57Jh1EiFU3l 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?q?Ar=C4=B1n=C3=A7_=C3=9CNAL?= Reply-To: arinc.unal@arinc9.com From: Arınç ÜNAL The MT7531_FORCE_EEE1G and MT7531_FORCE_EEE100 bits let the PMCR_FORCE_EEE1G and PMCR_FORCE_EEE100 bits determine the 1G/100 EEE abilities of the MAC. If MT7531_FORCE_EEE1G and MT7531_FORCE_EEE100 are unset, the abilities are left to be determined by PHY auto polling. The commit 40b5d2f15c09 ("net: dsa: mt7530: Add support for EEE features") made it so that the PMCR_FORCE_EEE1G and PMCR_FORCE_EEE100 bits are set on mt753x_phylink_mac_link_up(). But it did not set the MT7531_FORCE_EEE1G and MT7531_FORCE_EEE100 bits. Because of this, the EEE abilities will be determined by PHY auto polling, regardless of the result of phy_init_eee(). Define these bits and add them to the MT7531_FORCE_MODE mask which is set in mt7531_setup_common(). With this, there won't be any EEE abilities set when phy_init_eee() returns a negative value. Thanks to Russell for explaining when phy_init_eee() could return a negative value below. Looking at phy_init_eee(), it could return a negative value when: 1. phydev->drv is NULL 2. if genphy_c45_eee_is_active() returns negative 3. if genphy_c45_eee_is_active() returns zero, it returns -EPROTONOSUPPORT 4. if phy_set_bits_mmd() fails (e.g. communication error with the PHY) If we then look at genphy_c45_eee_is_active(), then: genphy_c45_read_eee_adv() and genphy_c45_read_eee_lpa() propagate their non-zero return values, otherwise this function returns zero or positive integer. If we then look at genphy_c45_read_eee_adv(), then a failure of phy_read_mmd() would cause a negative value to be returned. Looking at genphy_c45_read_eee_lpa(), the same is true. So, it can be summarised as: - phydev->drv is NULL - there is a communication error accessing the PHY - EEE is not active otherwise, it returns zero on success. If one wishes to determine whether an error occurred vs EEE not being supported through negotiation for the negotiated speed, if it returns -EPROTONOSUPPORT in the latter case. Other error codes mean either the driver has been unloaded or communication error. In conclusion, determining the EEE abilities by PHY auto polling shouldn't result in having any EEE abilities enabled, when one of the last two situations in the summary happens. And it seems that if phydev->drv is NULL, there would be bigger problems with the device than a broken link. So this is not a bugfix. Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 94932c3dbde9..f7c5355c1642 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -328,11 +328,15 @@ enum mt7530_vlan_port_acc_frm { #define MT7531_FORCE_DPX BIT(29) #define MT7531_FORCE_RX_FC BIT(28) #define MT7531_FORCE_TX_FC BIT(27) +#define MT7531_FORCE_EEE100 BIT(26) +#define MT7531_FORCE_EEE1G BIT(25) #define MT7531_FORCE_MODE (MT7531_FORCE_LNK | \ MT7531_FORCE_SPD | \ MT7531_FORCE_DPX | \ MT7531_FORCE_RX_FC | \ - MT7531_FORCE_TX_FC) + MT7531_FORCE_TX_FC | \ + MT7531_FORCE_EEE100 | \ + MT7531_FORCE_EEE1G) #define PMCR_LINK_SETTINGS_MASK (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \ PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \ PMCR_TX_FC_EN | PMCR_RX_FC_EN | \ -- 2.40.1