From patchwork Mon Feb 20 13:56:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 59455 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1319683wrn; Mon, 20 Feb 2023 05:57:34 -0800 (PST) X-Google-Smtp-Source: AK7set+Yrtc6vWqyU8u5FIHpAykHrzZa19VuO+vE8DvVASLnpG7vY3NhoqhcuZ/u4fvKvz2HJv21 X-Received: by 2002:a62:19d3:0:b0:5aa:2d65:4733 with SMTP id 202-20020a6219d3000000b005aa2d654733mr1988082pfz.10.1676901453815; Mon, 20 Feb 2023 05:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676901453; cv=none; d=google.com; s=arc-20160816; b=e6EndgXab992HhQz5LZaGi0rLNthaj+ba9ACCXD2nGCOoBmg9mB3rSal8hjW4cvbLN tjLc8pWwPL+FuycYwbpuDmBYoKOBEwcQmX/ncwn9Pki8cvVTgxiUyzCzds5XgcHifTur Km5jcJ0lnU0EBchn16OWGP7baaqqxfBS/nnp+9qVfJGuOHa3t3x+zzkUSVeRkYOfo/gt VFbRPhA+N+b3G2BSw7gS4sWrzhKDY+juZLnmnjx4XznuEyxZMxIwIgAfXMrRRM1k15Lw emWzKcglb3C12Dr7c4/iuz6LfadKJiu5YL8jZSNRwA8Hsm1Df3Y5NzKG6vkSEv41EFQH ybtA== 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; bh=sQgQUYFmKtq7cke5AC6TAgfNsc1xsu9QIaIQ/i/x/n8=; b=0Ppo/TRlMOaL8LPEdzy2ORgR3vyBkMhr2W1hqYByvudvL0cHpw66aLUQogDASNzsMe WAkb9bE5deZobvRWLrsfd90o1M1aIuOCoAM0nKKonNmPjVM53nA8mgZvdBOtDKczmpJC zHnMsEujcWq0FwrtH/LrCLeEyaLRCpmIDAPBNTi0mnAM3DyhSlRA9xtWBl59kK00yVnH aIgsvwb0KaYmJs5KXapSRSbphF8dLhh8LZbETEjCtEJdBduaBo9lQS3ulVM7aRV21AbN 2H/tAFQpFY5fyz/iLKVVtvv0cHT2mYSA6O7nFQcV8BjkDTTHigv/a7+04uXQYxrE4rSq Rkvw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a8-20020aa78e88000000b005a8b534dbccsi14038082pfr.339.2023.02.20.05.57.21; Mon, 20 Feb 2023 05:57:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232653AbjBTN5A (ORCPT + 99 others); Mon, 20 Feb 2023 08:57:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232615AbjBTN4v (ORCPT ); Mon, 20 Feb 2023 08:56:51 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA61B1EBFC for ; Mon, 20 Feb 2023 05:56:28 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU6eG-0006kz-QY; Mon, 20 Feb 2023 14:56:08 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pU6eE-006HMS-Jz; Mon, 20 Feb 2023 14:56:07 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pU6eE-004lZt-4r; Mon, 20 Feb 2023 14:56:06 +0100 From: Oleksij Rempel To: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Russell King Subject: [PATCH net-next v1 1/4] net: phy: c45: use "supported_eee" instead of supported for access validation Date: Mon, 20 Feb 2023 14:56:02 +0100 Message-Id: <20230220135605.1136137-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230220135605.1136137-1-o.rempel@pengutronix.de> References: <20230220135605.1136137-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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?1758358618639082268?= X-GMAIL-MSGID: =?utf-8?q?1758358618639082268?= Make use we use proper variable to validate access to potentially not supported registers. Otherwise we will get false read/write errors. Fixes: 022c3f87f88e ("net: phy: add genphy_c45_ethtool_get/set_eee() support") Signed-off-by: Oleksij Rempel Reviewed-by: Russell King (Oracle) --- drivers/net/phy/phy-c45.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index f9b128cecc3f..f23cce2c5199 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -674,7 +674,7 @@ int genphy_c45_write_eee_adv(struct phy_device *phydev, unsigned long *adv) { int val, changed; - if (linkmode_intersects(phydev->supported, PHY_EEE_CAP1_FEATURES)) { + if (linkmode_intersects(phydev->supported_eee, PHY_EEE_CAP1_FEATURES)) { val = linkmode_to_mii_eee_cap1_t(adv); /* In eee_broken_modes are stored MDIO_AN_EEE_ADV specific raw @@ -726,7 +726,7 @@ static int genphy_c45_read_eee_adv(struct phy_device *phydev, { int val; - if (linkmode_intersects(phydev->supported, PHY_EEE_CAP1_FEATURES)) { + if (linkmode_intersects(phydev->supported_eee, PHY_EEE_CAP1_FEATURES)) { /* IEEE 802.3-2018 45.2.7.13 EEE advertisement 1 * (Register 7.60) */ @@ -762,7 +762,7 @@ static int genphy_c45_read_eee_lpa(struct phy_device *phydev, { int val; - if (linkmode_intersects(phydev->supported, PHY_EEE_CAP1_FEATURES)) { + if (linkmode_intersects(phydev->supported_eee, PHY_EEE_CAP1_FEATURES)) { /* IEEE 802.3-2018 45.2.7.14 EEE link partner ability 1 * (Register 7.61) */ From patchwork Mon Feb 20 13:56:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 59454 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1319579wrn; Mon, 20 Feb 2023 05:57:17 -0800 (PST) X-Google-Smtp-Source: AK7set9o7vfShZ3f4bDm3Jm0EmF6nenh81ZoY/9fYzwd+6TEO0M5IkfNjBmXRkyiiApO6tFUWBt+ X-Received: by 2002:a05:6a20:1585:b0:bf:a1c:3ff0 with SMTP id h5-20020a056a20158500b000bf0a1c3ff0mr1050897pzj.52.1676901436714; Mon, 20 Feb 2023 05:57:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676901436; cv=none; d=google.com; s=arc-20160816; b=oHqZgmeLyaXDF3iMgucF1i5GXGZEZhwHcJce7W7o3Chb286zAnFE+4VVmp93i3/9NK aOqJRbt+bQDMy/pkqXidi/hLU1leGl3ZSEBzeVurEHnK9ez3XpU9Hi7Ef69DnwbpKAZV euBiiDY866nHB101n7uAgw+qcMH19xTes66dSb/qCDkVcEouESE7rU91pO+fawsHynQN vB+fQQdl/VuDZdBLZYWA99RFVeTcOftQt9eMOVB0xyV0BEQZ0dUtfT3KqSnqZFrmaRWy qoCfST6ZXTSMrw48ZvA2gx3yNwuKkGwNlkbgKuHqEg8ip9Y9p5wnEqsFGpeBppxeYxa2 0cdQ== 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; bh=OF765ZijefYZ3N52vBrpZH3p+SQNejt9iBxapRpX1UA=; b=f7LR18oy0ETVNBVADKKSCagBtyWjEKiU5tWJ/0k4i4KlkzAyhKdhYZgrHBy1EPppH0 Bgp73apeYiCUG1SZnvzljO7XsSEMdtGpJwsLtcjdreFJLKO4Wlc9XhD5L2s0HV3qZf/V +97r7DyRQJVsNfDx+aVkyj6uIvcA8NGxSYIMjP1Aj7gs+wenC8yfXN56Clq8YeK0fTzK aJx5WxmPCPZVjl4fRZUlSz9XYawIRa81Cf13IrN5YYd2lToKDTs2b0CiA4IhBCbKp6T0 FU/Jk9eejWSJ/xHLu4AUByT+0NMD4cZhW0VcCHVMEcgO/fghD1JBFJDLLWTY0L7Taj+1 NIcw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a654145000000b004facc8ab172si13578221pgp.846.2023.02.20.05.57.04; Mon, 20 Feb 2023 05:57:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232623AbjBTN4x (ORCPT + 99 others); Mon, 20 Feb 2023 08:56:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232608AbjBTN4u (ORCPT ); Mon, 20 Feb 2023 08:56:50 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B63C81EBF5 for ; Mon, 20 Feb 2023 05:56:26 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU6eG-0006km-QX; Mon, 20 Feb 2023 14:56:08 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pU6eE-006HMP-Hq; Mon, 20 Feb 2023 14:56:07 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pU6eE-004la2-5X; Mon, 20 Feb 2023 14:56:06 +0100 From: Oleksij Rempel To: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Russell King Subject: [PATCH net-next v1 2/4] net: phy: c45: add genphy_c45_an_config_eee_aneg() function Date: Mon, 20 Feb 2023 14:56:03 +0100 Message-Id: <20230220135605.1136137-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230220135605.1136137-1-o.rempel@pengutronix.de> References: <20230220135605.1136137-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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?1758358600776213372?= X-GMAIL-MSGID: =?utf-8?q?1758358600776213372?= Add new genphy_c45_an_config_eee_aneg() function and replace some of genphy_c45_write_eee_adv() calls. This will be needed by the next patch. Signed-off-by: Oleksij Rempel Reviewed-by: Russell King (Oracle) --- drivers/net/phy/phy-c45.c | 12 +++++++++++- drivers/net/phy/phy_device.c | 2 +- include/linux/phy.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index f23cce2c5199..904f64818922 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -262,7 +262,7 @@ int genphy_c45_an_config_aneg(struct phy_device *phydev) linkmode_and(phydev->advertising, phydev->advertising, phydev->supported); - ret = genphy_c45_write_eee_adv(phydev, phydev->supported_eee); + ret = genphy_c45_an_config_eee_aneg(phydev); if (ret < 0) return ret; else if (ret) @@ -858,6 +858,16 @@ int genphy_c45_read_eee_abilities(struct phy_device *phydev) } EXPORT_SYMBOL_GPL(genphy_c45_read_eee_abilities); +/** + * genphy_c45_an_config_eee_aneg - write advertised EEE link modes + * @phydev: target phy_device struct + * @adv: the linkmode advertisement settings + */ +int genphy_c45_an_config_eee_aneg(struct phy_device *phydev) +{ + return genphy_c45_write_eee_adv(phydev, phydev->supported_eee); +} + /** * genphy_c45_pma_read_abilities - read supported link modes from PMA * @phydev: target phy_device struct diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8d927c5e3bf8..0c47665effaf 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2231,7 +2231,7 @@ int __genphy_config_aneg(struct phy_device *phydev, bool changed) { int err; - err = genphy_c45_write_eee_adv(phydev, phydev->supported_eee); + err = genphy_c45_an_config_eee_aneg(phydev); if (err < 0) return err; else if (err) diff --git a/include/linux/phy.h b/include/linux/phy.h index 727bff531a14..19d83e112beb 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1765,6 +1765,7 @@ int genphy_c45_ethtool_get_eee(struct phy_device *phydev, int genphy_c45_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); int genphy_c45_write_eee_adv(struct phy_device *phydev, unsigned long *adv); +int genphy_c45_an_config_eee_aneg(struct phy_device *phydev); /* Generic C45 PHY driver */ extern struct phy_driver genphy_c45_driver; From patchwork Mon Feb 20 13:56:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 59453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1319563wrn; Mon, 20 Feb 2023 05:57:14 -0800 (PST) X-Google-Smtp-Source: AK7set+2SxX+SHhVHs/ekAzJCwYQ63B8R39a57TeP7QIoYdc4oN9BCaH+HRV28senFwxVfZVIf9Y X-Received: by 2002:a05:6a21:6d9f:b0:c7:8779:4168 with SMTP id wl31-20020a056a216d9f00b000c787794168mr1480570pzb.62.1676901434474; Mon, 20 Feb 2023 05:57:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676901434; cv=none; d=google.com; s=arc-20160816; b=NiivlVkeqil/uYtLinkaMzrOsVUtBKtW6kbyf0wdBk6lX2BVlyMIHU2HzD46RHth0C Yju0FcGOPDRCrrrnmyIm6Sa+AoYZqzIimGhurMSToR6UibmtYjd14fyfTMm0kU4oN/Ln 6nuVnKXtlZbrngcosB0heqUDxefEY/d2xiY5MnNg25r3f18w7RHKR5WdXRSsFhpSUCyP XU0ZCN4Cu3Y+/qo78tODDSyrcwRi4vYeYC2IEgKh3/Iv4ZD+kZV3eUH/igyNAA761fx+ GihfzzCPvejrTV/0rBzmsI0kVkSlnmI6UB3aWVRIXMDJ4gdDWUYb8U1o5lM5PoBdhUSN Ebyg== 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; bh=1oytaz0IfMM+GGeEJzcfFckDcfCr0ag2N82dbzs+Xa4=; b=e1TpY8/kTVhsu6jV6M2zEnuYSj6cm+BF/UH2YDyjphtBkig9oqoJB/SSxqBRxCLsgy LbHFgjeC5o7+LmMvRlsOxQ8hmhgxe8tPXkIPv6aj3fuuh9hcb1SBLJQC6acRgk9uQ0w4 E77rbNPSnbj6ooF22cy/93bW4eoTxL+6xh7Syb+6vB+IoAR1h9JWc1K0+v1I+6WcZlfm mkmUCuP1PI/vBzpsWEPXywB40sM0rE2OtAR4Vy1YNg8MlZZF2RYZf+XLhZW6i1EST4Wi 0FUrdR1xhnL99y12R5j0+sMt4fM6K7UlHlM40vjqqQlT7CTE7H828Eia9ekqD5sO3vSj n+YA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k78-20020a628451000000b005989f8de851si14312261pfd.149.2023.02.20.05.57.02; Mon, 20 Feb 2023 05:57:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232616AbjBTN4v (ORCPT + 99 others); Mon, 20 Feb 2023 08:56:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232572AbjBTN4s (ORCPT ); Mon, 20 Feb 2023 08:56:48 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FCC61EBED for ; Mon, 20 Feb 2023 05:56:24 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU6eG-0006kU-QX; Mon, 20 Feb 2023 14:56:09 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pU6eE-006HMM-6t; Mon, 20 Feb 2023 14:56:07 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pU6eE-004laB-6D; Mon, 20 Feb 2023 14:56:06 +0100 From: Oleksij Rempel To: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Russell King Subject: [PATCH net-next v1 3/4] net: phy: do not force EEE support Date: Mon, 20 Feb 2023 14:56:04 +0100 Message-Id: <20230220135605.1136137-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230220135605.1136137-1-o.rempel@pengutronix.de> References: <20230220135605.1136137-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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?1758358598513017025?= X-GMAIL-MSGID: =?utf-8?q?1758358598513017025?= With following patches: commit 9b01c885be36 ("net: phy: c22: migrate to genphy_c45_write_eee_adv()") commit 5827b168125d ("net: phy: c45: migrate to genphy_c45_write_eee_adv()") we set the advertisement to potentially supported values. This behavior may introduce new regressions on systems where EEE was disabled by default (BIOS or boot loader configuration or by other ways.) At same time, with this patches, we would overwrite EEE advertisement configuration made over ethtool. To avoid this issues, we need to cache initial and ethtool advertisement configuration and store it for later use. Fixes: 9b01c885be36 ("net: phy: c22: migrate to genphy_c45_write_eee_adv()") Fixes: 5827b168125d ("net: phy: c45: migrate to genphy_c45_write_eee_adv()") Fixes: 022c3f87f88e ("net: phy: add genphy_c45_ethtool_get/set_eee() support") Signed-off-by: Oleksij Rempel Reviewed-by: Russell King (Oracle) --- drivers/net/phy/phy-c45.c | 20 ++++++++++++-------- drivers/net/phy/phy_device.c | 19 +++++++++++++++++++ include/linux/phy.h | 5 +++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 904f64818922..974d6e96fc71 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -721,8 +721,7 @@ int genphy_c45_write_eee_adv(struct phy_device *phydev, unsigned long *adv) * @phydev: target phy_device struct * @adv: the linkmode advertisement status */ -static int genphy_c45_read_eee_adv(struct phy_device *phydev, - unsigned long *adv) +int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv) { int val; @@ -865,7 +864,12 @@ EXPORT_SYMBOL_GPL(genphy_c45_read_eee_abilities); */ int genphy_c45_an_config_eee_aneg(struct phy_device *phydev) { - return genphy_c45_write_eee_adv(phydev, phydev->supported_eee); + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {}; + + if (!phydev->eee_enabled) + return genphy_c45_write_eee_adv(phydev, adv); + + return genphy_c45_write_eee_adv(phydev, phydev->advertising_eee); } /** @@ -1431,17 +1435,17 @@ EXPORT_SYMBOL(genphy_c45_ethtool_get_eee); int genphy_c45_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data) { - __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {}; int ret; if (data->eee_enabled) { + phydev->eee_enabled = true; if (data->advertised) - adv[0] = data->advertised; - else - linkmode_copy(adv, phydev->supported_eee); + phydev->advertising_eee[0] = data->advertised; + } else { + phydev->eee_enabled = false; } - ret = genphy_c45_write_eee_adv(phydev, adv); + ret = genphy_c45_an_config_eee_aneg(phydev); if (ret < 0) return ret; if (ret > 0) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 0c47665effaf..ef2a9f079916 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3139,6 +3139,25 @@ static int phy_probe(struct device *dev) of_set_phy_supported(phydev); phy_advertise_supported(phydev); + /* Get PHY default EEE advertising modes and handle them as potentially + * safe initial configuration. + */ + err = genphy_c45_read_eee_adv(phydev, phydev->advertising_eee); + if (err) + return err; + + /* There is no "enabled" flag. If PHY is advertising, assume it is + * kind of enabled. + */ + phydev->eee_enabled = !linkmode_empty(phydev->advertising_eee); + + /* Some PHYs may advertise, by default, not support EEE modes. So, + * we need to clean them. + */ + if (phydev->eee_enabled) + linkmode_and(phydev->advertising_eee, phydev->supported_eee, + phydev->advertising_eee); + /* Get the EEE modes we want to prohibit. We will ask * the PHY stop advertising these mode later on */ diff --git a/include/linux/phy.h b/include/linux/phy.h index 19d83e112beb..36bf0bbc8efa 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -575,6 +575,8 @@ struct macsec_ops; * @advertising: Currently advertised linkmodes * @adv_old: Saved advertised while power saving for WoL * @supported_eee: supported PHY EEE linkmodes + * @advertising_eee: Currently advertised EEE linkmodes + * @eee_enabled: Flag indicating whether the EEE feature is enabled * @lp_advertising: Current link partner advertised linkmodes * @host_interfaces: PHY interface modes supported by host * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited @@ -681,6 +683,8 @@ struct phy_device { __ETHTOOL_DECLARE_LINK_MODE_MASK(adv_old); /* used for eee validation */ __ETHTOOL_DECLARE_LINK_MODE_MASK(supported_eee); + __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising_eee); + bool eee_enabled; /* Host supported PHY interface types. Should be ignored if empty. */ DECLARE_PHY_INTERFACE_MASK(host_interfaces); @@ -1766,6 +1770,7 @@ int genphy_c45_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); int genphy_c45_write_eee_adv(struct phy_device *phydev, unsigned long *adv); int genphy_c45_an_config_eee_aneg(struct phy_device *phydev); +int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv); /* Generic C45 PHY driver */ extern struct phy_driver genphy_c45_driver; From patchwork Mon Feb 20 13:56:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 59452 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1319534wrn; Mon, 20 Feb 2023 05:57:10 -0800 (PST) X-Google-Smtp-Source: AK7set8aaDpt7ecjR9MI8SHU0GIgt12qSp96ZGalEwxLUtlxiVmULHqujIMhlMfD/zz3/1RkICOV X-Received: by 2002:a17:90b:4b0a:b0:234:b35b:f905 with SMTP id lx10-20020a17090b4b0a00b00234b35bf905mr2120230pjb.2.1676901430214; Mon, 20 Feb 2023 05:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676901430; cv=none; d=google.com; s=arc-20160816; b=F2NemBG3ilJfeljGwKqZzY4MUMwlWMvUYtEOovllEG4DoANqixRmLaWX2OWW2kYW5K qu84gkDK3tQM4CP1nRzMSqqezcQdRX2edQRXW5DJnHeuEpZ925xHYG8aPPTKq4iygU2b sbfnZ2pn8yTDZv9p2L7akdYjHq1fxStz02uura33rkfkejQJL4WYlbBkwFzFJpN2W6Ky ANkPMjDz7tduG9XPWG/vO0KQeSwE05ueuqE/EwUXGyXO15Hpi+4zW+bvFjulbL4d9aIl v7g2aZ4OPJjqlXeaaTvsZ1j0T8kJr92QktMZZEjlQoYfQ1ZKgyDpROmZeOt0r45MU8GS sYlg== 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; bh=kuHfJMzaQQkLHkO2WOJv7KzmAZaxrgDV1rt3GBgeEBA=; b=tybWnNraZegnxYOoTRwmsQ1OoCYI5VrBRtbEfUn7hS7fseMivJYi1FleKkVoXe15B7 WH3eJvhOLdBwunqyLq4UesW5xfO1zXoqkLlpI6ct56IIIr8aF3imNe65WFy4Ucl7ytX5 2uMOFc8wJLjhGieM3+z1GyYrsYTtWCvSVwzKoWS6b3D+/Iun/Bd0MTGHLBigQ3KYjOn+ GJ2Aogy8vZlw0jU06mEmPQxL9WMRYJFzPwFoATxZx5fHzDV3D1WLLadhxjOKdK+nUlQK +kjFdcTImCPzJ1+SAiKB91YcXyFg6NibzwA7ycGXXQC6zCJ8xRnO+r1lJQDhVuO2+YSu JTJA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j71-20020a638b4a000000b004e931d7643asi15336396pge.707.2023.02.20.05.56.55; Mon, 20 Feb 2023 05:57:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232604AbjBTN4t (ORCPT + 99 others); Mon, 20 Feb 2023 08:56:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232600AbjBTN4r (ORCPT ); Mon, 20 Feb 2023 08:56:47 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E58A51EBE8 for ; Mon, 20 Feb 2023 05:56:21 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU6eG-0006k3-QX; Mon, 20 Feb 2023 14:56:08 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pU6eD-006HMG-Rk; Mon, 20 Feb 2023 14:56:07 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pU6eE-004laK-6u; Mon, 20 Feb 2023 14:56:06 +0100 From: Oleksij Rempel To: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Russell King Subject: [PATCH net-next v1 4/4] net: phy: c45: genphy_c45_ethtool_set_eee: validate EEE link modes Date: Mon, 20 Feb 2023 14:56:05 +0100 Message-Id: <20230220135605.1136137-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230220135605.1136137-1-o.rempel@pengutronix.de> References: <20230220135605.1136137-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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?1758358593990615228?= X-GMAIL-MSGID: =?utf-8?q?1758358593990615228?= Currently, it is possible to let some PHYs to advertise not supported EEE link modes. So, validate them before overwriting existing configuration. Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy-c45.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 974d6e96fc71..34efade0e2c3 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -1439,8 +1439,18 @@ int genphy_c45_ethtool_set_eee(struct phy_device *phydev, if (data->eee_enabled) { phydev->eee_enabled = true; - if (data->advertised) + if (data->advertised) { + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {}; + + adv[0] = data->advertised; + linkmode_andnot(adv, adv, phydev->supported_eee); + if (!linkmode_empty(adv)) { + phydev_warn(phydev, "At least some EEE link modes are not supported.\n"); + return -EINVAL; + } + phydev->advertising_eee[0] = data->advertised; + } } else { phydev->eee_enabled = false; }