Netdev List
 help / color / mirror / Atom feed
* [PATCH v4 2/6] PM / Runtime: introduce pm_runtime_set_memalloc_noio()
From: Ming Lei @ 2012-11-03  8:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alan Stern, Oliver Neukum, Minchan Kim, Greg Kroah-Hartman,
	Rafael J. Wysocki, Jens Axboe, David S. Miller, Andrew Morton,
	netdev, linux-usb, linux-pm, linux-mm, Ming Lei
In-Reply-To: <1351931714-11689-1-git-send-email-ming.lei@canonical.com>

The patch introduces the flag of memalloc_noio in 'struct dev_pm_info'
to help PM core to teach mm not allocating memory with GFP_KERNEL
flag for avoiding probable deadlock.

As explained in the comment, any GFP_KERNEL allocation inside
runtime_resume() or runtime_suspend() on any one of device in
the path from one block or network device to the root device
in the device tree may cause deadlock, the introduced
pm_runtime_set_memalloc_noio() sets or clears the flag on
device in the path recursively.

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
v4:
	- rename memalloc_noio_resume as memalloc_noio
	- remove pm_runtime_get_memalloc_noio()
	- add comments on pm_runtime_set_memalloc_noio
v3:
	- introduce pm_runtime_get_memalloc_noio()
	- hold one global lock on pm_runtime_set_memalloc_noio
	- hold device power lock when accessing memalloc_noio_resume
	  flag suggested by Alan Stern
	- implement pm_runtime_set_memalloc_noio without recursion
	  suggested by Alan Stern
v2:
	- introduce pm_runtime_set_memalloc_noio()
---
 drivers/base/power/runtime.c |   57 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/pm.h           |    1 +
 include/linux/pm_runtime.h   |    3 +++
 3 files changed, 61 insertions(+)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 3148b10..d477924 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -124,6 +124,63 @@ unsigned long pm_runtime_autosuspend_expiration(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);
 
+static int dev_memalloc_noio(struct device *dev, void *data)
+{
+	return dev->power.memalloc_noio;
+}
+
+/*
+ * pm_runtime_set_memalloc_noio - Set a device's memalloc_noio flag.
+ * @dev: Device to handle.
+ * @enable: True for setting the flag and False for clearing the flag.
+ *
+ * Set the flag for all devices in the path from the device to the
+ * root device in the device tree if @enable is true, otherwise clear
+ * the flag for devices in the path whose siblings don't set the flag.
+ *
+ * The function should only be called by block device, or network
+ * device driver for solving the deadlock problem during runtime
+ * resume/suspend:
+ * 	if memory allocation with GFP_KERNEL is called inside runtime
+ * 	resume/suspend callback of any one of its ancestors(or the
+ * 	block device itself), the deadlock may be triggered inside the
+ * 	memory allocation since it might not complete until the block
+ * 	device becomes active and the involed page I/O finishes. The
+ * 	situation is pointed out first by Alan Stern. Network device
+ * 	are involved in iSCSI kind of situation.
+ *
+ * The lock of dev_hotplug_mutex is held in the function for handling
+ * hotplug race because pm_runtime_set_memalloc_noio() may be called
+ * in async probe().
+ *
+ * The function should be called between device_add() and device_del()
+ * on the affected device(block/network device).
+ */
+void pm_runtime_set_memalloc_noio(struct device *dev, bool enable)
+{
+	static DEFINE_MUTEX(dev_hotplug_mutex);
+
+	mutex_lock(&dev_hotplug_mutex);
+	for(;;) {
+		/* hold power lock since bitfield is not SMP-safe. */
+		spin_lock_irq(&dev->power.lock);
+		dev->power.memalloc_noio = enable;
+		spin_unlock_irq(&dev->power.lock);
+
+		dev = dev->parent;
+
+		/* only clear the flag for one device if all
+		 * children of the device don't set the flag.
+		 */
+		if (!dev || (!enable &&
+			     device_for_each_child(dev, NULL,
+						   dev_memalloc_noio)))
+			break;
+	}
+	mutex_unlock(&dev_hotplug_mutex);
+}
+EXPORT_SYMBOL_GPL(pm_runtime_set_memalloc_noio);
+
 /**
  * rpm_check_suspend_allowed - Test whether a device may be suspended.
  * @dev: Device to test.
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 03d7bb1..1a8a69d 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -538,6 +538,7 @@ struct dev_pm_info {
 	unsigned int		irq_safe:1;
 	unsigned int		use_autosuspend:1;
 	unsigned int		timer_autosuspends:1;
+	unsigned int		memalloc_noio:1;
 	enum rpm_request	request;
 	enum rpm_status		runtime_status;
 	int			runtime_error;
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index f271860..775e063 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -47,6 +47,7 @@ extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay);
 extern unsigned long pm_runtime_autosuspend_expiration(struct device *dev);
 extern void pm_runtime_update_max_time_suspended(struct device *dev,
 						 s64 delta_ns);
+extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
 
 static inline bool pm_children_suspended(struct device *dev)
 {
@@ -149,6 +150,8 @@ static inline void pm_runtime_set_autosuspend_delay(struct device *dev,
 						int delay) {}
 static inline unsigned long pm_runtime_autosuspend_expiration(
 				struct device *dev) { return 0; }
+static inline void pm_runtime_set_memalloc_noio(struct device *dev,
+						bool enable){}
 
 #endif /* !CONFIG_PM_RUNTIME */
 
-- 
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related

* [PATCH v4 1/6] mm: teach mm by current context info to not do I/O during memory allocation
From: Ming Lei @ 2012-11-03  8:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alan Stern, Oliver Neukum, Minchan Kim, Greg Kroah-Hartman,
	Rafael J. Wysocki, Jens Axboe, David S. Miller, Andrew Morton,
	netdev, linux-usb, linux-pm, linux-mm, Ming Lei, Jiri Kosina,
	Mel Gorman, KAMEZAWA Hiroyuki, Michal Hocko, Ingo Molnar,
	Peter Zijlstra
In-Reply-To: <1351931714-11689-1-git-send-email-ming.lei@canonical.com>

This patch introduces PF_MEMALLOC_NOIO on process flag('flags' field of
'struct task_struct'), so that the flag can be set by one task
to avoid doing I/O inside memory allocation in the task's context.

The patch trys to solve one deadlock problem caused by block device,
and the problem may happen at least in the below situations:

- during block device runtime resume, if memory allocation with
GFP_KERNEL is called inside runtime resume callback of any one
of its ancestors(or the block device itself), the deadlock may be
triggered inside the memory allocation since it might not complete
until the block device becomes active and the involed page I/O finishes.
The situation is pointed out first by Alan Stern. It is not a good
approach to convert all GFP_KERNEL[1] in the path into GFP_NOIO because
several subsystems may be involved(for example, PCI, USB and SCSI may
be involved for usb mass stoarage device, network devices involved too
in the iSCSI case)

- during block device runtime suspend, because runtime resume need
to wait for completion of concurrent runtime suspend.

- during error handling of usb mass storage deivce, USB bus reset
will be put on the device, so there shouldn't have any
memory allocation with GFP_KERNEL during USB bus reset, otherwise
the deadlock similar with above may be triggered. Unfortunately, any
usb device may include one mass storage interface in theory, so it
requires all usb interface drivers to handle the situation. In fact,
most usb drivers don't know how to handle bus reset on the device
and don't provide .pre_set() and .post_reset() callback at all, so
USB core has to unbind and bind driver for these devices. So it
is still not practical to resort to GFP_NOIO for solving the problem.

Also the introduced solution can be used by block subsystem or block
drivers too, for example, set the PF_MEMALLOC_NOIO flag before doing
actual I/O transfer.

It is not a good idea to convert all these GFP_KERNEL in the
affected path into GFP_NOIO because these functions doing that may be
implemented as library and will be called in many other contexts.

