All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix sleeping function called from invalid context
@ 2014-11-13  7:02 ` Yoshihiro Kaneko
  0 siblings, 0 replies; 25+ messages in thread
From: Yoshihiro Kaneko @ 2014-11-13  7:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh

This series is based on net tree.

Mitsuhiro Kimura (2):
  sh_eth: Fix sleeping function called from invalid context
  sh_eth: Fix asynchronous external abort

 drivers/net/ethernet/renesas/sh_eth.c | 70 ++++++++++++++++++++---------------
 drivers/net/ethernet/renesas/sh_eth.h |  1 +
 2 files changed, 42 insertions(+), 29 deletions(-)

-- 
1.9.1


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

* [PATCH 0/2] Fix sleeping function called from invalid context
@ 2014-11-13  7:02 ` Yoshihiro Kaneko
  0 siblings, 0 replies; 25+ messages in thread
From: Yoshihiro Kaneko @ 2014-11-13  7:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh

This series is based on net tree.

Mitsuhiro Kimura (2):
  sh_eth: Fix sleeping function called from invalid context
  sh_eth: Fix asynchronous external abort

 drivers/net/ethernet/renesas/sh_eth.c | 70 ++++++++++++++++++++---------------
 drivers/net/ethernet/renesas/sh_eth.h |  1 +
 2 files changed, 42 insertions(+), 29 deletions(-)

-- 
1.9.1


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

