netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch v2 0/2] Fix system hang when loading mvneta module - take 2
@ 2013-07-29 19:56 Arnaud Patard
  2013-07-29 19:56 ` [patch v2 1/2] Fix hang when loading the mvneta driver Arnaud Patard
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arnaud Patard @ 2013-07-29 19:56 UTC (permalink / raw)
  To: netdev; +Cc: Thomas Petazzoni

Hi,

This is a second version of my patchset to fix mvneta as module.
I've addressed previous comments. I've also fixed probe
error path which was broken in the previous version.

Arnaud

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

* [patch v2 1/2] Fix hang when loading the mvneta driver
  2013-07-29 19:56 [patch v2 0/2] Fix system hang when loading mvneta module - take 2 Arnaud Patard
@ 2013-07-29 19:56 ` Arnaud Patard
  2013-07-29 19:56 ` [patch v2 2/2] Try to fix mvneta when compiled as module Arnaud Patard
  2013-07-31  2:32 ` [patch v2 0/2] Fix system hang when loading mvneta module - take 2 David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaud Patard @ 2013-07-29 19:56 UTC (permalink / raw)
  To: netdev; +Cc: Thomas Petazzoni

[-- Attachment #1: mvneta-module-hang.patch --]
[-- Type: text/plain, Size: 1608 bytes --]

When the mvneta driver is compiled, it'll be loaded with clocks disabled.
This implies that the clocks should be enabled again before any register
access or it'll hang.

To fix it:
- enable clock earlier
- move timer callback after setting timer.data

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>

Index: linux-next/drivers/net/ethernet/marvell/mvneta.c
===================================================================
--- linux-next.orig/drivers/net/ethernet/marvell/mvneta.c	2013-06-20 23:39:37.485391949 +0200
+++ linux-next/drivers/net/ethernet/marvell/mvneta.c	2013-06-20 23:39:37.481391949 +0200
@@ -2728,20 +2733,10 @@ static int mvneta_probe(struct platform_
 
 	pp = netdev_priv(dev);
 
-	pp->tx_done_timer.function = mvneta_tx_done_timer_callback;
-	init_timer(&pp->tx_done_timer);
-	clear_bit(MVNETA_F_TX_DONE_TIMER_BIT, &pp->flags);
-
 	pp->weight = MVNETA_RX_POLL_WEIGHT;
 	pp->phy_node = phy_node;
 	pp->phy_interface = phy_mode;
 
-	pp->base = of_iomap(dn, 0);
-	if (pp->base == NULL) {
-		err = -ENOMEM;
-		goto err_free_irq;
-	}
-
 	pp->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pp->clk)) {
 		err = PTR_ERR(pp->clk);
@@ -2765,7 +2760,16 @@ static int mvneta_probe(struct platform_
 		}
 	}
 
+	pp->base = of_iomap(dn, 0);
+	if (pp->base == NULL) {
+		err = -ENOMEM;
+		goto err_free_irq;
+	}
+
 	pp->tx_done_timer.data = (unsigned long)dev;
+	pp->tx_done_timer.function = mvneta_tx_done_timer_callback;
+	init_timer(&pp->tx_done_timer);
+	clear_bit(MVNETA_F_TX_DONE_TIMER_BIT, &pp->flags);
 
 	pp->tx_ring_size = MVNETA_MAX_TXD;
 	pp->rx_ring_size = MVNETA_MAX_RXD;

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

