Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3399879rwr; Sat, 22 Apr 2023 04:51:56 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0RVIOsH2C49s1tORRAm3vpjPp3IzzdjpIB3BJh628LupeeNJcV9oqhfhFeEaQ3H0n6dkR X-Received: by 2002:a17:90a:1994:b0:244:b4ea:add4 with SMTP id 20-20020a17090a199400b00244b4eaadd4mr7411070pji.3.1682164316433; Sat, 22 Apr 2023 04:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682164316; cv=none; d=google.com; s=arc-20160816; b=aHG+73YfBFuVQGNAOPWqdz2qE/zMxMOGWpR8XGlZYKRmBc33LNf8HGGOhlbciMRtI+ WEX+bXyTCZKl11+4Hwtsdidj7L4vQ0GsNr0hbAps/xKVpArmmJKcaXQ/mhGBXT+xVx2E Kqa7eErbqFyekJRxFpMRj84aF328q2OM3/4wLLy80DpHVxM8NxmEalmw1PtVU/dJDzfl z60xNJf6014JU1w32GhbSro+frYlOk/MGKwW1yZ3bFs5YFOdhOKGXv50DMolVU3T0ZzJ rXu190JHFLf2q+HLAsLtr+YaRNW1cbk/0yTNgY4vbnAd7kA1MkuoMFZMzY2TcUVMYjMm O2Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=8duXBOr5nLfeKW89wCehrCNfii4pOEpbIxD70HKnG3o=; b=dEB4kWI17lyGfXnNHtyMPo/d9pa4YFG+jF3xSmQU/OYdMvUP6QgGxFvhdIldkEqEhI EhqVDQjcwjfa2C0RgZoAiDZj+qTO2+KmxYme1ySVovAHjyo+gHYE5XuglfzeTnF8SIfi 5TzpJMOYMJ26zyYlDIkwz7qirB100ru0SclfeG2fDLVNClf9Fo0AQSwJ+3lL1TKuUiAV mz9ctssPI4RprwcyauB4/uNAVs2xEPxT0mCIHhqnYrsix4FyOFBGM1yGBEvQ0Uj7Gx2s Bj0LxJ9PmL1H7m/NJ2tMty5QblCVnlP+9aM5/jzSvgRkgt4uvVlU2iw1L4vucqOXbwfR qi/A== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw18-20020a17090b181200b002473c8f52fcsi10138144pjb.91.2023.04.22.04.51.42; Sat, 22 Apr 2023 04:51:56 -0700 (PDT) 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 S229698AbjDVLuB (ORCPT + 99 others); Sat, 22 Apr 2023 07:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjDVLt7 (ORCPT ); Sat, 22 Apr 2023 07:49:59 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9775272D; Sat, 22 Apr 2023 04:49:36 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pqBkE-00086c-2R; Sat, 22 Apr 2023 13:49:34 +0200 Date: Sat, 22 Apr 2023 12:49:30 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Chen Minqiang , Chukun Pan , Yevhen Kolomeiko , Alexander Couzens Subject: [RFC PATCH net-next 7/8] net: phy: realtek: check validity of 10GbE link-partner advertisement Message-ID: <0c3e0e665945ecc5f248438f3231ed48f92764df.1682163424.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Only use link-partner advertisement bits for 10GbE modes if they are actually valid. Check LOCALOK and REMOTEOK bits and clear 10GbE modes unless both of them are set. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 078f45447ddad..de73049037891 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -706,6 +706,10 @@ static int rtl822x_read_status(struct phy_device *phydev) if (lpadv < 0) return lpadv; + if (!(lpadv & MDIO_AN_10GBT_STAT_REMOK) || + !(lpadv & MDIO_AN_10GBT_STAT_LOCOK)) + lpadv = 0; + mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, lpadv); } -- 2.40.0