Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3406303rwa; Tue, 23 Aug 2022 04:22:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+n9JoMT78IjXb6PKk35ZHhGw94PveX+E1vSF3VKLP05cd7aNZ6nVcf3qkwNwS4E6KVfki X-Received: by 2002:a17:90a:7f89:b0:1fa:ad33:7289 with SMTP id m9-20020a17090a7f8900b001faad337289mr2766326pjl.173.1661253721034; Tue, 23 Aug 2022 04:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253721; cv=none; d=google.com; s=arc-20160816; b=Y4h0mMmrKuJgXhY6AqHLusfBrI5DOuUphfa+E9uqwY2rfnyYkQu6lhQ7QLCVLQhQmm V3gTCgORNwi71tpj4EM8rEcQcTl6UM676bqQZjWBX9XPmGUPBDJ2YcdTlDfmCRjLdIlC 5Y61rKWwAlnfFuJoJgAgrYBTsOyVeWo1puBCxkP3rnzBuF4wsWbomZuHf5OjRF1+ctjv 1omWT+ooFmcBssE9dolQVXN2RBCYhoH1K2A8WJmQeHQP8WAZTYyxffV/V7be1uQ2Vmbh mKK5uEJmO6le76ERLTR3nBPJ5C5HVL/DYa9mvGtHDN8DQ8G4z8fAGlZ0+HJSvAg+eU7I pK6A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l+Anz7qx1r0diKGKggAo2d/PPqKLi6LeezGjX1039go=; b=d8PH9eypAMatFoMTtlpJq10GbYPFMQwvu9AGC00UnQ9kTQGpLk/OA/T8h7/+fEnShD syh9+9nmSlM9gKvZDM2f4jahWTgebySxRNE7IuMRosaXsFRL715Uq71KWLiWM9ww1ySW 1tf9PdCTkk7nuzF0ZhwYDNQY/+tr8rv54UGUAkNZLfg++FwsAsd21rwGJ8doMBxJ0a58 JAfXgvT5I1ayg2mbTja5Q02GWtZXXKa/YiDnWULayrRlmc7zF0fr78+wQ5Rw+8AJpGDi kflE+tfUkYlcv6VEwrVp6NMONZtdpBzxkRi0xc1SkNla+bg9wM2AjzkOAlPESi+yUpVt PKcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iuSnnJ9a; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo5-20020a17090b1c8500b001f311d42a69si11550779pjb.41.2022.08.23.04.21.49; Tue, 23 Aug 2022 04:22:01 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iuSnnJ9a; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242965AbiHWJtB (ORCPT + 99 others); Tue, 23 Aug 2022 05:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352489AbiHWJq3 (ORCPT ); Tue, 23 Aug 2022 05:46:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 763909080D; Tue, 23 Aug 2022 01:43:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7F93361377; Tue, 23 Aug 2022 08:43:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DDD5C433D6; Tue, 23 Aug 2022 08:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244219; bh=MKtkNLnOpsU+iTzTYMESxp1iv6KPokCGsvYIOzSz0VY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iuSnnJ9ana6Bf9BjQ0Hv7b1WxSZCZCchijVrFoihWazp9Y2+1itKBjZPHS0pq/d71 +tojy+f0Ft3WJUdMfeGxM9/hQijg+0GBLIkkRfvBcMt8+M/uQdRjTXsu01BChgOTQW fbSXC+Z3nFiBZVbgLqbVEPLT7wG4TaI2EiXlhkpw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Jakub Kicinski Subject: [PATCH 5.15 058/244] net: phy: Warn about incorrect mdio_bus_phy_resume() state Date: Tue, 23 Aug 2022 10:23:37 +0200 Message-Id: <20220823080101.009863270@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Florian Fainelli commit 744d23c71af39c7dc77ac7c3cac87ae86a181a85 upstream. Calling mdio_bus_phy_resume() with neither the PHY state machine set to PHY_HALTED nor phydev->mac_managed_pm set to true is a good indication that we can produce a race condition looking like this: CPU0 CPU1 bcmgenet_resume -> phy_resume -> phy_init_hw -> phy_start -> phy_resume phy_start_aneg() mdio_bus_phy_resume -> phy_resume -> phy_write(..., BMCR_RESET) -> usleep() -> phy_read() with the phy_resume() function triggering a PHY behavior that might have to be worked around with (see bf8bfc4336f7 ("net: phy: broadcom: Fix brcm_fet_config_init()") for instance) that ultimately leads to an error reading from the PHY. Fixes: fba863b81604 ("net: phy: make PHY PM ops a no-op if MAC driver manages PHY PM") Signed-off-by: Florian Fainelli Link: https://lore.kernel.org/r/20220801233403.258871-1-f.fainelli@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/phy_device.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -315,6 +315,12 @@ static __maybe_unused int mdio_bus_phy_r phydev->suspended_by_mdio_bus = 0; + /* If we managed to get here with the PHY state machine in a state other + * than PHY_HALTED this is an indication that something went wrong and + * we should most likely be using MAC managed PM and we are not. + */ + WARN_ON(phydev->state != PHY_HALTED && !phydev->mac_managed_pm); + ret = phy_init_hw(phydev); if (ret < 0) return ret;