Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp156354iog; Fri, 24 Jun 2022 01:04:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ui+5zpVTAb2CY8SP3DBGGEf1FqjqKp20FwVF6lZpRdUUdcfMatUTEuu3stXEzhN1nBWNi8 X-Received: by 2002:a17:902:900c:b0:16a:4521:10fd with SMTP id a12-20020a170902900c00b0016a452110fdmr13495306plp.75.1656057889530; Fri, 24 Jun 2022 01:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656057889; cv=none; d=google.com; s=arc-20160816; b=zq+co9sOsHz5WxdqFb8iVvmVuvj31hXlfeUJ4dwIVbdNMp3oNg7AeAOJx9x1wtVzxw N3qjqWrDEgZzZnXaZ/ug3/m67hJZcvgW1QqopKkK5twJ/MWWuuh+VUn6eynjV6J5ONVC oNYRmEtczLIFGwzpSOAj/aiysNhWquNfZG1mlaEQGSkSemRSwrXJN/3rIdgEKAJFJj4B I8CV9pn9fCpi4BgPz/ceRHXVp10oL6q3nLmgrbdEV7fWLUUa7Qokl8JeFu45m5vQFn9g Z0539nICgUIY+LXwUnqZuwBbUq4P5aLnjBwuzqP/9JGI7mT/qhGiSs2y0rMtP1UvMVAx WeTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=gNXFeOIDQvwQ+RVN3cLjVZhKL6O87hVz0LsV+0OzLgM=; b=g/xkv8QM58KI+8ym0hYTepPzOa1SJMLWsQEA3+V+BBqu72yZ4gaC5zmm6OBtSBDoLK Yq+GcCsBSSO2jSPr1MojlXToChP83YRZywrCzLVSJr4Grutqed9SJ/+OaQ2e+GP9EDg/ +MG7iyAe6m9JQbFFNkpjH5402Y7xzcHE9Gbj33uMkMoMxPFGgU4a4cUqk6NXIJ8jg8JG eB7IDJoqyvQMQUyF3CWkY8kF2DPZGRnXO8A96HHa5GOggiMfhZ1ylVZwCDSIyHHo4lfh SfQHxg+0Udzcq6CZ54uUq/6//tdwseM3fSlnq5QsQO4G29qR26wc8YxGWJtk3QUBzPcl ZhSw== 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 mi4-20020a17090b4b4400b001ec9d524715si2534102pjb.84.2022.06.24.01.04.37; Fri, 24 Jun 2022 01:04:49 -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 S230192AbiFXH4T (ORCPT + 99 others); Fri, 24 Jun 2022 03:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbiFXH4L (ORCPT ); Fri, 24 Jun 2022 03:56:11 -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 9E51869FB9 for ; Fri, 24 Jun 2022 00:56:08 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4eAa-0006PA-Ql; Fri, 24 Jun 2022 09:56:00 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1o4eAY-002Nyq-Lj; Fri, 24 Jun 2022 09:56:00 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1o4eAZ-00DBFf-7O; Fri, 24 Jun 2022 09:55:59 +0200 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Lukas Wunner Subject: [PATCH net-next v1 1/1] net: phy: ax88772a: fix lost pause advertisement configuration Date: Fri, 24 Jun 2022 09:55:58 +0200 Message-Id: <20220624075558.3141464-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 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=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 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