In fact, memalloc_noio() can convert some of current static GFP_NOIO
allocation into GFP_KERNEL back in other non-affected contexts, at least
almost all GFP_NOIO in USB subsystem can be converted into GFP_KERNEL
after applying the approach and make allocation with GFP_IO
only happen in runtime resume/bus reset/block I/O transfer contexts
generally.

[1], several GFP_KERNEL allocation examples in runtime resume path

- pci subsystem
acpi_os_allocate
	<-acpi_ut_allocate
		<-ACPI_ALLOCATE_ZEROED
			<-acpi_evaluate_object
				<-__acpi_bus_set_power
					<-acpi_bus_set_power
						<-acpi_pci_set_power_state
							<-platform_pci_set_power_state
								<-pci_platform_power_transition
									<-__pci_complete_power_transition
										<-pci_set_power_state
											<-pci_restore_standard_config
												<-pci_pm_runtime_resume
- usb subsystem
usb_get_status
	<-finish_port_resume
		<-usb_port_resume
			<-generic_resume
				<-usb_resume_device
					<-usb_resume_both
						<-usb_runtime_resume

- some individual usb drivers
usblp, uvc, gspca, most of dvb-usb-v2 media drivers, cpia2, az6007, ....

That is just what I have found.  Unfortunately, this allocation can
only be found by human being now, and there should be many not found
since any function in the resume path(call tree) may allocate memory
with GFP_KERNEL.

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oneukum@suse.de>
Cc: Jiri Kosina <jiri.kosina@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
v4:
	- fix comment
v3:
	- no change
v2:
        - remove changes on 'may_writepage' and 'may_swap' because that
          isn't related with the patchset, and can't introduce I/O in
          allocation path if GFP_IOFS is unset, so handing 'may_swap'
          and may_writepage on GFP_NOIO or GFP_NOFS  should be a
          mm internal thing, and let mm guys deal with that, :-).

          Looks clearing the two may_XXX flag only excludes dirty pages
	  	  and anon pages for relaiming, and the behaviour should be decided
          by GFP FLAG, IMO.

        - unset GFP_IOFS in try_to_free_pages() path since
          alloc_page_buffers()
          and dma_alloc_from_contiguous may drop into the path, as
          pointed by KAMEZAWA Hiroyuki
v1:
        - take Minchan's change to avoid the check in alloc_page hot
          path

        - change the helpers' style into save/restore as suggested by
          Alan Stern
---
 include/linux/sched.h |   10 ++++++++++
 mm/page_alloc.c       |   10 +++++++++-
 mm/vmscan.c           |   12 ++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index fb27acd..283fe86 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1805,6 +1805,7 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *
 #define PF_FROZEN	0x00010000	/* frozen for system suspend */
 #define PF_FSTRANS	0x00020000	/* inside a filesystem transaction */
 #define PF_KSWAPD	0x00040000	/* I am kswapd */
+#define PF_MEMALLOC_NOIO 0x00080000	/* Allocating memory without IO involved */
 #define PF_LESS_THROTTLE 0x00100000	/* Throttle me less: I clean memory */
 #define PF_KTHREAD	0x00200000	/* I am a kernel thread */
 #define PF_RANDOMIZE	0x00400000	/* randomize virtual address space */
@@ -1842,6 +1843,15 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *
 #define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
 #define used_math() tsk_used_math(current)
 
+#define memalloc_noio() (current->flags & PF_MEMALLOC_NOIO)
+#define memalloc_noio_save(flag) do { \
+	(flag) = current->flags & PF_MEMALLOC_NOIO; \
+	current->flags |= PF_MEMALLOC_NOIO; \
+} while (0)
+#define memalloc_noio_restore(flag) do { \
+	current->flags = (current->flags & ~PF_MEMALLOC_NOIO) | flag; \
+} while (0)
+
 /*
  * task->jobctl flags
  */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 45c916b..3c47049 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2634,10 +2634,18 @@ retry_cpuset:
 	page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, nodemask, order,
 			zonelist, high_zoneidx, alloc_flags,
 			preferred_zone, migratetype);
-	if (unlikely(!page))
+	if (unlikely(!page)) {
+		/*
+		 * Runtime PM, block IO and its error handling path
+		 * can deadlock because I/O on the device might not
+		 * complete.
+		 */
+		if (unlikely(memalloc_noio()))
+			gfp_mask &= ~GFP_IOFS;
 		page = __alloc_pages_slowpath(gfp_mask, order,
 				zonelist, high_zoneidx, nodemask,
 				preferred_zone, migratetype);
+	}
 
 	trace_mm_page_alloc(page, order, gfp_mask, migratetype);
 
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 10090c8..035088a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2304,6 +2304,12 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
 		.gfp_mask = sc.gfp_mask,
 	};
 
