All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 0/2] Fix system hang when loading mvneta module
@ 2013-06-20 22:06 Arnaud Patard
  2013-06-20 22:06 ` [patch 1/2] Fix hang when loading the mvneta driver Arnaud Patard
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Arnaud Patard @ 2013-06-20 22:06 UTC (permalink / raw)
  To: netdev; +Cc: Thomas Petazzoni

This patchset aims at fixing a system hang when loading the mvneta module.
I'm not sure what's meaning of the magical value used in patch 2 but at least,
it's used in code from Marvell and make things work.

Regards,
Arnaud

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

* [patch 1/2] Fix hang when loading the mvneta driver
  2013-06-20 22:06 [patch 0/2] Fix system hang when loading mvneta module Arnaud Patard
@ 2013-06-20 22:06 ` Arnaud Patard
  2013-06-20 22:06 ` [patch 2/2] Try to fix mvneta when compiled as module Arnaud Patard
  2013-07-15 14:34 ` [patch 0/2] Fix system hang when loading mvneta module Thomas Petazzoni
  2 siblings, 0 replies; 6+ messages in thread
From: Arnaud Patard @ 2013-06-20 22:06 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] 6+ messages in thread

* [patch 2/2] Try to fix mvneta when compiled as module
  2013-06-20 22:06 [patch 0/2] Fix system hang when loading mvneta module Arnaud Patard
  2013-06-20 22:06 ` [patch 1/2] Fix hang when loading the mvneta driver Arnaud Patard
@ 2013-06-20 22:06 ` Arnaud Patard
  2013-06-23  8:06   ` Thomas Petazzoni
  2013-07-15 14:34 ` [patch 0/2] Fix system hang when loading mvneta module Thomas Petazzoni
  2 siblings, 1 reply; 6+ messages in thread
From: Arnaud Patard @ 2013-06-20 22:06 UTC (permalink / raw)
  To: netdev; +Cc: Thomas Petazzoni

[-- Attachment #1: mvneta-init-fix.patch --]
[-- Type: text/plain, Size: 1570 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-06-20 23:39:37.485391949 +0200
+++ linux-next/drivers/net/ethernet/marvell/mvneta.c	2013-06-20 23:39:37.481391949 +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 MVETH_SGMII_SERDES_CFG			 0x24A0
+#define MVETH_SGMII_SERDES_STAT			 0x24A4
 #define MVNETA_TYPE_PRIO                         0x24bc
 #define      MVNETA_FORCE_UNI                    BIT(21)
 #define MVNETA_TXQ_CMD_1                         0x24e4
@@ -655,6 +657,7 @@ 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, MVETH_SGMII_SERDES_CFG, 0xcc7);
 }
 
 /* Start the Ethernet port RX and TX activity */

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

* Re: [patch 2/2] Try to fix mvneta when compiled as module
  2013-06-20 22:06 ` [patch 2/2] Try to fix mvneta when compiled as module Arnaud Patard
@ 2013-06-23  8:06   ` Thomas Petazzoni
  2013-06-24  7:43     ` Arnaud Patard
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2013-06-23  8:06 UTC (permalink / raw)
  To: Arnaud Patard; +Cc: netdev, Lior Amsalem, Gregory Clément, Ezequiel Garcia

Dear Arnaud Patard (Rtp),

On Fri, 21 Jun 2013 00:06:46 +0200, Arnaud Patard (Rtp) wrote:

> 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

According to the Armada XP functional datasheet, this magical value
0xCC7 is the one to be used to configure a SERDES interface to use the
"Protocol Generation Setting" SGMII. There are other magical values for
DRSGMII, SQGMII, SATA Gen I and SATA Gen II. So you could really do:

#define    MVNETA_SGMII_SERDES_PROTO	0xcc7

> 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-06-20 23:39:37.485391949 +0200
> +++ linux-next/drivers/net/ethernet/marvell/mvneta.c	2013-06-20 23:39:37.481391949 +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 MVETH_SGMII_SERDES_CFG			 0x24A0
> +#define MVETH_SGMII_SERDES_STAT			 0x24A4

You are not using this last define in your patch. Please also use
MVNETA_ prefix for those defines, like all the other ones.

However, there is one thing that I am not understanding completely. The
C code you pointed above seems to do the following:

	pRegAddr[3] = SGMII_SERDES_CFG_REG(sgmiiPort);
	pRegAddr[4] = SGMII_SERDES_STAT_REG(sgmiiPort);
	[..]
	pRegVal[3] = (pSerdesInfo->busSpeed & (1 << serdesLineNum)) != 0 ? 0x1547 : 0xCC7;
	pRegVal[4] = 0x7;

So:

 1) In some conditions, it will use the 0x1547 value in some cases, and
    0xCC7 in the other ones. And interestingly, the datasheet doesn't
    mention what the 0x1547 magical value is.

 2) It writes 0x7 to the SGMII_SERDES_STAT_REG register, but the
    datasheet mentions this register as a read-only register.

Best regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [patch 2/2] Try to fix mvneta when compiled as module
  2013-06-23  8:06   ` Thomas Petazzoni
