aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Altaparmakov <anton@tuxera.com>2012-02-27 04:01:22 -0500
committerAnton Altaparmakov <anton@tuxera.com>2012-02-27 04:01:22 -0500
commitf621c5334396fd153cd882ea92466823b7e7b821 (patch)
tree7b829cad44dc0e5003d7cacac3a7a1b128637083
parent0afa1b62e33250d4777c5803a98ae69fbe872061 (diff)
parent500dd2370e77c9551ba298bdeeb91b02d8402199 (diff)
Merge branch 'master' of /Volumes/CaseSensitiveDisk/linux
-rw-r--r--MAINTAINERS7
-rw-r--r--Makefile2
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c29
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c12
-rw-r--r--arch/arm/mach-shmobile/board-kota2.c3
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c95
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c113
-rw-r--r--arch/arm/mach-shmobile/include/mach/sh73a0.h6
-rw-r--r--arch/arm/mach-shmobile/intc-sh73a0.c2
-rw-r--r--arch/arm/mach-shmobile/pfc-r8a7779.c2
-rw-r--r--arch/arm/mach-shmobile/pfc-sh7372.c41
-rw-r--r--arch/arm/mach-shmobile/smp-sh73a0.c2
-rw-r--r--arch/c6x/boot/Makefile2
-rw-r--r--arch/sh/boards/board-sh7757lcr.c20
-rw-r--r--arch/sh/boards/mach-ap325rxa/setup.c1
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c2
-rw-r--r--arch/sh/boards/mach-kfr2r09/setup.c1
-rw-r--r--arch/sh/boards/mach-migor/setup.c2
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c1
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.c2
-rw-r--r--arch/sh/include/asm/device.h8
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7724.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7757.c22
-rw-r--r--arch/sh/kernel/smp.c2
-rw-r--r--arch/sh/kernel/topology.c2
-rw-r--r--arch/sh/mm/cache-sh2a.c2
-rw-r--r--arch/x86/xen/enlighten.c6
-rw-r--r--arch/x86/xen/mmu.c8
-rw-r--r--drivers/atm/solos-pci.c4
-rw-r--r--drivers/bluetooth/btusb.c4
-rw-r--r--drivers/hwmon/ads1015.c3
-rw-r--r--drivers/hwmon/f75375s.c7
-rw-r--r--drivers/hwmon/max6639.c22
-rw-r--r--drivers/hwmon/pmbus/max34440.c2
-rw-r--r--drivers/media/radio/wl128x/Kconfig4
-rw-r--r--drivers/media/rc/imon.c26
-rw-r--r--drivers/media/video/hdpvr/hdpvr-core.c18
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c46
-rw-r--r--drivers/media/video/hdpvr/hdpvr.h1
-rw-r--r--drivers/media/video/omap3isp/ispccdc.c2
-rw-r--r--drivers/net/can/sja1000/sja1000.c13
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c_main.c4
-rw-r--r--drivers/net/ethernet/broadcom/b44.c2
-rw-r--r--drivers/net/ethernet/broadcom/cnic.c6
-rw-r--r--drivers/net/ethernet/cisco/enic/cq_enet_desc.h2
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_pp.c2
-rw-r--r--drivers/net/ethernet/jme.c10
-rw-r--r--drivers/net/ethernet/jme.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c10
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mr.c12
-rw-r--r--drivers/net/ethernet/micrel/ks8851_mll.c2
-rw-r--r--drivers/net/ethernet/sfc/rx.c4
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c6
-rw-r--r--drivers/net/phy/icplus.c55
-rw-r--r--drivers/net/ppp/ppp_generic.c23
-rw-r--r--drivers/net/usb/cdc_ether.c7
-rw-r--r--drivers/net/usb/hso.c2
-rw-r--r--drivers/net/usb/zaurus.c12
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c2
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c8
-rw-r--r--drivers/scsi/device_handler/scsi_dh_rdac.c25
-rw-r--r--drivers/scsi/ipr.c24
-rw-r--r--drivers/scsi/isci/host.c4
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c13
-rw-r--r--drivers/scsi/qla2xxx/qla_bsg.c50
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h13
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.c15
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c19
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/scsi_pm.c16
-rw-r--r--drivers/scsi/scsi_priv.h1
-rw-r--r--drivers/scsi/scsi_scan.c4
-rw-r--r--drivers/sh/clk/cpg.c2
-rw-r--r--drivers/video/pvr2fb.c2
-rw-r--r--fs/autofs4/autofs_i.h1
-rw-r--r--fs/autofs4/dev-ioctl.c1
-rw-r--r--fs/autofs4/inode.c2
-rw-r--r--fs/autofs4/waitq.c22
-rw-r--r--fs/btrfs/backref.c2
-rw-r--r--fs/btrfs/check-integrity.c2
-rw-r--r--fs/btrfs/compression.c2
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/disk-io.c12
-rw-r--r--fs/btrfs/extent-tree.c51
-rw-r--r--fs/btrfs/extent_io.c113
-rw-r--r--fs/btrfs/extent_io.h1
-rw-r--r--fs/btrfs/extent_map.h4
-rw-r--r--fs/btrfs/file.c29
-rw-r--r--fs/btrfs/free-space-cache.c1
-rw-r--r--fs/btrfs/inode-map.c6
-rw-r--r--fs/btrfs/inode.c40
-rw-r--r--fs/btrfs/ioctl.c59
-rw-r--r--fs/btrfs/scrub.c8
-rw-r--r--fs/btrfs/transaction.c16
-rw-r--r--fs/btrfs/volumes.c33
-rw-r--r--fs/direct-io.c4
-rw-r--r--fs/eventpoll.c30
-rw-r--r--fs/signalfd.c15
-rw-r--r--include/asm-generic/poll.h2
-rw-r--r--include/linux/compat.h4
-rw-r--r--include/linux/if_link.h1
-rw-r--r--include/linux/netfilter_bridge/ebtables.h4
-rw-r--r--include/linux/rtnetlink.h3
-rw-r--r--include/linux/signalfd.h5
-rw-r--r--include/linux/skbuff.h10
-rw-r--r--include/net/bluetooth/bluetooth.h2
-rw-r--r--include/net/bluetooth/hci_core.h6
-rw-r--r--include/net/bluetooth/l2cap.h12
-rw-r--r--include/net/netfilter/nf_conntrack.h2
-rw-r--r--include/net/rtnetlink.h2
-rw-r--r--kernel/fork.c5
-rw-r--r--mm/memcontrol.c5
-rw-r--r--mm/nommu.c9
-rw-r--r--net/atm/clip.c10
-rw-r--r--net/bluetooth/af_bluetooth.c12
-rw-r--r--net/bluetooth/hci_conn.c4
-rw-r--r--net/bluetooth/hci_core.c3
-rw-r--r--net/bluetooth/l2cap_core.c24
-rw-r--r--net/bluetooth/l2cap_sock.c4
-rw-r--r--net/bluetooth/rfcomm/core.c18
-rw-r--r--net/bluetooth/rfcomm/sock.c2
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/rtnetlink.c78
-rw-r--r--net/ipv4/ip_gre.c10
-rw-r--r--net/ipv4/ping.c1
-rw-r--r--net/ipv4/xfrm4_mode_beet.c5
-rw-r--r--net/ipv4/xfrm4_mode_tunnel.c6
-rw-r--r--net/ipv6/ip6mr.c4
-rw-r--r--net/ipv6/ndisc.c5
-rw-r--r--net/ipv6/xfrm6_mode_beet.c6
-rw-r--r--net/ipv6/xfrm6_mode_tunnel.c6
-rw-r--r--net/mac80211/debugfs_sta.c4
-rw-r--r--net/mac80211/rate.c2
-rw-r--r--net/mac80211/rate.h3
-rw-r--r--net/mac80211/sta_info.h2
-rw-r--r--net/netfilter/ipvs/ip_vs_core.c2
-rw-r--r--net/netfilter/nf_conntrack_core.c38
-rw-r--r--net/netfilter/nf_conntrack_netlink.c46
-rw-r--r--net/netfilter/nf_queue.c40
-rw-r--r--net/netfilter/xt_TEE.c5
-rw-r--r--net/sched/sch_netem.c6
-rwxr-xr-xscripts/coccicheck13
-rwxr-xr-xscripts/depmod.sh6
-rw-r--r--scripts/mod/file2alias.c35
-rw-r--r--scripts/package/builddeb12
154 files changed, 1223 insertions, 660 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 924fb0bb52e0..7fe9bb245bd3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -269,7 +269,6 @@ S: Orphan
269F: drivers/platform/x86/wmi.c 269F: drivers/platform/x86/wmi.c
270 270
271AD1889 ALSA SOUND DRIVER 271AD1889 ALSA SOUND DRIVER
272M: Kyle McMartin <kyle@mcmartin.ca>
273M: Thibaut Varene <T-Bone@parisc-linux.org> 272M: Thibaut Varene <T-Bone@parisc-linux.org>
274W: http://wiki.parisc-linux.org/AD1889 273W: http://wiki.parisc-linux.org/AD1889
275L: linux-parisc@vger.kernel.org 274L: linux-parisc@vger.kernel.org
@@ -3047,7 +3046,6 @@ F: drivers/hwspinlock/hwspinlock_*
3047F: include/linux/hwspinlock.h 3046F: include/linux/hwspinlock.h
3048 3047
3049HARMONY SOUND DRIVER 3048HARMONY SOUND DRIVER
3050M: Kyle McMartin <kyle@mcmartin.ca>
3051L: linux-parisc@vger.kernel.org 3049L: linux-parisc@vger.kernel.org
3052S: Maintained 3050S: Maintained
3053F: sound/parisc/harmony.* 3051F: sound/parisc/harmony.*
@@ -3782,7 +3780,7 @@ F: Documentation/kdump/
3782 3780
3783KERNEL AUTOMOUNTER v4 (AUTOFS4) 3781KERNEL AUTOMOUNTER v4 (AUTOFS4)
3784M: Ian Kent <raven@themaw.net> 3782M: Ian Kent <raven@themaw.net>
3785L: autofs@linux.kernel.org 3783L: autofs@vger.kernel.org
3786S: Maintained 3784S: Maintained
3787F: fs/autofs4/ 3785F: fs/autofs4/
3788 3786
@@ -5000,9 +4998,8 @@ F: Documentation/blockdev/paride.txt
5000F: drivers/block/paride/ 4998F: drivers/block/paride/
5001 4999
5002PARISC ARCHITECTURE 5000PARISC ARCHITECTURE
5003M: Kyle McMartin <kyle@mcmartin.ca>
5004M: Helge Deller <deller@gmx.de>
5005M: "James E.J. Bottomley" <jejb@parisc-linux.org> 5001M: "James E.J. Bottomley" <jejb@parisc-linux.org>
5002M: Helge Deller <deller@gmx.de>
5006L: linux-parisc@vger.kernel.org 5003L: linux-parisc@vger.kernel.org
5007W: http://www.parisc-linux.org/ 5004W: http://www.parisc-linux.org/
5008Q: http://patchwork.kernel.org/project/linux-parisc/list/ 5005Q: http://patchwork.kernel.org/project/linux-parisc/list/
diff --git a/Makefile b/Makefile
index 4ddd641ab615..b61a9638b6fc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 3 2PATCHLEVEL = 3
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc4 4EXTRAVERSION = -rc5
5NAME = Saber-toothed Squirrel 5NAME = Saber-toothed Squirrel
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index eff8a96c75ee..068b754bc348 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -30,6 +30,7 @@
30#include <linux/serial_sci.h> 30#include <linux/serial_sci.h>
31#include <linux/smsc911x.h> 31#include <linux/smsc911x.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/videodev2.h>
33#include <linux/input.h> 34#include <linux/input.h>
34#include <linux/input/sh_keysc.h> 35#include <linux/input/sh_keysc.h>
35#include <linux/mmc/host.h> 36#include <linux/mmc/host.h>
@@ -37,7 +38,6 @@
37#include <linux/mmc/sh_mobile_sdhi.h> 38#include <linux/mmc/sh_mobile_sdhi.h>
38#include <linux/mfd/tmio.h> 39#include <linux/mfd/tmio.h>
39#include <linux/sh_clk.h> 40#include <linux/sh_clk.h>
40#include <linux/dma-mapping.h>
41#include <video/sh_mobile_lcdc.h> 41#include <video/sh_mobile_lcdc.h>
42#include <video/sh_mipi_dsi.h> 42#include <video/sh_mipi_dsi.h>
43#include <sound/sh_fsi.h> 43#include <sound/sh_fsi.h>
@@ -159,19 +159,12 @@ static struct resource sh_mmcif_resources[] = {
159 }, 159 },
160}; 160};
161 161
162static struct sh_mmcif_dma sh_mmcif_dma = {
163 .chan_priv_rx = {
164 .slave_id = SHDMA_SLAVE_MMCIF_RX,
165 },
166 .chan_priv_tx = {
167 .slave_id = SHDMA_SLAVE_MMCIF_TX,
168 },
169};
170static struct sh_mmcif_plat_data sh_mmcif_platdata = { 162static struct sh_mmcif_plat_data sh_mmcif_platdata = {
171 .sup_pclk = 0, 163 .sup_pclk = 0,
172 .ocr = MMC_VDD_165_195, 164 .ocr = MMC_VDD_165_195,
173 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, 165 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
174 .dma = &sh_mmcif_dma, 166 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
167 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
175}; 168};
176 169
177static struct platform_device mmc_device = { 170static struct platform_device mmc_device = {
@@ -321,12 +314,11 @@ static struct resource mipidsi0_resources[] = {
321 }, 314 },
322}; 315};
323 316
324#define DSI0PHYCR 0xe615006c
325static int sh_mipi_set_dot_clock(struct platform_device *pdev, 317static int sh_mipi_set_dot_clock(struct platform_device *pdev,
326 void __iomem *base, 318 void __iomem *base,
327 int enable) 319 int enable)
328{ 320{
329 struct clk *pck; 321 struct clk *pck, *phy;
330 int ret; 322 int ret;
331 323
332 pck = clk_get(&pdev->dev, "dsip_clk"); 324 pck = clk_get(&pdev->dev, "dsip_clk");
@@ -335,18 +327,27 @@ static int sh_mipi_set_dot_clock(struct platform_device *pdev,
335 goto sh_mipi_set_dot_clock_pck_err; 327 goto sh_mipi_set_dot_clock_pck_err;
336 } 328 }
337 329
330 phy = clk_get(&pdev->dev, "dsiphy_clk");
331 if (IS_ERR(phy)) {
332 ret = PTR_ERR(phy);
333 goto sh_mipi_set_dot_clock_phy_err;
334 }
335
338 if (enable) { 336 if (enable) {
339 clk_set_rate(pck, clk_round_rate(pck, 24000000)); 337 clk_set_rate(pck, clk_round_rate(pck, 24000000));
340 __raw_writel(0x2a809010, DSI0PHYCR); 338 clk_set_rate(phy, clk_round_rate(pck, 510000000));
341 clk_enable(pck); 339 clk_enable(pck);
340 clk_enable(phy);
342 } else { 341 } else {
343 clk_disable(pck); 342 clk_disable(pck);
343 clk_disable(phy);
344 } 344 }
345 345
346 ret = 0; 346 ret = 0;
347 347
348 clk_put(phy);
349sh_mipi_set_dot_clock_phy_err:
348 clk_put(pck); 350 clk_put(pck);
349
350sh_mipi_set_dot_clock_pck_err: 351sh_mipi_set_dot_clock_pck_err:
351 return ret; 352 return ret;
352} 353}
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index aab0a349f759..eeb4d9664584 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -295,15 +295,6 @@ static struct resource sh_mmcif_resources[] = {
295 }, 295 },
296}; 296};
297 297
298static struct sh_mmcif_dma sh_mmcif_dma = {
299 .chan_priv_rx = {
300 .slave_id = SHDMA_SLAVE_MMCIF_RX,
301 },
302 .chan_priv_tx = {
303 .slave_id = SHDMA_SLAVE_MMCIF_TX,
304 },
305};
306
307static struct sh_mmcif_plat_data sh_mmcif_plat = { 298static struct sh_mmcif_plat_data sh_mmcif_plat = {
308 .sup_pclk = 0, 299 .sup_pclk = 0,
309 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 300 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
@@ -311,7 +302,8 @@ static struct sh_mmcif_plat_data sh_mmcif_plat = {
311 MMC_CAP_8_BIT_DATA | 302 MMC_CAP_8_BIT_DATA |
312 MMC_CAP_NEEDS_POLL, 303 MMC_CAP_NEEDS_POLL,
313 .get_cd = slot_cn7_get_cd, 304 .get_cd = slot_cn7_get_cd,
314 .dma = &sh_mmcif_dma, 305 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
306 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
315}; 307};
316 308
317static struct platform_device sh_mmcif_device = { 309static struct platform_device sh_mmcif_device = {
diff --git a/arch/arm/mach-shmobile/board-kota2.c b/arch/arm/mach-shmobile/board-kota2.c
index 857ceeec1bb0..c8e7ca23fc06 100644
--- a/arch/arm/mach-shmobile/board-kota2.c
+++ b/arch/arm/mach-shmobile/board-kota2.c
@@ -143,11 +143,10 @@ static struct gpio_keys_button gpio_buttons[] = {
143static struct gpio_keys_platform_data gpio_key_info = { 143static struct gpio_keys_platform_data gpio_key_info = {
144 .buttons = gpio_buttons, 144 .buttons = gpio_buttons,
145 .nbuttons = ARRAY_SIZE(gpio_buttons), 145 .nbuttons = ARRAY_SIZE(gpio_buttons),
146 .poll_interval = 250, /* polled for now */
147}; 146};
148 147
149static struct platform_device gpio_keys_device = { 148static struct platform_device gpio_keys_device = {
150 .name = "gpio-keys-polled", /* polled for now */ 149 .name = "gpio-keys",
151 .id = -1, 150 .id = -1,
152 .dev = { 151 .dev = {
153 .platform_data = &gpio_key_info, 152 .platform_data = &gpio_key_info,
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 9b42fbd10f8e..a2813247b455 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -43,7 +43,6 @@
43#include <linux/smsc911x.h> 43#include <linux/smsc911x.h>
44#include <linux/sh_intc.h> 44#include <linux/sh_intc.h>
45#include <linux/tca6416_keypad.h> 45#include <linux/tca6416_keypad.h>
46#include <linux/usb/r8a66597.h>
47#include <linux/usb/renesas_usbhs.h> 46#include <linux/usb/renesas_usbhs.h>
48#include <linux/dma-mapping.h> 47#include <linux/dma-mapping.h>
49 48
@@ -145,11 +144,6 @@
145 * 1-2 short | VBUS 5V | Host 144 * 1-2 short | VBUS 5V | Host
146 * open | external VBUS | Function 145 * open | external VBUS | Function
147 * 146 *
148 * *1
149 * CN31 is used as
150 * CONFIG_USB_R8A66597_HCD Host
151 * CONFIG_USB_RENESAS_USBHS Function
152 *
153 * CAUTION 147 * CAUTION
154 * 148 *
155 * renesas_usbhs driver can use external interrupt mode 149 * renesas_usbhs driver can use external interrupt mode
@@ -161,15 +155,6 @@
161 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0", 155 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
162 * because Touchscreen is using IRQ7-PORT40. 156 * because Touchscreen is using IRQ7-PORT40.
163 * It is impossible to use IRQ7 demux on this board. 157 * It is impossible to use IRQ7 demux on this board.
164 *
165 * We can use external interrupt mode USB-Function on "USB1".
166 * USB1 can become Host by r8a66597, and become Function by renesas_usbhs.
167 * But don't select both drivers in same time.
168 * These uses same IRQ number for request_irq(), and aren't supporting
169 * IRQF_SHARED / IORESOURCE_IRQ_SHAREABLE.
170 *
171 * Actually these are old/new version of USB driver.
172 * This mean its register will be broken if it supports shared IRQ,
173 */ 158 */
174 159
175/* 160/*
@@ -208,6 +193,16 @@
208 */ 193 */
209 194
210/* 195/*
196 * FSI - AK4642
197 *
198 * it needs amixer settings for playing
199 *
200 * amixer set "Headphone" on
201 * amixer set "HPOUTL Mixer DACH" on
202 * amixer set "HPOUTR Mixer DACH" on
203 */
204
205/*
211 * FIXME !! 206 * FIXME !!
212 * 207 *
213 * gpio_no_direction 208 * gpio_no_direction
@@ -676,51 +671,16 @@ static struct platform_device usbhs0_device = {
676 * Use J30 to select between Host and Function. This setting 671 * Use J30 to select between Host and Function. This setting
677 * can however not be detected by software. Hotplug of USBHS1 672 * can however not be detected by software. Hotplug of USBHS1
678 * is provided via IRQ8. 673 * is provided via IRQ8.
674 *
675 * Current USB1 works as "USB Host".
676 * - set J30 "short"
677 *
678 * If you want to use it as "USB gadget",
679 * - J30 "open"
680 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
681 * - add .get_vbus = usbhs_get_vbus in usbhs1_private
679 */ 682 */
680#define IRQ8 evt2irq(0x0300) 683#define IRQ8 evt2irq(0x0300)
681
682/* USBHS1 USB Host support via r8a66597_hcd */
683static void usb1_host_port_power(int port, int power)
684{
685 if (!power) /* only power-on is supported for now */
686 return;
687
688 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
689 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
690}
691
692static struct r8a66597_platdata usb1_host_data = {
693 .on_chip = 1,
694 .port_power = usb1_host_port_power,
695};
696
697static struct resource usb1_host_resources[] = {
698 [0] = {
699 .name = "USBHS1",
700 .start = 0xe68b0000,
701 .end = 0xe68b00e6 - 1,
702 .flags = IORESOURCE_MEM,
703 },
704 [1] = {
705 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
706 .flags = IORESOURCE_IRQ,
707 },
708};
709
710static struct platform_device usb1_host_device = {
711 .name = "r8a66597_hcd",
712 .id = 1,
713 .dev = {
714 .dma_mask = NULL, /* not use dma */
715 .coherent_dma_mask = 0xffffffff,
716 .platform_data = &usb1_host_data,
717 },
718 .num_resources = ARRAY_SIZE(usb1_host_resources),
719 .resource = usb1_host_resources,
720};
721
722/* USBHS1 USB Function support via renesas_usbhs */
723
724#define USB_PHY_MODE (1 << 4) 684#define USB_PHY_MODE (1 << 4)
725#define USB_PHY_INT_EN ((1 << 3) | (1 << 2)) 685#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
726#define USB_PHY_ON (1 << 1) 686#define USB_PHY_ON (1 << 1)
@@ -776,7 +736,7 @@ static void usbhs1_hardware_exit(struct platform_device *pdev)
776 736
777static int usbhs1_get_id(struct platform_device *pdev) 737static int usbhs1_get_id(struct platform_device *pdev)
778{ 738{
779 return USBHS_GADGET; 739 return USBHS_HOST;
780} 740}
781 741
782static u32 usbhs1_pipe_cfg[] = { 742static u32 usbhs1_pipe_cfg[] = {
@@ -807,7 +767,6 @@ static struct usbhs_private usbhs1_private = {
807 .hardware_exit = usbhs1_hardware_exit, 767 .hardware_exit = usbhs1_hardware_exit,
808 .get_id = usbhs1_get_id, 768 .get_id = usbhs1_get_id,
809 .phy_reset = usbhs_phy_reset, 769 .phy_reset = usbhs_phy_reset,
810 .get_vbus = usbhs_get_vbus,
811 }, 770 },
812 .driver_param = { 771 .driver_param = {
813 .buswait_bwait = 4, 772 .buswait_bwait = 4,
@@ -1184,15 +1143,6 @@ static struct resource sh_mmcif_resources[] = {
1184 }, 1143 },
1185}; 1144};
1186 1145
1187static struct sh_mmcif_dma sh_mmcif_dma = {
1188 .chan_priv_rx = {
1189 .slave_id = SHDMA_SLAVE_MMCIF_RX,
1190 },
1191 .chan_priv_tx = {
1192 .slave_id = SHDMA_SLAVE_MMCIF_TX,
1193 },
1194};
1195
1196static struct sh_mmcif_plat_data sh_mmcif_plat = { 1146static struct sh_mmcif_plat_data sh_mmcif_plat = {
1197 .sup_pclk = 0, 1147 .sup_pclk = 0,
1198 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 1148 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
@@ -1200,7 +1150,8 @@ static struct sh_mmcif_plat_data sh_mmcif_plat = {
1200 MMC_CAP_8_BIT_DATA | 1150 MMC_CAP_8_BIT_DATA |
1201 MMC_CAP_NEEDS_POLL, 1151 MMC_CAP_NEEDS_POLL,
1202 .get_cd = slot_cn7_get_cd, 1152 .get_cd = slot_cn7_get_cd,
1203 .dma = &sh_mmcif_dma, 1153 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
1154 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
1204}; 1155};
1205 1156
1206static struct platform_device sh_mmcif_device = { 1157static struct platform_device sh_mmcif_device = {
@@ -1311,7 +1262,6 @@ static struct platform_device *mackerel_devices[] __initdata = {
1311 &nor_flash_device, 1262 &nor_flash_device,
1312 &smc911x_device, 1263 &smc911x_device,
1313 &lcdc_device, 1264 &lcdc_device,
1314 &usb1_host_device,
1315 &usbhs1_device, 1265 &usbhs1_device,
1316 &usbhs0_device, 1266 &usbhs0_device,
1317 &leds_device, 1267 &leds_device,
@@ -1473,9 +1423,6 @@ static void __init mackerel_init(void)
1473 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */ 1423 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */
1474 gpio_request(GPIO_FN_IDIN_1_113, NULL); 1424 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1475 1425
1476 /* USB phy tweak to make the r8a66597_hcd host driver work */
1477 __raw_writew(0x8a0a, 0xe6058130); /* USBCR4 */
1478
1479 /* enable FSI2 port A (ak4643) */ 1426 /* enable FSI2 port A (ak4643) */
1480 gpio_request(GPIO_FN_FSIAIBT, NULL); 1427 gpio_request(GPIO_FN_FSIAIBT, NULL);
1481 gpio_request(GPIO_FN_FSIAILR, NULL); 1428 gpio_request(GPIO_FN_FSIAILR, NULL);
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index afbead6a6e17..7727cca6136c 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -365,6 +365,114 @@ static struct clk div6_clks[DIV6_NR] = {
365 dsi_parent, ARRAY_SIZE(dsi_parent), 12, 3), 365 dsi_parent, ARRAY_SIZE(dsi_parent), 12, 3),
366}; 366};
367 367
368/* DSI DIV */
369static unsigned long dsiphy_recalc(struct clk *clk)
370{
371 u32 value;
372
373 value = __raw_readl(clk->mapping->base);
374
375 /* FIXME */
376 if (!(value & 0x000B8000))
377 return clk->parent->rate;
378
379 value &= 0x3f;
380 value += 1;
381
382 if ((value < 12) ||
383 (value > 33)) {
384 pr_err("DSIPHY has wrong value (%d)", value);
385 return 0;
386 }
387
388 return clk->parent->rate / value;
389}
390
391static long dsiphy_round_rate(struct clk *clk, unsigned long rate)
392{
393 return clk_rate_mult_range_round(clk, 12, 33, rate);
394}
395
396static void dsiphy_disable(struct clk *clk)
397{
398 u32 value;
399
400 value = __raw_readl(clk->mapping->base);
401 value &= ~0x000B8000;
402
403 __raw_writel(value , clk->mapping->base);
404}
405
406static int dsiphy_enable(struct clk *clk)
407{
408 u32 value;
409 int multi;
410
411 value = __raw_readl(clk->mapping->base);
412 multi = (value & 0x3f) + 1;
413
414 if ((multi < 12) || (multi > 33))
415 return -EIO;
416
417 __raw_writel(value | 0x000B8000, clk->mapping->base);
418
419 return 0;
420}
421
422static int dsiphy_set_rate(struct clk *clk, unsigned long rate)
423{
424 u32 value;
425 int idx;
426
427 idx = rate / clk->parent->rate;
428 if ((idx < 12) || (idx > 33))
429 return -EINVAL;
430
431 idx += -1;
432
433 value = __raw_readl(clk->mapping->base);
434 value = (value & ~0x3f) + idx;
435
436 __raw_writel(value, clk->mapping->base);
437
438 return 0;
439}
440
441static struct clk_ops dsiphy_clk_ops = {
442 .recalc = dsiphy_recalc,
443 .round_rate = dsiphy_round_rate,
444 .set_rate = dsiphy_set_rate,
445 .enable = dsiphy_enable,
446 .disable = dsiphy_disable,
447};
448
449static struct clk_mapping dsi0phy_clk_mapping = {
450 .phys = DSI0PHYCR,
451 .len = 4,
452};
453
454static struct clk_mapping dsi1phy_clk_mapping = {
455 .phys = DSI1PHYCR,
456 .len = 4,
457};
458
459static struct clk dsi0phy_clk = {
460 .ops = &dsiphy_clk_ops,
461 .parent = &div6_clks[DIV6_DSI0P], /* late install */
462 .mapping = &dsi0phy_clk_mapping,
463};
464
465static struct clk dsi1phy_clk = {
466 .ops = &dsiphy_clk_ops,
467 .parent = &div6_clks[DIV6_DSI1P], /* late install */
468 .mapping = &dsi1phy_clk_mapping,
469};
470
471static struct clk *late_main_clks[] = {
472 &dsi0phy_clk,
473 &dsi1phy_clk,
474};
475
368enum { MSTP001, 476enum { MSTP001,
369 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100, 477 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100,
370 MSTP219, 478 MSTP219,
@@ -429,6 +537,8 @@ static struct clk_lookup lookups[] = {
429 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]), 537 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]),
430 CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]), 538 CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]),
431 CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]), 539 CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]),
540 CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.0", &dsi0phy_clk),
541 CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.1", &dsi1phy_clk),
432 542
433 /* MSTP32 clocks */ 543 /* MSTP32 clocks */
434 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */ 544 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */
@@ -504,6 +614,9 @@ void __init sh73a0_clock_init(void)
504 if (!ret) 614 if (!ret)
505 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 615 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR);
506 616
617 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
618 ret = clk_register(late_main_clks[k]);
619
507 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 620 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
508 621
509 if (!ret) 622 if (!ret)
diff --git a/arch/arm/mach-shmobile/include/mach/sh73a0.h b/arch/arm/mach-shmobile/include/mach/sh73a0.h
index 881d515a9686..cad57578ceed 100644
--- a/arch/arm/mach-shmobile/include/mach/sh73a0.h
+++ b/arch/arm/mach-shmobile/include/mach/sh73a0.h
@@ -515,8 +515,8 @@ enum {
515 SHDMA_SLAVE_MMCIF_RX, 515 SHDMA_SLAVE_MMCIF_RX,
516}; 516};
517 517
518/* PINT interrupts are located at Linux IRQ 768 and up */ 518/* PINT interrupts are located at Linux IRQ 800 and up */
519#define SH73A0_PINT0_IRQ(irq) ((irq) + 768) 519#define SH73A0_PINT0_IRQ(irq) ((irq) + 800)
520#define SH73A0_PINT1_IRQ(irq) ((irq) + 800) 520#define SH73A0_PINT1_IRQ(irq) ((irq) + 832)
521 521
522#endif /* __ASM_SH73A0_H__ */ 522#endif /* __ASM_SH73A0_H__ */
diff --git a/arch/arm/mach-shmobile/intc-sh73a0.c b/arch/arm/mach-shmobile/intc-sh73a0.c
index 1eda6b0b69e3..9857595eaa79 100644
--- a/arch/arm/mach-shmobile/intc-sh73a0.c
+++ b/arch/arm/mach-shmobile/intc-sh73a0.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/module.h>
22#include <linux/irq.h> 23#include <linux/irq.h>
23#include <linux/io.h> 24#include <linux/io.h>
24#include <linux/sh_intc.h> 25#include <linux/sh_intc.h>
@@ -445,6 +446,7 @@ void __init sh73a0_init_irq(void)
445 setup_irq(gic_spi(1 + k), &sh73a0_irq_pin_cascade[k]); 446 setup_irq(gic_spi(1 + k), &sh73a0_irq_pin_cascade[k]);
446 447
447 n = intcs_evt2irq(to_intc_vect(gic_spi(1 + k))); 448 n = intcs_evt2irq(to_intc_vect(gic_spi(1 + k)));
449 WARN_ON(irq_alloc_desc_at(n, numa_node_id()) != n);
448 irq_set_chip_and_handler_name(n, &intca_gic_irq_chip, 450 irq_set_chip_and_handler_name(n, &intca_gic_irq_chip,
449 handle_level_irq, "level"); 451 handle_level_irq, "level");
450 set_irq_flags(n, IRQF_VALID); /* yuck */ 452 set_irq_flags(n, IRQF_VALID); /* yuck */
diff --git a/arch/arm/mach-shmobile/pfc-r8a7779.c b/arch/arm/mach-shmobile/pfc-r8a7779.c
index 963532f2b2c4..d14c9b048077 100644
--- a/arch/arm/mach-shmobile/pfc-r8a7779.c
+++ b/arch/arm/mach-shmobile/pfc-r8a7779.c
@@ -2120,7 +2120,7 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
2120 FN_AUDATA3, 0, 0, 0 } 2120 FN_AUDATA3, 0, 0, 0 }
2121 }, 2121 },
2122 { PINMUX_CFG_REG_VAR("IPSR4", 0xfffc0030, 32, 2122 { PINMUX_CFG_REG_VAR("IPSR4", 0xfffc0030, 32,
2123 3, 1, 1, 1, 1, 1, 1, 3, 3, 1, 2123 3, 1, 1, 1, 1, 1, 1, 3, 3,
2124 1, 1, 1, 1, 1, 1, 3, 3, 3, 2) { 2124 1, 1, 1, 1, 1, 1, 3, 3, 3, 2) {
2125 /* IP4_31_29 [3] */ 2125 /* IP4_31_29 [3] */
2126 FN_DU1_DB0, FN_VI2_DATA4_VI2_B4, FN_SCL2_B, FN_SD3_DAT0, 2126 FN_DU1_DB0, FN_VI2_DATA4_VI2_B4, FN_SCL2_B, FN_SD3_DAT0,
diff --git a/arch/arm/mach-shmobile/pfc-sh7372.c b/arch/arm/mach-shmobile/pfc-sh7372.c
index 1bd6585a6acf..336093f9210a 100644
--- a/arch/arm/mach-shmobile/pfc-sh7372.c
+++ b/arch/arm/mach-shmobile/pfc-sh7372.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <mach/irqs.h>
26#include <mach/sh7372.h> 27#include <mach/sh7372.h>
27 28
28#define CPU_ALL_PORT(fn, pfx, sfx) \ 29#define CPU_ALL_PORT(fn, pfx, sfx) \
@@ -1594,6 +1595,43 @@ static struct pinmux_data_reg pinmux_data_regs[] = {
1594 { }, 1595 { },
1595}; 1596};
1596 1597
1598#define EXT_IRQ16L(n) evt2irq(0x200 + ((n) << 5))
1599#define EXT_IRQ16H(n) evt2irq(0x3200 + (((n) - 16) << 5))
1600static struct pinmux_irq pinmux_irqs[] = {
1601 PINMUX_IRQ(EXT_IRQ16L(0), PORT6_FN0, PORT162_FN0),
1602 PINMUX_IRQ(EXT_IRQ16L(1), PORT12_FN0),
1603 PINMUX_IRQ(EXT_IRQ16L(2), PORT4_FN0, PORT5_FN0),
1604 PINMUX_IRQ(EXT_IRQ16L(3), PORT8_FN0, PORT16_FN0),
1605 PINMUX_IRQ(EXT_IRQ16L(4), PORT17_FN0, PORT163_FN0),
1606 PINMUX_IRQ(EXT_IRQ16L(5), PORT18_FN0),
1607 PINMUX_IRQ(EXT_IRQ16L(6), PORT39_FN0, PORT164_FN0),
1608 PINMUX_IRQ(EXT_IRQ16L(7), PORT40_FN0, PORT167_FN0),
1609 PINMUX_IRQ(EXT_IRQ16L(8), PORT41_FN0, PORT168_FN0),
1610 PINMUX_IRQ(EXT_IRQ16L(9), PORT42_FN0, PORT169_FN0),
1611 PINMUX_IRQ(EXT_IRQ16L(10), PORT65_FN0),
1612 PINMUX_IRQ(EXT_IRQ16L(11), PORT67_FN0),
1613 PINMUX_IRQ(EXT_IRQ16L(12), PORT80_FN0, PORT137_FN0),
1614 PINMUX_IRQ(EXT_IRQ16L(13), PORT81_FN0, PORT145_FN0),
1615 PINMUX_IRQ(EXT_IRQ16L(14), PORT82_FN0, PORT146_FN0),
1616 PINMUX_IRQ(EXT_IRQ16L(15), PORT83_FN0, PORT147_FN0),
1617 PINMUX_IRQ(EXT_IRQ16H(16), PORT84_FN0, PORT170_FN0),
1618 PINMUX_IRQ(EXT_IRQ16H(17), PORT85_FN0),
1619 PINMUX_IRQ(EXT_IRQ16H(18), PORT86_FN0),
1620 PINMUX_IRQ(EXT_IRQ16H(19), PORT87_FN0),
1621 PINMUX_IRQ(EXT_IRQ16H(20), PORT92_FN0),
1622 PINMUX_IRQ(EXT_IRQ16H(21), PORT93_FN0),
1623 PINMUX_IRQ(EXT_IRQ16H(22), PORT94_FN0),
1624 PINMUX_IRQ(EXT_IRQ16H(23), PORT95_FN0),
1625 PINMUX_IRQ(EXT_IRQ16H(24), PORT112_FN0),
1626 PINMUX_IRQ(EXT_IRQ16H(25), PORT119_FN0),
1627 PINMUX_IRQ(EXT_IRQ16H(26), PORT121_FN0, PORT172_FN0),
1628 PINMUX_IRQ(EXT_IRQ16H(27), PORT122_FN0, PORT180_FN0),
1629 PINMUX_IRQ(EXT_IRQ16H(28), PORT123_FN0, PORT181_FN0),
1630 PINMUX_IRQ(EXT_IRQ16H(29), PORT129_FN0, PORT182_FN0),
1631 PINMUX_IRQ(EXT_IRQ16H(30), PORT130_FN0, PORT183_FN0),
1632 PINMUX_IRQ(EXT_IRQ16H(31), PORT138_FN0, PORT184_FN0),
1633};
1634
1597static struct pinmux_info sh7372_pinmux_info = { 1635static struct pinmux_info sh7372_pinmux_info = {
1598 .name = "sh7372_pfc", 1636 .name = "sh7372_pfc",
1599 .reserved_id = PINMUX_RESERVED, 1637 .reserved_id = PINMUX_RESERVED,
@@ -1614,6 +1652,9 @@ static struct pinmux_info sh7372_pinmux_info = {
1614 1652
1615 .gpio_data = pinmux_data, 1653 .gpio_data = pinmux_data,
1616 .gpio_data_size = ARRAY_SIZE(pinmux_data), 1654 .gpio_data_size = ARRAY_SIZE(pinmux_data),
1655
1656 .gpio_irq = pinmux_irqs,
1657 .gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
1617}; 1658};
1618 1659
1619void sh7372_pinmux_init(void) 1660void sh7372_pinmux_init(void)
diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c
index 0d159d64a345..2d0d4212be41 100644
--- a/arch/arm/mach-shmobile/smp-sh73a0.c
+++ b/arch/arm/mach-shmobile/smp-sh73a0.c
@@ -80,7 +80,7 @@ int __cpuinit sh73a0_boot_secondary(unsigned int cpu)
80 /* enable cache coherency */ 80 /* enable cache coherency */
81 modify_scu_cpu_psr(0, 3 << (cpu * 8)); 81 modify_scu_cpu_psr(0, 3 << (cpu * 8));
82 82
83 if (((__raw_readw(__io(PSTR)) >> (4 * cpu)) & 3) == 3) 83 if (((__raw_readl(__io(PSTR)) >> (4 * cpu)) & 3) == 3)
84 __raw_writel(1 << cpu, __io(WUPCR)); /* wake up */ 84 __raw_writel(1 << cpu, __io(WUPCR)); /* wake up */
85 else 85 else
86 __raw_writel(1 << cpu, __io(SRESCR)); /* reset */ 86 __raw_writel(1 << cpu, __io(SRESCR)); /* reset */
diff --git a/arch/c6x/boot/Makefile b/arch/c6x/boot/Makefile
index ecca820e6041..6891257d514c 100644
--- a/arch/c6x/boot/Makefile
+++ b/arch/c6x/boot/Makefile
@@ -13,7 +13,7 @@ obj-y += linked_dtb.o
13endif 13endif
14 14
15$(obj)/%.dtb: $(src)/dts/%.dts FORCE 15$(obj)/%.dtb: $(src)/dts/%.dts FORCE
16 $(call cmd,dtc) 16 $(call if_changed_dep,dtc)
17 17
18quiet_cmd_cp = CP $< $@$2 18quiet_cmd_cp = CP $< $@$2
19 cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false) 19 cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
diff --git a/arch/sh/boards/board-sh7757lcr.c b/arch/sh/boards/board-sh7757lcr.c
index 0838154dd216..24b1ee410daa 100644
--- a/arch/sh/boards/board-sh7757lcr.c
+++ b/arch/sh/boards/board-sh7757lcr.c
@@ -169,6 +169,11 @@ static struct resource sh_eth_giga1_resources[] = {
169 .end = 0xfee00fff, 169 .end = 0xfee00fff,
170 .flags = IORESOURCE_MEM, 170 .flags = IORESOURCE_MEM,
171 }, { 171 }, {
172 /* TSU */
173 .start = 0xfee01800,
174 .end = 0xfee01fff,
175 .flags = IORESOURCE_MEM,
176 }, {
172 .start = 316, 177 .start = 316,
173 .end = 316, 178 .end = 316,
174 .flags = IORESOURCE_IRQ, 179 .flags = IORESOURCE_IRQ,
@@ -210,20 +215,13 @@ static struct resource sh_mmcif_resources[] = {
210 }, 215 },
211}; 216};
212 217
213static struct sh_mmcif_dma sh7757lcr_mmcif_dma = {
214 .chan_priv_tx = {
215 .slave_id = SHDMA_SLAVE_MMCIF_TX,
216 },
217 .chan_priv_rx = {
218 .slave_id = SHDMA_SLAVE_MMCIF_RX,
219 }
220};
221
222static struct sh_mmcif_plat_data sh_mmcif_plat = { 218static struct sh_mmcif_plat_data sh_mmcif_plat = {
223 .dma = &sh7757lcr_mmcif_dma,
224 .sup_pclk = 0x0f, 219 .sup_pclk = 0x0f,
225 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 220 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
221 MMC_CAP_NONREMOVABLE,
226 .ocr = MMC_VDD_32_33 | MMC_VDD_33_34, 222 .ocr = MMC_VDD_32_33 | MMC_VDD_33_34,
223 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
224 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
227}; 225};
228 226
229static struct platform_device sh_mmcif_device = { 227static struct platform_device sh_mmcif_device = {
diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index 6418e95c2b6b..ebd0f818a25f 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -22,6 +22,7 @@
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/smsc911x.h> 23#include <linux/smsc911x.h>
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/videodev2.h>
25#include <media/ov772x.h> 26#include <media/ov772x.h>
26#include <media/soc_camera.h> 27#include <media/soc_camera.h>
27#include <media/soc_camera_platform.h> 28#include <media/soc_camera_platform.h>
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 033ef2ba621f..cde7c0085ced 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -29,9 +29,11 @@
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/input/sh_keysc.h> 30#include <linux/input/sh_keysc.h>
31#include <linux/sh_eth.h> 31#include <linux/sh_eth.h>
32#include <linux/videodev2.h>
32#include <video/sh_mobile_lcdc.h> 33#include <video/sh_mobile_lcdc.h>
33#include <sound/sh_fsi.h> 34#include <sound/sh_fsi.h>
34#include <media/sh_mobile_ceu.h> 35#include <media/sh_mobile_ceu.h>
36#include <media/soc_camera.h>
35#include <media/tw9910.h> 37#include <media/tw9910.h>
36#include <media/mt9t112.h> 38#include <media/mt9t112.h>
37#include <asm/heartbeat.h> 39#include <asm/heartbeat.h>
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index 2a18b06abdaf..5b382e1afaea 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -22,6 +22,7 @@
22#include <linux/input/sh_keysc.h> 22#include <linux/input/sh_keysc.h>
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/usb/r8a66597.h> 24#include <linux/usb/r8a66597.h>
25#include <linux/videodev2.h>
25#include <media/rj54n1cb0c.h> 26#include <media/rj54n1cb0c.h>
26#include <media/soc_camera.h> 27#include <media/soc_camera.h>
27#include <media/sh_mobile_ceu.h> 28#include <media/sh_mobile_ceu.h>
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index 68c3d6f42896..d37ba2720527 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -21,9 +21,11 @@
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/videodev2.h>
24#include <video/sh_mobile_lcdc.h> 25#include <video/sh_mobile_lcdc.h>
25#include <media/sh_mobile_ceu.h> 26#include <media/sh_mobile_ceu.h>
26#include <media/ov772x.h> 27#include <media/ov772x.h>
28#include <media/soc_camera.h>
27#include <media/tw9910.h> 29#include <media/tw9910.h>
28#include <asm/clock.h> 30#include <asm/clock.h>
29#include <asm/machvec.h> 31#include <asm/machvec.h>
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index 036fe1adaef1..2b07fc016950 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -24,6 +24,7 @@
24#include <linux/input/sh_keysc.h> 24#include <linux/input/sh_keysc.h>
25#include <linux/usb/r8a66597.h> 25#include <linux/usb/r8a66597.h>
26#include <linux/sh_eth.h> 26#include <linux/sh_eth.h>
27#include <linux/videodev2.h>
27#include <video/sh_mobile_lcdc.h> 28#include <video/sh_mobile_lcdc.h>
28#include <media/sh_mobile_ceu.h> 29#include <media/sh_mobile_ceu.h>
29#include <sound/sh_fsi.h> 30#include <sound/sh_fsi.h>
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
index fa7b978cc727..fb8f14990743 100644
--- a/arch/sh/drivers/pci/pci-sh7780.c
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -74,7 +74,7 @@ struct pci_errors {
74 { SH4_PCIINT_MLCK, "master lock error" }, 74 { SH4_PCIINT_MLCK, "master lock error" },
75 { SH4_PCIINT_TABT, "target-target abort" }, 75 { SH4_PCIINT_TABT, "target-target abort" },
76 { SH4_PCIINT_TRET, "target retry time out" }, 76 { SH4_PCIINT_TRET, "target retry time out" },
77 { SH4_PCIINT_MFDE, "master function disable erorr" }, 77 { SH4_PCIINT_MFDE, "master function disable error" },
78 { SH4_PCIINT_PRTY, "address parity error" }, 78 { SH4_PCIINT_PRTY, "address parity error" },
79 { SH4_PCIINT_SERR, "SERR" }, 79 { SH4_PCIINT_SERR, "SERR" },
80 { SH4_PCIINT_TWDP, "data parity error for target write" }, 80 { SH4_PCIINT_TWDP, "data parity error for target write" },
diff --git a/arch/sh/include/asm/device.h b/arch/sh/include/asm/device.h
index a1c9c0daec10..071bcb4d4bfd 100644
--- a/arch/sh/include/asm/device.h
+++ b/arch/sh/include/asm/device.h
@@ -3,9 +3,10 @@
3 * 3 *
4 * This file is released under the GPLv2 4 * This file is released under the GPLv2
5 */ 5 */
6#ifndef __ASM_SH_DEVICE_H
7#define __ASM_SH_DEVICE_H
6 8
7struct dev_archdata { 9#include <asm-generic/device.h>
8};
9 10
10struct platform_device; 11struct platform_device;
11/* allocate contiguous memory chunk and fill in struct resource */ 12/* allocate contiguous memory chunk and fill in struct resource */
@@ -14,5 +15,4 @@ int platform_resource_setup_memory(struct platform_device *pdev,
14 15
15void plat_early_device_setup(void); 16void plat_early_device_setup(void);
16 17
17struct pdev_archdata { 18#endif /* __ASM_SH_DEVICE_H */
18};
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index b3c039a5064a..70bd96646f42 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -343,7 +343,7 @@ static struct clk_lookup lookups[] = {
343 CLKDEV_DEV_ID("sh_mobile_ceu.1", &mstp_clks[HWBLK_CEU1]), 343 CLKDEV_DEV_ID("sh_mobile_ceu.1", &mstp_clks[HWBLK_CEU1]),
344 CLKDEV_CON_ID("beu1", &mstp_clks[HWBLK_BEU1]), 344 CLKDEV_CON_ID("beu1", &mstp_clks[HWBLK_BEU1]),
345 CLKDEV_CON_ID("2ddmac0", &mstp_clks[HWBLK_2DDMAC]), 345 CLKDEV_CON_ID("2ddmac0", &mstp_clks[HWBLK_2DDMAC]),
346 CLKDEV_CON_ID("spu0", &mstp_clks[HWBLK_SPU]), 346 CLKDEV_DEV_ID("sh_fsi.0", &mstp_clks[HWBLK_SPU]),
347 CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]), 347 CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]),
348 CLKDEV_DEV_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]), 348 CLKDEV_DEV_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]),
349 CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU0]), 349 CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU0]),
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
index a7b2da6b3a1a..2875e8be4f72 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
@@ -133,7 +133,7 @@ static struct resource spi0_resources[] = {
133 [0] = { 133 [0] = {
134 .start = 0xfe002000, 134 .start = 0xfe002000,
135 .end = 0xfe0020ff, 135 .end = 0xfe0020ff,
136 .flags = IORESOURCE_MEM, 136 .flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,
137 }, 137 },
138 [1] = { 138 [1] = {
139 .start = 86, 139 .start = 86,
@@ -661,6 +661,25 @@ static struct platform_device spi0_device = {
661 .resource = spi0_resources, 661 .resource = spi0_resources,
662}; 662};
663 663
664static struct resource spi1_resources[] = {
665 {
666 .start = 0xffd8ee70,
667 .end = 0xffd8eeff,
668 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
669 },
670 {
671 .start = 54,
672 .flags = IORESOURCE_IRQ,
673 },
674};
675
676static struct platform_device spi1_device = {
677 .name = "sh_spi",
678 .id = 1,
679 .num_resources = ARRAY_SIZE(spi1_resources),
680 .resource = spi1_resources,
681};
682
664static struct resource usb_ehci_resources[] = { 683static struct resource usb_ehci_resources[] = {
665 [0] = { 684 [0] = {
666 .start = 0xfe4f1000, 685 .start = 0xfe4f1000,
@@ -720,6 +739,7 @@ static struct platform_device *sh7757_devices[] __initdata = {
720 &dma2_device, 739 &dma2_device,
721 &dma3_device, 740 &dma3_device,
722 &spi0_device, 741 &spi0_device,
742 &spi1_device,
723 &usb_ehci_device, 743 &usb_ehci_device,
724 &usb_ohci_device, 744 &usb_ohci_device,
725}; 745};
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 3147a9a6fb8b..f624174bf239 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -63,7 +63,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
63 mp_ops->prepare_cpus(max_cpus); 63 mp_ops->prepare_cpus(max_cpus);
64 64
65#ifndef CONFIG_HOTPLUG_CPU 65#ifndef CONFIG_HOTPLUG_CPU
66 init_cpu_present(&cpu_possible_map); 66 init_cpu_present(cpu_possible_mask);
67#endif 67#endif
68} 68}
69 69
diff --git a/arch/sh/kernel/topology.c b/arch/sh/kernel/topology.c
index 4649a6ff0cfe..772caffba22f 100644
--- a/arch/sh/kernel/topology.c
+++ b/arch/sh/kernel/topology.c
@@ -27,7 +27,7 @@ static cpumask_t cpu_coregroup_map(unsigned int cpu)
27 * Presently all SH-X3 SMP cores are multi-cores, so just keep it 27 * Presently all SH-X3 SMP cores are multi-cores, so just keep it
28 * simple until we have a method for determining topology.. 28 * simple until we have a method for determining topology..
29 */ 29 */
30 return cpu_possible_map; 30 return *cpu_possible_mask;
31} 31}
32 32
33const struct cpumask *cpu_coregroup_mask(unsigned int cpu) 33const struct cpumask *cpu_coregroup_mask(unsigned int cpu)
diff --git a/arch/sh/mm/cache-sh2a.c b/arch/sh/mm/cache-sh2a.c
index ae08cbbfa569..949e2d3138a0 100644
--- a/arch/sh/mm/cache-sh2a.c
+++ b/arch/sh/mm/cache-sh2a.c
@@ -23,6 +23,7 @@
23#define MAX_OCACHE_PAGES 32 23#define MAX_OCACHE_PAGES 32
24#define MAX_ICACHE_PAGES 32 24#define MAX_ICACHE_PAGES 32
25 25
26#ifdef CONFIG_CACHE_WRITEBACK
26static void sh2a_flush_oc_line(unsigned long v, int way) 27static void sh2a_flush_oc_line(unsigned long v, int way)
27{ 28{
28 unsigned long addr = (v & 0x000007f0) | (way << 11); 29 unsigned long addr = (v & 0x000007f0) | (way << 11);
@@ -34,6 +35,7 @@ static void sh2a_flush_oc_line(unsigned long v, int way)
34 __raw_writel(data, CACHE_OC_ADDRESS_ARRAY | addr); 35 __raw_writel(data, CACHE_OC_ADDRESS_ARRAY | addr);
35 } 36 }
36} 37}
38#endif
37 39
38static void sh2a_invalidate_line(unsigned long cache_addr, unsigned long v) 40static void sh2a_invalidate_line(unsigned long cache_addr, unsigned long v)
39{ 41{
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 12eb07bfb267..4172af8ceeb3 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1141,7 +1141,9 @@ asmlinkage void __init xen_start_kernel(void)
1141 1141
1142 /* Prevent unwanted bits from being set in PTEs. */ 1142 /* Prevent unwanted bits from being set in PTEs. */
1143 __supported_pte_mask &= ~_PAGE_GLOBAL; 1143 __supported_pte_mask &= ~_PAGE_GLOBAL;
1144#if 0
1144 if (!xen_initial_domain()) 1145 if (!xen_initial_domain())
1146#endif
1145 __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD); 1147 __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD);
1146 1148
1147 __supported_pte_mask |= _PAGE_IOMAP; 1149 __supported_pte_mask |= _PAGE_IOMAP;
@@ -1204,10 +1206,6 @@ asmlinkage void __init xen_start_kernel(void)
1204 1206
1205 pgd = (pgd_t *)xen_start_info->pt_base; 1207 pgd = (pgd_t *)xen_start_info->pt_base;
1206 1208
1207 if (!xen_initial_domain())
1208 __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD);
1209
1210 __supported_pte_mask |= _PAGE_IOMAP;
1211 /* Don't do the full vcpu_info placement stuff until we have a 1209 /* Don't do the full vcpu_info placement stuff until we have a
1212 possible map and a non-dummy shared_info. */ 1210 possible map and a non-dummy shared_info. */
1213 per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; 1211 per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 58a0e46c404d..95c1cf60c669 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -415,13 +415,13 @@ static pteval_t iomap_pte(pteval_t val)
415static pteval_t xen_pte_val(pte_t pte) 415static pteval_t xen_pte_val(pte_t pte)
416{ 416{
417 pteval_t pteval = pte.pte; 417 pteval_t pteval = pte.pte;
418 418#if 0
419 /* If this is a WC pte, convert back from Xen WC to Linux WC */ 419 /* If this is a WC pte, convert back from Xen WC to Linux WC */
420 if ((pteval & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) == _PAGE_PAT) { 420 if ((pteval & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) == _PAGE_PAT) {
421 WARN_ON(!pat_enabled); 421 WARN_ON(!pat_enabled);
422 pteval = (pteval & ~_PAGE_PAT) | _PAGE_PWT; 422 pteval = (pteval & ~_PAGE_PAT) | _PAGE_PWT;
423 } 423 }
424 424#endif
425 if (xen_initial_domain() && (pteval & _PAGE_IOMAP)) 425 if (xen_initial_domain() && (pteval & _PAGE_IOMAP))
426 return pteval; 426 return pteval;
427 427
@@ -463,7 +463,7 @@ void xen_set_pat(u64 pat)
463static pte_t xen_make_pte(pteval_t pte) 463static pte_t xen_make_pte(pteval_t pte)
464{ 464{
465 phys_addr_t addr = (pte & PTE_PFN_MASK); 465 phys_addr_t addr = (pte & PTE_PFN_MASK);
466 466#if 0
467 /* If Linux is trying to set a WC pte, then map to the Xen WC. 467 /* If Linux is trying to set a WC pte, then map to the Xen WC.
468 * If _PAGE_PAT is set, then it probably means it is really 468 * If _PAGE_PAT is set, then it probably means it is really
469 * _PAGE_PSE, so avoid fiddling with the PAT mapping and hope 469 * _PAGE_PSE, so avoid fiddling with the PAT mapping and hope
@@ -476,7 +476,7 @@ static pte_t xen_make_pte(pteval_t pte)
476 if ((pte & (_PAGE_PCD | _PAGE_PWT)) == _PAGE_PWT) 476 if ((pte & (_PAGE_PCD | _PAGE_PWT)) == _PAGE_PWT)
477 pte = (pte & ~(_PAGE_PCD | _PAGE_PWT)) | _PAGE_PAT; 477 pte = (pte & ~(_PAGE_PCD | _PAGE_PWT)) | _PAGE_PAT;
478 } 478 }
479 479#endif
480 /* 480 /*
481 * Unprivileged domains are allowed to do IOMAPpings for 481 * Unprivileged domains are allowed to do IOMAPpings for
482 * PCI passthrough, but not map ISA space. The ISA 482 * PCI passthrough, but not map ISA space. The ISA
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 5d1d07645132..e8cd652d2017 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -1206,9 +1206,9 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1206 1206
1207 out_unmap_both: 1207 out_unmap_both:
1208 pci_set_drvdata(dev, NULL); 1208 pci_set_drvdata(dev, NULL);
1209 pci_iounmap(dev, card->config_regs);
1210 out_unmap_config:
1211 pci_iounmap(dev, card->buffers); 1209 pci_iounmap(dev, card->buffers);
1210 out_unmap_config:
1211 pci_iounmap(dev, card->config_regs);
1212 out_release_regions: 1212 out_release_regions:
1213 pci_release_regions(dev); 1213 pci_release_regions(dev);
1214 out: 1214 out:
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f00f596c1029..789c9b579aea 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -102,6 +102,7 @@ static struct usb_device_id btusb_table[] = {
102 102
103 /* Broadcom BCM20702A0 */ 103 /* Broadcom BCM20702A0 */
104 { USB_DEVICE(0x0a5c, 0x21e3) }, 104 { USB_DEVICE(0x0a5c, 0x21e3) },
105 { USB_DEVICE(0x0a5c, 0x21f3) },
105 { USB_DEVICE(0x413c, 0x8197) }, 106 { USB_DEVICE(0x413c, 0x8197) },
106 107
107 { } /* Terminating entry */ 108 { } /* Terminating entry */
@@ -726,9 +727,6 @@ static int btusb_send_frame(struct sk_buff *skb)
726 usb_fill_bulk_urb(urb, data->udev, pipe, 727 usb_fill_bulk_urb(urb, data->udev, pipe,
727 skb->data, skb->len, btusb_tx_complete, skb); 728 skb->data, skb->len, btusb_tx_complete, skb);
728 729
729 if (skb->priority >= HCI_PRIO_MAX - 1)
730 urb->transfer_flags = URB_ISO_ASAP;
731
732 hdev->stat.acl_tx++; 730 hdev->stat.acl_tx++;
733 break; 731 break;
734 732
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index eedca3cf9968..dd87ae96c262 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -271,7 +271,7 @@ static int ads1015_probe(struct i2c_client *client,
271 continue; 271 continue;
272 err = device_create_file(&client->dev, &ads1015_in[k].dev_attr); 272 err = device_create_file(&client->dev, &ads1015_in[k].dev_attr);
273 if (err) 273 if (err)
274 goto exit_free; 274 goto exit_remove;
275 } 275 }
276 276
277 data->hwmon_dev = hwmon_device_register(&client->dev); 277 data->hwmon_dev = hwmon_device_register(&client->dev);
@@ -285,7 +285,6 @@ static int ads1015_probe(struct i2c_client *client,
285exit_remove: 285exit_remove:
286 for (k = 0; k < ADS1015_CHANNELS; ++k) 286 for (k = 0; k < ADS1015_CHANNELS; ++k)
287 device_remove_file(&client->dev, &ads1015_in[k].dev_attr); 287 device_remove_file(&client->dev, &ads1015_in[k].dev_attr);
288exit_free:
289 kfree(data); 288 kfree(data);
290exit: 289exit:
291 return err; 290 return err;
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index f609b5727ba9..6bab2001ef3b 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -340,8 +340,6 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
340 fanmode |= (1 << F75387_FAN_MANU_MODE(nr)); 340 fanmode |= (1 << F75387_FAN_MANU_MODE(nr));
341 fanmode |= (1 << F75387_FAN_DUTY_MODE(nr)); 341 fanmode |= (1 << F75387_FAN_DUTY_MODE(nr));
342 data->pwm[nr] = 255; 342 data->pwm[nr] = 255;
343 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
344 data->pwm[nr]);
345 break; 343 break;
346 case 1: /* PWM */ 344 case 1: /* PWM */
347 fanmode |= (1 << F75387_FAN_MANU_MODE(nr)); 345 fanmode |= (1 << F75387_FAN_MANU_MODE(nr));
@@ -361,8 +359,6 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
361 case 0: /* full speed */ 359 case 0: /* full speed */
362 fanmode |= (3 << FAN_CTRL_MODE(nr)); 360 fanmode |= (3 << FAN_CTRL_MODE(nr));
363 data->pwm[nr] = 255; 361 data->pwm[nr] = 255;
364 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
365 data->pwm[nr]);
366 break; 362 break;
367 case 1: /* PWM */ 363 case 1: /* PWM */
368 fanmode |= (3 << FAN_CTRL_MODE(nr)); 364 fanmode |= (3 << FAN_CTRL_MODE(nr));
@@ -377,6 +373,9 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
377 373
378 f75375_write8(client, F75375_REG_FAN_TIMER, fanmode); 374 f75375_write8(client, F75375_REG_FAN_TIMER, fanmode);
379 data->pwm_enable[nr] = val; 375 data->pwm_enable[nr] = val;
376 if (val == 0)
377 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
378 data->pwm[nr]);
380 return 0; 379 return 0;
381} 380}
382 381
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c
index e10a092c603c..a6760bacd915 100644
--- a/drivers/hwmon/max6639.c
+++ b/drivers/hwmon/max6639.c
@@ -72,8 +72,8 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END };
72 72
73static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; 73static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 };
74 74
75#define FAN_FROM_REG(val, div, rpm_range) ((val) == 0 ? -1 : \ 75#define FAN_FROM_REG(val, rpm_range) ((val) == 0 || (val) == 255 ? \
76 (val) == 255 ? 0 : (rpm_ranges[rpm_range] * 30) / ((div + 1) * (val))) 76 0 : (rpm_ranges[rpm_range] * 30) / (val))
77#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255) 77#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255)
78 78
79/* 79/*
@@ -333,7 +333,7 @@ static ssize_t show_fan_input(struct device *dev,
333 return PTR_ERR(data); 333 return PTR_ERR(data);
334 334
335 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], 335 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index],
336 data->ppr, data->rpm_range)); 336 data->rpm_range));
337} 337}
338 338
339static ssize_t show_alarm(struct device *dev, 339static ssize_t show_alarm(struct device *dev,
@@ -429,9 +429,9 @@ static int max6639_init_client(struct i2c_client *client)
429 struct max6639_data *data = i2c_get_clientdata(client); 429 struct max6639_data *data = i2c_get_clientdata(client);
430 struct max6639_platform_data *max6639_info = 430 struct max6639_platform_data *max6639_info =
431 client->dev.platform_data; 431 client->dev.platform_data;
432 int i = 0; 432 int i;
433 int rpm_range = 1; /* default: 4000 RPM */ 433 int rpm_range = 1; /* default: 4000 RPM */
434 int err = 0; 434 int err;
435 435
436 /* Reset chip to default values, see below for GCONFIG setup */ 436 /* Reset chip to default values, see below for GCONFIG setup */
437 err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG, 437 err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG,
@@ -446,11 +446,6 @@ static int max6639_init_client(struct i2c_client *client)
446 else 446 else
447 data->ppr = 2; 447 data->ppr = 2;
448 data->ppr -= 1; 448 data->ppr -= 1;
449 err = i2c_smbus_write_byte_data(client,
450 MAX6639_REG_FAN_PPR(i),
451 data->ppr << 5);
452 if (err)
453 goto exit;
454 449
455 if (max6639_info) 450 if (max6639_info)
456 rpm_range = rpm_range_to_reg(max6639_info->rpm_range); 451 rpm_range = rpm_range_to_reg(max6639_info->rpm_range);
@@ -458,6 +453,13 @@ static int max6639_init_client(struct i2c_client *client)
458 453
459 for (i = 0; i < 2; i++) { 454 for (i = 0; i < 2; i++) {
460 455
456 /* Set Fan pulse per revolution */
457 err = i2c_smbus_write_byte_data(client,
458 MAX6639_REG_FAN_PPR(i),
459 data->ppr << 6);
460 if (err)
461 goto exit;
462
461 /* Fans config PWM, RPM */ 463 /* Fans config PWM, RPM */
462 err = i2c_smbus_write_byte_data(client, 464 err = i2c_smbus_write_byte_data(client,
463 MAX6639_REG_FAN_CONFIG1(i), 465 MAX6639_REG_FAN_CONFIG1(i),
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index beaf5a8d9c45..9b97a5b3cf3d 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -82,7 +82,7 @@ static int max34440_write_word_data(struct i2c_client *client, int page,
82 case PMBUS_VIRT_RESET_TEMP_HISTORY: 82 case PMBUS_VIRT_RESET_TEMP_HISTORY:
83 ret = pmbus_write_word_data(client, page, 83 ret = pmbus_write_word_data(client, page,
84 MAX34440_MFR_TEMPERATURE_PEAK, 84 MAX34440_MFR_TEMPERATURE_PEAK,
85 0xffff); 85 0x8000);
86 break; 86 break;
87 default: 87 default:
88 ret = -ENODATA; 88 ret = -ENODATA;
diff --git a/drivers/media/radio/wl128x/Kconfig b/drivers/media/radio/wl128x/Kconfig
index 86b28579f0c7..ea1e6545df36 100644
--- a/drivers/media/radio/wl128x/Kconfig
+++ b/drivers/media/radio/wl128x/Kconfig
@@ -4,8 +4,8 @@
4menu "Texas Instruments WL128x FM driver (ST based)" 4menu "Texas Instruments WL128x FM driver (ST based)"
5config RADIO_WL128X 5config RADIO_WL128X
6 tristate "Texas Instruments WL128x FM Radio" 6 tristate "Texas Instruments WL128x FM Radio"
7 depends on VIDEO_V4L2 && RFKILL 7 depends on VIDEO_V4L2 && RFKILL && GPIOLIB
8 select TI_ST if NET && GPIOLIB 8 select TI_ST if NET
9 help 9 help
10 Choose Y here if you have this FM radio chip. 10 Choose Y here if you have this FM radio chip.
11 11
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 3aeb29a7ce11..7f26fdf2e54e 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -47,7 +47,7 @@
47#define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>" 47#define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>"
48#define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display" 48#define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display"
49#define MOD_NAME "imon" 49#define MOD_NAME "imon"
50#define MOD_VERSION "0.9.3" 50#define MOD_VERSION "0.9.4"
51 51
52#define DISPLAY_MINOR_BASE 144 52#define DISPLAY_MINOR_BASE 144
53#define DEVICE_NAME "lcd%d" 53#define DEVICE_NAME "lcd%d"
@@ -1658,9 +1658,17 @@ static void usb_rx_callback_intf0(struct urb *urb)
1658 return; 1658 return;
1659 1659
1660 ictx = (struct imon_context *)urb->context; 1660 ictx = (struct imon_context *)urb->context;
1661 if (!ictx || !ictx->dev_present_intf0) 1661 if (!ictx)
1662 return; 1662 return;
1663 1663
1664 /*
1665 * if we get a callback before we're done configuring the hardware, we
1666 * can't yet process the data, as there's nowhere to send it, but we
1667 * still need to submit a new rx URB to avoid wedging the hardware
1668 */
1669 if (!ictx->dev_present_intf0)
1670 goto out;
1671
1664 switch (urb->status) { 1672 switch (urb->status) {
1665 case -ENOENT: /* usbcore unlink successful! */ 1673 case -ENOENT: /* usbcore unlink successful! */
1666 return; 1674 return;
@@ -1678,6 +1686,7 @@ static void usb_rx_callback_intf0(struct urb *urb)
1678 break; 1686 break;
1679 } 1687 }
1680 1688
1689out:
1681 usb_submit_urb(ictx->rx_urb_intf0, GFP_ATOMIC); 1690 usb_submit_urb(ictx->rx_urb_intf0, GFP_ATOMIC);
1682} 1691}
1683 1692
@@ -1690,9 +1699,17 @@ static void usb_rx_callback_intf1(struct urb *urb)
1690 return; 1699 return;
1691 1700
1692 ictx = (struct imon_context *)urb->context; 1701 ictx = (struct imon_context *)urb->context;
1693 if (!ictx || !ictx->dev_present_intf1) 1702 if (!ictx)
1694 return; 1703 return;
1695 1704
1705 /*
1706 * if we get a callback before we're done configuring the hardware, we
1707 * can't yet process the data, as there's nowhere to send it, but we
1708 * still need to submit a new rx URB to avoid wedging the hardware
1709 */
1710 if (!ictx->dev_present_intf1)
1711 goto out;
1712
1696 switch (urb->status) { 1713 switch (urb->status) {
1697 case -ENOENT: /* usbcore unlink successful! */ 1714 case -ENOENT: /* usbcore unlink successful! */
1698 return; 1715 return;
@@ -1710,6 +1727,7 @@ static void usb_rx_callback_intf1(struct urb *urb)
1710 break; 1727 break;
1711 } 1728 }
1712 1729
1730out:
1713 usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC); 1731 usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC);
1714} 1732}
1715 1733
@@ -2242,7 +2260,7 @@ find_endpoint_failed:
2242 mutex_unlock(&ictx->lock); 2260 mutex_unlock(&ictx->lock);
2243 usb_free_urb(rx_urb); 2261 usb_free_urb(rx_urb);
2244rx_urb_alloc_failed: 2262rx_urb_alloc_failed:
2245 dev_err(ictx->dev, "unable to initialize intf0, err %d\n", ret); 2263 dev_err(ictx->dev, "unable to initialize intf1, err %d\n", ret);
2246 2264
2247 return NULL; 2265 return NULL;
2248} 2266}
diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c
index e5eb56a5b618..6510110f53d0 100644
--- a/drivers/media/video/hdpvr/hdpvr-core.c
+++ b/drivers/media/video/hdpvr/hdpvr-core.c
@@ -154,10 +154,20 @@ static int device_authorization(struct hdpvr_device *dev)
154 } 154 }
155#endif 155#endif
156 156
157 dev->fw_ver = dev->usbc_buf[1];
158
157 v4l2_info(&dev->v4l2_dev, "firmware version 0x%x dated %s\n", 159 v4l2_info(&dev->v4l2_dev, "firmware version 0x%x dated %s\n",
158 dev->usbc_buf[1], &dev->usbc_buf[2]); 160 dev->fw_ver, &dev->usbc_buf[2]);
161
162 if (dev->fw_ver > 0x15) {
163 dev->options.brightness = 0x80;
164 dev->options.contrast = 0x40;
165 dev->options.hue = 0xf;
166 dev->options.saturation = 0x40;
167 dev->options.sharpness = 0x80;
168 }
159 169
160 switch (dev->usbc_buf[1]) { 170 switch (dev->fw_ver) {
161 case HDPVR_FIRMWARE_VERSION: 171 case HDPVR_FIRMWARE_VERSION:
162 dev->flags &= ~HDPVR_FLAG_AC3_CAP; 172 dev->flags &= ~HDPVR_FLAG_AC3_CAP;
163 break; 173 break;
@@ -169,7 +179,7 @@ static int device_authorization(struct hdpvr_device *dev)
169 default: 179 default:
170 v4l2_info(&dev->v4l2_dev, "untested firmware, the driver might" 180 v4l2_info(&dev->v4l2_dev, "untested firmware, the driver might"
171 " not work.\n"); 181 " not work.\n");
172 if (dev->usbc_buf[1] >= HDPVR_FIRMWARE_VERSION_AC3) 182 if (dev->fw_ver >= HDPVR_FIRMWARE_VERSION_AC3)
173 dev->flags |= HDPVR_FLAG_AC3_CAP; 183 dev->flags |= HDPVR_FLAG_AC3_CAP;
174 else 184 else
175 dev->flags &= ~HDPVR_FLAG_AC3_CAP; 185 dev->flags &= ~HDPVR_FLAG_AC3_CAP;
@@ -270,6 +280,8 @@ static const struct hdpvr_options hdpvr_default_options = {
270 .bitrate_mode = HDPVR_CONSTANT, 280 .bitrate_mode = HDPVR_CONSTANT,
271 .gop_mode = HDPVR_SIMPLE_IDR_GOP, 281 .gop_mode = HDPVR_SIMPLE_IDR_GOP,
272 .audio_codec = V4L2_MPEG_AUDIO_ENCODING_AAC, 282 .audio_codec = V4L2_MPEG_AUDIO_ENCODING_AAC,
283 /* original picture controls for firmware version <= 0x15 */
284 /* updated in device_authorization() for newer firmware */
273 .brightness = 0x86, 285 .brightness = 0x86,
274 .contrast = 0x80, 286 .contrast = 0x80,
275 .hue = 0x80, 287 .hue = 0x80,
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index 087f7c08cb85..11ffe9cc1780 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -283,12 +283,13 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev)
283 283
284 hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); 284 hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00);
285 285
286 dev->status = STATUS_STREAMING;
287
286 INIT_WORK(&dev->worker, hdpvr_transmit_buffers); 288 INIT_WORK(&dev->worker, hdpvr_transmit_buffers);
287 queue_work(dev->workqueue, &dev->worker); 289 queue_work(dev->workqueue, &dev->worker);
288 290
289 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, 291 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
290 "streaming started\n"); 292 "streaming started\n");
291 dev->status = STATUS_STREAMING;
292 293
293 return 0; 294 return 0;
294 } 295 }
@@ -722,21 +723,39 @@ static const s32 supported_v4l2_ctrls[] = {
722}; 723};
723 724
724static int fill_queryctrl(struct hdpvr_options *opt, struct v4l2_queryctrl *qc, 725static int fill_queryctrl(struct hdpvr_options *opt, struct v4l2_queryctrl *qc,
725 int ac3) 726 int ac3, int fw_ver)
726{ 727{
727 int err; 728 int err;
728 729
730 if (fw_ver > 0x15) {
731 switch (qc->id) {
732 case V4L2_CID_BRIGHTNESS:
733 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
734 case V4L2_CID_CONTRAST:
735 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x40);
736 case V4L2_CID_SATURATION:
737 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x40);
738 case V4L2_CID_HUE:
739 return v4l2_ctrl_query_fill(qc, 0x0, 0x1e, 1, 0xf);
740 case V4L2_CID_SHARPNESS:
741 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
742 }
743 } else {
744 switch (qc->id) {
745 case V4L2_CID_BRIGHTNESS:
746 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x86);
747 case V4L2_CID_CONTRAST:
748 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
749 case V4L2_CID_SATURATION:
750 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
751 case V4L2_CID_HUE:
752 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
753 case V4L2_CID_SHARPNESS:
754 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
755 }
756 }
757
729 switch (qc->id) { 758 switch (qc->id) {
730 case V4L2_CID_BRIGHTNESS:
731 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x86);
732 case V4L2_CID_CONTRAST:
733 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
734 case V4L2_CID_SATURATION:
735 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
736 case V4L2_CID_HUE:
737 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
738 case V4L2_CID_SHARPNESS:
739 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
740 case V4L2_CID_MPEG_AUDIO_ENCODING: 759 case V4L2_CID_MPEG_AUDIO_ENCODING:
741 return v4l2_ctrl_query_fill( 760 return v4l2_ctrl_query_fill(
742 qc, V4L2_MPEG_AUDIO_ENCODING_AAC, 761 qc, V4L2_MPEG_AUDIO_ENCODING_AAC,
@@ -794,7 +813,8 @@ static int vidioc_queryctrl(struct file *file, void *private_data,
794 813
795 if (qc->id == supported_v4l2_ctrls[i]) 814 if (qc->id == supported_v4l2_ctrls[i])
796 return fill_queryctrl(&dev->options, qc, 815 return fill_queryctrl(&dev->options, qc,
797 dev->flags & HDPVR_FLAG_AC3_CAP); 816 dev->flags & HDPVR_FLAG_AC3_CAP,
817 dev->fw_ver);
798 818
799 if (qc->id < supported_v4l2_ctrls[i]) 819 if (qc->id < supported_v4l2_ctrls[i])
800 break; 820 break;
diff --git a/drivers/media/video/hdpvr/hdpvr.h b/drivers/media/video/hdpvr/hdpvr.h
index d6439db1d18b..fea3c6926997 100644
--- a/drivers/media/video/hdpvr/hdpvr.h
+++ b/drivers/media/video/hdpvr/hdpvr.h
@@ -113,6 +113,7 @@ struct hdpvr_device {
113 /* usb control transfer buffer and lock */ 113 /* usb control transfer buffer and lock */
114 struct mutex usbc_mutex; 114 struct mutex usbc_mutex;
115 u8 *usbc_buf; 115 u8 *usbc_buf;
116 u8 fw_ver;
116}; 117};
117 118
118static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev) 119static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev)
diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c
index a74a79701d34..eaabc27f0fa2 100644
--- a/drivers/media/video/omap3isp/ispccdc.c
+++ b/drivers/media/video/omap3isp/ispccdc.c
@@ -1407,7 +1407,7 @@ static int __ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event)
1407static void ccdc_hs_vs_isr(struct isp_ccdc_device *ccdc) 1407static void ccdc_hs_vs_isr(struct isp_ccdc_device *ccdc)
1408{ 1408{
1409 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity); 1409 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity);
1410 struct video_device *vdev = &ccdc->subdev.devnode; 1410 struct video_device *vdev = ccdc->subdev.devnode;
1411 struct v4l2_event event; 1411 struct v4l2_event event;
1412 1412
1413 memset(&event, 0, sizeof(event)); 1413 memset(&event, 0, sizeof(event));
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 04a3f1b756a8..192b0d118df4 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -95,11 +95,16 @@ static void sja1000_write_cmdreg(struct sja1000_priv *priv, u8 val)
95 spin_unlock_irqrestore(&priv->cmdreg_lock, flags); 95 spin_unlock_irqrestore(&priv->cmdreg_lock, flags);
96} 96}
97 97
98static int sja1000_is_absent(struct sja1000_priv *priv)
99{
100 return (priv->read_reg(priv, REG_MOD) == 0xFF);
101}
102
98static int sja1000_probe_chip(struct net_device *dev) 103static int sja1000_probe_chip(struct net_device *dev)
99{ 104{
100 struct sja1000_priv *priv = netdev_priv(dev); 105 struct sja1000_priv *priv = netdev_priv(dev);
101 106
102 if (priv->reg_base && (priv->read_reg(priv, 0) == 0xFF)) { 107 if (priv->reg_base && sja1000_is_absent(priv)) {
103 printk(KERN_INFO "%s: probing @0x%lX failed\n", 108 printk(KERN_INFO "%s: probing @0x%lX failed\n",
104 DRV_NAME, dev->base_addr); 109 DRV_NAME, dev->base_addr);
105 return 0; 110 return 0;
@@ -493,6 +498,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
493 while ((isrc = priv->read_reg(priv, REG_IR)) && (n < SJA1000_MAX_IRQ)) { 498 while ((isrc = priv->read_reg(priv, REG_IR)) && (n < SJA1000_MAX_IRQ)) {
494 n++; 499 n++;
495 status = priv->read_reg(priv, REG_SR); 500 status = priv->read_reg(priv, REG_SR);
501 /* check for absent controller due to hw unplug */
502 if (status == 0xFF && sja1000_is_absent(priv))
503 return IRQ_NONE;
496 504
497 if (isrc & IRQ_WUI) 505 if (isrc & IRQ_WUI)
498 dev_warn(dev->dev.parent, "wakeup interrupt\n"); 506 dev_warn(dev->dev.parent, "wakeup interrupt\n");
@@ -509,6 +517,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
509 while (status & SR_RBS) { 517 while (status & SR_RBS) {
510 sja1000_rx(dev); 518 sja1000_rx(dev);
511 status = priv->read_reg(priv, REG_SR); 519 status = priv->read_reg(priv, REG_SR);
520 /* check for absent controller */
521 if (status == 0xFF && sja1000_is_absent(priv))
522 return IRQ_NONE;
512 } 523 }
513 } 524 }
514 if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) { 525 if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) {
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index b8591246eb4c..1ff3c6df35a2 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -2244,10 +2244,6 @@ static netdev_tx_t atl1c_xmit_frame(struct sk_buff *skb,
2244 dev_info(&adapter->pdev->dev, "tx locked\n"); 2244 dev_info(&adapter->pdev->dev, "tx locked\n");
2245 return NETDEV_TX_LOCKED; 2245 return NETDEV_TX_LOCKED;
2246 } 2246 }
2247 if (skb->mark == 0x01)
2248 type = atl1c_trans_high;
2249 else
2250 type = atl1c_trans_normal;
2251 2247
2252 if (atl1c_tpd_avail(adapter, type) < tpd_req) { 2248 if (atl1c_tpd_avail(adapter, type) < tpd_req) {
2253 /* no enough descriptor, just stop queue */ 2249 /* no enough descriptor, just stop queue */
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 3fb66d09ece5..cab87456a34a 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -2339,7 +2339,7 @@ static inline int __init b44_pci_init(void)
2339 return err; 2339 return err;
2340} 2340}
2341 2341
2342static inline void __exit b44_pci_exit(void) 2342static inline void b44_pci_exit(void)
2343{ 2343{
2344#ifdef CONFIG_B44_PCI 2344#ifdef CONFIG_B44_PCI
2345 ssb_pcihost_unregister(&b44_pci_driver); 2345 ssb_pcihost_unregister(&b44_pci_driver);
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index dd3a0a232ea0..818a573669e6 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -3584,7 +3584,11 @@ static int cnic_get_v6_route(struct sockaddr_in6 *dst_addr,
3584 fl6.flowi6_oif = dst_addr->sin6_scope_id; 3584 fl6.flowi6_oif = dst_addr->sin6_scope_id;
3585 3585
3586 *dst = ip6_route_output(&init_net, NULL, &fl6); 3586 *dst = ip6_route_output(&init_net, NULL, &fl6);
3587 if (*dst) 3587 if ((*dst)->error) {
3588 dst_release(*dst);
3589 *dst = NULL;
3590 return -ENETUNREACH;
3591 } else
3588 return 0; 3592 return 0;
3589#endif 3593#endif
3590 3594
diff --git a/drivers/net/ethernet/cisco/enic/cq_enet_desc.h b/drivers/net/ethernet/cisco/enic/cq_enet_desc.h
index c2c0680a1146..ac37cacc6136 100644
--- a/drivers/net/ethernet/cisco/enic/cq_enet_desc.h
+++ b/drivers/net/ethernet/cisco/enic/cq_enet_desc.h
@@ -157,7 +157,7 @@ static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc,
157 CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0; 157 CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0;
158 *fcoe_enc_error = (desc->flags & 158 *fcoe_enc_error = (desc->flags &
159 CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0; 159 CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0;
160 *fcoe_eof = (u8)((desc->checksum_fcoe >> 160 *fcoe_eof = (u8)((le16_to_cpu(desc->checksum_fcoe) >>
161 CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) & 161 CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) &
162 CQ_ENET_RQ_DESC_FCOE_EOF_MASK); 162 CQ_ENET_RQ_DESC_FCOE_EOF_MASK);
163 *checksum = 0; 163 *checksum = 0;
diff --git a/drivers/net/ethernet/cisco/enic/enic_pp.c b/drivers/net/ethernet/cisco/enic/enic_pp.c
index 22bf03a1829e..c347b6236f8f 100644
--- a/drivers/net/ethernet/cisco/enic/enic_pp.c
+++ b/drivers/net/ethernet/cisco/enic/enic_pp.c
@@ -72,7 +72,7 @@ static int enic_set_port_profile(struct enic *enic, int vf)
72 struct enic_port_profile *pp; 72 struct enic_port_profile *pp;
73 struct vic_provinfo *vp; 73 struct vic_provinfo *vp;
74 const u8 oui[3] = VIC_PROVINFO_CISCO_OUI; 74 const u8 oui[3] = VIC_PROVINFO_CISCO_OUI;
75 const u16 os_type = htons(VIC_GENERIC_PROV_OS_TYPE_LINUX); 75 const __be16 os_type = htons(VIC_GENERIC_PROV_OS_TYPE_LINUX);
76 char uuid_str[38]; 76 char uuid_str[38];
77 char client_mac_str[18]; 77 char client_mac_str[18];
78 u8 *client_mac; 78 u8 *client_mac;
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index 27d651a80f3f..55cbf65512c3 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -2328,19 +2328,11 @@ jme_change_mtu(struct net_device *netdev, int new_mtu)
2328 ((new_mtu) < IPV6_MIN_MTU)) 2328 ((new_mtu) < IPV6_MIN_MTU))
2329 return -EINVAL; 2329 return -EINVAL;
2330 2330
2331 if (new_mtu > 4000) {
2332 jme->reg_rxcs &= ~RXCS_FIFOTHNP;
2333 jme->reg_rxcs |= RXCS_FIFOTHNP_64QW;
2334 jme_restart_rx_engine(jme);
2335 } else {
2336 jme->reg_rxcs &= ~RXCS_FIFOTHNP;
2337 jme->reg_rxcs |= RXCS_FIFOTHNP_128QW;
2338 jme_restart_rx_engine(jme);
2339 }
2340 2331
2341 netdev->mtu = new_mtu; 2332 netdev->mtu = new_mtu;
2342 netdev_update_features(netdev); 2333 netdev_update_features(netdev);
2343 2334
2335 jme_restart_rx_engine(jme);
2344 jme_reset_link(jme); 2336 jme_reset_link(jme);
2345 2337
2346 return 0; 2338 return 0;
diff --git a/drivers/net/ethernet/jme.h b/drivers/net/ethernet/jme.h
index 4304072bd3c5..3efc897c9913 100644
--- a/drivers/net/ethernet/jme.h
+++ b/drivers/net/ethernet/jme.h
@@ -730,7 +730,7 @@ enum jme_rxcs_values {
730 RXCS_RETRYCNT_60 = 0x00000F00, 730 RXCS_RETRYCNT_60 = 0x00000F00,
731 731
732 RXCS_DEFAULT = RXCS_FIFOTHTP_128T | 732 RXCS_DEFAULT = RXCS_FIFOTHTP_128T |
733 RXCS_FIFOTHNP_128QW | 733 RXCS_FIFOTHNP_16QW |
734 RXCS_DMAREQSZ_128B | 734 RXCS_DMAREQSZ_128B |
735 RXCS_RETRYGAP_256ns | 735 RXCS_RETRYGAP_256ns |
736 RXCS_RETRYCNT_32, 736 RXCS_RETRYCNT_32,
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 8fa41f3082cf..9129ace02560 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -1036,7 +1036,7 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char* name, int * vector)
1036 struct mlx4_priv *priv = mlx4_priv(dev); 1036 struct mlx4_priv *priv = mlx4_priv(dev);
1037 int vec = 0, err = 0, i; 1037 int vec = 0, err = 0, i;
1038 1038
1039 spin_lock(&priv->msix_ctl.pool_lock); 1039 mutex_lock(&priv->msix_ctl.pool_lock);
1040 for (i = 0; !vec && i < dev->caps.comp_pool; i++) { 1040 for (i = 0; !vec && i < dev->caps.comp_pool; i++) {
1041 if (~priv->msix_ctl.pool_bm & 1ULL << i) { 1041 if (~priv->msix_ctl.pool_bm & 1ULL << i) {
1042 priv->msix_ctl.pool_bm |= 1ULL << i; 1042 priv->msix_ctl.pool_bm |= 1ULL << i;
@@ -1058,7 +1058,7 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char* name, int * vector)
1058 eq_set_ci(&priv->eq_table.eq[vec], 1); 1058 eq_set_ci(&priv->eq_table.eq[vec], 1);
1059 } 1059 }
1060 } 1060 }
1061 spin_unlock(&priv->msix_ctl.pool_lock); 1061 mutex_unlock(&priv->msix_ctl.pool_lock);
1062 1062
1063 if (vec) { 1063 if (vec) {
1064 *vector = vec; 1064 *vector = vec;
@@ -1079,13 +1079,13 @@ void mlx4_release_eq(struct mlx4_dev *dev, int vec)
1079 if (likely(i >= 0)) { 1079 if (likely(i >= 0)) {
1080 /*sanity check , making sure were not trying to free irq's 1080 /*sanity check , making sure were not trying to free irq's
1081 Belonging to a legacy EQ*/ 1081 Belonging to a legacy EQ*/
1082 spin_lock(&priv->msix_ctl.pool_lock); 1082 mutex_lock(&priv->msix_ctl.pool_lock);
1083 if (priv->msix_ctl.pool_bm & 1ULL << i) { 1083 if (priv->msix_ctl.pool_bm & 1ULL << i) {
1084 free_irq(priv->eq_table.eq[vec].irq, 1084 free_irq(priv->eq_table.eq[vec].irq,
1085 &priv->eq_table.eq[vec]); 1085 &priv->eq_table.eq[vec]);
1086 priv->msix_ctl.pool_bm &= ~(1ULL << i); 1086 priv->msix_ctl.pool_bm &= ~(1ULL << i);
1087 } 1087 }
1088 spin_unlock(&priv->msix_ctl.pool_lock); 1088 mutex_unlock(&priv->msix_ctl.pool_lock);
1089 } 1089 }
1090 1090
1091} 1091}
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 8a21e10952ea..9ea7cabcaf3c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -685,7 +685,7 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
685 return err; 685 return err;
686} 686}
687 687
688static int mlx4_QUERY_PORT(struct mlx4_dev *dev, void *ptr, u8 port) 688int mlx4_QUERY_PORT(struct mlx4_dev *dev, void *ptr, u8 port)
689{ 689{
690 struct mlx4_cmd_mailbox *outbox = ptr; 690 struct mlx4_cmd_mailbox *outbox = ptr;
691 691
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 678558b502fc..d498f049c74e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -531,15 +531,14 @@ int mlx4_change_port_types(struct mlx4_dev *dev,
531 for (port = 0; port < dev->caps.num_ports; port++) { 531 for (port = 0; port < dev->caps.num_ports; port++) {
532 /* Change the port type only if the new type is different 532 /* Change the port type only if the new type is different
533 * from the current, and not set to Auto */ 533 * from the current, and not set to Auto */
534 if (port_types[port] != dev->caps.port_type[port + 1]) { 534 if (port_types[port] != dev->caps.port_type[port + 1])
535 change = 1; 535 change = 1;
536 dev->caps.port_type[port + 1] = port_types[port];
537 }
538 } 536 }
539 if (change) { 537 if (change) {
540 mlx4_unregister_device(dev); 538 mlx4_unregister_device(dev);
541 for (port = 1; port <= dev->caps.num_ports; port++) { 539 for (port = 1; port <= dev->caps.num_ports; port++) {
542 mlx4_CLOSE_PORT(dev, port); 540 mlx4_CLOSE_PORT(dev, port);
541 dev->caps.port_type[port] = port_types[port - 1];
543 err = mlx4_SET_PORT(dev, port); 542 err = mlx4_SET_PORT(dev, port);
544 if (err) { 543 if (err) {
545 mlx4_err(dev, "Failed to set port %d, " 544 mlx4_err(dev, "Failed to set port %d, "
@@ -986,6 +985,9 @@ static int map_bf_area(struct mlx4_dev *dev)
986 resource_size_t bf_len; 985 resource_size_t bf_len;
987 int err = 0; 986 int err = 0;
988 987
988 if (!dev->caps.bf_reg_size)
989 return -ENXIO;
990
989 bf_start = pci_resource_start(dev->pdev, 2) + 991 bf_start = pci_resource_start(dev->pdev, 2) +
990 (dev->caps.num_uars << PAGE_SHIFT); 992 (dev->caps.num_uars << PAGE_SHIFT);
991 bf_len = pci_resource_len(dev->pdev, 2) - 993 bf_len = pci_resource_len(dev->pdev, 2) -
@@ -1825,7 +1827,7 @@ slave_start:
1825 goto err_master_mfunc; 1827 goto err_master_mfunc;
1826 1828
1827 priv->msix_ctl.pool_bm = 0; 1829 priv->msix_ctl.pool_bm = 0;
1828 spin_lock_init(&priv->msix_ctl.pool_lock); 1830 mutex_init(&priv->msix_ctl.pool_lock);
1829 1831
1830 mlx4_enable_msi_x(dev); 1832 mlx4_enable_msi_x(dev);
1831 if ((mlx4_is_mfunc(dev)) && 1833 if ((mlx4_is_mfunc(dev)) &&
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index c92269f8c057..28f8251561f4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -697,7 +697,7 @@ struct mlx4_sense {
697 697
698struct mlx4_msix_ctl { 698struct mlx4_msix_ctl {
699 u64 pool_bm; 699 u64 pool_bm;
700 spinlock_t pool_lock; 700 struct mutex pool_lock;
701}; 701};
702 702
703struct mlx4_steer { 703struct mlx4_steer {
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c
index 8deeef98280c..25a80d71fb2a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mr.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
@@ -304,7 +304,7 @@ static int mlx4_HW2SW_MPT(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox
304 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); 304 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED);
305} 305}
306 306
307static int mlx4_mr_reserve_range(struct mlx4_dev *dev, int cnt, int align, 307int mlx4_mr_reserve_range(struct mlx4_dev *dev, int cnt, int align,
308 u32 *base_mridx) 308 u32 *base_mridx)
309{ 309{
310 struct mlx4_priv *priv = mlx4_priv(dev); 310 struct mlx4_priv *priv = mlx4_priv(dev);
@@ -320,14 +320,14 @@ static int mlx4_mr_reserve_range(struct mlx4_dev *dev, int cnt, int align,
320} 320}
321EXPORT_SYMBOL_GPL(mlx4_mr_reserve_range); 321EXPORT_SYMBOL_GPL(mlx4_mr_reserve_range);
322 322
323static void mlx4_mr_release_range(struct mlx4_dev *dev, u32 base_mridx, int cnt) 323void mlx4_mr_release_range(struct mlx4_dev *dev, u32 base_mridx, int cnt)
324{ 324{
325 struct mlx4_priv *priv = mlx4_priv(dev); 325 struct mlx4_priv *priv = mlx4_priv(dev);
326 mlx4_bitmap_free_range(&priv->mr_table.mpt_bitmap, base_mridx, cnt); 326 mlx4_bitmap_free_range(&priv->mr_table.mpt_bitmap, base_mridx, cnt);
327} 327}
328EXPORT_SYMBOL_GPL(mlx4_mr_release_range); 328EXPORT_SYMBOL_GPL(mlx4_mr_release_range);
329 329
330static int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd, 330int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd,
331 u64 iova, u64 size, u32 access, int npages, 331 u64 iova, u64 size, u32 access, int npages,
332 int page_shift, struct mlx4_mr *mr) 332 int page_shift, struct mlx4_mr *mr)
333{ 333{
@@ -457,7 +457,7 @@ int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access,
457} 457}
458EXPORT_SYMBOL_GPL(mlx4_mr_alloc); 458EXPORT_SYMBOL_GPL(mlx4_mr_alloc);
459 459
460static void mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr) 460void mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr)
461{ 461{
462 int err; 462 int err;
463 463
@@ -852,7 +852,7 @@ err_free:
852} 852}
853EXPORT_SYMBOL_GPL(mlx4_fmr_alloc); 853EXPORT_SYMBOL_GPL(mlx4_fmr_alloc);
854 854
855static int mlx4_fmr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, 855int mlx4_fmr_alloc_reserved(struct mlx4_dev *dev, u32 mridx,
856 u32 pd, u32 access, int max_pages, 856 u32 pd, u32 access, int max_pages,
857 int max_maps, u8 page_shift, struct mlx4_fmr *fmr) 857 int max_maps, u8 page_shift, struct mlx4_fmr *fmr)
858{ 858{
@@ -954,7 +954,7 @@ int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr)
954} 954}
955EXPORT_SYMBOL_GPL(mlx4_fmr_free); 955EXPORT_SYMBOL_GPL(mlx4_fmr_free);
956 956
957static int mlx4_fmr_free_reserved(struct mlx4_dev *dev, struct mlx4_fmr *fmr) 957int mlx4_fmr_free_reserved(struct mlx4_dev *dev, struct mlx4_fmr *fmr)
958{ 958{
959 if (fmr->maps) 959 if (fmr->maps)
960 return -EBUSY; 960 return -EBUSY;
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index 231176fcd2ba..2784bc706f1e 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -1545,7 +1545,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1545 1545
1546 netdev->irq = platform_get_irq(pdev, 0); 1546 netdev->irq = platform_get_irq(pdev, 0);
1547 1547
1548 if (netdev->irq < 0) { 1548 if ((int)netdev->irq < 0) {
1549 err = netdev->irq; 1549 err = netdev->irq;
1550 goto err_get_irq; 1550 goto err_get_irq;
1551 } 1551 }
diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c
index aca349861767..fc52fca74193 100644
--- a/drivers/net/ethernet/sfc/rx.c
+++ b/drivers/net/ethernet/sfc/rx.c
@@ -156,11 +156,10 @@ static int efx_init_rx_buffers_skb(struct efx_rx_queue *rx_queue)
156 if (unlikely(!skb)) 156 if (unlikely(!skb))
157 return -ENOMEM; 157 return -ENOMEM;
158 158
159 /* Adjust the SKB for padding and checksum */ 159 /* Adjust the SKB for padding */
160 skb_reserve(skb, NET_IP_ALIGN); 160 skb_reserve(skb, NET_IP_ALIGN);
161 rx_buf->len = skb_len - NET_IP_ALIGN; 161 rx_buf->len = skb_len - NET_IP_ALIGN;
162 rx_buf->is_page = false; 162 rx_buf->is_page = false;
163 skb->ip_summed = CHECKSUM_UNNECESSARY;
164 163
165 rx_buf->dma_addr = pci_map_single(efx->pci_dev, 164 rx_buf->dma_addr = pci_map_single(efx->pci_dev,
166 skb->data, rx_buf->len, 165 skb->data, rx_buf->len,
@@ -496,6 +495,7 @@ static void efx_rx_packet_gro(struct efx_channel *channel,
496 495
497 EFX_BUG_ON_PARANOID(!checksummed); 496 EFX_BUG_ON_PARANOID(!checksummed);
498 rx_buf->u.skb = NULL; 497 rx_buf->u.skb = NULL;
498 skb->ip_summed = CHECKSUM_UNNECESSARY;
499 499
500 gro_result = napi_gro_receive(napi, skb); 500 gro_result = napi_gro_receive(napi, skb);
501 } 501 }
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 4fa0bcb25dfc..4b2f54565f64 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1009,7 +1009,7 @@ static void emac_rx_handler(void *token, int len, int status)
1009 int ret; 1009 int ret;
1010 1010
1011 /* free and bail if we are shutting down */ 1011 /* free and bail if we are shutting down */
1012 if (unlikely(!netif_running(ndev) || !netif_carrier_ok(ndev))) { 1012 if (unlikely(!netif_running(ndev))) {
1013 dev_kfree_skb_any(skb); 1013 dev_kfree_skb_any(skb);
1014 return; 1014 return;
1015 } 1015 }
@@ -1038,7 +1038,9 @@ static void emac_rx_handler(void *token, int len, int status)
1038recycle: 1038recycle:
1039 ret = cpdma_chan_submit(priv->rxchan, skb, skb->data, 1039 ret = cpdma_chan_submit(priv->rxchan, skb, skb->data,
1040 skb_tailroom(skb), GFP_KERNEL); 1040 skb_tailroom(skb), GFP_KERNEL);
1041 if (WARN_ON(ret < 0)) 1041
1042 WARN_ON(ret == -ENOMEM);
1043 if (unlikely(ret < 0))
1042 dev_kfree_skb_any(skb); 1044 dev_kfree_skb_any(skb);
1043} 1045}
1044 1046
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index c81f136ae670..0856e1b7a849 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -30,16 +30,16 @@
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32 32
33MODULE_DESCRIPTION("ICPlus IP175C/IP101A/IC1001 PHY drivers"); 33MODULE_DESCRIPTION("ICPlus IP175C/IP101A/IP101G/IC1001 PHY drivers");
34MODULE_AUTHOR("Michael Barkowski"); 34MODULE_AUTHOR("Michael Barkowski");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
36 36
37/* IP101A/IP1001 */ 37/* IP101A/G - IP1001 */
38#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */ 38#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */
39#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */ 39#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */
40#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */ 40#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */
41#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */ 41#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */
42#define IP101A_APS_ON 2 /* IP101A APS Mode bit */ 42#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */
43 43
44static int ip175c_config_init(struct phy_device *phydev) 44static int ip175c_config_init(struct phy_device *phydev)
45{ 45{
@@ -98,20 +98,24 @@ static int ip175c_config_init(struct phy_device *phydev)
98 98
99static int ip1xx_reset(struct phy_device *phydev) 99static int ip1xx_reset(struct phy_device *phydev)
100{ 100{
101 int err, bmcr; 101 int bmcr;
102 102
103 /* Software Reset PHY */ 103 /* Software Reset PHY */
104 bmcr = phy_read(phydev, MII_BMCR); 104 bmcr = phy_read(phydev, MII_BMCR);
105 if (bmcr < 0)
106 return bmcr;
105 bmcr |= BMCR_RESET; 107 bmcr |= BMCR_RESET;
106 err = phy_write(phydev, MII_BMCR, bmcr); 108 bmcr = phy_write(phydev, MII_BMCR, bmcr);
107 if (err < 0) 109 if (bmcr < 0)
108 return err; 110 return bmcr;
109 111
110 do { 112 do {
111 bmcr = phy_read(phydev, MII_BMCR); 113 bmcr = phy_read(phydev, MII_BMCR);
114 if (bmcr < 0)
115 return bmcr;
112 } while (bmcr & BMCR_RESET); 116 } while (bmcr & BMCR_RESET);
113 117
114 return err; 118 return 0;
115} 119}
116 120
117static int ip1001_config_init(struct phy_device *phydev) 121static int ip1001_config_init(struct phy_device *phydev)
@@ -124,7 +128,10 @@ static int ip1001_config_init(struct phy_device *phydev)
124 128
125 /* Enable Auto Power Saving mode */ 129 /* Enable Auto Power Saving mode */
126 c = phy_read(phydev, IP1001_SPEC_CTRL_STATUS_2); 130 c = phy_read(phydev, IP1001_SPEC_CTRL_STATUS_2);
131 if (c < 0)
132 return c;
127 c |= IP1001_APS_ON; 133 c |= IP1001_APS_ON;
134 c = phy_write(phydev, IP1001_SPEC_CTRL_STATUS_2, c);
128 if (c < 0) 135 if (c < 0)
129 return c; 136 return c;
130 137
@@ -132,14 +139,19 @@ static int ip1001_config_init(struct phy_device *phydev)
132 /* Additional delay (2ns) used to adjust RX clock phase 139 /* Additional delay (2ns) used to adjust RX clock phase
133 * at RGMII interface */ 140 * at RGMII interface */
134 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 141 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
142 if (c < 0)
143 return c;
144
135 c |= IP1001_PHASE_SEL_MASK; 145 c |= IP1001_PHASE_SEL_MASK;
136 c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c); 146 c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c);
147 if (c < 0)
148 return c;
137 } 149 }
138 150
139 return c; 151 return 0;
140} 152}
141 153
142static int ip101a_config_init(struct phy_device *phydev) 154static int ip101a_g_config_init(struct phy_device *phydev)
143{ 155{
144 int c; 156 int c;
145 157
@@ -149,7 +161,7 @@ static int ip101a_config_init(struct phy_device *phydev)
149 161
150 /* Enable Auto Power Saving mode */ 162 /* Enable Auto Power Saving mode */
151 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 163 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
152 c |= IP101A_APS_ON; 164 c |= IP101A_G_APS_ON;
153 return c; 165 return c;
154} 166}
155 167
@@ -191,6 +203,7 @@ static struct phy_driver ip1001_driver = {
191 .phy_id_mask = 0x0ffffff0, 203 .phy_id_mask = 0x0ffffff0,
192 .features = PHY_GBIT_FEATURES | SUPPORTED_Pause | 204 .features = PHY_GBIT_FEATURES | SUPPORTED_Pause |
193 SUPPORTED_Asym_Pause, 205 SUPPORTED_Asym_Pause,
206 .flags = PHY_HAS_INTERRUPT,
194 .config_init = &ip1001_config_init, 207 .config_init = &ip1001_config_init,
195 .config_aneg = &genphy_config_aneg, 208 .config_aneg = &genphy_config_aneg,
196 .read_status = &genphy_read_status, 209 .read_status = &genphy_read_status,
@@ -199,13 +212,14 @@ static struct phy_driver ip1001_driver = {
199 .driver = { .owner = THIS_MODULE,}, 212 .driver = { .owner = THIS_MODULE,},
200}; 213};
201 214
202static struct phy_driver ip101a_driver = { 215static struct phy_driver ip101a_g_driver = {
203 .phy_id = 0x02430c54, 216 .phy_id = 0x02430c54,
204 .name = "ICPlus IP101A", 217 .name = "ICPlus IP101A/G",
205 .phy_id_mask = 0x0ffffff0, 218 .phy_id_mask = 0x0ffffff0,
206 .features = PHY_BASIC_FEATURES | SUPPORTED_Pause | 219 .features = PHY_BASIC_FEATURES | SUPPORTED_Pause |
207 SUPPORTED_Asym_Pause, 220 SUPPORTED_Asym_Pause,
208 .config_init = &ip101a_config_init, 221 .flags = PHY_HAS_INTERRUPT,
222 .config_init = &ip101a_g_config_init,
209 .config_aneg = &genphy_config_aneg, 223 .config_aneg = &genphy_config_aneg,
210 .read_status = &genphy_read_status, 224 .read_status = &genphy_read_status,
211 .suspend = genphy_suspend, 225 .suspend = genphy_suspend,
@@ -221,7 +235,7 @@ static int __init icplus_init(void)
221 if (ret < 0) 235 if (ret < 0)
222 return -ENODEV; 236 return -ENODEV;
223 237
224 ret = phy_driver_register(&ip101a_driver); 238 ret = phy_driver_register(&ip101a_g_driver);
225 if (ret < 0) 239 if (ret < 0)
226 return -ENODEV; 240 return -ENODEV;
227 241
@@ -231,7 +245,7 @@ static int __init icplus_init(void)
231static void __exit icplus_exit(void) 245static void __exit icplus_exit(void)
232{ 246{
233 phy_driver_unregister(&ip1001_driver); 247 phy_driver_unregister(&ip1001_driver);
234 phy_driver_unregister(&ip101a_driver); 248 phy_driver_unregister(&ip101a_g_driver);
235 phy_driver_unregister(&ip175c_driver); 249 phy_driver_unregister(&ip175c_driver);
236} 250}
237 251
@@ -241,6 +255,7 @@ module_exit(icplus_exit);
241static struct mdio_device_id __maybe_unused icplus_tbl[] = { 255static struct mdio_device_id __maybe_unused icplus_tbl[] = {
242 { 0x02430d80, 0x0ffffff0 }, 256 { 0x02430d80, 0x0ffffff0 },
243 { 0x02430d90, 0x0ffffff0 }, 257 { 0x02430d90, 0x0ffffff0 },
258 { 0x02430c54, 0x0ffffff0 },
244 { } 259 { }
245}; 260};
246 261
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index edfa15d2e795..486b4048850d 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2024,14 +2024,22 @@ ppp_mp_reconstruct(struct ppp *ppp)
2024 continue; 2024 continue;
2025 } 2025 }
2026 if (PPP_MP_CB(p)->sequence != seq) { 2026 if (PPP_MP_CB(p)->sequence != seq) {
2027 u32 oldseq;
2027 /* Fragment `seq' is missing. If it is after 2028 /* Fragment `seq' is missing. If it is after
2028 minseq, it might arrive later, so stop here. */ 2029 minseq, it might arrive later, so stop here. */
2029 if (seq_after(seq, minseq)) 2030 if (seq_after(seq, minseq))
2030 break; 2031 break;
2031 /* Fragment `seq' is lost, keep going. */ 2032 /* Fragment `seq' is lost, keep going. */
2032 lost = 1; 2033 lost = 1;
2034 oldseq = seq;
2033 seq = seq_before(minseq, PPP_MP_CB(p)->sequence)? 2035 seq = seq_before(minseq, PPP_MP_CB(p)->sequence)?
2034 minseq + 1: PPP_MP_CB(p)->sequence; 2036 minseq + 1: PPP_MP_CB(p)->sequence;
2037
2038 if (ppp->debug & 1)
2039 netdev_printk(KERN_DEBUG, ppp->dev,
2040 "lost frag %u..%u\n",
2041 oldseq, seq-1);
2042
2035 goto again; 2043 goto again;
2036 } 2044 }
2037 2045
@@ -2076,6 +2084,10 @@ ppp_mp_reconstruct(struct ppp *ppp)
2076 struct sk_buff *tmp2; 2084 struct sk_buff *tmp2;
2077 2085
2078 skb_queue_reverse_walk_from_safe(list, p, tmp2) { 2086 skb_queue_reverse_walk_from_safe(list, p, tmp2) {
2087 if (ppp->debug & 1)
2088 netdev_printk(KERN_DEBUG, ppp->dev,
2089 "discarding frag %u\n",
2090 PPP_MP_CB(p)->sequence);
2079 __skb_unlink(p, list); 2091 __skb_unlink(p, list);
2080 kfree_skb(p); 2092 kfree_skb(p);
2081 } 2093 }
@@ -2091,6 +2103,17 @@ ppp_mp_reconstruct(struct ppp *ppp)
2091 /* If we have discarded any fragments, 2103 /* If we have discarded any fragments,
2092 signal a receive error. */ 2104 signal a receive error. */
2093 if (PPP_MP_CB(head)->sequence != ppp->nextseq) { 2105 if (PPP_MP_CB(head)->sequence != ppp->nextseq) {
2106 skb_queue_walk_safe(list, p, tmp) {
2107 if (p == head)
2108 break;
2109 if (ppp->debug & 1)
2110 netdev_printk(KERN_DEBUG, ppp->dev,
2111 "discarding frag %u\n",
2112 PPP_MP_CB(p)->sequence);
2113 __skb_unlink(p, list);
2114 kfree_skb(p);
2115 }
2116
2094 if (ppp->debug & 1) 2117 if (ppp->debug & 1)
2095 netdev_printk(KERN_DEBUG, ppp->dev, 2118 netdev_printk(KERN_DEBUG, ppp->dev,
2096 " missed pkts %u..%u\n", 2119 " missed pkts %u..%u\n",
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 41a61efc331e..90a30026a931 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -573,6 +573,13 @@ static const struct usb_device_id products [] = {
573 .driver_info = 0, 573 .driver_info = 0,
574}, 574},
575 575
576/* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */
577{
578 USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM,
579 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
580 .driver_info = 0,
581},
582
576/* 583/*
577 * WHITELIST!!! 584 * WHITELIST!!!
578 * 585 *
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 304fe78ff60e..e1324b4a0f66 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1632,7 +1632,7 @@ static int hso_get_count(struct tty_struct *tty,
1632 struct hso_serial *serial = get_serial_by_tty(tty); 1632 struct hso_serial *serial = get_serial_by_tty(tty);
1633 struct hso_tiocmget *tiocmget = serial->tiocmget; 1633 struct hso_tiocmget *tiocmget = serial->tiocmget;
1634 1634
1635 memset(&icount, 0, sizeof(struct serial_icounter_struct)); 1635 memset(icount, 0, sizeof(struct serial_icounter_struct));
1636 1636
1637 if (!tiocmget) 1637 if (!tiocmget)
1638 return -ENOENT; 1638 return -ENOENT;
diff --git a/drivers/net/usb/zaurus.c b/drivers/net/usb/zaurus.c
index f701d4127087..c3197ce0e2ad 100644
--- a/drivers/net/usb/zaurus.c
+++ b/drivers/net/usb/zaurus.c
@@ -316,6 +316,11 @@ static const struct usb_device_id products [] = {
316 ZAURUS_MASTER_INTERFACE, 316 ZAURUS_MASTER_INTERFACE,
317 .driver_info = ZAURUS_PXA_INFO, 317 .driver_info = ZAURUS_PXA_INFO,
318}, { 318}, {
319 /* C-750/C-760/C-860/SL-C3000 PDA in MDLM mode */
320 USB_DEVICE_AND_INTERFACE_INFO(0x04DD, 0x9031, USB_CLASS_COMM,
321 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
322 .driver_info = (unsigned long) &bogus_mdlm_info,
323}, {
319 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 324 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
320 | USB_DEVICE_ID_MATCH_DEVICE, 325 | USB_DEVICE_ID_MATCH_DEVICE,
321 .idVendor = 0x04DD, 326 .idVendor = 0x04DD,
@@ -349,6 +354,13 @@ static const struct usb_device_id products [] = {
349 ZAURUS_MASTER_INTERFACE, 354 ZAURUS_MASTER_INTERFACE,
350 .driver_info = OLYMPUS_MXL_INFO, 355 .driver_info = OLYMPUS_MXL_INFO,
351}, 356},
357
358/* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */
359{
360 USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM,
361 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
362 .driver_info = (unsigned long) &bogus_mdlm_info,
363},
352 { }, // END 364 { }, // END
353}; 365};
354MODULE_DEVICE_TABLE(usb, products); 366MODULE_DEVICE_TABLE(usb, products);
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index de7fc345148a..3dcd3857a36c 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -843,8 +843,8 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
843 /* for simplicity, don't copy L4 headers */ 843 /* for simplicity, don't copy L4 headers */
844 ctx->l4_hdr_size = 0; 844 ctx->l4_hdr_size = 0;
845 } 845 }
846 ctx->copy_size = ctx->eth_ip_hdr_size + 846 ctx->copy_size = min(ctx->eth_ip_hdr_size +
847 ctx->l4_hdr_size; 847 ctx->l4_hdr_size, skb->len);
848 } else { 848 } else {
849 ctx->eth_ip_hdr_size = 0; 849 ctx->eth_ip_hdr_size = 0;
850 ctx->l4_hdr_size = 0; 850 ctx->l4_hdr_size = 0;
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 635b592ad961..a427a16bb739 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -1346,7 +1346,7 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1346 fc = hdr->frame_control; 1346 fc = hdr->frame_control;
1347 for (i = 0; i < sc->hw->max_rates; i++) { 1347 for (i = 0; i < sc->hw->max_rates; i++) {
1348 struct ieee80211_tx_rate *rate = &tx_info->status.rates[i]; 1348 struct ieee80211_tx_rate *rate = &tx_info->status.rates[i];
1349 if (!rate->count) 1349 if (rate->idx < 0 || !rate->count)
1350 break; 1350 break;
1351 1351
1352 final_ts_idx = i; 1352 final_ts_idx = i;
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index c3b6c4652cd6..5b2972b43b0e 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -841,7 +841,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
841 ret = mwifiex_set_rf_channel(priv, channel, 841 ret = mwifiex_set_rf_channel(priv, channel,
842 priv->adapter->channel_type); 842 priv->adapter->channel_type);
843 843
844 ret = mwifiex_set_encode(priv, NULL, 0, 0, 1); /* Disable keys */ 844 /* As this is new association, clear locally stored
845 * keys and security related flags */
846 priv->sec_info.wpa_enabled = false;
847 priv->sec_info.wpa2_enabled = false;
848 priv->wep_key_curr_index = 0;
849 ret = mwifiex_set_encode(priv, NULL, 0, 0, 1);
845 850
846 if (mode == NL80211_IFTYPE_ADHOC) { 851 if (mode == NL80211_IFTYPE_ADHOC) {
847 /* "privacy" is set only for ad-hoc mode */ 852 /* "privacy" is set only for ad-hoc mode */
@@ -886,6 +891,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
886 dev_dbg(priv->adapter->dev, 891 dev_dbg(priv->adapter->dev,
887 "info: setting wep encryption" 892 "info: setting wep encryption"
888 " with key len %d\n", sme->key_len); 893 " with key len %d\n", sme->key_len);
894 priv->wep_key_curr_index = sme->key_idx;
889 ret = mwifiex_set_encode(priv, sme->key, sme->key_len, 895 ret = mwifiex_set_encode(priv, sme->key, sme->key_len,
890 sme->key_idx, 0); 896 sme->key_idx, 0);
891 } 897 }
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 53a31c753cb1..20c4557f5abd 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -364,10 +364,7 @@ static void release_controller(struct kref *kref)
364 struct rdac_controller *ctlr; 364 struct rdac_controller *ctlr;
365 ctlr = container_of(kref, struct rdac_controller, kref); 365 ctlr = container_of(kref, struct rdac_controller, kref);
366 366
367 flush_workqueue(kmpath_rdacd);
368 spin_lock(&list_lock);
369 list_del(&ctlr->node); 367 list_del(&ctlr->node);
370 spin_unlock(&list_lock);
371 kfree(ctlr); 368 kfree(ctlr);
372} 369}
373 370
@@ -376,20 +373,17 @@ static struct rdac_controller *get_controller(int index, char *array_name,
376{ 373{
377 struct rdac_controller *ctlr, *tmp; 374 struct rdac_controller *ctlr, *tmp;
378 375
379 spin_lock(&list_lock);
380
381 list_for_each_entry(tmp, &ctlr_list, node) { 376 list_for_each_entry(tmp, &ctlr_list, node) {
382 if ((memcmp(tmp->array_id, array_id, UNIQUE_ID_LEN) == 0) && 377 if ((memcmp(tmp->array_id, array_id, UNIQUE_ID_LEN) == 0) &&
383 (tmp->index == index) && 378 (tmp->index == index) &&
384 (tmp->host == sdev->host)) { 379 (tmp->host == sdev->host)) {
385 kref_get(&tmp->kref); 380 kref_get(&tmp->kref);
386 spin_unlock(&list_lock);
387 return tmp; 381 return tmp;
388 } 382 }
389 } 383 }
390 ctlr = kmalloc(sizeof(*ctlr), GFP_ATOMIC); 384 ctlr = kmalloc(sizeof(*ctlr), GFP_ATOMIC);
391 if (!ctlr) 385 if (!ctlr)
392 goto done; 386 return NULL;
393 387
394 /* initialize fields of controller */ 388 /* initialize fields of controller */
395 memcpy(ctlr->array_id, array_id, UNIQUE_ID_LEN); 389 memcpy(ctlr->array_id, array_id, UNIQUE_ID_LEN);
@@ -405,8 +399,7 @@ static struct rdac_controller *get_controller(int index, char *array_name,
405 INIT_WORK(&ctlr->ms_work, send_mode_select); 399 INIT_WORK(&ctlr->ms_work, send_mode_select);
406 INIT_LIST_HEAD(&ctlr->ms_head); 400 INIT_LIST_HEAD(&ctlr->ms_head);
407 list_add(&ctlr->node, &ctlr_list); 401 list_add(&ctlr->node, &ctlr_list);
408done: 402
409 spin_unlock(&list_lock);
410 return ctlr; 403 return ctlr;
411} 404}
412 405
@@ -517,9 +510,12 @@ static int initialize_controller(struct scsi_device *sdev,
517 index = 0; 510 index = 0;
518 else 511 else
519 index = 1; 512 index = 1;
513
514 spin_lock(&list_lock);
520 h->ctlr = get_controller(index, array_name, array_id, sdev); 515 h->ctlr = get_controller(index, array_name, array_id, sdev);
521 if (!h->ctlr) 516 if (!h->ctlr)
522 err = SCSI_DH_RES_TEMP_UNAVAIL; 517 err = SCSI_DH_RES_TEMP_UNAVAIL;
518 spin_unlock(&list_lock);
523 } 519 }
524 return err; 520 return err;
525} 521}
@@ -906,7 +902,9 @@ static int rdac_bus_attach(struct scsi_device *sdev)
906 return 0; 902 return 0;
907 903
908clean_ctlr: 904clean_ctlr:
905 spin_lock(&list_lock);
909 kref_put(&h->ctlr->kref, release_controller); 906 kref_put(&h->ctlr->kref, release_controller);
907 spin_unlock(&list_lock);
910 908
911failed: 909failed:
912 kfree(scsi_dh_data); 910 kfree(scsi_dh_data);
@@ -921,14 +919,19 @@ static void rdac_bus_detach( struct scsi_device *sdev )
921 struct rdac_dh_data *h; 919 struct rdac_dh_data *h;
922 unsigned long flags; 920 unsigned long flags;
923 921
924 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
925 scsi_dh_data = sdev->scsi_dh_data; 922 scsi_dh_data = sdev->scsi_dh_data;
923 h = (struct rdac_dh_data *) scsi_dh_data->buf;
924 if (h->ctlr && h->ctlr->ms_queued)
925 flush_workqueue(kmpath_rdacd);
926
927 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
926 sdev->scsi_dh_data = NULL; 928 sdev->scsi_dh_data = NULL;
927 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); 929 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
928 930
929 h = (struct rdac_dh_data *) scsi_dh_data->buf; 931 spin_lock(&list_lock);
930 if (h->ctlr) 932 if (h->ctlr)
931 kref_put(&h->ctlr->kref, release_controller); 933 kref_put(&h->ctlr->kref, release_controller);
934 spin_unlock(&list_lock);
932 kfree(scsi_dh_data); 935 kfree(scsi_dh_data);
933 module_put(THIS_MODULE); 936 module_put(THIS_MODULE);
934 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME); 937 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 67b169b7a5be..b538f0883fd2 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -4613,11 +4613,13 @@ static int __ipr_eh_host_reset(struct scsi_cmnd * scsi_cmd)
4613 ENTER; 4613 ENTER;
4614 ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata; 4614 ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata;
4615 4615
4616 dev_err(&ioa_cfg->pdev->dev, 4616 if (!ioa_cfg->in_reset_reload) {
4617 "Adapter being reset as a result of error recovery.\n"); 4617 dev_err(&ioa_cfg->pdev->dev,
4618 "Adapter being reset as a result of error recovery.\n");
4618 4619
4619 if (WAIT_FOR_DUMP == ioa_cfg->sdt_state) 4620 if (WAIT_FOR_DUMP == ioa_cfg->sdt_state)
4620 ioa_cfg->sdt_state = GET_DUMP; 4621 ioa_cfg->sdt_state = GET_DUMP;
4622 }
4621 4623
4622 rc = ipr_reset_reload(ioa_cfg, IPR_SHUTDOWN_ABBREV); 4624 rc = ipr_reset_reload(ioa_cfg, IPR_SHUTDOWN_ABBREV);
4623 4625
@@ -4907,7 +4909,7 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd)
4907 struct ipr_ioa_cfg *ioa_cfg; 4909 struct ipr_ioa_cfg *ioa_cfg;
4908 struct ipr_resource_entry *res; 4910 struct ipr_resource_entry *res;
4909 struct ipr_cmd_pkt *cmd_pkt; 4911 struct ipr_cmd_pkt *cmd_pkt;
4910 u32 ioasc; 4912 u32 ioasc, int_reg;
4911 int op_found = 0; 4913 int op_found = 0;
4912 4914
4913 ENTER; 4915 ENTER;
@@ -4920,7 +4922,17 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd)
4920 */ 4922 */
4921 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead) 4923 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead)
4922 return FAILED; 4924 return FAILED;
4923 if (!res || !ipr_is_gscsi(res)) 4925 if (!res)
4926 return FAILED;
4927
4928 /*
4929 * If we are aborting a timed out op, chances are that the timeout was caused
4930 * by a still not detected EEH error. In such cases, reading a register will
4931 * trigger the EEH recovery infrastructure.
4932 */
4933 int_reg = readl(ioa_cfg->regs.sense_interrupt_reg);
4934
4935 if (!ipr_is_gscsi(res))
4924 return FAILED; 4936 return FAILED;
4925 4937
4926 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { 4938 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index 1a65d6514237..418391b1c361 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -1848,9 +1848,11 @@ static enum sci_status sci_oem_parameters_set(struct isci_host *ihost)
1848 if (state == SCIC_RESET || 1848 if (state == SCIC_RESET ||
1849 state == SCIC_INITIALIZING || 1849 state == SCIC_INITIALIZING ||
1850 state == SCIC_INITIALIZED) { 1850 state == SCIC_INITIALIZED) {
1851 u8 oem_version = pci_info->orom ? pci_info->orom->hdr.version :
1852 ISCI_ROM_VER_1_0;
1851 1853
1852 if (sci_oem_parameters_validate(&ihost->oem_parameters, 1854 if (sci_oem_parameters_validate(&ihost->oem_parameters,
1853 pci_info->orom->hdr.version)) 1855 oem_version))
1854 return SCI_FAILURE_INVALID_PARAMETER_VALUE; 1856 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
1855 1857
1856 return SCI_SUCCESS; 1858 return SCI_SUCCESS;
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 0b2c95583660..a78036f5e1a6 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -4548,7 +4548,7 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
4548 printk(MPT2SAS_ERR_FMT "%s: pci error recovery reset\n", 4548 printk(MPT2SAS_ERR_FMT "%s: pci error recovery reset\n",
4549 ioc->name, __func__); 4549 ioc->name, __func__);
4550 r = 0; 4550 r = 0;
4551 goto out; 4551 goto out_unlocked;
4552 } 4552 }
4553 4553
4554 if (mpt2sas_fwfault_debug) 4554 if (mpt2sas_fwfault_debug)
@@ -4604,6 +4604,7 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
4604 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); 4604 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
4605 mutex_unlock(&ioc->reset_in_progress_mutex); 4605 mutex_unlock(&ioc->reset_in_progress_mutex);
4606 4606
4607 out_unlocked:
4607 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: exit\n", ioc->name, 4608 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: exit\n", ioc->name,
4608 __func__)); 4609 __func__));
4609 return r; 4610 return r;
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index a2f1b3043dfb..9f41b3b4358f 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1036,8 +1036,7 @@ qla2x00_link_state_show(struct device *dev, struct device_attribute *attr,
1036 vha->device_flags & DFLG_NO_CABLE) 1036 vha->device_flags & DFLG_NO_CABLE)
1037 len = snprintf(buf, PAGE_SIZE, "Link Down\n"); 1037 len = snprintf(buf, PAGE_SIZE, "Link Down\n");
1038 else if (atomic_read(&vha->loop_state) != LOOP_READY || 1038 else if (atomic_read(&vha->loop_state) != LOOP_READY ||
1039 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 1039 qla2x00_reset_active(vha))
1040 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
1041 len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n"); 1040 len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n");
1042 else { 1041 else {
1043 len = snprintf(buf, PAGE_SIZE, "Link Up - "); 1042 len = snprintf(buf, PAGE_SIZE, "Link Up - ");
@@ -1359,8 +1358,7 @@ qla2x00_thermal_temp_show(struct device *dev,
1359 return snprintf(buf, PAGE_SIZE, "\n"); 1358 return snprintf(buf, PAGE_SIZE, "\n");
1360 1359
1361 temp = frac = 0; 1360 temp = frac = 0;
1362 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 1361 if (qla2x00_reset_active(vha))
1363 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
1364 ql_log(ql_log_warn, vha, 0x707b, 1362 ql_log(ql_log_warn, vha, 0x707b,
1365 "ISP reset active.\n"); 1363 "ISP reset active.\n");
1366 else if (!vha->hw->flags.eeh_busy) 1364 else if (!vha->hw->flags.eeh_busy)
@@ -1379,8 +1377,7 @@ qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
1379 int rval = QLA_FUNCTION_FAILED; 1377 int rval = QLA_FUNCTION_FAILED;
1380 uint16_t state[5]; 1378 uint16_t state[5];
1381 1379
1382 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 1380 if (qla2x00_reset_active(vha))
1383 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
1384 ql_log(ql_log_warn, vha, 0x707c, 1381 ql_log(ql_log_warn, vha, 0x707c,
1385 "ISP reset active.\n"); 1382 "ISP reset active.\n");
1386 else if (!vha->hw->flags.eeh_busy) 1383 else if (!vha->hw->flags.eeh_busy)
@@ -1693,9 +1690,7 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1693 if (IS_FWI2_CAPABLE(ha)) { 1690 if (IS_FWI2_CAPABLE(ha)) {
1694 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma); 1691 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma);
1695 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY && 1692 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
1696 !test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) && 1693 !qla2x00_reset_active(vha) && !ha->dpc_active) {
1697 !test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) &&
1698 !ha->dpc_active) {
1699 /* Must be in a 'READY' state for statistics retrieval. */ 1694 /* Must be in a 'READY' state for statistics retrieval. */
1700 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id, 1695 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id,
1701 stats, stats_dma); 1696 stats, stats_dma);
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index b1d0f936bf2d..1682e2e4201d 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -108,13 +108,6 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job *bsg_job)
108 goto exit_fcp_prio_cfg; 108 goto exit_fcp_prio_cfg;
109 } 109 }
110 110
111 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
112 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
113 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
114 ret = -EBUSY;
115 goto exit_fcp_prio_cfg;
116 }
117
118 /* Get the sub command */ 111 /* Get the sub command */
119 oper = bsg_job->request->rqst_data.h_vendor.vendor_cmd[1]; 112 oper = bsg_job->request->rqst_data.h_vendor.vendor_cmd[1];
120 113
@@ -646,13 +639,6 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
646 dma_addr_t rsp_data_dma; 639 dma_addr_t rsp_data_dma;
647 uint32_t rsp_data_len; 640 uint32_t rsp_data_len;
648 641
649 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
650 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
651 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
652 ql_log(ql_log_warn, vha, 0x7018, "Abort active or needed.\n");
653 return -EBUSY;
654 }
655
656 if (!vha->flags.online) { 642 if (!vha->flags.online) {
657 ql_log(ql_log_warn, vha, 0x7019, "Host is not online.\n"); 643 ql_log(ql_log_warn, vha, 0x7019, "Host is not online.\n");
658 return -EIO; 644 return -EIO;
@@ -874,13 +860,6 @@ qla84xx_reset(struct fc_bsg_job *bsg_job)
874 int rval = 0; 860 int rval = 0;
875 uint32_t flag; 861 uint32_t flag;
876 862
877 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
878 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
879 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
880 ql_log(ql_log_warn, vha, 0x702e, "Abort active or needed.\n");
881 return -EBUSY;
882 }
883
884 if (!IS_QLA84XX(ha)) { 863 if (!IS_QLA84XX(ha)) {
885 ql_dbg(ql_dbg_user, vha, 0x702f, "Not 84xx, exiting.\n"); 864 ql_dbg(ql_dbg_user, vha, 0x702f, "Not 84xx, exiting.\n");
886 return -EINVAL; 865 return -EINVAL;
@@ -922,11 +901,6 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
922 uint32_t flag; 901 uint32_t flag;
923 uint32_t fw_ver; 902 uint32_t fw_ver;
924 903
925 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
926 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
927 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags))
928 return -EBUSY;
929
930 if (!IS_QLA84XX(ha)) { 904 if (!IS_QLA84XX(ha)) {
931 ql_dbg(ql_dbg_user, vha, 0x7032, 905 ql_dbg(ql_dbg_user, vha, 0x7032,
932 "Not 84xx, exiting.\n"); 906 "Not 84xx, exiting.\n");
@@ -1036,14 +1010,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1036 uint32_t data_len = 0; 1010 uint32_t data_len = 0;
1037 uint32_t dma_direction = DMA_NONE; 1011 uint32_t dma_direction = DMA_NONE;
1038 1012
1039 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
1040 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
1041 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
1042 ql_log(ql_log_warn, vha, 0x7039,
1043 "Abort active or needed.\n");
1044 return -EBUSY;
1045 }
1046
1047 if (!IS_QLA84XX(ha)) { 1013 if (!IS_QLA84XX(ha)) {
1048 ql_log(ql_log_warn, vha, 0x703a, 1014 ql_log(ql_log_warn, vha, 0x703a,
1049 "Not 84xx, exiting.\n"); 1015 "Not 84xx, exiting.\n");
@@ -1246,13 +1212,6 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
1246 1212
1247 bsg_job->reply->reply_payload_rcv_len = 0; 1213 bsg_job->reply->reply_payload_rcv_len = 0;
1248 1214
1249 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
1250 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
1251 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
1252 ql_log(ql_log_warn, vha, 0x7045, "abort active or needed.\n");
1253 return -EBUSY;
1254 }
1255
1256 if (!IS_IIDMA_CAPABLE(vha->hw)) { 1215 if (!IS_IIDMA_CAPABLE(vha->hw)) {
1257 ql_log(ql_log_info, vha, 0x7046, "iiDMA not supported.\n"); 1216 ql_log(ql_log_info, vha, 0x7046, "iiDMA not supported.\n");
1258 return -EINVAL; 1217 return -EINVAL;
@@ -1668,6 +1627,15 @@ qla24xx_bsg_request(struct fc_bsg_job *bsg_job)
1668 vha = shost_priv(host); 1627 vha = shost_priv(host);
1669 } 1628 }
1670 1629
1630 if (qla2x00_reset_active(vha)) {
1631 ql_dbg(ql_dbg_user, vha, 0x709f,
1632 "BSG: ISP abort active/needed -- cmd=%d.\n",
1633 bsg_job->request->msgcode);
1634 bsg_job->reply->result = (DID_ERROR << 16);
1635 bsg_job->job_done(bsg_job);
1636 return -EBUSY;
1637 }
1638
1671 ql_dbg(ql_dbg_user, vha, 0x7000, 1639 ql_dbg(ql_dbg_user, vha, 0x7000,
1672 "Entered %s msgcode=0x%x.\n", __func__, bsg_job->request->msgcode); 1640 "Entered %s msgcode=0x%x.\n", __func__, bsg_job->request->msgcode);
1673 1641
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 7c54624b5b13..45cbf0ba624d 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -19,7 +19,8 @@
19 * | DPC Thread | 0x401c | | 19 * | DPC Thread | 0x401c | |
20 * | Async Events | 0x5057 | 0x5052 | 20 * | Async Events | 0x5057 | 0x5052 |
21 * | Timer Routines | 0x6011 | 0x600e,0x600f | 21 * | Timer Routines | 0x6011 | 0x600e,0x600f |
22 * | User Space Interactions | 0x709e | | 22 * | User Space Interactions | 0x709e | 0x7018,0x702e |
23 * | | | 0x7039,0x7045 |
23 * | Task Management | 0x803c | 0x8025-0x8026 | 24 * | Task Management | 0x803c | 0x8025-0x8026 |
24 * | | | 0x800b,0x8039 | 25 * | | | 0x800b,0x8039 |
25 * | AER/EEH | 0x900f | | 26 * | AER/EEH | 0x900f | |
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index a6a4eebce4a8..af1003f9de1e 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -44,6 +44,7 @@
44 * ISP2100 HBAs. 44 * ISP2100 HBAs.
45 */ 45 */
46#define MAILBOX_REGISTER_COUNT_2100 8 46#define MAILBOX_REGISTER_COUNT_2100 8
47#define MAILBOX_REGISTER_COUNT_2200 24
47#define MAILBOX_REGISTER_COUNT 32 48#define MAILBOX_REGISTER_COUNT 32
48 49
49#define QLA2200A_RISC_ROM_VER 4 50#define QLA2200A_RISC_ROM_VER 4
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index 9902834e0b74..7cc4f36cd539 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -131,3 +131,16 @@ qla2x00_hba_err_chk_enabled(srb_t *sp)
131 } 131 }
132 return 0; 132 return 0;
133} 133}
134
135static inline int
136qla2x00_reset_active(scsi_qla_host_t *vha)
137{
138 scsi_qla_host_t *base_vha = pci_get_drvdata(vha->hw->pdev);
139
140 /* Test appropriate base-vha and vha flags. */
141 return test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) ||
142 test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
143 test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
144 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
145 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags);
146}
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index e804585cc59c..349843ea32f6 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2090,7 +2090,6 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
2090 break; 2090 break;
2091 case CT_IOCB_TYPE: 2091 case CT_IOCB_TYPE:
2092 qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); 2092 qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE);
2093 clear_bit(MBX_INTERRUPT, &vha->hw->mbx_cmd_flags);
2094 break; 2093 break;
2095 case ELS_IOCB_TYPE: 2094 case ELS_IOCB_TYPE:
2096 qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE); 2095 qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE);
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 34344d3f8658..08f1d01bdc1c 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -342,6 +342,8 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
342 342
343 set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); 343 set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags);
344 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); 344 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
345 /* Allow next mbx cmd to come in. */
346 complete(&ha->mbx_cmd_comp);
345 if (ha->isp_ops->abort_isp(vha)) { 347 if (ha->isp_ops->abort_isp(vha)) {
346 /* Failed. retry later. */ 348 /* Failed. retry later. */
347 set_bit(ISP_ABORT_NEEDED, 349 set_bit(ISP_ABORT_NEEDED,
@@ -350,6 +352,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
350 clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); 352 clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags);
351 ql_dbg(ql_dbg_mbx, base_vha, 0x101f, 353 ql_dbg(ql_dbg_mbx, base_vha, 0x101f,
352 "Finished abort_isp.\n"); 354 "Finished abort_isp.\n");
355 goto mbx_done;
353 } 356 }
354 } 357 }
355 } 358 }
@@ -358,6 +361,7 @@ premature_exit:
358 /* Allow next mbx cmd to come in. */ 361 /* Allow next mbx cmd to come in. */
359 complete(&ha->mbx_cmd_comp); 362 complete(&ha->mbx_cmd_comp);
360 363
364mbx_done:
361 if (rval) { 365 if (rval) {
362 ql_dbg(ql_dbg_mbx, base_vha, 0x1020, 366 ql_dbg(ql_dbg_mbx, base_vha, 0x1020,
363 "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, cmd=%x ****.\n", 367 "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, cmd=%x ****.\n",
@@ -2581,7 +2585,8 @@ qla2x00_stop_firmware(scsi_qla_host_t *vha)
2581 ql_dbg(ql_dbg_mbx, vha, 0x10a1, "Entered %s.\n", __func__); 2585 ql_dbg(ql_dbg_mbx, vha, 0x10a1, "Entered %s.\n", __func__);
2582 2586
2583 mcp->mb[0] = MBC_STOP_FIRMWARE; 2587 mcp->mb[0] = MBC_STOP_FIRMWARE;
2584 mcp->out_mb = MBX_0; 2588 mcp->mb[1] = 0;
2589 mcp->out_mb = MBX_1|MBX_0;
2585 mcp->in_mb = MBX_0; 2590 mcp->in_mb = MBX_0;
2586 mcp->tov = 5; 2591 mcp->tov = 5;
2587 mcp->flags = 0; 2592 mcp->flags = 0;
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
index 1cd46cd7ff90..270ba3130fde 100644
--- a/drivers/scsi/qla2xxx/qla_nx.c
+++ b/drivers/scsi/qla2xxx/qla_nx.c
@@ -1165,19 +1165,6 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
1165 qla82xx_wr_32(ha, QLA82XX_ROMUSB_GLB_SW_RESET, 0xfeffffff); 1165 qla82xx_wr_32(ha, QLA82XX_ROMUSB_GLB_SW_RESET, 0xfeffffff);
1166 else 1166 else
1167 qla82xx_wr_32(ha, QLA82XX_ROMUSB_GLB_SW_RESET, 0xffffffff); 1167 qla82xx_wr_32(ha, QLA82XX_ROMUSB_GLB_SW_RESET, 0xffffffff);
1168
1169 /* reset ms */
1170 val = qla82xx_rd_32(ha, QLA82XX_CRB_QDR_NET + 0xe4);
1171 val |= (1 << 1);
1172 qla82xx_wr_32(ha, QLA82XX_CRB_QDR_NET + 0xe4, val);
1173 msleep(20);
1174
1175 /* unreset ms */
1176 val = qla82xx_rd_32(ha, QLA82XX_CRB_QDR_NET + 0xe4);
1177 val &= ~(1 << 1);
1178 qla82xx_wr_32(ha, QLA82XX_CRB_QDR_NET + 0xe4, val);
1179 msleep(20);
1180
1181 qla82xx_rom_unlock(ha); 1168 qla82xx_rom_unlock(ha);
1182 1169
1183 /* Read the signature value from the flash. 1170 /* Read the signature value from the flash.
@@ -3392,7 +3379,7 @@ void qla82xx_watchdog(scsi_qla_host_t *vha)
3392 QLA82XX_CRB_PEG_NET_3 + 0x3c), 3379 QLA82XX_CRB_PEG_NET_3 + 0x3c),
3393 qla82xx_rd_32(ha, 3380 qla82xx_rd_32(ha,
3394 QLA82XX_CRB_PEG_NET_4 + 0x3c)); 3381 QLA82XX_CRB_PEG_NET_4 + 0x3c));
3395 if (LSW(MSB(halt_status)) == 0x67) 3382 if (((halt_status & 0x1fffff00) >> 8) == 0x67)
3396 ql_log(ql_log_warn, vha, 0xb052, 3383 ql_log(ql_log_warn, vha, 0xb052,
3397 "Firmware aborted with " 3384 "Firmware aborted with "
3398 "error code 0x00006700. Device is " 3385 "error code 0x00006700. Device is "
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 4ed1e4a96b95..036030c95339 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -625,6 +625,12 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
625 cmd->result = DID_NO_CONNECT << 16; 625 cmd->result = DID_NO_CONNECT << 16;
626 goto qc24_fail_command; 626 goto qc24_fail_command;
627 } 627 }
628
629 if (!fcport) {
630 cmd->result = DID_NO_CONNECT << 16;
631 goto qc24_fail_command;
632 }
633
628 if (atomic_read(&fcport->state) != FCS_ONLINE) { 634 if (atomic_read(&fcport->state) != FCS_ONLINE) {
629 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || 635 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
630 atomic_read(&base_vha->loop_state) == LOOP_DEAD) { 636 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
@@ -877,6 +883,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
877 883
878 spin_unlock_irqrestore(&ha->hardware_lock, flags); 884 spin_unlock_irqrestore(&ha->hardware_lock, flags);
879 if (ha->isp_ops->abort_command(sp)) { 885 if (ha->isp_ops->abort_command(sp)) {
886 ret = FAILED;
880 ql_dbg(ql_dbg_taskm, vha, 0x8003, 887 ql_dbg(ql_dbg_taskm, vha, 0x8003,
881 "Abort command mbx failed cmd=%p.\n", cmd); 888 "Abort command mbx failed cmd=%p.\n", cmd);
882 } else { 889 } else {
@@ -1124,7 +1131,6 @@ static int
1124qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) 1131qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1125{ 1132{
1126 scsi_qla_host_t *vha = shost_priv(cmd->device->host); 1133 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
1127 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
1128 struct qla_hw_data *ha = vha->hw; 1134 struct qla_hw_data *ha = vha->hw;
1129 int ret = FAILED; 1135 int ret = FAILED;
1130 unsigned int id, lun; 1136 unsigned int id, lun;
@@ -1133,15 +1139,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1133 id = cmd->device->id; 1139 id = cmd->device->id;
1134 lun = cmd->device->lun; 1140 lun = cmd->device->lun;
1135 1141
1136 if (!fcport) {
1137 return ret;
1138 }
1139
1140 ret = fc_block_scsi_eh(cmd);
1141 if (ret != 0)
1142 return ret;
1143 ret = FAILED;
1144
1145 ql_log(ql_log_info, vha, 0x8018, 1142 ql_log(ql_log_info, vha, 0x8018,
1146 "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun); 1143 "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun);
1147 1144
@@ -2047,7 +2044,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2047 ha->nvram_data_off = ~0; 2044 ha->nvram_data_off = ~0;
2048 ha->isp_ops = &qla2100_isp_ops; 2045 ha->isp_ops = &qla2100_isp_ops;
2049 } else if (IS_QLA2200(ha)) { 2046 } else if (IS_QLA2200(ha)) {
2050 ha->mbx_count = MAILBOX_REGISTER_COUNT; 2047 ha->mbx_count = MAILBOX_REGISTER_COUNT_2200;
2051 req_length = REQUEST_ENTRY_CNT_2200; 2048 req_length = REQUEST_ENTRY_CNT_2200;
2052 rsp_length = RESPONSE_ENTRY_CNT_2100; 2049 rsp_length = RESPONSE_ENTRY_CNT_2100;
2053 ha->max_loop_id = SNS_LAST_LOOP_ID_2100; 2050 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 23f33a6d52d7..29d780c38040 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.03.07.12-k" 10#define QLA2XXX_VERSION "8.03.07.13-k"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 3 13#define QLA_DRIVER_MINOR_VER 3
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index bf8bf79e6a1f..c4670642d023 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/pm_runtime.h> 8#include <linux/pm_runtime.h>
9#include <linux/export.h> 9#include <linux/export.h>
10#include <linux/async.h>
10 11
11#include <scsi/scsi.h> 12#include <scsi/scsi.h>
12#include <scsi/scsi_device.h> 13#include <scsi/scsi_device.h>
@@ -92,6 +93,19 @@ static int scsi_bus_resume_common(struct device *dev)
92 return err; 93 return err;
93} 94}
94 95
96static int scsi_bus_prepare(struct device *dev)
97{
98 if (scsi_is_sdev_device(dev)) {
99 /* sd probing uses async_schedule. Wait until it finishes. */
100 async_synchronize_full();
101
102 } else if (scsi_is_host_device(dev)) {
103 /* Wait until async scanning is finished */
104 scsi_complete_async_scans();
105 }
106 return 0;
107}
108
95static int scsi_bus_suspend(struct device *dev) 109static int scsi_bus_suspend(struct device *dev)
96{ 110{
97 return scsi_bus_suspend_common(dev, PMSG_SUSPEND); 111 return scsi_bus_suspend_common(dev, PMSG_SUSPEND);
@@ -110,6 +124,7 @@ static int scsi_bus_poweroff(struct device *dev)
110#else /* CONFIG_PM_SLEEP */ 124#else /* CONFIG_PM_SLEEP */
111 125
112#define scsi_bus_resume_common NULL 126#define scsi_bus_resume_common NULL
127#define scsi_bus_prepare NULL
113#define scsi_bus_suspend NULL 128#define scsi_bus_suspend NULL
114#define scsi_bus_freeze NULL 129#define scsi_bus_freeze NULL
115#define scsi_bus_poweroff NULL 130#define scsi_bus_poweroff NULL
@@ -218,6 +233,7 @@ void scsi_autopm_put_host(struct Scsi_Host *shost)
218#endif /* CONFIG_PM_RUNTIME */ 233#endif /* CONFIG_PM_RUNTIME */
219 234
220const struct dev_pm_ops scsi_bus_pm_ops = { 235const struct dev_pm_ops scsi_bus_pm_ops = {
236 .prepare = scsi_bus_prepare,
221 .suspend = scsi_bus_suspend, 237 .suspend = scsi_bus_suspend,
222 .resume = scsi_bus_resume_common, 238 .resume = scsi_bus_resume_common,
223 .freeze = scsi_bus_freeze, 239 .freeze = scsi_bus_freeze,
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 68eadd1c67fd..be4fa6d179b1 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -109,6 +109,7 @@ extern void scsi_exit_procfs(void);
109#endif /* CONFIG_PROC_FS */ 109#endif /* CONFIG_PROC_FS */
110 110
111/* scsi_scan.c */ 111/* scsi_scan.c */
112extern int scsi_complete_async_scans(void);
112extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int, 113extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
113 unsigned int, unsigned int, int); 114 unsigned int, unsigned int, int);
114extern void scsi_forget_host(struct Scsi_Host *); 115extern void scsi_forget_host(struct Scsi_Host *);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 89da43f73c00..29c4c0480976 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1815,6 +1815,7 @@ static void scsi_finish_async_scan(struct async_scan_data *data)
1815 } 1815 }
1816 spin_unlock(&async_scan_lock); 1816 spin_unlock(&async_scan_lock);
1817 1817
1818 scsi_autopm_put_host(shost);
1818 scsi_host_put(shost); 1819 scsi_host_put(shost);
1819 kfree(data); 1820 kfree(data);
1820} 1821}
@@ -1841,7 +1842,6 @@ static int do_scan_async(void *_data)
1841 1842
1842 do_scsi_scan_host(shost); 1843 do_scsi_scan_host(shost);
1843 scsi_finish_async_scan(data); 1844 scsi_finish_async_scan(data);
1844 scsi_autopm_put_host(shost);
1845 return 0; 1845 return 0;
1846} 1846}
1847 1847
@@ -1869,7 +1869,7 @@ void scsi_scan_host(struct Scsi_Host *shost)
1869 p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no); 1869 p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
1870 if (IS_ERR(p)) 1870 if (IS_ERR(p))
1871 do_scan_async(data); 1871 do_scan_async(data);
1872 /* scsi_autopm_put_host(shost) is called in do_scan_async() */ 1872 /* scsi_autopm_put_host(shost) is called in scsi_finish_async_scan() */
1873} 1873}
1874EXPORT_SYMBOL(scsi_scan_host); 1874EXPORT_SYMBOL(scsi_scan_host);
1875 1875
diff --git a/drivers/sh/clk/cpg.c b/drivers/sh/clk/cpg.c
index 45fee368b092..92d314a73f69 100644
--- a/drivers/sh/clk/cpg.c
+++ b/drivers/sh/clk/cpg.c
@@ -190,7 +190,7 @@ static int __init sh_clk_init_parent(struct clk *clk)
190 return -EINVAL; 190 return -EINVAL;
191 } 191 }
192 192
193 clk->parent = clk->parent_table[val]; 193 clk_reparent(clk, clk->parent_table[val]);
194 if (!clk->parent) { 194 if (!clk->parent) {
195 pr_err("sh_clk_init_parent: unable to set parent"); 195 pr_err("sh_clk_init_parent: unable to set parent");
196 return -EINVAL; 196 return -EINVAL;
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index f9975100d56d..3a3fdc62c75b 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -1061,7 +1061,7 @@ static struct pvr2_board {
1061 int (*init)(void); 1061 int (*init)(void);
1062 void (*exit)(void); 1062 void (*exit)(void);
1063 char name[16]; 1063 char name[16];
1064} board_driver[] = { 1064} board_driver[] __refdata = {
1065#ifdef CONFIG_SH_DREAMCAST 1065#ifdef CONFIG_SH_DREAMCAST
1066 { pvr2fb_dc_init, pvr2fb_dc_exit, "Sega DC PVR2" }, 1066 { pvr2fb_dc_init, pvr2fb_dc_exit, "Sega DC PVR2" },
1067#endif 1067#endif
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index d8d8e7ba6a1e..eb1cc92cd67d 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -110,6 +110,7 @@ struct autofs_sb_info {
110 int sub_version; 110 int sub_version;
111 int min_proto; 111 int min_proto;
112 int max_proto; 112 int max_proto;
113 int compat_daemon;
113 unsigned long exp_timeout; 114 unsigned long exp_timeout;
114 unsigned int type; 115 unsigned int type;
115 int reghost_enabled; 116 int reghost_enabled;
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 76741d8d7786..85f1fcdb30e7 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -385,6 +385,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
385 sbi->pipefd = pipefd; 385 sbi->pipefd = pipefd;
386 sbi->pipe = pipe; 386 sbi->pipe = pipe;
387 sbi->catatonic = 0; 387 sbi->catatonic = 0;
388 sbi->compat_daemon = is_compat_task();
388 } 389 }
389out: 390out:
390 mutex_unlock(&sbi->wq_mutex); 391 mutex_unlock(&sbi->wq_mutex);
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index e16980b00b8d..06858d955120 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -19,6 +19,7 @@
19#include <linux/parser.h> 19#include <linux/parser.h>
20#include <linux/bitops.h> 20#include <linux/bitops.h>
21#include <linux/magic.h> 21#include <linux/magic.h>
22#include <linux/compat.h>
22#include "autofs_i.h" 23#include "autofs_i.h"
23#include <linux/module.h> 24#include <linux/module.h>
24 25
@@ -224,6 +225,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
224 set_autofs_type_indirect(&sbi->type); 225 set_autofs_type_indirect(&sbi->type);
225 sbi->min_proto = 0; 226 sbi->min_proto = 0;
226 sbi->max_proto = 0; 227 sbi->max_proto = 0;
228 sbi->compat_daemon = is_compat_task();
227 mutex_init(&sbi->wq_mutex); 229 mutex_init(&sbi->wq_mutex);
228 mutex_init(&sbi->pipe_mutex); 230 mutex_init(&sbi->pipe_mutex);
229 spin_lock_init(&sbi->fs_lock); 231 spin_lock_init(&sbi->fs_lock);
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index da8876d38a7b..9c098db43344 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -91,7 +91,24 @@ static int autofs4_write(struct autofs_sb_info *sbi,
91 91
92 return (bytes > 0); 92 return (bytes > 0);
93} 93}
94 94
95/*
96 * The autofs_v5 packet was misdesigned.
97 *
98 * The packets are identical on x86-32 and x86-64, but have different
99 * alignment. Which means that 'sizeof()' will give different results.
100 * Fix it up for the case of running 32-bit user mode on a 64-bit kernel.
101 */
102static noinline size_t autofs_v5_packet_size(struct autofs_sb_info *sbi)
103{
104 size_t pktsz = sizeof(struct autofs_v5_packet);
105#if defined(CONFIG_X86_64) && defined(CONFIG_COMPAT)
106 if (sbi->compat_daemon > 0)
107 pktsz -= 4;
108#endif
109 return pktsz;
110}
111
95static void autofs4_notify_daemon(struct autofs_sb_info *sbi, 112static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
96 struct autofs_wait_queue *wq, 113 struct autofs_wait_queue *wq,
97 int type) 114 int type)
@@ -155,8 +172,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
155 { 172 {
156 struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet; 173 struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet;
157 174
158 pktsz = sizeof(*packet); 175 pktsz = autofs_v5_packet_size(sbi);
159
160 packet->wait_queue_token = wq->wait_queue_token; 176 packet->wait_queue_token = wq->wait_queue_token;
161 packet->len = wq->name.len; 177 packet->len = wq->name.len;
162 memcpy(packet->name, wq->name.name, wq->name.len); 178 memcpy(packet->name, wq->name.name, wq->name.len);
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 633c701a287d..98f6bf10bbd4 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -892,6 +892,8 @@ static char *iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
892 if (eb != eb_in) 892 if (eb != eb_in)
893 free_extent_buffer(eb); 893 free_extent_buffer(eb);
894 ret = inode_ref_info(parent, 0, fs_root, path, &found_key); 894 ret = inode_ref_info(parent, 0, fs_root, path, &found_key);
895 if (ret > 0)
896 ret = -ENOENT;
895 if (ret) 897 if (ret)
896 break; 898 break;
897 next_inum = found_key.offset; 899 next_inum = found_key.offset;
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index b669a7d8e499..d986824bb2b4 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -644,7 +644,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
644static int btrfsic_process_superblock(struct btrfsic_state *state, 644static int btrfsic_process_superblock(struct btrfsic_state *state,
645 struct btrfs_fs_devices *fs_devices) 645 struct btrfs_fs_devices *fs_devices)
646{ 646{
647 int ret; 647 int ret = 0;
648 struct btrfs_super_block *selected_super; 648 struct btrfs_super_block *selected_super;
649 struct list_head *dev_head = &fs_devices->devices; 649 struct list_head *dev_head = &fs_devices->devices;
650 struct btrfs_device *device; 650 struct btrfs_device *device;
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 14f1c5a0b2d2..d02c27cd14c7 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -588,6 +588,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
588 page_offset(bio->bi_io_vec->bv_page), 588 page_offset(bio->bi_io_vec->bv_page),
589 PAGE_CACHE_SIZE); 589 PAGE_CACHE_SIZE);
590 read_unlock(&em_tree->lock); 590 read_unlock(&em_tree->lock);
591 if (!em)
592 return -EIO;
591 593
592 compressed_len = em->block_len; 594 compressed_len = em->block_len;
593 cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS); 595 cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 27ebe61d3ccc..80b6486fd5e6 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -886,7 +886,7 @@ struct btrfs_block_rsv {
886 u64 reserved; 886 u64 reserved;
887 struct btrfs_space_info *space_info; 887 struct btrfs_space_info *space_info;
888 spinlock_t lock; 888 spinlock_t lock;
889 unsigned int full:1; 889 unsigned int full;
890}; 890};
891 891
892/* 892/*
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 811d9f918b1c..534266fe505f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2260,6 +2260,12 @@ int open_ctree(struct super_block *sb,
2260 goto fail_sb_buffer; 2260 goto fail_sb_buffer;
2261 } 2261 }
2262 2262
2263 if (sectorsize < PAGE_SIZE) {
2264 printk(KERN_WARNING "btrfs: Incompatible sector size "
2265 "found on %s\n", sb->s_id);
2266 goto fail_sb_buffer;
2267 }
2268
2263 mutex_lock(&fs_info->chunk_mutex); 2269 mutex_lock(&fs_info->chunk_mutex);
2264 ret = btrfs_read_sys_array(tree_root); 2270 ret = btrfs_read_sys_array(tree_root);
2265 mutex_unlock(&fs_info->chunk_mutex); 2271 mutex_unlock(&fs_info->chunk_mutex);
@@ -2301,6 +2307,12 @@ int open_ctree(struct super_block *sb,
2301 2307
2302 btrfs_close_extra_devices(fs_devices); 2308 btrfs_close_extra_devices(fs_devices);
2303 2309
2310 if (!fs_devices->latest_bdev) {
2311 printk(KERN_CRIT "btrfs: failed to read devices on %s\n",
2312 sb->s_id);
2313 goto fail_tree_roots;
2314 }
2315
2304retry_root_backup: 2316retry_root_backup:
2305 blocksize = btrfs_level_size(tree_root, 2317 blocksize = btrfs_level_size(tree_root,
2306 btrfs_super_root_level(disk_super)); 2318 btrfs_super_root_level(disk_super));
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 283af7a676a3..37e0a800d34e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3312,7 +3312,8 @@ commit_trans:
3312 } 3312 }
3313 data_sinfo->bytes_may_use += bytes; 3313 data_sinfo->bytes_may_use += bytes;
3314 trace_btrfs_space_reservation(root->fs_info, "space_info", 3314 trace_btrfs_space_reservation(root->fs_info, "space_info",
3315 (u64)data_sinfo, bytes, 1); 3315 (u64)(unsigned long)data_sinfo,
3316 bytes, 1);
3316 spin_unlock(&data_sinfo->lock); 3317 spin_unlock(&data_sinfo->lock);
3317 3318
3318 return 0; 3319 return 0;
@@ -3333,7 +3334,8 @@ void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes)
3333 spin_lock(&data_sinfo->lock); 3334 spin_lock(&data_sinfo->lock);
3334 data_sinfo->bytes_may_use -= bytes; 3335 data_sinfo->bytes_may_use -= bytes;
3335 trace_btrfs_space_reservation(root->fs_info, "space_info", 3336 trace_btrfs_space_reservation(root->fs_info, "space_info",
3336 (u64)data_sinfo, bytes, 0); 3337 (u64)(unsigned long)data_sinfo,
3338 bytes, 0);
3337 spin_unlock(&data_sinfo->lock); 3339 spin_unlock(&data_sinfo->lock);
3338} 3340}
3339 3341
@@ -3611,12 +3613,15 @@ static int may_commit_transaction(struct btrfs_root *root,
3611 if (space_info != delayed_rsv->space_info) 3613 if (space_info != delayed_rsv->space_info)
3612 return -ENOSPC; 3614 return -ENOSPC;
3613 3615
3616 spin_lock(&space_info->lock);
3614 spin_lock(&delayed_rsv->lock); 3617 spin_lock(&delayed_rsv->lock);
3615 if (delayed_rsv->size < bytes) { 3618 if (space_info->bytes_pinned + delayed_rsv->size < bytes) {
3616 spin_unlock(&delayed_rsv->lock); 3619 spin_unlock(&delayed_rsv->lock);
3620 spin_unlock(&space_info->lock);
3617 return -ENOSPC; 3621 return -ENOSPC;
3618 } 3622 }
3619 spin_unlock(&delayed_rsv->lock); 3623 spin_unlock(&delayed_rsv->lock);
3624 spin_unlock(&space_info->lock);
3620 3625
3621commit: 3626commit:
3622 trans = btrfs_join_transaction(root); 3627 trans = btrfs_join_transaction(root);
@@ -3695,9 +3700,9 @@ again:
3695 if (used + orig_bytes <= space_info->total_bytes) { 3700 if (used + orig_bytes <= space_info->total_bytes) {
3696 space_info->bytes_may_use += orig_bytes; 3701 space_info->bytes_may_use += orig_bytes;
3697 trace_btrfs_space_reservation(root->fs_info, 3702 trace_btrfs_space_reservation(root->fs_info,
3698 "space_info", 3703 "space_info",
3699 (u64)space_info, 3704 (u64)(unsigned long)space_info,
3700 orig_bytes, 1); 3705 orig_bytes, 1);
3701 ret = 0; 3706 ret = 0;
3702 } else { 3707 } else {
3703 /* 3708 /*
@@ -3766,9 +3771,9 @@ again:
3766 if (used + num_bytes < space_info->total_bytes + avail) { 3771 if (used + num_bytes < space_info->total_bytes + avail) {
3767 space_info->bytes_may_use += orig_bytes; 3772 space_info->bytes_may_use += orig_bytes;
3768 trace_btrfs_space_reservation(root->fs_info, 3773 trace_btrfs_space_reservation(root->fs_info,
3769 "space_info", 3774 "space_info",
3770 (u64)space_info, 3775 (u64)(unsigned long)space_info,
3771 orig_bytes, 1); 3776 orig_bytes, 1);
3772 ret = 0; 3777 ret = 0;
3773 } else { 3778 } else {
3774 wait_ordered = true; 3779 wait_ordered = true;
@@ -3913,8 +3918,8 @@ static void block_rsv_release_bytes(struct btrfs_fs_info *fs_info,
3913 spin_lock(&space_info->lock); 3918 spin_lock(&space_info->lock);
3914 space_info->bytes_may_use -= num_bytes; 3919 space_info->bytes_may_use -= num_bytes;
3915 trace_btrfs_space_reservation(fs_info, "space_info", 3920 trace_btrfs_space_reservation(fs_info, "space_info",
3916 (u64)space_info, 3921 (u64)(unsigned long)space_info,
3917 num_bytes, 0); 3922 num_bytes, 0);
3918 space_info->reservation_progress++; 3923 space_info->reservation_progress++;
3919 spin_unlock(&space_info->lock); 3924 spin_unlock(&space_info->lock);
3920 } 3925 }
@@ -4105,7 +4110,7 @@ static u64 calc_global_metadata_size(struct btrfs_fs_info *fs_info)
4105 num_bytes += div64_u64(data_used + meta_used, 50); 4110 num_bytes += div64_u64(data_used + meta_used, 50);
4106 4111
4107 if (num_bytes * 3 > meta_used) 4112 if (num_bytes * 3 > meta_used)
4108 num_bytes = div64_u64(meta_used, 3); 4113 num_bytes = div64_u64(meta_used, 3) * 2;
4109 4114
4110 return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10); 4115 return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10);
4111} 4116}
@@ -4132,14 +4137,14 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
4132 block_rsv->reserved += num_bytes; 4137 block_rsv->reserved += num_bytes;
4133 sinfo->bytes_may_use += num_bytes; 4138 sinfo->bytes_may_use += num_bytes;
4134 trace_btrfs_space_reservation(fs_info, "space_info", 4139 trace_btrfs_space_reservation(fs_info, "space_info",
4135 (u64)sinfo, num_bytes, 1); 4140 (u64)(unsigned long)sinfo, num_bytes, 1);
4136 } 4141 }
4137 4142
4138 if (block_rsv->reserved >= block_rsv->size) { 4143 if (block_rsv->reserved >= block_rsv->size) {
4139 num_bytes = block_rsv->reserved - block_rsv->size; 4144 num_bytes = block_rsv->reserved - block_rsv->size;
4140 sinfo->bytes_may_use -= num_bytes; 4145 sinfo->bytes_may_use -= num_bytes;
4141 trace_btrfs_space_reservation(fs_info, "space_info", 4146 trace_btrfs_space_reservation(fs_info, "space_info",
4142 (u64)sinfo, num_bytes, 0); 4147 (u64)(unsigned long)sinfo, num_bytes, 0);
4143 sinfo->reservation_progress++; 4148 sinfo->reservation_progress++;
4144 block_rsv->reserved = block_rsv->size; 4149 block_rsv->reserved = block_rsv->size;
4145 block_rsv->full = 1; 4150 block_rsv->full = 1;
@@ -4192,7 +4197,8 @@ void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
4192 if (!trans->bytes_reserved) 4197 if (!trans->bytes_reserved)
4193 return; 4198 return;
4194 4199
4195 trace_btrfs_space_reservation(root->fs_info, "transaction", (u64)trans, 4200 trace_btrfs_space_reservation(root->fs_info, "transaction",
4201 (u64)(unsigned long)trans,
4196 trans->bytes_reserved, 0); 4202 trans->bytes_reserved, 0);
4197 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved); 4203 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved);
4198 trans->bytes_reserved = 0; 4204 trans->bytes_reserved = 0;
@@ -4710,9 +4716,9 @@ static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache,
4710 space_info->bytes_reserved += num_bytes; 4716 space_info->bytes_reserved += num_bytes;
4711 if (reserve == RESERVE_ALLOC) { 4717 if (reserve == RESERVE_ALLOC) {
4712 trace_btrfs_space_reservation(cache->fs_info, 4718 trace_btrfs_space_reservation(cache->fs_info,
4713 "space_info", 4719 "space_info",
4714 (u64)space_info, 4720 (u64)(unsigned long)space_info,
4715 num_bytes, 0); 4721 num_bytes, 0);
4716 space_info->bytes_may_use -= num_bytes; 4722 space_info->bytes_may_use -= num_bytes;
4717 } 4723 }
4718 } 4724 }
@@ -7886,9 +7892,16 @@ int btrfs_trim_fs(struct btrfs_root *root, struct fstrim_range *range)
7886 u64 start; 7892 u64 start;
7887 u64 end; 7893 u64 end;
7888 u64 trimmed = 0; 7894 u64 trimmed = 0;
7895 u64 total_bytes = btrfs_super_total_bytes(fs_info->super_copy);
7889 int ret = 0; 7896 int ret = 0;
7890 7897
7891 cache = btrfs_lookup_block_group(fs_info, range->start); 7898 /*
7899 * try to trim all FS space, our block group may start from non-zero.
7900 */
7901 if (range->len == total_bytes)
7902 cache = btrfs_lookup_first_block_group(fs_info, range->start);
7903 else
7904 cache = btrfs_lookup_block_group(fs_info, range->start);
7892 7905
7893 while (cache) { 7906 while (cache) {
7894 if (cache->key.objectid >= (range->start + range->len)) { 7907 if (cache->key.objectid >= (range->start + range->len)) {
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fcf77e1ded40..a55fbe6252de 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -513,6 +513,15 @@ hit_next:
513 WARN_ON(state->end < start); 513 WARN_ON(state->end < start);
514 last_end = state->end; 514 last_end = state->end;
515 515
516 if (state->end < end && !need_resched())
517 next_node = rb_next(&state->rb_node);
518 else
519 next_node = NULL;
520
521 /* the state doesn't have the wanted bits, go ahead */
522 if (!(state->state & bits))
523 goto next;
524
516 /* 525 /*
517 * | ---- desired range ---- | 526 * | ---- desired range ---- |
518 * | state | or 527 * | state | or
@@ -565,20 +574,15 @@ hit_next:
565 goto out; 574 goto out;
566 } 575 }
567 576
568 if (state->end < end && prealloc && !need_resched())
569 next_node = rb_next(&state->rb_node);
570 else
571 next_node = NULL;
572
573 set |= clear_state_bit(tree, state, &bits, wake); 577 set |= clear_state_bit(tree, state, &bits, wake);
578next:
574 if (last_end == (u64)-1) 579 if (last_end == (u64)-1)
575 goto out; 580 goto out;
576 start = last_end + 1; 581 start = last_end + 1;
577 if (start <= end && next_node) { 582 if (start <= end && next_node) {
578 state = rb_entry(next_node, struct extent_state, 583 state = rb_entry(next_node, struct extent_state,
579 rb_node); 584 rb_node);
580 if (state->start == start) 585 goto hit_next;
581 goto hit_next;
582 } 586 }
583 goto search_again; 587 goto search_again;
584 588
@@ -961,8 +965,6 @@ hit_next:
961 965
962 set_state_bits(tree, state, &bits); 966 set_state_bits(tree, state, &bits);
963 clear_state_bit(tree, state, &clear_bits, 0); 967 clear_state_bit(tree, state, &clear_bits, 0);
964
965 merge_state(tree, state);
966 if (last_end == (u64)-1) 968 if (last_end == (u64)-1)
967 goto out; 969 goto out;
968 970
@@ -1007,7 +1009,6 @@ hit_next:
1007 if (state->end <= end) { 1009 if (state->end <= end) {
1008 set_state_bits(tree, state, &bits); 1010 set_state_bits(tree, state, &bits);
1009 clear_state_bit(tree, state, &clear_bits, 0); 1011 clear_state_bit(tree, state, &clear_bits, 0);
1010 merge_state(tree, state);
1011 if (last_end == (u64)-1) 1012 if (last_end == (u64)-1)
1012 goto out; 1013 goto out;
1013 start = last_end + 1; 1014 start = last_end + 1;
@@ -1068,8 +1069,6 @@ hit_next:
1068 1069
1069 set_state_bits(tree, prealloc, &bits); 1070 set_state_bits(tree, prealloc, &bits);
1070 clear_state_bit(tree, prealloc, &clear_bits, 0); 1071 clear_state_bit(tree, prealloc, &clear_bits, 0);
1071
1072 merge_state(tree, prealloc);
1073 prealloc = NULL; 1072 prealloc = NULL;
1074 goto out; 1073 goto out;
1075 } 1074 }
@@ -2154,13 +2153,46 @@ static int bio_readpage_error(struct bio *failed_bio, struct page *page,
2154 "this_mirror=%d, num_copies=%d, in_validation=%d\n", read_mode, 2153 "this_mirror=%d, num_copies=%d, in_validation=%d\n", read_mode,
2155 failrec->this_mirror, num_copies, failrec->in_validation); 2154 failrec->this_mirror, num_copies, failrec->in_validation);
2156 2155
2157 tree->ops->submit_bio_hook(inode, read_mode, bio, failrec->this_mirror, 2156 ret = tree->ops->submit_bio_hook(inode, read_mode, bio,
2158 failrec->bio_flags, 0); 2157 failrec->this_mirror,
2159 return 0; 2158 failrec->bio_flags, 0);
2159 return ret;
2160} 2160}
2161 2161
2162/* lots and lots of room for performance fixes in the end_bio funcs */ 2162/* lots and lots of room for performance fixes in the end_bio funcs */
2163 2163
2164int end_extent_writepage(struct page *page, int err, u64 start, u64 end)
2165{
2166 int uptodate = (err == 0);
2167 struct extent_io_tree *tree;
2168 int ret;
2169
2170 tree = &BTRFS_I(page->mapping->host)->io_tree;
2171
2172 if (tree->ops && tree->ops->writepage_end_io_hook) {
2173 ret = tree->ops->writepage_end_io_hook(page, start,
2174 end, NULL, uptodate);
2175 if (ret)
2176 uptodate = 0;
2177 }
2178
2179 if (!uptodate && tree->ops &&
2180 tree->ops->writepage_io_failed_hook) {
2181 ret = tree->ops->writepage_io_failed_hook(NULL, page,
2182 start, end, NULL);
2183 /* Writeback already completed */
2184 if (ret == 0)
2185 return 1;
2186 }
2187
2188 if (!uptodate) {
2189 clear_extent_uptodate(tree, start, end, NULL, GFP_NOFS);
2190 ClearPageUptodate(page);
2191 SetPageError(page);
2192 }
2193 return 0;
2194}
2195
2164/* 2196/*
2165 * after a writepage IO is done, we need to: 2197 * after a writepage IO is done, we need to:
2166 * clear the uptodate bits on error 2198 * clear the uptodate bits on error
@@ -2172,13 +2204,11 @@ static int bio_readpage_error(struct bio *failed_bio, struct page *page,
2172 */ 2204 */
2173static void end_bio_extent_writepage(struct bio *bio, int err) 2205static void end_bio_extent_writepage(struct bio *bio, int err)
2174{ 2206{
2175 int uptodate = err == 0;
2176 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 2207 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
2177 struct extent_io_tree *tree; 2208 struct extent_io_tree *tree;
2178 u64 start; 2209 u64 start;
2179 u64 end; 2210 u64 end;
2180 int whole_page; 2211 int whole_page;
2181 int ret;
2182 2212
2183 do { 2213 do {
2184 struct page *page = bvec->bv_page; 2214 struct page *page = bvec->bv_page;
@@ -2195,28 +2225,9 @@ static void end_bio_extent_writepage(struct bio *bio, int err)
2195 2225
2196 if (--bvec >= bio->bi_io_vec) 2226 if (--bvec >= bio->bi_io_vec)
2197 prefetchw(&bvec->bv_page->flags); 2227 prefetchw(&bvec->bv_page->flags);
2198 if (tree->ops && tree->ops->writepage_end_io_hook) {
2199 ret = tree->ops->writepage_end_io_hook(page, start,
2200 end, NULL, uptodate);
2201 if (ret)
2202 uptodate = 0;
2203 }
2204
2205 if (!uptodate && tree->ops &&
2206 tree->ops->writepage_io_failed_hook) {
2207 ret = tree->ops->writepage_io_failed_hook(bio, page,
2208 start, end, NULL);
2209 if (ret == 0) {
2210 uptodate = (err == 0);
2211 continue;
2212 }
2213 }
2214 2228
2215 if (!uptodate) { 2229 if (end_extent_writepage(page, err, start, end))
2216 clear_extent_uptodate(tree, start, end, NULL, GFP_NOFS); 2230 continue;
2217 ClearPageUptodate(page);
2218 SetPageError(page);
2219 }
2220 2231
2221 if (whole_page) 2232 if (whole_page)
2222 end_page_writeback(page); 2233 end_page_writeback(page);
@@ -2779,9 +2790,12 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2779 delalloc_start = delalloc_end + 1; 2790 delalloc_start = delalloc_end + 1;
2780 continue; 2791 continue;
2781 } 2792 }
2782 tree->ops->fill_delalloc(inode, page, delalloc_start, 2793 ret = tree->ops->fill_delalloc(inode, page,
2783 delalloc_end, &page_started, 2794 delalloc_start,
2784 &nr_written); 2795 delalloc_end,
2796 &page_started,
2797 &nr_written);
2798 BUG_ON(ret);
2785 /* 2799 /*
2786 * delalloc_end is already one less than the total 2800 * delalloc_end is already one less than the total
2787 * length, so we don't subtract one from 2801 * length, so we don't subtract one from
@@ -2818,8 +2832,12 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2818 if (tree->ops && tree->ops->writepage_start_hook) { 2832 if (tree->ops && tree->ops->writepage_start_hook) {
2819 ret = tree->ops->writepage_start_hook(page, start, 2833 ret = tree->ops->writepage_start_hook(page, start,
2820 page_end); 2834 page_end);
2821 if (ret == -EAGAIN) { 2835 if (ret) {
2822 redirty_page_for_writepage(wbc, page); 2836 /* Fixup worker will requeue */
2837 if (ret == -EBUSY)
2838 wbc->pages_skipped++;
2839 else
2840 redirty_page_for_writepage(wbc, page);
2823 update_nr_written(page, wbc, nr_written); 2841 update_nr_written(page, wbc, nr_written);
2824 unlock_page(page); 2842 unlock_page(page);
2825 ret = 0; 2843 ret = 0;
@@ -3289,7 +3307,7 @@ int try_release_extent_mapping(struct extent_map_tree *map,
3289 len = end - start + 1; 3307 len = end - start + 1;
3290 write_lock(&map->lock); 3308 write_lock(&map->lock);
3291 em = lookup_extent_mapping(map, start, len); 3309 em = lookup_extent_mapping(map, start, len);
3292 if (IS_ERR_OR_NULL(em)) { 3310 if (!em) {
3293 write_unlock(&map->lock); 3311 write_unlock(&map->lock);
3294 break; 3312 break;
3295 } 3313 }
@@ -3853,10 +3871,9 @@ int clear_extent_buffer_uptodate(struct extent_io_tree *tree,
3853 num_pages = num_extent_pages(eb->start, eb->len); 3871 num_pages = num_extent_pages(eb->start, eb->len);
3854 clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); 3872 clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
3855 3873
3856 if (eb_straddles_pages(eb)) { 3874 clear_extent_uptodate(tree, eb->start, eb->start + eb->len - 1,
3857 clear_extent_uptodate(tree, eb->start, eb->start + eb->len - 1, 3875 cached_state, GFP_NOFS);
3858 cached_state, GFP_NOFS); 3876
3859 }
3860 for (i = 0; i < num_pages; i++) { 3877 for (i = 0; i < num_pages; i++) {
3861 page = extent_buffer_page(eb, i); 3878 page = extent_buffer_page(eb, i);
3862 if (page) 3879 if (page)
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index bc6a042cb6fc..cecc3518c121 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -319,4 +319,5 @@ struct btrfs_mapping_tree;
319int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start, 319int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start,
320 u64 length, u64 logical, struct page *page, 320 u64 length, u64 logical, struct page *page,
321 int mirror_num); 321 int mirror_num);
322int end_extent_writepage(struct page *page, int err, u64 start, u64 end);
322#endif 323#endif
diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
index 33a7890b1f40..1195f09761fe 100644
--- a/fs/btrfs/extent_map.h
+++ b/fs/btrfs/extent_map.h
@@ -26,8 +26,8 @@ struct extent_map {
26 unsigned long flags; 26 unsigned long flags;
27 struct block_device *bdev; 27 struct block_device *bdev;
28 atomic_t refs; 28 atomic_t refs;
29 unsigned int in_tree:1; 29 unsigned int in_tree;
30 unsigned int compress_type:4; 30 unsigned int compress_type;
31}; 31};
32 32
33struct extent_map_tree { 33struct extent_map_tree {
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 859ba2dd8890..e8d06b6b9194 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1605,6 +1605,14 @@ static long btrfs_fallocate(struct file *file, int mode,
1605 return -EOPNOTSUPP; 1605 return -EOPNOTSUPP;
1606 1606
1607 /* 1607 /*
1608 * Make sure we have enough space before we do the
1609 * allocation.
1610 */
1611 ret = btrfs_check_data_free_space(inode, len);
1612 if (ret)
1613 return ret;
1614
1615 /*
1608 * wait for ordered IO before we have any locks. We'll loop again 1616 * wait for ordered IO before we have any locks. We'll loop again
1609 * below with the locks held. 1617 * below with the locks held.
1610 */ 1618 */
@@ -1667,27 +1675,12 @@ static long btrfs_fallocate(struct file *file, int mode,
1667 if (em->block_start == EXTENT_MAP_HOLE || 1675 if (em->block_start == EXTENT_MAP_HOLE ||
1668 (cur_offset >= inode->i_size && 1676 (cur_offset >= inode->i_size &&
1669 !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { 1677 !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) {
1670
1671 /*
1672 * Make sure we have enough space before we do the
1673 * allocation.
1674 */
1675 ret = btrfs_check_data_free_space(inode, last_byte -
1676 cur_offset);
1677 if (ret) {
1678 free_extent_map(em);
1679 break;
1680 }
1681
1682 ret = btrfs_prealloc_file_range(inode, mode, cur_offset, 1678 ret = btrfs_prealloc_file_range(inode, mode, cur_offset,
1683 last_byte - cur_offset, 1679 last_byte - cur_offset,
1684 1 << inode->i_blkbits, 1680 1 << inode->i_blkbits,
1685 offset + len, 1681 offset + len,
1686 &alloc_hint); 1682 &alloc_hint);
1687 1683
1688 /* Let go of our reservation. */
1689 btrfs_free_reserved_data_space(inode, last_byte -
1690 cur_offset);
1691 if (ret < 0) { 1684 if (ret < 0) {
1692 free_extent_map(em); 1685 free_extent_map(em);
1693 break; 1686 break;
@@ -1715,6 +1708,8 @@ static long btrfs_fallocate(struct file *file, int mode,
1715 &cached_state, GFP_NOFS); 1708 &cached_state, GFP_NOFS);
1716out: 1709out:
1717 mutex_unlock(&inode->i_mutex); 1710 mutex_unlock(&inode->i_mutex);
1711 /* Let go of our reservation. */
1712 btrfs_free_reserved_data_space(inode, len);
1718 return ret; 1713 return ret;
1719} 1714}
1720 1715
@@ -1761,7 +1756,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
1761 start - root->sectorsize, 1756 start - root->sectorsize,
1762 root->sectorsize, 0); 1757 root->sectorsize, 0);
1763 if (IS_ERR(em)) { 1758 if (IS_ERR(em)) {
1764 ret = -ENXIO; 1759 ret = PTR_ERR(em);
1765 goto out; 1760 goto out;
1766 } 1761 }
1767 last_end = em->start + em->len; 1762 last_end = em->start + em->len;
@@ -1773,7 +1768,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
1773 while (1) { 1768 while (1) {
1774 em = btrfs_get_extent_fiemap(inode, NULL, 0, start, len, 0); 1769 em = btrfs_get_extent_fiemap(inode, NULL, 0, start, len, 0);
1775 if (IS_ERR(em)) { 1770 if (IS_ERR(em)) {
1776 ret = -ENXIO; 1771 ret = PTR_ERR(em);
1777 break; 1772 break;
1778 } 1773 }
1779 1774
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index c2f20594c9f7..710ea380c7ed 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -777,6 +777,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
777 spin_lock(&block_group->lock); 777 spin_lock(&block_group->lock);
778 if (block_group->disk_cache_state != BTRFS_DC_WRITTEN) { 778 if (block_group->disk_cache_state != BTRFS_DC_WRITTEN) {
779 spin_unlock(&block_group->lock); 779 spin_unlock(&block_group->lock);
780 btrfs_free_path(path);
780 goto out; 781 goto out;
781 } 782 }
782 spin_unlock(&block_group->lock); 783 spin_unlock(&block_group->lock);
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index 213ffa86ce1b..ee15d88b33d2 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -438,7 +438,8 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
438 trans->bytes_reserved); 438 trans->bytes_reserved);
439 if (ret) 439 if (ret)
440 goto out; 440 goto out;
441 trace_btrfs_space_reservation(root->fs_info, "ino_cache", (u64)trans, 441 trace_btrfs_space_reservation(root->fs_info, "ino_cache",
442 (u64)(unsigned long)trans,
442 trans->bytes_reserved, 1); 443 trans->bytes_reserved, 1);
443again: 444again:
444 inode = lookup_free_ino_inode(root, path); 445 inode = lookup_free_ino_inode(root, path);
@@ -500,7 +501,8 @@ again:
500out_put: 501out_put:
501 iput(inode); 502 iput(inode);
502out_release: 503out_release:
503 trace_btrfs_space_reservation(root->fs_info, "ino_cache", (u64)trans, 504 trace_btrfs_space_reservation(root->fs_info, "ino_cache",
505 (u64)(unsigned long)trans,
504 trans->bytes_reserved, 0); 506 trans->bytes_reserved, 0);
505 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved); 507 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved);
506out: 508out:
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 32214fe0f7e3..892b34785ccc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1555,6 +1555,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
1555 struct inode *inode; 1555 struct inode *inode;
1556 u64 page_start; 1556 u64 page_start;
1557 u64 page_end; 1557 u64 page_end;
1558 int ret;
1558 1559
1559 fixup = container_of(work, struct btrfs_writepage_fixup, work); 1560 fixup = container_of(work, struct btrfs_writepage_fixup, work);
1560 page = fixup->page; 1561 page = fixup->page;
@@ -1582,12 +1583,21 @@ again:
1582 page_end, &cached_state, GFP_NOFS); 1583 page_end, &cached_state, GFP_NOFS);
1583 unlock_page(page); 1584 unlock_page(page);
1584 btrfs_start_ordered_extent(inode, ordered, 1); 1585 btrfs_start_ordered_extent(inode, ordered, 1);
1586 btrfs_put_ordered_extent(ordered);
1585 goto again; 1587 goto again;
1586 } 1588 }
1587 1589
1588 BUG(); 1590 ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);
1591 if (ret) {
1592 mapping_set_error(page->mapping, ret);
1593 end_extent_writepage(page, ret, page_start, page_end);
1594 ClearPageChecked(page);
1595 goto out;
1596 }
1597
1589 btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); 1598 btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state);
1590 ClearPageChecked(page); 1599 ClearPageChecked(page);
1600 set_page_dirty(page);
1591out: 1601out:
1592 unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end, 1602 unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end,
1593 &cached_state, GFP_NOFS); 1603 &cached_state, GFP_NOFS);
@@ -1630,7 +1640,7 @@ static int btrfs_writepage_start_hook(struct page *page, u64 start, u64 end)
1630 fixup->work.func = btrfs_writepage_fixup_worker; 1640 fixup->work.func = btrfs_writepage_fixup_worker;
1631 fixup->page = page; 1641 fixup->page = page;
1632 btrfs_queue_worker(&root->fs_info->fixup_workers, &fixup->work); 1642 btrfs_queue_worker(&root->fs_info->fixup_workers, &fixup->work);
1633 return -EAGAIN; 1643 return -EBUSY;
1634} 1644}
1635 1645
1636static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, 1646static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
@@ -4575,7 +4585,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
4575 ret = btrfs_insert_dir_item(trans, root, name, name_len, 4585 ret = btrfs_insert_dir_item(trans, root, name, name_len,
4576 parent_inode, &key, 4586 parent_inode, &key,
4577 btrfs_inode_type(inode), index); 4587 btrfs_inode_type(inode), index);
4578 BUG_ON(ret); 4588 if (ret)
4589 goto fail_dir_item;
4579 4590
4580 btrfs_i_size_write(parent_inode, parent_inode->i_size + 4591 btrfs_i_size_write(parent_inode, parent_inode->i_size +
4581 name_len * 2); 4592 name_len * 2);
@@ -4583,6 +4594,23 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
4583 ret = btrfs_update_inode(trans, root, parent_inode); 4594 ret = btrfs_update_inode(trans, root, parent_inode);
4584 } 4595 }
4585 return ret; 4596 return ret;
4597
4598fail_dir_item:
4599 if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
4600 u64 local_index;
4601 int err;
4602 err = btrfs_del_root_ref(trans, root->fs_info->tree_root,
4603 key.objectid, root->root_key.objectid,
4604 parent_ino, &local_index, name, name_len);
4605
4606 } else if (add_backref) {
4607 u64 local_index;
4608 int err;
4609
4610 err = btrfs_del_inode_ref(trans, root, name, name_len,
4611 ino, parent_ino, &local_index);
4612 }
4613 return ret;
4586} 4614}
4587 4615
4588static int btrfs_add_nondir(struct btrfs_trans_handle *trans, 4616static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
@@ -6696,8 +6724,10 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
6696 int err; 6724 int err;
6697 u64 index = 0; 6725 u64 index = 0;
6698 6726
6699 inode = btrfs_new_inode(trans, new_root, NULL, "..", 2, new_dirid, 6727 inode = btrfs_new_inode(trans, new_root, NULL, "..", 2,
6700 new_dirid, S_IFDIR | 0700, &index); 6728 new_dirid, new_dirid,
6729 S_IFDIR | (~current_umask() & S_IRWXUGO),
6730 &index);
6701 if (IS_ERR(inode)) 6731 if (IS_ERR(inode))
6702 return PTR_ERR(inode); 6732 return PTR_ERR(inode);
6703 inode->i_op = &btrfs_dir_inode_operations; 6733 inode->i_op = &btrfs_dir_inode_operations;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 03bb62a9ee24..d8b54715c2de 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -861,6 +861,7 @@ static int cluster_pages_for_defrag(struct inode *inode,
861 int i_done; 861 int i_done;
862 struct btrfs_ordered_extent *ordered; 862 struct btrfs_ordered_extent *ordered;
863 struct extent_state *cached_state = NULL; 863 struct extent_state *cached_state = NULL;
864 struct extent_io_tree *tree;
864 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping); 865 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
865 866
866 if (isize == 0) 867 if (isize == 0)
@@ -871,18 +872,34 @@ static int cluster_pages_for_defrag(struct inode *inode,
871 num_pages << PAGE_CACHE_SHIFT); 872 num_pages << PAGE_CACHE_SHIFT);
872 if (ret) 873 if (ret)
873 return ret; 874 return ret;
874again:
875 ret = 0;
876 i_done = 0; 875 i_done = 0;
876 tree = &BTRFS_I(inode)->io_tree;
877 877
878 /* step one, lock all the pages */ 878 /* step one, lock all the pages */
879 for (i = 0; i < num_pages; i++) { 879 for (i = 0; i < num_pages; i++) {
880 struct page *page; 880 struct page *page;
881again:
881 page = find_or_create_page(inode->i_mapping, 882 page = find_or_create_page(inode->i_mapping,
882 start_index + i, mask); 883 start_index + i, mask);
883 if (!page) 884 if (!page)
884 break; 885 break;
885 886
887 page_start = page_offset(page);
888 page_end = page_start + PAGE_CACHE_SIZE - 1;
889 while (1) {
890 lock_extent(tree, page_start, page_end, GFP_NOFS);
891 ordered = btrfs_lookup_ordered_extent(inode,
892 page_start);
893 unlock_extent(tree, page_start, page_end, GFP_NOFS);
894 if (!ordered)
895 break;
896
897 unlock_page(page);
898 btrfs_start_ordered_extent(inode, ordered, 1);
899 btrfs_put_ordered_extent(ordered);
900 lock_page(page);
901 }
902
886 if (!PageUptodate(page)) { 903 if (!PageUptodate(page)) {
887 btrfs_readpage(NULL, page); 904 btrfs_readpage(NULL, page);
888 lock_page(page); 905 lock_page(page);
@@ -893,15 +910,22 @@ again:
893 break; 910 break;
894 } 911 }
895 } 912 }
913
896 isize = i_size_read(inode); 914 isize = i_size_read(inode);
897 file_end = (isize - 1) >> PAGE_CACHE_SHIFT; 915 file_end = (isize - 1) >> PAGE_CACHE_SHIFT;
898 if (!isize || page->index > file_end || 916 if (!isize || page->index > file_end) {
899 page->mapping != inode->i_mapping) {
900 /* whoops, we blew past eof, skip this page */ 917 /* whoops, we blew past eof, skip this page */
901 unlock_page(page); 918 unlock_page(page);
902 page_cache_release(page); 919 page_cache_release(page);
903 break; 920 break;
904 } 921 }
922
923 if (page->mapping != inode->i_mapping) {
924 unlock_page(page);
925 page_cache_release(page);
926 goto again;
927 }
928
905 pages[i] = page; 929 pages[i] = page;
906 i_done++; 930 i_done++;
907 } 931 }
@@ -924,25 +948,6 @@ again:
924 lock_extent_bits(&BTRFS_I(inode)->io_tree, 948 lock_extent_bits(&BTRFS_I(inode)->io_tree,
925 page_start, page_end - 1, 0, &cached_state, 949 page_start, page_end - 1, 0, &cached_state,
926 GFP_NOFS); 950 GFP_NOFS);
927 ordered = btrfs_lookup_first_ordered_extent(inode, page_end - 1);
928 if (ordered &&
929 ordered->file_offset + ordered->len > page_start &&
930 ordered->file_offset < page_end) {
931 btrfs_put_ordered_extent(ordered);
932 unlock_extent_cached(&BTRFS_I(inode)->io_tree,
933 page_start, page_end - 1,
934 &cached_state, GFP_NOFS);
935 for (i = 0; i < i_done; i++) {
936 unlock_page(pages[i]);
937 page_cache_release(pages[i]);
938 }
939 btrfs_wait_ordered_range(inode, page_start,
940 page_end - page_start);
941 goto again;
942 }
943 if (ordered)
944 btrfs_put_ordered_extent(ordered);
945
946 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, 951 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start,
947 page_end - 1, EXTENT_DIRTY | EXTENT_DELALLOC | 952 page_end - 1, EXTENT_DIRTY | EXTENT_DELALLOC |
948 EXTENT_DO_ACCOUNTING, 0, 0, &cached_state, 953 EXTENT_DO_ACCOUNTING, 0, 0, &cached_state,
@@ -1327,6 +1332,12 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
1327 goto out; 1332 goto out;
1328 } 1333 }
1329 1334
1335 if (name[0] == '.' &&
1336 (namelen == 1 || (name[1] == '.' && namelen == 2))) {
1337 ret = -EEXIST;
1338 goto out;
1339 }
1340
1330 if (subvol) { 1341 if (subvol) {
1331 ret = btrfs_mksubvol(&file->f_path, name, namelen, 1342 ret = btrfs_mksubvol(&file->f_path, name, namelen,
1332 NULL, transid, readonly); 1343 NULL, transid, readonly);
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 9770cc5bfb76..abc0fbffa510 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1367,7 +1367,8 @@ out:
1367} 1367}
1368 1368
1369static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev, 1369static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev,
1370 u64 chunk_tree, u64 chunk_objectid, u64 chunk_offset, u64 length) 1370 u64 chunk_tree, u64 chunk_objectid, u64 chunk_offset, u64 length,
1371 u64 dev_offset)
1371{ 1372{
1372 struct btrfs_mapping_tree *map_tree = 1373 struct btrfs_mapping_tree *map_tree =
1373 &sdev->dev->dev_root->fs_info->mapping_tree; 1374 &sdev->dev->dev_root->fs_info->mapping_tree;
@@ -1391,7 +1392,8 @@ static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev,
1391 goto out; 1392 goto out;
1392 1393
1393 for (i = 0; i < map->num_stripes; ++i) { 1394 for (i = 0; i < map->num_stripes; ++i) {
1394 if (map->stripes[i].dev == sdev->dev) { 1395 if (map->stripes[i].dev == sdev->dev &&
1396 map->stripes[i].physical == dev_offset) {
1395 ret = scrub_stripe(sdev, map, i, chunk_offset, length); 1397 ret = scrub_stripe(sdev, map, i, chunk_offset, length);
1396 if (ret) 1398 if (ret)
1397 goto out; 1399 goto out;
@@ -1487,7 +1489,7 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end)
1487 break; 1489 break;
1488 } 1490 }
1489 ret = scrub_chunk(sdev, chunk_tree, chunk_objectid, 1491 ret = scrub_chunk(sdev, chunk_tree, chunk_objectid,
1490 chunk_offset, length); 1492 chunk_offset, length, found_key.offset);
1491 btrfs_put_block_group(cache); 1493 btrfs_put_block_group(cache);
1492 if (ret) 1494 if (ret)
1493 break; 1495 break;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 287a6728b1ad..04b77e3ceb7a 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -327,7 +327,8 @@ again:
327 327
328 if (num_bytes) { 328 if (num_bytes) {
329 trace_btrfs_space_reservation(root->fs_info, "transaction", 329 trace_btrfs_space_reservation(root->fs_info, "transaction",
330 (u64)h, num_bytes, 1); 330 (u64)(unsigned long)h,
331 num_bytes, 1);
331 h->block_rsv = &root->fs_info->trans_block_rsv; 332 h->block_rsv = &root->fs_info->trans_block_rsv;
332 h->bytes_reserved = num_bytes; 333 h->bytes_reserved = num_bytes;
333 } 334 }
@@ -915,7 +916,11 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
915 dentry->d_name.name, dentry->d_name.len, 916 dentry->d_name.name, dentry->d_name.len,
916 parent_inode, &key, 917 parent_inode, &key,
917 BTRFS_FT_DIR, index); 918 BTRFS_FT_DIR, index);
918 BUG_ON(ret); 919 if (ret) {
920 pending->error = -EEXIST;
921 dput(parent);
922 goto fail;
923 }
919 924
920 btrfs_i_size_write(parent_inode, parent_inode->i_size + 925 btrfs_i_size_write(parent_inode, parent_inode->i_size +
921 dentry->d_name.len * 2); 926 dentry->d_name.len * 2);
@@ -993,12 +998,9 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
993{ 998{
994 struct btrfs_pending_snapshot *pending; 999 struct btrfs_pending_snapshot *pending;
995 struct list_head *head = &trans->transaction->pending_snapshots; 1000 struct list_head *head = &trans->transaction->pending_snapshots;
996 int ret;
997 1001
998 list_for_each_entry(pending, head, list) { 1002 list_for_each_entry(pending, head, list)
999 ret = create_pending_snapshot(trans, fs_info, pending); 1003 create_pending_snapshot(trans, fs_info, pending);
1000 BUG_ON(ret);
1001 }
1002 return 0; 1004 return 0;
1003} 1005}
1004 1006
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0b4e2af7954d..ef41f285a475 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -459,12 +459,23 @@ int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
459{ 459{
460 struct btrfs_device *device, *next; 460 struct btrfs_device *device, *next;
461 461
462 struct block_device *latest_bdev = NULL;
463 u64 latest_devid = 0;
464 u64 latest_transid = 0;
465
462 mutex_lock(&uuid_mutex); 466 mutex_lock(&uuid_mutex);
463again: 467again:
464 /* This is the initialized path, it is safe to release the devices. */ 468 /* This is the initialized path, it is safe to release the devices. */
465 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) { 469 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
466 if (device->in_fs_metadata) 470 if (device->in_fs_metadata) {
471 if (!latest_transid ||
472 device->generation > latest_transid) {
473 latest_devid = device->devid;
474 latest_transid = device->generation;
475 latest_bdev = device->bdev;
476 }
467 continue; 477 continue;
478 }
468 479
469 if (device->bdev) { 480 if (device->bdev) {
470 blkdev_put(device->bdev, device->mode); 481 blkdev_put(device->bdev, device->mode);
@@ -487,6 +498,10 @@ again:
487 goto again; 498 goto again;
488 } 499 }
489 500
501 fs_devices->latest_bdev = latest_bdev;
502 fs_devices->latest_devid = latest_devid;
503 fs_devices->latest_trans = latest_transid;
504
490 mutex_unlock(&uuid_mutex); 505 mutex_unlock(&uuid_mutex);
491 return 0; 506 return 0;
492} 507}
@@ -1953,7 +1968,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
1953 em = lookup_extent_mapping(em_tree, chunk_offset, 1); 1968 em = lookup_extent_mapping(em_tree, chunk_offset, 1);
1954 read_unlock(&em_tree->lock); 1969 read_unlock(&em_tree->lock);
1955 1970
1956 BUG_ON(em->start > chunk_offset || 1971 BUG_ON(!em || em->start > chunk_offset ||
1957 em->start + em->len < chunk_offset); 1972 em->start + em->len < chunk_offset);
1958 map = (struct map_lookup *)em->bdev; 1973 map = (struct map_lookup *)em->bdev;
1959 1974
@@ -4356,6 +4371,20 @@ int btrfs_read_sys_array(struct btrfs_root *root)
4356 return -ENOMEM; 4371 return -ENOMEM;
4357 btrfs_set_buffer_uptodate(sb); 4372 btrfs_set_buffer_uptodate(sb);
4358 btrfs_set_buffer_lockdep_class(root->root_key.objectid, sb, 0); 4373 btrfs_set_buffer_lockdep_class(root->root_key.objectid, sb, 0);
4374 /*
4375 * The sb extent buffer is artifical and just used to read the system array.
4376 * btrfs_set_buffer_uptodate() call does not properly mark all it's
4377 * pages up-to-date when the page is larger: extent does not cover the
4378 * whole page and consequently check_page_uptodate does not find all
4379 * the page's extents up-to-date (the hole beyond sb),
4380 * write_extent_buffer then triggers a WARN_ON.
4381 *
4382 * Regular short extents go through mark_extent_buffer_dirty/writeback cycle,
4383 * but sb spans only this function. Add an explicit SetPageUptodate call
4384 * to silence the warning eg. on PowerPC 64.
4385 */
4386 if (PAGE_CACHE_SIZE > BTRFS_SUPER_INFO_SIZE)
4387 SetPageUptodate(sb->first_page);
4359 4388
4360 write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE); 4389 write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE);
4361 array_size = btrfs_super_sys_array_size(super_copy); 4390 array_size = btrfs_super_sys_array_size(super_copy);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 4a588dbd11bf..f4aadd15b613 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -173,7 +173,7 @@ void inode_dio_wait(struct inode *inode)
173 if (atomic_read(&inode->i_dio_count)) 173 if (atomic_read(&inode->i_dio_count))
174 __inode_dio_wait(inode); 174 __inode_dio_wait(inode);
175} 175}
176EXPORT_SYMBOL_GPL(inode_dio_wait); 176EXPORT_SYMBOL(inode_dio_wait);
177 177
178/* 178/*
179 * inode_dio_done - signal finish of a direct I/O requests 179 * inode_dio_done - signal finish of a direct I/O requests
@@ -187,7 +187,7 @@ void inode_dio_done(struct inode *inode)
187 if (atomic_dec_and_test(&inode->i_dio_count)) 187 if (atomic_dec_and_test(&inode->i_dio_count))
188 wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); 188 wake_up_bit(&inode->i_state, __I_DIO_WAKEUP);
189} 189}
190EXPORT_SYMBOL_GPL(inode_dio_done); 190EXPORT_SYMBOL(inode_dio_done);
191 191
192/* 192/*
193 * How many pages are in the queue? 193 * How many pages are in the queue?
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index aabdfc38cf24..ea54cdef04dd 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -320,6 +320,11 @@ static inline int ep_is_linked(struct list_head *p)
320 return !list_empty(p); 320 return !list_empty(p);
321} 321}
322 322
323static inline struct eppoll_entry *ep_pwq_from_wait(wait_queue_t *p)
324{
325 return container_of(p, struct eppoll_entry, wait);
326}
327
323/* Get the "struct epitem" from a wait queue pointer */ 328/* Get the "struct epitem" from a wait queue pointer */
324static inline struct epitem *ep_item_from_wait(wait_queue_t *p) 329static inline struct epitem *ep_item_from_wait(wait_queue_t *p)
325{ 330{
@@ -467,6 +472,18 @@ static void ep_poll_safewake(wait_queue_head_t *wq)
467 put_cpu(); 472 put_cpu();
468} 473}
469 474
475static void ep_remove_wait_queue(struct eppoll_entry *pwq)
476{
477 wait_queue_head_t *whead;
478
479 rcu_read_lock();
480 /* If it is cleared by POLLFREE, it should be rcu-safe */
481 whead = rcu_dereference(pwq->whead);
482 if (whead)
483 remove_wait_queue(whead, &pwq->wait);
484 rcu_read_unlock();
485}
486
470/* 487/*
471 * This function unregisters poll callbacks from the associated file 488 * This function unregisters poll callbacks from the associated file
472 * descriptor. Must be called with "mtx" held (or "epmutex" if called from 489 * descriptor. Must be called with "mtx" held (or "epmutex" if called from
@@ -481,7 +498,7 @@ static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
481 pwq = list_first_entry(lsthead, struct eppoll_entry, llink); 498 pwq = list_first_entry(lsthead, struct eppoll_entry, llink);
482 499
483 list_del(&pwq->llink); 500 list_del(&pwq->llink);
484 remove_wait_queue(pwq->whead, &pwq->wait); 501 ep_remove_wait_queue(pwq);
485 kmem_cache_free(pwq_cache, pwq); 502 kmem_cache_free(pwq_cache, pwq);
486 } 503 }
487} 504}
@@ -842,6 +859,17 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
842 struct epitem *epi = ep_item_from_wait(wait); 859 struct epitem *epi = ep_item_from_wait(wait);
843 struct eventpoll *ep = epi->ep; 860 struct eventpoll *ep = epi->ep;
844 861
862 if ((unsigned long)key & POLLFREE) {
863 ep_pwq_from_wait(wait)->whead = NULL;
864 /*
865 * whead = NULL above can race with ep_remove_wait_queue()
866 * which can do another remove_wait_queue() after us, so we
867 * can't use __remove_wait_queue(). whead->lock is held by
868 * the caller.
869 */
870 list_del_init(&wait->task_list);
871 }
872
845 spin_lock_irqsave(&ep->lock, flags); 873 spin_lock_irqsave(&ep->lock, flags);
846 874
847 /* 875 /*
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 492465b451dd..7ae2a574cb25 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -30,6 +30,21 @@
30#include <linux/signalfd.h> 30#include <linux/signalfd.h>
31#include <linux/syscalls.h> 31#include <linux/syscalls.h>
32 32
33void signalfd_cleanup(struct sighand_struct *sighand)
34{
35 wait_queue_head_t *wqh = &sighand->signalfd_wqh;
36 /*
37 * The lockless check can race with remove_wait_queue() in progress,
38 * but in this case its caller should run under rcu_read_lock() and
39 * sighand_cachep is SLAB_DESTROY_BY_RCU, we can safely return.
40 */
41 if (likely(!waitqueue_active(wqh)))
42 return;
43
44 /* wait_queue_t->func(POLLFREE) should do remove_wait_queue() */
45 wake_up_poll(wqh, POLLHUP | POLLFREE);
46}
47
33struct signalfd_ctx { 48struct signalfd_ctx {
34 sigset_t sigmask; 49 sigset_t sigmask;
35}; 50};
diff --git a/include/asm-generic/poll.h b/include/asm-generic/poll.h
index 44bce836d350..9ce7f44aebd2 100644
--- a/include/asm-generic/poll.h
+++ b/include/asm-generic/poll.h
@@ -28,6 +28,8 @@
28#define POLLRDHUP 0x2000 28#define POLLRDHUP 0x2000
29#endif 29#endif
30 30
31#define POLLFREE 0x4000 /* currently only for epoll */
32
31struct pollfd { 33struct pollfd {
32 int fd; 34 int fd;
33 short events; 35 short events;
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 41c9f6515f46..7e05fcee75a1 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -561,5 +561,9 @@ asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
561 unsigned long liovcnt, const struct compat_iovec __user *rvec, 561 unsigned long liovcnt, const struct compat_iovec __user *rvec,
562 unsigned long riovcnt, unsigned long flags); 562 unsigned long riovcnt, unsigned long flags);
563 563
564#else
565
566#define is_compat_task() (0)
567
564#endif /* CONFIG_COMPAT */ 568#endif /* CONFIG_COMPAT */
565#endif /* _LINUX_COMPAT_H */ 569#endif /* _LINUX_COMPAT_H */
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index c52d4b5f872a..4b24ff453aee 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -137,6 +137,7 @@ enum {
137 IFLA_AF_SPEC, 137 IFLA_AF_SPEC,
138 IFLA_GROUP, /* Group the device belongs to */ 138 IFLA_GROUP, /* Group the device belongs to */
139 IFLA_NET_NS_FD, 139 IFLA_NET_NS_FD,
140 IFLA_EXT_MASK, /* Extended info mask, VFs, etc */
140 __IFLA_MAX 141 __IFLA_MAX
141}; 142};
142 143
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index 8797ed16feb2..4dd5bd6994a8 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -285,8 +285,8 @@ struct ebt_table {
285 struct module *me; 285 struct module *me;
286}; 286};
287 287
288#define EBT_ALIGN(s) (((s) + (__alignof__(struct ebt_replace)-1)) & \ 288#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \
289 ~(__alignof__(struct ebt_replace)-1)) 289 ~(__alignof__(struct _xt_align)-1))
290extern struct ebt_table *ebt_register_table(struct net *net, 290extern struct ebt_table *ebt_register_table(struct net *net,
291 const struct ebt_table *table); 291 const struct ebt_table *table);
292extern void ebt_unregister_table(struct net *net, struct ebt_table *table); 292extern void ebt_unregister_table(struct net *net, struct ebt_table *table);
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 8e872ead88b5..577592ea0ea0 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -602,6 +602,9 @@ struct tcamsg {
602#define TCA_ACT_TAB 1 /* attr type must be >=1 */ 602#define TCA_ACT_TAB 1 /* attr type must be >=1 */
603#define TCAA_MAX 1 603#define TCAA_MAX 1
604 604
605/* New extended info filters for IFLA_EXT_MASK */
606#define RTEXT_FILTER_VF (1 << 0)
607
605/* End of information exported to user level */ 608/* End of information exported to user level */
606 609
607#ifdef __KERNEL__ 610#ifdef __KERNEL__
diff --git a/include/linux/signalfd.h b/include/linux/signalfd.h
index 3ff4961da9b5..247399b2979a 100644
--- a/include/linux/signalfd.h
+++ b/include/linux/signalfd.h
@@ -61,13 +61,16 @@ static inline void signalfd_notify(struct task_struct *tsk, int sig)
61 wake_up(&tsk->sighand->signalfd_wqh); 61 wake_up(&tsk->sighand->signalfd_wqh);
62} 62}
63 63
64extern void signalfd_cleanup(struct sighand_struct *sighand);
65
64#else /* CONFIG_SIGNALFD */ 66#else /* CONFIG_SIGNALFD */
65 67
66static inline void signalfd_notify(struct task_struct *tsk, int sig) { } 68static inline void signalfd_notify(struct task_struct *tsk, int sig) { }
67 69
70static inline void signalfd_cleanup(struct sighand_struct *sighand) { }
71
68#endif /* CONFIG_SIGNALFD */ 72#endif /* CONFIG_SIGNALFD */
69 73
70#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
71 75
72#endif /* _LINUX_SIGNALFD_H */ 76#endif /* _LINUX_SIGNALFD_H */
73
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 50db9b04a552..ae86adee3746 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1465,6 +1465,16 @@ static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1465} 1465}
1466#endif /* NET_SKBUFF_DATA_USES_OFFSET */ 1466#endif /* NET_SKBUFF_DATA_USES_OFFSET */
1467 1467
1468static inline void skb_mac_header_rebuild(struct sk_buff *skb)
1469{
1470 if (skb_mac_header_was_set(skb)) {
1471 const unsigned char *old_mac = skb_mac_header(skb);
1472
1473 skb_set_mac_header(skb, -skb->mac_len);
1474 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
1475 }
1476}
1477
1468static inline int skb_checksum_start_offset(const struct sk_buff *skb) 1478static inline int skb_checksum_start_offset(const struct sk_buff *skb)
1469{ 1479{
1470 return skb->csum_start - skb_headroom(skb); 1480 return skb->csum_start - skb_headroom(skb);
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index abaad6ed9b83..4a82ca0bb0b2 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -256,4 +256,6 @@ void l2cap_exit(void);
256int sco_init(void); 256int sco_init(void);
257void sco_exit(void); 257void sco_exit(void);
258 258
259void bt_sock_reclassify_lock(struct sock *sk, int proto);
260
259#endif /* __BLUETOOTH_H */ 261#endif /* __BLUETOOTH_H */
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ea9231f4935f..453893b3120e 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -540,7 +540,7 @@ void hci_conn_put_device(struct hci_conn *conn);
540static inline void hci_conn_hold(struct hci_conn *conn) 540static inline void hci_conn_hold(struct hci_conn *conn)
541{ 541{
542 atomic_inc(&conn->refcnt); 542 atomic_inc(&conn->refcnt);
543 cancel_delayed_work_sync(&conn->disc_work); 543 cancel_delayed_work(&conn->disc_work);
544} 544}
545 545
546static inline void hci_conn_put(struct hci_conn *conn) 546static inline void hci_conn_put(struct hci_conn *conn)
@@ -559,9 +559,9 @@ static inline void hci_conn_put(struct hci_conn *conn)
559 } else { 559 } else {
560 timeo = msecs_to_jiffies(10); 560 timeo = msecs_to_jiffies(10);
561 } 561 }
562 cancel_delayed_work_sync(&conn->disc_work); 562 cancel_delayed_work(&conn->disc_work);
563 queue_delayed_work(conn->hdev->workqueue, 563 queue_delayed_work(conn->hdev->workqueue,
564 &conn->disc_work, jiffies + timeo); 564 &conn->disc_work, timeo);
565 } 565 }
566} 566}
567 567
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 68f589150692..b1664ed884e6 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -611,7 +611,7 @@ static inline void l2cap_set_timer(struct l2cap_chan *chan,
611{ 611{
612 BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout); 612 BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout);
613 613
614 if (!__cancel_delayed_work(work)) 614 if (!cancel_delayed_work(work))
615 l2cap_chan_hold(chan); 615 l2cap_chan_hold(chan);
616 schedule_delayed_work(work, timeout); 616 schedule_delayed_work(work, timeout);
617} 617}
@@ -619,20 +619,20 @@ static inline void l2cap_set_timer(struct l2cap_chan *chan,
619static inline void l2cap_clear_timer(struct l2cap_chan *chan, 619static inline void l2cap_clear_timer(struct l2cap_chan *chan,
620 struct delayed_work *work) 620 struct delayed_work *work)
621{ 621{
622 if (__cancel_delayed_work(work)) 622 if (cancel_delayed_work(work))
623 l2cap_chan_put(chan); 623 l2cap_chan_put(chan);
624} 624}
625 625
626#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) 626#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
627#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) 627#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer)
628#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ 628#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \
629 L2CAP_DEFAULT_RETRANS_TO); 629 msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO));
630#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) 630#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer)
631#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ 631#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \
632 L2CAP_DEFAULT_MONITOR_TO); 632 msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO));
633#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) 633#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer)
634#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ 634#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \
635 L2CAP_DEFAULT_ACK_TO); 635 msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
636#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) 636#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer)
637 637
638static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) 638static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
@@ -834,7 +834,7 @@ int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);
834struct l2cap_chan *l2cap_chan_create(struct sock *sk); 834struct l2cap_chan *l2cap_chan_create(struct sock *sk);
835void l2cap_chan_close(struct l2cap_chan *chan, int reason); 835void l2cap_chan_close(struct l2cap_chan *chan, int reason);
836void l2cap_chan_destroy(struct l2cap_chan *chan); 836void l2cap_chan_destroy(struct l2cap_chan *chan);
837inline int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, 837int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
838 bdaddr_t *dst); 838 bdaddr_t *dst);
839int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, 839int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
840 u32 priority); 840 u32 priority);
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 8a2b0ae7dbd2..ab86036bbf0c 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -209,7 +209,7 @@ extern struct nf_conntrack_tuple_hash *
209__nf_conntrack_find(struct net *net, u16 zone, 209__nf_conntrack_find(struct net *net, u16 zone,
210 const struct nf_conntrack_tuple *tuple); 210 const struct nf_conntrack_tuple *tuple);
211 211
212extern void nf_conntrack_hash_insert(struct nf_conn *ct); 212extern int nf_conntrack_hash_check_insert(struct nf_conn *ct);
213extern void nf_ct_delete_from_lists(struct nf_conn *ct); 213extern void nf_ct_delete_from_lists(struct nf_conn *ct);
214extern void nf_ct_insert_dying_list(struct nf_conn *ct); 214extern void nf_ct_insert_dying_list(struct nf_conn *ct);
215 215
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 678f1ffaf843..370293901971 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -6,7 +6,7 @@
6 6
7typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *); 7typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *);
8typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *); 8typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *);
9typedef u16 (*rtnl_calcit_func)(struct sk_buff *); 9typedef u16 (*rtnl_calcit_func)(struct sk_buff *, struct nlmsghdr *);
10 10
11extern int __rtnl_register(int protocol, int msgtype, 11extern int __rtnl_register(int protocol, int msgtype,
12 rtnl_doit_func, rtnl_dumpit_func, 12 rtnl_doit_func, rtnl_dumpit_func,
diff --git a/kernel/fork.c b/kernel/fork.c
index b77fd559c78e..e2cd3e2a5ae8 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -66,6 +66,7 @@
66#include <linux/user-return-notifier.h> 66#include <linux/user-return-notifier.h>
67#include <linux/oom.h> 67#include <linux/oom.h>
68#include <linux/khugepaged.h> 68#include <linux/khugepaged.h>
69#include <linux/signalfd.h>
69 70
70#include <asm/pgtable.h> 71#include <asm/pgtable.h>
71#include <asm/pgalloc.h> 72#include <asm/pgalloc.h>
@@ -935,8 +936,10 @@ static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk)
935 936
936void __cleanup_sighand(struct sighand_struct *sighand) 937void __cleanup_sighand(struct sighand_struct *sighand)
937{ 938{
938 if (atomic_dec_and_test(&sighand->count)) 939 if (atomic_dec_and_test(&sighand->count)) {
940 signalfd_cleanup(sighand);
939 kmem_cache_free(sighand_cachep, sighand); 941 kmem_cache_free(sighand_cachep, sighand);
942 }
940} 943}
941 944
942 945
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6728a7ae6f2d..228d6461c12a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4414,6 +4414,9 @@ static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp,
4414 */ 4414 */
4415 BUG_ON(!thresholds); 4415 BUG_ON(!thresholds);
4416 4416
4417 if (!thresholds->primary)
4418 goto unlock;
4419
4417 usage = mem_cgroup_usage(memcg, type == _MEMSWAP); 4420 usage = mem_cgroup_usage(memcg, type == _MEMSWAP);
4418 4421
4419 /* Check if a threshold crossed before removing */ 4422 /* Check if a threshold crossed before removing */
@@ -4462,7 +4465,7 @@ swap_buffers:
4462 4465
4463 /* To be sure that nobody uses thresholds */ 4466 /* To be sure that nobody uses thresholds */
4464 synchronize_rcu(); 4467 synchronize_rcu();
4465 4468unlock:
4466 mutex_unlock(&memcg->thresholds_lock); 4469 mutex_unlock(&memcg->thresholds_lock);
4467} 4470}
4468 4471
diff --git a/mm/nommu.c b/mm/nommu.c
index b982290fd962..f59e170fceb4 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -696,9 +696,11 @@ static void add_vma_to_mm(struct mm_struct *mm, struct vm_area_struct *vma)
696 if (vma->vm_file) { 696 if (vma->vm_file) {
697 mapping = vma->vm_file->f_mapping; 697 mapping = vma->vm_file->f_mapping;
698 698
699 mutex_lock(&mapping->i_mmap_mutex);
699 flush_dcache_mmap_lock(mapping); 700 flush_dcache_mmap_lock(mapping);
700 vma_prio_tree_insert(vma, &mapping->i_mmap); 701 vma_prio_tree_insert(vma, &mapping->i_mmap);
701 flush_dcache_mmap_unlock(mapping); 702 flush_dcache_mmap_unlock(mapping);
703 mutex_unlock(&mapping->i_mmap_mutex);
702 } 704 }
703 705
704 /* add the VMA to the tree */ 706 /* add the VMA to the tree */
@@ -760,9 +762,11 @@ static void delete_vma_from_mm(struct vm_area_struct *vma)
760 if (vma->vm_file) { 762 if (vma->vm_file) {
761 mapping = vma->vm_file->f_mapping; 763 mapping = vma->vm_file->f_mapping;
762 764
765 mutex_lock(&mapping->i_mmap_mutex);
763 flush_dcache_mmap_lock(mapping); 766 flush_dcache_mmap_lock(mapping);
764 vma_prio_tree_remove(vma, &mapping->i_mmap); 767 vma_prio_tree_remove(vma, &mapping->i_mmap);
765 flush_dcache_mmap_unlock(mapping); 768 flush_dcache_mmap_unlock(mapping);
769 mutex_unlock(&mapping->i_mmap_mutex);
766 } 770 }
767 771
768 /* remove from the MM's tree and list */ 772 /* remove from the MM's tree and list */
@@ -775,8 +779,6 @@ static void delete_vma_from_mm(struct vm_area_struct *vma)
775 779
776 if (vma->vm_next) 780 if (vma->vm_next)
777 vma->vm_next->vm_prev = vma->vm_prev; 781 vma->vm_next->vm_prev = vma->vm_prev;
778
779 vma->vm_mm = NULL;
780} 782}
781 783
782/* 784/*
@@ -2052,6 +2054,7 @@ int nommu_shrink_inode_mappings(struct inode *inode, size_t size,
2052 high = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 2054 high = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
2053 2055
2054 down_write(&nommu_region_sem); 2056 down_write(&nommu_region_sem);
2057 mutex_lock(&inode->i_mapping->i_mmap_mutex);
2055 2058
2056 /* search for VMAs that fall within the dead zone */ 2059 /* search for VMAs that fall within the dead zone */
2057 vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap, 2060 vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap,
@@ -2059,6 +2062,7 @@ int nommu_shrink_inode_mappings(struct inode *inode, size_t size,
2059 /* found one - only interested if it's shared out of the page 2062 /* found one - only interested if it's shared out of the page
2060 * cache */ 2063 * cache */
2061 if (vma->vm_flags & VM_SHARED) { 2064 if (vma->vm_flags & VM_SHARED) {
2065 mutex_unlock(&inode->i_mapping->i_mmap_mutex);
2062 up_write(&nommu_region_sem); 2066 up_write(&nommu_region_sem);
2063 return -ETXTBSY; /* not quite true, but near enough */ 2067 return -ETXTBSY; /* not quite true, but near enough */
2064 } 2068 }
@@ -2086,6 +2090,7 @@ int nommu_shrink_inode_mappings(struct inode *inode, size_t size,
2086 } 2090 }
2087 } 2091 }
2088 2092
2093 mutex_unlock(&inode->i_mapping->i_mmap_mutex);
2089 up_write(&nommu_region_sem); 2094 up_write(&nommu_region_sem);
2090 return 0; 2095 return 0;
2091} 2096}
diff --git a/net/atm/clip.c b/net/atm/clip.c
index c12c2582457c..127fe70a1baa 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -46,8 +46,8 @@
46 46
47static struct net_device *clip_devs; 47static struct net_device *clip_devs;
48static struct atm_vcc *atmarpd; 48static struct atm_vcc *atmarpd;
49static struct neigh_table clip_tbl;
50static struct timer_list idle_timer; 49static struct timer_list idle_timer;
50static const struct neigh_ops clip_neigh_ops;
51 51
52static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip) 52static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip)
53{ 53{
@@ -123,6 +123,8 @@ static int neigh_check_cb(struct neighbour *n)
123 struct atmarp_entry *entry = neighbour_priv(n); 123 struct atmarp_entry *entry = neighbour_priv(n);
124 struct clip_vcc *cv; 124 struct clip_vcc *cv;
125 125
126 if (n->ops != &clip_neigh_ops)
127 return 0;
126 for (cv = entry->vccs; cv; cv = cv->next) { 128 for (cv = entry->vccs; cv; cv = cv->next) {
127 unsigned long exp = cv->last_use + cv->idle_timeout; 129 unsigned long exp = cv->last_use + cv->idle_timeout;
128 130
@@ -154,10 +156,10 @@ static int neigh_check_cb(struct neighbour *n)
154 156
155static void idle_timer_check(unsigned long dummy) 157static void idle_timer_check(unsigned long dummy)
156{ 158{
157 write_lock(&clip_tbl.lock); 159 write_lock(&arp_tbl.lock);
158 __neigh_for_each_release(&clip_tbl, neigh_check_cb); 160 __neigh_for_each_release(&arp_tbl, neigh_check_cb);
159 mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ); 161 mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ);
160 write_unlock(&clip_tbl.lock); 162 write_unlock(&arp_tbl.lock);
161} 163}
162 164
163static int clip_arp_rcv(struct sk_buff *skb) 165static int clip_arp_rcv(struct sk_buff *skb)
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index ef92864ac625..72eb187a5f60 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -71,19 +71,16 @@ static const char *const bt_slock_key_strings[BT_MAX_PROTO] = {
71 "slock-AF_BLUETOOTH-BTPROTO_AVDTP", 71 "slock-AF_BLUETOOTH-BTPROTO_AVDTP",
72}; 72};
73 73
74static inline void bt_sock_reclassify_lock(struct socket *sock, int proto) 74void bt_sock_reclassify_lock(struct sock *sk, int proto)
75{ 75{
76 struct sock *sk = sock->sk; 76 BUG_ON(!sk);
77
78 if (!sk)
79 return;
80
81 BUG_ON(sock_owned_by_user(sk)); 77 BUG_ON(sock_owned_by_user(sk));
82 78
83 sock_lock_init_class_and_name(sk, 79 sock_lock_init_class_and_name(sk,
84 bt_slock_key_strings[proto], &bt_slock_key[proto], 80 bt_slock_key_strings[proto], &bt_slock_key[proto],
85 bt_key_strings[proto], &bt_lock_key[proto]); 81 bt_key_strings[proto], &bt_lock_key[proto]);
86} 82}
83EXPORT_SYMBOL(bt_sock_reclassify_lock);
87 84
88int bt_sock_register(int proto, const struct net_proto_family *ops) 85int bt_sock_register(int proto, const struct net_proto_family *ops)
89{ 86{
@@ -145,7 +142,8 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto,
145 142
146 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { 143 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
147 err = bt_proto[proto]->create(net, sock, proto, kern); 144 err = bt_proto[proto]->create(net, sock, proto, kern);
148 bt_sock_reclassify_lock(sock, proto); 145 if (!err)
146 bt_sock_reclassify_lock(sock->sk, proto);
149 module_put(bt_proto[proto]->owner); 147 module_put(bt_proto[proto]->owner);
150 } 148 }
151 149
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 3db432473ad5..07bc69ed9498 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -635,6 +635,10 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
635 635
636 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { 636 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
637 struct hci_cp_auth_requested cp; 637 struct hci_cp_auth_requested cp;
638
639 /* encrypt must be pending if auth is also pending */
640 set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
641
638 cp.handle = cpu_to_le16(conn->handle); 642 cp.handle = cpu_to_le16(conn->handle);
639 hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED, 643 hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
640 sizeof(cp), &cp); 644 sizeof(cp), &cp);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9de93714213a..5aeb62491198 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -640,7 +640,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
640 /* Reset device */ 640 /* Reset device */
641 skb_queue_purge(&hdev->cmd_q); 641 skb_queue_purge(&hdev->cmd_q);
642 atomic_set(&hdev->cmd_cnt, 1); 642 atomic_set(&hdev->cmd_cnt, 1);
643 if (!test_bit(HCI_RAW, &hdev->flags)) { 643 if (!test_bit(HCI_RAW, &hdev->flags) &&
644 test_bit(HCI_QUIRK_NO_RESET, &hdev->quirks)) {
644 set_bit(HCI_INIT, &hdev->flags); 645 set_bit(HCI_INIT, &hdev->flags);
645 __hci_request(hdev, hci_reset_req, 0, 646 __hci_request(hdev, hci_reset_req, 0,
646 msecs_to_jiffies(250)); 647 msecs_to_jiffies(250));
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index faf0b11ac1d3..32d338c30e65 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1018,10 +1018,10 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
1018 hci_chan_del(conn->hchan); 1018 hci_chan_del(conn->hchan);
1019 1019
1020 if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) 1020 if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)
1021 __cancel_delayed_work(&conn->info_timer); 1021 cancel_delayed_work_sync(&conn->info_timer);
1022 1022
1023 if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend)) { 1023 if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend)) {
1024 __cancel_delayed_work(&conn->security_timer); 1024 cancel_delayed_work_sync(&conn->security_timer);
1025 smp_chan_destroy(conn); 1025 smp_chan_destroy(conn);
1026 } 1026 }
1027 1027
@@ -1120,7 +1120,7 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, bdaddr
1120 return c1; 1120 return c1;
1121} 1121}
1122 1122
1123inline int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *dst) 1123int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *dst)
1124{ 1124{
1125 struct sock *sk = chan->sk; 1125 struct sock *sk = chan->sk;
1126 bdaddr_t *src = &bt_sk(sk)->src; 1126 bdaddr_t *src = &bt_sk(sk)->src;
@@ -2574,7 +2574,7 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd
2574 2574
2575 if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) && 2575 if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) &&
2576 cmd->ident == conn->info_ident) { 2576 cmd->ident == conn->info_ident) {
2577 __cancel_delayed_work(&conn->info_timer); 2577 cancel_delayed_work(&conn->info_timer);
2578 2578
2579 conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; 2579 conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
2580 conn->info_ident = 0; 2580 conn->info_ident = 0;
@@ -2970,7 +2970,8 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2970 2970
2971 default: 2971 default:
2972 sk->sk_err = ECONNRESET; 2972 sk->sk_err = ECONNRESET;
2973 __set_chan_timer(chan, L2CAP_DISC_REJ_TIMEOUT); 2973 __set_chan_timer(chan,
2974 msecs_to_jiffies(L2CAP_DISC_REJ_TIMEOUT));
2974 l2cap_send_disconn_req(conn, chan, ECONNRESET); 2975 l2cap_send_disconn_req(conn, chan, ECONNRESET);
2975 goto done; 2976 goto done;
2976 } 2977 }
@@ -3120,7 +3121,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
3120 conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) 3121 conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)
3121 return 0; 3122 return 0;
3122 3123
3123 __cancel_delayed_work(&conn->info_timer); 3124 cancel_delayed_work(&conn->info_timer);
3124 3125
3125 if (result != L2CAP_IR_SUCCESS) { 3126 if (result != L2CAP_IR_SUCCESS) {
3126 conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; 3127 conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
@@ -4478,7 +4479,8 @@ static inline void l2cap_check_encryption(struct l2cap_chan *chan, u8 encrypt)
4478 if (encrypt == 0x00) { 4479 if (encrypt == 0x00) {
4479 if (chan->sec_level == BT_SECURITY_MEDIUM) { 4480 if (chan->sec_level == BT_SECURITY_MEDIUM) {
4480 __clear_chan_timer(chan); 4481 __clear_chan_timer(chan);
4481 __set_chan_timer(chan, L2CAP_ENC_TIMEOUT); 4482 __set_chan_timer(chan,
4483 msecs_to_jiffies(L2CAP_ENC_TIMEOUT));
4482 } else if (chan->sec_level == BT_SECURITY_HIGH) 4484 } else if (chan->sec_level == BT_SECURITY_HIGH)
4483 l2cap_chan_close(chan, ECONNREFUSED); 4485 l2cap_chan_close(chan, ECONNREFUSED);
4484 } else { 4486 } else {
@@ -4499,7 +4501,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
4499 4501
4500 if (hcon->type == LE_LINK) { 4502 if (hcon->type == LE_LINK) {
4501 smp_distribute_keys(conn, 0); 4503 smp_distribute_keys(conn, 0);
4502 __cancel_delayed_work(&conn->security_timer); 4504 cancel_delayed_work(&conn->security_timer);
4503 } 4505 }
4504 4506
4505 rcu_read_lock(); 4507 rcu_read_lock();
@@ -4546,7 +4548,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
4546 L2CAP_CONN_REQ, sizeof(req), &req); 4548 L2CAP_CONN_REQ, sizeof(req), &req);
4547 } else { 4549 } else {
4548 __clear_chan_timer(chan); 4550 __clear_chan_timer(chan);
4549 __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); 4551 __set_chan_timer(chan,
4552 msecs_to_jiffies(L2CAP_DISC_TIMEOUT));
4550 } 4553 }
4551 } else if (chan->state == BT_CONNECT2) { 4554 } else if (chan->state == BT_CONNECT2) {
4552 struct l2cap_conn_rsp rsp; 4555 struct l2cap_conn_rsp rsp;
@@ -4566,7 +4569,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
4566 } 4569 }
4567 } else { 4570 } else {
4568 l2cap_state_change(chan, BT_DISCONN); 4571 l2cap_state_change(chan, BT_DISCONN);
4569 __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); 4572 __set_chan_timer(chan,
4573 msecs_to_jiffies(L2CAP_DISC_TIMEOUT));
4570 res = L2CAP_CR_SEC_BLOCK; 4574 res = L2CAP_CR_SEC_BLOCK;
4571 stat = L2CAP_CS_NO_INFO; 4575 stat = L2CAP_CS_NO_INFO;
4572 } 4576 }
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index c61d967012b2..401d9428ae4c 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -849,6 +849,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
849 if (!sk) 849 if (!sk)
850 return NULL; 850 return NULL;
851 851
852 bt_sock_reclassify_lock(sk, BTPROTO_L2CAP);
853
852 l2cap_sock_init(sk, parent); 854 l2cap_sock_init(sk, parent);
853 855
854 return l2cap_pi(sk)->chan; 856 return l2cap_pi(sk)->chan;
@@ -1002,7 +1004,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p
1002 INIT_LIST_HEAD(&bt_sk(sk)->accept_q); 1004 INIT_LIST_HEAD(&bt_sk(sk)->accept_q);
1003 1005
1004 sk->sk_destruct = l2cap_sock_destruct; 1006 sk->sk_destruct = l2cap_sock_destruct;
1005 sk->sk_sndtimeo = L2CAP_CONN_TIMEOUT; 1007 sk->sk_sndtimeo = msecs_to_jiffies(L2CAP_CONN_TIMEOUT);
1006 1008
1007 sock_reset_flag(sk, SOCK_ZAPPED); 1009 sock_reset_flag(sk, SOCK_ZAPPED);
1008 1010
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 501649bf5596..8a602388f1e7 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -1164,12 +1164,18 @@ static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)
1164 break; 1164 break;
1165 1165
1166 case BT_DISCONN: 1166 case BT_DISCONN:
1167 /* When socket is closed and we are not RFCOMM 1167 /* rfcomm_session_put is called later so don't do
1168 * initiator rfcomm_process_rx already calls 1168 * anything here otherwise we will mess up the session
1169 * rfcomm_session_put() */ 1169 * reference counter:
1170 if (s->sock->sk->sk_state != BT_CLOSED) 1170 *
1171 if (list_empty(&s->dlcs)) 1171 * (a) when we are the initiator dlc_unlink will drive
1172 rfcomm_session_put(s); 1172 * the reference counter to 0 (there is no initial put
1173 * after session_add)
1174 *
1175 * (b) when we are not the initiator rfcomm_rx_process
1176 * will explicitly call put to balance the initial hold
1177 * done after session add.
1178 */
1173 break; 1179 break;
1174 } 1180 }
1175 } 1181 }
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index f066678faeee..22169c3f1482 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -956,6 +956,8 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
956 if (!sk) 956 if (!sk)
957 goto done; 957 goto done;
958 958
959 bt_sock_reclassify_lock(sk, BTPROTO_RFCOMM);
960
959 rfcomm_sock_init(sk, parent); 961 rfcomm_sock_init(sk, parent);
960 bacpy(&bt_sk(sk)->src, &src); 962 bacpy(&bt_sk(sk)->src, &src);
961 bacpy(&bt_sk(sk)->dst, &dst); 963 bacpy(&bt_sk(sk)->dst, &dst);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index e287346e0934..2a83914b0277 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -826,6 +826,8 @@ next_elt:
826 write_unlock_bh(&tbl->lock); 826 write_unlock_bh(&tbl->lock);
827 cond_resched(); 827 cond_resched();
828 write_lock_bh(&tbl->lock); 828 write_lock_bh(&tbl->lock);
829 nht = rcu_dereference_protected(tbl->nht,
830 lockdep_is_held(&tbl->lock));
829 } 831 }
830 /* Cycle through all hash buckets every base_reachable_time/2 ticks. 832 /* Cycle through all hash buckets every base_reachable_time/2 ticks.
831 * ARP entry timeouts range from 1/2 base_reachable_time to 3/2 833 * ARP entry timeouts range from 1/2 base_reachable_time to 3/2
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 65aebd450027..606a6e8f3671 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -60,7 +60,6 @@ struct rtnl_link {
60}; 60};
61 61
62static DEFINE_MUTEX(rtnl_mutex); 62static DEFINE_MUTEX(rtnl_mutex);
63static u16 min_ifinfo_dump_size;
64 63
65void rtnl_lock(void) 64void rtnl_lock(void)
66{ 65{
@@ -724,10 +723,11 @@ static void copy_rtnl_link_stats64(void *v, const struct rtnl_link_stats64 *b)
724} 723}
725 724
726/* All VF info */ 725/* All VF info */
727static inline int rtnl_vfinfo_size(const struct net_device *dev) 726static inline int rtnl_vfinfo_size(const struct net_device *dev,
727 u32 ext_filter_mask)
728{ 728{
729 if (dev->dev.parent && dev_is_pci(dev->dev.parent)) { 729 if (dev->dev.parent && dev_is_pci(dev->dev.parent) &&
730 730 (ext_filter_mask & RTEXT_FILTER_VF)) {
731 int num_vfs = dev_num_vf(dev->dev.parent); 731 int num_vfs = dev_num_vf(dev->dev.parent);
732 size_t size = nla_total_size(sizeof(struct nlattr)); 732 size_t size = nla_total_size(sizeof(struct nlattr));
733 size += nla_total_size(num_vfs * sizeof(struct nlattr)); 733 size += nla_total_size(num_vfs * sizeof(struct nlattr));
@@ -766,7 +766,8 @@ static size_t rtnl_port_size(const struct net_device *dev)
766 return port_self_size; 766 return port_self_size;
767} 767}
768 768
769static noinline size_t if_nlmsg_size(const struct net_device *dev) 769static noinline size_t if_nlmsg_size(const struct net_device *dev,
770 u32 ext_filter_mask)
770{ 771{
771 return NLMSG_ALIGN(sizeof(struct ifinfomsg)) 772 return NLMSG_ALIGN(sizeof(struct ifinfomsg))
772 + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */ 773 + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */
@@ -784,8 +785,9 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev)
784 + nla_total_size(4) /* IFLA_MASTER */ 785 + nla_total_size(4) /* IFLA_MASTER */
785 + nla_total_size(1) /* IFLA_OPERSTATE */ 786 + nla_total_size(1) /* IFLA_OPERSTATE */
786 + nla_total_size(1) /* IFLA_LINKMODE */ 787 + nla_total_size(1) /* IFLA_LINKMODE */
787 + nla_total_size(4) /* IFLA_NUM_VF */ 788 + nla_total_size(ext_filter_mask
788 + rtnl_vfinfo_size(dev) /* IFLA_VFINFO_LIST */ 789 & RTEXT_FILTER_VF ? 4 : 0) /* IFLA_NUM_VF */
790 + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */
789 + rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */ 791 + rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
790 + rtnl_link_get_size(dev) /* IFLA_LINKINFO */ 792 + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
791 + rtnl_link_get_af_size(dev); /* IFLA_AF_SPEC */ 793 + rtnl_link_get_af_size(dev); /* IFLA_AF_SPEC */
@@ -868,7 +870,7 @@ static int rtnl_port_fill(struct sk_buff *skb, struct net_device *dev)
868 870
869static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, 871static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
870 int type, u32 pid, u32 seq, u32 change, 872 int type, u32 pid, u32 seq, u32 change,
871 unsigned int flags) 873 unsigned int flags, u32 ext_filter_mask)
872{ 874{
873 struct ifinfomsg *ifm; 875 struct ifinfomsg *ifm;
874 struct nlmsghdr *nlh; 876 struct nlmsghdr *nlh;
@@ -941,10 +943,11 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
941 goto nla_put_failure; 943 goto nla_put_failure;
942 copy_rtnl_link_stats64(nla_data(attr), stats); 944 copy_rtnl_link_stats64(nla_data(attr), stats);
943 945
944 if (dev->dev.parent) 946 if (dev->dev.parent && (ext_filter_mask & RTEXT_FILTER_VF))
945 NLA_PUT_U32(skb, IFLA_NUM_VF, dev_num_vf(dev->dev.parent)); 947 NLA_PUT_U32(skb, IFLA_NUM_VF, dev_num_vf(dev->dev.parent));
946 948
947 if (dev->netdev_ops->ndo_get_vf_config && dev->dev.parent) { 949 if (dev->netdev_ops->ndo_get_vf_config && dev->dev.parent
950 && (ext_filter_mask & RTEXT_FILTER_VF)) {
948 int i; 951 int i;
949 952
950 struct nlattr *vfinfo, *vf; 953 struct nlattr *vfinfo, *vf;
@@ -1048,6 +1051,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1048 struct net_device *dev; 1051 struct net_device *dev;
1049 struct hlist_head *head; 1052 struct hlist_head *head;
1050 struct hlist_node *node; 1053 struct hlist_node *node;
1054 struct nlattr *tb[IFLA_MAX+1];
1055 u32 ext_filter_mask = 0;
1051 1056
1052 s_h = cb->args[0]; 1057 s_h = cb->args[0];
1053 s_idx = cb->args[1]; 1058 s_idx = cb->args[1];
@@ -1055,6 +1060,12 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1055 rcu_read_lock(); 1060 rcu_read_lock();
1056 cb->seq = net->dev_base_seq; 1061 cb->seq = net->dev_base_seq;
1057 1062
1063 nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
1064 ifla_policy);
1065
1066 if (tb[IFLA_EXT_MASK])
1067 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
1068
1058 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { 1069 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
1059 idx = 0; 1070 idx = 0;
1060 head = &net->dev_index_head[h]; 1071 head = &net->dev_index_head[h];
@@ -1064,7 +1075,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1064 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, 1075 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
1065 NETLINK_CB(cb->skb).pid, 1076 NETLINK_CB(cb->skb).pid,
1066 cb->nlh->nlmsg_seq, 0, 1077 cb->nlh->nlmsg_seq, 0,
1067 NLM_F_MULTI) <= 0) 1078 NLM_F_MULTI,
1079 ext_filter_mask) <= 0)
1068 goto out; 1080 goto out;
1069 1081
1070 nl_dump_check_consistent(cb, nlmsg_hdr(skb)); 1082 nl_dump_check_consistent(cb, nlmsg_hdr(skb));
@@ -1100,6 +1112,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1100 [IFLA_VF_PORTS] = { .type = NLA_NESTED }, 1112 [IFLA_VF_PORTS] = { .type = NLA_NESTED },
1101 [IFLA_PORT_SELF] = { .type = NLA_NESTED }, 1113 [IFLA_PORT_SELF] = { .type = NLA_NESTED },
1102 [IFLA_AF_SPEC] = { .type = NLA_NESTED }, 1114 [IFLA_AF_SPEC] = { .type = NLA_NESTED },
1115 [IFLA_EXT_MASK] = { .type = NLA_U32 },
1103}; 1116};
1104EXPORT_SYMBOL(ifla_policy); 1117EXPORT_SYMBOL(ifla_policy);
1105 1118
@@ -1509,8 +1522,6 @@ errout:
1509 1522
1510 if (send_addr_notify) 1523 if (send_addr_notify)
1511 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); 1524 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
1512 min_ifinfo_dump_size = max_t(u16, if_nlmsg_size(dev),
1513 min_ifinfo_dump_size);
1514 1525
1515 return err; 1526 return err;
1516} 1527}
@@ -1842,6 +1853,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1842 struct net_device *dev = NULL; 1853 struct net_device *dev = NULL;
1843 struct sk_buff *nskb; 1854 struct sk_buff *nskb;
1844 int err; 1855 int err;
1856 u32 ext_filter_mask = 0;
1845 1857
1846 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); 1858 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
1847 if (err < 0) 1859 if (err < 0)
@@ -1850,6 +1862,9 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1850 if (tb[IFLA_IFNAME]) 1862 if (tb[IFLA_IFNAME])
1851 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); 1863 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
1852 1864
1865 if (tb[IFLA_EXT_MASK])
1866 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
1867
1853 ifm = nlmsg_data(nlh); 1868 ifm = nlmsg_data(nlh);
1854 if (ifm->ifi_index > 0) 1869 if (ifm->ifi_index > 0)
1855 dev = __dev_get_by_index(net, ifm->ifi_index); 1870 dev = __dev_get_by_index(net, ifm->ifi_index);
@@ -1861,12 +1876,12 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1861 if (dev == NULL) 1876 if (dev == NULL)
1862 return -ENODEV; 1877 return -ENODEV;
1863 1878
1864 nskb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL); 1879 nskb = nlmsg_new(if_nlmsg_size(dev, ext_filter_mask), GFP_KERNEL);
1865 if (nskb == NULL) 1880 if (nskb == NULL)
1866 return -ENOBUFS; 1881 return -ENOBUFS;
1867 1882
1868 err = rtnl_fill_ifinfo(nskb, dev, RTM_NEWLINK, NETLINK_CB(skb).pid, 1883 err = rtnl_fill_ifinfo(nskb, dev, RTM_NEWLINK, NETLINK_CB(skb).pid,
1869 nlh->nlmsg_seq, 0, 0); 1884 nlh->nlmsg_seq, 0, 0, ext_filter_mask);
1870 if (err < 0) { 1885 if (err < 0) {
1871 /* -EMSGSIZE implies BUG in if_nlmsg_size */ 1886 /* -EMSGSIZE implies BUG in if_nlmsg_size */
1872 WARN_ON(err == -EMSGSIZE); 1887 WARN_ON(err == -EMSGSIZE);
@@ -1877,8 +1892,31 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1877 return err; 1892 return err;
1878} 1893}
1879 1894
1880static u16 rtnl_calcit(struct sk_buff *skb) 1895static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
1881{ 1896{
1897 struct net *net = sock_net(skb->sk);
1898 struct net_device *dev;
1899 struct nlattr *tb[IFLA_MAX+1];
1900 u32 ext_filter_mask = 0;
1901 u16 min_ifinfo_dump_size = 0;
1902
1903 nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX, ifla_policy);
1904
1905 if (tb[IFLA_EXT_MASK])
1906 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
1907
1908 if (!ext_filter_mask)
1909 return NLMSG_GOODSIZE;
1910 /*
1911 * traverse the list of net devices and compute the minimum
1912 * buffer size based upon the filter mask.
1913 */
1914 list_for_each_entry(dev, &net->dev_base_head, dev_list) {
1915 min_ifinfo_dump_size = max_t(u16, min_ifinfo_dump_size,
1916 if_nlmsg_size(dev,
1917 ext_filter_mask));
1918 }
1919
1882 return min_ifinfo_dump_size; 1920 return min_ifinfo_dump_size;
1883} 1921}
1884 1922
@@ -1913,13 +1951,11 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
1913 int err = -ENOBUFS; 1951 int err = -ENOBUFS;
1914 size_t if_info_size; 1952 size_t if_info_size;
1915 1953
1916 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev)), GFP_KERNEL); 1954 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
1917 if (skb == NULL) 1955 if (skb == NULL)
1918 goto errout; 1956 goto errout;
1919 1957
1920 min_ifinfo_dump_size = max_t(u16, if_info_size, min_ifinfo_dump_size); 1958 err = rtnl_fill_ifinfo(skb, dev, type, 0, 0, change, 0, 0);
1921
1922 err = rtnl_fill_ifinfo(skb, dev, type, 0, 0, change, 0);
1923 if (err < 0) { 1959 if (err < 0) {
1924 /* -EMSGSIZE implies BUG in if_nlmsg_size() */ 1960 /* -EMSGSIZE implies BUG in if_nlmsg_size() */
1925 WARN_ON(err == -EMSGSIZE); 1961 WARN_ON(err == -EMSGSIZE);
@@ -1977,7 +2013,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1977 return -EOPNOTSUPP; 2013 return -EOPNOTSUPP;
1978 calcit = rtnl_get_calcit(family, type); 2014 calcit = rtnl_get_calcit(family, type);
1979 if (calcit) 2015 if (calcit)
1980 min_dump_alloc = calcit(skb); 2016 min_dump_alloc = calcit(skb, nlh);
1981 2017
1982 __rtnl_unlock(); 2018 __rtnl_unlock();
1983 rtnl = net->rtnl; 2019 rtnl = net->rtnl;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 6b3ca5ba4450..38673d2860e2 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -65,7 +65,7 @@
65 it is infeasible task. The most general solutions would be 65 it is infeasible task. The most general solutions would be
66 to keep skb->encapsulation counter (sort of local ttl), 66 to keep skb->encapsulation counter (sort of local ttl),
67 and silently drop packet when it expires. It is a good 67 and silently drop packet when it expires. It is a good
68 solution, but it supposes maintaing new variable in ALL 68 solution, but it supposes maintaining new variable in ALL
69 skb, even if no tunneling is used. 69 skb, even if no tunneling is used.
70 70
71 Current solution: xmit_recursion breaks dead loops. This is a percpu 71 Current solution: xmit_recursion breaks dead loops. This is a percpu
@@ -91,14 +91,14 @@
91 91
92 One of them is to parse packet trying to detect inner encapsulation 92 One of them is to parse packet trying to detect inner encapsulation
93 made by our node. It is difficult or even impossible, especially, 93 made by our node. It is difficult or even impossible, especially,
94 taking into account fragmentation. TO be short, tt is not solution at all. 94 taking into account fragmentation. TO be short, ttl is not solution at all.
95 95
96 Current solution: The solution was UNEXPECTEDLY SIMPLE. 96 Current solution: The solution was UNEXPECTEDLY SIMPLE.
97 We force DF flag on tunnels with preconfigured hop limit, 97 We force DF flag on tunnels with preconfigured hop limit,
98 that is ALL. :-) Well, it does not remove the problem completely, 98 that is ALL. :-) Well, it does not remove the problem completely,
99 but exponential growth of network traffic is changed to linear 99 but exponential growth of network traffic is changed to linear
100 (branches, that exceed pmtu are pruned) and tunnel mtu 100 (branches, that exceed pmtu are pruned) and tunnel mtu
101 fastly degrades to value <68, where looping stops. 101 rapidly degrades to value <68, where looping stops.
102 Yes, it is not good if there exists a router in the loop, 102 Yes, it is not good if there exists a router in the loop,
103 which does not force DF, even when encapsulating packets have DF set. 103 which does not force DF, even when encapsulating packets have DF set.
104 But it is not our problem! Nobody could accuse us, we made 104 But it is not our problem! Nobody could accuse us, we made
@@ -457,8 +457,8 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
457 GRE tunnels with enabled checksum. Tell them "thank you". 457 GRE tunnels with enabled checksum. Tell them "thank you".
458 458
459 Well, I wonder, rfc1812 was written by Cisco employee, 459 Well, I wonder, rfc1812 was written by Cisco employee,
460 what the hell these idiots break standrads established 460 what the hell these idiots break standards established
461 by themself??? 461 by themselves???
462 */ 462 */
463 463
464 const struct iphdr *iph = (const struct iphdr *)skb->data; 464 const struct iphdr *iph = (const struct iphdr *)skb->data;
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index aea5a199c37a..b072386cee21 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -630,6 +630,7 @@ static int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
630 630
631 pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num); 631 pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num);
632 632
633 err = -EOPNOTSUPP;
633 if (flags & MSG_OOB) 634 if (flags & MSG_OOB)
634 goto out; 635 goto out;
635 636
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index 63418185f524..e3db3f915114 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -110,10 +110,7 @@ static int xfrm4_beet_input(struct xfrm_state *x, struct sk_buff *skb)
110 110
111 skb_push(skb, sizeof(*iph)); 111 skb_push(skb, sizeof(*iph));
112 skb_reset_network_header(skb); 112 skb_reset_network_header(skb);
113 113 skb_mac_header_rebuild(skb);
114 memmove(skb->data - skb->mac_len, skb_mac_header(skb),
115 skb->mac_len);
116 skb_set_mac_header(skb, -skb->mac_len);
117 114
118 xfrm4_beet_make_header(skb); 115 xfrm4_beet_make_header(skb);
119 116
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index 534972e114ac..ed4bf11ef9f4 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -66,7 +66,6 @@ static int xfrm4_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
66 66
67static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) 67static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
68{ 68{
69 const unsigned char *old_mac;
70 int err = -EINVAL; 69 int err = -EINVAL;
71 70
72 if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPIP) 71 if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPIP)
@@ -84,10 +83,9 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
84 if (!(x->props.flags & XFRM_STATE_NOECN)) 83 if (!(x->props.flags & XFRM_STATE_NOECN))
85 ipip_ecn_decapsulate(skb); 84 ipip_ecn_decapsulate(skb);
86 85
87 old_mac = skb_mac_header(skb);
88 skb_set_mac_header(skb, -skb->mac_len);
89 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
90 skb_reset_network_header(skb); 86 skb_reset_network_header(skb);
87 skb_mac_header_rebuild(skb);
88
91 err = 0; 89 err = 0;
92 90
93out: 91out:
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index c7e95c8c579f..5aa3981a3922 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1926,8 +1926,10 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
1926 }; 1926 };
1927 1927
1928 dst = ip6_route_output(net, NULL, &fl6); 1928 dst = ip6_route_output(net, NULL, &fl6);
1929 if (!dst) 1929 if (dst->error) {
1930 dst_release(dst);
1930 goto out_free; 1931 goto out_free;
1932 }
1931 1933
1932 skb_dst_drop(skb); 1934 skb_dst_drop(skb);
1933 skb_dst_set(skb, dst); 1935 skb_dst_set(skb, dst);
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d8f02ef88e59..c964958ac470 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1545,9 +1545,10 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1545 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex); 1545 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex);
1546 1546
1547 dst = ip6_route_output(net, NULL, &fl6); 1547 dst = ip6_route_output(net, NULL, &fl6);
1548 if (dst == NULL) 1548 if (dst->error) {
1549 dst_release(dst);
1549 return; 1550 return;
1550 1551 }
1551 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0); 1552 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
1552 if (IS_ERR(dst)) 1553 if (IS_ERR(dst))
1553 return; 1554 return;
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c
index a81ce9450750..9949a356d62c 100644
--- a/net/ipv6/xfrm6_mode_beet.c
+++ b/net/ipv6/xfrm6_mode_beet.c
@@ -80,7 +80,6 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
80static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb) 80static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
81{ 81{
82 struct ipv6hdr *ip6h; 82 struct ipv6hdr *ip6h;
83 const unsigned char *old_mac;
84 int size = sizeof(struct ipv6hdr); 83 int size = sizeof(struct ipv6hdr);
85 int err; 84 int err;
86 85
@@ -90,10 +89,7 @@ static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
90 89
91 __skb_push(skb, size); 90 __skb_push(skb, size);
92 skb_reset_network_header(skb); 91 skb_reset_network_header(skb);
93 92 skb_mac_header_rebuild(skb);
94 old_mac = skb_mac_header(skb);
95 skb_set_mac_header(skb, -skb->mac_len);
96 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
97 93
98 xfrm6_beet_make_header(skb); 94 xfrm6_beet_make_header(skb);
99 95
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
index 261e6e6f487e..9f2095b19ad0 100644
--- a/net/ipv6/xfrm6_mode_tunnel.c
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -63,7 +63,6 @@ static int xfrm6_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
63static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) 63static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
64{ 64{
65 int err = -EINVAL; 65 int err = -EINVAL;
66 const unsigned char *old_mac;
67 66
68 if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPV6) 67 if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPV6)
69 goto out; 68 goto out;
@@ -80,10 +79,9 @@ static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
80 if (!(x->props.flags & XFRM_STATE_NOECN)) 79 if (!(x->props.flags & XFRM_STATE_NOECN))
81 ipip6_ecn_decapsulate(skb); 80 ipip6_ecn_decapsulate(skb);
82 81
83 old_mac = skb_mac_header(skb);
84 skb_set_mac_header(skb, -skb->mac_len);
85 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
86 skb_reset_network_header(skb); 82 skb_reset_network_header(skb);
83 skb_mac_header_rebuild(skb);
84
87 err = 0; 85 err = 0;
88 86
89out: 87out:
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 2406b3e7393f..d86217d56bd7 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -63,14 +63,14 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
63 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : "" 63 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
64 64
65 int res = scnprintf(buf, sizeof(buf), 65 int res = scnprintf(buf, sizeof(buf),
66 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", 66 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
67 TEST(AUTH), TEST(ASSOC), TEST(PS_STA), 67 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
68 TEST(PS_DRIVER), TEST(AUTHORIZED), 68 TEST(PS_DRIVER), TEST(AUTHORIZED),
69 TEST(SHORT_PREAMBLE), 69 TEST(SHORT_PREAMBLE),
70 TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT), 70 TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
71 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL), 71 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
72 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER), 72 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
73 TEST(TDLS_PEER_AUTH)); 73 TEST(TDLS_PEER_AUTH), TEST(RATE_CONTROL));
74#undef TEST 74#undef TEST
75 return simple_read_from_buffer(userbuf, count, ppos, buf, res); 75 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
76} 76}
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 5a5a7767d541..ad64f4d5271a 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -336,7 +336,7 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
336 int i; 336 int i;
337 u32 mask; 337 u32 mask;
338 338
339 if (sta) { 339 if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
340 ista = &sta->sta; 340 ista = &sta->sta;
341 priv_sta = sta->rate_ctrl_priv; 341 priv_sta = sta->rate_ctrl_priv;
342 } 342 }
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h
index 168427b0ffdc..80cfc006dd74 100644
--- a/net/mac80211/rate.h
+++ b/net/mac80211/rate.h
@@ -41,7 +41,7 @@ static inline void rate_control_tx_status(struct ieee80211_local *local,
41 struct ieee80211_sta *ista = &sta->sta; 41 struct ieee80211_sta *ista = &sta->sta;
42 void *priv_sta = sta->rate_ctrl_priv; 42 void *priv_sta = sta->rate_ctrl_priv;
43 43
44 if (!ref) 44 if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
45 return; 45 return;
46 46
47 ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb); 47 ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb);
@@ -62,6 +62,7 @@ static inline void rate_control_rate_init(struct sta_info *sta)
62 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 62 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
63 63
64 ref->ops->rate_init(ref->priv, sband, ista, priv_sta); 64 ref->ops->rate_init(ref->priv, sband, ista, priv_sta);
65 set_sta_flag(sta, WLAN_STA_RATE_CONTROL);
65} 66}
66 67
67static inline void rate_control_rate_update(struct ieee80211_local *local, 68static inline void rate_control_rate_update(struct ieee80211_local *local,
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 6f77f12dc3fc..bfed851d0d36 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -52,6 +52,7 @@
52 * @WLAN_STA_SP: Station is in a service period, so don't try to 52 * @WLAN_STA_SP: Station is in a service period, so don't try to
53 * reply to other uAPSD trigger frames or PS-Poll. 53 * reply to other uAPSD trigger frames or PS-Poll.
54 * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame. 54 * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame.
55 * @WLAN_STA_RATE_CONTROL: rate control was initialized for this station.
55 */ 56 */
56enum ieee80211_sta_info_flags { 57enum ieee80211_sta_info_flags {
57 WLAN_STA_AUTH, 58 WLAN_STA_AUTH,
@@ -71,6 +72,7 @@ enum ieee80211_sta_info_flags {
71 WLAN_STA_UAPSD, 72 WLAN_STA_UAPSD,
72 WLAN_STA_SP, 73 WLAN_STA_SP,
73 WLAN_STA_4ADDR_EVENT, 74 WLAN_STA_4ADDR_EVENT,
75 WLAN_STA_RATE_CONTROL,
74}; 76};
75 77
76enum ieee80211_sta_state { 78enum ieee80211_sta_state {
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 611c3359b94d..2555816e7788 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -232,6 +232,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
232 __be16 dport = 0; /* destination port to forward */ 232 __be16 dport = 0; /* destination port to forward */
233 unsigned int flags; 233 unsigned int flags;
234 struct ip_vs_conn_param param; 234 struct ip_vs_conn_param param;
235 const union nf_inet_addr fwmark = { .ip = htonl(svc->fwmark) };
235 union nf_inet_addr snet; /* source network of the client, 236 union nf_inet_addr snet; /* source network of the client,
236 after masking */ 237 after masking */
237 238
@@ -267,7 +268,6 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
267 { 268 {
268 int protocol = iph.protocol; 269 int protocol = iph.protocol;
269 const union nf_inet_addr *vaddr = &iph.daddr; 270 const union nf_inet_addr *vaddr = &iph.daddr;
270 const union nf_inet_addr fwmark = { .ip = htonl(svc->fwmark) };
271 __be16 vport = 0; 271 __be16 vport = 0;
272 272
273 if (dst_port == svc->port) { 273 if (dst_port == svc->port) {
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 76613f5a55c0..ed86a3be678e 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -404,19 +404,49 @@ static void __nf_conntrack_hash_insert(struct nf_conn *ct,
404 &net->ct.hash[repl_hash]); 404 &net->ct.hash[repl_hash]);
405} 405}
406 406
407void nf_conntrack_hash_insert(struct nf_conn *ct) 407int
408nf_conntrack_hash_check_insert(struct nf_conn *ct)
408{ 409{
409 struct net *net = nf_ct_net(ct); 410 struct net *net = nf_ct_net(ct);
410 unsigned int hash, repl_hash; 411 unsigned int hash, repl_hash;
412 struct nf_conntrack_tuple_hash *h;
413 struct hlist_nulls_node *n;
411 u16 zone; 414 u16 zone;
412 415
413 zone = nf_ct_zone(ct); 416 zone = nf_ct_zone(ct);
414 hash = hash_conntrack(net, zone, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 417 hash = hash_conntrack(net, zone,
415 repl_hash = hash_conntrack(net, zone, &ct->tuplehash[IP_CT_DIR_REPLY].tuple); 418 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
419 repl_hash = hash_conntrack(net, zone,
420 &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
421
422 spin_lock_bh(&nf_conntrack_lock);
416 423
424 /* See if there's one in the list already, including reverse */
425 hlist_nulls_for_each_entry(h, n, &net->ct.hash[hash], hnnode)
426 if (nf_ct_tuple_equal(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
427 &h->tuple) &&
428 zone == nf_ct_zone(nf_ct_tuplehash_to_ctrack(h)))
429 goto out;
430 hlist_nulls_for_each_entry(h, n, &net->ct.hash[repl_hash], hnnode)
431 if (nf_ct_tuple_equal(&ct->tuplehash[IP_CT_DIR_REPLY].tuple,
432 &h->tuple) &&
433 zone == nf_ct_zone(nf_ct_tuplehash_to_ctrack(h)))
434 goto out;
435
436 add_timer(&ct->timeout);
437 nf_conntrack_get(&ct->ct_general);
417 __nf_conntrack_hash_insert(ct, hash, repl_hash); 438 __nf_conntrack_hash_insert(ct, hash, repl_hash);
439 NF_CT_STAT_INC(net, insert);
440 spin_unlock_bh(&nf_conntrack_lock);
441
442 return 0;
443
444out:
445 NF_CT_STAT_INC(net, insert_failed);
446 spin_unlock_bh(&nf_conntrack_lock);
447 return -EEXIST;
418} 448}
419EXPORT_SYMBOL_GPL(nf_conntrack_hash_insert); 449EXPORT_SYMBOL_GPL(nf_conntrack_hash_check_insert);
420 450
421/* Confirm a connection given skb; places it in hash table */ 451/* Confirm a connection given skb; places it in hash table */
422int 452int
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 9307b033c0c9..30c9d4ca0218 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1367,15 +1367,12 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
1367 nf_ct_protonum(ct)); 1367 nf_ct_protonum(ct));
1368 if (helper == NULL) { 1368 if (helper == NULL) {
1369 rcu_read_unlock(); 1369 rcu_read_unlock();
1370 spin_unlock_bh(&nf_conntrack_lock);
1371#ifdef CONFIG_MODULES 1370#ifdef CONFIG_MODULES
1372 if (request_module("nfct-helper-%s", helpname) < 0) { 1371 if (request_module("nfct-helper-%s", helpname) < 0) {
1373 spin_lock_bh(&nf_conntrack_lock);
1374 err = -EOPNOTSUPP; 1372 err = -EOPNOTSUPP;
1375 goto err1; 1373 goto err1;
1376 } 1374 }
1377 1375
1378 spin_lock_bh(&nf_conntrack_lock);
1379 rcu_read_lock(); 1376 rcu_read_lock();
1380 helper = __nf_conntrack_helper_find(helpname, 1377 helper = __nf_conntrack_helper_find(helpname,
1381 nf_ct_l3num(ct), 1378 nf_ct_l3num(ct),
@@ -1468,8 +1465,10 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
1468 if (tstamp) 1465 if (tstamp)
1469 tstamp->start = ktime_to_ns(ktime_get_real()); 1466 tstamp->start = ktime_to_ns(ktime_get_real());
1470 1467
1471 add_timer(&ct->timeout); 1468 err = nf_conntrack_hash_check_insert(ct);
1472 nf_conntrack_hash_insert(ct); 1469 if (err < 0)
1470 goto err2;
1471
1473 rcu_read_unlock(); 1472 rcu_read_unlock();
1474 1473
1475 return ct; 1474 return ct;
@@ -1490,6 +1489,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1490 struct nf_conntrack_tuple otuple, rtuple; 1489 struct nf_conntrack_tuple otuple, rtuple;
1491 struct nf_conntrack_tuple_hash *h = NULL; 1490 struct nf_conntrack_tuple_hash *h = NULL;
1492 struct nfgenmsg *nfmsg = nlmsg_data(nlh); 1491 struct nfgenmsg *nfmsg = nlmsg_data(nlh);
1492 struct nf_conn *ct;
1493 u_int8_t u3 = nfmsg->nfgen_family; 1493 u_int8_t u3 = nfmsg->nfgen_family;
1494 u16 zone; 1494 u16 zone;
1495 int err; 1495 int err;
@@ -1510,27 +1510,22 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1510 return err; 1510 return err;
1511 } 1511 }
1512 1512
1513 spin_lock_bh(&nf_conntrack_lock);
1514 if (cda[CTA_TUPLE_ORIG]) 1513 if (cda[CTA_TUPLE_ORIG])
1515 h = __nf_conntrack_find(net, zone, &otuple); 1514 h = nf_conntrack_find_get(net, zone, &otuple);
1516 else if (cda[CTA_TUPLE_REPLY]) 1515 else if (cda[CTA_TUPLE_REPLY])
1517 h = __nf_conntrack_find(net, zone, &rtuple); 1516 h = nf_conntrack_find_get(net, zone, &rtuple);
1518 1517
1519 if (h == NULL) { 1518 if (h == NULL) {
1520 err = -ENOENT; 1519 err = -ENOENT;
1521 if (nlh->nlmsg_flags & NLM_F_CREATE) { 1520 if (nlh->nlmsg_flags & NLM_F_CREATE) {
1522 struct nf_conn *ct;
1523 enum ip_conntrack_events events; 1521 enum ip_conntrack_events events;
1524 1522
1525 ct = ctnetlink_create_conntrack(net, zone, cda, &otuple, 1523 ct = ctnetlink_create_conntrack(net, zone, cda, &otuple,
1526 &rtuple, u3); 1524 &rtuple, u3);
1527 if (IS_ERR(ct)) { 1525 if (IS_ERR(ct))
1528 err = PTR_ERR(ct); 1526 return PTR_ERR(ct);
1529 goto out_unlock; 1527
1530 }
1531 err = 0; 1528 err = 0;
1532 nf_conntrack_get(&ct->ct_general);
1533 spin_unlock_bh(&nf_conntrack_lock);
1534 if (test_bit(IPS_EXPECTED_BIT, &ct->status)) 1529 if (test_bit(IPS_EXPECTED_BIT, &ct->status))
1535 events = IPCT_RELATED; 1530 events = IPCT_RELATED;
1536 else 1531 else
@@ -1545,23 +1540,19 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1545 ct, NETLINK_CB(skb).pid, 1540 ct, NETLINK_CB(skb).pid,
1546 nlmsg_report(nlh)); 1541 nlmsg_report(nlh));
1547 nf_ct_put(ct); 1542 nf_ct_put(ct);
1548 } else 1543 }
1549 spin_unlock_bh(&nf_conntrack_lock);
1550 1544
1551 return err; 1545 return err;
1552 } 1546 }
1553 /* implicit 'else' */ 1547 /* implicit 'else' */
1554 1548
1555 /* We manipulate the conntrack inside the global conntrack table lock,
1556 * so there's no need to increase the refcount */
1557 err = -EEXIST; 1549 err = -EEXIST;
1550 ct = nf_ct_tuplehash_to_ctrack(h);
1558 if (!(nlh->nlmsg_flags & NLM_F_EXCL)) { 1551 if (!(nlh->nlmsg_flags & NLM_F_EXCL)) {
1559 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h); 1552 spin_lock_bh(&nf_conntrack_lock);
1560
1561 err = ctnetlink_change_conntrack(ct, cda); 1553 err = ctnetlink_change_conntrack(ct, cda);
1554 spin_unlock_bh(&nf_conntrack_lock);
1562 if (err == 0) { 1555 if (err == 0) {
1563 nf_conntrack_get(&ct->ct_general);
1564 spin_unlock_bh(&nf_conntrack_lock);
1565 nf_conntrack_eventmask_report((1 << IPCT_REPLY) | 1556 nf_conntrack_eventmask_report((1 << IPCT_REPLY) |
1566 (1 << IPCT_ASSURED) | 1557 (1 << IPCT_ASSURED) |
1567 (1 << IPCT_HELPER) | 1558 (1 << IPCT_HELPER) |
@@ -1570,15 +1561,10 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1570 (1 << IPCT_MARK), 1561 (1 << IPCT_MARK),
1571 ct, NETLINK_CB(skb).pid, 1562 ct, NETLINK_CB(skb).pid,
1572 nlmsg_report(nlh)); 1563 nlmsg_report(nlh));
1573 nf_ct_put(ct); 1564 }
1574 } else
1575 spin_unlock_bh(&nf_conntrack_lock);
1576
1577 return err;
1578 } 1565 }
1579 1566
1580out_unlock: 1567 nf_ct_put(ct);
1581 spin_unlock_bh(&nf_conntrack_lock);
1582 return err; 1568 return err;
1583} 1569}
1584 1570
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index b3a7db678b8d..ce60cf0f6c11 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -203,6 +203,27 @@ err:
203 return status; 203 return status;
204} 204}
205 205
206#ifdef CONFIG_BRIDGE_NETFILTER
207/* When called from bridge netfilter, skb->data must point to MAC header
208 * before calling skb_gso_segment(). Else, original MAC header is lost
209 * and segmented skbs will be sent to wrong destination.
210 */
211static void nf_bridge_adjust_skb_data(struct sk_buff *skb)
212{
213 if (skb->nf_bridge)
214 __skb_push(skb, skb->network_header - skb->mac_header);
215}
216
217static void nf_bridge_adjust_segmented_data(struct sk_buff *skb)
218{
219 if (skb->nf_bridge)
220 __skb_pull(skb, skb->network_header - skb->mac_header);
221}
222#else
223#define nf_bridge_adjust_skb_data(s) do {} while (0)
224#define nf_bridge_adjust_segmented_data(s) do {} while (0)
225#endif
226
206int nf_queue(struct sk_buff *skb, 227int nf_queue(struct sk_buff *skb,
207 struct list_head *elem, 228 struct list_head *elem,
208 u_int8_t pf, unsigned int hook, 229 u_int8_t pf, unsigned int hook,
@@ -212,7 +233,7 @@ int nf_queue(struct sk_buff *skb,
212 unsigned int queuenum) 233 unsigned int queuenum)
213{ 234{
214 struct sk_buff *segs; 235 struct sk_buff *segs;
215 int err; 236 int err = -EINVAL;
216 unsigned int queued; 237 unsigned int queued;
217 238
218 if (!skb_is_gso(skb)) 239 if (!skb_is_gso(skb))
@@ -228,23 +249,25 @@ int nf_queue(struct sk_buff *skb,
228 break; 249 break;
229 } 250 }
230 251
252 nf_bridge_adjust_skb_data(skb);
231 segs = skb_gso_segment(skb, 0); 253 segs = skb_gso_segment(skb, 0);
232 /* Does not use PTR_ERR to limit the number of error codes that can be 254 /* Does not use PTR_ERR to limit the number of error codes that can be
233 * returned by nf_queue. For instance, callers rely on -ECANCELED to mean 255 * returned by nf_queue. For instance, callers rely on -ECANCELED to mean
234 * 'ignore this hook'. 256 * 'ignore this hook'.
235 */ 257 */
236 if (IS_ERR(segs)) 258 if (IS_ERR(segs))
237 return -EINVAL; 259 goto out_err;
238
239 queued = 0; 260 queued = 0;
240 err = 0; 261 err = 0;
241 do { 262 do {
242 struct sk_buff *nskb = segs->next; 263 struct sk_buff *nskb = segs->next;
243 264
244 segs->next = NULL; 265 segs->next = NULL;
245 if (err == 0) 266 if (err == 0) {
267 nf_bridge_adjust_segmented_data(segs);
246 err = __nf_queue(segs, elem, pf, hook, indev, 268 err = __nf_queue(segs, elem, pf, hook, indev,
247 outdev, okfn, queuenum); 269 outdev, okfn, queuenum);
270 }
248 if (err == 0) 271 if (err == 0)
249 queued++; 272 queued++;
250 else 273 else
@@ -252,11 +275,12 @@ int nf_queue(struct sk_buff *skb,
252 segs = nskb; 275 segs = nskb;
253 } while (segs); 276 } while (segs);
254 277
255 /* also free orig skb if only some segments were queued */ 278 if (queued) {
256 if (unlikely(err && queued))
257 err = 0;
258 if (err == 0)
259 kfree_skb(skb); 279 kfree_skb(skb);
280 return 0;
281 }
282 out_err:
283 nf_bridge_adjust_segmented_data(skb);
260 return err; 284 return err;
261} 285}
262 286
diff --git a/net/netfilter/xt_TEE.c b/net/netfilter/xt_TEE.c
index 3aae66facf9f..4d5057902839 100644
--- a/net/netfilter/xt_TEE.c
+++ b/net/netfilter/xt_TEE.c
@@ -152,9 +152,10 @@ tee_tg_route6(struct sk_buff *skb, const struct xt_tee_tginfo *info)
152 fl6.flowlabel = ((iph->flow_lbl[0] & 0xF) << 16) | 152 fl6.flowlabel = ((iph->flow_lbl[0] & 0xF) << 16) |
153 (iph->flow_lbl[1] << 8) | iph->flow_lbl[2]; 153 (iph->flow_lbl[1] << 8) | iph->flow_lbl[2];
154 dst = ip6_route_output(net, NULL, &fl6); 154 dst = ip6_route_output(net, NULL, &fl6);
155 if (dst == NULL) 155 if (dst->error) {
156 dst_release(dst);
156 return false; 157 return false;
157 158 }
158 skb_dst_drop(skb); 159 skb_dst_drop(skb);
159 skb_dst_set(skb, dst); 160 skb_dst_set(skb, dst);
160 skb->dev = dst->dev; 161 skb->dev = dst->dev;
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index e83d61ca78ca..5da548fa7ae9 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -501,9 +501,8 @@ tfifo_dequeue:
501 501
502 /* if more time remaining? */ 502 /* if more time remaining? */
503 if (cb->time_to_send <= psched_get_time()) { 503 if (cb->time_to_send <= psched_get_time()) {
504 skb = qdisc_dequeue_tail(sch); 504 __skb_unlink(skb, &sch->q);
505 if (unlikely(!skb)) 505 sch->qstats.backlog -= qdisc_pkt_len(skb);
506 goto qdisc_dequeue;
507 506
508#ifdef CONFIG_NET_CLS_ACT 507#ifdef CONFIG_NET_CLS_ACT
509 /* 508 /*
@@ -539,7 +538,6 @@ deliver:
539 qdisc_watchdog_schedule(&q->watchdog, cb->time_to_send); 538 qdisc_watchdog_schedule(&q->watchdog, cb->time_to_send);
540 } 539 }
541 540
542qdisc_dequeue:
543 if (q->qdisc) { 541 if (q->qdisc) {
544 skb = q->qdisc->ops->dequeue(q->qdisc); 542 skb = q->qdisc->ops->dequeue(q->qdisc);
545 if (skb) 543 if (skb)
diff --git a/scripts/coccicheck b/scripts/coccicheck
index 3c2776466d87..823e972149e5 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -9,15 +9,10 @@ if [ "$C" = "1" -o "$C" = "2" ]; then
9# FLAGS="-ignore_unknown_options -very_quiet" 9# FLAGS="-ignore_unknown_options -very_quiet"
10# OPTIONS=$* 10# OPTIONS=$*
11 11
12 if [ "$KBUILD_EXTMOD" = "" ] ; then 12# Workaround for Coccinelle < 0.2.3
13 # Workaround for Coccinelle < 0.2.3 13 FLAGS="-I $srctree/include -very_quiet"
14 FLAGS="-I $srctree/include -very_quiet" 14 shift $(( $# - 1 ))
15 shift $(( $# - 1 )) 15 OPTIONS=$1
16 OPTIONS=$1
17 else
18 echo M= is not currently supported when C=1 or C=2
19 exit 1
20 fi
21else 16else
22 ONLINE=0 17 ONLINE=0
23 FLAGS="-very_quiet" 18 FLAGS="-very_quiet"
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index a27235685949..2ae481703141 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -9,12 +9,6 @@ fi
9DEPMOD=$1 9DEPMOD=$1
10KERNELRELEASE=$2 10KERNELRELEASE=$2
11 11
12if ! "$DEPMOD" -V 2>/dev/null | grep -q module-init-tools; then
13 echo "Warning: you may need to install module-init-tools" >&2
14 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt" >&2
15 sleep 1
16fi
17
18if ! test -r System.map -a -x "$DEPMOD"; then 12if ! test -r System.map -a -x "$DEPMOD"; then
19 exit 0 13 exit 0
20fi 14fi
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index d0de2a2c3a2d..b89efe6e4c85 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -46,11 +46,37 @@ struct devtable {
46 void *function; 46 void *function;
47}; 47};
48 48
49#define ___cat(a,b) a ## b
50#define __cat(a,b) ___cat(a,b)
51
52/* we need some special handling for this host tool running eventually on
53 * Darwin. The Mach-O section handling is a bit different than ELF section
54 * handling. The differnces in detail are:
55 * a) we have segments which have sections
56 * b) we need a API call to get the respective section symbols */
57#if defined(__MACH__)
58#include <mach-o/getsect.h>
59
60#define INIT_SECTION(name) do { \
61 unsigned long name ## _len; \
62 char *__cat(pstart_,name) = getsectdata("__TEXT", \
63 #name, &__cat(name,_len)); \
64 char *__cat(pstop_,name) = __cat(pstart_,name) + \
65 __cat(name, _len); \
66 __cat(__start_,name) = (void *)__cat(pstart_,name); \
67 __cat(__stop_,name) = (void *)__cat(pstop_,name); \
68 } while (0)
69#define SECTION(name) __attribute__((section("__TEXT, " #name)))
70
71struct devtable **__start___devtable, **__stop___devtable;
72#else
73#define INIT_SECTION(name) /* no-op for ELF */
74#define SECTION(name) __attribute__((section(#name)))
75
49/* We construct a table of pointers in an ELF section (pointers generally 76/* We construct a table of pointers in an ELF section (pointers generally
50 * go unpadded by gcc). ld creates boundary syms for us. */ 77 * go unpadded by gcc). ld creates boundary syms for us. */
51extern struct devtable *__start___devtable[], *__stop___devtable[]; 78extern struct devtable *__start___devtable[], *__stop___devtable[];
52#define ___cat(a,b) a ## b 79#endif /* __MACH__ */
53#define __cat(a,b) ___cat(a,b)
54 80
55#if __GNUC__ == 3 && __GNUC_MINOR__ < 3 81#if __GNUC__ == 3 && __GNUC_MINOR__ < 3
56# define __used __attribute__((__unused__)) 82# define __used __attribute__((__unused__))
@@ -65,8 +91,8 @@ extern struct devtable *__start___devtable[], *__stop___devtable[];
65 (type *)NULL, \ 91 (type *)NULL, \
66 (char *)NULL)), \ 92 (char *)NULL)), \
67 sizeof(type), (function) }; \ 93 sizeof(type), (function) }; \
68 static struct devtable *__attribute__((section("__devtable"))) \ 94 static struct devtable *SECTION(__devtable) __used \
69 __used __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) 95 __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__)
70 96
71#define ADD(str, sep, cond, field) \ 97#define ADD(str, sep, cond, field) \
72do { \ 98do { \
@@ -1080,6 +1106,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
1080 do_pnp_card_entries(symval, sym->st_size, mod); 1106 do_pnp_card_entries(symval, sym->st_size, mod);
1081 else { 1107 else {
1082 struct devtable **p; 1108 struct devtable **p;
1109 INIT_SECTION(__devtable);
1083 1110
1084 for (p = __start___devtable; p < __stop___devtable; p++) { 1111 for (p = __start___devtable; p < __stop___devtable; p++) {
1085 if (sym_is(name, namelen, (*p)->device_id)) { 1112 if (sym_is(name, namelen, (*p)->device_id)) {
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index f6cbc3ddb68b..3c6c0b14c807 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -238,14 +238,14 @@ EOF
238fi 238fi
239 239
240# Build header package 240# Build header package
241(cd $srctree; find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$) 241(cd $srctree; find . -name Makefile -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
242(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> /tmp/files$$) 242(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
243(cd $objtree; find .config Module.symvers include scripts -type f >> /tmp/objfiles$$) 243(cd $objtree; find .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
244destdir=$kernel_headers_dir/usr/src/linux-headers-$version 244destdir=$kernel_headers_dir/usr/src/linux-headers-$version
245mkdir -p "$destdir" 245mkdir -p "$destdir"
246(cd $srctree; tar -c -f - -T /tmp/files$$) | (cd $destdir; tar -xf -) 246(cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
247(cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -) 247(cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -)
248rm -f /tmp/files$$ /tmp/objfiles$$ 248rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles"
249arch=$(dpkg --print-architecture) 249arch=$(dpkg --print-architecture)
250 250
251cat <<EOF >> debian/control 251cat <<EOF >> debian/control