+	if (unlikely(memalloc_noio())) {
+		gfp_mask &= ~GFP_IOFS;
+		sc.gfp_mask = gfp_mask;
+		shrink.gfp_mask = sc.gfp_mask;
+	}
+
 	throttle_direct_reclaim(gfp_mask, zonelist, nodemask);
 
 	/*
@@ -3304,6 +3310,12 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
 	};
 	unsigned long nr_slab_pages0, nr_slab_pages1;
 
+	if (unlikely(memalloc_noio())) {
+		gfp_mask &= ~GFP_IOFS;
+		sc.gfp_mask = gfp_mask;
+		shrink.gfp_mask = sc.gfp_mask;
+	}
+
 	cond_resched();
 	/*
 	 * We need to be able to allocate from the reserves for RECLAIM_SWAP
-- 
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related

* [PATCH v4 0/6] solve deadlock caused by memory allocation with I/O
From: Ming Lei @ 2012-11-03  8:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alan Stern, Oliver Neukum, Minchan Kim, Greg Kroah-Hartman,
	Rafael J. Wysocki, Jens Axboe, David S. Miller, Andrew Morton,
	netdev, linux-usb, linux-pm, linux-mm

This patchset try to solve one deadlock problem which might be caused
by memory allocation with block I/O during runtime PM and block device
error handling path. Traditionly, the problem is addressed by passing
GFP_NOIO statically to mm, but that is not a effective solution, see
detailed description in patch 1's commit log.

This patch set introduces one process flag and trys to fix the deadlock
problem on block device/network device during runtime PM or usb bus reset.

The 1st one is the change on include/sched.h and mm.

The 2nd patch introduces the flag of memalloc_noio on 'dev_pm_info',
and pm_runtime_set_memalloc_noio(), so that PM Core can teach mm to not
allocate mm with GFP_IOFS during the runtime_resume callback only on
device with the flag set.

The following 2 patches apply the introduced pm_runtime_set_memalloc_noio()
to mark all devices as memalloc_noio_resume in the path from the block or
network device to the root device in device tree.

The last 2 patches are applied again PM and USB subsystem to demonstrate
how to use the introduced mechanism to fix the deadlock problem.

Change logs:
V4:
	- patches from the 2nd to the 6th changed	
	- call pm_runtime_set_memalloc_noio() after device_add() as pointed
	by Alan
	- set PF_MEMALLOC_NOIO during runtime_suspend()

V3:
        - patch 2/6 and 5/6 changed, see their commit log
        - remove RFC from title since several guys have expressed that
        it is a reasonable solution
V2:
        - remove changes on 'may_writepage' and 'may_swap'(1/6)
        - unset GFP_IOFS in try_to_free_pages() path(1/6)
        - introduce pm_runtime_set_memalloc_noio()
        - only apply the meachnism on block/network device and its ancestors
        for runtime resume context
V1:
        - take Minchan's change to avoid the check in alloc_page hot path
        - change the helpers' style into save/restore as suggested by Alan
        - memory allocation with no io in usb bus reset path for all devices
        as suggested by Greg and Oliver

 block/genhd.c                |    9 +++++
 drivers/base/power/runtime.c |   89 +++++++++++++++++++++++++++++++++++++++++-
 drivers/usb/core/hub.c       |   13 ++++++
 include/linux/pm.h           |    1 +
 include/linux/pm_runtime.h   |    3 ++
 include/linux/sched.h        |   10 +++++
 mm/page_alloc.c              |   10 ++++-
 mm/vmscan.c                  |   12 ++++++
 net/core/net-sysfs.c         |    5 +++


Thanks,
--
Ming Lei

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply

* [PATCH net-next 2/2] cpsw: fix leaking IO mappings
From: Richard Cochran @ 2012-11-03  8:25 UTC (permalink / raw)
  To: netdev
  Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
	Vaibhav Hiremath
In-Reply-To: <cover.1351930782.git.richardcochran@gmail.com>

The CPSW driver remaps two different IO regions, but fails to unmap them
both. This patch fixes the issue by calling iounmap in the appropriate
places.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/ti/cpsw.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 6215246..7654a62 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1252,14 +1252,12 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
 		ret = -ENOENT;
 		goto clean_clk_ret;
 	}
-
 	if (!request_mem_region(priv->cpsw_res->start,
 				resource_size(priv->cpsw_res), ndev->name)) {
 		dev_err(priv->dev, "failed request i/o region\n");
 		ret = -ENXIO;
 		goto clean_clk_ret;
 	}
-
 	regs = ioremap(priv->cpsw_res->start, resource_size(priv->cpsw_res));
 	if (!regs) {
 		dev_err(priv->dev, "unable to map i/o region\n");
@@ -1274,16 +1272,14 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
 	if (!priv->cpsw_wr_res) {
 		dev_err(priv->dev, "error getting i/o resource\n");
 		ret = -ENOENT;
-		goto clean_clk_ret;
+		goto clean_iomap_ret;
 	}
-
 	if (!request_mem_region(priv->cpsw_wr_res->start,
 			resource_size(priv->cpsw_wr_res), ndev->name)) {
 		dev_err(priv->dev, "failed request i/o region\n");
 		ret = -ENXIO;
-		goto clean_clk_ret;
+		goto clean_iomap_ret;
 	}
-
 	regs = ioremap(priv->cpsw_wr_res->start,
 				resource_size(priv->cpsw_wr_res));
 	if (!regs) {
@@ -1326,7 +1322,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
 	if (!priv->dma) {
 		dev_err(priv->dev, "error initializing dma\n");
 		ret = -ENOMEM;
-		goto clean_iomap_ret;
+		goto clean_wr_iomap_ret;
 	}
 
 	priv->txch = cpdma_chan_create(priv->dma, tx_chan_num(0),
@@ -1407,11 +1403,13 @@ clean_dma_ret:
 	cpdma_chan_destroy(priv->txch);
 	cpdma_chan_destroy(priv->rxch);
 	cpdma_ctlr_destroy(priv->dma);
-clean_iomap_ret:
-	iounmap(priv->regs);
+clean_wr_iomap_ret:
+	iounmap(priv->wr_regs);
 clean_cpsw_wr_iores_ret:
 	release_mem_region(priv->cpsw_wr_res->start,
 			   resource_size(priv->cpsw_wr_res));
+clean_iomap_ret:
+	iounmap(priv->regs);
 clean_cpsw_iores_ret:
 	release_mem_region(priv->cpsw_res->start,
 			   resource_size(priv->cpsw_res));
@@ -1442,6 +1440,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev)
 	iounmap(priv->regs);
 	release_mem_region(priv->cpsw_res->start,
 			   resource_size(priv->cpsw_res));
+	iounmap(priv->wr_regs);
 	release_mem_region(priv->cpsw_wr_res->start,
 			   resource_size(priv->cpsw_wr_res));
 	pm_runtime_disable(&pdev->dev);
-- 
1.7.2.5

^ permalink raw reply related

* [PATCH net-next 1/2] cpsw: rename register banks to match the reference manual, part 2
From: Richard Cochran @ 2012-11-03  8:25 UTC (permalink / raw)
  To: netdev
  Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
	Vaibhav Hiremath
In-Reply-To: <cover.1351930782.git.richardcochran@gmail.com>

The code mixes up the CPSW_SS and the CPSW_WR register naming. This patch
changes the names to conform to the published Technical Reference Manual
from TI, in order to make working on the code less confusing.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/ti/cpsw.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 023d439..6215246 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -286,7 +286,7 @@ struct cpsw_priv {
 	struct platform_device		*pdev;
 	struct net_device		*ndev;
 	struct resource			*cpsw_res;
-	struct resource			*cpsw_ss_res;
+	struct resource			*cpsw_wr_res;
 	struct napi_struct		napi;
 	struct device			*dev;
 	struct cpsw_platform_data	data;
@@ -1270,25 +1270,25 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
 	priv->host_port_regs = regs + data->host_port_reg_ofs;
 	priv->cpts.reg = regs + data->cpts_reg_ofs;
 
-	priv->cpsw_ss_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (!priv->cpsw_ss_res) {
+	priv->cpsw_wr_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (!priv->cpsw_wr_res) {
 		dev_err(priv->dev, "error getting i/o resource\n");
 		ret = -ENOENT;
 		goto clean_clk_ret;
 	}
 
-	if (!request_mem_region(priv->cpsw_ss_res->start,
-			resource_size(priv->cpsw_ss_res), ndev->name)) {
+	if (!request_mem_region(priv->cpsw_wr_res->start,
+			resource_size(priv->cpsw_wr_res), ndev->name)) {
 		dev_err(priv->dev, "failed request i/o region\n");
 		ret = -ENXIO;
 		goto clean_clk_ret;
 	}
 
-	regs = ioremap(priv->cpsw_ss_res->start,
-				resource_size(priv->cpsw_ss_res));
+	regs = ioremap(priv->cpsw_wr_res->start,
+				resource_size(priv->cpsw_wr_res));
 	if (!regs) {
 		dev_err(priv->dev, "unable to map i/o region\n");
-		goto clean_cpsw_ss_iores_ret;
+		goto clean_cpsw_wr_iores_ret;
 	}
 	priv->wr_regs = regs;
 
@@ -1409,9 +1409,9 @@ clean_dma_ret:
 	cpdma_ctlr_destroy(priv->dma);
 clean_iomap_ret:
 	iounmap(priv->regs);
-clean_cpsw_ss_iores_ret:
-	release_mem_region(priv->cpsw_ss_res->start,
-			   resource_size(priv->cpsw_ss_res));
+clean_cpsw_wr_iores_ret:
+	release_mem_region(priv->cpsw_wr_res->start,
+			   resource_size(priv->cpsw_wr_res));
 clean_cpsw_iores_ret:
 	release_mem_region(priv->cpsw_res->start,
 			   resource_size(priv->cpsw_res));
@@ -1442,8 +1442,8 @@ static int __devexit cpsw_remove(struct platform_device *pdev)
 	iounmap(priv->regs);
 	release_mem_region(priv->cpsw_res->start,
 			   resource_size(priv->cpsw_res));
-	release_mem_region(priv->cpsw_ss_res->start,
-			   resource_size(priv->cpsw_ss_res));
+	release_mem_region(priv->cpsw_wr_res->start,
+			   resource_size(priv->cpsw_wr_res));
 	pm_runtime_disable(&pdev->dev);
 	clk_put(priv->clk);
 	kfree(priv->slaves);
-- 
1.7.2.5

^ permalink raw reply related

* [PATCH net-next 0/2] cpsw: fix resource leak for v3.8
From: Richard Cochran @ 2012-11-03  8:25 UTC (permalink / raw)
  To: netdev
  Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
	Vaibhav Hiremath

While looking at the idea of removing all of the register offsets in
the CPSW's device tree, I noticed that the driver would be leaking IO
mappings. Although this is, strictly speaking, a bug fix, still it can
wait to appear in v3.8, since there is no way to use the driver in
v3.7 (or earlier) anyhow.

Thanks,
Richard


Richard Cochran (2):
  cpsw: rename register banks to match the reference manual, part 2
  cpsw: fix leaking IO mappings

 drivers/net/ethernet/ti/cpsw.c |   39 +++++++++++++++++++--------------------
 1 files changed, 19 insertions(+), 20 deletions(-)

-- 
1.7.2.5

^ permalink raw reply

* Re: [PATCH v2 1/9] net: core: use this_cpu_ptr per-cpu helper
From: Steffen Klassert @ 2012-11-03  8:20 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Shan Wei, David Miller, timo.teras, NetDev, Kernel-Maillist
In-Reply-To: <0000013ac239c004-87f4c3e0-5c6a-4979-817f-0a0c4445a4e9-000000@email.amazonses.com>

On Fri, Nov 02, 2012 at 05:44:55PM +0000, Christoph Lameter wrote:
> On Sat, 3 Nov 2012, Shan Wei wrote:
> > +++ b/net/core/flow.c
> > @@ -327,11 +327,9 @@ static void flow_cache_flush_tasklet(unsigned long data)
> >  static void flow_cache_flush_per_cpu(void *data)
> >  {
> >  	struct flow_flush_info *info = data;
> > -	int cpu;
> >  	struct tasklet_struct *tasklet;
> >
> > -	cpu = smp_processor_id();
> > -	tasklet = &per_cpu_ptr(info->cache->percpu, cpu)->flush_tasklet;
> > +	tasklet = &this_cpu_ptr(info->cache->percpu)->flush_tasklet
> 
> Another case for the use of this_cpu_read

Actually, smp_processor_id() is used if either preemtion is off or
in a thread that is bound to the current cpu. So all code that uses
smp_processor_id() should be able to use __this_cpu_read instead of
this_cpu_read.

In this case, flow_cache_flush_per_cpu() is called via smp_call_function(),
so it is bound on the current cpu.

^ permalink raw reply

* Query regarding pushing a patch series against net-next tree
From: Vipul Pandya @ 2012-11-03  7:48 UTC (permalink / raw)
  To: netdev@vger.kernel.org, David Miller
  Cc: Steve Wise, kumar Sanghvi, Divy Le Ray, Dimitrios Michailidis

Hi David Miller,

We have a important patch series fixing a bug as well as adding a
feature. This patch series is prepared against net-next tree. However to
be able to build it successfully it requires a patch from net tree which
was pushed recently. So, we cannot push this patch series until both the
trees are merged. We would like this patch series to be submitted as
soon as possible to net-next so that it can be accepted by OFED community.

Can you please suggest how should we proceed for submitting this patch
series?

Thanks,
Vipul Pandya

^ permalink raw reply

* Re: [net-next:master 122/152] drivers/ptp/ptp_chardev.c:36 ptp_ioctl() warn: 'sysoff' puts 832 bytes on stack
From: David Miller @ 2012-11-03  5:39 UTC (permalink / raw)
  To: richardcochran; +Cc: yuanhan.liu, changlongx.xie, fengguang.wu, netdev
In-Reply-To: <20121103045339.GA2277@netboy.at.omicron.at>

From: Richard Cochran <richardcochran@gmail.com>
Date: Sat, 3 Nov 2012 05:53:39 +0100

> Isn't it being nicer to the memory allocation code not to repeatedly
> request small chunks?

Don't use performance as an argument against writing this code
correctly.

^ permalink raw reply

* Re: [PATCH v2 9/9] net: batman-adv: use per_cpu_add helper
From: Shan Wei @ 2012-11-03  4:58 UTC (permalink / raw)
  To: Sven Eckelmann
  Cc: NetDev, b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r,
	Kernel-Maillist, siwu-MaAgPAbsBIVS8oHt8HbXEIQuADTiUCJX,
	Christoph Lameter, lindner_marek-LWAfsSFWpa4, David Miller
In-Reply-To: <5905519.yWN2Ke3YlE@bentobox>

Sven Eckelmann said, at 2012/11/3 1:55:
> On Saturday 03 November 2012 00:02:06 Shan Wei wrote:
>> From: Shan Wei <davidshan-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
>>
>> As Christoph Lameter said:
>>> In addition, following usage of per_cpu_ptr can be replaced by
>>> this_cpu_read.
>>>
>>> cpu=get_cpu()
>>> ....
>>> *per_cpu_ptr(p,cpu)
>>> ....
>>> ....
>>> put_cpu()
>>
>> Right.
>>
>> Signed-off-by: Shan Wei <davidshan-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
>> ---
> 
> Is this really supposed to be the commit message?

Maybe it's ok when Linus said this. :-)

Christoph is the maintainer of per-cpu.
So........

PER-CPU MEMORY ALLOCATOR
M:      Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
M:      Christoph Lameter <cl-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
T:      git git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git
S:      Maintained
F:      include/linux/percpu*.h
F:      mm/percpu*.c
F:      arch/*/include/asm/percpu.h

