netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/3] Bugfix for the netsec driver
@ 2018-10-23 11:24 masahisa.kojima
  2018-10-23 11:24 ` [PATCH net v2 1/3] net: socionext: Stop PHY before resetting netsec masahisa.kojima
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: masahisa.kojima @ 2018-10-23 11:24 UTC (permalink / raw)
  To: netdev
  Cc: ilias.apalodimas, jaswinder.singh, ard.biesheuvel,
	osaki.yoshitoyo, Masahisa Kojima

From: Masahisa Kojima <masahisa.kojima@linaro.org>

This patch series include bugfix for the netsec ethernet
controller driver, fix the problem in interface down/up.

changes in v2:
 - change the place to perform the PHY power down
 - use the MACROs defiend in include/uapi/linux/mii.h
 - update commit comment

Masahisa Kojima (3):
  net: socionext: Stop PHY before resetting netsec
  net: socionext: Add dummy PHY register read in phy_write()
  net: socionext: Reset tx queue in ndo_stop

 drivers/net/ethernet/socionext/netsec.c | 40 ++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 6 deletions(-)

-- 
2.14.2

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

* [PATCH net v2 1/3] net: socionext: Stop PHY before resetting netsec
  2018-10-23 11:24 [PATCH net v2 0/3] Bugfix for the netsec driver masahisa.kojima
@ 2018-10-23 11:24 ` masahisa.kojima
  2018-10-23 11:24 ` [PATCH net v2 2/3] net: socionext: Add dummy PHY register read in phy_write() masahisa.kojima
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: masahisa.kojima @ 2018-10-23 11:24 UTC (permalink / raw)
  To: netdev
  Cc: ilias.apalodimas, jaswinder.singh, ard.biesheuvel,
	osaki.yoshitoyo, Masahisa Kojima

From: Masahisa Kojima <masahisa.kojima@linaro.org>

In ndo_stop, driver resets the netsec ethernet controller IP.
When the netsec IP is reset, HW running mode turns to NRM mode
and driver has to wait until this mode transition completes.

But mode transition to NRM will not complete if the PHY is
in normal operation state. Netsec IP requires PHY is in
power down state when it is reset.

This modification stops the PHY before resetting netsec.

Together with this modification, phy_addr is stored in netsec_priv
structure because ndev->phydev is not yet ready in ndo_init.

Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver")
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Signed-off-by: Yoshitoyo Osaki <osaki.yoshitoyo@socionext.com>
---
changes in v2:
 - change the place to perform the PHY power down
 - use the MACROs defiend in include/uapi/linux/mii.h

 drivers/net/ethernet/socionext/netsec.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 7aa5ebb6766c..829ed2718b22 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -274,6 +274,7 @@ struct netsec_priv {
 	struct clk *clk;
 	u32 msg_enable;
 	u32 freq;
+	u32 phy_addr;
 	bool rx_cksum_offload_flag;
 };
 
@@ -1340,11 +1341,11 @@ static int netsec_netdev_stop(struct net_device *ndev)
 	netsec_uninit_pkt_dring(priv, NETSEC_RING_TX);
 	netsec_uninit_pkt_dring(priv, NETSEC_RING_RX);
 
-	ret = netsec_reset_hardware(priv, false);
-
 	phy_stop(ndev->phydev);
 	phy_disconnect(ndev->phydev);
 
+	ret = netsec_reset_hardware(priv, false);
+
 	pm_runtime_put_sync(priv->dev);
 
 	return ret;
@@ -1354,6 +1355,7 @@ static int netsec_netdev_init(struct net_device *ndev)
 {
 	struct netsec_priv *priv = netdev_priv(ndev);
 	int ret;
+	u16 data;
 
 	ret = netsec_alloc_dring(priv, NETSEC_RING_TX);
 	if (ret)
@@ -1363,6 +1365,11 @@ static int netsec_netdev_init(struct net_device *ndev)
 	if (ret)
 		goto err1;
 
+	/* set phy power down */
+	data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR) |
+		BMCR_PDOWN;
+	netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data);
+
 	ret = netsec_reset_hardware(priv, true);
 	if (ret)
 		goto err2;
@@ -1412,7 +1419,7 @@ static const struct net_device_ops netsec_netdev_ops = {
 };
 
 static int netsec_of_probe(struct platform_device *pdev,
-			   struct netsec_priv *priv)
+			   struct netsec_priv *priv, u32 *phy_addr)
 {
 	priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
 	if (!priv->phy_np) {
@@ -1420,6 +1427,8 @@ static int netsec_of_probe(struct platform_device *pdev,
 		return -EINVAL;
 	}
 
+	*phy_addr = of_mdio_parse_addr(&pdev->dev, priv->phy_np);
+
 	priv->clk = devm_clk_get(&pdev->dev, NULL); /* get by 'phy_ref_clk' */
 	if (IS_ERR(priv->clk)) {
 		dev_err(&pdev->dev, "phy_ref_clk not found\n");
@@ -1620,12 +1629,14 @@ static int netsec_probe(struct platform_device *pdev)
 	}
 
 	if (dev_of_node(&pdev->dev))
-		ret = netsec_of_probe(pdev, priv);
+		ret = netsec_of_probe(pdev, priv, &phy_addr);
 	else
 		ret = netsec_acpi_probe(pdev, priv, &phy_addr);
 	if (ret)
 		goto free_ndev;
 
+	priv->phy_addr = phy_addr;
+
 	if (!priv->freq) {
 		dev_err(&pdev->dev, "missing PHY reference clock frequency\n");
 		ret = -ENODEV;
-- 
2.14.2

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

* [PATCH net v2 2/3] net: socionext: Add dummy PHY register read in phy_write()
  2018-10-23 11:24 [PATCH net v2 0/3] Bugfix for the netsec driver masahisa.kojima
  2018-10-23 11:24 ` [PATCH net v2 1/3] net: socionext: Stop PHY before resetting netsec masahisa.kojima