* [patch v2 2/2] Try to fix mvneta when compiled as module
  2013-07-29 19:56 [patch v2 0/2] Fix system hang when loading mvneta module - take 2 Arnaud Patard
  2013-07-29 19:56 ` [patch v2 1/2] Fix hang when loading the mvneta driver Arnaud Patard
@ 2013-07-29 19:56 ` Arnaud Patard
  2013-07-31  2:32 ` [patch v2 0/2] Fix system hang when loading mvneta module - take 2 David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaud Patard @ 2013-07-29 19:56 UTC (permalink / raw)
  To: netdev; +Cc: Thomas Petazzoni

[-- Attachment #1: mvneta-init-fix.patch --]
[-- Type: text/plain, Size: 2915 bytes --]

When the mvneta driver is compiled as module, the clock is disabled before
it's loading. This will reset the registers values and all configuration
made by the bootloader.

This patch sets the "sgmii serdes configuration" register to a magical value
found in:
https://github.com/yellowback/ubuntu-precise-armadaxp/blob/master/arch/arm/mach-armadaxp/armada_xp_family/ctrlEnv/mvCtrlEnvLib.c

With this change, the interrupts are working/generated and ethernet is
working.

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>

Index: linux-next/drivers/net/ethernet/marvell/mvneta.c
===================================================================
--- linux-next.orig/drivers/net/ethernet/marvell/mvneta.c	2013-07-29 21:48:20.673275215 +0200
+++ linux-next/drivers/net/ethernet/marvell/mvneta.c	2013-07-29 21:53:03.021262793 +0200
@@ -88,6 +88,8 @@
 #define      MVNETA_TX_IN_PRGRS                  BIT(1)
 #define      MVNETA_TX_FIFO_EMPTY                BIT(8)
 #define MVNETA_RX_MIN_FRAME_SIZE                 0x247c
+#define MVNETA_SGMII_SERDES_CFG			 0x24A0
+#define      MVNETA_SGMII_SERDES_PROTO		 0x0cc7
 #define MVNETA_TYPE_PRIO                         0x24bc
 #define      MVNETA_FORCE_UNI                    BIT(21)
 #define MVNETA_TXQ_CMD_1                         0x24e4
@@ -655,6 +657,8 @@ static void mvneta_port_sgmii_config(str
 	val = mvreg_read(pp, MVNETA_GMAC_CTRL_2);
 	val |= MVNETA_GMAC2_PSC_ENABLE;
 	mvreg_write(pp, MVNETA_GMAC_CTRL_2, val);
+
+	mvreg_write(pp, MVNETA_SGMII_SERDES_CFG, MVNETA_SGMII_SERDES_PROTO);
 }
 
 /* Start the Ethernet port RX and TX activity */
@@ -2735,11 +2739,17 @@ static int mvneta_probe(struct platform_
 	pp->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pp->clk)) {
 		err = PTR_ERR(pp->clk);
-		goto err_unmap;
+		goto err_free_irq;
 	}
 
 	clk_prepare_enable(pp->clk);
 
+	pp->base = of_iomap(dn, 0);
+	if (pp->base == NULL) {
+		err = -ENOMEM;
+		goto err_clk;
+	}
+
 	dt_mac_addr = of_get_mac_address(dn);
 	if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) {
 		mac_from = "device tree";
@@ -2755,12 +2765,6 @@ static int mvneta_probe(struct platform_
 		}
 	}
 
-	pp->base = of_iomap(dn, 0);
-	if (pp->base == NULL) {
-		err = -ENOMEM;
-		goto err_free_irq;
-	}
-
 	pp->tx_done_timer.data = (unsigned long)dev;
 	pp->tx_done_timer.function = mvneta_tx_done_timer_callback;
 	init_timer(&pp->tx_done_timer);
@@ -2775,7 +2779,7 @@ static int mvneta_probe(struct platform_
 	err = mvneta_init(pp, phy_addr);
 	if (err < 0) {
 		dev_err(&pdev->dev, "can't init eth hal\n");
-		goto err_clk;
+		goto err_unmap;
 	}
 	mvneta_port_power_up(pp, phy_mode);
 
@@ -2805,10 +2809,10 @@ static int mvneta_probe(struct platform_
 
 err_deinit:
 	mvneta_deinit(pp);
-err_clk:
-	clk_disable_unprepare(pp->clk);
 err_unmap:
 	iounmap(pp->base);
+err_clk:
+	clk_disable_unprepare(pp->clk);
 err_free_irq:
 	irq_dispose_mapping(dev->irq);
 err_free_netdev:

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

* Re: [patch v2 0/2] Fix system hang when loading mvneta module - take 2
  2013-07-29 19:56 [patch v2 0/2] Fix system hang when loading mvneta module - take 2 Arnaud Patard
  2013-07-29 19:56 ` [patch v2 1/2] Fix hang when loading the mvneta driver Arnaud Patard
  2013-07-29 19:56 ` [patch v2 2/2] Try to fix mvneta when compiled as module Arnaud Patard
@ 2013-07-31  2:32 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-07-31  2:32 UTC (permalink / raw)
  To: arnaud.patard; +Cc: netdev, thomas.petazzoni

From: Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org>
Date: Mon, 29 Jul 2013 21:56:46 +0200

> This is a second version of my patchset to fix mvneta as module.
> I've addressed previous comments. I've also fixed probe
> error path which was broken in the previous version.

Both applied, thanks.

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

end of thread, other threads:[~2013-07-31  2:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-29 19:56 [patch v2 0/2] Fix system hang when loading mvneta module - take 2 Arnaud Patard
2013-07-29 19:56 ` [patch v2 1/2] Fix hang when loading the mvneta driver Arnaud Patard
2013-07-29 19:56 ` [patch v2 2/2] Try to fix mvneta when compiled as module Arnaud Patard
2013-07-31  2:32 ` [patch v2 0/2] Fix system hang when loading mvneta module - take 2 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).