> 
> Kind regards,
> 	Sven
> 

^ permalink raw reply

* Re: [net-next:master 122/152] drivers/ptp/ptp_chardev.c:36 ptp_ioctl() warn: 'sysoff' puts 832 bytes on stack
From: Richard Cochran @ 2012-11-03  4:53 UTC (permalink / raw)
  To: David Miller; +Cc: yuanhan.liu, changlongx.xie, fengguang.wu, netdev
In-Reply-To: <20121102.213928.934210347094361569.davem@davemloft.net>

On Fri, Nov 02, 2012 at 09:39:28PM -0400, David Miller wrote:
> > I am aware that these methods use large stack buffers, but I thought
> > it was okay seeing as they are both under the 1k limit.
> 
> I think you should avoid such a local stack variable here.
> 
> It's not that big of a deal to use kmalloc or whatever so just
> do that and add the necessary kfree cleanups et al.

The usage pattern will be that the user calls these again and
again. For the sysoff it will be at least once every second, and for
the events it could be ASAP in a tight loop.

Isn't it being nicer to the memory allocation code not to repeatedly
request small chunks?

Thanks,
Richard

^ permalink raw reply

* [GIT] Networking
From: David Miller @ 2012-11-03  3:46 UTC (permalink / raw)
  To: torvalds; +Cc: akpm, netdev, linux-kernel


First post-Sandy pull request, here goes:

1) Fix antenna gain handling and initialization of chan->max_reg_power
   in wireless, from Felix Fietkau.

2) Fix nexthop handling in H.232 conntrack helper, from Julian
   Anastasov.

3) Only process 80211 mesh config header in certain kinds of frames,
   from Javier Cardona.

4) 80211 management frame header length needs to be validated, from
   Johannes Berg.

5) Don't access free'd SKBs in ath9k driver, from Felix Fietkay.

6) Test for permanent state correctly in VXLAN driver, from Stephen
   Hemminger.

7) BNX2X bug fixes from Yaniv Rosner and Dmitry Kravkov.

8) Fix off by one errors in bonding, from Nikolay ALeksandrov.

9) Fix divide by zero in TCP-Illinois congestion control.  From
   Jesper Dangaard Brouer.

10) TCP metrics code says "Yo dawg, I heard you like sizeof, so I
    did a sizeof of a sizeof, so you can size your size" Fix from
    Julian Anastasov.

11) Several drivers do mdiobus_free without first doing an
    mdiobus_unregister leading to stray pointer references.
    Fix from Peter Senna Tschudin.

12) Fix OOPS in l2tp_eth_create() error path, it's another danling
    pointer kinda situation.  Fix from Tom Parkin.

13) Hardware driven by the vmxnet driver can't handle larger than 16K
    fragments, so split them up when necessary.  From Eric Dumazet.

14) Handle zero length data length in tcp_send_rcvq() properly.  Fix
    from Pavel Emelyanov.

Please pull, thanks a lot!

The following changes since commit e657e078d3dfa9f96976db7a2b5fd7d7c9f1f1a6:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2012-10-26 15:00:48 -0700)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net master

for you to fetch changes up to c454e6111d1ef4268fe98e87087216e51c2718c3:

  tcp-repair: Handle zero-length data put in rcv queue (2012-11-02 22:01:45 -0400)

