Message ID | 20240204101128.49336-1-tp@osasysteme.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-51573-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp793406dyb; Mon, 5 Feb 2024 02:51:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBjbV6c3koHdd2XUJIwjre85Sfxq35BGE8Va6fN+uRKx1KVwzPPV7/8XQ976aJ/y7HxuQQ X-Received: by 2002:a17:906:846:b0:a37:5b1d:53d0 with SMTP id f6-20020a170906084600b00a375b1d53d0mr5071510ejd.31.1707130274588; Mon, 05 Feb 2024 02:51:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707130274; cv=pass; d=google.com; s=arc-20160816; b=c5a/45+PGyTWRkZcsj1jvMM+c4hGS+bLOm58akrQet1xvEgjRfdADWYCITtUQvtp7D odaGdxhahTRfI7bu212Z2VpjGk47IaUOw+NwDSSy+ZxPItKegiI42x3yHIgXaSQ5Ye3W BXX51yutrXOj8c0ny19BBG0hS4IuUvneB4AOrX/vdUDX9WJ1O4698yP3XEMl2+Gdaaok uT8wIazXYaXq1IXF+D3M8o8+0rav/z90Y4vmzJY0jSaP8Gzo0/rHRCzLYm8mQ/A8uN6W XNYvz5ReiVJhZdiISi2ZfMXp4ELlJRimWv0ZucwnYF4R+fY1AyuBJyBb/0x8eBgdC0GI hyHw== 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:dkim-signature; bh=FzWDtkDTEMXeY2GGs0Dk8CQkkL2udHkmJIAyDN4MJW0=; fh=u1AecMz8I7F/ymU5w28xPnswEqGTv7/qMehVRJ+NgGQ=; b=kjkkMAW7wAg76yG2G5dIn9qfd+iXvnIbhHEUGEkhhiwPoOifc876k57LB6LNDti00F cVevFmQ2F4HL/9P2CWtnPxh37Mysk2HGyE/2KdffTHhx099lACIUDIGmng5/DZ3WGcwt 39ZRhAgWqbvAO1ikBMV/HdAsbamXa+I5qnN40q5tToMq444NxyoZZh6eoD5AXeOASauX 7G9RfMDUw4cx4RNRiuaNK5RMt/rhhoM22BR6VH4/3HnOiGIdDU77dHt1Agotczd66ZBD Qzmh5R7uYqp+1IxkDywSfGXFF/1KIL6RxQW3pWYZr3xxRlackuWhvm1CNIe/eST0BGCy +DUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@osasysteme.de header.s=19022017 header.b=Eef8+IUx; arc=pass (i=1 spf=pass spfdomain=osasysteme.de dkim=pass dkdomain=osasysteme.de); spf=pass (google.com: domain of linux-kernel+bounces-51573-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51573-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCV3md2PK35KGUB3DnAIkmtnu1OdRXuqhNx/vtzlgCIHp7+B7xDdZIx5ELBchoA0MShcRroRR9HFqBuLaSToJuptF7kMCA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t8-20020a1709063e4800b00a37b8f91636si983430eji.319.2024.02.05.02.51.14 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 02:51:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51573-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@osasysteme.de header.s=19022017 header.b=Eef8+IUx; arc=pass (i=1 spf=pass spfdomain=osasysteme.de dkim=pass dkdomain=osasysteme.de); spf=pass (google.com: domain of linux-kernel+bounces-51573-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51573-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 D68801F2263B for <ouuuleilei@gmail.com>; Sun, 4 Feb 2024 10:12:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0E7B1B80A; Sun, 4 Feb 2024 10:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=osasysteme.de header.i=@osasysteme.de header.b="Eef8+IUx" Received: from secondary.pambor.com (secondary.pambor.com [46.38.233.203]) (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 0983A1B592; Sun, 4 Feb 2024 10:11:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.38.233.203 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707041512; cv=none; b=CgcRwZpZgpgLpHNoP5Iz9xG3O+rDrxaBU8l0YOBcmxX2IwMwn7PNBWL49X4cje6hpGRUYEXzi9Yjw+zkqsRxV6LvZ8r7CnLQL1scd9yVV/vKrBO1bLubgHGyZI6HJdsTETK77m1HcuO7TBFL6RKsWSN0M68c3UsHTQZMXwwau9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707041512; c=relaxed/simple; bh=GP/K0NDMKaVN58IzCg9WjhrcSkEgoqe/cArG54xldsk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=S+5eIJFhkxkaLWiUXaCXeYcQE7H66JdsDAwRdL930taVDcjyKbkaN0bvbqpgv9ZNFy7PwLAGZMUetDXDDHtkDkc7IZDauLPfDu8vKmQquHBAKoC/gTyEmD7Lelg8gLoSZLDaOsbS2h82phwNcRcCRYcHrqqLDVZj7YzhFkqeLXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=osasysteme.de; spf=pass smtp.mailfrom=osasysteme.de; dkim=pass (2048-bit key) header.d=osasysteme.de header.i=@osasysteme.de header.b=Eef8+IUx; arc=none smtp.client-ip=46.38.233.203 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=osasysteme.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=osasysteme.de Received: from localhost (localhost [127.0.0.1]) by secondary.pambor.com (Postfix) with ESMTP id 2C0396EFF59; Sun, 4 Feb 2024 11:12:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=osasysteme.de; s=19022017; t=1707041531; bh=GP/K0NDMKaVN58IzCg9WjhrcSkEgoqe/cArG54xldsk=; h=From:To:Cc:Subject:Date:From; b=Eef8+IUxJ317AplhtmwG/8ulU4OYW5UtcgCdAZRUys/MAFhmzSUnnpkE6WT/hkity JmTe4QuvnGsjD7XQeCqPGTBJ7hCUi8OiGPb/YBDiLpPyrfFW8/m7sieKVfQ9J2oh5N Jy/aT1xI1F6f5RNPSHt2ybNDLSe+/XzR7csD+WfBfiZc+O36JCNmYuLf1kM24//0iU 9ZZYPmbzeJBC++kFvX0VdDwTnKAeTeKfvLeXoUdGLROM5tZsNNW6mTMlrpQexaxNX/ X/ODuYjMhnobCluYSkYrEOzMzrvVhTs2emsmZ4yReJPxAHZzSIB0Unfg+MqOBa+LGE q08tsqs73cV8w== X-Virus-Scanned: Debian amavisd-new at secondary.pambor.com Received: from secondary.pambor.com ([127.0.0.1]) by localhost (secondary.pambor.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id I7Kpfd2cu_BG; Sun, 4 Feb 2024 11:12:08 +0100 (CET) Received: from chromebook.fritz.box (dynamic-2a01-0c22-d419-0100-dbc6-7578-807d-f886.c22.pool.telefonica.de [IPv6:2a01:c22:d419:100:dbc6:7578:807d:f886]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.osasysteme.de (Postfix) with ESMTPSA id 3BD166EFE8E; Sun, 4 Feb 2024 11:12:07 +0100 (CET) From: Tim Pambor <tp@osasysteme.de> To: Andrew Lunn <andrew@lunn.ch> Cc: Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Dan Murphy <dmurphy@ti.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Tim Pambor <tp@osasysteme.de> Subject: [PATCH v2] net: phy: dp83822: Fix RGMII TX delay configuration Date: Sun, 4 Feb 2024 11:11:28 +0100 Message-ID: <20240204101128.49336-1-tp@osasysteme.de> X-Mailer: git-send-email 2.43.0 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790055835009357587 X-GMAIL-MSGID: 1790055835009357587 |
Series |
[v2] net: phy: dp83822: Fix RGMII TX delay configuration
|
|
Commit Message
Tim Pambor
Feb. 4, 2024, 10:11 a.m. UTC
The logic for enabling the TX clock shift is inverse of enabling the RX
clock shift. The TX clock shift is disabled when DP83822_TX_CLK_SHIFT is
set. Correct the current behavior and always write the delay configuration
to ensure consistent delay settings regardless of bootloader configuration.
Reference: https://www.ti.com/lit/ds/symlink/dp83822i.pdf p. 69
Fixes: 8095295292b5 ("net: phy: DP83822: Add setting the fixed internal delay")
Signed-off-by: Tim Pambor <tp@osasysteme.de>
---
Changes in v2:
- Further cleanup of RGMII configuration
- Check for errors setting DP83822_RGMII_MODE_EN
---
drivers/net/phy/dp83822.c | 41 +++++++++++++--------------------------
1 file changed, 14 insertions(+), 27 deletions(-)
Comments
On Sun, 2024-02-04 at 11:11 +0100, Tim Pambor wrote: > The logic for enabling the TX clock shift is inverse of enabling the RX > clock shift. The TX clock shift is disabled when DP83822_TX_CLK_SHIFT is > set. Correct the current behavior and always write the delay configuration > to ensure consistent delay settings regardless of bootloader configuration. > > Reference: https://www.ti.com/lit/ds/symlink/dp83822i.pdf p. 69 > > Fixes: 8095295292b5 ("net: phy: DP83822: Add setting the fixed internal delay") > Signed-off-by: Tim Pambor <tp@osasysteme.de> > --- > Changes in v2: > - Further cleanup of RGMII configuration This overall makes the change more invasive, I'm unsure is in the direction pointed by Russell > - Check for errors setting DP83822_RGMII_MODE_EN > --- > drivers/net/phy/dp83822.c | 41 +++++++++++++-------------------------- > 1 file changed, 14 insertions(+), 27 deletions(-) > > diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c > index b7cb71817780..1b2c34a97396 100644 > --- a/drivers/net/phy/dp83822.c > +++ b/drivers/net/phy/dp83822.c > @@ -380,42 +380,29 @@ static int dp83822_config_init(struct phy_device *phydev) > { > struct dp83822_private *dp83822 = phydev->priv; > struct device *dev = &phydev->mdio.dev; > - int rgmii_delay; > - s32 rx_int_delay; > - s32 tx_int_delay; > + int rcsr_mask = DP83822_RGMII_MODE_EN; > + int rcsr = 0; > int err = 0; > int bmcr; > > if (phy_interface_is_rgmii(phydev)) { > - rx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, > - true); > + rcsr |= DP83822_RGMII_MODE_EN; > > - if (rx_int_delay <= 0) > - rgmii_delay = 0; > - else > - rgmii_delay = DP83822_RX_CLK_SHIFT; > + /* Set DP83822_RX_CLK_SHIFT to enable rx clk internal delay */ > + if (phy_get_internal_delay(phydev, dev, NULL, 0, true) > 0) > + rcsr |= DP83822_RX_CLK_SHIFT; > > - tx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, > - false); > - if (tx_int_delay <= 0) > - rgmii_delay &= ~DP83822_TX_CLK_SHIFT; > - else > - rgmii_delay |= DP83822_TX_CLK_SHIFT; > + /* Set DP83822_TX_CLK_SHIFT to disable tx clk internal delay */ > + if (phy_get_internal_delay(phydev, dev, NULL, 0, false) <= 0) > + rcsr |= DP83822_TX_CLK_SHIFT; > > - if (rgmii_delay) { > - err = phy_set_bits_mmd(phydev, DP83822_DEVADDR, > - MII_DP83822_RCSR, rgmii_delay); > - if (err) > - return err; > - } > - > - phy_set_bits_mmd(phydev, DP83822_DEVADDR, > - MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); > - } else { > - phy_clear_bits_mmd(phydev, DP83822_DEVADDR, > - MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); > + rcsr_mask |= DP83822_RX_CLK_SHIFT | DP83822_TX_CLK_SHIFT; It looks like there is a change of behavior here. The current code clear the DP83822_RGMII_MODE_EN, while this patch will clear DP83822_RX_CLK_SHIFT | DP83822_TX_CLK_SHIFT, leaving DP83822_RGMII_MODE_EN unmodified. It does not look correct to me. Cheers, Paolo
Hi Paolo, On Thu, 2024-02-08 at 11:12 +0100, Paolo Abeni wrote: > On Sun, 2024-02-04 at 11:11 +0100, Tim Pambor wrote: > > The logic for enabling the TX clock shift is inverse of enabling > > the RX > > clock shift. The TX clock shift is disabled when > > DP83822_TX_CLK_SHIFT is > > set. Correct the current behavior and always write the delay > > configuration > > to ensure consistent delay settings regardless of bootloader > > configuration. > > > > Reference: https://www.ti.com/lit/ds/symlink/dp83822i.pdf p. 69 > > > > Fixes: 8095295292b5 ("net: phy: DP83822: Add setting the fixed > > internal delay") > > Signed-off-by: Tim Pambor <tp@osasysteme.de> > > --- > > Changes in v2: > > - Further cleanup of RGMII configuration > > This overall makes the change more invasive, I'm unsure is in the > direction pointed by Russell > > > - Check for errors setting DP83822_RGMII_MODE_EN > > --- > > drivers/net/phy/dp83822.c | 41 +++++++++++++---------------------- > > ---- > > 1 file changed, 14 insertions(+), 27 deletions(-) > > > > diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c > > index b7cb71817780..1b2c34a97396 100644 > > --- a/drivers/net/phy/dp83822.c > > +++ b/drivers/net/phy/dp83822.c > > @@ -380,42 +380,29 @@ static int dp83822_config_init(struct > > phy_device *phydev) > > { > > struct dp83822_private *dp83822 = phydev->priv; > > struct device *dev = &phydev->mdio.dev; > > - int rgmii_delay; > > - s32 rx_int_delay; > > - s32 tx_int_delay; > > + int rcsr_mask = DP83822_RGMII_MODE_EN; > > + int rcsr = 0; > > int err = 0; > > int bmcr; > > > > if (phy_interface_is_rgmii(phydev)) { > > - rx_int_delay = phy_get_internal_delay(phydev, dev, > > NULL, 0, > > - true); > > + rcsr |= DP83822_RGMII_MODE_EN; > > > > - if (rx_int_delay <= 0) > > - rgmii_delay = 0; > > - else > > - rgmii_delay = DP83822_RX_CLK_SHIFT; > > + /* Set DP83822_RX_CLK_SHIFT to enable rx clk > > internal delay */ > > + if (phy_get_internal_delay(phydev, dev, NULL, 0, > > true) > 0) > > + rcsr |= DP83822_RX_CLK_SHIFT; > > > > - tx_int_delay = phy_get_internal_delay(phydev, dev, > > NULL, 0, > > - false); > > - if (tx_int_delay <= 0) > > - rgmii_delay &= ~DP83822_TX_CLK_SHIFT; > > - else > > - rgmii_delay |= DP83822_TX_CLK_SHIFT; > > + /* Set DP83822_TX_CLK_SHIFT to disable tx clk > > internal delay */ > > + if (phy_get_internal_delay(phydev, dev, NULL, 0, > > false) <= 0) > > + rcsr |= DP83822_TX_CLK_SHIFT; > > > > - if (rgmii_delay) { > > - err = phy_set_bits_mmd(phydev, > > DP83822_DEVADDR, > > - MII_DP83822_RCSR, > > rgmii_delay); > > - if (err) > > - return err; > > - } > > - > > - phy_set_bits_mmd(phydev, DP83822_DEVADDR, > > - MII_DP83822_RCSR, > > DP83822_RGMII_MODE_EN); > > - } else { > > - phy_clear_bits_mmd(phydev, DP83822_DEVADDR, > > - MII_DP83822_RCSR, > > DP83822_RGMII_MODE_EN); > > + rcsr_mask |= DP83822_RX_CLK_SHIFT | > > DP83822_TX_CLK_SHIFT; > > It looks like there is a change of behavior here. The current code > clear the DP83822_RGMII_MODE_EN, while this patch will clear > DP83822_RX_CLK_SHIFT | DP83822_TX_CLK_SHIFT, leaving > DP83822_RGMII_MODE_EN unmodified. The behavior of DP83822_RGMII_MODE_EN should not have changed. DP83822_RGMII_MODE_EN is always set in rcsr_mask and if the interface is RGMII, DP83822_RX_CLK_SHIFT and DP83822_TX_CLK_SHIFT are added to the mask as well. I also have tested this patch on hardware with a DP83822 phy in RGMII mode. > > It does not look correct to me. > > Cheers, > > Paolo >
diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index b7cb71817780..1b2c34a97396 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -380,42 +380,29 @@ static int dp83822_config_init(struct phy_device *phydev) { struct dp83822_private *dp83822 = phydev->priv; struct device *dev = &phydev->mdio.dev; - int rgmii_delay; - s32 rx_int_delay; - s32 tx_int_delay; + int rcsr_mask = DP83822_RGMII_MODE_EN; + int rcsr = 0; int err = 0; int bmcr; if (phy_interface_is_rgmii(phydev)) { - rx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, - true); + rcsr |= DP83822_RGMII_MODE_EN; - if (rx_int_delay <= 0) - rgmii_delay = 0; - else - rgmii_delay = DP83822_RX_CLK_SHIFT; + /* Set DP83822_RX_CLK_SHIFT to enable rx clk internal delay */ + if (phy_get_internal_delay(phydev, dev, NULL, 0, true) > 0) + rcsr |= DP83822_RX_CLK_SHIFT; - tx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, - false); - if (tx_int_delay <= 0) - rgmii_delay &= ~DP83822_TX_CLK_SHIFT; - else - rgmii_delay |= DP83822_TX_CLK_SHIFT; + /* Set DP83822_TX_CLK_SHIFT to disable tx clk internal delay */ + if (phy_get_internal_delay(phydev, dev, NULL, 0, false) <= 0) + rcsr |= DP83822_TX_CLK_SHIFT; - if (rgmii_delay) { - err = phy_set_bits_mmd(phydev, DP83822_DEVADDR, - MII_DP83822_RCSR, rgmii_delay); - if (err) - return err; - } - - phy_set_bits_mmd(phydev, DP83822_DEVADDR, - MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); - } else { - phy_clear_bits_mmd(phydev, DP83822_DEVADDR, - MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); + rcsr_mask |= DP83822_RX_CLK_SHIFT | DP83822_TX_CLK_SHIFT; } + err = phy_modify_mmd(phydev, DP83822_DEVADDR, MII_DP83822_RCSR, rcsr_mask, rcsr); + if (err < 0) + return err; + if (dp83822->fx_enabled) { err = phy_modify(phydev, MII_DP83822_CTRL_2, DP83822_FX_ENABLE, 1);