* [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
  2014-11-13  7:02 ` Yoshihiro Kaneko
@ 2014-11-13  7:02   ` Yoshihiro Kaneko
  -1 siblings, 0 replies; 25+ messages in thread
From: Yoshihiro Kaneko @ 2014-11-13  7:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh

From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

Fix the bug as follows:

----
[ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
[ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
[ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
[ 1238.230737] Backtrace:
[ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
[ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
[ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
[ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
[ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
[ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
[ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
[ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
[ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
[ 1238.446204]  r5:d5c21000 r4:d5ed7e08
[ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
[ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
[ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
[ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
[ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
[ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
[ 1238.598554]  r5:c049716c r4:d5c21240
[ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
[ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
[ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
[ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
----

Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
 drivers/net/ethernet/renesas/sh_eth.c | 64 +++++++++++++++++++----------------
 drivers/net/ethernet/renesas/sh_eth.h |  1 +
 2 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 60e9c2c..862a691 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -2042,6 +2042,8 @@ static int sh_eth_open(struct net_device *ndev)
 	if (ret)
 		goto out_free_irq;
 
+	mdp->is_opened = 1;
+
 	return ret;
 
 out_free_irq:
@@ -2131,6 +2133,36 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 	return NETDEV_TX_OK;
 }
 
+static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
+{
+	struct sh_eth_private *mdp = netdev_priv(ndev);
+
+	if (sh_eth_is_rz_fast_ether(mdp))
+		return &ndev->stats;
+
+	if (!mdp->is_opened)
+		return &ndev->stats;
+
+	ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR);
+	sh_eth_write(ndev, 0, TROCR);	/* (write clear) */
+	ndev->stats.collisions += sh_eth_read(ndev, CDCR);
+	sh_eth_write(ndev, 0, CDCR);	/* (write clear) */
+	ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR);
+	sh_eth_write(ndev, 0, LCCR);	/* (write clear) */
+
+	if (sh_eth_is_gether(mdp)) {
+		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR);
+		sh_eth_write(ndev, 0, CERCR);	/* (write clear) */
+		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR);
+		sh_eth_write(ndev, 0, CEECR);	/* (write clear) */
+	} else {
+		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR);
+		sh_eth_write(ndev, 0, CNDCR);	/* (write clear) */
+	}
+
+	return &ndev->stats;
+}
+
 /* device close function */
 static int sh_eth_close(struct net_device *ndev)
 {
@@ -2145,6 +2177,7 @@ static int sh_eth_close(struct net_device *ndev)
 	sh_eth_write(ndev, 0, EDTRR);
 	sh_eth_write(ndev, 0, EDRRR);
 
+	sh_eth_get_stats(ndev);
 	/* PHY Disconnect */
 	if (mdp->phydev) {
 		phy_stop(mdp->phydev);
@@ -2163,36 +2196,9 @@ static int sh_eth_close(struct net_device *ndev)
 
 	pm_runtime_put_sync(&mdp->pdev->dev);
 
-	return 0;
-}
-
-static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
-{
-	struct sh_eth_private *mdp = netdev_priv(ndev);
-
-	if (sh_eth_is_rz_fast_ether(mdp))
-		return &ndev->stats;
-
-	pm_runtime_get_sync(&mdp->pdev->dev);
-
-	ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR);
-	sh_eth_write(ndev, 0, TROCR);	/* (write clear) */
-	ndev->stats.collisions += sh_eth_read(ndev, CDCR);
-	sh_eth_write(ndev, 0, CDCR);	/* (write clear) */
-	ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR);
-	sh_eth_write(ndev, 0, LCCR);	/* (write clear) */
-	if (sh_eth_is_gether(mdp)) {
-		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR);
-		sh_eth_write(ndev, 0, CERCR);	/* (write clear) */
-		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR);
-		sh_eth_write(ndev, 0, CEECR);	/* (write clear) */
-	} else {
-		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR);
-		sh_eth_write(ndev, 0, CNDCR);	/* (write clear) */
-	}
-	pm_runtime_put_sync(&mdp->pdev->dev);
+	mdp->is_opened = 0;
 
-	return &ndev->stats;
+	return 0;
 }
 
 /* ioctl to device function */
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
index b37c427..9a1c550 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -508,6 +508,7 @@ struct sh_eth_private {
 	u32 rx_buf_sz;			/* Based on MTU+slack. */
 	int edmac_endian;
 	struct napi_struct napi;
+	bool is_opened;
 	/* MII transceiver section. */
 	u32 phy_id;			/* PHY ID */
 	struct mii_bus *mii_bus;	/* MDIO bus control */
-- 
1.9.1


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

* [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
@ 2014-11-13  7:02   ` Yoshihiro Kaneko
  0 siblings, 0 replies; 25+ messages in thread
From: Yoshihiro Kaneko @ 2014-11-13  7:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh

From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

Fix the bug as follows:

----
[ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
[ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
[ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
[ 1238.230737] Backtrace:
[ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
[ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
[ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
[ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
[ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
[ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
[ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
[ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
[ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
[ 1238.446204]  r5:d5c21000 r4:d5ed7e08
[ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
[ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
[ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
[ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
[ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
[ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
[ 1238.598554]  r5:c049716c r4:d5c21240
[ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
[ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
[ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
[ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
----

Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
 drivers/net/ethernet/renesas/sh_eth.c | 64 +++++++++++++++++++----------------
 drivers/net/ethernet/renesas/sh_eth.h |  1 +
 2 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 60e9c2c..862a691 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -2042,6 +2042,8 @@ static int sh_eth_open(struct net_device *ndev)
 	if (ret)
 		goto out_free_irq;
 
+	mdp->is_opened = 1;
+
 	return ret;
 
 out_free_irq:
@@ -2131,6 +2133,36 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 	return NETDEV_TX_OK;
 }
 
+static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
+{
+	struct sh_eth_private *mdp = netdev_priv(ndev);
+
+	if (sh_eth_is_rz_fast_ether(mdp))
+		return &ndev->stats;
+
+	if (!mdp->is_opened)
+		return &ndev->stats;
+
+	ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR);
+	sh_eth_write(ndev, 0, TROCR);	/* (write clear) */
+	ndev->stats.collisions += sh_eth_read(ndev, CDCR);
+	sh_eth_write(ndev, 0, CDCR);	/* (write clear) */
+	ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR);
+	sh_eth_write(ndev, 0, LCCR);	/* (write clear) */
+
+	if (sh_eth_is_gether(mdp)) {
+		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR);
+		sh_eth_write(ndev, 0, CERCR);	/* (write clear) */
+		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR);
+		sh_eth_write(ndev, 0, CEECR);	/* (write clear) */
+	} else {
+		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR);
+		sh_eth_write(ndev, 0, CNDCR);	/* (write clear) */
+	}
+
+	return &ndev->stats;
+}
+
 /* device close function */
 static int sh_eth_close(struct net_device *ndev)
 {
@@ -2145,6 +2177,7 @@ static int sh_eth_close(struct net_device *ndev)
 	sh_eth_write(ndev, 0, EDTRR);
 	sh_eth_write(ndev, 0, EDRRR);
 
+	sh_eth_get_stats(ndev);
 	/* PHY Disconnect */
 	if (mdp->phydev) {
 		phy_stop(mdp->phydev);
@@ -2163,36 +2196,9 @@ static int sh_eth_close(struct net_device *ndev)
 
 	pm_runtime_put_sync(&mdp->pdev->dev);
 
-	return 0;
-}
-
-static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
-{
-	struct sh_eth_private *mdp = netdev_priv(ndev);
-
-	if (sh_eth_is_rz_fast_ether(mdp))
-		return &ndev->stats;
-
-	pm_runtime_get_sync(&mdp->pdev->dev);
-
-	ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR);
-	sh_eth_write(ndev, 0, TROCR);	/* (write clear) */
-	ndev->stats.collisions += sh_eth_read(ndev, CDCR);
-	sh_eth_write(ndev, 0, CDCR);	/* (write clear) */
-	ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR);
-	sh_eth_write(ndev, 0, LCCR);	/* (write clear) */
-	if (sh_eth_is_gether(mdp)) {
-		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR);
-		sh_eth_write(ndev, 0, CERCR);	/* (write clear) */
-		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR);
-		sh_eth_write(ndev, 0, CEECR);	/* (write clear) */
-	} else {
-		ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR);
-		sh_eth_write(ndev, 0, CNDCR);	/* (write clear) */
-	}
-	pm_runtime_put_sync(&mdp->pdev->dev);
+	mdp->is_opened = 0;
 
-	return &ndev->stats;
+	return 0;
 }
 
 /* ioctl to device function */
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
index b37c427..9a1c550 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -508,6 +508,7 @@ struct sh_eth_private {
 	u32 rx_buf_sz;			/* Based on MTU+slack. */
 	int edmac_endian;
 	struct napi_struct napi;
+	bool is_opened;
 	/* MII transceiver section. */
 	u32 phy_id;			/* PHY ID */
 	struct mii_bus *mii_bus;	/* MDIO bus control */
-- 
1.9.1


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

* [PATCH 2/2] sh_eth: Fix asynchronous external abort
  2014-11-13  7:02 ` Yoshihiro Kaneko
@ 2014-11-13  7:02   ` Yoshihiro Kaneko
  -1 siblings, 0 replies; 25+ messages in thread
From: Yoshihiro Kaneko @ 2014-11-13  7:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh

From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

When clock is disabled, Ethernet register access raise Bus error.

----
[  792.240535] Unhandled fault: asynchronous external abort (0x1211) at 0x00000000
[  792.262485] Internal error: : 1211 [#1] PREEMPT SMP ARM
[  792.278165] Modules linked in:
[  792.287340] CPU: 1 PID: 1495 Comm: ethtool Not tainted 3.10.31-ltsi-00046-gefa0b46-dirty #1089
[  792.313195] task: d68e30c0 ti: d6878000 task.ti: d6878000
[  792.329404] PC is at sh_eth_reset+0x2cc/0x3a8
[  792.342476] LR is at sh_eth_dmac_init+0x18/0x374
[  792.356327] pc : [<c029907c>]    lr : [<c029ed20>]    psr: 20070013
[  792.356327] sp : d6879d78  ip : d6879d98  fp : d6879d94
[  792.390792] r10: d6385c80  r9 : d6878000  r8 : 00000000
[  792.406470] r7 : 00000000  r6 : 00000000  r5 : 00000001  r4 : d6385800
[  792.426061] r3 : e78dc200  r2 : e78dc000  r1 : 00000000  r0 : d6385800
[  792.445653] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  792.467072] Control: 30c53c7d  Table: 55c0a140  DAC: 55555555
[  792.484315] Process ethtool (pid: 1495, stack limit = 0xd6878238)
[  792.502601] Stack: (0xd6879d78 to 0xd687a000)
[  792.515669] 9d60:                                                       c049ca32 d6385800
[  792.540221] 9d80: 00000000 00000000 d6879dbc d6879d98 c029ed20 c0298dbc c049ca32 d6385800
[  792.564771] 9da0: 00000000 c06502c0 00000000 00000000 d6879dec d6879dc0 c029f7c8 c029ed14
[  792.589321] 9dc0: c029f610 be976b6c 00000011 c06502c0 00000000 00000000 d6878000 d6385800
[  792.613871] 9de0: d6879e6c d6879df0 c03b70f0 c029f61c 00004000 00000000 d6879e1c 00000011
[  792.638420] 9e00: 00000000 00000000 00000000 d6160000 00000011 00000400 00000000 00000000
[  792.662969] 9e20: 00000400 00000400 00000000 00000000 00000040 00000000 d6879e5c d6879e48
[  792.687519] 9e40: c0452f20 00008946 be976c20 c06502c0 00000000 00000000 d6878000 be976c20
[  792.712069] 9e60: d6879ec4 d6879e70 c03c4870 c03b64f0 000000d0 d69d1a40 30687465 00000000
[  792.736618] 9e80: 00000000 00000000 be976b6c 00000000 00000000 00000000 c03f85e0 00008946
[  792.761168] 9ea0: fffffdfd be976c20 00008946 d65686a0 d6878000 be976c20 d6879ee4 d6879ec8
[  792.785717] 9ec0: c039feb0 c03c435c c039fc48 be976c20 d6ae38c0 00000003 d6879ef4 d6879ee8
[  792.810267] 9ee0: c00c8540 c039fc54 d6879f74 d6879ef8 c00c9114 c00c851c d6879fac d6879f08
[  792.834817] 9f00: c0009288 c001b168 d6879f40 00000003 d6879f3c d6879f20 c00bafe0 c00bae6c
[  792.859366] 9f20: d6879f44 d6879f30 d6879f44 d6879f38 c0454c04 c0049738 d6879f64 d6879f48
[  792.883916] 9f40: c00d2978 c0454be4 00000003 be976c20 d6ae38c0 00000000 00008946 00000003
[  792.908466] 9f60: d6878000 00000000 d6879fa4 d6879f78 c00c91ac c00c8b84 d6879fb0 00000000
[  792.933015] 9f80: d6879fac be976c18 be976b88 be976b60 00000036 c000f068 00000000 d6879fa8
[  792.957565] 9fa0: c000eec0 c00c9178 be976c18 be976b88 00000003 00008946 be976c20 be976c18
[  792.982114] 9fc0: be976c18 be976b88 be976b60 00000036 be976b5c be976b58 be976b80 0001f754
[  793.006664] 9fe0: 000433f0 be976b4c 0000d8e8 b6e035ac 200d0010 00000003 c90515a9 0f9c2043
[  793.031212] Backtrace:
[  793.038564] [<c0298db0>] (sh_eth_reset+0x0/0x3a8) from [<c029ed20>] (sh_eth_dmac_init+0x18/0x374)
[  793.065199]  r6:00000000 r5:00000000 r4:d6385800 r3:c049ca32
[  793.082257] [<c029ed08>] (sh_eth_dmac_init+0x0/0x374) from [<c029f7c8>] (sh_eth_set_ringparam+0x1b8/0x2cc)
[  793.111241]  r8:00000000 r7:00000000 r6:c06502c0 r5:00000000 r4:d6385800
r3:c049ca32
[  793.134860] [<c029f610>] (sh_eth_set_ringparam+0x0/0x2cc) from [<c03b70f0>] (dev_ethtool+0xc0c/0x1e4c)
[  793.162807] [<c03b64e4>] (dev_ethtool+0x0/0x1e4c) from [<c03c4870>] (dev_ioctl+0x520/0x688)
[  793.187881] [<c03c4350>] (dev_ioctl+0x0/0x688) from [<c039feb0>] (sock_ioctl+0x268/0x2a0)
[  793.212435] [<c039fc48>] (sock_ioctl+0x0/0x2a0) from [<c00c8540>] (vfs_ioctl+0x30/0x44)
[  793.236461]  r6:00000003 r5:d6ae38c0 r4:be976c20 r3:c039fc48
[  793.253516] [<c00c8510>] (vfs_ioctl+0x0/0x44) from [<c00c9114>] (do_vfs_ioctl+0x59c/0x5f4)
[  793.278328] [<c00c8b78>] (do_vfs_ioctl+0x0/0x5f4) from [<c00c91ac>] (SyS_ioctl+0x40/0x68)
[  793.302882] [<c00c916c>] (SyS_ioctl+0x0/0x68) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
[  793.327952]  r8:c000f068 r7:00000036 r6:be976b60 r5:be976b88 r4:be976c18
[  793.348155] Code: e0823003 e5935000 f57ff04f e3855001 (f57ff04f)
[  793.366445] ---[ end trace 6885a6a6c1fc41e3 ]---
----

Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
 drivers/net/ethernet/renesas/sh_eth.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 862a691..dadbd00 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1839,6 +1839,9 @@ static int sh_eth_set_settings(struct net_device *ndev,
 	unsigned long flags;
 	int ret;
 
+	if (!mdp->is_opened)
+		return -EAGAIN;
+
 	spin_lock_irqsave(&mdp->lock, flags);
 
 	/* disable tx and rx */
@@ -1975,6 +1978,9 @@ static int sh_eth_set_ringparam(struct net_device *ndev,
 	mdp->num_rx_ring = ring->rx_pending;
 	mdp->num_tx_ring = ring->tx_pending;
 
+	if (!mdp->is_opened)
+		return 0;
+
 	ret = sh_eth_ring_init(ndev);
 	if (ret < 0) {
 		netdev_err(ndev, "%s: sh_eth_ring_init failed.\n", __func__);
-- 
1.9.1


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

* [PATCH 2/2] sh_eth: Fix asynchronous external abort
@ 2014-11-13  7:02   ` Yoshihiro Kaneko
  0 siblings, 0 replies; 25+ messages in thread
From: Yoshihiro Kaneko @ 2014-11-13  7:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh

From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

When clock is disabled, Ethernet register access raise Bus error.

----
[  792.240535] Unhandled fault: asynchronous external abort (0x1211) at 0x00000000
[  792.262485] Internal error: : 1211 [#1] PREEMPT SMP ARM
[  792.278165] Modules linked in:
[  792.287340] CPU: 1 PID: 1495 Comm: ethtool Not tainted 3.10.31-ltsi-00046-gefa0b46-dirty #1089
[  792.313195] task: d68e30c0 ti: d6878000 task.ti: d6878000
[  792.329404] PC is at sh_eth_reset+0x2cc/0x3a8
[  792.342476] LR is at sh_eth_dmac_init+0x18/0x374
[  792.356327] pc : [<c029907c>]    lr : [<c029ed20>]    psr: 20070013
[  792.356327] sp : d6879d78  ip : d6879d98  fp : d6879d94
[  792.390792] r10: d6385c80  r9 : d6878000  r8 : 00000000
[  792.406470] r7 : 00000000  r6 : 00000000  r5 : 00000001  r4 : d6385800
[  792.426061] r3 : e78dc200  r2 : e78dc000  r1 : 00000000  r0 : d6385800
[  792.445653] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  792.467072] Control: 30c53c7d  Table: 55c0a140  DAC: 55555555
[  792.484315] Process ethtool (pid: 1495, stack limit = 0xd6878238)
[  792.502601] Stack: (0xd6879d78 to 0xd687a000)
[  792.515669] 9d60:                                                       c049ca32 d6385800
[  792.540221] 9d80: 00000000 00000000 d6879dbc d6879d98 c029ed20 c0298dbc c049ca32 d6385800
[  792.564771] 9da0: 00000000 c06502c0 00000000 00000000 d6879dec d6879dc0 c029f7c8 c029ed14
[  792.589321] 9dc0: c029f610 be976b6c 00000011 c06502c0 00000000 00000000 d6878000 d6385800
[  792.613871] 9de0: d6879e6c d6879df0 c03b70f0 c029f61c 00004000 00000000 d6879e1c 00000011
[  792.638420] 9e00: 00000000 00000000 00000000 d6160000 00000011 00000400 00000000 00000000
[  792.662969] 9e20: 00000400 00000400 00000000 00000000 00000040 00000000 d6879e5c d6879e48
[  792.687519] 9e40: c0452f20 00008946 be976c20 c06502c0 00000000 00000000 d6878000 be976c20
[  792.712069] 9e60: d6879ec4 d6879e70 c03c4870 c03b64f0 000000d0 d69d1a40 30687465 00000000
[  792.736618] 9e80: 00000000 00000000 be976b6c 00000000 00000000 00000000 c03f85e0 00008946
[  792.761168] 9ea0: fffffdfd be976c20 00008946 d65686a0 d6878000 be976c20 d6879ee4 d6879ec8
[  792.785717] 9ec0: c039feb0 c03c435c c039fc48 be976c20 d6ae38c0 00000003 d6879ef4 d6879ee8
[  792.810267] 9ee0: c00c8540 c039fc54 d6879f74 d6879ef8 c00c9114 c00c851c d6879fac d6879f08
[  792.834817] 9f00: c0009288 c001b168 d6879f40 00000003 d6879f3c d6879f20 c00bafe0 c00bae6c
[  792.859366] 9f20: d6879f44 d6879f30 d6879f44 d6879f38 c0454c04 c0049738 d6879f64 d6879f48
[  792.883916] 9f40: c00d2978 c0454be4 00000003 be976c20 d6ae38c0 00000000 00008946 00000003
[  792.908466] 9f60: d6878000 00000000 d6879fa4 d6879f78 c00c91ac c00c8b84 d6879fb0 00000000
[  792.933015] 9f80: d6879fac be976c18 be976b88 be976b60 00000036 c000f068 00000000 d6879fa8
[  792.957565] 9fa0: c000eec0 c00c9178 be976c18 be976b88 00000003 00008946 be976c20 be976c18
[  792.982114] 9fc0: be976c18 be976b88 be976b60 00000036 be976b5c be976b58 be976b80 0001f754
[  793.006664] 9fe0: 000433f0 be976b4c 0000d8e8 b6e035ac 200d0010 00000003 c90515a9 0f9c2043
[  793.031212] Backtrace:
[  793.038564] [<c0298db0>] (sh_eth_reset+0x0/0x3a8) from [<c029ed20>] (sh_eth_dmac_init+0x18/0x374)
[  793.065199]  r6:00000000 r5:00000000 r4:d6385800 r3:c049ca32
[  793.082257] [<c029ed08>] (sh_eth_dmac_init+0x0/0x374) from [<c029f7c8>] (sh_eth_set_ringparam+0x1b8/0x2cc)
[  793.111241]  r8:00000000 r7:00000000 r6:c06502c0 r5:00000000 r4:d6385800
r3:c049ca32
[  793.134860] [<c029f610>] (sh_eth_set_ringparam+0x0/0x2cc) from [<c03b70f0>] (dev_ethtool+0xc0c/0x1e4c)
[  793.162807] [<c03b64e4>] (dev_ethtool+0x0/0x1e4c) from [<c03c4870>] (dev_ioctl+0x520/0x688)
[  793.187881] [<c03c4350>] (dev_ioctl+0x0/0x688) from [<c039feb0>] (sock_ioctl+0x268/0x2a0)
[  793.212435] [<c039fc48>] (sock_ioctl+0x0/0x2a0) from [<c00c8540>] (vfs_ioctl+0x30/0x44)
[  793.236461]  r6:00000003 r5:d6ae38c0 r4:be976c20 r3:c039fc48
[  793.253516] [<c00c8510>] (vfs_ioctl+0x0/0x44) from [<c00c9114>] (do_vfs_ioctl+0x59c/0x5f4)
[  793.278328] [<c00c8b78>] (do_vfs_ioctl+0x0/0x5f4) from [<c00c91ac>] (SyS_ioctl+0x40/0x68)
[  793.302882] [<c00c916c>] (SyS_ioctl+0x0/0x68) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
[  793.327952]  r8:c000f068 r7:00000036 r6:be976b60 r5:be976b88 r4:be976c18
[  793.348155] Code: e0823003 e5935000 f57ff04f e3855001 (f57ff04f)
[  793.366445] ---[ end trace 6885a6a6c1fc41e3 ]---
----

Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
 drivers/net/ethernet/renesas/sh_eth.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 862a691..dadbd00 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1839,6 +1839,9 @@ static int sh_eth_set_settings(struct net_device *ndev,
 	unsigned long flags;
 	int ret;
 
+	if (!mdp->is_opened)
+		return -EAGAIN;
+
 	spin_lock_irqsave(&mdp->lock, flags);
 
 	/* disable tx and rx */
@@ -1975,6 +1978,9 @@ static int sh_eth_set_ringparam(struct net_device *ndev,
 	mdp->num_rx_ring = ring->rx_pending;
 	mdp->num_tx_ring = ring->tx_pending;
 
+	if (!mdp->is_opened)
+		return 0;
+
 	ret = sh_eth_ring_init(ndev);
 	if (ret < 0) {
 		netdev_err(ndev, "%s: sh_eth_ring_init failed.\n", __func__);
-- 
1.9.1


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

* Re: [PATCH 0/2] Fix sleeping function called from invalid context
  2014-11-13  7:02 ` Yoshihiro Kaneko
@ 2014-11-13 20:05   ` David Miller
  -1 siblings, 0 replies; 25+ messages in thread
From: David Miller @ 2014-11-13 20:05 UTC (permalink / raw)
  To: ykaneko0929; +Cc: netdev, horms, magnus.damm, linux-sh

From: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Date: Thu, 13 Nov 2014 16:02:13 +0900

> This series is based on net tree.

A header posting is supposed to explain things, at a high level,
about the patch series.

For example, what is the patch series doing, and why.  What is the
context of the changes, is it meant to fix a specific bug report,
and if so which one?

Both of your sh_eth patch series have this problem.

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

* Re: [PATCH 0/2] Fix sleeping function called from invalid context
@ 2014-11-13 20:05   ` David Miller
  0 siblings, 0 replies; 25+ messages in thread
From: David Miller @ 2014-11-13 20:05 UTC (permalink / raw)
  To: ykaneko0929; +Cc: netdev, horms, magnus.damm, linux-sh

From: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Date: Thu, 13 Nov 2014 16:02:13 +0900

> This series is based on net tree.

A header posting is supposed to explain things, at a high level,
about the patch series.

For example, what is the patch series doing, and why.  What is the
context of the changes, is it meant to fix a specific bug report,
and if so which one?

Both of your sh_eth patch series have this problem.

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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
  2014-11-13  7:02   ` Yoshihiro Kaneko
@ 2014-11-13 22:33     ` Sergei Shtylyov
  -1 siblings, 0 replies; 25+ messages in thread
From: Sergei Shtylyov @ 2014-11-13 22:33 UTC (permalink / raw)
  To: Yoshihiro Kaneko, netdev
  Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh

On 11/13/2014 10:02 AM, Yoshihiro Kaneko wrote:

> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

> Fix the bug as follows:

> ----
> [ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
> [ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
> [ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
> [ 1238.230737] Backtrace:
> [ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
> [ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
> [ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
> [ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
> [ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
> [ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
> [ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
> [ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
> [ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
> [ 1238.446204]  r5:d5c21000 r4:d5ed7e08
> [ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
> [ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
> [ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
> [ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
> [ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
> [ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
> [ 1238.598554]  r5:c049716c r4:d5c21240
> [ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
> [ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
> [ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
> [ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
> ----

    How to reproduce this?

> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>

[...]

> diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
> index b37c427..9a1c550 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.h
> +++ b/drivers/net/ethernet/renesas/sh_eth.h
> @@ -508,6 +508,7 @@ struct sh_eth_private {
>   	u32 rx_buf_sz;			/* Based on MTU+slack. */
>   	int edmac_endian;
>   	struct napi_struct napi;
> +	bool is_opened;

    Placing it after 'vlan_num_ids' (and making it a bitfield?) would probably 
allow to save some space.

WBR, Sergei


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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
@ 2014-11-13 22:33     ` Sergei Shtylyov
  0 siblings, 0 replies; 25+ messages in thread
From: Sergei Shtylyov @ 2014-11-13 22:33 UTC (permalink / raw)
  To: Yoshihiro Kaneko, netdev
  Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh

On 11/13/2014 10:02 AM, Yoshihiro Kaneko wrote:

> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

> Fix the bug as follows:

> ----
> [ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
> [ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
> [ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
> [ 1238.230737] Backtrace:
> [ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
> [ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
> [ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
> [ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
> [ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
> [ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
> [ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
> [ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
> [ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
> [ 1238.446204]  r5:d5c21000 r4:d5ed7e08
> [ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
> [ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
> [ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
> [ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
> [ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
> [ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
> [ 1238.598554]  r5:c049716c r4:d5c21240
> [ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
> [ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
> [ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
> [ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
> ----

    How to reproduce this?

> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>

[...]

> diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
> index b37c427..9a1c550 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.h
> +++ b/drivers/net/ethernet/renesas/sh_eth.h
> @@ -508,6 +508,7 @@ struct sh_eth_private {
>   	u32 rx_buf_sz;			/* Based on MTU+slack. */
>   	int edmac_endian;
>   	struct napi_struct napi;
> +	bool is_opened;

    Placing it after 'vlan_num_ids' (and making it a bitfield?) would probably 
allow to save some space.

WBR, Sergei


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

* Re: [PATCH 2/2] sh_eth: Fix asynchronous external abort
  2014-11-13  7:02   ` Yoshihiro Kaneko
@ 2014-11-24  1:18     ` Simon Horman
  -1 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2014-11-24  1:18 UTC (permalink / raw)
  To: Yoshihiro Kaneko; +Cc: netdev, David S. Miller, Magnus Damm, linux-sh

Hi Kaneko-san, Hi All,

On Thu, Nov 13, 2014 at 04:02:15PM +0900, Yoshihiro Kaneko wrote:
> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> 
> When clock is disabled, Ethernet register access raise Bus error.

I have spoken with Kimura-san and the problem may be reproduced by
calling ethtool with -s of -G while the network interface is down.

e.g.:
ifconfig eth0 down
ethtool -G eth0 rx 512

I have confirmed that the problem above appears in net-next
and appears to be resolved with this patch and the previous on
in this series (which seems to be a dependency) applied.

> ----
> [  792.240535] Unhandled fault: asynchronous external abort (0x1211) at 0x00000000
> [  792.262485] Internal error: : 1211 [#1] PREEMPT SMP ARM
> [  792.278165] Modules linked in:
> [  792.287340] CPU: 1 PID: 1495 Comm: ethtool Not tainted 3.10.31-ltsi-00046-gefa0b46-dirty #1089
> [  792.313195] task: d68e30c0 ti: d6878000 task.ti: d6878000
> [  792.329404] PC is at sh_eth_reset+0x2cc/0x3a8
> [  792.342476] LR is at sh_eth_dmac_init+0x18/0x374
> [  792.356327] pc : [<c029907c>]    lr : [<c029ed20>]    psr: 20070013
> [  792.356327] sp : d6879d78  ip : d6879d98  fp : d6879d94
> [  792.390792] r10: d6385c80  r9 : d6878000  r8 : 00000000
> [  792.406470] r7 : 00000000  r6 : 00000000  r5 : 00000001  r4 : d6385800
> [  792.426061] r3 : e78dc200  r2 : e78dc000  r1 : 00000000  r0 : d6385800
> [  792.445653] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
> [  792.467072] Control: 30c53c7d  Table: 55c0a140  DAC: 55555555
> [  792.484315] Process ethtool (pid: 1495, stack limit = 0xd6878238)
> [  792.502601] Stack: (0xd6879d78 to 0xd687a000)
> [  792.515669] 9d60:                                                       c049ca32 d6385800
> [  792.540221] 9d80: 00000000 00000000 d6879dbc d6879d98 c029ed20 c0298dbc c049ca32 d6385800
> [  792.564771] 9da0: 00000000 c06502c0 00000000 00000000 d6879dec d6879dc0 c029f7c8 c029ed14
> [  792.589321] 9dc0: c029f610 be976b6c 00000011 c06502c0 00000000 00000000 d6878000 d6385800
> [  792.613871] 9de0: d6879e6c d6879df0 c03b70f0 c029f61c 00004000 00000000 d6879e1c 00000011
> [  792.638420] 9e00: 00000000 00000000 00000000 d6160000 00000011 00000400 00000000 00000000
> [  792.662969] 9e20: 00000400 00000400 00000000 00000000 00000040 00000000 d6879e5c d6879e48
> [  792.687519] 9e40: c0452f20 00008946 be976c20 c06502c0 00000000 00000000 d6878000 be976c20
> [  792.712069] 9e60: d6879ec4 d6879e70 c03c4870 c03b64f0 000000d0 d69d1a40 30687465 00000000
> [  792.736618] 9e80: 00000000 00000000 be976b6c 00000000 00000000 00000000 c03f85e0 00008946
> [  792.761168] 9ea0: fffffdfd be976c20 00008946 d65686a0 d6878000 be976c20 d6879ee4 d6879ec8
> [  792.785717] 9ec0: c039feb0 c03c435c c039fc48 be976c20 d6ae38c0 00000003 d6879ef4 d6879ee8
> [  792.810267] 9ee0: c00c8540 c039fc54 d6879f74 d6879ef8 c00c9114 c00c851c d6879fac d6879f08
> [  792.834817] 9f00: c0009288 c001b168 d6879f40 00000003 d6879f3c d6879f20 c00bafe0 c00bae6c
> [  792.859366] 9f20: d6879f44 d6879f30 d6879f44 d6879f38 c0454c04 c0049738 d6879f64 d6879f48
> [  792.883916] 9f40: c00d2978 c0454be4 00000003 be976c20 d6ae38c0 00000000 00008946 00000003
> [  792.908466] 9f60: d6878000 00000000 d6879fa4 d6879f78 c00c91ac c00c8b84 d6879fb0 00000000
> [  792.933015] 9f80: d6879fac be976c18 be976b88 be976b60 00000036 c000f068 00000000 d6879fa8
> [  792.957565] 9fa0: c000eec0 c00c9178 be976c18 be976b88 00000003 00008946 be976c20 be976c18
> [  792.982114] 9fc0: be976c18 be976b88 be976b60 00000036 be976b5c be976b58 be976b80 0001f754
> [  793.006664] 9fe0: 000433f0 be976b4c 0000d8e8 b6e035ac 200d0010 00000003 c90515a9 0f9c2043
> [  793.031212] Backtrace:
> [  793.038564] [<c0298db0>] (sh_eth_reset+0x0/0x3a8) from [<c029ed20>] (sh_eth_dmac_init+0x18/0x374)
> [  793.065199]  r6:00000000 r5:00000000 r4:d6385800 r3:c049ca32
> [  793.082257] [<c029ed08>] (sh_eth_dmac_init+0x0/0x374) from [<c029f7c8>] (sh_eth_set_ringparam+0x1b8/0x2cc)
> [  793.111241]  r8:00000000 r7:00000000 r6:c06502c0 r5:00000000 r4:d6385800
> r3:c049ca32
> [  793.134860] [<c029f610>] (sh_eth_set_ringparam+0x0/0x2cc) from [<c03b70f0>] (dev_ethtool+0xc0c/0x1e4c)
> [  793.162807] [<c03b64e4>] (dev_ethtool+0x0/0x1e4c) from [<c03c4870>] (dev_ioctl+0x520/0x688)
> [  793.187881] [<c03c4350>] (dev_ioctl+0x0/0x688) from [<c039feb0>] (sock_ioctl+0x268/0x2a0)
> [  793.212435] [<c039fc48>] (sock_ioctl+0x0/0x2a0) from [<c00c8540>] (vfs_ioctl+0x30/0x44)
> [  793.236461]  r6:00000003 r5:d6ae38c0 r4:be976c20 r3:c039fc48
> [  793.253516] [<c00c8510>] (vfs_ioctl+0x0/0x44) from [<c00c9114>] (do_vfs_ioctl+0x59c/0x5f4)
> [  793.278328] [<c00c8b78>] (do_vfs_ioctl+0x0/0x5f4) from [<c00c91ac>] (SyS_ioctl+0x40/0x68)
> [  793.302882] [<c00c916c>] (SyS_ioctl+0x0/0x68) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
> [  793.327952]  r8:c000f068 r7:00000036 r6:be976b60 r5:be976b88 r4:be976c18
> [  793.348155] Code: e0823003 e5935000 f57ff04f e3855001 (f57ff04f)
> [  793.366445] ---[ end trace 6885a6a6c1fc41e3 ]---
> ----
> 
> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> ---
>  drivers/net/ethernet/renesas/sh_eth.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
> index 862a691..dadbd00 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.c
> +++ b/drivers/net/ethernet/renesas/sh_eth.c
> @@ -1839,6 +1839,9 @@ static int sh_eth_set_settings(struct net_device *ndev,
>  	unsigned long flags;
>  	int ret;
>  
> +	if (!mdp->is_opened)
> +		return -EAGAIN;
> +
>  	spin_lock_irqsave(&mdp->lock, flags);
>  
>  	/* disable tx and rx */
> @@ -1975,6 +1978,9 @@ static int sh_eth_set_ringparam(struct net_device *ndev,
>  	mdp->num_rx_ring = ring->rx_pending;
>  	mdp->num_tx_ring = ring->tx_pending;
>  
> +	if (!mdp->is_opened)
> +		return 0;
> +
>  	ret = sh_eth_ring_init(ndev);
>  	if (ret < 0) {
>  		netdev_err(ndev, "%s: sh_eth_ring_init failed.\n", __func__);
> -- 
> 1.9.1
> 

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

* Re: [PATCH 2/2] sh_eth: Fix asynchronous external abort
@ 2014-11-24  1:18     ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2014-11-24  1:18 UTC (permalink / raw)
  To: Yoshihiro Kaneko; +Cc: netdev, David S. Miller, Magnus Damm, linux-sh

Hi Kaneko-san, Hi All,

On Thu, Nov 13, 2014 at 04:02:15PM +0900, Yoshihiro Kaneko wrote:
> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> 
> When clock is disabled, Ethernet register access raise Bus error.

I have spoken with Kimura-san and the problem may be reproduced by
calling ethtool with -s of -G while the network interface is down.

e.g.:
ifconfig eth0 down
ethtool -G eth0 rx 512

I have confirmed that the problem above appears in net-next
and appears to be resolved with this patch and the previous on
in this series (which seems to be a dependency) applied.

> ----
> [  792.240535] Unhandled fault: asynchronous external abort (0x1211) at 0x00000000
> [  792.262485] Internal error: : 1211 [#1] PREEMPT SMP ARM
> [  792.278165] Modules linked in:
> [  792.287340] CPU: 1 PID: 1495 Comm: ethtool Not tainted 3.10.31-ltsi-00046-gefa0b46-dirty #1089
> [  792.313195] task: d68e30c0 ti: d6878000 task.ti: d6878000
> [  792.329404] PC is at sh_eth_reset+0x2cc/0x3a8
> [  792.342476] LR is at sh_eth_dmac_init+0x18/0x374
> [  792.356327] pc : [<c029907c>]    lr : [<c029ed20>]    psr: 20070013
> [  792.356327] sp : d6879d78  ip : d6879d98  fp : d6879d94
> [  792.390792] r10: d6385c80  r9 : d6878000  r8 : 00000000
> [  792.406470] r7 : 00000000  r6 : 00000000  r5 : 00000001  r4 : d6385800
> [  792.426061] r3 : e78dc200  r2 : e78dc000  r1 : 00000000  r0 : d6385800
> [  792.445653] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
> [  792.467072] Control: 30c53c7d  Table: 55c0a140  DAC: 55555555
> [  792.484315] Process ethtool (pid: 1495, stack limit = 0xd6878238)
> [  792.502601] Stack: (0xd6879d78 to 0xd687a000)
> [  792.515669] 9d60:                                                       c049ca32 d6385800
> [  792.540221] 9d80: 00000000 00000000 d6879dbc d6879d98 c029ed20 c0298dbc c049ca32 d6385800
> [  792.564771] 9da0: 00000000 c06502c0 00000000 00000000 d6879dec d6879dc0 c029f7c8 c029ed14
> [  792.589321] 9dc0: c029f610 be976b6c 00000011 c06502c0 00000000 00000000 d6878000 d6385800
> [  792.613871] 9de0: d6879e6c d6879df0 c03b70f0 c029f61c 00004000 00000000 d6879e1c 00000011
> [  792.638420] 9e00: 00000000 00000000 00000000 d6160000 00000011 00000400 00000000 00000000
> [  792.662969] 9e20: 00000400 00000400 00000000 00000000 00000040 00000000 d6879e5c d6879e48
> [  792.687519] 9e40: c0452f20 00008946 be976c20 c06502c0 00000000 00000000 d6878000 be976c20
> [  792.712069] 9e60: d6879ec4 d6879e70 c03c4870 c03b64f0 000000d0 d69d1a40 30687465 00000000
> [  792.736618] 9e80: 00000000 00000000 be976b6c 00000000 00000000 00000000 c03f85e0 00008946
> [  792.761168] 9ea0: fffffdfd be976c20 00008946 d65686a0 d6878000 be976c20 d6879ee4 d6879ec8
> [  792.785717] 9ec0: c039feb0 c03c435c c039fc48 be976c20 d6ae38c0 00000003 d6879ef4 d6879ee8
> [  792.810267] 9ee0: c00c8540 c039fc54 d6879f74 d6879ef8 c00c9114 c00c851c d6879fac d6879f08
> [  792.834817] 9f00: c0009288 c001b168 d6879f40 00000003 d6879f3c d6879f20 c00bafe0 c00bae6c
> [  792.859366] 9f20: d6879f44 d6879f30 d6879f44 d6879f38 c0454c04 c0049738 d6879f64 d6879f48
> [  792.883916] 9f40: c00d2978 c0454be4 00000003 be976c20 d6ae38c0 00000000 00008946 00000003
> [  792.908466] 9f60: d6878000 00000000 d6879fa4 d6879f78 c00c91ac c00c8b84 d6879fb0 00000000
> [  792.933015] 9f80: d6879fac be976c18 be976b88 be976b60 00000036 c000f068 00000000 d6879fa8
> [  792.957565] 9fa0: c000eec0 c00c9178 be976c18 be976b88 00000003 00008946 be976c20 be976c18
> [  792.982114] 9fc0: be976c18 be976b88 be976b60 00000036 be976b5c be976b58 be976b80 0001f754
> [  793.006664] 9fe0: 000433f0 be976b4c 0000d8e8 b6e035ac 200d0010 00000003 c90515a9 0f9c2043
> [  793.031212] Backtrace:
> [  793.038564] [<c0298db0>] (sh_eth_reset+0x0/0x3a8) from [<c029ed20>] (sh_eth_dmac_init+0x18/0x374)
> [  793.065199]  r6:00000000 r5:00000000 r4:d6385800 r3:c049ca32
> [  793.082257] [<c029ed08>] (sh_eth_dmac_init+0x0/0x374) from [<c029f7c8>] (sh_eth_set_ringparam+0x1b8/0x2cc)
> [  793.111241]  r8:00000000 r7:00000000 r6:c06502c0 r5:00000000 r4:d6385800
> r3:c049ca32
> [  793.134860] [<c029f610>] (sh_eth_set_ringparam+0x0/0x2cc) from [<c03b70f0>] (dev_ethtool+0xc0c/0x1e4c)
> [  793.162807] [<c03b64e4>] (dev_ethtool+0x0/0x1e4c) from [<c03c4870>] (dev_ioctl+0x520/0x688)
> [  793.187881] [<c03c4350>] (dev_ioctl+0x0/0x688) from [<c039feb0>] (sock_ioctl+0x268/0x2a0)
> [  793.212435] [<c039fc48>] (sock_ioctl+0x0/0x2a0) from [<c00c8540>] (vfs_ioctl+0x30/0x44)
> [  793.236461]  r6:00000003 r5:d6ae38c0 r4:be976c20 r3:c039fc48
> [  793.253516] [<c00c8510>] (vfs_ioctl+0x0/0x44) from [<c00c9114>] (do_vfs_ioctl+0x59c/0x5f4)
> [  793.278328] [<c00c8b78>] (do_vfs_ioctl+0x0/0x5f4) from [<c00c91ac>] (SyS_ioctl+0x40/0x68)
> [  793.302882] [<c00c916c>] (SyS_ioctl+0x0/0x68) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
> [  793.327952]  r8:c000f068 r7:00000036 r6:be976b60 r5:be976b88 r4:be976c18
> [  793.348155] Code: e0823003 e5935000 f57ff04f e3855001 (f57ff04f)
> [  793.366445] ---[ end trace 6885a6a6c1fc41e3 ]---
> ----
> 
> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> ---
>  drivers/net/ethernet/renesas/sh_eth.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
> index 862a691..dadbd00 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.c
> +++ b/drivers/net/ethernet/renesas/sh_eth.c
> @@ -1839,6 +1839,9 @@ static int sh_eth_set_settings(struct net_device *ndev,
>  	unsigned long flags;
>  	int ret;
>  
> +	if (!mdp->is_opened)
> +		return -EAGAIN;
> +
>  	spin_lock_irqsave(&mdp->lock, flags);
>  
>  	/* disable tx and rx */
> @@ -1975,6 +1978,9 @@ static int sh_eth_set_ringparam(struct net_device *ndev,
>  	mdp->num_rx_ring = ring->rx_pending;
>  	mdp->num_tx_ring = ring->tx_pending;
>  
> +	if (!mdp->is_opened)
> +		return 0;
> +
>  	ret = sh_eth_ring_init(ndev);
>  	if (ret < 0) {
>  		netdev_err(ndev, "%s: sh_eth_ring_init failed.\n", __func__);
> -- 
> 1.9.1
> 

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

* Re: [PATCH 2/2] sh_eth: Fix asynchronous external abort
  2014-11-24  1:18     ` Simon Horman
  (?)
@ 2014-11-24  2:19     ` Ben Hutchings
  -1 siblings, 0 replies; 25+ messages in thread
From: Ben Hutchings @ 2014-11-24  2:19 UTC (permalink / raw)
  To: Simon Horman
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, linux-sh

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

On Mon, 2014-11-24 at 10:18 +0900, Simon Horman wrote:
> Hi Kaneko-san, Hi All,
> 
> On Thu, Nov 13, 2014 at 04:02:15PM +0900, Yoshihiro Kaneko wrote:
> > From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> > 
> > When clock is disabled, Ethernet register access raise Bus error.
> 
> I have spoken with Kimura-san and the problem may be reproduced by
> calling ethtool with -s of -G while the network interface is down.
> 
> e.g.:
> ifconfig eth0 down
> ethtool -G eth0 rx 512
> 
> I have confirmed that the problem above appears in net-next
> and appears to be resolved with this patch and the previous on
> in this series (which seems to be a dependency) applied.
[...]

The change to sh_eth_set_ringparam() is fine.  But I don't think it is
correct for sh_eth_set_settings() to fail when the interface is down.
It should behave like sh_eth_set_ringparam() - validate and remember the
requested settings, so they can be applied when the interface is brought
up.

When drivers have their own rules about when certain configuration
operations can and can't be used, we end up with messes like WEXT.

Ben.

-- 
Ben Hutchings
Absolutum obsoletum. (If it works, it's out of date.) - Stafford Beer

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* Re: [PATCH 2/2] sh_eth: Fix asynchronous external abort
  2014-11-24  1:18     ` Simon Horman
@ 2014-11-24  8:41       ` Geert Uytterhoeven
  -1 siblings, 0 replies; 25+ messages in thread
From: Geert Uytterhoeven @ 2014-11-24  8:41 UTC (permalink / raw)
  To: Simon Horman
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, Linux-sh list

On Mon, Nov 24, 2014 at 2:18 AM, Simon Horman <horms@verge.net.au> wrote:
> On Thu, Nov 13, 2014 at 04:02:15PM +0900, Yoshihiro Kaneko wrote:
>> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
>>
>> When clock is disabled, Ethernet register access raise Bus error.
>
> I have spoken with Kimura-san and the problem may be reproduced by
> calling ethtool with -s of -G while the network interface is down.
>
> e.g.:
> ifconfig eth0 down
> ethtool -G eth0 rx 512

That makes sense.

I think it would be good to add the reproduction steps to the commit message.

> I have confirmed that the problem above appears in net-next
> and appears to be resolved with this patch and the previous on
> in this series (which seems to be a dependency) applied.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 2/2] sh_eth: Fix asynchronous external abort
@ 2014-11-24  8:41       ` Geert Uytterhoeven
  0 siblings, 0 replies; 25+ messages in thread
From: Geert Uytterhoeven @ 2014-11-24  8:41 UTC (permalink / raw)
  To: Simon Horman
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, Linux-sh list

On Mon, Nov 24, 2014 at 2:18 AM, Simon Horman <horms@verge.net.au> wrote:
> On Thu, Nov 13, 2014 at 04:02:15PM +0900, Yoshihiro Kaneko wrote:
>> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
>>
>> When clock is disabled, Ethernet register access raise Bus error.
>
> I have spoken with Kimura-san and the problem may be reproduced by
> calling ethtool with -s of -G while the network interface is down.
>
> e.g.:
> ifconfig eth0 down
> ethtool -G eth0 rx 512

That makes sense.

I think it would be good to add the reproduction steps to the commit message.

> I have confirmed that the problem above appears in net-next
> and appears to be resolved with this patch and the previous on
> in this series (which seems to be a dependency) applied.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 2/2] sh_eth: Fix asynchronous external abort
  2014-11-24  8:41       ` Geert Uytterhoeven
@ 2014-11-25  0:10         ` Simon Horman
  -1 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2014-11-25  0:10 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, Linux-sh list

On Mon, Nov 24, 2014 at 09:41:18AM +0100, Geert Uytterhoeven wrote:
> On Mon, Nov 24, 2014 at 2:18 AM, Simon Horman <horms@verge.net.au> wrote:
> > On Thu, Nov 13, 2014 at 04:02:15PM +0900, Yoshihiro Kaneko wrote:
> >> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> >>
> >> When clock is disabled, Ethernet register access raise Bus error.
> >
> > I have spoken with Kimura-san and the problem may be reproduced by
> > calling ethtool with -s of -G while the network interface is down.
> >
> > e.g.:
> > ifconfig eth0 down
> > ethtool -G eth0 rx 512
> 
> That makes sense.
> 
> I think it would be good to add the reproduction steps to the commit message.

Yes, I agree entirely.

> > I have confirmed that the problem above appears in net-next
> > and appears to be resolved with this patch and the previous on
> > in this series (which seems to be a dependency) applied.
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 2/2] sh_eth: Fix asynchronous external abort
@ 2014-11-25  0:10         ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2014-11-25  0:10 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, Linux-sh list

On Mon, Nov 24, 2014 at 09:41:18AM +0100, Geert Uytterhoeven wrote:
> On Mon, Nov 24, 2014 at 2:18 AM, Simon Horman <horms@verge.net.au> wrote:
> > On Thu, Nov 13, 2014 at 04:02:15PM +0900, Yoshihiro Kaneko wrote:
> >> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> >>
> >> When clock is disabled, Ethernet register access raise Bus error.
> >
> > I have spoken with Kimura-san and the problem may be reproduced by
> > calling ethtool with -s of -G while the network interface is down.
> >
> > e.g.:
> > ifconfig eth0 down
> > ethtool -G eth0 rx 512
> 
> That makes sense.
> 
> I think it would be good to add the reproduction steps to the commit message.

Yes, I agree entirely.

> > I have confirmed that the problem above appears in net-next
> > and appears to be resolved with this patch and the previous on
> > in this series (which seems to be a dependency) applied.
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
  2014-11-13 22:33     ` Sergei Shtylyov
@ 2014-11-25  2:17       ` Simon Horman
  -1 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2014-11-25  2:17 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, linux-sh

Hi Sergei,

On Fri, Nov 14, 2014 at 01:33:58AM +0300, Sergei Shtylyov wrote:
> On 11/13/2014 10:02 AM, Yoshihiro Kaneko wrote:
> 
> >From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> 
> >Fix the bug as follows:
> 
> >----
> >[ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
> >[ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
> >[ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
> >[ 1238.230737] Backtrace:
> >[ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
> >[ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
> >[ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
> >[ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
> >[ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
> >[ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
> >[ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
> >[ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
> >[ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
> >[ 1238.446204]  r5:d5c21000 r4:d5ed7e08
> >[ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
> >[ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
> >[ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
> >[ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
> >[ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
> >[ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
> >[ 1238.598554]  r5:c049716c r4:d5c21240
> >[ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
> >[ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
> >[ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
> >[ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
> >----
> 
>    How to reproduce this?

I have spoken with Kimura-san and the problem may be reproduced by
building the kernel with CONFIG_DEBUG_ATOMIC_SLEEP=y and reading network
statistics while the network interface is down.

e.g.:

ifconfig eth0 down
cat /sys/class/net/eth0/statistics/tx_errors

I have confirmed that the problem above appears in net-next
and appears to be resolved by this patch.


Would you be happy with this patch if the changelog was enhanced
and the minor issue you point our below was resolved?

> >Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> >Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> 
> [...]
> 
> >diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
> >index b37c427..9a1c550 100644
> >--- a/drivers/net/ethernet/renesas/sh_eth.h
> >+++ b/drivers/net/ethernet/renesas/sh_eth.h
> >@@ -508,6 +508,7 @@ struct sh_eth_private {
> >  	u32 rx_buf_sz;			/* Based on MTU+slack. */
> >  	int edmac_endian;
> >  	struct napi_struct napi;
> >+	bool is_opened;
> 
>    Placing it after 'vlan_num_ids' (and making it a bitfield?) would
> probably allow to save some space.
> 
> WBR, Sergei
> 

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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
@ 2014-11-25  2:17       ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2014-11-25  2:17 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, linux-sh

Hi Sergei,

On Fri, Nov 14, 2014 at 01:33:58AM +0300, Sergei Shtylyov wrote:
> On 11/13/2014 10:02 AM, Yoshihiro Kaneko wrote:
> 
> >From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> 
> >Fix the bug as follows:
> 
> >----
> >[ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
> >[ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
> >[ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
> >[ 1238.230737] Backtrace:
> >[ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
> >[ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
> >[ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
> >[ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
> >[ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
> >[ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
> >[ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
> >[ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
> >[ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
> >[ 1238.446204]  r5:d5c21000 r4:d5ed7e08
> >[ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
> >[ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
> >[ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
> >[ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
> >[ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
> >[ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
> >[ 1238.598554]  r5:c049716c r4:d5c21240
> >[ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
> >[ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
> >[ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
> >[ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
> >----
> 
>    How to reproduce this?

I have spoken with Kimura-san and the problem may be reproduced by
building the kernel with CONFIG_DEBUG_ATOMIC_SLEEP=y and reading network
statistics while the network interface is down.

e.g.:

ifconfig eth0 down
cat /sys/class/net/eth0/statistics/tx_errors

I have confirmed that the problem above appears in net-next
and appears to be resolved by this patch.


Would you be happy with this patch if the changelog was enhanced
and the minor issue you point our below was resolved?

> >Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> >Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> 
> [...]
> 
> >diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
> >index b37c427..9a1c550 100644
> >--- a/drivers/net/ethernet/renesas/sh_eth.h
> >+++ b/drivers/net/ethernet/renesas/sh_eth.h
> >@@ -508,6 +508,7 @@ struct sh_eth_private {
> >  	u32 rx_buf_sz;			/* Based on MTU+slack. */
> >  	int edmac_endian;
> >  	struct napi_struct napi;
> >+	bool is_opened;
> 
>    Placing it after 'vlan_num_ids' (and making it a bitfield?) would
> probably allow to save some space.
> 
> WBR, Sergei
> 

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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
  2014-11-25  2:17       ` Simon Horman
@ 2014-11-25 11:02         ` Sergei Shtylyov
  -1 siblings, 0 replies; 25+ messages in thread
From: Sergei Shtylyov @ 2014-11-25 11:02 UTC (permalink / raw)
  To: Simon Horman
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, linux-sh

Hello.

On 11/25/2014 5:17 AM, Simon Horman wrote:

>>> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

>>> Fix the bug as follows:

>>> ----
>>> [ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
>>> [ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
>>> [ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
>>> [ 1238.230737] Backtrace:
>>> [ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
>>> [ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
>>> [ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
>>> [ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
>>> [ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
>>> [ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
>>> [ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
>>> [ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
>>> [ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
>>> [ 1238.446204]  r5:d5c21000 r4:d5ed7e08
>>> [ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
>>> [ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
>>> [ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
>>> [ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
>>> [ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
>>> [ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
>>> [ 1238.598554]  r5:c049716c r4:d5c21240
>>> [ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
>>> [ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
>>> [ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
>>> [ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
>>> ----

>>     How to reproduce this?

> I have spoken with Kimura-san and the problem may be reproduced by
> building the kernel with CONFIG_DEBUG_ATOMIC_SLEEP=y and reading network
> statistics while the network interface is down.

> e.g.:

> ifconfig eth0 down
> cat /sys/class/net/eth0/statistics/tx_errors

> I have confirmed that the problem above appears in net-next
> and appears to be resolved by this patch.

    Shouldn't we target 'net' for the fixes instead?

> Would you be happy with this patch if the changelog was enhanced
> and the minor issue you point our below was resolved?

    Most probably yes.

>>> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>

[...]

WBR, Sergei


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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
@ 2014-11-25 11:02         ` Sergei Shtylyov
  0 siblings, 0 replies; 25+ messages in thread
From: Sergei Shtylyov @ 2014-11-25 11:02 UTC (permalink / raw)
  To: Simon Horman
  Cc: Yoshihiro Kaneko, netdev, David S. Miller, Magnus Damm, linux-sh

Hello.

On 11/25/2014 5:17 AM, Simon Horman wrote:

>>> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

>>> Fix the bug as follows:

>>> ----
>>> [ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
>>> [ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
>>> [ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
>>> [ 1238.230737] Backtrace:
>>> [ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
>>> [ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
>>> [ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
>>> [ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
>>> [ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
>>> [ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
>>> [ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
>>> [ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
>>> [ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
>>> [ 1238.446204]  r5:d5c21000 r4:d5ed7e08
>>> [ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
>>> [ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
>>> [ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
>>> [ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
>>> [ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
>>> [ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
>>> [ 1238.598554]  r5:c049716c r4:d5c21240
>>> [ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
>>> [ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
>>> [ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
>>> [ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
>>> ----

>>     How to reproduce this?

> I have spoken with Kimura-san and the problem may be reproduced by
> building the kernel with CONFIG_DEBUG_ATOMIC_SLEEP=y and reading network
> statistics while the network interface is down.

> e.g.:

> ifconfig eth0 down
> cat /sys/class/net/eth0/statistics/tx_errors

> I have confirmed that the problem above appears in net-next
> and appears to be resolved by this patch.

    Shouldn't we target 'net' for the fixes instead?

> Would you be happy with this patch if the changelog was enhanced
> and the minor issue you point our below was resolved?

    Most probably yes.

>>> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>

[...]

WBR, Sergei

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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
  2014-11-13  7:02   ` Yoshihiro Kaneko
@ 2014-11-25 13:35     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 25+ messages in thread
From: Geert Uytterhoeven @ 2014-11-25 13:35 UTC (permalink / raw)
  To: Yoshihiro Kaneko
  Cc: netdev, David S. Miller, Simon Horman, Magnus Damm, Linux-sh list

Hi Kaneko-san,

On Thu, Nov 13, 2014 at 8:02 AM, Yoshihiro Kaneko <ykaneko0929@gmail.com> wrote:
> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
>
> Fix the bug as follows:
>
> ----
> [ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
> [ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
> [ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
> [ 1238.230737] Backtrace:
> [ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
> [ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
> [ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
> [ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
> [ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
> [ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
> [ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
> [ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
> [ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
> [ 1238.446204]  r5:d5c21000 r4:d5ed7e08
> [ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
> [ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
> [ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
> [ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
> [ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
> [ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
> [ 1238.598554]  r5:c049716c r4:d5c21240
> [ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
> [ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
> [ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
> [ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
> ----
>
> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> ---
>  drivers/net/ethernet/renesas/sh_eth.c | 64 +++++++++++++++++++----------------
>  drivers/net/ethernet/renesas/sh_eth.h |  1 +
>  2 files changed, 36 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
> index 60e9c2c..862a691 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.c
> +++ b/drivers/net/ethernet/renesas/sh_eth.c
> @@ -2042,6 +2042,8 @@ static int sh_eth_open(struct net_device *ndev)
>         if (ret)
>                 goto out_free_irq;
>
> +       mdp->is_opened = 1;
> +
>         return ret;
>
>  out_free_irq:
> @@ -2131,6 +2133,36 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>         return NETDEV_TX_OK;
>  }
>
> +static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
> +{
> +       struct sh_eth_private *mdp = netdev_priv(ndev);
> +
> +       if (sh_eth_is_rz_fast_ether(mdp))
> +               return &ndev->stats;
> +
> +       if (!mdp->is_opened)

Can't you use netif_running(ndev) instead?

That way you don't need the is_opened field and track open/close
calls.

> --- a/drivers/net/ethernet/renesas/sh_eth.h
> +++ b/drivers/net/ethernet/renesas/sh_eth.h
> @@ -508,6 +508,7 @@ struct sh_eth_private {
>         u32 rx_buf_sz;                  /* Based on MTU+slack. */
>         int edmac_endian;
>         struct napi_struct napi;
> +       bool is_opened;
>         /* MII transceiver section. */
>         u32 phy_id;                     /* PHY ID */
>         struct mii_bus *mii_bus;        /* MDIO bus control */

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
@ 2014-11-25 13:35     ` Geert Uytterhoeven
  0 siblings, 0 replies; 25+ messages in thread
From: Geert Uytterhoeven @ 2014-11-25 13:35 UTC (permalink / raw)
  To: Yoshihiro Kaneko
  Cc: netdev, David S. Miller, Simon Horman, Magnus Damm, Linux-sh list

Hi Kaneko-san,

On Thu, Nov 13, 2014 at 8:02 AM, Yoshihiro Kaneko <ykaneko0929@gmail.com> wrote:
> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
>
> Fix the bug as follows:
>
> ----
> [ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
> [ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
> [ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
> [ 1238.230737] Backtrace:
> [ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
> [ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
> [ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
> [ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
> [ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
> [ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
> [ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
> [ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
> [ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
> [ 1238.446204]  r5:d5c21000 r4:d5ed7e08
> [ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
> [ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
> [ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
> [ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
> [ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
> [ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
> [ 1238.598554]  r5:c049716c r4:d5c21240
> [ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
> [ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
> [ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
> [ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
> ----
>
> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> ---
>  drivers/net/ethernet/renesas/sh_eth.c | 64 +++++++++++++++++++----------------
>  drivers/net/ethernet/renesas/sh_eth.h |  1 +
>  2 files changed, 36 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
> index 60e9c2c..862a691 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.c
> +++ b/drivers/net/ethernet/renesas/sh_eth.c
> @@ -2042,6 +2042,8 @@ static int sh_eth_open(struct net_device *ndev)
>         if (ret)
>                 goto out_free_irq;
>
> +       mdp->is_opened = 1;
> +
>         return ret;
>
>  out_free_irq:
> @@ -2131,6 +2133,36 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>         return NETDEV_TX_OK;
>  }
>
> +static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
> +{
> +       struct sh_eth_private *mdp = netdev_priv(ndev);
> +
> +       if (sh_eth_is_rz_fast_ether(mdp))
> +               return &ndev->stats;
> +
> +       if (!mdp->is_opened)

Can't you use netif_running(ndev) instead?

That way you don't need the is_opened field and track open/close
calls.

> --- a/drivers/net/ethernet/renesas/sh_eth.h
> +++ b/drivers/net/ethernet/renesas/sh_eth.h
> @@ -508,6 +508,7 @@ struct sh_eth_private {
>         u32 rx_buf_sz;                  /* Based on MTU+slack. */
>         int edmac_endian;
>         struct napi_struct napi;
> +       bool is_opened;
>         /* MII transceiver section. */
>         u32 phy_id;                     /* PHY ID */
>         struct mii_bus *mii_bus;        /* MDIO bus control */

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
  2014-11-25 13:35     ` Geert Uytterhoeven
@ 2014-11-25 14:09       ` Sergei Shtylyov
  -1 siblings, 0 replies; 25+ messages in thread
From: Sergei Shtylyov @ 2014-11-25 14:09 UTC (permalink / raw)
  To: Geert Uytterhoeven, Yoshihiro Kaneko
  Cc: netdev, David S. Miller, Simon Horman, Magnus Damm, Linux-sh list

Hello.

On 11/25/2014 4:35 PM, Geert Uytterhoeven wrote:

>> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

>> Fix the bug as follows:

>> ----
>> [ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
>> [ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
>> [ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
>> [ 1238.230737] Backtrace:
>> [ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
>> [ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
>> [ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
>> [ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
>> [ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
>> [ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
>> [ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
>> [ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
>> [ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
>> [ 1238.446204]  r5:d5c21000 r4:d5ed7e08
>> [ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
>> [ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
>> [ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
>> [ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
>> [ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
>> [ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
>> [ 1238.598554]  r5:c049716c r4:d5c21240
>> [ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
>> [ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
>> [ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
>> [ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
>> ----

>> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
>> ---
>>   drivers/net/ethernet/renesas/sh_eth.c | 64 +++++++++++++++++++----------------
>>   drivers/net/ethernet/renesas/sh_eth.h |  1 +
>>   2 files changed, 36 insertions(+), 29 deletions(-)

>> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
>> index 60e9c2c..862a691 100644
>> --- a/drivers/net/ethernet/renesas/sh_eth.c
>> +++ b/drivers/net/ethernet/renesas/sh_eth.c
[...]
>> @@ -2131,6 +2133,36 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>>          return NETDEV_TX_OK;
>>   }
>>
>> +static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
>> +{
>> +       struct sh_eth_private *mdp = netdev_priv(ndev);
>> +
>> +       if (sh_eth_is_rz_fast_ether(mdp))
>> +               return &ndev->stats;
>> +
>> +       if (!mdp->is_opened)

> Can't you use netif_running(ndev) instead?

    The __LINK_STATE_START flag it tests gets set in __dev_open() before 
calling the ndo_open() method. Looks like it would be somewhat unsafe to use it...

WBR, Sergei


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

* Re: [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
@ 2014-11-25 14:09       ` Sergei Shtylyov
  0 siblings, 0 replies; 25+ messages in thread
From: Sergei Shtylyov @ 2014-11-25 14:09 UTC (permalink / raw)
  To: Geert Uytterhoeven, Yoshihiro Kaneko
  Cc: netdev, David S. Miller, Simon Horman, Magnus Damm, Linux-sh list

Hello.

On 11/25/2014 4:35 PM, Geert Uytterhoeven wrote:

>> From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>

>> Fix the bug as follows:

>> ----
>> [ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
>> [ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
>> [ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
>> [ 1238.230737] Backtrace:
>> [ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
>> [ 1238.263499]  r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
>> [ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
>> [ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
>> [ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
>> [ 1238.357170]  r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
>> [ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
>> [ 1238.402468]  r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
>> [ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
>> [ 1238.446204]  r5:d5c21000 r4:d5ed7e08
>> [ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
>> [ 1238.484413]  r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
>> [ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
>> [ 1238.529196]  r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
>> [ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
>> [ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
>> [ 1238.598554]  r5:c049716c r4:d5c21240
>> [ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
>> [ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
>> [ 1238.657944]  r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
>> [ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
>> ----

>> Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
>> ---
>>   drivers/net/ethernet/renesas/sh_eth.c | 64 +++++++++++++++++++----------------
>>   drivers/net/ethernet/renesas/sh_eth.h |  1 +
>>   2 files changed, 36 insertions(+), 29 deletions(-)

>> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
>> index 60e9c2c..862a691 100644
>> --- a/drivers/net/ethernet/renesas/sh_eth.c
>> +++ b/drivers/net/ethernet/renesas/sh_eth.c
[...]
>> @@ -2131,6 +2133,36 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>>          return NETDEV_TX_OK;
>>   }
>>
>> +static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
>> +{
>> +       struct sh_eth_private *mdp = netdev_priv(ndev);
>> +
>> +       if (sh_eth_is_rz_fast_ether(mdp))
>> +               return &ndev->stats;
>> +
>> +       if (!mdp->is_opened)

> Can't you use netif_running(ndev) instead?

    The __LINK_STATE_START flag it tests gets set in __dev_open() before 
calling the ndo_open() method. Looks like it would be somewhat unsafe to use it...

WBR, Sergei

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

end of thread, other threads:[~2014-11-25 14:09 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-13  7:02 [PATCH 0/2] Fix sleeping function called from invalid context Yoshihiro Kaneko
2014-11-13  7:02 ` Yoshihiro Kaneko
2014-11-13  7:02 ` [PATCH 1/2] sh_eth: " Yoshihiro Kaneko
2014-11-13  7:02   ` Yoshihiro Kaneko
2014-11-13 22:33   ` Sergei Shtylyov
2014-11-13 22:33     ` Sergei Shtylyov
2014-11-25  2:17     ` Simon Horman
2014-11-25  2:17       ` Simon Horman
2014-11-25 11:02       ` Sergei Shtylyov
2014-11-25 11:02         ` Sergei Shtylyov
2014-11-25 13:35   ` Geert Uytterhoeven
2014-11-25 13:35     ` Geert Uytterhoeven
2014-11-25 14:09     ` Sergei Shtylyov
2014-11-25 14:09       ` Sergei Shtylyov
2014-11-13  7:02 ` [PATCH 2/2] sh_eth: Fix asynchronous external abort Yoshihiro Kaneko
2014-11-13  7:02   ` Yoshihiro Kaneko
2014-11-24  1:18   ` Simon Horman
2014-11-24  1:18     ` Simon Horman
2014-11-24  2:19     ` Ben Hutchings
2014-11-24  8:41     ` Geert Uytterhoeven
2014-11-24  8:41       ` Geert Uytterhoeven
2014-11-25  0:10       ` Simon Horman
2014-11-25  0:10         ` Simon Horman
2014-11-13 20:05 ` [PATCH 0/2] Fix sleeping function called from invalid context David Miller
2014-11-13 20:05   ` David Miller

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.