----------------------------------------------------------------
Antonio Quartulli (1):
      mac80211: fix SSID copy on IBSS JOIN

David S. Miller (2):
      Merge branch 'master' of git://1984.lsi.us.es/nf
      Merge branch 'for-davem' of git://git.kernel.org/.../linville/wireless

Dmitry Kravkov (2):
      bnx2x: Disable FCoE for 57840 since not yet supported by FW
      bnx2x: fix HW initialization using fw 7.8.x

Eric Dumazet (1):
      vmxnet3: must split too big fragments

Felix Fietkau (3):
      cfg80211: fix antenna gain handling
      cfg80211: fix initialization of chan->max_reg_power
      ath9k: fix stale pointers potentially causing access to free'd skbs

Hein Tibosch (1):
      netfilter: nf_defrag_ipv6: solve section mismatch in nf_conntrack_reasm

Jacob Keller (1):
      ixgbe: PTP get_ts_info missing software support

Javier Cardona (3):
      mac80211: Only process mesh config header on frames that RA_MATCH
      mac80211: Don't drop frames received with mesh ttl == 1
      mac80211: don't inspect Sequence Control field on control frames

Jesper Dangaard Brouer (1):
      net: fix divide by zero in tcp algorithm illinois

Johannes Berg (5):
      mac80211: use blacklist for duplicate IE check
      wireless: drop invalid mesh address extension frames
      mac80211: check management frame header length
      mac80211: verify that skb data is present
      mac80211: make sure data is accessible in EAPOL check

John W. Linville (2):
      Merge branch 'for-john' of git://git.kernel.org/.../jberg/mac80211
      Merge branch 'master' of git://git.kernel.org/.../linville/wireless into for-davem

Julian Anastasov (2):
      netfilter: nf_conntrack: fix rt_gateway checks for H.323 helper
      tcp: Fix double sizeof in new tcp_metrics code

Masanari Iida (1):
      net: sctp: Fix typo in net/sctp

Pavel Emelyanov (1):
      tcp-repair: Handle zero-length data put in rcv queue

Peter Senna Tschudin (2):
      drivers/net/ethernet/nxp/lpc_eth.c: Call mdiobus_unregister before mdiobus_free
      drivers/net/phy/mdio-bitbang.c: Call mdiobus_unregister before mdiobus_free

Stanislaw Gruszka (1):
      rt2800: validate step value for temperature compensation

Sven Eckelmann (1):
      ath9k: Test for TID only in BlockAcks while checking tx status

Tom Parkin (1):
      l2tp: fix oops in l2tp_eth_create() error path

Ulrich Weber (1):
      netfilter: nf_nat: don't check for port change on ICMP tuples

Vipul Pandya (1):
      cxgb4: Fix unable to get UP event from the LLD

Yaniv Rosner (6):
      bnx2x: Fix 57810 1G-KR link against certain switches.
      bnx2x: Fix link down in 57712 following LFA
      bnx2x: Restore global registers back to default.
      bnx2x: Fix potential incorrect link speed provision
      bnx2x: Fix unrecognized SFP+ module after driver is loaded
      bnx2x: Fix no link on 577xx 10G-baseT

nikolay@redhat.com (2):
      bonding: fix off-by-one error
      bonding: fix second off-by-one error

stephen hemminger (1):
      vxlan: don't expire permanent entries

 drivers/net/bonding/bond_sysfs.c                 |   4 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 158 +++++++++++++++++++++++++++++++++++--------------
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |  13 +++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c  |  10 ----
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c |   3 +
 drivers/net/ethernet/nxp/lpc_eth.c               |   1 +
 drivers/net/phy/mdio-bitbang.c                   |   1 +
 drivers/net/vmxnet3/vmxnet3_drv.c                |  65 +++++++++++++-------
 drivers/net/vxlan.c                              |   2 +-
 drivers/net/wireless/ath/ath9k/xmit.c            |  10 +++-
 drivers/net/wireless/rt2x00/rt2800lib.c          |   2 +-
 include/net/cfg80211.h                           |   9 +++
 net/ipv4/netfilter/iptable_nat.c                 |   4 +-
 net/ipv4/tcp_illinois.c                          |   8 ++-
 net/ipv4/tcp_input.c                             |   3 +
 net/ipv4/tcp_metrics.c                           |   2 +-
 net/ipv6/netfilter/ip6table_nat.c                |   4 +-
 net/ipv6/netfilter/nf_conntrack_reasm.c          |   4 +-
 net/l2tp/l2tp_eth.c                              |   1 +
 net/mac80211/ibss.c                              |   2 +-
 net/mac80211/rx.c                                |  74 +++++++++++++++++------
 net/mac80211/util.c                              |  42 ++++++++++---
 net/netfilter/nf_conntrack_h323_main.c           |   3 +-
 net/sctp/socket.c                                |   2 +-
 net/wireless/core.c                              |   3 +-
 net/wireless/reg.c                               |   5 +-
 net/wireless/util.c                              |  14 +++--
 27 files changed, 320 insertions(+), 129 deletions(-)

^ permalink raw reply

* [RFC PATCH v2] iproute2: bridge: add veb/vepa toggle
From: John Fastabend @ 2012-11-03  3:24 UTC (permalink / raw)
  To: bhutchings; +Cc: shemminger, netdev

Test bridge commands to set veb, vepa modes to iproute2.

[root@jf-dev1-dcblab iproute2]# ./bridge/bridge bridge show
eth2: mode VEB bridge_flags: self
eth3: mode VEPA bridge_flags: self
eth10: mode VEB bridge_flags: self
eth12: mode VEB bridge_flags: self

[root@jf-dev1-dcblab iproute2]# ./bridge/bridge bridge state mode veb dev eth3 self
bridge_mode_set eth3: type 19 family 7 mode VEB flags 0002

[root@jf-dev1-dcblab iproute2]# ./bridge/bridge bridge show
eth2: mode VEB bridge_flags: self
eth3: mode VEB bridge_flags: self
eth10: mode VEB bridge_flags: self
eth12: mode VEB bridge_flags: self

Maybe the final patch should separate protocol (STP) configuraiton
from the bridge setup (VEB.VEPA). But this is good for testing in
the meantime.

v2: remove a lot of the crazy cruft in the last patch

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---

 bridge/br_common.h      |    1 
 bridge/bridge.c         |    3 -
 bridge/fdb.c            |  244 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/if_link.h |   16 +++
 4 files changed, 263 insertions(+), 1 deletions(-)

diff --git a/bridge/br_common.h b/bridge/br_common.h
index 718ecb9..3e5dcab 100644
--- a/bridge/br_common.h
+++ b/bridge/br_common.h
@@ -5,6 +5,7 @@ extern int print_fdb(const struct sockaddr_nl *who,
 		     struct nlmsghdr *n, void *arg);
 
 extern int do_fdb(int argc, char **argv);
+extern int do_bridge(int argc, char **argv);
 extern int do_monitor(int argc, char **argv);
 
 extern int preferred_family;
diff --git a/bridge/bridge.c b/bridge/bridge.c
index e2c33b0..b5145c1 100644
--- a/bridge/bridge.c
+++ b/bridge/bridge.c
@@ -27,7 +27,7 @@ static void usage(void)
 {
 	fprintf(stderr,
 "Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
-"where  OBJECT := { fdb |  monitor }\n"
+"where  OBJECT := { fdb |  monitor | bridge }\n"
 "       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails]\n" );
 	exit(-1);
 }
@@ -43,6 +43,7 @@ static const struct cmd {
 	int (*func)(int argc, char **argv);
 } cmds[] = {
 	{ "fdb", 	do_fdb },
+	{ "bridge",	do_bridge },
 	{ "monitor",	do_monitor },
 	{ "help",	do_help },
 	{ 0 }
diff --git a/bridge/fdb.c b/bridge/fdb.c
index 4ca4861..e1c138d 100644
--- a/bridge/fdb.c
+++ b/bridge/fdb.c
@@ -34,6 +34,13 @@ static void usage(void)
 	exit(-1);
 }
 