@ 2018-10-23 11:24 ` masahisa.kojima
  2018-10-23 11:24 ` [PATCH net v2 3/3] net: socionext: Reset tx queue in ndo_stop masahisa.kojima
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: masahisa.kojima @ 2018-10-23 11:24 UTC (permalink / raw)
  To: netdev
  Cc: ilias.apalodimas, jaswinder.singh, ard.biesheuvel,
	osaki.yoshitoyo, Masahisa Kojima

From: Masahisa Kojima <masahisa.kojima@linaro.org>

There is a compatibility issue between RTL8211E implemented
in Developerbox and netsec ethernet controller IP.

Our MDIO controller stops MDC clock right after the write
access, but RTL8211E expects MDC clock must be kept toggling
for several clock cycle with MDIO high before entering
the IDLE state. Without keeping clock after write access,
write access is not correctly handled and register is not
updated.

To meet this requirement, netsec driver needs to issue dummy
read(e.g. read PHYID1(offset 0x2) register) right after write
access, to keep MDC clock.

We think this compatibility issue is a problem specific to
our MDIO controller and RTL8211E.

Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver")
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Signed-off-by: Yoshitoyo Osaki <osaki.yoshitoyo@socionext.com>
---
changes in v2:
 - use the MACROs defiend in include/uapi/linux/mii.h

 drivers/net/ethernet/socionext/netsec.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 829ed2718b22..5c295cc0b8f8 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -432,9 +432,12 @@ static int netsec_mac_update_to_phy_state(struct netsec_priv *priv)
 	return 0;
 }
 
+static int netsec_phy_read(struct mii_bus *bus, int phy_addr, int reg_addr);
+
 static int netsec_phy_write(struct mii_bus *bus,
 			    int phy_addr, int reg, u16 val)
 {
+	int status;
 	struct netsec_priv *priv = bus->priv;
 
 	if (netsec_mac_write(priv, GMAC_REG_GDR, val))
@@ -447,8 +450,19 @@ static int netsec_phy_write(struct mii_bus *bus,
 			      GMAC_REG_SHIFT_CR_GAR)))
 		return -ETIMEDOUT;
 
