Netdev List
 help / color / mirror / Atom feed
* [PATCH V3] ipconfig: Inform user if carrier is not ready
From: Erwan Velu @ 2012-09-14 19:30 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, rick.jones2
In-Reply-To: <20120914.151724.505809965127351650.davem@davemloft.net>

From: Erwan Velu <erwanaliasr1@gmail.com>

While using the ip= option at the cmdline, the kernel can hold the boot
process for 2 minutes (CONF_CARRIER_TIMEOUT) if the carrier is not
present.

While waiting the carrier, user is not informed about this situation and
so could think the kernel is frozen.

If we don't get the carrier after some seconds, let's display a message to
inform the user about the remaining time before reaching the timeout.

Signed-off-by: Erwan Velu <erwanaliasr1@gmail.com>
---
  net/ipv4/ipconfig.c |   12 ++++++++++++
  1 file changed, 12 insertions(+)

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 67e8a6b..b79dca6 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -90,6 +90,7 @@
  /* Define the friendly delay before and after opening net devices */
  #define CONF_POST_OPEN        10    /* After opening: 10 msecs */
  #define CONF_CARRIER_TIMEOUT    120000    /* Wait for carrier timeout */
+#define CONF_WARN_CARRIER_TIMEOUT 5000    /* Time before showing a 
warning message  */

  /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
  #define CONF_OPEN_RETRIES     2    /* (Re)open devices twice */
@@ -205,6 +206,7 @@ static int __init ic_open_devs(void)
      struct net_device *dev;
      unsigned short oflags;
      unsigned long start;
+    unsigned int loops=0;

      last = &ic_first_dev;
      rtnl_lock();
@@ -266,6 +268,16 @@ static int __init ic_open_devs(void)
              if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
                  goto have_carrier;

+        /* This loop is blocking the boot process until
+           we get the carrier or reach the timeout.
+           We have to inform the user about the situation as
+           it could look like a kernel freeze.
+           After CONF_WARN_CARRIER_TIMEOUT milliseconds,
+           we display the remaing time before reaching the timeout.*/
+        if (++loops == CONF_WARN_CARRIER_TIMEOUT) {
+            pr_info("IP-Config: Waiting up to %d seconds for carrier on 
interface\n",
+                (CONF_CARRIER_TIMEOUT - CONF_WARN_CARRIER_TIMEOUT)/ 1000);
+        }
          msleep(1);
      }
  have_carrier:
-- 
1.7.10

^ permalink raw reply related

* Re: [PATCH V2] ipconfig: Inform user if carrier is not ready
From: Erwan Velu @ 2012-09-14 19:31 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, rick.jones2
In-Reply-To: <20120914.151724.505809965127351650.davem@davemloft.net>

Le 14/09/2012 21:17, David Miller a écrit :
> This is badly formatted, either because you explicitly did so or 
> because your email client corrupted the patch. Either way you have to 
> fix this before we can seriously consider your patch. 
All apollogies, that was my stupid fault.

That's fixed. Sent as V3.

Thanks for proof-reading this stupid patch :)

Erwan

^ permalink raw reply

* Re: [PATCH V3] ipconfig: Inform user if carrier is not ready
From: David Miller @ 2012-09-14 19:42 UTC (permalink / raw)
  To: erwanaliasr1; +Cc: netdev, rick.jones2
In-Reply-To: <505385E2.6050600@gmail.com>


Your email client is still corrupting this patch.

Turn off all transformations in your outgoing emails such as
text formatting and such.

In fact, email the patch to yourself, and make sure you can successfully
apply the result.

Also, you have formatted the comment improperly.

Don't format comments:

	/* Like
	   this.  */

but rather, format them:

	/* Like
	 * this.
	 */

You also didn't style the variable declaration and assignment properly,
there must be a space around the "=" sign, like this:

	unsigned int loops = 0;

Thanks.

^ permalink raw reply

* [PATCH] xfrm_user: return error pointer instead of NULL #2
From: Mathias Krause @ 2012-09-14 19:58 UTC (permalink / raw)
  To: David S. Miller
  Cc: Steffen Klassert, netdev, linux-kernel, Mathias Krause, stable

When dump_one_policy() returns an error, e.g. because of a too small
buffer to dump the whole xfrm policy, xfrm_policy_netlink() returns
NULL instead of an error pointer. But its caller expects an error
pointer and therefore continues to operate on a NULL skbuff.

Cc: stable@vger.kernel.org
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---

Note, this is a different, but similar issue as my previous patch
with the almost same subject.

I'm not aware of a way how to exploit this bug as the policy *should*
always fit into the netlink buffer but better safe then sorry, so cc
stable.

 net/xfrm/xfrm_user.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index dac08e2..d12b625 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1548,6 +1548,7 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
 {
 	struct xfrm_dump_info info;
 	struct sk_buff *skb;
+	int err;
 
 	skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!skb)
@@ -1558,9 +1559,10 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
 	info.nlmsg_seq = seq;
 	info.nlmsg_flags = 0;
 
-	if (dump_one_policy(xp, dir, 0, &info) < 0) {
+	err = dump_one_policy(xp, dir, 0, &info);
+	if (err) {
 		kfree_skb(skb);
-		return NULL;
+		return ERR_PTR(err);
 	}
 
 	return skb;
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH V3] ipconfig: Inform user if carrier is not ready
From: Erwan Velu @ 2012-09-14 20:13 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, rick.jones2
In-Reply-To: <20120914.154227.677746835040890172.davem@davemloft.net>

Le 14/09/2012 21:42, David Miller a écrit :
> Your email client is still corrupting this patch.
>
> Turn off all transformations in your outgoing emails such as
> text formatting and such.
>
> In fact, email the patch to yourself, and make sure you can successfully
> apply the result
I didn't succeed at making thunderbird not corrupting the patch...
I did put the patch on an http link to insure no corruption will occurs.

http://pubz.free.fr/0001-ipconfig-Inform-user-if-carrier-is-not-ready.patch

Hope this will be acceptable....

Cheers,

^ permalink raw reply

* Re: [PATCH V3] ipconfig: Inform user if carrier is not ready
From: David Miller @ 2012-09-14 20:23 UTC (permalink / raw)
  To: erwanaliasr1; +Cc: netdev, rick.jones2
In-Reply-To: <50538FCC.5030907@gmail.com>

From: Erwan Velu <erwanaliasr1@gmail.com>
Date: Fri, 14 Sep 2012 22:13:00 +0200

> I didn't succeed at making thunderbird not corrupting the patch...

Read Documentation/email-clients.txt in the kernel tree for help.

^ permalink raw reply

* [PATCH v4] ipconfig: Inform user if carrier is not ready
From: Erwan Velu @ 2012-09-14 20:56 UTC (permalink / raw)
  To: netdev; +Cc: Erwan Velu

