[net,v1,1/1] net: dsa: microchip: make sure drive strength configuration is not lost by soft reset
Message ID | 20240304135612.814404-1-o.rempel@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-90691-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp1433871dyc; Mon, 4 Mar 2024 05:57:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCViH1SrXs/lh4Wj2Bjf5AOvmjrlSG4WwcGBgzyv4bG8IQNW21egXOjVhxnynCe8gz9srfptOvyH2ilcwgGUvx4pPQd1vw== X-Google-Smtp-Source: AGHT+IEYGqBq8paf8NfsySxlWFIDHkA4pKY94ZWTnFQq/IGmVplXVMaTxK3tS9FDwA66JwmH24TS X-Received: by 2002:ac2:4c87:0:b0:513:3d27:baa5 with SMTP id d7-20020ac24c87000000b005133d27baa5mr3473736lfl.9.1709560627301; Mon, 04 Mar 2024 05:57:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709560627; cv=pass; d=google.com; s=arc-20160816; b=k678fLUDsIqP7l9js27PXlpzFOl5NWOlUY0yFIflKuG8JOp0RznnmFjl6pcGqHGG8V +y86sRZfHQgVr4yrBrBmsVezJ3w1X1go5ppEW7jB1e6jZs0u9TQFsDuXHBGgR1LAwLN3 LPuWZv6cVi1GEwn0GSBuwhNH/8CA1yWTzjQdWMr9dATeJmqEi5rm2cXrqox9apLWYGdy h0x16I7ka1ByKIaugBgNz331S/L8V6VLdLw+Tkkh8BDqlxHh9auUpJgiTHqXZjXu7GfB +hxJ/rKXNsHDLzBLSu/ssPS3pCDQDaxPJcAs43iN3//ydraVlNVBsKb95Dq044ItEFqM rdCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Qu802eosuaqPz93V7C4QlcLw35mM7sl08do8nyPcUWE=; fh=M1qfrahb/qW7n6G/0kHpmUybK+Ky3Jq5+sps382+aZ4=; b=uuCiOlmitd4BHqAqJ3vJEoFU2i/RC3oy+0HcS00fo3k6Qhlbw6e2fZdljeG70pIU8Q eAGA6YsBx4Md+Ob6DE4YIFguj9zFCOxzxhRvXmPIjgYiCZj2jAoLz0KlH/0wya0s+ikS MJABg6Io1TZyXAo0f/JE0JnMqRyoKYsgJw3QiWO6qfDwkxws8HalMGYHPvQzJAIxZy3B aH/fwxlMw06ajs3LSAb0aE8cNnLPyJrwa+Q9RfmozujPrboSvZsT3W+OCSJyAXDy3V96 LFEiciimM/zFYok1Fr85boZcUXWkzFTw1wEAw8ZTc0aCN+XXY3qMDNQyTUQHNZ8pjsLZ VbTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-90691-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90691-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qx7-20020a170906fcc700b00a45464679basi852216ejb.871.2024.03.04.05.57.07 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 05:57:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90691-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-90691-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90691-ouuuleilei=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6B8EC1F226F5 for <ouuuleilei@gmail.com>; Mon, 4 Mar 2024 13:56:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 029EF3F9E8; Mon, 4 Mar 2024 13:56:26 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 0C0AB2EB0F for <linux-kernel@vger.kernel.org>; Mon, 4 Mar 2024 13:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709560584; cv=none; b=jjheQezQ3kUVDFbuaGivUEvwxglAeO5wUpHZMQ+H2XsxdTj7JIdWuZpT1ljBM0Fp/jyLZHybwiIYjXyFE+frSWgac5OFr42guuu4+IvUNidC2SDb7h54nj+UEx2iHoJ3PMEOidFgLgsy4Ygi4psergjTeJBA/W4AnpUHnyRDpGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709560584; c=relaxed/simple; bh=QJQ63Qy2NxLUI09eztah+cUO41gaSAxVF3u7uBvwMs4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=PPRw6/lAAAoPpBj0NVq5oav7nXpyzb54sX68+9RLf7+5o3cAds03R7zlZBvwSQ9lW0JCvj6jx5FsCajomxDwJfVfAtsQjk3GJVeJHQ3/Pc0tLNtrOolBL9AlN/rU8Yf8go7TMVhS13d5jU3ouoy5d6C+V//7J85nscpCK033he4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <ore@pengutronix.de>) id 1rh8ng-0004OE-7v; Mon, 04 Mar 2024 14:56:16 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <ore@pengutronix.de>) id 1rh8nf-004MiW-0Y; Mon, 04 Mar 2024 14:56:15 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from <ore@pengutronix.de>) id 1rh8ne-003Prr-34; Mon, 04 Mar 2024 14:56:14 +0100 From: Oleksij Rempel <o.rempel@pengutronix.de> To: "David S. Miller" <davem@davemloft.net>, Andrew Lunn <andrew@lunn.ch>, Eric Dumazet <edumazet@google.com>, Florian Fainelli <f.fainelli@gmail.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Vladimir Oltean <olteanv@gmail.com>, Woojung Huh <woojung.huh@microchip.com>, Arun Ramadoss <arun.ramadoss@microchip.com> Cc: Oleksij Rempel <o.rempel@pengutronix.de>, kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: [PATCH net v1 1/1] net: dsa: microchip: make sure drive strength configuration is not lost by soft reset Date: Mon, 4 Mar 2024 14:56:12 +0100 Message-Id: <20240304135612.814404-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792604244512522309 X-GMAIL-MSGID: 1792604244512522309 |
Series |
[net,v1,1/1] net: dsa: microchip: make sure drive strength configuration is not lost by soft reset
|
|
Commit Message
Oleksij Rempel
March 4, 2024, 1:56 p.m. UTC
This driver has two separate reset sequence in different places:
- gpio/HW reset on start of ksz_switch_register()
- SW reset on start of ksz_setup()
The second one will overwrite drive strength configuration made in the
ksz_switch_register().
To fix it, move ksz_parse_drive_strength() from ksz_switch_register() to
ksz_setup().
Fixes: d67d7247f641 ("net: dsa: microchip: Add drive strength configuration")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/net/dsa/microchip/ksz_common.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
Comments
Hi Oleksij, On Mon, 2024-03-04 at 14:56 +0100, Oleksij Rempel wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you > know the content is safe > > This driver has two separate reset sequence in different places: > - gpio/HW reset on start of ksz_switch_register() > - SW reset on start of ksz_setup() > > The second one will overwrite drive strength configuration made in > the > ksz_switch_register(). > > To fix it, move ksz_parse_drive_strength() from ksz_switch_register() > to > ksz_setup(). > > Fixes: d67d7247f641 ("net: dsa: microchip: Add drive strength > configuration") > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > --- > drivers/net/dsa/microchip/ksz_common.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/dsa/microchip/ksz_common.c > b/drivers/net/dsa/microchip/ksz_common.c > index d58cc685478b1..83a5936506059 100644 > --- a/drivers/net/dsa/microchip/ksz_common.c > +++ b/drivers/net/dsa/microchip/ksz_common.c > @@ -2260,6 +2260,8 @@ static int ksz_pirq_setup(struct ksz_device > *dev, u8 p) > return ksz_irq_common_setup(dev, pirq); > } > > +static int ksz_parse_drive_strength(struct ksz_device *dev); > + IMO: move the ksz_parse_drive_strength( ) here instead of prototype alone. Since the function is used in only one place and it will be logical to follow. > static int ksz_setup(struct dsa_switch *ds) > { > struct ksz_device *dev = ds->priv; > @@ -2281,6 +2283,10 @@ static int ksz_setup(struct dsa_switch *ds) > return ret; > } > > + ret = ksz_parse_drive_strength(dev); > + if (ret) > + return ret; > + > /* set broadcast storm protection 10% rate */ > regmap_update_bits(ksz_regmap_16(dev), > regs[S_BROADCAST_CTRL], > BROADCAST_STORM_RATE, > @@ -4345,10 +4351,6 @@ int ksz_switch_register(struct ksz_device > *dev) > for (port_num = 0; port_num < dev->info->port_cnt; > ++port_num) > dev->ports[port_num].interface = > PHY_INTERFACE_MODE_NA; > if (dev->dev->of_node) { > - ret = ksz_parse_drive_strength(dev); > - if (ret) > - return ret; > - > ret = of_get_phy_mode(dev->dev->of_node, &interface); > if (ret == 0) > dev->compat_interface = interface; > -- > 2.39.2 >
Hi Arun, On Mon, Mar 04, 2024 at 02:25:54PM +0000, Arun.Ramadoss@microchip.com wrote: > Hi Oleksij, > > On Mon, 2024-03-04 at 14:56 +0100, Oleksij Rempel wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you > > know the content is safe > > > > This driver has two separate reset sequence in different places: > > - gpio/HW reset on start of ksz_switch_register() > > - SW reset on start of ksz_setup() > > > > The second one will overwrite drive strength configuration made in > > the > > ksz_switch_register(). > > > > To fix it, move ksz_parse_drive_strength() from ksz_switch_register() > > to > > ksz_setup(). > > > > Fixes: d67d7247f641 ("net: dsa: microchip: Add drive strength > > configuration") > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > > --- > > drivers/net/dsa/microchip/ksz_common.c | 10 ++++++---- > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/net/dsa/microchip/ksz_common.c > > b/drivers/net/dsa/microchip/ksz_common.c > > index d58cc685478b1..83a5936506059 100644 > > --- a/drivers/net/dsa/microchip/ksz_common.c > > +++ b/drivers/net/dsa/microchip/ksz_common.c > > @@ -2260,6 +2260,8 @@ static int ksz_pirq_setup(struct ksz_device > > *dev, u8 p) > > return ksz_irq_common_setup(dev, pirq); > > } > > > > +static int ksz_parse_drive_strength(struct ksz_device *dev); > > + > > IMO: move the ksz_parse_drive_strength( ) here instead of prototype > alone. Since the function is used in only one place and it will be > logical to follow. I fully agree, but I fear this change would be too big for stable. @Jakub, what is your preference? Regards, Oleksij
> I fully agree, but I fear this change would be too big for stable.
How big is the change to do it correctly?
The stable rules are all about making it obviously correct, and so low
risk. In general, a big patch is not always obviously correct. But if
all you are doing is moving code around, no actual change, and it
clearly states that, the size limit should not matter, the risk is
low. Include this information as justification in the commit message,
and it should be O.K.
Andrew
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index d58cc685478b1..83a5936506059 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2260,6 +2260,8 @@ static int ksz_pirq_setup(struct ksz_device *dev, u8 p) return ksz_irq_common_setup(dev, pirq); } +static int ksz_parse_drive_strength(struct ksz_device *dev); + static int ksz_setup(struct dsa_switch *ds) { struct ksz_device *dev = ds->priv; @@ -2281,6 +2283,10 @@ static int ksz_setup(struct dsa_switch *ds) return ret; } + ret = ksz_parse_drive_strength(dev); + if (ret) + return ret; + /* set broadcast storm protection 10% rate */ regmap_update_bits(ksz_regmap_16(dev), regs[S_BROADCAST_CTRL], BROADCAST_STORM_RATE, @@ -4345,10 +4351,6 @@ int ksz_switch_register(struct ksz_device *dev) for (port_num = 0; port_num < dev->info->port_cnt; ++port_num) dev->ports[port_num].interface = PHY_INTERFACE_MODE_NA; if (dev->dev->of_node) { - ret = ksz_parse_drive_strength(dev); - if (ret) - return ret; - ret = of_get_phy_mode(dev->dev->of_node, &interface); if (ret == 0) dev->compat_interface = interface;