Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp340676iog; Wed, 29 Jun 2022 00:59:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sLvnlqWH2CHTqYTRpGLD8F2XN5+yNhlAvxZQRCGG5j4B/xXfl8FuKDJIPn8z1+MFSKdrQN X-Received: by 2002:a05:6a00:4091:b0:527:b95d:6041 with SMTP id bw17-20020a056a00409100b00527b95d6041mr9053649pfb.10.1656489582548; Wed, 29 Jun 2022 00:59:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656489582; cv=none; d=google.com; s=arc-20160816; b=lZ+ZVyCIJdYqlrtAqgH5xX9XEaDtQVMsVxZWWzrdUvrnf5e8ZUXdIWLrTFDP04I9ql cpB0OU4UQR7NEpoty5tFeXhsGWJ7j/MnudRUmSX8RzQXaySyn9XMSRZCE9p+WpEL5Pex qNbe43zLgMe0APdvlETngVIZHrr/OXrXXXckADof4N7FH2nneuMpuZ5x0h2ircR5HEMV qiWXmONRzooxaGxaxHsAUwZxtmUxgnTnHCOuttFsaRtNltVIJ4I/Wpsy2k1H0gjJ1g0P 4GrdYVwKA/7CLyVNSFdlrkyW6Nx5dtx7PN0MPNvs3h17Kr5jItXo5cG1CtpK2DvtQ22j 5nDg== 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:dkim-signature; bh=udw9lHGmzoAvFePyLCTqIKD8e/mAeVeJzVZcMu5/Lq4=; b=dNbdOayswpeVtt8/YEzeZX9MTEbDvuSrxKvzMOVqkYnbUneK6YwSCnu+7ciMPVih3f uuB0g1F2JlphMBvDfxovkywhSmfEMqGO7PlBeDxBj+ROzGIVDfU3IvGlHXO6QBJBpBfN Elv7W7YJz8YBEGAnIoS+21+9gveOffVHqBHj5xkVh71wGv5EI/0qdDyLG3xmBrMAx1dy p+7DyS821mLchUu1Z+i+2Sbjz8P75Rm9AS4ag/ELEpETpLJS2aj67BJBhJoBut2dEnFx 2NFZXIWYCKFwCA99CefIKldUX/6ox52sqlNA8KQpVqaEtUguyhLNAemg+YdnfcX065Bp DL/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=j+Wgdvbg; 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 l69-20020a638848000000b0040c977c9679si20027533pgd.30.2022.06.29.00.59.28; Wed, 29 Jun 2022 00:59:42 -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=@lunn.ch header.s=20171124 header.b=j+Wgdvbg; 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 S230019AbiF2HXM (ORCPT + 99 others); Wed, 29 Jun 2022 03:23:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230516AbiF2HXG (ORCPT ); Wed, 29 Jun 2022 03:23:06 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC5C0222; Wed, 29 Jun 2022 00:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=udw9lHGmzoAvFePyLCTqIKD8e/mAeVeJzVZcMu5/Lq4=; b=j+WgdvbgwVAiXYEKAtG4WPjD0X 46phVxCdZseTfn5Sqq8rzFUj9MHWNX27GVEfZiR0NHLIGG84wfxUcMdEybxgfTXszXBobgLYgcyNU TK+U5pj9jP0tFtlxOEx/8NavELJT8zKDhgCEVxFpIERWhb+Oq7yvGRDDwejQbKGTS8Pc=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1o6S23-008gOb-QH; Wed, 29 Jun 2022 09:22:39 +0200 Date: Wed, 29 Jun 2022 09:22:39 +0200 From: Andrew Lunn To: Lukas Wunner Cc: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Heiner Kallweit , Russell King , Marek Szyprowski , Thomas Gleixner , netdev@vger.kernel.org, Steve Glendinning , UNGLinuxDriver@microchip.com, Oliver Neukum , Andre Edich , Oleksij Rempel , Martyn Welch , Gabriel Hojda , Christoph Fritz , Lino Sanfilippo , Philipp Rosenberger , Ferry Toth , Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, "Rafael J. Wysocki" Subject: Re: [PATCH net v4] net: phy: Don't trigger state machine while in suspend 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 On Tue, Jun 28, 2022 at 12:15:08PM +0200, Lukas Wunner wrote: > Upon system sleep, mdio_bus_phy_suspend() stops the phy_state_machine(), > but subsequent interrupts may retrigger it: > > They may have been left enabled to facilitate wakeup and are not > quiesced until the ->suspend_noirq() phase. Unwanted interrupts may > hence occur between mdio_bus_phy_suspend() and dpm_suspend_noirq(), > as well as between dpm_resume_noirq() and mdio_bus_phy_resume(). > > Retriggering the phy_state_machine() through an interrupt is not only > undesirable for the reason given in mdio_bus_phy_suspend() (freezing it > midway with phydev->lock held), but also because the PHY may be > inaccessible after it's suspended: Accesses to USB-attached PHYs are > blocked once usb_suspend_both() clears the can_submit flag and PHYs on > PCI network cards may become inaccessible upon suspend as well. > > Amend phy_interrupt() to avoid triggering the state machine if the PHY > is suspended. Signal wakeup instead if the attached net_device or its > parent has been configured as a wakeup source. (Those conditions are > identical to mdio_bus_phy_may_suspend().) Postpone handling of the > interrupt until the PHY has resumed. > > Before stopping the phy_state_machine() in mdio_bus_phy_suspend(), > wait for a concurrent phy_interrupt() to run to completion. That is > necessary because phy_interrupt() may have checked the PHY's suspend > status before the system sleep transition commenced and it may thus > retrigger the state machine after it was stopped. > > Likewise, after re-enabling interrupt handling in mdio_bus_phy_resume(), > wait for a concurrent phy_interrupt() to complete to ensure that > interrupts which it postponed are properly rerun. > > The issue was exposed by commit 1ce8b37241ed ("usbnet: smsc95xx: Forward > PHY interrupts to PHY driver to avoid polling"), but has existed since > forever. > > Fixes: 541cd3ee00a4 ("phylib: Fix deadlock on resume") > Link: https://lore.kernel.org/netdev/a5315a8a-32c2-962f-f696-de9a26d30091@samsung.com/ > Reported-by: Marek Szyprowski > Tested-by: Marek Szyprowski > Signed-off-by: Lukas Wunner > Acked-by: Rafael J. Wysocki > Cc: stable@vger.kernel.org # v2.6.33+ Reviewed-by: Andrew Lunn Andrew