linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays
@ 2023-05-22 12:28 Harini Katakam
  2023-05-22 12:28 ` [PATCH net-next v4 1/2] phy: mscc: Use PHY_ID_MATCH_VENDOR to minimize PHY ID table Harini Katakam
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Harini Katakam @ 2023-05-22 12:28 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, kuba, edumazet, pabeni,
	vladimir.oltean, wsa+renesas, simon.horman
  Cc: netdev, linux-kernel, harinikatakamlinux, michal.simek,
	harini.katakam, radhey.shyam.pandey

Provide an option to change RGMII delay value via devicetree.

v4:
- Remove VSC8531_02 support. Existing code will identify VSC8531_01/02
and there is no unique functionality to be added for either version.
- Correct type of rx/tx_delay to accept correct return value.
- Added Andrew's tag to patch 1

Lore link for v3: 
https://lore.kernel.org/netdev/20230511120808.28646-1-harini.katakam@amd.com/

v3 changes:
- Remove patch 2/3 from v2 as custom mscc properties dont need to be
defined. rx-internal-delay-ps and tx-internal-delay-ps can be used.
- Change RGMII delay precedence as advised by Vladimir:
 phy-mode                       rgmii                          rgmii-rxid/rgmii-id
 --------------------------------------------------------------------------------------------
 rx-internal-delay-ps absent    0.2 ns                         2 ns
 rx-internal-delay-ps present   follow rx-internal-delay-ps    follow rx-internal-delay-ps
- Split VSC8531-02 and RGMII delay config into separate patches.
- Correct vendor ID
- Update commit description and subject everywhere to say RGMII delays
instead of RGMII tuning.

v2 changes:
- Added patch to use a common vendor phy id match
- Removed dt include header patch because delays should be specied in
ps, not register values
- Updated DT binding description and commit for optional delay tuning to
be clearer on the precedence
- Updated dt property name to include vendor instead of phy device name
- Switch both VSC8531 and VSC8531-02 to use exact phy id match as they
share the same model number
- Ensure RCT
- Improve optional property read

Harini Katakam (2):
  phy: mscc: Use PHY_ID_MATCH_VENDOR to minimize PHY ID table
  phy: mscc: Add support for RGMII delay configuration

 drivers/net/phy/mscc/mscc.h      |  3 ++
 drivers/net/phy/mscc/mscc_main.c | 49 +++++++++++++++++++-------------
 2 files changed, 32 insertions(+), 20 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next v4 1/2] phy: mscc: Use PHY_ID_MATCH_VENDOR to minimize PHY ID table
  2023-05-22 12:28 [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays Harini Katakam
@ 2023-05-22 12:28 ` Harini Katakam
  2023-05-22 12:28 ` [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration Harini Katakam
  2023-05-24  9:56 ` [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays Vladimir Oltean
  2 siblings, 0 replies; 8+ messages in thread
From: Harini Katakam @ 2023-05-22 12:28 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, kuba, edumazet, pabeni,
	vladimir.oltean, wsa+renesas, simon.horman
  Cc: netdev, linux-kernel, harinikatakamlinux, michal.simek,
	harini.katakam, radhey.shyam.pandey

All the PHY devices variants specified have the same mask and
hence can be simplified to one vendor look up for 0x00070400.
Any individual config can be identified by PHY_ID_MATCH_EXACT
in the respective structure.

Signed-off-by: Harini Katakam <harini.katakam@amd.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
v4:
Added Andrew's tag
v3:
Correct vendor ID
v2:
New patch
 drivers/net/phy/mscc/mscc.h      |  1 +
 drivers/net/phy/mscc/mscc_main.c | 14 +-------------
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h
index a50235fdf7d9..9acee8759105 100644
--- a/drivers/net/phy/mscc/mscc.h
+++ b/drivers/net/phy/mscc/mscc.h
@@ -290,6 +290,7 @@ enum rgmii_clock_delay {
 #define PHY_ID_VSC8575			  0x000707d0
 #define PHY_ID_VSC8582			  0x000707b0
 #define PHY_ID_VSC8584			  0x000707c0
+#define PHY_VENDOR_MSCC			0x00070400
 
 #define MSCC_VDDMAC_1500		  1500
 #define MSCC_VDDMAC_1800		  1800
diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
index 62bf99e45af1..91010524e03d 100644
--- a/drivers/net/phy/mscc/mscc_main.c
+++ b/drivers/net/phy/mscc/mscc_main.c
@@ -2656,19 +2656,7 @@ static struct phy_driver vsc85xx_driver[] = {
 module_phy_driver(vsc85xx_driver);
 
 static struct mdio_device_id __maybe_unused vsc85xx_tbl[] = {
-	{ PHY_ID_VSC8504, 0xfffffff0, },
-	{ PHY_ID_VSC8514, 0xfffffff0, },
-	{ PHY_ID_VSC8530, 0xfffffff0, },
-	{ PHY_ID_VSC8531, 0xfffffff0, },
-	{ PHY_ID_VSC8540, 0xfffffff0, },
-	{ PHY_ID_VSC8541, 0xfffffff0, },
-	{ PHY_ID_VSC8552, 0xfffffff0, },
-	{ PHY_ID_VSC856X, 0xfffffff0, },
-	{ PHY_ID_VSC8572, 0xfffffff0, },
-	{ PHY_ID_VSC8574, 0xfffffff0, },
-	{ PHY_ID_VSC8575, 0xfffffff0, },
-	{ PHY_ID_VSC8582, 0xfffffff0, },
-	{ PHY_ID_VSC8584, 0xfffffff0, },
+	{ PHY_ID_MATCH_VENDOR(PHY_VENDOR_MSCC) },
 	{ }
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration
  2023-05-22 12:28 [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays Harini Katakam
  2023-05-22 12:28 ` [PATCH net-next v4 1/2] phy: mscc: Use PHY_ID_MATCH_VENDOR to minimize PHY ID table Harini Katakam
@ 2023-05-22 12:28 ` Harini Katakam
  2023-05-24  3:32   ` Jakub Kicinski
  2023-05-24 10:09   ` Vladimir Oltean
  2023-05-24  9:56 ` [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays Vladimir Oltean
  2 siblings, 2 replies; 8+ messages in thread
From: Harini Katakam @ 2023-05-22 12:28 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, kuba, edumazet, pabeni,
	vladimir.oltean, wsa+renesas, simon.horman
  Cc: netdev, linux-kernel, harinikatakamlinux, michal.simek,
	harini.katakam, radhey.shyam.pandey

Add support for optional rx/tx-internal-delay-ps from devicetree.
- When rx/tx-internal-delay-ps is/are specified, these take priority
- When either is absent,
1) use 2ns for respective settings if rgmii-id/rxid/txid is/are present
2) use 0.2ns for respective settings if mode is rgmii

Signed-off-by: Harini Katakam <harini.katakam@amd.com>
---
v4:
Fix type of rx_delay and tx_delay
Reported by Simon Horman and
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202305140248.lh4LUw2j-lkp@intel.com/
v3 - Patch split:
- Use rx/tx-internal-delay-ps with phy_get_internal_delay
- Change RGMII delay selection precedence
- Update commit description and subject everywhere to say RGMII delays
instead of RGMII tuning.
 drivers/net/phy/mscc/mscc.h      |  2 ++
 drivers/net/phy/mscc/mscc_main.c | 35 +++++++++++++++++++++++++-------
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h
index 9acee8759105..900bf37db9de 100644
--- a/drivers/net/phy/mscc/mscc.h
+++ b/drivers/net/phy/mscc/mscc.h
@@ -374,6 +374,8 @@ struct vsc8531_private {
 	 * package.
 	 */
 	unsigned int base_addr;
+	s32 rx_delay;
+	s32 tx_delay;
 
 #if IS_ENABLED(CONFIG_MACSEC)
 	/* MACsec fields:
diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
index 91010524e03d..9e856231e464 100644
--- a/drivers/net/phy/mscc/mscc_main.c
+++ b/drivers/net/phy/mscc/mscc_main.c
@@ -525,17 +525,14 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl,
 {
 	u16 rgmii_rx_delay_pos = ffs(rgmii_rx_delay_mask) - 1;
 	u16 rgmii_tx_delay_pos = ffs(rgmii_tx_delay_mask) - 1;
+	struct vsc8531_private *vsc8531 = phydev->priv;
 	u16 reg_val = 0;
 	int rc;
 
 	mutex_lock(&phydev->lock);
 
-	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
-	    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
-		reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos;
-	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
-	    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
-		reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos;
+	reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos;
+	reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos;
 
 	rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2,
 			      rgmii_cntl,
@@ -1808,10 +1805,34 @@ static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev)
 	return IRQ_HANDLED;
 }
 
+static const int vsc8531_internal_delay[] = {200, 800, 1100, 1700, 2000, 2300,
+					     2600, 3400};
 static int vsc85xx_config_init(struct phy_device *phydev)
 {
-	int rc, i, phy_id;
+	int delay_size = ARRAY_SIZE(vsc8531_internal_delay);
 	struct vsc8531_private *vsc8531 = phydev->priv;
+	struct device *dev = &phydev->mdio.dev;
+	int rc, i, phy_id;
+
+	vsc8531->rx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0],
+						   delay_size, true);
+	if (vsc8531->rx_delay < 0) {
+		if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
+		    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
+			vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS;
+		else
+			vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS;
+	}
+
+	vsc8531->tx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0],
+						   delay_size, false);
+	if (vsc8531->tx_delay < 0) {
+		if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
+		    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
+			vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS;
+		else
+			vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS;
+	}
 
 	rc = vsc85xx_default_config(phydev);
 	if (rc)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration
  2023-05-22 12:28 ` [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration Harini Katakam
@ 2023-05-24  3:32   ` Jakub Kicinski
  2023-05-24 10:09   ` Vladimir Oltean
  1 sibling, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2023-05-24  3:32 UTC (permalink / raw)
  To: andrew, vladimir.oltean
  Cc: Harini Katakam, hkallweit1, linux, davem, edumazet, pabeni,
	wsa+renesas, simon.horman, netdev, linux-kernel,
	harinikatakamlinux, michal.simek, radhey.shyam.pandey

On Mon, 22 May 2023 17:58:29 +0530 Harini Katakam wrote:
> Add support for optional rx/tx-internal-delay-ps from devicetree.
> - When rx/tx-internal-delay-ps is/are specified, these take priority
> - When either is absent,
> 1) use 2ns for respective settings if rgmii-id/rxid/txid is/are present
> 2) use 0.2ns for respective settings if mode is rgmii
> 
> Signed-off-by: Harini Katakam <harini.katakam@amd.com>

PHY folks, looks good?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays
  2023-05-22 12:28 [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays Harini Katakam
  2023-05-22 12:28 ` [PATCH net-next v4 1/2] phy: mscc: Use PHY_ID_MATCH_VENDOR to minimize PHY ID table Harini Katakam
  2023-05-22 12:28 ` [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration Harini Katakam
@ 2023-05-24  9:56 ` Vladimir Oltean
  2023-05-24 10:15   ` Katakam, Harini
  2 siblings, 1 reply; 8+ messages in thread
From: Vladimir Oltean @ 2023-05-24  9:56 UTC (permalink / raw)
  To: Harini Katakam
  Cc: andrew, hkallweit1, linux, davem, kuba, edumazet, pabeni,
	wsa+renesas, simon.horman, netdev, linux-kernel,
	harinikatakamlinux, michal.simek, radhey.shyam.pandey

Hi Harini,

On Mon, May 22, 2023 at 05:58:27PM +0530, Harini Katakam wrote:
> Provide an option to change RGMII delay value via devicetree.
> 
> v4:
> - Remove VSC8531_02 support. Existing code will identify VSC8531_01/02
> and there is no unique functionality to be added for either version.
> - Correct type of rx/tx_delay to accept correct return value.
> - Added Andrew's tag to patch 1

Would you mind waiting until this patch set for "net" is merged first,
then rebasing your "net-next" work on top of it?
https://patchwork.kernel.org/project/netdevbpf/cover/20230523153108.18548-1-david.epping@missinglinkelectronics.com/

You should be able to resend your patch set tomorrow, after the net pull
request and the subsequent net -> net-next merge.

There are going to be merge conflicts if your series gets applied
simultaneously, and they're ugly enough that I would prefer you to deal
with them locally, before submitting, rather than leaving the netdev
maintainers do it.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration
  2023-05-22 12:28 ` [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration Harini Katakam
  2023-05-24  3:32   ` Jakub Kicinski
@ 2023-05-24 10:09   ` Vladimir Oltean
  2023-05-24 11:38     ` Katakam, Harini
  1 sibling, 1 reply; 8+ messages in thread
From: Vladimir Oltean @ 2023-05-24 10:09 UTC (permalink / raw)
  To: Harini Katakam
  Cc: andrew, hkallweit1, linux, davem, kuba, edumazet, pabeni,
	wsa+renesas, simon.horman, netdev, linux-kernel,
	harinikatakamlinux, michal.simek, radhey.shyam.pandey

On Mon, May 22, 2023 at 05:58:29PM +0530, Harini Katakam wrote:
> diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
> index 91010524e03d..9e856231e464 100644
> --- a/drivers/net/phy/mscc/mscc_main.c
> +++ b/drivers/net/phy/mscc/mscc_main.c
> @@ -525,17 +525,14 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl,
>  {
>  	u16 rgmii_rx_delay_pos = ffs(rgmii_rx_delay_mask) - 1;
>  	u16 rgmii_tx_delay_pos = ffs(rgmii_tx_delay_mask) - 1;
> +	struct vsc8531_private *vsc8531 = phydev->priv;
>  	u16 reg_val = 0;
>  	int rc;
>  
>  	mutex_lock(&phydev->lock);
>  
> -	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
> -	    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> -		reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos;
> -	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
> -	    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> -		reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos;
> +	reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos;
> +	reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos;

What about vsc8584_config_init() -> vsc85xx_rgmii_set_skews()? Who will
have configured rx_delay and tx_delay for that call path?

Isn't it better to absorb the device tree parsing logic into
vsc85xx_rgmii_set_skews(), I wonder?

And if we do that, is it still necessary to use struct vsc8531_private
as temporary storage space from vsc85xx_config_init() to vsc85xx_rgmii_set_skews(),
or will two local variables (rx_delay, tx_delay) serve that purpose just fine?

>  
>  	rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2,
>  			      rgmii_cntl,
> @@ -1808,10 +1805,34 @@ static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev)
>  	return IRQ_HANDLED;
>  }
>  
> +static const int vsc8531_internal_delay[] = {200, 800, 1100, 1700, 2000, 2300,
> +					     2600, 3400};

Could you please avoid intermingling this with the function code, and
move it at the top of mscc_main.c?

Also, vsc8531_internal_delay[] or vsc85xx_internal_delay[]? The values
are also good for VSC8572, the other caller of vsc85xx_rgmii_set_skews().

>  static int vsc85xx_config_init(struct phy_device *phydev)
>  {
> -	int rc, i, phy_id;
> +	int delay_size = ARRAY_SIZE(vsc8531_internal_delay);
>  	struct vsc8531_private *vsc8531 = phydev->priv;
> +	struct device *dev = &phydev->mdio.dev;
> +	int rc, i, phy_id;
> +
> +	vsc8531->rx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0],

You can just write "x" rather than "&x[0]".

> +						   delay_size, true);
> +	if (vsc8531->rx_delay < 0) {
> +		if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
> +		    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> +			vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS;
> +		else
> +			vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS;
> +	}
> +
> +	vsc8531->tx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0],
> +						   delay_size, false);
> +	if (vsc8531->tx_delay < 0) {
> +		if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
> +		    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> +			vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS;
> +		else
> +			vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS;
> +	}
>  
>  	rc = vsc85xx_default_config(phydev);
>  	if (rc)
> -- 
> 2.17.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays
  2023-05-24  9:56 ` [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays Vladimir Oltean
@ 2023-05-24 10:15   ` Katakam, Harini
  0 siblings, 0 replies; 8+ messages in thread
From: Katakam, Harini @ 2023-05-24 10:15 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: andrew, hkallweit1, linux, davem, kuba, edumazet, pabeni,
	wsa+renesas, simon.horman, netdev, linux-kernel,
	harinikatakamlinux, Simek, Michal, Pandey, Radhey Shyam

Hi Vladimir,

> -----Original Message-----
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> Sent: Wednesday, May 24, 2023 3:27 PM
> To: Katakam, Harini <harini.katakam@amd.com>
> Cc: andrew@lunn.ch; hkallweit1@gmail.com; linux@armlinux.org.uk;
> davem@davemloft.net; kuba@kernel.org; edumazet@google.com;
> pabeni@redhat.com; wsa+renesas@sang-engineering.com;
> simon.horman@corigine.com; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; harinikatakamlinux@gmail.com; Simek, Michal
> <michal.simek@amd.com>; Pandey, Radhey Shyam
> <radhey.shyam.pandey@amd.com>
> Subject: Re: [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII
> delays
> 
> Hi Harini,
> 
> On Mon, May 22, 2023 at 05:58:27PM +0530, Harini Katakam wrote:
> > Provide an option to change RGMII delay value via devicetree.
> >
> > v4:
> > - Remove VSC8531_02 support. Existing code will identify VSC8531_01/02
> > and there is no unique functionality to be added for either version.
> > - Correct type of rx/tx_delay to accept correct return value.
> > - Added Andrew's tag to patch 1
> 
> Would you mind waiting until this patch set for "net" is merged first, then
> rebasing your "net-next" work on top of it?
> https://patchwork.kernel.org/project/netdevbpf/cover/20230523153108.1854
> 8-1-david.epping@missinglinkelectronics.com/
> 
> You should be able to resend your patch set tomorrow, after the net pull
> request and the subsequent net -> net-next merge.
> 
> There are going to be merge conflicts if your series gets applied
> simultaneously, and they're ugly enough that I would prefer you to deal with
> them locally, before submitting, rather than leaving the netdev maintainers do
> it.

Ok sure, I'll wait and rebase after the above set is merged.

Regards,
Harini


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration
  2023-05-24 10:09   ` Vladimir Oltean
@ 2023-05-24 11:38     ` Katakam, Harini
  0 siblings, 0 replies; 8+ messages in thread
From: Katakam, Harini @ 2023-05-24 11:38 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: andrew, hkallweit1, linux, davem, kuba, edumazet, pabeni,
	wsa+renesas, simon.horman, netdev, linux-kernel,
	harinikatakamlinux, Simek, Michal, Pandey, Radhey Shyam

Hi Vladimir,

> -----Original Message-----
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> Sent: Wednesday, May 24, 2023 3:39 PM
> To: Katakam, Harini <harini.katakam@amd.com>
> Cc: andrew@lunn.ch; hkallweit1@gmail.com; linux@armlinux.org.uk;
> davem@davemloft.net; kuba@kernel.org; edumazet@google.com;
> pabeni@redhat.com; wsa+renesas@sang-engineering.com;
> simon.horman@corigine.com; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; harinikatakamlinux@gmail.com; Simek, Michal
> <michal.simek@amd.com>; Pandey, Radhey Shyam
> <radhey.shyam.pandey@amd.com>
> Subject: Re: [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay
> configuration
> 
> On Mon, May 22, 2023 at 05:58:29PM +0530, Harini Katakam wrote:
> > diff --git a/drivers/net/phy/mscc/mscc_main.c
> b/drivers/net/phy/mscc/mscc_main.c
> > index 91010524e03d..9e856231e464 100644
> > --- a/drivers/net/phy/mscc/mscc_main.c
> > +++ b/drivers/net/phy/mscc/mscc_main.c
> > @@ -525,17 +525,14 @@ static int vsc85xx_rgmii_set_skews(struct
> phy_device *phydev, u32 rgmii_cntl,
> >  {
> >  	u16 rgmii_rx_delay_pos = ffs(rgmii_rx_delay_mask) - 1;
> >  	u16 rgmii_tx_delay_pos = ffs(rgmii_tx_delay_mask) - 1;
> > +	struct vsc8531_private *vsc8531 = phydev->priv;
> >  	u16 reg_val = 0;
> >  	int rc;
> >
> >  	mutex_lock(&phydev->lock);
> >
> > -	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
> > -	    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> > -		reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos;
> > -	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
> > -	    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> > -		reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos;
> > +	reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos;
> > +	reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos;
> 
> What about vsc8584_config_init() -> vsc85xx_rgmii_set_skews()? Who will
> have configured rx_delay and tx_delay for that call path?

In my current series "rx_delay" and "tx_delay" would end up 0 and a
delay of 0.2 ns will be programmed (default for that field).
I guess if the phy-mode is RGMII/-ID on VSC8584, 2ns will not be programmed.
This will be a problem for any device not using vsc85xx_config_init

> 
> Isn't it better to absorb the device tree parsing logic into
> vsc85xx_rgmii_set_skews(), I wonder?

Yes, that is possible, let me respin. That will ensure existing values are not broken
for any VSC85xx user, if they do not have delay properties in the DT.

> 
> And if we do that, is it still necessary to use struct vsc8531_private
> as temporary storage space from vsc85xx_config_init() to
> vsc85xx_rgmii_set_skews(),
> or will two local variables (rx_delay, tx_delay) serve that purpose just fine?

No need of the structure member, local variables will do.

> 
> >
> >  	rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2,
> >  			      rgmii_cntl,
> > @@ -1808,10 +1805,34 @@ static irqreturn_t
> vsc8584_handle_interrupt(struct phy_device *phydev)
> >  	return IRQ_HANDLED;
> >  }
> >
> > +static const int vsc8531_internal_delay[] = {200, 800, 1100, 1700, 2000,
> 2300,
> > +					     2600, 3400};
> 
> Could you please avoid intermingling this with the function code, and
> move it at the top of mscc_main.c?
> 
> Also, vsc8531_internal_delay[] or vsc85xx_internal_delay[]? The values
> are also good for VSC8572, the other caller of vsc85xx_rgmii_set_skews().

vsc85xx_internal_delay is more appropriate, will change.

Thanks for the review.

Regards,
Harini

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-24 11:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22 12:28 [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays Harini Katakam
2023-05-22 12:28 ` [PATCH net-next v4 1/2] phy: mscc: Use PHY_ID_MATCH_VENDOR to minimize PHY ID table Harini Katakam
2023-05-22 12:28 ` [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration Harini Katakam
2023-05-24  3:32   ` Jakub Kicinski
2023-05-24 10:09   ` Vladimir Oltean
2023-05-24 11:38     ` Katakam, Harini
2023-05-24  9:56 ` [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delays Vladimir Oltean
2023-05-24 10:15   ` Katakam, Harini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).