+static void bridge_usage(void)
+{
+	fprintf(stderr, "Usage: br bridge er mode {veb | vepa} dev DEV\n");
+	fprintf(stderr, "	br bridge {show} [ dev DEV] \n");
+	exit(-1);
+}
+
 static const char *state_n2a(unsigned s)
 {
 	static char buf[32];
@@ -269,3 +276,240 @@ int do_fdb(int argc, char **argv)
 	fprintf(stderr, "Command \"%s\" is unknown, try \"bridge fdb help\".\n", *argv);
 	exit(-1);
 }
+
+int print_bridge(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
+{
+	FILE *fp = arg;
+	struct ifinfomsg *ifm = NLMSG_DATA(n);
+	int len = n->nlmsg_len;
+	struct rtattr * tb[IFLA_MAX+1];
+       
+	len -= NLMSG_LENGTH(sizeof(*ifm));
+	if (len < 0) {
+		fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
+		return -1;
+	}
+
+	if (ifm->ifi_family != AF_BRIDGE) {
+		fprintf(stderr, "hmm: Not PF_BRIDGE is %i\n", ifm->ifi_family);
+	}
+
+	if (filter_index && filter_index != ifm->ifi_index)
+		return 0;
+
+	parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifm), len);
+
+	if (!tb[IFLA_IFNAME]) {
+		fprintf(stderr, "%s: missing ifname using ifi_index %u name %s\n",
+			__func__, ifm->ifi_index,
+			ll_index_to_name(ifm->ifi_index));
+	}
+	if (tb[IFLA_AF_SPEC]) {
+		struct rtattr *bridge[IFLA_BRIDGE_MAX+1];
+		__u16 mode = 0, flags = 0;
+
+		parse_rtattr_nested(bridge, IFLA_BRIDGE_MAX, tb[IFLA_AF_SPEC]);
+		if (bridge[IFLA_BRIDGE_MODE])
+			mode =*(__u16*)RTA_DATA(bridge[IFLA_BRIDGE_MODE]);
+		if (bridge[IFLA_BRIDGE_FLAGS])
+			flags =*(__u16*)RTA_DATA(bridge[IFLA_BRIDGE_FLAGS]);
+
+		fprintf(stderr, "%s: mode %s bridge_flags: %s %s\n",
+			ll_index_to_name(ifm->ifi_index),
+			mode ? "VEPA" : "VEB",
+			flags & BRIDGE_FLAGS_SELF ? "self" : "",
+			flags & BRIDGE_FLAGS_MASTER ? "master" : "");
+	}
+
+	if (tb[IFLA_PROTINFO]) {
+		__u8 state = *(__u8*)RTA_DATA(tb[IFLA_PROTINFO]);
+		char *sstate;
+
+		switch (state) {
+		case 0:
+			sstate = "DISABLED";
+			break;
+		case 1:
+			sstate = "LISTENING";
+			break;
+		case 2:
+			sstate = "LEARNING";
+			break;
+		case 3:
+			sstate = "FORWARDING";
+			break;
+		case 4:
+			sstate = "BLOCKING";
+			break;
+		default:
+			sstate = "UNKNOWN";
+			break;
+		}
+	
+
+		fprintf(stderr, "%s: %s: ifla_protinfo: %s\n",
+			ll_index_to_name(ifm->ifi_index),
+			__func__, sstate);
+	}
+
+	fflush(fp);
+	return 0;
+}
+
+static int bridge_show(int argc, char **argv)
+{
+	char *filter_dev = NULL;
+
+       
+	while (argc > 0) {
+		if (strcmp(*argv, "dev") == 0) {
+			NEXT_ARG();
+			if (filter_dev)
+				duparg("dev", *argv);
+                       
+			filter_dev = *argv;
+		}
+		argc--; argv++;
+	}
+
+	if (filter_dev) {
+		if ((filter_index = if_nametoindex(filter_dev)) == 0) {
+			fprintf(stderr, "Cannot find device \"%s\"\n", filter_dev);
+			return -1;
+		}
+	}
+
+	if (rtnl_wilddump_request(&rth, PF_BRIDGE, RTM_GETLINK) < 0) {
+		perror("Cannot send dump request");
+		exit(1);
+	}
+
+	if (rtnl_dump_filter(&rth, print_bridge, stdout) < 0) {
+		fprintf(stderr, "Dump terminated\n");
+		exit(1);
+	}
+
+	return 0;
+}
+
+static int bridge_state_set(int argc, char **argv)
+{
+	struct {
+		struct nlmsghdr		n;
+		struct ifinfomsg	ifm;
+		char			buf[1024];
+	} req;
+	struct {
+		struct nlmsghdr		hdr;
+		struct nlmsgerr		err;
+		struct nlmsghdr		rhdr;
+		struct ifinfomsg	ifm;
+		char			buf[1024];
+	} reply;
+	char *d = NULL;
+	__u8 state = 0;
+	__u16 mode = -1, flags = 0;
+	
+	memset(&req, 0, sizeof(req));
+	memset(&reply, 0, sizeof(reply));
+
+	req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+	req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_ACK;
+	req.n.nlmsg_type = RTM_SETLINK;
+	req.ifm.ifi_family = PF_BRIDGE;
+
+	while (argc > 0) {
+		if (strcmp(*argv, "dev") == 0) {
+			NEXT_ARG();
+			d = *argv;	
+		} else if (matches(*argv, "state") == 0) {
+			NEXT_ARG();
+			if (matches(*argv, "DISABLED") == 0)
+				state = 0;
+			else if (matches(*argv, "LISTENING") == 0)
+				 state = 1;
+			else if (matches(*argv, "LEARNING") == 0)
+				 state = 2;
+			else if (matches(*argv, "FORWARDING") == 0)
+				 state = 3;
+			else if (matches(*argv, "BLOCKING") == 0)
+				 state = 4;
+			else
+				invarg("Invalid state value\n", *argv);
+
+		} else if (matches(*argv, "mode") == 0) {
+			NEXT_ARG();
+			if (matches(*argv, "veb") == 0)
+				mode = BRIDGE_MODE_VEB;
+			else if (matches(*argv, "vepa") == 0)
+				 mode = BRIDGE_MODE_VEPA;
+			else
+				invarg("Invalid mode value\n", *argv);
+
+		} else if (matches(*argv, "master") == 0) {
+			flags |= BRIDGE_FLAGS_MASTER;
+		} else if (matches(*argv, "self") == 0) {
+			flags |= BRIDGE_FLAGS_SELF;
+		}
+
+		argc--; argv++;
+	}
+
+	if (!d) {
+		fprintf(stderr, "Device required.\n");
+		exit(-1);
+	}
+
+       req.ifm.ifi_index = ll_name_to_index(d);
+       if (req.ifm.ifi_index == 0) {
+               fprintf(stderr, "Cannot find device \"%s\"\n", d);
+               return -1;
+       }
+
+	if (state < 4)
+		addattr8(&req.n, sizeof(req.buf), IFLA_PROTINFO, state);
+       
+	printf("%s %s(%u): type %i family %i state 0x%x ", __func__, d, req.ifm.ifi_index,
+		req.n.nlmsg_type, req.ifm.ifi_family, state);
+
+	if (mode < 3 || flags) {
+		struct rtattr *binfo;
+		int err = 0;
+
+		binfo = addattr_nest(&req.n, sizeof(req), IFLA_AF_SPEC);
+		if (flags)
+			err = addattr16(&req.n, sizeof(req), IFLA_BRIDGE_FLAGS, flags);
+		if (mode < 3)
+			err = addattr16(&req.n, sizeof(req), IFLA_BRIDGE_MODE, mode);
+		if (err < 0)
+			fprintf(stderr, "addattr16 failes\n");
+		addattr_nest_end(&req.n, binfo);
+       
+		printf("mode %s\n", mode == BRIDGE_MODE_VEPA ? "VEPA" : "VEB");
+	}
+
+	printf("%s: %s(%u): rtnl_talk length %u\n", __func__, d, req.ifm.ifi_index, req.n.nlmsg_len);
+	if (rtnl_talk(&rth, &req.n, 0, 0, &reply.hdr) < 0) {
+		printf("\nREPLY: error %i\n", reply.err.error);
+		print_bridge(NULL, &reply.err.msg, stderr);
+		exit(2);
+	}
+
+	return 0;
+}
+
+int do_bridge(int argc, char **argv)
+{
+	ll_init_map(&rth);
+
+	if (argc > 0) {
+		if (matches(*argv, "show") == 0)
+			return bridge_show(argc-1, argv+1);
+		else if (matches(*argv, "state") == 0)
+			return bridge_state_set(argc-1, argv+1);
+		else if (matches(*argv, "help") == 0)
+			bridge_usage();
+	}
+
+	exit(0);
+}
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 012d95a..1a6c2f1 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -142,6 +142,7 @@ enum {
 #define IFLA_PROMISCUITY IFLA_PROMISCUITY
 	IFLA_NUM_TX_QUEUES,
 	IFLA_NUM_RX_QUEUES,
+	IFLA_BRIDGE,
 	__IFLA_MAX
 };
 