@ 2013-06-24  7:43     ` Arnaud Patard
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaud Patard @ 2013-06-24  7:43 UTC (permalink / raw)
  To: Thomas Petazzoni
  Cc: netdev, Lior Amsalem, Gregory Clément, Ezequiel Garcia

Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

> Dear Arnaud Patard (Rtp),
>
> On Fri, 21 Jun 2013 00:06:46 +0200, Arnaud Patard (Rtp) wrote:
>
>> 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
>
> According to the Armada XP functional datasheet, this magical value
> 0xCC7 is the one to be used to configure a SERDES interface to use the
> "Protocol Generation Setting" SGMII. There are other magical values for
> DRSGMII, SQGMII, SATA Gen I and SATA Gen II. So you could really do:
>
> #define    MVNETA_SGMII_SERDES_PROTO	0xcc7
>

ok.

>> 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-06-20 23:39:37.485391949 +0200
>> +++ linux-next/drivers/net/ethernet/marvell/mvneta.c	2013-06-20 23:39:37.481391949 +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 MVETH_SGMII_SERDES_CFG			 0x24A0
>> +#define MVETH_SGMII_SERDES_STAT			 0x24A4
>
> You are not using this last define in your patch. Please also use
> MVNETA_ prefix for those defines, like all the other ones.
>
> However, there is one thing that I am not understanding completely. The
> C code you pointed above seems to do the following:
>
> 	pRegAddr[3] = SGMII_SERDES_CFG_REG(sgmiiPort);
> 	pRegAddr[4] = SGMII_SERDES_STAT_REG(sgmiiPort);
> 	[..]
> 	pRegVal[3] = (pSerdesInfo->busSpeed & (1 << serdesLineNum)) != 0 ? 0x1547 : 0xCC7;
> 	pRegVal[4] = 0x7;
>
> So:
>
>  1) In some conditions, it will use the 0x1547 value in some cases, and
>     0xCC7 in the other ones. And interestingly, the datasheet doesn't
>     mention what the 0x1547 magical value is.

The problem I got was that I didn't understand how to 'translate' the
(1 << serdesLineNum) part, so I removed it. Moreover, dumping the
registers when everything built-in (aka 'working'), I read a value
corresponding to the 0xcc7 case but not the other one so it seemed to me
it was safer to not use the 0x1547 case.

>
>  2) It writes 0x7 to the SGMII_SERDES_STAT_REG register, but the
>     datasheet mentions this register as a read-only register.

weird. Can be remains of code for old tape outs or something wrong on
the doc, 'fixed' in some pdf about erratas.

Thanks,
Arnaud

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

* Re: [patch 0/2] Fix system hang when loading mvneta module
  2013-06-20 22:06 [patch 0/2] Fix system hang when loading mvneta module Arnaud Patard
  2013-06-20 22:06 ` [patch 1/2] Fix hang when loading the mvneta driver Arnaud Patard
  2013-06-20 22:06 ` [patch 2/2] Try to fix mvneta when compiled as module Arnaud Patard
@ 2013-07-15 14:34 ` Thomas Petazzoni
  2 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2013-07-15 14:34 UTC (permalink / raw)
  To: Arnaud Patard; +Cc: netdev

Dear Arnaud Patard (Rtp),

On Fri, 21 Jun 2013 00:06:44 +0200, Arnaud Patard (Rtp) wrote:

> This patchset aims at fixing a system hang when loading the mvneta module.
> I'm not sure what's meaning of the magical value used in patch 2 but at least,
> it's used in code from Marvell and make things work.

3.11-rc1 is now out. Do you intend to resend an updated version of your
patch set, fixed according to the previous discussions?

Thanks!

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

end of thread, other threads:[~2013-07-15 14:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-20 22:06 [patch 0/2] Fix system hang when loading mvneta module Arnaud Patard
2013-06-20 22:06 ` [patch 1/2] Fix hang when loading the mvneta driver Arnaud Patard
2013-06-20 22:06 ` [patch 2/2] Try to fix mvneta when compiled as module Arnaud Patard
2013-06-23  8:06   ` Thomas Petazzoni
2013-06-24  7:43     ` Arnaud Patard
2013-07-15 14:34 ` [patch 0/2] Fix system hang when loading mvneta module Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.