Received: by 2002:ab2:644:0:b0:1ec:cbc4:63fb with SMTP id 4csp1157318lqn; Mon, 26 Feb 2024 09:13:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXQiKZTh5Pb3w00zNH9OZbhtvlg33fShJsg3aECGCtq2dHEiZu+9exezTKodRsJ+UzX95GnRYHEi69+YJ9JAxVK4Jc4W5qaBBLKa2TkSw== X-Google-Smtp-Source: AGHT+IFEZOR3Esi53YWIOMvyT6dXuTfup8U7JypfVAjBaW1wb6074+0Uu1wlZr5CI4VqI0P9cmRe X-Received: by 2002:a05:6a20:d390:b0:1a0:f616:32be with SMTP id iq16-20020a056a20d39000b001a0f61632bemr6813115pzb.10.1708967581519; Mon, 26 Feb 2024 09:13:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708967581; cv=pass; d=google.com; s=arc-20160816; b=HJqwdh20ltpwvzaoGrUnHsXLTdFi/+WMKrMuObDmj/bWtHxeGHxPlkaTl6XAqwbCiS kSVnGW8E1CQIODZ4QNOmSd8FkkPLs68weF/Nvu7akikxzaF+YskR0C1oPdtfnwVQEOx0 JMe4qUqpRZHuBiux+wWdxc33DoGa+lVcYbdUxxEPB81qlCEJdUI3+PvwVhP6mihzuUGa /s9qRciFtCWZ0TMLB6N6/rfNves6otcMrBe+R6UkL8Q5/Y8evuGNZbJNhtvWZzbdidyu zfMauMLqGhTC/rdpzRI3xZSkZ9v19Hj1ECVE8fbLrrHU2Me2BRsy4DQB5HtthbBomxOj MQtg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fcMmbwH20hlzGHDT13qM5dHjc11AwHNty8n4xGkTVaU=; fh=uSIrIhhugUtGfiRPm4s3NXv0yUrMBe85EQNQEj9DbZo=; b=Vu+L7JjIq0S0dwa0qIz0/1is6f6t9N7x0L8o/PnF2wLMJVkk9NiFyfBatxIQGQzLAI cvnVtkHAk8GtLlV1fV5mqkvnHQ9e7/OuQvS/uqOCC7uzo+ObEbX4i6nNcUh4mo5a+gDt iZHs3MQVPFTJRddDb5oUc3sAcJ7bHsxdaXEmQDTIkU9Y9lDTAqotKcBWvDPUqN4ugTrI xqS7/fkeBEfA7FDYziUSqN0wEqjcqEa+aND2NcinO1Hfz9rhHKzLmw5+QIRLpybOzi04 vyFOQCB0JcKT9Guet831hVbol0Ug26osVn2aBSnIdFbeHYe98dmBkMVP/8xvMxf9KW99 fuNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=6UaQbr33; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-81926-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v10-20020a63610a000000b005dbdc9098c6si3977459pgb.445.2024.02.26.09.13.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:13:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81926-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=6UaQbr33; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-81926-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 46BC1B284B5 for ; Mon, 26 Feb 2024 16:44:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A90E512CDAE; Mon, 26 Feb 2024 16:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="6UaQbr33" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0618112C55F; Mon, 26 Feb 2024 16:44:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708965877; cv=none; b=tpQY9Rx1WhCKzkpN1BxdV4gkHJjzLSSXHJRMplaogGVesPwFzEo5qBTHLFnrMHTN7AFlwXWHmTKn2jV66yB+zxa1/qrBTgXEB5spdrqEIGkDlF9tk2PLupefNvfZR9J1TSmNV4a8wsKHEUD0u1wwO8bC4OJELKZYszqo2QqkSpc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708965877; c=relaxed/simple; bh=2cC/qsuNQsXbbz+8yooGwMCr+WBfFCZgH3VG+mTM184=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ssJHwN9GKxGu9WWCTsm72N82O7tZ9nGsx7nEykFR0qH4H8UfOTSc5MkWKL3CwYunkGlEdUt47VFkLuKLnJUU8trHHlCi0ARfQnc14e9ka2saUPwjzpS4wNgVwZXvMKRKE/5g9p3axHDmh3T/wvn5NeI5sKhqoy136yaXSl4TpyA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=6UaQbr33; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch 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=fcMmbwH20hlzGHDT13qM5dHjc11AwHNty8n4xGkTVaU=; b=6UaQbr33atA+6ymp+NcdZPU6br 9dgd95Z/HtBuOdZtagB50eg97f8wLfphVDn8qu82XcdTIam1tu0l/V2UYpIUc0pttDSzUdjfQOiXR 2Tlr/9/WaM243kcn2bjci/PRPJMdby+4MwpFMCEUIEoNXIR07causqgJUm3j+23Kz+II=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1ree5f-008kBh-Fv; Mon, 26 Feb 2024 17:44:31 +0100 Date: Mon, 26 Feb 2024 17:44:31 +0100 From: Andrew Lunn To: Oleksij Rempel Cc: Florian Fainelli , "Russell King (Oracle)" , Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: Re: [PATCH net-next v6 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes Message-ID: References: <20240223094425.691209-1-o.rempel@pengutronix.de> <20240223094425.691209-6-o.rempel@pengutronix.de> <84e1368d-ec6a-48af-945b-509528c45dff@lunn.ch> <6af3406a-7968-41e5-bf6e-71d020d8b28a@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat, Feb 24, 2024 at 06:57:12PM +0100, Oleksij Rempel wrote: > On Fri, Feb 23, 2024 at 09:53:06AM -0800, Florian Fainelli wrote: > > On 2/23/24 05:26, Russell King (Oracle) wrote: > > > On Fri, Feb 23, 2024 at 02:17:59PM +0100, Andrew Lunn wrote: > > > > On Fri, Feb 23, 2024 at 10:38:20AM +0000, Russell King (Oracle) wrote: > > > > > On Fri, Feb 23, 2024 at 10:44:22AM +0100, Oleksij Rempel wrote: > > > > > > +static void phy_ethtool_set_eee_noneg(struct phy_device *phydev, > > > > > > + struct ethtool_keee *data) > > > > > > +{ > > > > > > + if (phydev->eee_cfg.tx_lpi_enabled != > > > > > > + data->tx_lpi_enabled) { > > > > > > + eee_to_eeecfg(data, &phydev->eee_cfg); > > > > > > + phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg); > > > > > > + if (phydev->link) > > > > > > + phy_link_up(phydev); > > > > > > > > > > I'm not convinced this is a good idea. Hasn't phylib previously had > > > > > the guarantee that the link will go down between two link-up events? > > > > > So calling phy_link_up() may result in either the MAC driver ignoring > > > > > it, or modifying registers that are only supposed to be modified while > > > > > the MAC side is down. > > > > > > > > When auto-neg is used, we expect the link to go down and come back up > > > > again. > > > > > > > > Here we are dealing with the case that autoneg is not used. The MAC > > > > needs informing somehow. If we want to preserve the down/up, we could > > > > call phy_link_down() and then phy_link_up() back to back. > > > > > > Would it be better to have a separate callback for EEE state (as I > > > mentioned in another comment on this series?) That would be better > > > for future SmartEEE support. > > > > That sounds like a good approach to me. The additional callback also helps > > figure out which drivers use the API and it should be simpler to audit for > > changes in the future, too. > > At this point I need help to understand how to proceed. > What exactly do you have in mind? Some description like following would > be helpful: > Add callback with name phy_link_set_eee(), which should be executed in > function bla/blup.. When i first did this patchset, SmartEEE was out of scope. One question we should decide is, is it still out of scope, and we should first get 'dumb' EEE fixed everywhere, and than come back and look at SmartEEE? Or do we want to consider SmartEEE now? The idea of this patchset was to push as much as possible down into phylib. The MAC needs to say it supports EEE. I left handling of the tx_lpi_timer to the MAC driver, because the PHY has nothing it can do with that value. phylib then just needs to tell the MAC to enable or disable EEE when autoneg has completed. That i made part of the adjust link callback because that is the only callback we have, and most developers seem to understand it, and the locking around it. However, it does get messy when EEE can change without an auto-neg, as pointed out here. If we are leaving SmartEEE out of scope for the moment, i would say just doing a down/up is sufficient, lets get this merged and all 'dumb' EEE fixed. If we want feature creep and to think about SmartEEE then we need a few changes in the overall design. We need to make eee_get and eee_set transparent to the MAC driver, since the PHY could be doing it all. So phylib needs to track tx_lpi_timer. If the MAC driver indicates it can do 'dumb' EEE we probably want to use that in preference to SmartEEE, since i guess the MAC can also save a little power in LPI mode. So the adjust link callback needs to say: Enable MAC EEE with this value of tx_lpi_timer, or turn off MAC EEE. When using SmartEEE it will never actually do either. The current phylib model is that adjust_link is the only callback, and the MAC driver peeks into phydev to find what it needs. I would probably stick to that model, and not add MAC callbacks. phylink is slightly different, mac_link_up() passes everything the MAC needs to know as parameters, so one of my patches adds an extra parameter to indicate if EEE should be enabled or disabled. That would need extending with the tx_lpi_timer value. Andrew