-	return netsec_mac_wait_while_busy(priv, GMAC_REG_GAR,
-					  NETSEC_GMAC_GAR_REG_GB);
+	status = netsec_mac_wait_while_busy(priv, GMAC_REG_GAR,
+					    NETSEC_GMAC_GAR_REG_GB);
+
+	/* Developerbox implements RTL8211E PHY and there is
+	 * a compatibility problem with F_GMAC4.
+	 * RTL8211E expects MDC clock must be kept toggling for several
+	 * clock cycle with MDIO high before entering the IDLE state.
+	 * To meet this requirement, netsec driver needs to issue dummy
+	 * read(e.g. read PHYID1(offset 0x2) register) right after write.
+	 */
+	netsec_phy_read(bus, phy_addr, MII_PHYSID1);
+
+	return status;
 }
 
 static int netsec_phy_read(struct mii_bus *bus, int phy_addr, int reg_addr)
-- 
2.14.2

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

* [PATCH net v2 3/3] net: socionext: Reset tx queue in ndo_stop
  2018-10-23 11:24 [PATCH net v2 0/3] Bugfix for the netsec driver masahisa.kojima
  2018-10-23 11:24 ` [PATCH net v2 1/3] net: socionext: Stop PHY before resetting netsec masahisa.kojima
  2018-10-23 11:24 ` [PATCH net v2 2/3] net: socionext: Add dummy PHY register read in phy_write() masahisa.kojima
@ 2018-10-23 11:24 ` masahisa.kojima
  2018-10-23 11:32 ` [PATCH net v2 0/3] Bugfix for the netsec driver Ard Biesheuvel
  2018-10-23 17:55 ` David Miller
  4 siblings, 0 replies; 7+ messages in thread
From: masahisa.kojima @ 2018-10-23 11:24 UTC (permalink / raw)
  To: netdev
  Cc: ilias.apalodimas, jaswinder.singh, ard.biesheuvel,
	osaki.yoshitoyo, Masahisa Kojima

From: Masahisa Kojima <masahisa.kojima@linaro.org>

We observed that packets and bytes count are not reset
when user performs interface down. Eventually, tx queue is
exhausted and packets will not be sent out.
To avoid this problem, resets tx queue in ndo_stop.

Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver")
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Signed-off-by: Yoshitoyo Osaki <osaki.yoshitoyo@socionext.com>
---
changes in v2:
 - update commit comment

 drivers/net/ethernet/socionext/netsec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 5c295cc0b8f8..d4da7e017207 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -952,6 +952,9 @@ static void netsec_uninit_pkt_dring(struct netsec_priv *priv, int id)
 	dring->head = 0;
 	dring->tail = 0;
 	dring->pkt_cnt = 0;
+
+	if (id == NETSEC_RING_TX)
+		netdev_reset_queue(priv->ndev);
 }
 
 static void netsec_free_dring(struct netsec_priv *priv, int id)
-- 
2.14.2

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

* Re: [PATCH net v2 0/3] Bugfix for the netsec driver
  2018-10-23 11:24 [PATCH net v2 0/3] Bugfix for the netsec driver masahisa.kojima
                   ` (2 preceding siblings ...)
  2018-10-23 11:24 ` [PATCH net v2 3/3] net: socionext: Reset tx queue in ndo_stop masahisa.kojima
@ 2018-10-23 11:32 ` Ard Biesheuvel
  2018-10-23 11:39   ` Masahisa Kojima
  2018-10-23 17:55 ` David Miller
  4 siblings, 1 reply; 7+ messages in thread
From: Ard Biesheuvel @ 2018-10-23 11:32 UTC (permalink / raw)
  To: Masahisa Kojima, Florian Fainelli
  Cc: <netdev@vger.kernel.org>,
	Ilias Apalodimas, Jaswinder Singh, Yoshitoyo Osaki

(+ Florian)

On 23 October 2018 at 08:24,  <masahisa.kojima@linaro.org> wrote:
> From: Masahisa Kojima <masahisa.kojima@linaro.org>
>
> This patch series include bugfix for the netsec ethernet
> controller driver, fix the problem in interface down/up.
>
> changes in v2:
>  - change the place to perform the PHY power down
>  - use the MACROs defiend in include/uapi/linux/mii.h
>  - update commit comment
>
> Masahisa Kojima (3):
>   net: socionext: Stop PHY before resetting netsec
>   net: socionext: Add dummy PHY register read in phy_write()
>   net: socionext: Reset tx queue in ndo_stop
>
>  drivers/net/ethernet/socionext/netsec.c | 40 ++++++++++++++++++++++++++++-----
>  1 file changed, 34 insertions(+), 6 deletions(-)
>