While using the ip= option at the cmdline, the kernel can hold the boot
process for 2 minutes (CONF_CARRIER_TIMEOUT) if the carrier is not
present.

While waiting the carrier, user is not informed about this situation and
so could think the kernel is frozen.

If we don't get the carrier after some seconds, let's display a message to
inform the user about the remaining time before reaching the timeout.

Signed-off-by: Erwan Velu <erwanaliasr1@gmail.com>
---
 net/ipv4/ipconfig.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 67e8a6b..fb17bad 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -90,6 +90,7 @@
 /* Define the friendly delay before and after opening net devices */
 #define CONF_POST_OPEN		10	/* After opening: 10 msecs */
 #define CONF_CARRIER_TIMEOUT	120000	/* Wait for carrier timeout */
+#define CONF_WARN_CARRIER_TIMEOUT 5000	/* Time before showing a warning message  */
 
 /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
 #define CONF_OPEN_RETRIES 	2	/* (Re)open devices twice */
@@ -205,6 +206,7 @@ static int __init ic_open_devs(void)
 	struct net_device *dev;
 	unsigned short oflags;
 	unsigned long start;
+	unsigned int loops = 0;
 
 	last = &ic_first_dev;
 	rtnl_lock();
@@ -266,6 +268,17 @@ static int __init ic_open_devs(void)
 			if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
 				goto have_carrier;
 
+		/* This loop is blocking the boot process until 
+		 *  we get the carrier or reach the timeout.
+		 *  We have to inform the user about the situation as 
+		 *  it could look like a kernel freeze.
+		 *  After CONF_WARN_CARRIER_TIMEOUT milliseconds,
+		 *  we display the remaing time before reaching the timeout.
+		 */
+		if (++loops == CONF_WARN_CARRIER_TIMEOUT) {
+			pr_info("IP-Config: Waiting up to %d seconds for carrier on interface\n", 
+				(CONF_CARRIER_TIMEOUT - CONF_WARN_CARRIER_TIMEOUT)/ 1000);
+		}
 		msleep(1);
 	}
 have_carrier:
-- 
1.7.10

^ permalink raw reply related

* Re: [PATCH V3] ipconfig: Inform user if carrier is not ready
From: Erwan Velu @ 2012-09-14 20:59 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, rick.jones2
In-Reply-To: <20120914.162328.1573012858060481900.davem@davemloft.net>

Le 14/09/2012 22:23, David Miller a écrit :
> From: Erwan Velu <erwanaliasr1@gmail.com>
> Date: Fri, 14 Sep 2012 22:13:00 +0200
>
>> I didn't succeed at making thunderbird not corrupting the patch...
> Read Documentation/email-clients.txt in the kernel tree for help.
>
Sent with git send-email... this time this will be far better I hope..
Thanks rick for pointing this.

Sorry for this long thread about newbie posting...

Erwan

^ permalink raw reply

* Re: kernel BUG at kernel/timer.c:748!
From: Dave Jones @ 2012-09-14 21:29 UTC (permalink / raw)
  To: Julian Anastasov; +Cc: netdev
In-Reply-To: <alpine.LFD.2.00.1209052343110.2201@ja.ssi.bg>

On Wed, Sep 05, 2012 at 11:48:29PM +0300, Julian Anastasov wrote:
 
 > > kernel BUG at kernel/timer.c:748!
 > > Call Trace:
 > >  ? lock_sock_nested+0x8d/0xa0
 > >  sk_reset_timer+0x1c/0x30
 > >  ? sock_setsockopt+0x8c/0x960
 > >  inet_csk_reset_keepalive_timer+0x20/0x30
 > >  tcp_set_keepalive+0x3d/0x50
 > >  sock_setsockopt+0x923/0x960
 > >  ? trace_hardirqs_on_caller+0x16/0x1e0
 > >  ? fget_light+0x24c/0x520
 > >  sys_setsockopt+0xc6/0xe0
 > >  system_call_fastpath+0x1a/0x1f
 > 
 > 	Can this help? In case you see ICMPV6_PKT_TOOBIG...
 > 
 > [PATCH] tcp: fix possible socket refcount problem for ipv6

I just managed to reproduce this bug on rc5 with this patch,
so it doesn't seem to help.

	Dave

^ permalink raw reply

* [PATCH 00/24] ARM: readl/writel conversion fallout
From: Arnd Bergmann @ 2012-09-14 21:34 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-fbdev, linux-sh, Tony Lindgren, Linus Walleij, Will Deacon,
	Wolfram Sang, Roland Stigge, Kukjin Kim, linux-scsi,
	Nicolas Pitre, Magnus Damm, linux-input, Russell King,
	David Brown, Arnd Bergmann, Nicolas Ferre, spear-devel,
	Florian Tobias Schandinat, Shiraz Hashim, Simon Horman, Shawn Guo,
	Ryan Mallon, Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel

Linux-next currently contains 195bbcac "ARM: 7500/1: io: avoid writeback
addressing modes for __raw_ accessors" from Will Deacon. While this
patch does a number of very useful things, it also causes a lot of
new build warnings in ARM specific code that was passing an integer
as the address into readl/writel or similar functions.

Most architectures have never allowed this, and my feeling is that
it's time for ARM to do the same, so instead of changing the
readl/writel behavior back, we should fix all code that uses
incorrect addressing.

A few people have already posted platform specific patches, this
should take care of the rest that is needed for all defconfig
builds. The majority of the warnings was in the shmobile platform,
so those patches are by far the largest.

I'm happy to have these patches go through individual subsystem
maintainers, especially for the device drivers and those that
have conflicts with other changes (ixp4xx, integrator, shmobile),
but I can carry the reamining ones in one branch for arm-soc.

Right now, the whole set is available in the testing/__iomem
branch.

	Arnd

Cc: "David S. Miller" <davem@davemloft.net>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: David Brown <davidb@codeaurora.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Imre Kaloz <kaloz@openwrt.org>
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Roland Stigge <stigge@antcom.de>
Cc: Ryan Mallon <rmallon@gmail.com>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Shiraz Hashim <shiraz.hashim@st.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: STEricsson_nomadik_linux@list.st.com>
Cc: linux-fbdev@vger.kernel.org
Cc: linux-input@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: spear-devel@list.st.com