@@ -375,6 +376,21 @@ enum {
 #define PORT_UUID_MAX		16
 #define PORT_SELF_VF		-1
 
+/* Bridge Flags */
+#define BRIDGE_FLAGS_MASTER	1	/* Bridge command to/from master */
+#define BRIDGE_FLAGS_SELF	2	/* Bridge command to/from lowerdev */
+
+#define BRIDGE_MODE_VEB		0	/* Default loopback mode */
+#define BRIDGE_MODE_VEPA	1	/* 802.1Qbg defined VEPA mode */
+
+/* Bridge management nested attributes */
+enum {
+	IFLA_BRIDGE_FLAGS,
+	IFLA_BRIDGE_MODE,
+	__IFLA_BRIDGE_MAX,
+};
+#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
+
 enum {
 	PORT_REQUEST_PREASSOCIATE = 0,
 	PORT_REQUEST_PREASSOCIATE_RR,

^ permalink raw reply related

* (unknown), 
From: Mr. Allen Large @ 2012-11-02  0:59 UTC (permalink / raw)





This Email is to bring to your notice that you have been personally
accredited sole beneficiary to Mr. Allen and Violet Large deposited sum of
4,543,728.00 US Dollars PLEASE CONTACT Mr. Allen Large at
(allenand_v0927@hotmail.co.uk) FOR MORE DETAILS. ONLINE CORDINATOR

^ permalink raw reply

* [net-next PATCH] net: fix bridge notify hook to manage flags correctly
From: John Fastabend @ 2012-11-03  2:32 UTC (permalink / raw)
  To: bhutchings, davem; +Cc: netdev

The bridge notify hook rtnl_bridge_notify() was not handling the
case where the master flags was set or with both flags set. First
flags are not being passed correctly and second the logic to parse
them is broken.

This patch passes the original flags value and fixes the
logic.

Reported-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---

 net/core/rtnetlink.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 51dc58f..7eae53b 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2373,13 +2373,19 @@ static int rtnl_bridge_notify(struct net_device *dev, u16 flags)
 		goto errout;
 	}
 
-	if (!flags && master && master->netdev_ops->ndo_bridge_getlink)
+	if ((!flags || (flags & BRIDGE_FLAGS_MASTER)) &&
+	    master && master->netdev_ops->ndo_bridge_getlink) {
 		err = master->netdev_ops->ndo_bridge_getlink(skb, 0, 0, dev);
-	else if (dev->netdev_ops->ndo_bridge_getlink)
-		err = dev->netdev_ops->ndo_bridge_getlink(skb, 0, 0, dev);
+		if (err < 0)
+			goto errout;
+	}
 
-	if (err < 0)
-		goto errout;
+	if ((flags & BRIDGE_FLAGS_SELF) &&
+	    dev->netdev_ops->ndo_bridge_getlink) {
+		err = dev->netdev_ops->ndo_bridge_getlink(skb, 0, 0, dev);
+		if (err < 0)
+			goto errout;
+	}
 
 	rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
 	return 0;
@@ -2398,7 +2404,8 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
 	struct net_device *dev;
 	struct nlattr *br_spec, *attr = NULL;
 	int rem, err = -EOPNOTSUPP;
-	u16 flags = 0;
+	u16 oflags, flags = 0;
+	bool have_flags = false;
 
 	if (nlmsg_len(nlh) < sizeof(*ifm))
 		return -EINVAL;
@@ -2417,12 +2424,15 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (br_spec) {
 		nla_for_each_nested(attr, br_spec, rem) {
 			if (nla_type(attr) == IFLA_BRIDGE_FLAGS) {
+				have_flags = true;
 				flags = nla_get_u16(attr);
 				break;
 			}
 		}
 	}
 
+	oflags = flags;
+
 	if (!flags || (flags & BRIDGE_FLAGS_MASTER)) {
 		if (!dev->master ||
 		    !dev->master->netdev_ops->ndo_bridge_setlink) {
@@ -2447,11 +2457,11 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
 			flags &= ~BRIDGE_FLAGS_SELF;
 	}
 
-	if (attr && nla_type(attr) == IFLA_BRIDGE_FLAGS)
+	if (have_flags)
 		memcpy(nla_data(attr), &flags, sizeof(flags));
 	/* Generate event to notify upper layer of bridge change */
 	if (!err)
-		err = rtnl_bridge_notify(dev, flags);
+		err = rtnl_bridge_notify(dev, oflags);
 out:
 	return err;
 }

^ permalink raw reply related

* Re: [PATCH net] tcp-repair: Handle zero-length data put in rcv queue
From: David Miller @ 2012-11-03  2:02 UTC (permalink / raw)
  To: xemul; +Cc: netdev, gmavrikas
In-Reply-To: <508E9B3D.1050505@parallels.com>

From: Pavel Emelyanov <xemul@parallels.com>
Date: Mon, 29 Oct 2012 19:05:33 +0400

> When sending data into a tcp socket in repair state we should check
> for the amount of data being 0 explicitly. Otherwise we'll have an skb 
> with seq == end_seq in rcv queue, but tcp doesn't expect this to happen
> (in particular a warn_on in tcp_recvmsg shoots).
> 
> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
> Reported-by: Giorgos Mavrikas <gmavrikas@gmail.com>

Applied, thanks.

> From 8f70f4ea4f509a3772ee7eb5d9d5c2571a86652a Mon Sep 17 00:00:00 2001
> From: Pavel Emelyanov <xemul@parallels.com>
> Date: Mon, 29 Oct 2012 18:12:41 +0400
> Subject: [PATCH] fix for repair queue getback
> 
> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>

What is this?

^ permalink raw reply

* Re: [PATCH 10/16] ethernet: Convert dev_printk(KERN_<LEVEL> to dev_<level>(
From: David Miller @ 2012-11-03  2:00 UTC (permalink / raw)
  To: joe; +Cc: divy, netdev, linux-kernel
In-Reply-To: <78c3d489101b08588cb067181171eb070bdac756.1351411047.git.joe@perches.com>

From: Joe Perches <joe@perches.com>
Date: Sun, 28 Oct 2012 01:05:48 -0700

> dev_<level> calls take less code than dev_printk(KERN_<LEVEL>
> and reducing object size is good.
> Coalesce formats for easier grep.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

I forgot the other day so indicate that I applied this to
net-next, thanks.

^ permalink raw reply

* Re: [PATCH] vmxnet3: must split too big fragments
From: David Miller @ 2012-11-03  1:58 UTC (permalink / raw)
  To: eric.dumazet; +Cc: sbhatewara, pv-drivers, netdev, linux-kernel, jongman.heo
In-Reply-To: <1351531849.12280.54.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 29 Oct 2012 18:30:49 +0100

> From: Eric Dumazet <edumazet@google.com>
> 
> vmxnet3 has a 16Kbytes limit per tx descriptor, that happened to work
> as long as we provided PAGE_SIZE fragments.
> 
> Our stack can now build larger fragments, so we need to split them to
> the 16kbytes boundary.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: jongman heo <jongman.heo@samsung.com>
> Tested-by: jongman heo <jongman.heo@samsung.com>
> Cc: Shreyas Bhatewara <sbhatewara@vmware.com>

Applied, thanks everyone.

^ permalink raw reply

* Re: [PATCH 1/1] l2tp: fix oops in l2tp_eth_create() error path
From: David Miller @ 2012-11-03  1:57 UTC (permalink / raw)
  To: tparkin; +Cc: netdev, jchapman
In-Reply-To: <1351590108-21067-1-git-send-email-tparkin@katalix.com>

From: Tom Parkin <tparkin@katalix.com>
Date: Tue, 30 Oct 2012 09:41:48 +0000

> When creating an L2TPv3 Ethernet session, if register_netdev() should fail for
> any reason (for example, automatic naming for "l2tpeth%d" interfaces hits the
> 32k-interface limit), the netdev is freed in the error path.  However, the
> l2tp_eth_sess structure's dev pointer is left uncleared, and this results in
> l2tp_eth_delete() then attempting to unregister the same netdev later in the
> session teardown.  This results in an oops.
> 
> To avoid this, clear the session dev pointer in the error path.
> 
> Signed-off-by: Tom Parkin <tparkin@katalix.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink()
From: David Miller @ 2012-11-03  1:54 UTC (permalink / raw)
  To: john.r.fastabend; +Cc: bhutchings, netdev, shemminger
In-Reply-To: <5094766B.1000407@intel.com>

From: John Fastabend <john.r.fastabend@intel.com>
Date: Fri, 02 Nov 2012 18:42:03 -0700

> On 11/2/2012 3:56 PM, Ben Hutchings wrote:
>> Commit e5a55a898720096f43bc24938f8875c0a1b34cd7 ('net: create generic
>> bridge ops') broke the handling of a non-zero starting index in
>> rtnl_bridge_getlink() (based on the old br_dump_ifinfo()).
>>
>> When the starting index is non-zero, we need to increment the current
>> index for each entry that we are skipping.  Also, we need to check the
>> index before both cases, since we may previously have stopped
>> iteration between getting information about a device from its master
>> and from itself.
>>
>> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
>> ---
> 
> I needed to be testing with more interfaces. Its clearly broke
> with >41 veth devices. This patch fixes it thanks a lot Ben!
> 
> Tested-by: John Fastabend <john.r.fastabend@intel.com>

Applied, thanks everyone.

 

^ permalink raw reply

* Re: [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink()
From: John Fastabend @ 2012-11-03  1:42 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: David Miller, netdev, Stephen Hemminger
In-Reply-To: <1351897012.2703.17.camel@bwh-desktop.uk.solarflarecom.com>

On 11/2/2012 3:56 PM, Ben Hutchings wrote:
> Commit e5a55a898720096f43bc24938f8875c0a1b34cd7 ('net: create generic
> bridge ops') broke the handling of a non-zero starting index in
> rtnl_bridge_getlink() (based on the old br_dump_ifinfo()).
>
> When the starting index is non-zero, we need to increment the current
> index for each entry that we are skipping.  Also, we need to check the
> index before both cases, since we may previously have stopped
> iteration between getting information about a device from its master
> and from itself.
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
> ---

I needed to be testing with more interfaces. Its clearly broke
with >41 veth devices. This patch fixes it thanks a lot Ben!

Tested-by: John Fastabend <john.r.fastabend@intel.com>

^ permalink raw reply

* Re: [PATCH net] cxgb4: Fix unable to get UP event from the LLD
From: David Miller @ 2012-11-03  1:42 UTC (permalink / raw)
  To: vipul; +Cc: netdev, divy, dm, jay
In-Reply-To: <1351512156-11636-1-git-send-email-vipul@chelsio.com>

From: Vipul Pandya <vipul@chelsio.com>
Date: Mon, 29 Oct 2012 17:32:36 +0530

> If T4 configuration file gets loaded from the /lib/firmware/cxgb4/ directory
> then offload capabilities of the cards were getting disabled during
> initialization. Hence ULDs do not get an UP event from the LLD.
> 
> Signed-off-by: Jay Hernandez <jay@chelsio.com>
> Signed-off-by: Vipul Pandya <vipul@chelsio.com>

Applied, thanks.

^ permalink raw reply

* Re: [net-next:master 122/152] drivers/ptp/ptp_chardev.c:36 ptp_ioctl() warn: 'sysoff' puts 832 bytes on stack
From: David Miller @ 2012-11-03  1:39 UTC (permalink / raw)
  To: richardcochran; +Cc: yuanhan.liu, changlongx.xie, fengguang.wu, netdev
In-Reply-To: <20121102085915.GC2486@netboy.at.omicron.at>

From: Richard Cochran <richardcochran@gmail.com>
Date: Fri, 2 Nov 2012 09:59:15 +0100

> On Fri, Nov 02, 2012 at 10:06:31AM +0800, Yuanhan Liu wrote:
>> 
>> Hi Richard,
>> 
>> _just_ FYI and let you aware of it, there are new smatch warnings show up in
>> 
>> tree:   git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
>> head:   b77bc2069d1e437d5a1a71bb5cfcf4556ee40015
>> commit: 215b13dd288c2e1e4461c1530a801f5f83e8cd90 [122/152] ptp: add an ioctl to compare PHC time with system time
>> 
>> + drivers/ptp/ptp_chardev.c:36 ptp_ioctl() warn: 'sysoff' puts 832 bytes on stack
>>   drivers/ptp/ptp_chardev.c:144 ptp_read() warn: 'event' puts 960 bytes on stack
> 
> I am aware that these methods use large stack buffers, but I thought
> it was okay seeing as they are both under the 1k limit.

I think you should avoid such a local stack variable here.

It's not that big of a deal to use kmalloc or whatever so just
do that and add the necessary kfree cleanups et al.

^ permalink raw reply

* Re: [RESEND PATCH net-next] ipv6/multipath: remove flag NLM_F_EXCL after the first nexthop
From: David Miller @ 2012-11-03  1:38 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: shemminger, netdev, joe, bernat, eric.dumazet, yoshfuji
In-Reply-To: <1351846702-4982-1-git-send-email-nicolas.dichtel@6wind.com>

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Fri,  2 Nov 2012 09:58:22 +0100

> fib6_add_rt2node() will reject the nexthop if this flag is set, so
> we perform the check only for the first nexthop.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

It seems a bit hackish, but I don't have any better ideas, so
applied, thanks.

^ permalink raw reply

* Re: [PATCH 2/2] drivers/net/phy/mdio-bitbang.c: Call mdiobus_unregister before mdiobus_free
From: David Miller @ 2012-11-03  1:36 UTC (permalink / raw)
  To: peter.senna; +Cc: srinivas.kandagatla, netdev, linux-kernel, kernel-janitors
In-Reply-To: <1351440721-9121-2-git-send-email-peter.senna@gmail.com>

From: Peter Senna Tschudin <peter.senna@gmail.com>
Date: Sun, 28 Oct 2012 17:12:01 +0100

> Based on commit b27393aecf66199f5ddad37c302d3e0cfadbe6c0
> 
> Calling mdiobus_free without calling mdiobus_unregister causes
> BUG_ON(). This patch fixes the issue.
> 
> The semantic patch that found this issue(http://coccinelle.lip6.fr/):
> // <smpl>
> @@
> expression E;
> @@
>   ... when != mdiobus_unregister(E);
> 
> + mdiobus_unregister(E);
>   mdiobus_free(E);
> // </smpl>
> 
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>

Applied.

^ 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