Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7999866rwr; Wed, 10 May 2023 16:17:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ480SAyHa0mQ8zfditWrUD+NidgAeI1Xh9K6eQ+8tAuqbmCA3HduOpS990Qcb+klUlsZlcm X-Received: by 2002:a17:90b:1d87:b0:247:9d19:311f with SMTP id pf7-20020a17090b1d8700b002479d19311fmr19246378pjb.30.1683760623570; Wed, 10 May 2023 16:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683760623; cv=none; d=google.com; s=arc-20160816; b=A4Ps+Jq8ZDEUF+qlHga/fC0LQAWwccB94JIo4CAsKdN5mlO0sZZOWMX+a4D5EDfyUJ fn1QnQVJGbBCLe88mn6M3vhA2IAFaAow2ygMfyhds16P/QfzAnUKLdWP72dhdAX7a4RW hwM+j7s4fqlfLlW75sMLFxxUiepzpVXBLv2Nq9qx8pr4+TI8ajFVWaRTiEsGO+36+12e e2qJOp5Qfo8HolkMbgeQMLsV19xsbL5rGRn3JHeS2xhMZ1YsaAkcSxcnQKdexuxxygkz pdLLhoqNF3HSA71SwxIvX1R1aBe23tv9lErQZzc9fTeHDg6a3C44Ds24ryTy38Gk0EKY r20g== 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:to:from:date; bh=GIiS0fWEVQ/Ll22Lnm0hVFBDGpomp5UcSojoTi9HQnU=; b=Sqn/V3lOX/QFJ4wdbcW1e4R0ctaDZnmR6W9s9UMt98+dCb65mWLnpNKObNRcZu85gS 8MfRA0LUQ0pf34/LdFEmo9RPVwEOrO9k4QKuF6sbgG6QCWYRxmSwWndy2YTXl7vNdcUQ ZIfyOpmTR5a75v87aTtl3GWFTDg4NQkPiP5zB2sSVOhTl6xxJYgMtlMo2d9XRFzoysAd QZoTDaXoXxqZqXiDOafKKrAFawWGSckWbaPJ71w4rtOS1YAtMvTLL1k4lyPsVAVE23Vq xSQMHGpat4J2zPjylXOFHmFDjVaBprz2A9qkKq0JFRT9iv6dzYF9+t+WhYOX54GCK5B9 mZMA== 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 pc11-20020a17090b3b8b00b002507cbb009bsi9958768pjb.112.2023.05.10.16.16.50; Wed, 10 May 2023 16:17:03 -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 S236716AbjEJXAs (ORCPT + 99 others); Wed, 10 May 2023 19:00:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236637AbjEJXAr (ORCPT ); Wed, 10 May 2023 19:00:47 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0A6610F5; Wed, 10 May 2023 16:00:39 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pwsnU-0004Uo-0h; Wed, 10 May 2023 23:00:36 +0000 Date: Thu, 11 May 2023 00:58:42 +0200 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , AngeloGioacchino Del Regno Subject: [PATCH net-next 5/8] net: phy: realtek: make sure paged read is protected by mutex Message-ID: 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 As we cannot rely on phy_read_paged function before the PHY is identified, the paged read in rtlgen_supports_2_5gbps needs to be open coded as it is being called by the match_phy_device function, ie. before .read_page and .write_page have been populated. Make sure it is also protected by the MDIO bus mutex and use rtl821x_write_page instead of 3 individually locked MDIO bus operations. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index acadb6f0057b..e6a46c4d97b1 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -744,9 +744,11 @@ static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) { int val; - phy_write(phydev, RTL821x_PAGE_SELECT, 0xa61); - val = phy_read(phydev, 0x13); - phy_write(phydev, RTL821x_PAGE_SELECT, 0); + phy_lock_mdio_bus(phydev); + rtl821x_write_page(phydev, 0xa61); + val = __phy_read(phydev, 0x13); + rtl821x_write_page(phydev, 0); + phy_unlock_mdio_bus(phydev); return val >= 0 && val & RTL_SUPPORTS_2500FULL; } -- 2.40.0