From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA5CEC7EE22 for ; Tue, 9 May 2023 22:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234547AbjEIWeu (ORCPT ); Tue, 9 May 2023 18:34:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234970AbjEIWek (ORCPT ); Tue, 9 May 2023 18:34:40 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2DC444AB; Tue, 9 May 2023 15:34:34 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6438d95f447so4525279b3a.3; Tue, 09 May 2023 15:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683671673; x=1686263673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AzNBgngNpXj0wbXwRY/xf3HuUbNLwyU+aM5xfz4oMR8=; b=rSMmU4vmlHSAEnKN/8a9GLIElgeVrZwc6fUmse218q1b4bkrPXoOQ3Unw9Z+7KAagX ANrlFnPb2f0W01H7SuZ6PpO+fFpdPkUAvQgBBOrbfdf++oeCj70jc0ovc2ZUzyzudYqq GmDSZK2OUMW5/kpyYM4ZfeYu8cA/GDGGdnxUxFOl7JcKIegYD0aQrRnD4cWyiJSqplUw ekjcJAHWRuNmU/TtS1Fc7dbL/GJ/jOFBq+ZEBGtN9FVVcOPO6LqVG/VQXMopCQ+M5MWs 0GKzWC+XbUXYjMyhNCzcIHOjVScaLJrQAUAiLUuMrEyj+eYrhuI0uRVcgFokq4N5uVLz U+wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683671673; x=1686263673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AzNBgngNpXj0wbXwRY/xf3HuUbNLwyU+aM5xfz4oMR8=; b=Y5jyWM+uhpD4j/C7cyv1E9b1EVQKl+5Yj7MFgt4anbNrp122nIbhz64NAS34DvVWAE 02ZG5i4HdNDTLaQl/S8DfK13rDnnNFf/3ID7zBmFlIkFWGkXXw2YmJiWMLllhCsBnOkk 8ROj98aoibzWWTcPUt8I/y1AQkGIp9f5bkg84dqUQ1PoplQrEKdEskX6K/UHE06UcyOc shbD+GWaKn5a543LYsLTADDijziFuzGwYR7ezuxuNFOtMejzkHvshoUEC2BorDIAXuhD ijXG1PnElyb113KMFq6Eagx2x7jzOLfbmQht/0kPP30N+gEKnsxp9yH/rO598u6+rsF+ q7wg== X-Gm-Message-State: AC+VfDwt8daO/j1UjdoQCWt1D3rF9VWruodermj3etH418xoXjyFnMJs LeLpw+NiZD11ubN3VeBQMIjwCLAziEQ= X-Google-Smtp-Source: ACHHUZ6Kzds0js6vEO0RYckMGm6A6hSKgLgi4J/dQl+vB3ceP3Na7+6vzHEfydlxK3xNd1TPgYnjUw== X-Received: by 2002:a05:6a00:240a:b0:63d:3a18:4a08 with SMTP id z10-20020a056a00240a00b0063d3a184a08mr18856654pfh.24.1683671673565; Tue, 09 May 2023 15:34:33 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id p5-20020aa78605000000b006438898ce82sm2317274pfn.140.2023.05.09.15.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 15:34:33 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Peter Geis , Frank , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 1/3] net: phy: Allow drivers to always call into ->suspend() Date: Tue, 9 May 2023 15:34:01 -0700 Message-Id: <20230509223403.1852603-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509223403.1852603-1-f.fainelli@gmail.com> References: <20230509223403.1852603-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A few PHY drivers are currently attempting to not suspend the PHY when Wake-on-LAN is enabled, however that code is not currently executing at all due to an early check in phy_suspend(). This prevents PHY drivers from making an appropriate decisions and put the hardware into a low power state if desired. In order to allow the PHY drivers to opt into getting their ->suspend routine to be called, add a PHY_ALWAYS_CALL_SUSPEND bit which can be set. A boolean that tracks whether the PHY or the attached MAC has Wake-on-LAN enabled is also provided for convenience. If phydev::wol_enabled then the PHY shall not prevent its own Wake-on-LAN detection logic from working and shall not prevent the Ethernet MAC from receiving packets for matching. Signed-off-by: Florian Fainelli --- drivers/net/phy/phy_device.c | 5 +++-- include/linux/phy.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 17d0d0555a79..8852b0c53114 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1860,9 +1860,10 @@ int phy_suspend(struct phy_device *phydev) if (phydev->suspended) return 0; - /* If the device has WOL enabled, we cannot suspend the PHY */ phy_ethtool_get_wol(phydev, &wol); - if (wol.wolopts || (netdev && netdev->wol_enabled)) + phydev->wol_enabled = wol.wolopts || (netdev && netdev->wol_enabled); + /* If the device has WOL enabled, we cannot suspend the PHY */ + if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) return -EBUSY; if (!phydrv || !phydrv->suspend) diff --git a/include/linux/phy.h b/include/linux/phy.h index c5a0dc829714..e0df8b3c2bdb 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -86,6 +86,7 @@ extern const int phy_10gbit_features_array[1]; #define PHY_IS_INTERNAL 0x00000001 #define PHY_RST_AFTER_CLK_EN 0x00000002 #define PHY_POLL_CABLE_TEST 0x00000004 +#define PHY_ALWAYS_CALL_SUSPEND 0x00000008 #define MDIO_DEVICE_IS_PHY 0x80000000 /** @@ -548,6 +549,8 @@ struct macsec_ops; * @downshifted_rate: Set true if link speed has been downshifted. * @is_on_sfp_module: Set true if PHY is located on an SFP module. * @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY + * @wol_enabled: Set to true if the PHY or the attached MAC have Wake-on-LAN + * enabled. * @state: State of the PHY for management purposes * @dev_flags: Device-specific flags used by the PHY driver. * @@ -644,6 +647,7 @@ struct phy_device { unsigned downshifted_rate:1; unsigned is_on_sfp_module:1; unsigned mac_managed_pm:1; + unsigned wol_enabled:1; unsigned autoneg:1; /* The most recently read link state */ -- 2.34.1