Hello Masahisa,

As a courtesy, please cc people that have commented on your patches on
subsequent revisions of the series.

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

* Re: [PATCH net v2 0/3] Bugfix for the netsec driver
  2018-10-23 11:32 ` [PATCH net v2 0/3] Bugfix for the netsec driver Ard Biesheuvel
@ 2018-10-23 11:39   ` Masahisa Kojima
  0 siblings, 0 replies; 7+ messages in thread
From: Masahisa Kojima @ 2018-10-23 11:39 UTC (permalink / raw)
  To: Ard Biesheuvel, Florian Fainelli
  Cc: netdev, Ilias Apalodimas, Jassi Brar, Yoshitoyo Osaki

Hi Florian, Ard,

Yes, that is my mistake. Thank you very much for pointing out, Ard.
On Tue, 23 Oct 2018 at 20:32, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> (+ Florian)
>
> On 23 October 2018 at 08:24,  <masahisa.kojima@linaro.org> wrote:
> > From: Masahisa Kojima <masahisa.kojima@linaro.org>
> >
> > This patch series include bugfix for the netsec ethernet
> > controller driver, fix the problem in interface down/up.
> >
> > changes in v2:
> >  - change the place to perform the PHY power down
> >  - use the MACROs defiend in include/uapi/linux/mii.h
> >  - update commit comment
> >
> > Masahisa Kojima (3):
> >   net: socionext: Stop PHY before resetting netsec
> >   net: socionext: Add dummy PHY register read in phy_write()
> >   net: socionext: Reset tx queue in ndo_stop
> >
> >  drivers/net/ethernet/socionext/netsec.c | 40 ++++++++++++++++++++++++++++-----
> >  1 file changed, 34 insertions(+), 6 deletions(-)
> >
>
> Hello Masahisa,
>
> As a courtesy, please cc people that have commented on your patches on
> subsequent revisions of the series.

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

* Re: [PATCH net v2 0/3] Bugfix for the netsec driver
  2018-10-23 11:24 [PATCH net v2 0/3] Bugfix for the netsec driver masahisa.kojima
                   ` (3 preceding siblings ...)
  2018-10-23 11:32 ` [PATCH net v2 0/3] Bugfix for the netsec driver Ard Biesheuvel
@ 2018-10-23 17:55 ` David Miller
  4 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2018-10-23 17:55 UTC (permalink / raw)
  To: masahisa.kojima
  Cc: netdev, ilias.apalodimas, jaswinder.singh, ard.biesheuvel,
	osaki.yoshitoyo

From: masahisa.kojima@linaro.org
Date: Tue, 23 Oct 2018 20:24:25 +0900

> From: Masahisa Kojima <masahisa.kojima@linaro.org>
> 
> This patch series include bugfix for the netsec ethernet
> controller driver, fix the problem in interface down/up.
> 
> changes in v2:
>  - change the place to perform the PHY power down
>  - use the MACROs defiend in include/uapi/linux/mii.h
>  - update commit comment

Series applied.

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

end of thread, other threads:[~2018-10-24  2:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23 11:24 [PATCH net v2 0/3] Bugfix for the netsec driver masahisa.kojima
2018-10-23 11:24 ` [PATCH net v2 1/3] net: socionext: Stop PHY before resetting netsec masahisa.kojima
2018-10-23 11:24 ` [PATCH net v2 2/3] net: socionext: Add dummy PHY register read in phy_write() masahisa.kojima
2018-10-23 11:24 ` [PATCH net v2 3/3] net: socionext: Reset tx queue in ndo_stop masahisa.kojima
2018-10-23 11:32 ` [PATCH net v2 0/3] Bugfix for the netsec driver Ard Biesheuvel
2018-10-23 11:39   ` Masahisa Kojima
2018-10-23 17:55 ` David Miller

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).