Arnd Bergmann (24):
  ARM: shmobile: use __iomem pointers for MMIO
  ARM: at91: use __iomem pointers for MMIO
  ARM: ebsa: use __iomem pointers for MMIO
  ARM: ep93xx: use _iomem pointers for MMIO
  ARM: imx: use __iomem pointers for MMIO
  ARM: integrator: use __iomem pointers for MMIO
  ARM: iop13xx: use __iomem pointers for MMIO
  ARM: iop32x: use __iomem pointers for MMIO
  ARM: ixp4xx: use __iomem pointers for MMIO
  ARM: ks8695: use __iomem pointers for MMIO
  ARM: lpc32xx: use __iomem pointers for MMIO
  ARM: msm: use __iomem pointers for MMIO
  ARM: nomadik: use __iomem pointers for MMIO
  ARM: prima2: use __iomem pointers for MMIO
  ARM: sa1100: use __iomem pointers for MMIO
  ARM: spear13xx: use __iomem pointers for MMIO
  ARM: OMAP: use __iomem pointers for MMIO
  ARM: samsung: use __iomem pointers for MMIO
  sh: use __iomem pointers for MMIO
  input: rpcmouse: use __iomem pointers for MMIO
  serial: ks8695: use __iomem pointers for MMIO
  scsi: eesox: use __iomem pointers for MMIO
  video: da8xx-fb: use __iomem pointers for MMIO
  net: seeq: use __iomem pointers for MMIO

 arch/arm/mach-at91/at91x40.c                    |    2 +-
 arch/arm/mach-at91/at91x40_time.c               |    4 +-
 arch/arm/mach-at91/include/mach/hardware.h      |    4 +-
 arch/arm/mach-at91/include/mach/uncompress.h    |    6 +-
 arch/arm/mach-at91/setup.c                      |    4 +-
 arch/arm/mach-ebsa110/core.c                    |    8 +--
 arch/arm/mach-ebsa110/core.h                    |   12 ++--
 arch/arm/mach-ep93xx/include/mach/ts72xx.h      |   10 ++--
 arch/arm/mach-ep93xx/ts72xx.c                   |   10 ++--
 arch/arm/mach-imx/mach-armadillo5x0.c           |    2 +-
 arch/arm/mach-imx/mach-kzm_arm11_01.c           |    4 +-
 arch/arm/mach-imx/mach-mx31ads.c                |    2 +-
 arch/arm/mach-imx/mach-mx31lite.c               |    2 +-
 arch/arm/mach-integrator/core.c                 |    4 +-
 arch/arm/mach-integrator/cpu.c                  |    8 +--
 arch/arm/mach-integrator/integrator_ap.c        |   12 ++--
 arch/arm/mach-integrator/integrator_cp.c        |    6 +-
 arch/arm/mach-integrator/pci_v3.c               |   12 ++--
 arch/arm/mach-iop13xx/include/mach/iop13xx.h    |   20 +++----
 arch/arm/mach-iop13xx/include/mach/memory.h     |   14 ++---
 arch/arm/mach-iop13xx/io.c                      |   12 ++--
 arch/arm/mach-iop13xx/pci.c                     |   16 +++---
 arch/arm/mach-iop13xx/pci.h                     |    4 +-
 arch/arm/mach-iop13xx/setup.c                   |   10 ++--
 arch/arm/mach-iop32x/glantank.c                 |    2 +-
 arch/arm/mach-ixp4xx/common.c                   |    8 +--
 arch/arm/mach-ixp4xx/include/mach/cpu.h         |    5 +-
 arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h |   10 ++--
 arch/arm/mach-ks8695/cpu.c                      |    2 +-
 arch/arm/mach-ks8695/include/mach/hardware.h    |    2 +-
 arch/arm/mach-ks8695/include/mach/uncompress.h  |    6 +-
 arch/arm/mach-lpc32xx/common.c                  |    8 +--
 arch/arm/mach-lpc32xx/include/mach/hardware.h   |    2 +-
 arch/arm/mach-msm/smd.c                         |   19 +++---
 arch/arm/mach-nomadik/board-nhk8815.c           |    3 +-
 arch/arm/mach-nomadik/include/mach/hardware.h   |    2 +-
 arch/arm/mach-nomadik/include/mach/uncompress.h |    8 +--
 arch/arm/mach-prima2/include/mach/uncompress.h  |    4 +-
 arch/arm/mach-sa1100/include/mach/simpad.h      |    2 +-
 arch/arm/mach-sa1100/simpad.c                   |    2 +-
 arch/arm/mach-shmobile/board-ap4evb.c           |   12 ++--
 arch/arm/mach-shmobile/board-armadillo800eva.c  |    6 +-
 arch/arm/mach-shmobile/board-bonito.c           |    8 +--
 arch/arm/mach-shmobile/board-g3evm.c            |   12 ++--
 arch/arm/mach-shmobile/board-g4evm.c            |   30 +++++-----
 arch/arm/mach-shmobile/board-kzm9g.c            |    8 +--
 arch/arm/mach-shmobile/board-mackerel.c         |   22 +++----
 arch/arm/mach-shmobile/clock-r8a7740.c          |   46 +++++++--------
 arch/arm/mach-shmobile/clock-sh7367.c           |   44 +++++++-------
 arch/arm/mach-shmobile/clock-sh7372.c           |   60 +++++++++----------
 arch/arm/mach-shmobile/clock-sh7377.c           |   50 ++++++++--------
 arch/arm/mach-shmobile/clock-sh73a0.c           |   70 +++++++++++------------
 arch/arm/mach-shmobile/include/mach/gpio.h      |    6 +-
 arch/arm/mach-shmobile/intc-r8a7779.c           |   14 ++---
 arch/arm/mach-shmobile/intc-sh7372.c            |   27 +++++----
 arch/arm/mach-shmobile/intc-sh73a0.c            |   20 ++++---
 arch/arm/mach-shmobile/pm-rmobile.c             |    6 +-
 arch/arm/mach-shmobile/pm-sh7372.c              |   57 +++++++++---------
 arch/arm/mach-shmobile/setup-sh7367.c           |    2 +-
 arch/arm/mach-shmobile/setup-sh7377.c           |    2 +-
 arch/arm/mach-shmobile/setup-sh73a0.c           |    2 +-
 arch/arm/mach-spear13xx/include/mach/spear.h    |   14 ++---
 arch/arm/mach-spear13xx/spear13xx.c             |    6 +-
 arch/arm/plat-mxc/include/mach/mx31.h           |    6 +-
 arch/arm/plat-omap/include/plat/hardware.h      |   18 +++---
 arch/arm/plat-samsung/s5p-irq-gpioint.c         |    4 +-
 drivers/input/mouse/rpcmouse.c                  |    2 +-
 drivers/net/ethernet/seeq/ether3.c              |    4 +-
 drivers/scsi/arm/eesox.c                        |    2 +-
 drivers/sh/intc/access.c                        |   56 +++++++++---------
 drivers/sh/intc/chip.c                          |    8 +--
 drivers/sh/intc/core.c                          |    6 +-
 drivers/sh/intc/handle.c                        |    6 +-
 drivers/sh/intc/internals.h                     |   18 +++---
 drivers/sh/intc/virq.c                          |    3 +-
 drivers/tty/serial/serial_ks8695.c              |    4 +-
 drivers/video/da8xx-fb.c                        |    8 +--
 include/linux/serial_sci.h                      |    2 +-
 include/linux/sh_clk.h                          |    4 +-
 79 files changed, 477 insertions(+), 471 deletions(-)

-- 
1.7.10

^ permalink raw reply

* [PATCH 24/24] net: seeq: use __iomem pointers for MMIO
From: Arnd Bergmann @ 2012-09-14 21:34 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-kernel, Will Deacon, Russell King, Nicolas Pitre,
	Arnd Bergmann, netdev, David S. Miller
In-Reply-To: <1347658492-11608-1-git-send-email-arnd@arndb.de>

ARM is moving to stricter checks on readl/write functions,
so we need to use the correct types everywhere.

Cc: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/seeq/ether3.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/seeq/ether3.c b/drivers/net/ethernet/seeq/ether3.c
index df808ac..6a40dd0 100644
--- a/drivers/net/ethernet/seeq/ether3.c
+++ b/drivers/net/ethernet/seeq/ether3.c
@@ -99,13 +99,13 @@ typedef enum {
  * The SEEQ8005 doesn't like us writing to its registers
  * too quickly.
  */
-static inline void ether3_outb(int v, const void __iomem *r)
+static inline void ether3_outb(int v, void __iomem *r)
 {
 	writeb(v, r);
 	udelay(1);
 }
 
-static inline void ether3_outw(int v, const void __iomem *r)
+static inline void ether3_outw(int v, void __iomem *r)
 {
 	writew(v, r);
 	udelay(1);
-- 
1.7.10

^ permalink raw reply related

* inet_gifconf question
From: Alan Cox @ 2012-09-14 22:09 UTC (permalink / raw)
  To: netdev

Can anyone tell me what inet_gifconf is meant to be doing with the test
of ifa->ifa_label against NULL when ifa->ifa_label is an array ?

Alan

^ permalink raw reply

* Re: [PATCH 24/24] net: seeq: use __iomem pointers for MMIO
From: Russell King - ARM Linux @ 2012-09-14 23:56 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Nicolas Pitre, netdev, Will Deacon, linux-kernel, David S. Miller,
	linux-arm-kernel
In-Reply-To: <1347658492-11608-25-git-send-email-arnd@arndb.de>

On Fri, Sep 14, 2012 at 11:34:52PM +0200, Arnd Bergmann wrote:
> ARM is moving to stricter checks on readl/write functions,
> so we need to use the correct types everywhere.

Same comment as for eesox.  const void __iomem * is not a problem on
x86, so it should not be a problem on ARM.

^ permalink raw reply

* Re: [PATCH 24/24] net: seeq: use __iomem pointers for MMIO
From: David Miller @ 2012-09-15  4:00 UTC (permalink / raw)
  To: linux; +Cc: arnd, linux-arm-kernel, linux-kernel, will.deacon, nico, netdev
In-Reply-To: <20120914235607.GF12245@n2100.arm.linux.org.uk>

From: Russell King - ARM Linux <linux@arm.linux.org.uk>
Date: Sat, 15 Sep 2012 00:56:07 +0100

> On Fri, Sep 14, 2012 at 11:34:52PM +0200, Arnd Bergmann wrote:
>> ARM is moving to stricter checks on readl/write functions,
>> so we need to use the correct types everywhere.
> 
> Same comment as for eesox.  const void __iomem * is not a problem on
> x86, so it should not be a problem on ARM.

Agreed.

^ permalink raw reply

* Re: inet_gifconf question
From: David Miller @ 2012-09-15  4:01 UTC (permalink / raw)
  To: alan; +Cc: netdev
In-Reply-To: <20120914230935.65a3769b@pyramind.ukuu.org.uk>

From: Alan Cox <alan@lxorguk.ukuu.org.uk>
Date: Fri, 14 Sep 2012 23:09:35 +0100

> Can anyone tell me what inet_gifconf is meant to be doing with the test
> of ifa->ifa_label against NULL when ifa->ifa_label is an array ?

It wasn't always an array, and this spot got missed during the
conversion it seems.

^ permalink raw reply

* [PATCH] sched: fix virtual-start-time update in QFQ
From: Paolo Valente @ 2012-09-15 10:41 UTC (permalink / raw)
  To: davem, shemminger, jhs
  Cc: fchecconi, rizzo, netdev, linux-kernel, paolo.valente

If the old timestamps of a class, say cl, are stale when the class
becomes active, then QFQ may assign to cl a much higher start time
than the maximum value allowed. This may happen when QFQ assigns to
the start time of cl the finish time of a group whose classes are
characterized by a higher value of the ratio
max_class_pkt/weight_of_the_class with respect to that of
cl. Inserting a class with a too high start time into the bucket list
corrupts the data structure and may eventually lead to crashes.
This patch limits the maximum start time assigned to a class.

Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
---
 net/sched/sch_qfq.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index e4723d3..211a212 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -865,7 +865,10 @@ static void qfq_update_start(struct qfq_sched *q, struct qfq_class *cl)
 		if (mask) {
 			struct qfq_group *next = qfq_ffs(q, mask);
 			if (qfq_gt(roundedF, next->F)) {
-				cl->S = next->F;
+				if (qfq_gt(limit, next->F))
+					cl->S = next->F;
+				else /* preserve timestamp correctness */
+					cl->S = limit;
 				return;
 			}
 		}
-- 
1.7.9.5

^ permalink raw reply related

* Re: interrupt coalescing and CSUM offload
From: Joakim Tjernlund @ 2012-09-15 12:09 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20120914093252.020992cc@nehalam.linuxnetplumber.net>

Stephen Hemminger <shemminger@vyatta.com> wrote on 2012/09/14 18:32:52:
>
> On Fri, 14 Sep 2012 16:35:13 +0200
> Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
>
> >
> > I am adding interrupt coalescing to the ucc_geth driver. Unfortunately
> > there is only support for RX interrupt coalescing.
> > I wonder if there is any way "simulate" TX interrupt coalescing?
> >
> > I am also looking at adding HWCSUM support but this device can only do
> > IP header CSUM offload. This doesn't seem to be an option in Linux?
> > As I understand it, one must do CSUM offload for the whole frame, both
> > IP header and TCP/UDP csums?
> >
> >  Jocke
>
> There are a few drivers that turn off TX interrupt completely.
> They cleanup TX buffers on next send and have a timer to cleanup

Only on send? Currently ucc_geth does TX free in napi(where RX is processed too).
It would be nice if one could indicate to the drivers xmit() if there
are more frames to be sent. Then xmit() could choose not to turn on TX irq for
preceding frames.

> as well. This has performance benefits, but it does cause issues
> with local flow control (the freeing of skb is used to rate
> limit local traffic).

Was my reasoning correct w.r.t CSUM?

^ permalink raw reply

* Re: [PATCH net-next 1/2] net: provide a default dev->ethtool_ops
From: Ben Hutchings @ 2012-09-15 13:40 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Maciej Żenczykowski
In-Reply-To: <1347607441.8555.265.camel@edumazet-glaptop>

On Fri, 2012-09-14 at 09:24 +0200, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Instead of forcing device drivers to provide empty ethtool_ops or tweak
> net/core/ethtool.c again, we could provide a generic ethtool_ops.
> 
> This occurred to me when I wanted to add GSO support to GRE tunnels.
> ethtool -k support should be generic for all drivers.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Maciej Żenczykowski <maze@google.com>

Yes, I should have done this ages ago.  Just some nit-picking below:

[...]
> diff --git a/net/core/dev.c b/net/core/dev.c
> index b1e6d63..ff8dcfc 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -6045,6 +6045,11 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
>  
>  	strcpy(dev->name, name);
>  	dev->group = INIT_NETDEV_GROUP;
> +	if (!dev->ethtool_ops) {
> +		static const struct ethtool_ops default_ethtool_ops;
> +
> +		dev->ethtool_ops = &default_ethtool_ops;
> +	}

This block has a blank line in it, so I think it needs a blank line
either side to make the visual grouping of code right.  Alternately you
could pull the variable out of the block.

[...] 
> @@ -1410,8 +1409,9 @@ static int ethtool_get_module_eeprom(struct net_device *dev,
>  				      modinfo.eeprom_len);
>  }
>  
> -/* The main entry point in this file.  Called from net/core/dev.c */
> -
> +/* The main entry point in this file.  Called from net/core/dev.c
> + * with RTNL held.
> + */

Good point but an unrelated change.

>  int dev_ethtool(struct net *net, struct ifreq *ifr)
>  {
>  	struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
> @@ -1419,25 +1419,15 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
>  	u32 ethcmd;
>  	int rc;
>  	u32 old_features;
> +	const struct ethtool_ops *ops;
>  
>  	if (!dev || !netif_device_present(dev))
>  		return -ENODEV;
>  
> +	ops = dev->ethtool_ops;
[...]

Introducing this local variable is a useful cleanup but again should be
a separate change.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply

* Re: Remarks and comments about ipconfig behavior
From: Erwan Velu @ 2012-09-15 16:18 UTC (permalink / raw)
  To: David Miller; +Cc: netdev
In-Reply-To: <20120913.163134.361379133013906511.davem@davemloft.net>

Le 13/09/2012 22:31, David Miller a écrit :
> I've seen PHY/switch/hub combinations that take longer than 30 seconds to fully negotiate the link. There is really no upper limit to the link speed/duplex/etc. negoatiation process. Even if the actual negoatiation protocol had an upper limit on negoatiation time, hardware implementations do things like try sampling the quality of the cable signal and may choose to down-rev the advertised features and restart the negoatiation. 

I do understand that some might need some longer values while some others like me really need a smaller one.

On my case, this 2mn wait breaks an hardware watchdog, so I did a small patch on my local build to get it reduced as I know  the selected value works fine for this hardware setup. And it works now perfectly.

So could it be valuable to export it as a CONFIG_something instead of patching this #define ?

Cheers,

^ permalink raw reply

* [RFC PATCH 1/3] usbnet: introduce usbnet_link_change API
From: Ming Lei @ 2012-09-15 17:48 UTC (permalink / raw)
  To: David S. Miller, Greg Kroah-Hartman
  Cc: Oliver Neukum, Fink Dmitry, Rafael Wysocki, Alan Stern,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	Ming Lei
In-Reply-To: <1347731299-29898-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

This patch introduces the API of usbnet_link_change, so that
usbnet can trace the link change, which may help to implement
the later runtime PM triggered by usb ethernet link change.

Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
 drivers/net/usb/usbnet.c   |   11 +++++++++++
 include/linux/usb/usbnet.h |    2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index e944109..95a96b1 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1591,6 +1591,17 @@ int usbnet_resume (struct usb_interface *intf)
 }
 EXPORT_SYMBOL_GPL(usbnet_resume);
 
+void usbnet_link_change(struct usbnet *dev, int link, int need_reset)
+{
+	if (link)
+		netif_carrier_on(dev->net);
+	else
+		netif_carrier_off(dev->net);
+
+	if (need_reset && link)
+		usbnet_defer_kevent(dev, EVENT_LINK_RESET);
+}
+EXPORT_SYMBOL_GPL(usbnet_link_change);
 
 /*-------------------------------------------------------------------------*/
 
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index f87cf62..1937b74 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -160,7 +160,7 @@ extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *);
 extern int usbnet_suspend(struct usb_interface *, pm_message_t);
 extern int usbnet_resume(struct usb_interface *);
 extern void usbnet_disconnect(struct usb_interface *);

^ permalink raw reply related

* [RFC PATCH 0/3] usbnet: support runtime PM triggered by link change
From: Ming Lei @ 2012-09-15 17:48 UTC (permalink / raw)
  To: David S. Miller, Greg Kroah-Hartman
  Cc: Oliver Neukum, Fink Dmitry, Rafael Wysocki, Alan Stern, netdev,
	linux-usb

Hi,

Currently only very few usbnet devices support the traffic based
runtime PM, eg. wake up devices if there are packets to be transmitted.

For the below situation, it should make sense to runtime suspend usbnet
device to save power:
	
	- after network link becomes down

This patch implements the runtime PM triggered by network link change
event, and it works basically on asix usbnet device after a simple
runtime PM test.

 drivers/net/usb/asix_devices.c |    6 +-
 drivers/net/usb/cdc_ether.c    |    5 +-
 drivers/net/usb/cdc_ncm.c      |    9 +-
 drivers/net/usb/dm9601.c       |    7 +-
 drivers/net/usb/mcs7830.c      |    6 +-
 drivers/net/usb/sierra_net.c   |    6 +-
 drivers/net/usb/usbnet.c       |  224 +++++++++++++++++++++++++++++++++++++++-
 include/linux/usb/usbnet.h     |   21 +++-
 8 files changed, 250 insertions(+), 34 deletions(-)


Thanks
--
Ming Lei

^ permalink raw reply

* [RFC PATCH 2/3] usbnet: apply usbnet_link_change
From: Ming Lei @ 2012-09-15 17:48 UTC (permalink / raw)
  To: David S. Miller, Greg Kroah-Hartman
  Cc: Oliver Neukum, Fink Dmitry, Rafael Wysocki, Alan Stern, netdev,
	linux-usb, Ming Lei
In-Reply-To: <1347731299-29898-1-git-send-email-ming.lei@canonical.com>

This patch applies the introduce usbnet_link_change API.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/net/usb/asix_devices.c |    6 +-----
 drivers/net/usb/cdc_ether.c    |    5 +----
 drivers/net/usb/cdc_ncm.c      |    9 +++------
 drivers/net/usb/dm9601.c       |    7 +------
 drivers/net/usb/mcs7830.c      |    6 +-----
 drivers/net/usb/sierra_net.c   |    3 +--
 drivers/net/usb/usbnet.c       |    2 +-
 7 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 4fd48df..c354bb1 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -55,11 +55,7 @@ static void asix_status(struct usbnet *dev, struct urb *urb)
 	event = urb->transfer_buffer;
 	link = event->link & 0x01;
 	if (netif_carrier_ok(dev->net) != link) {
-		if (link) {
-			netif_carrier_on(dev->net);
-			usbnet_defer_kevent (dev, EVENT_LINK_RESET );
-		} else
-			netif_carrier_off(dev->net);
+		usbnet_link_change(dev, link, 1);
 		netdev_dbg(dev->net, "Link Status is: %d\n", link);
 	}
 }
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index a03de71..c6e4be5 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -406,10 +406,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
 	case USB_CDC_NOTIFY_NETWORK_CONNECTION:
 		netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
 			  event->wValue ? "on" : "off");
-		if (event->wValue)
-			netif_carrier_on(dev->net);
-		else
-			netif_carrier_off(dev->net);
+		usbnet_link_change(dev, event->wValue, 0);
 		break;
 	case USB_CDC_NOTIFY_SPEED_CHANGE:	/* tx/rx rates */
 		netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n",
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 4cd582a..f425c2c 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -593,7 +593,7 @@ advance:
 	 * (carrier is OFF) during attach, so the IP network stack does not
 	 * start IPv6 negotiation and more.
 	 */
-	netif_carrier_off(dev->net);
+	usbnet_link_change(dev, 0, 0);
 	ctx->tx_speed = ctx->rx_speed = 0;
 	return 0;
 
@@ -1131,12 +1131,9 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
 			" %sconnected\n",
 			ctx->netdev->name, ctx->connected ? "" : "dis");
 
-		if (ctx->connected)
-			netif_carrier_on(dev->net);
-		else {
-			netif_carrier_off(dev->net);
+		usbnet_link_change(dev, ctx->connected, 0);
+		if (!ctx->connected)
 			ctx->tx_speed = ctx->rx_speed = 0;
-		}
 		break;
 
 	case USB_CDC_NOTIFY_SPEED_CHANGE:
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index e0433ce..7422d5a 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -587,12 +587,7 @@ static void dm9601_status(struct usbnet *dev, struct urb *urb)
 
 	link = !!(buf[0] & 0x40);
 	if (netif_carrier_ok(dev->net) != link) {
-		if (link) {
-			netif_carrier_on(dev->net);
-			usbnet_defer_kevent (dev, EVENT_LINK_RESET);
-		}
-		else
-			netif_carrier_off(dev->net);
+		usbnet_link_change(dev, link, 1);
 		netdev_dbg(dev->net, "Link Status is: %d\n", link);
 	}
 }
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 03c2d8d..49a98b7 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -639,11 +639,7 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb)
 
 	link = !(buf[1] & 0x20);
 	if (netif_carrier_ok(dev->net) != link) {
-		if (link) {
-			netif_carrier_on(dev->net);
-			usbnet_defer_kevent(dev, EVENT_LINK_RESET);
-		} else
-			netif_carrier_off(dev->net);
+		usbnet_link_change(dev, link, 1);
 		netdev_dbg(dev->net, "Link Status is: %d\n", link);
 	}
 }
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 7ae70e9..08ed9e5 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -414,11 +414,10 @@ static void sierra_net_handle_lsi(struct usbnet *dev, char *data,
 	if (link_up) {
 		sierra_net_set_ctx_index(priv, hh->msgspecific.byte);
 		priv->link_up = 1;
-		netif_carrier_on(dev->net);
 	} else {
 		priv->link_up = 0;
-		netif_carrier_off(dev->net);
 	}
+	usbnet_link_change(dev, link_up, 0);
 }
 
 static void sierra_net_dosync(struct usbnet *dev)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 95a96b1..054ffd8 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1487,7 +1487,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	netif_device_attach (net);
 
 	if (dev->driver_info->flags & FLAG_LINK_INTR)
-		netif_carrier_off(net);
+		usbnet_link_change(dev, 0, 0);
 
 	return 0;
 
-- 
1.7.9.5

^ permalink raw reply related

* [RFC PATCH 3/3] usbnet: support runtime PM triggered by link change
From: Ming Lei @ 2012-09-15 17:48 UTC (permalink / raw)
  To: David S. Miller, Greg Kroah-Hartman
  Cc: Oliver Neukum, Fink Dmitry, Rafael Wysocki, Alan Stern, netdev,
	linux-usb, Ming Lei
In-Reply-To: <1347731299-29898-1-git-send-email-ming.lei@canonical.com>

This patch implements runtime PM triggered by link change event
for devices which haven't defined manage_power() callback, based
on the below consideration:

- this kind of runtime PM has been supported by some PCI network
interfaces already, and it does make sense to suspend the usb
device to save power if no link is detected

- link down triggered runtime needn't to be implemented for devices
which have already supported traffic based runtime PM by .manage_power,
because runtime suspend can be triggered when no tx frames are to be
transmitted after link becoms down.

Unfortunately, some usbnet devices don't support remote wakeup,
or some devices may support it but the remote wakup can't be enabled
for link change event for some reason(no documents are public, not
supported ...).

This patch takes a periodic timer to wake up devices for detecting
the link change event if remote wakeup by link change can't be
supported. If the link is found to be down, put the device into
suspend immediately.

For the devices which support remote wakeup by link change and
don't support remote wakeup by incoming packets(not implement
manage_power callback), the patch can still make link change
triggered runtime PM working on these devices.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/net/usb/sierra_net.c |    3 +-
 drivers/net/usb/usbnet.c     |  211 +++++++++++++++++++++++++++++++++++++++++-
 include/linux/usb/usbnet.h   |   19 ++++
 3 files changed, 229 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 08ed9e5..0993f2d 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -418,6 +418,7 @@ static void sierra_net_handle_lsi(struct usbnet *dev, char *data,
 		priv->link_up = 0;
 	}
 	usbnet_link_change(dev, link_up, 0);
+	usbnet_link_updated(dev);
 }
 
 static void sierra_net_dosync(struct usbnet *dev)
@@ -915,7 +916,7 @@ static struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev,
 
 static const struct driver_info sierra_net_info_direct_ip = {
 	.description = "Sierra Wireless USB-to-WWAN Modem",
-	.flags = FLAG_WWAN | FLAG_SEND_ZLP,
+	.flags = FLAG_WWAN | FLAG_SEND_ZLP | FLAG_LINK_UPDATE_BY_DRIVER,
 	.bind = sierra_net_bind,
 	.unbind = sierra_net_unbind,
 	.status = sierra_net_status,
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 054ffd8..8db1618 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -677,6 +677,186 @@ static void usbnet_terminate_urbs(struct usbnet *dev)
 	remove_wait_queue(&unlink_wakeup, &wait);
 }
 
+void usbnet_link_updated(struct usbnet *dev)
+{
+	complete(&dev->link_update_completion);
+}
+EXPORT_SYMBOL_GPL(usbnet_link_updated);
+
+#define usbnet_link_suspend(dev) do { \
+	dev_dbg(&dev->intf->dev, "%s:link suspend", __func__); \
+	usb_autopm_put_interface_async(dev->intf); \
+} while(0)
+
+#define usbnet_link_resume(dev) do { \
+	dev_dbg(&dev->intf->dev, "%s:link resume", __func__); \
+	usb_autopm_get_interface_async(dev->intf); \
+} while(0)
+
+static int need_link_runtime_pm(struct usbnet *dev)
+{
+	if (dev->driver_info->manage_power)
+		return 0;
+
+	if (!dev->driver_info->status)
+		return 0;
+
+	return 1;
+}
+
+/* called by usbnet_suspend */
+static void start_link_detect(struct usbnet *dev)
+{
+	if (!dev->link_rpm_enabled)
+		return;
+
+	if (dev->link_remote_wakeup)
+		return;
+
+	if (dev->link_check_started)
+		return;
+
+	dev->link_check_started = 1;
+	schedule_delayed_work(&dev->link_detect_work,
+			      msecs_to_jiffies(3000));
+}
+
+/* called by usbnet_resume */
+static void end_link_detect(struct usbnet *dev, int force_cancel)
+{
+	if (!dev->link_rpm_enabled)
+		return;
+
+	if (!dev->link_check_started)
+		return;
+
+	/*
+	 * cancel the link detect work if usbnet is resumed
+	 * not by link detect work
+	 */
+	if (!dev->link_checking || force_cancel)
+		cancel_delayed_work_sync(&dev->link_detect_work);
+
+	dev->link_check_started = 0;
+}
+
+/* called by usbnet_open */
+static void enable_link_runtime_pm(struct usbnet *dev)
+{
+	dev->link_rpm_enabled = 1;
+
+	if (!dev->link_remote_wakeup) {
+		dev->old_autosuspend_delay =
+			dev->udev->dev.power.autosuspend_delay;
+		pm_runtime_set_autosuspend_delay(&dev->udev->dev, 1);
+	}
+
+	if (!netif_carrier_ok(dev->net)) {
+		dev->link_open_suspend = 1;
+		usbnet_link_suspend(dev);
+	}
+}
+
+/* called by usbnet_stop */
+static void disable_link_runtime_pm(struct usbnet *dev)
+{
+	if (!dev->link_rpm_enabled)
+		return;
+	dev->link_rpm_enabled = 0;
+	end_link_detect(dev, 1);
+	if (dev->link_open_suspend) {
+		usbnet_link_resume(dev);
+		dev->link_open_suspend = 0;
+	}
+	if (!dev->link_remote_wakeup)
+		pm_runtime_set_autosuspend_delay(&dev->udev->dev,
+						 dev->old_autosuspend_delay);
+}
+
+static void update_link_state(struct usbnet *dev)
+{
+	char		*buf = NULL;
+	unsigned	pipe = 0;
+	unsigned	maxp;
+	int		ret, act_len, timeout;
+	struct urb	urb;
+
+	pipe = usb_rcvintpipe(dev->udev,
+			      dev->status->desc.bEndpointAddress
+				& USB_ENDPOINT_NUMBER_MASK);
+	maxp = usb_maxpacket(dev->udev, pipe, 0);
+
+	/*
+	 * Take default timeout as 2 times of period.
+	 * It is observed that asix device can update its link
+	 * state duing one period(128ms). Low level driver can set
+	 * its default update link time in bind() callback.
+	 */
+	if (!dev->link_update_timeout) {
+		timeout = max((int) dev->status->desc.bInterval,
+			(dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
+		timeout = 1 << timeout;
+		if (dev->udev->speed == USB_SPEED_HIGH)
+			timeout /= 8;
+		if (timeout < 128)
+			timeout = 128;
+	} else
+		timeout = dev->link_update_timeout;
+
+	buf = kmalloc(maxp, GFP_KERNEL);
+	if (!buf)
+		return;
+
+	dev_dbg(&dev->intf->dev, "%s: timeout %dms\n", __func__, timeout);
+	ret = usb_interrupt_msg(dev->udev, pipe, buf, maxp,
+			&act_len, timeout);
+	if (!ret) {
+		urb.status = 0;
+		urb.actual_length = act_len;
+		urb.transfer_buffer = buf;
+		urb.transfer_buffer_length = maxp;
+		dev->driver_info->status(dev, &urb);
+		if (dev->driver_info->flags &
+		    FLAG_LINK_UPDATE_BY_DRIVER)
+			wait_for_completion(&dev->link_update_completion);
+		dev_dbg(&dev->intf->dev, "%s: link updated\n", __func__);
+	} else
+		dev_dbg(&dev->intf->dev, "%s: link update failed %d\n",
+				__func__, ret);
+	kfree(buf);
+}
+
+static void link_detect_work(struct work_struct *work)
+{
+	struct usbnet	*dev = container_of(work, struct usbnet,
+					    link_detect_work.work);
+
+	dev_dbg(&dev->intf->dev, "%s: link resume\n", __func__);
+
+	dev->link_checking = 1;
+	usb_autopm_get_interface(dev->intf);
+	update_link_state(dev);
+	dev->link_checking = 0;
+
+	dev_dbg(&dev->intf->dev, "%s: link state %d\n",
+		__func__, netif_carrier_ok(dev->net));
+
+	if (!netif_carrier_ok(dev->net))
+		usb_autopm_put_interface(dev->intf);
+	else
+		usb_submit_urb(dev->interrupt, GFP_NOIO);
+}
+
+static void init_link_rpm(struct usbnet *dev)
+{
+	INIT_DELAYED_WORK(&dev->link_detect_work, link_detect_work);
+	init_completion(&dev->link_update_completion);
+
+	dev->link_remote_wakeup = !!(dev->driver_info->flags &
+				  FLAG_LINK_SUPPORT_REMOTE_WAKEUP);
+	dev->link_state = 1;
+}
+
 int usbnet_stop (struct net_device *net)
 {
 	struct usbnet		*dev = netdev_priv(net);
@@ -719,8 +899,10 @@ int usbnet_stop (struct net_device *net)
 	tasklet_kill (&dev->bh);
 	if (info->manage_power)
 		info->manage_power(dev, 0);
-	else
+	else {
+		disable_link_runtime_pm(dev);
 		usb_autopm_put_interface(dev->intf);
+	}
 
 	return 0;
 }
@@ -795,6 +977,9 @@ int usbnet_open (struct net_device *net)
 		if (retval < 0)
 			goto done_manage_power_error;
 		usb_autopm_put_interface(dev->intf);
+	} else {
+		if (need_link_runtime_pm(dev))
+			enable_link_runtime_pm(dev);
 	}
 	return retval;
 
@@ -1489,6 +1674,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	if (dev->driver_info->flags & FLAG_LINK_INTR)
 		usbnet_link_change(dev, 0, 0);
 
+	init_link_rpm(dev);
+
 	return 0;
 
 out4:
@@ -1538,6 +1725,9 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
 		 * wake the device
 		 */
 		netif_device_attach (dev->net);
+
+		if (PMSG_IS_AUTO(message))
+			start_link_detect(dev);
 	}
 	return 0;
 }
@@ -1552,8 +1742,10 @@ int usbnet_resume (struct usb_interface *intf)
 
 	if (!--dev->suspend_count) {
 		/* resume interrupt URBs */
-		if (dev->interrupt && test_bit(EVENT_DEV_OPEN, &dev->flags))
-			usb_submit_urb(dev->interrupt, GFP_NOIO);
+		if (dev->interrupt && test_bit(EVENT_DEV_OPEN, &dev->flags)) {
+			if (!dev->link_checking)
+				usb_submit_urb(dev->interrupt, GFP_NOIO);
+		}
 
 		spin_lock_irq(&dev->txq.lock);
 		while ((res = usb_get_from_anchor(&dev->deferred))) {
@@ -1586,6 +1778,8 @@ int usbnet_resume (struct usb_interface *intf)
 				netif_tx_wake_all_queues(dev->net);
 			tasklet_schedule (&dev->bh);
 		}
+
+		end_link_detect(dev, 0);
 	}
 	return 0;
 }
@@ -1593,6 +1787,9 @@ EXPORT_SYMBOL_GPL(usbnet_resume);
 
 void usbnet_link_change(struct usbnet *dev, int link, int need_reset)
 {
+	dev_dbg(&dev->intf->dev, "%s: old_link=%d link=%d\n", __func__,
+		dev->link_state, link);
+
 	if (link)
 		netif_carrier_on(dev->net);
 	else
@@ -1600,6 +1797,14 @@ void usbnet_link_change(struct usbnet *dev, int link, int need_reset)
 
 	if (need_reset && link)
 		usbnet_defer_kevent(dev, EVENT_LINK_RESET);
+
+	if (dev->link_rpm_enabled) {
+		if (!link && dev->link_state)
+			usbnet_link_suspend(dev);
+		else if (link && !dev->link_state && dev->link_remote_wakeup)
+			usbnet_link_resume(dev);
+	}
+	dev->link_state = link;
 }
 EXPORT_SYMBOL_GPL(usbnet_link_change);
 
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 1937b74..c96a623 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -68,6 +68,18 @@ struct usbnet {
 #		define EVENT_RX_PAUSED	5
 #		define EVENT_DEV_ASLEEP 6
 #		define EVENT_DEV_OPEN	7
+
+	/* link down triggered runtime PM */
+	struct delayed_work	link_detect_work;
+	struct completion	link_update_completion;
+	int			link_update_timeout;
+	int			old_autosuspend_delay;
+	unsigned int		link_rpm_enabled:1;
+	unsigned int		link_check_started:1;
+	unsigned int		link_checking:1;
+	unsigned int		link_open_suspend:1;
+	unsigned int		link_state:1;
+	unsigned int		link_remote_wakeup:1;
 };
 
 static inline struct usb_driver *driver_of(struct usb_interface *intf)
@@ -106,6 +118,12 @@ struct driver_info {
 #define FLAG_MULTI_PACKET	0x2000
 #define FLAG_RX_ASSEMBLE	0x4000	/* rx packets may span >1 frames */
 
+/* some drivers may not update link state in .status */
+#define FLAG_LINK_UPDATE_BY_DRIVER	0x8000
+
+/* device support remote wakeup by link change */
+#define FLAG_LINK_SUPPORT_REMOTE_WAKEUP	0x10000
+
 	/* init device ... can sleep, or cause probe() failure */
 	int	(*bind)(struct usbnet *, struct usb_interface *);
 
@@ -161,6 +179,7 @@ extern int usbnet_suspend(struct usb_interface *, pm_message_t);
 extern int usbnet_resume(struct usb_interface *);
 extern void usbnet_disconnect(struct usb_interface *);
 extern void usbnet_link_change(struct usbnet *dev, int link, int need_reset);
+extern void usbnet_link_updated(struct usbnet *dev);
 
 /* Drivers that reuse some of the standard USB CDC infrastructure
  * (notably, using multiple interfaces according to the CDC
-- 
1.7.9.5

^ permalink raw reply related

* Re: kernel BUG at kernel/timer.c:748!
From: Yuchung Cheng @ 2012-09-15 18:16 UTC (permalink / raw)
  To: Dave Jones; +Cc: Julian Anastasov, netdev
In-Reply-To: <20120914212958.GA25053@redhat.com>

On Fri, Sep 14, 2012 at 2:29 PM, Dave Jones <davej@redhat.com> wrote:
> On Wed, Sep 05, 2012 at 11:48:29PM +0300, Julian Anastasov wrote:
>
>  > > kernel BUG at kernel/timer.c:748!
>  > > Call Trace:
>  > >  ? lock_sock_nested+0x8d/0xa0
>  > >  sk_reset_timer+0x1c/0x30
>  > >  ? sock_setsockopt+0x8c/0x960
>  > >  inet_csk_reset_keepalive_timer+0x20/0x30
>  > >  tcp_set_keepalive+0x3d/0x50
>  > >  sock_setsockopt+0x923/0x960
>  > >  ? trace_hardirqs_on_caller+0x16/0x1e0
>  > >  ? fget_light+0x24c/0x520
>  > >  sys_setsockopt+0xc6/0xe0
>  > >  system_call_fastpath+0x1a/0x1f
>  >
>  >      Can this help? In case you see ICMPV6_PKT_TOOBIG...
>  >
>  > [PATCH] tcp: fix possible socket refcount problem for ipv6
>
> I just managed to reproduce this bug on rc5 with this patch,
> so it doesn't seem to help.
Could you post some tcpdump traces?

>
>         Dave
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" 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

* Warning! Your mailbox is almost full.
From: Webmail Account Upgrade @ 2012-09-15 17:20 UTC (permalink / raw)


You have exceeded your email limit quota of 450MB. You need to upgrade  
your email limit quota to 2GB within the next 48 hours. Use the below  
web link to upgrade your email account:

click link below:
   http://www.formchamp.com/goform.php?id=38313

Thank you for using our email.
Copyright ©2012 Email Helpdesk Centre.
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox