Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2082943lqt; Mon, 22 Apr 2024 00:17:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXO2oBwerBDFKBkRSvK7biPhmsMYdmmlQKPfTPhGla2raTZE/xlcSS6ujNHeiB8NDYw69JOczMNIDEg7o9089BQICrm9+eRZMCXZfuZcg== X-Google-Smtp-Source: AGHT+IGvAGSMwrg3KdqD+FM7RpK2tomqPDlIWFLbiEQo0yc9R1UK6HAqtr8sVsBxML5KnxoeN28j X-Received: by 2002:a17:907:98d:b0:a55:adf5:e698 with SMTP id bf13-20020a170907098d00b00a55adf5e698mr3776572ejc.28.1713770246921; Mon, 22 Apr 2024 00:17:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713770246; cv=pass; d=google.com; s=arc-20160816; b=IMUfkZXvtnxUy0N+/tAN/nX6s4vNCEUewWf0RrucpsEjG1Wb4asHqUHnz1uuKRmFbt zybp2w3aBoNVggWy2zq2IrSSbEusnM3IIK0pYgvNT5iya/my3xDGdczIzNFZE9ido6Uf DhSaHhBx1+GT5G/Gdc1C7+H2C+9O934xxEHOHGLzLojc4BmKhx6J4/6YplOtyZQ3S5w7 GhypAQo213GvVMli4u1hEp6DVlGpJ2mpsQAhdLPn8qd3YbzBvazmbjtO5tOiljjxHzKy 9lWrLsOcg0KAeXWEvSQ8SpHG5rzIXZWKpMoEydVkdRbOFDaSCPJ24dy5mSZwkdnDZTOe 2RYA== 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=y2GA5iREUpEt9q5ewB3KVZRLAmeH8qUQq7PeAeNTkm+TXhDpQqvyaKT0410NuMOprA HprEa1zbv1wj7Te8pnqywJS/0MO5uOtrPQ2A03Q17T1ztyp0UaLztVY/9QKOqS4ITgKQ r/TMvLwgIYGSGLQROLRUF9+xbvp7KQ+Y/NPOuyGVTsHk8eg/xddo/l1H3q9oG/taxvQE DUGTZ819pyBqKgycqcWiA5KZkk0n9kHS14tPJEpfnTWJmX8CoeNv52VMv2ZC58dMlB0r Bam57dvztmNuESvNNxw2jnK5D8IHk8OUzFLUg3l3U7K949u8O/kSVPcY01WPQ4aPGYWE I1Sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ezpE1ScZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bt8-20020a170906b14800b00a51cf7066cesi5580789ejb.482.2024.04.22.00.17.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 00:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ezpE1ScZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152842-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 792981F221C4 for ; Mon, 22 Apr 2024 07:17:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 010D450282; Mon, 22 Apr 2024 07:15:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ezpE1ScZ" 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 E73444AECB; Mon, 22 Apr 2024 07:15:30 +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=1713770131; cv=none; b=ciIi/atuXtdNWZ6i3QpcUYKGsDzQEJZg/M8wHBAEpU4AZ1WQZXRUswAHi2gnW7Hz8y3vKu76AGmodA+iHALGWBxfB1+fHVVlBar2Z3R+SJD+wkzEmdl18SbgnuEdgnk+2w6T7ccC+iP+ntXSUNkSwhF6Hyt8tYQdeClelYJtNSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713770131; c=relaxed/simple; bh=z4CnLGKrUD1pUXLNlD1qUSpXMrxsT8sEfZkE95NlMB0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UmyXEJLq8LfHvtMRdfFH6r1Hs9J3r3/92Ro7r+MhRwNF7OYR3qFAml7I5VSoIMML8uIaMNwX6Q3iNmYxsIkzbgkfyAV3DYy9nBAWnFVHwtQ9OgYaWuCulXW9kHgGj5dqcmsTguxDJdFb2tfglqVEuIcn3mGDPJX+STf7BVvTFNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ezpE1ScZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 84D14C2BD11; Mon, 22 Apr 2024 07:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713770130; bh=z4CnLGKrUD1pUXLNlD1qUSpXMrxsT8sEfZkE95NlMB0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ezpE1ScZJCFXbxXHqCHd9SV9BHPnrxkMinxxGZn/HtpHykaf/WIebiSHLIZl2o63f QzKwkcla9+eDNOaRWMlgaXMIKkFcht/eGCJ7EYYMpAH+kuCRPQ2XjbI37kAZlDQtEw /9HrEO8hSdqE+EP/KEieeOP+1r03rvgUD/XFKdujWpAh8mHkCHsQVFh9vxvQMcH2pY UkUpa4mCsWZGqFhhrglbGFGYYi6u9p0qQg/UOeEwV2XKG/FZmAA6E2ED92Mn1ro6Uy LKA4LJV7JT8SzDgfGjEYrjra5bdEPwcuWk42P3prB0zqOoHrQhsTMROK21OE/6u/Rd 74AKgfl4qnbSA== 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 7139AC07E8F; Mon, 22 Apr 2024 07:15:30 +0000 (UTC) From: =?utf-8?q?Ar=C4=B1n=C3=A7_=C3=9CNAL_via_B4_Relay?= Date: Mon, 22 Apr 2024 10:15:08 +0300 Subject: [PATCH net-next v2 01/15] 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: <20240422-for-netnext-mt7530-improvements-4-v2-1-a75157ba76ad@arinc9.com> References: <20240422-for-netnext-mt7530-improvements-4-v2-0-a75157ba76ad@arinc9.com> In-Reply-To: <20240422-for-netnext-mt7530-improvements-4-v2-0-a75157ba76ad@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=1713770127; l=3406; i=arinc.unal@arinc9.com; s=arinc9-Xeront; h=from:subject:message-id; bh=1dA5Tqo1oiLbTJdCrnbheqEyfiDY3WFrwARn+Ftc72o=; b=VtnuvYkOYN+vEkQPGT+08Dj8e91SfG1jvR2MB7fvYI4pfbzc+KCifP2+OI09UraHx7ga76W0i BmPeae9oPLBBPCT+uxq7/ZYsXjP47z7C5SjOZDfqp7Be7WI3T9ZJQpq 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