From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 439262139D4; Fri, 28 Jun 2024 08:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719564521; cv=none; b=X9JsLWq0H6mygTjMk5R8BCm1AGz7yhqnYjcZtF7isoAbDnW5Iyj1Y4Ihiq3Taw/Yc1YF3GrXlKgb7lFzxygniy+XNgJzisLuYE0T9AykxhJCFJpWF6KClx/UeKnsruHbFr9l+sAwdId6/nDxAB+hKCAXYvhXNsxiDdbKLm43t+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719564521; c=relaxed/simple; bh=A6px550VytGofjT3+jVBAMJXX1t+sC2mLVSUSTZRS8I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=OYOT393kH1bq/Evv0EykwhdimXLSKLsyRs6jCLx9k6rQbDbNZW2TiqYnB/jTlLkQohwJLkjC3Ha2qaBhY72XqX07ekpceOT7JCeizZodSompeycBFaOWYycTRv55oZ8HhIt9ICbC2PQ4I0OwmOFTudGZfmSLNiNzTfWYwxx10YY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B0anQbRd; arc=none smtp.client-ip=209.85.222.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B0anQbRd" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-79c084adaf4so25003085a.0; Fri, 28 Jun 2024 01:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719564519; x=1720169319; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=FC5inub+a2gTo101EG65k6awbFwbIe494mAOJlTq0k8=; b=B0anQbRdRuKLHGpScAOK621qdSaw+cF017tNcw1wjVQyvsf1A5LDfX5BLXooaOXS3S XOYhzdfgkwofRsjjI3ZDtia2k9iYU3bWIDcIRT/GT//3YNcDllhDqaOm2qs7VM6TTmYW m62RYMAe8xV6xm71+WW/oJbVqXncfFIJS6YzMt1dTCFS80TKdZPW4xQznLRw7uOU6LnO eUSEJMMADKLTQCRgZ/Jj5UZjEy5X5tEVAFA9W1lhvWXA4ClrRxPd/4fO3u8RvvyYU12e e2mdbWT+O9dArDuFPNehQu6iXicuJMgBV20WqRkwy32aH/V7WnSRtDlJkAOyaNWMdYof /dVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719564519; x=1720169319; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FC5inub+a2gTo101EG65k6awbFwbIe494mAOJlTq0k8=; b=XrY44ih4yo7lbZy/PHjznh5GxBxRJeVU8W+9/m2DfMoYWbugAWGT2Pp04V3NEW4u4G RWAMgkksleQjvYaoeTuS2qsp5AHOmwDFBiHhfX8sgMH3r52tQVYvB3NLhP1TQA4yj6H0 TMc1z+cReQvD7/1KF7wTa3CD5+t8hmMgPWvWYTMyVZM/DWDNi7aKa74+ydKnpXDAnbO1 S0PA6jsIUCj9/Be1N04HdXj0pvbi2RCt1KQTnnaG8Fni40lMF0CmuDeZ5YlcHlFMB19W 6DBShs58jLRmnwmfL0EIT9tI+KLSIZvsT7G+K+8WJIJ88XRqTbSArHuKzl+90J2UlXaX PwQA== X-Forwarded-Encrypted: i=1; AJvYcCWQJn+hxiuuXPp/sscZBfkaKwuCpYcH4Ms0BTP/UyHwN12ycXgxQKH3rux5+TExQmmAUeS75z64FdIEBrJPrPjc8Yvc95LAFbGfYIZghQ17gTg76sgz9lvYj7uCtTjOiIo5G/at X-Gm-Message-State: AOJu0YxX7sA6CYf9okUG7Es+RRChDsNcdHAiH4Z9a29c87+rZ5F4otLq c7Gvvfpn8LXY9HfQ/sfDFeIgWO4mqyVgCdeDvug3FisH57WKTnR3 X-Google-Smtp-Source: AGHT+IEPNxHOG1Ol9emvU7ROgWNd/bp8LmGHMbFRD0zXeZVqdhJ8tRao5DUAIa+tpnrPb0FVhQxDpw== X-Received: by 2002:a05:6214:d63:b0:6b2:b060:c7d3 with SMTP id 6a1803df08f44-6b540aaa499mr246008546d6.52.1719564518914; Fri, 28 Jun 2024 01:48:38 -0700 (PDT) Received: from [192.168.3.22] (89-145-235-100.xdsl.murphx.net. [89.145.235.100]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b59e5f3693sm6137886d6.96.2024.06.28.01.48.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jun 2024 01:48:38 -0700 (PDT) Message-ID: <76b863f1-1e5f-4d7c-9f39-aabb35865f69@gmail.com> Date: Fri, 28 Jun 2024 09:48:34 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net: phy: phy_device: fix PHY WOL enabled, PM failed to suspend To: "Russell King (Oracle)" Cc: Youwan Wang , andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240628060318.458925-1-youwan@nfschina.com> <249879ad-aa97-452c-a173-65255818d2d4@gmail.com> Content-Language: en-US From: Florian Fainelli Autocrypt: addr=f.fainelli@gmail.com; keydata= xsDiBEjPuBIRBACW9MxSJU9fvEOCTnRNqG/13rAGsj+vJqontvoDSNxRgmafP8d3nesnqPyR xGlkaOSDuu09rxuW+69Y2f1TzjFuGpBk4ysWOR85O2Nx8AJ6fYGCoeTbovrNlGT1M9obSFGQ X3IzRnWoqlfudjTO5TKoqkbOgpYqIo5n1QbEjCCwCwCg3DOH/4ug2AUUlcIT9/l3pGvoRJ0E AICDzi3l7pmC5IWn2n1mvP5247urtHFs/uusE827DDj3K8Upn2vYiOFMBhGsxAk6YKV6IP0d ZdWX6fqkJJlu9cSDvWtO1hXeHIfQIE/xcqvlRH783KrihLcsmnBqOiS6rJDO2x1eAgC8meAX SAgsrBhcgGl2Rl5gh/jkeA5ykwbxA/9u1eEuL70Qzt5APJmqVXR+kWvrqdBVPoUNy/tQ8mYc nzJJ63ng3tHhnwHXZOu8hL4nqwlYHRa9eeglXYhBqja4ZvIvCEqSmEukfivk+DlIgVoOAJbh qIWgvr3SIEuR6ayY3f5j0f2ejUMYlYYnKdiHXFlF9uXm1ELrb0YX4GMHz80nRmxvcmlhbiBG YWluZWxsaSA8Zi5mYWluZWxsaUBnbWFpbC5jb20+wmYEExECACYCGyMGCwkIBwMCBBUCCAME FgIDAQIeAQIXgAUCVF/S8QUJHlwd3wAKCRBhV5kVtWN2DvCVAJ4u4/bPF4P3jxb4qEY8I2gS 6hG0gACffNWlqJ2T4wSSn+3o7CCZNd7SLSDOw00ESM+4EhAQAL/o09boR9D3Vk1Tt7+gpYr3 WQ6hgYVON905q2ndEoA2J0dQxJNRw3snabHDDzQBAcqOvdi7YidfBVdKi0wxHhSuRBfuOppu pdXkb7zxuPQuSveCLqqZWRQ+Cc2QgF7S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B1q1Q5lwZp2TLAJlz92DmFwBg1hyFzwDADjZ2nrDxKUiybXIgZp9 aU2d++ptEGCVJOfEW4qpWCCLPbOT7XBr+g/4H3qWbs3j/cDDq7LuVYIe+wchy/iXEJaQVeTC y5arMQorqTFWlEOgRA8OP47L9knl9i4xuR0euV6DChDrguup2aJVU8JPBBgRAgAPAhsMBQJU X9LxBQkeXB3fAAoJEGFXmRW1Y3YOj4UAn3nrFLPZekMeqX5aD/aq/dsbXSfyAKC45Go0YyxV HGuUuzv+GKZ6nsysJw== In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 6/28/2024 9:38 AM, Russell King (Oracle) wrote: > On Fri, Jun 28, 2024 at 09:25:54AM +0100, Florian Fainelli wrote: >> >> >> On 6/28/2024 9:17 AM, Russell King (Oracle) wrote: >>> On Fri, Jun 28, 2024 at 02:03:18PM +0800, Youwan Wang wrote: >>>> If the PHY of the mido bus is enabled with Wake-on-LAN (WOL), >>>> we cannot suspend the PHY. Although the WOL status has been >>>> checked in phy_suspend(), returning -EBUSY(-16) would cause >>>> the Power Management (PM) to fail to suspend. Since >>>> phy_suspend() is an exported symbol (EXPORT_SYMBOL), >>>> timely error reporting is needed. Therefore, an additional >>>> check is performed here. If the PHY of the mido bus is enabled >>>> with WOL, we skip calling phy_suspend() to avoid PM failure. >>>> >>>> log: >>>> [ 322.631362] OOM killer disabled. >>>> [ 322.631364] Freezing remaining freezable tasks >>>> [ 322.632536] Freezing remaining freezable tasks completed (elapsed 0.001 seconds) >>>> [ 322.632540] printk: Suspending console(s) (use no_console_suspend to debug) >>>> [ 322.633052] YT8521 Gigabit Ethernet stmmac-0:01: >>>> PM: dpm_run_callback(): mdio_bus_phy_suspend+0x0/0x110 [libphy] returns -16 >>>> [ 322.633071] YT8521 Gigabit Ethernet stmmac-0:01: >>>> PM: failed to suspend: error -16 >>>> [ 322.669699] PM: Some devices failed to suspend, or early wake event detected >>>> [ 322.669949] OOM killer enabled. >>>> [ 322.669951] Restarting tasks ... done. >>>> [ 322.671008] random: crng reseeded on system resumption >>>> [ 322.671014] PM: suspend exit >>>> >>>> If the YT8521 driver adds phydrv->flags, ask the YT8521 driver to process >>>> WOL at suspend and resume time, the phydev->suspended_by_mdio_bus=1 >>>> flag would cause the resume failure. >> >> Did you mean to write that if the YT8521 PHY driver entry set the >> PHY_ALWAYS_CALL_SUSPEND flag, then it would cause an error during resume? If >> so, why is that? > > It doesn't appear to do that - at least not in net-next, and not in > mainline. > >>> I think the reason this is happening is because the PHY has WoL enabled >>> on it without the kernel/netdev driver being aware that WoL is enabled. >>> Thus, mdio_bus_phy_may_suspend() returns true, allowing the suspend to >>> happen, but then we find unexpectedly that WoL is enabled on the PHY. >>> >>> However, whenever a user configures WoL, netdev->wol_enabled will be >>> set when _any_ WoL mode is enabled and cleared only if all WoL modes >>> are disabled. >>> >>> Thus, what we have is a de-sync between the kernel state and hardware >>> state, leading to the suspend failing. >>> >>> I don't see anything in the motorcomm driver that requires suspend >>> if WoL is enabled - yt8521_suspend() first checks to see whether WoL >>> is enabled, and exits if it is. >>> >>> Andrew - how do you feel about reading the WoL state from the PHY and >>> setting netdev->wol_enabled if any WoL is enabled on the PHY? That >>> would mean that the netdev's WoL state is consistent with the PHY >>> whether or not the user has configured WoL. >> >> Would not the situation described here be solved by having the Motorcomm PHY >> driver set PHY_ALWAYS_CALL_SUSPEND since it deals with checking whether WoL >> is enabled or not and will just return then. > > Is there a reason that netdev->wol_enabled shouldn't reflect the > hardware configuration? Unless there is some sort of Ethernet MAC driver bug that we are not being made aware of, the only thing that I can of is happening here, is that a SW/FW agent other than Linux would have enabled the PHY for Wake-on-LAN, and there was no configuration done by the user via the Ethernet MAC driver that attempted to enable Wake-on-LAN. In that case only can I think of a disconnect between the HW and SW states? > > If netdev->wol_enabled is appropriately set, then it seems to me > that there's little reason for motorcomm to be checking whether > WoL is enabled in its suspend function - which means less driver > specific code and driver specific behaviour. > That should work, too. -- Florian