Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp217676iog; Fri, 24 Jun 2022 02:40:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tB1PgcZgR0VMroXVgG8SfT5vAUriR1uSNlui3ik9tFXIJnqNcQ5Xqqm9C5SC4h5EFWR4AQ X-Received: by 2002:a17:907:a42c:b0:722:c374:4062 with SMTP id sg44-20020a170907a42c00b00722c3744062mr12975842ejc.758.1656063629574; Fri, 24 Jun 2022 02:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656063629; cv=none; d=google.com; s=arc-20160816; b=IsmjOfkAfjt6NAr6fkq2GgGiKw0qkHFouwhYlTj3h2NHwk9SVK1sruwFuP8LXpJ2Y6 wxtPvXKDpdHbdlrTfM74piuc5zhme98Zu4LtyYuVSPkciRTOTQ7tc+Z1PPflb1U3t6Nx AlqD/+Ln5SOwCeHralTyl7MR/1oxYqzlPQyz2PDzH2Czi9KV6zCaT4moVa6KfYHMs8qB 8JE3TwCz2RNJ8DP1lsh6wMlOYlBDjZNvSAZxNutTXq+BaHFr7vaOdWls/mws3nLptzER Z23dB1BWCx9iT9sgpLGRBd3M2/uhWHSqQlRnq9oqLWDvtnYT25IXQ2ofIgybl7hoBKOK dfFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=n4qervAqpB5rq63Ct9SFCDG2QfJAFe4WMR6c2P15Wnk=; b=xgYsr6HR54XJ5h9TKDow3XvbvEFz9rLFePWU2i4itdyq0eAeOYMqTr3DeI1me5A+qx rMWF1AtA0ODOY7whNcDqcKxvS7ga7AVhlwT26J40dWCFKrgRxTYreaiajAXtLYQKBsMZ 559O2ywSmPTbZP93Uim3t4rZsYDyJfzVHGuVkfKjT10HDv9zLG+RPb7H+xMJJZoW4efX tw9yFUdmrlIEaBCcpPaSWukSgMncDYkdZLxpmU8WoB71UnPRvzTNaGLgkH++7fXHO71m f2WPo1lLMoVw/d1nk3Vsh8k1HG//O381uE9LNFwb/P7Mxm/ajTVN9RV/baql3BeMxZAV 6uUg== ARC-Authentication-Results: i=1; mx.google.com; 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 dd6-20020a1709069b8600b00715785bb641si1125399ejc.31.2022.06.24.02.40.03; Fri, 24 Jun 2022 02:40:29 -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; 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 S229745AbiFXJMs (ORCPT + 99 others); Fri, 24 Jun 2022 05:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231535AbiFXJLt (ORCPT ); Fri, 24 Jun 2022 05:11:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03C624F9C6 for ; Fri, 24 Jun 2022 02:11:43 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4fLj-0000HT-Aa; Fri, 24 Jun 2022 11:11:35 +0200 Received: from ore by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1o4fLh-0000Rq-Py; Fri, 24 Jun 2022 11:11:33 +0200 Date: Fri, 24 Jun 2022 11:11:33 +0200 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit Cc: Lukas Wunner , linux-kernel@vger.kernel.org, kernel@pengutronix.de, netdev@vger.kernel.org Subject: Re: [PATCH net-next v1 1/1] net: phy: ax88772a: fix lost pause advertisement configuration Message-ID: <20220624091133.GA804@pengutronix.de> References: <20220624075558.3141464-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220624075558.3141464-1-o.rempel@pengutronix.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 I forgot to add PHY maintainers. CCing Andrew and Heiner. On Fri, Jun 24, 2022 at 09:55:58AM +0200, Oleksij Rempel wrote: > In case of asix_ax88772a_link_change_notify() workaround, we run soft > reset which will automatically clear MII_ADVERTISE configuration. The > PHYlib framework do not know about changed configuration state of the > PHY, so we need to save and restore all needed configuration registers. > > Fixes: dde258469257 ("net: usb/phy: asix: add support for ax88772A/C PHYs") > Signed-off-by: Oleksij Rempel > --- > drivers/net/phy/ax88796b.c | 37 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 36 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/phy/ax88796b.c b/drivers/net/phy/ax88796b.c > index 457896337505..6971d0196917 100644 > --- a/drivers/net/phy/ax88796b.c > +++ b/drivers/net/phy/ax88796b.c > @@ -18,6 +18,11 @@ MODULE_DESCRIPTION("Asix PHY driver"); > MODULE_AUTHOR("Michael Schmitz "); > MODULE_LICENSE("GPL"); > > +struct asix_context { > + u16 bmcr; > + u16 advertise; > +}; > + > /** > * asix_soft_reset - software reset the PHY via BMCR_RESET bit > * @phydev: target phy_device struct > @@ -83,13 +88,43 @@ static int asix_ax88772a_read_status(struct phy_device *phydev) > return 0; > } > > +/* save relevant PHY registers to private copy */ > +static void asix_context_save(struct phy_device *phydev, > + struct asix_context *context) > +{ > + context->bmcr = phy_read(phydev, MII_BMCR); > + context->advertise = phy_read(phydev, MII_ADVERTISE); > +} > + > +/* restore relevant PHY registers from private copy */ > +static void asix_context_restore(struct phy_device *phydev, > + const struct asix_context *context) > +{ > + u16 bmcr = context->bmcr; > + > + phy_write(phydev, MII_ADVERTISE, context->advertise); > + > + /* after all settings are restored, restart autoneg */ > + if (phydev->autoneg == AUTONEG_ENABLE) > + bmcr |= BMCR_ANRESTART; > + > + phy_write(phydev, MII_BMCR, bmcr); > +} > + > static void asix_ax88772a_link_change_notify(struct phy_device *phydev) > { > /* Reset PHY, otherwise MII_LPA will provide outdated information. > * This issue is reproducible only with some link partner PHYs > */ > - if (phydev->state == PHY_NOLINK && phydev->drv->soft_reset) > + if (phydev->state == PHY_NOLINK && phydev->drv->soft_reset) { > + struct asix_context context; > + > + asix_context_save(phydev, &context); > + > phydev->drv->soft_reset(phydev); > + > + asix_context_restore(phydev, &context); > + } > } > > static struct phy_driver asix_driver[] = { > -- > 2.30.2 > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |