Netdev List
 help / color / mirror / Atom feed
* RE: [PATCH] net/hyperv: RX packets may keep on increasing although the NIC is down
From: wenqi_ma @ 2012-04-19  0:45 UTC (permalink / raw)
  To: haiyangz, netdev; +Cc: davem, kys
In-Reply-To: <A1F3067C9B68744AA19F6802BAB8FFDC0DD331FB@TK5EX14MBXC221.redmond.corp.microsoft.com>

Thanks for your comments and suggestion, I will resubmit the revised patch later.

Best Regards,
Wenqi Ma

-----Original Message-----
From: Haiyang Zhang [mailto:haiyangz@microsoft.com] 
Sent: Wednesday, April 18, 2012 10:20 PM
To: Wenqi Ma (RD-CN); netdev@vger.kernel.org
Cc: davem@davemloft.net; KY Srinivasan
Subject: RE: [PATCH] net/hyperv: RX packets may keep on increasing although the NIC is down



> -----Original Message-----
> From: Haiyang Zhang
> Sent: Wednesday, April 18, 2012 10:11 AM
> To: 'Wenqi Ma'; netdev@vger.kernel.org
> Cc: davem@davemloft.net; KY Srinivasan
> Subject: RE: [PATCH] net/hyperv: RX packets may keep on increasing
> although the NIC is down
> 
> 
> 
> > -----Original Message-----
> > From: Wenqi Ma [mailto:wenqi_ma@trendmicro.com.cn]
> > Sent: Wednesday, April 18, 2012 10:02 AM
> > To: netdev@vger.kernel.org
> > Cc: davem@davemloft.net; Haiyang Zhang; Wenqi Ma
> > Subject: [PATCH] net/hyperv: RX packets may keep on increasing although
> > the NIC is down
> >
> > Although the network interface is down, the RX packets number which
> > could be observed by ifconfig may keep on increasing.
> >
> > This is because the WORK scheduled in netvsc_set_multicast_list()
> > may be executed after netvsc_close(). That means the rndis filter
> > may be re-enabled by do_set_multicast() even if it was closed by
> > netvsc_close().
> >
> > By canceling possible WORK before close the rndis filter, the issue
> > could be never happened.
> >
> > Signed-off-by: Wenqi Ma <wenqi_ma@trendmicro.com.cn>
> > ---
> >  drivers/net/hyperv/netvsc_drv.c |   32 +++++++++++++-------------------
> >  1 files changed, 13 insertions(+), 19 deletions(-)
> 
> Thanks for patching it. I have some comments --
> The existing "struct set_multicast_work" is no longer in use, so it should be
> removed now.
> You should also add cancel_work into netvsc_change_mtu().

Also the patch subject should say what fixes/changes you made, not the bug behavior.
Recommend something like, "Adding cancellation to set promiscuous mode work".

Thanks,
- Haiyang


TREND MICRO EMAIL NOTICE
The information contained in this email and any attachments is confidential and may be subject to copyright or other intellectual property protection. If you are not the intended recipient, you are not authorized to use or disclose this information, and we request that you notify us by reply mail or telephone and delete the original message from your mail system.

^ permalink raw reply

* [PATCH v2] set fake_rtable's dst to NULL to avoid kernel Oops.
From: Peter Huang(Peng) @ 2012-04-19  0:52 UTC (permalink / raw)
  To: Stephen Hemminger, 'David S. Miller', netdev
  Cc: ctrix+debianbugs, peter.huangpeng, harry.majun, linux-kernel,
	Eric Dumazet, peter.huangpeng

Compared with the patch sent before I added a new flag DST_FAKE_RTABLE 
to dst_entry struct.


Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Peter Huang <peter.huangpeng@huawei.com>
---
  include/linux/netfilter_bridge.h |    8 ++++++++
  include/net/dst.h                |    1 +
  net/bridge/br_forward.c          |    1 +
  net/bridge/br_netfilter.c        |    8 ++------
  4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/linux/netfilter_bridge.h 
b/include/linux/netfilter_bridge.h
index 0ddd161..51745df 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -104,9 +104,17 @@ struct bridge_skb_cb {
         } daddr;
  };

+static inline void br_drop_fake_rtable(struct sk_buff *skb) {
+       struct dst_entry *dst = skb_dst(skb);
+
+       if (dst && (dst->flags & DST_FAKE_RTABLE))
+               skb_dst_drop(skb);
+}
+
  #else
  #define nf_bridge_maybe_copy_header(skb)       (0)
  #define nf_bridge_pad(skb)                     (0)
+#define br_drop_fake_rtable(skb)               (0)
  #endif /* CONFIG_BRIDGE_NETFILTER */

  #endif /* __KERNEL__ */
diff --git a/include/net/dst.h b/include/net/dst.h
index 59c5d18..b094030 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -55,6 +55,7 @@ struct dst_entry {
  #define DST_NOCACHE            0x0010
  #define DST_NOCOUNT            0x0020
  #define DST_NOPEER             0x0040
+#define DST_FAKE_RTABLE                0x0080

         short                   error;
         short                   obsolete;
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 61f6534..a2098e3 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -47,6 +47,7 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
                 kfree_skb(skb);
         } else {
                 skb_push(skb, ETH_HLEN);
+               br_drop_fake_rtable(skb);
                 dev_queue_xmit(skb);
         }

diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index dec4f38..d7f49b6 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -156,7 +156,7 @@ void br_netfilter_rtable_init(struct net_bridge *br)
         rt->dst.dev = br->dev;
         rt->dst.path = &rt->dst;
         dst_init_metrics(&rt->dst, br_dst_default_metrics, true);
-       rt->dst.flags   = DST_NOXFRM | DST_NOPEER;
+       rt->dst.flags   = DST_NOXFRM | DST_NOPEER | DST_FAKE_RTABLE;
         rt->dst.ops = &fake_dst_ops;
  }

@@ -694,11 +694,7 @@ static unsigned int br_nf_local_in(unsigned int 
hook, struct sk_buff *skb,
                                    const struct net_device *out,
                                    int (*okfn)(struct sk_buff *))
  {
-       struct rtable *rt = skb_rtable(skb);
-
-       if (rt && rt == bridge_parent_rtable(in))
-               skb_dst_drop(skb);
-
+       br_drop_fake_rtable(skb);
         return NF_ACCEPT;
  }

^ permalink raw reply related

* [PATCH] net ax25: Reorder ax25_exit to remove races.
From: Eric W. Biederman @ 2012-04-19  2:11 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Ralf Baechle, linux-hams


While reviewing the sysctl code in ax25 I spotted races in ax25_exit
where it is possible to receive notifications and packets after already
freeing up some of the data structures needed to process those
notifications and updates.

Call unregister_netdevice_notifier early so that the rest of the cleanup
code does not need to deal with network devices.  This takes advantage
of my recent enhancement to unregister_netdevice_notifier to send
unregister notifications of all network devices that are current
registered.

Move the unregistration for packet types, socket types and protocol
types before we cleanup any of the ax25 data structures to remove the
possibilities of other races.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 net/ax25/af_ax25.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 0906c19..9d9a6a3 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -2011,16 +2011,17 @@ static void __exit ax25_exit(void)
 	proc_net_remove(&init_net, "ax25_route");
 	proc_net_remove(&init_net, "ax25");
 	proc_net_remove(&init_net, "ax25_calls");
-	ax25_rt_free();
-	ax25_uid_free();
-	ax25_dev_free();
 
-	ax25_unregister_sysctl();
 	unregister_netdevice_notifier(&ax25_dev_notifier);
+	ax25_unregister_sysctl();
 
 	dev_remove_pack(&ax25_packet_type);
 
 	sock_unregister(PF_AX25);
 	proto_unregister(&ax25_proto);
+
+	ax25_rt_free();
+	ax25_uid_free();
+	ax25_dev_free();
 }
 module_exit(ax25_exit);
-- 
1.7.2.5


^ permalink raw reply related

* [PATCH v3] set fake_rtable's dst to NULL to avoid kernel Oops.
From: Peter Huang(Peng) @ 2012-04-19  2:27 UTC (permalink / raw)
  To: 'David S. Miller', netdev, Stephen Hemminger
  Cc: ctrix+debianbugs, Eric Dumazet, harry.majun, linux-kernel,
	peter.huangpeng, peter.huangpeng

When bridge is deleted before tap/vif device's delete, kernel may 
encounter an oops because of NULL reference to fake_rtable's dst.
Set fake_rtable's dst to NULL before sending packets out can solve this 
problem.

v3 enrich commit header

v2 added a new flag DST_FAKE_RTABLE to dst_entry struct.


Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Peter Huang <peter.huangpeng@huawei.com>
---
  include/linux/netfilter_bridge.h |    8 ++++++++
  include/net/dst.h                |    1 +
  net/bridge/br_forward.c          |    1 +
  net/bridge/br_netfilter.c        |    8 ++------
  4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/linux/netfilter_bridge.h 
b/include/linux/netfilter_bridge.h
index 0ddd161..51745df 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -104,9 +104,17 @@ struct bridge_skb_cb {
         } daddr;
  };

+static inline void br_drop_fake_rtable(struct sk_buff *skb) {
+       struct dst_entry *dst = skb_dst(skb);
+
+       if (dst && (dst->flags & DST_FAKE_RTABLE))
+               skb_dst_drop(skb);
+}
+
  #else
  #define nf_bridge_maybe_copy_header(skb)       (0)
  #define nf_bridge_pad(skb)                     (0)
+#define br_drop_fake_rtable(skb)               (0)
  #endif /* CONFIG_BRIDGE_NETFILTER */

  #endif /* __KERNEL__ */
diff --git a/include/net/dst.h b/include/net/dst.h
index 59c5d18..b094030 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -55,6 +55,7 @@ struct dst_entry {
  #define DST_NOCACHE            0x0010
  #define DST_NOCOUNT            0x0020
  #define DST_NOPEER             0x0040
+#define DST_FAKE_RTABLE                0x0080

         short                   error;
         short                   obsolete;
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 61f6534..a2098e3 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -47,6 +47,7 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
                 kfree_skb(skb);
         } else {
                 skb_push(skb, ETH_HLEN);
+               br_drop_fake_rtable(skb);
                 dev_queue_xmit(skb);
         }

diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index dec4f38..d7f49b6 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -156,7 +156,7 @@ void br_netfilter_rtable_init(struct net_bridge *br)
         rt->dst.dev = br->dev;
         rt->dst.path = &rt->dst;
         dst_init_metrics(&rt->dst, br_dst_default_metrics, true);
-       rt->dst.flags   = DST_NOXFRM | DST_NOPEER;
+       rt->dst.flags   = DST_NOXFRM | DST_NOPEER | DST_FAKE_RTABLE;
         rt->dst.ops = &fake_dst_ops;
  }

@@ -694,11 +694,7 @@ static unsigned int br_nf_local_in(unsigned int 
hook, struct sk_buff *skb,
                                    const struct net_device *out,
                                    int (*okfn)(struct sk_buff *))
  {
-       struct rtable *rt = skb_rtable(skb);
-
-       if (rt && rt == bridge_parent_rtable(in))
-               skb_dst_drop(skb);
-
+       br_drop_fake_rtable(skb);
         return NF_ACCEPT;
  }

^ permalink raw reply related

* [PATCH] net/hyperv: Adding cancellation to ensure rndis filter is closed
From: Wenqi Ma @ 2012-04-19 10:39 UTC (permalink / raw)
  To: netdev; +Cc: davem, haiyangz, Wenqi Ma

Although the network interface is down, the RX packets number which
could be observed by ifconfig may keep on increasing.

This is because the WORK scheduled in netvsc_set_multicast_list()
may be executed after netvsc_close(). That means the rndis filter
may be re-enabled by do_set_multicast() even if it was closed by
netvsc_close().

By canceling possible WORK before close the rndis filter, the issue
could be never happened.

Signed-off-by: Wenqi Ma <wenqi_ma@trendmicro.com.cn>
Reviewed-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/net/hyperv/netvsc_drv.c |   38 ++++++++++++++------------------------
 1 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index dd29478..2d59138 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -44,6 +44,7 @@ struct net_device_context {
 	/* point back to our device context */
 	struct hv_device *device_ctx;
 	struct delayed_work dwork;
+	struct work_struct work;
 };
 
 
@@ -51,30 +52,22 @@ static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
 
-struct set_multicast_work {
-	struct work_struct work;
-	struct net_device *net;
-};
-
 static void do_set_multicast(struct work_struct *w)
 {
-	struct set_multicast_work *swk =
-		container_of(w, struct set_multicast_work, work);
-	struct net_device *net = swk->net;
-
-	struct net_device_context *ndevctx = netdev_priv(net);
+	struct net_device_context *ndevctx =
+		container_of(w, struct net_device_context, work);
 	struct netvsc_device *nvdev;
 	struct rndis_device *rdev;
 
 	nvdev = hv_get_drvdata(ndevctx->device_ctx);
-	if (nvdev == NULL)
-		goto out;
+	if (nvdev == NULL || nvdev->ndev == NULL)
+		return;
 
 	rdev = nvdev->extension;
 	if (rdev == NULL)
-		goto out;
+		return;
 
-	if (net->flags & IFF_PROMISC)
+	if (nvdev->ndev->flags & IFF_PROMISC)
 		rndis_filter_set_packet_filter(rdev,
 			NDIS_PACKET_TYPE_PROMISCUOUS);
 	else
@@ -82,21 +75,13 @@ static void do_set_multicast(struct work_struct *w)
 			NDIS_PACKET_TYPE_BROADCAST |
 			NDIS_PACKET_TYPE_ALL_MULTICAST |
 			NDIS_PACKET_TYPE_DIRECTED);
-
-out:
-	kfree(w);
 }
 
 static void netvsc_set_multicast_list(struct net_device *net)
 {
-	struct set_multicast_work *swk =
-		kmalloc(sizeof(struct set_multicast_work), GFP_ATOMIC);
-	if (swk == NULL)
-		return;
+	struct net_device_context *net_device_ctx = netdev_priv(net);
 
-	swk->net = net;
-	INIT_WORK(&swk->work, do_set_multicast);
-	schedule_work(&swk->work);
+	schedule_work(&net_device_ctx->work);
 }
 
 static int netvsc_open(struct net_device *net)
@@ -125,6 +110,8 @@ static int netvsc_close(struct net_device *net)
 
 	netif_tx_disable(net);
 
+	/* Make sure netvsc_set_multicast_list doesn't re-enable filter! */
+	cancel_work_sync(&net_device_ctx->work);
 	ret = rndis_filter_close(device_obj);
 	if (ret != 0)
 		netdev_err(net, "unable to close device (ret %d).\n", ret);
@@ -335,6 +322,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 
 	nvdev->start_remove = true;
 	cancel_delayed_work_sync(&ndevctx->dwork);
+	cancel_work_sync(&ndevctx->work);
 	netif_tx_disable(ndev);
 	rndis_filter_device_remove(hdev);
 
@@ -403,6 +391,7 @@ static int netvsc_probe(struct hv_device *dev,
 	net_device_ctx->device_ctx = dev;
 	hv_set_drvdata(dev, net);
 	INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp);
+	INIT_WORK(&net_device_ctx->work, do_set_multicast);
 
 	net->netdev_ops = &device_ops;
 
@@ -456,6 +445,7 @@ static int netvsc_remove(struct hv_device *dev)
 
 	ndev_ctx = netdev_priv(net);
 	cancel_delayed_work_sync(&ndev_ctx->dwork);
+	cancel_work_sync(&ndev_ctx->work);
 
 	/* Stop outbound asap */
 	netif_tx_disable(net);
-- 
1.7.1

TREND MICRO EMAIL NOTICE
The information contained in this email and any attachments is confidential and may be subject to copyright or other intellectual property protection. If you are not the intended recipient, you are not authorized to use or disclose this information, and we request that you notify us by reply mail or telephone and delete the original message from your mail system.

^ permalink raw reply related

* [PATCH 1/2] workqueue: Catch more locking problems with flush_work()
From: Stephen Boyd @ 2012-04-19  3:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tejun Heo, netdev, Ben Dooks

If a workqueue is flushed but the work item is not scheduled to
run, lockdep checking will be circumvented. For example:

 static DEFINE_MUTEX(mutex);

 static void my_work(struct work_struct *w)
 {
         mutex_lock(&mutex);
         mutex_unlock(&mutex);
 }

 static DECLARE_WORK(work, my_work);

 static int __init start_test_module(void)
 {
         schedule_work(&work);
         return 0;
 }
 module_init(start_test_module);

 static void __exit stop_test_module(void)
 {
         mutex_lock(&mutex);
         flush_work(&work);
         mutex_unlock(&mutex);
 }
 module_exit(stop_test_module);

would only print a warning if the work item was actively running
when flush_work() was called. Otherwise flush_work() returns
early. In this trivial example nothing could go wrong, but if the
work item is schedule via an interrupt we could potentially have a
scenario where the work item is running just at the time flush_work()
is called. This could become a classic AB-BA locking problem.

Add a lockdep hint in flush_work() in the "work not running" case
so that we always catch this potential deadlock scenario.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 kernel/workqueue.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 66ec08d..eb800df 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2513,8 +2513,11 @@ bool flush_work(struct work_struct *work)
 		wait_for_completion(&barr.done);
 		destroy_work_on_stack(&barr.work);
 		return true;
-	} else
+	} else {
+		lock_map_acquire(&work->lockdep_map);
+		lock_map_release(&work->lockdep_map);
 		return false;
+	}
 }
 EXPORT_SYMBOL_GPL(flush_work);
 
-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 2/2] ks8851: Fix mutex deadlock in ks8851_net_stop()
From: Stephen Boyd @ 2012-04-19  3:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: netdev, Tejun Heo, Ben Dooks
In-Reply-To: <1334805958-29119-1-git-send-email-sboyd@codeaurora.org>

There is a potential deadlock scenario when the ks8851 driver
is removed. The interrupt handler schedules a workqueue which
acquires a mutex that ks8851_net_stop() also acquires before
flushing the workqueue. Previously lockdep wouldn't be able
to find this problem but now that it has the support we can
trigger this lockdep warning by rmmoding the driver after
an ifconfig up.

Fix the possible deadlock by disabling the interrupts in 
the chip and then release the lock across the workqueue
flushing. The mutex is only there to proect the registers
anyway so this should be ok.

=======================================================
[ INFO: possible circular locking dependency detected ]
3.0.21-00021-g8b33780-dirty #2911
-------------------------------------------------------
rmmod/125 is trying to acquire lock:
 ((&ks->irq_work)){+.+...}, at: [<c019e0b8>] flush_work+0x0/0xac

but task is already holding lock:
 (&ks->lock){+.+...}, at: [<bf00b850>] ks8851_net_stop+0x64/0x138 [ks8851]

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ks->lock){+.+...}:
       [<c01b89c8>] __lock_acquire+0x940/0x9f8
       [<c01b9058>] lock_acquire+0x10c/0x130
       [<c083dbec>] mutex_lock_nested+0x68/0x3dc
       [<bf00bd48>] ks8851_irq_work+0x24/0x46c [ks8851]
       [<c019c580>] process_one_work+0x2d8/0x518
       [<c019cb98>] worker_thread+0x220/0x3a0
       [<c01a2ad4>] kthread+0x88/0x94
       [<c0107008>] kernel_thread_exit+0x0/0x8

-> #0 ((&ks->irq_work)){+.+...}:
       [<c01b7984>] validate_chain+0x914/0x1018
       [<c01b89c8>] __lock_acquire+0x940/0x9f8
       [<c01b9058>] lock_acquire+0x10c/0x130
       [<c019e104>] flush_work+0x4c/0xac
       [<bf00b858>] ks8851_net_stop+0x6c/0x138 [ks8851]
       [<c06b209c>] __dev_close_many+0x98/0xcc
       [<c06b2174>] dev_close_many+0x68/0xd0
       [<c06b22ec>] rollback_registered_many+0xcc/0x2b8
       [<c06b2554>] rollback_registered+0x28/0x34
       [<c06b25b8>] unregister_netdevice_queue+0x58/0x7c
       [<c06b25f4>] unregister_netdev+0x18/0x20
       [<bf00c1f4>] ks8851_remove+0x64/0xb4 [ks8851]
       [<c049ddf0>] spi_drv_remove+0x18/0x1c
       [<c0468e98>] __device_release_driver+0x7c/0xbc
       [<c0468f64>] driver_detach+0x8c/0xb4
       [<c0467f00>] bus_remove_driver+0xb8/0xe8
       [<c01c1d20>] sys_delete_module+0x1e8/0x27c
       [<c0105ec0>] ret_fast_syscall+0x0/0x3c

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ks->lock);
                               lock((&ks->irq_work));
                               lock(&ks->lock);
  lock((&ks->irq_work));

 *** DEADLOCK ***

4 locks held by rmmod/125:
 #0:  (&__lockdep_no_validate__){+.+.+.}, at: [<c0468f44>] driver_detach+0x6c/0xb4
 #1:  (&__lockdep_no_validate__){+.+.+.}, at: [<c0468f50>] driver_detach+0x78/0xb4
 #2:  (rtnl_mutex){+.+.+.}, at: [<c06b25e8>] unregister_netdev+0xc/0x20
 #3:  (&ks->lock){+.+...}, at: [<bf00b850>] ks8851_net_stop+0x64/0x138 [ks8851]

Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/net/ethernet/micrel/ks8851.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index c722aa60..20f50ec 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -889,16 +889,17 @@ static int ks8851_net_stop(struct net_device *dev)
 	netif_stop_queue(dev);
 
 	mutex_lock(&ks->lock);
+	/* turn off the IRQs and ack any outstanding */
+	ks8851_wrreg16(ks, KS_IER, 0x0000);
+	ks8851_wrreg16(ks, KS_ISR, 0xffff);
+	mutex_unlock(&ks->lock);
 
 	/* stop any outstanding work */
 	flush_work(&ks->irq_work);
 	flush_work(&ks->tx_work);
 	flush_work(&ks->rxctrl_work);
 
-	/* turn off the IRQs and ack any outstanding */
-	ks8851_wrreg16(ks, KS_IER, 0x0000);
-	ks8851_wrreg16(ks, KS_ISR, 0xffff);
-
+	mutex_lock(&ks->lock);
 	/* shutdown RX process */
 	ks8851_wrreg16(ks, KS_RXCR1, 0x0000);
 
@@ -907,6 +908,7 @@ static int ks8851_net_stop(struct net_device *dev)
 
 	/* set powermode to soft power down to save power */
 	ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);
+	mutex_unlock(&ks->lock);
 
 	/* ensure any queued tx buffers are dumped */
 	while (!skb_queue_empty(&ks->txq)) {
@@ -918,7 +920,6 @@ static int ks8851_net_stop(struct net_device *dev)
 		dev_kfree_skb(txb);
 	}
 
-	mutex_unlock(&ks->lock);
 	return 0;
 }
 
-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH] net: fix compile error of leaking kmemleak.h header
From: Shan Wei @ 2012-04-19  4:05 UTC (permalink / raw)
  To: David Miller; +Cc: majianpeng, Eric Dumazet, NetDev, davidshan

From: Shan Wei <davidshan@tencent.com>

net/core/sysctl_net_core.c: In function ‘sysctl_core_init’:
net/core/sysctl_net_core.c:259: error: implicit declaration of function ‘kmemleak_not_leak’

with same error in net/ipv4/route.c

Signed-off-by: Shan Wei <davidshan@tencent.com>
---
 net/core/sysctl_net_core.c |    1 +
 net/ipv4/route.c           |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index cee5991..247c69b 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -14,6 +14,7 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/kmemleak.h>
 
 #include <net/ip.h>
 #include <net/sock.h>
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index bcd4744..a1c115d 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -109,6 +109,7 @@
 #include <net/rtnetlink.h>
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
+#include <linux/kmemleak.h>
 #endif
 #include <net/secure_seq.h>
 
-- 
1.7.1

^ permalink raw reply related

* Re: [PATCH] net: fix compile error of leaking kmemleak.h header
From: Shan Wei @ 2012-04-19  4:08 UTC (permalink / raw)
  To: David Miller; +Cc: majianpeng, Eric Dumazet, NetDev, davidshan
In-Reply-To: <4F8F8F1A.6020000@gmail.com>

Shan Wei said, at 2012/4/19 12:05:

> From: Shan Wei <davidshan@tencent.com>
> 
> net/core/sysctl_net_core.c: In function ‘sysctl_core_init’:
> net/core/sysctl_net_core.c:259: error: implicit declaration of function ‘kmemleak_not_leak’
> 
> with same error in net/ipv4/route.c


This is for net-next.....

^ permalink raw reply

* Re: [PATCH] net: fix compile error of leaking kmemleak.h header
From: David Miller @ 2012-04-19  4:13 UTC (permalink / raw)
  To: shanwei88; +Cc: majianpeng, eric.dumazet, netdev, davidshan
In-Reply-To: <4F8F8F1A.6020000@gmail.com>

From: Shan Wei <shanwei88@gmail.com>
Date: Thu, 19 Apr 2012 12:05:46 +0800

> From: Shan Wei <davidshan@tencent.com>
> 
> net/core/sysctl_net_core.c: In function ‘sysctl_core_init’:
> net/core/sysctl_net_core.c:259: error: implicit declaration of function ‘kmemleak_not_leak’
> 
> with same error in net/ipv4/route.c
> 
> Signed-off-by: Shan Wei <davidshan@tencent.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] net: fix compile error of leaking kmemleak.h header
From: Eric Dumazet @ 2012-04-19  4:22 UTC (permalink / raw)
  To: Shan Wei; +Cc: David Miller, majianpeng, NetDev, davidshan
In-Reply-To: <4F8F8F1A.6020000@gmail.com>

On Thu, 2012-04-19 at 12:05 +0800, Shan Wei wrote:
> From: Shan Wei <davidshan@tencent.com>
> 
> net/core/sysctl_net_core.c: In function ‘sysctl_core_init’:
> net/core/sysctl_net_core.c:259: error: implicit declaration of function ‘kmemleak_not_leak’
> 
> with same error in net/ipv4/route.c
> 
> Signed-off-by: Shan Wei <davidshan@tencent.com>
> ---
>  net/core/sysctl_net_core.c |    1 +
>  net/ipv4/route.c           |    1 +
>  2 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
> index cee5991..247c69b 100644
> --- a/net/core/sysctl_net_core.c
> +++ b/net/core/sysctl_net_core.c
> @@ -14,6 +14,7 @@
>  #include <linux/vmalloc.h>
>  #include <linux/init.h>
>  #include <linux/slab.h>
> +#include <linux/kmemleak.h>
>  
>  #include <net/ip.h>
>  #include <net/sock.h>
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index bcd4744..a1c115d 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -109,6 +109,7 @@
>  #include <net/rtnetlink.h>
>  #ifdef CONFIG_SYSCTL
>  #include <linux/sysctl.h>
> +#include <linux/kmemleak.h>
>  #endif
>  #include <net/secure_seq.h>
>  

yep, SLAB doesnt include it like SLUB

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

^ permalink raw reply

* net-next iwlwifi breaks compile - was Re: pull request: wireless-next 2012-04-18
From: Oliver Hartkopp @ 2012-04-19  4:49 UTC (permalink / raw)
  To: David Miller, Meenakshi Venkataraman, Wey-Yi Guy
  Cc: linville-2XuSBdqkA4R54TAoqtyWWQ,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20120418.153653.2130740499995307564.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>

On 18.04.2012 21:36, David Miller wrote:

> From: "John W. Linville" <linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
> Date: Wed, 18 Apr 2012 15:05:22 -0400
> 
>> Another batch of wireless updates intended for 3.5...
>>
>> Highlights include some wl12xx refactoring, NFC HCI and SHDLC updates,
>> an ath6kl pull, some mesh updates, and the usual updates to iwlwifi,
>> ath9k, brcm80211, mwifiex, libertas, and other drivers.
>>
>> Please let me know if there are problems!
> 
> Also pulled, thanks a lot.


Commit "iwlwifi: move scan related declarations out of iwl-core.h"

http://git.kernel.org/?p=linux/kernel/git/davem/net-next.git;a=commitdiff;h=8fb96d6e176cbf0a97b2391fa1fa09e608ee86f8

breaks the compile when CONFIG_IWLWIFI_DEBUGFS is not set, see:

  CC [M]  drivers/net/wireless/iwlwifi/iwl-agn-tt.o
In file included from drivers/net/wireless/iwlwifi/iwl-agn-tt.c:40:0:
drivers/net/wireless/iwlwifi/iwl-core.h:97:19: error: static declaration of 'iwl_alloc_traffic_mem' follows non-static declaration
drivers/net/wireless/iwlwifi/iwl-agn.h:513:5: note: previous declaration of 'iwl_alloc_traffic_mem' was here
make[4]: *** [drivers/net/wireless/iwlwifi/iwl-agn-tt.o] Error 1
make[3]: *** [drivers/net/wireless/iwlwifi] Error 2
make[2]: *** [drivers/net/wireless] Error 2
make[1]: *** [drivers/net] Error 2
make: *** [drivers] Error 2
make: *** Waiting for unfinished jobs....

Please check these kind of source reorganizations with different CONFIG settings too.

Regards,
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [RFC v4] Add TCP encap_rcv hook (repost)
From: Simon Horman @ 2012-04-19  4:53 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA, dev-yBygre7rU0TnMu66kgdUjQ; +Cc: Eric Dumazet

This hook is based on a hook of the same name provided by UDP.  It provides
a way for to receive packets that have a TCP header and treat them in some
alternate way.

It is intended to be used by an implementation of the STT tunneling
protocol within Open vSwtich's datapath. A prototype of such an
implementation has been made.

The STT draft is available at
http://tools.ietf.org/html/draft-davie-stt-01

My prototype STT implementation has been posted to the dev-UOEtcQmXneFl884UGnbwIQ@public.gmane.org
The second version can be found at:
http://www.mail-archive.com/dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org/msg09001.html
It needs to be updated to call tcp_encap_enable()

Cc: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Simon Horman <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>

---
v4
* Make use of static_key,
  a tonic for insanity suggested by Eric Dumazet

v3
* Replace more UDP references with TCP
* Move socket accesses to inside socket lock
  and release lock on return.

v2
* Fix comment to refer to TCP rather than UDP
* Allow skb to continue traversing the stack if
  the encap_rcv callback returns a positive value.
  This is the same behaviour as the UDP hook.
---
 include/linux/tcp.h |    3 +++
 include/net/tcp.h   |    1 +
 net/ipv4/tcp_ipv4.c |   34 +++++++++++++++++++++++++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index b6c62d2..7210b23 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -472,6 +472,9 @@ struct tcp_sock {
 	 * contains related tcp_cookie_transactions fields.
 	 */
 	struct tcp_cookie_values  *cookie_values;
+
+	/* For encapsulation sockets. */
+	int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
 };
 
 static inline struct tcp_sock *tcp_sk(const struct sock *sk)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index d5984e3..35d4070 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1576,5 +1576,6 @@ static inline struct tcp_extend_values *tcp_xv(struct request_values *rvp)
 
 extern void tcp_v4_init(void);
 extern void tcp_init(void);
+extern void tcp_encap_enable(void);
 
 #endif	/* _TCP_H */
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 0cb86ce..907735d 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -62,6 +62,7 @@
 #include <linux/init.h>
 #include <linux/times.h>
 #include <linux/slab.h>
+#include <linux/static_key.h>
 
 #include <net/net_namespace.h>
 #include <net/icmp.h>
@@ -1657,6 +1658,14 @@ csum_err:
 }
 EXPORT_SYMBOL(tcp_v4_do_rcv);
 
+static struct static_key tcp_encap_needed __read_mostly;
+void tcp_encap_enable(void)
+{
+	if (!static_key_enabled(&tcp_encap_needed))
+		static_key_slow_inc(&tcp_encap_needed);
+}
+EXPORT_SYMBOL(tcp_encap_enable);
+
 /*
  *	From tcp_input.c
  */
@@ -1666,6 +1675,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
 	const struct iphdr *iph;
 	const struct tcphdr *th;
 	struct sock *sk;
+	struct tcp_sock *tp;
 	int ret;
 	struct net *net = dev_net(skb->dev);
 
@@ -1726,9 +1736,30 @@ process:
 
 	bh_lock_sock_nested(sk);
 	ret = 0;
+
+	tp = tcp_sk(sk);
+	if (static_key_false(&tcp_encap_needed)) {
+		int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
+		encap_rcv = ACCESS_ONCE(tp->encap_rcv);
+		if (encap_rcv != NULL) {
+			/*
+			 * This is an encapsulation socket so pass the skb to
+			 * the socket's tcp_encap_rcv() hook. Otherwise, just
+			 * fall through and pass this up the TCP socket.
+			 * up->encap_rcv() returns the following value:
+			 * <=0 if skb was successfully passed to the encap
+			 *     handler or was discarded by it.
+			 * >0 if skb should be passed on to TCP.
+			 */
+			if (encap_rcv(sk, skb) <= 0) {
+				ret = 0;
+				goto unlock_sock;
+			}
+		}
+	}
+
 	if (!sock_owned_by_user(sk)) {
 #ifdef CONFIG_NET_DMA
-		struct tcp_sock *tp = tcp_sk(sk);
 		if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
 			tp->ucopy.dma_chan = net_dma_find_channel();
 		if (tp->ucopy.dma_chan)
@@ -1744,6 +1775,7 @@ process:
 		NET_INC_STATS_BH(net, LINUX_MIB_TCPBACKLOGDROP);
 		goto discard_and_relse;
 	}
+unlock_sock:
 	bh_unlock_sock(sk);
 
 	sock_put(sk);
-- 
1.7.9.5

^ permalink raw reply related

* linux-next: manual merge of the vhost tree with the net-next tree
From: Stephen Rothwell @ 2012-04-19  5:35 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-next, linux-kernel, Jason Wang, David Miller, netdev

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

Hi Michael,

Today's linux-next merge of the vhost tree got a conflict in
drivers/net/virtio_net.c between commit 586d17c5a01b ("virtio-net: send
gratuitous packets when needed") from the net-next tree and commit
66fdfb7bc203 ("virtio-net: remove useless disable on freeze") from the
vhost tree.

Just context changes.  I fixed it up (I think - see below) and can carry
the fix as necessary.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc drivers/net/virtio_net.c
index fa58c78,3e4767f..0000000
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@@ -1224,16 -1183,6 +1224,11 @@@ static int virtnet_freeze(struct virtio
  {
  	struct virtnet_info *vi = vdev->priv;
  
 +	/* Prevent config work handler from accessing the device */
 +	mutex_lock(&vi->config_lock);
 +	vi->config_enable = false;
 +	mutex_unlock(&vi->config_lock);
 +
- 	virtqueue_disable_cb(vi->rvq);
- 	virtqueue_disable_cb(vi->svq);
- 	if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ))
- 		virtqueue_disable_cb(vi->cvq);
- 
  	netif_device_detach(vi->dev);
  	cancel_delayed_work_sync(&vi->refill);
  

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: linux-next: manual merge of the vhost tree with the net-next tree
From: Michael S. Tsirkin @ 2012-04-19  5:40 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: linux-next, linux-kernel, Jason Wang, David Miller, netdev
In-Reply-To: <20120419153547.c9e4cf4865b28c61668a2be1@canb.auug.org.au>

On Thu, Apr 19, 2012 at 03:35:47PM +1000, Stephen Rothwell wrote:
> Hi Michael,
> 
> Today's linux-next merge of the vhost tree got a conflict in
> drivers/net/virtio_net.c between commit 586d17c5a01b ("virtio-net: send
> gratuitous packets when needed") from the net-next tree and commit
> 66fdfb7bc203 ("virtio-net: remove useless disable on freeze") from the
> vhost tree.
> 
> Just context changes.  I fixed it up (I think - see below) and can carry
> the fix as necessary.

The fix looks right, thanks a lot.

> -- 
> Cheers,
> Stephen Rothwell                    sfr@canb.auug.org.au
> 
> diff --cc drivers/net/virtio_net.c
> index fa58c78,3e4767f..0000000
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@@ -1224,16 -1183,6 +1224,11 @@@ static int virtnet_freeze(struct virtio
>   {
>   	struct virtnet_info *vi = vdev->priv;
>   
>  +	/* Prevent config work handler from accessing the device */
>  +	mutex_lock(&vi->config_lock);
>  +	vi->config_enable = false;
>  +	mutex_unlock(&vi->config_lock);
>  +
> - 	virtqueue_disable_cb(vi->rvq);
> - 	virtqueue_disable_cb(vi->svq);
> - 	if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ))
> - 		virtqueue_disable_cb(vi->cvq);
> - 
>   	netif_device_detach(vi->dev);
>   	cancel_delayed_work_sync(&vi->refill);
>   

^ permalink raw reply

* Re: [PATCH 2/4] batman: don't bother flipping ->tt_crc
From: Antonio Quartulli @ 2012-04-19  5:41 UTC (permalink / raw)
  To: Al Viro
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q
In-Reply-To: <20120418181058.GD6589-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>

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

On Wed, Apr 18, 2012 at 07:10:58 +0100, Al Viro wrote:
> @@ -722,7 +721,7 @@ update_tt:
>  		tt_update_orig(bat_priv, orig_node, tt_buff,
>  			       batman_ogm_packet->tt_num_changes,
>  			       batman_ogm_packet->ttvn,
> -			       batman_ogm_packet->tt_crc);
> +			       ntohs(batman_ogm_packet->tt_crc));

If we don't need to flip tt_crc, wy are you introducing ntohs here? Am I
overlooking something?

> @@ -969,7 +968,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
>  		ethhdr->h_source, if_incoming->net_dev->name,
>  		if_incoming->net_dev->dev_addr, batman_ogm_packet->orig,
>  		batman_ogm_packet->prev_sender, batman_ogm_packet->seqno,
> -		batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc,
> +		batman_ogm_packet->ttvn, ntohs(batman_ogm_packet->tt_crc),
>  		batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,

The same here..I am not understanding..

Thank you for your patches!

Cheers,


-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply

* [net-next 1/4] stmmac: use custom init/exit functions in pm ops
From: Giuseppe CAVALLARO @ 2012-04-19  5:48 UTC (permalink / raw)
  To: netdev; +Cc: Francesco Virlinzi, Giuseppe Cavallaro

From: Francesco Virlinzi <francesco.virlinzi@st.com>

Freeze and restore can call the custom init/exit functions.
Also the patch adds a custom data field that can be used
for storing platform data useful on restore the embedded
setup (e.g. GPIO, SYSCFG).

Signed-off-by: Francesco Virlinzi <francesco.virlinzi@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   17 +++++++++++++----
 include/linux/stmmac.h                             |    1 +
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 12bd221..ba30d38 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -189,9 +189,6 @@ static int stmmac_pltfr_remove(struct platform_device *pdev)
 	if (priv->plat->exit)
 		priv->plat->exit(pdev);
 
-	if (priv->plat->exit)
-		priv->plat->exit(pdev);
-
 	platform_set_drvdata(pdev, NULL);
 
 	iounmap((void *)priv->ioaddr);
@@ -218,14 +215,26 @@ static int stmmac_pltfr_resume(struct device *dev)
 
 int stmmac_pltfr_freeze(struct device *dev)
 {
+	int ret;
+	struct plat_stmmacenet_data *plat_dat = dev_get_platdata(dev);
 	struct net_device *ndev = dev_get_drvdata(dev);
+	struct platform_device *pdev = to_platform_device(dev);
 
-	return stmmac_freeze(ndev);
+	ret = stmmac_freeze(ndev);
+	if (plat_dat->exit)
+		plat_dat->exit(pdev);
+
+	return ret;
 }
 
 int stmmac_pltfr_restore(struct device *dev)
 {
+	struct plat_stmmacenet_data *plat_dat = dev_get_platdata(dev);
 	struct net_device *ndev = dev_get_drvdata(dev);
+	struct platform_device *pdev = to_platform_device(dev);
+
+	if (plat_dat->init)
+		plat_dat->init(pdev);
 
 	return stmmac_restore(ndev);
 }
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index cf64031..f85c93d 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -109,6 +109,7 @@ struct plat_stmmacenet_data {
 	int (*init)(struct platform_device *pdev);
 	void (*exit)(struct platform_device *pdev);
 	void *custom_cfg;
+	void *custom_data;
 	void *bsp_priv;
 };
 #endif
-- 
1.7.4.4

^ permalink raw reply related

* [net-next 2/4 (v2)] stmmac: Move the mdio_register/_unregister in probe/remove
From: Giuseppe CAVALLARO @ 2012-04-19  5:48 UTC (permalink / raw)
  To: netdev; +Cc: Francesco Virlinzi
In-Reply-To: <1334814502-29707-1-git-send-email-peppe.cavallaro@st.com>

From: Francesco Virlinzi <francesco.virlinzi@st.com>

This patch moves the mdio_register/_unregister in probe/remove
functions and this also is required when hibernation on disk
is done.

---

v2: remove useless open_clk_dis label and do a simple tidy-up
in the open function.

Signed-off-by: Francesco Virlinzi <francesco.virlinzi@st,com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st,com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   34 ++++++++++-----------
 1 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a64f0d4..9ecd6cf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -933,24 +933,10 @@ static int stmmac_open(struct net_device *dev)
 	struct stmmac_priv *priv = netdev_priv(dev);
 	int ret;
 
-	stmmac_clk_enable(priv);
-
-	stmmac_check_ether_addr(priv);
-
-	/* MDIO bus Registration */
-	ret = stmmac_mdio_register(dev);
-	if (ret < 0) {
-		pr_debug("%s: MDIO bus (id: %d) registration failed",
-			 __func__, priv->plat->bus_id);
-		goto open_clk_dis;
-	}
-
 #ifdef CONFIG_STMMAC_TIMER
 	priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
-	if (unlikely(priv->tm == NULL)) {
-		ret = -ENOMEM;
-		goto open_clk_dis;
-	}
+	if (unlikely(priv->tm == NULL))
+		return -ENOMEM;
 
 	priv->tm->freq = tmrate;
 
@@ -964,6 +950,10 @@ static int stmmac_open(struct net_device *dev)
 	} else
 		priv->tm->enable = 1;
 #endif
+	stmmac_clk_enable(priv);
+
+	stmmac_check_ether_addr(priv);
+
 	ret = stmmac_init_phy(dev);
 	if (unlikely(ret)) {
 		pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
@@ -1067,8 +1057,8 @@ open_error:
 	if (priv->phydev)
 		phy_disconnect(priv->phydev);
 
-open_clk_dis:
 	stmmac_clk_disable(priv);
+
 	return ret;
 }
 
@@ -1120,7 +1110,6 @@ static int stmmac_release(struct net_device *dev)
 #ifdef CONFIG_STMMAC_DEBUG_FS
 	stmmac_exit_fs();
 #endif
-	stmmac_mdio_unregister(dev);
 	stmmac_clk_disable(priv);
 
 	return 0;
@@ -1932,6 +1921,14 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
 	else
 		priv->clk_csr = priv->plat->clk_csr;
 
+	/* MDIO bus Registration */
+	ret = stmmac_mdio_register(ndev);
+	if (ret < 0) {
+		pr_debug("%s: MDIO bus (id: %d) registration failed",
+			 __func__, priv->plat->bus_id);
+		goto error;
+	}
+
 	return priv;
 
 error:
@@ -1959,6 +1956,7 @@ int stmmac_dvr_remove(struct net_device *ndev)
 	priv->hw->dma->stop_tx(priv->ioaddr);
 
 	stmmac_set_mac(priv->ioaddr, false);
+	stmmac_mdio_unregister(ndev);
 	netif_carrier_off(ndev);
 	unregister_netdev(ndev);
 	free_netdev(ndev);
-- 
1.7.4.4

^ permalink raw reply related

* [net-next 3/4] stmmac: verify the dma_cfg platform fields
From: Giuseppe CAVALLARO @ 2012-04-19  5:48 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro, Viresh Kumar
In-Reply-To: <1334814502-29707-1-git-send-email-peppe.cavallaro@st.com>

Recently the dma parameters that can be passed from the platform
have been moved from the plat_stmmacenet_data to the stmmac_dma_cfg.

In case of this new structure is not well allocated the driver can
fails. This is an example how this field is managed in ST platforms

static struct stmmac_dma_cfg gmac_dma_setting = {
        .pbl = 32,
};

static struct plat_stmmacenet_data stih415_ethernet_platform_data[] = {
	{
		.dma_cfg = &gmac_dma_setting,
		.has_gmac = 1,
[snip]

This patch so verifies that the dma_cfg passed from the platform.
In case of it is NULL there is no reason that the driver has to fail
and some default values can be passed. These are ok for all the
Synopsys chips and could impact on performances, only.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
cc: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/common.h       |    1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |   23 ++++++++++++++++---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c   |    7 ++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |    1 -
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 9e42b5d..f5dedcb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -147,6 +147,7 @@ struct stmmac_extra_stats {
 #define DMA_HW_FEAT_FLEXIPPSEN	0x04000000 /* Flexible PPS Output */
 #define DMA_HW_FEAT_SAVLANINS	0x08000000 /* Source Addr or VLAN Insertion */
 #define DMA_HW_FEAT_ACTPHYIF	0x70000000 /* Active/selected PHY interface */
+#define DEFAULT_DMA_PBL		8
 
 enum rx_frame_status { /* IPC status */
 	good_frame = 0,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 9ecd6cf..efc42e1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -919,6 +919,24 @@ static void stmmac_check_ether_addr(struct stmmac_priv *priv)
 						   priv->dev->dev_addr);
 }
 
+static int stmmac_init_dma_engine(struct stmmac_priv *priv)
+{
+	int pbl = DEFAULT_DMA_PBL, fixed_burst = 0, burst_len = 0;
+
+	/* Some DMA parameters can be passed from the platform;
+	 * in case of these are not passed we keep a default
+	 * (good for all the chips) and init the DMA! */
+	if (priv->plat->dma_cfg) {
+		pbl = priv->plat->dma_cfg->pbl;
+		fixed_burst = priv->plat->dma_cfg->fixed_burst;
+		burst_len = priv->plat->dma_cfg->burst_len;
+	}
+
+	return priv->hw->dma->init(priv->ioaddr, pbl, fixed_burst,
+				   burst_len, priv->dma_tx_phy,
+				   priv->dma_rx_phy);
+}
+
 /**
  *  stmmac_open - open entry point of the driver
  *  @dev : pointer to the device structure.
@@ -967,10 +985,7 @@ static int stmmac_open(struct net_device *dev)
 	init_dma_desc_rings(dev);
 
 	/* DMA initialization and SW reset */
-	ret = priv->hw->dma->init(priv->ioaddr, priv->plat->dma_cfg->pbl,
-				  priv->plat->dma_cfg->fixed_burst,
-				  priv->plat->dma_cfg->burst_len,
-				  priv->dma_tx_phy, priv->dma_rx_phy);
+	ret = stmmac_init_dma_engine(priv);
 	if (ret < 0) {
 		pr_err("%s: DMA initialization failed\n", __func__);
 		goto open_error;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 65e0f98..58fab53 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -28,6 +28,7 @@
 
 struct plat_stmmacenet_data plat_dat;
 struct stmmac_mdio_bus_data mdio_data;
+struct stmmac_dma_cfg dma_cfg;
 
 static void stmmac_default_data(void)
 {
@@ -35,8 +36,6 @@ static void stmmac_default_data(void)
 	plat_dat.bus_id = 1;
 	plat_dat.phy_addr = 0;
 	plat_dat.interface = PHY_INTERFACE_MODE_GMII;
-	plat_dat.dma_cfg->pbl = 32;
-	plat_dat.dma_cfg->burst_len = DMA_AXI_BLEN_256;
 	plat_dat.clk_csr = 2;	/* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
 	plat_dat.has_gmac = 1;
 	plat_dat.force_sf_dma_mode = 1;
@@ -45,6 +44,10 @@ static void stmmac_default_data(void)
 	mdio_data.phy_reset = NULL;
 	mdio_data.phy_mask = 0;
 	plat_dat.mdio_bus_data = &mdio_data;
+
+	dma_cfg.pbl = 32;
+	dma_cfg.burst_len = DMA_AXI_BLEN_256;
+	plat_dat.dma_cfg = &dma_cfg;
 }
 
 /**
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index ba30d38..3dd8f08 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -50,7 +50,6 @@ static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
 	 * once needed on other platforms.
 	 */
 	if (of_device_is_compatible(np, "st,spear600-gmac")) {
-		plat->dma_cfg->pbl = 8;
 		plat->has_gmac = 1;
 		plat->pmt = 1;
 	}
-- 
1.7.4.4

^ permalink raw reply related

* [net-next 4/4] stmmac: do not fail when probe and there is no csr clk defined
From: Giuseppe CAVALLARO @ 2012-04-19  5:48 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro
In-Reply-To: <1334814502-29707-1-git-send-email-peppe.cavallaro@st.com>

On some platforms, for example where we are doing the bring-up,
the csr clock is not passed from the framework and the Ethernet
device driver is failing when it can work w/o any issues and
using the default values. So this patch just warnings the case
of the csr clock cannot be acquired but w/o failing the probe
step. I have just tested it on ST STiH415 SoC (ARM).

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      |   13 +++++++------
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    5 ++++-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 9f2435c..db2de9a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -107,7 +107,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
 #ifdef CONFIG_HAVE_CLK
 static inline int stmmac_clk_enable(struct stmmac_priv *priv)
 {
-	if (priv->stmmac_clk)
+	if (!IS_ERR(priv->stmmac_clk))
 		return clk_enable(priv->stmmac_clk);
 
 	return 0;
@@ -115,17 +115,18 @@ static inline int stmmac_clk_enable(struct stmmac_priv *priv)
 
 static inline void stmmac_clk_disable(struct stmmac_priv *priv)
 {
-	if (priv->stmmac_clk)
-		clk_disable(priv->stmmac_clk);
+	if (IS_ERR(priv->stmmac_clk))
+		return;
+
+	clk_disable(priv->stmmac_clk);
 }
 static inline int stmmac_clk_get(struct stmmac_priv *priv)
 {
 	priv->stmmac_clk = clk_get(priv->device, NULL);
 
-	if (IS_ERR(priv->stmmac_clk)) {
-		pr_err("%s: ERROR clk_get failed\n", __func__);
+	if (IS_ERR(priv->stmmac_clk))
 		return PTR_ERR(priv->stmmac_clk);
-	}
+
 	return 0;
 }
 #else
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index efc42e1..1a4cf81 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -168,6 +168,9 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv)
 #ifdef CONFIG_HAVE_CLK
 	u32 clk_rate;
 
+	if (IS_ERR(priv->stmmac_clk))
+		return;
+
 	clk_rate = clk_get_rate(priv->stmmac_clk);
 
 	/* Platform provided default clk_csr would be assumed valid
@@ -1923,7 +1926,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
 	}
 
 	if (stmmac_clk_get(priv))
-		goto error;
+		pr_warning("%s: warning: cannot get CSR clock\n", __func__);
 
 	/* If a specific clk_csr value is passed from the platform
 	 * this means that the CSR Clock Range selection cannot be
-- 
1.7.4.4

^ permalink raw reply related

* Re: [PATCH 2/4] batman: don't bother flipping ->tt_crc
From: Antonio Quartulli @ 2012-04-19  5:49 UTC (permalink / raw)
  To: Al Viro
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q
In-Reply-To: <20120419054113.GA8658-E/2OGukznS5g9hUCZPvPmw@public.gmane.org>

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

On Thu, Apr 19, 2012 at 07:41:14AM +0200, Antonio Quartulli wrote:
> On Wed, Apr 18, 2012 at 07:10:58 +0100, Al Viro wrote:
> > @@ -722,7 +721,7 @@ update_tt:
> >  		tt_update_orig(bat_priv, orig_node, tt_buff,
> >  			       batman_ogm_packet->tt_num_changes,
> >  			       batman_ogm_packet->ttvn,
> > -			       batman_ogm_packet->tt_crc);
> > +			       ntohs(batman_ogm_packet->tt_crc));
> 
> If we don't need to flip tt_crc, wy are you introducing ntohs here? Am I
> overlooking something?

Ok. I was missing the correct meaning of __be16. Now everything is clear.


Cheers,

-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply

* Re: [PATCH] stmmac: fix kernel crash when device probed for SPEAr with DT
From: Giuseppe CAVALLARO @ 2012-04-19  5:51 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: spear-devel, viresh.linux@gmail.com, netdev@vger.kernel.org,
	davem@davemloft.net, Deepak SIKRI
In-Reply-To: <4F8E4DD3.8030908@st.com>

Hello Viresh.

On 4/18/2012 7:14 AM, Viresh Kumar wrote:
> On 4/18/2012 10:41 AM, Giuseppe CAVALLARO wrote:
>> I hoped it was fully tested on SPEAr platforms. at any rate
> 
> I am only working for SPEAr3xx with DT support and this patch is must as
> without it we have build failures. Haven't tested on any other SPEAr SoCs, they
> may require extra pdata fields to be initialized, but that will follow with
> their DT support.
> 

I've just sent 4 patches so I kindly ask you to review the patch named:
  [net-next 3/4] stmmac: verify the dma_cfg platform fields
where I reworked the logic behind the dma_cfg conf.

Peppe

^ permalink raw reply

* Re: [net-next 3/4] stmmac: verify the dma_cfg platform fields
From: Viresh Kumar @ 2012-04-19  6:05 UTC (permalink / raw)
  To: Giuseppe CAVALLARO; +Cc: netdev@vger.kernel.org, spear-devel
In-Reply-To: <1334814502-29707-3-git-send-email-peppe.cavallaro@st.com>

On 4/19/2012 11:18 AM, Giuseppe CAVALLARO wrote:
> Recently the dma parameters that can be passed from the platform
> have been moved from the plat_stmmacenet_data to the stmmac_dma_cfg.
> 
> In case of this new structure is not well allocated the driver can
> fails. This is an example how this field is managed in ST platforms
> 
> static struct stmmac_dma_cfg gmac_dma_setting = {
>         .pbl = 32,
> };
> 
> static struct plat_stmmacenet_data stih415_ethernet_platform_data[] = {
> 	{
> 		.dma_cfg = &gmac_dma_setting,
> 		.has_gmac = 1,
> [snip]
> 
> This patch so verifies that the dma_cfg passed from the platform.
> In case of it is NULL there is no reason that the driver has to fail
> and some default values can be passed. These are ok for all the
> Synopsys chips and could impact on performances, only.
> 
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> cc: Viresh Kumar <viresh.kumar@st.com>

I really can't review it, as i am not stmmac expert. But, i am sure
the problem i highlighted will be resolved by this patch.

Another thing, as SPEAr is using stmmac, can you always cc spear-devel@list.st.com
for all stmmac patches.

-- 
viresh

^ permalink raw reply

* linux-next: build failure after merge of the final tree (net-next tree related)
From: Stephen Rothwell @ 2012-04-19  6:28 UTC (permalink / raw)
  To: David Miller, netdev; +Cc: linux-next, linux-kernel, majianpeng

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

Hi all,

After merging the final tree, today's linux-next build (sparc64 defconfig)
failed like this:

net/ipv4/route.c: In function 'ip_static_sysctl_init':
net/ipv4/route.c:3517:2: error: implicit declaration of function 'kmemleak_not_leak' [-Werror=implicit-function-declaration]

Caused by commit 7f5938810890 ("net/ipv4:Remove two memleak reports by
kmemleak_not_leak").

net/core/sysctl_net_core.c: In function 'sysctl_core_init':
net/core/sysctl_net_core.c:259:2: error: implicit declaration of function 'kmemleak_not_leak' [-Werror=implicit-function-declaration]

Caused by commit 798ec84d4575 ("net/core:Remove memleak reports by
kmemleak_not_leak").

I added this patch for today:

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Thu, 19 Apr 2012 16:25:16 +1000
Subject: [PATCH] net: using kmemleak_not_leak requires including kmemleak.h

fixes these build errors:

net/ipv4/route.c: In function 'ip_static_sysctl_init':
net/ipv4/route.c:3517:2: error: implicit declaration of function 'kmemleak_not_leak' [-Werror=implicit-function-declaration]
net/core/sysctl_net_core.c: In function 'sysctl_core_init':
net/core/sysctl_net_core.c:259:2: error: implicit declaration of function 'kmemleak_not_leak' [-Werror=implicit-function-declaration]

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 net/core/sysctl_net_core.c |    1 +
 net/ipv4/route.c           |    1 +
 2 files changed, 2 insertions(+)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index cee5991..247c69b 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -14,6 +14,7 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/kmemleak.h>
 
 #include <net/ip.h>
 #include <net/sock.h>
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index bcd4744..dcb4205 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -93,6 +93,7 @@
 #include <linux/times.h>
 #include <linux/slab.h>
 #include <linux/prefetch.h>
+#include <linux/kmemleak.h>
 #include <net/dst.h>
 #include <net/net_namespace.h>
 #include <net/protocol.h>
-- 
1.7.10.rc3

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply related

* Re: [net-next 3/4] stmmac: verify the dma_cfg platform fields
From: Giuseppe CAVALLARO @ 2012-04-19  6:29 UTC (permalink / raw)
  To: Viresh KUMAR; +Cc: netdev@vger.kernel.org, spear-devel
In-Reply-To: <4F8FAB12.2060108@st.com>

On 4/19/2012 8:05 AM, Viresh KUMAR wrote:
> On 4/19/2012 11:18 AM, Giuseppe CAVALLARO wrote:
>> Recently the dma parameters that can be passed from the platform
>> have been moved from the plat_stmmacenet_data to the stmmac_dma_cfg.
>>
>> In case of this new structure is not well allocated the driver can
>> fails. This is an example how this field is managed in ST platforms
>>
>> static struct stmmac_dma_cfg gmac_dma_setting = {
>>         .pbl = 32,
>> };
>>
>> static struct plat_stmmacenet_data stih415_ethernet_platform_data[] = {
>> 	{
>> 		.dma_cfg = &gmac_dma_setting,
>> 		.has_gmac = 1,
>> [snip]
>>
>> This patch so verifies that the dma_cfg passed from the platform.
>> In case of it is NULL there is no reason that the driver has to fail
>> and some default values can be passed. These are ok for all the
>> Synopsys chips and could impact on performances, only.
>>
>> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>> cc: Viresh Kumar <viresh.kumar@st.com>
> 
> I really can't review it, as i am not stmmac expert. But, i am sure
> the problem i highlighted will be resolved by this patch.
> 
> Another thing, as SPEAr is using stmmac, can you always cc spear-devel@list.st.com
> for all stmmac patches.

Yes! I have forgotten to add spear guys ;-)

Thanks for your feedbak

Peppe

> 

^ 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